- scriptified the remains of AAmmo.

This commit is contained in:
Christoph Oelckers 2017-01-18 14:18:17 +01:00
commit d9fd2d509f
22 changed files with 122 additions and 245 deletions

View file

@ -294,7 +294,6 @@ int FindMugShotStateIndex(FName state);
// Base Status Bar ----------------------------------------------------------
class FTexture;
class AAmmo;
enum
{
@ -395,7 +394,7 @@ protected:
void RefreshBackground () const;
void GetCurrentAmmo (AAmmo *&ammo1, AAmmo *&ammo2, int &ammocount1, int &ammocount2) const;
void GetCurrentAmmo (AInventory *&ammo1, AInventory *&ammo2, int &ammocount1, int &ammocount2) const;
public:
AInventory *ValidateInvFirst (int numVisible) const;

View file

@ -58,7 +58,6 @@
#include "gstrings.h"
#include "version.h"
#include "cmdlib.h"
#include "a_ammo.h"
#include "g_levellocals.h"
#define ARTIFLASH_OFFSET (statusBar->invBarOffset+6)
@ -1517,7 +1516,7 @@ public:
return translationtables[TRANSLATION_Players][int(CPlayer - players)];
}
AAmmo *ammo1, *ammo2;
AInventory *ammo1, *ammo2;
int ammocount1, ammocount2;
ABasicArmor *armor;
FImageCollection Images;

View file

