[IFxWorld] Structure fixes

This commit is contained in:
momo5502 2016-12-22 12:58:12 +01:00
parent 336a891d26
commit a4ad38c4d9
4 changed files with 260 additions and 260 deletions
src
Components/Modules
Game

@ -384,7 +384,7 @@ namespace Components
if (ZoneBuilder::IsEnabled()) if (ZoneBuilder::IsEnabled())
{ {
AssetHandler::RegisterInterface(new Assets::IXModel()); AssetHandler::RegisterInterface(new Assets::IXModel());
AssetHandler::RegisterInterface(new Assets::IFxWorld()); AssetHandler::RegisterInterface(new Assets::IFxWorld());
AssetHandler::RegisterInterface(new Assets::IMapEnts()); AssetHandler::RegisterInterface(new Assets::IMapEnts());
AssetHandler::RegisterInterface(new Assets::IRawFile()); AssetHandler::RegisterInterface(new Assets::IRawFile());
AssetHandler::RegisterInterface(new Assets::IComWorld()); AssetHandler::RegisterInterface(new Assets::IComWorld());

@ -2,9 +2,9 @@
namespace Assets namespace Assets
{ {
void IFxWorld::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void IFxWorld::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {
AssertSize(Game::FxWorld, 116); AssertSize(Game::FxWorld, 116);
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
SaveLogEnter("FxWorld"); SaveLogEnter("FxWorld");
@ -15,166 +15,166 @@ namespace Assets
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL); buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);
if (asset->name) if (asset->name)
{ {
buffer->saveString(builder->getAssetName(this->getType(), asset->name)); buffer->saveString(builder->getAssetName(this->getType(), asset->name));
Utils::Stream::ClearPointer(&dest->name); Utils::Stream::ClearPointer(&dest->name);
} }
// saveFxGlassSystem // saveFxGlassSystem
{ {
AssertSize(Game::FxGlassSystem, 112); AssertSize(Game::FxGlassSystem, 112);
if(asset->glassSys.defs) if (asset->glassSys.defs)
{ {
AssertSize(Game::FxGlassDef, 36); AssertSize(Game::FxGlassDef, 36);
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
Game::FxGlassDef* glassDefTable = buffer->dest<Game::FxGlassDef>(); Game::FxGlassDef* glassDefTable = buffer->dest<Game::FxGlassDef>();
buffer->saveArray(asset->glassSys.defs, asset->glassSys.defCount); buffer->saveArray(asset->glassSys.defs, asset->glassSys.defCount);
for (unsigned int i = 0; i < asset->glassSys.defCount; ++i) for (unsigned int i = 0; i < asset->glassSys.defCount; ++i)
{ {
Game::FxGlassDef* glassDef = &asset->glassSys.defs[i]; Game::FxGlassDef* glassDef = &asset->glassSys.defs[i];
Game::FxGlassDef* destGlassDef = &glassDefTable[i]; Game::FxGlassDef* destGlassDef = &glassDefTable[i];
if (glassDef->physPreset) if (glassDef->physPreset)
{ {
destGlassDef->physPreset = builder->requireAsset(Game::XAssetType::ASSET_TYPE_PHYSPRESET, glassDef->physPreset->name).physPreset; destGlassDef->physPreset = builder->requireAsset(Game::XAssetType::ASSET_TYPE_PHYSPRESET, glassDef->physPreset->name).physPreset;
} }
if (glassDef->material) if (glassDef->material)
{ {
destGlassDef->material = builder->requireAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, glassDef->material->name).material; destGlassDef->material = builder->requireAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, glassDef->material->name).material;
} }
if (glassDef->materialShattered) if (glassDef->materialShattered)
{ {
destGlassDef->materialShattered = builder->requireAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, glassDef->materialShattered->name).material; destGlassDef->materialShattered = builder->requireAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, glassDef->materialShattered->name).material;
} }
} }
} }
buffer->pushBlock(Game::XFILE_BLOCK_RUNTIME); buffer->pushBlock(Game::XFILE_BLOCK_RUNTIME);
if (asset->glassSys.piecePlaces) if (asset->glassSys.piecePlaces)
{ {
AssertSize(Game::FxGlassPiecePlace, 32); AssertSize(Game::FxGlassPiecePlace, 32);
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
buffer->saveArray(asset->glassSys.piecePlaces, asset->glassSys.pieceLimit); buffer->saveArray(asset->glassSys.piecePlaces, asset->glassSys.pieceLimit);
Utils::Stream::ClearPointer(&dest->glassSys.piecePlaces); Utils::Stream::ClearPointer(&dest->glassSys.piecePlaces);
} }
if (asset->glassSys.pieceStates) if (asset->glassSys.pieceStates)
{ {
AssertSize(Game::FxGlassPieceState, 32); AssertSize(Game::FxGlassPieceState, 32);
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
buffer->saveArray(asset->glassSys.pieceStates, asset->glassSys.pieceLimit); buffer->saveArray(asset->glassSys.pieceStates, asset->glassSys.pieceLimit);
Utils::Stream::ClearPointer(&dest->glassSys.pieceStates); Utils::Stream::ClearPointer(&dest->glassSys.pieceStates);
} }
if (asset->glassSys.pieceDynamics) if (asset->glassSys.pieceDynamics)
{ {
AssertSize(Game::FxGlassPieceDynamics, 36); AssertSize(Game::FxGlassPieceDynamics, 36);
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
buffer->saveArray(asset->glassSys.pieceDynamics, asset->glassSys.pieceLimit); buffer->saveArray(asset->glassSys.pieceDynamics, asset->glassSys.pieceLimit);
Utils::Stream::ClearPointer(&dest->glassSys.pieceDynamics); Utils::Stream::ClearPointer(&dest->glassSys.pieceDynamics);
} }
if (asset->glassSys.geoData) if (asset->glassSys.geoData)
{ {
AssertSize(Game::FxGlassGeometryData, 4); AssertSize(Game::FxGlassGeometryData, 4);
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
buffer->saveArray(asset->glassSys.geoData, asset->glassSys.geoDataLimit); buffer->saveArray(asset->glassSys.geoData, asset->glassSys.geoDataLimit);
Utils::Stream::ClearPointer(&dest->glassSys.geoData); Utils::Stream::ClearPointer(&dest->glassSys.geoData);
} }
if (asset->glassSys.isInUse) if (asset->glassSys.isInUse)
{ {
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
buffer->saveArray(asset->glassSys.isInUse, asset->glassSys.pieceWordCount); buffer->saveArray(asset->glassSys.isInUse, asset->glassSys.pieceWordCount);
Utils::Stream::ClearPointer(&dest->glassSys.isInUse); Utils::Stream::ClearPointer(&dest->glassSys.isInUse);
} }
if (asset->glassSys.cellBits) if (asset->glassSys.cellBits)
{ {
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
buffer->saveArray(asset->glassSys.cellBits, asset->glassSys.pieceWordCount * asset->glassSys.cellCount); buffer->saveArray(asset->glassSys.cellBits, asset->glassSys.pieceWordCount * asset->glassSys.cellCount);
Utils::Stream::ClearPointer(&dest->glassSys.cellBits); Utils::Stream::ClearPointer(&dest->glassSys.cellBits);
} }
if (asset->glassSys.visData) if (asset->glassSys.visData)
{ {
buffer->align(Utils::Stream::ALIGN_16); buffer->align(Utils::Stream::ALIGN_16);
buffer->save(asset->glassSys.visData, 1, (asset->glassSys.pieceLimit + 15) & 0xFFFFFFF0); buffer->save(asset->glassSys.visData, 1, (asset->glassSys.pieceLimit + 15) & 0xFFFFFFF0);
Utils::Stream::ClearPointer(&dest->glassSys.visData); Utils::Stream::ClearPointer(&dest->glassSys.visData);
} }
if (asset->glassSys.linkOrg) if (asset->glassSys.linkOrg)
{ {
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
buffer->saveArray(asset->glassSys.linkOrg, asset->glassSys.pieceLimit); buffer->saveArray(asset->glassSys.linkOrg, asset->glassSys.pieceLimit);
Utils::Stream::ClearPointer(&dest->glassSys.linkOrg); Utils::Stream::ClearPointer(&dest->glassSys.linkOrg);
} }
if (asset->glassSys.halfThickness) if (asset->glassSys.halfThickness)
{ {
buffer->align(Utils::Stream::ALIGN_16); buffer->align(Utils::Stream::ALIGN_16);
buffer->save(asset->glassSys.halfThickness, 1, ((4 * asset->glassSys.pieceLimit) + 12) & 0xFFFFFFF0); buffer->save(asset->glassSys.halfThickness, 1, ((4 * asset->glassSys.pieceLimit) + 12) & 0xFFFFFFF0);
Utils::Stream::ClearPointer(&dest->glassSys.halfThickness); Utils::Stream::ClearPointer(&dest->glassSys.halfThickness);
} }
buffer->popBlock(); buffer->popBlock();
if (asset->glassSys.lightingHandles) if (asset->glassSys.lightingHandles)
{ {
buffer->align(Utils::Stream::ALIGN_2); buffer->align(Utils::Stream::ALIGN_2);
buffer->saveArray(asset->glassSys.lightingHandles, asset->glassSys.initPieceCount); buffer->saveArray(asset->glassSys.lightingHandles, asset->glassSys.initPieceCount);
Utils::Stream::ClearPointer(&dest->glassSys.lightingHandles); Utils::Stream::ClearPointer(&dest->glassSys.lightingHandles);
} }
if (asset->glassSys.initPieceStates) if (asset->glassSys.initPieceStates)
{ {
AssertSize(Game::FxGlassInitPieceState, 52); AssertSize(Game::FxGlassInitPieceState, 52);
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
buffer->saveArray(asset->glassSys.initPieceStates, asset->glassSys.initPieceCount); buffer->saveArray(asset->glassSys.initPieceStates, asset->glassSys.initPieceCount);
Utils::Stream::ClearPointer(&dest->glassSys.initPieceStates); Utils::Stream::ClearPointer(&dest->glassSys.initPieceStates);
} }
if (asset->glassSys.initGeoData) if (asset->glassSys.initGeoData)
{ {
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
buffer->saveArray(asset->glassSys.initGeoData, asset->glassSys.initGeoDataCount); buffer->saveArray(asset->glassSys.initGeoData, asset->glassSys.initGeoDataCount);
Utils::Stream::ClearPointer(&dest->glassSys.initGeoData); Utils::Stream::ClearPointer(&dest->glassSys.initGeoData);
} }
} }
SaveLogExit(); SaveLogExit();
} }
void IFxWorld::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void IFxWorld::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {
Game::FxWorld* asset = header.fxWorld; Game::FxWorld* asset = header.fxWorld;
if (asset->glassSys.defs) if (asset->glassSys.defs)
{ {
for (unsigned int i = 0; i < asset->glassSys.defCount; ++i) for (unsigned int i = 0; i < asset->glassSys.defCount; ++i)
{ {
builder->loadAsset(Game::XAssetType::ASSET_TYPE_PHYSPRESET, asset->glassSys.defs[i].physPreset->name); builder->loadAsset(Game::XAssetType::ASSET_TYPE_PHYSPRESET, asset->glassSys.defs[i].physPreset->name);
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->glassSys.defs[i].material->name); builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->glassSys.defs[i].material->name);
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->glassSys.defs[i].materialShattered->name); builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->glassSys.defs[i].materialShattered->name);
} }
} }
} }
void IFxWorld::load(Game::XAssetHeader* /*header*/, std::string name, Components::ZoneBuilder::Zone* /*builder*/) void IFxWorld::load(Game::XAssetHeader* /*header*/, std::string name, Components::ZoneBuilder::Zone* /*builder*/)
{ {
Game::FxWorld* map = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_FX_MAP, name.data()).fxWorld; Game::FxWorld* map = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_FX_MAP, name.data()).fxWorld;
if (map) return; if (map) return;
Components::Logger::Error("Missing fx_map %s... you can't make them yet you idiot.", name.data()); Components::Logger::Error("Missing fx_map %s... you can't make them yet you idiot.", name.data());
} }
} }

