[Weapon] More fixes, configstring reallocation is needed though

This commit is contained in:
momo5502 2017-02-03 00:00:08 +01:00
parent 2a6b79fd1b
commit 451eef2873
4 changed files with 90 additions and 0 deletions

View File

@ -15,8 +15,79 @@ namespace Components
return header; return header;
} }
const char* Weapon::GetWeaponConfigString(int index)
{
int weaponIndex = index - 2804;
if(weaponIndex < 1200)
{
return Game::CL_GetConfigString(index);
}
else
{
return Game::CL_GetConfigString(weaponIndex + 2939);
}
}
void Weapon::SaveRegisteredWeapons()
{
*reinterpret_cast<DWORD*>(0x1A86098) = 0;
if (Game::BG_GetNumWeapons() > 1u)
{
for (unsigned int i = 1; i < Game::BG_GetNumWeapons() && i < 1200; ++i)
{
Game::SV_SetConfigstring(i + 2804, Game::BG_GetWeaponName(i));
}
}
if (Game::BG_GetNumWeapons() > 1200)
{
for (unsigned int i = 1200; i < Game::BG_GetNumWeapons(); ++i)
{
Game::SV_SetConfigstring(i + 2939, Game::BG_GetWeaponName(i));
}
}
}
void Weapon::PatchLimit() void Weapon::PatchLimit()
{ {
// Commented out parts require a reallocation of the configstrings
// TODO: Increase the configstring limit accordingly
Utils::Hook::Set<DWORD>(0x403783, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x403E8C, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x41BC34, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x42EB42, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x44FA7B, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x474E0D, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x48E8F2, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x492647, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x494585, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x4945DB, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x4B1F96, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x4D4A99, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x4DD566, WEAPON_LIMIT);
//Utils::Hook::Set<DWORD>(0x4E3683, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x58609F, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x586CAE, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x58F7BE, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x58F7D9, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x58F82D, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x5D6C8B, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x5D6CF7, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x5E24D5, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x5E2604, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x5E2828, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x5E2B4F, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x5E366C, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x5F2614, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x5F7187, WEAPON_LIMIT);
Utils::Hook::Set<DWORD>(0x5FECF9, WEAPON_LIMIT);
//Utils::Hook(0x4BD52D, Weapon::GetWeaponConfigString, HOOK_CALL).install()->quick();
//Utils::Hook(0x45D170, Weapon::SaveRegisteredWeapons, HOOK_JUMP).install()->quick();
static int bg_weaponCompleteDefs[WEAPON_LIMIT]; static int bg_weaponCompleteDefs[WEAPON_LIMIT];
Utils::Hook::Set<DWORD>(0x4B35E1, sizeof(bg_weaponCompleteDefs)); Utils::Hook::Set<DWORD>(0x4B35E1, sizeof(bg_weaponCompleteDefs));
Utils::Hook::Set(0x44CE07, bg_weaponCompleteDefs); Utils::Hook::Set(0x44CE07, bg_weaponCompleteDefs);

View File

@ -18,5 +18,8 @@ namespace Components
private: private:
static Game::XAssetHeader WeaponFileLoad(Game::XAssetType type, std::string filename); static Game::XAssetHeader WeaponFileLoad(Game::XAssetType type, std::string filename);
static void PatchLimit(); static void PatchLimit();
static const char* GetWeaponConfigString(int index);
static void SaveRegisteredWeapons();
}; };
} }

View File

