This commit is contained in:
commit
8294be1b32
@ -1,5 +1,7 @@
|
||||
#include <STDInclude.hpp>
|
||||
|
||||
#define IW4X_IMG_VERSION "0"
|
||||
|
||||
namespace Assets
|
||||
{
|
||||
void IGfxImage::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||
@ -19,13 +21,31 @@ namespace Assets
|
||||
image->category = 0;
|
||||
image->cardMemory = 0;
|
||||
|
||||
image->loadDef = builder->getAllocator()->allocate<Game::GfxImageLoadDef>();
|
||||
if (!image->loadDef)
|
||||
const char* tempName = image->name;
|
||||
if (tempName[0] == '*') tempName++;
|
||||
|
||||
Components::FileSystem::File imageFile(fmt::sprintf("images/%s.iw4xImage", tempName));
|
||||
if (imageFile.exists())
|
||||
{
|
||||
Components::Logger::Error("Failed to allocate GfxImageLoadDef structure!");
|
||||
return;
|
||||
Utils::Stream::Reader reader(builder->getAllocator(), imageFile.getBuffer());
|
||||
|
||||
if (reader.read<__int64>() != *reinterpret_cast<__int64*>("IW4xImg" IW4X_IMG_VERSION))
|
||||
{
|
||||
Components::Logger::Error(0, "Reading image '%s' failed, header is invalid!", name.data());
|
||||
}
|
||||
|
||||
AssertSize(Game::MapType, 1);
|
||||
image->mapType = reader.read<Game::MapType>();
|
||||
image->semantic = reader.read<char>();
|
||||
image->category = reader.read<char>();
|
||||
|
||||
image->dataLen1 = reader.read<int>();
|
||||
image->dataLen2 = image->dataLen1;
|
||||
|
||||
image->loadDef = reinterpret_cast<Game::GfxImageLoadDef*>(reader.readArray<char>(image->dataLen1 + 16));
|
||||
}
|
||||
else
|
||||
{
|
||||
char nameBuffer[MAX_PATH] = { 0 };
|
||||
Components::Materials::FormatImagePath(nameBuffer, sizeof(nameBuffer), 0, 0, name.data());
|
||||
Components::FileSystem::File iwi(nameBuffer);
|
||||
@ -44,7 +64,7 @@ namespace Assets
|
||||
image->dataLen1 = iwiHeader->fileSizeForPicmip[0] - 32;
|
||||
image->dataLen2 = iwiHeader->fileSizeForPicmip[0] - 32;
|
||||
|
||||
if (std::memcmp(iwiHeader->tag, "IWi", 3))
|
||||
if (std::memcmp(iwiHeader->tag, "IWi", 3) && iwiHeader->version == 8)
|
||||
{
|
||||
Components::Logger::Error("Image is not a valid IWi!");
|
||||
return;
|
||||
@ -86,6 +106,7 @@ namespace Assets
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header->image = image;
|
||||
}
|
||||
|
@ -81,7 +81,10 @@ namespace Assets
|
||||
|
||||
for (int j = 0; j < cell->portalCount; ++j)
|
||||
{
|
||||
cell->portals[i].vertices = reader.readArray<Game::vec3_t>(cell->portals[i].vertexCount);
|
||||
if (cell->portals[j].vertices)
|
||||
{
|
||||
cell->portals[j].vertices = reader.readArray<Game::vec3_t>(cell->portals[j].vertexCount & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user