annotate StorylineTextTable.cpp @ 275:250e49fef6f6

m
author Ritor1
date Mon, 18 Feb 2013 16:39:49 +0600
parents 2799737f8a74
children 7f19b3f7d935
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 "allocator.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 )
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
25 pAllocator->FreeChunk(pHistoryTXT_Raw);
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
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
30 for (i=0;i<29;++i)
233
0df4136b6aac store_line
Gloval
parents:
diff changeset
31 {
0df4136b6aac store_line
Gloval
parents:
diff changeset
32 test_string = strtok(NULL, "\r") + 1;
0df4136b6aac store_line
Gloval
parents:
diff changeset
33 break_loop = false;
0df4136b6aac store_line
Gloval
parents:
diff changeset
34 decode_step=0;
0df4136b6aac store_line
Gloval
parents:
diff changeset
35 do
0df4136b6aac store_line
Gloval
parents:
diff changeset
36 {
0df4136b6aac store_line
Gloval
parents:
diff changeset
37 c = *(unsigned char*)test_string;
0df4136b6aac store_line
Gloval
parents:
diff changeset
38 temp_str_len = 0;
0df4136b6aac store_line
Gloval
parents:
diff changeset
39 while((c!='\t')&&(c>0))
0df4136b6aac store_line
Gloval
parents:
diff changeset
40 {
0df4136b6aac store_line
Gloval
parents:
diff changeset
41 ++temp_str_len;
0df4136b6aac store_line
Gloval
parents:
diff changeset
42 c=test_string[temp_str_len];
0df4136b6aac store_line
Gloval
parents:
diff changeset
43 }
0df4136b6aac store_line
Gloval
parents:
diff changeset
44 tmp_pos=test_string+temp_str_len;
0df4136b6aac store_line
Gloval
parents:
diff changeset
45 if (*tmp_pos == 0)
0df4136b6aac store_line
Gloval
parents:
diff changeset
46 break_loop = true;
0df4136b6aac store_line
Gloval
parents:
diff changeset
47 *tmp_pos = 0;
0df4136b6aac store_line
Gloval
parents:
diff changeset
48 if (temp_str_len)
0df4136b6aac store_line
Gloval
parents:
diff changeset
49 {
0df4136b6aac store_line
Gloval
parents:
diff changeset
50 switch (decode_step)
0df4136b6aac store_line
Gloval
parents:
diff changeset
51 {
0df4136b6aac store_line
Gloval
parents:
diff changeset
52 case 1:
0df4136b6aac store_line
Gloval
parents:
diff changeset
53 StoreLine[i+1].pText=RemoveQuotes(test_string);
0df4136b6aac store_line
Gloval
parents:
diff changeset
54 break;
0df4136b6aac store_line
Gloval
parents:
diff changeset
55 case 2:
0df4136b6aac store_line
Gloval
parents:
diff changeset
56 StoreLine[i+1].uTime=atoi(test_string); //strange but in text here string not digit
0df4136b6aac store_line
Gloval
parents:
diff changeset
57 break;
0df4136b6aac store_line
Gloval
parents:
diff changeset
58 case 3:
0df4136b6aac store_line
Gloval
parents:
diff changeset
59 StoreLine[i+1].pPageTitle=RemoveQuotes(test_string);
0df4136b6aac store_line
Gloval
parents:
diff changeset
60 break;
0df4136b6aac store_line
Gloval
parents:
diff changeset
61 }
0df4136b6aac store_line
Gloval
parents:
diff changeset
62 }
0df4136b6aac store_line
Gloval
parents:
diff changeset
63 else
0df4136b6aac store_line
Gloval
parents:
diff changeset
64 {
237
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
65 break_loop = true;
233
0df4136b6aac store_line
Gloval
parents:
diff changeset
66 }
0df4136b6aac store_line
Gloval
parents:
diff changeset
67 ++decode_step;
0df4136b6aac store_line
Gloval
parents:
diff changeset
68 test_string=tmp_pos+1;
0df4136b6aac store_line
Gloval
parents:
diff changeset
69 } while ((decode_step<4)&&!break_loop);
0df4136b6aac store_line
Gloval
parents:
diff changeset
70 }
237
2799737f8a74 more text parsers refactor
Gloval
parents: 233
diff changeset
71 }