Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/raa-eruanna/qzdoom into q…
Browse files Browse the repository at this point in the history
…zdoom
  • Loading branch information
dpjudas committed Jan 19, 2017
2 parents 112085e + 9333ce1 commit e235d83
Show file tree
Hide file tree
Showing 63 changed files with 1,346 additions and 1,923 deletions.
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Expand Up @@ -1195,11 +1195,9 @@ set (PCH_SOURCES
w_wad.cpp
wi_stuff.cpp
zstrformat.cpp
g_inventory/a_ammo.cpp
g_inventory/a_armor.cpp
g_inventory/a_keys.cpp
g_inventory/a_pickups.cpp
g_inventory/a_weaponpiece.cpp
g_inventory/a_weapons.cpp
g_strife/strife_sbar.cpp
g_shared/a_action.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/actor.h
Expand Up @@ -721,7 +721,7 @@ class AActor : public DThinker

// Finds the first item of a particular type.
AInventory *FindInventory (PClassActor *type, bool subclass=false);
AInventory *FindInventory (FName type);
AInventory *FindInventory (FName type, bool subclass = false);
template<class T> T *FindInventory ()
{
return static_cast<T *> (FindInventory (RUNTIME_TEMPLATE_CLASS(T)));
Expand Down
10 changes: 5 additions & 5 deletions src/am_map.cpp
Expand Up @@ -2740,8 +2740,8 @@ void AM_drawKeys ()
mpoint_t p;
DAngle angle;

TThinkerIterator<AKey> it;
AKey *key;
TThinkerIterator<AInventory> it(NAME_Key);
AInventory *key;

while ((key = it.Next()) != NULL)
{
Expand Down Expand Up @@ -2853,7 +2853,7 @@ void AM_drawThings ()
// Find the key's own color.
// Only works correctly if single-key locks have lower numbers than any-key locks.
// That is the case for all default keys, however.
if (t->IsKindOf(RUNTIME_CLASS(AKey)))
if (t->IsKindOf(PClass::FindActor(NAME_Key)))
{
if (G_SkillProperty(SKILLP_EasyKey))
{
Expand All @@ -2863,7 +2863,7 @@ void AM_drawThings ()
else if (am_showkeys)
{
int P_GetMapColorForKey (AInventory * key);
int c = P_GetMapColorForKey(static_cast<AKey *>(t));
int c = P_GetMapColorForKey(static_cast<AInventory *>(t));

if (c >= 0) color.FromRGB(RPART(c), GPART(c), BPART(c));
else color = AMColors[AMColors.ThingColor_CountItem];
Expand Down Expand Up @@ -3048,7 +3048,7 @@ void AM_Drawer ()
return;

bool allmap = (level.flags2 & LEVEL2_ALLMAP) != 0;
bool allthings = allmap && players[consoleplayer].mo->FindInventory(PClass::FindActor(NAME_PowerScanner), true) != nullptr;
bool allthings = allmap && players[consoleplayer].mo->FindInventory(NAME_PowerScanner, true) != nullptr;

if (am_portaloverlay)
{
Expand Down
11 changes: 5 additions & 6 deletions src/b_think.cpp
Expand Up @@ -21,7 +21,6 @@
#include "d_event.h"
#include "d_player.h"
#include "vectors.h"
#include "a_ammo.h"

static FRandom pr_botmove ("BotMove");

Expand Down Expand Up @@ -346,12 +345,12 @@ void DBot::WhatToGet (AActor *item)
}
}
}
else if (item->IsKindOf (RUNTIME_CLASS(AAmmo)))
else if (item->IsKindOf (PClass::FindActor(NAME_Ammo)))
{
AAmmo *ammo = static_cast<AAmmo *> (item);
PClassActor *parent = ammo->GetParentAmmo ();
AInventory *holdingammo = player->mo->FindInventory (parent);

auto ac = PClass::FindActor(NAME_Ammo);
auto parent = item->GetClass();
while (parent->ParentClass != ac) parent = (PClassActor*)(parent->ParentClass);
AInventory *holdingammo = player->mo->FindInventory(parent);
if (holdingammo != NULL && holdingammo->Amount >= holdingammo->MaxAmount)
{
return;
Expand Down
3 changes: 1 addition & 2 deletions src/ct_chat.cpp
Expand Up @@ -31,7 +31,6 @@
#include "templates.h"
#include "d_net.h"
#include "d_event.h"
#include "a_armor.h"

#define QUEUESIZE 128
#define MESSAGESIZE 128
Expand Down Expand Up @@ -434,7 +433,7 @@ static bool DoSubstitution (FString &out, const char *in)
{
if (strnicmp(a, "armor", 5) == 0)
{
AInventory *armor = player->mo->FindInventory<ABasicArmor>();
AInventory *armor = player->mo->FindInventory(NAME_BasicArmor);
out.AppendFormat("%d", armor != NULL ? armor->Amount : 0);
}
}
Expand Down
36 changes: 16 additions & 20 deletions src/d_dehacked.cpp
Expand Up @@ -74,8 +74,6 @@
#include "info.h"
#include "v_text.h"
#include "vmbuilder.h"
#include "a_armor.h"
#include "a_ammo.h"

// [SO] Just the way Randy said to do it :)
// [RH] Made this CVAR_SERVERINFO
Expand Down Expand Up @@ -1536,7 +1534,7 @@ static int PatchSprite (int sprNum)
static int PatchAmmo (int ammoNum)
{
PClassActor *ammoType = NULL;
AAmmo *defaultAmmo = NULL;
AInventory *defaultAmmo = NULL;
int result;
int oldclip;
int dummy;
Expand All @@ -1549,7 +1547,7 @@ static int PatchAmmo (int ammoNum)
ammoType = AmmoNames[ammoNum];
if (ammoType != NULL)
{
defaultAmmo = (AAmmo *)GetDefaultByType (ammoType);
defaultAmmo = (AInventory*)GetDefaultByType (ammoType);
if (defaultAmmo != NULL)
{
max = &defaultAmmo->MaxAmount;
Expand All @@ -1575,8 +1573,8 @@ static int PatchAmmo (int ammoNum)
// Calculate the new backpack-given amounts for this ammo.
if (ammoType != NULL)
{
defaultAmmo->BackpackMaxAmount = defaultAmmo->MaxAmount * 2;
defaultAmmo->BackpackAmount = defaultAmmo->Amount;
defaultAmmo->IntVar("BackpackMaxAmount") = defaultAmmo->MaxAmount * 2;
defaultAmmo->IntVar("BackpackAmount") = defaultAmmo->Amount;
}

// Fix per-ammo/max-ammo amounts for descendants of the base ammo class
Expand All @@ -1591,7 +1589,7 @@ static int PatchAmmo (int ammoNum)

if (type->IsDescendantOf (ammoType))
{
defaultAmmo = (AAmmo *)GetDefaultByType (type);
defaultAmmo = (AInventory *)GetDefaultByType (type);
defaultAmmo->MaxAmount = *max;
defaultAmmo->Amount = Scale (defaultAmmo->Amount, *per, oldclip);
}
Expand Down Expand Up @@ -1673,7 +1671,7 @@ static int PatchWeapon (int weapNum)
info->AmmoType1 = (PClassInventory*)AmmoNames[val];
if (info->AmmoType1 != NULL)
{
info->AmmoGive1 = ((AAmmo*)GetDefaultByType (info->AmmoType1))->Amount * 2;
info->AmmoGive1 = ((AInventory*)GetDefaultByType (info->AmmoType1))->Amount * 2;
if (info->AmmoUse1 == 0)
{
info->AmmoUse1 = 1;
Expand Down Expand Up @@ -1949,26 +1947,24 @@ static int PatchMisc (int dummy)

// Update default item properties by patching the affected items
// Note: This won't have any effect on DECORATE derivates of these items!
ABasicArmorPickup *armor;

armor = static_cast<ABasicArmorPickup *> (GetDefaultByName ("GreenArmor"));
auto armor = GetDefaultByName ("GreenArmor");
if (armor!=NULL)
{
armor->SaveAmount = 100 * deh.GreenAC;
armor->SavePercent = deh.GreenAC == 1 ? 0.33335 : 0.5;
armor->IntVar(NAME_SaveAmount) = 100 * deh.GreenAC;
armor->FloatVar(NAME_SavePercent) = deh.GreenAC == 1 ? 0.33335 : 0.5;
}
armor = static_cast<ABasicArmorPickup *> (GetDefaultByName ("BlueArmor"));
armor = GetDefaultByName ("BlueArmor");
if (armor!=NULL)
{
armor->SaveAmount = 100 * deh.BlueAC;
armor->SavePercent = deh.BlueAC == 1 ? 0.33335 : 0.5;
armor->IntVar(NAME_SaveAmount) = 100 * deh.BlueAC;
armor->FloatVar(NAME_SavePercent) = deh.BlueAC == 1 ? 0.33335 : 0.5;
}

ABasicArmorBonus *barmor;
barmor = static_cast<ABasicArmorBonus *> (GetDefaultByName ("ArmorBonus"));
auto barmor = GetDefaultByName ("ArmorBonus");
if (barmor!=NULL)
{
barmor->MaxSaveAmount = deh.MaxArmor;
barmor->IntVar("MaxSaveAmount") = deh.MaxArmor;
}

AInventory *health;
Expand Down Expand Up @@ -2930,7 +2926,7 @@ static bool LoadDehSupp ()
else
{
auto cls = PClass::FindActor(sc.String);
if (cls == NULL || !cls->IsDescendantOf(RUNTIME_CLASS(AAmmo)))
if (cls == NULL || !cls->IsDescendantOf(PClass::FindActor(NAME_Ammo)))
{
sc.ScriptError("Unknown ammo type '%s'", sc.String);
}
Expand Down Expand Up @@ -3184,7 +3180,7 @@ bool ADehackedPickup::ShouldRespawn ()
void ADehackedPickup::PlayPickupSound (AActor *toucher)
{
if (RealPickup != nullptr)
RealPickup->PlayPickupSound (toucher);
RealPickup->CallPlayPickupSound (toucher);
}

void ADehackedPickup::DoPickupSpecial (AActor *toucher)
Expand Down
5 changes: 0 additions & 5 deletions src/d_player.h
Expand Up @@ -177,11 +177,6 @@ class APlayerPawn : public AActor

};

class APlayerChunk : public APlayerPawn
{
DECLARE_CLASS (APlayerChunk, APlayerPawn)
};

//
// PlayerPawn flags
//
Expand Down
2 changes: 1 addition & 1 deletion src/dobject.cpp
Expand Up @@ -571,7 +571,7 @@ DEFINE_ACTION_FUNCTION(DObject, GetClassName)
void *DObject::ScriptVar(FName field, PType *type)
{
auto sym = dyn_cast<PField>(GetClass()->Symbols.FindSymbol(field, true));
if (sym && sym->Type == type)
if (sym && (sym->Type == type || type == nullptr))
{
return (((char*)this) + sym->Offset);
}
Expand Down
1 change: 1 addition & 0 deletions src/dobject.h
Expand Up @@ -482,6 +482,7 @@ class DObject
PalEntry &ColorVar(FName field);
FName &NameVar(FName field);
double &FloatVar(FName field);
template<class T> T*& PointerVar(FName field);

// If you need to replace one object with another and want to
// change any pointers from the old object to the new object,
Expand Down
1 change: 0 additions & 1 deletion src/dobjtype.cpp
Expand Up @@ -45,7 +45,6 @@
#include "autosegs.h"
#include "v_text.h"
#include "a_pickups.h"
#include "a_weaponpiece.h"
#include "d_player.h"
#include "doomerrors.h"
#include "fragglescript/t_fs.h"
Expand Down
6 changes: 5 additions & 1 deletion src/dobjtype.h
Expand Up @@ -1093,5 +1093,9 @@ inline double &DObject::FloatVar(FName field)
return *(double*)ScriptVar(field, TypeFloat64);
}


template<class T>
inline T *&DObject::PointerVar(FName field)
{
return *(T**)ScriptVar(field, nullptr); // pointer check is more tricky and for the handful of uses in the DECORATE parser not worth the hassle.
}
#endif
16 changes: 4 additions & 12 deletions src/fragglescript/t_func.cpp
Expand Up @@ -69,7 +69,6 @@
#include "p_setup.h"
#include "p_spec.h"
#include "r_utility.h"
#include "a_ammo.h"
#include "math/cmath.h"
#include "g_levellocals.h"

Expand Down Expand Up @@ -2478,14 +2477,7 @@ static void FS_TakeInventory (AActor *actor, const char * type, int amount)
// If it's not ammo, destroy it. Ammo needs to stick around, even
// when it's zero for the benefit of the weapons that use it and
// to maintain the maximum ammo amounts a backpack might have given.
if (item->GetClass()->ParentClass != RUNTIME_CLASS(AAmmo))
{
item->Destroy ();
}
else
{
item->Amount = 0;
}
item->DepleteOrDestroy();
}
}
}
Expand Down Expand Up @@ -2628,7 +2620,7 @@ void FParser::SF_MaxPlayerAmmo()
if(amount < 0) amount = 0;
if (!iammo)
{
iammo = static_cast<AAmmo *>(Spawn (ammotype));
iammo = static_cast<AInventory *>(Spawn (ammotype));
iammo->Amount = 0;
iammo->AttachToOwner (players[playernum].mo);
}
Expand All @@ -2644,13 +2636,13 @@ void FParser::SF_MaxPlayerAmmo()
break;
}
}
((AAmmo*)iammo)->BackpackMaxAmount=amount;
iammo->IntVar("BackpackMaxAmount") = amount;
}

t_return.type = svt_int;
AInventory * iammo = players[playernum].mo->FindInventory(ammotype);
if (iammo) t_return.value.i = iammo->MaxAmount;
else t_return.value.i = ((AAmmo*)GetDefaultByType(ammotype))->MaxAmount;
else t_return.value.i = ((AInventory*)GetDefaultByType(ammotype))->MaxAmount;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/g_game.cpp
Expand Up @@ -447,7 +447,7 @@ CCMD (use)
{
if (argv.argc() > 1 && who != NULL)
{
SendItemUse = who->FindInventory(PClass::FindActor(argv[1]));
SendItemUse = who->FindInventory(argv[1]);
}
}

Expand All @@ -468,7 +468,7 @@ CCMD (drop)
{
if (argv.argc() > 1 && who != NULL)
{
SendItemDrop = who->FindInventory(PClass::FindActor(argv[1]));
SendItemDrop = who->FindInventory(argv[1]);
}
}

Expand Down Expand Up @@ -513,7 +513,7 @@ CCMD (select)
{
if (argv.argc() > 1)
{
AInventory *item = who->FindInventory(PClass::FindActor(argv[1]));
AInventory *item = who->FindInventory(argv[1]);
if (item != NULL)
{
who->InvSel = item;
Expand Down

0 comments on commit e235d83

Please sign in to comment.