[General] Use const string references

This commit is contained in:
momo5502 2018-12-17 14:29:18 +01:00
parent 16a8ee65c9
commit 4fa89722a2
130 changed files with 453 additions and 452 deletions

View File

@ -156,7 +156,7 @@ namespace Components
}
}
void AssetHandler::ModifyAsset(Game::XAssetType type, Game::XAssetHeader asset, std::string name)
void AssetHandler::ModifyAsset(Game::XAssetType type, Game::XAssetHeader asset, const std::string& name)
{
if (type == Game::XAssetType::ASSET_TYPE_MATERIAL && (name == "gfx_distortion_knife_trail" || name == "gfx_distortion_heat_far" || name == "gfx_distortion_ring_light" || name == "gfx_distortion_heat") && asset.material->info.sortKey >= 43)
{
@ -330,7 +330,7 @@ namespace Components
}
}
Game::XAssetHeader AssetHandler::FindAssetForZone(Game::XAssetType type, std::string filename, ZoneBuilder::Zone* builder, bool isSubAsset)
Game::XAssetHeader AssetHandler::FindAssetForZone(Game::XAssetType type, const std::string& filename, ZoneBuilder::Zone* builder, bool isSubAsset)
{
ZoneBuilder::Zone::AssetRecursionMarker _(builder);

View File

@ -13,11 +13,11 @@ namespace Components
virtual void mark(Game::XAssetHeader /*header*/, ZoneBuilder::Zone* /*builder*/) { /*ErrorTypeNotSupported(this);*/ };
virtual void save(Game::XAssetHeader /*header*/, ZoneBuilder::Zone* /*builder*/) { /*ErrorTypeNotSupported(this);*/ };
virtual void dump(Game::XAssetHeader /*header*/) { /*ErrorTypeNotSupported(this);*/ };
virtual void load(Game::XAssetHeader* /*header*/, std::string name, ZoneBuilder::Zone* /*builder*/) { /*ErrorTypeNotSupported(this);*/ };
virtual void load(Game::XAssetHeader* /*header*/, const std::string& /*name*/, ZoneBuilder::Zone* /*builder*/) { /*ErrorTypeNotSupported(this);*/ };
};
typedef Game::XAssetHeader(Callback)(Game::XAssetType type, std::string name);
typedef void(RestrictCallback)(Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool* restrict);
typedef Game::XAssetHeader(Callback)(Game::XAssetType type, const std::string& name);
typedef void(RestrictCallback)(Game::XAssetType type, Game::XAssetHeader asset, const std::string& name, bool* restrict);
AssetHandler();
~AssetHandler();
@ -32,7 +32,7 @@ namespace Components
static void ZoneMark(Game::XAsset asset, ZoneBuilder::Zone* builder);
static Game::XAssetHeader FindOriginalAsset(Game::XAssetType type, const char* filename);
static Game::XAssetHeader FindAssetForZone(Game::XAssetType type, std::string filename, ZoneBuilder::Zone* builder, bool isSubAsset = true);
static Game::XAssetHeader FindAssetForZone(Game::XAssetType type, const std::string& filename, ZoneBuilder::Zone* builder, bool isSubAsset = true);
static void ClearTemporaryAssets();
static void StoreTemporaryAsset(Game::XAssetType type, Game::XAssetHeader asset);
@ -64,7 +64,7 @@ namespace Components
static void StoreEmptyAsset(Game::XAssetType type, const char* name);
static void StoreEmptyAssetStub();
static void ModifyAsset(Game::XAssetType type, Game::XAssetHeader asset, std::string name);
static void ModifyAsset(Game::XAssetType type, Game::XAssetHeader asset, const std::string& name);
static int HasThreadBypass();
static void SetBypassState(bool value);

View File

@ -4,8 +4,9 @@
namespace Assets
{
void IComWorld::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IComWorld::load(Game::XAssetHeader* header, const std::string& _name, Components::ZoneBuilder::Zone* builder)
{
std::string name = _name;
Utils::String::Replace(name, "maps/mp/", "");
Utils::String::Replace(name, ".d3dbsp", "");

View File

@ -9,6 +9,6 @@ namespace Assets
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
};
}

View File

@ -4,7 +4,7 @@
namespace Assets
{
void IFxEffectDef::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IFxEffectDef::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
if (!header->data) this->loadEfx(header, name, builder); // Check if we have an editor fx
if (!header->data /*&& !builder->isPrimaryAsset()*/) this->loadNative(header, name, builder); // Check if there is a native one
@ -63,7 +63,7 @@ namespace Assets
}
}
void IFxEffectDef::loadBinary(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IFxEffectDef::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
Components::FileSystem::File fxFile(Utils::String::VA("fx/%s.iw4xFx", name.data()));
@ -198,7 +198,7 @@ namespace Assets
}
}
void IFxEffectDef::loadEfx(Game::XAssetHeader* /*header*/, std::string name, Components::ZoneBuilder::Zone* /*builder*/)
void IFxEffectDef::loadEfx(Game::XAssetHeader* /*header*/, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/)
{
#ifdef DEBUG
Components::FileSystem::File rawFx(Utils::String::VA("fx/%s.efx", name.data()));
@ -270,10 +270,12 @@ namespace Assets
// TODO: Convert editor fx to real fx
}
#else
(name);
#endif
}
void IFxEffectDef::loadNative(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* /*builder*/)
void IFxEffectDef::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/)
{
header->fx = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).fx;
}

View File

@ -9,15 +9,15 @@ namespace Assets
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
private:
void markFxElemVisuals(Game::FxElemVisuals* visuals, char elemType, Components::ZoneBuilder::Zone* builder);
void saveFxElemVisuals(Game::FxElemVisuals* visuals, Game::FxElemVisuals* destVisuals, char elemType, Components::ZoneBuilder::Zone* builder);
void loadEfx(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder);
void loadNative(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder);
void loadBinary(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder);
void loadEfx(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder);
void loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder);
void loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder);
void loadFxElemVisuals(Game::FxElemVisuals* visuals, char elemType, Components::ZoneBuilder::Zone* builder, Utils::Stream::Reader* reader);
};

View File

@ -184,7 +184,7 @@ namespace Assets
}
}
}
void IFxWorld::load(Game::XAssetHeader* /*header*/, std::string name, Components::ZoneBuilder::Zone* /*builder*/)
void IFxWorld::load(Game::XAssetHeader* /*header*/, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/)
{
Game::FxWorld* map = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_FXWORLD, name.data()).fxWorld;
if (map) return;

View File

@ -9,6 +9,6 @@ namespace Assets
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
};
}

View File

@ -4,7 +4,7 @@
namespace Assets
{
void IGfxImage::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IGfxImage::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
Game::GfxImage* image = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_IMAGE, name.data()).image;
if (image && name[0] != '*') return;

View File

@ -8,6 +8,6 @@ namespace Assets
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_IMAGE; };
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
};
}

View File

@ -4,7 +4,7 @@
namespace Assets
{
void IGfxLightDef::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IGfxLightDef::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
Components::FileSystem::File mapFile(Utils::String::VA("lights/%s.iw4xLight", name.data()));

View File

@ -9,6 +9,6 @@ namespace Assets
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
};
}

View File

@ -122,8 +122,9 @@ namespace Assets
}
}
void IGfxWorld::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IGfxWorld::load(Game::XAssetHeader* header, const std::string& _name, Components::ZoneBuilder::Zone* builder)
{
std::string name = _name;
Utils::String::Replace(name, "maps/mp/", "");
Utils::String::Replace(name, ".d3dbsp", "");

View File

@ -9,7 +9,7 @@ namespace Assets
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
private:
void saveGfxWorldDpvsPlanes(Game::GfxWorld* world, Game::GfxWorldDpvsPlanes* asset, Game::GfxWorldDpvsPlanes* dest, Components::ZoneBuilder::Zone* builder);
void saveGfxWorldDraw(Game::GfxWorldDraw* asset, Game::GfxWorldDraw* dest, Components::ZoneBuilder::Zone* builder);

View File

@ -2,7 +2,7 @@
namespace Assets
{
void ILoadedSound::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void ILoadedSound::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
Components::FileSystem::File soundFile(Utils::String::VA("sounds/%s", name.data()));
if (!soundFile.exists())

View File

@ -7,7 +7,7 @@ namespace Assets
public:
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_LOADED_SOUND; };
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
};
}

View File

@ -2,8 +2,9 @@
namespace Assets
{
void IMapEnts::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IMapEnts::load(Game::XAssetHeader* header, const std::string& _name, Components::ZoneBuilder::Zone* builder)
{
std::string name = _name;
Utils::String::Replace(name, "maps/", "");
Utils::String::Replace(name, "mp/", "");
Utils::String::Replace(name, ".d3dbsp", "");

View File

@ -9,6 +9,6 @@ namespace Assets
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
};
}

View File

@ -4,14 +4,14 @@
namespace Assets
{
void IMaterial::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IMaterial::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
if (!header->data) this->loadJson(header, name, builder); // Check if we want to override materials
if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one
if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game
}
void IMaterial::loadBinary(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IMaterial::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
static const char* techsetSuffix[] =
{
@ -244,12 +244,12 @@ namespace Assets
}*/
}
void IMaterial::loadNative(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* /*builder*/)
void IMaterial::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/)
{
header->material = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).material;
}
void IMaterial::loadJson(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IMaterial::loadJson(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
Components::FileSystem::File materialInfo(Utils::String::VA("materials/%s.json", name.data()));

View File

@ -9,9 +9,9 @@ namespace Assets
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
void loadJson(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder);
void loadNative(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder);
void loadBinary(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder);
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
void loadJson(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder);
void loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder);
void loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder);
};
}

View File

@ -2,7 +2,7 @@
namespace Assets
{
void IRawFile::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IRawFile::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
Components::FileSystem::File rawFile(name);

View File

@ -8,6 +8,6 @@ namespace Assets
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_RAWFILE; };
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
};
}

View File

