diff options
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/script_company.cpp | 2 | ||||
-rw-r--r-- | src/script/api/script_types.hpp | 2 | ||||
-rw-r--r-- | src/script/squirrel_helper.hpp | 3 |
3 files changed, 5 insertions, 2 deletions
diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp index dddcc950c..876ad84c5 100644 --- a/src/script/api/script_company.cpp +++ b/src/script/api/script_company.cpp @@ -238,7 +238,7 @@ EnforcePrecondition(false, company != COMPANY_INVALID); /* Network commands only allow 0 to indicate invalid tiles, not INVALID_TILE */ - return ScriptObject::DoCommand(tile == INVALID_TILE ? 0 : tile , (uint32)(delta), company | expenses_type << 8 , CMD_CHANGE_BANK_BALANCE); + return ScriptObject::DoCommand(tile == INVALID_TILE ? (TileIndex)0U : tile , (uint32)(delta), company | expenses_type << 8 , CMD_CHANGE_BANK_BALANCE); } /* static */ bool ScriptCompany::BuildCompanyHQ(TileIndex tile) diff --git a/src/script/api/script_types.hpp b/src/script/api/script_types.hpp index 0d652a2d2..a570aabf7 100644 --- a/src/script/api/script_types.hpp +++ b/src/script/api/script_types.hpp @@ -82,6 +82,7 @@ #include "../../core/overflowsafe_type.hpp" #include "../../company_type.h" +#include "../../tile_type.h" #include <squirrel.h> /* Define all types here, so we don't have to include the whole _type.h maze */ @@ -100,7 +101,6 @@ typedef uint32 StringID; ///< The ID of a string. typedef uint16 SubsidyID; ///< The ID of a subsidy. typedef uint16 StoryPageID; ///< The ID of a story page. typedef uint16 StoryPageElementID; ///< The ID of a story page element. -typedef uint32 TileIndex; ///< The ID of a tile (just named differently). typedef uint16 TownID; ///< The ID of a town. typedef uint32 VehicleID; ///< The ID of a vehicle. diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp index 6a3ba6125..7308006fa 100644 --- a/src/script/squirrel_helper.hpp +++ b/src/script/squirrel_helper.hpp @@ -14,6 +14,7 @@ #include "../core/smallvec_type.hpp" #include "../economy_type.h" #include "../string_func.h" +#include "../tile_type.h" #include "squirrel_helper_type.hpp" template <class CL, ScriptType ST> const char *GetClassName(); @@ -85,6 +86,7 @@ namespace SQConvert { template <> inline int Return<int32> (HSQUIRRELVM vm, int32 res) { sq_pushinteger(vm, res); return 1; } template <> inline int Return<int64> (HSQUIRRELVM vm, int64 res) { sq_pushinteger(vm, res); return 1; } template <> inline int Return<Money> (HSQUIRRELVM vm, Money res) { sq_pushinteger(vm, res); return 1; } + template <> inline int Return<TileIndex> (HSQUIRRELVM vm, TileIndex res) { sq_pushinteger(vm, (int32)res.value); return 1; } template <> inline int Return<bool> (HSQUIRRELVM vm, bool res) { sq_pushbool (vm, res); return 1; } template <> inline int Return<char *> (HSQUIRRELVM vm, char *res) { if (res == nullptr) sq_pushnull(vm); else { sq_pushstring(vm, res, -1); free(res); } return 1; } template <> inline int Return<const char *>(HSQUIRRELVM vm, const char *res) { if (res == nullptr) sq_pushnull(vm); else { sq_pushstring(vm, res, -1); } return 1; } @@ -103,6 +105,7 @@ namespace SQConvert { template <> inline int16 GetParam(ForceType<int16> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } template <> inline int32 GetParam(ForceType<int32> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } template <> inline int64 GetParam(ForceType<int64> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } + template <> inline TileIndex GetParam(ForceType<TileIndex> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return TileIndex((uint32)(int32)tmp); } template <> inline Money GetParam(ForceType<Money> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } template <> inline bool GetParam(ForceType<bool> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQBool tmp; sq_getbool (vm, index, &tmp); return tmp != 0; } template <> inline void *GetParam(ForceType<void *> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer tmp; sq_getuserpointer(vm, index, &tmp); return tmp; } |