More optimization.
This commit is contained in:
parent
388d5836cd
commit
ba3187ce9e
@ -230,12 +230,10 @@ namespace Components
|
||||
|
||||
Game::XAssetHeader AssetHandler::FindOriginalAsset(Game::XAssetType type, const char* filename)
|
||||
{
|
||||
Game::XAssetHeader header = { 0 };
|
||||
|
||||
bool OriginalState = AssetHandler::BypassState;
|
||||
|
||||
AssetHandler::BypassState = true;
|
||||
header = Game::DB_FindXAssetHeader(type, filename);
|
||||
Game::XAssetHeader header = Game::DB_FindXAssetHeader(type, filename);
|
||||
if(!OriginalState) AssetHandler::BypassState = false;
|
||||
|
||||
return header;
|
||||
|
@ -28,7 +28,6 @@ namespace Components
|
||||
|
||||
char ownPth[MAX_PATH] = { 0 };
|
||||
char workdir[MAX_PATH] = { 0 };
|
||||
char regred[MAX_PATH] = { 0 };
|
||||
|
||||
DWORD dwsize = MAX_PATH;
|
||||
HMODULE hModule = GetModuleHandle(NULL);
|
||||
@ -67,6 +66,8 @@ namespace Components
|
||||
LONG openRes = RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Classes\\iw4x\\shell\\open\\command", 0, KEY_ALL_ACCESS, &hKey);
|
||||
if (openRes == ERROR_SUCCESS)
|
||||
{
|
||||
char regred[MAX_PATH] = { 0 };
|
||||
|
||||
// Check if the game has been moved.
|
||||
openRes = RegQueryValueEx(hKey, 0, 0, 0, reinterpret_cast<BYTE*>(regred), &dwsize);
|
||||
if (openRes == ERROR_SUCCESS)
|
||||
|
@ -92,7 +92,7 @@ namespace Components
|
||||
{
|
||||
std::regex _(expression);
|
||||
}
|
||||
catch (std::exception e)
|
||||
catch (const std::exception e)
|
||||
{
|
||||
MessageBoxA(0, Utils::VA("Invalid regular expression: %s", expression.data()), "Warning", MB_ICONEXCLAMATION);
|
||||
return;
|
||||
|
@ -126,8 +126,6 @@ namespace Components
|
||||
}
|
||||
|
||||
Game::pc_token_t token;
|
||||
Game::keywordHash_t *key;
|
||||
|
||||
if (!Game::PC_ReadTokenHandle(handle, &token) || token.string[0] != '{')
|
||||
{
|
||||
Utils::Memory::Free(menu->items);
|
||||
@ -152,7 +150,7 @@ namespace Components
|
||||
|
||||
int idx = Menus::KeywordHash(token.string);
|
||||
|
||||
key = Game::menuParseKeywordHash[idx];
|
||||
Game::keywordHash_t* key = Game::menuParseKeywordHash[idx];
|
||||
|
||||
if (!key)
|
||||
{
|
||||
@ -186,9 +184,6 @@ namespace Components
|
||||
|
||||
if (Menus::IsValidSourceHandle(handle))
|
||||
{
|
||||
// Sanitize event name
|
||||
std::string menuName = menu;
|
||||
|
||||
while (true)
|
||||
{
|
||||
ZeroMemory(&token, sizeof(token));
|
||||
@ -320,36 +315,32 @@ namespace Components
|
||||
{
|
||||
if (!Menus::IsValidSourceHandle(handle)) return;
|
||||
|
||||
Game::script_t *script;
|
||||
Game::token_t *token;
|
||||
Game::define_t *define;
|
||||
Game::indent_t *indent;
|
||||
Game::source_t *source = Game::sourceFiles[handle];
|
||||
|
||||
while (source->scriptstack)
|
||||
{
|
||||
script = source->scriptstack;
|
||||
Game::script_t* script = source->scriptstack;
|
||||
source->scriptstack = source->scriptstack->next;
|
||||
Game::FreeMemory(script);
|
||||
}
|
||||
|
||||
while (source->tokens)
|
||||
{
|
||||
token = source->tokens;
|
||||
Game::token_t* token = source->tokens;
|
||||
source->tokens = source->tokens->next;
|
||||
Game::FreeMemory(token);
|
||||
}
|
||||
|
||||
while (source->defines)
|
||||
{
|
||||
define = source->defines;
|
||||
Game::define_t* define = source->defines;
|
||||
source->defines = source->defines->next;
|
||||
Game::FreeMemory(define);
|
||||
}
|
||||
|
||||
while (source->indentstack)
|
||||
{
|
||||
indent = source->indentstack;
|
||||
Game::indent_t* indent = source->indentstack;
|
||||
source->indentstack = source->indentstack->next;
|
||||
Utils::Memory::Free(indent);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace Components
|
||||
Address(std::string addrString);
|
||||
Address(Game::netadr_t addr) : address(addr) {}
|
||||
Address(Game::netadr_t* addr) : Address(*addr) {}
|
||||
Address(const Address& obj) { this->address = obj.address; };
|
||||
Address(const Address& obj) : address(obj.address) {};
|
||||
bool operator!=(const Address &obj) { return !(*this == obj); };
|
||||
bool operator==(const Address &obj);
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace Components
|
||||
{
|
||||
|
||||
ZoneBuilder::Zone::Zone(std::string name) : DataMap("zone_source/" + name + ".csv"), ZoneName(name), IndexStart(0),
|
||||
ZoneBuilder::Zone::Zone(std::string name) : DataMap("zone_source/" + name + ".csv"), ZoneName(name), IndexStart(0), Branding { 0 },
|
||||
|
||||
// Reserve 100MB by default.
|
||||
// That's totally fine, as the dedi doesn't load images and therefore doesn't need much memory.
|
||||
@ -307,9 +307,9 @@ namespace Components
|
||||
void ZoneBuilder::Zone::AddBranding()
|
||||
{
|
||||
char* data = "FastFile built using iw4x IW4 ZoneTool!";
|
||||
branding = { ZoneBuilder::Zone::ZoneName.data(), (int)strlen(data), 0, data };
|
||||
ZoneBuilder::Zone::Branding = { ZoneBuilder::Zone::ZoneName.data(), (int)strlen(data), 0, data };
|
||||
|
||||
Game::XAssetHeader header = { &branding };
|
||||
Game::XAssetHeader header = { &Branding };
|
||||
Game::XAsset brandingAsset = { Game::XAssetType::ASSET_TYPE_RAWFILE, header };
|
||||
ZoneBuilder::Zone::LoadedAssets.push_back(brandingAsset);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ namespace Components
|
||||
std::map<std::string, std::string> RenameMap[Game::XAssetType::ASSET_TYPE_COUNT];
|
||||
std::map<const void*, uint32_t> PointerMap;
|
||||
|
||||
Game::RawFile branding;
|
||||
Game::RawFile Branding;
|
||||
};
|
||||
|
||||
ZoneBuilder();
|
||||
|
@ -48,7 +48,7 @@
|
||||
#define ASIO_STANDALONE
|
||||
#include <zlib.h>
|
||||
#include <curses.h>
|
||||
#include <asio.hpp>
|
||||
//#include <asio.hpp>
|
||||
#include <json11.hpp>
|
||||
|
||||
#pragma warning(pop)
|
||||
|
@ -51,7 +51,7 @@ namespace Steam
|
||||
unsigned __int64 Matchmaking::CreateLobby(int eLobbyType, int cMaxMembers)
|
||||
{
|
||||
uint64_t result = Callbacks::RegisterCall();
|
||||
LobbyCreated* retvals = new LobbyCreated;
|
||||
LobbyCreated* retvals = ::Utils::Memory::AllocateArray<LobbyCreated>();
|
||||
SteamID id;
|
||||
|
||||
id.AccountID = 1337132;
|
||||
@ -72,7 +72,7 @@ namespace Steam
|
||||
unsigned __int64 Matchmaking::JoinLobby(SteamID steamIDLobby)
|
||||
{
|
||||
uint64_t result = Callbacks::RegisterCall();
|
||||
LobbyEnter* retvals = new LobbyEnter;
|
||||
LobbyEnter* retvals = ::Utils::Memory::AllocateArray<LobbyEnter>();
|
||||
retvals->m_bLocked = false;
|
||||
retvals->m_EChatRoomEnterResponse = 1;
|
||||
retvals->m_rgfChatPermissions = 0xFFFFFFFF;
|
||||
|
@ -61,7 +61,7 @@ namespace Steam
|
||||
|
||||
if (result.data)
|
||||
{
|
||||
delete[] result.data;
|
||||
::Utils::Memory::Free(result.data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,9 +77,9 @@ namespace Steam
|
||||
if (!Overlay)
|
||||
{
|
||||
HKEY hRegKey;
|
||||
char steamPath[MAX_PATH] = { 0 };
|
||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &hRegKey) == ERROR_SUCCESS)
|
||||
{
|
||||
char steamPath[MAX_PATH] = { 0 };
|
||||
DWORD dwLength = sizeof(steamPath);
|
||||
RegQueryValueExA(hRegKey, "InstallPath", NULL, NULL, reinterpret_cast<BYTE*>(steamPath), &dwLength);
|
||||
RegCloseKey(hRegKey);
|
||||
|
@ -8,7 +8,7 @@ namespace Utils
|
||||
class Hook
|
||||
{
|
||||
public:
|
||||
Hook() : Place(nullptr), Stub(nullptr), Initialized(false), Installed(false), UseJump(false), Protection(0) { ZeroMemory(Hook::Buffer, sizeof(Hook::Buffer)); }
|
||||
Hook() : Place(nullptr), Stub(nullptr), Initialized(false), Installed(false), Original(0), UseJump(false), Protection(0) { ZeroMemory(Hook::Buffer, sizeof(Hook::Buffer)); }
|
||||
Hook(void* place, void* stub, bool useJump = true) : Hook() { Hook::Initialize(place, stub, useJump); }
|
||||
Hook(DWORD place, void* stub, bool useJump = true) : Hook(reinterpret_cast<void*>(place), stub, useJump) {}
|
||||
Hook(DWORD place, DWORD stub, bool useJump = true) : Hook(reinterpret_cast<void*>(place), reinterpret_cast<void*>(stub), useJump) {}
|
||||
|
@ -24,8 +24,8 @@ namespace Utils
|
||||
{
|
||||
public:
|
||||
InfoString() {};
|
||||
InfoString(std::string buffer) :InfoString() { this->Parse(buffer); };
|
||||
InfoString(const InfoString &obj) { this->KeyValuePairs = obj.KeyValuePairs; };
|
||||
InfoString(std::string buffer) : InfoString() { this->Parse(buffer); };
|
||||
InfoString(const InfoString &obj) : KeyValuePairs(obj.KeyValuePairs) {};
|
||||
|
||||
void Set(std::string key, std::string value);
|
||||
std::string Get(std::string key);
|
||||
|
Loading…
Reference in New Issue
Block a user