Mercurial > mm7
annotate DecorationList.cpp @ 2283:53d4e8539ca1
StorylineText::Initialize using tokenizer
author | Grumpy7 |
---|---|
date | Fri, 14 Mar 2014 23:33:07 +0100 |
parents | e2433db49428 |
children | ddb803517a48 |
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:
1583
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
1297 | 2 #include "Sprites.h" |
3 #include "DecorationList.h" | |
4 #include "MM7.h" | |
5 #include "FrameTableInc.h" | |
6 #include "mm7_data.h" | |
7 #include "Indoor.h" | |
1545 | 8 #include "ErrorHandling.h" |
1297 | 9 |
10 //----- (0045864C) -------------------------------------------------------- | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
11 void DecorationList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) |
1297 | 12 { |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
13 uint num_mm6_decs = data_mm6 ? *(int *)data_mm6 : 0, |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
14 num_mm7_decs = data_mm7 ? *(int *)data_mm7 : 0, |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
15 num_mm8_decs = data_mm8 ? *(int *)data_mm8 : 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
16 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
17 uNumDecorations = num_mm6_decs + num_mm7_decs + num_mm8_decs; |
1545 | 18 Assert(uNumDecorations); |
19 Assert(!num_mm8_decs); | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
20 |
1583 | 21 pDecorations = (DecorationDesc *)malloc(uNumDecorations * sizeof(DecorationDesc)); |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
22 memcpy(pDecorations, (char *)data_mm7 + 4, num_mm7_decs * sizeof(DecorationDesc)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
23 for (uint i = 0; i < num_mm6_decs; ++i) |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
24 { |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
25 memcpy(pDecorations + num_mm7_decs + i, (char *)data_mm6 + 4 + i * sizeof(DecorationDesc_mm6), sizeof(DecorationDesc_mm6)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
26 pDecorations[num_mm7_decs + i].uColoredLightRed = 255; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
27 pDecorations[num_mm7_decs + i].uColoredLightGreen = 255; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
28 pDecorations[num_mm7_decs + i].uColoredLightBlue = 255; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
29 pDecorations[num_mm7_decs + i].__padding = 255; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
30 } |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1421
diff
changeset
|
31 memcpy(pDecorations + num_mm6_decs + num_mm7_decs, (char *)data_mm8 + 4, num_mm8_decs * sizeof(DecorationDesc)); |
1297 | 32 } |
33 | |
34 //----- (00458693) -------------------------------------------------------- | |
35 void DecorationList::InitializeDecorationSprite(unsigned int uDecID) | |
36 { | |
37 pSpriteFrameTable->InitializeSprite(this->pDecorations[uDecID].uSpriteID); | |
38 } | |
39 | |
40 //----- (004586B0) -------------------------------------------------------- | |
41 bool DecorationList::FromFileTxt(const char *Args) | |
42 { | |
43 DecorationList *v2; // ebx@1 | |
44 FILE *v3; // eax@1 | |
45 unsigned int v4; // esi@3 | |
46 void *v5; // eax@10 | |
47 FILE *v6; // ST18_4@12 | |
48 char *i; // eax@12 | |
49 unsigned __int16 v8; // ax@16 | |
2274 | 50 //const char *v9; // ST20_4@16 |
51 //const char *v10; // ST18_4@16 | |
52 //__int16 v11; // ax@16 | |
53 //const char *v12; // ST14_4@16 | |
54 //unsigned __int16 v13; // ax@16 | |
1297 | 55 const char *v14; // ST10_4@16 |
2274 | 56 //__int16 v15; // ax@16 |
1297 | 57 const char *v16; // ST0C_4@16 |
58 unsigned __int8 v17; // al@16 | |
59 const char *v18; // ST08_4@16 | |
60 unsigned __int8 v19; // al@16 | |
61 const char *v20; // ST04_4@16 | |
62 unsigned __int8 v21; // al@16 | |
63 const char *v22; // ST00_4@16 | |
64 unsigned __int8 v23; // zf@16 | |
65 char v24; // sf@16 | |
66 unsigned __int8 v25; // of@16 | |
67 int j; // edi@17 | |
68 const char *v27; // esi@18 | |
69 int v29; // eax@21 | |
70 int v30; // eax@23 | |
71 int v31; // eax@25 | |
72 int v32; // eax@27 | |
73 int v33; // eax@29 | |
74 int v34; // eax@31 | |
75 int v35; // eax@33 | |
76 FrameTableTxtLine v37; // [sp+Ch] [bp-460h]@17 | |
77 FrameTableTxtLine v38; // [sp+88h] [bp-3E4h]@13 | |
78 char Dest; // [sp+104h] [bp-368h]@17 | |
79 char Buf; // [sp+17Ch] [bp-2F0h]@3 | |
80 FrameTableTxtLine v41; // [sp+370h] [bp-FCh]@4 | |
81 FrameTableTxtLine v42; // [sp+3ECh] [bp-80h]@4 | |
82 FILE *File; // [sp+468h] [bp-4h]@1 | |
83 unsigned int Argsa; // [sp+474h] [bp+8h]@3 | |
84 | |
85 v2 = this; | |
86 v3 = fopen(Args, "r"); | |
87 File = v3; | |
88 if ( !v3 ) | |
1545 | 89 Error("DecorationDescriptionList::load - Unable to open file: %s."); |
90 | |
1297 | 91 v4 = 0; |
92 Argsa = 0; | |
93 if ( fgets(&Buf, 490, v3) ) | |
94 { | |
95 do | |
96 { | |
97 *strchr(&Buf, 10) = 0; | |
98 memcpy(&v42, frame_table_txt_parser(&Buf, &v41), sizeof(v42)); | |
99 if ( v42.uPropCount && *v42.pProperties[0] != 47 && v42.uPropCount >= 3 ) | |
100 ++Argsa; | |
101 } | |
102 while ( fgets(&Buf, 490, File) ); | |
103 v4 = Argsa; | |
104 } | |
105 v2->uNumDecorations = v4; | |
1583 | 106 v5 = malloc(84 * v4); |
1297 | 107 v2->pDecorations = (DecorationDesc *)v5; |
108 if ( !v5 ) | |
1545 | 109 Error("DecorationDescriptionList::load - Out of Memory!"); |
110 | |
1297 | 111 v6 = File; |
112 v2->uNumDecorations = 0; | |
113 fseek(v6, 0, 0); | |
114 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) | |
115 { | |
116 *strchr(&Buf, 10) = 0; | |
117 memcpy(&v42, frame_table_txt_parser(&Buf, &v38), sizeof(v42)); | |
118 if ( v42.uPropCount && *v42.pProperties[0] != 47 && v42.uPropCount >= 3 ) | |
119 { | |
120 strcpy(v2->pDecorations[v2->uNumDecorations].pName, v42.pProperties[1]); | |
121 v8 = pSpriteFrameTable->FastFindSprite(v2->pDecorations[v2->uNumDecorations].pName); | |
2274 | 122 //v9 = v42.pProperties[2]; |
1297 | 123 v2->pDecorations[v2->uNumDecorations].uSpriteID = v8; |
2274 | 124 strcpy(v2->pDecorations[v2->uNumDecorations].field_20, v42.pProperties[2]); |
125 //v10 = v42.pProperties[3]; | |
1297 | 126 v2->pDecorations[v2->uNumDecorations].uType = 0; |
2274 | 127 //v11 = atoi(v42.pProperties[3]); |
128 //v12 = v42.pProperties[4]; | |
129 v2->pDecorations[v2->uNumDecorations].uRadius = atoi(v42.pProperties[3]); | |
130 //v13 = atoi(v42.pProperties[4]); | |
131 //v14 = v42.pProperties[5]; | |
132 v2->pDecorations[v2->uNumDecorations].uDecorationHeight = atoi(v42.pProperties[4]); | |
133 //v15 = atoi(v42.pProperties[5]); | |
134 //v16 = v42.pProperties[6]; | |
135 v2->pDecorations[v2->uNumDecorations].uLightRadius = atoi(v42.pProperties[5]); | |
136 //v17 = atoi(v42.pProperties[6]); | |
137 //v18 = v42.pProperties[7]; | |
138 v2->pDecorations[v2->uNumDecorations].uColoredLightRed = atoi(v42.pProperties[6]); | |
139 //v19 = atoi(v42.pProperties[7]); | |
140 //v20 = v42.pProperties[8]; | |
141 v2->pDecorations[v2->uNumDecorations].uColoredLightGreen = atoi(v42.pProperties[7]); | |
142 //v21 = atoi(v42.pProperties[8]); | |
143 //v22 = v42.pProperties[9]; | |
144 v2->pDecorations[v2->uNumDecorations].uColoredLightBlue = atoi(v42.pProperties[8]); | |
145 v2->pDecorations[v2->uNumDecorations].uSoundID = atoi(v42.pProperties[9]); | |
2276 | 146 __debugbreak();//Ritor1: need cleaning |
1297 | 147 v25 = __OFSUB__(v42.uPropCount, 10); |
148 v23 = v42.uPropCount == 10; | |
149 v24 = v42.uPropCount - 10 < 0; | |
150 v2->pDecorations[v2->uNumDecorations].uFlags = 0; | |
151 if ( !((unsigned __int8)(v24 ^ v25) | v23) ) | |
152 { | |
153 strcpy(&Dest, v42.pProperties[10]); | |
154 memcpy(&v41, frame_table_txt_parser(&Dest, &v37), sizeof(v41)); | |
155 for ( j = 0; j < v41.uPropCount; ++j ) | |
156 { | |
157 v27 = v41.pProperties[j]; | |
158 if ( _stricmp(v41.pProperties[j], "NBM") ) | |
159 { | |
160 if ( _stricmp(v27, "Invisible") ) | |
161 { | |
162 if ( _stricmp(v27, "FS") ) | |
163 { | |
164 if ( _stricmp(v27, "FM") ) | |
165 { | |
166 if ( _stricmp(v27, "FF") ) | |
167 { | |
168 if ( _stricmp(v27, "Marker") ) | |
169 { | |
170 if ( _stricmp(v27, "LoopSlow") ) | |
171 { | |
172 if ( _stricmp(v27, "EmitFire") ) | |
173 { | |
174 if ( _stricmp(v27, "Dawn") ) | |
175 { | |
176 if ( !_stricmp(v27, "Dusk") ) | |
177 HIBYTE(v2->pDecorations[v2->uNumDecorations].uFlags) |= 2u; | |
178 } | |
179 else | |
180 { | |
181 HIBYTE(v2->pDecorations[v2->uNumDecorations].uFlags) |= 1u; | |
182 } | |
183 } | |
184 else | |
185 { | |
186 v35 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
187 *(char *)v35 |= 0x80u; | |
188 } | |
189 } | |
190 else | |
191 { | |
192 v34 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
193 *(char *)v34 |= 0x40u; | |
194 } | |
195 } | |
196 else | |
197 { | |
198 v33 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
199 *(char *)v33 |= 0x20u; | |
200 } | |
201 } | |
202 else | |
203 { | |
204 v32 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
205 *(char *)v32 |= 0x10u; | |
206 } | |
207 } | |
208 else | |
209 { | |
210 v31 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
211 *(char *)v31 |= 8u; | |
212 } | |
213 } | |
214 else | |
215 { | |
216 v30 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
217 *(char *)v30 |= 4u; | |
218 } | |
219 } | |
220 else | |
221 { | |
222 v29 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
223 *(char *)v29 |= 2u; | |
224 } | |
225 } | |
226 else | |
2266 | 227 v2->pDecorations[v2->uNumDecorations].uFlags |= 1; |
1297 | 228 } |
229 } | |
230 ++v2->uNumDecorations; | |
231 } | |
232 } | |
233 fclose(File); | |
234 return 1; | |
235 } | |
236 //----- (00458600) -------------------------------------------------------- | |
237 void DecorationList::ToFile() | |
238 { | |
239 FILE *v2; // eax@1 | |
240 FILE *v3; // edi@1 | |
241 | |
242 v2 = fopen("data\\ddeclist.bin", "wb"); | |
243 v3 = v2; | |
244 if ( !v2 ) | |
1545 | 245 Error("Unable to save ddeclist.bin!"); |
246 | |
2264 | 247 fwrite(this, 4, 1, v2); |
248 fwrite(this->pDecorations, 84, this->uNumDecorations, v3); | |
1297 | 249 fclose(v3); |
250 } | |
251 //----- (004488B6) -------------------------------------------------------- | |
252 unsigned __int16 DecorationList::GetDecorIdByName(const char *pName) | |
253 { | |
2264 | 254 if ( pName && (signed int)this->uNumDecorations > 1 ) |
1297 | 255 { |
2264 | 256 for ( uint uID = 1; uID < (signed int)this->uNumDecorations; ++uID ) |
1297 | 257 { |
2264 | 258 if ( !_stricmp(pName, this->pDecorations[uID].pName) ) |
259 return uID; | |
1297 | 260 } |
261 } | |
2264 | 262 return 0; |
1297 | 263 } |