diff --git a/deps/premake/fonts.lua b/deps/premake/fonts.lua index 6385cc8e..9d6cccfc 100644 --- a/deps/premake/fonts.lua +++ b/deps/premake/fonts.lua @@ -1,4 +1,6 @@ -fonts = {} +fonts = { + source = path.join(dependencies.basePath, "extra/font"), +} function fonts.import() fonts.includes() @@ -6,7 +8,7 @@ end function fonts.includes() includedirs { - path.join(dependencies.basePath, "extra/font"), + fonts.source, } end @@ -17,7 +19,7 @@ function fonts.project() fonts.includes() files { - path.join(dependencies.basePath, "extra/font/*.hpp"), + path.join(fonts.source, "Terminus_4.49.1.ttf.hpp"), } warnings "Off" diff --git a/deps/premake/gsl.lua b/deps/premake/gsl.lua index 7a2daf64..79309bbd 100644 --- a/deps/premake/gsl.lua +++ b/deps/premake/gsl.lua @@ -8,7 +8,7 @@ end function gsl.includes() includedirs { - path.join(gsl.source, "include") + path.join(gsl.source, "include"), } end diff --git a/deps/premake/iw4-open-formats.lua b/deps/premake/iw4-open-formats.lua index e4d169b7..9b6751da 100644 --- a/deps/premake/iw4-open-formats.lua +++ b/deps/premake/iw4-open-formats.lua @@ -17,7 +17,6 @@ end function iw4_open_formats.project() project "iw4-open-formats" language "C++" - cppdialect "C++latest" iw4_open_formats.includes() diff --git a/deps/premake/protobuf.lua b/deps/premake/protobuf.lua index a293576f..e0aaf0a7 100644 --- a/deps/premake/protobuf.lua +++ b/deps/premake/protobuf.lua @@ -38,10 +38,6 @@ function protobuf.project() } rules {"ProtobufCompiler"} - - defines {"_SCL_SECURE_NO_WARNINGS"} - - linkoptions {"-IGNORE:4221"} warnings "Off" kind "StaticLib" diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 18a80dc7..d7843aa9 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -211,7 +211,7 @@ namespace Components if (Game::SV_IsTestClient(ent->s.number) == 0) { - Game::Scr_Error("^1BotStop: Can only call on a bot!\n"); + Game::Scr_Error("^1BotStop: Can only call on a bot!"); return; } @@ -226,7 +226,7 @@ namespace Components if (Game::SV_IsTestClient(ent->s.number) == 0) { - Game::Scr_Error("^1BotWeapon: Can only call on a bot!\n"); + Game::Scr_Error("^1BotWeapon: Can only call on a bot!"); return; } @@ -249,7 +249,7 @@ namespace Components if (Game::SV_IsTestClient(ent->s.number) == 0) { - Game::Scr_Error("^1BotAction: Can only call on a bot!\n"); + Game::Scr_Error("^1BotAction: Can only call on a bot!"); return; } @@ -257,13 +257,13 @@ namespace Components if (action == nullptr) { - Game::Scr_ParamError(0, "^1BotAction: Illegal parameter!\n"); + Game::Scr_ParamError(0, "^1BotAction: Illegal parameter!"); return; } if (action[0] != '+' && action[0] != '-') { - Game::Scr_ParamError(0, "^1BotAction: Sign for action must be '+' or '-'.\n"); + Game::Scr_ParamError(0, "^1BotAction: Sign for action must be '+' or '-'"); return; } @@ -281,7 +281,7 @@ namespace Components return; } - Game::Scr_ParamError(0, "^1BotAction: Unknown action.\n"); + Game::Scr_ParamError(0, "^1BotAction: Unknown action"); }); GSC::Script::AddMethod("BotMovement", [](Game::scr_entref_t entref) // Usage: BotMovement(, ); @@ -290,7 +290,7 @@ namespace Components if (Game::SV_IsTestClient(ent->s.number) == 0) { - Game::Scr_Error("^1BotMovement: Can only call on a bot!\n"); + Game::Scr_Error("^1BotMovement: Can only call on a bot!"); return; } diff --git a/src/Components/Modules/Chat.cpp b/src/Components/Modules/Chat.cpp index 78fc42f4..807d39dd 100644 --- a/src/Components/Modules/Chat.cpp +++ b/src/Components/Modules/Chat.cpp @@ -590,7 +590,7 @@ namespace Components { if (Game::Scr_GetNumParam() != 1) { - Game::Scr_Error("^1OnPlayerSay: Needs one function pointer!\n"); + Game::Scr_Error("^1OnPlayerSay: Needs one function pointer!"); return; } diff --git a/src/Components/Modules/GSC/IO.cpp b/src/Components/Modules/GSC/IO.cpp index cb998a82..bc5bc2fd 100644 --- a/src/Components/Modules/GSC/IO.cpp +++ b/src/Components/Modules/GSC/IO.cpp @@ -16,13 +16,13 @@ namespace Components::GSC if (!path) { - Game::Scr_ParamError(0, "^1FileWrite: filepath is not defined!\n"); + Game::Scr_ParamError(0, "^1FileWrite: filepath is not defined!"); return; } if (!text || !mode) { - Game::Scr_Error("^1FileWrite: Illegal parameters!\n"); + Game::Scr_Error("^1FileWrite: Illegal parameters!"); return; } @@ -59,7 +59,7 @@ namespace Components::GSC if (!path) { - Game::Scr_ParamError(0, "^1FileRead: filepath is not defined!\n"); + Game::Scr_ParamError(0, "^1FileRead: filepath is not defined!"); return; } @@ -92,7 +92,7 @@ namespace Components::GSC if (!path) { - Game::Scr_ParamError(0, "^1FileExists: filepath is not defined!\n"); + Game::Scr_ParamError(0, "^1FileExists: filepath is not defined!"); return; } @@ -115,7 +115,7 @@ namespace Components::GSC if (!path) { - Game::Scr_ParamError(0, "^1FileRemove: filepath is not defined!\n"); + Game::Scr_ParamError(0, "^1FileRemove: filepath is not defined!"); return; } diff --git a/src/Components/Modules/GSC/ScriptExtension.cpp b/src/Components/Modules/GSC/ScriptExtension.cpp index 7151885e..5e27c36d 100644 --- a/src/Components/Modules/GSC/ScriptExtension.cpp +++ b/src/Components/Modules/GSC/ScriptExtension.cpp @@ -113,7 +113,7 @@ namespace Components::GSC { if (static_cast(index) >= Game::scrVmPub->outparamcount) { - Game::Scr_ParamError(static_cast(index), "^1GetCodePosForParam: Index is out of range!\n"); + Game::Scr_ParamError(static_cast(index), "^1GetCodePosForParam: Index is out of range!"); return ""; } @@ -121,7 +121,7 @@ namespace Components::GSC if (value->type != Game::VAR_FUNCTION) { - Game::Scr_ParamError(static_cast(index), "^1GetCodePosForParam: Expects a function as parameter!\n"); + Game::Scr_ParamError(static_cast(index), "^1GetCodePosForParam: Expects a function as parameter!"); return ""; } @@ -223,7 +223,7 @@ namespace Components::GSC { if (Game::Scr_GetNumParam() != 2) { - Game::Scr_Error("^1ReplaceFunc: Needs two parameters!\n"); + Game::Scr_Error("^1ReplaceFunc: Needs two parameters!"); return; } @@ -247,7 +247,7 @@ namespace Components::GSC const auto* str = Game::Scr_GetString(0); if (!str) { - Game::Scr_ParamError(0, "^1Exec: Illegal parameter!\n"); + Game::Scr_ParamError(0, "^1Exec: Illegal parameter!"); return; } @@ -262,7 +262,7 @@ namespace Components::GSC const auto* str = Game::Scr_GetString(i); if (!str) { - Game::Scr_ParamError(i, "^1PrintConsole: Illegal parameter!\n"); + Game::Scr_ParamError(i, "^1PrintConsole: Illegal parameter!"); return; } diff --git a/src/Components/Modules/GSC/ScriptPatches.cpp b/src/Components/Modules/GSC/ScriptPatches.cpp index 68d2e329..45709fa7 100644 --- a/src/Components/Modules/GSC/ScriptPatches.cpp +++ b/src/Components/Modules/GSC/ScriptPatches.cpp @@ -24,7 +24,7 @@ namespace Components::GSC { if (Game::Scr_GetNumParam() < 3) { - Game::Scr_Error("USAGE: tableLookupIStringByRow( filename, rowNum, returnValueColumnNum )\n"); + Game::Scr_Error("USAGE: tableLookupIStringByRow( filename, rowNum, returnValueColumnNum )"); return; } @@ -36,7 +36,7 @@ namespace Components::GSC if (table == nullptr) { - Game::Scr_ParamError(0, Utils::String::VA("%s does not exist\n", fileName)); + Game::Scr_ParamError(0, Utils::String::VA("%s does not exist", fileName)); return; } diff --git a/src/Components/Modules/GSC/ScriptStorage.cpp b/src/Components/Modules/GSC/ScriptStorage.cpp index ef211056..c2cecdf5 100644 --- a/src/Components/Modules/GSC/ScriptStorage.cpp +++ b/src/Components/Modules/GSC/ScriptStorage.cpp @@ -16,7 +16,7 @@ namespace Components::GSC if (key == nullptr || value == nullptr) { - Game::Scr_Error("^1StorageSet: Illegal parameters!\n"); + Game::Scr_Error("^1StorageSet: Illegal parameters!"); return; } @@ -29,13 +29,13 @@ namespace Components::GSC if (key == nullptr) { - Game::Scr_ParamError(0, "^1StorageRemove: Illegal parameter!\n"); + Game::Scr_ParamError(0, "^1StorageRemove: Illegal parameter!"); return; } if (!Data.contains(key)) { - Game::Scr_Error(Utils::String::VA("^1StorageRemove: Store does not have key '%s'!\n", key)); + Game::Scr_Error(Utils::String::VA("^1StorageRemove: Store does not have key '%s'!", key)); return; } @@ -48,13 +48,13 @@ namespace Components::GSC if (key == nullptr) { - Game::Scr_ParamError(0, "^1StorageGet: Illegal parameter!\n"); + Game::Scr_ParamError(0, "^1StorageGet: Illegal parameter!"); return; } if (!Data.contains(key)) { - Game::Scr_Error(Utils::String::VA("^1StorageGet: Store does not have key '%s'!\n", key)); + Game::Scr_Error(Utils::String::VA("^1StorageGet: Store does not have key '%s'!", key)); } const auto& data = Data.at(key); @@ -67,7 +67,7 @@ namespace Components::GSC if (key == nullptr) { - Game::Scr_ParamError(0, "^1StorageHas: Illegal parameter!\n"); + Game::Scr_ParamError(0, "^1StorageHas: Illegal parameter!"); return; } @@ -78,7 +78,7 @@ namespace Components::GSC { if (Data.empty()) { - Game::Scr_Error("^1StorageDump: ScriptStorage is empty!\n"); + Game::Scr_Error("^1StorageDump: ScriptStorage is empty!"); return; } diff --git a/src/Components/Modules/GSC/String.cpp b/src/Components/Modules/GSC/String.cpp index ebfb5bed..f8e119df 100644 --- a/src/Components/Modules/GSC/String.cpp +++ b/src/Components/Modules/GSC/String.cpp @@ -51,6 +51,25 @@ namespace Components::GSC } }); + Script::AddFunction("GetChar", [] + { + const auto* str = Game::Scr_GetString(0); + const auto index = Game::Scr_GetInt(1); + + if (!str) + { + Game::Scr_Error("^1GetChar: Illegal parameter!"); + return; + } + + if (static_cast(index) >= std::strlen(str)) + { + Game::Scr_Error("GetChar: char index is out of bounds"); + } + + Game::Scr_AddInt(str[index]); + }); + // Func present on IW5 Script::AddFunction("StrICmp", [] // gsc: StrICmp(, ) { @@ -70,7 +89,7 @@ namespace Components::GSC if (!str || !suffix) { - Game::Scr_Error("^1IsEndStr: Illegal parameters!\n"); + Game::Scr_Error("^1IsEndStr: Illegal parameters!"); return; } diff --git a/src/Components/Modules/GSC/UserInfo.cpp b/src/Components/Modules/GSC/UserInfo.cpp index 697d798b..d3ec1d21 100644 --- a/src/Components/Modules/GSC/UserInfo.cpp +++ b/src/Components/Modules/GSC/UserInfo.cpp @@ -54,7 +54,7 @@ namespace Components::GSC if (name == nullptr) { - Game::Scr_ParamError(0, "^1SetName: Illegal parameter!\n"); + Game::Scr_ParamError(0, "^1SetName: Illegal parameter!"); return; } @@ -79,7 +79,7 @@ namespace Components::GSC if (clanName == nullptr) { - Game::Scr_ParamError(0, "^1SetClanTag: Illegal parameter!\n"); + Game::Scr_ParamError(0, "^1SetClanTag: Illegal parameter!"); return; } diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index 1418e6aa..a19da69a 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -340,7 +340,7 @@ namespace Components Network::OnClientPacket("getInfo", [](const Network::Address& address, [[maybe_unused]] const std::string& data) { auto botCount = 0; - auto clientCount = 0; + auto effectiveClientCount = 0; auto maxClientCount = *Game::svs_clientCount; const auto securityLevel = Dvar::Var("sv_securityLevel").get(); const auto* password = *Game::g_password ? (*Game::g_password)->current.string : ""; @@ -360,14 +360,14 @@ namespace Components } else { - ++clientCount; + ++effectiveClientCount; } } } else { maxClientCount = *Game::party_maxplayers ? (*Game::party_maxplayers)->current.integer : 18; - clientCount = Game::PartyHost_CountMembers(Game::g_lobbyData); + effectiveClientCount = Game::PartyHost_CountMembers(Game::g_lobbyData); } Utils::InfoString info; @@ -377,7 +377,7 @@ namespace Components info.set("gametype", (*Game::sv_gametype)->current.string); info.set("fs_game", (*Game::fs_gameDirVar)->current.string); info.set("xuid", Utils::String::VA("%llX", Steam::SteamUser()->GetSteamID().bits)); - info.set("clients", std::to_string(clientCount)); + info.set("clients", std::to_string(effectiveClientCount)); info.set("bots", std::to_string(botCount)); info.set("sv_maxclients", std::to_string(maxClientCount)); info.set("protocol", std::to_string(PROTOCOL)); diff --git a/src/Components/Modules/Stats.cpp b/src/Components/Modules/Stats.cpp index 8e9580b2..d02e384c 100644 --- a/src/Components/Modules/Stats.cpp +++ b/src/Components/Modules/Stats.cpp @@ -104,7 +104,7 @@ namespace Components const auto iNumParms = Game::Scr_GetNumParam(); if (iNumParms != 2) { - Game::Scr_Error(Utils::String::VA("GetStat: takes 2 arguments, got %u.\n", iNumParms)); + Game::Scr_Error(Utils::String::VA("GetStat: takes 2 arguments, got %u.", iNumParms)); } const auto index = Game::Scr_GetInt(0);