Fixes and shit.

This commit is contained in:
momo5502 2016-01-28 00:32:46 +01:00
parent 5f0f7cb1fa
commit 73ed335b11
7 changed files with 97 additions and 17 deletions

View File

@ -223,6 +223,7 @@ namespace Components
if (!header.data)
{
header = Game::DB_FindXAssetHeader(type, filename.data());
Components::AssetHandler::StoreTemporaryAsset(type, header); // Might increase efficiency...
}
return header;

View File

@ -103,6 +103,8 @@ namespace Assets
dest->name = reinterpret_cast<char*>(-1);
}
buffer->PushBlock(Game::XFILE_BLOCK_TEMP);
if (asset->texture)
{
buffer->Align(Utils::Stream::ALIGN_4);
@ -117,5 +119,6 @@ namespace Assets
}
buffer->PopBlock();
buffer->PopBlock();
}
}

View File

@ -55,6 +55,14 @@ namespace Components
{
Game::Font* font = Game::R_RegisterFont("fonts/normalFont");
float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
if (IsDebuggerPresent())
{
color[0] = 1.00f;
color[1] = 0.53f;
color[2] = 0.23f;
}
Game::R_AddCmdDrawText("DEBUG-BUILD", 0x7FFFFFFF, font, 15.0f, 10.0f + Game::R_TextHeight(font), 1.0f, 1.0f, 0.0f, color, 0);
});
#else

View File

@ -4,6 +4,22 @@ namespace Components
{
std::vector<std::string> FastFiles::ZonePaths;
// This has to be called only once, when the game starts
void FastFiles::LoadInitialZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync)
{
std::vector<Game::XZoneInfo> data;
Utils::Merge(&data, zoneInfo, zoneCount);
// Load custom weapons, if present (force that later on)
if (FastFiles::Exists("weapons_mp"))
{
data.push_back({ "weapons_mp", 1, 0 });
}
return FastFiles::LoadDLCUIZones(data.data(), data.size(), sync);
}
// This has to be called every time the cgame is reinitialized
void FastFiles::LoadDLCUIZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync)
{
std::vector<Game::XZoneInfo> data;
@ -11,18 +27,46 @@ namespace Components
Game::XZoneInfo info = { nullptr, 2, 0 };
// Custom ui stuff
if (FastFiles::Exists("iw4x_ui_mp"))
{
info.name = "iw4x_ui_mp";
data.push_back(info);
}
else // Fallback
{
info.name = "dlc1_ui_mp";
data.push_back(info);
info.name = "dlc2_ui_mp";
data.push_back(info);
// Load custom weapons, if present (force that later on)
if (FastFiles::Exists("weapons_mp"))
{
data.push_back({ "weapons_mp", 1, 0 });
}
return FastFiles::LoadLocalizeZones(data.data(), data.size(), sync);
}
// This has to be called every time fastfiles are loaded :D
void FastFiles::LoadLocalizeZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync)
{
std::vector<Game::XZoneInfo> data;
Utils::Merge(&data, zoneInfo, zoneCount);
Game::XZoneInfo info = { nullptr, 4, 0 };
// Not sure how they should be loaded :S
std::string langZone = Utils::VA("localized_iw4x_%s", Game::Win_GetLanguage());
if (FastFiles::Exists(langZone))
{
info.name = langZone.data();
}
else if (FastFiles::Exists("localized_iw4x_english")) // Fallback
{
info.name = "localized_iw4x_english";
}
data.push_back(info);
Game::DB_LoadXAssets(data.data(), data.size(), sync);
}
@ -89,7 +133,7 @@ namespace Components
Utils::Hook(0x44DA90, FastFiles::GetZoneLocation, HOOK_JUMP).Install()->Quick();
// Allow dlc ui zone loading
Utils::Hook(0x506BC7, FastFiles::LoadDLCUIZones, HOOK_CALL).Install()->Quick();
Utils::Hook(0x506BC7, FastFiles::LoadInitialZones, HOOK_CALL).Install()->Quick();
Utils::Hook(0x60B4AC, FastFiles::LoadDLCUIZones, HOOK_CALL).Install()->Quick();
// basic checks (hash jumps, both normal and playlist)

View File

@ -12,9 +12,12 @@ namespace Components
static bool Exists(std::string file);
static void LoadLocalizeZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);
private:
static std::vector<std::string> ZonePaths;
static const char* GetZoneLocation(const char* file);
static void LoadInitialZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);
static void LoadDLCUIZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);
};
}

View File

@ -47,7 +47,7 @@ namespace Components
data.push_back({ patchZone.data(), zoneInfo->allocFlags, zoneInfo->freeFlags });
}
Game::DB_LoadXAssets(data.data(), data.size(), sync);
return FastFiles::LoadLocalizeZones(data.data(), data.size(), sync);
}
bool Maps::LoadAssetRestrict(Game::XAssetType type, Game::XAssetHeader asset, const char* name)

View File

@ -89,7 +89,10 @@ namespace Components
{
if (DataMap.GetElementAt(i, 0) == "localize")
{
Localization::SetTemp(DataMap.GetElementAt(i, 1), DataMap.GetElementAt(i, 2));
std::string stringOverride = DataMap.GetElementAt(i, 2);
Utils::Replace(stringOverride, "\\n", "\n");
Localization::SetTemp(DataMap.GetElementAt(i, 1), stringOverride);
}
else
{
@ -437,10 +440,28 @@ namespace Components
AssetHandler::OnLoad([] (Game::XAssetType type, Game::XAssetHeader asset, const char* name)
{
if (FastFiles::Current() == "penis")
{
OutputDebugStringA(name);
}
// static void* blocTable = 0;
//
// if (FastFiles::Current() == "iw4x_ui_mp" && type == Game::XAssetType::ASSET_TYPE_MATERIAL)
// {
// if (std::string(name) == "preview_mp_bloc")
// {
// blocTable = asset.material->stateBitTable;
// }
// else if (blocTable)
// {
// void* thisTable = asset.material->stateBitTable;
//
// if (thisTable != blocTable)
// {
// OutputDebugStringA("DIFF!");
// }
// else
// {
// OutputDebugStringA("YAY!");
// }
// }
// }
return true;
});