Merge branch 'feature/steam-avatars' into 'develop'

[Merge] feature/steam-avatars -> develop
This commit is contained in:
momo5502 2017-06-05 14:42:48 +02:00
commit 3f3fe2a3d1
9 changed files with 560 additions and 287 deletions

View File

@ -195,7 +195,7 @@ namespace Components
__asm __asm
{ {
push ebx push ebx
push[esp + 8h] // Index push [esp + 8h] // Index
push esi // Color ref push esi // Color ref
call Colors::LookupColor call Colors::LookupColor
add esp, 8h add esp, 8h

View File

@ -115,9 +115,13 @@ namespace Components
Friends::SortList(); Friends::SortList();
int notify = Dvar::Var("cl_notifyFriendState").get<int>(); int notify = Dvar::Var("cl_notifyFriendState").get<int>();
if(gotOnline && (notify == -1 || (notify == 1 && !Game::CL_IsCgameInitialized())) && !Dvar::Var("ui_streamFriendly").get<bool>()) if (gotOnline && (notify == -1 || (notify == 1 && !Game::CL_IsCgameInitialized())) && !Dvar::Var("ui_streamFriendly").get<bool>())
{ {
Toast::Show("cardicon_joystick", entry->name, "is playing IW4x", 3000); Game::Material* material = Friends::CreateAvatar(user);
Toast::Show(material, entry->name, "is playing IW4x", 3000, [material]()
{
Materials::Delete(material, true);
});
} }
} }
@ -530,6 +534,40 @@ namespace Components
Utils::IO::WriteFile("players/friends.dat", list.SerializeAsString()); Utils::IO::WriteFile("players/friends.dat", list.SerializeAsString());
} }
Game::Material* Friends::CreateAvatar(SteamID user)
{
if (!Steam::Proxy::SteamUtils || !Steam::Proxy::SteamFriends) return nullptr;
int index = Steam::Proxy::SteamFriends->GetMediumFriendAvatar(user);
unsigned int width, height;
Steam::Proxy::SteamUtils->GetImageSize(index, &width, &height);
Game::GfxImage* image = Materials::CreateImage(Utils::String::VA("texture_%llX", user.bits), width, height, 1, 0x1000003, D3DFMT_A8R8G8B8);
D3DLOCKED_RECT lockedRect;
image->map->LockRect(0, &lockedRect, nullptr, 0);
unsigned char* buffer = static_cast<unsigned char*>(lockedRect.pBits);
Steam::Proxy::SteamUtils->GetImageRGBA(index, buffer, width * height * 4);
// Swap red and blue channel
for (unsigned int i = 0; i < width * height * 4; i += 4)
{
std::swap(buffer[i + 0], buffer[i + 2]);
}
// Steam rounds the corners and somehow fuck up the pixels there
buffer[3] = 0; // top-left
buffer[(width - 1) * 4 + 3] = 0; // top-right
buffer[((height - 1) * width * 4) + 3] = 0; // bottom-left
buffer[((height - 1) * width * 4) + (width - 1) * 4 + 3] = 0; // bottom-right
image->map->UnlockRect(0);
return Materials::Create(Utils::String::VA("avatar_%llX", user.bits), image);
}
Friends::Friends() Friends::Friends()
{ {
Friends::LoggedOn = false; Friends::LoggedOn = false;
@ -687,6 +725,56 @@ namespace Components
Friends::UpdateFriends(); Friends::UpdateFriends();
}); });
Command::Add("testavatar", [](Command::Params*)
{
std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
for (auto user : Friends::FriendsList)
{
Logger::Print("Fetching %s...\n", user.name.data());
int index = Steam::Proxy::SteamFriends->GetMediumFriendAvatar(user.userId);
if (!Steam::Proxy::SteamUtils) return;
static Game::GfxImage image = { nullptr };
if (image.map) Game::Image_Release(&image);
static Game::Material* material = nullptr;
unsigned int width, height;
Steam::Proxy::SteamUtils->GetImageSize(index, &width, &height);
Game::Image_Setup(&image, static_cast<short>(width), static_cast<short>(height), 1, 0x1000003, D3DFMT_A8R8G8B8);
Logger::Print("%dx%d\n", width, height);
D3DLOCKED_RECT lockedRect;
image.map->LockRect(0, &lockedRect, nullptr, 0);
unsigned char* buffer = static_cast<unsigned char*>(lockedRect.pBits);
Steam::Proxy::SteamUtils->GetImageRGBA(index, buffer, width * height * 4);
// Swap red and blue channel
for (unsigned int i = 0; i < width * height * 4; i += 4)
{
std::swap(buffer[i + 0], buffer[i + 2]);
}
image.map->UnlockRect(0);
if (!material)
{
material = Materials::Create("avatar", &image);
Scheduler::OnFrame([]()
{
float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
Game::CL_DrawStretchPicPhysical(10.0f, 10.0f, 100.0f, 100.0f, 0, 0, 1.0f, 1.0f, color, material);
});
}
break;
}
});
} }
Friends::~Friends() Friends::~Friends()