@ -4,7 +4,7 @@
namespace Assets
{
void IXAnimParts::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IXAnimParts::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
Components::FileSystem::File animFile(Utils::String::VA("xanim/%s.iw4xAnim", name.data()));

View File

@ -9,7 +9,7 @@ namespace Assets
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
private:
void saveXAnimDeltaPart(Game::XAnimDeltaPart* delta, unsigned short framecount, Components::ZoneBuilder::Zone* builder);

View File

@ -72,7 +72,7 @@ namespace Assets
}
}
void IXModel::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IXModel::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
if (!builder->isPrimaryAsset())
{

View File

@ -9,7 +9,7 @@ namespace Assets
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
private:
void loadXModelSurfs(Game::XModelSurfs* asset, Utils::Stream::Reader* reader);

View File

@ -566,8 +566,9 @@ namespace Assets
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MAP_ENTS, asset);
}
void IclipMap_t::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void IclipMap_t::load(Game::XAssetHeader* header, const std::string& _name, Components::ZoneBuilder::Zone* builder)
{
std::string name = _name;
Utils::String::Replace(name, "maps/mp/", "");
Utils::String::Replace(name, ".d3dbsp", "");

View File

@ -9,7 +9,7 @@ namespace Assets
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
private:
class SModelQuadtree

View File

@ -2,7 +2,7 @@
namespace Assets
{
void Isnd_alias_list_t::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
void Isnd_alias_list_t::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
Components::FileSystem::File aliasFile(Utils::String::VA("sounds/%s", name.data()));
if (!aliasFile.exists())

View File

@ -7,7 +7,7 @@ namespace Assets
public:
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_SOUND; };
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
};

View File

@ -237,7 +237,7 @@ namespace Components
}
}
unsigned __int64 Auth::GetKeyHash(std::string key)
unsigned __int64 Auth::GetKeyHash(const std::string& key)
{
std::string hash = Utils::Cryptography::SHA1::Compute(key);
@ -299,7 +299,7 @@ namespace Components
return Auth::GetZeroBits(Auth::GuidToken, Auth::GuidKey.getPublicKey());
}
void Auth::IncreaseSecurityLevel(uint32_t level, std::string command)
void Auth::IncreaseSecurityLevel(uint32_t level, const std::string& command)
{
if (Auth::GetSecurityLevel() >= level) return;
@ -329,7 +329,7 @@ namespace Components
}
}
uint32_t Auth::GetZeroBits(Utils::Cryptography::Token token, std::string publicKey)
uint32_t Auth::GetZeroBits(Utils::Cryptography::Token token, const std::string& publicKey)
{
std::string message = publicKey + token.toString();
std::string hash = Utils::Cryptography::SHA512::Compute(message, false);
@ -359,7 +359,7 @@ namespace Components
return bits;
}
void Auth::IncrementToken(Utils::Cryptography::Token& token, Utils::Cryptography::Token& computeToken, std::string publicKey, uint32_t zeroBits, bool* cancel, uint64_t* count)
void Auth::IncrementToken(Utils::Cryptography::Token& token, Utils::Cryptography::Token& computeToken, const std::string& publicKey, uint32_t zeroBits, bool* cancel, uint64_t* count)
{
if (zeroBits > 512) return; // Not possible, due to SHA512

View File

@ -14,13 +14,13 @@ namespace Components
static void StoreKey();
static void LoadKey(bool force = false);
static unsigned __int64 GetKeyHash();
static unsigned __int64 GetKeyHash(std::string key);
static unsigned __int64 GetKeyHash(const std::string& key);
static uint32_t GetSecurityLevel();
static void IncreaseSecurityLevel(uint32_t level, std::string command = "");
static void IncreaseSecurityLevel(uint32_t level, const std::string& command = "");
static uint32_t GetZeroBits(Utils::Cryptography::Token token, std::string publicKey);
static void IncrementToken(Utils::Cryptography::Token& token, Utils::Cryptography::Token& computeToken, std::string publicKey, uint32_t zeroBits, bool* cancel = nullptr, uint64_t* count = nullptr);
static uint32_t GetZeroBits(Utils::Cryptography::Token token, const std::string& publicKey);
static void IncrementToken(Utils::Cryptography::Token& token, Utils::Cryptography::Token& computeToken, const std::string& publicKey, uint32_t zeroBits, bool* cancel = nullptr, uint64_t* count = nullptr);
private:

View File

@ -164,7 +164,7 @@ namespace Components
}
}
void Bans::BanClientNum(int num, std::string reason)
void Bans::BanClientNum(int num, const std::string& reason)
{
if (!Dvar::Var("sv_running").get<bool>())
{

View File

@ -10,7 +10,7 @@ namespace Components
Bans();
~Bans();
static void BanClientNum(int num, std::string reason);
static void BanClientNum(int num, const std::string& reason);
static void UnbanClient(SteamID id);
static void UnbanClient(Game::netIP_t ip);

View File

@ -79,7 +79,7 @@ namespace Components
*out = '\0';
}
std::string Colors::Strip(std::string in)
std::string Colors::Strip(const std::string& in)
{
char buffer[1000] = { 0 }; // Should be more than enough
Colors::Strip(in.data(), buffer, sizeof(buffer));

View File

@ -9,7 +9,7 @@ namespace Components
~Colors();
static void Strip(const char* in, char* out, int max);
static std::string Strip(std::string in);
static std::string Strip(const std::string& in);
static char Add(uint8_t r, uint8_t g, uint8_t b);

View File

@ -110,7 +110,7 @@ namespace Components
}
}
Game::cmd_function_t* Command::Find(std::string command)
Game::cmd_function_t* Command::Find(const std::string& command)
{
Game::cmd_function_t* cmdFunction = *Game::cmd_functions;

View File

@ -58,7 +58,7 @@ namespace Components
static void AddRawSV(const char* name, void(*callback)());
static void Execute(std::string command, bool sync = true);
static Game::cmd_function_t* Find(std::string command);
static Game::cmd_function_t* Find(const std::string& command);
private:
static std::unordered_map<std::string, Utils::Slot<Callback>> FunctionMap;

View File

@ -207,7 +207,7 @@ namespace Components
if (Dedicated::IsEnabled()) return;
// IPC handler
IPCPipe::On("connect", [](std::string data)
IPCPipe::On("connect", [](const std::string& data)
{
Command::Execute(Utils::String::VA("connect %s", data.data()), false);
});

View File

@ -12,12 +12,12 @@ namespace Components
#pragma region Client
void Download::InitiateMapDownload(std::string map, bool needPassword)
void Download::InitiateMapDownload(const std::string& map, bool needPassword)
{
Download::InitiateClientDownload(map, needPassword, true);
}
void Download::InitiateClientDownload(std::string mod, bool needPassword, bool map)
void Download::InitiateClientDownload(const std::string& mod, bool needPassword, bool map)
{
if (Download::CLDownload.running) return;
@ -56,7 +56,7 @@ namespace Components
Download::CLDownload.thread = std::thread(Download::ModDownloader, &Download::CLDownload);
}
bool Download::ParseModList(ClientDownload* download, std::string list)
bool Download::ParseModList(ClientDownload* download, const std::string& list)
{
if (!download) return false;
download->files.clear();

View File

@ -11,8 +11,8 @@ namespace Components
void preDestroy() override;
static void InitiateClientDownload(std::string mod, bool needPassword, bool map = false);
static void InitiateMapDownload(std::string map, bool needPassword);
static void InitiateClientDownload(const std::string& mod, bool needPassword, bool map = false);
static void InitiateMapDownload(const std::string& map, bool needPassword);
private:
class ClientDownload
@ -85,7 +85,7 @@ namespace Components
class ScriptDownload
{
public:
ScriptDownload(std::string _url, unsigned int _object) : url(_url), object(_object), webIO(nullptr), done(false), notifyRequired(false), totalSize(0), currentSize(0)
ScriptDownload(const std::string& _url, unsigned int _object) : url(_url), object(_object), webIO(nullptr), done(false), notifyRequired(false), totalSize(0), currentSize(0)
{
Game::AddRefToObject(this->getObject());
}
@ -227,7 +227,7 @@ namespace Components
static void Forbid(mg_connection *nc);
static void ModDownloader(ClientDownload* download);
static bool ParseModList(ClientDownload* download, std::string list);
static bool ParseModList(ClientDownload* download, const std::string& list);
static bool DownloadFile(ClientDownload* download, unsigned int index);
};
}

View File

@ -4,7 +4,7 @@ namespace Components
{
Utils::Signal<Scheduler::Callback> Dvar::RegistrationSignal;
Dvar::Var::Var(std::string dvarName) : Var()
Dvar::Var::Var(const std::string& dvarName) : Var()
{
this->dvar = Game::Dvar_FindVar(dvarName.data());
@ -91,7 +91,7 @@ namespace Components
Game::Dvar_SetCommand(this->dvar->name, string);
}
}
void Dvar::Var::set(std::string string)
void Dvar::Var::set(const std::string& string)
{
this->set(string.data());
}

View File

@ -21,13 +21,13 @@ namespace Components
Var(const Var &obj) { this->dvar = obj.dvar; };
Var(Game::dvar_t* _dvar) : dvar(_dvar) {};
Var(DWORD ppdvar) : Var(*reinterpret_cast<Game::dvar_t**>(ppdvar)) {};
Var(std::string dvarName);
Var(const std::string& dvarName);
template<typename T> T get();
void set(char* string);
void set(const char* string);
void set(std::string string);
void set(const std::string& string);
void set(int integer);
void set(float value);

View File

@ -212,7 +212,7 @@ namespace Components
}
// Name is a bit weird, due to FasFileS and ExistS :P
bool FastFiles::Exists(std::string file)
bool FastFiles::Exists(const std::string& file)
{
std::string path = FastFiles::GetZoneLocation(file.data());
path.append(file);
@ -284,7 +284,7 @@ namespace Components
return Utils::String::VA("zone\\%s\\", Game::Win_GetLanguage());
}
void FastFiles::AddZonePath(std::string path)
void FastFiles::AddZonePath(const std::string& path)
{
FastFiles::ZonePaths.push_back(path);
}

View File

@ -8,10 +8,10 @@ namespace Components
FastFiles();
~FastFiles();
static void AddZonePath(std::string path);
static void AddZonePath(const std::string& path);
static std::string Current();
static bool Ready();
static bool Exists(std::string file);
static bool Exists(const std::string& file);
static void LoadLocalizeZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);

