Check if zone is loaded.

This commit is contained in:
momo5502 2016-02-03 22:01:10 +01:00
parent 69bdda10f2
commit dcd46633ca
3 changed files with 26 additions and 9 deletions

View File

@ -60,15 +60,14 @@ namespace Components
void ZoneBuilder::Zone::LoadFastFiles()
{
Logger::Print("Loading required FastFiles...\n");
for (int i = 0; i < DataMap.GetRows(); ++i)
{
if (DataMap.GetElementAt(i, 0) == "require")
{
std::string fastfile = DataMap.GetElementAt(i, 1);
//Logger::Print("Loading '%s'...\n", fastfile.c_str());
//if (!DB_IsZoneLoaded(fastfile.c_str()))
if (!Game::DB_IsZoneLoaded(fastfile.c_str()))
{
Game::XZoneInfo info;
info.name = fastfile.data();
@ -76,13 +75,11 @@ namespace Components
info.freeFlags = 0;
Game::DB_LoadXAssets(&info, 1, true);
//LoadFastFile(fastfile.c_str(), true);
}
// else
// {
// Logger::Print("Zone '%s' already loaded\n", fastfile.c_str());
// }
else
{
Logger::Print("Zone '%s' already loaded\n", fastfile.c_str());
}
}
}
}

View File

@ -264,6 +264,25 @@ namespace Game
return ASSET_TYPE_INVALID;
}
bool DB_IsZoneLoaded(const char* zone)
{
int zoneCount = Utils::Hook::Get<int>(0x1261BCC);
char* zoneIndices = reinterpret_cast<char*>(0x16B8A34);
char* zoneData = reinterpret_cast<char*>(0x14C0F80);
for (int i = 0; i < zoneCount; i++)
{
std::string name = zoneData + 4 + 0xA4 * (zoneIndices[i] & 0xFF);
if (name == zone)
{
return true;
}
}
return false;
}
void MessageBox(std::string message, std::string title)
{
SetConsole("com_errorMessage", message.data());

View File

@ -362,6 +362,7 @@ namespace Game
const char *DB_GetXAssetName(XAsset *asset);
XAssetType DB_GetXAssetNameType(const char* name);
bool DB_IsZoneLoaded(const char* zone);
void MessageBox(std::string message, std::string title);