@ -6,7 +6,7 @@ namespace Assets
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_FX_MAP; }; virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_FX_MAP; };
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override; virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
}; };
} }

@ -352,7 +352,7 @@ namespace Game
GfxImage *image; GfxImage *image;
}; };
#define SEMANTIC_WATER_MAP 11 #define SEMANTIC_WATER_MAP 11
union MaterialTextureDefInfo union MaterialTextureDefInfo
{ {
@ -3143,8 +3143,8 @@ namespace Game
int dpvsSurfaceCount; int dpvsSurfaceCount;
unsigned int skyCount; unsigned int skyCount;
GfxSky* skies; GfxSky* skies;
int unkCount1; int unkCount1;
int unkCount2; int unkCount2;
char unknown1[16]; char unknown1[16];
GfxWorldDpvsPlanes dpvsPlanes; //The following rely on the count in this GfxWorldDpvsPlanes dpvsPlanes; //The following rely on the count in this
GfxCellTreeCount *aabbTreeCounts; GfxCellTreeCount *aabbTreeCounts;
@ -3160,9 +3160,9 @@ namespace Game
int materialMemoryCount; int materialMemoryCount;
MaterialMemory *materialMemory; MaterialMemory *materialMemory;
sunflare_t sun; sunflare_t sun;
char pad[64]; char pad[64];
GfxImage* unknownImage; GfxImage* unknownImage;
unsigned int *cellCasterBits[2]; unsigned int *cellCasterBits[2];
GfxSceneDynModel *sceneDynModel; GfxSceneDynModel *sceneDynModel;
GfxSceneDynBrush *sceneDynBrush; GfxSceneDynBrush *sceneDynBrush;
unsigned int *primaryLightEntityShadowVis; unsigned int *primaryLightEntityShadowVis;
@ -3212,142 +3212,142 @@ namespace Game
}; };
#pragma pack(push, 4) #pragma pack(push, 4)
struct FxGlassDef struct FxGlassDef
{ {
float halfThickness; float halfThickness;
float texVecs[2][2]; float texVecs[2][2];
GfxColor color; GfxColor color;
Material *material; Material *material;
Material *materialShattered; Material *materialShattered;
PhysPreset *physPreset; PhysPreset *physPreset;
}; };
#pragma pack(pop) #pragma pack(pop)
struct FxSpatialFrame struct FxSpatialFrame
{ {
float quat[4]; float quat[4];
float origin[3]; float origin[3];
}; };
union FxGlassPiecePlace union FxGlassPiecePlace
{ {
struct struct
{ {
FxSpatialFrame frame; FxSpatialFrame frame;
float radius; float radius;
}; };
unsigned int nextFree; unsigned int nextFree;
}; };
struct FxGlassPieceState struct FxGlassPieceState
{ {
float texCoordOrigin[2]; float texCoordOrigin[2];
unsigned int supportMask; unsigned int supportMask;
unsigned __int16 initIndex; unsigned __int16 initIndex;
unsigned __int16 geoDataStart; unsigned __int16 geoDataStart;
unsigned __int16 lightingIndex; unsigned __int16 lightingIndex;
char defIndex; char defIndex;
char pad[3]; char pad[3];
char vertCount; char vertCount;
char holeDataCount; char holeDataCount;
char crackDataCount; char crackDataCount;
char fanDataCount; char fanDataCount;
unsigned __int16 flags; unsigned __int16 flags;
float areaX2; float areaX2;
}; };
struct FxGlassPieceDynamics struct FxGlassPieceDynamics
{ {
char pad[36]; char pad[36];
}; };
struct FxGlassVertex struct FxGlassVertex
{ {
__int16 x; __int16 x;
__int16 y; __int16 y;
}; };
struct FxGlassHoleHeader struct FxGlassHoleHeader
{ {
unsigned __int16 uniqueVertCount; unsigned __int16 uniqueVertCount;
char touchVert; char touchVert;
char pad[1]; char pad[1];
}; };
struct FxGlassCrackHeader struct FxGlassCrackHeader
{ {
unsigned __int16 uniqueVertCount; unsigned __int16 uniqueVertCount;
char beginVertIndex; char beginVertIndex;
char endVertIndex; char endVertIndex;
}; };
union FxGlassGeometryData union FxGlassGeometryData
{ {
FxGlassVertex vert; FxGlassVertex vert;
FxGlassHoleHeader hole; FxGlassHoleHeader hole;
FxGlassCrackHeader crack; FxGlassCrackHeader crack;
char asBytes[4]; char asBytes[4];
__int16 anonymous[2]; __int16 anonymous[2];
}; };
#pragma pack(push, 4) #pragma pack(push, 4)
struct FxGlassInitPieceState //Note, on MW3 this is missing 4 bytes, just not sure whats missing yet struct FxGlassInitPieceState //Note, on MW3 this is missing 4 bytes, just not sure whats missing yet
{ {
/* /*
FxSpatialFrame frame; FxSpatialFrame frame;
float radius; float radius;
float texCoordOrigin[2]; float texCoordOrigin[2];
unsigned int supportMask; unsigned int supportMask;
float areaX2; float areaX2;
unsigned __int16 lightingIndex; unsigned __int16 lightingIndex;
char defIndex; char defIndex;
char vertCount; char vertCount;
char fanDataCount; char fanDataCount;
*/ */
char pad[52]; char pad[52];
}; };
#pragma pack(pop) #pragma pack(pop)
#pragma pack(push, 8) #pragma pack(push, 8)
struct FxGlassSystem struct FxGlassSystem
{ {
int time; int time;
int prevTime; int prevTime;
unsigned int defCount; unsigned int defCount;
unsigned int pieceLimit; unsigned int pieceLimit;
unsigned int pieceWordCount; unsigned int pieceWordCount;
unsigned int initPieceCount; unsigned int initPieceCount;
unsigned int cellCount; unsigned int cellCount;
unsigned int activePieceCount; unsigned int activePieceCount;
unsigned int firstFreePiece; unsigned int firstFreePiece;
unsigned int geoDataLimit; unsigned int geoDataLimit;
unsigned int geoDataCount; unsigned int geoDataCount;
unsigned int initGeoDataCount; unsigned int initGeoDataCount;
FxGlassDef *defs; FxGlassDef *defs;
FxGlassPiecePlace *piecePlaces; FxGlassPiecePlace *piecePlaces;
FxGlassPieceState *pieceStates; FxGlassPieceState *pieceStates;
FxGlassPieceDynamics *pieceDynamics; FxGlassPieceDynamics *pieceDynamics;
FxGlassGeometryData *geoData; FxGlassGeometryData *geoData;
unsigned int *isInUse; unsigned int *isInUse;
unsigned int *cellBits; unsigned int *cellBits;
char *visData; char *visData;
float (*linkOrg)[3]; float(*linkOrg)[3];
float *halfThickness; float *halfThickness;
unsigned __int16 *lightingHandles; unsigned __int16 *lightingHandles;
FxGlassInitPieceState *initPieceStates; FxGlassInitPieceState *initPieceStates;
FxGlassGeometryData *initGeoData; FxGlassGeometryData *initGeoData;
bool needToCompactData; bool needToCompactData;
char initCount; char initCount;
float effectChanceAccum; float effectChanceAccum;
int lastPieceDeletionTime; int lastPieceDeletionTime;
}; };
#pragma pack(pop) #pragma pack(pop)
struct FxWorld struct FxWorld
{ {
const char * name; const char * name;
FxGlassSystem glassSys; FxGlassSystem glassSys;
}; };
union XAssetHeader union XAssetHeader
{ {
@ -3379,7 +3379,7 @@ namespace Game
GameWorldSp* gameWorldSp; GameWorldSp* gameWorldSp;
TracerDef* tracer; TracerDef* tracer;
VehicleDef* vehicle; VehicleDef* vehicle;
FxWorld* fxWorld; FxWorld* fxWorld;
GfxWorld* gfxWorld; GfxWorld* gfxWorld;
GfxLightDef* lightDef; GfxLightDef* lightDef;
SndCurve* sndCurve; SndCurve* sndCurve;
@ -3624,7 +3624,7 @@ namespace Game
}; };
#pragma pack(pop) #pragma pack(pop)
typedef char mapname_t[40]; typedef char mapname_t[40];
#ifdef __cplusplus #ifdef __cplusplus
} }