Update function tables

This commit is contained in:
Federico Cecchetto 2021-04-23 14:33:01 +02:00
parent cd6670d75a
commit e78eb74060
3 changed files with 1791 additions and 1095 deletions

File diff suppressed because it is too large Load Diff

View File

@ -62,12 +62,12 @@ namespace scripting
static const auto function_table = 0xB153F90;
static const auto method_table = 0xB155890;
if (index < 0x2DF)
if (index < 0x320)
{
return reinterpret_cast<script_function*>(game::base_address + function_table)[index];
return reinterpret_cast<script_function*>(game::base_address + function_table)[index - 1];
}
return reinterpret_cast<script_function*>(game::base_address + method_table)[index];
return reinterpret_cast<script_function*>(game::base_address + method_table)[index - 0x8000];
}
}

View File

@ -3,9 +3,9 @@
namespace scripting::lua
{
/*namespace
namespace
{
struct array_value
/*struct array_value
{
int index;
script_value value;
@ -107,9 +107,38 @@ namespace scripting::lua
table[sol::metatable_key] = metatable;
return {state, table};
}
}*/
bool is_istring(const sol::lua_value& value)
{
if (!value.is<std::string>())
{
return false;
}
const auto str = value.as<std::string>();
return str[0] == '&';
}
script_value string_to_istring(const sol::lua_value& value)
{
const auto str = value.as<std::string>().erase(0, 1);
const auto string_value = game::SL_GetString(str.data(), 0);
game::VariableValue variable{};
variable.type = game::SCRIPT_ISTRING;
variable.u.uintValue = string_value;
const auto _ = gsl::finally([&variable]()
{
game::RemoveRefToValue(variable.type, variable.u);
});
return script_value(variable);
}
}
script_value convert(const sol::lua_value& value)
{
if (value.is<int>())
@ -137,6 +166,11 @@ namespace scripting::lua
return {value.as<float>()};
}
if (is_istring(value))
{
return string_to_istring(value);
}
if (value.is<std::string>())
{
return {value.as<std::string>()};