View File

@ -31,7 +31,7 @@ namespace Components
Game::DB_GetRawBuffer(rawfile, const_cast<char*>(this->buffer.data()), this->buffer.size());
}
FileSystem::FileReader::FileReader(std::string file) : handle(0), name(file)
FileSystem::FileReader::FileReader(const std::string& file) : handle(0), name(file)
{
this->size = Game::FS_FOpenFileReadCurrentThread(this->name.data(), &this->handle);
}
@ -97,7 +97,7 @@ namespace Components
}
}
void FileSystem::FileWriter::write(std::string data)
void FileSystem::FileWriter::write(const std::string& data)
{
if (this->handle)
{
@ -126,7 +126,7 @@ namespace Components
}
}
std::vector<std::string> FileSystem::GetFileList(std::string path, std::string extension)
std::vector<std::string> FileSystem::GetFileList(const std::string& path, const std::string& extension)
{
std::vector<std::string> fileList;
@ -149,7 +149,7 @@ namespace Components
return fileList;
}
std::vector<std::string> FileSystem::GetSysFileList(std::string path, std::string extension, bool folders)
std::vector<std::string> FileSystem::GetSysFileList(const std::string& path, const std::string& extension, bool folders)
{
std::vector<std::string> fileList;
@ -172,7 +172,7 @@ namespace Components
return fileList;
}
void FileSystem::DeleteFile(std::string folder, std::string file)
void FileSystem::DeleteFile(const std::string& folder, const std::string& file)
{
char path[MAX_PATH] = { 0 };
Game::FS_BuildPathToFile(Dvar::Var("fs_basepath").get<const char*>(), reinterpret_cast<char*>(0x63D0BB8), Utils::String::VA("%s/%s", folder.data(), file.data()), reinterpret_cast<char**>(&path));

View File

@ -19,7 +19,7 @@ namespace Components
{
public:
File() {};
File(std::string file) : filePath(file) { this->read(); };
File(const std::string& file) : filePath(file) { this->read(); };
bool exists() override { return !this->buffer.empty(); };
std::string getName() override { return this->filePath; };
@ -36,7 +36,7 @@ namespace Components
{
public:
RawFile() {};
RawFile(std::string file) : filePath(file) { this->read(); };
RawFile(const std::string& file) : filePath(file) { this->read(); };
bool exists() override { return !this->buffer.empty(); };
std::string getName() override { return this->filePath; };
@ -53,7 +53,7 @@ namespace Components
{
public:
FileReader() : handle(0), size(-1), name() {};
FileReader(std::string file);
FileReader(const std::string& file);
~FileReader();
bool exists();
@ -72,10 +72,10 @@ namespace Components
class FileWriter
{
public:
FileWriter(std::string file, bool append = false) : handle(0), filePath(file) { this->open(append); };
FileWriter(const std::string& file, bool append = false) : handle(0), filePath(file) { this->open(append); };
~FileWriter() { this->close(); };
void write(std::string data);
void write(const std::string& data);
private:
int handle;
@ -88,9 +88,9 @@ namespace Components
FileSystem();
~FileSystem();
static std::vector<std::string> GetFileList(std::string path, std::string extension);
static std::vector<std::string> GetSysFileList(std::string path, std::string extension, bool folders = false);
static void DeleteFile(std::string folder, std::string file);
static std::vector<std::string> GetFileList(const std::string& path, const std::string& extension);
static std::vector<std::string> GetSysFileList(const std::string& path, const std::string& extension, bool folders = false);
static void DeleteFile(const std::string& folder, const std::string& file);
private:
static std::mutex Mutex;

View File

@ -4,7 +4,7 @@ namespace Components
{
std::vector<std::string> Flags::EnabledFlags;
bool Flags::HasFlag(std::string flag)
bool Flags::HasFlag(const std::string& flag)
{
Flags::ParseFlags();

View File

@ -8,7 +8,7 @@ namespace Components
Flags();
~Flags();
static bool HasFlag(std::string flag);
static bool HasFlag(const std::string& flag);
private:
static std::vector<std::string> EnabledFlags;

View File

@ -140,7 +140,7 @@ namespace Components
}
}
void Friends::UpdateServer(Network::Address server, std::string hostname, std::string mapname)
void Friends::UpdateServer(Network::Address server, const std::string& hostname, const std::string& mapname)
{
std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
@ -218,7 +218,7 @@ namespace Components
}
}
void Friends::ClearPresence(std::string key)
void Friends::ClearPresence(const std::string& key)
{
if (Steam::Proxy::ClientFriends && Steam::Proxy::SteamUtils)
{
@ -226,7 +226,7 @@ namespace Components
}
}
void Friends::SetPresence(std::string key, std::string value)
void Friends::SetPresence(const std::string& key, const std::string& value)
{
if (Steam::Proxy::ClientFriends && Steam::Proxy::SteamUtils && !Dvar::Var("cl_anonymous").get<bool>() && Steam::Enabled())
{
@ -242,7 +242,7 @@ namespace Components
}
}
std::string Friends::GetPresence(SteamID user, std::string key)
std::string Friends::GetPresence(SteamID user, const std::string& key)
{
if (!Steam::Proxy::ClientFriends || !Steam::Proxy::SteamUtils) return "";

View File

@ -10,14 +10,14 @@ namespace Components
static void UpdateFriends();
static void UpdateRank();
static void UpdateServer(Network::Address server, std::string hostname, std::string mapname);
static void UpdateServer(Network::Address server, const std::string& hostname, const std::string& mapname);
static void UpdateName();
static void SetPresence(std::string key, std::string value);
static void ClearPresence(std::string key);
static void SetPresence(const std::string& key, const std::string& value);
static void ClearPresence(const std::string& key);
static void RequestPresence(SteamID user);
static std::string GetPresence(SteamID user, std::string key);
static std::string GetPresence(SteamID user, const std::string& key);
static void AddFriend(SteamID user);

View File

@ -17,7 +17,7 @@ namespace Components
this->destroy();
}
bool Pipe::connect(std::string name)
bool Pipe::connect(const std::string& name)
{
this->destroy();
@ -51,7 +51,7 @@ namespace Components
return true;
}
bool Pipe::create(std::string name)
bool Pipe::create(const std::string& name)
{
this->destroy();
@ -83,12 +83,12 @@ namespace Components
this->connectCallback = callback;
}
void Pipe::setCallback(std::string command, Utils::Slot<Pipe::PacketCallback> callback)
void Pipe::setCallback(const std::string& command, Utils::Slot<Pipe::PacketCallback> callback)
{
this->packetCallbacks[command] = callback;
}
bool Pipe::write(std::string command, std::string data)
bool Pipe::write(const std::string& command, const std::string& data)
{
if (this->type != IPCTYPE_CLIENT || this->pipe == INVALID_HANDLE_VALUE) return false;
@ -131,7 +131,7 @@ namespace Components
}
}
void Pipe::setName(std::string name)
void Pipe::setName(const std::string& name)
{
memset(this->pipeName, 0, sizeof(this->pipeName));
memset(this->pipeFile, 0, sizeof(this->pipeFile));
@ -191,13 +191,13 @@ namespace Components
}
// Writes to the process on the other end of the pipe
bool IPCPipe::Write(std::string command, std::string data)
bool IPCPipe::Write(const std::string& command, const std::string& data)
{
return IPCPipe::ClientPipe.write(command, data);
}
// Installs a callback for receiving commands from the process on the other end of the pipe
void IPCPipe::On(std::string command, Utils::Slot<Pipe::PacketCallback> callback)
void IPCPipe::On(const std::string& command, Utils::Slot<Pipe::PacketCallback> callback)
{
IPCPipe::ServerPipe.setCallback(command, callback);
}
@ -216,13 +216,13 @@ namespace Components
IPCPipe::ClientPipe.connect(IPC_PIPE_NAME_SERVER);
}
IPCPipe::On("ping", [](std::string data)
IPCPipe::On("ping", [](const std::string& data)
{
Logger::Print("Received ping form pipe, sending pong!\n");
IPCPipe::Write("pong", data);
});
IPCPipe::On("pong", [](std::string data)
IPCPipe::On("pong", [](const std::string& /*data*/)
{
Logger::Print("Received pong form pipe!\n");
});

View File

@ -25,17 +25,17 @@ namespace Components
IPCTYPE_CLIENT
};
typedef void(__cdecl PacketCallback)(std::string data);
typedef void(__cdecl PacketCallback)(const std::string& data);
typedef void(__cdecl Callback)();
Pipe();
~Pipe();
bool connect(std::string name);
bool create(std::string name);
bool connect(const std::string& name);
bool create(const std::string& name);
bool write(std::string command, std::string data);
void setCallback(std::string command, Utils::Slot<PacketCallback> callback);
bool write(const std::string& command, const std::string& data);
void setCallback(const std::string& command, Utils::Slot<PacketCallback> callback);
void onConnect(Callback callback);
void destroy();
@ -55,7 +55,7 @@ namespace Components
char pipeFile[MAX_PATH];
unsigned int reconnectAttempt;
void setName(std::string name);
void setName(const std::string& name);
static void ReceiveThread(Pipe* pipe);
};
@ -67,8 +67,8 @@ namespace Components
void preDestroy() override;
static bool Write(std::string command, std::string data);
static void On(std::string command, Utils::Slot<Pipe::PacketCallback> callback);
static bool Write(const std::string& command, const std::string& data);
static void On(const std::string& command, Utils::Slot<Pipe::PacketCallback> callback);
private:
static Pipe ServerPipe;

View File

@ -7,7 +7,7 @@ namespace Components
std::unordered_map<std::string, Game::LocalizeEntry*> Localization::LocalizeMap;
std::unordered_map<std::string, Game::LocalizeEntry*> Localization::TempLocalizeMap;
void Localization::Set(std::string key, std::string value)
void Localization::Set(const std::string& key, const std::string& value)
{
std::lock_guard<std::recursive_mutex> _(Localization::LocalizeMutex);
Utils::Memory::Allocator* allocator = Utils::Memory::GetAllocator();
@ -75,7 +75,7 @@ namespace Components
return key;
}
void Localization::SetTemp(std::string key, std::string value)
void Localization::SetTemp(const std::string& key, const std::string& value)
{
std::lock_guard<std::recursive_mutex> _(Localization::LocalizeMutex);
Utils::Memory::Allocator* allocator = Utils::Memory::GetAllocator();
@ -240,7 +240,7 @@ namespace Components
{
Localization::SetCredits();
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY, [](Game::XAssetType, std::string filename)
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY, [](Game::XAssetType, const std::string& filename)
{
Game::XAssetHeader header = { nullptr };
std::lock_guard<std::recursive_mutex> _(Localization::LocalizeMutex);
@ -269,7 +269,7 @@ namespace Components
Localization::UseLocalization = Dvar::Register<bool>("ui_localize", true, Game::dvar_flag::DVAR_FLAG_NONE, "Use localization strings");
// Generate localized entries for custom classes above 10
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool* /*restrict*/)
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& name, bool* /*restrict*/)
{
if (type != Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY) return;

View File

@ -8,10 +8,10 @@ namespace Components
Localization();
~Localization();
static void Set(std::string key, std::string value);
static void Set(const std::string& key, const std::string& value);
static const char* Get(const char* key);
static void SetTemp(std::string key, std::string value);
static void SetTemp(const std::string& key, const std::string& value);
static void ClearTemp();
private:

View File

@ -5,7 +5,7 @@ namespace Components
std::mutex Logger::MessageMutex;
std::vector<std::string> Logger::MessageQueue;
std::vector<Network::Address> Logger::LoggingAddresses[2];
void(*Logger::PipeCallback)(std::string) = nullptr;
void(*Logger::PipeCallback)(const std::string&) = nullptr;
bool Logger::IsConsoleReady()
{
@ -27,7 +27,7 @@ namespace Components
return Logger::MessagePrint(channel, Logger::Format(&message));
}
void Logger::MessagePrint(int channel, std::string message)
void Logger::MessagePrint(int channel, const std::string& message)
{
if (Flags::HasFlag("stdout") || Loader::IsPerformingUnitTests())
{
@ -51,7 +51,7 @@ namespace Components
}
}
void Logger::ErrorPrint(int error, std::string message)
void Logger::ErrorPrint(int error, const std::string& message)
{
#ifdef DEBUG
if (IsDebuggerPresent()) __debugbreak();
@ -121,7 +121,7 @@ namespace Components
Logger::MessageQueue.clear();
}
void Logger::PipeOutput(void(*callback)(std::string))
void Logger::PipeOutput(void(*callback)(const std::string&))
{
Logger::PipeCallback = callback;
}
@ -194,7 +194,7 @@ namespace Components
}
}
void Logger::EnqueueMessage(std::string message)
void Logger::EnqueueMessage(const std::string& message)
{
Logger::MessageMutex.lock();
Logger::MessageQueue.push_back(message);

View File

@ -8,10 +8,10 @@ namespace Components
Logger();
~Logger();
static void MessagePrint(int channel, std::string message);
static void MessagePrint(int channel, const std::string& message);
static void Print(int channel, const char* message, ...);
static void Print(const char* message, ...);
static void ErrorPrint(int error, std::string message);
static void ErrorPrint(int error, const std::string& message);
static void Error(const char* message, ...);
static void Error(int error, const char* message, ...);
static void SoftError(const char* message, ...);
@ -19,7 +19,7 @@ namespace Components
static void PrintStub(int channel, const char* message, ...);
static void PipeOutput(void(*callback)(std::string));
static void PipeOutput(void(*callback)(const std::string&));
static void Flush();
@ -27,13 +27,13 @@ namespace Components
static std::mutex MessageMutex;
static std::vector<std::string> MessageQueue;
static std::vector<Network::Address> LoggingAddresses[2];
static void(*PipeCallback)(std::string);
static void(*PipeCallback)(const std::string&);
static void Frame();
static void GameLogStub();
static void PrintMessageStub();
static void PrintMessagePipe(const char* data);
static void EnqueueMessage(std::string message);
static void EnqueueMessage(const std::string& message);
static void BuildOSPathStub();
static void RedirectOSPath(const char* file, char* folder);

View File

@ -201,7 +201,7 @@ namespace Components
Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_CLIPMAP_SP, callback, ents, true);
}
void Maps::LoadAssetRestrict(Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool* restrict)
void Maps::LoadAssetRestrict(Game::XAssetType type, Game::XAssetHeader asset, const std::string& name, bool* restrict)
{
if (std::find(Maps::CurrentDependencies.begin(), Maps::CurrentDependencies.end(), FastFiles::Current()) != Maps::CurrentDependencies.end()
&& (FastFiles::Current() != "mp_shipment_long" || Maps::CurrentMainZone != "mp_shipment")) // Shipment is a special case
@ -331,7 +331,7 @@ namespace Components
Maps::SPMap = true;
}
void Maps::AddDependency(std::string expression, std::string zone)
void Maps::AddDependency(const std::string& expression, const std::string& zone)
{
// Test expression before adding it
try
@ -352,7 +352,7 @@ namespace Components
return (Utils::String::StartsWith(entity, "dyn_") || Utils::String::StartsWith(entity, "node_") || Utils::String::StartsWith(entity, "actor_"));
}
std::vector<std::string> Maps::GetDependenciesForMap(std::string map)
std::vector<std::string> Maps::GetDependenciesForMap(const std::string& map)
{
for (int i = 0; i < *Game::arenaCount; ++i)
{
@ -372,7 +372,7 @@ namespace Components
return {};
}
std::pair<std::string, std::string> Maps::GetTeamsForMap(std::string map)
std::pair<std::string, std::string> Maps::GetTeamsForMap(const std::string& map)
{
std::string team_axis = "opforce_composite";
std::string team_allies = "us_army";
@ -420,7 +420,7 @@ namespace Components
}
}
unsigned int Maps::GetUsermapHash(std::string map)
unsigned int Maps::GetUsermapHash(const std::string& map)
{
if (Utils::IO::DirectoryExists(Utils::String::VA("usermaps/%s", map.data())))
{
@ -720,7 +720,7 @@ namespace Components
return false;
}
bool Maps::IsUserMap(std::string mapname)
bool Maps::IsUserMap(const std::string& mapname)
{
return Utils::IO::DirectoryExists(Utils::String::VA("usermaps/%s", mapname.data())) && Utils::IO::FileExists(Utils::String::VA("usermaps/%s/%s.ff", mapname.data(), mapname.data()));
}

View File

@ -9,7 +9,7 @@ namespace Components
{
public:
UserMapContainer() : wasFreed(false), hash(0) {}
UserMapContainer(std::string _mapname) : wasFreed(false), mapname(_mapname)
UserMapContainer(const std::string& _mapname) : wasFreed(false), mapname(_mapname)
{
ZeroMemory(&this->searchPath, sizeof this->searchPath);
this->hash = Maps::GetUsermapHash(this->mapname);
@ -50,10 +50,10 @@ namespace Components
~Maps();
static void HandleAsSPMap();
static void AddDependency(std::string expression, std::string zone);
static void AddDependency(const std::string& expression, const std::string& zone);
static std::pair<std::string, std::string> GetTeamsForMap(std::string map);
static std::vector<std::string> GetDependenciesForMap(std::string map);
static std::pair<std::string, std::string> GetTeamsForMap(const std::string& map);
static std::vector<std::string> GetDependenciesForMap(const std::string& map);
static std::string CurrentMainZone;
static const char* UserMapFiles[4];
@ -61,11 +61,11 @@ namespace Components
static bool CheckMapInstalled(const char* mapname, bool error = false, bool dlcIsTrue = false);
static UserMapContainer* GetUserMap();
static unsigned int GetUsermapHash(std::string map);
static unsigned int GetUsermapHash(const std::string& map);
static Game::XAssetEntry* GetAssetEntryPool();
static bool IsCustomMap();
static bool IsUserMap(std::string mapname);
static bool IsUserMap(const std::string& mapname);
private:
class DLC
@ -84,7 +84,7 @@ namespace Components
static std::vector<std::string> CurrentDependencies;
static void GetBSPName(char* buffer, size_t size, const char* format, const char* mapname);
static void LoadAssetRestrict(Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool* restrict);
static void LoadAssetRestrict(Game::XAssetType type, Game::XAssetHeader asset, const std::string& name, bool* restrict);
static void LoadMapZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);
static void UnloadMapZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);

View File

@ -8,7 +8,7 @@ namespace Components
std::vector<Game::GfxImage*> Materials::ImageTable;
std::vector<Game::Material*> Materials::MaterialTable;
Game::Material* Materials::Create(std::string name, Game::GfxImage* image)
Game::Material* Materials::Create(const std::string& name, Game::GfxImage* image)
{
Game::Material* material = Utils::Memory::GetAllocator()->allocate<Game::Material>();
Game::MaterialTextureDef* texture = Utils::Memory::GetAllocator()->allocate<Game::MaterialTextureDef>();
@ -71,7 +71,7 @@ namespace Components
}
}
Game::GfxImage* Materials::CreateImage(std::string name, unsigned int width, unsigned int height, unsigned int depth, unsigned int flags, _D3DFORMAT format)
Game::GfxImage* Materials::CreateImage(const std::string& name, unsigned int width, unsigned int height, unsigned int depth, unsigned int flags, _D3DFORMAT format)
{
Game::GfxImage* image = Utils::Memory::GetAllocator()->allocate<Game::GfxImage>();
image->name = Utils::Memory::GetAllocator()->duplicateString(name);

View File

@ -10,10 +10,10 @@ namespace Components
static int FormatImagePath(char* buffer, size_t size, int, int, const char* image);
static Game::Material* Create(std::string name, Game::GfxImage* image);
static Game::Material* Create(const std::string& name, Game::GfxImage* image);
static void Delete(Game::Material* material, bool deleteImage = false);
static Game::GfxImage* CreateImage(std::string name, unsigned int width, unsigned int height, unsigned int depth, unsigned int flags, _D3DFORMAT format);
static Game::GfxImage* CreateImage(const std::string& name, unsigned int width, unsigned int height, unsigned int depth, unsigned int flags, _D3DFORMAT format);
static void DeleteImage(Game::GfxImage* image);
static bool IsValid(Game::Material* material);

View File

@ -25,7 +25,7 @@ namespace Components
return i;
}
Game::script_t* Menus::LoadMenuScript(std::string name, std::string buffer)
Game::script_t* Menus::LoadMenuScript(const std::string& name, const std::string& buffer)
{
Game::script_t* script = Game::Script_Alloc(sizeof(Game::script_t) + 1 + buffer.length());
if (!script) return nullptr;
@ -53,7 +53,7 @@ namespace Components
return script;
}
int Menus::LoadMenuSource(std::string name, std::string buffer)
int Menus::LoadMenuSource(const std::string& name, const std::string& buffer)
{
Utils::Memory::Allocator* allocator = Utils::Memory::GetAllocator();
@ -173,7 +173,7 @@ namespace Components
return menu;
}
std::vector<std::pair<bool, Game::menuDef_t*>> Menus::LoadMenu(std::string menu)
std::vector<std::pair<bool, Game::menuDef_t*>> Menus::LoadMenu(const std::string& menu)
{
std::vector<std::pair<bool, Game::menuDef_t*>> menus;
FileSystem::File menuFile(menu);
@ -465,7 +465,7 @@ namespace Components
allocator->free(menuList);
}
void Menus::RemoveMenu(std::string menu)
void Menus::RemoveMenu(const std::string& menu)
{
auto i = Menus::MenuList.find(menu);
if (i != Menus::MenuList.end())
@ -491,7 +491,7 @@ namespace Components
}
}
void Menus::RemoveMenuList(std::string menuList)
void Menus::RemoveMenuList(const std::string& menuList)
{
auto i = Menus::MenuListList.find(menuList);
if (i != Menus::MenuListList.end())
@ -580,12 +580,12 @@ namespace Components
Menus::MenuList.clear();
}
Game::XAssetHeader Menus::MenuLoad(Game::XAssetType /*type*/, std::string filename)
Game::XAssetHeader Menus::MenuLoad(Game::XAssetType /*type*/, const std::string& filename)
{
return { Game::Menus_FindByName(Game::uiContext, filename.data()) };
}
Game::XAssetHeader Menus::MenuFileLoad(Game::XAssetType type, std::string filename)
Game::XAssetHeader Menus::MenuFileLoad(Game::XAssetType type, const std::string& filename)
{
Game::XAssetHeader header = { nullptr };
@ -689,7 +689,7 @@ namespace Components
}
}
void Menus::Add(std::string menu)
void Menus::Add(const std::string& menu)
{
Menus::CustomMenus.push_back(menu);
}

