diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 0b7663c0e..55ee808a6 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,9 @@ April 4, 2009 (Changes by Graf Zahl) +- fixed: Any player class inheriting directly from PlayerPawn was left with + empty weapon slots due to the recent rewrite of the weapon slot assignment + code. To handle such classes each game now defines a default weapon slot + setting in its gameinfo. This will be used when a player class without any + weapon slot settings is used. - added 'damage' to the actor variables exported to DECORATE's expression evaluator. - fixed: solid corpses could block ripper missile that originally killed them. diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 023002dd6..58709d97f 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -73,6 +73,7 @@ struct FWeaponSlots bool LocateWeapon (const PClass *type, int *const slot, int *const index); ESlotDef AddDefaultWeapon (int slot, const PClass *type); void AddExtraWeapons(); + void SetFromGameInfo(); void SetFromPlayer(const PClass *type); void StandardSetup(const PClass *type); void LocalSetup(const PClass *type); diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 11829f857..8beec1688 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -1115,6 +1115,44 @@ void FWeaponSlots::AddExtraWeapons() } } +//=========================================================================== +// +// FWeaponSlots :: SetFromGameInfo +// +// If neither the player class nor any defined weapon contain a +// slot assignment, use the game's defaults +// +//=========================================================================== + +void FWeaponSlots::SetFromGameInfo() +{ + unsigned int i; + + // Only if all slots are empty + for (i = 0; i < NUM_WEAPON_SLOTS; ++i) + { + if (Slots[i].Size() > 0) return; + } + + // Append extra weapons to the slots. + for (i = 0; i < NUM_WEAPON_SLOTS; ++i) + { + for (unsigned j = 0; j < gameinfo.DefaultWeaponSlots[i].Size(); i++) + { + const PClass *cls = PClass::FindClass(gameinfo.DefaultWeaponSlots[i][j]); + if (cls == NULL) + { + Printf("Unknown weapon class '%s' found in default weapon slot assignments\n", + gameinfo.DefaultWeaponSlots[i][j].GetChars()); + } + else + { + Slots[i].AddWeapon(cls); + } + } + } +} + //=========================================================================== // // FWeaponSlots :: StandardSetup @@ -1122,6 +1160,7 @@ void FWeaponSlots::AddExtraWeapons() // Setup weapons in this order: // 1. Use slots from player class. // 2. Add extra weapons that specify their own slots. +// 3. If all slots are empty, use the settings from the gameinfo (compatibility fallback) // //=========================================================================== @@ -1129,6 +1168,7 @@ void FWeaponSlots::StandardSetup(const PClass *type) { SetFromPlayer(type); AddExtraWeapons(); + SetFromGameInfo(); } //=========================================================================== diff --git a/src/gi.cpp b/src/gi.cpp index 18c0554e1..514b09e74 100644 --- a/src/gi.cpp +++ b/src/gi.cpp @@ -175,7 +175,26 @@ void FMapInfoParser::ParseGameInfo() FString nextKey = sc.String; sc.MustGetToken('='); - if(nextKey.CompareNoCase("border") == 0) + if (nextKey.CompareNoCase("weaponslot") == 0) + { + sc.MustGetToken(TK_IntConst); + if (sc.Number < 0 || sc.Number >= 10) + { + sc.ScriptError("Weapon slot index must be in range [0..9].\n"); + } + int i = sc.Number; + gameinfo.DefaultWeaponSlots[i].Clear(); + sc.MustGetToken(','); + do + { + sc.MustGetString(); + FName val = sc.String; + gameinfo.DefaultWeaponSlots[i].Push(val); + + } + while (sc.CheckToken(',')); + } + else if(nextKey.CompareNoCase("border") == 0) { if(sc.CheckToken(TK_Identifier)) { diff --git a/src/gi.h b/src/gi.h index 0e3ad50a2..09908e5a3 100644 --- a/src/gi.h +++ b/src/gi.h @@ -72,6 +72,7 @@ struct gameinfo_t TArray creditPages; TArray finalePages; TArray infoPages; + TArray DefaultWeaponSlots[10]; FString titleMusic; float titleTime; diff --git a/wadsrc/static/mapinfo/chex.txt b/wadsrc/static/mapinfo/chex.txt index 7c00dd8bb..dec8990c2 100644 --- a/wadsrc/static/mapinfo/chex.txt +++ b/wadsrc/static/mapinfo/chex.txt @@ -25,6 +25,13 @@ gameinfo backpacktype = "ZorchPack" statusbar = "sbarinfo/doom.txt" intermissionmusic = "$MUSIC_INTER" + weaponslot = 1, "Bootspoon", "SuperBootspork" + weaponslot = 2, "MiniZorcher" + weaponslot = 3, "LargeZorcher", "SuperLargeZorcher" + weaponslot = 4, "RapidZorcher" + weaponslot = 5, "ZorchPropulsor" + weaponslot = 6, "PhasingZorcher" + weaponslot = 7, "LAZDevice" } skill baby diff --git a/wadsrc/static/mapinfo/doomcommon.txt b/wadsrc/static/mapinfo/doomcommon.txt index 84fc4c1ef..1de00818e 100644 --- a/wadsrc/static/mapinfo/doomcommon.txt +++ b/wadsrc/static/mapinfo/doomcommon.txt @@ -25,6 +25,13 @@ gameinfo backpacktype = "Backpack" statusbar = "sbarinfo/doom.txt" intermissionmusic = "$MUSIC_DM2INT" + weaponslot = 1, "Fist", "Chainsaw" + weaponslot = 2, "Pistol" + weaponslot = 3, "Shotgun", "SuperShotgun" + weaponslot = 4, "Chaingun" + weaponslot = 5, "RocketLauncher" + weaponslot = 6, "PlasmaRifle" + weaponslot = 7, "BFG9000" } skill baby diff --git a/wadsrc/static/mapinfo/heretic.txt b/wadsrc/static/mapinfo/heretic.txt index a56c90fc1..733498aa9 100644 --- a/wadsrc/static/mapinfo/heretic.txt +++ b/wadsrc/static/mapinfo/heretic.txt @@ -25,6 +25,13 @@ gameinfo backpacktype = "BagOfHolding" statusbar = "" intermissionmusic = "mus_intr" + weaponslot = 1, "Staff", "Gauntlets" + weaponslot = 2, "GoldWand" + weaponslot = 3, "Crossbow" + weaponslot = 4, "Blaster" + weaponslot = 5, "SkullRod" + weaponslot = 6, "PhoenixRod" + weaponslot = 7, "Mace" } skill baby diff --git a/wadsrc/static/mapinfo/hexen.txt b/wadsrc/static/mapinfo/hexen.txt index 7cf50f892..be391e994 100644 --- a/wadsrc/static/mapinfo/hexen.txt +++ b/wadsrc/static/mapinfo/hexen.txt @@ -28,6 +28,10 @@ gameinfo backpacktype = "BagOfHolding" // Hexen doesn't have a backpack so use Heretic's. statusbar = "" intermissionmusic = "hub" + weaponslot = 1, "FWeapFist", "CWeapMace", "MWeapWand" + weaponslot = 2, "FWeapAxe", "CWeapStaff", "MWeapFrost" + weaponslot = 3, "FWeapHammer", "CWeapFlame", "MWeapLightning" + weaponslot = 4, "FWeapQuietus", "CWeapWraithverge", "MWeapBloodscourge" } skill baby diff --git a/wadsrc/static/mapinfo/strife.txt b/wadsrc/static/mapinfo/strife.txt index 03341496c..b94b02846 100644 --- a/wadsrc/static/mapinfo/strife.txt +++ b/wadsrc/static/mapinfo/strife.txt @@ -25,6 +25,14 @@ gameinfo backpacktype = "AmmoSatchel" statusbar = "" intermissionmusic = "d_slide" + weaponslot = 1, "PunchDagger" + weaponslot = 2, "StrifeCrossbow2", "StrifeCrossbow" + weaponslot = 3, "AssaultGun" + weaponslot = 4, "MiniMissileLauncher" + weaponslot = 5, "StrifeGrenadeLauncher2", "StrifeGrenadeLauncher" + weaponslot = 6, "FlameThrower" + weaponslot = 7, "Mauler2", "Mauler" + weaponslot = 8, "Sigil" } skill baby