mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-01 00:21:35 +00:00
- fixed: SBARInfo's Tick function was using actor references from its last Draw operation.
Between these two calls these can change so these need to be retrieved each time either Draw or Tick are called.
This commit is contained in:
parent
13d07e7912
commit
b3cff43be3
1 changed files with 32 additions and 19 deletions
|
@ -1016,6 +1016,29 @@ public:
|
||||||
CPlayer = player;
|
CPlayer = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetReferences()
|
||||||
|
{
|
||||||
|
if (CPlayer->ReadyWeapon != nullptr)
|
||||||
|
{
|
||||||
|
ammo1 = CPlayer->ReadyWeapon->PointerVar<AActor>(NAME_Ammo1);
|
||||||
|
ammo2 = CPlayer->ReadyWeapon->PointerVar<AActor>(NAME_Ammo2);
|
||||||
|
if (ammo1 == nullptr)
|
||||||
|
{
|
||||||
|
ammo1 = ammo2;
|
||||||
|
ammo2 = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ammo1 = ammo2 = nullptr;
|
||||||
|
}
|
||||||
|
ammocount1 = ammo1 != nullptr ? ammo1->IntVar(NAME_Amount) : 0;
|
||||||
|
ammocount2 = ammo2 != nullptr ? ammo2->IntVar(NAME_Amount) : 0;
|
||||||
|
|
||||||
|
//prepare ammo counts
|
||||||
|
armor = CPlayer->mo->FindInventory(NAME_BasicArmor);
|
||||||
|
}
|
||||||
|
|
||||||
void _Draw (EHudState state)
|
void _Draw (EHudState state)
|
||||||
{
|
{
|
||||||
int hud = STBAR_NORMAL;
|
int hud = STBAR_NORMAL;
|
||||||
|
@ -1040,25 +1063,7 @@ public:
|
||||||
}
|
}
|
||||||
wrapper->ForceHUDScale(script->huds[hud]->ForceScaled());
|
wrapper->ForceHUDScale(script->huds[hud]->ForceScaled());
|
||||||
|
|
||||||
if (CPlayer->ReadyWeapon != nullptr)
|
SetReferences();
|
||||||
{
|
|
||||||
ammo1 = CPlayer->ReadyWeapon->PointerVar<AActor>(NAME_Ammo1);
|
|
||||||
ammo2 = CPlayer->ReadyWeapon->PointerVar<AActor>(NAME_Ammo2);
|
|
||||||
if (ammo1 == nullptr)
|
|
||||||
{
|
|
||||||
ammo1 = ammo2;
|
|
||||||
ammo2 = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ammo1 = ammo2 = nullptr;
|
|
||||||
}
|
|
||||||
ammocount1 = ammo1 != nullptr ? ammo1->IntVar(NAME_Amount) : 0;
|
|
||||||
ammocount2 = ammo2 != nullptr ? ammo2->IntVar(NAME_Amount) : 0;
|
|
||||||
|
|
||||||
//prepare ammo counts
|
|
||||||
armor = CPlayer->mo->FindInventory(NAME_BasicArmor);
|
|
||||||
|
|
||||||
if(state != HUD_AltHud)
|
if(state != HUD_AltHud)
|
||||||
{
|
{
|
||||||
|
@ -1113,6 +1118,9 @@ public:
|
||||||
else
|
else
|
||||||
lastPopup = NULL;
|
lastPopup = NULL;
|
||||||
|
|
||||||
|
// These may not live any longer than beyond here!
|
||||||
|
ammo1 = ammo2 = nullptr;
|
||||||
|
armor = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _NewGame ()
|
void _NewGame ()
|
||||||
|
@ -1129,6 +1137,7 @@ public:
|
||||||
|
|
||||||
void _Tick ()
|
void _Tick ()
|
||||||
{
|
{
|
||||||
|
SetReferences();
|
||||||
if(currentPopup != DBaseStatusBar::POP_None)
|
if(currentPopup != DBaseStatusBar::POP_None)
|
||||||
{
|
{
|
||||||
script->popups[currentPopup-1].tick();
|
script->popups[currentPopup-1].tick();
|
||||||
|
@ -1146,6 +1155,10 @@ public:
|
||||||
script->huds[lastHud]->Tick(NULL, this, false);
|
script->huds[lastHud]->Tick(NULL, this, false);
|
||||||
if(lastInventoryBar != NULL && CPlayer->inventorytics > 0)
|
if(lastInventoryBar != NULL && CPlayer->inventorytics > 0)
|
||||||
lastInventoryBar->Tick(NULL, this, false);
|
lastInventoryBar->Tick(NULL, this, false);
|
||||||
|
|
||||||
|
// These may not live any longer than beyond here!
|
||||||
|
ammo1 = ammo2 = nullptr;
|
||||||
|
armor = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _ShowPop(int popnum)
|
void _ShowPop(int popnum)
|
||||||
|
|
Loading…
Reference in a new issue