Codechange: Don't use globals for story/goal/sign/group command proc return values.
This commit is contained in:
@@ -161,11 +161,6 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
GetStorage()->last_command_res = res;
|
||||
/* Also store the results of various global variables */
|
||||
SetNewVehicleID(_new_vehicle_id);
|
||||
SetNewSignID(_new_sign_id);
|
||||
SetNewGroupID(_new_group_id);
|
||||
SetNewGoalID(_new_goal_id);
|
||||
SetNewStoryPageID(_new_story_page_id);
|
||||
SetNewStoryPageElementID(_new_story_page_element_id);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptObject::GetLastCommandRes()
|
||||
@@ -193,56 +188,6 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
return GetStorage()->new_vehicle_id;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetNewSignID(SignID sign_id)
|
||||
{
|
||||
GetStorage()->new_sign_id = sign_id;
|
||||
}
|
||||
|
||||
/* static */ SignID ScriptObject::GetNewSignID()
|
||||
{
|
||||
return GetStorage()->new_sign_id;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetNewGroupID(GroupID group_id)
|
||||
{
|
||||
GetStorage()->new_group_id = group_id;
|
||||
}
|
||||
|
||||
/* static */ GroupID ScriptObject::GetNewGroupID()
|
||||
{
|
||||
return GetStorage()->new_group_id;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetNewGoalID(GoalID goal_id)
|
||||
{
|
||||
GetStorage()->new_goal_id = goal_id;
|
||||
}
|
||||
|
||||
/* static */ GroupID ScriptObject::GetNewGoalID()
|
||||
{
|
||||
return GetStorage()->new_goal_id;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetNewStoryPageID(StoryPageID story_page_id)
|
||||
{
|
||||
GetStorage()->new_story_page_id = story_page_id;
|
||||
}
|
||||
|
||||
/* static */ GroupID ScriptObject::GetNewStoryPageID()
|
||||
{
|
||||
return GetStorage()->new_story_page_id;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetNewStoryPageElementID(StoryPageElementID story_page_element_id)
|
||||
{
|
||||
GetStorage()->new_story_page_element_id = story_page_element_id;
|
||||
}
|
||||
|
||||
/* static */ GroupID ScriptObject::GetNewStoryPageElementID()
|
||||
{
|
||||
return GetStorage()->new_story_page_element_id;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetAllowDoCommand(bool allow)
|
||||
{
|
||||
GetStorage()->allow_do_command = allow;
|
||||
|
@@ -197,31 +197,6 @@ protected:
|
||||
*/
|
||||
static VehicleID GetNewVehicleID();
|
||||
|
||||
/**
|
||||
* Get the latest stored new_sign_id.
|
||||
*/
|
||||
static SignID GetNewSignID();
|
||||
|
||||
/**
|
||||
* Get the latest stored new_group_id.
|
||||
*/
|
||||
static GroupID GetNewGroupID();
|
||||
|
||||
/**
|
||||
* Get the latest stored new_goal_id.
|
||||
*/
|
||||
static GoalID GetNewGoalID();
|
||||
|
||||
/**
|
||||
* Get the latest stored new_story_page_id.
|
||||
*/
|
||||
static StoryPageID GetNewStoryPageID();
|
||||
|
||||
/**
|
||||
* Get the latest stored new_story_page_id.
|
||||
*/
|
||||
static StoryPageID GetNewStoryPageElementID();
|
||||
|
||||
/**
|
||||
* Store a allow_do_command per company.
|
||||
* @param allow The new allow.
|
||||
@@ -305,36 +280,6 @@ private:
|
||||
*/
|
||||
static void SetNewVehicleID(VehicleID vehicle_id);
|
||||
|
||||
/**
|
||||
* Store a new_sign_id per company.
|
||||
* @param sign_id The new SignID.
|
||||
*/
|
||||
static void SetNewSignID(SignID sign_id);
|
||||
|
||||
/**
|
||||
* Store a new_group_id per company.
|
||||
* @param group_id The new GroupID.
|
||||
*/
|
||||
static void SetNewGroupID(GroupID group_id);
|
||||
|
||||
/**
|
||||
* Store a new_goal_id per company.
|
||||
* @param goal_id The new GoalID.
|
||||
*/
|
||||
static void SetNewGoalID(GoalID goal_id);
|
||||
|
||||
/**
|
||||
* Store a new_story_page_id per company.
|
||||
* @param story_page_id The new StoryPageID.
|
||||
*/
|
||||
static void SetNewStoryPageID(StoryPageID story_page_id);
|
||||
|
||||
/**
|
||||
* Store a new_story_page_id per company.
|
||||
* @param story_page_id The new StoryPageID.
|
||||
*/
|
||||
static void SetNewStoryPageElementID(StoryPageElementID story_page_element_id);
|
||||
|
||||
/* Helper functions for DoCommand. */
|
||||
static std::tuple<bool, bool, bool> DoCommandPrep();
|
||||
static bool DoCommandProcessResult(const CommandCost &res, Script_SuspendCallbackProc *callback, bool estimate_only);
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "../company_base.h"
|
||||
#include "../company_func.h"
|
||||
#include "../fileio_func.h"
|
||||
#include "../misc/endian_buffer.hpp"
|
||||
|
||||
#include "../safeguards.h"
|
||||
|
||||
@@ -274,27 +275,27 @@ void ScriptInstance::CollectGarbage()
|
||||
|
||||
/* static */ void ScriptInstance::DoCommandReturnSignID(ScriptInstance *instance)
|
||||
{
|
||||
instance->engine->InsertResult(ScriptObject::GetNewSignID());
|
||||
instance->engine->InsertResult(EndianBufferReader::ToValue<SignID>(ScriptObject::GetLastCommandResData()));
|
||||
}
|
||||
|
||||
/* static */ void ScriptInstance::DoCommandReturnGroupID(ScriptInstance *instance)
|
||||
{
|
||||
instance->engine->InsertResult(ScriptObject::GetNewGroupID());
|
||||
instance->engine->InsertResult(EndianBufferReader::ToValue<GroupID>(ScriptObject::GetLastCommandResData()));
|
||||
}
|
||||
|
||||
/* static */ void ScriptInstance::DoCommandReturnGoalID(ScriptInstance *instance)
|
||||
{
|
||||
instance->engine->InsertResult(ScriptObject::GetNewGoalID());
|
||||
instance->engine->InsertResult(EndianBufferReader::ToValue<GoalID>(ScriptObject::GetLastCommandResData()));
|
||||
}
|
||||
|
||||
/* static */ void ScriptInstance::DoCommandReturnStoryPageID(ScriptInstance *instance)
|
||||
{
|
||||
instance->engine->InsertResult(ScriptObject::GetNewStoryPageID());
|
||||
instance->engine->InsertResult(EndianBufferReader::ToValue<StoryPageID>(ScriptObject::GetLastCommandResData()));
|
||||
}
|
||||
|
||||
/* static */ void ScriptInstance::DoCommandReturnStoryPageElementID(ScriptInstance *instance)
|
||||
{
|
||||
instance->engine->InsertResult(ScriptObject::GetNewStoryPageElementID());
|
||||
instance->engine->InsertResult(EndianBufferReader::ToValue<StoryPageElementID>(ScriptObject::GetLastCommandResData()));
|
||||
}
|
||||
|
||||
ScriptStorage *ScriptInstance::GetStorage()
|
||||
|
@@ -50,11 +50,6 @@ private:
|
||||
CommandDataBuffer last_cmd_ret; ///< The extra data returned by the last command.
|
||||
|
||||
VehicleID new_vehicle_id; ///< The ID of the new Vehicle.
|
||||
SignID new_sign_id; ///< The ID of the new Sign.
|
||||
GroupID new_group_id; ///< The ID of the new Group.
|
||||
GoalID new_goal_id; ///< The ID of the new Goal.
|
||||
StoryPageID new_story_page_id; ///< The ID of the new StoryPage.
|
||||
StoryPageID new_story_page_element_id; ///< The ID of the new StoryPageElement.
|
||||
|
||||
std::vector<int> callback_value; ///< The values which need to survive a callback.
|
||||
|
||||
@@ -79,11 +74,6 @@ public:
|
||||
last_tile (INVALID_TILE),
|
||||
last_cmd (CMD_END),
|
||||
new_vehicle_id (0),
|
||||
new_sign_id (0),
|
||||
new_group_id (0),
|
||||
new_goal_id (0),
|
||||
new_story_page_id (0),
|
||||
new_story_page_element_id(0),
|
||||
/* calback_value (can't be set) */
|
||||
road_type (INVALID_ROADTYPE),
|
||||
rail_type (INVALID_RAILTYPE),
|
||||
|
Reference in New Issue
Block a user