Mercurial > mm7
comparison LOD.cpp @ 670:9824e2eeee30
fixed decorations animation
author | Gloval |
---|---|
date | Fri, 15 Mar 2013 01:51:51 +0400 |
parents | 0e368c04acfb |
children | 1d05543f522d |
comparison
equal
deleted
inserted
replaced
666:a5750c94b022 | 670:9824e2eeee30 |
---|---|
225 return LoadSubIndices("sprites08") == 0; | 225 return LoadSubIndices("sprites08") == 0; |
226 } | 226 } |
227 | 227 |
228 //----- (004AC7C0) -------------------------------------------------------- | 228 //----- (004AC7C0) -------------------------------------------------------- |
229 int LODFile_Sprites::LoadSprite(const char *pContainerName, unsigned int uPaletteID) | 229 int LODFile_Sprites::LoadSprite(const char *pContainerName, unsigned int uPaletteID) |
230 { signed int v3; // edi@1 | 230 { |
231 LODFile_Sprites *v4; // esi@1 | 231 |
232 unsigned int v5; // eax@6 | 232 FILE *sprite_file; // eax@12 |
233 signed int v6; // ecx@10 | 233 LODSprite temp_sprite_hdr; // [sp+Ch] [bp-3Ch]@12 |
234 Sprite *v7; // eax@11 | 234 int i, sprite_indx; |
235 FILE *v8; // eax@12 | 235 |
236 Sprite *v10; // edx@21 | 236 //find if already loaded |
237 int v11; // eax@21 | |
238 int v12; // eax@22 | |
239 unsigned __int8 v13; // zf@23 | |
240 unsigned __int8 v14; // sf@23 | |
241 LODSprite DstBuf; // [sp+Ch] [bp-3Ch]@12 | |
242 char *Str1; // [sp+34h] [bp-14h]@24 | |
243 LODSprite *v17; // [sp+38h] [bp-10h]@3 | |
244 int v18; // [sp+44h] [bp-4h]@12 | |
245 | |
246 auto a3 = uPaletteID; | |
247 v3 = 0; | |
248 v4 = this; | |
249 if ( pRenderer->pRenderD3D ) | |
250 { | |
251 if ( (signed int)this->uNumLoadedSprites > 0 ) | |
252 { | |
253 v17 = 0; | |
254 while ( _strcmpi(*(const char **)&v17->pName[(unsigned int)v4->pHardwareSprites], pContainerName) ) | |
255 { | |
256 ++v17; | |
257 ++v3; | |
258 if ( v3 >= (signed int)v4->uNumLoadedSprites ) | |
259 goto LABEL_6; | |
260 } | |
261 return v3; | |
262 } | |
263 } | |
264 else | |
265 { | |
266 if ( (signed int)this->uNumLoadedSprites > 0 ) | |
267 { | |
268 v17 = this->pSpriteHeaders; | |
269 while ( _strcmpi(v17->pName, pContainerName) ) | |
270 { | |
271 ++v17; | |
272 ++v3; | |
273 if ( v3 >= (signed int)v4->uNumLoadedSprites ) | |
274 goto LABEL_6; | |
275 } | |
276 return v3; | |
277 } | |
278 } | |
279 LABEL_6: | |
280 v5 = v4->uNumLoadedSprites; | |
281 if ( v5 == 1500 ) | |
282 return -1; | |
283 if ( pRenderer->pRenderD3D && v4->field_ECAC ) | |
284 { | |
285 if ( !v4->pHardwareSprites ) | |
286 { | |
287 v4->pHardwareSprites = (Sprite *)pAllocator->AllocNamedChunk(0, 0xEA60u, "hardSprites"); | |
288 v6 = 0; | |
289 do | |
290 { | |
291 v7 = &v4->pHardwareSprites[v6]; | |
292 ++v6; | |
293 v7->pName = 0; | |
294 v7->pTextureSurface = 0; | |
295 v7->pTexture = 0; | |
296 } | |
297 while ( v6 < 1500 ); | |
298 } | |
299 DstBuf.uHeight = 0; | |
300 DstBuf.uPaletteId = 0; | |
301 DstBuf.word_1A = 0; | |
302 DstBuf.pSpriteLines = 0; | |
303 DstBuf.pDecompressedBytes = 0; | |
304 v18 = 0; | |
305 v8 = FindContainer(pContainerName, 0); | |
306 if ( !v8 ) | |
307 { | |
308 v18 = -1; | |
309 //LODSprite::dtor(&DstBuf); | |
310 return -1; | |
311 } | |
312 fread(&DstBuf, 1u, 0x20u, v8); | |
313 v10 = v4->pHardwareSprites; | |
314 v11 = 5 * v4->uNumLoadedSprites; | |
315 v18 = -1; | |
316 pHardwareSprites[uNumLoadedSprites].uBufferWidth = DstBuf.uWidth; | |
317 pHardwareSprites[uNumLoadedSprites].uBufferHeight = DstBuf.uHeight; | |
318 pSpriteHeaders[uNumLoadedSprites].uWidth = DstBuf.uWidth; | |
319 pSpriteHeaders[uNumLoadedSprites].uHeight = DstBuf.uHeight; | |
320 //LODSprite::dtor(&DstBuf); | |
321 goto LABEL_29; | |
322 } | |
323 v12 = LoadSpriteFromFile( &v4->pSpriteHeaders[v5], pContainerName); | |
324 v4->pSpriteHeaders[v4->uNumLoadedSprites].word_1A = 0; | |
325 if ( v12 != -1 ) | |
326 { | |
327 LABEL_28: | |
328 v4->pSpriteHeaders[v4->uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette( | |
329 v4->pSpriteHeaders[v4->uNumLoadedSprites].uPaletteId); | |
330 LABEL_29: | |
331 if ( pRenderer->pRenderD3D ) | 237 if ( pRenderer->pRenderD3D ) |
332 { | 238 { |
333 v4->pHardwareSprites[v4->uNumLoadedSprites].pName = (const char *)pAllocator->AllocNamedChunk( | 239 for (i=0; i<uNumLoadedSprites;++i) |
334 v4->pHardwareSprites[v4->uNumLoadedSprites].pName, | 240 { |
335 0x14u, | 241 if (!(_strcmpi(pHardwareSprites[i].pName, pContainerName))) |
336 pContainerName); | 242 return i; |
337 strcpy((char *)pHardwareSprites[uNumLoadedSprites].pName, pContainerName); | 243 } |
338 v4->pHardwareSprites[v4->uNumLoadedSprites].uPaletteID = uPaletteID; | 244 } |
339 pRenderer->MoveSpriteToDevice(&pHardwareSprites[uNumLoadedSprites]); | 245 else |
340 } | 246 { |
341 ++v4->uNumLoadedSprites; | 247 for (i=0; i<uNumLoadedSprites;++i) |
342 return v4->uNumLoadedSprites - 1; | 248 { |
343 } | 249 if (!(_strcmpi(pSpriteHeaders[i].pName, pContainerName))) |
344 v13 = v4->uNumLoadedSprites == 0; | 250 return i; |
345 v14 = (v4->uNumLoadedSprites & 0x80000000u) != 0; | 251 } |
346 v17 = 0; | 252 } |
347 if ( v14 | v13 ) | 253 |
348 { | 254 if (uNumLoadedSprites == 1500 ) |
349 LABEL_27: | 255 return -1; |
350 if ( LoadSpriteFromFile(&v4->pSpriteHeaders[v4->uNumLoadedSprites], "pending") == -1 ) | 256 //if not loaded - load from file |
351 return -1; | 257 |
352 goto LABEL_28; | 258 if ( pRenderer->pRenderD3D && field_ECAC ) |
353 } | 259 { |
354 Str1 = (char *)v4->pSpriteHeaders; | 260 if ( !pHardwareSprites ) |
355 while ( _strcmpi(Str1, "pending") ) | 261 { |
356 { | 262 pHardwareSprites = (Sprite *)pAllocator->AllocNamedChunk(0, 1500*sizeof(Sprite) , "hardSprites");//0xEA60u |
357 v17 = (LODSprite *)((char *)v17 + 1); | 263 for (i=0; i<1500;++i) |
358 Str1 += 40; | 264 { |
359 if ( (signed int)v17 >= (signed int)v4->uNumLoadedSprites ) | 265 pHardwareSprites[i].pName=NULL; |
360 goto LABEL_27; | 266 pHardwareSprites[i].pTextureSurface=NULL; |
361 } | 267 pHardwareSprites[i].pTexture=NULL; |
362 return (int)v17; | 268 } |
363 } | 269 } |
270 temp_sprite_hdr.uHeight = 0; | |
271 temp_sprite_hdr.uPaletteId = 0; | |
272 temp_sprite_hdr.word_1A = 0; | |
273 temp_sprite_hdr.pSpriteLines = 0; | |
274 temp_sprite_hdr.pDecompressedBytes = 0; | |
275 sprite_file = FindContainer(pContainerName, 0); | |
276 if ( !sprite_file ) | |
277 return -1; | |
278 fread(&temp_sprite_hdr, 1, sizeof(LODSprite), sprite_file); | |
279 pHardwareSprites[uNumLoadedSprites].uBufferWidth = temp_sprite_hdr.uWidth; | |
280 pHardwareSprites[uNumLoadedSprites].uBufferHeight = temp_sprite_hdr.uHeight; | |
281 pSpriteHeaders[uNumLoadedSprites].uWidth = temp_sprite_hdr.uWidth; | |
282 pSpriteHeaders[uNumLoadedSprites].uHeight = temp_sprite_hdr.uHeight; | |
283 } | |
284 else | |
285 { | |
286 sprite_indx = LoadSpriteFromFile( &pSpriteHeaders[uNumLoadedSprites], pContainerName); | |
287 pSpriteHeaders[uNumLoadedSprites].word_1A = 0; | |
288 | |
289 if ( sprite_indx != -1 ) | |
290 { | |
291 pSpriteHeaders[uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId); | |
292 } | |
293 else | |
294 { | |
295 if ( uNumLoadedSprites<=0 ) | |
296 uNumLoadedSprites=0; | |
297 else | |
298 { | |
299 for (i=0; i<uNumLoadedSprites;++i) | |
300 { | |
301 if (!(_strcmpi(pSpriteHeaders[i].pName, "pending"))) | |
302 return i; | |
303 } | |
304 } | |
305 if ( LoadSpriteFromFile(&pSpriteHeaders[uNumLoadedSprites], "pending") == -1 ) | |
306 return -1; | |
307 pSpriteHeaders[uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId); | |
308 } | |
309 } | |
310 | |
311 if ( pRenderer->pRenderD3D ) | |
312 { | |
313 pHardwareSprites[uNumLoadedSprites].pName = (const char *)pAllocator->AllocNamedChunk(pHardwareSprites[uNumLoadedSprites].pName, 20, pContainerName); | |
314 strcpy((char *)pHardwareSprites[uNumLoadedSprites].pName, pContainerName); | |
315 pHardwareSprites[uNumLoadedSprites].uPaletteID = uPaletteID; | |
316 pRenderer->MoveSpriteToDevice(&pHardwareSprites[uNumLoadedSprites]); | |
317 } | |
318 ++uNumLoadedSprites; | |
319 return uNumLoadedSprites - 1; | |
320 | |
321 } | |
364 | 322 |
365 //----- (004ACADA) -------------------------------------------------------- | 323 //----- (004ACADA) -------------------------------------------------------- |
366 void LODFile_Sprites::ReleaseLostHardwareSprites() | 324 void LODFile_Sprites::ReleaseLostHardwareSprites() |
367 { | 325 { |
368 LODFile_Sprites *v1; // esi@1 | 326 LODFile_Sprites *v1; // esi@1 |