Force dedicated servers in online mode

This commit is contained in:
BrentVL-1952840 2023-02-23 09:55:36 +01:00
parent 6716c828db
commit d1b0ed9e56
4 changed files with 37 additions and 24 deletions

View File

@ -2,6 +2,7 @@
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "scheduler.hpp"
#include <utils/hook.hpp>
@ -13,6 +14,11 @@ namespace dedicated_patches
{
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1);
}
game::eNetworkModes get_online_mode()
{
return game::MODE_NETWORK_ONLINE;
}
}
struct component final : server_component
@ -21,6 +27,15 @@ namespace dedicated_patches
{
// Fix infinite loop
utils::hook::jump(0x1402E86B0_g, scr_are_textures_loaded_stub);
utils::hook::jump(0x1405003E0_g, get_online_mode);
utils::hook::jump(0x1405003B0_g, get_online_mode);
scheduler::once([]()
{
game::Com_SessionMode_SetNetworkMode(game::MODE_NETWORK_ONLINE);
game::Com_SessionMode_SetGameMode(game::MODE_GAME_MATCHMAKING_PLAYLIST);
}, scheduler::pipeline::main, 1s);
}
};
}

View File

@ -227,29 +227,6 @@ namespace party
const auto address = *reinterpret_cast<uint64_t*>(0x1453DABB8_g) + (0x25780 * local_client_num) + 0x10;
return *reinterpret_cast<game::netadr_t*>(address);
}
bool is_mp()
{
return game::Com_SessionMode_GetMode() == game::MODE_MULTIPLAYER;
}
int should_transfer_stub(uint8_t* storage_file_info)
{
auto should_transfer = game::ShouldTransfer(storage_file_info);
const auto offset = storage_file_info - reinterpret_cast<uint8_t*>(0x14343CDF0_g);
const auto index = offset / 120;
// Choose between multiplayer or zombies indices
const auto stats_index = is_mp() ? 12 : 17;
const auto loadout_index = is_mp() ? 15 : 20;
if (index >= stats_index && index <= loadout_index && is_connecting_to_dedi && get_connected_server() == connect_host)
{
should_transfer = !should_transfer;
}
return should_transfer;
}
}
void query_server(const game::netadr_t& host, query_callback callback)
@ -270,7 +247,6 @@ namespace party
void post_unpack() override
{
utils::hook::jump(0x141EE6030_g, connect_stub);
utils::hook::call(0x1422781E3_g, should_transfer_stub);
network::on("infoResponse", [](const game::netadr_t& target, const network::data_view& data)
{

View File

@ -18,6 +18,17 @@ namespace game
CONTROLLER_INDEX_COUNT = 0x4,
};
enum eGameModes
{
MODE_GAME_MATCHMAKING_PLAYLIST = 0x0,
MODE_GAME_MATCHMAKING_MANUAL = 0x1,
MODE_GAME_DEFAULT = 0x2,
MODE_GAME_LEAGUE = 0x3,
MODE_GAME_THEATER = 0x4,
MODE_GAME_COUNT = 0x5,
MODE_GAME_INVALID = 0x5,
};
enum eModes
{
MODE_ZOMBIES = 0x0,
@ -28,6 +39,15 @@ namespace game
MODE_FIRST = 0x0,
};
enum eNetworkModes
{
MODE_NETWORK_OFFLINE = 0x0,
MODE_NETWORK_SYSTEMLINK = 0x1,
MODE_NETWORK_ONLINE = 0x2,
MODE_NETWORK_COUNT = 0x3,
MODE_NETWORK_INVALID = 0x3,
};
enum bdLobbyErrorCode
{
BD_NO_ERROR = 0x0,

View File

@ -21,6 +21,8 @@ namespace game
WEAK symbol<void(int channel, unsigned int label, const char* fmt, ...)> Com_Printf{0x1421499C0, 0x140505630};
WEAK symbol<void(const char* file, int line, int code, const char* fmt, ...)> Com_Error_{0x1420F8BD0};
WEAK symbol<bool(eModes mode)> Com_SessionMode_IsMode{0x1420F7DD0};
WEAK symbol<void(eNetworkModes networkMode)> Com_SessionMode_SetNetworkMode{0x1420F8010, 0x140500B80};
WEAK symbol<eGameModes(eGameModes gameMode)> Com_SessionMode_SetGameMode{0x0, 0x140500B40};
WEAK symbol<bool()> Com_IsRunningUILevel{0x142148DB0};
WEAK symbol<void(int localClientNum, eModes fromMode, eModes toMode, uint32_t flags)> Com_SwitchMode{
0x14214AF30