Mercurial > mm7
annotate FrameTableInc.cpp @ 2432:99e7bd7ec0a2
* Fixed OpenAL crash for videos
* Fixed double release of movie for Emerald Intro
author | a.parshin |
---|---|
date | Wed, 23 Jul 2014 21:38:34 +0300 |
parents | f4af3b203f65 |
children |
rev | line source |
---|---|
2415 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
703
diff
changeset
|
5 #define _CRT_SECURE_NO_WARNINGS |
0 | 6 #include "FrameTableInc.h" |
701 | 7 #include <memory.h> |
8 //identical function to work in differnt threads | |
9 | |
10 //----- (004BE3BF) -------------------------------------------------------- | |
703 | 11 FrameTableTxtLine* txt_file_frametable_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table) |
701 | 12 { |
13 bool new_token_flag; // edx@3 | |
14 bool in_quotes; // [sp+Ch] [bp-4h]@3 | |
15 char* parse_pos; | |
16 unsigned char test_char; | |
17 int i; | |
18 | |
19 static char tokens_buff1[1000]; | |
20 static struct FrameTableTxtLine temp_tokens_table1; // weak | |
21 | |
22 temp_tokens_table1.uPropCount = 0; | |
0 | 23 |
701 | 24 if ( str_to_parse && *str_to_parse ) |
25 { | |
26 parse_pos=(char*)str_to_parse; | |
27 new_token_flag = true; | |
28 in_quotes = false; | |
29 for(i = 0; (i<1000)&&(temp_tokens_table1.uPropCount < 30) ; ++i) | |
30 { | |
31 test_char=*parse_pos; | |
32 tokens_buff1[i]=test_char; | |
33 if ( !test_char ) | |
34 break; | |
35 if ( (test_char != ' ') && (test_char != ',') && (test_char != '\t') || in_quotes ) | |
36 { | |
37 if ( test_char == '"' ) | |
38 { | |
39 tokens_buff1[i]= '\0'; | |
40 new_token_flag = true; | |
41 if ( in_quotes ) | |
42 in_quotes = false; | |
43 else | |
44 { | |
45 in_quotes = true; | |
46 if ( *(parse_pos+1) == '"' ) | |
47 { | |
48 temp_tokens_table1.pProperties[temp_tokens_table1.uPropCount] = &tokens_buff1[i]; | |
49 ++temp_tokens_table1.uPropCount; | |
50 } | |
51 } | |
52 } | |
53 else | |
54 { | |
55 if ( new_token_flag ) | |
56 { | |
57 temp_tokens_table1.pProperties[temp_tokens_table1.uPropCount] = &tokens_buff1[i]; | |
58 ++temp_tokens_table1.uPropCount; | |
59 } | |
60 new_token_flag = false; | |
61 } | |
62 } | |
63 else | |
64 { | |
65 tokens_buff1[i]= '\0'; | |
66 new_token_flag = true; | |
67 } | |
68 ++parse_pos; | |
69 } | |
70 tokens_buff1[i]= '\0'; | |
71 } | |
72 memcpy(tokens_table, &temp_tokens_table1, sizeof(FrameTableTxtLine)); | |
73 return tokens_table; | |
74 } | |
75 // F8BA58: using guessed type FrameTableTxtLine static_stru_F8BA58; | |
76 | |
77 //----- (004BE485) -------------------------------------------------------- | |
78 FrameTableTxtLine * frame_table_txt_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table) | |
79 { | |
80 bool new_token_flag; // edx@3 | |
81 bool in_quotes; // [sp+Ch] [bp-4h]@3 | |
82 char* parse_pos; | |
83 unsigned char test_char; | |
84 int i; | |
85 | |
86 static char tokens_buff2[1000]; | |
87 static struct FrameTableTxtLine temp_tokens_table2; // weak | |
88 temp_tokens_table2.uPropCount = 0; | |
89 | |
90 if ( str_to_parse && *str_to_parse ) | |
91 { | |
92 parse_pos=(char*)str_to_parse; | |
93 new_token_flag = true; | |
94 in_quotes = false; | |
95 for(i = 0; (i<1000)&&(temp_tokens_table2.uPropCount < 30); ++i) | |
96 { | |
97 test_char=*parse_pos; | |
98 tokens_buff2[i]=test_char; | |
99 if ( !test_char ) | |
100 break; | |
101 if ( (test_char != ' ') && (test_char != ',') && (test_char != '\t') || in_quotes ) | |
102 { | |
103 if ( test_char == '"' ) | |
104 { | |
105 tokens_buff2[i]= '\0'; | |
106 new_token_flag = true; | |
107 if ( in_quotes ) | |
108 in_quotes = false; | |
109 else | |
110 { | |
111 in_quotes = true; | |
112 if ( *(parse_pos+1) == '"' ) | |
113 { | |
114 temp_tokens_table2.pProperties[temp_tokens_table2.uPropCount] = &tokens_buff2[i]; | |
115 ++temp_tokens_table2.uPropCount; | |
116 } | |
117 } | |
118 } | |
119 else | |
120 { | |
121 if ( new_token_flag ) | |
122 { | |
123 temp_tokens_table2.pProperties[temp_tokens_table2.uPropCount] = &tokens_buff2[i]; | |
124 ++temp_tokens_table2.uPropCount; | |
125 } | |
126 new_token_flag = false; | |
127 } | |
128 } | |
129 else | |
130 { | |
131 tokens_buff2[i]= '\0'; | |
132 new_token_flag = true; | |
133 } | |
134 ++parse_pos; | |
135 } | |
136 | |
137 tokens_buff2[i]= '\0'; | |
138 } | |
139 memcpy(tokens_table, &temp_tokens_table2, sizeof(FrameTableTxtLine)); | |
140 return tokens_table; | |
141 } | |
142 |