- did some more lightening on the PlayerPawn class. 4 more properties and one native member function have been handled.

This commit is contained in:
Christoph Oelckers 2019-01-03 10:06:45 +01:00
parent 8da1b5c1b0
commit 9e5c5b68c5
11 changed files with 61 additions and 61 deletions

View file

@ -101,7 +101,6 @@ public:
// These are virtual on the script side only.
void PlayIdle();
const char *GetSoundClass () const;
int hasBuddha(); // returns 0 for no buddha, 1 for regular buddha and 2 for strong buddha
enum EInvulState
@ -141,18 +140,17 @@ public:
double ViewBob;
double curBob;
// Former class properties that were moved into the object to get rid of the meta class.
FName SoundClass; // Sound class
FName Face; // Doom status bar face (when used)
FName Portrait;
FName Slot[10];
// Everything below this point is only used by scripted code.
// Everything below this point is only used by scripted code or through the scripted variable interface.
int RunHealth;
TObjPtr<AActor*> InvFirst; // first inventory item displayed on inventory bar
double ForwardMove1, ForwardMove2;
double SideMove1, SideMove2;
double HexenArmor[5];
// Former class properties that were moved into the object to get rid of the meta class.
FName SoundClass; // Sound class
FName Portrait;
FName Slot[10];
PClassActor *FlechetteType;
};

View file

@ -491,7 +491,7 @@ void FWeaponSlots::SendDifferences(int playernum, const FWeaponSlots &other)
void FWeaponSlots::SetFromPlayer(PClassActor *type)
{
Clear();
auto Slot = ((APlayerPawn*)GetDefaultByType(type))->Slot;
auto Slot = &GetDefaultByType(type)->NameVar(NAME_Slot);
for (int i = 0; i < NUM_WEAPON_SLOTS; ++i)
{
if (Slot[i] != NAME_None)

View file

@ -477,7 +477,7 @@ FTexture *FMugShot::GetFace(player_t *player, const char *default_face, int accu
if (CurrentState != NULL)
{
int skin = player->userinfo.GetSkin();
const char *skin_face = (stateflags & FMugShot::CUSTOM) ? nullptr : (player->morphTics ? ((APlayerPawn*)GetDefaultByType(player->MorphedPlayerClass))->Face.GetChars() : Skins[skin].Face.GetChars());
const char *skin_face = (stateflags & FMugShot::CUSTOM) ? nullptr : (player->morphTics ? ((APlayerPawn*)GetDefaultByType(player->MorphedPlayerClass))->NameVar(NAME_Face).GetChars() : Skins[skin].Face.GetChars());
return CurrentState->GetCurrentFrameTexture(default_face, skin_face, level, angle);
}
return NULL;

View file

@ -1036,6 +1036,9 @@ xx(ForwardMove1)
xx(ForwardMove2)
xx(SideMove1)
xx(SideMove2)
xx(Face)
xx(Slot)
xx(SoundClass)
xx(BlueCard)
xx(YellowCard)

View file

@ -819,18 +819,6 @@ void APlayerPawn::Serialize(FSerializer &arc)
("fullheight", FullHeight, def->FullHeight);
}
//===========================================================================
//
// APlayerPawn :: MarkPlayerSounds
//
//===========================================================================
DEFINE_ACTION_FUNCTION(APlayerPawn, MarkPlayerSounds)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
S_MarkPlayerSounds(self->GetSoundClass());
return 0;
}
//===========================================================================
//
// APlayerPawn :: BeginPlay
@ -954,30 +942,10 @@ void APlayerPawn::GiveDeathmatchInventory()
}
}
//===========================================================================
//
// APlayerPawn :: GetSoundClass
//
//===========================================================================
const char *APlayerPawn::GetSoundClass() const
{
if (player != NULL &&
(player->mo == NULL || !(player->mo->flags4 &MF4_NOSKIN)) &&
(unsigned int)player->userinfo.GetSkin() >= PlayerClasses.Size () &&
(unsigned)player->userinfo.GetSkin() < Skins.Size())
{
return Skins[player->userinfo.GetSkin()].Name.GetChars();
}
return SoundClass != NAME_None? SoundClass.GetChars() : "player";
}
//===========================================================================
//
// APlayerPawn :: hasBuddha
//
//===========================================================================
int APlayerPawn::hasBuddha()
@ -2088,7 +2056,6 @@ DEFINE_FIELD(APlayerPawn, ViewBob)
DEFINE_FIELD(APlayerPawn, curBob)
DEFINE_FIELD(APlayerPawn, FullHeight)
DEFINE_FIELD(APlayerPawn, SoundClass)
DEFINE_FIELD(APlayerPawn, Face)
DEFINE_FIELD(APlayerPawn, Portrait)
DEFINE_FIELD(APlayerPawn, Slot)
DEFINE_FIELD(APlayerPawn, HexenArmor)

View file

@ -1013,14 +1013,8 @@ void R_InitSprites ()
auto basetype = ((APlayerPawn*)GetDefaultByType(PlayerClasses[i].Type));
Skins[i].Name = "Base";
if (basetype->Face == NAME_None)
{
Skins[i].Face = "STF";
}
else
{
Skins[i].Face = basetype->Face;
}
auto face = basetype->NameVar(NAME_Face);
Skins[i].Face = face == NAME_None? FName("STF") : face;
Skins[i].range0start = basetype->IntVar(NAME_ColorRangeStart);
Skins[i].range0end = basetype->IntVar(NAME_ColorRangeEnd);
Skins[i].Scale = basetype->Scale;

