[Friends] First version of working avatars
This commit is contained in:
@ -394,19 +394,6 @@ namespace Game
|
||||
return poolEntry;
|
||||
}
|
||||
|
||||
__declspec(naked) void Menu_FreeItemMemory(Game::itemDef_t* /*item*/)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
pushad
|
||||
mov edi, [esp + 24h]
|
||||
mov eax, 63D880h
|
||||
call eax
|
||||
popad
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
const char* TableLookup(StringTable* stringtable, int row, int column)
|
||||
{
|
||||
if (!stringtable || !stringtable->values || row >= stringtable->rowCount || column >= stringtable->columnCount) return "";
|
||||
@ -454,24 +441,6 @@ namespace Game
|
||||
return gameType;
|
||||
}
|
||||
|
||||
__declspec(naked) float UI_GetScoreboardLeft(void* /*a1*/)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
push eax
|
||||
pushad
|
||||
|
||||
mov ecx, 590390h
|
||||
mov eax, [esp + 28h]
|
||||
call ecx
|
||||
mov[esp + 20h], eax
|
||||
popad
|
||||
pop eax
|
||||
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
const char *DB_GetXAssetName(XAsset *asset)
|
||||
{
|
||||
if (!asset) return "";
|
||||
@ -572,6 +541,219 @@ namespace Game
|
||||
if(lock) InterlockedDecrement(lockVar);
|
||||
}
|
||||
|
||||
// this cant be MessageBox because windows.h has a define that converts it to MessageBoxW. which is just stupid
|
||||
void ShowMessageBox(std::string message, std::string title)
|
||||
{
|
||||
if (!Game::CL_IsCgameInitialized())
|
||||
{
|
||||
Dvar_SetStringByName("com_errorMessage", message.data());
|
||||
Dvar_SetStringByName("com_errorTitle", title.data());
|
||||
Cbuf_AddText(0, "openmenu error_popmenu_lobby");
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int R_HashString(const char* string)
|
||||
{
|
||||
unsigned int hash = 0;
|
||||
|
||||
while (*string)
|
||||
{
|
||||
hash = (*string | 0x20) ^ (33 * hash);
|
||||
++string;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
void SV_KickClientError(client_t* client, std::string reason)
|
||||
{
|
||||
if (client->state < 5)
|
||||
{
|
||||
Components::Network::SendCommand(client->addr, "error", reason);
|
||||
}
|
||||
|
||||
SV_KickClient(client, reason.data());
|
||||
}
|
||||
|
||||
void Scr_iPrintLn(int clientNum, std::string message)
|
||||
{
|
||||
Game::SV_GameSendServerCommand(clientNum, 0, Utils::String::VA("%c \"%s\"", 0x66, message.data()));
|
||||
}
|
||||
|
||||
void Scr_iPrintLnBold(int clientNum, std::string message)
|
||||
{
|
||||
Game::SV_GameSendServerCommand(clientNum, 0, Utils::String::VA("%c \"%s\"", 0x67, message.data()));
|
||||
}
|
||||
|
||||
int FS_FOpenFileReadCurrentThread(const char* file, int* fh)
|
||||
{
|
||||
if (GetCurrentThreadId() == *reinterpret_cast<DWORD*>(0x1CDE7FC))
|
||||
{
|
||||
return FS_FOpenFileRead(file, fh);
|
||||
}
|
||||
else if (GetCurrentThreadId() == *reinterpret_cast<DWORD*>(0x1CDE814))
|
||||
{
|
||||
return FS_FOpenFileReadDatabase(file, fh);
|
||||
}
|
||||
else
|
||||
{
|
||||
*fh = NULL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void Load_IndexBuffer(void* data, IDirect3DIndexBuffer9** storeHere, int count)
|
||||
{
|
||||
if (Components::Dvar::Var("r_loadForRenderer").get<bool>())
|
||||
{
|
||||
void* buffer = R_AllocStaticIndexBuffer(storeHere, 2 * count);
|
||||
std::memcpy(buffer, data, 2 * count);
|
||||
|
||||
if (storeHere && *storeHere)
|
||||
{
|
||||
(*storeHere)->Unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char* Com_GetParseThreadInfo()
|
||||
{
|
||||
if (Game::Sys_IsMainThread())
|
||||
{
|
||||
return reinterpret_cast<char*>(0x6466628);
|
||||
}
|
||||
else if (Game::Sys_IsRenderThread())
|
||||
{
|
||||
return reinterpret_cast<char*>(0x646AC34);
|
||||
}
|
||||
else if (Game::Sys_IsServerThread())
|
||||
{
|
||||
return reinterpret_cast<char*>(0x646F240);
|
||||
}
|
||||
else if(Game::Sys_IsDatabaseThread())
|
||||
{
|
||||
return reinterpret_cast<char*>(0x647384C);
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Com_SetParseNegativeNumbers(int parse)
|
||||
{
|
||||
char* g_parse = Com_GetParseThreadInfo();
|
||||
|
||||
if (g_parse)
|
||||
{
|
||||
g_parse[1056 * *(reinterpret_cast<DWORD*>(g_parse) + 4224) + 1032] = parse != 0;
|
||||
}
|
||||
}
|
||||
|
||||
int CL_GetMaxXP()
|
||||
{
|
||||
StringTable* rankTable = DB_FindXAssetHeader(ASSET_TYPE_STRINGTABLE, "mp/rankTable.csv").stringTable;
|
||||
const char* maxrank = StringTable_Lookup(rankTable, 0, "maxrank", 1);
|
||||
return atoi(StringTable_Lookup(rankTable, 0, maxrank, 7));
|
||||
}
|
||||
|
||||
void SortWorldSurfaces(GfxWorld* world)
|
||||
{
|
||||
DWORD* specular1 = reinterpret_cast<DWORD*>(0x69F105C);
|
||||
DWORD* specular2 = reinterpret_cast<DWORD*>(0x69F92D4);
|
||||
DWORD saveSpecular1 = *specular1;
|
||||
DWORD saveSpecular2 = *specular2;
|
||||
|
||||
GfxWorld** gameWorld = reinterpret_cast<GfxWorld**>(0x66DEE94);
|
||||
GfxWorld* saveWorld = *gameWorld;
|
||||
|
||||
*specular1 = 1;
|
||||
*specular2 = 1;
|
||||
*gameWorld = world;
|
||||
|
||||
R_SortWorldSurfaces();
|
||||
|
||||
*gameWorld = saveWorld;
|
||||
*specular1 = saveSpecular1;
|
||||
*specular2 = saveSpecular2;
|
||||
}
|
||||
|
||||
void R_AddDebugBounds(float* color, Bounds* b)
|
||||
{
|
||||
Game::vec3_t v1, v2, v3, v4, v5, v6, v7, v8;
|
||||
float* center = b->midPoint;
|
||||
float* halfSize = b->halfSize;
|
||||
|
||||
v1[0] = center[0] - halfSize[0];
|
||||
v1[1] = center[1] - halfSize[1];
|
||||
v1[2] = center[2] - halfSize[2];
|
||||
|
||||
v2[0] = center[0] + halfSize[0];
|
||||
v2[1] = center[1] - halfSize[1];
|
||||
v2[2] = center[2] - halfSize[2];
|
||||
|
||||
v3[0] = center[0] - halfSize[0];
|
||||
v3[1] = center[1] + halfSize[1];
|
||||
v3[2] = center[2] - halfSize[2];
|
||||
|
||||
v4[0] = center[0] + halfSize[0];
|
||||
v4[1] = center[1] + halfSize[1];
|
||||
v4[2] = center[2] - halfSize[2];
|
||||
|
||||
v5[0] = center[0] - halfSize[0];
|
||||
v5[1] = center[1] - halfSize[1];
|
||||
v5[2] = center[2] + halfSize[2];
|
||||
|
||||
v6[0] = center[0] + halfSize[0];
|
||||
v6[1] = center[1] - halfSize[1];
|
||||
v6[2] = center[2] + halfSize[2];
|
||||
|
||||
v7[0] = center[0] - halfSize[0];
|
||||
v7[1] = center[1] + halfSize[1];
|
||||
v7[2] = center[2] + halfSize[2];
|
||||
|
||||
v8[0] = center[0] + halfSize[0];
|
||||
v8[1] = center[1] + halfSize[1];
|
||||
v8[2] = center[2] + halfSize[2];
|
||||
|
||||
// bottom
|
||||
Game::R_AddDebugLine(color, v1, v2);
|
||||
Game::R_AddDebugLine(color, v2, v4);
|
||||
Game::R_AddDebugLine(color, v4, v3);
|
||||
Game::R_AddDebugLine(color, v3, v1);
|
||||
|
||||
// top
|
||||
Game::R_AddDebugLine(color, v5, v6);
|
||||
Game::R_AddDebugLine(color, v6, v8);
|
||||
Game::R_AddDebugLine(color, v8, v7);
|
||||
Game::R_AddDebugLine(color, v7, v5);
|
||||
|
||||
// verticals
|
||||
Game::R_AddDebugLine(color, v1, v5);
|
||||
Game::R_AddDebugLine(color, v2, v6);
|
||||
Game::R_AddDebugLine(color, v3, v7);
|
||||
Game::R_AddDebugLine(color, v4, v8);
|
||||
}
|
||||
|
||||
#pragma optimize("", off)
|
||||
__declspec(naked) float UI_GetScoreboardLeft(void* /*a1*/)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
push eax
|
||||
pushad
|
||||
|
||||
mov ecx, 590390h
|
||||
mov eax, [esp + 28h]
|
||||
call ecx
|
||||
mov[esp + 20h], eax
|
||||
popad
|
||||
pop eax
|
||||
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) XAssetHeader DB_FindXAssetDefaultHeaderInternal(XAssetType /*type*/)
|
||||
{
|
||||
__asm
|
||||
@ -583,7 +765,7 @@ namespace Game
|
||||
mov edi, [esp + 28h]
|
||||
call eax
|
||||
|
||||
mov [esp + 20h], eax
|
||||
mov[esp + 20h], eax
|
||||
popad
|
||||
pop eax
|
||||
|
||||
@ -633,30 +815,6 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
// this cant be MessageBox because windows.h has a define that converts it to MessageBoxW. which is just stupid
|
||||
void ShowMessageBox(std::string message, std::string title)
|
||||
{
|
||||
if (!Game::CL_IsCgameInitialized())
|
||||
{
|
||||
Dvar_SetStringByName("com_errorMessage", message.data());
|
||||
Dvar_SetStringByName("com_errorTitle", title.data());
|
||||
Cbuf_AddText(0, "openmenu error_popmenu_lobby");
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int R_HashString(const char* string)
|
||||
{
|
||||
unsigned int hash = 0;
|
||||
|
||||
while (*string)
|
||||
{
|
||||
hash = (*string | 0x20) ^ (33 * hash);
|
||||
++string;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
__declspec(naked) void R_LoadSunThroughDvars(const char* /*mapname*/, sunflare_t* /*sun*/)
|
||||
{
|
||||
__asm
|
||||
@ -697,7 +855,7 @@ namespace Game
|
||||
|
||||
mov edi, 0
|
||||
mov esi, [esp + 24h]
|
||||
push[esp + 28h]
|
||||
push [esp + 28h]
|
||||
push 0
|
||||
push 0
|
||||
|
||||
@ -711,26 +869,6 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
void SV_KickClientError(client_t* client, std::string reason)
|
||||
{
|
||||
if (client->state < 5)
|
||||
{
|
||||
Components::Network::SendCommand(client->addr, "error", reason);
|
||||
}
|
||||
|
||||
SV_KickClient(client, reason.data());
|
||||
}
|
||||
|
||||
void Scr_iPrintLn(int clientNum, std::string message)
|
||||
{
|
||||
Game::SV_GameSendServerCommand(clientNum, 0, Utils::String::VA("%c \"%s\"", 0x66, message.data()));
|
||||
}
|
||||
|
||||
void Scr_iPrintLnBold(int clientNum, std::string message)
|
||||
{
|
||||
Game::SV_GameSendServerCommand(clientNum, 0, Utils::String::VA("%c \"%s\"", 0x67, message.data()));
|
||||
}
|
||||
|
||||
__declspec(naked) void Scr_NotifyId(unsigned int /*id*/, unsigned __int16 /*stringValue*/, unsigned int /*paramcount*/)
|
||||
{
|
||||
__asm
|
||||
@ -778,37 +916,6 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
int FS_FOpenFileReadCurrentThread(const char* file, int* fh)
|
||||
{
|
||||
if (GetCurrentThreadId() == *reinterpret_cast<DWORD*>(0x1CDE7FC))
|
||||
{
|
||||
return FS_FOpenFileRead(file, fh);
|
||||
}
|
||||
else if (GetCurrentThreadId() == *reinterpret_cast<DWORD*>(0x1CDE814))
|
||||
{
|
||||
return FS_FOpenFileReadDatabase(file, fh);
|
||||
}
|
||||
else
|
||||
{
|
||||
*fh = NULL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void Load_IndexBuffer(void* data, IDirect3DIndexBuffer9** storeHere, int count)
|
||||
{
|
||||
if (Components::Dvar::Var("r_loadForRenderer").get<bool>())
|
||||
{
|
||||
void* buffer = R_AllocStaticIndexBuffer(storeHere, 2 * count);
|
||||
std::memcpy(buffer, data, 2 * count);
|
||||
|
||||
if (storeHere && *storeHere)
|
||||
{
|
||||
(*storeHere)->Unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void Load_VertexBuffer(void* /*data*/, IDirect3DVertexBuffer9** /*where*/, int /*len*/)
|
||||
{
|
||||
__asm
|
||||
@ -829,91 +936,40 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
char* Com_GetParseThreadInfo()
|
||||
{
|
||||
if (Game::Sys_IsMainThread())
|
||||
{
|
||||
return reinterpret_cast<char*>(0x6466628);
|
||||
}
|
||||
else if (Game::Sys_IsRenderThread())
|
||||
{
|
||||
return reinterpret_cast<char*>(0x646AC34);
|
||||
}
|
||||
else if (Game::Sys_IsServerThread())
|
||||
{
|
||||
return reinterpret_cast<char*>(0x646F240);
|
||||
}
|
||||
else if(Game::Sys_IsDatabaseThread())
|
||||
{
|
||||
return reinterpret_cast<char*>(0x647384C);
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Com_SetParseNegativeNumbers(int parse)
|
||||
{
|
||||
char* g_parse = Com_GetParseThreadInfo();
|
||||
|
||||
if (g_parse)
|
||||
{
|
||||
g_parse[1056 * *(reinterpret_cast<DWORD*>(g_parse) + 4224) + 1032] = parse != 0;
|
||||
}
|
||||
}
|
||||
|
||||
int CL_GetMaxXP()
|
||||
{
|
||||
StringTable* rankTable = DB_FindXAssetHeader(ASSET_TYPE_STRINGTABLE, "mp/rankTable.csv").stringTable;
|
||||
const char* maxrank = StringTable_Lookup(rankTable, 0, "maxrank", 1);
|
||||
return atoi(StringTable_Lookup(rankTable, 0, maxrank, 7));
|
||||
}
|
||||
|
||||
__declspec(naked) void Image_Setup(GfxImage* /*image*/, unsigned int /*width*/, unsigned int /*height*/, unsigned int /*depth*/, unsigned int /*flags*/, int /*format*/)
|
||||
__declspec(naked) void Image_Setup(GfxImage* /*image*/, unsigned int /*width*/, unsigned int /*height*/, unsigned int /*depth*/, unsigned int /*flags*/, _D3DFORMAT /*format*/)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
pushad
|
||||
xor edi, edi
|
||||
|
||||
mov eax, [esp + 24h] // image
|
||||
mov di, word ptr [esp + 28h] // width
|
||||
push [esp + 38h] // format
|
||||
push [esp + 38h] // flags
|
||||
push 0
|
||||
push [esp + 3Ch] // depth
|
||||
push [esp + 3Ch] // height
|
||||
mov eax, [esp + 24h] // image
|
||||
mov edi, [esp + 28h] // width
|
||||
push [esp + 38h] // format
|
||||
push [esp + 38h] // flags
|
||||
push [esp + 38h] // depth
|
||||
push [esp + 38h] // height
|
||||
|
||||
mov ecx, 54AF50h
|
||||
call ecx
|
||||
|
||||
add esp, 14h
|
||||
add esp, 10h
|
||||
|
||||
popad
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
void SortWorldSurfaces(GfxWorld* world)
|
||||
__declspec(naked) void Menu_FreeItemMemory(itemDef_t* /*item*/)
|
||||
{
|
||||
DWORD* specular1 = reinterpret_cast<DWORD*>(0x69F105C);
|
||||
DWORD* specular2 = reinterpret_cast<DWORD*>(0x69F92D4);
|
||||
DWORD saveSpecular1 = *specular1;
|
||||
DWORD saveSpecular2 = *specular2;
|
||||
|
||||
GfxWorld** gameWorld = reinterpret_cast<GfxWorld**>(0x66DEE94);
|
||||
GfxWorld* saveWorld = *gameWorld;
|
||||
|
||||
*specular1 = 1;
|
||||
*specular2 = 1;
|
||||
*gameWorld = world;
|
||||
|
||||
R_SortWorldSurfaces();
|
||||
|
||||
*gameWorld = saveWorld;
|
||||
*specular1 = saveSpecular1;
|
||||
*specular2 = saveSpecular2;
|
||||
__asm
|
||||
{
|
||||
pushad
|
||||
mov edi, [esp + 24h]
|
||||
mov eax, 63D880h
|
||||
call eax
|
||||
popad
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void R_AddDebugLine(float* /*color*/, float* /*v1*/, float* /*v2*/)
|
||||
@ -975,61 +1031,5 @@ namespace Game
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
void R_AddDebugBounds(float* color, Bounds* b)
|
||||
{
|
||||
Game::vec3_t v1, v2, v3, v4, v5, v6, v7, v8;
|
||||
float* center = b->midPoint;
|
||||
float* halfSize = b->halfSize;
|
||||
|
||||
v1[0] = center[0] - halfSize[0];
|
||||
v1[1] = center[1] - halfSize[1];
|
||||
v1[2] = center[2] - halfSize[2];
|
||||
|
||||
v2[0] = center[0] + halfSize[0];
|
||||
v2[1] = center[1] - halfSize[1];
|
||||
v2[2] = center[2] - halfSize[2];
|
||||
|
||||
v3[0] = center[0] - halfSize[0];
|
||||
v3[1] = center[1] + halfSize[1];
|
||||
v3[2] = center[2] - halfSize[2];
|
||||
|
||||
v4[0] = center[0] + halfSize[0];
|
||||
v4[1] = center[1] + halfSize[1];
|
||||
v4[2] = center[2] - halfSize[2];
|
||||
|
||||
v5[0] = center[0] - halfSize[0];
|
||||
v5[1] = center[1] - halfSize[1];
|
||||
v5[2] = center[2] + halfSize[2];
|
||||
|
||||
v6[0] = center[0] + halfSize[0];
|
||||
v6[1] = center[1] - halfSize[1];
|
||||
v6[2] = center[2] + halfSize[2];
|
||||
|
||||
v7[0] = center[0] - halfSize[0];
|
||||
v7[1] = center[1] + halfSize[1];
|
||||
v7[2] = center[2] + halfSize[2];
|
||||
|
||||
v8[0] = center[0] + halfSize[0];
|
||||
v8[1] = center[1] + halfSize[1];
|
||||
v8[2] = center[2] + halfSize[2];
|
||||
|
||||
// bottom
|
||||
Game::R_AddDebugLine(color, v1, v2);
|
||||
Game::R_AddDebugLine(color, v2, v4);
|
||||
Game::R_AddDebugLine(color, v4, v3);
|
||||
Game::R_AddDebugLine(color, v3, v1);
|
||||
|
||||
// top
|
||||
Game::R_AddDebugLine(color, v5, v6);
|
||||
Game::R_AddDebugLine(color, v6, v8);
|
||||
Game::R_AddDebugLine(color, v8, v7);
|
||||
Game::R_AddDebugLine(color, v7, v5);
|
||||
|
||||
// verticals
|
||||
Game::R_AddDebugLine(color, v1, v5);
|
||||
Game::R_AddDebugLine(color, v2, v6);
|
||||
Game::R_AddDebugLine(color, v3, v7);
|
||||
Game::R_AddDebugLine(color, v4, v8);
|
||||
}
|
||||
#pragma optimize("", on)
|
||||
}
|
||||
|
@ -845,7 +845,7 @@ namespace Game
|
||||
|
||||
int CL_GetMaxXP();
|
||||
|
||||
void Image_Setup(GfxImage* image, unsigned int width, unsigned int height, unsigned int depth, unsigned int flags, int format);
|
||||
void Image_Setup(GfxImage* image, unsigned int width, unsigned int height, unsigned int depth, unsigned int flags, _D3DFORMAT format);
|
||||
|
||||
void SortWorldSurfaces(GfxWorld* world);
|
||||
void R_AddDebugLine(float* color, float* v1, float* v2);
|
||||
|
Reference in New Issue
Block a user