@ -244,31 +244,31 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
texture = TexMan(statusBar->CPlayer->mo->ScoreIcon);
else if(type == AMMO1)
{
AAmmo *ammo = statusBar->ammo1;
auto ammo = statusBar->ammo1;
if(ammo != NULL)
GetIcon(ammo);
}
else if(type == AMMO2)
{
AAmmo *ammo = statusBar->ammo2;
auto ammo = statusBar->ammo2;
if(ammo != NULL)
GetIcon(ammo);
}
else if(type == ARMOR)
{
ABasicArmor *armor = statusBar->armor;
auto armor = statusBar->armor;
if(armor != NULL && armor->Amount != 0)
GetIcon(armor);
}
else if(type == WEAPONICON)
{
AWeapon *weapon = statusBar->CPlayer->ReadyWeapon;
auto weapon = statusBar->CPlayer->ReadyWeapon;
if(weapon != NULL)
GetIcon(weapon);
}
else if(type == SIGIL)
{
AInventory *item = statusBar->CPlayer->mo->FindInventory(PClass::FindActor(NAME_Sigil));
auto item = statusBar->CPlayer->mo->FindInventory(PClass::FindActor(NAME_Sigil));
if (item != NULL)
texture = TexMan(item->Icon);
}
@ -1076,10 +1076,10 @@ class CommandDrawNumber : public CommandDrawString
if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindActor(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
if(inventoryItem == NULL || !PClass::FindActor(NAME_Ammo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
{
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
inventoryItem = RUNTIME_CLASS(AAmmo);
inventoryItem = PClass::FindActor(NAME_Ammo);
}
if(parenthesized) sc.MustGetToken(')');
@ -1092,10 +1092,10 @@ class CommandDrawNumber : public CommandDrawString
if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindActor(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
if(inventoryItem == NULL || !PClass::FindActor(NAME_Ammo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
{
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
inventoryItem = RUNTIME_CLASS(AAmmo);
inventoryItem = PClass::FindActor(NAME_Ammo);
}
if(parenthesized) sc.MustGetToken(')');
@ -1435,7 +1435,7 @@ class CommandDrawNumber : public CommandDrawString
{
// num = statusBar.CPlayer.mo.GetEffectTicsForItem(inventoryItem) / TICRATE + 1;
static VMFunction *func = nullptr;
if (func == nullptr) func = static_cast<PFunction*>(RUNTIME_CLASS(APlayerPawn)->Symbols.FindSymbol("GetEffectTicsForItem", false))->Variants[0].Implementation;
if (func == nullptr) func = PClass::FindFunction(NAME_PlayerPawn, "GetEffectTicsForItem");
VMValue params[] = { statusBar->CPlayer->mo, inventoryItem };
int retv;
VMReturn ret(&retv);
@ -2630,10 +2630,10 @@ class CommandDrawBar : public SBarInfoCommand
sc.MustGetToken(TK_Identifier);
type = AMMO;
data.inventoryItem = PClass::FindActor(sc.String);
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(data.inventoryItem)) //must be a kind of ammo
if(data.inventoryItem == NULL || !PClass::FindActor(NAME_Ammo)->IsAncestorOf(data.inventoryItem)) //must be a kind of ammo
{
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
data.inventoryItem = RUNTIME_CLASS(AAmmo);
data.inventoryItem = PClass::FindActor(NAME_Ammo);
}
if(parenthesized) sc.MustGetToken(')');
@ -2825,8 +2825,10 @@ class CommandDrawBar : public SBarInfoCommand
break;
case POWERUPTIME:
{
// [value, max] = statusBar.CPlayer.mo.GetEffectTicsForItem(inventoryItem);
// value++; max++;
static VMFunction *func = nullptr;
if (func == nullptr) func = static_cast<PFunction*>(RUNTIME_CLASS(APlayerPawn)->Symbols.FindSymbol("GetEffectTicsForItem", false))->Variants[0].Implementation;
if (func == nullptr) func = PClass::FindFunction(NAME_PlayerPawn, "GetEffectTicsForItem");
VMValue params[] = { statusBar->CPlayer->mo, data.inventoryItem };
VMReturn ret[2];
int ival;
@ -3312,10 +3314,10 @@ class CommandWeaponAmmo : public SBarInfoNegatableFlowControl
for(int i = 0;i < 2;i++)
{
ammo[i] = PClass::FindClass(sc.String);
if(ammo[i] == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(ammo[i])) //must be a kind of ammo
if(ammo[i] == NULL || !PClass::FindActor(NAME_Ammo)->IsAncestorOf(ammo[i])) //must be a kind of ammo
{
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
ammo[i] = RUNTIME_CLASS(AAmmo);
ammo[i] = PClass::FindActor(NAME_Ammo);
}
if(sc.CheckToken(TK_OrOr))

View file

@ -44,7 +44,6 @@
#include "w_wad.h"
#include "a_keys.h"
#include "a_armor.h"
#include "a_ammo.h"
#include "sbar.h"
#include "sc_man.h"
#include "templates.h"
@ -527,7 +526,7 @@ static void AddAmmoToList(AWeapon * weapdef)
PClassInventory * ti = i==0? weapdef->AmmoType1 : weapdef->AmmoType2;
if (ti)
{
AAmmo * ammodef=(AAmmo*)GetDefaultByType(ti);
auto ammodef=(AInventory*)GetDefaultByType(ti);
if (ammodef && !(ammodef->ItemFlags&IF_INVBAR))
{
@ -561,9 +560,9 @@ static void GetAmmoTextLengths(player_t *CPlayer, int& ammocur, int& ammomax)
{
for (auto type : orderedammos)
{
AAmmo * ammoitem = static_cast<AAmmo*>(CPlayer->mo->FindInventory(type));
AAmmo * inv = nullptr == ammoitem
? static_cast<AAmmo*>(GetDefaultByType(type))
auto ammoitem = CPlayer->mo->FindInventory(type);
auto inv = nullptr == ammoitem
? static_cast<AInventory*>(GetDefaultByType(type))
: ammoitem;
assert(nullptr != inv);
@ -648,9 +647,9 @@ static int DrawAmmo(player_t *CPlayer, int x, int y)
{
PClassInventory * type = orderedammos[i];
AAmmo * ammoitem = (AAmmo*)CPlayer->mo->FindInventory(type);
auto ammoitem = CPlayer->mo->FindInventory(type);
AAmmo * inv = ammoitem? ammoitem : (AAmmo*)GetDefaultByType(orderedammos[i]);
auto inv = ammoitem? ammoitem : (AInventory*)GetDefaultByType(orderedammos[i]);
FTextureID AltIcon = GetHUDIcon(type);
FTextureID icon = !AltIcon.isNull()? AltIcon : inv->Icon;
if (!icon.isValid()) continue;

View file

@ -1794,7 +1794,7 @@ AInventory *DBaseStatusBar::ValidateInvFirst (int numVisible) const
//
//============================================================================
void DBaseStatusBar::GetCurrentAmmo (AAmmo *&ammo1, AAmmo *&ammo2, int &ammocount1, int &ammocount2) const
void DBaseStatusBar::GetCurrentAmmo (AInventory *&ammo1, AInventory *&ammo2, int &ammocount1, int &ammocount2) const
{
if (CPlayer->ReadyWeapon != NULL)
{