[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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ namespace Assets
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 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;
};
}

View File

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