View file

@ -45,6 +45,7 @@
#include "serializer.h"
#include "v_text.h"
#include "g_levellocals.h"
#include "r_data/sprites.h"
#include "vm.h"
// MACROS ------------------------------------------------------------------
@ -1888,6 +1889,27 @@ bool S_AreSoundsEquivalent (AActor *actor, int id1, int id2)
return id1 == id2;
}
//===========================================================================
//
// APlayerPawn :: GetSoundClass
//
//===========================================================================
static const char *GetSoundClass(AActor *pp)
{
auto player = pp->player;
if (player != nullptr &&
(player->mo == nullptr || !(player->mo->flags4 &MF4_NOSKIN)) &&
(unsigned int)player->userinfo.GetSkin() >= PlayerClasses.Size() &&
(unsigned)player->userinfo.GetSkin() < Skins.Size())
{
return Skins[player->userinfo.GetSkin()].Name.GetChars();
}
auto sclass = pp->NameVar(NAME_SoundClass);
return sclass != NAME_None ? sclass.GetChars() : "player";
}
//==========================================================================
//
// S_FindSkinnedSound
@ -1900,10 +1922,10 @@ int S_FindSkinnedSound (AActor *actor, FSoundID refid)
const char *pclass;
int gender = 0;
if (actor != NULL && actor->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
if (actor != nullptr)
{
pclass = static_cast<APlayerPawn*>(actor)->GetSoundClass ();
if (actor->player != NULL) gender = actor->player->userinfo.GetGender();
pclass = GetSoundClass (actor);
if (actor->player != nullptr) gender = actor->player->userinfo.GetGender();
}
else
{
@ -2053,8 +2075,9 @@ void sfxinfo_t::MarkUsed()
//
//==========================================================================
void S_MarkPlayerSounds (const char *playerclass)
void S_MarkPlayerSounds (AActor *player)
{
const char *playerclass = GetSoundClass(player);
int classidx = S_FindPlayerClass(playerclass);
if (classidx < 0)
{

View file

@ -364,7 +364,7 @@ int S_AddSoundLump (const char *logicalname, int lump); // Add sound by lump ind
int S_AddPlayerSound (const char *playerclass, const int gender, int refid, const char *lumpname);
int S_AddPlayerSound (const char *playerclass, const int gender, int refid, int lumpnum, bool fromskin=false);
int S_AddPlayerSoundExisting (const char *playerclass, const int gender, int refid, int aliasto, bool fromskin=false);
void S_MarkPlayerSounds (const char *playerclass);
void S_MarkPlayerSounds (AActor *player);
void S_ShrinkPlayerSoundLists ();
void S_UnloadSound (sfxinfo_t *sfx);
sfxinfo_t *S_LoadSound(sfxinfo_t *sfx, FSoundLoadBuffer *pBuffer = nullptr);

View file

@ -1358,7 +1358,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, soundclass, S, PlayerPawn)
FString tmp = str;
tmp.ReplaceChars (' ', '_');
defaults->SoundClass = tmp.IsNotEmpty()? FName(tmp) : NAME_None;
defaults->NameVar(NAME_SoundClass) = tmp.IsNotEmpty()? FName(tmp) : NAME_None;
}
//==========================================================================
@ -1369,7 +1369,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, face, S, PlayerPawn)
PROP_STRING_PARM(str, 0);
FString tmp = str;
if (tmp.Len() == 0) defaults->Face = NAME_None;
if (tmp.Len() == 0) defaults->NameVar(NAME_Face) = NAME_None;
else
{
tmp.ToUpper();
@ -1384,7 +1384,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, face, S, PlayerPawn)
"Invalid face '%s' for '%s';\nSTF replacement codes must be 3 alphanumeric characters.\n",
tmp.GetChars(), info->TypeName.GetChars());
}
defaults->Face = tmp;
defaults->NameVar(NAME_Face) = tmp;
}
}
@ -1691,7 +1691,8 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, weaponslot, ISsssssssssssssssssssssssssssss
PROP_STRING_PARM(str, i);
weapons << ' ' << str;
}
defaults->Slot[slot] = weapons.IsEmpty()? NAME_None : FName(weapons);
FName *slots = &defaults->NameVar(NAME_Slot);
slots[slot] = weapons.IsEmpty()? NAME_None : FName(weapons);
}
}

View file

@ -1649,6 +1649,20 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckFor3DCeilingHit, CheckFor3DCeilingHit
//===========================================================================
//
// APlayerPawn :: MarkPlayerSounds
//
//===========================================================================
DEFINE_ACTION_FUNCTION_NATIVE(APlayerPawn, MarkPlayerSounds, S_MarkPlayerSounds)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
S_MarkPlayerSounds(self);
return 0;
}
DEFINE_FIELD(AActor, snext)
DEFINE_FIELD(AActor, player)
DEFINE_FIELD_NAMED(AActor, __Pos, pos)

View file

@ -25,7 +25,6 @@ class PlayerPawn : Actor native
native clearscope Inventory InvFirst; // first inventory item displayed on inventory bar
native clearscope Inventory InvSel; // selected inventory item
native Name SoundClass; // Sound class
native Name Face; // Doom status bar face (when used)
native Name Portrait;
native Name Slot[10];
native double HexenArmor[5];
@ -51,6 +50,7 @@ class PlayerPawn : Actor native
meta Name HealingRadiusType;
meta Name InvulMode;
meta Name Face;
meta int TeleportFreezeTime;
meta int ColorRangeStart; // Skin color range
meta int ColorRangeEnd;