mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-09-02 19:39:12 +00:00
Codefix b2c5712
: [Script] Squirrel::GetRealInstance doesn't work with negative index
This commit is contained in:
@@ -511,6 +511,7 @@ bool Squirrel::CreateClassInstance(const std::string &class_name, void *real_ins
|
|||||||
|
|
||||||
/* static */ SQUserPointer Squirrel::GetRealInstance(HSQUIRRELVM vm, int index, const char *tag)
|
/* static */ SQUserPointer Squirrel::GetRealInstance(HSQUIRRELVM vm, int index, const char *tag)
|
||||||
{
|
{
|
||||||
|
if (index < 0) index += sq_gettop(vm) + 1;
|
||||||
Squirrel *engine = static_cast<Squirrel *>(sq_getforeignptr(vm));
|
Squirrel *engine = static_cast<Squirrel *>(sq_getforeignptr(vm));
|
||||||
std::string class_name = fmt::format("{}{}", engine->GetAPIName(), tag);
|
std::string class_name = fmt::format("{}{}", engine->GetAPIName(), tag);
|
||||||
sq_pushroottable(vm);
|
sq_pushroottable(vm);
|
||||||
|
Reference in New Issue
Block a user