From 720572ddda7d22ef8c60bd6d03c07d508883fd84 Mon Sep 17 00:00:00 2001 From: dobrykafe Date: Thu, 29 Feb 2024 01:17:11 +0100 Subject: [PATCH] make chat command arguments case-insensitive when possible --- src/game/server/ddracechat.cpp | 46 +++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/game/server/ddracechat.cpp b/src/game/server/ddracechat.cpp index ede927d60..b52825e17 100644 --- a/src/game/server/ddracechat.cpp +++ b/src/game/server/ddracechat.cpp @@ -151,7 +151,7 @@ void CGameContext::ConSettings(IConsole::IResult *pResult, void *pUserData) float HookTemp; pSelf->m_Tuning.Get("player_collision", &ColTemp); pSelf->m_Tuning.Get("player_hooking", &HookTemp); - if(str_comp(pArg, "teams") == 0) + if(str_comp_nocase(pArg, "teams") == 0) { str_format(aBuf, sizeof(aBuf), "%s %s", g_Config.m_SvTeam == SV_TEAM_ALLOWED ? @@ -162,61 +162,61 @@ void CGameContext::ConSettings(IConsole::IResult *pResult, void *pUserData) "and all of your team will die if the team is locked"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", aBuf); } - else if(str_comp(pArg, "cheats") == 0) + else if(str_comp_nocase(pArg, "cheats") == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", g_Config.m_SvTestingCommands ? "Cheats are enabled on this server" : "Cheats are disabled on this server"); } - else if(str_comp(pArg, "collision") == 0) + else if(str_comp_nocase(pArg, "collision") == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", ColTemp ? "Players can collide on this server" : "Players can't collide on this server"); } - else if(str_comp(pArg, "hooking") == 0) + else if(str_comp_nocase(pArg, "hooking") == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", HookTemp ? "Players can hook each other on this server" : "Players can't hook each other on this server"); } - else if(str_comp(pArg, "endlesshooking") == 0) + else if(str_comp_nocase(pArg, "endlesshooking") == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", g_Config.m_SvEndlessDrag ? "Players hook time is unlimited" : "Players hook time is limited"); } - else if(str_comp(pArg, "hitting") == 0) + else if(str_comp_nocase(pArg, "hitting") == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", g_Config.m_SvHit ? "Players weapons affect others" : "Players weapons has no affect on others"); } - else if(str_comp(pArg, "oldlaser") == 0) + else if(str_comp_nocase(pArg, "oldlaser") == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", g_Config.m_SvOldLaser ? "Lasers can hit you if you shot them and they pull you towards the bounce origin (Like DDRace Beta)" : "Lasers can't hit you if you shot them, and they pull others towards the shooter"); } - else if(str_comp(pArg, "me") == 0) + else if(str_comp_nocase(pArg, "me") == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", g_Config.m_SvSlashMe ? "Players can use /me commands the famous IRC Command" : "Players can't use the /me command"); } - else if(str_comp(pArg, "timeout") == 0) + else if(str_comp_nocase(pArg, "timeout") == 0) { str_format(aBuf, sizeof(aBuf), "The Server Timeout is currently set to %d seconds", g_Config.m_ConnTimeout); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", aBuf); } - else if(str_comp(pArg, "votes") == 0) + else if(str_comp_nocase(pArg, "votes") == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", g_Config.m_SvVoteKick ? @@ -233,14 +233,14 @@ void CGameContext::ConSettings(IConsole::IResult *pResult, void *pUserData) "Players are just kicked and not banned if they get voted off"); } } - else if(str_comp(pArg, "pause") == 0) + else if(str_comp_nocase(pArg, "pause") == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", g_Config.m_SvPauseable ? "/spec will pause you and your tee will vanish" : "/spec will pause you but your tee will not vanish"); } - else if(str_comp(pArg, "scores") == 0) + else if(str_comp_nocase(pArg, "scores") == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", g_Config.m_SvHideScore ? @@ -414,7 +414,7 @@ void CGameContext::ConTeamTop5(IConsole::IResult *pResult, void *pUserData) } else { - const char *pRequestedName = (str_comp(pResult->GetString(0), "me") == 0) ? + const char *pRequestedName = (str_comp_nocase(pResult->GetString(0), "me") == 0) ? pSelf->Server()->ClientName(pResult->m_ClientID) : pResult->GetString(0); pSelf->Score()->ShowPlayerTeamTop5(pResult->m_ClientID, pRequestedName, 0); @@ -422,7 +422,7 @@ void CGameContext::ConTeamTop5(IConsole::IResult *pResult, void *pUserData) } else if(pResult->NumArguments() == 2 && pResult->GetInteger(1) != 0) { - const char *pRequestedName = (str_comp(pResult->GetString(0), "me") == 0) ? + const char *pRequestedName = (str_comp_nocase(pResult->GetString(0), "me") == 0) ? pSelf->Server()->ClientName(pResult->m_ClientID) : pResult->GetString(0); pSelf->Score()->ShowPlayerTeamTop5(pResult->m_ClientID, pRequestedName, pResult->GetInteger(1)); @@ -472,7 +472,7 @@ void CGameContext::ConTimes(IConsole::IResult *pResult, void *pUserData) } else { - const char *pRequestedName = (str_comp(pResult->GetString(0), "me") == 0) ? + const char *pRequestedName = (str_comp_nocase(pResult->GetString(0), "me") == 0) ? pSelf->Server()->ClientName(pResult->m_ClientID) : pResult->GetString(0); pSelf->Score()->ShowTimes(pResult->m_ClientID, pRequestedName, pResult->GetInteger(1)); @@ -480,7 +480,7 @@ void CGameContext::ConTimes(IConsole::IResult *pResult, void *pUserData) } else if(pResult->NumArguments() == 2 && pResult->GetInteger(1) != 0) { - const char *pRequestedName = (str_comp(pResult->GetString(0), "me") == 0) ? + const char *pRequestedName = (str_comp_nocase(pResult->GetString(0), "me") == 0) ? pSelf->Server()->ClientName(pResult->m_ClientID) : pResult->GetString(0); pSelf->Score()->ShowTimes(pResult->m_ClientID, pRequestedName, pResult->GetInteger(1)); @@ -1255,19 +1255,19 @@ void CGameContext::ConEyeEmote(IConsole::IResult *pResult, void *pUserData) return; int EmoteType = 0; - if(!str_comp(pResult->GetString(0), "angry")) + if(!str_comp_nocase(pResult->GetString(0), "angry")) EmoteType = EMOTE_ANGRY; - else if(!str_comp(pResult->GetString(0), "blink")) + else if(!str_comp_nocase(pResult->GetString(0), "blink")) EmoteType = EMOTE_BLINK; - else if(!str_comp(pResult->GetString(0), "close")) + else if(!str_comp_nocase(pResult->GetString(0), "close")) EmoteType = EMOTE_BLINK; - else if(!str_comp(pResult->GetString(0), "happy")) + else if(!str_comp_nocase(pResult->GetString(0), "happy")) EmoteType = EMOTE_HAPPY; - else if(!str_comp(pResult->GetString(0), "pain")) + else if(!str_comp_nocase(pResult->GetString(0), "pain")) EmoteType = EMOTE_PAIN; - else if(!str_comp(pResult->GetString(0), "surprise")) + else if(!str_comp_nocase(pResult->GetString(0), "surprise")) EmoteType = EMOTE_SURPRISE; - else if(!str_comp(pResult->GetString(0), "normal")) + else if(!str_comp_nocase(pResult->GetString(0), "normal")) EmoteType = EMOTE_NORMAL; else {