openttd updated to 1.5.0-beta2
--HG-- branch : openttd
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $Id: script_instance.cpp 26057 2013-11-23 13:12:19Z rubidium $ */
|
||||
/* $Id: script_instance.cpp 26785 2014-09-07 09:30:57Z rubidium $ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "../company_func.h"
|
||||
#include "../fileio_func.h"
|
||||
|
||||
#include "../safeguards.h"
|
||||
|
||||
ScriptStorage::~ScriptStorage()
|
||||
{
|
||||
/* Free our pointers */
|
||||
@@ -44,7 +46,7 @@ ScriptStorage::~ScriptStorage()
|
||||
static void PrintFunc(bool error_msg, const SQChar *message)
|
||||
{
|
||||
/* Convert to OpenTTD internal capable string */
|
||||
ScriptController::Print(error_msg, SQ2OTTD(message));
|
||||
ScriptController::Print(error_msg, message);
|
||||
}
|
||||
|
||||
ScriptInstance::ScriptInstance(const char *APIName) :
|
||||
@@ -114,8 +116,8 @@ bool ScriptInstance::LoadCompatibilityScripts(const char *api_version, Subdirect
|
||||
char buf[MAX_PATH];
|
||||
Searchpath sp;
|
||||
FOR_ALL_SEARCHPATHS(sp) {
|
||||
FioAppendDirectory(buf, MAX_PATH, sp, dir);
|
||||
ttd_strlcat(buf, script_name, MAX_PATH);
|
||||
FioAppendDirectory(buf, lastof(buf), sp, dir);
|
||||
strecat(buf, script_name, lastof(buf));
|
||||
if (!FileExists(buf)) continue;
|
||||
|
||||
if (this->engine->LoadScript(buf)) return true;
|
||||
@@ -365,11 +367,8 @@ static const SaveLoad _script_byte[] = {
|
||||
_script_sl_byte = SQSL_STRING;
|
||||
SlObject(NULL, _script_byte);
|
||||
}
|
||||
const SQChar *res;
|
||||
sq_getstring(vm, index, &res);
|
||||
/* @bug if a string longer than 512 characters is given to SQ2OTTD, the
|
||||
* internal buffer overflows. */
|
||||
const char *buf = SQ2OTTD(res);
|
||||
const SQChar *buf;
|
||||
sq_getstring(vm, index, &buf);
|
||||
size_t len = strlen(buf) + 1;
|
||||
if (len >= 255) {
|
||||
ScriptLog::Error("Maximum string length is 254 chars. No data saved.");
|
||||
@@ -567,7 +566,7 @@ bool ScriptInstance::IsPaused()
|
||||
SlObject(NULL, _script_byte);
|
||||
static char buf[256];
|
||||
SlArray(buf, _script_sl_byte, SLE_CHAR);
|
||||
if (vm != NULL) sq_pushstring(vm, OTTD2SQ(buf), -1);
|
||||
if (vm != NULL) sq_pushstring(vm, buf, -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -592,7 +591,7 @@ bool ScriptInstance::IsPaused()
|
||||
|
||||
case SQSL_BOOL: {
|
||||
SlObject(NULL, _script_byte);
|
||||
if (vm != NULL) sq_pushinteger(vm, (SQBool)(_script_sl_byte != 0));
|
||||
if (vm != NULL) sq_pushbool(vm, (SQBool)(_script_sl_byte != 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -656,7 +655,7 @@ bool ScriptInstance::CallLoad()
|
||||
/* Go to the instance-root */
|
||||
sq_pushobject(vm, *this->instance);
|
||||
/* Find the function-name inside the script */
|
||||
sq_pushstring(vm, OTTD2SQ("Load"), -1);
|
||||
sq_pushstring(vm, "Load", -1);
|
||||
/* Change the "Load" string in a function pointer */
|
||||
sq_get(vm, -2);
|
||||
/* Push the main instance as "this" object */
|
||||
|
||||
Reference in New Issue
Block a user