annotate StorylineTextTable.cpp @ 2212:e18200fcfb50

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