mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-16 01:21:17 +00:00
- removed all direct references of AInventory::Owner and AInventory::Amount from the C++ code.
This commit is contained in:
parent
739999b5ed
commit
c0686309fc
15 changed files with 124 additions and 157 deletions
|
@ -376,8 +376,8 @@ void DBot::WhatToGet (AActor *item)
|
||||||
return;
|
return;
|
||||||
auto ammo1 = heldWeapon->PointerVar<AInventory>(NAME_Ammo1);
|
auto ammo1 = heldWeapon->PointerVar<AInventory>(NAME_Ammo1);
|
||||||
auto ammo2 = heldWeapon->PointerVar<AInventory>(NAME_Ammo2);
|
auto ammo2 = heldWeapon->PointerVar<AInventory>(NAME_Ammo2);
|
||||||
if ((ammo1 == NULL || ammo1->Amount >= ammo1->MaxAmount) &&
|
if ((ammo1 == NULL || ammo1->IntVar(NAME_Amount) >= ammo1->MaxAmount) &&
|
||||||
(ammo2 == NULL || ammo2->Amount >= ammo2->MaxAmount))
|
(ammo2 == NULL || ammo2->IntVar(NAME_Amount) >= ammo2->MaxAmount))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -389,7 +389,7 @@ void DBot::WhatToGet (AActor *item)
|
||||||
auto parent = item->GetClass();
|
auto parent = item->GetClass();
|
||||||
while (parent->ParentClass != ac) parent = static_cast<PClassActor*>(parent->ParentClass);
|
while (parent->ParentClass != ac) parent = static_cast<PClassActor*>(parent->ParentClass);
|
||||||
AInventory *holdingammo = player->mo->FindInventory(parent);
|
AInventory *holdingammo = player->mo->FindInventory(parent);
|
||||||
if (holdingammo != NULL && holdingammo->Amount >= holdingammo->MaxAmount)
|
if (holdingammo != NULL && holdingammo->IntVar(NAME_Amount) >= holdingammo->MaxAmount)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ void C_PrintInv(AActor *target)
|
||||||
{
|
{
|
||||||
Printf (" %s #%u (%d/%d)\n", item->GetClass()->TypeName.GetChars(),
|
Printf (" %s #%u (%d/%d)\n", item->GetClass()->TypeName.GetChars(),
|
||||||
item->InventoryID,
|
item->InventoryID,
|
||||||
item->Amount, item->MaxAmount);
|
item->IntVar(NAME_Amount), item->MaxAmount);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
Printf (" List count: %d\n", count);
|
Printf (" List count: %d\n", count);
|
||||||
|
|
|
@ -423,7 +423,7 @@ static bool DoSubstitution (FString &out, const char *in)
|
||||||
if (strnicmp(a, "armor", 5) == 0)
|
if (strnicmp(a, "armor", 5) == 0)
|
||||||
{
|
{
|
||||||
AInventory *armor = player->mo->FindInventory(NAME_BasicArmor);
|
AInventory *armor = player->mo->FindInventory(NAME_BasicArmor);
|
||||||
out.AppendFormat("%d", armor != NULL ? armor->Amount : 0);
|
out.AppendFormat("%d", armor != NULL ? armor->IntVar(NAME_Amount) : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (len == 9)
|
else if (len == 9)
|
||||||
|
@ -436,10 +436,10 @@ static bool DoSubstitution (FString &out, const char *in)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out.AppendFormat("%d", ammo1 != NULL ? ammo1->Amount : 0);
|
out.AppendFormat("%d", ammo1 != NULL ? ammo1->IntVar(NAME_Amount) : 0);
|
||||||
if (ammo2 != NULL)
|
if (ammo2 != NULL)
|
||||||
{
|
{
|
||||||
out.AppendFormat("/%d", ammo2->Amount);
|
out.AppendFormat("/%d", ammo2->IntVar(NAME_Amount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1560,7 +1560,7 @@ static int PatchAmmo (int ammoNum)
|
||||||
if (defaultAmmo != NULL)
|
if (defaultAmmo != NULL)
|
||||||
{
|
{
|
||||||
max = &defaultAmmo->MaxAmount;
|
max = &defaultAmmo->MaxAmount;
|
||||||
per = &defaultAmmo->Amount;
|
per = &defaultAmmo->IntVar(NAME_Amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1583,7 +1583,7 @@ static int PatchAmmo (int ammoNum)
|
||||||
if (ammoType != NULL)
|
if (ammoType != NULL)
|
||||||
{
|
{
|
||||||
defaultAmmo->IntVar("BackpackMaxAmount") = defaultAmmo->MaxAmount * 2;
|
defaultAmmo->IntVar("BackpackMaxAmount") = defaultAmmo->MaxAmount * 2;
|
||||||
defaultAmmo->IntVar("BackpackAmount") = defaultAmmo->Amount;
|
defaultAmmo->IntVar("BackpackAmount") = defaultAmmo->IntVar(NAME_Amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix per-ammo/max-ammo amounts for descendants of the base ammo class
|
// Fix per-ammo/max-ammo amounts for descendants of the base ammo class
|
||||||
|
@ -1600,7 +1600,7 @@ static int PatchAmmo (int ammoNum)
|
||||||
{
|
{
|
||||||
defaultAmmo = (AInventory *)GetDefaultByType (type);
|
defaultAmmo = (AInventory *)GetDefaultByType (type);
|
||||||
defaultAmmo->MaxAmount = *max;
|
defaultAmmo->MaxAmount = *max;
|
||||||
defaultAmmo->Amount = Scale (defaultAmmo->Amount, *per, oldclip);
|
defaultAmmo->IntVar(NAME_Amount) = Scale (defaultAmmo->IntVar(NAME_Amount), *per, oldclip);
|
||||||
}
|
}
|
||||||
else if (type->IsDescendantOf (NAME_Weapon))
|
else if (type->IsDescendantOf (NAME_Weapon))
|
||||||
{
|
{
|
||||||
|
@ -1684,7 +1684,7 @@ static int PatchWeapon (int weapNum)
|
||||||
AmmoType = AmmoNames[val];
|
AmmoType = AmmoNames[val];
|
||||||
if (AmmoType != nullptr)
|
if (AmmoType != nullptr)
|
||||||
{
|
{
|
||||||
info->IntVar(NAME_AmmoGive1) = ((AInventory*)GetDefaultByType(AmmoType))->Amount * 2;
|
info->IntVar(NAME_AmmoGive1) = ((AInventory*)GetDefaultByType(AmmoType))->IntVar(NAME_Amount) * 2;
|
||||||
auto &AmmoUse = info->IntVar(NAME_AmmoUse1);
|
auto &AmmoUse = info->IntVar(NAME_AmmoUse1);
|
||||||
if (AmmoUse == 0)
|
if (AmmoUse == 0)
|
||||||
{
|
{
|
||||||
|
@ -1998,14 +1998,14 @@ static int PatchMisc (int dummy)
|
||||||
health = static_cast<AInventory *> (GetDefaultByName ("Soulsphere"));
|
health = static_cast<AInventory *> (GetDefaultByName ("Soulsphere"));
|
||||||
if (health!=NULL)
|
if (health!=NULL)
|
||||||
{
|
{
|
||||||
health->Amount = deh.SoulsphereHealth;
|
health->IntVar(NAME_Amount) = deh.SoulsphereHealth;
|
||||||
health->MaxAmount = deh.MaxSoulsphere;
|
health->MaxAmount = deh.MaxSoulsphere;
|
||||||
}
|
}
|
||||||
|
|
||||||
health = static_cast<AInventory *> (GetDefaultByName ("MegasphereHealth"));
|
health = static_cast<AInventory *> (GetDefaultByName ("MegasphereHealth"));
|
||||||
if (health!=NULL)
|
if (health!=NULL)
|
||||||
{
|
{
|
||||||
health->Amount = health->MaxAmount = deh.MegasphereHealth;
|
health->IntVar(NAME_Amount) = health->MaxAmount = deh.MegasphereHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
APlayerPawn *player = static_cast<APlayerPawn *> (GetDefaultByName ("DoomPlayer"));
|
APlayerPawn *player = static_cast<APlayerPawn *> (GetDefaultByName ("DoomPlayer"));
|
||||||
|
|
|
@ -2420,28 +2420,11 @@ void FParser::SF_IsPlayerObj(void)
|
||||||
//
|
//
|
||||||
// CheckInventory
|
// CheckInventory
|
||||||
//
|
//
|
||||||
// Returns how much of a particular item an actor has.
|
// forward to the ACS equivalent.
|
||||||
//
|
//
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
static int FS_CheckInventory (AActor *activator, const char *type)
|
int CheckInventory(AActor *activator, const char *type, bool max = false);
|
||||||
{
|
|
||||||
if (activator == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (strcmp (type, "Armor") == 0)
|
|
||||||
{
|
|
||||||
type = "BasicArmor";
|
|
||||||
}
|
|
||||||
else if (strcmp (type, "Health") == 0)
|
|
||||||
{
|
|
||||||
return activator->health;
|
|
||||||
}
|
|
||||||
|
|
||||||
PClassActor *info = PClass::FindActor (type);
|
|
||||||
AInventory *item = activator->FindInventory (info);
|
|
||||||
return item ? item->Amount : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -2474,7 +2457,7 @@ void FParser::SF_PlayerKeys(void)
|
||||||
if(t_argc == 2)
|
if(t_argc == 2)
|
||||||
{
|
{
|
||||||
t_return.type = svt_int;
|
t_return.type = svt_int;
|
||||||
t_return.value.i = FS_CheckInventory(players[playernum].mo, keyname);
|
t_return.value.i = CheckInventory(players[playernum].mo, keyname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2718,7 +2701,7 @@ void FParser::SF_CheckInventory(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
t_return.type = svt_int;
|
t_return.type = svt_int;
|
||||||
t_return.value.i = FS_CheckInventory(players[playernum].mo, stringvalue(t_argv[1]));
|
t_return.value.i = CheckInventory(players[playernum].mo, stringvalue(t_argv[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -454,7 +454,7 @@ CCMD(invquery)
|
||||||
AInventory *inv = players[consoleplayer].mo->InvSel;
|
AInventory *inv = players[consoleplayer].mo->InvSel;
|
||||||
if (inv != NULL)
|
if (inv != NULL)
|
||||||
{
|
{
|
||||||
Printf(PRINT_HIGH, "%s (%dx)\n", inv->GetTag(), inv->Amount);
|
Printf(PRINT_HIGH, "%s (%dx)\n", inv->GetTag(), inv->IntVar(NAME_Amount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1064,8 +1064,8 @@ public:
|
||||||
{
|
{
|
||||||
ammo1 = ammo2 = nullptr;
|
ammo1 = ammo2 = nullptr;
|
||||||
}
|
}
|
||||||
ammocount1 = ammo1 != nullptr ? ammo1->Amount : 0;
|
ammocount1 = ammo1 != nullptr ? ammo1->IntVar(NAME_Amount) : 0;
|
||||||
ammocount2 = ammo2 != nullptr ? ammo2->Amount : 0;
|
ammocount2 = ammo2 != nullptr ? ammo2->IntVar(NAME_Amount) : 0;
|
||||||
|
|
||||||
//prepare ammo counts
|
//prepare ammo counts
|
||||||
armor = CPlayer->mo->FindInventory(NAME_BasicArmor);
|
armor = CPlayer->mo->FindInventory(NAME_BasicArmor);
|
||||||
|
|
|
@ -257,7 +257,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
||||||
else if(type == ARMOR)
|
else if(type == ARMOR)
|
||||||
{
|
{
|
||||||
auto armor = statusBar->armor;
|
auto armor = statusBar->armor;
|
||||||
if(armor != NULL && armor->Amount != 0)
|
if(armor != NULL && armor->IntVar(NAME_Amount) != 0)
|
||||||
GetIcon(armor);
|
GetIcon(armor);
|
||||||
}
|
}
|
||||||
else if(type == WEAPONICON)
|
else if(type == WEAPONICON)
|
||||||
|
@ -600,8 +600,8 @@ class CommandDrawSwitchableImage : public CommandDrawImage
|
||||||
if(armor != NULL)
|
if(armor != NULL)
|
||||||
{
|
{
|
||||||
auto n = armor->NameVar(NAME_ArmorType).GetIndex();
|
auto n = armor->NameVar(NAME_ArmorType).GetIndex();
|
||||||
bool matches1 = n == armorType[0] && EvaluateOperation(conditionalOperator[0], conditionalValue[0], armor->Amount);
|
bool matches1 = n == armorType[0] && EvaluateOperation(conditionalOperator[0], conditionalValue[0], armor->IntVar(NAME_Amount));
|
||||||
bool matches2 = n == armorType[1] && EvaluateOperation(conditionalOperator[1], conditionalValue[1], armor->Amount);
|
bool matches2 = n == armorType[1] && EvaluateOperation(conditionalOperator[1], conditionalValue[1], armor->IntVar(NAME_Amount));
|
||||||
|
|
||||||
drawAlt = 1;
|
drawAlt = 1;
|
||||||
if(conditionAnd)
|
if(conditionAnd)
|
||||||
|
@ -620,12 +620,12 @@ class CommandDrawSwitchableImage : public CommandDrawImage
|
||||||
else //check the inventory items and draw selected sprite
|
else //check the inventory items and draw selected sprite
|
||||||
{
|
{
|
||||||
AInventory* item = statusBar->CPlayer->mo->FindInventory(inventoryItem[0]);
|
AInventory* item = statusBar->CPlayer->mo->FindInventory(inventoryItem[0]);
|
||||||
if(item == NULL || !EvaluateOperation(conditionalOperator[0], conditionalValue[0], item->Amount))
|
if(item == NULL || !EvaluateOperation(conditionalOperator[0], conditionalValue[0], item->IntVar(NAME_Amount)))
|
||||||
drawAlt = 1;
|
drawAlt = 1;
|
||||||
if(conditionAnd)
|
if(conditionAnd)
|
||||||
{
|
{
|
||||||
item = statusBar->CPlayer->mo->FindInventory(inventoryItem[1]);
|
item = statusBar->CPlayer->mo->FindInventory(inventoryItem[1]);
|
||||||
bool secondCondition = item != NULL && EvaluateOperation(conditionalOperator[1], conditionalValue[1], item->Amount);
|
bool secondCondition = item != NULL && EvaluateOperation(conditionalOperator[1], conditionalValue[1], item->IntVar(NAME_Amount));
|
||||||
if((item != NULL && secondCondition) && drawAlt == 0) //both
|
if((item != NULL && secondCondition) && drawAlt == 0) //both
|
||||||
{
|
{
|
||||||
drawAlt = 0;
|
drawAlt = 0;
|
||||||
|
@ -1329,7 +1329,7 @@ class CommandDrawNumber : public CommandDrawString
|
||||||
interpolationSpeed = script->interpolationSpeed;
|
interpolationSpeed = script->interpolationSpeed;
|
||||||
break;
|
break;
|
||||||
case ARMOR:
|
case ARMOR:
|
||||||
num = statusBar->armor != NULL ? statusBar->armor->Amount : 0;
|
num = statusBar->armor != NULL ? statusBar->armor->IntVar(NAME_Amount) : 0;
|
||||||
if(script->interpolateArmor)
|
if(script->interpolateArmor)
|
||||||
interpolationSpeed = script->armorInterpolationSpeed;
|
interpolationSpeed = script->armorInterpolationSpeed;
|
||||||
break;
|
break;
|
||||||
|
@ -1353,7 +1353,7 @@ class CommandDrawNumber : public CommandDrawString
|
||||||
{
|
{
|
||||||
AInventory* item = statusBar->CPlayer->mo->FindInventory(inventoryItem);
|
AInventory* item = statusBar->CPlayer->mo->FindInventory(inventoryItem);
|
||||||
if(item != NULL)
|
if(item != NULL)
|
||||||
num = item->Amount;
|
num = item->IntVar(NAME_Amount);
|
||||||
else
|
else
|
||||||
num = 0;
|
num = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -1451,7 +1451,7 @@ class CommandDrawNumber : public CommandDrawString
|
||||||
{
|
{
|
||||||
AInventory* item = statusBar->CPlayer->mo->FindInventory(inventoryItem);
|
AInventory* item = statusBar->CPlayer->mo->FindInventory(inventoryItem);
|
||||||
if(item != NULL)
|
if(item != NULL)
|
||||||
num = item->Amount;
|
num = item->IntVar(NAME_Amount);
|
||||||
else
|
else
|
||||||
num = 0;
|
num = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -1466,7 +1466,7 @@ class CommandDrawNumber : public CommandDrawString
|
||||||
}
|
}
|
||||||
case SELECTEDINVENTORY:
|
case SELECTEDINVENTORY:
|
||||||
if(statusBar->CPlayer->mo->InvSel != NULL)
|
if(statusBar->CPlayer->mo->InvSel != NULL)
|
||||||
num = statusBar->CPlayer->mo->InvSel->Amount;
|
num = statusBar->CPlayer->mo->InvSel->IntVar(NAME_Amount);
|
||||||
break;
|
break;
|
||||||
case ACCURACY:
|
case ACCURACY:
|
||||||
num = statusBar->CPlayer->mo->accuracy;
|
num = statusBar->CPlayer->mo->accuracy;
|
||||||
|
@ -1708,7 +1708,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
|
||||||
}
|
}
|
||||||
CommandDrawImage::Draw(block, statusBar);
|
CommandDrawImage::Draw(block, statusBar);
|
||||||
}
|
}
|
||||||
if(alwaysShowCounter || statusBar->CPlayer->mo->InvSel->Amount != 1)
|
if(alwaysShowCounter || statusBar->CPlayer->mo->InvSel->IntVar(NAME_Amount) != 1)
|
||||||
CommandDrawNumber::Draw(block, statusBar);
|
CommandDrawNumber::Draw(block, statusBar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2131,7 +2131,7 @@ class CommandDrawInventoryBar : public SBarInfoCommand
|
||||||
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgARTIBOX], rx, ry, block->XOffset(), block->YOffset(), bgalpha, block->FullScreenOffsets());
|
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgARTIBOX], rx, ry, block->XOffset(), block->YOffset(), bgalpha, block->FullScreenOffsets());
|
||||||
|
|
||||||
if(style != STYLE_Strife) //Strife draws the cursor before the icons
|
if(style != STYLE_Strife) //Strife draws the cursor before the icons
|
||||||
statusBar->DrawGraphic(TexMan(item->Icon), rx - (style == STYLE_HexenStrict ? 2 : 0), ry - (style == STYLE_HexenStrict ? 1 : 0), block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->Amount <= 0);
|
statusBar->DrawGraphic(TexMan(item->Icon), rx - (style == STYLE_HexenStrict ? 2 : 0), ry - (style == STYLE_HexenStrict ? 1 : 0), block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0);
|
||||||
if(item == statusBar->CPlayer->mo->InvSel)
|
if(item == statusBar->CPlayer->mo->InvSel)
|
||||||
{
|
{
|
||||||
if(style == STYLE_Heretic)
|
if(style == STYLE_Heretic)
|
||||||
|
@ -2146,10 +2146,10 @@ class CommandDrawInventoryBar : public SBarInfoCommand
|
||||||
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgSELECTBOX], rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgSELECTBOX], rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||||
}
|
}
|
||||||
if(style == STYLE_Strife)
|
if(style == STYLE_Strife)
|
||||||
statusBar->DrawGraphic(TexMan(item->Icon), rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->Amount <= 0);
|
statusBar->DrawGraphic(TexMan(item->Icon), rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0);
|
||||||
if(counters != NULL && (alwaysShowCounter || item->Amount != 1))
|
if(counters != NULL && (alwaysShowCounter || item->IntVar(NAME_Amount) != 1))
|
||||||
{
|
{
|
||||||
counters[i]->valueArgument = item->Amount;
|
counters[i]->valueArgument = item->IntVar(NAME_Amount);
|
||||||
counters[i]->Draw(block, statusBar);
|
counters[i]->Draw(block, statusBar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2667,7 +2667,7 @@ class CommandDrawBar : public SBarInfoCommand
|
||||||
{
|
{
|
||||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem); //max comparer
|
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem); //max comparer
|
||||||
if(item != NULL)
|
if(item != NULL)
|
||||||
max = item->Amount;
|
max = item->IntVar(NAME_Amount);
|
||||||
else
|
else
|
||||||
max = 0;
|
max = 0;
|
||||||
}
|
}
|
||||||
|
@ -2675,14 +2675,14 @@ class CommandDrawBar : public SBarInfoCommand
|
||||||
max = statusBar->CPlayer->mo->GetMaxHealth(true);
|
max = statusBar->CPlayer->mo->GetMaxHealth(true);
|
||||||
break;
|
break;
|
||||||
case ARMOR:
|
case ARMOR:
|
||||||
value = statusBar->armor != NULL ? statusBar->armor->Amount : 0;
|
value = statusBar->armor != NULL ? statusBar->armor->IntVar(NAME_Amount) : 0;
|
||||||
if(data.useMaximumConstant)
|
if(data.useMaximumConstant)
|
||||||
max = data.value;
|
max = data.value;
|
||||||
else if(data.inventoryItem != NULL)
|
else if(data.inventoryItem != NULL)
|
||||||
{
|
{
|
||||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
|
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
|
||||||
if(item != NULL)
|
if(item != NULL)
|
||||||
max = item->Amount;
|
max = item->IntVar(NAME_Amount);
|
||||||
else
|
else
|
||||||
max = 0;
|
max = 0;
|
||||||
}
|
}
|
||||||
|
@ -2714,7 +2714,7 @@ class CommandDrawBar : public SBarInfoCommand
|
||||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
|
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
|
||||||
if(item != NULL)
|
if(item != NULL)
|
||||||
{
|
{
|
||||||
value = item->Amount;
|
value = item->IntVar(NAME_Amount);
|
||||||
max = item->MaxAmount;
|
max = item->MaxAmount;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2742,7 +2742,7 @@ class CommandDrawBar : public SBarInfoCommand
|
||||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
|
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
|
||||||
if(item != NULL)
|
if(item != NULL)
|
||||||
{
|
{
|
||||||
value = item->Amount;
|
value = item->IntVar(NAME_Amount);
|
||||||
max = item->MaxAmount;
|
max = item->MaxAmount;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3178,7 +3178,7 @@ class CommandDrawGem : public SBarInfoCommand
|
||||||
}
|
}
|
||||||
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
|
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
|
||||||
{
|
{
|
||||||
goalValue = armor ? (statusBar->armor ? statusBar->armor->Amount : 0) : statusBar->CPlayer->mo->health;
|
goalValue = armor ? (statusBar->armor ? statusBar->armor->IntVar(NAME_Amount) : 0) : statusBar->CPlayer->mo->health;
|
||||||
int max = armor ? 100 : statusBar->CPlayer->mo->GetMaxHealth(true);
|
int max = armor ? 100 : statusBar->CPlayer->mo->GetMaxHealth(true);
|
||||||
if(max != 0 && goalValue > 0)
|
if(max != 0 && goalValue > 0)
|
||||||
{
|
{
|
||||||
|
@ -3318,7 +3318,7 @@ class CommandInInventory : public SBarInfoNegatableFlowControl
|
||||||
conditionAnd(false)
|
conditionAnd(false)
|
||||||
{
|
{
|
||||||
item[0] = item[1] = NULL;
|
item[0] = item[1] = NULL;
|
||||||
amount[0] = amount[1] = 0;
|
Amount[0] = Amount[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseNegatable(FScanner &sc, bool fullScreenOffsets)
|
void ParseNegatable(FScanner &sc, bool fullScreenOffsets)
|
||||||
|
@ -3337,7 +3337,7 @@ class CommandInInventory : public SBarInfoNegatableFlowControl
|
||||||
if (sc.CheckToken(','))
|
if (sc.CheckToken(','))
|
||||||
{
|
{
|
||||||
sc.MustGetNumber();
|
sc.MustGetNumber();
|
||||||
amount[i] = sc.Number;
|
Amount[i] = sc.Number;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sc.CheckToken(TK_OrOr))
|
if(sc.CheckToken(TK_OrOr))
|
||||||
|
@ -3361,8 +3361,8 @@ class CommandInInventory : public SBarInfoNegatableFlowControl
|
||||||
SBarInfoNegatableFlowControl::Tick(block, statusBar, hudChanged);
|
SBarInfoNegatableFlowControl::Tick(block, statusBar, hudChanged);
|
||||||
|
|
||||||
AInventory *invItem[2] = { statusBar->CPlayer->mo->FindInventory(item[0]), statusBar->CPlayer->mo->FindInventory(item[1]) };
|
AInventory *invItem[2] = { statusBar->CPlayer->mo->FindInventory(item[0]), statusBar->CPlayer->mo->FindInventory(item[1]) };
|
||||||
if (invItem[0] != NULL && amount[0] > 0 && invItem[0]->Amount < amount[0]) invItem[0] = NULL;
|
if (invItem[0] != NULL && Amount[0] > 0 && invItem[0]->IntVar(NAME_Amount) < Amount[0]) invItem[0] = NULL;
|
||||||
if (invItem[1] != NULL && amount[1] > 0 && invItem[1]->Amount < amount[1]) invItem[1] = NULL;
|
if (invItem[1] != NULL && Amount[1] > 0 && invItem[1]->IntVar(NAME_Amount) < Amount[1]) invItem[1] = NULL;
|
||||||
|
|
||||||
if (item[1])
|
if (item[1])
|
||||||
{
|
{
|
||||||
|
@ -3377,7 +3377,7 @@ class CommandInInventory : public SBarInfoNegatableFlowControl
|
||||||
protected:
|
protected:
|
||||||
bool conditionAnd;
|
bool conditionAnd;
|
||||||
PClassActor *item[2];
|
PClassActor *item[2];
|
||||||
int amount[2];
|
int Amount[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -3422,7 +3422,7 @@ class CommandIfHealth : public SBarInfoNegatableFlowControl
|
||||||
{
|
{
|
||||||
sc.MustGetToken(TK_IntConst);
|
sc.MustGetToken(TK_IntConst);
|
||||||
percentage = sc.CheckToken('%');
|
percentage = sc.CheckToken('%');
|
||||||
hpamount = sc.Number;
|
hpAmount = sc.Number;
|
||||||
}
|
}
|
||||||
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
|
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
|
||||||
{
|
{
|
||||||
|
@ -3430,10 +3430,10 @@ class CommandIfHealth : public SBarInfoNegatableFlowControl
|
||||||
|
|
||||||
int phealth = percentage ? statusBar->CPlayer->mo->health * 100 / statusBar->CPlayer->mo->GetMaxHealth() : statusBar->CPlayer->mo->health;
|
int phealth = percentage ? statusBar->CPlayer->mo->health * 100 / statusBar->CPlayer->mo->GetMaxHealth() : statusBar->CPlayer->mo->health;
|
||||||
|
|
||||||
SetTruth(phealth >= hpamount, block, statusBar);
|
SetTruth(phealth >= hpAmount, block, statusBar);
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
int hpamount;
|
int hpAmount;
|
||||||
bool percentage;
|
bool percentage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1818,7 +1818,7 @@ static int UseInventory (AActor *activator, const char *type)
|
||||||
//
|
//
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
static int CheckInventory (AActor *activator, const char *type, bool max)
|
int CheckInventory (AActor *activator, const char *type, bool max)
|
||||||
{
|
{
|
||||||
if (activator == NULL || type == NULL)
|
if (activator == NULL || type == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1865,7 +1865,7 @@ static int CheckInventory (AActor *activator, const char *type, bool max)
|
||||||
return ((AInventory *)GetDefaultByType(info))->MaxAmount;
|
return ((AInventory *)GetDefaultByType(info))->MaxAmount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return item ? item->Amount : 0;
|
return item ? item->IntVar(NAME_Amount) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---- Plane watchers ----//
|
//---- Plane watchers ----//
|
||||||
|
@ -5551,7 +5551,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
|
||||||
{
|
{
|
||||||
FName p(FBehavior::StaticLookupString(args[0]));
|
FName p(FBehavior::StaticLookupString(args[0]));
|
||||||
auto armor = players[args[1]].mo->FindInventory(NAME_BasicArmor);
|
auto armor = players[args[1]].mo->FindInventory(NAME_BasicArmor);
|
||||||
if (armor && armor->NameVar(NAME_ArmorType) == p) return armor->Amount;
|
if (armor && armor->NameVar(NAME_ArmorType) == p) return armor->IntVar(NAME_Amount);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -5562,7 +5562,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
|
||||||
|
|
||||||
auto equippedarmor = activator->FindInventory(NAME_BasicArmor);
|
auto equippedarmor = activator->FindInventory(NAME_BasicArmor);
|
||||||
|
|
||||||
if (equippedarmor && equippedarmor->Amount != 0)
|
if (equippedarmor && equippedarmor->IntVar(NAME_Amount) != 0)
|
||||||
{
|
{
|
||||||
switch(args[0])
|
switch(args[0])
|
||||||
{
|
{
|
||||||
|
@ -8881,7 +8881,7 @@ scriptwait:
|
||||||
if (activator)
|
if (activator)
|
||||||
{
|
{
|
||||||
auto armor = activator->FindInventory(NAME_BasicArmor);
|
auto armor = activator->FindInventory(NAME_BasicArmor);
|
||||||
PushToStack (armor ? armor->Amount : 0);
|
PushToStack (armor ? armor->IntVar(NAME_Amount) : 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -9405,7 +9405,7 @@ scriptwait:
|
||||||
if (item != NULL)
|
if (item != NULL)
|
||||||
{
|
{
|
||||||
item->MaxAmount = STACK(1);
|
item->MaxAmount = STACK(1);
|
||||||
item->Amount = 0;
|
item->IntVar(NAME_Amount) = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,38 +341,6 @@ DEFINE_ACTION_FUNCTION(AActor, GetMissileDamage)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// CountInv
|
|
||||||
//
|
|
||||||
// NON-ACTION function to return the inventory count of an item.
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(AActor, CountInv)
|
|
||||||
{
|
|
||||||
if (numret > 0)
|
|
||||||
{
|
|
||||||
assert(ret != NULL);
|
|
||||||
PARAM_SELF_PROLOGUE(AActor);
|
|
||||||
PARAM_CLASS(itemtype, AInventory);
|
|
||||||
PARAM_INT(pick_pointer);
|
|
||||||
|
|
||||||
self = COPY_AAPTR(self, pick_pointer);
|
|
||||||
if (self == NULL || itemtype == NULL)
|
|
||||||
{
|
|
||||||
ret->SetInt(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AInventory *item = self->FindInventory(itemtype);
|
|
||||||
ret->SetInt(item ? item->Amount : 0);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// GetDistance
|
// GetDistance
|
||||||
|
@ -1131,48 +1099,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_Jump)
|
||||||
ACTION_RETURN_STATE(NULL);
|
ACTION_RETURN_STATE(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// State jump function
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(AActor, CheckInventory)
|
|
||||||
{
|
|
||||||
PARAM_SELF_PROLOGUE(AActor);
|
|
||||||
PARAM_CLASS (itemtype, AInventory);
|
|
||||||
PARAM_INT (itemamount);
|
|
||||||
PARAM_INT (setowner);
|
|
||||||
|
|
||||||
if (itemtype == nullptr)
|
|
||||||
{
|
|
||||||
ACTION_RETURN_BOOL(false);
|
|
||||||
}
|
|
||||||
AActor *owner = COPY_AAPTR(self, setowner);
|
|
||||||
if (owner == nullptr)
|
|
||||||
{
|
|
||||||
ACTION_RETURN_BOOL(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
AInventory *item = owner->FindInventory(itemtype);
|
|
||||||
|
|
||||||
if (item)
|
|
||||||
{
|
|
||||||
if (itemamount > 0)
|
|
||||||
{
|
|
||||||
if (item->Amount >= itemamount)
|
|
||||||
{
|
|
||||||
ACTION_RETURN_BOOL(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (item->Amount >= item->MaxAmount)
|
|
||||||
{
|
|
||||||
ACTION_RETURN_BOOL(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ACTION_RETURN_BOOL(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
@ -4157,11 +4083,11 @@ static bool DoRadiusGive(AActor *self, AActor *thing, PClassActor *item, int amo
|
||||||
AInventory *gift = static_cast<AInventory *>(Spawn(item));
|
AInventory *gift = static_cast<AInventory *>(Spawn(item));
|
||||||
if (gift->IsKindOf(NAME_Health))
|
if (gift->IsKindOf(NAME_Health))
|
||||||
{
|
{
|
||||||
gift->Amount *= amount;
|
gift->IntVar(NAME_Amount) *= amount;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gift->Amount = amount;
|
gift->IntVar(NAME_Amount) = amount;
|
||||||
}
|
}
|
||||||
gift->flags |= MF_DROPPED;
|
gift->flags |= MF_DROPPED;
|
||||||
gift->ClearCounters();
|
gift->ClearCounters();
|
||||||
|
|
|
@ -619,7 +619,7 @@ static bool CheckStrifeItem (player_t *player, PClassActor *itemtype, int amount
|
||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return amount < 0 || item->Amount >= amount;
|
return amount < 0 || item->IntVar(NAME_Amount) >= amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
|
@ -636,7 +636,7 @@ DEFINE_ACTION_FUNCTION(AActor, InStateSequence)
|
||||||
bool AActor::IsMapActor()
|
bool AActor::IsMapActor()
|
||||||
{
|
{
|
||||||
// [SP] Don't remove owned inventory objects.
|
// [SP] Don't remove owned inventory objects.
|
||||||
return (!IsKindOf(NAME_Inventory) || static_cast<AInventory *>(this)->Owner == nullptr);
|
return (!IsKindOf(NAME_Inventory) || GC::ReadBarrier(PointerVar<AActor>(NAME_Owner)) == nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -797,7 +797,7 @@ void AActor::DestroyAllInventory ()
|
||||||
toDelete.Push(inv);
|
toDelete.Push(inv);
|
||||||
AInventory *item = inv->Inventory;
|
AInventory *item = inv->Inventory;
|
||||||
inv->Inventory = nullptr;
|
inv->Inventory = nullptr;
|
||||||
inv->Owner = nullptr;
|
inv->PointerVar<AActor>(NAME_Owner) = nullptr;
|
||||||
inv = item;
|
inv = item;
|
||||||
}
|
}
|
||||||
for (auto p : toDelete)
|
for (auto p : toDelete)
|
||||||
|
@ -1020,9 +1020,9 @@ void AActor::ObtainInventory (AActor *other)
|
||||||
}
|
}
|
||||||
|
|
||||||
AInventory *item = Inventory;
|
AInventory *item = Inventory;
|
||||||
while (item != NULL)
|
while (item != nullptr)
|
||||||
{
|
{
|
||||||
item->Owner = this;
|
item->PointerVar<AActor>(NAME_Owner) = this;
|
||||||
item = item->Inventory;
|
item = item->Inventory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3802,7 +3802,7 @@ void AActor::Tick ()
|
||||||
// by the order in the inventory, not the order in the thinker table
|
// by the order in the inventory, not the order in the thinker table
|
||||||
AInventory *item = Inventory;
|
AInventory *item = Inventory;
|
||||||
|
|
||||||
while (item != NULL && item->Owner == this)
|
while (item != NULL)
|
||||||
{
|
{
|
||||||
IFVIRTUALPTR(item, AInventory, DoEffect)
|
IFVIRTUALPTR(item, AInventory, DoEffect)
|
||||||
{
|
{
|
||||||
|
|
|
@ -620,7 +620,7 @@ class Actor : Thinker native
|
||||||
native clearscope double Distance3DSquared(Actor other) const;
|
native clearscope double Distance3DSquared(Actor other) const;
|
||||||
native void SetOrigin(vector3 newpos, bool moving);
|
native void SetOrigin(vector3 newpos, bool moving);
|
||||||
native void SetXYZ(vector3 newpos);
|
native void SetXYZ(vector3 newpos);
|
||||||
native Actor GetPointer(int aaptr);
|
native clearscope Actor GetPointer(int aaptr);
|
||||||
native double BulletSlope(out FTranslatedLineTarget pLineTarget = null, int aimflags = 0);
|
native double BulletSlope(out FTranslatedLineTarget pLineTarget = null, int aimflags = 0);
|
||||||
native void CheckFakeFloorTriggers (double oldz, bool oldz_has_viewheight = false);
|
native void CheckFakeFloorTriggers (double oldz, bool oldz_has_viewheight = false);
|
||||||
|
|
||||||
|
@ -750,7 +750,6 @@ class Actor : Thinker native
|
||||||
native bool Warp(Actor dest, double xofs = 0, double yofs = 0, double zofs = 0, double angle = 0, int flags = 0, double heightoffset = 0, double radiusoffset = 0, double pitch = 0);
|
native bool Warp(Actor dest, double xofs = 0, double yofs = 0, double zofs = 0, double angle = 0, int flags = 0, double heightoffset = 0, double radiusoffset = 0, double pitch = 0);
|
||||||
|
|
||||||
// DECORATE compatible functions
|
// DECORATE compatible functions
|
||||||
native clearscope int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT) const;
|
|
||||||
native double GetDistance(bool checkz, int ptr = AAPTR_TARGET) const;
|
native double GetDistance(bool checkz, int ptr = AAPTR_TARGET) const;
|
||||||
native double GetAngle(int flags, int ptr = AAPTR_TARGET) const;
|
native double GetAngle(int flags, int ptr = AAPTR_TARGET) const;
|
||||||
native double GetZAt(double px = 0, double py = 0, double angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT);
|
native double GetZAt(double px = 0, double py = 0, double angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT);
|
||||||
|
|
|
@ -91,8 +91,6 @@ extend class Actor
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
native bool CheckInventory(class<Inventory> itemtype, int itemamount, int owner = AAPTR_DEFAULT);
|
|
||||||
|
|
||||||
action state A_JumpIfInventory(class<Inventory> itemtype, int itemamount, statelabel label, int owner = AAPTR_DEFAULT)
|
action state A_JumpIfInventory(class<Inventory> itemtype, int itemamount, statelabel label, int owner = AAPTR_DEFAULT)
|
||||||
{
|
{
|
||||||
return CheckInventory(itemtype, itemamount, owner)? ResolveState(label) : null;
|
return CheckInventory(itemtype, itemamount, owner)? ResolveState(label) : null;
|
||||||
|
|
|
@ -671,6 +671,67 @@ extend class Actor
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// CountInv
|
||||||
|
//
|
||||||
|
// NON-ACTION function to return the inventory count of an item.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
clearscope int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT) const
|
||||||
|
{
|
||||||
|
let realself = GetPointer(ptr_select);
|
||||||
|
if (realself == NULL || itemtype == NULL)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let item = realself.FindInventory(itemtype);
|
||||||
|
return item ? item.Amount : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// State jump function
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
bool CheckInventory(class<Inventory> itemtype, int itemamount, int owner = AAPTR_DEFAULT)
|
||||||
|
{
|
||||||
|
if (itemtype == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let owner = GetPointer(owner);
|
||||||
|
if (owner == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let item = owner.FindInventory(itemtype);
|
||||||
|
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
if (itemamount > 0)
|
||||||
|
{
|
||||||
|
if (item.Amount >= itemamount)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (item.Amount >= item.MaxAmount)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue