mirror of https://github.com/OpenTTD/OpenTTD
(svn r22150) [1.1] -Backport from trunk:
- Fix: When a NOT_REACHED in saveload can be reached due to an invalid savegame, use SlErrorCorrupt instead. In other words, do not crash but show an error message (r22122) - Fix: In case of high frame_freq one could get commands executed after a new network game was started (r22121) - Fix: [NoAI] Prevent AIs from getting consistently over their allowed amount of operations by subtracting the amount they went over 'budget' from the budget for the next 'tick' (r22120) - Fix: The refit window was not correctly updated after selecting with Ctrl+Click [FS#4525] (r22118) - Fix: CanRemoveRoadWithStop() failed for _current_company = OWNER_TOWN, and for OWNER_NONE-owned road (r22117)release/1.1
parent
96ab68d6bc
commit
cad2aa6b14
|
@ -221,10 +221,11 @@ void NetworkExecuteLocalCommandQueue()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free the local command queue.
|
* Free the local command queues.
|
||||||
*/
|
*/
|
||||||
void NetworkFreeLocalCommandQueue()
|
void NetworkFreeLocalCommandQueue()
|
||||||
{
|
{
|
||||||
|
_local_wait_queue.Free();
|
||||||
_local_execution_queue.Free();
|
_local_execution_queue.Free();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,7 +326,7 @@ void AfterLoadVehicles(bool part_of_load)
|
||||||
rv->subtype = 0;
|
rv->subtype = 0;
|
||||||
rv->SetArticulatedPart();
|
rv->SetArticulatedPart();
|
||||||
} else {
|
} else {
|
||||||
NOT_REACHED();
|
SlErrorCorrupt("Invalid road vehicle subtype");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,19 @@ bool Squirrel::MethodExists(HSQOBJECT instance, const char *method_name)
|
||||||
bool Squirrel::Resume(int suspend)
|
bool Squirrel::Resume(int suspend)
|
||||||
{
|
{
|
||||||
assert(!this->crashed);
|
assert(!this->crashed);
|
||||||
|
/* Did we use more operations than we should have in the
|
||||||
|
* previous tick? If so, subtract that from the current run. */
|
||||||
|
if (this->overdrawn_ops > 0 && suspend > 0) {
|
||||||
|
this->overdrawn_ops -= suspend;
|
||||||
|
/* Do we need to wait even more? */
|
||||||
|
if (this->overdrawn_ops >= 0) return true;
|
||||||
|
|
||||||
|
/* We can now only run whatever is "left". */
|
||||||
|
suspend = -this->overdrawn_ops;
|
||||||
|
}
|
||||||
|
|
||||||
this->crashed = !sq_resumecatch(this->vm, suspend);
|
this->crashed = !sq_resumecatch(this->vm, suspend);
|
||||||
|
this->overdrawn_ops = -this->vm->_ops_till_suspend;
|
||||||
return this->vm->_suspended != 0;
|
return this->vm->_suspended != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,6 +322,7 @@ Squirrel::Squirrel()
|
||||||
this->print_func = NULL;
|
this->print_func = NULL;
|
||||||
this->global_pointer = NULL;
|
this->global_pointer = NULL;
|
||||||
this->crashed = false;
|
this->crashed = false;
|
||||||
|
this->overdrawn_ops = 0;
|
||||||
|
|
||||||
/* Handle compile-errors ourself, so we can display it nicely */
|
/* Handle compile-errors ourself, so we can display it nicely */
|
||||||
sq_setcompilererrorhandler(this->vm, &Squirrel::CompileError);
|
sq_setcompilererrorhandler(this->vm, &Squirrel::CompileError);
|
||||||
|
|
|
@ -22,6 +22,7 @@ private:
|
||||||
void *global_pointer; ///< Can be set by who ever initializes Squirrel
|
void *global_pointer; ///< Can be set by who ever initializes Squirrel
|
||||||
SQPrintFunc *print_func; ///< Points to either NULL, or a custom print handler
|
SQPrintFunc *print_func; ///< Points to either NULL, or a custom print handler
|
||||||
bool crashed; ///< True if the squirrel script made an error.
|
bool crashed; ///< True if the squirrel script made an error.
|
||||||
|
int overdrawn_ops; ///< The amount of operations we have overdrawn.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The internal RunError handler. It looks up the real error and calls RunError with it.
|
* The internal RunError handler. It looks up the real error and calls RunError with it.
|
||||||
|
|
|
@ -3452,16 +3452,21 @@ static bool CanRemoveRoadWithStop(TileIndex tile, DoCommandFlag flags)
|
||||||
/* Yeah... water can always remove stops, right? */
|
/* Yeah... water can always remove stops, right? */
|
||||||
if (_current_company == OWNER_WATER) return true;
|
if (_current_company == OWNER_WATER) return true;
|
||||||
|
|
||||||
Owner road_owner = _current_company;
|
|
||||||
Owner tram_owner = _current_company;
|
|
||||||
|
|
||||||
RoadTypes rts = GetRoadTypes(tile);
|
RoadTypes rts = GetRoadTypes(tile);
|
||||||
if (HasBit(rts, ROADTYPE_ROAD)) road_owner = GetRoadOwner(tile, ROADTYPE_ROAD);
|
if (HasBit(rts, ROADTYPE_TRAM)) {
|
||||||
if (HasBit(rts, ROADTYPE_TRAM)) tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM);
|
Owner tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM);
|
||||||
|
if (tram_owner != OWNER_NONE && CheckOwnership(tram_owner).Failed()) return false;
|
||||||
|
}
|
||||||
|
if (HasBit(rts, ROADTYPE_ROAD)) {
|
||||||
|
Owner road_owner = GetRoadOwner(tile, ROADTYPE_ROAD);
|
||||||
|
if (road_owner != OWNER_TOWN) {
|
||||||
|
if (road_owner != OWNER_NONE && CheckOwnership(road_owner).Failed()) return false;
|
||||||
|
} else {
|
||||||
|
if (CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_ROAD), OWNER_TOWN, ROADTYPE_ROAD, flags).Failed()) return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((road_owner != OWNER_TOWN && CheckOwnership(road_owner).Failed()) || CheckOwnership(tram_owner).Failed()) return false;
|
return true;
|
||||||
|
|
||||||
return road_owner != OWNER_TOWN || CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_ROAD), OWNER_TOWN, ROADTYPE_ROAD, flags).Succeeded();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags)
|
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags)
|
||||||
|
|
|
@ -795,7 +795,12 @@ struct RefitWindow : public Window {
|
||||||
this->click_x = GetClickPosition(pt.x - nwi->pos_x);
|
this->click_x = GetClickPosition(pt.x - nwi->pos_x);
|
||||||
this->SetSelectedVehicles(pt.x - nwi->pos_x);
|
this->SetSelectedVehicles(pt.x - nwi->pos_x);
|
||||||
this->SetWidgetDirty(VRW_VEHICLE_PANEL_DISPLAY);
|
this->SetWidgetDirty(VRW_VEHICLE_PANEL_DISPLAY);
|
||||||
if (!_ctrl_pressed) SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
|
if (!_ctrl_pressed) {
|
||||||
|
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
|
||||||
|
} else {
|
||||||
|
/* The vehicle selection has changed. */
|
||||||
|
this->InvalidateData(2);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue