diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 631a2518..b31d4e28 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -264,6 +264,7 @@ public: const PClass *ProjectileType; // Projectile used by primary attack const PClass *AltProjectileType; // Projectile used by alternate attack int SelectionOrder; // Lower-numbered weapons get picked first + int MinSelAmmo1, MinSelAmmo2; // Ignore in BestWeapon() if inadequate ammo fixed_t MoveCombatDist; // Used by bots, but do they *really* need it? int ReloadCounter; // For A_CheckForReload int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha) diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index c5035e41..24d6a545 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -65,6 +65,10 @@ void AWeapon::Serialize (FArchive &arc) } arc << FOVScale << Crosshair; + if (SaveVersion >= 4203) + { + arc << MinSelAmmo1 << MinSelAmmo2; + } } //=========================================================================== diff --git a/src/name.cpp b/src/name.cpp index c0d14b51..36cce259 100644 --- a/src/name.cpp +++ b/src/name.cpp @@ -65,6 +65,7 @@ struct FName::NameManager::NameBlock // PRIVATE DATA DEFINITIONS ------------------------------------------------ FName::NameManager FName::NameData; +bool FName::NameManager::Inited; // Define the predefined names. static const char *PredefinedNames[] = diff --git a/src/name.h b/src/name.h index fa161ab2..3e2eaf4b 100644 --- a/src/name.h +++ b/src/name.h @@ -116,7 +116,7 @@ protected: int AddName (const char *text, unsigned int hash, unsigned int bucket); NameBlock *AddBlock (size_t len); void InitBuckets (); - bool Inited; + static bool Inited; }; static NameManager NameData; diff --git a/src/p_user.cpp b/src/p_user.cpp index 132fa499..47d9ff2e 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -766,6 +766,12 @@ AWeapon *APlayerPawn::BestWeapon (const PClass *ammotype) !weap->CheckAmmo (AWeapon::PrimaryFire, false)) continue; + // Don't select if if there isn't enough ammo as determined by the weapon's author. + if (weap->MinSelAmmo1 > 0 && (weap->Ammo1 == NULL || weap->Ammo1->Amount < weap->MinSelAmmo1)) + continue; + if (weap->MinSelAmmo2 > 0 && (weap->Ammo2 == NULL || weap->Ammo2->Amount < weap->MinSelAmmo2)) + continue; + // This weapon is usable! bestOrder = weap->SelectionOrder; bestMatch = weap; diff --git a/src/svnrevision.h b/src/svnrevision.h index 5762d4f2..a884a648 100644 --- a/src/svnrevision.h +++ b/src/svnrevision.h @@ -3,5 +3,5 @@ // This file was automatically generated by the // updaterevision tool. Do not edit by hand. -#define ZD_SVN_REVISION_STRING "4202" -#define ZD_SVN_REVISION_NUMBER 4202 +#define ZD_SVN_REVISION_STRING "4204" +#define ZD_SVN_REVISION_NUMBER 4204 diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 5fc607ca..482a841a 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1739,6 +1739,24 @@ DEFINE_CLASS_PROPERTY(selectionorder, I, Weapon) defaults->SelectionOrder = i; } +//========================================================================== +// +//========================================================================== +DEFINE_CLASS_PROPERTY(minselectionammo1, I, Weapon) +{ + PROP_INT_PARM(i, 0); + defaults->MinSelAmmo1 = i; +} + +//========================================================================== +// +//========================================================================== +DEFINE_CLASS_PROPERTY(minselectionammo2, I, Weapon) +{ + PROP_INT_PARM(i, 0); + defaults->MinSelAmmo2 = i; +} + //========================================================================== // //==========================================================================