- started removing literal references of AInventory, so far only simple stuff.

This commit is contained in:
Christoph Oelckers 2018-12-04 00:41:39 +01:00
parent 99a87f62b6
commit 3d28006eda
13 changed files with 48 additions and 50 deletions

View File

@ -290,7 +290,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
if (r < 128)
{
TThinkerIterator<AInventory> it (MAX_STATNUM+1, bglobal.firstthing);
AInventory *item = it.Next();
auto item = it.Next();
if (item != NULL || (item = it.Next()) != NULL)
{
@ -369,8 +369,8 @@ void DBot::WhatToGet (AActor *item)
{
if (!weapgiveammo)
return;
auto ammo1 = heldWeapon->PointerVar<AInventory>(NAME_Ammo1);
auto ammo2 = heldWeapon->PointerVar<AInventory>(NAME_Ammo2);
auto ammo1 = heldWeapon->PointerVar<AActor>(NAME_Ammo1);
auto ammo2 = heldWeapon->PointerVar<AActor>(NAME_Ammo2);
if ((ammo1 == NULL || ammo1->IntVar(NAME_Amount) >= ammo1->IntVar(NAME_MaxAmount)) &&
(ammo2 == NULL || ammo2->IntVar(NAME_Amount) >= ammo2->IntVar(NAME_MaxAmount)))
{

View File

@ -375,8 +375,8 @@ static bool DoSubstitution (FString &out, const char *in)
{
player_t *player = &players[consoleplayer];
auto weapon = player->ReadyWeapon;
auto ammo1 = weapon ? weapon->PointerVar<AInventory>(NAME_Ammo1) : nullptr;
auto ammo2 = weapon ? weapon->PointerVar<AInventory>(NAME_Ammo2) : nullptr;
auto ammo1 = weapon ? weapon->PointerVar<AActor>(NAME_Ammo1) : nullptr;
auto ammo2 = weapon ? weapon->PointerVar<AActor>(NAME_Ammo2) : nullptr;
const char *a, *b;
a = in;
@ -415,7 +415,7 @@ static bool DoSubstitution (FString &out, const char *in)
{
if (strnicmp(a, "armor", 5) == 0)
{
AInventory *armor = player->mo->FindInventory(NAME_BasicArmor);
auto armor = player->mo->FindInventory(NAME_BasicArmor);
out.AppendFormat("%d", armor != NULL ? armor->IntVar(NAME_Amount) : 0);
}
}

View File

@ -1673,7 +1673,7 @@ static int PatchWeapon (int weapNum)
AmmoType = AmmoNames[val];
if (AmmoType != nullptr)
{
info->IntVar(NAME_AmmoGive1) = ((AInventory*)GetDefaultByType(AmmoType))->IntVar(NAME_Amount) * 2;
info->IntVar(NAME_AmmoGive1) = GetDefaultByType(AmmoType)->IntVar(NAME_Amount) * 2;
auto &AmmoUse = info->IntVar(NAME_AmmoUse1);
if (AmmoUse == 0)
{
@ -1977,21 +1977,20 @@ static int PatchMisc (int dummy)
barmor->IntVar("MaxSaveAmount") = deh.MaxArmor;
}
AInventory *health;
health = static_cast<AInventory *> (GetDefaultByName ("HealthBonus"));
auto health = GetDefaultByName ("HealthBonus");
if (health!=NULL)
{
health->IntVar(NAME_MaxAmount) = 2 * deh.MaxHealth;
}
health = static_cast<AInventory *> (GetDefaultByName ("Soulsphere"));
health = GetDefaultByName ("Soulsphere");
if (health!=NULL)
{
health->IntVar(NAME_Amount) = deh.SoulsphereHealth;
health->IntVar(NAME_MaxAmount) = deh.MaxSoulsphere;
}
health = static_cast<AInventory *> (GetDefaultByName ("MegasphereHealth"));
health = GetDefaultByName ("MegasphereHealth");
if (health!=NULL)
{
health->IntVar(NAME_Amount) = health->IntVar(NAME_MaxAmount) = deh.MegasphereHealth;
@ -3067,8 +3066,8 @@ void FinishDehPatch ()
if (!type->IsDescendantOf(NAME_Inventory))
{
// If this is a hacked non-inventory item we must also copy AInventory's special states
statedef.AddStateDefines(RUNTIME_CLASS(AInventory)->GetStateLabels());
// If this is a hacked non-inventory item we must also copy Inventory's special states
statedef.AddStateDefines(PClass::FindActor(NAME_Inventory)->GetStateLabels());
}
statedef.InstallStates(subclass, defaults2);
@ -3111,7 +3110,7 @@ void FinishDehPatch ()
auto wcls = PClass::FindActor(NAME_Weapon);
for(unsigned i = 0; i < WeaponNames.Size(); i++)
{
AInventory *weap = (AInventory*)GetDefaultByType(WeaponNames[i]);
auto weap = GetDefaultByType(WeaponNames[i]);
bool found = false;
if (weap->flags6 & MF6_INTRYMOVE)
{
@ -3163,7 +3162,7 @@ void FinishDehPatch ()
DEFINE_ACTION_FUNCTION(ADehackedPickup, DetermineType)
{
PARAM_SELF_PROLOGUE(AInventory);
PARAM_SELF_PROLOGUE(AActor);
// Look at the actor's current sprite to determine what kind of
// item to pretend to me.

View File

@ -2249,11 +2249,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_INVUSEALL:
if (gamestate == GS_LEVEL && !paused)
{
AInventory *item = players[player].mo->Inventory;
auto item = players[player].mo->Inventory;
auto pitype = PClass::FindActor(NAME_PuzzleItem);
while (item != NULL)
{
AInventory *next = item->Inventory;
auto next = item->Inventory;
IFVIRTUALPTR(item, AInventory, UseAll)
{
VMValue param[] = { item, players[player].mo };
@ -2275,7 +2275,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
if (gamestate == GS_LEVEL && !paused
&& players[player].playerstate != PST_DEAD)
{
AInventory *item = players[player].mo->Inventory;
auto item = players[player].mo->Inventory;
while (item != NULL && item->InventoryID != which)
{
item = item->Inventory;

View File

@ -508,7 +508,7 @@ CCMD (select)
{
if (argv.argc() > 1)
{
AInventory *item = who->FindInventory(argv[1]);
auto item = who->FindInventory(argv[1]);
if (item != NULL)
{
who->InvSel = item;

View File

@ -556,7 +556,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
bool found2 = false;
drawAlt = 1;
for(AInventory *item = statusBar->CPlayer->mo->Inventory;item != NULL;item = item->Inventory)
for(auto item = statusBar->CPlayer->mo->Inventory;item != NULL;item = item->Inventory)
{
if(item->IsKindOf(NAME_Key))
{
@ -1208,7 +1208,7 @@ class CommandDrawNumber : public CommandDrawString
if (inventoryItem == NULL || !inventoryItem->IsDescendantOf(NAME_Inventory))
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
inventoryItem = RUNTIME_CLASS(AInventory);
inventoryItem = PClass::FindActor(NAME_Inventory);
}
}
sc.MustGetToken(',');
@ -1476,7 +1476,7 @@ class CommandDrawNumber : public CommandDrawString
break;
case KEYS:
num = 0;
for(AInventory *item = statusBar->CPlayer->mo->Inventory;item != NULL;item = item->Inventory)
for(auto item = statusBar->CPlayer->mo->Inventory;item != NULL;item = item->Inventory)
{
if(item->IsKindOf(NAME_Key))
num++;
@ -2351,7 +2351,7 @@ class CommandDrawKeyBar : public SBarInfoCommand
void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar)
{
AInventory *item = statusBar->CPlayer->mo->Inventory;
auto item = statusBar->CPlayer->mo->Inventory;
if(item == NULL)
return;
int slotOffset = 0;
@ -2603,7 +2603,7 @@ class CommandDrawBar : public SBarInfoCommand
if(data.inventoryItem == NULL || !data.inventoryItem->IsDescendantOf(NAME_Inventory))
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
data.inventoryItem = RUNTIME_CLASS(AInventory);
data.inventoryItem = PClass::FindActor(NAME_Inventory);
}
}
sc.MustGetToken(',');
@ -2665,7 +2665,7 @@ class CommandDrawBar : public SBarInfoCommand
max = data.value;
else if(data.inventoryItem != NULL)
{
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem); //max comparer
auto item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem); //max comparer
if(item != NULL)
max = item->IntVar(NAME_Amount);
else
@ -2680,7 +2680,7 @@ class CommandDrawBar : public SBarInfoCommand
max = data.value;
else if(data.inventoryItem != NULL)
{
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
auto item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
if(item != NULL)
max = item->IntVar(NAME_Amount);
else
@ -2711,7 +2711,7 @@ class CommandDrawBar : public SBarInfoCommand
break;
case AMMO:
{
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
auto item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
if(item != NULL)
{
value = item->IntVar(NAME_Amount);
@ -2739,7 +2739,7 @@ class CommandDrawBar : public SBarInfoCommand
break;
case INVENTORY:
{
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
auto item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
if(item != NULL)
{
value = item->IntVar(NAME_Amount);
@ -2825,7 +2825,7 @@ class CommandDrawBar : public SBarInfoCommand
if(data.inventoryItem == NULL || !data.inventoryItem->IsDescendantOf(NAME_Inventory)) //must be a kind of inventory
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
data.inventoryItem = RUNTIME_CLASS(AInventory);
data.inventoryItem = PClass::FindActor(NAME_Inventory);
}
}
else if(extendedSyntax && sc.CheckToken(TK_IntConst))
@ -3331,7 +3331,7 @@ class CommandInInventory : public SBarInfoNegatableFlowControl
if (item[i] == NULL || !item[i]->IsDescendantOf(NAME_Inventory)) //must be a kind of ammo
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
item[i] = RUNTIME_CLASS(AInventory);
item[i] = PClass::FindActor(NAME_Inventory);
}
if (sc.CheckToken(','))

View File

@ -1733,7 +1733,7 @@ void P_WriteACSVars(FSerializer &arc)
static bool DoUseInv (AActor *actor, PClassActor *info)
{
AInventory *item = actor->FindInventory (info);
auto item = actor->FindInventory (info);
if (item != NULL)
{
player_t* const player = actor->player;
@ -1837,7 +1837,7 @@ int CheckInventory (AActor *activator, const char *type, bool max)
return 0;
}
AInventory *item = activator->FindInventory (info);
auto item = activator->FindInventory (info);
if (max)
{
@ -9357,7 +9357,7 @@ scriptwait:
}
else
{
STACK(1) = ((AInventory *)GetDefaultByType (type))->IntVar(NAME_MaxAmount);
STACK(1) = GetDefaultByType (type)->IntVar(NAME_MaxAmount);
}
}
else

View File

@ -2114,7 +2114,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DropInventory)
if (drop)
{
AInventory *inv = self->FindInventory(drop);
auto inv = self->FindInventory(drop);
if (inv)
{
self->DropInventory(inv, amount);

View File

@ -963,7 +963,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
if (takestuff)
{
AInventory *item = static_cast<AInventory *>(Spawn(reply->GiveType));
auto item = static_cast<AInventory *>(Spawn(reply->GiveType));
// Items given here should not count as items!
item->ClearCounters();
if (item->GetClass()->TypeName == NAME_FlameThrower)

View File

@ -324,7 +324,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
//flags &= ~MF_INVINCIBLE;
// [RH] Notify this actor's items.
for (AInventory *item = Inventory; item != NULL; )
for (auto item = Inventory; item != NULL; )
{
AInventory *next = item->Inventory;
IFVIRTUALPTR(item, AInventory, OwnerDied)

View File

@ -2961,7 +2961,7 @@ FUNC(LS_SetPlayerProperty)
{ // Take power from activator
if (power != 4)
{
AInventory *item = it->FindInventory(powers[power], true);
auto item = it->FindInventory(powers[power], true);
if (item != NULL)
{
item->Destroy ();
@ -3001,7 +3001,7 @@ FUNC(LS_SetPlayerProperty)
{ // Take power
if (power != 4)
{
AInventory *item = players[i].mo->FindInventory (PClass::FindActor(powers[power]));
auto item = players[i].mo->FindInventory (PClass::FindActor(powers[power]));
if (item != NULL)
{
item->Destroy ();

View File

@ -781,7 +781,7 @@ void AActor::DestroyAllInventory ()
while (inv != nullptr)
{
toDelete.Push(inv);
AInventory *item = inv->Inventory;
auto item = inv->Inventory;
inv->Inventory = nullptr;
inv->PointerVar<AActor>(NAME_Owner) = nullptr;
inv = item;
@ -902,18 +902,17 @@ DEFINE_ACTION_FUNCTION(AActor, FindInventory)
AInventory *AActor::GiveInventoryType (PClassActor *type)
{
AInventory *item = NULL;
if (type != NULL)
if (type != nullptr)
{
item = static_cast<AInventory *>(Spawn (type));
auto item = static_cast<AInventory *>(Spawn (type));
if (!CallTryPickup (item, this))
{
item->Destroy ();
return NULL;
return nullptr;
}
return item;
}
return item;
return nullptr;
}
DEFINE_ACTION_FUNCTION(AActor, GiveInventoryType)
@ -1005,7 +1004,7 @@ void AActor::ObtainInventory (AActor *other)
you->InvSel = NULL;
}
AInventory *item = Inventory;
auto item = Inventory;
while (item != nullptr)
{
item->PointerVar<AActor>(NAME_Owner) = this;
@ -3451,7 +3450,7 @@ bool AActor::AdjustReflectionAngle (AActor *thing, DAngle &angle)
int AActor::AbsorbDamage(int damage, FName dmgtype)
{
for (AInventory *item = Inventory; item != nullptr; item = item->Inventory)
for (auto item = Inventory; item != nullptr; item = item->Inventory)
{
IFVIRTUALPTR(item, AInventory, AbsorbDamage)
{
@ -3467,7 +3466,7 @@ void AActor::AlterWeaponSprite(visstyle_t *vis)
int changed = 0;
TArray<AInventory *> items;
// This needs to go backwards through the items but the list has no backlinks.
for (AInventory *item = Inventory; item != nullptr; item = item->Inventory)
for (auto item = Inventory; item != nullptr; item = item->Inventory)
{
items.Push(item);
}
@ -3786,7 +3785,7 @@ void AActor::Tick ()
{
// Handle powerup effects here so that the order is controlled
// by the order in the inventory, not the order in the thinker table
AInventory *item = Inventory;
auto item = Inventory;
while (item != NULL)
{

View File

@ -95,7 +95,7 @@ void V_AddPlayerBlend (player_t *CPlayer, float blend[4], float maxinvalpha, int
int cnt;
// [RH] All powerups can affect the screen blending now
for (AInventory *item = CPlayer->mo->Inventory; item != NULL; item = item->Inventory)
for (auto item = CPlayer->mo->Inventory; item != NULL; item = item->Inventory)
{
PalEntry color = 0;