annotate StorylineTextTable.cpp @ 2277:b9adf4f414f6

submenu Other
author Ritor1
date Fri, 14 Mar 2014 13:58:51 +0600
parents aff7a7b072b7
children 53d4e8539ca1
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: 2153
diff changeset
1 #define _CRT_SECURE_NO_WARNINGS
233
0df4136b6aac store_line
Gloval
parents:
diff changeset
2 #include <stdlib.h>
0df4136b6aac store_line
Gloval
parents:
diff changeset
3 #include <string.h>
0df4136b6aac store_line
Gloval
parents:
diff changeset
4
0df4136b6aac store_line
Gloval
parents:
diff changeset
5 #include "LOD.h"
0df4136b6aac store_line
Gloval
parents:
diff changeset
6 #include "texts.h"
0df4136b6aac store_line
Gloval
parents:
diff changeset
7 #include "StorylineTextTable.h"
0df4136b6aac store_line
Gloval
parents:
diff changeset
8
0df4136b6aac store_line
Gloval
parents:
diff changeset
9 char *pHistoryTXT_Raw;
0df4136b6aac store_line
Gloval
parents:
diff changeset
10 struct StorylineText *pStorylineText;
0df4136b6aac store_line
Gloval
parents:
diff changeset
11
0df4136b6aac store_line
Gloval
parents:
diff changeset
12 //----- (00453E6D) --------------------------------------------------------
0df4136b6aac store_line
Gloval
parents:
diff changeset
13 void StorylineText::Initialize()
237
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
14 {
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
15
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
16 int i;
233
0df4136b6aac store_line
Gloval
parents:
diff changeset
17 char* test_string;
0df4136b6aac store_line
Gloval
parents:
diff changeset
18 unsigned char c;
0df4136b6aac store_line
Gloval
parents:
diff changeset
19 bool break_loop;
0df4136b6aac store_line
Gloval
parents:
diff changeset
20 unsigned int temp_str_len;
0df4136b6aac store_line
Gloval
parents:
diff changeset
21 char* tmp_pos;
0df4136b6aac store_line
Gloval
parents:
diff changeset
22 int decode_step;
0df4136b6aac store_line
Gloval
parents:
diff changeset
23
237
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
24 if ( pHistoryTXT_Raw )
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1165
diff changeset
25 free(pHistoryTXT_Raw);
237
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
26 pHistoryTXT_Raw = NULL;
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
27 pHistoryTXT_Raw = (char *)pEvents_LOD->LoadRaw("history.txt", 0);
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
28 strtok(pHistoryTXT_Raw, "\r");
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
29
338
1c681ad45653 history changes
zipi
parents: 329
diff changeset
30 StoreLine[0].pText=nullptr;
1c681ad45653 history changes
zipi
parents: 329
diff changeset
31 StoreLine[0].pPageTitle=nullptr;
1c681ad45653 history changes
zipi
parents: 329
diff changeset
32 StoreLine[0].uTime=0;
1c681ad45653 history changes
zipi
parents: 329
diff changeset
33 StoreLine[0].f_9=0;
1c681ad45653 history changes
zipi
parents: 329
diff changeset
34 StoreLine[0].f_A=0;
1c681ad45653 history changes
zipi
parents: 329
diff changeset
35 StoreLine[0].f_B=0;
1c681ad45653 history changes
zipi
parents: 329
diff changeset
36
237
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
37 for (i=0;i<29;++i)
233
0df4136b6aac store_line
Gloval
parents:
diff changeset
38 {
0df4136b6aac store_line
Gloval
parents:
diff changeset
39 test_string = strtok(NULL, "\r") + 1;
0df4136b6aac store_line
Gloval
parents:
diff changeset
40 break_loop = false;
0df4136b6aac store_line
Gloval
parents:
diff changeset
41 decode_step=0;
0df4136b6aac store_line
Gloval
parents:
diff changeset
42 do
0df4136b6aac store_line
Gloval
parents:
diff changeset
43 {
0df4136b6aac store_line
Gloval
parents:
diff changeset
44 c = *(unsigned char*)test_string;
0df4136b6aac store_line
Gloval
parents:
diff changeset
45 temp_str_len = 0;
0df4136b6aac store_line
Gloval
parents:
diff changeset
46 while((c!='\t')&&(c>0))
0df4136b6aac store_line
Gloval
parents:
diff changeset
47 {
0df4136b6aac store_line
Gloval
parents:
diff changeset
48 ++temp_str_len;
0df4136b6aac store_line
Gloval
parents:
diff changeset
49 c=test_string[temp_str_len];
0df4136b6aac store_line
Gloval
parents:
diff changeset
50 }
0df4136b6aac store_line
Gloval
parents:
diff changeset
51 tmp_pos=test_string+temp_str_len;
0df4136b6aac store_line
Gloval
parents:
diff changeset
52 if (*tmp_pos == 0)
0df4136b6aac store_line
Gloval
parents:
diff changeset
53 break_loop = true;
0df4136b6aac store_line
Gloval
parents:
diff changeset
54 *tmp_pos = 0;
0df4136b6aac store_line
Gloval
parents:
diff changeset
55 if (temp_str_len)
0df4136b6aac store_line
Gloval
parents:
diff changeset
56 {
0df4136b6aac store_line
Gloval
parents:
diff changeset
57 switch (decode_step)
0df4136b6aac store_line
Gloval
parents:
diff changeset
58 {
0df4136b6aac store_line
Gloval
parents:
diff changeset
59 case 1:
329
f76027321087 LoadLevel_InitializeLevelStr
Gloval
parents: 313
diff changeset
60 StoreLine[i+1].pText=RemoveQuotes(test_string);
233
0df4136b6aac store_line
Gloval
parents:
diff changeset
61 break;
0df4136b6aac store_line
Gloval
parents:
diff changeset
62 case 2:
329
f76027321087 LoadLevel_InitializeLevelStr
Gloval
parents: 313
diff changeset
63 StoreLine[i+1].uTime=atoi(test_string); //strange but in text here string not digit
233
0df4136b6aac store_line
Gloval
parents:
diff changeset
64 break;
0df4136b6aac store_line
Gloval
parents:
diff changeset
65 case 3:
329
f76027321087 LoadLevel_InitializeLevelStr
Gloval
parents: 313
diff changeset
66 StoreLine[i+1].pPageTitle=RemoveQuotes(test_string);
233
0df4136b6aac store_line
Gloval
parents:
diff changeset
67 break;
0df4136b6aac store_line
Gloval
parents:
diff changeset
68 }
0df4136b6aac store_line
Gloval
parents:
diff changeset
69 }
0df4136b6aac store_line
Gloval
parents:
diff changeset
70 else
0df4136b6aac store_line
Gloval
parents:
diff changeset
71 {
237
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
72 break_loop = true;
233
0df4136b6aac store_line
Gloval
parents:
diff changeset
73 }
0df4136b6aac store_line
Gloval
parents:
diff changeset
74 ++decode_step;
0df4136b6aac store_line
Gloval
parents:
diff changeset
75 test_string=tmp_pos+1;
0df4136b6aac store_line
Gloval
parents:
diff changeset
76 } while ((decode_step<4)&&!break_loop);
0df4136b6aac store_line
Gloval
parents:
diff changeset
77 }
237
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
78 }