comparison ObjectList.cpp @ 1296:c423f946dc99

moving files continue
author Ritor1
date Tue, 18 Jun 2013 17:28:11 +0600
parents
children 13b7be8b06a0
comparison
equal deleted inserted replaced
1295:86a83e12d795 1296:c423f946dc99
1 #include "ObjectList.h"
2 #include "mm7_data.h"
3 #include "Sprites.h"
4 #include "FrameTableInc.h"
5 #include "Allocator.h"
6
7 //----- (0042EB42) --------------------------------------------------------
8 __int16 ObjectList::ObjectIDByItemID(unsigned __int16 uItemID)
9 {
10 unsigned int v2; // edx@1
11 signed int v3; // eax@1
12 char *v4; // ecx@2
13
14 v2 = this->uNumObjects;
15 v3 = 0;
16 if ( (signed int)this->uNumObjects <= 0 )
17 {
18 LABEL_5:
19 LOWORD(v3) = 0;
20 }
21 else
22 {
23 v4 = (char *)&this->pObjects->uObjectID;
24 while ( uItemID != *(short *)v4 )
25 {
26 ++v3;
27 v4 += 56;
28 if ( v3 >= (signed int)v2 )
29 goto LABEL_5;
30 }
31 }
32 return v3;
33 }
34 //----- (00459064) --------------------------------------------------------
35 void ObjectList::InitializeSprites()
36 {
37 for (uint i = 0; i < uNumObjects; ++i)
38 pSpriteFrameTable->InitializeSprite(pObjects[i].uSpriteID);
39 }
40
41 //----- (00459090) --------------------------------------------------------
42 void ObjectList::ToFile()
43 {
44 ObjectList *v1; // esi@1
45 FILE *v2; // eax@1
46 FILE *v3; // edi@1
47
48 v1 = this;
49 v2 = fopen("data\\dobjlist.bin", "wb");
50 v3 = v2;
51 if ( !v2 )
52 Abortf("Unable to save dobjlist.bin!");
53 fwrite(v1, 4u, 1u, v2);
54 fwrite(v1->pObjects, 0x38u, v1->uNumObjects, v3);
55 fclose(v3);
56 }
57
58 //----- (004590DC) --------------------------------------------------------
59 void ObjectList::FromFile(void *pSerialized)
60 {
61 uNumObjects = *(int *)pSerialized;
62 pObjects = (ObjectDesc *)pAllocator->AllocNamedChunk(pObjects, 56 * uNumObjects, "Obj Descrip");
63 memcpy(pObjects, (char *)pSerialized + 4, 56 * uNumObjects);
64 }
65
66 //----- (00459123) --------------------------------------------------------
67 bool ObjectList::FromFileTxt(const char *Args)
68 {
69 ObjectList *v2; // ebx@1
70 __int32 v3; // edi@1
71 FILE *v4; // eax@1
72 unsigned int v5; // esi@3
73 void *v6; // eax@9
74 FILE *v7; // ST0C_4@11
75 char *i; // eax@11
76 unsigned __int16 v9; // ax@14
77 const char *v10; // ST20_4@14
78 __int16 v11; // ax@14
79 const char *v12; // ST1C_4@14
80 __int16 v13; // ax@14
81 const char *v14; // ST18_4@14
82 __int16 v15; // ax@14
83 const char *v16; // ST14_4@14
84 __int16 v17; // ax@14
85 const char *v18; // ST10_4@14
86 __int16 v19; // ax@14
87 const char *v20; // ST0C_4@14
88 int v21; // esi@16
89 const char *v22; // edi@16
90 int v23; // eax@17
91 int v24; // eax@19
92 int v25; // eax@21
93 int v26; // eax@21
94 int v27; // eax@21
95 int v28; // eax@23
96 int v29; // eax@25
97 int v30; // eax@27
98 int v31; // eax@29
99 const char *v32; // edi@30
100 const char *v33; // ST20_4@35
101 int v34; // eax@35
102 char v35; // al@35
103 const char *v36; // ST1C_4@35
104 char v37; // al@35
105 const char *v38; // ST18_4@35
106 FrameTableTxtLine v40; // [sp+8h] [bp-460h]@14
107 FrameTableTxtLine v41; // [sp+84h] [bp-3E4h]@12
108 char Dest; // [sp+100h] [bp-368h]@14
109 char Buf; // [sp+178h] [bp-2F0h]@3
110 FrameTableTxtLine v44; // [sp+36Ch] [bp-FCh]@4
111 FrameTableTxtLine v45; // [sp+3E8h] [bp-80h]@4
112 FILE *File; // [sp+464h] [bp-4h]@1
113 unsigned int Argsa; // [sp+470h] [bp+8h]@3
114 int Argsb; // [sp+470h] [bp+8h]@15
115
116 v2 = this;
117 pAllocator->FreeChunk(this->pObjects);
118 v3 = 0;
119 v2->pObjects = 0;
120 v2->uNumObjects = 0;
121 v4 = fopen(Args, "r");
122 File = v4;
123 if ( !v4 )
124 Abortf("ObjectDescriptionList::load - Unable to open file: %s.");
125 v5 = 0;
126 Argsa = 0;
127 if ( fgets(&Buf, 490, v4) )
128 {
129 do
130 {
131 *strchr(&Buf, 10) = 0;
132 memcpy(&v45, frame_table_txt_parser(&Buf, &v44), sizeof(v45));
133 if ( v45.uPropCount && *v45.pProperties[0] != '/' )
134 ++Argsa;
135 }
136 while ( fgets(&Buf, 490, File) );
137 v5 = Argsa;
138 v3 = 0;
139 }
140 v2->uNumObjects = v5;
141 v6 = pAllocator->AllocNamedChunk(v2->pObjects, 56 * v5, "Obj Descrip");
142 v2->pObjects = (ObjectDesc *)v6;
143 if ( v6 == (void *)v3 )
144 Abortf("ObjectDescriptionList::load - Out of Memory!");
145 memset(v6, v3, 56 * v2->uNumObjects);
146 v7 = File;
147 v2->uNumObjects = v3;
148 fseek(v7, v3, v3);
149 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
150 {
151 *strchr(&Buf, 10) = 0;
152 memcpy(&v45, frame_table_txt_parser(&Buf, &v41), sizeof(v45));
153 if ( v45.uPropCount && *v45.pProperties[0] != 47 )
154 {
155 strcpy(v2->pObjects[v2->uNumObjects].field_0, v45.pProperties[0]);
156 v9 = pSpriteFrameTable->FastFindSprite((char *)v45.pProperties[1]);
157 v10 = v45.pProperties[2];
158 v2->pObjects[v2->uNumObjects].uSpriteID = v9;
159 v11 = atoi(v10);
160 v12 = v45.pProperties[3];
161 v2->pObjects[v2->uNumObjects].uObjectID = v11;
162 v13 = atoi(v12);
163 v14 = v45.pProperties[4];
164 v2->pObjects[v2->uNumObjects].uRadius = v13;
165 v15 = atoi(v14);
166 v16 = v45.pProperties[5];
167 v2->pObjects[v2->uNumObjects].uHeight = v15;
168 v17 = atoi(v16);
169 v18 = v45.pProperties[6];
170 v2->pObjects[v2->uNumObjects].uLifetime = v17;
171 v19 = atoi(v18);
172 v20 = v45.pProperties[7];
173 v2->pObjects[v2->uNumObjects].uSpeed = v19;
174 strcpy(&Dest, v20);
175 memcpy(&v44, frame_table_txt_parser(&Dest, &v40), sizeof(v44));
176 if ( v45.uPropCount > 7 )
177 {
178 for ( Argsb = 0; Argsb < v44.uPropCount; ++Argsb )
179 {
180 v21 = Argsb;
181 v22 = v44.pProperties[Argsb];
182 if ( !_stricmp(v44.pProperties[Argsb], "NoDraw") )
183 {
184 v23 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
185 *(char *)v23 |= 1u;
186 }
187 if ( !_stricmp(v22, "Lifetime") )
188 {
189 v24 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
190 *(char *)v24 |= 4u;
191 }
192 if ( !_stricmp(v22, "FTLifetime") )
193 {
194 v25 = (int)&v2->pObjects[v2->uNumObjects];
195 *(short *)(v25 + 42) = 8 * pSpriteFrameTable->pSpriteSFrames[*(short *)(v25 + 40)].uAnimLength;
196 v26 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
197 *(char *)v26 |= 8u;
198 v27 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
199 *(char *)v27 |= 4u;
200 }
201 if ( !_stricmp(v22, "NoPickup") )
202 {
203 v28 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
204 *(char *)v28 |= 0x10u;
205 }
206 if ( !_stricmp(v22, "NoGravity") )
207 {
208 v29 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
209 *(char *)v29 |= 0x20u;
210 }
211 if ( !_stricmp(v22, "FlagOnIntercept") )
212 {
213 v30 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
214 *(char *)v30 |= 0x40u;
215 }
216 if ( !_stricmp(v22, "Bounce") )
217 {
218 v31 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
219 *(char *)v31 |= 0x80u;
220 }
221 v32 = v45.pProperties[v21];
222 if ( !_stricmp(v45.pProperties[v21], "Fire") )
223 HIBYTE(v2->pObjects[v2->uNumObjects].uFlags) |= 2u;
224 if ( !_stricmp(v32, "Lines") )
225 HIBYTE(v2->pObjects[v2->uNumObjects].uFlags) |= 4u;
226 if ( !_stricmp(v44.pProperties[v21], "bits") )
227 {
228 v33 = v44.pProperties[v21 + 1];
229 v34 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
230 *(char *)(v34 + 1) |= 1u;
231 v35 = atoi(v33);
232 v36 = v44.pProperties[v21 + 2];
233 v2->pObjects[v2->uNumObjects].uParticleTrailColorR = v35;
234 v37 = atoi(v36);
235 v38 = v44.pProperties[v21 + 3];
236 v2->pObjects[v2->uNumObjects].uParticleTrailColorG = v37;
237 v2->pObjects[v2->uNumObjects].uParticleTrailColorB = atoi(v38);
238 }
239 }
240 }
241 ++v2->uNumObjects;
242 }
243 }
244 fclose(File);
245 return 1;
246 }