From 566cad6784be7103a080e96e306e0eba8e6b8725 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 6 Dec 2016 19:36:57 +0100 Subject: [PATCH] [IFxEffectDef] Prepare efx loading --- .../Modules/AssetInterfaces/IFxEffectDef.cpp | 17 ++ .../Modules/AssetInterfaces/IFxEffectDef.hpp | 1 + src/Game/Functions.cpp | 2 + src/Game/Functions.hpp | 2 + src/Game/Structs.hpp | 164 ++++++++++-------- 5 files changed, 110 insertions(+), 76 deletions(-) diff --git a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp index bf714c18..95a518f6 100644 --- a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp +++ b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp @@ -2,6 +2,23 @@ namespace Assets { + void IFxEffectDef::load(Game::XAssetHeader* /*header*/, std::string /*name*/, Components::ZoneBuilder::Zone* /*builder*/) + { + // TODO: + // - Add the missing Editor-structures (FxEditorEffectDef, FxEditorElemDef, ...) + // - Initialize a parse session for the FX + // - Correctly load the FX by parsing each token + // - Convert the Editor-structures to the native ones + + if (0) + { + for (int i = 0; i < FX_ELEM_FIELD_COUNT; ++i) + { + Game::s_elemFields[i].handler(nullptr, nullptr); + } + } + } + void IFxEffectDef::markFxElemVisuals(Game::FxElemVisuals* visuals, char elemType, Components::ZoneBuilder::Zone* builder) { switch (elemType) diff --git a/src/Components/Modules/AssetInterfaces/IFxEffectDef.hpp b/src/Components/Modules/AssetInterfaces/IFxEffectDef.hpp index 145aa339..0590f61e 100644 --- a/src/Components/Modules/AssetInterfaces/IFxEffectDef.hpp +++ b/src/Components/Modules/AssetInterfaces/IFxEffectDef.hpp @@ -7,6 +7,7 @@ namespace Assets virtual void save(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; private: void markFxElemVisuals(Game::FxElemVisuals* visuals, char elemType, Components::ZoneBuilder::Zone* builder); diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 96a57563..fe48ca27 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -311,6 +311,8 @@ namespace Game Game::MaterialPass** varMaterialPass = (Game::MaterialPass**)0x112A960; snd_alias_list_t*** varsnd_alias_list_name = (snd_alias_list_t***)0x112AF38; + FxElemField* s_elemFields = (FxElemField*)0x73B848; + XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize) { int elSize = DB_GetXAssetSizeHandlers[type](); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index b4005860..70197cd2 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -628,6 +628,8 @@ namespace Game extern Game::MaterialPass** varMaterialPass; extern snd_alias_list_t*** varsnd_alias_list_name; + extern FxElemField* s_elemFields; + XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize); void Menu_FreeItemMemory(Game::itemDef_t* item); const char* TableLookup(StringTable* stringtable, int row, int column); diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index cb4eff46..e736eb0a 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -1847,88 +1847,100 @@ namespace Game // 88 - 0x58 }; +/* FxEffectDef::flags */ +#define FX_ELEM_LOOPING 0x1 +#define FX_ELEM_USE_RAND_COLOR 0x2 +#define FX_ELEM_USE_RAND_ALPHA 0x4 +#define FX_ELEM_USE_RAND_SIZE0 0x8 +#define FX_ELEM_USE_RAND_SIZE1 0x10 +#define FX_ELEM_USE_RAND_SCALE 0x20 +#define FX_ELEM_USE_RAND_ROT_DELTA 0x40 +#define FX_ELEM_MOD_COLOR_BY_ALPHA 0x80 +#define FX_ELEM_USE_RAND_VEL0 0x100 +#define FX_ELEM_USE_RAND_VEL1 0x200 +#define FX_ELEM_USE_BACK_COMPAT_VEL 0x400 +#define FX_ELEM_ABS_VEL0 0x800 +#define FX_ELEM_ABS_VEL1 0x1000 +#define FX_ELEM_PLAY_ON_TOUCH 0x2000 +#define FX_ELEM_PLAY_ON_DEATH 0x4000 +#define FX_ELEM_PLAY_ON_RUN 0x8000 +#define FX_ELEM_BOUNDING_SPHERE 0x10000 +#define FX_ELEM_USE_ITEM_CLIP 0x20000 +#define FX_ELEM_DECAL_FADE_IN 0x40000 +#define FX_ELEM_DISABLED 0x80000000 - /* FxEffectDef::flags */ -#define FX_ELEM_LOOPING 0x1 -#define FX_ELEM_USE_RAND_COLOR 0x2 -#define FX_ELEM_USE_RAND_ALPHA 0x4 -#define FX_ELEM_USE_RAND_SIZE0 0x8 -#define FX_ELEM_USE_RAND_SIZE1 0x10 -#define FX_ELEM_USE_RAND_SCALE 0x20 -#define FX_ELEM_USE_RAND_ROT_DELTA 0x40 -#define FX_ELEM_MOD_COLOR_BY_ALPHA 0x80 -#define FX_ELEM_USE_RAND_VEL0 0x100 -#define FX_ELEM_USE_RAND_VEL1 0x200 -#define FX_ELEM_USE_BACK_COMPAT_VEL 0x400 -#define FX_ELEM_ABS_VEL0 0x800 -#define FX_ELEM_ABS_VEL1 0x1000 -#define FX_ELEM_PLAY_ON_TOUCH 0x2000 -#define FX_ELEM_PLAY_ON_DEATH 0x4000 -#define FX_ELEM_PLAY_ON_RUN 0x8000 -#define FX_ELEM_BOUNDING_SPHERE 0x10000 -#define FX_ELEM_USE_ITEM_CLIP 0x20000 -#define FX_ELEM_DISABLED 0x80000000 -#define FX_ELEM_DECAL_FADE_IN 0x40000 +/* FxElemDef::flags */ +#define FX_ELEM_SPAWN_RELATIVE_TO_EFFECT 0x2 +#define FX_ELEM_SPAWN_FRUSTUM_CULL 0x4 +#define FX_ELEM_RUNNER_USES_RAND_ROT 0x8 +#define FX_ELEM_SPAWN_OFFSET_NONE 0x0 +#define FX_ELEM_SPAWN_OFFSET_SPHERE 0x10 +#define FX_ELEM_SPAWN_OFFSET_CYLINDER 0x20 +#define FX_ELEM_SPAWN_OFFSET_MASK 0x30 +#define FX_ELEM_RUN_RELATIVE_TO_WORLD 0x0 +#define FX_ELEM_RUN_RELATIVE_TO_SPAWN 0x40 +#define FX_ELEM_RUN_RELATIVE_TO_EFFECT 0x80 +#define FX_ELEM_RUN_RELATIVE_TO_OFFSET 0xC0 +#define FX_ELEM_RUN_MASK 0xC0 +#define FX_ELEM_USE_COLLISION 0x100 +#define FX_ELEM_DIE_ON_TOUCH 0x200 +#define FX_ELEM_DRAW_PAST_FOG 0x400 +#define FX_ELEM_DRAW_WITH_VIEWMODEL 0x800 +#define FX_ELEM_BLOCK_SIGHT 0x1000 +#define FX_ELEM_HAS_VELOCITY_GRAPH_LOCAL 0x1000000 +#define FX_ELEM_HAS_VELOCITY_GRAPH_WORLD 0x2000000 +#define FX_ELEM_HAS_GRAVITY 0x4000000 +#define FX_ELEM_USE_MODEL_PHYSICS 0x8000000 +#define FX_ELEM_NONUNIFORM_SCALE 0x10000000 +#define FX_ELEM_CLOUD_SHAPE_CUBE 0x0 +#define FX_ELEM_CLOUD_SHAPE_SPHERE_LARGE 0x20000000 +#define FX_ELEM_CLOUD_SHAPE_SPHERE_MEDIUM 0x40000000 +#define FX_ELEM_CLOUD_SHAPE_SPHERE_SMALL 0x60000000 +#define FX_ELEM_CLOUD_MASK 0x60000000 +#define FX_ELEM_DISABLE_FOUNTAIN_COLLISION 0x80000000 +#define FX_ELEM_DRAW_IN_THERMAL_ONLY 0x2000 +#define FX_ELEM_TRAIL_ORIENT_BY_VELOCITY 0x4000 +#define FX_ELEM_EMIT_ORIENT_BY_ELEM 0x8000 - /* FxElemDef::flags */ -#define FX_ELEM_SPAWN_RELATIVE_TO_EFFECT 0x2 -#define FX_ELEM_SPAWN_FRUSTUM_CULL 0x4 -#define FX_ELEM_RUNNER_USES_RAND_ROT 0x8 -#define FX_ELEM_SPAWN_OFFSET_NONE 0x0 -#define FX_ELEM_SPAWN_OFFSET_SPHERE 0x10 -#define FX_ELEM_SPAWN_OFFSET_CYLINDER 0x20 -#define FX_ELEM_SPAWN_OFFSET_MASK 0x30 -#define FX_ELEM_RUN_RELATIVE_TO_WORLD 0x0 -#define FX_ELEM_RUN_RELATIVE_TO_SPAWN 0x40 -#define FX_ELEM_RUN_RELATIVE_TO_EFFECT 0x80 -#define FX_ELEM_RUN_RELATIVE_TO_OFFSET 0xC0 -#define FX_ELEM_RUN_MASK 0xC0 -#define FX_ELEM_USE_COLLISION 0x100 -#define FX_ELEM_DIE_ON_TOUCH 0x200 -#define FX_ELEM_DRAW_PAST_FOG 0x400 -#define FX_ELEM_DRAW_WITH_VIEWMODEL 0x800 -#define FX_ELEM_BLOCK_SIGHT 0x1000 -#define FX_ELEM_HAS_VELOCITY_GRAPH_LOCAL 0x1000000 -#define FX_ELEM_HAS_VELOCITY_GRAPH_WORLD 0x2000000 -#define FX_ELEM_HAS_GRAVITY 0x4000000 -#define FX_ELEM_USE_MODEL_PHYSICS 0x8000000 -#define FX_ELEM_NONUNIFORM_SCALE 0x10000000 -#define FX_ELEM_CLOUD_SHAPE_CUBE 0x0 -#define FX_ELEM_CLOUD_SHAPE_SPHERE_LARGE 0x20000000 -#define FX_ELEM_CLOUD_SHAPE_SPHERE_MEDIUM 0x40000000 -#define FX_ELEM_CLOUD_SHAPE_SPHERE_SMALL 0x60000000 -#define FX_ELEM_CLOUD_MASK 0x60000000 -#define FX_ELEM_DISABLE_FOUNTAIN_COLLISION 0x80000000 -#define FX_ELEM_DRAW_IN_THERMAL_ONLY 0x2000 -#define FX_ELEM_TRAIL_ORIENT_BY_VELOCITY 0x4000 -#define FX_ELEM_EMIT_ORIENT_BY_ELEM 0x8000 - - /* FxElemAtlas::behavior */ -#define FX_ATLAS_START_MASK 0x3 -#define FX_ATLAS_START_FIXED 0x0 -#define FX_ATLAS_START_RANDOM 0x1 -#define FX_ATLAS_START_INDEXED 0x2 -#define FX_ATLAS_PLAY_OVER_LIFE 0x4 -#define FX_ATLAS_LOOP_ONLY_N_TIMES 0x8 +/* FxElemAtlas::behavior */ +#define FX_ATLAS_START_MASK 0x3 +#define FX_ATLAS_START_FIXED 0x0 +#define FX_ATLAS_START_RANDOM 0x1 +#define FX_ATLAS_START_INDEXED 0x2 +#define FX_ATLAS_PLAY_OVER_LIFE 0x4 +#define FX_ATLAS_LOOP_ONLY_N_TIMES 0x8 enum FxElemType : char { FX_ELEM_TYPE_SPRITE_BILLBOARD = 0x0, - FX_ELEM_TYPE_SPRITE_ORIENTED = 0x1, - FX_ELEM_TYPE_TAIL = 0x2, - FX_ELEM_TYPE_TRAIL = 0x3, - FX_ELEM_TYPE_CLOUD = 0x4, - FX_ELEM_TYPE_SPARKCLOUD = 0x5, - FX_ELEM_TYPE_SPARKFOUNTAIN = 0x6, - FX_ELEM_TYPE_MODEL = 0x7, - FX_ELEM_TYPE_OMNI_LIGHT = 0x8, - FX_ELEM_TYPE_SPOT_LIGHT = 0x9, - FX_ELEM_TYPE_SOUND = 0xA, - FX_ELEM_TYPE_DECAL = 0xB, - FX_ELEM_TYPE_RUNNER = 0xC, - FX_ELEM_TYPE_COUNT = 0xD, - FX_ELEM_TYPE_LAST_SPRITE = 0x3, - FX_ELEM_TYPE_LAST_DRAWN = 0x9, + FX_ELEM_TYPE_SPRITE_ORIENTED = 0x1, + FX_ELEM_TYPE_TAIL = 0x2, + FX_ELEM_TYPE_TRAIL = 0x3, + FX_ELEM_TYPE_CLOUD = 0x4, + FX_ELEM_TYPE_SPARKCLOUD = 0x5, + FX_ELEM_TYPE_SPARKFOUNTAIN = 0x6, + FX_ELEM_TYPE_MODEL = 0x7, + FX_ELEM_TYPE_OMNI_LIGHT = 0x8, + FX_ELEM_TYPE_SPOT_LIGHT = 0x9, + FX_ELEM_TYPE_SOUND = 0xA, + FX_ELEM_TYPE_DECAL = 0xB, + FX_ELEM_TYPE_RUNNER = 0xC, + FX_ELEM_TYPE_COUNT = 0xD, + FX_ELEM_TYPE_LAST_SPRITE = 0x3, + FX_ELEM_TYPE_LAST_DRAWN = 0x9, + }; + +#define FX_ELEM_FIELD_COUNT 90 + + struct FxEditorElemDef + { + // Uh... + }; + + struct FxElemField + { + const char *keyName; + bool(__cdecl *handler)(const char**, FxEditorElemDef*); }; struct FxElemVec3Range