comparison DecorationList.cpp @ 1297:5450af4f57ef

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