[General]: Small cleanup (#870)

This commit is contained in:
Edo 2023-03-23 11:27:44 +00:00 committed by GitHub
parent 48e82543db
commit 58bf01196e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 7 deletions

View File

@ -101,7 +101,7 @@ namespace Components::GSC
LoadCustomScriptsFromFolder(mapDir);
// Mode specific
const auto modeDir = Utils::String::Format("scripts/mp/{}", (*Game::g_gametype)->current.string);
const auto* modeDir = Utils::String::Format("scripts/mp/{}", (*Game::g_gametype)->current.string);
LoadCustomScriptsFromFolder(modeDir);
}

View File

@ -93,9 +93,9 @@ namespace Components
Game::unzClose(this->searchPath.iwd->handle);
auto _free = Utils::Hook::Call<void(void*)>(0x6B5CF2);
_free(this->searchPath.iwd->buildBuffer);
_free(this->searchPath.iwd);
// Use game's free function
Utils::Hook::Call<void(void*)>(0x6B5CF2)(this->searchPath.iwd->buildBuffer);
Utils::Hook::Call<void(void*)>(0x6B5CF2)(this->searchPath.iwd);
ZeroMemory(&this->searchPath, sizeof this->searchPath);
}

View File

@ -103,6 +103,7 @@ namespace Game
MSG_ReadDeltaUsercmdKey_t MSG_ReadDeltaUsercmdKey = MSG_ReadDeltaUsercmdKey_t(0x491F00);
MSG_ReadBitsCompress_t MSG_ReadBitsCompress = MSG_ReadBitsCompress_t(0x4DCC30);
MSG_WriteBitsCompress_t MSG_WriteBitsCompress = MSG_WriteBitsCompress_t(0x4319D0);
Huff_offsetReceive_t Huff_offsetReceive = Huff_offsetReceive_t(0x466060);
NetadrToSockadr_t NetadrToSockadr = NetadrToSockadr_t(0x4B4B40);
@ -389,6 +390,8 @@ namespace Game
bool* s_havePlaylists = reinterpret_cast<bool*>(0x1AD3680);
huffman_t* msgHuff = reinterpret_cast<huffman_t*>(0x1CB9EC0);
const char* TableLookup(StringTable* stringtable, int row, int column)
{
if (!stringtable || !stringtable->values || row >= stringtable->rowCount || column >= stringtable->columnCount) return "";

View File

@ -263,6 +263,9 @@ namespace Game
typedef int(*MSG_WriteBitsCompress_t)(bool trainHuffman, const unsigned char* from, unsigned char* to, int size);
extern MSG_WriteBitsCompress_t MSG_WriteBitsCompress;
typedef void(*Huff_offsetReceive_t)(nodetype* node, int* ch, const unsigned char* fin, int* offset);
extern Huff_offsetReceive_t Huff_offsetReceive;
typedef void(*NetadrToSockadr_t)(netadr_t *a, sockaddr *s);
extern NetadrToSockadr_t NetadrToSockadr;
@ -727,6 +730,8 @@ namespace Game
extern bool* s_havePlaylists;
extern huffman_t* msgHuff;
constexpr auto MAX_MSGLEN = 0x20000;
ScreenPlacement* ScrPlace_GetFullPlacement();

View File

@ -11011,6 +11011,31 @@ namespace Game
snd_alias_list_t* aliasList;
};
struct nodetype
{
nodetype* left;
nodetype* right;
nodetype* parent;
int weight;
int symbol;
};
struct huff_t
{
int blocNode;
int blocPtrs;
nodetype* tree;
nodetype* loc[257];
nodetype** freelist;
nodetype nodeList[768];
nodetype* nodePtrs[768];
};
struct huffman_t
{
huff_t compressDecompress;
};
#pragma endregion
#ifndef IDA

View File

@ -24,7 +24,7 @@ namespace Utils::String
std::string ToLower(const std::string& text)
{
std::string result;
std::ranges::transform(text, std::back_inserter(result), [](const unsigned char input)
std::ranges::transform(text, std::back_inserter(result), [](const unsigned char input) -> char
{
return static_cast<char>(std::tolower(input));
});
@ -35,7 +35,7 @@ namespace Utils::String
std::string ToUpper(const std::string& text)
{
std::string result;
std::ranges::transform(text, std::back_inserter(result), [](const unsigned char input)
std::ranges::transform(text, std::back_inserter(result), [](const unsigned char input) -> char
{
return static_cast<char>(std::toupper(input));
});

View File

@ -73,7 +73,7 @@ namespace Utils::String
Entry stringPool[Buffers];
};
template <typename Arg> // This should display a nice "null" instead of a number
template <typename Arg> // This should display a nice "nullptr" instead of a number
static void SanitizeFormatArgs(Arg& arg)
{
if constexpr (std::is_same_v<Arg, char*> || std::is_same_v<Arg, const char*>)