From 6eb8ded471644a817eebcf6e42f7de3959aac2e4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 2 Jan 2019 22:13:25 +0100 Subject: [PATCH] - made ColorRangeStart and ColorRangeEnd meta properties of APlayerPawn. These are only used during initialization and they should have been readonly from the start. --- src/d_player.h | 2 -- src/namedef.h | 5 +++++ src/p_user.cpp | 2 -- src/r_data/sprites.cpp | 24 ++++++++++++------------ src/scripting/thingdef_properties.cpp | 4 ++-- wadsrc/static/zscript/shared/player.txt | 4 ++-- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 3d1a95bffa..0f076bf18c 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -151,8 +151,6 @@ public: FName Portrait; FName Slot[10]; double HexenArmor[5]; - uint8_t ColorRangeStart; // Skin color range - uint8_t ColorRangeEnd; // Everything below this point is only used by scripted code. PClassActor *FlechetteType; diff --git a/src/namedef.h b/src/namedef.h index c217261e7b..a4c801af4e 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -1028,6 +1028,11 @@ xx(WeaponFlags) xx(DropTime) xx(PickupSound) +// PlayerPawn member fields +xx(ColorRangeStart) +xx(ColorRangeEnd) + + xx(BlueCard) xx(YellowCard) xx(RedCard) diff --git a/src/p_user.cpp b/src/p_user.cpp index 92369ceb83..99564c7cc3 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2142,8 +2142,6 @@ DEFINE_FIELD(APlayerPawn, Face) DEFINE_FIELD(APlayerPawn, Portrait) DEFINE_FIELD(APlayerPawn, Slot) DEFINE_FIELD(APlayerPawn, HexenArmor) -DEFINE_FIELD(APlayerPawn, ColorRangeStart) -DEFINE_FIELD(APlayerPawn, ColorRangeEnd) DEFINE_FIELD_X(PlayerInfo, player_t, mo) DEFINE_FIELD_X(PlayerInfo, player_t, playerstate) diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index 9896fbf4dd..686aa1349f 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -778,22 +778,22 @@ void R_InitSkins (void) if (!remove) { - auto transdef = ((APlayerPawn*)GetDefaultByType(transtype)); - auto basedef = ((APlayerPawn*)GetDefaultByType(basetype)); + auto transdef = GetDefaultByType(transtype); + auto basedef = GetDefaultByType(basetype); - Skins[i].range0start = transdef->ColorRangeStart; - Skins[i].range0end = transdef->ColorRangeEnd; + Skins[i].range0start = transdef->IntVar(NAME_ColorRangeStart); + Skins[i].range0end = transdef->IntVar(NAME_ColorRangeEnd); remove = true; for (j = 0; j < (int)PlayerClasses.Size (); j++) { auto type = PlayerClasses[j].Type; - auto type_def = ((APlayerPawn*)GetDefaultByType(type)); + auto type_def = GetDefaultByType(type); if (type->IsDescendantOf (basetype) && GetDefaultByType(type)->SpawnState->sprite == GetDefaultByType(basetype)->SpawnState->sprite && - type_def->ColorRangeStart == basedef->ColorRangeStart && - type_def->ColorRangeEnd == basedef->ColorRangeEnd) + type_def->IntVar(NAME_ColorRangeStart) == basedef->IntVar(NAME_ColorRangeStart) && + type_def->IntVar(NAME_ColorRangeEnd) == basedef->IntVar(NAME_ColorRangeEnd)) { PlayerClasses[j].Skins.Push ((int)i); remove = false; @@ -995,9 +995,9 @@ void R_InitSprites () for (i = 0; i < numskins; i++) { // Assume Doom skin by default - auto type = ((APlayerPawn*)GetDefaultByType(PlayerClasses[0].Type)); - Skins[i].range0start = type->ColorRangeStart; - Skins[i].range0end = type->ColorRangeEnd; + auto type = GetDefaultByType(PlayerClasses[0].Type); + Skins[i].range0start = type->IntVar(NAME_ColorRangeStart); + Skins[i].range0end = type->IntVar(NAME_ColorRangeEnd); Skins[i].Scale = type->Scale; } @@ -1021,8 +1021,8 @@ void R_InitSprites () { Skins[i].Face = basetype->Face; } - Skins[i].range0start = basetype->ColorRangeStart; - Skins[i].range0end = basetype->ColorRangeEnd; + Skins[i].range0start = basetype->IntVar(NAME_ColorRangeStart); + Skins[i].range0end = basetype->IntVar(NAME_ColorRangeEnd); Skins[i].Scale = basetype->Scale; Skins[i].sprite = basetype->SpawnState->sprite; Skins[i].namespc = ns_global; diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index d54684a486..a709b8e31d 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -1399,8 +1399,8 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, colorrange, I_I, PlayerPawn) if (start > end) swapvalues (start, end); - defaults->ColorRangeStart = start; - defaults->ColorRangeEnd = end; + defaults->IntVar(NAME_ColorRangeStart) = start; + defaults->IntVar(NAME_ColorRangeEnd) = end; } //========================================================================== diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index 3bf0487ce1..0a6d962d16 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -29,8 +29,6 @@ class PlayerPawn : Actor native native Name Portrait; native Name Slot[10]; native double HexenArmor[5]; - native uint8 ColorRangeStart; // Skin color range - native uint8 ColorRangeEnd; // [GRB] Player class properties native double JumpZ; @@ -54,6 +52,8 @@ class PlayerPawn : Actor native meta Name HealingRadiusType; meta Name InvulMode; meta int TeleportFreezeTime; + meta int ColorRangeStart; // Skin color range + meta int ColorRangeEnd; property prefix: Player; property HealRadiusType: HealingradiusType;