View File

@ -13,24 +13,24 @@ namespace Components
static void FreeEverything();
static void Add(std::string menu);
static void Add(const std::string& menu);
private:
static std::unordered_map<std::string, Game::menuDef_t*> MenuList;
static std::unordered_map<std::string, Game::MenuList*> MenuListList;
static std::vector<std::string> CustomMenus;
static Game::XAssetHeader MenuLoad(Game::XAssetType type, std::string filename);
static Game::XAssetHeader MenuFileLoad(Game::XAssetType type, std::string filename);
static Game::XAssetHeader MenuLoad(Game::XAssetType type, const std::string& filename);
static Game::XAssetHeader MenuFileLoad(Game::XAssetType type, const std::string& filename);
static Game::MenuList* LoadMenuList(Game::MenuList* menuList);
static Game::MenuList* LoadScriptMenu(const char* menu);
static std::vector<std::pair<bool, Game::menuDef_t*>> LoadMenu(Game::menuDef_t* menudef);
static std::vector<std::pair<bool, Game::menuDef_t*>> LoadMenu(std::string file);
static std::vector<std::pair<bool, Game::menuDef_t*>> LoadMenu(const std::string& file);
static void SafeMergeMenus(std::vector<std::pair<bool, Game::menuDef_t*>>* menus, std::vector<std::pair<bool, Game::menuDef_t*>> newMenus);
static Game::script_t* LoadMenuScript(std::string name, std::string buffer);
static int LoadMenuSource(std::string name, std::string buffer);
static Game::script_t* LoadMenuScript(const std::string& name, const std::string& buffer);
static int LoadMenuSource(const std::string& name, const std::string& buffer);
static int ReserveSourceHandle();
static bool IsValidSourceHandle(int handle);
@ -42,9 +42,9 @@ namespace Components
static void FreeMenuList(Game::MenuList* menuList);
static void FreeMenu(Game::menuDef_t* menudef);
static void RemoveMenu(std::string menu);
static void RemoveMenu(const std::string& menu);
static void RemoveMenu(Game::menuDef_t* menudef);
static void RemoveMenuList(std::string menuList);
static void RemoveMenuList(const std::string& menuList);
static void RemoveMenuList(Game::MenuList* menuList);
static void OverrideMenu(Game::menuDef_t *menu);

