Mercurial > mm7
annotate DecorationList.cpp @ 2275:8193a64c7461
Слияние
author | Ritor1 |
---|---|
date | Fri, 14 Mar 2014 09:32:42 +0600 |
parents | 90f56da08d76 01489aec3cb0 |
children | e2433db49428 |
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]); | |
1297 | 146 v25 = __OFSUB__(v42.uPropCount, 10); |
147 v23 = v42.uPropCount == 10; | |
148 v24 = v42.uPropCount - 10 < 0; | |
149 v2->pDecorations[v2->uNumDecorations].uFlags = 0; | |
150 if ( !((unsigned __int8)(v24 ^ v25) | v23) ) | |
151 { | |
152 strcpy(&Dest, v42.pProperties[10]); | |
153 memcpy(&v41, frame_table_txt_parser(&Dest, &v37), sizeof(v41)); | |
154 for ( j = 0; j < v41.uPropCount; ++j ) | |
155 { | |
156 v27 = v41.pProperties[j]; | |
157 if ( _stricmp(v41.pProperties[j], "NBM") ) | |
158 { | |
159 if ( _stricmp(v27, "Invisible") ) | |
160 { | |
161 if ( _stricmp(v27, "FS") ) | |
162 { | |
163 if ( _stricmp(v27, "FM") ) | |
164 { | |
165 if ( _stricmp(v27, "FF") ) | |
166 { | |
167 if ( _stricmp(v27, "Marker") ) | |
168 { | |
169 if ( _stricmp(v27, "LoopSlow") ) | |
170 { | |
171 if ( _stricmp(v27, "EmitFire") ) | |
172 { | |
173 if ( _stricmp(v27, "Dawn") ) | |
174 { | |
175 if ( !_stricmp(v27, "Dusk") ) | |
176 HIBYTE(v2->pDecorations[v2->uNumDecorations].uFlags) |= 2u; | |
177 } | |
178 else | |
179 { | |
180 HIBYTE(v2->pDecorations[v2->uNumDecorations].uFlags) |= 1u; | |
181 } | |
182 } | |
183 else | |
184 { | |
185 v35 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
186 *(char *)v35 |= 0x80u; | |
187 } | |
188 } | |
189 else | |
190 { | |
191 v34 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
192 *(char *)v34 |= 0x40u; | |
193 } | |
194 } | |
195 else | |
196 { | |
197 v33 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
198 *(char *)v33 |= 0x20u; | |
199 } | |
200 } | |
201 else | |
202 { | |
203 v32 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
204 *(char *)v32 |= 0x10u; | |
205 } | |
206 } | |
207 else | |
208 { | |
209 v31 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
210 *(char *)v31 |= 8u; | |
211 } | |
212 } | |
213 else | |
214 { | |
215 v30 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
216 *(char *)v30 |= 4u; | |
217 } | |
218 } | |
219 else | |
220 { | |
221 v29 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; | |
222 *(char *)v29 |= 2u; | |
223 } | |
224 } | |
225 else | |
2266 | 226 v2->pDecorations[v2->uNumDecorations].uFlags |= 1; |
1297 | 227 } |
228 } | |
229 ++v2->uNumDecorations; | |
230 } | |
231 } | |
232 fclose(File); | |
233 return 1; | |
234 } | |
235 //----- (00458600) -------------------------------------------------------- | |
236 void DecorationList::ToFile() | |
237 { | |
238 FILE *v2; // eax@1 | |
239 FILE *v3; // edi@1 | |
240 | |
241 v2 = fopen("data\\ddeclist.bin", "wb"); | |
242 v3 = v2; | |
243 if ( !v2 ) | |
1545 | 244 Error("Unable to save ddeclist.bin!"); |
245 | |
2264 | 246 fwrite(this, 4, 1, v2); |
247 fwrite(this->pDecorations, 84, this->uNumDecorations, v3); | |
1297 | 248 fclose(v3); |
249 } | |
250 //----- (004488B6) -------------------------------------------------------- | |
251 unsigned __int16 DecorationList::GetDecorIdByName(const char *pName) | |
252 { | |
2264 | 253 if ( pName && (signed int)this->uNumDecorations > 1 ) |
1297 | 254 { |
2264 | 255 for ( uint uID = 1; uID < (signed int)this->uNumDecorations; ++uID ) |
1297 | 256 { |
2264 | 257 if ( !_stricmp(pName, this->pDecorations[uID].pName) ) |
258 return uID; | |
1297 | 259 } |
260 } | |
2264 | 261 return 0; |
1297 | 262 } |