# HG changeset patch
# User Nomad
# Date 1350993081 -7200
# Node ID 8a8dd0164b1256caab432bd77f40a8d7dec4e1af
# Parent 79a30ee1ecdb307a5bd26be9313230f9c7935e3d
BLV render
cd check fix
diff -r 79a30ee1ecdb -r 8a8dd0164b12 Bink_Smacker.cpp
--- a/Bink_Smacker.cpp Mon Oct 22 20:54:14 2012 +0200
+++ b/Bink_Smacker.cpp Tue Oct 23 13:51:21 2012 +0200
@@ -22,6 +22,7 @@
void (__stdcall *smackw32_SmackBufferClose)(HSMACKBUF) = 0;
void (__stdcall *smackw32_SmackBlitClose)(HSMACKBLIT) = 0;
int (__stdcall *smackw32_SmackBlitClear)(HSMACKBLIT, unsigned short *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, int) = 0;
+int (__stdcall *smackw32_SmackGoto)(_SMACK *, long) = 0;
void SMACKW32_DLL_Initialize()
{
HMODULE pDll = LoadLibraryW(L"SmackW32.dll");
@@ -42,6 +43,7 @@
smackw32_SmackBufferClose = (void (__stdcall *)(HSMACKBUF))GetProcAddress(pDll, "_SmackBufferClose@4");
smackw32_SmackBlitClose = (void (__stdcall *)(HSMACKBLIT))GetProcAddress(pDll, "_SmackBlitClose@4");
smackw32_SmackBlitClear = (int (__stdcall *)(HSMACKBLIT, unsigned short *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, int))GetProcAddress(pDll, "_SmackBlitClear@32");
+ smackw32_SmackGoto = (int (__stdcall *)(_SMACK *, long))GetProcAddress(pDll, "_SmackGoto@8");
}
@@ -129,6 +131,10 @@
return (smackw32_SmackBlitClear)(a1, pFrameData, uTargetSurfacePitch, uOutX, uOutY, uOutZ, uOutW, a8);
}
+int __stdcall SmackGoto(_SMACK *a1, long a2)
+{
+ return (smackw32_SmackGoto)(a1, a2);
+}
int __stdcall SmackBufferOpen(HWND a1, long a2, long a3, long a4, long a5, long a6)
@@ -144,12 +150,6 @@
}
-int __stdcall SmackGoto(_SMACK *a1, long a2)
-{
- __asm int 3
- return 0;
-}
-
// sub_4D83D0: using guessed type int __stdcall SmackBufferNewPalette(_DWORD, _DWORD, _DWORD);
int __stdcall SmackBufferNewPalette(long a1, long a2, long a3)
{
diff -r 79a30ee1ecdb -r 8a8dd0164b12 Game.cpp
--- a/Game.cpp Mon Oct 22 20:54:14 2012 +0200
+++ b/Game.cpp Tue Oct 23 13:51:21 2012 +0200
@@ -48,8 +48,6 @@
//----- (0044103C) --------------------------------------------------------
void Game::Draw()
{
- Render *v0; // esi@3
- int _null; // ebx@6
float v2; // ST24_4@11
//double v3; // ST28_8@11
int v4; // edi@26
@@ -71,14 +69,13 @@
pIndoorCamera->Initialize2();
pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff();
pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum();
- //v0 = &pRenderer;
+
if ( pVideoPlayer->AnyMovieLoaded() )
{
- _null = 0;
if ( pRenderer->pRenderD3D )
goto LABEL_22;
- pRenderer->SetGameRenderStates();
- pMouse->_469E3B();
+ pRenderer->BeginSceneD3D();
+ pMouse->DrawCursorToTarget();
}
else
{
@@ -91,10 +88,10 @@
pParty->vPrevPosition.z = pParty->vPosition.z;
pParty->sPrevRotationX = pParty->sRotationX;
pParty->sPrevEyelevel = pParty->sEyelevel;
- pRenderer->SetGameRenderStates();
- _null = 0;
+ pRenderer->BeginSceneD3D();
+
if ( !pRenderer->pRenderD3D )
- pMouse->_469E3B();
+ pMouse->DrawCursorToTarget();
if ( !sub_4226C2() || viewparams->field_48 == 1 )
{
if ( pRenderer->pRenderD3D )
@@ -121,44 +118,43 @@
pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
LABEL_22:
pRenderer->BeginScene();
- if ( pRenderer->pRenderD3D != (RenderD3D *)_null )
- pMouse->_469E3B();
- if ( pOtherOverlayList->field_3EC != _null )
+ if (pRenderer->pRenderD3D)
+ pMouse->DrawCursorToTarget();
+ if (pOtherOverlayList->field_3EC)
viewparams->bRedrawGameUI = 1;
v4 = viewparams->bRedrawGameUI;
GameUI_DrawStatusBar();
- if ( viewparams->bRedrawGameUI == _null )
+ if (!viewparams->bRedrawGameUI)
{
- //nullsub_1();
GameUI_DrawRightPanelItems();
}
else
{
GameUI_DrawRightPanelFrames();
GameUI_DrawStatusBar_2();
- viewparams->bRedrawGameUI = _null;
+ viewparams->bRedrawGameUI = false;
}
- if ( pVideoPlayer->pSmackerMovie == (_SMACK *)_null )
+ if (!pVideoPlayer->pSmackerMovie)
{
GameUI_DrawMinimap(0x1E8u, 0x10u, 0x271u, 0x85u, viewparams->uMinimapZoom, pParty->uFlags & 2);
- if ( v4 != _null )
+ if (v4)
{
- if ( !sub_4226C2() && pRenderer->pRenderD3D != (RenderD3D *)_null )
+ if ( !sub_4226C2() && pRenderer->pRenderD3D)
pRenderer->FillRect2(
- _null,
+ 0,
pViewport->uViewportX,
pViewport->uViewportY,
pViewport->uViewportZ - pViewport->uViewportX,
pViewport->uViewportW - pViewport->uViewportY + 1,
LOWORD(pRenderer->uTargetGMask) | LOWORD(pRenderer->uTargetBMask));
- viewparams->field_48 = _null;
+ viewparams->field_48 = 0;
}
}
v5 = pOtherOverlayList->field_3EC;
- pOtherOverlayList->field_3EC = _null;
+ pOtherOverlayList->field_3EC = 0;
viewparams->bRedrawGameUI = v5;
GameUI_DrawPartySpells();
- if ( v4 != _null || pParty->pHirelings[0].evtc != _null || pParty->pHirelings[1].evtc != _null )
+ if (v4 || pParty->pHirelings[0].evtc || pParty->pHirelings[1].evtc )
DrawHiredNPCs();
GameUI_DrawPortraits(v4);
GameUI_DrawLifeManaBars();
@@ -174,8 +170,8 @@
GUI_UpdateWindows();
pParty->_4909F4();
++stru_51076C.field_8;
- dword_5B5924 = _null;
- if ( v4 != _null )
+ dword_5B5924 = 0;
+ if (v4)
pMouse->field_14 = 1;
pMouse->_469EA4();
pMouse->DrawCursor();
@@ -184,7 +180,6 @@
pRenderer->Present();
pParty->uFlags &= 0xFFFFFFFDu;
}
-// 5B5924: using guessed type int dword_5B5924;
//----- (0047A815) --------------------------------------------------------
@@ -293,7 +288,7 @@
if ( pVideoPlayer->pSmackerMovie && !SmackWait(pVideoPlayer->pSmackerMovie) )
{
pRenderer->BeginScene();
- pMouse->_469E3B();
+ pMouse->DrawCursorToTarget();
pVideoPlayer->SmackUpdatePalette(pVideoPlayer->hWindow);
pMouse->_469EA4();
pRenderer->EndScene();
@@ -301,7 +296,7 @@
if ( pVideoPlayer->pBinkMovie && !BinkWait(pVideoPlayer->pBinkMovie) )
{
pRenderer->BeginScene();
- pMouse->_469E3B();
+ pMouse->DrawCursorToTarget();
pVideoPlayer->BinkUpdatePalette(pVideoPlayer->hWindow);
pMouse->_469EA4();
pRenderer->EndScene();
@@ -907,7 +902,7 @@
pThreadWardInstance = new ThreadWard;
pParticleEngine = new ParticleEngine;
- pMouseInstance = new Mouse(pThreadWardInstance);
+ pMouse = pMouseInstance = new Mouse(pThreadWardInstance);
pLightmapBuilder = new LightmapBuilder;
pVisInstance = new Vis;
pStru6Instance = new stru6;
diff -r 79a30ee1ecdb -r 8a8dd0164b12 Indoor_stuff.h
--- a/Indoor_stuff.h Mon Oct 22 20:54:14 2012 +0200
+++ b/Indoor_stuff.h Tue Oct 23 13:51:21 2012 +0200
@@ -74,6 +74,9 @@
// _eh_vector_constructor_iterator_(field_FA8, 2252, 150,
// (void (__thiscall *)(void *))stru170_stru0::stru170_stru0,
// (void (__thiscall *)(void *))stru170_stru0::dtor);
+ uNumFaceIDs = 0;
+ std__vector_000FA8 = 0;
+ field_53730 = 0;
}
void _4AFB86(int a2, unsigned int uFaceID);
diff -r 79a30ee1ecdb -r 8a8dd0164b12 Might and Magic Trilogy.vcxproj.filters
--- a/Might and Magic Trilogy.vcxproj.filters Mon Oct 22 20:54:14 2012 +0200
+++ b/Might and Magic Trilogy.vcxproj.filters Tue Oct 23 13:51:21 2012 +0200
@@ -147,7 +147,6 @@
-
@@ -200,7 +199,6 @@
-
@@ -317,7 +315,4 @@
-
-
-
\ No newline at end of file
diff -r 79a30ee1ecdb -r 8a8dd0164b12 Mouse.cpp
--- a/Mouse.cpp Mon Oct 22 20:54:14 2012 +0200
+++ b/Mouse.cpp Tue Oct 23 13:51:21 2012 +0200
@@ -390,53 +390,15 @@
}
//----- (00469E3B) --------------------------------------------------------
-unsigned __int16 *Mouse::_469E3B()
+void Mouse::DrawCursorToTarget()
{
- unsigned __int16 *result; // eax@1
- int v2; // esi@3
- unsigned int v3; // edx@3
- int v4; // edi@4
- unsigned __int16 *v5; // ebx@5
- unsigned __int16 *v6; // esi@6
- unsigned int v7; // [sp+4h] [bp-Ch]@2
- unsigned __int16 *v8; // [sp+8h] [bp-8h]@2
- unsigned __int16 *v9; // [sp+Ch] [bp-4h]@2
+ if (!pCursorBitmap3_sysmembits_16bit)
+ return;
- result = this->pCursorBitmap3_sysmembits_16bit;
- if ( result )
- {
- v9 = this->pCursorBitmap3_sysmembits_16bit;
- v7 = pRenderer->uTargetSurfacePitch;
- v8 = pRenderer->pTargetSurface;
- result = (unsigned __int16 *)this->field_44;
- if ( (signed int)result < this->field_4C )
- {
- v2 = this->field_48;
- v3 = pRenderer->uTargetSurfacePitch * (int)result;
- do
- {
- v4 = this->field_40;
- if ( v4 < v2 )
- {
- v5 = &v8[v3 + v4];
- do
- {
- v6 = v9;
- ++v9;
- ++v4;
- *v5 = *v6;
- v2 = this->field_48;
- ++v5;
- }
- while ( v4 < v2 );
- }
- v3 += v7;
- result = (unsigned __int16 *)((char *)result + 1);
- }
- while ( (signed int)result < this->field_4C );
- }
- }
- return result;
+ auto pSrc = pCursorBitmap3_sysmembits_16bit;
+ for (uint y = field_44; y < field_4C; ++y)
+ for (uint x = field_40; x < field_48; ++x)
+ pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++;
}
//----- (00469EA4) --------------------------------------------------------
diff -r 79a30ee1ecdb -r 8a8dd0164b12 Mouse.h
--- a/Mouse.h Mon Oct 22 20:54:14 2012 +0200
+++ b/Mouse.h Tue Oct 23 13:51:21 2012 +0200
@@ -72,7 +72,7 @@
void DrawCursor();
void _469E1C();
void _469E24();
- unsigned __int16 *_469E3B();
+ void DrawCursorToTarget();
void _469EA4();
void Activate(int bActive);
void SetMouseClick(int x, int y);
diff -r 79a30ee1ecdb -r 8a8dd0164b12 Player.h
--- a/Player.h Mon Oct 22 20:54:14 2012 +0200
+++ b/Player.h Tue Oct 23 13:51:21 2012 +0200
@@ -193,6 +193,29 @@
#pragma pack(push, 1)
struct Player
{
+ enum Condition: unsigned __int32
+ {
+ Condition_Cursed = 0,
+ Condition_Weak = 1,
+ Condition_Sleep = 2,
+ Condition_Fear = 3,
+ Condition_Drunk = 4,
+ Condition_Insane = 5,
+ Condition_Poison1 = 6,
+ Condition_Disease1 = 7,
+ Condition_Posion2 = 8,
+ Condition_Disease2 = 9,
+ Condition_Poison3 = 10,
+ Condition_Disease3 = 11,
+ Condition_Paralyzed = 12,
+ Condition_Unconcious = 13,
+ Condition_Dead = 14,
+ Condition_Pertified = 15,
+ Condition_Eradicated = 16,
+ Condition_Zombie = 17,
+ Condition_Good = 18
+ };
+
Player();
void SetVariable(enum VariableType var, signed int a3);
@@ -315,6 +338,9 @@
bool Recover(signed int a2);
bool CanCastSpell(unsigned int uRequiredMana);
+ inline bool Dead() {return pConditions[Condition::Condition_Dead] != 0;}
+ inline bool Eradicated() {return pConditions[Condition::Condition_Eradicated] != 0;}
+
__int64 pConditions[20];
diff -r 79a30ee1ecdb -r 8a8dd0164b12 Render.cpp
--- a/Render.cpp Mon Oct 22 20:54:14 2012 +0200
+++ b/Render.cpp Tue Oct 23 13:51:21 2012 +0200
@@ -4614,6 +4614,7 @@
v1->field_1036B8 = 0;
v1->_gpu_memory_used = 0;
uNumBillboardsToDraw = 0;
+ bFogEnabled = false;
}
bool Render::Initialize(bool bWindowed, uint uDefaultDevice,
@@ -7106,29 +7107,10 @@
}
//----- (004A1EB6) --------------------------------------------------------
-void Render::SetGameRenderStates()
-{
- Render *v1; // esi@1
- unsigned int v2; // eax@1
- RenderD3D *v3; // ecx@2
- unsigned int uFogColor; // edi@6
- IDirect3DDevice3 *v5; // eax@8
- //IDirect3DDevice3Vtbl *v6; // ecx@8
- RenderD3D *v7; // eax@9
- RenderD3D *v8; // eax@9
- std::string v9; // [sp-14h] [bp-2Ch]@4
- IDirect3DDevice3 *v10; // [sp-8h] [bp-20h]@9
- signed int v11; // [sp-4h] [bp-1Ch]@4
- int v12; // [sp+0h] [bp-18h]@4
- std::string *v13; // [sp+10h] [bp-8h]@4
- int a3; // [sp+17h] [bp-1h]@4
-
- v1 = this;
- v2 = this->uNumD3DSceneBegins;
- this->uNumD3DSceneBegins = v2 + 1;
- if ( !v2 )
- {
- v3 = this->pRenderD3D;
+void Render::BeginSceneD3D()
+{
+ if (!uNumD3DSceneBegins++)
+ {
if (pRenderD3D)
{
pRenderD3D->ClearTarget(1u, 0, 1u, 1.0);
@@ -7142,42 +7124,27 @@
uFogColor = GetLevelFogColor();
else
uFogColor = 0;
- v5 = v1->pRenderD3D->pDevice;
- //v6 = v5->lpVtbl;
+
if ( uFogColor & 0xFF000000 )
{
- v12 = 1;
- v11 = 28;
- v10 = v5;
- pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u);
- //v7 = v1->pRenderD3D;
- v12 = uFogColor & 0xFFFFFF;
- v11 = 34;
- //v10 = v7->pDevice;
+ pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1);
pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF);
- v8 = v1->pRenderD3D;
- *(float *)&v12 = 0.0;
- v11 = 35;
- //v10 = v8->pDevice;
pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0);
- v1->bUsingSpecular = 1;
+ bUsingSpecular = true;
}
else
{
- *(float *)&v12 = 0.0;
- v11 = 28;
- v10 = v5;
pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0);
- v1->bUsingSpecular = 0;
+ bUsingSpecular = 0;
}
}
else
{
- LockRenderSurface((void **)&v1->pTargetSurface, &v1->uTargetSurfacePitch);
- if ( v1->pTargetSurface )
- v1->field_18_locked_pitch = v1->uTargetSurfacePitch;
+ LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch);
+ if (pTargetSurface)
+ field_18_locked_pitch = uTargetSurfacePitch;
else
- --v1->uNumD3DSceneBegins;
+ --uNumD3DSceneBegins;
}
}
}
diff -r 79a30ee1ecdb -r 8a8dd0164b12 Render.h
--- a/Render.h Mon Oct 22 20:54:14 2012 +0200
+++ b/Render.h Tue Oct 23 13:51:21 2012 +0200
@@ -304,7 +304,7 @@
unsigned int Billboard_ProbablyAddToListAndSortByZOrder(unsigned int a1);
unsigned int GetBillboardDrawListSize();
unsigned int GetParentBillboardID(unsigned int uBillboardID);
- void SetGameRenderStates();
+ void BeginSceneD3D();
void DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
unsigned int GetActorTintColor(float a2, int a3, int a4, int a5, RenderBillboard *a6);
void DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture);
diff -r 79a30ee1ecdb -r 8a8dd0164b12 mm7_1.cpp
--- a/mm7_1.cpp Mon Oct 22 20:54:14 2012 +0200
+++ b/mm7_1.cpp Tue Oct 23 13:51:21 2012 +0200
@@ -1352,9 +1352,9 @@
v0 = uGameUIFontMain;
v1 = uGameUIFontShadow;
v2 = sub_44100D() != 0 ? 381 : 322;
- sprintfex(pTmpBuf, "\r087%lu", pParty->uNumFoodRations);
+ sprintf(pTmpBuf, "\r087%lu", pParty->uNumFoodRations);
pGUIWindow0->DrawText(pFontSmallnum, 0, v2, v0, pTmpBuf, 0, 0, v1);
- sprintfex(pTmpBuf, "\r028%lu", pParty->uNumGold);
+ sprintf(pTmpBuf, "\r028%lu", pParty->uNumGold);
pGUIWindow0->DrawText(pFontSmallnum, 0, v2, v0, pTmpBuf, 0, 0, v1);
}
}
diff -r 79a30ee1ecdb -r 8a8dd0164b12 mm7_2.cpp
--- a/mm7_2.cpp Mon Oct 22 20:54:14 2012 +0200
+++ b/mm7_2.cpp Tue Oct 23 13:51:21 2012 +0200
@@ -3440,7 +3440,7 @@
window.uFrameWidth = 460;
window.uFrameZ = 452;
v0 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[575], &window, 13, 0) + 7;
- pRenderer->SetGameRenderStates();
+ pRenderer->BeginSceneD3D();
if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
pIndoor->Draw();
@@ -11278,7 +11278,7 @@
v3 = pPixels;
if ( pRenderer->pRenderD3D )
{
- pRenderer->SetGameRenderStates();
+ pRenderer->BeginSceneD3D();
if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
{
pIndoor->Draw();
@@ -13503,7 +13503,7 @@
drive[0] = 'A' + i;
if (GetDriveTypeA(drive) == DRIVE_CDROM)
- if (CheckMM7CD(bGotCDFromRegistry))
+ if (CheckMM7CD(*drive))
{
cMM7GameCDDriveLetter = *drive;
WriteWindowsRegistryString("CDDrive", drive);
@@ -14066,6 +14066,9 @@
RECT Rect; // [sp+Ch] [bp-20h]@15
int a2[4]; // [sp+1Ch] [bp-10h]@15
+ auto mm7text_dll = LoadLibraryW(L"mm7text.dll");
+ sprintfex = (int (__cdecl *)(char *a1, const char *a2, ...))GetProcAddress(mm7text_dll, "_sprintfex");
+
if (pCmdLine && *pCmdLine)
{
if (wcsstr(pCmdLine, L"-usedefs"))
diff -r 79a30ee1ecdb -r 8a8dd0164b12 mm7_3.cpp
--- a/mm7_3.cpp Mon Oct 22 20:54:14 2012 +0200
+++ b/mm7_3.cpp Tue Oct 23 13:51:21 2012 +0200
@@ -13532,8 +13532,8 @@
pRenderer->_4A65CC(
pPartySpellbuffsUI_XYs[v1][0],
pPartySpellbuffsUI_XYs[v1][1],
- (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0),
- (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0),
+ (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0),
+ (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0),
v0 + 20 * pPartySpellbuffsUI_smthns[v1],
0,
63);
diff -r 79a30ee1ecdb -r 8a8dd0164b12 mm7_4.cpp
--- a/mm7_4.cpp Mon Oct 22 20:54:14 2012 +0200
+++ b/mm7_4.cpp Tue Oct 23 13:51:21 2012 +0200
@@ -3065,12 +3065,6 @@
//----- (00491F87) --------------------------------------------------------
void __cdecl DrawHiredNPCs()
{
- int v0; // ecx@2
- char *v1; // eax@2
- int v2; // edx@4
- signed int v3; // ebx@6
- char *v4; // esi@7
- int v5; // ecx@13
int v6; // eax@15
char v7; // al@17
unsigned int v8; // eax@18
@@ -3081,7 +3075,7 @@
unsigned int v13; // eax@23
IconFrame *v14; // eax@24
unsigned int v15; // eax@26
- char pContainer; // [sp+Ch] [bp-30h]@18
+ char pContainer[20]; // [sp+Ch] [bp-30h]@18
unsigned int v17; // [sp+20h] [bp-1Ch]@19
signed int uFrameID; // [sp+24h] [bp-18h]@19
int i; // [sp+28h] [bp-14h]@15
@@ -3094,38 +3088,24 @@
{
v23 = 0;
v22 = 0;
- v0 = 0;
- v1 = (char *)pParty->pHirelings;
- do
- {
- if ( *(int *)v1 )
- {
- v2 = v22++;
- pTmpBuf[v2] = v0;
- }
- v1 += 76;
- ++v0;
- }
- while ( (signed int)v1 < (signed int)&pParty->pPickedItem );
- v3 = 0;
- if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
- {
- v4 = (char *)pNPCStats->pNewNPCData;
- do
- {
- if ( v4[8] & 0x80 && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v4, pParty->pHirelings[0].pName)) )
- {
- if ( !pParty->pHirelings[1].pName || strcmp(*(const char **)v4, pParty->pHirelings[1].pName) )
- {
- v5 = v22++;
- pTmpBuf[v5] = v3 + 2;
- }
- }
- ++v3;
- v4 += 76;
- }
- while ( v3 < (signed int)pNPCStats->uNumNewNPCs );
- }
+ for (uint i = 0; i < 2; ++i)
+ {
+ if (pParty->pHirelings[i].pName)
+ pTmpBuf[v22++] = i;
+ }
+
+ for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
+ {
+ if (pNPCStats->pNewNPCData[i].uFlags & 0x80)
+ {
+ if (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName))
+ {
+ if (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName))
+ pTmpBuf[v22++] = i + 2;
+ }
+ }
+ }
+
v6 = (unsigned __int8)pParty->field_709;
for ( i = (unsigned __int8)pParty->field_709; i < v22; v6 = i++ + 1 )
{
@@ -3134,22 +3114,22 @@
v7 = pTmpBuf[v6];
if ( (unsigned __int8)v7 >= 2u )
{
- sprintfex(&pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID);
- v15 = pIcons_LOD->LoadTexture(&pContainer, TEXTURE_16BIT_PALETTE);
+ sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID);
+ v15 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
pRenderer->DrawTextureIndexed(
pHiredNPCsIconsOffsetsX[v23],
pHiredNPCsIconsOffsetsY[v23],
- (Texture *)(v15 != -1 ? 72 * v15 + 7145548 : 0));
+ (Texture *)(v15 != -1 ? &pIcons_LOD->pTextures[v15] : 0));
}
else
{
- sprintfex(&pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID);
- v8 = pIcons_LOD->LoadTexture(&pContainer, TEXTURE_16BIT_PALETTE);
+ sprintf(pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID);
+ v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
v9 = v23;
pRenderer->DrawTextureIndexed(
pHiredNPCsIconsOffsetsX[v9],
pHiredNPCsIconsOffsetsY[v9],
- (Texture *)(v8 != -1 ? (int)&pIcons_LOD->pTextures[v8] : 0));
+ (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0));
v10 = (unsigned __int8)pTmpBuf[i];
if ( pParty->pHirelings[v10].bDrawSomeAnim == 1 )
{
@@ -3190,12 +3170,7 @@
//----- (004921C1) --------------------------------------------------------
void GameUI_DrawPortraits(unsigned int _this)
{
- signed int v1; // ebx@2
- int v2; // ebp@7
- char *v3; // esi@7
Texture *v4; // eax@10
- signed int v5; // edx@13
- PlayerFrame *v6; // eax@14
unsigned int v7; // eax@17
PlayerFrame *v8; // eax@21
unsigned int v9; // eax@27
@@ -3203,21 +3178,15 @@
bool v11; // edi@40
bool v12; // edx@43
bool v13; // ecx@46
- int v14; // esi@54
- char *v15; // edi@55
int v16; // eax@57
- __int16 *v17; // esi@59
- char *v18; // edi@59
int v19; // eax@62
Texture *v20; // [sp-4h] [bp-1Ch]@27
- signed int v21; // [sp+10h] [bp-8h]@7
unsigned int v22; // [sp+14h] [bp-4h]@1
v22 = _this;
if ( qword_A750D8 )
{
qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed;
- v1 = 0;
if ( qword_A750D8 <= 0 )
{
if ( pPlayers[word_A750E2]->CanAct() )
@@ -3225,95 +3194,80 @@
qword_A750D8 = 0i64;
}
}
- else
- {
- v1 = 0;
- }
- v2 = 0;
- v21 = v1;
- v3 = (char *)&pParty->pPlayers[0].pConditions[14];
- while ( 1 )
- {
- if ( *((_QWORD *)v3 + 2) )
+
+ for (uint i = 0; i < 4; ++i)
+ {
+ auto pPlayer = pParty->pPlayers + i;
+
+ if (pPlayer->Eradicated())
{
v4 = pTexture_PlayerFaceEradicated;
LABEL_27:
v20 = v4;
- v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[v2];
+ v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i];
if ( pParty->pPartyBuffs[11].uExpireTime )
pRenderer->_4A6E7E(v9, 0x183u, v20);
else
pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, v20);
- v10 = *((int *)v3 + 1541) >= v1 && (*((int *)v3 + 1541) > v1 || *((int *)v3 + 1540) > (unsigned int)v1);
- if ( *((int *)v3 + 1489) >= v1 && (*((int *)v3 + 1489) > v1 || *((int *)v3 + 1488) > (unsigned int)v1) )
- v1 = 1;
- v11 = *((_QWORD *)v3 + 758) > 0i64;
- v12 = *((_QWORD *)v3 + 756) > 0i64;
- v13 = *((_QWORD *)v3 + 768) > 0i64;
- if ( v13 | v12 | v11 | v1 | v10 )
- sub_441A4E(v2);
+ auto _v1 = 0;
+ v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0;
+ if (pPlayer->pPlayerBuffs[1].uExpireTime > 0)
+ _v1 = 1;
+ v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0;
+ v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0;
+ v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0;
+ if ( v13 | v12 | v11 | _v1 | v10 )
+ sub_441A4E(i);
goto LABEL_50;
}
- if ( *(_QWORD *)v3 )
+ if (pPlayer->Dead())
{
v4 = pTexture_PlayerFaceDead;
goto LABEL_27;
}
- v5 = 0;
- if ( (signed int)pPlayerFrameTable->uNumFrames <= v1 )
- {
-LABEL_17:
+
v7 = 0;
- }
- else
- {
- v6 = pPlayerFrameTable->pFrames;
- while ( v6->uSequenceID != *((short *)v3 + 3350) )
- {
- ++v5;
- ++v6;
- if ( v5 >= (signed int)pPlayerFrameTable->uNumFrames )
- goto LABEL_17;
- }
- v7 = v5;
- }
- if ( v7 == v1 )
+ for (uint j = 0; j < pPlayerFrameTable->uNumFrames; ++j)
+ if (pPlayerFrameTable->pFrames[j].uSequenceID == pPlayer->uExpressionID)
+ {
+ v7 = j;
+ break;
+ }
+
+ if ( v7 == 0 )
v7 = 1;
- if ( *((short *)v3 + 3350) == 21 )
+ if (pPlayer->uExpressionID == 21 )
v8 = pPlayerFrameTable->GetFrameBy_y(
- (int *)v3 + 1678,
- (int *)v3 + 1677,
+ &pPlayer->field_1AA8,
+ &pPlayer->field_1AA4,
pMiscTimer->uTimeElapsed);
else
- v8 = pPlayerFrameTable->GetFrameBy_x(v7, *((short *)v3 + 3351));
- if ( *((short *)v3 + 3353) != v8->uTextureID - 1 || v22 )
- {
- *((short *)v3 + 3353) = v8->uTextureID - 1;
- v1 = 0;
- v4 = (Texture *)A74CEC_player_faces_minus1_indexing[v21 + v8->uTextureID];
+ v8 = pPlayerFrameTable->GetFrameBy_x(v7, pPlayer->uExpressionTimePassed);
+ if (pPlayer->field_1AA2 != v8->uTextureID - 1 || v22 )
+ {
+ pPlayer->field_1AA2 = v8->uTextureID - 1;
+ v4 = (Texture *)pTextures_PlayerFaces[i][v8->uTextureID];
goto LABEL_27;
}
LABEL_50:
- v21 += 56;
- v3 += 6972;
- ++v2;
- if ( (signed int)v3 >= (signed int)&pParty->pHirelings[1].field_24 )
- break;
- v1 = 0;
- }
+ ;
+ }
+
if ( pParty->bTurnBasedModeOn == 1 )
{
if ( pTurnEngine->field_4 != 1 )
{
if ( (pTurnEngine->pQueue[0].uPackedID & 7) == 4 )
{
- v14 = 0;
+ //v14 = 0;
if ( pTurnEngine->uActorQueueSize > 0 )
{
- v15 = (char *)pTurnEngine->pQueue;
- do
- {
- if ( (*v15 & 7) != 4 )
+ //v15 = (char *)pTurnEngine->pQueue;
+ for (uint i = 0; i < pTurnEngine->uActorQueueSize; ++i)
+ {
+ auto pElem = pTurnEngine->pQueue + i;
+
+ if ( (pElem->uPackedID & 7) != 4 )
break;
v16 = dword_5079D0;
if ( pParty->uFlags & 0x10 )
@@ -3326,24 +3280,20 @@
v16 = dword_5079C8;
}
pRenderer->DrawTextureTransparent(
- pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[*(int *)v15 >> 3] - 4,
+ pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[pElem->uPackedID >> 3] - 4,
0x181u,
- (Texture *)(v16 != -1 ? (int)&pIcons_LOD->pTextures[v16] : 0));
- ++v14;
- v15 += 16;
- }
- while ( v14 < pTurnEngine->uActorQueueSize );
- }
- }
- }
- }
- else
- {
- v17 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing;
- v18 = (char *)pParty->pPlayers;
- do
- {
- if ( ((Player *)v18)->CanAct() && !*((short *)v18 + 3226) )
+ (Texture *)(v16 != -1 ? &pIcons_LOD->pTextures[v16] : 0));
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ for (uint i = 0; i < 4; ++i)
+ {
+ auto pPlayer = pParty->pPlayers + i;
+ if (pPlayer->CanAct() && !pPlayer->uTimeToRecovery)
{
v19 = dword_5079D0;
if ( pParty->uFlags & 0x10 )
@@ -3356,14 +3306,11 @@
v19 = dword_5079C8;
}
pRenderer->DrawTextureTransparent(
- *v17 - 4,
+ pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4,
0x181u,
- (Texture *)(v19 != -1 ? (int)&pIcons_LOD->pTextures[v19] : 0));
- }
- v18 += 6972;
- ++v17;
- }
- while ( (signed int)v18 < (signed int)pParty->pHirelings );
+ (Texture *)(v19 != -1 ? &pIcons_LOD->pTextures[v19] : 0));
+ }
+ }
}
}