diff --git a/src/3rdparty/squirrel/squirrel/sqbaselib.cpp b/src/3rdparty/squirrel/squirrel/sqbaselib.cpp index 486b888b53..66a81edb4b 100644 --- a/src/3rdparty/squirrel/squirrel/sqbaselib.cpp +++ b/src/3rdparty/squirrel/squirrel/sqbaselib.cpp @@ -210,16 +210,22 @@ static SQInteger base_suspend(HSQUIRRELVM v) static SQInteger base_array(HSQUIRRELVM v) { SQArray *a; - SQObject &size = stack_get(v,2); + SQInteger nInitialSize = tointeger(stack_get(v,2)); + SQInteger ret = 1; + if (nInitialSize < 0) { + v->Raise_Error(_SC("can't create/resize array with/to size %d"), nInitialSize); + nInitialSize = 0; + ret = -1; + } if(sq_gettop(v) > 2) { a = SQArray::Create(_ss(v),0); - a->Resize(tointeger(size),stack_get(v,3)); + a->Resize(nInitialSize,stack_get(v,3)); } else { - a = SQArray::Create(_ss(v),tointeger(size)); + a = SQArray::Create(_ss(v),nInitialSize); } v->Push(a); - return 1; + return ret; } static SQInteger base_type(HSQUIRRELVM v) diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 891798424b..128f231f83 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -254,9 +254,8 @@ static void IndustryDrawBubbleGenerator( const TileInfo *ti) { if (IsIndustryCompleted(ti->tile)) { AddChildSpriteScreen(SPR_IT_BUBBLE_GENERATOR_BUBBLE, PAL_NONE, 5, _industry_anim_offs_bubbles[GetAnimationFrame(ti->tile)]); - } else { - AddChildSpriteScreen(SPR_IT_BUBBLE_GENERATOR_SPRING, PAL_NONE, 3, 67); } + AddChildSpriteScreen(SPR_IT_BUBBLE_GENERATOR_SPRING, PAL_NONE, 3, 67); } static void IndustryDrawToyFactory(const TileInfo *ti) diff --git a/src/script/api/script_vehicle.cpp b/src/script/api/script_vehicle.cpp index b6a28af4f7..c4c6ca5905 100644 --- a/src/script/api/script_vehicle.cpp +++ b/src/script/api/script_vehicle.cpp @@ -311,7 +311,8 @@ { if (!IsValidVehicle(vehicle_id)) return -1; - return ::Vehicle::Get(vehicle_id)->GetDisplaySpeed(); // km-ish/h + const ::Vehicle *v = ::Vehicle::Get(vehicle_id); + return (v->vehstatus & (::VS_STOPPED | ::VS_CRASHED)) == 0 ? v->GetDisplaySpeed() : 0; // km-ish/h } /* static */ ScriptVehicle::VehicleState ScriptVehicle::GetState(VehicleID vehicle_id) diff --git a/src/script/api/script_vehicle.hpp b/src/script/api/script_vehicle.hpp index da36a542ce..bbcf929759 100644 --- a/src/script/api/script_vehicle.hpp +++ b/src/script/api/script_vehicle.hpp @@ -213,7 +213,7 @@ public: /** * Get the current speed of a vehicle. - * @param vehicle_id The vehicle to get the age of. + * @param vehicle_id The vehicle to get the speed of. * @pre IsValidVehicle(vehicle_id). * @return The current speed of the vehicle. * @note The speed is in OpenTTD's internal speed unit. @@ -232,7 +232,7 @@ public: /** * Get the running cost of this vehicle. - * @param vehicle_id The vehicle to get the age of. + * @param vehicle_id The vehicle to get the running cost of. * @pre IsValidVehicle(vehicle_id). * @return The running cost of the vehicle per year. * @note Cost is per year; divide by 365 to get per day.