@ -2,6 +2,8 @@
namespace Game namespace Game
{ {
BG_GetNumWeapons_t BG_GetNumWeapons = BG_GetNumWeapons_t(0x4F5CC0);
BG_GetWeaponName_t BG_GetWeaponName = BG_GetWeaponName_t(0x4E6EC0);
BG_LoadWeaponDef_LoadObj_t BG_LoadWeaponDef_LoadObj = BG_LoadWeaponDef_LoadObj_t(0x57B5F0); BG_LoadWeaponDef_LoadObj_t BG_LoadWeaponDef_LoadObj = BG_LoadWeaponDef_LoadObj_t(0x57B5F0);
Cbuf_AddServerText_t Cbuf_AddServerText = Cbuf_AddServerText_t(0x4BB9B0); Cbuf_AddServerText_t Cbuf_AddServerText = Cbuf_AddServerText_t(0x4BB9B0);
@ -14,6 +16,7 @@ namespace Game
CL_ConnectFromParty_t CL_ConnectFromParty = CL_ConnectFromParty_t(0x433D30); CL_ConnectFromParty_t CL_ConnectFromParty = CL_ConnectFromParty_t(0x433D30);
CL_DownloadsComplete_t CL_DownloadsComplete = CL_DownloadsComplete_t(0x42CE90); CL_DownloadsComplete_t CL_DownloadsComplete = CL_DownloadsComplete_t(0x42CE90);
CL_DrawStretchPicPhysical_t CL_DrawStretchPicPhysical = CL_DrawStretchPicPhysical_t(0x4FC120); CL_DrawStretchPicPhysical_t CL_DrawStretchPicPhysical = CL_DrawStretchPicPhysical_t(0x4FC120);
CL_GetConfigString_t CL_GetConfigString = CL_GetConfigString_t(0x44ADB0);
CL_GetRankForXP_t CL_GetRankForXP = CL_GetRankForXP_t(0x4FF8A0); CL_GetRankForXP_t CL_GetRankForXP = CL_GetRankForXP_t(0x4FF8A0);
CL_GetRankIcon_t CL_GetRankIcon = CL_GetRankIcon_t(0x4A7B30); CL_GetRankIcon_t CL_GetRankIcon = CL_GetRankIcon_t(0x4A7B30);
CL_HandleRelayPacket_t CL_HandleRelayPacket = CL_HandleRelayPacket_t(0x5A8C70); CL_HandleRelayPacket_t CL_HandleRelayPacket = CL_HandleRelayPacket_t(0x5A8C70);
@ -228,6 +231,7 @@ namespace Game
SV_Cmd_TokenizeString_t SV_Cmd_TokenizeString = SV_Cmd_TokenizeString_t(0x4B5780); SV_Cmd_TokenizeString_t SV_Cmd_TokenizeString = SV_Cmd_TokenizeString_t(0x4B5780);
SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString = SV_Cmd_EndTokenizedString_t(0x464750); SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString = SV_Cmd_EndTokenizedString_t(0x464750);
SV_DirectConnect_t SV_DirectConnect = SV_DirectConnect_t(0x460480); SV_DirectConnect_t SV_DirectConnect = SV_DirectConnect_t(0x460480);
SV_SetConfigstring_t SV_SetConfigstring = SV_SetConfigstring_t(0x4982E0);
Sys_Error_t Sys_Error = Sys_Error_t(0x4E0200); Sys_Error_t Sys_Error = Sys_Error_t(0x4E0200);
Sys_FreeFileList_t Sys_FreeFileList = Sys_FreeFileList_t(0x4D8580); Sys_FreeFileList_t Sys_FreeFileList = Sys_FreeFileList_t(0x4D8580);

View File

@ -2,6 +2,12 @@
namespace Game namespace Game
{ {
typedef unsigned int(__cdecl * BG_GetNumWeapons_t)();
extern BG_GetNumWeapons_t BG_GetNumWeapons;
typedef const char*(__cdecl * BG_GetWeaponName_t)(unsigned int index);
extern BG_GetWeaponName_t BG_GetWeaponName;
typedef void*(__cdecl * BG_LoadWeaponDef_LoadObj_t)(const char* filename); typedef void*(__cdecl * BG_LoadWeaponDef_LoadObj_t)(const char* filename);
extern BG_LoadWeaponDef_LoadObj_t BG_LoadWeaponDef_LoadObj; extern BG_LoadWeaponDef_LoadObj_t BG_LoadWeaponDef_LoadObj;
@ -29,6 +35,9 @@ namespace Game
typedef void(_cdecl * CL_DrawStretchPicPhysical_t)(float x, float y, float w, float h, float xScale, float yScale, float xay, float yay, const float *color, Game::Material* material); typedef void(_cdecl * CL_DrawStretchPicPhysical_t)(float x, float y, float w, float h, float xScale, float yScale, float xay, float yay, const float *color, Game::Material* material);
extern CL_DrawStretchPicPhysical_t CL_DrawStretchPicPhysical; extern CL_DrawStretchPicPhysical_t CL_DrawStretchPicPhysical;
typedef const char*(_cdecl* CL_GetConfigString_t)(int index);
extern CL_GetConfigString_t CL_GetConfigString;
typedef int(_cdecl* CL_GetRankForXP_t)(int xp); typedef int(_cdecl* CL_GetRankForXP_t)(int xp);
extern CL_GetRankForXP_t CL_GetRankForXP; extern CL_GetRankForXP_t CL_GetRankForXP;
@ -541,6 +550,9 @@ namespace Game
typedef void(__cdecl * SV_Cmd_EndTokenizedString_t)(); typedef void(__cdecl * SV_Cmd_EndTokenizedString_t)();
extern SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString; extern SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString;
typedef void(__cdecl * SV_SetConfigstring_t)(int index, const char* string);
extern SV_SetConfigstring_t SV_SetConfigstring;
typedef void(__cdecl * SV_DirectConnect_t)(netadr_t adr); typedef void(__cdecl * SV_DirectConnect_t)(netadr_t adr);
extern SV_DirectConnect_t SV_DirectConnect; extern SV_DirectConnect_t SV_DirectConnect;