Skip to content

Commit

Permalink
Refactor some functions from macro to real functions
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileYzn committed Jan 26, 2024
1 parent 678796c commit b5d282b
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 70 deletions.
2 changes: 1 addition & 1 deletion MatchBot/MatchAdmin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void CMatchAdmin::ServerActivate()
catch (...)
{
// Catch for erros
LOG_CONSOLE(PLID, "[%s] %s", __func__, lpMemScript->GetError().c_str());
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%s] %s", __func__, lpMemScript->GetError().c_str());
}
}

Expand Down
32 changes: 16 additions & 16 deletions MatchBot/MatchAdminMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ void CMatchAdminMenu::KickMenuHandle(int EntityIndex, P_MENU_ITEM Item)
{
gMatchUtil.ServerCommand("kick #%d", g_engfuncs.pfnGetPlayerUserId(Target->edict()));

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" kick \"%s<%i><%s><%s>\"",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down Expand Up @@ -254,9 +254,9 @@ void CMatchAdminMenu::BanMenuHandle(int EntityIndex, P_MENU_ITEM Item)

gMatchUtil.ServerCommand("wait;wait;writeid;writeip");

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" banned \"%s<%i><%s><%s>\" for %d min(s)",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down Expand Up @@ -312,9 +312,9 @@ void CMatchAdminMenu::SlayMenuHandle(int EntityIndex, P_MENU_ITEM Item)
{
MDLL_ClientKill(Target->edict());

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" slays \"%s<%i><%s><%s>\"",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down Expand Up @@ -394,9 +394,9 @@ void CMatchAdminMenu::TeamMenuHandle(int EntityIndex, P_MENU_ITEM Item)

Target->CSPlayer()->JoinTeam((TeamName)Item.Extra);

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" set team \"%s<%i><%s><%s>\"",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down Expand Up @@ -449,9 +449,9 @@ void CMatchAdminMenu::MapMenuHandle(int EntityIndex, P_MENU_ITEM Item)

gMatchUtil.SayText(nullptr, Player->entindex(), _T("^3%s^1 changed map to: ^4%s^1..."), STRING(Player->edict()->v.netname), Item.Text.c_str());

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" changed map to %s",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down Expand Up @@ -576,9 +576,9 @@ bool CMatchAdminMenu::Message(CBasePlayer* Player)

gMatchUtil.SayText(nullptr, Player->entindex(), _T("^3(%s)^1: %s"), STRING(Player->edict()->v.netname), Args.c_str());

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" message: %s",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down Expand Up @@ -627,9 +627,9 @@ bool CMatchAdminMenu::Rcon(CBasePlayer* Player)

gMatchUtil.SayText(Player->edict(), Player->entindex(), _T("^3Executed^1: %s"), Args.c_str());

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" server command: %s",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down Expand Up @@ -677,9 +677,9 @@ void CMatchAdminMenu::SwapTeams(int EntityIndex)
// Send message
gMatchUtil.SayText(nullptr, Player->entindex(), _T("^3%s^1 changed team sides manually."), STRING(Player->edict()->v.netname));

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" changed team sides",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down
20 changes: 10 additions & 10 deletions MatchBot/MatchBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,9 +1186,9 @@ void CMatchBot::StartVoteMap(CBasePlayer* Player)
// Start Match
this->SetState(STATE_START);

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" started vote map",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down Expand Up @@ -1242,9 +1242,9 @@ void CMatchBot::StartVoteTeam(CBasePlayer* Player)
// Start Match
this->SetState(STATE_START);

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" started vote team",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down Expand Up @@ -1318,9 +1318,9 @@ void CMatchBot::StartMatch(CBasePlayer* Player)
// Change state
gMatchTask.Create(TASK_CHANGE_STATE, 3.0f, false, (void*)this->NextState, State);

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" started match",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down Expand Up @@ -1384,9 +1384,9 @@ void CMatchBot::StopMatch(CBasePlayer* Player)

if (Player)
{
LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" stopped match",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down Expand Up @@ -1435,9 +1435,9 @@ void CMatchBot::RestartMatch(CBasePlayer* Player)

if (Player)
{
LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" restarted match",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down
2 changes: 1 addition & 1 deletion MatchBot/MatchCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void CMatchCommand::ServerActivate()
catch (...)
{
// Catch for erros
LOG_CONSOLE(PLID, "[%s] %s", __func__, lpMemScript->GetError().c_str());
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%s] %s", __func__, lpMemScript->GetError().c_str());
}
}

Expand Down
10 changes: 5 additions & 5 deletions MatchBot/MatchCvarMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void CMatchCvarMenu::ServerActivate()
catch (...)
{
// Catch for erros
LOG_CONSOLE(PLID, "[%s] %s", __func__, lpMemScript->GetError().c_str());
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%s] %s", __func__, lpMemScript->GetError().c_str());
}
}

