buymenu button class to struct conversion

This commit is contained in:
Christopher Dawalt 2021-08-25 05:50:20 -04:00
parent b8fd0a0f6f
commit b3f4b95cc1
8 changed files with 770 additions and 635 deletions

View File

@ -3,6 +3,11 @@
//---WARNINGS DISABLED---
#pragma warning disable Q302 /*uninitialised locals*/
// See ui_buymenu.qc for why this is disabled.
// No idea how to make warnings disabled only per file, in there
// would affect all files included in the compile after anyway
#pragma warning disable F314 /*implicit cast*/
/////////////////////////////////////////////////////////////////

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,4 @@
#define ASSIGN_AMMODATA(arg_constName) ary_ammoData[AMMO_ID::##arg_constName] = (ammodata_t*) &ammo_##arg_constName;
#define DECLARE_AMMODATA(arg_varName, arg_sDisplayName, arg_fPricePerBullet, arg_iMax) ammodata_t ammo_##arg_varName = {arg_sDisplayName, arg_fPricePerBullet, arg_iMax};
#define ASSIGN_SHELLEJECTDATA(arg_constName) ary_shellEjectData[SHELLEJECT_ID::##arg_constName] = (shellejectdata_t*) &shelleject_##arg_constName;
#define DECLARE_SHELLEJECTDATA(arg_varName, arg_sModelPath, arg_sTouchSound) shellejectdata_t shelleject_##arg_varName = {arg_sModelPath, arg_sTouchSound};
#define ASSIGN_MUZZLEFLASHDATA(arg_constName) ary_muzzleFlashData[MUZZLEFLASH_ID::##arg_constName] = (muzzleflashdata_t*) &muzzleflash_##arg_constName;
#define DECLARE_MUZZLEFLASHDATA(arg_varName, arg_sSpritePath) var muzzleflashdata_t muzzleflash_##arg_varName = {0, arg_sSpritePath};
enum AMMO_ID{
NONE = 0,

View File

@ -1,4 +1,14 @@
#define ASSIGN_AMMODATA(arg_constName) ary_ammoData[AMMO_ID::##arg_constName] = (ammodata_t*) &ammo_##arg_constName;
#define DECLARE_AMMODATA(arg_varName, arg_sDisplayName, arg_fPricePerBullet, arg_iMax) ammodata_t ammo_##arg_varName = {arg_sDisplayName, arg_fPricePerBullet, arg_iMax};
#define ASSIGN_SHELLEJECTDATA(arg_constName) ary_shellEjectData[SHELLEJECT_ID::##arg_constName] = (shellejectdata_t*) &shelleject_##arg_constName;
#define DECLARE_SHELLEJECTDATA(arg_varName, arg_sModelPath, arg_sTouchSound) shellejectdata_t shelleject_##arg_varName = {arg_sModelPath, arg_sTouchSound};
#define ASSIGN_MUZZLEFLASHDATA(arg_constName) ary_muzzleFlashData[MUZZLEFLASH_ID::##arg_constName] = (muzzleflashdata_t*) &muzzleflash_##arg_constName;
#define DECLARE_MUZZLEFLASHDATA(arg_varName, arg_sSpritePath) var muzzleflashdata_t muzzleflash_##arg_varName = {0, arg_sSpritePath};
DECLARE_AMMODATA(NONE, "_NONE_", 0, 0)
DECLARE_AMMODATA(_9X19MM, "9 x 19mm", 1.6666666666, 210)
DECLARE_AMMODATA(_45ACP, ".45Acp", 5.1, 200)

View File

@ -155,7 +155,9 @@ class player:base_player
int recentLaserDistanceDisplay;
// does anything use this?
BOOL forceViewModelUpdate;
// NOTICE - individual dynamic weapons have "iForceBodygroup1Submodel".
// "prev_iForceBodygroup1Submodel" is player-wide (here) instead because we only need to
// keep track of changes in a weapon's iForceBodygroup1Submodel while that weapon is
@ -224,8 +226,13 @@ class player:base_player
PREDICTED_INT(iMeleeCycler);
//SHARED!!!
// SHARED
vector vViewAngleOffsetTarget;
vector vViewAngleOffsetTarget1;
vector vViewAngleOffsetTarget2;
vector vViewAngleOffsetTarget3;
vector vViewAngleOffsetTarget4;
PREDICTED_FLOAT(fAccuracyKickback);
PREDICTED_FLOAT(fAccuracyKickbackStartCooldown);

View File

@ -236,6 +236,11 @@ if (pl.inputSecondaryTapFrameCount == 0)\
#define GET_VIEW_ANGLES pl.v_angle
#endif
#ifdef CLIENT
#define GET_MY_VIEW_ANGLES view_angles
#else
#define GET_MY_VIEW_ANGLES this.v_angle
#endif
// OLD UNDERWATER CHECK. Using a new var for more accuracy.

View File

@ -1,8 +1,5 @@
class player;
// Doing at least this because nuclide's src/server/weapons.qc
// still expects it to exist.
@ -11,6 +8,90 @@ class player;
// inventory element.
#define WEAPON_NONE 0
// Any preference for macro constants or 'enumflags', whatever does the auto-power-of-2?
// No idea, doing macros for now
#define BITS_AKIMBOCHOICE_NONE 0
#define BITS_AKIMBOCHOICE_LEFT 1
#define BITS_AKIMBOCHOICE_RIGHT 2
#define BITS_AKIMBOCHOICE_BOTH (BITS_AKIMBOCHOICE_LEFT | BITS_AKIMBOCHOICE_RIGHT)
// Firemodes, normal
// melee weapons don't really do firemode.
// Can be used for burst-fire bullets too for bypassing some requirements.
#define BITS_FIREMODE_NONE 0
#define BITS_FIREMODE_BURST 1
#define BITS_FIREMODE_FULL 2
#define BITS_FIREMODE_SEMI 4
#define BITS_FIREMODE_PUMP 8
// Akimbo firemodes
#define BITS_FIREMODE_AKIMBO_NONE 0
#define BITS_FIREMODE_AKIMBO_SEMI_AUTO 1
#define BITS_FIREMODE_AKIMBO_FREE_SEMI 2
#define BITS_FIREMODE_AKIMBO_FULL_AUTO 4
#define BITS_FIREMODE_AKIMBO_FREE_FULL 8
#define BITS_WEAPONOPT_NONE 0x00
#define BITS_WEAPONOPT_SILENCER 0x01
#define BITS_WEAPONOPT_LASERSIGHT 0x02
#define BITS_WEAPONOPT_FLASHLIGHT 0x04
#define BITS_WEAPONOPT_SCOPE 0x08
#define BITS_WEAPONOPT_AKIMBO 0x10
#define BITS_WEAPONOPT_FULLLOAD 0x20
// This is a special flag to say, skip showing buyoptions altogether. The buy button goes straight to
// buying the weapon.
//good for items (stealh shoes, kevlar)
#define BITS_WEAPONOPT_INSTANT 0x80000000
// Types of weapons that, if present, can be toggled on/off by the player. Only some can.
// A lot of other behavior about this isn't automatic though, a change here does little elsewhere.
#define BITMASK_WEAPONOPT_TOGGLEABLE BITS_WEAPONOPT_LASERSIGHT | BITS_WEAPONOPT_FLASHLIGHT
// only min/max order of bits.
#define BITMASK_WEAPONOPT_TOGGLEABLE_MIN BITS_WEAPONOPT_LASERSIGHT
#define BITMASK_WEAPONOPT_TOGGLEABLE_MAX BITS_WEAPONOPT_FLASHLIGHT
#define BUYCATEGORY_NONE 0
#define BUYCATEGORY_HANDGUNS 1
#define BUYCATEGORY_SMGS 2
#define BUYCATEGORY_RIFLES 3
#define BUYCATEGORY_SHOTGUNS 4
#define BUYCATEGORY_SPECIALPURPOSE 5
#define WEAPONDATA_TYPEID_BASIC 0
#define WEAPONDATA_TYPEID_GUN 1
#define WEAPONDATA_TYPEID_IRONSIGHT 2
//#define WEAPONDATA_TYPEID_AKIMBO 3
#define WEAPONDATA_TYPEID_MELEE 3
//Note that THROWABLE is knives, not grenades.
#define WEAPONDATA_TYPEID_THROWABLE 4
#define ary_myWeapons_length 16
class player;
class weapondynamic_t;
// commonly used in akimbo-fire methods for weapon-specific firint script.
// Parameter list commonly looks like:
// player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed
typedef void(player, weapondynamic_t, int) MethodType_WeaponAttack;
//returned by weapon_base_onPrimaryAttack_melee to tell what type of thing was hit, since some
// aspects of a hit depend on knowing this (knives & katana have different sounds for each of
@ -148,44 +229,6 @@ int ary_AKIMBO_UPGRADE_TO_WEAPON[] = {
// What akimbo weapons are involved, if asked?
// no, let's bitmask it.
/*
enum AkimboChoice{
NONE = 0, //???
LEFT = 1,
RIGHT = 2,
BOTH = 3
};
*/
#define BITS_AKIMBOCHOICE_NONE 0
#define BITS_AKIMBOCHOICE_LEFT 1
#define BITS_AKIMBOCHOICE_RIGHT 2
#define BITS_AKIMBOCHOICE_BOTH (BITS_AKIMBOCHOICE_LEFT | BITS_AKIMBOCHOICE_RIGHT)
// melee weapons don't really do firemode.
// Can be used for burst-fire bullets too for bypassing some requirements.
#define BITS_FIREMODE_NONE 0
#define BITS_FIREMODE_BURST 1
#define BITS_FIREMODE_FULL 2
#define BITS_FIREMODE_SEMI 4
#define BITS_FIREMODE_PUMP 8
//AKIMBO
//???
#define BITS_FIREMODE_AKIMBO_NONE 0
#define BITS_FIREMODE_AKIMBO_SEMI_AUTO 1
#define BITS_FIREMODE_AKIMBO_FREE_SEMI 2
#define BITS_FIREMODE_AKIMBO_FULL_AUTO 4
#define BITS_FIREMODE_AKIMBO_FREE_FULL 8
//string getFiremodeName(int firemodeBit);
//string getAkimboFiremodeName(int firemodeBit);
@ -220,59 +263,6 @@ string getAkimboFiremodeName(int firemodeBit){
#define BITS_WEAPONOPT_NONE 0x00
#define BITS_WEAPONOPT_SILENCER 0x01
#define BITS_WEAPONOPT_LASERSIGHT 0x02
#define BITS_WEAPONOPT_FLASHLIGHT 0x04
#define BITS_WEAPONOPT_SCOPE 0x08
#define BITS_WEAPONOPT_AKIMBO 0x10
#define BITS_WEAPONOPT_FULLLOAD 0x20
// This is a special flag to say, skip showing buyoptions altogether. The buy button goes straight to
// buying the weapon.
//good for items (stealh shoes, kevlar)
#define BITS_WEAPONOPT_INSTANT 0x80000000
// Types of weapons that, if present, can be toggled on/off by the player. Only some can.
// A lot of other behavior about this isn't automatic though, a change here does little elsewhere.
#define BITMASK_WEAPONOPT_TOGGLEABLE BITS_WEAPONOPT_LASERSIGHT | BITS_WEAPONOPT_FLASHLIGHT
// only min/max order of bits.
#define BITMASK_WEAPONOPT_TOGGLEABLE_MIN BITS_WEAPONOPT_LASERSIGHT
#define BITMASK_WEAPONOPT_TOGGLEABLE_MAX BITS_WEAPONOPT_FLASHLIGHT
#define BUYCATEGORY_NONE 0
#define BUYCATEGORY_HANDGUNS 1
#define BUYCATEGORY_SMGS 2
#define BUYCATEGORY_RIFLES 3
#define BUYCATEGORY_SHOTGUNS 4
#define BUYCATEGORY_SPECIALPURPOSE 5
#define WEAPONDATA_TYPEID_BASIC 0
#define WEAPONDATA_TYPEID_GUN 1
#define WEAPONDATA_TYPEID_IRONSIGHT 2
//#define WEAPONDATA_TYPEID_AKIMBO 3
#define WEAPONDATA_TYPEID_MELEE 3
//Note that THROWABLE is knives, not grenades.
#define WEAPONDATA_TYPEID_THROWABLE 4
#define ASSIGN_WEAPONDATA(arg_constName, arg_weaponName) ary_weaponData[WEAPON_ID::##arg_constName] = (weapondata_basic_t*) &weapon_##arg_weaponName;
// NOTICE - the ID lacks the "_akimbo" suffix. The actual variable name has the "_akimbo" suffix.
// Just provide the name of the weapon without the "_akimbo" suffix and it will be added as needed
// automatically.
#define ASSIGN_AKIMBOUPGRADEDATA(arg_constName, arg_weaponName) ary_akimboUpgradeData[WEAPON_AKIMBO_UPGRADE_ID::##arg_constName] = (weapondata_basic_t*) &weapon_##arg_weaponName##_akimbo;
#define ary_myWeapons_length 16
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
@ -824,16 +814,16 @@ BOOL weapon_shotgun_onInterrupt(player pl, weapondata_basic_t* basePRef, weapond
void weapon_shotgun_reload(player pl, weapondata_basic_t* basePRef, weapondynamic_t arg_thisWeapon);
void weapon_shotgun_onThink_reloadLogic(player pl, weapondata_gun_t* basePRef, weapondynamic_t arg_thisWeapon);
void weapon_gun_akimbo_semi_primaryAttack(void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack);
void weapon_gun_akimbo_semi_secondaryAttack(void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack);
void weapon_ironsight_akimbo_semi_secondaryAttack(void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack, int arg_weaponTypeID);
void weapon_gun_akimbo_semi_primaryAttack(MethodType_WeaponAttack arg_funAttack);
void weapon_gun_akimbo_semi_secondaryAttack(MethodType_WeaponAttack arg_funAttack);
void weapon_ironsight_akimbo_semi_secondaryAttack(MethodType_WeaponAttack arg_funAttack, int arg_weaponTypeID);
void weapon_gun_akimbo_full_primaryAttack(void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack);
void weapon_gun_akimbo_full_secondaryAttack(void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack);
void weapon_gun_akimbo_full_primaryAttack(MethodType_WeaponAttack arg_funAttack);
void weapon_gun_akimbo_full_secondaryAttack(MethodType_WeaponAttack arg_funAttack);
BOOL weapon_akimbo_semiAttackDualHack(player pl, weapondynamic_t arg_thisWeapon, int arg_flagger, void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack);
BOOL weapon_akimbo_fullAttackDualHack(player pl, weapondynamic_t arg_thisWeapon, int arg_flagger, void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack);
BOOL weapon_akimbo_AttackDualHack(player pl, weapondynamic_t arg_thisWeapon, int arg_flagger, void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack);
BOOL weapon_akimbo_semiAttackDualHack(player pl, weapondynamic_t arg_thisWeapon, int arg_flagger, MethodType_WeaponAttack arg_funAttack);
BOOL weapon_akimbo_fullAttackDualHack(player pl, weapondynamic_t arg_thisWeapon, int arg_flagger, MethodType_WeaponAttack arg_funAttack);
BOOL weapon_akimbo_AttackDualHack(player pl, weapondynamic_t arg_thisWeapon, int arg_flagger, MethodType_WeaponAttack arg_funAttack);
int weapon_akimbo_semiAttackChoice(player pl, weapondata_basic_t* basePRef, weapondynamic_t arg_thisWeapon, int attackTypeUsed);
int weapon_akimbo_fullAttackChoice(player pl, weapondata_basic_t* basePRef, weapondynamic_t arg_thisWeapon, int attackTypeUsed);

View File

@ -1,4 +1,17 @@
#define ASSIGN_WEAPONDATA(arg_constName, arg_weaponName) ary_weaponData[WEAPON_ID::##arg_constName] = (weapondata_basic_t*) &weapon_##arg_weaponName;
// NOTICE - the ID lacks the "_akimbo" suffix. The actual variable name has the "_akimbo" suffix.
// Just provide the name of the weapon without the "_akimbo" suffix and it will be added as needed
// automatically.
#define ASSIGN_AKIMBOUPGRADEDATA(arg_constName, arg_weaponName) ary_akimboUpgradeData[WEAPON_AKIMBO_UPGRADE_ID::##arg_constName] = (weapondata_basic_t*) &weapon_##arg_weaponName##_akimbo;
weapon_t w_null = {};
// Populate each slot with a member of the enum early on in runtime instead.
@ -640,7 +653,7 @@ weapon_shotgun_onThink_reloadLogic(player pl, weapondata_gun_t* basePRef, weapon
// happens there.
void
weapon_gun_akimbo_semi_primaryAttack(
void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack
MethodType_WeaponAttack arg_funAttack
){
player pl = (player)self;
weapondynamic_t arg_thisWeapon = pl.ary_myWeapons[pl.inventoryEquippedIndex];
@ -678,7 +691,7 @@ weapon_gun_akimbo_semi_primaryAttack(
// That version also needs the weapon type ID given for the ironsight-toggle call
void
weapon_gun_akimbo_semi_secondaryAttack(
void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack
MethodType_WeaponAttack arg_funAttack
){
player pl = (player)self;
weapondynamic_t arg_thisWeapon = pl.ary_myWeapons[pl.inventoryEquippedIndex];
@ -715,7 +728,7 @@ weapon_gun_akimbo_semi_secondaryAttack(
void
weapon_ironsight_akimbo_semi_secondaryAttack(
void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack,
MethodType_WeaponAttack arg_funAttack,
int arg_weaponTypeID
){
player pl = (player)self;
@ -751,14 +764,12 @@ weapon_ironsight_akimbo_semi_secondaryAttack(
// And now for full semi weapons (holding down the mouse fires continuously)
// They don't use the DUAL_TOLERANCE system regardless of the constant.
// Also, no ironsight version, that combo never happens.
void
weapon_gun_akimbo_full_primaryAttack(
void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack
MethodType_WeaponAttack arg_funAttack
){
player pl = (player)self;
weapondynamic_t arg_thisWeapon = pl.ary_myWeapons[pl.inventoryEquippedIndex];
@ -776,7 +787,7 @@ weapon_gun_akimbo_full_primaryAttack(
void
weapon_gun_akimbo_full_secondaryAttack(
void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack
MethodType_WeaponAttack arg_funAttack
){
player pl = (player)self;
weapondynamic_t arg_thisWeapon = pl.ary_myWeapons[pl.inventoryEquippedIndex];
@ -797,7 +808,7 @@ weapon_gun_akimbo_full_secondaryAttack(
BOOL
weapon_akimbo_AttackDualHack(
player pl, weapondynamic_t arg_thisWeapon, int arg_flagger,
void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack
MethodType_WeaponAttack arg_funAttack
){
//printfline("WELL WHAT. %.2f, %i, %i", pl.akimboDualFireToleranceTime, pl.akimboFirePrev, arg_flagger);
if(arg_flagger == 0){
@ -870,7 +881,7 @@ weapon_akimbo_AttackDualHack(
BOOL
weapon_akimbo_semiAttackDualHack(
player pl, weapondynamic_t arg_thisWeapon, int arg_flagger,
void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack
MethodType_WeaponAttack arg_funAttack
){
if(arg_thisWeapon.iFireModeAkimbo == BITS_FIREMODE_AKIMBO_SEMI_AUTO){
return FALSE;
@ -884,7 +895,7 @@ weapon_akimbo_semiAttackDualHack(
BOOL
weapon_akimbo_fullAttackDualHack(
player pl, weapondynamic_t arg_thisWeapon, int arg_flagger,
void(player pl, weapondynamic_t arg_thisWeapon, int attackTypeUsed) arg_funAttack
MethodType_WeaponAttack arg_funAttack
){
if(arg_thisWeapon.iFireModeAkimbo == BITS_FIREMODE_AKIMBO_FULL_AUTO){
return FALSE;