annotate FrameTableInc.cpp @ 2288:406605240b0a

GetItemTextureFilename cleaned up
author Grumpy7
date Sun, 16 Mar 2014 02:59:52 +0100
parents aff7a7b072b7
children f4af3b203f65
rev   line source
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
1 #define _CRT_SECURE_NO_WARNINGS
0
Ritor1
parents:
diff changeset
2 #include "FrameTableInc.h"
701
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
3 #include <memory.h>
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
4 //identical function to work in differnt threads
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
5
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
6 //----- (004BE3BF) --------------------------------------------------------
703
a9c1fb7483c2 monster parser almost complete.
Gloval
parents: 701
diff changeset
7 FrameTableTxtLine* txt_file_frametable_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table)
701
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
8 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
9 bool new_token_flag; // edx@3
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
10 bool in_quotes; // [sp+Ch] [bp-4h]@3
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
11 char* parse_pos;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
12 unsigned char test_char;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
13 int i;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
14
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
15 static char tokens_buff1[1000];
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
16 static struct FrameTableTxtLine temp_tokens_table1; // weak
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
17
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
18 temp_tokens_table1.uPropCount = 0;
0
Ritor1
parents:
diff changeset
19
701
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
20 if ( str_to_parse && *str_to_parse )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
21 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
22 parse_pos=(char*)str_to_parse;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
23 new_token_flag = true;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
24 in_quotes = false;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
25 for(i = 0; (i<1000)&&(temp_tokens_table1.uPropCount < 30) ; ++i)
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
26 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
27 test_char=*parse_pos;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
28 tokens_buff1[i]=test_char;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
29 if ( !test_char )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
30 break;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
31 if ( (test_char != ' ') && (test_char != ',') && (test_char != '\t') || in_quotes )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
32 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
33 if ( test_char == '"' )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
34 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
35 tokens_buff1[i]= '\0';
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
36 new_token_flag = true;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
37 if ( in_quotes )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
38 in_quotes = false;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
39 else
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
40 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
41 in_quotes = true;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
42 if ( *(parse_pos+1) == '"' )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
43 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
44 temp_tokens_table1.pProperties[temp_tokens_table1.uPropCount] = &tokens_buff1[i];
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
45 ++temp_tokens_table1.uPropCount;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
46 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
47 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
48 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
49 else
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
50 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
51 if ( new_token_flag )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
52 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
53 temp_tokens_table1.pProperties[temp_tokens_table1.uPropCount] = &tokens_buff1[i];
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
54 ++temp_tokens_table1.uPropCount;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
55 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
56 new_token_flag = false;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
57 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
58 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
59 else
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
60 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
61 tokens_buff1[i]= '\0';
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
62 new_token_flag = true;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
63 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
64 ++parse_pos;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
65 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
66 tokens_buff1[i]= '\0';
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
67 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
68 memcpy(tokens_table, &temp_tokens_table1, sizeof(FrameTableTxtLine));
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
69 return tokens_table;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
70 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
71 // F8BA58: using guessed type FrameTableTxtLine static_stru_F8BA58;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
72
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
73 //----- (004BE485) --------------------------------------------------------
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
74 FrameTableTxtLine * frame_table_txt_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table)
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
75 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
76 bool new_token_flag; // edx@3
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
77 bool in_quotes; // [sp+Ch] [bp-4h]@3
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
78 char* parse_pos;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
79 unsigned char test_char;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
80 int i;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
81
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
82 static char tokens_buff2[1000];
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
83 static struct FrameTableTxtLine temp_tokens_table2; // weak
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
84 temp_tokens_table2.uPropCount = 0;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
85
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
86 if ( str_to_parse && *str_to_parse )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
87 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
88 parse_pos=(char*)str_to_parse;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
89 new_token_flag = true;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
90 in_quotes = false;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
91 for(i = 0; (i<1000)&&(temp_tokens_table2.uPropCount < 30); ++i)
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
92 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
93 test_char=*parse_pos;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
94 tokens_buff2[i]=test_char;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
95 if ( !test_char )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
96 break;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
97 if ( (test_char != ' ') && (test_char != ',') && (test_char != '\t') || in_quotes )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
98 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
99 if ( test_char == '"' )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
100 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
101 tokens_buff2[i]= '\0';
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
102 new_token_flag = true;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
103 if ( in_quotes )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
104 in_quotes = false;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
105 else
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
106 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
107 in_quotes = true;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
108 if ( *(parse_pos+1) == '"' )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
109 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
110 temp_tokens_table2.pProperties[temp_tokens_table2.uPropCount] = &tokens_buff2[i];
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
111 ++temp_tokens_table2.uPropCount;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
112 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
113 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
114 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
115 else
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
116 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
117 if ( new_token_flag )
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
118 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
119 temp_tokens_table2.pProperties[temp_tokens_table2.uPropCount] = &tokens_buff2[i];
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
120 ++temp_tokens_table2.uPropCount;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
121 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
122 new_token_flag = false;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
123 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
124 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
125 else
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
126 {
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
127 tokens_buff2[i]= '\0';
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
128 new_token_flag = true;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
129 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
130 ++parse_pos;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
131 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
132
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
133 tokens_buff2[i]= '\0';
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
134 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
135 memcpy(tokens_table, &temp_tokens_table2, sizeof(FrameTableTxtLine));
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
136 return tokens_table;
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
137 }
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 0
diff changeset
138