mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 04:20:34 +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
a5b7250f3b
commit
ff21cee842
1 changed files with 32 additions and 19 deletions
|
@ -1026,6 +1026,29 @@ public:
|
|||
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)
|
||||
{
|
||||
int hud = STBAR_NORMAL;
|
||||
|
@ -1050,25 +1073,7 @@ public:
|
|||
}
|
||||
wrapper->ForceHUDScale(script->huds[hud]->ForceScaled());
|
||||
|
||||
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);
|
||||
SetReferences();
|
||||
|
||||
if(state != HUD_AltHud)
|
||||
{
|
||||
|
@ -1123,6 +1128,9 @@ public:
|
|||
else
|
||||
lastPopup = NULL;
|
||||
|
||||
// These may not live any longer than beyond here!
|
||||
ammo1 = ammo2 = nullptr;
|
||||
armor = nullptr;
|
||||
}
|
||||
|
||||
void _NewGame ()
|
||||
|
@ -1139,6 +1147,7 @@ public:
|
|||
|
||||
void _Tick ()
|
||||
{
|
||||
SetReferences();
|
||||
if(currentPopup != DBaseStatusBar::POP_None)
|
||||
{
|
||||
script->popups[currentPopup-1].tick();
|
||||
|
@ -1156,6 +1165,10 @@ public:
|
|||
script->huds[lastHud]->Tick(NULL, this, false);
|
||||
if(lastInventoryBar != NULL && CPlayer->inventorytics > 0)
|
||||
lastInventoryBar->Tick(NULL, this, false);
|
||||
|
||||
// These may not live any longer than beyond here!
|
||||
ammo1 = ammo2 = nullptr;
|
||||
armor = nullptr;
|
||||
}
|
||||
|
||||
void _ShowPop(int popnum)
|
||||
|
|
Loading…
Reference in a new issue