annotate Engine/Tables/FrameTableInc.cpp @ 2553:48708da03b7f

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