View File

@ -32,6 +32,14 @@ namespace Components
}; };
#pragma pack(pop) #pragma pack(pop)
struct AvatarImageLoaded
{
SteamID m_steamID; // steamid the avatar has been loaded for
int m_iImage; // the image index of the now loaded image
int m_iWide; // width of the loaded image
int m_iTall; // height of the loaded image
};
struct PersonaStateChange struct PersonaStateChange
{ {
SteamID m_ulSteamID; // steamID of the friend who changed SteamID m_ulSteamID; // steamID of the friend who changed
@ -87,5 +95,7 @@ namespace Components
static void SetRawPresence(const char* key, const char* value); static void SetRawPresence(const char* key, const char* value);
static std::vector<int> GetAppIdList(); static std::vector<int> GetAppIdList();
static Game::Material* CreateAvatar(SteamID user);
}; };
} }

View File

@ -5,6 +5,121 @@ namespace Components
int Materials::ImageNameLength; int Materials::ImageNameLength;
Utils::Hook Materials::ImageVersionCheckHook; Utils::Hook Materials::ImageVersionCheckHook;
std::vector<Game::GfxImage*> Materials::ImageTable;
std::vector<Game::Material*> Materials::MaterialTable;
Game::Material* Materials::Create(std::string name, Game::GfxImage* image)
{
Game::Material* material = Utils::Memory::GetAllocator()->allocate<Game::Material>();
Game::MaterialTextureDef* texture = Utils::Memory::GetAllocator()->allocate<Game::MaterialTextureDef>();
material->textureCount = 1;
material->textureTable = texture;
material->name = Utils::Memory::GetAllocator()->duplicateString(name);
material->sortKey = 0x22;
material->textureAtlasColumnCount = 1;
material->textureAtlasRowCount = 1;
for(int i = 0; i < 48; ++i)
{
if(i != 4) material->stateBitsEntry[i] = -1;
}
material->stateFlags = 3;
material->cameraRegion = 4;
material->techniqueSet = Game::DB_FindXAssetHeader(Game::ASSET_TYPE_TECHNIQUE_SET, "2d").techniqueSet;
material->textureTable->nameHash = Game::R_HashString("colorMap");
material->textureTable->nameStart = 'c';
material->textureTable->nameEnd = 'p';
material->textureTable->sampleState = -30;
material->textureTable->info.image = image;
Game::Material* cursor = Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "ui_cursor").material;
if(cursor)
{
material->stateBitTable = cursor->stateBitTable;
material->stateBitsCount = cursor->stateBitsCount;
}
Materials::MaterialTable.push_back(material);
return material;
}
void Materials::Delete(Game::Material* material, bool deleteImage)
{
if (!material) return;
if (deleteImage)
{
for (char i = 0; i < material->textureCount; ++i)
{
Materials::DeleteImage(material->textureTable[i].info.image);
}
}
Utils::Memory::GetAllocator()->free(material->textureTable);
Utils::Memory::GetAllocator()->free(material->name);
Utils::Memory::GetAllocator()->free(material);
auto mat = std::find(Materials::MaterialTable.begin(), Materials::MaterialTable.end(), material);
if (mat != Materials::MaterialTable.end())
{
Materials::MaterialTable.erase(mat);
}
}
Game::GfxImage* Materials::CreateImage(std::string name, unsigned int width, unsigned int height, unsigned int depth, unsigned int flags, _D3DFORMAT format)
{
Game::GfxImage* image = Utils::Memory::GetAllocator()->allocate<Game::GfxImage>();
image->name = Utils::Memory::GetAllocator()->duplicateString(name);
Game::Image_Setup(image, width, height, depth, flags, format);
Materials::ImageTable.push_back(image);
return image;
}
void Materials::DeleteImage(Game::GfxImage* image)
{
if (!image) return;
Game::Image_Release(image);
Utils::Memory::GetAllocator()->free(image->name);
Utils::Memory::GetAllocator()->free(image);
auto img = std::find(Materials::ImageTable.begin(), Materials::ImageTable.end(), image);
if (img != Materials::ImageTable.end())
{
Materials::ImageTable.erase(img);
}
}
void Materials::DeleteAll()
{
std::vector<Game::Material*> materials;
Utils::Merge(&materials, Materials::MaterialTable);
Materials::MaterialTable.clear();
for(auto& material : materials)
{
Materials::Delete(material);
}
std::vector<Game::GfxImage*> images;
Utils::Merge(&images, Materials::ImageTable);
Materials::ImageTable.clear();
for (auto& image : images)
{
Materials::DeleteImage(image);
}
}
__declspec(naked) void Materials::ImageVersionCheck() __declspec(naked) void Materials::ImageVersionCheck()
{ {
__asm __asm
@ -187,17 +302,28 @@ namespace Components
} }
#endif #endif
// Scheduler::OnFrame([] () Renderer::OnDeviceRecoveryBegin([]()
// { {
// Game::Font* font = Game::R_RegisterFont("fonts/normalFont"); for (auto& image : Materials::ImageTable)
// float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; {
// Game::Image_Release(image);
// Game::R_AddCmdDrawText("test^==preview_mp_rustzob", 0x7FFFFFFF, font, 500.0f, 150.0f, 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_SHADOWED); image->map = nullptr;
// }, true); }
});
Renderer::OnDeviceRecoveryEnd([]()
{
for (auto& image : Materials::ImageTable)
{
Utils::Hook::Call<void(void*)>(0x51F7B0)(image);
}
});
} }
Materials::~Materials() Materials::~Materials()
{ {
Materials::DeleteAll();
Materials::ImageVersionCheckHook.uninstall(); Materials::ImageVersionCheckHook.uninstall();
} }
} }

