Skip to content

Commit

Permalink
Use MAX_PLAYERS everywhere for maximum player count
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVanheer committed Dec 1, 2021
1 parent b7b59d7 commit 565c27f
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 27 deletions.
6 changes: 3 additions & 3 deletions cl_dll/StudioModelRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS_HUD + 1];
#define TEAM3_COLOR 45
#define TEAM4_COLOR 100

int m_nPlayerGaitSequences[MAX_CLIENTS];
int m_nPlayerGaitSequences[MAX_PLAYERS];

// Global engine <-> studio model rendering code interface
engine_studio_api_t IEngineStudio;
Expand Down Expand Up @@ -1639,8 +1639,8 @@ char* ReturnCorrectedModelString(int iSwitchClass)
#endif

#ifdef _TFC
float g_flSpinUpTime[33];
float g_flSpinDownTime[33];
float g_flSpinUpTime[MAX_PLAYERS + 1];
float g_flSpinDownTime[MAX_PLAYERS + 1];
#endif


Expand Down
2 changes: 1 addition & 1 deletion cl_dll/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void DLLEXPORT HUD_CreateEntities()
}

#if defined(_TFC)
extern int g_bACSpinning[33];
extern int g_bACSpinning[MAX_PLAYERS + 1];
#endif

/*
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/ev_hldm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

extern engine_studio_api_t IEngineStudio;

static int tracerCount[32];
static int tracerCount[MAX_PLAYERS];

#include "pm_shared.h"

Expand Down
2 changes: 0 additions & 2 deletions cl_dll/hud_msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "particleman.h"
extern IParticleMan* g_pParticleMan;

#define MAX_CLIENTS 32

#if !defined(_TFC)
extern BEAM* pBeam;
extern BEAM* pBeam2;
Expand Down
16 changes: 10 additions & 6 deletions cl_dll/voice_status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void CVoiceStatus::Frame(double frametime)
m_Labels[i].m_pBackground->setVisible(false);
}

for (int i = 0; i < VOICE_MAX_PLAYERS; i++)
for (int i = 0; i < MAX_PLAYERS; i++)
UpdateBanButton(i);
}

Expand All @@ -340,7 +340,7 @@ void CVoiceStatus::CreateEntities()
cl_entity_t* localPlayer = gEngfuncs.GetLocalPlayer();

int iOutModel = 0;
for (int i = 0; i < VOICE_MAX_PLAYERS; i++)
for (int i = 0; i < MAX_PLAYERS; i++)
{
if (!m_VoicePlayers[i])
continue;
Expand Down Expand Up @@ -424,7 +424,7 @@ void CVoiceStatus::UpdateSpeakerStatus(int entindex, bool bTalking)
m_bServerAcked = bTalking;
}

if (entindex >= 0 && entindex <= VOICE_MAX_PLAYERS)
if (entindex >= 0 && entindex <= MAX_PLAYERS)
{
int iClient = entindex - 1;
if (iClient < 0)
Expand Down Expand Up @@ -530,9 +530,13 @@ void CVoiceStatus::UpdateServerState(bool bForce)

for (unsigned long dw = 0; dw < VOICE_MAX_PLAYERS_DW; dw++)
{
//The ban mask is a 32 bit int, so make sure this doesn't silently break.
//Note that the server will also need updating.
static_assert(MAX_PLAYERS <= 32, "The voice ban bit vector only supports up to 32 players");

unsigned long serverBanMask = 0;
unsigned long banMask = 0;
for (unsigned long i = 0; i < 32; i++)
for (unsigned long i = 0; i < MAX_PLAYERS; i++)
{
char playerID[16];
if (0 == gEngfuncs.GetPlayerUniqueID(i + 1, playerID))
Expand All @@ -541,7 +545,7 @@ void CVoiceStatus::UpdateServerState(bool bForce)
if (m_BanMgr.GetPlayerBan(playerID))
banMask |= 1 << i;

if (m_ServerBannedPlayers[dw * 32 + i])
if (m_ServerBannedPlayers[dw * MAX_PLAYERS + i])
serverBanMask |= 1 << i;
}

Expand Down Expand Up @@ -811,7 +815,7 @@ void CVoiceStatus::FreeBitmaps()
m_pScoreboardBanned = NULL;

// Clear references to the images in panels.
for (int i = 0; i < VOICE_MAX_PLAYERS; i++)
for (int i = 0; i < MAX_PLAYERS; i++)
{
if (m_pBanButtons[i])
{
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/voice_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class CVoiceStatus : public CHudBase, public vgui::CDefaultInputSignal
// It is checked periodically, and the server is told to squelch or unsquelch the appropriate players.
CPlayerBitVec m_ServerBannedPlayers;

cl_entity_s m_VoiceHeadModels[VOICE_MAX_PLAYERS]; // These aren't necessarily in the order of players. They are just
cl_entity_s m_VoiceHeadModels[MAX_PLAYERS]; // These aren't necessarily in the order of players. They are just
// a place for it to put data in during CreateEntities.

IVoiceStatusHelper *m_pHelper; // Each mod provides an implementation of this.
Expand All @@ -184,7 +184,7 @@ class CVoiceStatus : public CHudBase, public vgui::CDefaultInputSignal
vgui::BitmapTGA *m_pScoreboardSquelch;
vgui::BitmapTGA *m_pScoreboardBanned;

vgui::Label *m_pBanButtons[VOICE_MAX_PLAYERS]; // scoreboard buttons.
vgui::Label *m_pBanButtons[MAX_PLAYERS]; // scoreboard buttons.

// Squelch mode stuff.
bool m_bInSquelchMode;
Expand Down
1 change: 0 additions & 1 deletion common/com_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#define STUDIO_RENDER 1
#define STUDIO_EVENTS 2

#define MAX_CLIENTS 32
#define MAX_EDICTS 900

#define MAX_MODEL_NAME 64
Expand Down
1 change: 1 addition & 0 deletions dlls/cdll_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#pragma once

constexpr int MAX_PLAYERS = 32;
#define MAX_WEAPONS 64 // ???

#define MAX_WEAPON_SLOTS 5 // hud item selection slots
Expand Down
2 changes: 2 additions & 0 deletions dlls/triggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,8 @@ void CBaseTrigger::HurtTouch(CBaseEntity* pOther)
if ((pev->spawnflags & SF_TRIGGER_HURT_NO_CLIENTS) != 0 && pOther->IsPlayer())
return;

static_assert(MAX_PLAYERS <= 32, "Rework the player mask logic to support more than 32 players");

// HACKHACK -- In multiplayer, players touch this based on packet receipt.
// So the players who send packets later aren't always hurt. Keep track of
// how much time has passed and whether or not you've touched that player
Expand Down
6 changes: 3 additions & 3 deletions game_shared/voice_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#pragma once

#include "cdll_dll.h"
#include "bitvec.h"

#define VOICE_MAX_PLAYERS 32 // (todo: this should just be set to MAX_CLIENTS).
#define VOICE_MAX_PLAYERS_DW ((VOICE_MAX_PLAYERS / 32) + !!(VOICE_MAX_PLAYERS & 31))
constexpr int VOICE_MAX_PLAYERS_DW = (MAX_PLAYERS / 32) + ((MAX_PLAYERS & 31) != 0 ? 1 : 0);

typedef CBitVec<VOICE_MAX_PLAYERS> CPlayerBitVec;
typedef CBitVec<MAX_PLAYERS> CPlayerBitVec;
9 changes: 5 additions & 4 deletions game_shared/voice_gamemgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// $NoKeywords: $
//=============================================================================

#include "extdll.h"
#include "voice_gamemgr.h"
#include <assert.h>
#include "extdll.h"
Expand All @@ -22,12 +23,12 @@ CPlayerBitVec g_PlayerModEnable; // Set to 1 for each player if the player wants
// (If it's zero, then the server reports that the game rules are saying the
// player can't hear anyone).

CPlayerBitVec g_BanMasks[VOICE_MAX_PLAYERS]; // Tells which players don't want to hear each other.
CPlayerBitVec g_BanMasks[MAX_PLAYERS]; // Tells which players don't want to hear each other.
// These are indexed as clients and each bit represents a client
// (so player entity is bit+1).

CPlayerBitVec g_SentGameRulesMasks[VOICE_MAX_PLAYERS]; // These store the masks we last sent to each client so we can determine if
CPlayerBitVec g_SentBanMasks[VOICE_MAX_PLAYERS]; // we need to resend them.
CPlayerBitVec g_SentGameRulesMasks[MAX_PLAYERS]; // These store the masks we last sent to each client so we can determine if
CPlayerBitVec g_SentBanMasks[MAX_PLAYERS]; // we need to resend them.
CPlayerBitVec g_bWantModEnable;

cvar_t voice_serverdebug = {"voice_serverdebug", "0"};
Expand Down Expand Up @@ -101,7 +102,7 @@ bool CVoiceGameMgr::Init(
int maxClients)
{
m_pHelper = pHelper;
m_nMaxPlayers = VOICE_MAX_PLAYERS < maxClients ? VOICE_MAX_PLAYERS : maxClients;
m_nMaxPlayers = MAX_PLAYERS < maxClients ? MAX_PLAYERS : maxClients;
g_engfuncs.pfnPrecacheModel("sprites/voiceicon.spr");

m_msgPlayerVoiceMask = REG_USER_MSG("VoiceMask", VOICE_MAX_PLAYERS_DW * 4 * 2);
Expand Down
6 changes: 2 additions & 4 deletions pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ typedef struct hull_s
// fall over
#define ROLL 2

#define MAX_CLIENTS 32

#define CONTENTS_CURRENT_0 -9
#define CONTENTS_CURRENT_90 -10
#define CONTENTS_CURRENT_180 -11
Expand All @@ -138,7 +136,7 @@ typedef struct hull_s
#define CONTENTS_TRANSLUCENT -15

static Vector rgv3tStuckTable[54];
static int rgStuckLast[MAX_CLIENTS][2];
static int rgStuckLast[MAX_PLAYERS][2];

// Texture names
static int gcTextures = 0;
Expand Down Expand Up @@ -1707,7 +1705,7 @@ bool PM_CheckStuck()
int i;
pmtrace_t traceresult;

static float rgStuckCheckTime[MAX_CLIENTS][2]; // Last time we did a full
static float rgStuckCheckTime[MAX_PLAYERS][2]; // Last time we did a full

// If position is okay, exit
hitent = pmove->PM_TestPlayerPosition(pmove->origin, &traceresult);
Expand Down

0 comments on commit 565c27f

Please sign in to comment.