Fix code-analysis warnings.
This commit is contained in:
@ -6,6 +6,8 @@ namespace Components
|
||||
|
||||
void Colors::Strip(const char* in, char* out, int max)
|
||||
{
|
||||
if (!in || !out) return;
|
||||
|
||||
max--;
|
||||
int current = 0;
|
||||
while (*in != 0 && current < max)
|
||||
@ -18,9 +20,9 @@ namespace Components
|
||||
}
|
||||
else
|
||||
{
|
||||
*in++;
|
||||
in++;
|
||||
}
|
||||
*in++;
|
||||
in++;
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ namespace Components
|
||||
|
||||
void Maps::LoadMapZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync)
|
||||
{
|
||||
if (!zoneInfo) return;
|
||||
|
||||
Maps::CurrentDependencies.clear();
|
||||
for (auto i = Maps::DependencyList.begin(); i != Maps::DependencyList.end(); i++)
|
||||
{
|
||||
@ -24,19 +26,25 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
Game::XZoneInfo* data = new Game::XZoneInfo[zoneCount + Maps::CurrentDependencies.size()];
|
||||
memcpy(data, zoneInfo, sizeof(Game::XZoneInfo) * zoneCount);
|
||||
std::vector<Game::XZoneInfo> data;
|
||||
|
||||
for (unsigned int i = 0; i < zoneCount; i++)
|
||||
{
|
||||
data.push_back(zoneInfo[i]);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < Maps::CurrentDependencies.size(); i++)
|
||||
{
|
||||
data[zoneCount + i].name = (&Maps::CurrentDependencies[i])->data();
|
||||
data[zoneCount + i].allocFlags = data->allocFlags;
|
||||
data[zoneCount + i].freeFlags = data->freeFlags;
|
||||
Game::XZoneInfo info;
|
||||
|
||||
info.name = (&Maps::CurrentDependencies[i])->data();
|
||||
info.allocFlags = zoneInfo->allocFlags;
|
||||
info.freeFlags = zoneInfo->freeFlags;
|
||||
|
||||
data.push_back(info);
|
||||
}
|
||||
|
||||
Game::DB_LoadXAssets(data, zoneCount + Maps::CurrentDependencies.size(), sync);
|
||||
|
||||
delete[] data;
|
||||
Game::DB_LoadXAssets(data.data(), data.size(), sync);
|
||||
}
|
||||
|
||||
bool Maps::LoadAssetRestrict(Game::XAssetType type, Game::XAssetHeader asset, const char* name)
|
||||
|
@ -69,6 +69,11 @@ namespace Components
|
||||
script->next = NULL;
|
||||
|
||||
source = (Game::source_t *)calloc(1, sizeof(Game::source_t));
|
||||
if (!source)
|
||||
{
|
||||
Game::FreeMemory(script);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(source->filename, "string", 64);
|
||||
source->scriptstack = script;
|
||||
@ -111,7 +116,15 @@ namespace Components
|
||||
Game::menuDef_t* Menus::ParseMenu(int handle)
|
||||
{
|
||||
Game::menuDef_t* menu = (Game::menuDef_t*)calloc(1, sizeof(Game::menuDef_t));
|
||||
if (!menu) return nullptr;
|
||||
|
||||
menu->items = (Game::itemDef_t**)calloc(512, sizeof(Game::itemDef_t*));
|
||||
if (!menu->items)
|
||||
{
|
||||
free(menu);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Menus::MenuList.push_back(menu);
|
||||
|
||||
Game::pc_token_t token;
|
||||
@ -187,7 +200,8 @@ namespace Components
|
||||
|
||||
if (!_stricmp(token.string, "menudef"))
|
||||
{
|
||||
menus.push_back(Menus::ParseMenu(handle));
|
||||
Game::menuDef_t* menudef = Menus::ParseMenu(handle);
|
||||
if (menudef) menus.push_back(menudef);
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,8 +231,16 @@ namespace Components
|
||||
|
||||
// Allocate new menu list
|
||||
Game::MenuList* newList = (Game::MenuList*)calloc(1, sizeof(Game::MenuList));
|
||||
newList->name = _strdup(menu);
|
||||
if (!newList) return nullptr;
|
||||
|
||||
newList->menus = (Game::menuDef_t **)calloc(menus.size(), sizeof(Game::menuDef_t *));
|
||||
if (!newList->menus)
|
||||
{
|
||||
free(newList);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
newList->name = _strdup(menu);
|
||||
newList->menuCount = menus.size();
|
||||
|
||||
// Copy new menus
|
||||
@ -254,8 +276,16 @@ namespace Components
|
||||
|
||||
// Allocate new menu list
|
||||
Game::MenuList* newList = (Game::MenuList*)calloc(1, sizeof(Game::MenuList));
|
||||
newList->name = _strdup(menuList->name);
|
||||
if (!newList) return menuList;
|
||||
|
||||
newList->menus = (Game::menuDef_t **)calloc(menus.size(), sizeof(Game::menuDef_t *));
|
||||
if (!newList->menus)
|
||||
{
|
||||
free(newList);
|
||||
return menuList;
|
||||
}
|
||||
|
||||
newList->name = _strdup(menuList->name);
|
||||
newList->menuCount = menus.size();
|
||||
|
||||
// Copy new menus
|
||||
@ -335,20 +365,22 @@ namespace Components
|
||||
|
||||
void Menus::FreeMenuList(Game::MenuList* menuList)
|
||||
{
|
||||
if (menuList)
|
||||
if (!menuList) return;
|
||||
|
||||
// Keep our compiler happy
|
||||
Game::MenuList list = { menuList->name, menuList->menuCount, menuList->menus };
|
||||
|
||||
if (list.name)
|
||||
{
|
||||
if (menuList->name)
|
||||
{
|
||||
free((void*)menuList->name);
|
||||
}
|
||||
|
||||
if (menuList->menus)
|
||||
{
|
||||
free(menuList->menus);
|
||||
}
|
||||
|
||||
free(menuList);
|
||||
free(list.name);
|
||||
}
|
||||
|
||||
if (list.menus)
|
||||
{
|
||||
free(list.menus);
|
||||
}
|
||||
|
||||
free(menuList);
|
||||
}
|
||||
|
||||
void Menus::RemoveMenu(Game::menuDef_t* menudef)
|
||||
@ -498,7 +530,7 @@ namespace Components
|
||||
Utils::Hook::Nop(0x453406, 5);
|
||||
|
||||
//make Com_Error and similar go back to main_text instead of menu_xboxlive.
|
||||
strcpy((char*)0x6FC790, "main_text");
|
||||
Utils::Hook::SetString(0x6FC790, "main_text");
|
||||
|
||||
Command::Add("openmenu", [] (Command::Params params)
|
||||
{
|
||||
|
@ -102,7 +102,6 @@ namespace Components
|
||||
// increase font sizes for chat on higher resolutions
|
||||
static float float13 = 13.0f;
|
||||
static float float10 = 10.0f;
|
||||
|
||||
Utils::Hook::Set<float*>(0x5814AE, &float13);
|
||||
Utils::Hook::Set<float*>(0x5814C8, &float10);
|
||||
|
||||
@ -130,7 +129,7 @@ namespace Components
|
||||
Utils::Hook::Nop(0x4AA8A1, 6);
|
||||
|
||||
// Rename stat file - TODO: beautify
|
||||
strcpy((char*)0x71C048, "iw4x.stat");
|
||||
Utils::Hook::SetString(0x71C048, "iw4x.stat");
|
||||
|
||||
// Patch stats steamid
|
||||
Utils::Hook::Nop(0x682EBF, 20);
|
||||
|
Reference in New Issue
Block a user