mirror of
https://github.com/XLabsProject/s1x-client.git
synced 2023-08-02 15:02:12 +02:00
party: fix usage of stoi (#520)
This commit is contained in:
parent
795b3129b8
commit
573b19a35a
47
appveyor.yml
47
appveyor.yml
@ -1,47 +0,0 @@
|
||||
# AppVeyor CI configuration
|
||||
|
||||
version: "#{build} ({branch})"
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
PREMAKE_ACTION: vs2019
|
||||
CI: 1
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
|
||||
skip_branch_with_pr: true
|
||||
|
||||
# Doesn't work :(
|
||||
#cache:
|
||||
# - build
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
platform: x64
|
||||
|
||||
install:
|
||||
- ps: |
|
||||
Write-Host "Updating version information..." -ForegroundColor Cyan
|
||||
Update-AppveyorBuild -Version $(& tools/premake5.exe version | select -Last 1)
|
||||
- git submodule update --init --recursive
|
||||
- ps: |
|
||||
Write-Host "Generating project files with premake..." -ForegroundColor Cyan
|
||||
& "./tools/premake5.exe" $env:PREMAKE_ACTION
|
||||
Write-Host "Generated" -ForegroundColor Green
|
||||
|
||||
build:
|
||||
project: build/s1x.sln
|
||||
parallel: true
|
||||
verbosity: minimal
|
||||
|
||||
artifacts:
|
||||
- path: build/version.txt
|
||||
- path: build/bin/**/s1x.exe
|
||||
# - path: build/bin/**/*.exe
|
||||
# - path: build/bin/**/*.pdb
|
@ -431,7 +431,7 @@ namespace party
|
||||
{
|
||||
for (auto i = 0; i < *game::mp::svs_numclients; ++i)
|
||||
{
|
||||
scheduler::once([i, reason]()
|
||||
scheduler::once([i, reason]
|
||||
{
|
||||
game::SV_KickClientNum(i, reason.data());
|
||||
}, scheduler::pipeline::server);
|
||||
@ -519,10 +519,10 @@ namespace party
|
||||
|
||||
utils::hook::call(0x14048811C, didyouknow_stub); // allow custom didyouknow based on sv_motd
|
||||
|
||||
network::on("getInfo", [](const game::netadr_s& target, const std::string_view& data)
|
||||
network::on("getInfo", [](const game::netadr_s& target, const std::string& data)
|
||||
{
|
||||
utils::info_string info{};
|
||||
info.set("challenge", std::string{data});
|
||||
info.set("challenge", data);
|
||||
info.set("gamename", "S1");
|
||||
info.set("hostname", get_dvar_string("sv_hostname"));
|
||||
info.set("gametype", get_dvar_string("g_gametype"));
|
||||
@ -542,9 +542,14 @@ namespace party
|
||||
network::send(target, "infoResponse", info.build(), '\n');
|
||||
});
|
||||
|
||||
network::on("infoResponse", [](const game::netadr_s& target, const std::string_view& data)
|
||||
if (game::environment::is_dedi())
|
||||
{
|
||||
const utils::info_string info{data};
|
||||
return;
|
||||
}
|
||||
|
||||
network::on("infoResponse", [](const game::netadr_s& target, const std::string& data)
|
||||
{
|
||||
const utils::info_string info(data);
|
||||
server_list::handle_info_response(target, info);
|
||||
|
||||
if (connect_state.host != target)
|
||||
@ -554,59 +559,67 @@ namespace party
|
||||
|
||||
if (info.get("challenge") != connect_state.challenge)
|
||||
{
|
||||
const auto str = "Invalid challenge.";
|
||||
printf("%s\n", str);
|
||||
game::Com_Error(game::ERR_DROP, str);
|
||||
const auto* error_msg = "Invalid challenge.";
|
||||
console::error("%s\n", error_msg);
|
||||
game::Com_Error(game::ERR_DROP, "%s", error_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto gamename = info.get("gamename");
|
||||
if (gamename != "S1"s)
|
||||
{
|
||||
const auto str = "Invalid gamename.";
|
||||
printf("%s\n", str);
|
||||
game::Com_Error(game::ERR_DROP, str);
|
||||
const auto* error_msg = "Invalid gamename.";
|
||||
console::error("%s\n", error_msg);
|
||||
game::Com_Error(game::ERR_DROP, "%s", error_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto playmode = info.get("playmode");
|
||||
if (game::CodPlayMode(std::atoi(playmode.data())) != game::Com_GetCurrentCoDPlayMode())
|
||||
if (std::atoi(playmode.data()) != game::Com_GetCurrentCoDPlayMode())
|
||||
{
|
||||
const auto str = "Invalid playmode.";
|
||||
printf("%s\n", str);
|
||||
game::Com_Error(game::ERR_DROP, str);
|
||||
const auto* error_msg = "Invalid playmode.";
|
||||
console::error("%s\n", error_msg);
|
||||
game::Com_Error(game::ERR_DROP, "%s", error_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto sv_running = info.get("sv_running");
|
||||
if (!std::atoi(sv_running.data()))
|
||||
if (sv_running.empty() || sv_running == "0"s)
|
||||
{
|
||||
const auto str = "Server not running.";
|
||||
printf("%s\n", str);
|
||||
game::Com_Error(game::ERR_DROP, str);
|
||||
const auto* error_msg = "Server not running.";
|
||||
console::error("%s\n", error_msg);
|
||||
game::Com_Error(game::ERR_DROP, "%s", error_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto mapname = info.get("mapname");
|
||||
if (mapname.empty())
|
||||
{
|
||||
const auto str = "Invalid map.";
|
||||
printf("%s\n", str);
|
||||
game::Com_Error(game::ERR_DROP, str);
|
||||
const auto* error_msg = "Invalid map.";
|
||||
console::error("%s\n", error_msg);
|
||||
game::Com_Error(game::ERR_DROP, "%s", error_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto gametype = info.get("gametype");
|
||||
if (gametype.empty())
|
||||
{
|
||||
const auto str = "Invalid gametype.";
|
||||
printf("%s\n", str);
|
||||
game::Com_Error(game::ERR_DROP, str);
|
||||
const auto* error_msg = "Invalid gametype.";
|
||||
console::error("%s\n", error_msg);
|
||||
game::Com_Error(game::ERR_DROP, "%s", error_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
party::sv_motd = info.get("sv_motd");
|
||||
party::sv_maxclients = std::stoi(info.get("sv_maxclients"));
|
||||
sv_motd = info.get("sv_motd");
|
||||
|
||||
try
|
||||
{
|
||||
sv_maxclients = std::stoi(info.get("sv_maxclients"));
|
||||
}
|
||||
catch([[maybe_unused]] const std::exception& ex)
|
||||
{
|
||||
sv_maxclients = 1;
|
||||
}
|
||||
|
||||
connect_to_party(target, mapname, gametype);
|
||||
});
|
||||
|
@ -188,11 +188,11 @@ int main()
|
||||
// people will start with admin rights if it crashes.
|
||||
limit_parallel_dll_loading();
|
||||
|
||||
srand(uint32_t(time(nullptr)));
|
||||
std::srand(uint32_t(time(nullptr)));
|
||||
|
||||
{
|
||||
auto premature_shutdown = true;
|
||||
const auto _ = gsl::finally([&premature_shutdown]()
|
||||
const auto _ = gsl::finally([&premature_shutdown]
|
||||
{
|
||||
if (premature_shutdown)
|
||||
{
|
||||
@ -227,17 +227,12 @@ int main()
|
||||
|
||||
premature_shutdown = false;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
MessageBoxA(nullptr, e.what(), "ERROR", MB_ICONERROR);
|
||||
MessageBoxA(nullptr, ex.what(), nullptr, MB_ICONERROR);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return static_cast<int>(entry_point());
|
||||
}
|
||||
|
||||
int __stdcall WinMain(HINSTANCE, HINSTANCE, PSTR, int)
|
||||
{
|
||||
return main();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user