Update to 12.0-beta1
This commit is contained in:
@@ -116,8 +116,7 @@ bool ScriptInstance::LoadCompatibilityScripts(const char *api_version, Subdirect
|
||||
{
|
||||
char script_name[32];
|
||||
seprintf(script_name, lastof(script_name), "compat_%s.nut", api_version);
|
||||
Searchpath sp;
|
||||
FOR_ALL_SEARCHPATHS(sp) {
|
||||
for (Searchpath sp : _valid_searchpaths) {
|
||||
std::string buf = FioGetDirectory(sp, dir);
|
||||
buf += script_name;
|
||||
if (!FileExists(buf)) continue;
|
||||
@@ -125,7 +124,7 @@ bool ScriptInstance::LoadCompatibilityScripts(const char *api_version, Subdirect
|
||||
if (this->engine->LoadScript(buf.c_str())) return true;
|
||||
|
||||
ScriptLog::Error("Failed to load API compatibility script");
|
||||
DEBUG(script, 0, "Error compiling / running API compatibility script: %s", buf.c_str());
|
||||
Debug(script, 0, "Error compiling / running API compatibility script: {}", buf);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -153,7 +152,7 @@ void ScriptInstance::Continue()
|
||||
|
||||
void ScriptInstance::Died()
|
||||
{
|
||||
DEBUG(script, 0, "The script died unexpectedly.");
|
||||
Debug(script, 0, "The script died unexpectedly.");
|
||||
this->is_dead = true;
|
||||
this->in_shutdown = true;
|
||||
|
||||
@@ -255,9 +254,12 @@ void ScriptInstance::GameLoop()
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptInstance::CollectGarbage() const
|
||||
void ScriptInstance::CollectGarbage()
|
||||
{
|
||||
if (this->is_started && !this->IsDead()) this->engine->CollectGarbage();
|
||||
if (this->is_started && !this->IsDead()) {
|
||||
ScriptObject::ActiveInstance active(this);
|
||||
this->engine->CollectGarbage();
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void ScriptInstance::DoCommandReturn(ScriptInstance *instance)
|
||||
@@ -343,8 +345,7 @@ static byte _script_sl_byte; ///< Used as source/target by the script saveload c
|
||||
|
||||
/** SaveLoad array that saves/loads exactly one byte. */
|
||||
static const SaveLoad _script_byte[] = {
|
||||
SLEG_VAR(_script_sl_byte, SLE_UINT8),
|
||||
SLE_END()
|
||||
SLEG_VAR("type", _script_sl_byte, SLE_UINT8),
|
||||
};
|
||||
|
||||
/* static */ bool ScriptInstance::SaveObject(HSQUIRRELVM vm, SQInteger index, int max_depth, bool test)
|
||||
@@ -363,8 +364,8 @@ static const SaveLoad _script_byte[] = {
|
||||
SQInteger res;
|
||||
sq_getinteger(vm, index, &res);
|
||||
if (!test) {
|
||||
int value = (int)res;
|
||||
SlArray(&value, 1, SLE_INT32);
|
||||
int64 value = (int64)res;
|
||||
SlCopy(&value, 1, SLE_INT64);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -384,7 +385,7 @@ static const SaveLoad _script_byte[] = {
|
||||
if (!test) {
|
||||
_script_sl_byte = (byte)len;
|
||||
SlObject(nullptr, _script_byte);
|
||||
SlArray(const_cast<char *>(buf), len, SLE_CHAR);
|
||||
SlCopy(const_cast<char *>(buf), len, SLE_CHAR);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -563,16 +564,17 @@ bool ScriptInstance::IsPaused()
|
||||
SlObject(nullptr, _script_byte);
|
||||
switch (_script_sl_byte) {
|
||||
case SQSL_INT: {
|
||||
int value;
|
||||
SlArray(&value, 1, SLE_INT32);
|
||||
int64 value;
|
||||
SlCopy(&value, 1, IsSavegameVersionBefore(SLV_SCRIPT_INT64) ? SLE_INT32 : SLE_INT64);
|
||||
if (vm != nullptr) sq_pushinteger(vm, (SQInteger)value);
|
||||
return true;
|
||||
}
|
||||
|
||||
case SQSL_STRING: {
|
||||
SlObject(nullptr, _script_byte);
|
||||
static char buf[256];
|
||||
SlArray(buf, _script_sl_byte, SLE_CHAR);
|
||||
static char buf[std::numeric_limits<decltype(_script_sl_byte)>::max()];
|
||||
SlCopy(buf, _script_sl_byte, SLE_CHAR);
|
||||
StrMakeValidInPlace(buf, buf + _script_sl_byte);
|
||||
if (vm != nullptr) sq_pushstring(vm, buf, -1);
|
||||
return true;
|
||||
}
|
||||
@@ -690,7 +692,7 @@ bool ScriptInstance::DoCommandCallback(const CommandCost &result, TileIndex tile
|
||||
ScriptObject::ActiveInstance active(this);
|
||||
|
||||
if (!ScriptObject::CheckLastCommand(tile, p1, p2, cmd)) {
|
||||
DEBUG(script, 1, "DoCommandCallback terminating a script, last command does not match expected command");
|
||||
Debug(script, 1, "DoCommandCallback terminating a script, last command does not match expected command");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user