World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
FrameTableInc.cpp
См. документацию.
2 
3 #include <memory.h>
4 
5 // identical function to work in differnt threads
6 
7 //----- (004BE3BF) --------------------------------------------------------
8 FrameTableTxtLine *txt_file_frametable_parser(const char *str_to_parse,
9  FrameTableTxtLine *tokens_table) {
10  bool new_token_flag; // edx@3
11  bool in_quotes; // [sp+Ch] [bp-4h]@3
12  char *parse_pos;
13  unsigned char test_char;
14  int i;
15 
16  static char tokens_buff1[1000];
17  static struct FrameTableTxtLine temp_tokens_table1;
18 
19  temp_tokens_table1.uPropCount = 0;
20 
21  if (str_to_parse && *str_to_parse) {
22  parse_pos = (char *)str_to_parse;
23  new_token_flag = true;
24  in_quotes = false;
25  for (i = 0; (i < 1000) && (temp_tokens_table1.uPropCount < 30); ++i) {
26  test_char = *parse_pos;
27  tokens_buff1[i] = test_char;
28  if (!test_char) break;
29  if ((test_char != ' ') && (test_char != ',') &&
30  (test_char != '\t') ||
31  in_quotes) {
32  if (test_char == '"') {
33  tokens_buff1[i] = '\0';
34  new_token_flag = true;
35  if (in_quotes) {
36  in_quotes = false;
37  } else {
38  in_quotes = true;
39  if (*(parse_pos + 1) == '"') {
40  temp_tokens_table1
41  .pProperties[temp_tokens_table1.uPropCount] =
42  &tokens_buff1[i];
43  ++temp_tokens_table1.uPropCount;
44  }
45  }
46  } else {
47  if (new_token_flag) {
48  temp_tokens_table1
49  .pProperties[temp_tokens_table1.uPropCount] =
50  &tokens_buff1[i];
51  ++temp_tokens_table1.uPropCount;
52  }
53  new_token_flag = false;
54  }
55  } else {
56  tokens_buff1[i] = '\0';
57  new_token_flag = true;
58  }
59  ++parse_pos;
60  }
61  tokens_buff1[i] = '\0';
62  }
63  memcpy(tokens_table, &temp_tokens_table1, sizeof(FrameTableTxtLine));
64  return tokens_table;
65 }
66 // F8BA58: using guessed type FrameTableTxtLine static_stru_F8BA58;
67 
68 //----- (004BE485) --------------------------------------------------------
69 FrameTableTxtLine *frame_table_txt_parser(const char *str_to_parse,
70  FrameTableTxtLine *tokens_table) {
71  bool new_token_flag; // edx@3
72  bool in_quotes; // [sp+Ch] [bp-4h]@3
73  char *parse_pos;
74  unsigned char test_char;
75  int i;
76 
77  static char tokens_buff2[1000];
78  static struct FrameTableTxtLine temp_tokens_table2;
79  temp_tokens_table2.uPropCount = 0;
80 
81  if (str_to_parse && *str_to_parse) {
82  parse_pos = (char *)str_to_parse;
83  new_token_flag = true;
84  in_quotes = false;
85  for (i = 0; (i < 1000) && (temp_tokens_table2.uPropCount < 30); ++i) {
86  test_char = *parse_pos;
87  tokens_buff2[i] = test_char;
88  if (!test_char) break;
89  if ((test_char != ' ') && (test_char != ',') &&
90  (test_char != '\t') ||
91  in_quotes) {
92  if (test_char == '"') {
93  tokens_buff2[i] = '\0';
94  new_token_flag = true;
95  if (in_quotes) {
96  in_quotes = false;
97  } else {
98  in_quotes = true;
99  if (*(parse_pos + 1) == '"') {
100  temp_tokens_table2
101  .pProperties[temp_tokens_table2.uPropCount] =
102  &tokens_buff2[i];
103  ++temp_tokens_table2.uPropCount;
104  }
105  }
106  } else {
107  if (new_token_flag) {
108  temp_tokens_table2
109  .pProperties[temp_tokens_table2.uPropCount] =
110  &tokens_buff2[i];
111  ++temp_tokens_table2.uPropCount;
112  }
113  new_token_flag = false;
114  }
115  } else {
116  tokens_buff2[i] = '\0';
117  new_token_flag = true;
118  }
119  ++parse_pos;
120  }
121 
122  tokens_buff2[i] = '\0';
123  }
124  memcpy(tokens_table, &temp_tokens_table2, sizeof(FrameTableTxtLine));
125  return tokens_table;
126 }
FrameTableTxtLine::uPropCount
int uPropCount
Definition: FrameTableInc.h:12
FrameTableTxtLine::pProperties
const char * pProperties[30]
Definition: FrameTableInc.h:13
frame_table_txt_parser
FrameTableTxtLine * frame_table_txt_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table)
Definition: FrameTableInc.cpp:69
txt_file_frametable_parser
FrameTableTxtLine * txt_file_frametable_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table)
Definition: FrameTableInc.cpp:8
FrameTableInc.h
FrameTableTxtLine
Definition: FrameTableInc.h:11