View File

@ -10,7 +10,15 @@ namespace Components
static int FormatImagePath(char* buffer, size_t size, int, int, const char* image); static int FormatImagePath(char* buffer, size_t size, int, int, const char* image);
static Game::Material* Create(std::string name, Game::GfxImage* image);
static void Delete(Game::Material* material, bool deleteImage = false);
static Game::GfxImage* CreateImage(std::string name, unsigned int width, unsigned int height, unsigned int depth, unsigned int flags, _D3DFORMAT format);
static void DeleteImage(Game::GfxImage* image);
private: private:
static std::vector<Game::GfxImage*> ImageTable;
static std::vector<Game::Material*> MaterialTable;
static int ImageNameLength; static int ImageNameLength;
static Utils::Hook ImageVersionCheckHook; static Utils::Hook ImageVersionCheckHook;
@ -29,5 +37,7 @@ namespace Components
#endif #endif
static int MaterialComparePrint(Game::Material* m1, Game::Material* m2); static int MaterialComparePrint(Game::Material* m1, Game::Material* m2);
static void DeleteAll();
}; };
} }

View File

@ -7,10 +7,16 @@ namespace Components
Toast::WinToastHandler* Toast::ToastHandler = nullptr; Toast::WinToastHandler* Toast::ToastHandler = nullptr;
void Toast::Show(std::string image, std::string title, std::string description, int length) void Toast::Show(std::string image, std::string title, std::string description, int length, Utils::Slot<void()> callback)
{
Game::Material* material = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, image.data()).material;
return Show(material, title, description, length, callback);
}
void Toast::Show(Game::Material* material, std::string title, std::string description, int length, Utils::Slot<void()> callback)
{ {
Toast::Mutex.lock(); Toast::Mutex.lock();
Toast::Queue.push({ image, Utils::String::ToUpper(title), description, length, 0 }); Toast::Queue.push({ material, Utils::String::ToUpper(title), description, length, 0, callback });
Toast::Mutex.unlock(); Toast::Mutex.unlock();
} }
@ -54,7 +60,6 @@ namespace Components
float descSize = 0.9f; float descSize = 0.9f;
Game::Material* white = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, "white").material; Game::Material* white = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, "white").material;
Game::Material* image = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, toast->image.data()).material;
Game::Font* font = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_FONT, "fonts/objectiveFont").font; Game::Font* font = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_FONT, "fonts/objectiveFont").font;
Game::Font* descfont = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_FONT, "fonts/normalFont").font; Game::Font* descfont = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_FONT, "fonts/normalFont").font;
Game::vec4_t wColor = { 1.0f, 1.0f, 1.0f, 1.0f }; Game::vec4_t wColor = { 1.0f, 1.0f, 1.0f, 1.0f };
@ -111,7 +116,10 @@ namespace Components
Game::CL_DrawStretchPicPhysical(static_cast<float>(width / 2 - bWidth / 2), static_cast<float>(height + bHeight / 2), bWidth * 1.0f, border * 1.0f, 0, 0, 1.0f, 1.0f, borderColor, white); // Bottom Game::CL_DrawStretchPicPhysical(static_cast<float>(width / 2 - bWidth / 2), static_cast<float>(height + bHeight / 2), bWidth * 1.0f, border * 1.0f, 0, 0, 1.0f, 1.0f, borderColor, white); // Bottom
// Image // Image
Game::CL_DrawStretchPicPhysical(static_cast<float>(width / 2 - bWidth / 2 + iOffsetLeft), static_cast<float>(height - bHeight / 2 + iOffset), imgDim * 1.0f, imgDim * 1.0f, 0, 0, 1.0f, 1.0f, wColor, image); if (toast->image && toast->image->textureTable && toast->image->textureCount && toast->image->textureTable->info.image && toast->image->textureTable->info.image->map)
{
Game::CL_DrawStretchPicPhysical(static_cast<float>(width / 2 - bWidth / 2 + iOffsetLeft), static_cast<float>(height - bHeight / 2 + iOffset), imgDim * 1.0f, imgDim * 1.0f, 0, 0, 1.0f, 1.0f, wColor, toast->image);
}
// Text // Text
float leftText = width / 2 - bWidth / 2 - cornerSize + iOffsetLeft * 2 + imgDim; float leftText = width / 2 - bWidth / 2 - cornerSize + iOffsetLeft * 2 + imgDim;
@ -136,6 +144,7 @@ namespace Components
if ((toast->start + toast->length) < Game::Sys_Milliseconds()) if ((toast->start + toast->length) < Game::Sys_Milliseconds())
{ {
if(toast->callback) toast->callback();
Toast::Queue.pop(); Toast::Queue.pop();
} }
else else

