[Maps] Load raw suns

This commit is contained in:
momo5502 2016-12-01 21:00:09 +01:00
parent 2c0f582427
commit 38aba91cc9
4 changed files with 53 additions and 0 deletions

View File

@ -183,6 +183,18 @@ namespace Components
}
}
void Maps::LoadRawSun()
{
Game::R_FlushSun();
Game::GfxWorld* world = *reinterpret_cast<Game::GfxWorld**>(0x66DEE94);
if (FileSystem::File(fmt::sprintf("sun/%s.sun", world->baseName)).exists())
{
Game::R_LoadSunThroughDvars(world->baseName, &world->sun);
}
}
void Maps::GetBSPName(char* buffer, size_t size, const char* format, const char* mapname)
{
if (!Utils::String::StartsWith(mapname, "mp_") && !Utils::String::StartsWith(mapname, "zm_"))
@ -545,6 +557,9 @@ namespace Components
// WorldData pointer replacement
Utils::Hook(0x4D90B6, Maps::GetWorldDataStub, HOOK_CALL).install()->quick();
// Allow loading raw suns
Utils::Hook(0x51B46A, Maps::LoadRawSun, HOOK_CALL).install()->quick();
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_GAME_MAP_SP, 1);
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_IMAGE, 7168);
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_LOADED_SOUND, 2700);

View File

@ -45,6 +45,8 @@ namespace Components
static Game::GameMap_Data* GetWorldData();
static void GetWorldDataStub();
static void LoadRawSun();
static void AddDlc(DLC dlc);
static void UpdateDlcStatus();

View File

@ -175,6 +175,7 @@ namespace Game
R_LoadGraphicsAssets_t R_LoadGraphicsAssets = (R_LoadGraphicsAssets_t)0x506AC0;
R_TextWidth_t R_TextWidth = (R_TextWidth_t)0x5056C0;
R_TextHeight_t R_TextHeight = (R_TextHeight_t)0x505770;
R_FlushSun_t R_FlushSun = (R_FlushSun_t)0x53FB50;
Scr_LoadGameType_t Scr_LoadGameType = (Scr_LoadGameType_t)0x4D9520;
@ -461,6 +462,36 @@ namespace Game
return hash;
}
void R_LoadSunThroughDvars(const char* mapname, sunflare_t* sun)
{
__asm
{
push ecx
push sun
mov eax, mapname
mov ecx, 53F990h
call ecx
add esp, 4h
pop ecx
}
}
void R_SetSunFromDvars(sunflare_t* sun)
{
__asm
{
push esi
mov esi, sun
mov eax, 53F6D0h
call ecx
pop esi
}
}
void SV_KickClient(client_t* client, const char* reason)
{
__asm

View File

@ -425,6 +425,9 @@ namespace Game
typedef int(__cdecl * R_TextHeight_t)(Font* font);
extern R_TextHeight_t R_TextHeight;
typedef void(__cdecl * R_FlushSun_t)();
extern R_FlushSun_t R_FlushSun;
typedef void(__cdecl * Scr_ShutdownAllocNode_t)();
extern Scr_ShutdownAllocNode_t Scr_ShutdownAllocNode;
@ -641,6 +644,8 @@ namespace Game
void MessageBox(std::string message, std::string title);
unsigned int R_HashString(const char* string);
void R_LoadSunThroughDvars(const char* mapname, sunflare_t* sun);
void R_SetSunFromDvars(sunflare_t* sun);
void SV_KickClient(client_t* client, const char* reason);
void SV_KickClientError(client_t* client, std::string reason);