[Maps] Make sure techsets are clean when sorting materials

This commit is contained in:
momo5502 2017-05-28 18:13:48 +02:00
parent 345c8e5a98
commit df2dd13b1d
6 changed files with 19 additions and 38 deletions

View File

@ -7,7 +7,7 @@ namespace Assets
void IFxEffectDef::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
{
if (!header->data) this->loadEfx(header, name, builder); // Check if we have an editor fx
//if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one
if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one
if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game
}

View File

@ -848,29 +848,9 @@ namespace Components
}
}
int Maps::DatabaseReadyDelayed()
{
static bool ready = false;
static Utils::Time::Interval interval;
if(Game::Sys_IsDatabaseReady())
int Maps::DatabaseAndTechsetsReady()
{
if(!ready)
{
ready = true;
interval.update();
}
else if(interval.elapsed(2s))
{
return 1;
}
}
else
{
ready = false;
}
return 0;
return (Game::Sys_IsDatabaseReady() && !*reinterpret_cast<bool*>(0x69F9AFD)); // Make sure techsets are not dirty
}
Maps::Maps()
@ -956,8 +936,8 @@ namespace Components
// Disable distortion on custom maps
Utils::Hook(0x50AA47, Maps::SetDistortionStub, HOOK_CALL).install()->quick();
// Delay material sorting
Utils::Hook(0x50AAE6, Maps::DatabaseReadyDelayed, HOOK_CALL).install()->quick();
// Only sort materials when techsets are clean
Utils::Hook(0x50AAE6, Maps::DatabaseAndTechsetsReady, HOOK_CALL).install()->quick();
// Intercept map loading for usermap initialization
Utils::Hook(0x6245E3, Maps::SpawnServerStub, HOOK_CALL).install()->quick();

View File

@ -123,7 +123,7 @@ namespace Components
static Game::dvar_t* GetDistortionDvar();
static void SetDistortionStub();
static int DatabaseReadyDelayed();
static int DatabaseAndTechsetsReady();
void reallocateEntryPool();
};

View File

@ -126,6 +126,12 @@ namespace Components
return _snprintf_s(buffer, size, size, "images/%s.iwi", image);
}
int Materials::MaterialComparePrint(Game::Material* m1, Game::Material* m2)
{
//__debugbreak();
return Utils::Hook::Call<int(Game::Material*, Game::Material*)>(0x5235B0)(m1, m2);
}
#ifdef DEBUG
void Materials::DumpImageCfg(int, const char*, const char* material)
{
@ -142,12 +148,6 @@ namespace Components
}
}
int Materials::MaterialComparePrint(Game::Material* m1, Game::Material* m2)
{
//__debugbreak();
return Utils::Hook::Call<int(Game::Material*, Game::Material*)>(0x5235B0)(m1, m2);
}
#endif
Materials::Materials()
@ -169,6 +169,9 @@ namespace Components
// Resolve preview images to loadscreens
Utils::Hook(0x53AC19, Materials::FormatImagePath, HOOK_CALL).install()->quick();
// Debug material comparison
Utils::Hook::Set<void*>(0x523894, Materials::MaterialComparePrint);
#ifdef DEBUG
if (Flags::HasFlag("dump"))
{
@ -182,8 +185,6 @@ namespace Components
Utils::Hook::Nop(0x51F5AC, 5);
Utils::Hook::Nop(0x51F4C4, 5);
}
Utils::Hook::Set<void*>(0x523894, Materials::MaterialComparePrint);
#endif
// Renderer::OnFrame([] ()

View File

@ -30,7 +30,8 @@ namespace Components
#ifdef DEBUG
static void DumpImageCfg(int, const char*, const char* material);
static void DumpImageCfgPath(int, const char*, const char* material);
static int MaterialComparePrint(Game::Material* m1, Game::Material* m2);
#endif
static int MaterialComparePrint(Game::Material* m1, Game::Material* m2);
};
}

View File

@ -4049,7 +4049,6 @@ namespace Game
unsigned int entityOffset;
};
/* 3765 */
struct VariableValue
{
VariableUnion u;
@ -4058,7 +4057,7 @@ namespace Game
struct ScriptContainer
{
Game::VariableValue* stack;
VariableValue* stack;
char unk1;
char unk2;
char unk3;