Skip to content

Commit

Permalink
Updated Game Description
Browse files Browse the repository at this point in the history
Updated Game Description
  • Loading branch information
SmileYzn committed Dec 18, 2024
1 parent 6b45988 commit 955f081
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 72 deletions.
4 changes: 2 additions & 2 deletions MatchBot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ OBJECTS = *.cpp
LINKER = -static-libgcc -static-libstdc++

# C flags
CFLAGS = -std=gnu++11 -shared -m32 -mtune=generic -msse3 -msse4.1 -pipe -g0 -O3 -s -flto=auto -funroll-loops -fno-stack-protector -g -DNDEBUG -Dlinux -D__linux__ -DGLIBCXX_USE_CXX11_ABI=0 -U_FORTIFY_SOURCE
CFLAGS = -std=gnu++11 -shared -m32 -mtune=generic -msse3 -msse4.1 -pipe -g0 -O3 -s -flto=auto -funroll-loops -fno-stack-protector -g -DNDEBUG -Dlinux -D__linux__ -DGLIBCXX_USE_CXX11_ABI=1 -U_FORTIFY_SOURCE

# Include directory
INCLUDE = -I. -I$(CSSDK)/common -I$(CSSDK)/dlls -I$(CSSDK)/engine -I$(CSSDK)/game_shared -I$(CSSDK)/pm_shared -I$(CSSDK)/public -I$(METAMOD)
Expand All @@ -41,7 +41,7 @@ $(NAME): $(OBJ_LINUX)
$(COMPILER) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINKER) -o$(BIN_DIR)/$(NAME)_mm.so

check:
cppcheck $(INCLUDE) --quiet --max-configs=100 --std=gnu++11 -DNDEBUG -Dlinux -D__linux__ -DGLIBCXX_USE_CXX11_ABI=1 -U_FORTIFY_SOURCE .
cppcheck $(INCLUDE) --quiet --max-configs=100 -DNDEBUG -Dlinux -D__linux__ -DGLIBCXX_USE_CXX11_ABI=1 -U_FORTIFY_SOURCE .

default: all

Expand Down
31 changes: 19 additions & 12 deletions MatchBot/MatchBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,14 +1152,24 @@ void CMatchBot::RoundEnd(int winStatus, ScenarioEventEndRound event, float tmDel
// Update Game Name
void CMatchBot::UpdateGameName()
{
// Game Name
static char GameDesc[32];

// If has CSGameRules loaded
if (g_pGameRules)
{
// Store original game description
if (!this->m_GameDesc.empty())
if (this->m_GameDesc.empty())
{
// Get default game name
this->m_GameDesc = CSGameRules()->GetGameDescription();
if (CSGameRules()->GetGameDescription())
{
this->m_GameDesc = CSGameRules()->GetGameDescription();
}
else
{
this->m_GameDesc = "Counter-Strike";
}
}

// If is enabled
Expand All @@ -1172,30 +1182,27 @@ void CMatchBot::UpdateGameName()
if (State == STATE_DEAD)
{
// Restore default game name
Q_strcpy(CSGameRules()->m_GameDesc, this->m_GameDesc.c_str());
Q_strncpy(GameDesc, this->m_GameDesc.c_str(), sizeof(GameDesc));
}
else if (State == STATE_WARMUP || State == STATE_START)
{
// Set game name from state name
Q_strcpy(CSGameRules()->m_GameDesc, gMatchBot.GetState(State));
Q_strncpy(GameDesc, gMatchBot.GetState(State), sizeof(GameDesc));
}
else if (State >= STATE_FIRST_HALF && State <= STATE_END)
{
// Game Name
static char GameName[32];

// Format game name with teams and scores
Q_snprintf(GameName, sizeof(GameName), "%s %d : %d %s", gMatchBot.GetTeam(TERRORIST, true), gMatchBot.GetScore(TERRORIST), gMatchBot.GetScore(CT), gMatchBot.GetTeam(CT, true));

// Set to game description
Q_strcpy_s(CSGameRules()->m_GameDesc, GameName);
Q_snprintf(GameDesc, sizeof(GameDesc), "%s %d : %d %s", gMatchBot.GetTeam(TERRORIST, true), gMatchBot.GetScore(TERRORIST), gMatchBot.GetScore(CT), gMatchBot.GetTeam(CT, true));
}
}
else
{
// Restore default game name
Q_strcpy(CSGameRules()->m_GameDesc, this->m_GameDesc.c_str());
Q_strncpy(GameDesc, this->m_GameDesc.c_str(), sizeof(GameDesc));
}

// Set
CSGameRules()->m_GameDesc = GameDesc;
}
}

Expand Down
2 changes: 0 additions & 2 deletions MatchBot/MatchMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ std::array<CMatchMenu, MAX_CLIENTS + 1> gMatchMenu;

