annotate StorylineTextTable.cpp @ 2152:d44b7775fc06

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