Merge branch 'develop' into dependabot/submodules/deps/libtommath-5809141
This commit is contained in:
commit
8fb50fd32a
2
deps/iw4-open-formats
vendored
2
deps/iw4-open-formats
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 9c245e794c7c452de82aa9fd07e6b3edb27be9b7
|
Subproject commit f4ff5d532aeaac1c3254ef20ace687ab41622ab9
|
@ -30,6 +30,8 @@ namespace Components
|
|||||||
std::uint16_t lastAltWeapon;
|
std::uint16_t lastAltWeapon;
|
||||||
std::uint8_t meleeDist;
|
std::uint8_t meleeDist;
|
||||||
float meleeYaw;
|
float meleeYaw;
|
||||||
|
std::int8_t remoteAngles[2];
|
||||||
|
float angles[3];
|
||||||
bool active;
|
bool active;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -54,10 +56,11 @@ namespace Components
|
|||||||
{ "sprint", Game::CMD_BUTTON_SPRINT },
|
{ "sprint", Game::CMD_BUTTON_SPRINT },
|
||||||
{ "leanleft", Game::CMD_BUTTON_LEAN_LEFT },
|
{ "leanleft", Game::CMD_BUTTON_LEAN_LEFT },
|
||||||
{ "leanright", Game::CMD_BUTTON_LEAN_RIGHT },
|
{ "leanright", Game::CMD_BUTTON_LEAN_RIGHT },
|
||||||
{ "ads", Game::CMD_BUTTON_ADS },
|
{ "ads", Game::CMD_BUTTON_ADS | Game::CMD_BUTTON_THROW },
|
||||||
{ "holdbreath", Game::CMD_BUTTON_BREATH },
|
{ "holdbreath", Game::CMD_BUTTON_BREATH },
|
||||||
{ "usereload", Game::CMD_BUTTON_USE_RELOAD },
|
{ "usereload", Game::CMD_BUTTON_USE_RELOAD },
|
||||||
{ "activate", Game::CMD_BUTTON_ACTIVATE },
|
{ "activate", Game::CMD_BUTTON_ACTIVATE },
|
||||||
|
{ "remote", Game::CMD_BUTTON_REMOTE },
|
||||||
};
|
};
|
||||||
|
|
||||||
void Bots::UpdateBotNames()
|
void Bots::UpdateBotNames()
|
||||||
@ -214,7 +217,10 @@ namespace Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
ZeroMemory(&g_botai[entref.entnum], sizeof(BotMovementInfo));
|
ZeroMemory(&g_botai[entref.entnum], sizeof(BotMovementInfo));
|
||||||
g_botai[entref.entnum].weapon = 1;
|
g_botai[entref.entnum].weapon = static_cast<std::uint16_t>(ent->client->ps.weapCommon.weapon);
|
||||||
|
g_botai[entref.entnum].angles[0] = ent->client->ps.viewangles[0];
|
||||||
|
g_botai[entref.entnum].angles[1] = ent->client->ps.viewangles[1];
|
||||||
|
g_botai[entref.entnum].angles[2] = ent->client->ps.viewangles[2];
|
||||||
g_botai[entref.entnum].active = true;
|
g_botai[entref.entnum].active = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -311,6 +317,43 @@ namespace Components
|
|||||||
g_botai[entref.entnum].meleeDist = static_cast<int8_t>(dist);
|
g_botai[entref.entnum].meleeDist = static_cast<int8_t>(dist);
|
||||||
g_botai[entref.entnum].active = true;
|
g_botai[entref.entnum].active = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
GSC::Script::AddMethod("BotRemoteAngles", [](const Game::scr_entref_t entref) // Usage: <bot> BotRemoteAngles(<int>, <int>);
|
||||||
|
{
|
||||||
|
const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||||
|
if (!Game::SV_IsTestClient(ent->s.number))
|
||||||
|
{
|
||||||
|
Game::Scr_Error("BotRemoteAngles: Can only call on a bot!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto pitch = std::clamp<int>(Game::Scr_GetInt(0), std::numeric_limits<char>::min(), std::numeric_limits<char>::max());
|
||||||
|
const auto yaw = std::clamp<int>(Game::Scr_GetInt(1), std::numeric_limits<char>::min(), std::numeric_limits<char>::max());
|
||||||
|
|
||||||
|
g_botai[entref.entnum].remoteAngles[0] = static_cast<int8_t>(pitch);
|
||||||
|
g_botai[entref.entnum].remoteAngles[1] = static_cast<int8_t>(yaw);
|
||||||
|
g_botai[entref.entnum].active = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
GSC::Script::AddMethod("BotAngles", [](const Game::scr_entref_t entref) // Usage: <bot> BotAngles(<float>, <float>, <float>);
|
||||||
|
{
|
||||||
|
const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||||
|
if (!Game::SV_IsTestClient(ent->s.number))
|
||||||
|
{
|
||||||
|
Game::Scr_Error("BotAngles: Can only call on a bot!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto pitch = Game::Scr_GetFloat(0);
|
||||||
|
const auto yaw = Game::Scr_GetFloat(1);
|
||||||
|
const auto roll = Game::Scr_GetFloat(2);
|
||||||
|
|
||||||
|
g_botai[entref.entnum].angles[0] = pitch;
|
||||||
|
g_botai[entref.entnum].angles[1] = yaw;
|
||||||
|
g_botai[entref.entnum].angles[2] = roll;
|
||||||
|
|
||||||
|
g_botai[entref.entnum].active = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bots::BotAiAction(Game::client_s* cl)
|
void Bots::BotAiAction(Game::client_s* cl)
|
||||||
@ -341,10 +384,12 @@ namespace Components
|
|||||||
userCmd.primaryWeaponForAltMode = g_botai[clientNum].lastAltWeapon;
|
userCmd.primaryWeaponForAltMode = g_botai[clientNum].lastAltWeapon;
|
||||||
userCmd.meleeChargeYaw = g_botai[clientNum].meleeYaw;
|
userCmd.meleeChargeYaw = g_botai[clientNum].meleeYaw;
|
||||||
userCmd.meleeChargeDist = g_botai[clientNum].meleeDist;
|
userCmd.meleeChargeDist = g_botai[clientNum].meleeDist;
|
||||||
|
userCmd.remoteControlAngles[0] = g_botai[clientNum].remoteAngles[0];
|
||||||
|
userCmd.remoteControlAngles[1] = g_botai[clientNum].remoteAngles[1];
|
||||||
|
|
||||||
userCmd.angles[0] = ANGLE2SHORT((cl->gentity->client->ps.viewangles[0] - cl->gentity->client->ps.delta_angles[0]));
|
userCmd.angles[0] = ANGLE2SHORT(g_botai[clientNum].angles[0] - cl->gentity->client->ps.delta_angles[0]);
|
||||||
userCmd.angles[1] = ANGLE2SHORT((cl->gentity->client->ps.viewangles[1] - cl->gentity->client->ps.delta_angles[1]));
|
userCmd.angles[1] = ANGLE2SHORT(g_botai[clientNum].angles[1] - cl->gentity->client->ps.delta_angles[1]);
|
||||||
userCmd.angles[2] = ANGLE2SHORT((cl->gentity->client->ps.viewangles[2] - cl->gentity->client->ps.delta_angles[2]));
|
userCmd.angles[2] = ANGLE2SHORT(g_botai[clientNum].angles[2] - cl->gentity->client->ps.delta_angles[2]);
|
||||||
|
|
||||||
Game::SV_ClientThink(cl, &userCmd);
|
Game::SV_ClientThink(cl, &userCmd);
|
||||||
}
|
}
|
||||||
|
@ -248,9 +248,10 @@ namespace Components
|
|||||||
return Name.get<Game::dvar_t*>();
|
return Name.get<Game::dvar_t*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Game::dvar_t* Dvar::Dvar_RegisterSVNetworkFps(const char* dvarName, int /*value*/, int min, int /*max*/, std::uint16_t /*flags*/, const char* description)
|
const Game::dvar_t* Dvar::Dvar_RegisterSVNetworkFps(const char* dvarName, int value, int min, int /*max*/, std::uint16_t /*flags*/, const char* description)
|
||||||
{
|
{
|
||||||
return Game::Dvar_RegisterInt(dvarName, 1000, min, 1000, Game::DVAR_NONE, description);
|
// bump limit up to 1000
|
||||||
|
return Game::Dvar_RegisterInt(dvarName, value, min, 1000, Game::DVAR_NONE, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Game::dvar_t* Dvar::Dvar_RegisterPerkExtendedMeleeRange(const char* dvarName, float value, float min, float /*max*/, std::uint16_t flags, const char* description)
|
const Game::dvar_t* Dvar::Dvar_RegisterPerkExtendedMeleeRange(const char* dvarName, float value, float min, float /*max*/, std::uint16_t flags, const char* description)
|
||||||
|
@ -315,7 +315,10 @@ namespace Components
|
|||||||
Friends::LoggedOn = (Steam::Proxy::SteamUser_ && Steam::Proxy::SteamUser_->LoggedOn());
|
Friends::LoggedOn = (Steam::Proxy::SteamUser_ && Steam::Proxy::SteamUser_->LoggedOn());
|
||||||
if (!Steam::Proxy::SteamFriends) return;
|
if (!Steam::Proxy::SteamFriends) return;
|
||||||
|
|
||||||
Game::UI_UpdateArenas();
|
if (Game::Sys_IsMainThread())
|
||||||
|
{
|
||||||
|
Game::UI_UpdateArenas();
|
||||||
|
}
|
||||||
|
|
||||||
int count = Steam::Proxy::SteamFriends->GetFriendCount(4);
|
int count = Steam::Proxy::SteamFriends->GetFriendCount(4);
|
||||||
|
|
||||||
|
@ -38,32 +38,32 @@ namespace Components
|
|||||||
void Logger::MessagePrint(const int channel, const std::string& msg)
|
void Logger::MessagePrint(const int channel, const std::string& msg)
|
||||||
{
|
{
|
||||||
static const auto shouldPrint = []() -> bool
|
static const auto shouldPrint = []() -> bool
|
||||||
{
|
{
|
||||||
return Flags::HasFlag("stdout") || Loader::IsPerformingUnitTests();
|
return Flags::HasFlag("stdout") || Loader::IsPerformingUnitTests();
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (shouldPrint)
|
if (shouldPrint)
|
||||||
{
|
{
|
||||||
(void)std::fputs(msg.data(), stdout);
|
(void)std::fputs(msg.data(), stdout);
|
||||||
(void)std::fflush(stdout);
|
(void)std::fflush(stdout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if (!IsConsoleReady())
|
if (!IsConsoleReady())
|
||||||
{
|
{
|
||||||
OutputDebugStringA(msg.data());
|
OutputDebugStringA(msg.data());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!Game::Sys_IsMainThread())
|
if (!Game::Sys_IsMainThread())
|
||||||
{
|
{
|
||||||
EnqueueMessage(msg);
|
EnqueueMessage(msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Game::Com_PrintMessage(channel, msg.data(), 0);
|
Game::Com_PrintMessage(channel, msg.data(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::DebugInternal(const std::string_view& fmt, std::format_args&& args, [[maybe_unused]] const std::source_location& loc)
|
void Logger::DebugInternal(const std::string_view& fmt, std::format_args&& args, [[maybe_unused]] const std::source_location& loc)
|
||||||
@ -120,33 +120,33 @@ namespace Components
|
|||||||
void Logger::PrintFail2BanInternal(const std::string_view& fmt, std::format_args&& args)
|
void Logger::PrintFail2BanInternal(const std::string_view& fmt, std::format_args&& args)
|
||||||
{
|
{
|
||||||
static const auto shouldPrint = []() -> bool
|
static const auto shouldPrint = []() -> bool
|
||||||
{
|
{
|
||||||
return Flags::HasFlag("fail2ban");
|
return Flags::HasFlag("fail2ban");
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (!shouldPrint)
|
if (!shouldPrint)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto msg = std::vformat(fmt, args);
|
auto msg = std::vformat(fmt, args);
|
||||||
|
|
||||||
static auto log_next_time_stamp = true;
|
static auto log_next_time_stamp = true;
|
||||||
if (log_next_time_stamp)
|
if (log_next_time_stamp)
|
||||||
{
|
{
|
||||||
auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
||||||
// Convert to local time
|
// Convert to local time
|
||||||
std::tm timeInfo = *std::localtime(&now);
|
std::tm timeInfo = *std::localtime(&now);
|
||||||
|
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << std::put_time(&timeInfo, "%Y-%m-%d %H:%M:%S ");
|
ss << std::put_time(&timeInfo, "%Y-%m-%d %H:%M:%S ");
|
||||||
|
|
||||||
msg.insert(0, ss.str());
|
msg.insert(0, ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
log_next_time_stamp = (msg.find('\n') != std::string::npos);
|
log_next_time_stamp = (msg.find('\n') != std::string::npos);
|
||||||
|
|
||||||
Utils::IO::WriteFile(IW4x_fail2ban_location.get<std::string>(), msg, true);
|
Utils::IO::WriteFile(IW4x_fail2ban_location.get<std::string>(), msg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Frame()
|
void Logger::Frame()
|
||||||
@ -227,28 +227,28 @@ namespace Components
|
|||||||
|
|
||||||
pushad
|
pushad
|
||||||
|
|
||||||
push [esp + 28h]
|
push[esp + 28h]
|
||||||
call PrintMessagePipe
|
call PrintMessagePipe
|
||||||
add esp, 4h
|
add esp, 4h
|
||||||
|
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
|
|
||||||
returnPrint:
|
returnPrint :
|
||||||
pushad
|
pushad
|
||||||
|
|
||||||
push 0 // gLog
|
push 0 // gLog
|
||||||
push [esp + 2Ch] // data
|
push[esp + 2Ch] // data
|
||||||
call NetworkLog
|
call NetworkLog
|
||||||
add esp, 8h
|
add esp, 8h
|
||||||
|
|
||||||
popad
|
popad
|
||||||
|
|
||||||
push esi
|
push esi
|
||||||
mov esi, [esp + 0Ch]
|
mov esi, [esp + 0Ch]
|
||||||
|
|
||||||
push 4AA835h
|
push 4AA835h
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,13 +262,16 @@ namespace Components
|
|||||||
{
|
{
|
||||||
const auto* g_log = (*Game::g_log) ? (*Game::g_log)->current.string : "";
|
const auto* g_log = (*Game::g_log) ? (*Game::g_log)->current.string : "";
|
||||||
|
|
||||||
if (std::strcmp(g_log, file) == 0)
|
if (g_log) // This can be null - has happened before
|
||||||
{
|
{
|
||||||
if (std::strcmp(folder, "userraw") != 0)
|
if (std::strcmp(g_log, file) == 0)
|
||||||
{
|
{
|
||||||
if (IW4x_one_log.get<bool>())
|
if (std::strcmp(folder, "userraw") != 0)
|
||||||
{
|
{
|
||||||
strncpy_s(folder, 256, "userraw", _TRUNCATE);
|
if (IW4x_one_log.get<bool>())
|
||||||
|
{
|
||||||
|
strncpy_s(folder, 256, "userraw", _TRUNCATE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,8 +283,8 @@ namespace Components
|
|||||||
{
|
{
|
||||||
pushad
|
pushad
|
||||||
|
|
||||||
push [esp + 20h + 8h]
|
push[esp + 20h + 8h]
|
||||||
push [esp + 20h + 10h]
|
push[esp + 20h + 10h]
|
||||||
call RedirectOSPath
|
call RedirectOSPath
|
||||||
add esp, 8h
|
add esp, 8h
|
||||||
|
|
||||||
@ -310,117 +313,140 @@ namespace Components
|
|||||||
void Logger::AddServerCommands()
|
void Logger::AddServerCommands()
|
||||||
{
|
{
|
||||||
Command::AddSV("log_add", [](const Command::Params* params)
|
Command::AddSV("log_add", [](const Command::Params* params)
|
||||||
{
|
|
||||||
if (params->size() < 2) return;
|
|
||||||
|
|
||||||
std::unique_lock lock(LoggingMutex);
|
|
||||||
|
|
||||||
Network::Address addr(params->get(1));
|
|
||||||
if (std::ranges::find(LoggingAddresses[0], addr) == LoggingAddresses[0].end())
|
|
||||||
{
|
{
|
||||||
LoggingAddresses[0].push_back(addr);
|
if (params->size() < 2) return;
|
||||||
}
|
|
||||||
});
|
std::unique_lock lock(LoggingMutex);
|
||||||
|
|
||||||
|
Network::Address addr(params->get(1));
|
||||||
|
if (std::ranges::find(LoggingAddresses[0], addr) == LoggingAddresses[0].end())
|
||||||
|
{
|
||||||
|
LoggingAddresses[0].push_back(addr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Command::AddSV("log_del", [](const Command::Params* params)
|
Command::AddSV("log_del", [](const Command::Params* params)
|
||||||
{
|
|
||||||
if (params->size() < 2) return;
|
|
||||||
|
|
||||||
std::unique_lock lock(LoggingMutex);
|
|
||||||
|
|
||||||
const auto num = std::atoi(params->get(1));
|
|
||||||
if (!std::strcmp(VA("%i", num), params->get(1)) && static_cast<unsigned int>(num) < LoggingAddresses[0].size())
|
|
||||||
{
|
{
|
||||||
auto addr = Logger::LoggingAddresses[0].begin() + num;
|
if (params->size() < 2) return;
|
||||||
Print("Address {} removed\n", addr->getString());
|
|
||||||
LoggingAddresses[0].erase(addr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Network::Address addr(params->get(1));
|
|
||||||
|
|
||||||
if (const auto i = std::ranges::find(LoggingAddresses[0], addr); i != LoggingAddresses[0].end())
|
std::unique_lock lock(LoggingMutex);
|
||||||
|
|
||||||
|
const auto num = std::atoi(params->get(1));
|
||||||
|
if (!std::strcmp(VA("%i", num), params->get(1)) && static_cast<unsigned int>(num) < LoggingAddresses[0].size())
|
||||||
{
|
{
|
||||||
LoggingAddresses[0].erase(i);
|
auto addr = Logger::LoggingAddresses[0].begin() + num;
|
||||||
Print("Address {} removed\n", addr.getString());
|
Print("Address {} removed\n", addr->getString());
|
||||||
|
LoggingAddresses[0].erase(addr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Print("Address {} not found!\n", addr.getString());
|
Network::Address addr(params->get(1));
|
||||||
|
|
||||||
|
if (const auto i = std::ranges::find(LoggingAddresses[0], addr); i != LoggingAddresses[0].end())
|
||||||
|
{
|
||||||
|
LoggingAddresses[0].erase(i);
|
||||||
|
Print("Address {} removed\n", addr.getString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Print("Address {} not found!\n", addr.getString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
Command::AddSV("log_list", []([[maybe_unused]] const Command::Params* params)
|
Command::AddSV("log_list", []([[maybe_unused]] const Command::Params* params)
|
||||||
{
|
|
||||||
Print("# ID: Address\n");
|
|
||||||
Print("-------------\n");
|
|
||||||
|
|
||||||
std::unique_lock lock(LoggingMutex);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < LoggingAddresses[0].size(); ++i)
|
|
||||||
{
|
{
|
||||||
Print("#{:03d}: {}\n", i, LoggingAddresses[0][i].getString());
|
Print("# ID: Address\n");
|
||||||
}
|
Print("-------------\n");
|
||||||
});
|
|
||||||
|
std::unique_lock lock(LoggingMutex);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < LoggingAddresses[0].size(); ++i)
|
||||||
|
{
|
||||||
|
Print("#{:03d}: {}\n", i, LoggingAddresses[0][i].getString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Command::AddSV("g_log_add", [](const Command::Params* params)
|
Command::AddSV("g_log_add", [](const Command::Params* params)
|
||||||
{
|
|
||||||
if (params->size() < 2) return;
|
|
||||||
|
|
||||||
std::unique_lock lock(LoggingMutex);
|
|
||||||
|
|
||||||
const Network::Address addr(params->get(1));
|
|
||||||
if (std::ranges::find(LoggingAddresses[1], addr) == LoggingAddresses[1].end())
|
|
||||||
{
|
{
|
||||||
LoggingAddresses[1].push_back(addr);
|
if (params->size() < 2) return;
|
||||||
}
|
|
||||||
});
|
std::unique_lock lock(LoggingMutex);
|
||||||
|
|
||||||
|
const Network::Address addr(params->get(1));
|
||||||
|
if (std::ranges::find(LoggingAddresses[1], addr) == LoggingAddresses[1].end())
|
||||||
|
{
|
||||||
|
LoggingAddresses[1].push_back(addr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Command::AddSV("g_log_del", [](const Command::Params* params)
|
Command::AddSV("g_log_del", [](const Command::Params* params)
|
||||||
{
|
|
||||||
if (params->size() < 2) return;
|
|
||||||
|
|
||||||
std::unique_lock lock(LoggingMutex);
|
|
||||||
|
|
||||||
const auto num = std::atoi(params->get(1));
|
|
||||||
if (!std::strcmp(VA("%i", num), params->get(1)) && static_cast<unsigned int>(num) < LoggingAddresses[1].size())
|
|
||||||
{
|
{
|
||||||
const auto addr = LoggingAddresses[1].begin() + num;
|
if (params->size() < 2) return;
|
||||||
Print("Address {} removed\n", addr->getString());
|
|
||||||
LoggingAddresses[1].erase(addr);
|
std::unique_lock lock(LoggingMutex);
|
||||||
}
|
|
||||||
else
|
const auto num = std::atoi(params->get(1));
|
||||||
{
|
if (!std::strcmp(VA("%i", num), params->get(1)) && static_cast<unsigned int>(num) < LoggingAddresses[1].size())
|
||||||
const Network::Address addr(params->get(1));
|
|
||||||
const auto i = std::ranges::find(LoggingAddresses[1].begin(), LoggingAddresses[1].end(), addr);
|
|
||||||
if (i != LoggingAddresses[1].end())
|
|
||||||
{
|
{
|
||||||
LoggingAddresses[1].erase(i);
|
const auto addr = LoggingAddresses[1].begin() + num;
|
||||||
Print("Address {} removed\n", addr.getString());
|
Print("Address {} removed\n", addr->getString());
|
||||||
|
LoggingAddresses[1].erase(addr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Print("Address {} not found!\n", addr.getString());
|
const Network::Address addr(params->get(1));
|
||||||
|
const auto i = std::ranges::find(LoggingAddresses[1].begin(), LoggingAddresses[1].end(), addr);
|
||||||
|
if (i != LoggingAddresses[1].end())
|
||||||
|
{
|
||||||
|
LoggingAddresses[1].erase(i);
|
||||||
|
Print("Address {} removed\n", addr.getString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Print("Address {} not found!\n", addr.getString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
Command::AddSV("g_log_list", []([[maybe_unused]] const Command::Params* params)
|
Command::AddSV("g_log_list", []([[maybe_unused]] const Command::Params* params)
|
||||||
{
|
|
||||||
Print("# ID: Address\n");
|
|
||||||
Print("-------------\n");
|
|
||||||
|
|
||||||
std::unique_lock lock(LoggingMutex);
|
|
||||||
for (std::size_t i = 0; i < LoggingAddresses[1].size(); ++i)
|
|
||||||
{
|
{
|
||||||
Print("#{:03d}: {}\n", i, LoggingAddresses[1][i].getString());
|
Print("# ID: Address\n");
|
||||||
|
Print("-------------\n");
|
||||||
|
|
||||||
|
std::unique_lock lock(LoggingMutex);
|
||||||
|
for (std::size_t i = 0; i < LoggingAddresses[1].size(); ++i)
|
||||||
|
{
|
||||||
|
Print("#{:03d}: {}\n", i, LoggingAddresses[1][i].getString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintAliasError(Game::conChannel_t channel, const char* originalMsg, const char* soundName, const char* lastErrorStr)
|
||||||
|
{
|
||||||
|
// We add a bit more info and we clear the sound stream when it happens
|
||||||
|
// to avoid spamming the error
|
||||||
|
const auto newMsg = std::format("{}Make sure you have the 'miles' folder in your game directory! Otherwise MP3 and other codecs will be unavailable.\n", originalMsg);
|
||||||
|
Game::Com_PrintError(channel, newMsg.c_str(), soundName, lastErrorStr);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < ARRAYSIZE(Game::milesGlobal->streamReadInfo); i++)
|
||||||
|
{
|
||||||
|
if (0 == std::strncmp(Game::milesGlobal->streamReadInfo[i].path, soundName, ARRAYSIZE(Game::milesGlobal->streamReadInfo[i].path)))
|
||||||
|
{
|
||||||
|
Game::milesGlobal->streamReadInfo[i].path[0] = '\x00'; // This kills it and make sure it doesn't get played again for now
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::Logger()
|
Logger::Logger()
|
||||||
{
|
{
|
||||||
|
// Print sound aliases errors
|
||||||
|
if (!Dedicated::IsEnabled())
|
||||||
|
{
|
||||||
|
Utils::Hook(0x64BA67, PrintAliasError, HOOK_CALL).install()->quick();
|
||||||
|
}
|
||||||
|
|
||||||
Utils::Hook(0x642139, BuildOSPath_Stub, HOOK_JUMP).install()->quick();
|
Utils::Hook(0x642139, BuildOSPath_Stub, HOOK_JUMP).install()->quick();
|
||||||
|
|
||||||
Scheduler::Loop(Frame, Scheduler::Pipeline::SERVER);
|
Scheduler::Loop(Frame, Scheduler::Pipeline::SERVER);
|
||||||
@ -438,10 +464,10 @@ namespace Components
|
|||||||
|
|
||||||
Events::OnSVInit(AddServerCommands);
|
Events::OnSVInit(AddServerCommands);
|
||||||
Events::OnDvarInit([]
|
Events::OnDvarInit([]
|
||||||
{
|
{
|
||||||
IW4x_one_log = Dvar::Register<bool>("iw4x_onelog", false, Game::DVAR_LATCH, "Only write the game log to the 'userraw' OS folder");
|
IW4x_one_log = Dvar::Register<bool>("iw4x_onelog", false, Game::DVAR_LATCH, "Only write the game log to the 'userraw' OS folder");
|
||||||
IW4x_fail2ban_location = Dvar::Register<const char*>("iw4x_fail2ban_location", "/var/log/iw4x.log", Game::DVAR_NONE, "Fail2Ban logfile location");
|
IW4x_fail2ban_location = Dvar::Register<const char*>("iw4x_fail2ban_location", "/var/log/iw4x.log", Game::DVAR_NONE, "Fail2Ban logfile location");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::~Logger()
|
Logger::~Logger()
|
||||||
|
@ -23,12 +23,12 @@ namespace Components
|
|||||||
|
|
||||||
static void Print(const std::string_view& fmt)
|
static void Print(const std::string_view& fmt)
|
||||||
{
|
{
|
||||||
PrintInternal(Game::CON_CHANNEL_DONT_FILTER, fmt, std::make_format_args(0));
|
PrintInternal(Game::CON_CHANNEL_DONT_FILTER, fmt, std::make_format_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Print(Game::conChannel_t channel, const std::string_view& fmt)
|
static void Print(Game::conChannel_t channel, const std::string_view& fmt)
|
||||||
{
|
{
|
||||||
PrintInternal(channel, fmt, std::make_format_args(0));
|
PrintInternal(channel, fmt, std::make_format_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
@ -47,7 +47,7 @@ namespace Components
|
|||||||
|
|
||||||
static void Error(Game::errorParm_t error, const std::string_view& fmt)
|
static void Error(Game::errorParm_t error, const std::string_view& fmt)
|
||||||
{
|
{
|
||||||
ErrorInternal(error, fmt, std::make_format_args(0));
|
ErrorInternal(error, fmt, std::make_format_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
@ -59,7 +59,7 @@ namespace Components
|
|||||||
|
|
||||||
static void Warning(Game::conChannel_t channel, const std::string_view& fmt)
|
static void Warning(Game::conChannel_t channel, const std::string_view& fmt)
|
||||||
{
|
{
|
||||||
WarningInternal(channel, fmt, std::make_format_args(0));
|
WarningInternal(channel, fmt, std::make_format_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
@ -71,7 +71,7 @@ namespace Components
|
|||||||
|
|
||||||
static void PrintError(Game::conChannel_t channel, const std::string_view& fmt)
|
static void PrintError(Game::conChannel_t channel, const std::string_view& fmt)
|
||||||
{
|
{
|
||||||
PrintErrorInternal(channel, fmt, std::make_format_args(0));
|
PrintErrorInternal(channel, fmt, std::make_format_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
@ -83,7 +83,7 @@ namespace Components
|
|||||||
|
|
||||||
static void PrintFail2Ban(const std::string_view& fmt)
|
static void PrintFail2Ban(const std::string_view& fmt)
|
||||||
{
|
{
|
||||||
PrintFail2BanInternal(fmt, std::make_format_args(0));
|
PrintFail2BanInternal(fmt, std::make_format_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
|
@ -103,9 +103,9 @@ namespace Components
|
|||||||
|
|
||||||
const char* Maps::LoadArenaFileStub(const char* name, char* buffer, int size)
|
const char* Maps::LoadArenaFileStub(const char* name, char* buffer, int size)
|
||||||
{
|
{
|
||||||
std::string data = RawFiles::ReadRawFile(name, buffer, size);
|
std::string data;
|
||||||
|
|
||||||
if (Maps::UserMap.isValid())
|
if (Maps::UserMap.isValid())
|
||||||
{
|
{
|
||||||
const auto mapname = Maps::UserMap.getName();
|
const auto mapname = Maps::UserMap.getName();
|
||||||
const auto arena = GetArenaPath(mapname);
|
const auto arena = GetArenaPath(mapname);
|
||||||
@ -116,6 +116,10 @@ namespace Components
|
|||||||
data = Utils::IO::ReadFile(arena);
|
data = Utils::IO::ReadFile(arena);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data = RawFiles::ReadRawFile(name, buffer, size);
|
||||||
|
}
|
||||||
|
|
||||||
strncpy_s(buffer, size, data.data(), _TRUNCATE);
|
strncpy_s(buffer, size, data.data(), _TRUNCATE);
|
||||||
return buffer;
|
return buffer;
|
||||||
@ -141,11 +145,11 @@ namespace Components
|
|||||||
Maps::CurrentDependencies.clear();
|
Maps::CurrentDependencies.clear();
|
||||||
|
|
||||||
auto dependencies = GetDependenciesForMap(zoneInfo->name);
|
auto dependencies = GetDependenciesForMap(zoneInfo->name);
|
||||||
|
|
||||||
std::vector<Game::XZoneInfo> data;
|
std::vector<Game::XZoneInfo> data;
|
||||||
Utils::Merge(&data, zoneInfo, zoneCount);
|
Utils::Merge(&data, zoneInfo, zoneCount);
|
||||||
Utils::Memory::Allocator allocator;
|
Utils::Memory::Allocator allocator;
|
||||||
|
|
||||||
if (dependencies.requiresTeamZones)
|
if (dependencies.requiresTeamZones)
|
||||||
{
|
{
|
||||||
auto teams = dependencies.requiredTeams;
|
auto teams = dependencies.requiredTeams;
|
||||||
@ -177,7 +181,7 @@ namespace Components
|
|||||||
auto patchZone = std::format("patch_{}", zoneInfo->name);
|
auto patchZone = std::format("patch_{}", zoneInfo->name);
|
||||||
if (FastFiles::Exists(patchZone))
|
if (FastFiles::Exists(patchZone))
|
||||||
{
|
{
|
||||||
data.push_back({patchZone.data(), zoneInfo->allocFlags, zoneInfo->freeFlags});
|
data.push_back({ patchZone.data(), zoneInfo->allocFlags, zoneInfo->freeFlags });
|
||||||
}
|
}
|
||||||
|
|
||||||
return FastFiles::LoadLocalizeZones(data.data(), data.size(), sync);
|
return FastFiles::LoadLocalizeZones(data.data(), data.size(), sync);
|
||||||
@ -185,18 +189,18 @@ namespace Components
|
|||||||
|
|
||||||
void Maps::OverrideMapEnts(Game::MapEnts* ents)
|
void Maps::OverrideMapEnts(Game::MapEnts* ents)
|
||||||
{
|
{
|
||||||
auto callback = [] (Game::XAssetHeader header, void* ents)
|
auto callback = [](Game::XAssetHeader header, void* ents)
|
||||||
{
|
|
||||||
Game::MapEnts* mapEnts = reinterpret_cast<Game::MapEnts*>(ents);
|
|
||||||
Game::clipMap_t* clipMap = header.clipMap;
|
|
||||||
|
|
||||||
if (clipMap && mapEnts && !_stricmp(mapEnts->name, clipMap->name))
|
|
||||||
{
|
{
|
||||||
clipMap->mapEnts = mapEnts;
|
Game::MapEnts* mapEnts = reinterpret_cast<Game::MapEnts*>(ents);
|
||||||
//*Game::marMapEntsPtr = mapEnts;
|
Game::clipMap_t* clipMap = header.clipMap;
|
||||||
//Game::G_SpawnEntitiesFromString();
|
|
||||||
}
|
if (clipMap && mapEnts && !_stricmp(mapEnts->name, clipMap->name))
|
||||||
};
|
{
|
||||||
|
clipMap->mapEnts = mapEnts;
|
||||||
|
//*Game::marMapEntsPtr = mapEnts;
|
||||||
|
//Game::G_SpawnEntitiesFromString();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Internal doesn't lock the thread, as locking is impossible, due to executing this in the thread that holds the current lock
|
// Internal doesn't lock the thread, as locking is impossible, due to executing this in the thread that holds the current lock
|
||||||
Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_CLIPMAP_MP, callback, ents, true);
|
Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_CLIPMAP_MP, callback, ents, true);
|
||||||
@ -276,7 +280,7 @@ namespace Components
|
|||||||
Logger::Print("Waiting for database...\n");
|
Logger::Print("Waiting for database...\n");
|
||||||
while (!Game::Sys_IsDatabaseReady()) std::this_thread::sleep_for(10ms);
|
while (!Game::Sys_IsDatabaseReady()) std::this_thread::sleep_for(10ms);
|
||||||
|
|
||||||
if (!Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAMEWORLD_MP].gameWorldMp || !Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAMEWORLD_MP].gameWorldMp->name ||
|
if (!Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAMEWORLD_MP].gameWorldMp || !Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAMEWORLD_MP].gameWorldMp->name ||
|
||||||
!Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAMEWORLD_MP].gameWorldMp->g_glassData || Maps::SPMap)
|
!Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAMEWORLD_MP].gameWorldMp->g_glassData || Maps::SPMap)
|
||||||
{
|
{
|
||||||
return Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAMEWORLD_SP].gameWorldSp->g_glassData;
|
return Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAMEWORLD_SP].gameWorldSp->g_glassData;
|
||||||
@ -294,7 +298,7 @@ namespace Components
|
|||||||
|
|
||||||
call Maps::GetWorldData
|
call Maps::GetWorldData
|
||||||
|
|
||||||
mov [esp + 20h], eax
|
mov[esp + 20h], eax
|
||||||
popad
|
popad
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
@ -314,6 +318,28 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Maps::ForceRefreshArenas()
|
||||||
|
{
|
||||||
|
if (Game::Sys_IsMainThread())
|
||||||
|
{
|
||||||
|
if (*Game::g_quitRequested)
|
||||||
|
{
|
||||||
|
// No need to refresh if we're exiting the game
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Game::sharedUiInfo_t* uiInfo = reinterpret_cast<Game::sharedUiInfo_t*>(0x62E4B78);
|
||||||
|
uiInfo->updateArenas = 1;
|
||||||
|
Game::UI_UpdateArenas();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Dangerous!!
|
||||||
|
assert(false && "Arenas refreshed from wrong thread??");
|
||||||
|
Logger::Print("Tried to refresh arenas from a thread that is NOT the main thread!! This could have lead to a crash. Please report this bug and how you got it!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO : Remove hook entirely?
|
// TODO : Remove hook entirely?
|
||||||
void Maps::GetBSPName(char* buffer, size_t size, const char* format, const char* mapname)
|
void Maps::GetBSPName(char* buffer, size_t size, const char* format, const char* mapname)
|
||||||
{
|
{
|
||||||
@ -459,7 +485,7 @@ namespace Components
|
|||||||
char hashBuf[100] = { 0 };
|
char hashBuf[100] = { 0 };
|
||||||
unsigned int hash = atoi(Game::MSG_ReadStringLine(msg, hashBuf, sizeof hashBuf));
|
unsigned int hash = atoi(Game::MSG_ReadStringLine(msg, hashBuf, sizeof hashBuf));
|
||||||
|
|
||||||
if(!Maps::CheckMapInstalled(mapname, false, true) || hash && hash != Maps::GetUsermapHash(mapname))
|
if (!Maps::CheckMapInstalled(mapname, false, true) || hash && hash != Maps::GetUsermapHash(mapname))
|
||||||
{
|
{
|
||||||
// Reconnecting forces the client to download the new map
|
// Reconnecting forces the client to download the new map
|
||||||
Command::Execute("disconnect", false);
|
Command::Execute("disconnect", false);
|
||||||
@ -480,12 +506,12 @@ namespace Components
|
|||||||
push eax
|
push eax
|
||||||
pushad
|
pushad
|
||||||
|
|
||||||
push [esp + 28h]
|
push[esp + 28h]
|
||||||
push ebp
|
push ebp
|
||||||
call Maps::TriggerReconnectForMap
|
call Maps::TriggerReconnectForMap
|
||||||
add esp, 8h
|
add esp, 8h
|
||||||
|
|
||||||
mov [esp + 20h], eax
|
mov[esp + 20h], eax
|
||||||
|
|
||||||
popad
|
popad
|
||||||
pop eax
|
pop eax
|
||||||
@ -495,7 +521,7 @@ namespace Components
|
|||||||
|
|
||||||
push 487C50h // Rotate map
|
push 487C50h // Rotate map
|
||||||
|
|
||||||
skipRotation:
|
skipRotation :
|
||||||
retn
|
retn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -506,7 +532,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
pushad
|
pushad
|
||||||
|
|
||||||
push [esp + 24h]
|
push[esp + 24h]
|
||||||
call Maps::PrepareUsermap
|
call Maps::PrepareUsermap
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
@ -523,7 +549,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
pushad
|
pushad
|
||||||
|
|
||||||
push [esp + 24h]
|
push[esp + 24h]
|
||||||
call Maps::PrepareUsermap
|
call Maps::PrepareUsermap
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
@ -668,7 +694,7 @@ namespace Components
|
|||||||
Logger::Error(Game::ERR_DISCONNECT,
|
Logger::Error(Game::ERR_DISCONNECT,
|
||||||
"Missing map file {}.\nYou may have a damaged installation or are attempting to load a non-existent map.", mapname);
|
"Missing map file {}.\nYou may have a damaged installation or are attempting to load a non-existent map.", mapname);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +732,7 @@ namespace Components
|
|||||||
|
|
||||||
void Maps::G_SpawnTurretHook(Game::gentity_s* ent, int unk, int unk2)
|
void Maps::G_SpawnTurretHook(Game::gentity_s* ent, int unk, int unk2)
|
||||||
{
|
{
|
||||||
if (Maps::CurrentMainZone == "mp_backlot_sh"s || Maps::CurrentMainZone == "mp_con_spring"s ||
|
if (Maps::CurrentMainZone == "mp_backlot_sh"s || Maps::CurrentMainZone == "mp_con_spring"s ||
|
||||||
Maps::CurrentMainZone == "mp_mogadishu_sh"s || Maps::CurrentMainZone == "mp_nightshift_sh"s)
|
Maps::CurrentMainZone == "mp_mogadishu_sh"s || Maps::CurrentMainZone == "mp_nightshift_sh"s)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -736,7 +762,7 @@ namespace Components
|
|||||||
Logger::Error(Game::errorParm_t::ERR_DROP, "Invalid trigger index ({}) in entities exceeds the maximum trigger count ({}) defined in the clipmap. Check your map ents, or your clipmap!", triggerIndex, ents->trigger.count);
|
Logger::Error(Game::errorParm_t::ERR_DROP, "Invalid trigger index ({}) in entities exceeds the maximum trigger count ({}) defined in the clipmap. Check your map ents, or your clipmap!", triggerIndex, ents->trigger.count);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Utils::Hook::Call<unsigned short(int, Game::Bounds*)>(0x4416C0)(triggerIndex, bounds);
|
return Utils::Hook::Call<unsigned short(int, Game::Bounds*)>(0x4416C0)(triggerIndex, bounds);
|
||||||
}
|
}
|
||||||
@ -744,29 +770,29 @@ namespace Components
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Maps::Maps()
|
Maps::Maps()
|
||||||
{
|
{
|
||||||
Scheduler::Once([]
|
Scheduler::Once([]
|
||||||
{
|
|
||||||
Dvar::Register<bool>("isDlcInstalled_All", false, Game::DVAR_EXTERNAL | Game::DVAR_INIT, "");
|
|
||||||
Maps::RListSModels = Dvar::Register<bool>("r_listSModels", false, Game::DVAR_NONE, "Display a list of visible SModels");
|
|
||||||
|
|
||||||
Maps::AddDlc({ 1, "Stimulus Pack", {"mp_complex", "mp_compact", "mp_storm", "mp_overgrown", "mp_crash"} });
|
|
||||||
Maps::AddDlc({ 2, "Resurgence Pack", {"mp_abandon", "mp_vacant", "mp_trailerpark", "mp_strike", "mp_fuel2"} });
|
|
||||||
Maps::AddDlc({ 3, "IW4x Classics", {"mp_nuked", "mp_cross_fire", "mp_cargoship", "mp_bloc", "mp_killhouse", "mp_bog_sh", "mp_cargoship_sh", "mp_shipment", "mp_shipment_long", "mp_rust_long", "mp_firingrange", "mp_bloc_sh", "mp_crash_tropical", "mp_estate_tropical", "mp_fav_tropical", "mp_storm_spring"} });
|
|
||||||
Maps::AddDlc({ 4, "Call Of Duty 4 Pack", {"mp_farm", "mp_backlot", "mp_pipeline", "mp_countdown", "mp_crash_snow", "mp_carentan", "mp_broadcast", "mp_showdown", "mp_convoy", "mp_citystreets"} });
|
|
||||||
Maps::AddDlc({ 5, "Modern Warfare 3 Pack", {"mp_dome", "mp_hardhat", "mp_paris", "mp_seatown", "mp_bravo", "mp_underground", "mp_plaza2", "mp_village", "mp_alpha"}});
|
|
||||||
|
|
||||||
Maps::UpdateDlcStatus();
|
|
||||||
|
|
||||||
UIScript::Add("downloadDLC", []([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info)
|
|
||||||
{
|
{
|
||||||
const auto dlc = token.get<int>();
|
Dvar::Register<bool>("isDlcInstalled_All", false, Game::DVAR_EXTERNAL | Game::DVAR_INIT, "");
|
||||||
|
Maps::RListSModels = Dvar::Register<bool>("r_listSModels", false, Game::DVAR_NONE, "Display a list of visible SModels");
|
||||||
|
|
||||||
Game::ShowMessageBox(Utils::String::VA("DLC %d does not exist!", dlc), "ERROR");
|
Maps::AddDlc({ 1, "Stimulus Pack", {"mp_complex", "mp_compact", "mp_storm", "mp_overgrown", "mp_crash"} });
|
||||||
});
|
Maps::AddDlc({ 2, "Resurgence Pack", {"mp_abandon", "mp_vacant", "mp_trailerpark", "mp_strike", "mp_fuel2"} });
|
||||||
}, Scheduler::Pipeline::MAIN);
|
Maps::AddDlc({ 3, "IW4x Classics", {"mp_nuked", "mp_cross_fire", "mp_cargoship", "mp_bloc", "mp_killhouse", "mp_bog_sh", "mp_cargoship_sh", "mp_shipment", "mp_shipment_long", "mp_rust_long", "mp_firingrange", "mp_bloc_sh", "mp_crash_tropical", "mp_estate_tropical", "mp_fav_tropical", "mp_storm_spring"} });
|
||||||
|
Maps::AddDlc({ 4, "Call Of Duty 4 Pack", {"mp_farm", "mp_backlot", "mp_pipeline", "mp_countdown", "mp_crash_snow", "mp_carentan", "mp_broadcast", "mp_showdown", "mp_convoy", "mp_citystreets"} });
|
||||||
|
Maps::AddDlc({ 5, "Modern Warfare 3 Pack", {"mp_dome", "mp_hardhat", "mp_paris", "mp_seatown", "mp_bravo", "mp_underground", "mp_plaza2", "mp_village", "mp_alpha"} });
|
||||||
|
|
||||||
|
Maps::UpdateDlcStatus();
|
||||||
|
|
||||||
|
UIScript::Add("downloadDLC", []([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info)
|
||||||
|
{
|
||||||
|
const auto dlc = token.get<int>();
|
||||||
|
|
||||||
|
Game::ShowMessageBox(Utils::String::VA("DLC %d does not exist!", dlc), "ERROR");
|
||||||
|
});
|
||||||
|
}, Scheduler::Pipeline::MAIN);
|
||||||
|
|
||||||
// disable turrets on CoD:OL 448+ maps for now
|
// disable turrets on CoD:OL 448+ maps for now
|
||||||
Utils::Hook(0x5EE577, Maps::G_SpawnTurretHook, HOOK_CALL).install()->quick();
|
Utils::Hook(0x5EE577, Maps::G_SpawnTurretHook, HOOK_CALL).install()->quick();
|
||||||
@ -782,7 +808,7 @@ namespace Components
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
//#define SORT_SMODELS
|
//#define SORT_SMODELS
|
||||||
#if !defined(DEBUG) || !defined(SORT_SMODELS)
|
#if !defined(DEBUG) || !defined(SORT_SMODELS)
|
||||||
// Don't sort static models
|
// Don't sort static models
|
||||||
@ -825,13 +851,13 @@ namespace Components
|
|||||||
Utils::Hook(0x5B34DD, Maps::LoadMapLoadscreenStub, HOOK_CALL).install()->quick();
|
Utils::Hook(0x5B34DD, Maps::LoadMapLoadscreenStub, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
Command::Add("delayReconnect", []()
|
Command::Add("delayReconnect", []()
|
||||||
{
|
|
||||||
Scheduler::Once([]
|
|
||||||
{
|
{
|
||||||
Command::Execute("closemenu popup_reconnectingtoparty", false);
|
Scheduler::Once([]
|
||||||
Command::Execute("reconnect", false);
|
{
|
||||||
}, Scheduler::Pipeline::CLIENT, 10s);
|
Command::Execute("closemenu popup_reconnectingtoparty", false);
|
||||||
});
|
Command::Execute("reconnect", false);
|
||||||
|
}, Scheduler::Pipeline::CLIENT, 10s);
|
||||||
|
});
|
||||||
|
|
||||||
if (Dedicated::IsEnabled())
|
if (Dedicated::IsEnabled())
|
||||||
{
|
{
|
||||||
@ -845,12 +871,6 @@ namespace Components
|
|||||||
// Load usermap arena file
|
// Load usermap arena file
|
||||||
Utils::Hook(0x630A88, Maps::LoadArenaFileStub, HOOK_CALL).install()->quick();
|
Utils::Hook(0x630A88, Maps::LoadArenaFileStub, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
// Always refresh arena when loading or unloading a zone
|
|
||||||
Utils::Hook::Nop(0x485017, 2);
|
|
||||||
Utils::Hook::Nop(0x4BDFB7, 2); // Unknown
|
|
||||||
Utils::Hook::Nop(0x45ED6F, 2); // loadGameInfo
|
|
||||||
Utils::Hook::Nop(0x4A5888, 2); // UI_InitOnceForAllClients
|
|
||||||
|
|
||||||
// Allow hiding specific smodels
|
// Allow hiding specific smodels
|
||||||
Utils::Hook(0x50E67C, Maps::HideModelStub, HOOK_CALL).install()->quick();
|
Utils::Hook(0x50E67C, Maps::HideModelStub, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
@ -861,33 +881,33 @@ namespace Components
|
|||||||
|
|
||||||
// Client only
|
// Client only
|
||||||
Scheduler::Loop([]
|
Scheduler::Loop([]
|
||||||
{
|
|
||||||
auto*& gameWorld = *reinterpret_cast<Game::GfxWorld**>(0x66DEE94);
|
|
||||||
if (!Game::CL_IsCgameInitialized() || !gameWorld || !Maps::RListSModels.get<bool>()) return;
|
|
||||||
|
|
||||||
std::map<std::string, int> models;
|
|
||||||
for (unsigned int i = 0; i < gameWorld->dpvs.smodelCount; ++i)
|
|
||||||
{
|
{
|
||||||
if (gameWorld->dpvs.smodelVisData[0][i])
|
auto*& gameWorld = *reinterpret_cast<Game::GfxWorld**>(0x66DEE94);
|
||||||
|
if (!Game::CL_IsCgameInitialized() || !gameWorld || !Maps::RListSModels.get<bool>()) return;
|
||||||
|
|
||||||
|
std::map<std::string, int> models;
|
||||||
|
for (unsigned int i = 0; i < gameWorld->dpvs.smodelCount; ++i)
|
||||||
{
|
{
|
||||||
std::string name = gameWorld->dpvs.smodelDrawInsts[i].model->name;
|
if (gameWorld->dpvs.smodelVisData[0][i])
|
||||||
|
{
|
||||||
|
std::string name = gameWorld->dpvs.smodelDrawInsts[i].model->name;
|
||||||
|
|
||||||
if (!models.contains(name)) models[name] = 1;
|
if (!models.contains(name)) models[name] = 1;
|
||||||
else models[name]++;
|
else models[name]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Game::Font_s* font = Game::R_RegisterFont("fonts/smallFont", 0);
|
Game::Font_s* font = Game::R_RegisterFont("fonts/smallFont", 0);
|
||||||
auto height = Game::R_TextHeight(font);
|
auto height = Game::R_TextHeight(font);
|
||||||
auto scale = 0.75f;
|
auto scale = 0.75f;
|
||||||
float color[4] = {0.0f, 1.0f, 0.0f, 1.0f};
|
float color[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for (auto& model : models)
|
for (auto& model : models)
|
||||||
{
|
{
|
||||||
Game::R_AddCmdDrawText(Utils::String::VA("%d %s", model.second, model.first.data()), std::numeric_limits<int>::max(), font, 15.0f, (height * scale + 1) * (i++ + 1) + 15.0f, scale, scale, 0.0f, color, Game::ITEM_TEXTSTYLE_NORMAL);
|
Game::R_AddCmdDrawText(Utils::String::VA("%d %s", model.second, model.first.data()), std::numeric_limits<int>::max(), font, 15.0f, (height * scale + 1) * (i++ + 1) + 15.0f, scale, scale, 0.0f, color, Game::ITEM_TEXTSTYLE_NORMAL);
|
||||||
}
|
}
|
||||||
}, Scheduler::Pipeline::RENDERER);
|
}, Scheduler::Pipeline::RENDERER);
|
||||||
}
|
}
|
||||||
|
|
||||||
Maps::~Maps()
|
Maps::~Maps()
|
||||||
|
@ -13,7 +13,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
ZeroMemory(&this->searchPath, sizeof this->searchPath);
|
ZeroMemory(&this->searchPath, sizeof this->searchPath);
|
||||||
this->hash = Maps::GetUsermapHash(this->mapname);
|
this->hash = Maps::GetUsermapHash(this->mapname);
|
||||||
Game::UI_UpdateArenas();
|
Maps::ForceRefreshArenas();
|
||||||
}
|
}
|
||||||
|
|
||||||
~UserMapContainer()
|
~UserMapContainer()
|
||||||
@ -29,7 +29,10 @@ namespace Components
|
|||||||
{
|
{
|
||||||
bool wasValid = this->isValid();
|
bool wasValid = this->isValid();
|
||||||
this->mapname.clear();
|
this->mapname.clear();
|
||||||
if (wasValid) Game::UI_UpdateArenas();
|
if (wasValid)
|
||||||
|
{
|
||||||
|
Maps::ForceRefreshArenas();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadIwd();
|
void loadIwd();
|
||||||
@ -95,6 +98,8 @@ namespace Components
|
|||||||
|
|
||||||
static Dvar::Var RListSModels;
|
static Dvar::Var RListSModels;
|
||||||
|
|
||||||
|
static void ForceRefreshArenas();
|
||||||
|
|
||||||
static void GetBSPName(char* buffer, size_t size, const char* format, const char* mapname);
|
static void GetBSPName(char* buffer, size_t size, const char* format, const char* mapname);
|
||||||
static void LoadAssetRestrict(Game::XAssetType type, Game::XAssetHeader asset, const std::string& name, bool* restrict);
|
static void LoadAssetRestrict(Game::XAssetType type, Game::XAssetHeader asset, const std::string& name, bool* restrict);
|
||||||
static void LoadMapZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);
|
static void LoadMapZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);
|
||||||
|
@ -244,12 +244,12 @@ namespace Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto workingDir = std::filesystem::current_path().string();
|
const std::filesystem::path workingDir = std::filesystem::current_path();
|
||||||
const std::string binary = *Game::sys_exitCmdLine;
|
const std::wstring binary = Utils::String::Convert(*Game::sys_exitCmdLine);
|
||||||
const std::string command = binary == "iw4x-sp.exe" ? "iw4x-sp" : "iw4x";
|
const std::wstring commandLine = std::format(L"\"{}\" iw4x --pass \"{}\"", (workingDir / binary).wstring(), Utils::GetLaunchParameters());
|
||||||
|
|
||||||
SetEnvironmentVariableA("MW2_INSTALL", workingDir.data());
|
SetEnvironmentVariableA("MW2_INSTALL", workingDir.string().data());
|
||||||
Utils::Library::LaunchProcess(binary, std::format("{} --pass \"{}\"", command, GetCommandLineA()), workingDir);
|
Utils::Library::LaunchProcess(binary, commandLine, workingDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(naked) void QuickPatch::SND_GetAliasOffset_Stub()
|
__declspec(naked) void QuickPatch::SND_GetAliasOffset_Stub()
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
|
constexpr auto BASE_PLAYERSTATS_VERSION = 155;
|
||||||
|
|
||||||
Utils::Memory::Allocator StructuredData::MemAllocator;
|
Utils::Memory::Allocator StructuredData::MemAllocator;
|
||||||
|
|
||||||
const char* StructuredData::EnumTranslation[COUNT] =
|
const char* StructuredData::EnumTranslation[COUNT] =
|
||||||
@ -26,6 +28,11 @@ namespace Components
|
|||||||
{
|
{
|
||||||
if (!data || type >= StructuredData::PlayerDataType::COUNT) return;
|
if (!data || type >= StructuredData::PlayerDataType::COUNT) return;
|
||||||
|
|
||||||
|
// Reallocate them before patching
|
||||||
|
Game::StructuredDataEnum* newEnums = MemAllocator.allocateArray<Game::StructuredDataEnum>(data->enumCount);
|
||||||
|
std::memcpy(newEnums, data->enums, sizeof(Game::StructuredDataEnum) * data->enumCount);
|
||||||
|
data->enums = newEnums;
|
||||||
|
|
||||||
Game::StructuredDataEnum* dataEnum = &data->enums[type];
|
Game::StructuredDataEnum* dataEnum = &data->enums[type];
|
||||||
|
|
||||||
// Build index-sorted data vector
|
// Build index-sorted data vector
|
||||||
@ -87,23 +94,52 @@ namespace Components
|
|||||||
|
|
||||||
void StructuredData::PatchCustomClassLimit(Game::StructuredDataDef* data, int count)
|
void StructuredData::PatchCustomClassLimit(Game::StructuredDataDef* data, int count)
|
||||||
{
|
{
|
||||||
const int customClassSize = 64;
|
constexpr auto CLASS_ARRAY = 5;
|
||||||
|
const auto originalClassCount = data->indexedArrays[CLASS_ARRAY].arraySize;
|
||||||
|
|
||||||
for (int i = 0; i < data->structs[0].propertyCount; ++i)
|
if (count != originalClassCount)
|
||||||
{
|
{
|
||||||
// 3003 is the offset of the customClasses structure
|
const int customClassSize = 64;
|
||||||
if (data->structs[0].properties[i].offset >= 3643)
|
|
||||||
|
// We need to recreate the struct list cause it's used in order definitions
|
||||||
|
auto newStructs = StructuredData::MemAllocator.allocateArray<Game::StructuredDataStruct>(data->structCount);
|
||||||
|
std::memcpy(newStructs, data->structs, data->structCount * sizeof(Game::StructuredDataStruct));
|
||||||
|
data->structs = newStructs;
|
||||||
|
|
||||||
|
constexpr auto structIndex = 0;
|
||||||
{
|
{
|
||||||
// -10 because 10 is the default amount of custom classes.
|
auto strct = &data->structs[structIndex];
|
||||||
data->structs[0].properties[i].offset += ((count - 10) * customClassSize);
|
|
||||||
|
auto newProperties = StructuredData::MemAllocator.allocateArray<Game::StructuredDataStructProperty>(strct->propertyCount);
|
||||||
|
std::memcpy(newProperties, strct->properties, strct->propertyCount * sizeof(Game::StructuredDataStructProperty));
|
||||||
|
strct->properties = newProperties;
|
||||||
|
|
||||||
|
for (int propertyIndex = 0; propertyIndex < strct->propertyCount; ++propertyIndex)
|
||||||
|
{
|
||||||
|
// 3643 is the offset of the customClasses structure
|
||||||
|
if (strct->properties[propertyIndex].offset >= 3643)
|
||||||
|
{
|
||||||
|
// -10 because 10 is the default amount of custom classes.
|
||||||
|
strct->properties[propertyIndex].offset += ((count - originalClassCount) * customClassSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update structure size
|
||||||
|
data->size += ((count - originalClassCount) * customClassSize);
|
||||||
|
|
||||||
|
// Update amount of custom classes
|
||||||
|
if (data->indexedArrays[CLASS_ARRAY].arraySize != count)
|
||||||
|
{
|
||||||
|
// We need to recreate the whole array - this reference could be reused accross definitions
|
||||||
|
auto newIndexedArray = StructuredData::MemAllocator.allocateArray<Game::StructuredDataIndexedArray>(data->indexedArrayCount);
|
||||||
|
std::memcpy(newIndexedArray, data->indexedArrays, data->indexedArrayCount * sizeof(Game::StructuredDataIndexedArray));
|
||||||
|
data->indexedArrays = newIndexedArray;
|
||||||
|
|
||||||
|
// Add classes
|
||||||
|
data->indexedArrays[CLASS_ARRAY].arraySize = count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update structure size
|
|
||||||
data->size += ((count - 10) * customClassSize);
|
|
||||||
|
|
||||||
// Update amount of custom classes
|
|
||||||
data->indexedArrays[5].arraySize = count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StructuredData::PatchAdditionalData(Game::StructuredDataDef* data, std::unordered_map<std::string, std::string>& patches)
|
void StructuredData::PatchAdditionalData(Game::StructuredDataDef* data, std::unordered_map<std::string, std::string>& patches)
|
||||||
@ -119,26 +155,44 @@ namespace Components
|
|||||||
|
|
||||||
bool StructuredData::UpdateVersionOffsets(Game::StructuredDataDefSet* set, Game::StructuredDataBuffer* buffer, Game::StructuredDataDef* whatever)
|
bool StructuredData::UpdateVersionOffsets(Game::StructuredDataDefSet* set, Game::StructuredDataBuffer* buffer, Game::StructuredDataDef* whatever)
|
||||||
{
|
{
|
||||||
Game::StructuredDataDef* newDef = &set->defs[0];
|
if (set->defCount > 1)
|
||||||
Game::StructuredDataDef* oldDef = &set->defs[0];
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < set->defCount; ++i)
|
|
||||||
{
|
{
|
||||||
if (newDef->version < set->defs[i].version)
|
int bufferVersion = *reinterpret_cast<int*>(buffer->data);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < set->defCount; i++)
|
||||||
{
|
{
|
||||||
newDef = &set->defs[i];
|
if (set->defs[i].version == bufferVersion)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
// No update to conduct
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Game::StructuredDataDef* newDef = &set->defs[i - 1];
|
||||||
|
Game::StructuredDataDef* oldDef = &set->defs[i];
|
||||||
|
|
||||||
|
if (newDef->version == 159 && oldDef->version <= 158)
|
||||||
|
{
|
||||||
|
// this should move the data 320 bytes infront
|
||||||
|
std::memmove(&buffer->data[3963], &buffer->data[3643], oldDef->size - 3643);
|
||||||
|
}
|
||||||
|
else if (newDef->version > 159 && false)
|
||||||
|
{
|
||||||
|
// 159 cannot be translated upwards and it's hard to say why
|
||||||
|
// Reading it fails in various ways
|
||||||
|
// might be the funky class bump...?
|
||||||
|
|
||||||
|
Command::Execute("setPlayerData prestige 10");
|
||||||
|
Command::Execute("setPlayerData experience 2516000");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Utils::Hook::Call<bool(void*, void*, void*)>(0x456830)(set, buffer, whatever);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (set->defs[i].version == *reinterpret_cast<int*>(buffer->data))
|
return Utils::Hook::Call<bool(void*, void*, void*)>(0x456830)(set, buffer, whatever);
|
||||||
{
|
|
||||||
oldDef = &set->defs[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newDef->version >= 159 && oldDef->version <= 158)
|
|
||||||
{
|
|
||||||
// this should move the data 320 bytes infront
|
|
||||||
std::memmove(&buffer->data[3963], &buffer->data[3643], oldDef->size - 3643);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StructuredData_UpdateVersion
|
// StructuredData_UpdateVersion
|
||||||
@ -182,7 +236,7 @@ namespace Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->defs[0].version != 155)
|
if (data->defs[0].version != BASE_PLAYERSTATS_VERSION)
|
||||||
{
|
{
|
||||||
Logger::Error(Game::ERR_FATAL, "Initial PlayerDataDef is not version 155, patching not possible!");
|
Logger::Error(Game::ERR_FATAL, "Initial PlayerDataDef is not version 155, patching not possible!");
|
||||||
return;
|
return;
|
||||||
@ -262,16 +316,10 @@ namespace Components
|
|||||||
auto* newData = StructuredData::MemAllocator.allocateArray<Game::StructuredDataDef>(data->defCount + patchDefinitions.size());
|
auto* newData = StructuredData::MemAllocator.allocateArray<Game::StructuredDataDef>(data->defCount + patchDefinitions.size());
|
||||||
std::memcpy(&newData[patchDefinitions.size()], data->defs, sizeof Game::StructuredDataDef * data->defCount);
|
std::memcpy(&newData[patchDefinitions.size()], data->defs, sizeof Game::StructuredDataDef * data->defCount);
|
||||||
|
|
||||||
// Prepare the buffers
|
// Set the versions
|
||||||
for (unsigned int i = 0; i < patchDefinitions.size(); ++i)
|
for (unsigned int i = 0; i < patchDefinitions.size(); ++i)
|
||||||
{
|
{
|
||||||
std::memcpy(&newData[i], data->defs, sizeof Game::StructuredDataDef);
|
newData[i].version = (patchDefinitions.size() - i) + BASE_PLAYERSTATS_VERSION;
|
||||||
newData[i].version = (patchDefinitions.size() - i) + 155;
|
|
||||||
|
|
||||||
// Reallocate the enum array
|
|
||||||
auto* newEnums = StructuredData::MemAllocator.allocateArray<Game::StructuredDataEnum>(data->defs->enumCount);
|
|
||||||
std::memcpy(newEnums, data->defs->enums, sizeof Game::StructuredDataEnum * data->defs->enumCount);
|
|
||||||
newData[i].enums = newEnums;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply new data
|
// Apply new data
|
||||||
@ -279,10 +327,18 @@ namespace Components
|
|||||||
data->defCount += patchDefinitions.size();
|
data->defCount += patchDefinitions.size();
|
||||||
|
|
||||||
// Patch the definition
|
// Patch the definition
|
||||||
for (unsigned int i = 0; i < data->defCount; ++i)
|
for (int i = data->defCount - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
// No need to patch version 155
|
// No need to patch version 155
|
||||||
if (newData[i].version == 155) continue;
|
if (newData[i].version == BASE_PLAYERSTATS_VERSION)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We start from the previous one
|
||||||
|
const auto version = newData[i].version;
|
||||||
|
data->defs[i] = data->defs[i + 1];
|
||||||
|
newData[i].version = version;
|
||||||
|
|
||||||
if (patchDefinitions.contains(newData[i].version))
|
if (patchDefinitions.contains(newData[i].version))
|
||||||
{
|
{
|
||||||
|
@ -2,11 +2,14 @@
|
|||||||
#include "ClientCommand.hpp"
|
#include "ClientCommand.hpp"
|
||||||
#include "MapRotation.hpp"
|
#include "MapRotation.hpp"
|
||||||
#include "Vote.hpp"
|
#include "Vote.hpp"
|
||||||
|
#include "Events.hpp"
|
||||||
|
|
||||||
using namespace Utils::String;
|
using namespace Utils::String;
|
||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
|
Dvar::Var Vote::SV_VotesRequired;
|
||||||
|
|
||||||
std::unordered_map<std::string, Vote::CommandHandler> Vote::VoteCommands =
|
std::unordered_map<std::string, Vote::CommandHandler> Vote::VoteCommands =
|
||||||
{
|
{
|
||||||
{"map_restart", HandleMapRestart},
|
{"map_restart", HandleMapRestart},
|
||||||
@ -37,6 +40,17 @@ namespace Components
|
|||||||
Game::SV_SetConfigstring(Game::CS_VOTE_NO, VA("%i", Game::level->voteNo));
|
Game::SV_SetConfigstring(Game::CS_VOTE_NO, VA("%i", Game::level->voteNo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Vote::VotesRequired()
|
||||||
|
{
|
||||||
|
auto votesRequired = Vote::SV_VotesRequired.get<int>();
|
||||||
|
|
||||||
|
if (votesRequired > 0)
|
||||||
|
{
|
||||||
|
return votesRequired;
|
||||||
|
}
|
||||||
|
return Game::level->numConnectedClients / 2 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
bool Vote::IsInvalidVoteString(const std::string& input)
|
bool Vote::IsInvalidVoteString(const std::string& input)
|
||||||
{
|
{
|
||||||
static const char* separators[] = { "\n", "\r", ";" };
|
static const char* separators[] = { "\n", "\r", ";" };
|
||||||
@ -204,7 +218,7 @@ namespace Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Game::level->numConnectedClients < 2)
|
if (Game::level->numConnectedClients < VotesRequired())
|
||||||
{
|
{
|
||||||
Game::SV_GameSendServerCommand(ent - Game::g_entities, Game::SV_CMD_CAN_IGNORE, VA("%c \"GAME_VOTINGNOTENOUGHPLAYERS\"", 0x65));
|
Game::SV_GameSendServerCommand(ent - Game::g_entities, Game::SV_CMD_CAN_IGNORE, VA("%c \"GAME_VOTINGNOTENOUGHPLAYERS\"", 0x65));
|
||||||
return;
|
return;
|
||||||
@ -218,7 +232,7 @@ namespace Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ent->client->sess.voteCount >= 3)
|
if (ent->client->sess.voteCount >= VotesRequired())
|
||||||
{
|
{
|
||||||
Game::SV_GameSendServerCommand(ent - Game::g_entities, Game::SV_CMD_CAN_IGNORE, VA("%c \"GAME_MAXVOTESCALLED\"", 0x65));
|
Game::SV_GameSendServerCommand(ent - Game::g_entities, Game::SV_CMD_CAN_IGNORE, VA("%c \"GAME_MAXVOTESCALLED\"", 0x65));
|
||||||
return;
|
return;
|
||||||
@ -321,6 +335,10 @@ namespace Components
|
|||||||
// Replicate g_allowVote
|
// Replicate g_allowVote
|
||||||
Utils::Hook::Set<std::uint32_t>(0x5E3A4F, Game::DVAR_INTERNAL | Game::DVAR_CODINFO);
|
Utils::Hook::Set<std::uint32_t>(0x5E3A4F, Game::DVAR_INTERNAL | Game::DVAR_CODINFO);
|
||||||
|
|
||||||
|
Events::OnDvarInit([]{
|
||||||
|
Vote::SV_VotesRequired = Game::Dvar_RegisterInt("sv_votesRequired", 0, 0, 18, Game::DVAR_NONE, "Set the amount of votes required for a vote to pass.\n0 = (players / 2) + 1");
|
||||||
|
});
|
||||||
|
|
||||||
ClientCommand::Add("callvote", Cmd_CallVote_f);
|
ClientCommand::Add("callvote", Cmd_CallVote_f);
|
||||||
ClientCommand::Add("vote", Cmd_Vote_f);
|
ClientCommand::Add("vote", Cmd_Vote_f);
|
||||||
|
|
||||||
|
@ -11,11 +11,14 @@ namespace Components
|
|||||||
using CommandHandler = std::function<bool(const Game::gentity_s* ent, const Command::ServerParams* params)>;
|
using CommandHandler = std::function<bool(const Game::gentity_s* ent, const Command::ServerParams* params)>;
|
||||||
static std::unordered_map<std::string, CommandHandler> VoteCommands;
|
static std::unordered_map<std::string, CommandHandler> VoteCommands;
|
||||||
|
|
||||||
|
static Dvar::Var SV_VotesRequired;
|
||||||
|
|
||||||
static constexpr auto* CallVoteDesc = "%c \"GAME_VOTECOMMANDSARE\x15 map_restart, map_rotate, map <mapname>, g_gametype <typename>, typemap <typename> <mapname>, "
|
static constexpr auto* CallVoteDesc = "%c \"GAME_VOTECOMMANDSARE\x15 map_restart, map_rotate, map <mapname>, g_gametype <typename>, typemap <typename> <mapname>, "
|
||||||
"kick <player>, tempBanUser <player>\"";
|
"kick <player>, tempBanUser <player>\"";
|
||||||
|
|
||||||
static void DisplayVote(const Game::gentity_s* ent);
|
static void DisplayVote(const Game::gentity_s* ent);
|
||||||
static bool IsInvalidVoteString(const std::string& input);
|
static bool IsInvalidVoteString(const std::string& input);
|
||||||
|
static int VotesRequired();
|
||||||
|
|
||||||
static bool HandleMapRestart(const Game::gentity_s* ent, const Command::ServerParams* params);
|
static bool HandleMapRestart(const Game::gentity_s* ent, const Command::ServerParams* params);
|
||||||
static bool HandleMapRotate(const Game::gentity_s* ent, const Command::ServerParams* params);
|
static bool HandleMapRotate(const Game::gentity_s* ent, const Command::ServerParams* params);
|
||||||
|
@ -17,10 +17,13 @@ namespace Game
|
|||||||
G_DebugLineWithDuration_t G_DebugLineWithDuration = G_DebugLineWithDuration_t(0x4C3280);
|
G_DebugLineWithDuration_t G_DebugLineWithDuration = G_DebugLineWithDuration_t(0x4C3280);
|
||||||
|
|
||||||
gentity_s* g_entities = reinterpret_cast<gentity_s*>(0x18835D8);
|
gentity_s* g_entities = reinterpret_cast<gentity_s*>(0x18835D8);
|
||||||
|
bool* g_quitRequested = reinterpret_cast<bool*>(0x649FB61);
|
||||||
|
|
||||||
NetField* clientStateFields = reinterpret_cast<Game::NetField*>(0x741E40);
|
NetField* clientStateFields = reinterpret_cast<Game::NetField*>(0x741E40);
|
||||||
size_t clientStateFieldsCount = Utils::Hook::Get<size_t>(0x7433C8);
|
size_t clientStateFieldsCount = Utils::Hook::Get<size_t>(0x7433C8);
|
||||||
|
|
||||||
|
MssLocal* milesGlobal = reinterpret_cast<MssLocal*>(0x649A1A0);
|
||||||
|
|
||||||
const char* origErrorMsg = reinterpret_cast<const char*>(0x79B124);
|
const char* origErrorMsg = reinterpret_cast<const char*>(0x79B124);
|
||||||
|
|
||||||
XModel* G_GetModel(const int index)
|
XModel* G_GetModel(const int index)
|
||||||
|
@ -52,10 +52,13 @@ namespace Game
|
|||||||
constexpr std::size_t MAX_GENTITIES = 2048;
|
constexpr std::size_t MAX_GENTITIES = 2048;
|
||||||
constexpr std::size_t ENTITYNUM_NONE = MAX_GENTITIES - 1;
|
constexpr std::size_t ENTITYNUM_NONE = MAX_GENTITIES - 1;
|
||||||
extern gentity_s* g_entities;
|
extern gentity_s* g_entities;
|
||||||
|
extern bool* g_quitRequested;
|
||||||
|
|
||||||
// This does not belong anywhere else
|
// This does not belong anywhere else
|
||||||
extern NetField* clientStateFields;
|
extern NetField* clientStateFields;
|
||||||
extern size_t clientStateFieldsCount;
|
extern size_t clientStateFieldsCount;
|
||||||
|
extern MssLocal* milesGlobal;
|
||||||
|
|
||||||
|
|
||||||
extern const char* origErrorMsg;
|
extern const char* origErrorMsg;
|
||||||
|
|
||||||
|
@ -1139,11 +1139,11 @@ namespace Game
|
|||||||
unsigned __int16 triCount;
|
unsigned __int16 triCount;
|
||||||
XSurfaceCollisionTree* collisionTree;
|
XSurfaceCollisionTree* collisionTree;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DObjSkelMat
|
struct DObjSkelMat
|
||||||
{
|
{
|
||||||
float axis[3][4];
|
float axis[3][4];
|
||||||
float origin[4];
|
float origin[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct XSurface
|
struct XSurface
|
||||||
@ -1978,6 +1978,7 @@ namespace Game
|
|||||||
CMD_BUTTON_FRAG = 1 << 14,
|
CMD_BUTTON_FRAG = 1 << 14,
|
||||||
CMD_BUTTON_OFFHAND_SECONDARY = 1 << 15,
|
CMD_BUTTON_OFFHAND_SECONDARY = 1 << 15,
|
||||||
CMD_BUTTON_THROW = 1 << 19,
|
CMD_BUTTON_THROW = 1 << 19,
|
||||||
|
CMD_BUTTON_REMOTE = 1 << 20,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usercmd_s
|
struct usercmd_s
|
||||||
@ -2425,7 +2426,7 @@ namespace Game
|
|||||||
float scale;
|
float scale;
|
||||||
unsigned int noScalePartBits[6];
|
unsigned int noScalePartBits[6];
|
||||||
unsigned __int16* boneNames;
|
unsigned __int16* boneNames;
|
||||||
unsigned char *parentList;
|
unsigned char* parentList;
|
||||||
short* quats;
|
short* quats;
|
||||||
float* trans;
|
float* trans;
|
||||||
unsigned char* partClassification;
|
unsigned char* partClassification;
|
||||||
@ -4020,7 +4021,7 @@ namespace Game
|
|||||||
GfxSurfaceBounds* surfacesBounds;
|
GfxSurfaceBounds* surfacesBounds;
|
||||||
GfxStaticModelDrawInst* smodelDrawInsts;
|
GfxStaticModelDrawInst* smodelDrawInsts;
|
||||||
GfxDrawSurf* surfaceMaterials;
|
GfxDrawSurf* surfaceMaterials;
|
||||||
unsigned int* surfaceCastsSunShadow;
|
unsigned int* surfaceCastsSunShadow;
|
||||||
volatile int usageCount;
|
volatile int usageCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4031,7 +4032,7 @@ namespace Game
|
|||||||
unsigned __int16 materialSortedIndex : 12;
|
unsigned __int16 materialSortedIndex : 12;
|
||||||
unsigned __int16 visDataRefCountLessOne : 4;
|
unsigned __int16 visDataRefCountLessOne : 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
union GfxSModelSurfHeader
|
union GfxSModelSurfHeader
|
||||||
{
|
{
|
||||||
GfxSModelSurfHeaderFields fields;
|
GfxSModelSurfHeaderFields fields;
|
||||||
@ -5518,6 +5519,32 @@ namespace Game
|
|||||||
StructuredDataEnumEntry* entries;
|
StructuredDataEnumEntry* entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum LookupResultDataType
|
||||||
|
{
|
||||||
|
LOOKUP_RESULT_INT = 0x0,
|
||||||
|
LOOKUP_RESULT_BOOL = 0x1,
|
||||||
|
LOOKUP_RESULT_STRING = 0x2,
|
||||||
|
LOOKUP_RESULT_FLOAT = 0x3,
|
||||||
|
LOOKUP_RESULT_SHORT = 0x4,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum LookupState
|
||||||
|
{
|
||||||
|
LOOKUP_IN_PROGRESS = 0x0,
|
||||||
|
LOOKUP_FINISHED = 0x1,
|
||||||
|
LOOKUP_ERROR = 0x2,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum LookupError
|
||||||
|
{
|
||||||
|
LOOKUP_ERROR_NONE = 0x0,
|
||||||
|
LOOKUP_ERROR_WRONG_DATA_TYPE = 0x1,
|
||||||
|
LOOKUP_ERROR_INDEX_OUTSIDE_BOUNDS = 0x2,
|
||||||
|
LOOKUP_ERROR_INVALID_STRUCT_PROPERTY = 0x3,
|
||||||
|
LOOKUP_ERROR_INVALID_ENUM_VALUE = 0x4,
|
||||||
|
LOOKUP_ERROR_COUNT = 0x5,
|
||||||
|
};
|
||||||
|
|
||||||
enum StructuredDataTypeCategory
|
enum StructuredDataTypeCategory
|
||||||
{
|
{
|
||||||
DATA_INT = 0x0,
|
DATA_INT = 0x0,
|
||||||
@ -5593,6 +5620,15 @@ namespace Game
|
|||||||
unsigned int size;
|
unsigned int size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct StructuredDataLookup
|
||||||
|
{
|
||||||
|
StructuredDataDef* def;
|
||||||
|
StructuredDataType* type;
|
||||||
|
unsigned int offset;
|
||||||
|
LookupError error;
|
||||||
|
};
|
||||||
|
|
||||||
struct StructuredDataDefSet
|
struct StructuredDataDefSet
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
@ -7931,8 +7967,8 @@ namespace Game
|
|||||||
|
|
||||||
struct GfxCmdBufContext
|
struct GfxCmdBufContext
|
||||||
{
|
{
|
||||||
GfxCmdBufSourceState *source;
|
GfxCmdBufSourceState* source;
|
||||||
GfxCmdBufState *state;
|
GfxCmdBufState* state;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GfxDrawGroupSetupFields
|
struct GfxDrawGroupSetupFields
|
||||||
@ -8384,18 +8420,18 @@ namespace Game
|
|||||||
int timeStamp;
|
int timeStamp;
|
||||||
DObjAnimMat* mat;
|
DObjAnimMat* mat;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bitarray
|
struct bitarray
|
||||||
{
|
{
|
||||||
int array[6];
|
int array[6];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 1923 */
|
/* 1923 */
|
||||||
struct XAnimCalcAnimInfo
|
struct XAnimCalcAnimInfo
|
||||||
{
|
{
|
||||||
DObjAnimMat rotTransArray[1152];
|
DObjAnimMat rotTransArray[1152];
|
||||||
bitarray animPartBits;
|
bitarray animPartBits;
|
||||||
bitarray ignorePartBits;
|
bitarray ignorePartBits;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -11100,6 +11136,159 @@ namespace Game
|
|||||||
FFD_USER_MAP = 0x2,
|
FFD_USER_MAP = 0x2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ASISTAGE
|
||||||
|
{
|
||||||
|
int(__stdcall* ASI_stream_open)(unsigned int, int(__stdcall*)(unsigned int, void*, int, int), unsigned int);
|
||||||
|
int(__stdcall* ASI_stream_process)(int, void*, int);
|
||||||
|
int(__stdcall* ASI_stream_seek)(int, int);
|
||||||
|
int(__stdcall* ASI_stream_close)(int);
|
||||||
|
int(__stdcall* ASI_stream_property)(int, unsigned int, void*, const void*, void*);
|
||||||
|
unsigned int INPUT_BIT_RATE;
|
||||||
|
unsigned int INPUT_SAMPLE_RATE;
|
||||||
|
unsigned int INPUT_BITS;
|
||||||
|
unsigned int INPUT_CHANNELS;
|
||||||
|
unsigned int OUTPUT_BIT_RATE;
|
||||||
|
unsigned int OUTPUT_SAMPLE_RATE;
|
||||||
|
unsigned int OUTPUT_BITS;
|
||||||
|
unsigned int OUTPUT_CHANNELS;
|
||||||
|
unsigned int OUTPUT_RESERVOIR;
|
||||||
|
unsigned int POSITION;
|
||||||
|
unsigned int PERCENT_DONE;
|
||||||
|
unsigned int MIN_INPUT_BLOCK_SIZE;
|
||||||
|
unsigned int RAW_RATE;
|
||||||
|
unsigned int RAW_BITS;
|
||||||
|
unsigned int RAW_CHANNELS;
|
||||||
|
unsigned int REQUESTED_RATE;
|
||||||
|
unsigned int REQUESTED_BITS;
|
||||||
|
unsigned int REQUESTED_CHANS;
|
||||||
|
unsigned int STREAM_SEEK_POS;
|
||||||
|
unsigned int DATA_START_OFFSET;
|
||||||
|
unsigned int DATA_LEN;
|
||||||
|
int stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _STREAM
|
||||||
|
{
|
||||||
|
int block_oriented;
|
||||||
|
int using_ASI;
|
||||||
|
ASISTAGE* ASI;
|
||||||
|
void* samp;
|
||||||
|
unsigned int fileh;
|
||||||
|
char* bufs[3];
|
||||||
|
unsigned int bufsizes[3];
|
||||||
|
int reset_ASI[3];
|
||||||
|
int reset_seek_pos[3];
|
||||||
|
int bufstart[3];
|
||||||
|
void* asyncs[3];
|
||||||
|
int loadedbufstart[2];
|
||||||
|
int loadedorder[2];
|
||||||
|
int loadorder;
|
||||||
|
int bufsize;
|
||||||
|
int readsize;
|
||||||
|
unsigned int buf1;
|
||||||
|
int size1;
|
||||||
|
unsigned int buf2;
|
||||||
|
int size2;
|
||||||
|
unsigned int buf3;
|
||||||
|
int size3;
|
||||||
|
unsigned int datarate;
|
||||||
|
int filerate;
|
||||||
|
int filetype;
|
||||||
|
unsigned int fileflags;
|
||||||
|
int totallen;
|
||||||
|
int substart;
|
||||||
|
int sublen;
|
||||||
|
int subpadding;
|
||||||
|
unsigned int blocksize;
|
||||||
|
int padding;
|
||||||
|
int padded;
|
||||||
|
int loadedsome;
|
||||||
|
unsigned int startpos;
|
||||||
|
unsigned int totalread;
|
||||||
|
unsigned int loopsleft;
|
||||||
|
unsigned int error;
|
||||||
|
int preload;
|
||||||
|
unsigned int preloadpos;
|
||||||
|
int noback;
|
||||||
|
int alldone;
|
||||||
|
int primeamount;
|
||||||
|
int readatleast;
|
||||||
|
int playcontrol;
|
||||||
|
void(__stdcall* callback)(_STREAM*);
|
||||||
|
int user_data[8];
|
||||||
|
void* next;
|
||||||
|
int autostreaming;
|
||||||
|
int docallback;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum SND_EQTYPE
|
||||||
|
{
|
||||||
|
SND_EQTYPE_FIRST = 0x0,
|
||||||
|
SND_EQTYPE_LOWPASS = 0x0,
|
||||||
|
SND_EQTYPE_HIGHPASS = 0x1,
|
||||||
|
SND_EQTYPE_LOWSHELF = 0x2,
|
||||||
|
SND_EQTYPE_HIGHSHELF = 0x3,
|
||||||
|
SND_EQTYPE_BELL = 0x4,
|
||||||
|
SND_EQTYPE_LAST = 0x4,
|
||||||
|
SND_EQTYPE_COUNT = 0x5,
|
||||||
|
SND_EQTYPE_INVALID = 0x5,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct __declspec(align(4)) SndEqParams
|
||||||
|
{
|
||||||
|
SND_EQTYPE type;
|
||||||
|
float gain;
|
||||||
|
float freq;
|
||||||
|
float q;
|
||||||
|
bool enabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MssEqInfo
|
||||||
|
{
|
||||||
|
SndEqParams params[3][64];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MssFileHandle
|
||||||
|
{
|
||||||
|
unsigned int id;
|
||||||
|
MssFileHandle* next;
|
||||||
|
int handle;
|
||||||
|
char fileName[128];
|
||||||
|
unsigned int hashCode;
|
||||||
|
int offset;
|
||||||
|
int fileOffset;
|
||||||
|
int fileLength;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct __declspec(align(4)) MssStreamReadInfo
|
||||||
|
{
|
||||||
|
char path[256];
|
||||||
|
int timeshift;
|
||||||
|
float fraction;
|
||||||
|
int startDelay;
|
||||||
|
_STREAM* handle;
|
||||||
|
bool readError;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MssLocal
|
||||||
|
{
|
||||||
|
struct _DIG_DRIVER* driver;
|
||||||
|
struct _SAMPLE* handle_sample[40];
|
||||||
|
_STREAM* handle_stream[12];
|
||||||
|
bool voiceEqDisabled[52];
|
||||||
|
MssEqInfo eq[2];
|
||||||
|
float eqLerp;
|
||||||
|
unsigned int eqFilter;
|
||||||
|
int currentRoomtype;
|
||||||
|
MssFileHandle fileHandle[12];
|
||||||
|
MssFileHandle* freeFileHandle;
|
||||||
|
bool isMultiChannel;
|
||||||
|
float realVolume[12];
|
||||||
|
int playbackRate[52];
|
||||||
|
MssStreamReadInfo streamReadInfo[12];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#ifndef IDA
|
#ifndef IDA
|
||||||
|
@ -102,17 +102,17 @@ namespace Utils
|
|||||||
this->module_ = nullptr;
|
this->module_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Library::LaunchProcess(const std::string& process, const std::string& commandLine, const std::string& currentDir)
|
void Library::LaunchProcess(const std::wstring& process, const std::wstring& commandLine, const std::filesystem::path& currentDir)
|
||||||
{
|
{
|
||||||
STARTUPINFOA startupInfo;
|
STARTUPINFOW startupInfo;
|
||||||
PROCESS_INFORMATION processInfo;
|
PROCESS_INFORMATION processInfo;
|
||||||
|
|
||||||
ZeroMemory(&startupInfo, sizeof(startupInfo));
|
ZeroMemory(&startupInfo, sizeof(startupInfo));
|
||||||
ZeroMemory(&processInfo, sizeof(processInfo));
|
ZeroMemory(&processInfo, sizeof(processInfo));
|
||||||
startupInfo.cb = sizeof(startupInfo);
|
startupInfo.cb = sizeof(startupInfo);
|
||||||
|
|
||||||
CreateProcessA(process.data(), const_cast<char*>(commandLine.data()), nullptr,
|
CreateProcessW(process.data(), const_cast<wchar_t*>(commandLine.data()), nullptr,
|
||||||
nullptr, false, NULL, nullptr, currentDir.data(),
|
nullptr, false, NULL, nullptr, currentDir.wstring().data(),
|
||||||
&startupInfo, &processInfo);
|
&startupInfo, &processInfo);
|
||||||
|
|
||||||
if (processInfo.hThread && processInfo.hThread != INVALID_HANDLE_VALUE)
|
if (processInfo.hThread && processInfo.hThread != INVALID_HANDLE_VALUE)
|
||||||
|
@ -65,7 +65,7 @@ namespace Utils
|
|||||||
return T();
|
return T();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LaunchProcess(const std::string& process, const std::string& commandLine, const std::string& currentDir);
|
static void LaunchProcess(const std::wstring& process, const std::wstring& commandLine, const std::filesystem::path& currentDir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HMODULE module_;
|
HMODULE module_;
|
||||||
|
@ -163,6 +163,28 @@ namespace Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::wstring GetLaunchParameters()
|
||||||
|
{
|
||||||
|
std::wstring args;
|
||||||
|
|
||||||
|
int numArgs;
|
||||||
|
auto* const argv = CommandLineToArgvW(GetCommandLineW(), &numArgs);
|
||||||
|
|
||||||
|
if (argv)
|
||||||
|
{
|
||||||
|
for (auto i = 1; i < numArgs; ++i)
|
||||||
|
{
|
||||||
|
std::wstring arg(argv[i]);
|
||||||
|
args.append(arg);
|
||||||
|
args.append(L" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalFree(argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
HMODULE GetNTDLL()
|
HMODULE GetNTDLL()
|
||||||
{
|
{
|
||||||
return GetModuleHandleA("ntdll.dll");
|
return GetModuleHandleA("ntdll.dll");
|
||||||
|
@ -24,6 +24,8 @@ namespace Utils
|
|||||||
|
|
||||||
void OpenUrl(const std::string& url);
|
void OpenUrl(const std::string& url);
|
||||||
|
|
||||||
|
std::wstring GetLaunchParameters();
|
||||||
|
|
||||||
bool HasIntersection(unsigned int base1, unsigned int len1, unsigned int base2, unsigned int len2);
|
bool HasIntersection(unsigned int base1, unsigned int len1, unsigned int base2, unsigned int len2);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
Loading…
Reference in New Issue
Block a user