void CMatchMenu::Clear()
{
this->m_Text = "";

this->m_Data.clear();

this->m_Page = -1;
Expand Down
2 changes: 1 addition & 1 deletion MatchBot/MatchPause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void CMatchPause::ServerActivate()

this->m_Paused = false;

this->m_PauseTeam = "";
this->m_PauseTeam;

this->m_BuyTime = 0.0f;
}
Expand Down
8 changes: 4 additions & 4 deletions MatchBot/MatchPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ bool CMatchPlayer::PlayerConnect(edict_t* pEntity, const char* pszName, const ch
this->m_Player[AuthId].Status = 1;

// Disconnect reason
this->m_Player[AuthId].DcReason = "";
this->m_Player[AuthId].DcReason.clear();

// Last Team
this->m_Player[AuthId].LastTeam = TeamName::UNASSIGNED;
Expand Down Expand Up @@ -155,7 +155,7 @@ void CMatchPlayer::PlayerGetIntoGame(CBasePlayer* Player)
this->m_Player[AuthId].Status = 2;

// Disconnect reason
this->m_Player[AuthId].DcReason = "";
this->m_Player[AuthId].DcReason.clear();

// Last Team
this->m_Player[AuthId].LastTeam = Player->m_iTeam;
Expand Down Expand Up @@ -205,7 +205,7 @@ void CMatchPlayer::PlayerSwitchTeam(CBasePlayer* Player)
this->m_Player[AuthId].Status = 2;

// Disconnect reason
this->m_Player[AuthId].DcReason = "";
this->m_Player[AuthId].DcReason.clear();

// Last Team
this->m_Player[AuthId].LastTeam = Player->m_iTeam;
Expand Down Expand Up @@ -437,7 +437,7 @@ void CMatchPlayer::PlayerMenuActionHandle(int EntityIndex, P_MENU_ITEM Item)

gpMetaUtilFuncs->pfnLogMessage
(
&Plugin_info,
PLID,
"\"%s<%i><%s><%s>\" kick \"%s<%i><%s><%s>\"",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down
18 changes: 9 additions & 9 deletions MatchBot/MatchStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ void CMatchStats::RoundEvent(GameEventType GameEvent, CBasePlayer* Killer, CBase
}

// Set victim
Event.Victim = "";
Event.Victim.clear();

// Set origin
Event.VictimOrigin = { 0.0f, 0.0f, 0.0f };
Expand All @@ -715,7 +715,7 @@ void CMatchStats::RoundEvent(GameEventType GameEvent, CBasePlayer* Killer, CBase
case EVENT_BOMB_DROPPED:
{
// Set killer
Event.Killer = "";
Event.Killer.clear();

// Set origin
Event.KillerOrigin = { 0.0f, 0.0f, 0.0f };
Expand Down Expand Up @@ -755,7 +755,7 @@ void CMatchStats::RoundEvent(GameEventType GameEvent, CBasePlayer* Killer, CBase
}

// Set victim
Event.Victim = "";
Event.Victim.clear();

// Set origin
Event.VictimOrigin = { 0.0f, 0.0f, 0.0f };
Expand Down Expand Up @@ -790,7 +790,7 @@ void CMatchStats::RoundEvent(GameEventType GameEvent, CBasePlayer* Killer, CBase
}

// Set victim
Event.Victim = "";
Event.Victim.clear();

// Set origin
Event.VictimOrigin = { 0.0f, 0.0f, 0.0f };
Expand Down Expand Up @@ -821,7 +821,7 @@ void CMatchStats::RoundEvent(GameEventType GameEvent, CBasePlayer* Killer, CBase
}

// Set victim
Event.Victim = "";
Event.Victim.clear();

// Set origin
Event.VictimOrigin = { 0.0f, 0.0f, 0.0f };
Expand Down Expand Up @@ -854,13 +854,13 @@ void CMatchStats::RoundEvent(GameEventType GameEvent, CBasePlayer* Killer, CBase
Event.Loser = CT;

// Set killer
Event.Killer = "";
Event.Killer.clear();

// Set origin
Event.KillerOrigin = { 0.0f, 0.0f, 0.0f };

// Set victim
Event.Victim = "";
Event.Victim.clear();

// Set origin
Event.VictimOrigin = { 0.0f, 0.0f, 0.0f };
Expand All @@ -884,13 +884,13 @@ void CMatchStats::RoundEvent(GameEventType GameEvent, CBasePlayer* Killer, CBase
Event.Loser = TERRORIST;

// Set killer
Event.Killer = "";
Event.Killer.clear();

// Set origin
Event.KillerOrigin = { 0.0f, 0.0f, 0.0f };

// Set victim
Event.Victim = "";
Event.Victim.clear();

// Set origin
Event.VictimOrigin = { 0.0f, 0.0f, 0.0f };
Expand Down
6 changes: 3 additions & 3 deletions MatchBot/MatchStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ typedef struct S_MATCH_DATA
void Reset()
{
// Reset host name
this->HostName = "";
this->HostName.clear();

// Reset Map Name
this->Map = "";
this->Map.clear();

// Reset Address
this->Address = "";
this->Address.clear();

// Reset match time
this->Time.fill(0U);
Expand Down
30 changes: 12 additions & 18 deletions MatchBot/MatchUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,26 @@ int CMatchUtil::MakeDirectory(const char* Path)
// Register console variable
cvar_t* CMatchUtil::CvarRegister(const char* Name, const char* Value)
{
// Get cvar pointer
cvar_t* Pointer = g_engfuncs.pfnCVarGetPointer(Name);

// If not exists
if (!Pointer)
{
// Variable for Cvar Helper
this->m_CvarData[Name].name = Name;
if (Name)
{
this->m_CvarData[Name].name = Name;

// Set name
this->m_CvarData[Name].string = (char*)(Value);

// Set flags
this->m_CvarData[Name].flags = (FCVAR_SERVER | FCVAR_SPONLY);
this->m_CvarData[Name].string = strdup(Value);

// Register the variable
g_engfuncs.pfnCVarRegister(&this->m_CvarData[Name]);
this->m_CvarData[Name].flags = (FCVAR_SERVER | FCVAR_PROTECTED | FCVAR_SPONLY | FCVAR_UNLOGGED);

// Get created pointer
Pointer = g_engfuncs.pfnCVarGetPointer(this->m_CvarData[Name].name);
g_engfuncs.pfnCVarRegister(&this->m_CvarData[Name]);

// If is not null
if(Pointer)
{
// We can set values
g_engfuncs.pfnCvar_DirectSet(Pointer, Value);
Pointer = g_engfuncs.pfnCVarGetPointer(this->m_CvarData[Name].name);

if (Pointer)
{
g_engfuncs.pfnCvar_DirectSet(Pointer, Value);
}
}
}

Expand Down
18 changes: 9 additions & 9 deletions MatchBot/ReAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bool ReAPI_Init()
{
if (!IS_DEDICATED_SERVER())
{
gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] ReHLDS API Can only run on Half-Life Dedicated Server", Plugin_info.logtag);
//gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] ReHLDS API Can only run on Half-Life Dedicated Server", Plugin_info.logtag);
return false;
}

Expand All @@ -25,15 +25,15 @@ bool ReAPI_Init()

if (!engineModule)
{
gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] Failed to locate engine module", Plugin_info.logtag);
//gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] Failed to locate engine module", Plugin_info.logtag);
return false;
}

CreateInterfaceFn ifaceFactory = Sys_GetFactory(engineModule);

if (!ifaceFactory)
{
gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] Failed to locate interface factory in engine module", Plugin_info.logtag);
//gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] Failed to locate interface factory in engine module", Plugin_info.logtag);
return false;
}

Expand All @@ -43,7 +43,7 @@ bool ReAPI_Init()

if (!g_RehldsApi)
{
gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] Failed to locate retrieve rehlds api interface from engine module, return code is %d", Plugin_info.logtag, retCode);
//gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] Failed to locate retrieve rehlds api interface from engine module, return code is %d", Plugin_info.logtag, retCode);
return false;
}

Expand All @@ -52,25 +52,25 @@ bool ReAPI_Init()

if (majorVersion != REHLDS_API_VERSION_MAJOR)
{
gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] ReHLDS API major version mismatch; expected %d, real %d", Plugin_info.logtag, REHLDS_API_VERSION_MAJOR, majorVersion);
//gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] ReHLDS API major version mismatch; expected %d, real %d", Plugin_info.logtag, REHLDS_API_VERSION_MAJOR, majorVersion);

if (majorVersion < REHLDS_API_VERSION_MAJOR)
{
gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] Please update the ReHLDS up to a major version API >= %d", Plugin_info.logtag, REHLDS_API_VERSION_MAJOR);
//gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] Please update the ReHLDS up to a major version API >= %d", Plugin_info.logtag, REHLDS_API_VERSION_MAJOR);
}

else if (majorVersion > REHLDS_API_VERSION_MAJOR)
{
gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] Please update the %s up to a major version API >= %d", Plugin_info.logtag, Plugin_info.logtag, majorVersion);
//gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] Please update the %s up to a major version API >= %d", Plugin_info.logtag, Plugin_info.logtag, majorVersion);
}

return false;
}

if (minorVersion < REHLDS_API_VERSION_MINOR)
{
gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] ReHLDS API minor version mismatch; expected at least %d, real %d", Plugin_info.logtag, REHLDS_API_VERSION_MINOR, minorVersion);
gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] Please update the ReHLDS up to a minor version API >= %d", Plugin_info.logtag, REHLDS_API_VERSION_MINOR);
//gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] ReHLDS API minor version mismatch; expected at least %d, real %d", Plugin_info.logtag, REHLDS_API_VERSION_MINOR, minorVersion);
//gpMetaUtilFuncs->pfnLogConsole(PLID, "[%s] Please update the ReHLDS up to a minor version API >= %d", Plugin_info.logtag, REHLDS_API_VERSION_MINOR);
return false;
}

Expand Down
Loading

0 comments on commit 955f081

Please sign in to comment.