[General] Get rid of unnecessary submodules
This commit is contained in:
parent
a6314ab418
commit
c9d160c72a
@ -49,6 +49,7 @@ namespace Components
|
|||||||
#include "Modules\Command.hpp"
|
#include "Modules\Command.hpp"
|
||||||
#include "Modules\Console.hpp"
|
#include "Modules\Console.hpp"
|
||||||
#include "Modules\IPCPipe.hpp"
|
#include "Modules\IPCPipe.hpp"
|
||||||
|
#include "Modules\UIScript.hpp"
|
||||||
#include "Modules\ModList.hpp"
|
#include "Modules\ModList.hpp"
|
||||||
#include "Modules\Network.hpp"
|
#include "Modules\Network.hpp"
|
||||||
#include "Modules\Theatre.hpp"
|
#include "Modules\Theatre.hpp"
|
||||||
@ -61,7 +62,6 @@ namespace Components
|
|||||||
#include "Modules\RawFiles.hpp"
|
#include "Modules\RawFiles.hpp"
|
||||||
#include "Modules\Renderer.hpp"
|
#include "Modules\Renderer.hpp"
|
||||||
#include "Modules\UIFeeder.hpp"
|
#include "Modules\UIFeeder.hpp"
|
||||||
#include "Modules\UIScript.hpp"
|
|
||||||
#include "Modules\AntiCheat.hpp"
|
#include "Modules\AntiCheat.hpp"
|
||||||
#include "Modules\Dedicated.hpp"
|
#include "Modules\Dedicated.hpp"
|
||||||
#include "Modules\Discovery.hpp"
|
#include "Modules\Discovery.hpp"
|
||||||
|
@ -198,7 +198,7 @@ namespace Components
|
|||||||
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, reinterpret_cast<char*>(callee), &module);
|
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, reinterpret_cast<char*>(callee), &module);
|
||||||
GetModuleFileNameA(module, buffer, sizeof buffer);
|
GetModuleFileNameA(module, buffer, sizeof buffer);
|
||||||
|
|
||||||
MessageBoxA(0, fmt::sprintf("Loading library %s via %s %X", std::string(library.begin(), library.end()).data(), buffer, reinterpret_cast<uint32_t>(callee)).data(), 0, 0);
|
MessageBoxA(0, Utils::String::VA("Loading library %s via %s %X", std::string(library.begin(), library.end()).data(), buffer, reinterpret_cast<uint32_t>(callee)), 0, 0);
|
||||||
|
|
||||||
return LoadLibraryExW(library.data(), NULL, 0);
|
return LoadLibraryExW(library.data(), NULL, 0);
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ namespace Components
|
|||||||
{
|
{
|
||||||
thread_local bool AssetHandler::BypassState;
|
thread_local bool AssetHandler::BypassState;
|
||||||
std::map<Game::XAssetType, AssetHandler::IAsset*> AssetHandler::AssetInterfaces;
|
std::map<Game::XAssetType, AssetHandler::IAsset*> AssetHandler::AssetInterfaces;
|
||||||
std::map<Game::XAssetType, wink::slot<AssetHandler::Callback>> AssetHandler::TypeCallbacks;
|
std::map<Game::XAssetType, Utils::Slot<AssetHandler::Callback>> AssetHandler::TypeCallbacks;
|
||||||
wink::signal<wink::slot<AssetHandler::RestrictCallback>> AssetHandler::RestrictSignal;
|
Utils::Signal<AssetHandler::RestrictCallback> AssetHandler::RestrictSignal;
|
||||||
|
|
||||||
std::map<void*, void*> AssetHandler::Relocations;
|
std::map<void*, void*> AssetHandler::Relocations;
|
||||||
|
|
||||||
@ -215,12 +215,12 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetHandler::OnFind(Game::XAssetType type, AssetHandler::Callback* callback)
|
void AssetHandler::OnFind(Game::XAssetType type, Utils::Slot<AssetHandler::Callback> callback)
|
||||||
{
|
{
|
||||||
AssetHandler::TypeCallbacks[type] = callback;
|
AssetHandler::TypeCallbacks[type] = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetHandler::OnLoad(AssetHandler::RestrictCallback* callback)
|
void AssetHandler::OnLoad(Utils::Slot<AssetHandler::RestrictCallback> callback)
|
||||||
{
|
{
|
||||||
AssetHandler::RestrictSignal.connect(callback);
|
AssetHandler::RestrictSignal.connect(callback);
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ namespace Components
|
|||||||
const char* getName() { return "AssetHandler"; };
|
const char* getName() { return "AssetHandler"; };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void OnFind(Game::XAssetType type, Callback* callback);
|
static void OnFind(Game::XAssetType type, Utils::Slot<Callback> callback);
|
||||||
static void OnLoad(RestrictCallback* callback);
|
static void OnLoad(Utils::Slot<RestrictCallback> callback);
|
||||||
|
|
||||||
static void ClearRelocations();
|
static void ClearRelocations();
|
||||||
static void Relocate(void* start, void* to, DWORD size = 4);
|
static void Relocate(void* start, void* to, DWORD size = 4);
|
||||||
@ -45,8 +45,8 @@ namespace Components
|
|||||||
static std::map<std::string, Game::XAssetHeader> TemporaryAssets[Game::XAssetType::ASSET_TYPE_COUNT];
|
static std::map<std::string, Game::XAssetHeader> TemporaryAssets[Game::XAssetType::ASSET_TYPE_COUNT];
|
||||||
|
|
||||||
static std::map<Game::XAssetType, IAsset*> AssetInterfaces;
|
static std::map<Game::XAssetType, IAsset*> AssetInterfaces;
|
||||||
static std::map<Game::XAssetType, wink::slot<Callback>> TypeCallbacks;
|
static std::map<Game::XAssetType, Utils::Slot<Callback>> TypeCallbacks;
|
||||||
static wink::signal<wink::slot<RestrictCallback>> RestrictSignal;
|
static Utils::Signal<RestrictCallback> RestrictSignal;
|
||||||
|
|
||||||
static std::map<void*, void*> Relocations;
|
static std::map<void*, void*> Relocations;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace Assets
|
|||||||
const char* tempName = image->name;
|
const char* tempName = image->name;
|
||||||
if (tempName[0] == '*') tempName++;
|
if (tempName[0] == '*') tempName++;
|
||||||
|
|
||||||
Components::FileSystem::File imageFile(fmt::sprintf("images/%s.iw4xImage", tempName));
|
Components::FileSystem::File imageFile(Utils::String::VA("images/%s.iw4xImage", tempName));
|
||||||
if (imageFile.exists())
|
if (imageFile.exists())
|
||||||
{
|
{
|
||||||
Utils::Stream::Reader reader(builder->getAllocator(), imageFile.getBuffer());
|
Utils::Stream::Reader reader(builder->getAllocator(), imageFile.getBuffer());
|
||||||
|
@ -128,7 +128,7 @@ namespace Assets
|
|||||||
Utils::String::Replace(name, "maps/mp/", "");
|
Utils::String::Replace(name, "maps/mp/", "");
|
||||||
Utils::String::Replace(name, ".d3dbsp", "");
|
Utils::String::Replace(name, ".d3dbsp", "");
|
||||||
|
|
||||||
Components::FileSystem::File mapFile(fmt::sprintf("gfxworld/%s.iw4xGfxWorld", name.data()));
|
Components::FileSystem::File mapFile(Utils::String::VA("gfxworld/%s.iw4xGfxWorld", name.data()));
|
||||||
|
|
||||||
if (mapFile.exists())
|
if (mapFile.exists())
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ namespace Assets
|
|||||||
|
|
||||||
void IMaterial::loadBinary(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
void IMaterial::loadBinary(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
Components::FileSystem::File materialFile(fmt::sprintf("materials/%s.iw4xMaterial", name.data()));
|
Components::FileSystem::File materialFile(Utils::String::VA("materials/%s.iw4xMaterial", name.data()));
|
||||||
if (!materialFile.exists()) return;
|
if (!materialFile.exists()) return;
|
||||||
|
|
||||||
Game::Material* material = builder->getAllocator()->allocate<Game::Material>();
|
Game::Material* material = builder->getAllocator()->allocate<Game::Material>();
|
||||||
@ -139,7 +139,7 @@ namespace Assets
|
|||||||
|
|
||||||
void IMaterial::loadJson(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
void IMaterial::loadJson(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
Components::FileSystem::File materialInfo(fmt::sprintf("materials/%s.json", name.data()));
|
Components::FileSystem::File materialInfo(Utils::String::VA("materials/%s.json", name.data()));
|
||||||
|
|
||||||
if (!materialInfo.exists()) return;
|
if (!materialInfo.exists()) return;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ namespace Assets
|
|||||||
{
|
{
|
||||||
void IXAnimParts::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
void IXAnimParts::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
Components::FileSystem::File animFile(fmt::sprintf("xanim/%s.iw4xAnim", name.data()));
|
Components::FileSystem::File animFile(Utils::String::VA("xanim/%s.iw4xAnim", name.data()));
|
||||||
|
|
||||||
if (animFile.exists())
|
if (animFile.exists())
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,7 @@ namespace Assets
|
|||||||
|
|
||||||
void IXModel::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
void IXModel::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
Components::FileSystem::File modelFile(fmt::sprintf("xmodel/%s.iw4xModel", name.data()));
|
Components::FileSystem::File modelFile(Utils::String::VA("xmodel/%s.iw4xModel", name.data()));
|
||||||
|
|
||||||
if (modelFile.exists())
|
if (modelFile.exists())
|
||||||
{
|
{
|
||||||
|
@ -571,7 +571,7 @@ namespace Assets
|
|||||||
Utils::String::Replace(name, "maps/mp/", "");
|
Utils::String::Replace(name, "maps/mp/", "");
|
||||||
Utils::String::Replace(name, ".d3dbsp", "");
|
Utils::String::Replace(name, ".d3dbsp", "");
|
||||||
|
|
||||||
Components::FileSystem::File clipFile(fmt::sprintf("clipmap/%s.iw4xClipMap", name.data()));
|
Components::FileSystem::File clipFile(Utils::String::VA("clipmap/%s.iw4xClipMap", name.data()));
|
||||||
if (!clipFile.exists())
|
if (!clipFile.exists())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -45,7 +45,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Toast::Show("cardicon_locked", "Success", fmt::sprintf("Your new security level is %d", Auth::GetSecurityLevel()), 5000);
|
Toast::Show("cardicon_locked", "Success", Utils::String::VA("Your new security level is %d", Auth::GetSecurityLevel()), 5000);
|
||||||
Command::Execute(Auth::TokenContainer.command, false);
|
Command::Execute(Auth::TokenContainer.command, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ namespace Components
|
|||||||
|
|
||||||
if (userLevel < ourLevel)
|
if (userLevel < ourLevel)
|
||||||
{
|
{
|
||||||
Network::Send(address, fmt::sprintf("error\nYour security level (%d) is lower than the server's security level (%d)", userLevel, ourLevel));
|
Network::Send(address, Utils::String::VA("error\nYour security level (%d) is lower than the server's security level (%d)", userLevel, ourLevel));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +402,7 @@ namespace Components
|
|||||||
Logger::Print("Your security token is: %s\n", Utils::String::DumpHex(Auth::GuidToken.toString(), "").data());
|
Logger::Print("Your security token is: %s\n", Utils::String::DumpHex(Auth::GuidToken.toString(), "").data());
|
||||||
Logger::Print("Your computation token is: %s\n", Utils::String::DumpHex(Auth::ComputeToken.toString(), "").data());
|
Logger::Print("Your computation token is: %s\n", Utils::String::DumpHex(Auth::ComputeToken.toString(), "").data());
|
||||||
|
|
||||||
Toast::Show("cardicon_locked", "^5Security Level", fmt::sprintf("Your security level is %d", level), 3000);
|
Toast::Show("cardicon_locked", "^5Security Level", Utils::String::VA("Your security level is %d", level), 3000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -412,7 +412,7 @@ namespace Components
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
UIScript::Add("security_increase_cancel", [] ()
|
UIScript::Add("security_increase_cancel", [] (UIScript::Token)
|
||||||
{
|
{
|
||||||
Auth::TokenContainer.cancel = true;
|
Auth::TokenContainer.cancel = true;
|
||||||
Logger::Print("Token incrementation process canceled!\n");
|
Logger::Print("Token incrementation process canceled!\n");
|
||||||
|
@ -82,12 +82,12 @@ namespace Components
|
|||||||
|
|
||||||
for (auto& idEntry : list.idList)
|
for (auto& idEntry : list.idList)
|
||||||
{
|
{
|
||||||
idVector.push_back(fmt::sprintf("%llX", idEntry.Bits));
|
idVector.push_back(Utils::String::VA("%llX", idEntry.Bits));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& ipEntry : list.ipList)
|
for (auto& ipEntry : list.ipList)
|
||||||
{
|
{
|
||||||
ipVector.push_back(fmt::sprintf("%u.%u.%u.%u",
|
ipVector.push_back(Utils::String::VA("%u.%u.%u.%u",
|
||||||
ipEntry.bytes[0] & 0xFF,
|
ipEntry.bytes[0] & 0xFF,
|
||||||
ipEntry.bytes[1] & 0xFF,
|
ipEntry.bytes[1] & 0xFF,
|
||||||
ipEntry.bytes[2] & 0xFF,
|
ipEntry.bytes[2] & 0xFF,
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
Utils::Memory::Allocator Command::MemAllocator;
|
Utils::Memory::Allocator Command::MemAllocator;
|
||||||
std::unordered_map<std::string, wink::slot<Command::Callback>> Command::FunctionMap;
|
std::unordered_map<std::string, Utils::Slot<Command::Callback>> Command::FunctionMap;
|
||||||
std::unordered_map<std::string, wink::slot<Command::Callback>> Command::FunctionMapSV;
|
std::unordered_map<std::string, Utils::Slot<Command::Callback>> Command::FunctionMapSV;
|
||||||
|
|
||||||
std::string Command::Params::join(size_t startIndex)
|
std::string Command::Params::join(size_t startIndex)
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ namespace Components
|
|||||||
return Game::cmd_argc_sv[this->commandId];
|
return Game::cmd_argc_sv[this->commandId];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command::Add(const char* name, Command::Callback* callback)
|
void Command::Add(const char* name, Utils::Slot<Command::Callback> callback)
|
||||||
{
|
{
|
||||||
std::string command = Utils::String::ToLower(name);
|
std::string command = Utils::String::ToLower(name);
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ namespace Components
|
|||||||
Command::FunctionMap[command] = callback;
|
Command::FunctionMap[command] = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command::AddSV(const char* name, Command::Callback* callback)
|
void Command::AddSV(const char* name, Utils::Slot<Command::Callback> callback)
|
||||||
{
|
{
|
||||||
if (Loader::IsPregame())
|
if (Loader::IsPregame())
|
||||||
{
|
{
|
||||||
|
@ -54,8 +54,8 @@ namespace Components
|
|||||||
|
|
||||||
static Game::cmd_function_t* Allocate();
|
static Game::cmd_function_t* Allocate();
|
||||||
|
|
||||||
static void Add(const char* name, Callback* callback);
|
static void Add(const char* name, Utils::Slot<Callback> callback);
|
||||||
static void AddSV(const char* name, Callback* callback);
|
static void AddSV(const char* name, Utils::Slot<Callback> callback);
|
||||||
static void AddRaw(const char* name, void(*callback)(), bool key = false);
|
static void AddRaw(const char* name, void(*callback)(), bool key = false);
|
||||||
static void AddRawSV(const char* name, void(*callback)());
|
static void AddRawSV(const char* name, void(*callback)());
|
||||||
static void Execute(std::string command, bool sync = true);
|
static void Execute(std::string command, bool sync = true);
|
||||||
@ -64,8 +64,8 @@ namespace Components
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static Utils::Memory::Allocator MemAllocator;
|
static Utils::Memory::Allocator MemAllocator;
|
||||||
static std::unordered_map<std::string, wink::slot<Callback>> FunctionMap;
|
static std::unordered_map<std::string, Utils::Slot<Callback>> FunctionMap;
|
||||||
static std::unordered_map<std::string, wink::slot<Callback>> FunctionMapSV;
|
static std::unordered_map<std::string, Utils::Slot<Callback>> FunctionMapSV;
|
||||||
|
|
||||||
static void MainCallback();
|
static void MainCallback();
|
||||||
static void MainCallbackSV();
|
static void MainCallbackSV();
|
||||||
|
@ -135,7 +135,7 @@ namespace Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = fmt::sprintf("%s,1", ownPth);
|
data = Utils::String::VA("%s,1", ownPth);
|
||||||
openRes = RegSetValueExA(hKey, 0, 0, REG_SZ, reinterpret_cast<const BYTE*>(data.data()), data.size() + 1);
|
openRes = RegSetValueExA(hKey, 0, 0, REG_SZ, reinterpret_cast<const BYTE*>(data.data()), data.size() + 1);
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ namespace Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = fmt::sprintf("\"%s\" \"%s\"", ownPth, "%1");
|
data = Utils::String::VA("\"%s\" \"%s\"", ownPth, "%1");
|
||||||
openRes = RegSetValueExA(hKey, 0, 0, REG_SZ, reinterpret_cast<const BYTE*>(data.data()), data.size() + 1);
|
openRes = RegSetValueExA(hKey, 0, 0, REG_SZ, reinterpret_cast<const BYTE*>(data.data()), data.size() + 1);
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Command::Execute(fmt::sprintf("connect %s", ConnectProtocol::ConnectString.data()), false);
|
Command::Execute(Utils::String::VA("connect %s", ConnectProtocol::ConnectString.data()), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +214,7 @@ namespace Components
|
|||||||
// IPC handler
|
// IPC handler
|
||||||
IPCPipe::On("connect", [] (std::string data)
|
IPCPipe::On("connect", [] (std::string data)
|
||||||
{
|
{
|
||||||
Command::Execute(fmt::sprintf("connect %s", data.data()), false);
|
Command::Execute(Utils::String::VA("connect %s", data.data()), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Invocation handler
|
// Invocation handler
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
wink::signal<wink::slot<Dedicated::Callback>> Dedicated::FrameSignal;
|
Utils::Signal<Dedicated::Callback> Dedicated::FrameSignal;
|
||||||
wink::signal<wink::slot<Dedicated::Callback>> Dedicated::FrameOnceSignal;
|
Utils::Signal<Dedicated::Callback> Dedicated::FrameOnceSignal;
|
||||||
|
|
||||||
bool Dedicated::SendChat;
|
bool Dedicated::SendChat;
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ namespace Components
|
|||||||
if (!partyEnable) // Time wrapping should not occur in party servers, but yeah...
|
if (!partyEnable) // Time wrapping should not occur in party servers, but yeah...
|
||||||
{
|
{
|
||||||
if (mapname.empty()) mapname = "mp_rust";
|
if (mapname.empty()) mapname = "mp_rust";
|
||||||
Command::Execute(fmt::sprintf("map %s", mapname.data()), false);
|
Command::Execute(Utils::String::VA("map %s", mapname.data()), false);
|
||||||
mapname.clear();
|
mapname.clear();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -162,11 +162,11 @@ namespace Components
|
|||||||
|
|
||||||
if (!Dvar::Var("sv_cheats").get<bool>())
|
if (!Dvar::Var("sv_cheats").get<bool>())
|
||||||
{
|
{
|
||||||
Command::Execute(fmt::sprintf("map %s", Dvar::Var("mapname").get<const char*>()), true);
|
Command::Execute(Utils::String::VA("map %s", Dvar::Var("mapname").get<const char*>()), true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Command::Execute(fmt::sprintf("devmap %s", Dvar::Var("mapname").get<const char*>()), true);
|
Command::Execute(Utils::String::VA("devmap %s", Dvar::Var("mapname").get<const char*>()), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -208,7 +208,7 @@ namespace Components
|
|||||||
Dvar::Var("sv_mapRotationCurrent").set(rotation);
|
Dvar::Var("sv_mapRotationCurrent").set(rotation);
|
||||||
|
|
||||||
Logger::Print("Loading new map: %s\n", value.data());
|
Logger::Print("Loading new map: %s\n", value.data());
|
||||||
Command::Execute(fmt::sprintf("map %s", value.data()), true);
|
Command::Execute(Utils::String::VA("map %s", value.data()), true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (key == "gametype")
|
else if (key == "gametype")
|
||||||
@ -228,18 +228,18 @@ namespace Components
|
|||||||
int masterPort = Dvar::Var("masterPort").get<int>();
|
int masterPort = Dvar::Var("masterPort").get<int>();
|
||||||
const char* masterServerName = Dvar::Var("masterServerName").get<const char*>();
|
const char* masterServerName = Dvar::Var("masterServerName").get<const char*>();
|
||||||
|
|
||||||
Network::Address master(fmt::sprintf("%s:%u", masterServerName, masterPort));
|
Network::Address master(Utils::String::VA("%s:%u", masterServerName, masterPort));
|
||||||
|
|
||||||
Logger::Print("Sending heartbeat to master: %s:%u\n", masterServerName, masterPort);
|
Logger::Print("Sending heartbeat to master: %s:%u\n", masterServerName, masterPort);
|
||||||
Network::SendCommand(master, "heartbeat", "IW4");
|
Network::SendCommand(master, "heartbeat", "IW4");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dedicated::Once(Dedicated::Callback* callback)
|
void Dedicated::Once(Utils::Slot<Dedicated::Callback> callback)
|
||||||
{
|
{
|
||||||
Dedicated::FrameOnceSignal.connect(callback);
|
Dedicated::FrameOnceSignal.connect(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dedicated::OnFrame(Dedicated::Callback* callback)
|
void Dedicated::OnFrame(Utils::Slot<Dedicated::Callback> callback)
|
||||||
{
|
{
|
||||||
Dedicated::FrameSignal.connect(callback);
|
Dedicated::FrameSignal.connect(callback);
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,12 @@ namespace Components
|
|||||||
|
|
||||||
static void Heartbeat();
|
static void Heartbeat();
|
||||||
|
|
||||||
static void OnFrame(Callback* callback);
|
static void OnFrame(Utils::Slot<Callback> callback);
|
||||||
static void Once(Callback* callback);
|
static void Once(Utils::Slot<Callback> callback);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static wink::signal<wink::slot<Callback>> FrameSignal;
|
static Utils::Signal<Callback> FrameSignal;
|
||||||
static wink::signal<wink::slot<Callback>> FrameOnceSignal;
|
static Utils::Signal<Callback> FrameOnceSignal;
|
||||||
|
|
||||||
static bool SendChat;
|
static bool SendChat;
|
||||||
|
|
||||||
|
@ -31,11 +31,11 @@ namespace Components
|
|||||||
|
|
||||||
Logger::Print("Starting local server discovery...\n");
|
Logger::Print("Starting local server discovery...\n");
|
||||||
|
|
||||||
Discovery::Challenge = fmt::sprintf("%X", Utils::Cryptography::Rand::GenerateInt());
|
Discovery::Challenge = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||||
|
|
||||||
unsigned int minPort = Dvar::Var("net_discoveryPortRangeMin").get<unsigned int>();
|
unsigned int minPort = Dvar::Var("net_discoveryPortRangeMin").get<unsigned int>();
|
||||||
unsigned int maxPort = Dvar::Var("net_discoveryPortRangeMax").get<unsigned int>();
|
unsigned int maxPort = Dvar::Var("net_discoveryPortRangeMax").get<unsigned int>();
|
||||||
Network::BroadcastRange(minPort, maxPort, fmt::sprintf("discovery %s", Discovery::Challenge.data()));
|
Network::BroadcastRange(minPort, maxPort, Utils::String::VA("discovery %s", Discovery::Challenge.data()));
|
||||||
|
|
||||||
Logger::Print("Discovery sent within %dms, awaiting responses...\n", Game::Sys_Milliseconds() - start);
|
Logger::Print("Discovery sent within %dms, awaiting responses...\n", Game::Sys_Milliseconds() - start);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ namespace Components
|
|||||||
fDownload->download->timeStampBytes += bytes;
|
fDownload->download->timeStampBytes += bytes;
|
||||||
|
|
||||||
double progress = (100.0 / fDownload->download->totalBytes) * fDownload->download->downBytes;
|
double progress = (100.0 / fDownload->download->totalBytes) * fDownload->download->downBytes;
|
||||||
Localization::SetTemp("MPUI_PROGRESS_DL", fmt::sprintf("(%d/%d) %d%%", fDownload->index + 1, fDownload->download->files.size(), static_cast<unsigned int>(progress)));
|
Localization::SetTemp("MPUI_PROGRESS_DL", Utils::String::VA("(%d/%d) %d%%", fDownload->index + 1, fDownload->download->files.size(), static_cast<unsigned int>(progress)));
|
||||||
|
|
||||||
int delta = Game::Sys_Milliseconds() - fDownload->download->lastTimeStamp;
|
int delta = Game::Sys_Milliseconds() - fDownload->download->lastTimeStamp;
|
||||||
if (delta > 300)
|
if (delta > 300)
|
||||||
@ -218,7 +218,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
if (download->terminateThread) return;
|
if (download->terminateThread) return;
|
||||||
|
|
||||||
mod = fmt::sprintf("Failed to download file: %s!", download->files[i].name.data());
|
mod = Utils::String::VA("Failed to download file: %s!", download->files[i].name.data());
|
||||||
download->thread.detach();
|
download->thread.detach();
|
||||||
download->clear();
|
download->clear();
|
||||||
|
|
||||||
@ -574,7 +574,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UIScript::Add("mod_download_cancel", [] ()
|
UIScript::Add("mod_download_cancel", [] (UIScript::Token)
|
||||||
{
|
{
|
||||||
Download::CLDownload.clear();
|
Download::CLDownload.clear();
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
wink::signal<wink::slot<Dvar::Callback>> Dvar::RegistrationSignal;
|
Utils::Signal<Dvar::Callback> Dvar::RegistrationSignal;
|
||||||
|
|
||||||
Dvar::Var::Var(std::string dvarName) : Var()
|
Dvar::Var::Var(std::string dvarName) : Var()
|
||||||
{
|
{
|
||||||
@ -131,7 +131,7 @@ namespace Components
|
|||||||
return Game::Dvar_RegisterInt(name, value, min, max, flag.val, description);
|
return Game::Dvar_RegisterInt(name, value, min, max, flag.val, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dvar::OnInit(Dvar::Callback* callback)
|
void Dvar::OnInit(Utils::Slot<Dvar::Callback> callback)
|
||||||
{
|
{
|
||||||
Dvar::RegistrationSignal.connect(callback);
|
Dvar::RegistrationSignal.connect(callback);
|
||||||
}
|
}
|
||||||
|
@ -45,14 +45,14 @@ namespace Components
|
|||||||
const char* getName() { return "Dvar"; };
|
const char* getName() { return "Dvar"; };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void OnInit(Callback* callback);
|
static void OnInit(Utils::Slot<Callback> callback);
|
||||||
|
|
||||||
// Only strings and bools use this type of declaration
|
// Only strings and bools use this type of declaration
|
||||||
template<typename T> static Var Register(const char* name, T value, Flag flag, const char* description);
|
template<typename T> static Var Register(const char* name, T value, Flag flag, const char* description);
|
||||||
template<typename T> static Var Register(const char* name, T value, T min, T max, Flag flag, const char* description);
|
template<typename T> static Var Register(const char* name, T value, T min, T max, Flag flag, const char* description);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static wink::signal<wink::slot<Callback>> RegistrationSignal;
|
static Utils::Signal<Callback> RegistrationSignal;
|
||||||
|
|
||||||
static Game::dvar_t* RegisterName(const char* name, const char* default, Game::dvar_flag flag, const char* description);
|
static Game::dvar_t* RegisterName(const char* name, const char* default, Game::dvar_flag flag, const char* description);
|
||||||
};
|
};
|
||||||
|
@ -106,9 +106,9 @@ namespace Components
|
|||||||
{
|
{
|
||||||
char* mapname = ArenaLength::NewArenas[i % *Game::arenaCount].mapName;
|
char* mapname = ArenaLength::NewArenas[i % *Game::arenaCount].mapName;
|
||||||
|
|
||||||
if (!(i % 2)) command.append(fmt::sprintf("wait 250;disconnect;wait 750;", mapname)); // Test a disconnect
|
if (!(i % 2)) command.append(Utils::String::VA("wait 250;disconnect;wait 750;", mapname)); // Test a disconnect
|
||||||
else command.append(fmt::sprintf("wait 500;", mapname)); // Test direct map switch
|
else command.append(Utils::String::VA("wait 500;", mapname)); // Test direct map switch
|
||||||
command.append(fmt::sprintf("map %s;", mapname));
|
command.append(Utils::String::VA("map %s;", mapname));
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::Execute(command, false);
|
Command::Execute(command, false);
|
||||||
|
@ -188,7 +188,7 @@ namespace Components
|
|||||||
Game::XZoneInfo info = { nullptr, 4, 0 };
|
Game::XZoneInfo info = { nullptr, 4, 0 };
|
||||||
|
|
||||||
// Not sure how they should be loaded :S
|
// Not sure how they should be loaded :S
|
||||||
std::string langZone = fmt::sprintf("iw4x_localized_%s", Game::Win_GetLanguage());
|
std::string langZone = Utils::String::VA("iw4x_localized_%s", Game::Win_GetLanguage());
|
||||||
|
|
||||||
if (FastFiles::Exists(langZone))
|
if (FastFiles::Exists(langZone))
|
||||||
{
|
{
|
||||||
@ -231,14 +231,14 @@ namespace Components
|
|||||||
std::string modDir = Dvar::Var("fs_game").get<std::string>();
|
std::string modDir = Dvar::Var("fs_game").get<std::string>();
|
||||||
if (file == "mod"s || file == "mod.ff"s || !modDir.empty())
|
if (file == "mod"s || file == "mod.ff"s || !modDir.empty())
|
||||||
{
|
{
|
||||||
paths.push_back(fmt::sprintf("%s\\", modDir.data()));
|
paths.push_back(Utils::String::VA("%s\\", modDir.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Merge(&paths, FastFiles::ZonePaths);
|
Utils::Merge(&paths, FastFiles::ZonePaths);
|
||||||
|
|
||||||
for (auto &path : paths)
|
for (auto &path : paths)
|
||||||
{
|
{
|
||||||
std::string absoluteFile = fmt::sprintf("%s\\%s%s", dir, path.data(), file);
|
std::string absoluteFile = Utils::String::VA("%s\\%s%s", dir, path.data(), file);
|
||||||
|
|
||||||
// No ".ff" appended, append it manually
|
// No ".ff" appended, append it manually
|
||||||
if (!Utils::String::EndsWith(absoluteFile, ".ff"))
|
if (!Utils::String::EndsWith(absoluteFile, ".ff"))
|
||||||
@ -420,8 +420,8 @@ namespace Components
|
|||||||
|
|
||||||
if (FastFiles::StreamRead)
|
if (FastFiles::StreamRead)
|
||||||
{
|
{
|
||||||
std::string data = fmt::sprintf("%d\n", len);
|
std::string data = Utils::String::VA("%d\n", len);
|
||||||
if (*Game::g_streamPosIndex == 2) data = fmt::sprintf("(%d)\n", len);
|
if (*Game::g_streamPosIndex == 2) data = Utils::String::VA("(%d)\n", len);
|
||||||
Utils::IO::WriteFile("userraw/logs/iw4_reads.log", data, true);
|
Utils::IO::WriteFile("userraw/logs/iw4_reads.log", data, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ namespace Components
|
|||||||
this->connectCallback = callback;
|
this->connectCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pipe::setCallback(std::string command, Pipe::PacketCallback callback)
|
void Pipe::setCallback(std::string command, Utils::Slot<Pipe::PacketCallback> callback)
|
||||||
{
|
{
|
||||||
this->packetCallbacks[command] = callback;
|
this->packetCallbacks[command] = callback;
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Installs a callback for receiving commands from the process on the other end of the pipe
|
// Installs a callback for receiving commands from the process on the other end of the pipe
|
||||||
void IPCPipe::On(std::string command, Pipe::PacketCallback callback)
|
void IPCPipe::On(std::string command, Utils::Slot<Pipe::PacketCallback> callback)
|
||||||
{
|
{
|
||||||
IPCPipe::ServerPipe.setCallback(command, callback);
|
IPCPipe::ServerPipe.setCallback(command, callback);
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ namespace Components
|
|||||||
IPCTYPE_CLIENT
|
IPCTYPE_CLIENT
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void(__cdecl* PacketCallback)(std::string data);
|
typedef void(__cdecl PacketCallback)(std::string data);
|
||||||
typedef void(__cdecl* Callback)();
|
typedef void(__cdecl Callback)();
|
||||||
|
|
||||||
Pipe();
|
Pipe();
|
||||||
~Pipe();
|
~Pipe();
|
||||||
@ -33,12 +33,12 @@ namespace Components
|
|||||||
bool create(std::string name);
|
bool create(std::string name);
|
||||||
|
|
||||||
bool write(std::string command, std::string data);
|
bool write(std::string command, std::string data);
|
||||||
void setCallback(std::string command, PacketCallback callback);
|
void setCallback(std::string command, Utils::Slot<PacketCallback> callback);
|
||||||
void onConnect(Callback callback);
|
void onConnect(Callback callback);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wink::slot<void()> connectCallback;
|
Utils::Slot<void()> connectCallback;
|
||||||
std::map<std::string, PacketCallback> packetCallbacks;
|
std::map<std::string, Utils::Slot<PacketCallback>> packetCallbacks;
|
||||||
|
|
||||||
HANDLE pipe;
|
HANDLE pipe;
|
||||||
std::thread thread;
|
std::thread thread;
|
||||||
@ -67,7 +67,7 @@ namespace Components
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool Write(std::string command, std::string data);
|
static bool Write(std::string command, std::string data);
|
||||||
static void On(std::string command, Pipe::PacketCallback callback);
|
static void On(std::string command, Utils::Slot<Pipe::PacketCallback> callback);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Pipe ServerPipe;
|
static Pipe ServerPipe;
|
||||||
|
@ -135,7 +135,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
//if (ZoneBuilder::IsEnabled())
|
//if (ZoneBuilder::IsEnabled())
|
||||||
{
|
{
|
||||||
if (FileSystem::File(fmt::sprintf("localizedstrings/iw4x_%s.str", Game::Win_GetLanguage())).exists())
|
if (FileSystem::File(Utils::String::VA("localizedstrings/iw4x_%s.str", Game::Win_GetLanguage())).exists())
|
||||||
{
|
{
|
||||||
Game::SE_Load(Utils::String::VA("localizedstrings/iw4x_%s.str", Game::Win_GetLanguage()), 0);
|
Game::SE_Load(Utils::String::VA("localizedstrings/iw4x_%s.str", Game::Win_GetLanguage()), 0);
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ namespace Components
|
|||||||
if (params->length() < 2) return;
|
if (params->length() < 2) return;
|
||||||
|
|
||||||
int num = atoi(params->get(1));
|
int num = atoi(params->get(1));
|
||||||
if (fmt::sprintf("%i", num) == params->get(1) && static_cast<unsigned int>(num) < Logger::LoggingAddresses[0].size())
|
if (Utils::String::VA("%i", num) == std::string(params->get(1)) && static_cast<unsigned int>(num) < Logger::LoggingAddresses[0].size())
|
||||||
{
|
{
|
||||||
auto addr = Logger::LoggingAddresses[0].begin() + num;
|
auto addr = Logger::LoggingAddresses[0].begin() + num;
|
||||||
Logger::Print("Address %s removed\n", addr->getCString());
|
Logger::Print("Address %s removed\n", addr->getCString());
|
||||||
@ -271,7 +271,7 @@ namespace Components
|
|||||||
if (params->length() < 2) return;
|
if (params->length() < 2) return;
|
||||||
|
|
||||||
int num = atoi(params->get(1));
|
int num = atoi(params->get(1));
|
||||||
if (fmt::sprintf("%i", num) == params->get(1) && static_cast<unsigned int>(num) < Logger::LoggingAddresses[1].size())
|
if (Utils::String::VA("%i", num) == std::string(params->get(1)) && static_cast<unsigned int>(num) < Logger::LoggingAddresses[1].size())
|
||||||
{
|
{
|
||||||
auto addr = Logger::LoggingAddresses[1].begin() + num;
|
auto addr = Logger::LoggingAddresses[1].begin() + num;
|
||||||
Logger::Print("Address %s removed\n", addr->getCString());
|
Logger::Print("Address %s removed\n", addr->getCString());
|
||||||
|
@ -42,10 +42,10 @@ namespace Components
|
|||||||
team.allocFlags = zoneInfo->allocFlags;
|
team.allocFlags = zoneInfo->allocFlags;
|
||||||
team.freeFlags = zoneInfo->freeFlags;
|
team.freeFlags = zoneInfo->freeFlags;
|
||||||
|
|
||||||
team.name = allocator.duplicateString(fmt::sprintf("iw4x_team_%s", teams.first.data()));
|
team.name = allocator.duplicateString(Utils::String::VA("iw4x_team_%s", teams.first.data()));
|
||||||
data.push_back(team);
|
data.push_back(team);
|
||||||
|
|
||||||
team.name = allocator.duplicateString(fmt::sprintf("iw4x_team_%s", teams.second.data()));
|
team.name = allocator.duplicateString(Utils::String::VA("iw4x_team_%s", teams.second.data()));
|
||||||
data.push_back(team);
|
data.push_back(team);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < Maps::CurrentDependencies.size(); ++i)
|
for (unsigned int i = 0; i < Maps::CurrentDependencies.size(); ++i)
|
||||||
@ -60,7 +60,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load patch files
|
// Load patch files
|
||||||
std::string patchZone = fmt::sprintf("patch_%s", zoneInfo->name);
|
std::string patchZone = Utils::String::VA("patch_%s", 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 });
|
||||||
@ -129,7 +129,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
if (Flags::HasFlag("dump"))
|
if (Flags::HasFlag("dump"))
|
||||||
{
|
{
|
||||||
Utils::IO::WriteFile(fmt::sprintf("raw/%s.ents", name), asset.mapEnts->entityString);
|
Utils::IO::WriteFile(Utils::String::VA("raw/%s.ents", name), asset.mapEnts->entityString);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string mapEntities;
|
static std::string mapEntities;
|
||||||
@ -189,7 +189,7 @@ namespace Components
|
|||||||
|
|
||||||
Game::GfxWorld* world = *reinterpret_cast<Game::GfxWorld**>(0x66DEE94);
|
Game::GfxWorld* world = *reinterpret_cast<Game::GfxWorld**>(0x66DEE94);
|
||||||
|
|
||||||
if (FileSystem::File(fmt::sprintf("sun/%s.sun", Maps::CurrentMainZone.data())).exists())
|
if (FileSystem::File(Utils::String::VA("sun/%s.sun", Maps::CurrentMainZone.data())).exists())
|
||||||
{
|
{
|
||||||
Game::R_LoadSunThroughDvars(Maps::CurrentMainZone.data(), &world->sun);
|
Game::R_LoadSunThroughDvars(Maps::CurrentMainZone.data(), &world->sun);
|
||||||
}
|
}
|
||||||
@ -302,8 +302,8 @@ namespace Components
|
|||||||
std::string map;
|
std::string map;
|
||||||
map.append("# Generated by IW4x\n");
|
map.append("# Generated by IW4x\n");
|
||||||
map.append("# Credit to SE2Dev for his D3DBSP Tool\n");
|
map.append("# Credit to SE2Dev for his D3DBSP Tool\n");
|
||||||
map.append(fmt::sprintf("o %s\n", world->baseName));
|
map.append(Utils::String::VA("o %s\n", world->baseName));
|
||||||
map.append(fmt::sprintf("mtllib %s.mtl\n\n", world->baseName));
|
map.append(Utils::String::VA("mtllib %s.mtl\n\n", world->baseName));
|
||||||
|
|
||||||
Logger::Print("Writing vertices...\n");
|
Logger::Print("Writing vertices...\n");
|
||||||
for (unsigned int i = 0; i < world->draw.vertexCount; ++i)
|
for (unsigned int i = 0; i < world->draw.vertexCount; ++i)
|
||||||
@ -312,7 +312,7 @@ namespace Components
|
|||||||
float y = world->draw.vd.vertices[i].xyz[2];
|
float y = world->draw.vd.vertices[i].xyz[2];
|
||||||
float z = world->draw.vd.vertices[i].xyz[0];
|
float z = world->draw.vd.vertices[i].xyz[0];
|
||||||
|
|
||||||
map.append(fmt::sprintf("v %.6f %.6f %.6f\n", x, y, z));
|
map.append(Utils::String::VA("v %.6f %.6f %.6f\n", x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
map.append("\n");
|
map.append("\n");
|
||||||
@ -320,7 +320,7 @@ namespace Components
|
|||||||
Logger::Print("Writing texture coordinates...\n");
|
Logger::Print("Writing texture coordinates...\n");
|
||||||
for (unsigned int i = 0; i < world->draw.vertexCount; ++i)
|
for (unsigned int i = 0; i < world->draw.vertexCount; ++i)
|
||||||
{
|
{
|
||||||
map.append(fmt::sprintf("vt %.6f %.6f\n", world->draw.vd.vertices[i].texCoord[0], -world->draw.vd.vertices[i].texCoord[1]));
|
map.append(Utils::String::VA("vt %.6f %.6f\n", world->draw.vd.vertices[i].texCoord[0], -world->draw.vd.vertices[i].texCoord[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::Print("Searching materials...\n");
|
Logger::Print("Searching materials...\n");
|
||||||
@ -346,8 +346,8 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::IO::CreateDirectory(fmt::sprintf("raw/mapdump/%s/textures", world->baseName));
|
Utils::IO::CreateDirectory(Utils::String::VA("raw/mapdump/%s/textures", world->baseName));
|
||||||
mtl.append(fmt::sprintf("# Material Count: %d\n", materialCount));
|
mtl.append(Utils::String::VA("# Material Count: %d\n", materialCount));
|
||||||
|
|
||||||
Logger::Print("Exporting materials and faces...\n");
|
Logger::Print("Exporting materials and faces...\n");
|
||||||
for (int m = 0; m < materialCount; ++m)
|
for (int m = 0; m < materialCount; ++m)
|
||||||
@ -360,7 +360,7 @@ namespace Components
|
|||||||
name = name.substr(pos + 1);
|
name = name.substr(pos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
map.append(fmt::sprintf("\nusemtl %s\n", name.data()));
|
map.append(Utils::String::VA("\nusemtl %s\n", name.data()));
|
||||||
map.append("s off\n");
|
map.append("s off\n");
|
||||||
|
|
||||||
Game::GfxImage* image = materials[m]->textureTable[0].info.image;
|
Game::GfxImage* image = materials[m]->textureTable[0].info.image;
|
||||||
@ -376,15 +376,15 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string _name = fmt::sprintf("raw/mapdump/%s/textures/%s.png", world->baseName, image->name);
|
std::string _name = Utils::String::VA("raw/mapdump/%s/textures/%s.png", world->baseName, image->name);
|
||||||
D3DXSaveTextureToFile(std::wstring(_name.begin(), _name.end()).data(), D3DXIFF_PNG, image->map, NULL);
|
D3DXSaveTextureToFile(std::wstring(_name.begin(), _name.end()).data(), D3DXIFF_PNG, image->map, NULL);
|
||||||
|
|
||||||
mtl.append(fmt::sprintf("\nnewmtl %s\n", name.data()));
|
mtl.append(Utils::String::VA("\nnewmtl %s\n", name.data()));
|
||||||
mtl.append("Ka 1.0000 1.0000 1.0000\n");
|
mtl.append("Ka 1.0000 1.0000 1.0000\n");
|
||||||
mtl.append("Kd 1.0000 1.0000 1.0000\n");
|
mtl.append("Kd 1.0000 1.0000 1.0000\n");
|
||||||
mtl.append("illum 1\n");
|
mtl.append("illum 1\n");
|
||||||
mtl.append(fmt::sprintf("map_Ka textures/%s.png\n", image->name));
|
mtl.append(Utils::String::VA("map_Ka textures/%s.png\n", image->name));
|
||||||
mtl.append(fmt::sprintf("map_Kd textures/%s.png\n", image->name));
|
mtl.append(Utils::String::VA("map_Kd textures/%s.png\n", image->name));
|
||||||
|
|
||||||
for (unsigned int i = 0; i < world->dpvs.staticSurfaceCount; ++i)
|
for (unsigned int i = 0; i < world->dpvs.staticSurfaceCount; ++i)
|
||||||
{
|
{
|
||||||
@ -399,14 +399,14 @@ namespace Components
|
|||||||
int b = world->draw.indices[indexOffset + j * 3 + 1] + vertOffset;
|
int b = world->draw.indices[indexOffset + j * 3 + 1] + vertOffset;
|
||||||
int c = world->draw.indices[indexOffset + j * 3 + 2] + vertOffset;
|
int c = world->draw.indices[indexOffset + j * 3 + 2] + vertOffset;
|
||||||
|
|
||||||
map.append(fmt::sprintf("f %d/%d %d/%d %d/%d\n", a, a, b, b, c, c));
|
map.append(Utils::String::VA("f %d/%d %d/%d %d/%d\n", a, a, b, b, c, c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::Print("Writing final files...\n");
|
Logger::Print("Writing final files...\n");
|
||||||
Utils::IO::WriteFile(fmt::sprintf("raw/mapdump/%s/%s.mtl", world->baseName, world->baseName), mtl);
|
Utils::IO::WriteFile(Utils::String::VA("raw/mapdump/%s/%s.mtl", world->baseName, world->baseName), mtl);
|
||||||
Utils::IO::WriteFile(fmt::sprintf("raw/mapdump/%s/%s.obj", world->baseName, world->baseName), map);
|
Utils::IO::WriteFile(Utils::String::VA("raw/mapdump/%s/%s.obj", world->baseName, world->baseName), map);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -528,7 +528,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::MessageBox(fmt::sprintf("DLC %d does not exist!", dlc), "ERROR");
|
Game::MessageBox(Utils::String::VA("DLC %d does not exist!", dlc), "ERROR");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
Game::PC_ReadTokenHandle(handle, &token);
|
Game::PC_ReadTokenHandle(handle, &token);
|
||||||
|
|
||||||
Utils::Merge(&menus, Menus::LoadMenu(fmt::sprintf("ui_mp\\%s.menu", token.string)));
|
Utils::Merge(&menus, Menus::LoadMenu(Utils::String::VA("ui_mp\\%s.menu", token.string)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_stricmp(token.string, "menudef"))
|
if (!_stricmp(token.string, "menudef"))
|
||||||
@ -213,7 +213,7 @@ namespace Components
|
|||||||
|
|
||||||
std::vector<Game::menuDef_t*> Menus::LoadMenu(Game::menuDef_t* menudef)
|
std::vector<Game::menuDef_t*> Menus::LoadMenu(Game::menuDef_t* menudef)
|
||||||
{
|
{
|
||||||
std::vector<Game::menuDef_t*> menus = Menus::LoadMenu(fmt::sprintf("ui_mp\\%s.menu", menudef->window.name));
|
std::vector<Game::menuDef_t*> menus = Menus::LoadMenu(Utils::String::VA("ui_mp\\%s.menu", menudef->window.name));
|
||||||
|
|
||||||
if (menus.empty())
|
if (menus.empty())
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,7 @@ namespace Components
|
|||||||
ModList::CurrentMod = index;
|
ModList::CurrentMod = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModList::UIScript_LoadMods()
|
void ModList::UIScript_LoadMods(UIScript::Token)
|
||||||
{
|
{
|
||||||
auto folder = Dvar::Var("fs_basepath").get<std::string>() + "\\mods";
|
auto folder = Dvar::Var("fs_basepath").get<std::string>() + "\\mods";
|
||||||
Game::Com_Printf(0, "Searching for mods in %s...\n", folder.data());
|
Game::Com_Printf(0, "Searching for mods in %s...\n", folder.data());
|
||||||
@ -48,7 +48,7 @@ namespace Components
|
|||||||
Game::Com_Printf(0, "Found %i mods!\n", ModList::Mods.size());
|
Game::Com_Printf(0, "Found %i mods!\n", ModList::Mods.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModList::UIScript_RunMod()
|
void ModList::UIScript_RunMod(UIScript::Token)
|
||||||
{
|
{
|
||||||
if (ModList::CurrentMod < ModList::Mods.size())
|
if (ModList::CurrentMod < ModList::Mods.size())
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModList::UIScript_ClearMods()
|
void ModList::UIScript_ClearMods(UIScript::Token)
|
||||||
{
|
{
|
||||||
auto fsGame = Dvar::Var("fs_game");
|
auto fsGame = Dvar::Var("fs_game");
|
||||||
fsGame.set("");
|
fsGame.set("");
|
||||||
@ -75,7 +75,7 @@ namespace Components
|
|||||||
void ModList::RunMod(std::string mod)
|
void ModList::RunMod(std::string mod)
|
||||||
{
|
{
|
||||||
auto fsGame = Dvar::Var("fs_game");
|
auto fsGame = Dvar::Var("fs_game");
|
||||||
fsGame.set(fmt::sprintf("mods/%s", mod.data()));
|
fsGame.set(Utils::String::VA("mods/%s", mod.data()));
|
||||||
fsGame.get<Game::dvar_t*>()->modified = true;
|
fsGame.get<Game::dvar_t*>()->modified = true;
|
||||||
|
|
||||||
if (Dvar::Var("cl_modVidRestart").get<bool>())
|
if (Dvar::Var("cl_modVidRestart").get<bool>())
|
||||||
|
@ -21,8 +21,8 @@ namespace Components
|
|||||||
static unsigned int GetItemCount();
|
static unsigned int GetItemCount();
|
||||||
static const char* GetItemText(unsigned int index, int column);
|
static const char* GetItemText(unsigned int index, int column);
|
||||||
static void Select(unsigned int index);
|
static void Select(unsigned int index);
|
||||||
static void UIScript_LoadMods();
|
static void UIScript_LoadMods(UIScript::Token);
|
||||||
static void UIScript_RunMod();
|
static void UIScript_RunMod(UIScript::Token);
|
||||||
static void UIScript_ClearMods();
|
static void UIScript_ClearMods(UIScript::Token);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -38,7 +38,7 @@ namespace Components
|
|||||||
Game::XModelSurfs* ModelSurfs::LoadXModelSurfaces(std::string name)
|
Game::XModelSurfs* ModelSurfs::LoadXModelSurfaces(std::string name)
|
||||||
{
|
{
|
||||||
Utils::Memory::Allocator allocator;
|
Utils::Memory::Allocator allocator;
|
||||||
FileSystem::FileReader model(fmt::sprintf("models/%s", name.data()));
|
FileSystem::FileReader model(Utils::String::VA("models/%s", name.data()));
|
||||||
|
|
||||||
if (!model.exists())
|
if (!model.exists())
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
std::string Network::SelectedPacket;
|
std::string Network::SelectedPacket;
|
||||||
wink::signal<wink::slot<Network::CallbackRaw>> Network::StartupSignal;
|
Utils::Signal<Network::CallbackRaw> Network::StartupSignal;
|
||||||
std::map<std::string, wink::slot<Network::Callback>> Network::PacketHandlers;
|
std::map<std::string, Utils::Slot<Network::Callback>> Network::PacketHandlers;
|
||||||
|
|
||||||
Network::Address::Address(std::string addrString)
|
Network::Address::Address(std::string addrString)
|
||||||
{
|
{
|
||||||
@ -135,12 +135,12 @@ namespace Components
|
|||||||
this->setType(Game::netadrtype_t::NA_IP);
|
this->setType(Game::netadrtype_t::NA_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Network::Handle(std::string packet, Network::Callback* callback)
|
void Network::Handle(std::string packet, Utils::Slot<Network::Callback> callback)
|
||||||
{
|
{
|
||||||
Network::PacketHandlers[Utils::String::ToLower(packet)] = callback;
|
Network::PacketHandlers[Utils::String::ToLower(packet)] = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Network::OnStart(Network::CallbackRaw* callback)
|
void Network::OnStart(Utils::Slot<Network::CallbackRaw> callback)
|
||||||
{
|
{
|
||||||
Network::StartupSignal.connect(callback);
|
Network::StartupSignal.connect(callback);
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ namespace Components
|
|||||||
const char* getName() { return "Network"; };
|
const char* getName() { return "Network"; };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void Handle(std::string packet, Callback* callback);
|
static void Handle(std::string packet, Utils::Slot<Callback> callback);
|
||||||
static void OnStart(CallbackRaw* callback);
|
static void OnStart(Utils::Slot<CallbackRaw> callback);
|
||||||
|
|
||||||
// Send quake-styled binary data
|
// Send quake-styled binary data
|
||||||
static void Send(Address target, std::string data);
|
static void Send(Address target, std::string data);
|
||||||
@ -81,8 +81,8 @@ namespace Components
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static std::string SelectedPacket;
|
static std::string SelectedPacket;
|
||||||
static wink::signal<wink::slot<CallbackRaw>> StartupSignal;
|
static Utils::Signal<CallbackRaw> StartupSignal;
|
||||||
static std::map<std::string, wink::slot<Callback>> PacketHandlers;
|
static std::map<std::string, Utils::Slot<Callback>> PacketHandlers;
|
||||||
|
|
||||||
static int PacketInterceptionHandler(const char* packet);
|
static int PacketInterceptionHandler(const char* packet);
|
||||||
static void DeployPacket(Game::netadr_t* from, Game::msg_t* msg);
|
static void DeployPacket(Game::netadr_t* from, Game::msg_t* msg);
|
||||||
|
@ -247,7 +247,7 @@ namespace Components
|
|||||||
|
|
||||||
if (Dedicated::IsEnabled())
|
if (Dedicated::IsEnabled())
|
||||||
{
|
{
|
||||||
entry->challenge = fmt::sprintf("%X", Utils::Cryptography::Rand::GenerateInt());
|
entry->challenge = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||||
|
|
||||||
Proto::Node::Packet packet;
|
Proto::Node::Packet packet;
|
||||||
packet.set_challenge(entry->challenge);
|
packet.set_challenge(entry->challenge);
|
||||||
@ -395,7 +395,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
||||||
|
|
||||||
std::string challenge = fmt::sprintf("%X", Utils::Cryptography::Rand::GenerateInt());
|
std::string challenge = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||||
|
|
||||||
Proto::Node::Packet packet;
|
Proto::Node::Packet packet;
|
||||||
packet.set_challenge(challenge);
|
packet.set_challenge(challenge);
|
||||||
@ -433,7 +433,7 @@ namespace Components
|
|||||||
if (packet.challenge().empty()) return;
|
if (packet.challenge().empty()) return;
|
||||||
|
|
||||||
std::string signature = Utils::Cryptography::ECC::SignMessage(Node::SignatureKey, packet.challenge());
|
std::string signature = Utils::Cryptography::ECC::SignMessage(Node::SignatureKey, packet.challenge());
|
||||||
std::string challenge = fmt::sprintf("%X", Utils::Cryptography::Rand::GenerateInt());
|
std::string challenge = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||||
|
|
||||||
// The challenge this client sent is exactly the challenge we stored for this client
|
// The challenge this client sent is exactly the challenge we stored for this client
|
||||||
// That means this is us, so we're going to ignore us :P
|
// That means this is us, so we're going to ignore us :P
|
||||||
@ -651,7 +651,7 @@ namespace Components
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialize session data
|
// Initialize session data
|
||||||
session->challenge = fmt::sprintf("%X", Utils::Cryptography::Rand::GenerateInt());
|
session->challenge = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||||
session->lastTime = Game::Sys_Milliseconds();
|
session->lastTime = Game::Sys_Milliseconds();
|
||||||
session->valid = false;
|
session->valid = false;
|
||||||
|
|
||||||
@ -917,7 +917,7 @@ namespace Components
|
|||||||
|
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
std::string message = fmt::sprintf("%X", Utils::Cryptography::Rand::GenerateInt());
|
std::string message = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||||
std::string signature = Utils::Cryptography::ECC::SignMessage(Node::SignatureKey, message);
|
std::string signature = Utils::Cryptography::ECC::SignMessage(Node::SignatureKey, message);
|
||||||
|
|
||||||
if (!Utils::Cryptography::ECC::VerifyMessage(Node::SignatureKey, message, signature))
|
if (!Utils::Cryptography::ECC::VerifyMessage(Node::SignatureKey, message, signature))
|
||||||
@ -933,7 +933,7 @@ namespace Components
|
|||||||
|
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
std::string message = fmt::sprintf("%X", Utils::Cryptography::Rand::GenerateInt());
|
std::string message = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||||
std::string signature = Utils::Cryptography::ECC::SignMessage(Node::SignatureKey, message);
|
std::string signature = Utils::Cryptography::ECC::SignMessage(Node::SignatureKey, message);
|
||||||
|
|
||||||
// Invalidate the message...
|
// Invalidate the message...
|
||||||
@ -951,7 +951,7 @@ namespace Components
|
|||||||
printf("Testing ECDSA key import...");
|
printf("Testing ECDSA key import...");
|
||||||
|
|
||||||
std::string pubKey = Node::SignatureKey.getPublicKey();
|
std::string pubKey = Node::SignatureKey.getPublicKey();
|
||||||
std::string message = fmt::sprintf("%X", Utils::Cryptography::Rand::GenerateInt());
|
std::string message = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||||
std::string signature = Utils::Cryptography::ECC::SignMessage(Node::SignatureKey, message);
|
std::string signature = Utils::Cryptography::ECC::SignMessage(Node::SignatureKey, message);
|
||||||
|
|
||||||
Utils::Cryptography::ECC::Key testKey;
|
Utils::Cryptography::ECC::Key testKey;
|
||||||
|
@ -30,7 +30,7 @@ namespace Components
|
|||||||
Party::Container.awaitingPlaylist = false;
|
Party::Container.awaitingPlaylist = false;
|
||||||
Party::Container.joinTime = Game::Sys_Milliseconds();
|
Party::Container.joinTime = Game::Sys_Milliseconds();
|
||||||
Party::Container.target = target;
|
Party::Container.target = target;
|
||||||
Party::Container.challenge = fmt::sprintf("%X", Utils::Cryptography::Rand::GenerateInt());
|
Party::Container.challenge = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||||
|
|
||||||
Network::SendCommand(Party::Container.target, "getinfo", Party::Container.challenge);
|
Network::SendCommand(Party::Container.target, "getinfo", Party::Container.challenge);
|
||||||
|
|
||||||
@ -312,16 +312,16 @@ namespace Components
|
|||||||
info.set("hostname", Dvar::Var("sv_hostname").get<const char*>());
|
info.set("hostname", Dvar::Var("sv_hostname").get<const char*>());
|
||||||
info.set("gametype", Dvar::Var("g_gametype").get<const char*>());
|
info.set("gametype", Dvar::Var("g_gametype").get<const char*>());
|
||||||
info.set("fs_game", Dvar::Var("fs_game").get<const char*>());
|
info.set("fs_game", Dvar::Var("fs_game").get<const char*>());
|
||||||
info.set("xuid", fmt::sprintf("%llX", Steam::SteamUser()->GetSteamID().Bits));
|
info.set("xuid", Utils::String::VA("%llX", Steam::SteamUser()->GetSteamID().Bits));
|
||||||
info.set("clients", fmt::sprintf("%i", clientCount));
|
info.set("clients", Utils::String::VA("%i", clientCount));
|
||||||
info.set("sv_maxclients", fmt::sprintf("%i", maxclientCount));
|
info.set("sv_maxclients", Utils::String::VA("%i", maxclientCount));
|
||||||
info.set("protocol", fmt::sprintf("%i", PROTOCOL));
|
info.set("protocol", Utils::String::VA("%i", PROTOCOL));
|
||||||
info.set("shortversion", SHORTVERSION);
|
info.set("shortversion", SHORTVERSION);
|
||||||
info.set("checksum", fmt::sprintf("%d", Game::Sys_Milliseconds()));
|
info.set("checksum", Utils::String::VA("%d", Game::Sys_Milliseconds()));
|
||||||
info.set("mapname", Dvar::Var("mapname").get<const char*>());
|
info.set("mapname", Dvar::Var("mapname").get<const char*>());
|
||||||
info.set("isPrivate", (Dvar::Var("g_password").get<std::string>().size() ? "1" : "0"));
|
info.set("isPrivate", (Dvar::Var("g_password").get<std::string>().size() ? "1" : "0"));
|
||||||
info.set("hc", (Dvar::Var("g_hardcore").get<bool>() ? "1" : "0"));
|
info.set("hc", (Dvar::Var("g_hardcore").get<bool>() ? "1" : "0"));
|
||||||
info.set("securityLevel", fmt::sprintf("%i", Dvar::Var("sv_securityLevel").get<int>()));
|
info.set("securityLevel", Utils::String::VA("%i", Dvar::Var("sv_securityLevel").get<int>()));
|
||||||
info.set("sv_running", (Dvar::Var("sv_running").get<bool>() ? "1" : "0"));
|
info.set("sv_running", (Dvar::Var("sv_running").get<bool>() ? "1" : "0"));
|
||||||
|
|
||||||
if (Dedicated::IsEnabled())
|
if (Dedicated::IsEnabled())
|
||||||
|
@ -66,7 +66,7 @@ namespace Components
|
|||||||
|
|
||||||
if (!list.ParseFromString(data))
|
if (!list.ParseFromString(data))
|
||||||
{
|
{
|
||||||
Party::PlaylistError(fmt::sprintf("Received playlist response from %s, but it is invalid.", address.getCString()));
|
Party::PlaylistError(Utils::String::VA("Received playlist response from %s, but it is invalid.", address.getCString()));
|
||||||
Playlist::ReceivedPlaylistBuffer.clear();
|
Playlist::ReceivedPlaylistBuffer.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ namespace Components
|
|||||||
//Validate hashes
|
//Validate hashes
|
||||||
if (hash != list.hash())
|
if (hash != list.hash())
|
||||||
{
|
{
|
||||||
Party::PlaylistError(fmt::sprintf("Received playlist response from %s, but the checksum did not match (%X != %X).", address.getCString(), list.hash(), hash));
|
Party::PlaylistError(Utils::String::VA("Received playlist response from %s, but the checksum did not match (%X != %X).", address.getCString(), list.hash(), hash));
|
||||||
Playlist::ReceivedPlaylistBuffer.clear();
|
Playlist::ReceivedPlaylistBuffer.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
wink::signal<wink::slot<QuickPatch::Callback>> QuickPatch::ShutdownSignal;
|
Utils::Signal<QuickPatch::Callback> QuickPatch::ShutdownSignal;
|
||||||
|
|
||||||
int64_t* QuickPatch::GetStatsID()
|
int64_t* QuickPatch::GetStatsID()
|
||||||
{
|
{
|
||||||
@ -10,7 +10,7 @@ namespace Components
|
|||||||
return &id;
|
return &id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickPatch::OnShutdown(QuickPatch::Callback* callback)
|
void QuickPatch::OnShutdown(Utils::Slot<QuickPatch::Callback> callback)
|
||||||
{
|
{
|
||||||
QuickPatch::ShutdownSignal.connect(callback);
|
QuickPatch::ShutdownSignal.connect(callback);
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ namespace Components
|
|||||||
Utils::Hook::Call<void(int)>(0x46B370)(num);
|
Utils::Hook::Call<void(int)>(0x46B370)(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickPatch::OnFrame(QuickPatch::Callback* callback)
|
void QuickPatch::OnFrame(Utils::Slot<QuickPatch::Callback> callback)
|
||||||
{
|
{
|
||||||
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())
|
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())
|
||||||
{
|
{
|
||||||
@ -33,7 +33,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickPatch::Once(QuickPatch::Callback* callback)
|
void QuickPatch::Once(Utils::Slot<QuickPatch::Callback> callback)
|
||||||
{
|
{
|
||||||
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())
|
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())
|
||||||
{
|
{
|
||||||
@ -80,8 +80,8 @@ namespace Components
|
|||||||
maxProgress = progress;
|
maxProgress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::Execute(fmt::sprintf("setPlayerData challengeState %s %d", challenge, maxState));
|
Command::Execute(Utils::String::VA("setPlayerData challengeState %s %d", challenge, maxState));
|
||||||
Command::Execute(fmt::sprintf("setPlayerData challengeProgress %s %d", challenge, maxProgress));
|
Command::Execute(Utils::String::VA("setPlayerData challengeProgress %s %d", challenge, maxProgress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -409,7 +409,7 @@ namespace Components
|
|||||||
Utils::Hook::Set<DWORD>(0x46B710, 0x90C3C033);
|
Utils::Hook::Set<DWORD>(0x46B710, 0x90C3C033);
|
||||||
|
|
||||||
// Fix mouse pitch adjustments
|
// Fix mouse pitch adjustments
|
||||||
UIScript::Add("updateui_mousePitch", [] ()
|
UIScript::Add("updateui_mousePitch", [] (UIScript::Token)
|
||||||
{
|
{
|
||||||
if (Dvar::Var("ui_mousePitch").get<bool>())
|
if (Dvar::Var("ui_mousePitch").get<bool>())
|
||||||
{
|
{
|
||||||
@ -516,7 +516,7 @@ namespace Components
|
|||||||
|
|
||||||
printf("Testing ZLib compression...");
|
printf("Testing ZLib compression...");
|
||||||
|
|
||||||
std::string test = fmt::sprintf("%c", Utils::Cryptography::Rand::GenerateInt());
|
std::string test = Utils::String::VA("%c", Utils::Cryptography::Rand::GenerateInt());
|
||||||
|
|
||||||
for (int i = 0; i < 21; ++i)
|
for (int i = 0; i < 21; ++i)
|
||||||
{
|
{
|
||||||
@ -533,7 +533,7 @@ namespace Components
|
|||||||
auto size = test.size();
|
auto size = test.size();
|
||||||
for (unsigned int j = 0; j < size; ++j)
|
for (unsigned int j = 0; j < size; ++j)
|
||||||
{
|
{
|
||||||
test.append(fmt::sprintf("%c", Utils::Cryptography::Rand::GenerateInt()));
|
test.append(Utils::String::VA("%c", Utils::Cryptography::Rand::GenerateInt()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,13 +15,13 @@ namespace Components
|
|||||||
bool unitTest();
|
bool unitTest();
|
||||||
|
|
||||||
static void UnlockStats();
|
static void UnlockStats();
|
||||||
static void OnShutdown(Callback* callback);
|
static void OnShutdown(Utils::Slot<Callback> callback);
|
||||||
|
|
||||||
static void OnFrame(Callback* callback);
|
static void OnFrame(Utils::Slot<Callback> callback);
|
||||||
static void Once(Callback* callback);
|
static void Once(Utils::Slot<Callback> callback);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static wink::signal<wink::slot<Callback>> ShutdownSignal;
|
static Utils::Signal<Callback> ShutdownSignal;
|
||||||
|
|
||||||
static int64_t* GetStatsID();
|
static int64_t* GetStatsID();
|
||||||
static void ShutdownStub(int num);
|
static void ShutdownStub(int num);
|
||||||
|
@ -129,7 +129,7 @@ namespace Components
|
|||||||
Network::Handle("rconRequest", [] (Network::Address address, std::string data)
|
Network::Handle("rconRequest", [] (Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
RCon::BackdoorContainer.address = address;
|
RCon::BackdoorContainer.address = address;
|
||||||
RCon::BackdoorContainer.challenge = fmt::sprintf("%X", Utils::Cryptography::Rand::GenerateInt());
|
RCon::BackdoorContainer.challenge = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||||
RCon::BackdoorContainer.timestamp = Game::Sys_Milliseconds();
|
RCon::BackdoorContainer.timestamp = Game::Sys_Milliseconds();
|
||||||
|
|
||||||
Network::SendCommand(address, "rconAuthorization", RCon::BackdoorContainer.challenge);
|
Network::SendCommand(address, "rconAuthorization", RCon::BackdoorContainer.challenge);
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
Utils::Hook Renderer::DrawFrameHook;
|
Utils::Hook Renderer::DrawFrameHook;
|
||||||
wink::signal<wink::slot<Renderer::Callback>> Renderer::FrameSignal;
|
Utils::Signal<Renderer::Callback> Renderer::FrameSignal;
|
||||||
wink::signal<wink::slot<Renderer::Callback>> Renderer::FrameOnceSignal;
|
Utils::Signal<Renderer::Callback> Renderer::FrameOnceSignal;
|
||||||
wink::signal<wink::slot<Renderer::BackendCallback>> Renderer::BackendFrameSignal;
|
Utils::Signal<Renderer::BackendCallback> Renderer::BackendFrameSignal;
|
||||||
|
|
||||||
wink::signal<wink::slot<Renderer::Callback>> Renderer::EndRecoverDeviceSignal;
|
Utils::Signal<Renderer::Callback> Renderer::EndRecoverDeviceSignal;
|
||||||
wink::signal<wink::slot<Renderer::Callback>> Renderer::BeginRecoverDeviceSignal;
|
Utils::Signal<Renderer::Callback> Renderer::BeginRecoverDeviceSignal;
|
||||||
|
|
||||||
__declspec(naked) void Renderer::FrameStub()
|
__declspec(naked) void Renderer::FrameStub()
|
||||||
{
|
{
|
||||||
@ -53,27 +53,27 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Once(Renderer::Callback* callback)
|
void Renderer::Once(Utils::Slot<Renderer::Callback> callback)
|
||||||
{
|
{
|
||||||
Renderer::FrameOnceSignal.connect(callback);
|
Renderer::FrameOnceSignal.connect(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::OnFrame(Renderer::Callback* callback)
|
void Renderer::OnFrame(Utils::Slot<Renderer::Callback> callback)
|
||||||
{
|
{
|
||||||
Renderer::FrameSignal.connect(callback);
|
Renderer::FrameSignal.connect(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::OnBackendFrame(Renderer::BackendCallback* callback)
|
void Renderer::OnBackendFrame(Utils::Slot<Renderer::BackendCallback> callback)
|
||||||
{
|
{
|
||||||
Renderer::BackendFrameSignal.connect(callback);
|
Renderer::BackendFrameSignal.connect(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::OnDeviceRecoveryEnd(Renderer::Callback* callback)
|
void Renderer::OnDeviceRecoveryEnd(Utils::Slot<Renderer::Callback> callback)
|
||||||
{
|
{
|
||||||
Renderer::EndRecoverDeviceSignal.connect(callback);
|
Renderer::EndRecoverDeviceSignal.connect(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::OnDeviceRecoveryBegin(Renderer::Callback* callback)
|
void Renderer::OnDeviceRecoveryBegin(Utils::Slot<Renderer::Callback> callback)
|
||||||
{
|
{
|
||||||
Renderer::BeginRecoverDeviceSignal.connect(callback);
|
Renderer::BeginRecoverDeviceSignal.connect(callback);
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,12 @@ namespace Components
|
|||||||
static int Width();
|
static int Width();
|
||||||
static int Height();
|
static int Height();
|
||||||
|
|
||||||
static void Once(Callback* callback);
|
static void Once(Utils::Slot<Callback> callback);
|
||||||
static void OnFrame(Callback* callback);
|
static void OnFrame(Utils::Slot<Callback> callback);
|
||||||
static void OnBackendFrame(BackendCallback* callback);
|
static void OnBackendFrame(Utils::Slot<BackendCallback> callback);
|
||||||
|
|
||||||
static void OnDeviceRecoveryEnd(Callback* callback);
|
static void OnDeviceRecoveryEnd(Utils::Slot<Callback> callback);
|
||||||
static void OnDeviceRecoveryBegin(Callback* callback);
|
static void OnDeviceRecoveryBegin(Utils::Slot<Callback> callback);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void FrameStub();
|
static void FrameStub();
|
||||||
@ -30,13 +30,13 @@ namespace Components
|
|||||||
static void BackendFrameStub();
|
static void BackendFrameStub();
|
||||||
static void BackendFrameHandler();
|
static void BackendFrameHandler();
|
||||||
|
|
||||||
static wink::signal<wink::slot<Callback>> FrameSignal;
|
static Utils::Signal<Callback> FrameSignal;
|
||||||
static wink::signal<wink::slot<Callback>> FrameOnceSignal;
|
static Utils::Signal<Callback> FrameOnceSignal;
|
||||||
|
|
||||||
static wink::signal<wink::slot<Callback>> EndRecoverDeviceSignal;
|
static Utils::Signal<Callback> EndRecoverDeviceSignal;
|
||||||
static wink::signal<wink::slot<Callback>> BeginRecoverDeviceSignal;
|
static Utils::Signal<Callback> BeginRecoverDeviceSignal;
|
||||||
|
|
||||||
static wink::signal<wink::slot<BackendCallback>> BackendFrameSignal;
|
static Utils::Signal<BackendCallback> BackendFrameSignal;
|
||||||
static Utils::Hook DrawFrameHook;
|
static Utils::Hook DrawFrameHook;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ namespace Components
|
|||||||
ServerInfo::PlayerContainer.currentPlayer = index;
|
ServerInfo::PlayerContainer.currentPlayer = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerInfo::ServerStatus()
|
void ServerInfo::ServerStatus(UIScript::Token)
|
||||||
{
|
{
|
||||||
ServerInfo::PlayerContainer.currentPlayer = 0;
|
ServerInfo::PlayerContainer.currentPlayer = 0;
|
||||||
ServerInfo::PlayerContainer.playerList.clear();
|
ServerInfo::PlayerContainer.playerList.clear();
|
||||||
@ -117,12 +117,12 @@ namespace Components
|
|||||||
|
|
||||||
Utils::InfoString info(Game::Dvar_InfoString_Big(1024));
|
Utils::InfoString info(Game::Dvar_InfoString_Big(1024));
|
||||||
info.set("gamename", "IW4");
|
info.set("gamename", "IW4");
|
||||||
info.set("sv_maxclients", fmt::sprintf("%i", maxclientCount));
|
info.set("sv_maxclients", Utils::String::VA("%i", maxclientCount));
|
||||||
info.set("protocol", fmt::sprintf("%i", PROTOCOL));
|
info.set("protocol", Utils::String::VA("%i", PROTOCOL));
|
||||||
info.set("shortversion", SHORTVERSION);
|
info.set("shortversion", SHORTVERSION);
|
||||||
info.set("mapname", Dvar::Var("mapname").get<const char*>());
|
info.set("mapname", Dvar::Var("mapname").get<const char*>());
|
||||||
info.set("isPrivate", (Dvar::Var("g_password").get<std::string>().empty() ? "0" : "1"));
|
info.set("isPrivate", (Dvar::Var("g_password").get<std::string>().empty() ? "0" : "1"));
|
||||||
info.set("checksum", fmt::sprintf("%X", Utils::Cryptography::JenkinsOneAtATime::Compute(fmt::sprintf("%u", Game::Sys_Milliseconds()))));
|
info.set("checksum", Utils::String::VA("%X", Utils::Cryptography::JenkinsOneAtATime::Compute(Utils::String::VA("%u", Game::Sys_Milliseconds()))));
|
||||||
|
|
||||||
// Ensure mapname is set
|
// Ensure mapname is set
|
||||||
if (info.get("mapname").empty())
|
if (info.get("mapname").empty())
|
||||||
@ -198,7 +198,7 @@ namespace Components
|
|||||||
name = namePtr;
|
name = namePtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerList.append(fmt::sprintf("%i %i \"%s\"\n", score, ping, name.data()));
|
playerList.append(Utils::String::VA("%i %i \"%s\"\n", score, ping, name.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Network::SendCommand(address, "statusResponse", "\\" + info.build() + "\n" + playerList + "\n");
|
Network::SendCommand(address, "statusResponse", "\\" + info.build() + "\n" + playerList + "\n");
|
||||||
|
@ -31,7 +31,7 @@ namespace Components
|
|||||||
|
|
||||||
static Container PlayerContainer;
|
static Container PlayerContainer;
|
||||||
|
|
||||||
static void ServerStatus();
|
static void ServerStatus(UIScript::Token);
|
||||||
|
|
||||||
static unsigned int GetPlayerCount();
|
static unsigned int GetPlayerCount();
|
||||||
static const char* GetPlayerText(unsigned int index, int column);
|
static const char* GetPlayerText(unsigned int index, int column);
|
||||||
|
@ -144,7 +144,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerList::UpdateVisibleList()
|
void ServerList::UpdateVisibleList(UIScript::Token)
|
||||||
{
|
{
|
||||||
auto list = ServerList::GetList();
|
auto list = ServerList::GetList();
|
||||||
if (!list) return;
|
if (!list) return;
|
||||||
@ -153,7 +153,7 @@ namespace Components
|
|||||||
|
|
||||||
if (tempList.empty())
|
if (tempList.empty())
|
||||||
{
|
{
|
||||||
ServerList::Refresh();
|
ServerList::Refresh(UIScript::Token());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -171,7 +171,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerList::RefreshVisibleList()
|
void ServerList::RefreshVisibleList(UIScript::Token)
|
||||||
{
|
{
|
||||||
Dvar::Var("ui_serverSelected").set(false);
|
Dvar::Var("ui_serverSelected").set(false);
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ namespace Components
|
|||||||
// Refresh entirely, if there is no entry in the list
|
// Refresh entirely, if there is no entry in the list
|
||||||
if (list->empty())
|
if (list->empty())
|
||||||
{
|
{
|
||||||
ServerList::Refresh();
|
ServerList::Refresh(UIScript::Token());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ namespace Components
|
|||||||
ServerList::SortList();
|
ServerList::SortList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerList::Refresh()
|
void ServerList::Refresh(UIScript::Token)
|
||||||
{
|
{
|
||||||
Dvar::Var("ui_serverSelected").set(false);
|
Dvar::Var("ui_serverSelected").set(false);
|
||||||
Localization::Set("MPUI_SERVERQUERIED", "Sent requests: 0/0");
|
Localization::Set("MPUI_SERVERQUERIED", "Sent requests: 0/0");
|
||||||
@ -457,7 +457,7 @@ namespace Components
|
|||||||
if (lList)
|
if (lList)
|
||||||
{
|
{
|
||||||
lList->push_back(server);
|
lList->push_back(server);
|
||||||
ServerList::RefreshVisibleList();
|
ServerList::RefreshVisibleList(UIScript::Token());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,14 +557,14 @@ namespace Components
|
|||||||
SendServers--;
|
SendServers--;
|
||||||
|
|
||||||
server->sendTime = Game::Sys_Milliseconds();
|
server->sendTime = Game::Sys_Milliseconds();
|
||||||
server->challenge = fmt::sprintf("%X", Utils::Cryptography::Rand::GenerateInt());
|
server->challenge = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||||
|
|
||||||
++ServerList::RefreshContainer.sentCount;
|
++ServerList::RefreshContainer.sentCount;
|
||||||
|
|
||||||
Network::SendCommand(server->target, "getinfo", server->challenge);
|
Network::SendCommand(server->target, "getinfo", server->challenge);
|
||||||
|
|
||||||
// Display in the menu, like in COD4
|
// Display in the menu, like in COD4
|
||||||
Localization::Set("MPUI_SERVERQUERIED", fmt::sprintf("Sent requests: %d/%d", ServerList::RefreshContainer.sentCount, ServerList::RefreshContainer.sendCount));
|
Localization::Set("MPUI_SERVERQUERIED", Utils::String::VA("Sent requests: %d/%d", ServerList::RefreshContainer.sentCount, ServerList::RefreshContainer.sendCount));
|
||||||
|
|
||||||
if (SendServers <= 0) break;
|
if (SendServers <= 0) break;
|
||||||
}
|
}
|
||||||
@ -585,7 +585,7 @@ namespace Components
|
|||||||
|
|
||||||
netSource.set(source);
|
netSource.set(source);
|
||||||
|
|
||||||
ServerList::RefreshVisibleList();
|
ServerList::RefreshVisibleList(UIScript::Token());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerList::UpdateGameType()
|
void ServerList::UpdateGameType()
|
||||||
@ -601,7 +601,7 @@ namespace Components
|
|||||||
|
|
||||||
joinGametype.set(gametype);
|
joinGametype.set(gametype);
|
||||||
|
|
||||||
ServerList::RefreshVisibleList();
|
ServerList::RefreshVisibleList(UIScript::Token());
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerList::ServerList()
|
ServerList::ServerList()
|
||||||
@ -664,7 +664,7 @@ namespace Components
|
|||||||
UIScript::Add("RefreshFilter", ServerList::UpdateVisibleList);
|
UIScript::Add("RefreshFilter", ServerList::UpdateVisibleList);
|
||||||
|
|
||||||
UIScript::Add("RefreshServers", ServerList::Refresh);
|
UIScript::Add("RefreshServers", ServerList::Refresh);
|
||||||
UIScript::Add("JoinServer", [] ()
|
UIScript::Add("JoinServer", [] (UIScript::Token)
|
||||||
{
|
{
|
||||||
ServerList::ServerInfo* info = ServerList::GetServer(ServerList::CurrentServer);
|
ServerList::ServerInfo* info = ServerList::GetServer(ServerList::CurrentServer);
|
||||||
|
|
||||||
@ -690,7 +690,7 @@ namespace Components
|
|||||||
Logger::Print("Sorting server list by token: %d\n", ServerList::SortKey);
|
Logger::Print("Sorting server list by token: %d\n", ServerList::SortKey);
|
||||||
ServerList::SortList();
|
ServerList::SortList();
|
||||||
});
|
});
|
||||||
UIScript::Add("CreateListFavorite", [] ()
|
UIScript::Add("CreateListFavorite", [] (UIScript::Token)
|
||||||
{
|
{
|
||||||
ServerList::ServerInfo* info = ServerList::GetCurrentServer();
|
ServerList::ServerInfo* info = ServerList::GetCurrentServer();
|
||||||
|
|
||||||
@ -699,11 +699,11 @@ namespace Components
|
|||||||
ServerList::StoreFavourite(info->addr.getString());
|
ServerList::StoreFavourite(info->addr.getString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
UIScript::Add("CreateFavorite", [] ()
|
UIScript::Add("CreateFavorite", [] (UIScript::Token)
|
||||||
{
|
{
|
||||||
ServerList::StoreFavourite(Dvar::Var("ui_favoriteAddress").get<std::string>());
|
ServerList::StoreFavourite(Dvar::Var("ui_favoriteAddress").get<std::string>());
|
||||||
});
|
});
|
||||||
UIScript::Add("CreateCurrentServerFavorite", []()
|
UIScript::Add("CreateCurrentServerFavorite", [] (UIScript::Token)
|
||||||
{
|
{
|
||||||
if (Dvar::Var("cl_ingame").get<bool>())
|
if (Dvar::Var("cl_ingame").get<bool>())
|
||||||
{
|
{
|
||||||
|
@ -31,9 +31,9 @@ namespace Components
|
|||||||
const char* getName() { return "ServerList"; };
|
const char* getName() { return "ServerList"; };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void Refresh();
|
static void Refresh(UIScript::Token);
|
||||||
static void RefreshVisibleList();
|
static void RefreshVisibleList(UIScript::Token);
|
||||||
static void UpdateVisibleList();
|
static void UpdateVisibleList(UIScript::Token);
|
||||||
static void InsertRequest(Network::Address address, bool acquireMutex = true);
|
static void InsertRequest(Network::Address address, bool acquireMutex = true);
|
||||||
static void Insert(Network::Address address, Utils::InfoString info);
|
static void Insert(Network::Address address, Utils::InfoString info);
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ namespace Components
|
|||||||
// First check if all versions are present
|
// First check if all versions are present
|
||||||
for (int i = 156;; ++i)
|
for (int i = 156;; ++i)
|
||||||
{
|
{
|
||||||
FileSystem::File definition(fmt::sprintf("%s/%d.json", filename.data(), i));
|
FileSystem::File definition(Utils::String::VA("%s/%d.json", filename.data(), i));
|
||||||
if (!definition.exists()) break;
|
if (!definition.exists()) break;
|
||||||
|
|
||||||
std::vector<std::vector<std::string>> enumContainer;
|
std::vector<std::vector<std::string>> enumContainer;
|
||||||
|
@ -175,11 +175,11 @@ namespace Components
|
|||||||
Theatre::CurrentInfo.length = Game::Sys_Milliseconds() - Theatre::CurrentInfo.length;
|
Theatre::CurrentInfo.length = Game::Sys_Milliseconds() - Theatre::CurrentInfo.length;
|
||||||
|
|
||||||
// Write metadata
|
// Write metadata
|
||||||
FileSystem::FileWriter meta(fmt::sprintf("%s.json", Theatre::CurrentInfo.name.data()));
|
FileSystem::FileWriter meta(Utils::String::VA("%s.json", Theatre::CurrentInfo.name.data()));
|
||||||
meta.write(json11::Json(Theatre::CurrentInfo).dump());
|
meta.write(json11::Json(Theatre::CurrentInfo).dump());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Theatre::LoadDemos()
|
void Theatre::LoadDemos(UIScript::Token)
|
||||||
{
|
{
|
||||||
Theatre::CurrentSelection = 0;
|
Theatre::CurrentSelection = 0;
|
||||||
Theatre::Demos.clear();
|
Theatre::Demos.clear();
|
||||||
@ -188,7 +188,7 @@ namespace Components
|
|||||||
|
|
||||||
for (auto demo : demos)
|
for (auto demo : demos)
|
||||||
{
|
{
|
||||||
FileSystem::File meta(fmt::sprintf("demos/%s.json", demo.data()));
|
FileSystem::File meta(Utils::String::VA("demos/%s.json", demo.data()));
|
||||||
|
|
||||||
if (meta.exists())
|
if (meta.exists())
|
||||||
{
|
{
|
||||||
@ -215,7 +215,7 @@ namespace Components
|
|||||||
std::reverse(Theatre::Demos.begin(), Theatre::Demos.end());
|
std::reverse(Theatre::Demos.begin(), Theatre::Demos.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Theatre::DeleteDemo()
|
void Theatre::DeleteDemo(UIScript::Token)
|
||||||
{
|
{
|
||||||
if (Theatre::CurrentSelection < Theatre::Demos.size())
|
if (Theatre::CurrentSelection < Theatre::Demos.size())
|
||||||
{
|
{
|
||||||
@ -235,15 +235,15 @@ namespace Components
|
|||||||
Dvar::Var("ui_demo_date").set("");
|
Dvar::Var("ui_demo_date").set("");
|
||||||
|
|
||||||
// Reload demos
|
// Reload demos
|
||||||
Theatre::LoadDemos();
|
Theatre::LoadDemos(UIScript::Token());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Theatre::PlayDemo()
|
void Theatre::PlayDemo(UIScript::Token)
|
||||||
{
|
{
|
||||||
if (Theatre::CurrentSelection < Theatre::Demos.size())
|
if (Theatre::CurrentSelection < Theatre::Demos.size())
|
||||||
{
|
{
|
||||||
Command::Execute(fmt::sprintf("demo %s", Theatre::Demos[Theatre::CurrentSelection].name.data()), true);
|
Command::Execute(Utils::String::VA("demo %s", Theatre::Demos[Theatre::CurrentSelection].name.data()), true);
|
||||||
Command::Execute("demoback", false);
|
Command::Execute("demoback", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,10 +308,10 @@ namespace Components
|
|||||||
{
|
{
|
||||||
Logger::Print("Deleting old demo %s\n", files[i].data());
|
Logger::Print("Deleting old demo %s\n", files[i].data());
|
||||||
FileSystem::DeleteFile("demos", files[i].data());
|
FileSystem::DeleteFile("demos", files[i].data());
|
||||||
FileSystem::DeleteFile("demos", fmt::sprintf("%s.json", files[i].data()));
|
FileSystem::DeleteFile("demos", Utils::String::VA("%s.json", files[i].data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::Execute(fmt::format("record auto_{}", time(0)), true);
|
Command::Execute(Utils::String::VA("record auto_%lld", time(0)), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Utils::Hook::Call<DWORD()>(0x42BBB0)();
|
return Utils::Hook::Call<DWORD()>(0x42BBB0)();
|
||||||
|
@ -28,7 +28,7 @@ namespace Components
|
|||||||
{ "gametype", gametype },
|
{ "gametype", gametype },
|
||||||
{ "author", author },
|
{ "author", author },
|
||||||
{ "length", length },
|
{ "length", length },
|
||||||
{ "timestamp", fmt::sprintf("%lld", timeStamp) } //Ugly, but prevents information loss
|
{ "timestamp", Utils::String::VA("%lld", timeStamp) } //Ugly, but prevents information loss
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -44,9 +44,9 @@ namespace Components
|
|||||||
static void WriteBaseline();
|
static void WriteBaseline();
|
||||||
static void StoreBaseline(PBYTE snapshotMsg);
|
static void StoreBaseline(PBYTE snapshotMsg);
|
||||||
|
|
||||||
static void LoadDemos();
|
static void LoadDemos(UIScript::Token);
|
||||||
static void DeleteDemo();
|
static void DeleteDemo(UIScript::Token);
|
||||||
static void PlayDemo();
|
static void PlayDemo(UIScript::Token);
|
||||||
|
|
||||||
static unsigned int GetDemoCount();
|
static unsigned int GetDemoCount();
|
||||||
static const char* GetDemoText(unsigned int item, int column);
|
static const char* GetDemoText(unsigned int item, int column);
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, wink::slot<UIScript::Callback>> UIScript::UIScripts;
|
std::unordered_map<std::string, Utils::Slot<UIScript::Callback>> UIScript::UIScripts;
|
||||||
std::unordered_map<int, wink::slot<UIScript::CallbackRaw>> UIScript::UIOwnerDraws;
|
std::unordered_map<int, Utils::Slot<UIScript::CallbackRaw>> UIScript::UIOwnerDraws;
|
||||||
|
|
||||||
template<> int UIScript::Token::get()
|
template<> int UIScript::Token::get()
|
||||||
{
|
{
|
||||||
@ -48,17 +48,12 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIScript::Add(std::string name, UIScript::Callback* callback)
|
void UIScript::Add(std::string name, Utils::Slot<UIScript::Callback> callback)
|
||||||
{
|
{
|
||||||
UIScript::UIScripts[name] = callback;
|
UIScript::UIScripts[name] = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIScript::Add(std::string name, UIScript::CallbackRaw* callback)
|
void UIScript::AddOwnerDraw(int ownerdraw, Utils::Slot<UIScript::CallbackRaw> callback)
|
||||||
{
|
|
||||||
UIScript::Add(name, reinterpret_cast<UIScript::Callback*>(callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIScript::AddOwnerDraw(int ownerdraw, UIScript::CallbackRaw* callback)
|
|
||||||
{
|
{
|
||||||
UIScript::UIOwnerDraws[ownerdraw] = callback;
|
UIScript::UIOwnerDraws[ownerdraw] = callback;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace Components
|
|||||||
class Token
|
class Token
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Token() : token(0) {};
|
||||||
Token(const char** args) : token(0) { this->parse(args); };
|
Token(const char** args) : token(0) { this->parse(args); };
|
||||||
Token(const Token &obj) { this->token = obj.token; };
|
Token(const Token &obj) { this->token = obj.token; };
|
||||||
|
|
||||||
@ -29,17 +30,15 @@ namespace Components
|
|||||||
typedef void(Callback)(Token token);
|
typedef void(Callback)(Token token);
|
||||||
typedef void(CallbackRaw)();
|
typedef void(CallbackRaw)();
|
||||||
|
|
||||||
static void Add(std::string name, Callback* callback);
|
static void Add(std::string name, Utils::Slot<Callback> callback);
|
||||||
static void Add(std::string name, CallbackRaw* callback);
|
static void AddOwnerDraw(int ownerdraw, Utils::Slot<CallbackRaw> callback);
|
||||||
|
|
||||||
static void AddOwnerDraw(int ownerdraw, CallbackRaw* callback);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void OwnerDrawHandleKeyStub(int ownerDraw, int flags, float *special, int key);
|
static void OwnerDrawHandleKeyStub(int ownerDraw, int flags, float *special, int key);
|
||||||
static bool RunMenuScript(const char* name, const char** args);
|
static bool RunMenuScript(const char* name, const char** args);
|
||||||
static void RunMenuScriptStub();
|
static void RunMenuScriptStub();
|
||||||
|
|
||||||
static std::unordered_map<std::string, wink::slot<Callback>> UIScripts;
|
static std::unordered_map<std::string, Utils::Slot<Callback>> UIScripts;
|
||||||
static std::unordered_map<int, wink::slot<CallbackRaw>> UIOwnerDraws;
|
static std::unordered_map<int, Utils::Slot<CallbackRaw>> UIOwnerDraws;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace Components
|
|||||||
Game::XAssetHeader header = { 0 };
|
Game::XAssetHeader header = { 0 };
|
||||||
|
|
||||||
// Try loading raw weapon
|
// Try loading raw weapon
|
||||||
if (FileSystem::File(fmt::sprintf("weapons/mp/%s", filename.data())).exists())
|
if (FileSystem::File(Utils::String::VA("weapons/mp/%s", filename.data())).exists())
|
||||||
{
|
{
|
||||||
header.data = Game::BG_LoadWeaponDef_LoadObj(filename.data());
|
header.data = Game::BG_LoadWeaponDef_LoadObj(filename.data());
|
||||||
}
|
}
|
||||||
|
@ -780,7 +780,7 @@ namespace Components
|
|||||||
source = source.substr(0, source.find(".csv"));
|
source = source.substr(0, source.find(".csv"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::Execute(fmt::sprintf("buildzone %s", source.data()), true);
|
Command::Execute(Utils::String::VA("buildzone %s", source.data()), true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -537,7 +537,7 @@ namespace Game
|
|||||||
{
|
{
|
||||||
if (client->state < 5)
|
if (client->state < 5)
|
||||||
{
|
{
|
||||||
Components::Network::Send(client->addr, fmt::sprintf("error\n%s", reason.data()));
|
Components::Network::Send(client->addr, Utils::String::VA("error\n%s", reason.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
SV_KickClient(client, reason.data());
|
SV_KickClient(client, reason.data());
|
||||||
|
@ -75,7 +75,6 @@ template <size_t S> class Sizer { };
|
|||||||
#include <mongoose.h>
|
#include <mongoose.h>
|
||||||
#include <json11.hpp>
|
#include <json11.hpp>
|
||||||
#include <tomcrypt.h>
|
#include <tomcrypt.h>
|
||||||
#include <wink/signal.hpp>
|
|
||||||
#ifndef DISABLE_BITMESSAGE
|
#ifndef DISABLE_BITMESSAGE
|
||||||
#include <BitMRC.h>
|
#include <BitMRC.h>
|
||||||
#endif
|
#endif
|
||||||
@ -88,8 +87,6 @@ template <size_t S> class Sizer { };
|
|||||||
#undef min
|
#undef min
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <fmt/printf.h>
|
|
||||||
|
|
||||||
// Protobuf
|
// Protobuf
|
||||||
#include "proto/network.pb.h"
|
#include "proto/network.pb.h"
|
||||||
#include "proto/party.pb.h"
|
#include "proto/party.pb.h"
|
||||||
|
@ -3,10 +3,27 @@
|
|||||||
#include "base128.h"
|
#include "base128.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define VA_BUFFER_COUNT 32
|
||||||
|
#define VA_BUFFER_SIZE 65536
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils
|
||||||
{
|
{
|
||||||
namespace String
|
namespace String
|
||||||
{
|
{
|
||||||
|
const char *VA(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
static char g_vaBuffer[VA_BUFFER_COUNT][VA_BUFFER_SIZE];
|
||||||
|
static int g_vaNextBufferIndex = 0;
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
char* dest = g_vaBuffer[g_vaNextBufferIndex];
|
||||||
|
vsnprintf_s(g_vaBuffer[g_vaNextBufferIndex], VA_BUFFER_SIZE, fmt, ap);
|
||||||
|
g_vaNextBufferIndex = (g_vaNextBufferIndex + 1) % VA_BUFFER_COUNT;
|
||||||
|
va_end(ap);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
std::string ToLower(std::string input)
|
std::string ToLower(std::string input)
|
||||||
{
|
{
|
||||||
std::transform(input.begin(), input.end(), input.begin(), ::tolower);
|
std::transform(input.begin(), input.end(), input.begin(), ::tolower);
|
||||||
@ -35,7 +52,7 @@ namespace Utils
|
|||||||
result.append(separator);
|
result.append(separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.append(fmt::sprintf("%02X", data[i] & 0xFF));
|
result.append(Utils::String::VA("%02X", data[i] & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -122,7 +139,7 @@ namespace Utils
|
|||||||
int minutes = minutesTotal % 60;
|
int minutes = minutesTotal % 60;
|
||||||
int hoursTotal = minutesTotal / 60;
|
int hoursTotal = minutesTotal / 60;
|
||||||
|
|
||||||
return fmt::sprintf("%02d:%02d:%02d", hoursTotal, minutes, seconds);
|
return Utils::String::VA("%02d:%02d:%02d", hoursTotal, minutes, seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FormatBandwidth(size_t bytes, int milliseconds)
|
std::string FormatBandwidth(size_t bytes, int milliseconds)
|
||||||
@ -144,7 +161,7 @@ namespace Utils
|
|||||||
bytesPerSecond /= 1000;
|
bytesPerSecond /= 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt::sprintf("%.2f %s/s", static_cast<float>(bytesPerSecond), sizes[i]);
|
return Utils::String::VA("%.2f %s/s", static_cast<float>(bytesPerSecond), sizes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encodes a given string in Base64
|
// Encodes a given string in Base64
|
||||||
|
@ -2,27 +2,7 @@ namespace Utils
|
|||||||
{
|
{
|
||||||
namespace String
|
namespace String
|
||||||
{
|
{
|
||||||
template <typename ...Args>
|
const char *VA(const char *fmt, ...);
|
||||||
const char* VA(std::string message, Args && ...args)
|
|
||||||
{
|
|
||||||
#define VA_BUFFER_COUNT 4
|
|
||||||
#define VA_BUFFER_SIZE 65536
|
|
||||||
|
|
||||||
static char g_vaBuffer[VA_BUFFER_COUNT][VA_BUFFER_SIZE];
|
|
||||||
static int g_vaNextBufferIndex = 0;
|
|
||||||
|
|
||||||
char* buffer = g_vaBuffer[g_vaNextBufferIndex];
|
|
||||||
g_vaNextBufferIndex = (g_vaNextBufferIndex + 1) % VA_BUFFER_COUNT;
|
|
||||||
|
|
||||||
std::string str = fmt::sprintf(message, std::forward<Args>(args)...);
|
|
||||||
|
|
||||||
if (memmove_s(buffer, VA_BUFFER_SIZE, str.data(), str.size() + 1))
|
|
||||||
{
|
|
||||||
*buffer = 0; // Error
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
int IsSpace(int c);
|
int IsSpace(int c);
|
||||||
std::string ToLower(std::string input);
|
std::string ToLower(std::string input);
|
||||||
|
@ -24,4 +24,32 @@ namespace Utils
|
|||||||
target->push_back(entry);
|
target->push_back(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T> using Slot = std::function<T>;
|
||||||
|
template <typename T>
|
||||||
|
class Signal
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void connect(Slot<T> slot)
|
||||||
|
{
|
||||||
|
slots.push_back(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear()
|
||||||
|
{
|
||||||
|
slots.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ...Args>
|
||||||
|
void operator()(Args&&... args) const
|
||||||
|
{
|
||||||
|
for (auto& slot : slots)
|
||||||
|
{
|
||||||
|
slot(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<Slot<T>> slots;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ namespace Utils
|
|||||||
body += data + "\r\n";
|
body += data + "\r\n";
|
||||||
body += "--" + boundary + "--\r\n";
|
body += "--" + boundary + "--\r\n";
|
||||||
|
|
||||||
headers["Content-Length"] = fmt::sprintf("%u", body.size());
|
headers["Content-Length"] = Utils::String::VA("%u", body.size());
|
||||||
|
|
||||||
return this->execute("POST", body, headers);
|
return this->execute("POST", body, headers);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user