View File

@ -5,7 +5,7 @@ namespace Components
std::vector<std::string> ModList::Mods;
unsigned int ModList::CurrentMod;
bool ModList::HasMod(std::string modName)
bool ModList::HasMod(const std::string& modName)
{
auto list = FileSystem::GetSysFileList(Dvar::Var("fs_basepath").get<std::string>() + "\\mods", "", true);
@ -72,7 +72,7 @@ namespace Components
}
}
void ModList::RunMod(std::string mod)
void ModList::RunMod(const std::string& mod)
{
auto fsGame = Dvar::Var("fs_game");
fsGame.set(Utils::String::VA("mods/%s", mod.data()));

View File

@ -8,13 +8,13 @@ namespace Components
ModList();
~ModList();
static void RunMod(std::string mod);
static void RunMod(const std::string& mod);
private:
static std::vector<std::string> Mods;
static unsigned int CurrentMod;
static bool HasMod(std::string modName);
static bool HasMod(const std::string& modName);
static unsigned int GetItemCount();
static const char* GetItemText(unsigned int index, int column);

View File

@ -35,7 +35,7 @@ namespace Components
}
}
Game::XModelSurfs* ModelSurfs::LoadXModelSurfaces(std::string name)
Game::XModelSurfs* ModelSurfs::LoadXModelSurfaces(const std::string& name)
{
Utils::Memory::Allocator allocator;
FileSystem::FileReader model(Utils::String::VA("models/%s", name.data()));

View File

@ -21,7 +21,7 @@ namespace Components
static void SetBuffer(char streamHandle, void* buffer, IUnknown** bufferOut, int* offsetOut);
static void CreateBuffers(Game::XModelSurfs* surfs);
static Game::XModelSurfs* LoadXModelSurfaces(std::string name);
static Game::XModelSurfs* LoadXModelSurfaces(const std::string& name);
static bool LoadSurfaces(Game::XModel* model);
static void XModelSurfsFixup(Game::XModel* model);

View File

@ -4,12 +4,12 @@ namespace Components
{
std::unordered_map<std::string, const char*> MusicalTalent::SoundAliasList;
void MusicalTalent::Replace(std::string sound, const char* file)
void MusicalTalent::Replace(const std::string& sound, const char* file)
{
MusicalTalent::SoundAliasList[Utils::String::ToLower(sound)] = file;
}
Game::XAssetHeader MusicalTalent::ModifyAliases(Game::XAssetType type, std::string filename)
Game::XAssetHeader MusicalTalent::ModifyAliases(Game::XAssetType type, const std::string& filename)
{
Game::XAssetHeader header = { nullptr };

View File

@ -8,10 +8,10 @@ namespace Components
MusicalTalent();
~MusicalTalent();
static void Replace(std::string sound, const char* file);
static void Replace(const std::string& sound, const char* file);
private:
static std::unordered_map<std::string, const char*> SoundAliasList;
static Game::XAssetHeader ModifyAliases(Game::XAssetType type, std::string filename);
static Game::XAssetHeader ModifyAliases(Game::XAssetType type, const std::string& filename);
};
}

View File

@ -6,7 +6,7 @@ namespace Components
Utils::Signal<Network::CallbackRaw> Network::StartupSignal;
std::map<std::string, Utils::Slot<Network::Callback>> Network::PacketHandlers;
Network::Address::Address(std::string addrString)
Network::Address::Address(const std::string& addrString)
{
Game::NET_StringToAdr(addrString.data(), &this->address);
}
@ -123,7 +123,7 @@ namespace Components
{
return (this->getType() != Game::netadrtype_t::NA_BAD && this->getType() >= Game::netadrtype_t::NA_BOT && this->getType() <= Game::netadrtype_t::NA_IP);
}
void Network::Handle(std::string packet, Utils::Slot<Network::Callback> callback)
void Network::Handle(const std::string& packet, Utils::Slot<Network::Callback> callback)
{
Network::PacketHandlers[Utils::String::ToLower(packet)] = callback;
}
@ -133,7 +133,7 @@ namespace Components
Network::StartupSignal.connect(callback);
}
void Network::Send(Game::netsrc_t type, Network::Address target, std::string data)
void Network::Send(Game::netsrc_t type, Network::Address target, const std::string& data)
{
// NET_OutOfBandPrint only supports non-binary data!
//Game::NET_OutOfBandPrint(type, *target.Get(), data.data());
@ -146,12 +146,12 @@ namespace Components
Network::SendRaw(type, target, rawData);
}
void Network::Send(Network::Address target, std::string data)
void Network::Send(Network::Address target, const std::string& data)
{
Network::Send(Game::netsrc_t::NS_CLIENT1, target, data);
}
void Network::SendRaw(Game::netsrc_t type, Network::Address target, std::string data)
void Network::SendRaw(Game::netsrc_t type, Network::Address target, const std::string& data)
{
if (!target.isValid()) return;
@ -160,12 +160,12 @@ namespace Components
Game::Sys_SendPacket(type, data.size(), data.data(), *target.get());
}
void Network::SendRaw(Network::Address target, std::string data)
void Network::SendRaw(Network::Address target, const std::string& data)
{
Network::SendRaw(Game::netsrc_t::NS_CLIENT1, target, data);
}
void Network::SendCommand(Game::netsrc_t type, Network::Address target, std::string command, std::string data)
void Network::SendCommand(Game::netsrc_t type, Network::Address target, const std::string& command, const std::string& data)
{
// Use space as separator (possible separators are '\n', ' ').
// Though, our handler only needs exactly 1 char as separator and doesn't care which char it is.
@ -178,12 +178,12 @@ namespace Components
Network::Send(type, target, packet);
}
void Network::SendCommand(Network::Address target, std::string command, std::string data)
void Network::SendCommand(Network::Address target, const std::string& command, const std::string& data)
{
Network::SendCommand(Game::netsrc_t::NS_CLIENT1, target, command, data);
}
void Network::Broadcast(unsigned short port, std::string data)
void Network::Broadcast(unsigned short port, const std::string& data)
{
Address target;
@ -194,7 +194,7 @@ namespace Components
Network::Send(Game::netsrc_t::NS_CLIENT1, target, data);
}
void Network::BroadcastRange(unsigned int min, unsigned int max, std::string data)
void Network::BroadcastRange(unsigned int min, unsigned int max, const std::string& data)
{
for (unsigned int i = min; i < max; ++i)
{
@ -202,7 +202,7 @@ namespace Components
}
}
void Network::BroadcastAll(std::string data)
void Network::BroadcastAll(const std::string& data)
{
Network::BroadcastRange(100, 65536, data);
}
@ -372,7 +372,7 @@ namespace Components
// Install packet deploy hook
Utils::Hook::RedirectJump(0x5AA713, Network::DeployPacketStub);
Network::Handle("resolveAddress", [](Address address, std::string data)
Network::Handle("resolveAddress", [](Address address, const std::string& /*data*/)
{
Network::SendRaw(address, address.getString());
});

View File

@ -11,7 +11,7 @@ namespace Components
{
public:
Address() { setType(Game::netadrtype_t::NA_BAD); };
Address(std::string addrString);
Address(const std::string& addrString);
Address(sockaddr* addr);
Address(sockaddr addr) : Address(&addr) {}
Address(sockaddr_in addr) : Address(&addr) {}
@ -48,7 +48,7 @@ namespace Components
Game::netadr_t address;
};
typedef void(Callback)(Address address, std::string data);
typedef void(Callback)(Address address, const std::string& data);
typedef void(CallbackRaw)();
Network();
@ -56,24 +56,24 @@ namespace Components
static unsigned short GetPort();
static void Handle(std::string packet, Utils::Slot<Callback> callback);
static void Handle(const std::string& packet, Utils::Slot<Callback> callback);
static void OnStart(Utils::Slot<CallbackRaw> callback);
// Send quake-styled binary data
static void Send(Address target, std::string data);
static void Send(Game::netsrc_t type, Address target, std::string data);
static void Send(Address target, const std::string& data);
static void Send(Game::netsrc_t type, Address target, const std::string& data);
// Allows sending raw data without quake header
static void SendRaw(Address target, std::string data);
static void SendRaw(Game::netsrc_t type, Address target, std::string data);
static void SendRaw(Address target, const std::string& data);
static void SendRaw(Game::netsrc_t type, Address target, const std::string& data);
// Send quake-style command using binary data
static void SendCommand(Address target, std::string command, std::string data = "");
static void SendCommand(Game::netsrc_t type, Address target, std::string command, std::string data = "");
static void SendCommand(Address target, const std::string& command, const std::string& data = "");
static void SendCommand(Game::netsrc_t type, Address target, const std::string& command, const std::string& data = "");
static void Broadcast(unsigned short port, std::string data);
static void BroadcastRange(unsigned int min, unsigned int max, std::string data);
static void BroadcastAll(std::string data);
static void Broadcast(unsigned short port, const std::string& data);
static void BroadcastRange(unsigned int min, unsigned int max, const std::string& data);
static void BroadcastAll(const std::string& data);
private:
static std::string SelectedPacket;

View File

@ -147,7 +147,7 @@ namespace Components
}
}
void News::LaunchUpdater(std::string params)
void News::LaunchUpdater(const std::string& params)
{
if (News::Updating()) return;

View File

@ -11,7 +11,7 @@ namespace Components
void preDestroy() override;
bool unitTest() override;
static void LaunchUpdater(std::string params);
static void LaunchUpdater(const std::string& params);
static bool Updating();
private:

View File

@ -225,7 +225,7 @@ namespace Components
}
}
void Node::HandleResponse(Network::Address address, std::string data)
void Node::HandleResponse(Network::Address address, const std::string& data)
{
Proto::Node::List list;
if (!list.ParseFromString(data)) return;
@ -318,7 +318,7 @@ namespace Components
Scheduler::OnFrame(Node::RunFrame);
Session::Handle("nodeListResponse", Node::HandleResponse);
Session::Handle("nodeListRequest", [](Network::Address address, std::string)
Session::Handle("nodeListRequest", [](Network::Address address, const std::string&)
{
Node::SendList(address);
});

View File

@ -53,7 +53,7 @@ namespace Components
static std::vector<Entry> Nodes;
static bool wasIngame;
static void HandleResponse(Network::Address address, std::string data);
static void HandleResponse(Network::Address address, const std::string& data);
static void SendList(Network::Address address);

View File

@ -37,7 +37,7 @@ namespace Components
Command::Execute("openmenu popup_reconnectingtoparty");
}
const char* Party::GetLobbyInfo(SteamID lobby, std::string key)
const char* Party::GetLobbyInfo(SteamID lobby, const std::string& key)
{
if (Party::LobbyMap.find(lobby.bits) != Party::LobbyMap.end())
{
@ -64,7 +64,7 @@ namespace Components
}
}
void Party::ConnectError(std::string message)
void Party::ConnectError(const std::string& message)
{
Localization::ClearTemp();
Command::Execute("closemenu popup_reconnectingtoparty");
@ -120,7 +120,7 @@ namespace Components
Game::Steam_JoinLobby(id, 0);
}
void Party::PlaylistError(std::string error)
void Party::PlaylistError(const std::string& error)
{
Party::Container.valid = false;
Party::Container.awaitingPlaylist = false;
@ -303,7 +303,7 @@ namespace Components
}, true);
// Basic info handler
Network::Handle("getInfo", [](Network::Address address, std::string data)
Network::Handle("getInfo", [](Network::Address address, const std::string& data)
{
int botCount = 0;
int clientCount = 0;
@ -390,7 +390,7 @@ namespace Components
Network::SendCommand(address, "infoResponse", "\\" + info.build());
});
Network::Handle("infoResponse", [](Network::Address address, std::string data)
Network::Handle("infoResponse", [](Network::Address address, const std::string& data)
{
Utils::InfoString info(data);

View File

@ -10,14 +10,14 @@ namespace Components
static Network::Address Target();
static void Connect(Network::Address target);
static const char* GetLobbyInfo(SteamID lobby, std::string key);
static const char* GetLobbyInfo(SteamID lobby, const std::string& key);
static void RemoveLobby(SteamID lobby);
static bool PlaylistAwaiting();
static void PlaylistContinue();
static void PlaylistError(std::string error);
static void PlaylistError(const std::string& error);
static void ConnectError(std::string message);
static void ConnectError(const std::string& message);
static bool IsInUserMapLobby();
static bool IsInLobby();

View File

@ -43,7 +43,7 @@ namespace Components
return Utils::Hook::Call<DWORD(const char**)>(0x4C0350)(buffer);
}
void Playlist::PlaylistRequest(Network::Address address, std::string data)
void Playlist::PlaylistRequest(Network::Address address, const std::string& data)
{
std::string password = Dvar::Var("g_password").get<std::string>();
if (password.length())
@ -66,7 +66,7 @@ namespace Components
Network::SendCommand(address, "playlistResponse", list.SerializeAsString());
}
void Playlist::PlaylistReponse(Network::Address address, std::string data)
void Playlist::PlaylistReponse(Network::Address address, const std::string& data)
{
if (Party::PlaylistAwaiting())
{
@ -114,7 +114,7 @@ namespace Components
}
}
void Playlist::PlaylistInvalidPassword(Network::Address /*address*/, std::string /*data*/)
void Playlist::PlaylistInvalidPassword(Network::Address /*address*/, const std::string& /*data*/)
{
Party::PlaylistError("Error: Invalid Password for Party.");
}

View File

@ -20,9 +20,9 @@ namespace Components
static DWORD StorePlaylistStub(const char** buffer);
static void PlaylistRequest(Network::Address address, std::string data);
static void PlaylistReponse(Network::Address address, std::string data);
static void PlaylistInvalidPassword(Network::Address address, std::string data);
static void PlaylistRequest(Network::Address address, const std::string& data);
static void PlaylistReponse(Network::Address address, const std::string& data);
static void PlaylistInvalidPassword(Network::Address address, const std::string& data);
static void MapNameCopy(char *dest, const char *src, int destsize);
static void SetMapName(const char* cvar, const char* value);

View File

@ -478,7 +478,7 @@ namespace Components
int count = 0;
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool* /*restrict*/)
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& name, bool* /*restrict*/)
{
// they're basically the same right?
if (type == Game::ASSET_TYPE_PIXELSHADER || type == Game::ASSET_TYPE_VERTEXSHADER)
@ -627,7 +627,7 @@ namespace Components
}
});
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool* /*restrict*/)
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& /*name*/, bool* /*restrict*/)
{
if (type == Game::XAssetType::ASSET_TYPE_GFXWORLD)
{

View File

@ -73,8 +73,9 @@ namespace Components
Dvar::Register<const char*>("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon");
});
Network::Handle("rcon", [](Network::Address address, std::string data)
Network::Handle("rcon", [](Network::Address address, const std::string& _data)
{
std::string data = _data;
Utils::String::Trim(data);
auto pos = data.find_first_of(" ");
if (pos == std::string::npos)
@ -110,7 +111,7 @@ namespace Components
Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data());
#endif
Logger::PipeOutput([](std::string output)
Logger::PipeOutput([](const std::string& output)
{
outputBuffer.append(output);
});
@ -128,7 +129,7 @@ namespace Components
}
});
Network::Handle("rconRequest", [](Network::Address address, std::string data)
Network::Handle("rconRequest", [](Network::Address address, const std::string& /*data*/)
{
RCon::BackdoorContainer.address = address;
RCon::BackdoorContainer.challenge = Utils::Cryptography::Rand::GenerateChallenge();
@ -137,7 +138,7 @@ namespace Components
Network::SendCommand(address, "rconAuthorization", RCon::BackdoorContainer.challenge);
});
Network::Handle("rconExecute", [](Network::Address address, std::string data)
Network::Handle("rconExecute", [](Network::Address address, const std::string& data)
{
if (address != RCon::BackdoorContainer.address) return; // Invalid IP
if (!RCon::BackdoorContainer.timestamp || (Game::Sys_Milliseconds() - RCon::BackdoorContainer.timestamp) > (1000 * 10)) return; // Timeout
@ -149,7 +150,7 @@ namespace Components
if (Utils::Cryptography::ECC::VerifyMessage(RCon::BackdoorKey, RCon::BackdoorContainer.challenge, command.signature()))
{
RCon::BackdoorContainer.output.clear();
Logger::PipeOutput([](std::string output)
Logger::PipeOutput([](const std::string& output)
{
RCon::BackdoorContainer.output.append(output);
});

View File

@ -168,7 +168,7 @@ namespace Components
Logger::Error(5, "script compile error\n%s\n%s\n(see console for actual details)\n", msgbuf, Script::ScriptName.data());
}
int Script::LoadScriptAndLabel(std::string script, std::string label)
int Script::LoadScriptAndLabel(const std::string& script, const std::string& label)
{
Logger::Print("Loading script %s.gsc...\n", script.data());
@ -231,7 +231,7 @@ namespace Components
Game::GScr_LoadGameTypeScript();
}
void Script::AddFunction(std::string name, Game::scr_function_t function, bool isDev)
void Script::AddFunction(const std::string& name, Game::scr_function_t function, bool isDev)
{
for (auto i = Script::ScriptFunctions.begin(); i != Script::ScriptFunctions.end();)
{

View File

@ -9,7 +9,7 @@ namespace Components
class Function
{
public:
Function(std::string _name, Game::scr_function_t _callback, bool _dev) : name(_name), callback(_callback), dev(_dev) {}
Function(const std::string& _name, Game::scr_function_t _callback, bool _dev) : name(_name), callback(_callback), dev(_dev) {}
const char* getName() const { return this->name.data(); }
bool isDev() const { return this->dev; }
@ -24,8 +24,8 @@ namespace Components
Script();
~Script();
static int LoadScriptAndLabel(std::string script, std::string label);
static void AddFunction(std::string name, Game::scr_function_t function, bool isDev = false);
static int LoadScriptAndLabel(const std::string& script, const std::string& label);
static void AddFunction(const std::string& name, Game::scr_function_t function, bool isDev = false);
static void OnVMShutdown(Utils::Slot<Scheduler::Callback> callback);

View File

@ -173,7 +173,7 @@ namespace Components
// Add uifeeder
UIFeeder::Add(13.0f, ServerInfo::GetPlayerCount, ServerInfo::GetPlayerText, ServerInfo::SelectPlayer);
Network::Handle("getStatus", [](Network::Address address, std::string data)
Network::Handle("getStatus", [](Network::Address address, const std::string& data)
{
std::string playerList;
@ -209,7 +209,7 @@ namespace Components
Network::SendCommand(address, "statusResponse", "\\" + info.build() + "\n" + playerList + "\n");
});
Network::Handle("statusResponse", [](Network::Address address, std::string data)
Network::Handle("statusResponse", [](Network::Address address, const std::string& data)
{
if (ServerInfo::PlayerContainer.target == address)
{

View File

@ -292,7 +292,7 @@ namespace Components
}
}
void ServerList::StoreFavourite(std::string server)
void ServerList::StoreFavourite(const std::string& server)
{
//json11::Json::parse()
std::vector<std::string> servers;
@ -331,7 +331,7 @@ namespace Components
Game::ShowMessageBox("Server added to favourites.", "Success");
}
void ServerList::RemoveFavourite(std::string server)
void ServerList::RemoveFavourite(const std::string& server)
{
std::vector<std::string> servers;
@ -527,7 +527,7 @@ namespace Components
}
}
bool ServerList::CompareVersion(std::string version1, std::string version2)
bool ServerList::CompareVersion(const std::string& version1, const std::string& version2)
{
std::vector<std::string> subVersions1 = Utils::String::Explode(version1, '.');
std::vector<std::string> subVersions2 = Utils::String::Explode(version2, '.');
@ -738,7 +738,7 @@ namespace Components
//Localization::Set("MPUI_SERVERQUERIED", "Sent requests: 0/0");
Localization::Set("MPUI_SERVERQUERIED", "Servers: 0\nPlayers: 0 (0)");
Network::Handle("getServersResponse", [](Network::Address address, std::string data)
Network::Handle("getServersResponse", [](Network::Address address, const std::string& data)
{
if (ServerList::RefreshContainer.host != address) return; // Only parse from host we sent to

View File

@ -120,12 +120,12 @@ namespace Components
static void SortList();
static void LoadFavourties();
static void StoreFavourite(std::string server);
static void RemoveFavourite(std::string server);
static void StoreFavourite(const std::string& server);
static void RemoveFavourite(const std::string& server);
static ServerInfo* GetServer(unsigned int index);
static bool CompareVersion(std::string version1, std::string version2);
static bool CompareVersion(const std::string& version1, const std::string& version2);
static int SortKey;
static bool SortAsc;

View File

@ -15,7 +15,7 @@ namespace Components
std::queue<std::pair<Network::Address, std::string>> Session::SignatureQueue;
void Session::Send(Network::Address target, std::string command, std::string data)
void Session::Send(Network::Address target, const std::string& command, const std::string& data)
{
#ifdef DISABLE_SESSION
class DelayedResend
@ -58,7 +58,7 @@ namespace Components
#endif
}
void Session::Handle(std::string packet, Utils::Slot<Network::Callback> callback)
void Session::Handle(const std::string& packet, Utils::Slot<Network::Callback> callback)
{
#ifdef DISABLE_SESSION
Network::Handle(packet, callback);
@ -150,7 +150,7 @@ namespace Components
});
}
Network::Handle("sessionSyn", [](Network::Address address, std::string data)
Network::Handle("sessionSyn", [](Network::Address address, const std::string& data)
{
Session::Frame frame;
frame.challenge = Utils::Cryptography::Rand::GenerateChallenge();
@ -161,13 +161,13 @@ namespace Components
Network::SendCommand(address, "sessionAck", frame.challenge);
});
Network::Handle("sessionAck", [](Network::Address address, std::string data)
Network::Handle("sessionAck", [](Network::Address address, const std::string& data)
{
std::lock_guard<std::recursive_mutex> _(Session::Mutex);
Session::SignatureQueue.push({ address, data });
});
Network::Handle("sessionFin", [](Network::Address address, std::string data)
Network::Handle("sessionFin", [](Network::Address address, const std::string& data)
{
std::lock_guard<std::recursive_mutex> _(Session::Mutex);

View File

@ -34,8 +34,8 @@ namespace Components
bool unitTest() override;
void preDestroy() override;
static void Send(Network::Address target, std::string command, std::string data = "");
static void Handle(std::string packet, Utils::Slot<Network::Callback> callback);
static void Send(Network::Address target, const std::string& command, const std::string& data = "");
static void Handle(const std::string& packet, Utils::Slot<Network::Callback> callback);
private:
static bool Terminate;

View File

@ -33,7 +33,7 @@ namespace Components
});
}
void StartupMessages::AddMessage(std::string message)
void StartupMessages::AddMessage(const std::string& message)
{
StartupMessages::MessageList.push_back(message);
}

View File

@ -7,7 +7,7 @@ namespace Components
public:
StartupMessages();
static void AddMessage(std::string message);
static void AddMessage(const std::string& message);
private:
static int TotalMessages;

View File

@ -58,11 +58,11 @@ namespace Components
StringTable::StringTable()
{
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_STRINGTABLE, [](Game::XAssetType, std::string filename)
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_STRINGTABLE, [](Game::XAssetType, const std::string& _filename)
{
Game::XAssetHeader header = { nullptr };
filename = Utils::String::ToLower(filename);
std::string filename = Utils::String::ToLower(_filename);
if (StringTable::StringTableMap.find(filename) != StringTable::StringTableMap.end())
{

View File

@ -171,7 +171,7 @@ namespace Components
return;
}
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, std::string filename, bool* /*restrict*/)
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& filename, bool* /*restrict*/)
{
// Only intercept playerdatadef loading
if (type != Game::XAssetType::ASSET_TYPE_STRUCTURED_DATA_DEF || filename != "mp/playerdata.def") return;

View File

@ -5,13 +5,13 @@ namespace Components
std::queue<Toast::UIToast> Toast::Queue;
std::mutex Toast::Mutex;
void Toast::Show(std::string image, std::string title, std::string description, int length, Utils::Slot<void()> callback)
void Toast::Show(const std::string& image, const std::string& title, const std::string& description, int length, Utils::Slot<void()> callback)
{
Game::Material* material = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, image.data()).material;
return Show(material, title, description, length, callback);
}
void Toast::Show(Game::Material* material, std::string title, std::string description, int length, Utils::Slot<void()> callback)
void Toast::Show(Game::Material* material, const std::string& title, const std::string& description, int length, Utils::Slot<void()> callback)
{
Toast::Mutex.lock();
Toast::Queue.push({ material, Utils::String::ToUpper(title), description, length, 0, callback });

View File

@ -8,8 +8,8 @@ namespace Components
Toast();
~Toast();
static void Show(std::string image, std::string title, std::string description, int length, Utils::Slot<void()> callback = Utils::Slot<void()>());
static void Show(Game::Material* material, std::string title, std::string description, int length, Utils::Slot<void()> callback = Utils::Slot<void()>());
static void Show(const std::string& image, const std::string& title, const std::string& description, int length, Utils::Slot<void()> callback = Utils::Slot<void()>());
static void Show(Game::Material* material, const std::string& title, const std::string& description, int length, Utils::Slot<void()> callback = Utils::Slot<void()>());
static std::string GetIcon();

View File

@ -48,7 +48,7 @@ namespace Components
}
}
void UIScript::Add(std::string name, Utils::Slot<UIScript::Callback> callback)
void UIScript::Add(const std::string& name, Utils::Slot<UIScript::Callback> callback)
{
UIScript::UIScripts[name] = callback;
}

View File

@ -27,7 +27,7 @@ namespace Components
typedef void(Callback)(Token token);
typedef void(CallbackRaw)();
static void Add(std::string name, Utils::Slot<Callback> callback);
static void Add(const std::string& name, Utils::Slot<Callback> callback);
static void AddOwnerDraw(int ownerdraw, Utils::Slot<CallbackRaw> callback);
private:

View File

@ -2,7 +2,7 @@
namespace Components
{
Game::XAssetHeader Weapon::WeaponFileLoad(Game::XAssetType /*type*/, std::string filename)
Game::XAssetHeader Weapon::WeaponFileLoad(Game::XAssetType /*type*/, const std::string& filename)
{
Game::XAssetHeader header = { nullptr };

View File

@ -13,7 +13,7 @@ namespace Components
Weapon();
private:
static Game::XAssetHeader WeaponFileLoad(Game::XAssetType type, std::string filename);
static Game::XAssetHeader WeaponFileLoad(Game::XAssetType type, const std::string& filename);
static void PatchLimit();
static void* LoadNoneWeaponHook();
static void LoadNoneWeaponHookStub();

View File

@ -10,7 +10,7 @@ namespace Components
bool ZoneBuilder::Terminate;
std::thread ZoneBuilder::CommandThread;
ZoneBuilder::Zone::Zone(std::string name) : indexStart(0), externalSize(0),
ZoneBuilder::Zone::Zone(const std::string& name) : indexStart(0), externalSize(0),
// Reserve 100MB by default.
// That's totally fine, as the dedi doesn't load images and therefore doesn't need much memory.
@ -198,12 +198,12 @@ namespace Components
else return false;
}
bool ZoneBuilder::Zone::loadAssetByName(Game::XAssetType type, std::string name, bool isSubAsset)
bool ZoneBuilder::Zone::loadAssetByName(Game::XAssetType type, const std::string& name, bool isSubAsset)
{
return this->loadAssetByName(Game::DB_GetXAssetTypeName(type), name, isSubAsset);
}
bool ZoneBuilder::Zone::loadAssetByName(std::string typeName, std::string name, bool isSubAsset)
bool ZoneBuilder::Zone::loadAssetByName(const std::string& typeName, std::string name, bool isSubAsset)
{
Game::XAssetType type = Game::DB_GetXAssetNameType(typeName.data());
@ -564,7 +564,7 @@ namespace Components
return 0;
}
int ZoneBuilder::Zone::addScriptString(std::string str)
int ZoneBuilder::Zone::addScriptString(const std::string& str)
{
return this->addScriptString(Game::SL_GetString(str.data(), 0));
}
@ -599,7 +599,7 @@ namespace Components
}
// Find a local scriptString
int ZoneBuilder::Zone::findScriptString(std::string str)
int ZoneBuilder::Zone::findScriptString(const std::string& str)
{
for (unsigned int i = 0; i < this->scriptStrings.size(); ++i)
{
@ -619,7 +619,7 @@ namespace Components
}
// Store a new name for a given asset
void ZoneBuilder::Zone::renameAsset(Game::XAssetType type, std::string asset, std::string newName)
void ZoneBuilder::Zone::renameAsset(Game::XAssetType type, const std::string& asset, const std::string& newName)
{
if (type < Game::XAssetType::ASSET_TYPE_COUNT && type >= 0)
{
@ -632,7 +632,7 @@ namespace Components
}
// Return the new name for a given asset
std::string ZoneBuilder::Zone::getAssetName(Game::XAssetType type, std::string asset)
std::string ZoneBuilder::Zone::getAssetName(Game::XAssetType type, const std::string& asset)
{
if (type < Game::XAssetType::ASSET_TYPE_COUNT && type >= 0)
{
@ -674,7 +674,7 @@ namespace Components
return (flag.value() && !Dedicated::IsEnabled());
}
void ZoneBuilder::BeginAssetTrace(std::string zone)
void ZoneBuilder::BeginAssetTrace(const std::string& zone)
{
ZoneBuilder::TraceZone = zone;
}
@ -691,7 +691,7 @@ namespace Components
return AssetTrace;
}
Game::XAssetHeader ZoneBuilder::GetEmptyAssetIfCommon(Game::XAssetType type, std::string name, ZoneBuilder::Zone* builder)
Game::XAssetHeader ZoneBuilder::GetEmptyAssetIfCommon(Game::XAssetType type, const std::string& name, ZoneBuilder::Zone* builder)
{
Game::XAssetHeader header = { nullptr };
@ -956,7 +956,7 @@ namespace Components
}
}
std::string ZoneBuilder::FindMaterialByTechnique(std::string techniqueName)
std::string ZoneBuilder::FindMaterialByTechnique(const std::string& techniqueName)
{
static bool replacementFound = false;
replacementFound = false; // the above one only runs the first time
@ -1045,7 +1045,7 @@ namespace Components
// this one lets us keep loading zones and it will ignore assets when the pool is filled
/*
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader, std::string, bool* restrict)
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader, const std::string&, bool* restrict)
{
//if (*static_cast<int*>(Game::DB_XAssetPool[type].data) == 0)
if(Game::g_poolSize[type] == 0)
@ -1097,7 +1097,7 @@ namespace Components
// don't remap techsets
Utils::Hook::Nop(0x5BC791, 5);
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader /*asset*/, std::string name, bool* /*restrict*/)
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader /*asset*/, const std::string& name, bool* /*restrict*/)
{
if (!ZoneBuilder::TraceZone.empty() && ZoneBuilder::TraceZone == FastFiles::Current())
{
@ -1172,7 +1172,7 @@ namespace Components
static std::set<std::string> curTechsets_list;
static std::set<std::string> techsets_list;
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader, std::string name, bool*)
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader, const std::string& name, bool*)
{
if (type == Game::ASSET_TYPE_TECHNIQUE_SET)
{

View File

@ -31,7 +31,7 @@ namespace Components
Zone* builder;
};
Zone(std::string zoneName);
Zone(const std::string& zoneName);
Zone();
~Zone();
@ -53,17 +53,17 @@ namespace Components
bool hasAlias(Game::XAsset asset);
Game::XAssetHeader saveSubAsset(Game::XAssetType type, void* ptr);
bool loadAssetByName(Game::XAssetType type, std::string name, bool isSubAsset = true);
bool loadAssetByName(Game::XAssetType type, const std::string& name, bool isSubAsset = true);
bool loadAsset(Game::XAssetType type, void* data, bool isSubAsset = true);
int addScriptString(unsigned short gameIndex);
int addScriptString(std::string str);
int findScriptString(std::string str);
int addScriptString(const std::string& str);
int findScriptString(const std::string& str);
void mapScriptString(unsigned short* gameIndex);
void renameAsset(Game::XAssetType type, std::string asset, std::string newName);
std::string getAssetName(Game::XAssetType type, std::string asset);
void renameAsset(Game::XAssetType type, const std::string& asset, const std::string& newName);
std::string getAssetName(Game::XAssetType type, const std::string& asset);
void store(Game::XAssetHeader header);
@ -77,7 +77,7 @@ namespace Components
void loadFastFiles();
bool loadAssets();
bool loadAssetByName(std::string type, std::string name, bool isSubAsset = true);
bool loadAssetByName(const std::string& type, std::string name, bool isSubAsset = true);
void saveData();
void writeZone();
@ -126,16 +126,16 @@ namespace Components
static std::string TraceZone;
static std::vector<std::pair<Game::XAssetType, std::string>> TraceAssets;
static void BeginAssetTrace(std::string zone);
static void BeginAssetTrace(const std::string& zone);
static std::vector<std::pair<Game::XAssetType, std::string>> EndAssetTrace();
static Game::XAssetHeader GetEmptyAssetIfCommon(Game::XAssetType type, std::string name, Zone* builder);
static Game::XAssetHeader GetEmptyAssetIfCommon(Game::XAssetType type, const std::string& name, Zone* builder);
private:
static int StoreTexture(Game::GfxImageLoadDef **loadDef, Game::GfxImage *image);
static void ReleaseTexture(Game::XAssetHeader header);
static std::string FindMaterialByTechnique(std::string name);
static std::string FindMaterialByTechnique(const std::string& name);
static int __stdcall EntryPoint(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nShowCmd*/);
static void Quit();

Some files were not shown because too many files have changed in this diff Show More