[Script] Allow 6 params for setExpFog

This commit is contained in:
momo5502 2017-04-29 23:08:41 +02:00
parent 7fcd0331be
commit 70d7312472
6 changed files with 92 additions and 1 deletions

View File

@ -142,7 +142,7 @@ namespace Components
unsigned int Colors::ColorIndex(char index) unsigned int Colors::ColorIndex(char index)
{ {
char result = index - '0'; char result = index - '0';
if (result >= Colors::ColorTable.size() || result < 0) result = 7; if (static_cast<unsigned int>(result) >= Colors::ColorTable.size() || result < 0) result = 7;
return result; return result;
} }

View File

@ -227,6 +227,24 @@ namespace Components
Game::GScr_LoadGameTypeScript(); Game::GScr_LoadGameTypeScript();
} }
int Script::SetExpFogStub()
{
if(Game::Scr_GetNumParam() == 6)
{
Game::VariableValue*& scr_stack = *reinterpret_cast<Game::VariableValue**>(0x2040D00);
if(scr_stack)
{
Game::Scr_AddFloat(0); // Push transition time onto the stack
Game::VariableValue transitionTime;
std::memcpy(&transitionTime, scr_stack, sizeof Game::VariableValue);
std::memmove(&scr_stack[0], &scr_stack[1], sizeof(Game::VariableValue) * 6);
std::memcpy(&scr_stack[6], &transitionTime, sizeof Game::VariableValue);
}
}
return Game::Scr_GetNumParam();
}
Script::Script() Script::Script()
{ {
Utils::Hook(0x612DB0, Script::StoreFunctionNameStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x612DB0, Script::StoreFunctionNameStub, HOOK_JUMP).install()->quick();
@ -239,6 +257,8 @@ namespace Components
Utils::Hook(0x48EFFE, Script::LoadGameType, HOOK_CALL).install()->quick(); Utils::Hook(0x48EFFE, Script::LoadGameType, HOOK_CALL).install()->quick();
Utils::Hook(0x45D44A, Script::LoadGameTypeScript, HOOK_CALL).install()->quick(); Utils::Hook(0x45D44A, Script::LoadGameTypeScript, HOOK_CALL).install()->quick();
Utils::Hook(0x5F41A3, Script::SetExpFogStub, HOOK_CALL).install()->quick();
} }
Script::~Script() Script::~Script()

View File

@ -34,5 +34,7 @@ namespace Components
static void LoadGameType(); static void LoadGameType();
static void LoadGameTypeScript(); static void LoadGameTypeScript();
static int SetExpFogStub();
}; };
} }

View File

@ -213,6 +213,7 @@ namespace Game
Scr_FreeThread_t Scr_FreeThread = Scr_FreeThread_t(0x4BD320); Scr_FreeThread_t Scr_FreeThread = Scr_FreeThread_t(0x4BD320);
Scr_AddString_t Scr_AddString = Scr_AddString_t(0x412310); Scr_AddString_t Scr_AddString = Scr_AddString_t(0x412310);
Scr_AddFloat_t Scr_AddFloat = Scr_AddFloat_t(0x61E860);
Scr_Notify_t Scr_Notify = Scr_Notify_t(0x4A4750); Scr_Notify_t Scr_Notify = Scr_Notify_t(0x4A4750);
Scr_ShutdownAllocNode_t Scr_ShutdownAllocNode = Scr_ShutdownAllocNode_t(0x441650); Scr_ShutdownAllocNode_t Scr_ShutdownAllocNode = Scr_ShutdownAllocNode_t(0x441650);

View File

@ -511,6 +511,9 @@ namespace Game
typedef void(__cdecl * Scr_AddString_t)(const char* str); typedef void(__cdecl * Scr_AddString_t)(const char* str);
extern Scr_AddString_t Scr_AddString; extern Scr_AddString_t Scr_AddString;
typedef int(__cdecl * Scr_AddFloat_t)(float);
extern Scr_AddFloat_t Scr_AddFloat;
typedef void(__cdecl * Scr_ShutdownAllocNode_t)(); typedef void(__cdecl * Scr_ShutdownAllocNode_t)();
extern Scr_ShutdownAllocNode_t Scr_ShutdownAllocNode; extern Scr_ShutdownAllocNode_t Scr_ShutdownAllocNode;

View File

@ -3956,6 +3956,71 @@ namespace Game
int dataCount; int dataCount;
} gameState; } gameState;
struct VariableStackBuffer
{
const char *pos;
unsigned __int16 size;
unsigned __int16 bufLen;
unsigned __int16 localId;
char time;
char buf[1];
};
enum VariableType
{
VAR_UNDEFINED = 0x0,
VAR_BEGIN_REF = 0x1,
VAR_POINTER = 0x1,
VAR_STRING = 0x2,
VAR_ISTRING = 0x3,
VAR_VECTOR = 0x4,
VAR_END_REF = 0x5,
VAR_FLOAT = 0x5,
VAR_INTEGER = 0x6,
VAR_CODEPOS = 0x7,
VAR_PRECODEPOS = 0x8,
VAR_FUNCTION = 0x9,
VAR_BUILTIN_FUNCTION = 0xA,
VAR_BUILTIN_METHOD = 0xB,
VAR_STACK = 0xC,
VAR_ANIMATION = 0xD,
VAR_PRE_ANIMATION = 0xE,
VAR_THREAD = 0xF,
VAR_NOTIFY_THREAD = 0x10,
VAR_TIME_THREAD = 0x11,
VAR_CHILD_THREAD = 0x12,
VAR_OBJECT = 0x13,
VAR_DEAD_ENTITY = 0x14,
VAR_ENTITY = 0x15,
VAR_ARRAY = 0x16,
VAR_DEAD_THREAD = 0x17,
VAR_COUNT = 0x18,
VAR_FREE = 0x18,
VAR_THREAD_LIST = 0x19,
VAR_ENDON_LIST = 0x1A,
VAR_TOTAL_COUNT = 0x1B,
};
union VariableUnion
{
int intValue;
unsigned int uintValue;
float floatValue;
unsigned int stringValue;
const float *vectorValue;
const char *codePosValue;
unsigned int pointerValue;
VariableStackBuffer *stackValue;
unsigned int entityOffset;
};
/* 3765 */
struct VariableValue
{
VariableUnion u;
int type;
};
#ifndef IDA #ifndef IDA
} }
#endif #endif