(svn r23777) -Codechange: refactor allocating memory and fetching strings into a single function for scripts

This commit is contained in:
rubidium
2012-01-08 21:48:05 +00:00
parent ab38e3227d
commit 4479f90843
14 changed files with 27 additions and 60 deletions

View File

@@ -16,6 +16,8 @@
#include "../../company_base.h"
#include "../../network/network.h"
#include "../../genworld.h"
#include "../../string_func.h"
#include "../../strings_func.h"
#include "../script_storage.hpp"
#include "../script_instance.hpp"
@@ -233,6 +235,13 @@ ScriptObject::ActiveInstance::~ActiveInstance()
return GetStorage()->log_data;
}
/* static */ char *ScriptObject::GetString(StringID string)
{
char buffer[64];
::GetString(buffer, string, lastof(buffer));
return ::strdup(buffer);
}
/* static */ void ScriptObject::SetCallbackVariable(int index, int value)
{
if ((size_t)index >= GetStorage()->callback_value.size()) GetStorage()->callback_value.resize(index + 1);