Mercurial > mm7
diff Overlays.cpp @ 0:9c0607679772
init
author | Ritor1 |
---|---|
date | Sat, 12 Jan 2013 09:45:18 +0600 |
parents | |
children | 8b8fd4d83fdc |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Overlays.cpp Sat Jan 12 09:45:18 2013 +0600 @@ -0,0 +1,302 @@ +#include <stdlib.h> + +#include "Overlays.h" +#include "Sprites.h" +#include "FrameTableInc.h" +#include "Allocator.h" +#include "IconFrameTable.h" +#include "Time.h" +#include "Party.h" +#include "TurnEngine.h" +#include "LOD.h" +#include "Render.h" + +#include "mm7_data.h" + + + + + +struct OtherOverlayList *pOtherOverlayList = new OtherOverlayList; // idb +struct OverlayList *pOverlayList = new OverlayList; + + + + + + + + +//----- (004418B1) -------------------------------------------------------- +int OtherOverlayList::_4418B1(int a2, int a3, int a4, int a5) +{ + return 0; +} + +//----- (004418B6) -------------------------------------------------------- +int OtherOverlayList::_4418B6(int uOverlayID, __int16 a3, int a4, int a5, __int16 a6) +{ + signed int v6; // edx@1 + OtherOverlayList *v7; // eax@1 + signed int result; // eax@4 + signed int v9; // esi@6 + __int16 v10; // dx@9 + __int16 v11; // dx@11 + + v6 = 0; + v7 = this; + while ( v7->pOverlays[0].field_6 > 0 ) + { + ++v6; + v7 = (OtherOverlayList *)((char *)v7 + 20); + if ( v6 >= 50 ) + return 0; + } + v7->pOverlays[0].field_0 = 0; + v7->pOverlays[0].field_A = 0; + v7->pOverlays[0].field_8 = 0; + v7->pOverlays[0].field_C = a3; + v9 = 0; + if ( (signed int)pOverlayList->uNumOverlays <= 0 ) + { +LABEL_9: + v10 = 0; + } + else + { + while ( uOverlayID != pOverlayList->pOverlays[v9].uOverlayID ) + { + ++v9; + if ( v9 >= (signed int)pOverlayList->uNumOverlays ) + goto LABEL_9; + } + v10 = v9; + } + v7->pOverlays[0].field_2 = v10; + v7->pOverlays[0].field_4 = 0; + if ( a4 ) + v11 = a4; + else + v11 = 8 * pSpriteFrameTable->pSpriteSFrames[pOverlayList->pOverlays[v10].uSpriteFramesetID].uAnimLength; + v7->pOverlays[0].field_6 = v11; + v7->pOverlays[0].field_10 = a5; + v7->pOverlays[0].field_E = a6; + result = 1; + this->field_3EC = 1; + return result; +} + +//----- (00441964) -------------------------------------------------------- +unsigned int OtherOverlayList::_441964(int a2) +{ + unsigned int result; // eax@1 + IconFrameTable *v3; // ecx@6 + void *v4; // eax@12 + unsigned int v5; // [sp-8h] [bp-Ch]@4 + int v6; // [sp-4h] [bp-8h]@4 + Texture *v7; // [sp-4h] [bp-8h]@14 + + result = pCurrentScreen; + if ( pCurrentScreen + || pParty->bTurnBasedModeOn != 1 ) + return result; + if ( pTurnEngine->field_4 == 3 ) + { + v6 = pEventTimer->uStartTime; + v5 = pIconIDs_Turn[5 - pTurnEngine->uActionPointsLeft / 26]; + } + else + { + if ( pTurnEngine->field_4 == 1 ) + { + v6 = dword_50C994; + v3 = pIconsFrameTable; + if ( dword_50C998_turnbased_icon_1A ) + v5 = uIconID_TurnStart; + else + v5 = uIconID_TurnHour; + goto LABEL_12; + } + if ( pTurnEngine->field_4 != 2 ) + { + v4 = this; + goto LABEL_14; + } + v6 = pEventTimer->uStartTime; + v5 = uIconID_TurnStop; + } + v3 = pIconsFrameTable; +LABEL_12: + v4 = pIconsFrameTable->GetFrame(v5, v6); +LABEL_14: + v7 = &pIcons_LOD->pTextures[*((short *)v4 + 15)]; + if ( pRenderer->pRenderD3D ) + pRenderer->DrawTextureIndexed(0x18Au, 0x120u, v7); + else + pRenderer->DrawTextureTransparent(0x18Au, 0x120u, v7); + result = dword_50C994; + if ( dword_50C994 < dword_50C998_turnbased_icon_1A ) + { + result = pEventTimer->uTimeElapsed + dword_50C994; + dword_50C994 = result; + if ( (signed int)result >= dword_50C998_turnbased_icon_1A ) + dword_50C998_turnbased_icon_1A = 0; + } + return result; +} +// 4E28F8: using guessed type int pCurrentScreen; +// 50C994: using guessed type int dword_50C994; +// 50C998: using guessed type int dword_50C998_turnbased_icon_1A; + + +//----- (00458D97) -------------------------------------------------------- +void OverlayList::InitializeSprites() +{ + OverlayList *v1; // esi@1 + signed int i; // edi@1 + + v1 = this; + for ( i = 0; i < (signed int)v1->uNumOverlays; ++i ) + pSpriteFrameTable->InitializeSprite(v1->pOverlays[i].uSpriteFramesetID); +} + +//----- (00458DBC) -------------------------------------------------------- +void OverlayList::ToFile() +{ + OverlayList *v1; // esi@1 + FILE *v2; // eax@1 + FILE *v3; // edi@1 + + v1 = this; + v2 = fopen("data\\doverlay.bin", "wb"); + v3 = v2; + if ( !v2 ) + Abortf("Unable to save doverlay.bin!"); + fwrite(v1, 4u, 1u, v2); + fwrite(v1->pOverlays, 8u, v1->uNumOverlays, v3); + fclose(v3); +} + +//----- (00458E08) -------------------------------------------------------- +void OverlayList::FromFile(void *pSerialized) +{ + uNumOverlays = *(int *)pSerialized; + pOverlays = (OverlayDesc *)pAllocator->AllocNamedChunk(pOverlays, 8 * uNumOverlays, "Ovl Des."); + memcpy(pOverlays, (char *)pSerialized + 4, 8 * uNumOverlays); +} + +//----- (00458E4F) -------------------------------------------------------- +bool OverlayList::FromFileTxt(const char *Args) +{ + OverlayList *v2; // ebx@1 + __int32 v3; // edi@1 + FILE *v4; // eax@1 + unsigned int v5; // esi@3 + const void *v6; // ST18_4@9 + void *v7; // eax@9 + FILE *v8; // ST0C_4@11 + char *i; // eax@11 + unsigned __int16 v10; // ax@14 + const char *v11; // ST1C_4@14 + int v12; // eax@16 + OverlayDesc *v13; // ecx@16 + char v14; // zf@16 + unsigned int v15; // eax@16 + char Buf; // [sp+10h] [bp-2F0h]@3 + FrameTableTxtLine v18; // [sp+204h] [bp-FCh]@4 + FrameTableTxtLine v19; // [sp+280h] [bp-80h]@4 + FILE *File; // [sp+2FCh] [bp-4h]@1 + unsigned int Argsa; // [sp+308h] [bp+8h]@3 + + v2 = this; + pAllocator->FreeChunk(this->pOverlays); + v3 = 0; + v2->pOverlays = 0; + v2->uNumOverlays = 0; + v4 = fopen(Args, "r"); + File = v4; + if ( !v4 ) + Abortf("ObjectDescriptionList::load - Unable to open file: %s."); + v5 = 0; + Argsa = 0; + if ( fgets(&Buf, 490, v4) ) + { + do + { + *strchr(&Buf, 10) = 0; + memcpy(&v19, texture_frame_table_txt_parser(&Buf, &v18), sizeof(v19)); + if ( v19.field_0 && *v19.pProperties[0] != 47 ) + ++Argsa; + } + while ( fgets(&Buf, 490, File) ); + v5 = Argsa; + v3 = 0; + } + v6 = v2->pOverlays; + v2->uNumOverlays = v5; + v7 = pAllocator->AllocNamedChunk(v6, 8 * v5, "Ovl Des."); + v2->pOverlays = (OverlayDesc *)v7; + if ( v7 == (void *)v3 ) + Abortf("OverlayDescriptionList::load - Out of Memory!"); + memset(v7, v3, 8 * v2->uNumOverlays); + v8 = File; + v2->uNumOverlays = v3; + fseek(v8, v3, v3); + for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) + { + *strchr(&Buf, 10) = 0; + memcpy(&v19, texture_frame_table_txt_parser(&Buf, &v18), sizeof(v19)); + if ( v19.field_0 && *v19.pProperties[0] != 47 ) + { + v10 = atoi(v19.pProperties[0]); + v11 = v19.pProperties[1]; + v2->pOverlays[v2->uNumOverlays].uOverlayID = v10; + if ( _strcmpi(v11, "center") ) + { + v12 = _strcmpi(v19.pProperties[1], "transparent"); + v13 = v2->pOverlays; + v14 = v12 == 0; + v15 = v2->uNumOverlays; + if ( v14 ) + v13[v15].uOverlayType = 2; + else + v13[v15].uOverlayType = 1; + } + else + { + v2->pOverlays[v2->uNumOverlays].uOverlayType = 0; + } + v2->pOverlays[v2->uNumOverlays++].uSpriteFramesetID = pSpriteFrameTable->FastFindSprite( + (char *)v19.pProperties[2]); + } + } + fclose(File); + return 1; +} + + +//----- (0045855F) -------------------------------------------------------- +void OtherOverlay::Reset() +{ + this->field_10 = 65536; + this->field_A = 0; + this->field_8 = 0; + this->field_6 = 0; + this->field_4 = 0; + this->field_2 = 0; + this->field_C = 0; + this->field_E = 0; +} + +//----- (004584B8) -------------------------------------------------------- +OtherOverlay::OtherOverlay() +{ + this->field_A = 0; + this->field_8 = 0; + this->field_6 = 0; + this->field_4 = 0; + this->field_2 = 0; + this->field_C = 0; + this->field_E = 0; + this->field_10 = 65536; +} \ No newline at end of file