Expand Down Expand Up @@ -144,9 +144,9 @@ void CMatchCvarMenu::UpdateValue(CBasePlayer* Player, int ItemIndex)

g_engfuncs.pfnCVarSetString(this->m_Data[ItemIndex].Pointer->name, it->c_str());

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" changed cvar %s to %s",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand All @@ -162,9 +162,9 @@ void CMatchCvarMenu::UpdateValue(CBasePlayer* Player, int ItemIndex)
{
g_engfuncs.pfnCVarSetString(this->m_Data[ItemIndex].Pointer->name, begin->c_str());

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" changed cvar %s to %s",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down
2 changes: 1 addition & 1 deletion MatchBot/MatchLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void CMatchLanguage::Load()
catch (...)
{
// Catch for erros
LOG_CONSOLE(PLID, "[%s] %s", __func__, lpMemScript->GetError().c_str());
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%s] %s", __func__, lpMemScript->GetError().c_str());
}
}

Expand Down
4 changes: 2 additions & 2 deletions MatchBot/MatchMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void CMatchMenu::Hide(int EntityIndex)
{
static int iMsgShowMenu;

if (iMsgShowMenu || (iMsgShowMenu = gpMetaUtilFuncs->pfnGetUserMsgID(PLID, "ShowMenu", NULL)))
if (iMsgShowMenu || (iMsgShowMenu = gpMetaUtilFuncs->pfnGetUserMsgID(&Plugin_info, "ShowMenu", NULL)))
{
g_engfuncs.pfnMessageBegin(MSG_ONE, iMsgShowMenu, nullptr, Player->edict());
g_engfuncs.pfnWriteShort(0);
Expand Down Expand Up @@ -246,7 +246,7 @@ void CMatchMenu::ShowMenu(int EntityIndex, int Slots, int Time, std::string Text
{
static int iMsgShowMenu;

if (iMsgShowMenu || (iMsgShowMenu = gpMetaUtilFuncs->pfnGetUserMsgID(PLID, "ShowMenu", NULL)))
if (iMsgShowMenu || (iMsgShowMenu = gpMetaUtilFuncs->pfnGetUserMsgID(&Plugin_info, "ShowMenu", NULL)))
{
Player->m_iMenu = Menu_OFF;

Expand Down
2 changes: 1 addition & 1 deletion MatchBot/MatchPause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void CMatchPause::SetRoundTime(int Time, bool FreezePeriod)
static int iMsgRoundTime;

// If has message index or set message index if is null
if (iMsgRoundTime || (iMsgRoundTime = gpMetaUtilFuncs->pfnGetUserMsgID(PLID, "RoundTime", NULL)))
if (iMsgRoundTime || (iMsgRoundTime = gpMetaUtilFuncs->pfnGetUserMsgID(&Plugin_info, "RoundTime", NULL)))
{
g_engfuncs.pfnMessageBegin(MSG_ALL, iMsgRoundTime, NULL, NULL);
g_engfuncs.pfnWriteShort(Time);
Expand Down
12 changes: 6 additions & 6 deletions MatchBot/MatchPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ void CMatchPlayer::PlayerMenuActionHandle(int EntityIndex, P_MENU_ITEM Item)
{
gMatchUtil.ServerCommand("kick #%d", Item.Extra);

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" kick \"%s<%i><%s><%s>\"",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand All @@ -389,9 +389,9 @@ void CMatchPlayer::PlayerMenuActionHandle(int EntityIndex, P_MENU_ITEM Item)
{
MDLL_ClientKill(Target->edict());

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" slays \"%s<%i><%s><%s>\"",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down Expand Up @@ -446,9 +446,9 @@ void CMatchPlayer::PlayerBanMenuActionHandle(int EntityIndex, P_MENU_ITEM Item)

gMatchUtil.ServerCommand("wait;wait;writeid;writeip");

LOG_MESSAGE
gpMetaUtilFuncs->pfnLogMessage
(
PLID,
&Plugin_info,
"\"%s<%i><%s><%s>\" banned \"%s<%i><%s><%s>\" for %d min(s)",
STRING(Player->edict()->v.netname),
g_engfuncs.pfnGetPlayerUserId(Player->edict()),
Expand Down
12 changes: 6 additions & 6 deletions MatchBot/MatchUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void CMatchUtil::TeamInfo(edict_t* pEntity, int playerIndex, const char* pszTeam
{
static int iMsgTeamInfo;

if (iMsgTeamInfo || (iMsgTeamInfo = gpMetaUtilFuncs->pfnGetUserMsgID(PLID, "TeamInfo", NULL)))
if (iMsgTeamInfo || (iMsgTeamInfo = gpMetaUtilFuncs->pfnGetUserMsgID(&Plugin_info, "TeamInfo", NULL)))
{
g_engfuncs.pfnMessageBegin(MSG_ONE, iMsgTeamInfo, nullptr, pEntity);
g_engfuncs.pfnWriteByte(playerIndex);
Expand All @@ -77,7 +77,7 @@ void CMatchUtil::MakeDeathMessage(edict_t* pKiller, edict_t* pVictim, bool Heads
{
static int iMsgDeathMsg;

if (iMsgDeathMsg || (iMsgDeathMsg = gpMetaUtilFuncs->pfnGetUserMsgID(PLID, "DeathMsg", NULL)))
if (iMsgDeathMsg || (iMsgDeathMsg = gpMetaUtilFuncs->pfnGetUserMsgID(&Plugin_info, "DeathMsg", NULL)))
{
g_engfuncs.pfnMessageBegin(MSG_ALL, iMsgDeathMsg, NULL, NULL);

Expand All @@ -97,7 +97,7 @@ void CMatchUtil::SayText(edict_t* pEntity, int Sender, const char* Format, ...)
{
static int iMsgSayText;

if (iMsgSayText || (iMsgSayText = gpMetaUtilFuncs->pfnGetUserMsgID(PLID, "SayText", NULL)))
if (iMsgSayText || (iMsgSayText = gpMetaUtilFuncs->pfnGetUserMsgID(&Plugin_info, "SayText", NULL)))
{
char Buffer[191] = { 0 };

Expand Down Expand Up @@ -188,7 +188,7 @@ void CMatchUtil::ClientPrint(edict_t* pEntity, int msg_dest, const char* Format,

static int iMsgTextMsg;

if (iMsgTextMsg || (iMsgTextMsg = gpMetaUtilFuncs->pfnGetUserMsgID(PLID, "TextMsg", NULL)))
if (iMsgTextMsg || (iMsgTextMsg = gpMetaUtilFuncs->pfnGetUserMsgID(&Plugin_info, "TextMsg", NULL)))
{
if (pEntity)
{
Expand Down Expand Up @@ -579,7 +579,7 @@ std::map<int, std::string> CMatchUtil::GetMapList(bool CurrentMap)
catch (...)
{
// Catch for erros
LOG_CONSOLE(PLID, "[%s] %s", __func__, lpMemScript->GetError().c_str());
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%s] %s", __func__, lpMemScript->GetError().c_str());
}
}

Expand All @@ -594,7 +594,7 @@ void CMatchUtil::ShowMotd(edict_t* pEntity, char* Motd, int MotdLength)
{
static int iMsgMOTD;

if (iMsgMOTD || (iMsgMOTD = gpMetaUtilFuncs->pfnGetUserMsgID(PLID, "MOTD", NULL)))
if (iMsgMOTD || (iMsgMOTD = gpMetaUtilFuncs->pfnGetUserMsgID(&Plugin_info, "MOTD", NULL)))
{
if (MotdLength < 128)
{
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())
{
LOG_CONSOLE(PLID, "[%s] ReHLDS API Can only run on Half-Life Dedicated Server", Plugin_info.logtag);
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%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)
{
LOG_CONSOLE(PLID, "[%s] Failed to locate engine module", Plugin_info.logtag);
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%s] Failed to locate engine module", Plugin_info.logtag);
return false;
}

CreateInterfaceFn ifaceFactory = Sys_GetFactory(engineModule);

if (!ifaceFactory)
{
LOG_CONSOLE(PLID, "[%s] Failed to locate interface factory in engine module", Plugin_info.logtag);
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%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)
{
LOG_CONSOLE(PLID, "[%s] Failed to locate retrieve rehlds api interface from engine module, return code is %d", Plugin_info.logtag, retCode);
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%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)
{
LOG_CONSOLE(PLID, "[%s] ReHLDS API major version mismatch; expected %d, real %d", Plugin_info.logtag, REHLDS_API_VERSION_MAJOR, majorVersion);
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%s] ReHLDS API major version mismatch; expected %d, real %d", Plugin_info.logtag, REHLDS_API_VERSION_MAJOR, majorVersion);

if (majorVersion < REHLDS_API_VERSION_MAJOR)
{
LOG_CONSOLE(PLID, "[%s] Please update the ReHLDS up to a major version API >= %d", Plugin_info.logtag, REHLDS_API_VERSION_MAJOR);
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%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)
{
LOG_CONSOLE(PLID, "[%s] Please update the %s up to a major version API >= %d", Plugin_info.logtag, Plugin_info.logtag, majorVersion);
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%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)
{
LOG_CONSOLE(PLID, "[%s] ReHLDS API minor version mismatch; expected at least %d, real %d", Plugin_info.logtag, REHLDS_API_VERSION_MINOR, minorVersion);
LOG_CONSOLE(PLID, "[%s] Please update the ReHLDS up to a minor version API >= %d", Plugin_info.logtag, REHLDS_API_VERSION_MINOR);
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%s] ReHLDS API minor version mismatch; expected at least %d, real %d", Plugin_info.logtag, REHLDS_API_VERSION_MINOR, minorVersion);
gpMetaUtilFuncs->pfnLogConsole(&Plugin_info, "[%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 b5d282b

Please sign in to comment.