Merge branch 'master' into jgrpp

This commit is contained in:
Jonathan G Rennison
2019-11-16 19:54:31 +00:00
69 changed files with 805 additions and 814 deletions

View File

@@ -58,9 +58,11 @@
{
CCountedPtr<Text> counter(text);
EnforcePrecondition(false, text != nullptr);
const char *encoded_text = text->GetEncodedText();
EnforcePreconditionEncodedText(false, encoded_text);
const char *encoded_text = nullptr;
if (text != nullptr) {
encoded_text = text->GetEncodedText();
EnforcePreconditionEncodedText(false, encoded_text);
}
EnforcePrecondition(false, IsValidTown(town_id));
return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, 0, CMD_TOWN_SET_TEXT, encoded_text);

View File

@@ -146,7 +146,7 @@ public:
/**
* Rename a town.
* @param town_id The town to rename
* @param name The new name of the town. If nullptr or an empty string is passed, the town name will be reset to the default name.
* @param name The new name of the town. If null is passed, the town name will be reset to the default name.
* @pre IsValidTown(town_id).
* @return True if the action succeeded.
* @api -ai
@@ -156,7 +156,7 @@ public:
/**
* Set the custom text of a town, shown in the GUI.
* @param town_id The town to set the custom text of.
* @param text The text to set it to (can be either a raw string, or a ScriptText object).
* @param text The text to set it to (can be either a raw string, or a ScriptText object). If null is passed, the text will be removed.
* @pre IsValidTown(town_id).
* @return True if the action succeeded.
* @api -ai

View File

@@ -87,7 +87,7 @@ void ScriptInstance::Initialize(const char *main_script, const char *instance_na
}
/* Create the main-class */
this->instance = MallocT<SQObject>(1);
this->instance = new SQObject();
if (!this->engine->CreateClassInstance(instance_name, this->controller, this->instance)) {
/* If CreateClassInstance has returned false instance has not been
* registered with squirrel, so avoid trying to Release it by clearing it now */
@@ -141,7 +141,7 @@ ScriptInstance::~ScriptInstance()
if (engine != nullptr) delete this->engine;
delete this->storage;
delete this->controller;
free(this->instance);
delete this->instance;
}
void ScriptInstance::Continue()