View File

@ -11,7 +11,8 @@ namespace Components
typedef WinToastLib::WinToastTemplate Template; typedef WinToastLib::WinToastTemplate Template;
static void Show(std::string image, std::string title, std::string description, int length); static void Show(std::string image, std::string title, std::string description, int length, Utils::Slot<void()> callback = Utils::Slot<void()>());
static void Show(Game::Material* material, std::string title, std::string description, int length, Utils::Slot<void()> callback = Utils::Slot<void()>());
static bool ShowNative(const WinToastLib::WinToastTemplate& toast); static bool ShowNative(const WinToastLib::WinToastTemplate& toast);
static std::string GetIcon(); static std::string GetIcon();
@ -20,14 +21,16 @@ namespace Components
class UIToast class UIToast
{ {
public: public:
std::string image; Game::Material* image;
std::string title; std::string title;
std::string desc; std::string desc;
int length; int length;
int start; int start;
Utils::Slot<void()> callback;
}; };
class WinToastHandler: public WinToastLib::IWinToastHandler { class WinToastHandler: public WinToastLib::IWinToastHandler
{
public: public:
void toastActivated() const override {}; void toastActivated() const override {};
void toastDismissed(WinToastLib::IWinToastHandler::WinToastDismissalReason /*state*/) const override {}; void toastDismissed(WinToastLib::IWinToastHandler::WinToastDismissalReason /*state*/) const override {};

View File

@ -394,19 +394,6 @@ namespace Game
return poolEntry; 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) const char* TableLookup(StringTable* stringtable, int row, int column)
{ {
if (!stringtable || !stringtable->values || row >= stringtable->rowCount || column >= stringtable->columnCount) return ""; if (!stringtable || !stringtable->values || row >= stringtable->rowCount || column >= stringtable->columnCount) return "";
@ -454,24 +441,6 @@ namespace Game
return gameType; 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) const char *DB_GetXAssetName(XAsset *asset)
{ {
if (!asset) return ""; if (!asset) return "";
@ -572,67 +541,6 @@ namespace Game
if(lock) InterlockedDecrement(lockVar); if(lock) InterlockedDecrement(lockVar);
} }
__declspec(naked) XAssetHeader DB_FindXAssetDefaultHeaderInternal(XAssetType /*type*/)
{
__asm
{
push eax
pushad
mov eax, 5BB210h
mov edi, [esp + 28h]
call eax
mov [esp + 20h], eax
popad
pop eax
retn
}
}
__declspec(naked) XAssetEntry* DB_FindXAssetEntry(XAssetType /*type*/, const char* /*name*/)
{
__asm
{
push eax
pushad
mov edi, [esp + 2Ch] // name
push edi
mov edi, [esp + 2Ch] // type
mov eax, 5BB1B0h
call eax
add esp, 4h
mov[esp + 20h], eax
popad
pop eax
retn
}
}
__declspec(naked) void FS_AddLocalizedGameDirectory(const char* /*path*/, const char* /*dir*/)
{
__asm
{
pushad
mov ebx, [esp + 24h]
mov eax, [esp + 28h]
mov ecx, 642EF0h
call ecx
popad
retn
}
}
// this cant be MessageBox because windows.h has a define that converts it to MessageBoxW. which is just stupid // 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) void ShowMessageBox(std::string message, std::string title)
{ {
@ -657,60 +565,6 @@ namespace Game
return hash; return hash;
} }
__declspec(naked) void R_LoadSunThroughDvars(const char* /*mapname*/, sunflare_t* /*sun*/)
{
__asm
{
pushad
push [esp + 28h]
mov eax, [esp + 28h]
mov ecx, 53F990h
call ecx
add esp, 4h
popad
retn
}
}
__declspec(naked) void R_SetSunFromDvars(sunflare_t* /*sun*/)
{
__asm
{
pushad
mov esi, [esp + 24h]
mov eax, 53F6D0h
call eax
popad
retn
}
}
__declspec(naked) void SV_KickClient(client_t* /*client*/, const char* /*reason*/)
{
__asm
{
pushad
mov edi, 0
mov esi, [esp + 24h]
push[esp + 28h]
push 0
push 0
mov eax, 6249A0h
call eax
add esp, 0Ch
popad
retn
}
}
void SV_KickClientError(client_t* client, std::string reason) void SV_KickClientError(client_t* client, std::string reason)
{ {
if (client->state < 5) if (client->state < 5)
@ -731,53 +585,6 @@ namespace Game
Game::SV_GameSendServerCommand(clientNum, 0, Utils::String::VA("%c \"%s\"", 0x67, message.data())); 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
{
pushad
mov eax, [esp + 2Ch] // paramcount
push [esp + 28h] // stringValue
push [esp + 28h] // id
mov edx, 61E670h // Scr_NotifyId
call edx
add esp, 8h
popad
retn
}
}
__declspec(naked) void IN_KeyUp(kbutton_t* /*button*/)
{
__asm
{
pushad
mov esi, [esp + 24h]
mov eax, 5A5580h
call eax
popad
retn
}
}
__declspec(naked) void IN_KeyDown(kbutton_t* /*button*/)
{
__asm
{
pushad
mov esi, [esp + 24h]
mov eax, 5A54E0h
call eax
popad
retn
}
}
int FS_FOpenFileReadCurrentThread(const char* file, int* fh) int FS_FOpenFileReadCurrentThread(const char* file, int* fh)
{ {
if (GetCurrentThreadId() == *reinterpret_cast<DWORD*>(0x1CDE7FC)) if (GetCurrentThreadId() == *reinterpret_cast<DWORD*>(0x1CDE7FC))
@ -809,26 +616,6 @@ namespace Game
} }
} }
__declspec(naked) void Load_VertexBuffer(void* /*data*/, IDirect3DVertexBuffer9** /*where*/, int /*len*/)
{
__asm
{
pushad
mov eax, [esp + 2Ch]
mov edi, [esp + 28h]
push [esp + 24h]
mov ebx, 5112C0h
call ebx
add esp, 4
popad
retn
}
}
char* Com_GetParseThreadInfo() char* Com_GetParseThreadInfo()
{ {
if (Game::Sys_IsMainThread()) if (Game::Sys_IsMainThread())
@ -891,6 +678,300 @@ namespace Game
*specular2 = saveSpecular2; *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
{
push eax
pushad
mov eax, 5BB210h
mov edi, [esp + 28h]
call eax
mov[esp + 20h], eax
popad
pop eax
retn
}
}
__declspec(naked) XAssetEntry* DB_FindXAssetEntry(XAssetType /*type*/, const char* /*name*/)
{
__asm
{
push eax
pushad
mov edi, [esp + 2Ch] // name
push edi
mov edi, [esp + 2Ch] // type
mov eax, 5BB1B0h
call eax
add esp, 4h
mov[esp + 20h], eax
popad
pop eax
retn
}
}
__declspec(naked) void FS_AddLocalizedGameDirectory(const char* /*path*/, const char* /*dir*/)
{
__asm
{
pushad
mov ebx, [esp + 24h]
mov eax, [esp + 28h]
mov ecx, 642EF0h
call ecx
popad
retn
}
}
__declspec(naked) void R_LoadSunThroughDvars(const char* /*mapname*/, sunflare_t* /*sun*/)
{
__asm
{
pushad
push [esp + 28h]
mov eax, [esp + 28h]
mov ecx, 53F990h
call ecx
add esp, 4h
popad
retn
}
}
__declspec(naked) void R_SetSunFromDvars(sunflare_t* /*sun*/)
{
__asm
{
pushad
mov esi, [esp + 24h]
mov eax, 53F6D0h
call eax
popad
retn
}
}
__declspec(naked) void SV_KickClient(client_t* /*client*/, const char* /*reason*/)
{
__asm
{
pushad
mov edi, 0
mov esi, [esp + 24h]
push [esp + 28h]
push 0
push 0
mov eax, 6249A0h
call eax
add esp, 0Ch
popad
retn
}
}
__declspec(naked) void Scr_NotifyId(unsigned int /*id*/, unsigned __int16 /*stringValue*/, unsigned int /*paramcount*/)
{
__asm
{
pushad
mov eax, [esp + 2Ch] // paramcount
push [esp + 28h] // stringValue
push [esp + 28h] // id
mov edx, 61E670h // Scr_NotifyId
call edx
add esp, 8h
popad
retn
}
}
__declspec(naked) void IN_KeyUp(kbutton_t* /*button*/)
{
__asm
{
pushad
mov esi, [esp + 24h]
mov eax, 5A5580h
call eax
popad
retn
}
}
__declspec(naked) void IN_KeyDown(kbutton_t* /*button*/)
{
__asm
{
pushad
mov esi, [esp + 24h]
mov eax, 5A54E0h
call eax
popad
retn
}
}
__declspec(naked) void Load_VertexBuffer(void* /*data*/, IDirect3DVertexBuffer9** /*where*/, int /*len*/)
{
__asm
{
pushad
mov eax, [esp + 2Ch]
mov edi, [esp + 28h]
push [esp + 24h]
mov ebx, 5112C0h
call ebx
add esp, 4
popad
retn
}
}
__declspec(naked) void Image_Setup(GfxImage* /*image*/, unsigned int /*width*/, unsigned int /*height*/, unsigned int /*depth*/, unsigned int /*flags*/, _D3DFORMAT /*format*/)
{
__asm
{
pushad
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, 10h
popad
retn
}
}
__declspec(naked) void Menu_FreeItemMemory(itemDef_t* /*item*/)
{
__asm
{
pushad
mov edi, [esp + 24h]
mov eax, 63D880h
call eax
popad
retn
}
}
__declspec(naked) void R_AddDebugLine(float* /*color*/, float* /*v1*/, float* /*v2*/) __declspec(naked) void R_AddDebugLine(float* /*color*/, float* /*v1*/, float* /*v2*/)
{ {
__asm __asm
@ -950,61 +1031,5 @@ namespace Game
retn retn
} }
} }
#pragma optimize("", on)
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);
}
} }

View File

@ -845,6 +845,8 @@ namespace Game
int CL_GetMaxXP(); int CL_GetMaxXP();
void Image_Setup(GfxImage* image, unsigned int width, unsigned int height, unsigned int depth, unsigned int flags, _D3DFORMAT format);
void SortWorldSurfaces(GfxWorld* world); void SortWorldSurfaces(GfxWorld* world);
void R_AddDebugLine(float* color, float* v1, float* v2); void R_AddDebugLine(float* color, float* v1, float* v2);
void R_AddDebugString(float *color, float *pos, float scale, const char *str); void R_AddDebugString(float *color, float *pos, float scale, const char *str);