[IFxEffectDef] More preparations for fx loading

This commit is contained in:
momo5502 2016-12-07 21:19:01 +01:00
parent 788ccae967
commit dfa50dc1bb
4 changed files with 86 additions and 13 deletions

View File

@ -2,19 +2,31 @@
namespace Assets
{
void IFxEffectDef::load(Game::XAssetHeader* /*header*/, std::string /*name*/, Components::ZoneBuilder::Zone* /*builder*/)
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)
Components::FileSystem::File rawFx(fmt::sprintf("fx/%s.efx", name.data()));
if (rawFx.exists())
{
Game::s_elemFields[i].handler(nullptr, nullptr);
const char* session = rawFx.getBuffer().data();
Game::Com_BeginParseSession("fx");
Game::Com_SetSpaceDelimited(0);
Game::Com_SetParseNegativeNumbers(1);
const char* format = Game::Com_Parse(&session);
if (format != "iwfx"s)
{
Game::Com_EndParseSession();
Components::Logger::Error("Effect needs to be updated from the legacy format.\n");
}
for (int i = 0; i < FX_ELEM_FIELD_COUNT; ++i)
{
Game::s_elemFields[i].handler(nullptr, nullptr);
}
Game::Com_EndParseSession();
}
}
}

View File

@ -44,7 +44,7 @@ namespace Components
{
if (args)
{
this->token = Game::Com_ParseExt(args);
this->token = Game::Com_Parse(args);
}
}

View File

@ -27,7 +27,10 @@ namespace Game
Com_Error_t Com_Error = (Com_Error_t)0x4B22D0;
Com_Printf_t Com_Printf = (Com_Printf_t)0x402500;
Com_PrintMessage_t Com_PrintMessage = (Com_PrintMessage_t)0x4AA830;
Com_ParseExt_t Com_ParseExt = (Com_ParseExt_t)0x474D60;
Com_EndParseSession_t Com_EndParseSession = (Com_EndParseSession_t)0x4B80B0;
Com_BeginParseSession_t Com_BeginParseSession = (Com_BeginParseSession_t)0x4AAB80;
Com_SetSpaceDelimited_t Com_SetSpaceDelimited = (Com_SetSpaceDelimited_t)0x4FC710;
Com_Parse_t Com_Parse = (Com_Parse_t)0x474D60;
Com_SetSlowMotion_t Com_SetSlowMotion = (Com_SetSlowMotion_t)0x446E20;
Con_DrawMiniConsole_t Con_DrawMiniConsole = (Con_DrawMiniConsole_t)0x464F30;
@ -222,6 +225,9 @@ namespace Game
Sys_IsDatabaseReady_t Sys_IsDatabaseReady = (Sys_IsDatabaseReady_t)0x4CA4A0;
Sys_IsDatabaseReady2_t Sys_IsDatabaseReady2 = (Sys_IsDatabaseReady2_t)0x441280;
Sys_IsMainThread_t Sys_IsMainThread = (Sys_IsMainThread_t)0x4C37D0;
Sys_IsRenderThread_t Sys_IsRenderThread = (Sys_IsRenderThread_t)0x4B20E0;
Sys_IsServerThread_t Sys_IsServerThread = (Sys_IsServerThread_t)0x4B0270;
Sys_IsDatabaseThread_t Sys_IsDatabaseThread = (Sys_IsDatabaseThread_t)0x4C6020;
Sys_SendPacket_t Sys_SendPacket = (Sys_SendPacket_t)0x60FDC0;
Sys_ShowConsole_t Sys_ShowConsole = (Sys_ShowConsole_t)0x4305E0;
Sys_ListFiles_t Sys_ListFiles = (Sys_ListFiles_t)0x45A660;
@ -608,4 +614,38 @@ namespace Game
pop edi
}
}
void* Com_GetParseThreadInfo()
{
if (Game::Sys_IsMainThread())
{
return reinterpret_cast<void*>(0x6466628);
}
else if (Game::Sys_IsRenderThread())
{
return reinterpret_cast<void*>(0x646AC34);
}
else if (Game::Sys_IsServerThread())
{
return reinterpret_cast<void*>(0x646F240);
}
else if(Game::Sys_IsDatabaseThread())
{
return reinterpret_cast<void*>(0x647384C);
}
else
{
return nullptr;
}
}
void Com_SetParseNegativeNumbers(int parse)
{
char* g_parse = reinterpret_cast<char*>(Com_GetParseThreadInfo());
if (g_parse)
{
g_parse[1056 * *(reinterpret_cast<DWORD*>(g_parse) + 4224) + 1032] = parse != 0;
}
}
}

View File

@ -57,8 +57,17 @@ namespace Game
typedef void(__cdecl * Com_PrintMessage_t)(int channel, const char *msg, int error);
extern Com_PrintMessage_t Com_PrintMessage;
typedef char* (__cdecl * Com_ParseExt_t)(const char **data_p);
extern Com_ParseExt_t Com_ParseExt;
typedef void(__cdecl * Com_EndParseSession_t)();
extern Com_EndParseSession_t Com_EndParseSession;
typedef void(__cdecl * Com_BeginParseSession_t)(const char* why);
extern Com_BeginParseSession_t Com_BeginParseSession;
typedef void(__cdecl * Com_SetSpaceDelimited_t)(int);
extern Com_SetSpaceDelimited_t Com_SetSpaceDelimited;
typedef char* (__cdecl * Com_Parse_t)(const char **data_p);
extern Com_Parse_t Com_Parse;
typedef void(__cdecl * Com_SetSlowMotion_t)(float start, float end, int duration);
extern Com_SetSlowMotion_t Com_SetSlowMotion;
@ -518,6 +527,15 @@ namespace Game
typedef bool(__cdecl * Sys_IsMainThread_t)();
extern Sys_IsMainThread_t Sys_IsMainThread;
typedef bool(__cdecl * Sys_IsRenderThread_t)();
extern Sys_IsRenderThread_t Sys_IsRenderThread;
typedef bool(__cdecl * Sys_IsServerThread_t)();
extern Sys_IsServerThread_t Sys_IsServerThread;
typedef bool(__cdecl * Sys_IsDatabaseThread_t)();
extern Sys_IsDatabaseThread_t Sys_IsDatabaseThread;
typedef char** (__cdecl * Sys_ListFiles_t)(const char *directory, const char *extension, const char *filter, int *numfiles, int wantsubs);
extern Sys_ListFiles_t Sys_ListFiles;
@ -665,4 +683,7 @@ namespace Game
void Load_IndexBuffer(void* data, IDirect3DIndexBuffer9** storeHere, int count);
void Load_VertexBuffer(void* data, IDirect3DVertexBuffer9** where, int len);
void* Com_GetParseThreadInfo();
void Com_SetParseNegativeNumbers(int parse);
}