|
@@ -307,25 +307,25 @@ static void UpdateShipDeltaXY(Vehicle *v
|
|
|
MKIT(-16, -3, 32, 6),
|
|
|
MKIT( -3, -3, 6, 6),
|
|
|
MKIT( -3, -16, 6, 32),
|
|
|
};
|
|
|
#undef MKIT
|
|
|
uint32 x = _delta_xy_table[dir];
|
|
|
v->x_offs = GB(x, 0, 8);
|
|
|
v->y_offs = GB(x, 8, 8);
|
|
|
v->sprite_width = GB(x, 16, 8);
|
|
|
v->sprite_height = GB(x, 24, 8);
|
|
|
}
|
|
|
|
|
|
static void RecalcShipStuff(Vehicle *v)
|
|
|
void RecalcShipStuff(Vehicle *v)
|
|
|
{
|
|
|
UpdateShipDeltaXY(v, v->direction);
|
|
|
v->cur_image = GetShipImage(v, v->direction);
|
|
|
MarkShipDirty(v);
|
|
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
|
|
}
|
|
|
|
|
|
static const TileIndexDiffC _ship_leave_depot_offs[] = {
|
|
|
{-1, 0},
|
|
|
{ 0, -1}
|
|
|
};
|
|
|
|
|
@@ -382,68 +382,24 @@ static bool ShipAccelerate(Vehicle *v)
|
|
|
if ((byte)++spd == 0) return true;
|
|
|
|
|
|
v->progress = (t = v->progress) - (byte)spd;
|
|
|
|
|
|
return (t < v->progress);
|
|
|
}
|
|
|
|
|
|
static int32 EstimateShipCost(EngineID engine_type)
|
|
|
{
|
|
|
return ShipVehInfo(engine_type)->base_cost * (_price.ship_base>>3)>>5;
|
|
|
}
|
|
|
|
|
|
static void ShipEnterDepot(Vehicle *v)
|
|
|
{
|
|
|
v->u.ship.state = 0x80;
|
|
|
v->vehstatus |= VS_HIDDEN;
|
|
|
v->cur_speed = 0;
|
|
|
RecalcShipStuff(v);
|
|
|
|
|
|
VehicleServiceInDepot(v);
|
|
|
|
|
|
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
|
|
|
|
|
TriggerVehicle(v, VEHICLE_TRIGGER_DEPOT);
|
|
|
|
|
|
if (v->current_order.type == OT_GOTO_DEPOT) {
|
|
|
Order t;
|
|
|
int32 cost;
|
|
|
|
|
|
InvalidateWindow(WC_VEHICLE_VIEW, v->index);
|
|
|
|
|
|
t = v->current_order;
|
|
|
v->current_order.type = OT_DUMMY;
|
|
|
v->current_order.flags = 0;
|
|
|
|
|
|
_current_player = v->owner;
|
|
|
cost = DoCommand(v->tile, v->index, t.refit_cargo | t.refit_subtype << 8, DC_EXEC, CMD_REFIT_SHIP);
|
|
|
if (!CmdFailed(cost) && v->owner == _local_player && cost != 0) ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost);
|
|
|
|
|
|
if (HASBIT(t.flags, OFB_PART_OF_ORDERS)) {
|
|
|
v->cur_order_index++;
|
|
|
} else if (HASBIT(t.flags, OFB_HALT_IN_DEPOT)) {
|
|
|
v->vehstatus |= VS_STOPPED;
|
|
|
if (v->owner == _local_player) {
|
|
|
SetDParam(0, v->unitnumber);
|
|
|
AddNewsItem(
|
|
|
STR_981C_SHIP_IS_WAITING_IN_DEPOT,
|
|
|
NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
|
|
|
v->index,
|
|
|
0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
InvalidateWindowClasses(WC_SHIPS_LIST);
|
|
|
}
|
|
|
|
|
|
static void ShipArrivesAt(const Vehicle* v, Station* st)
|
|
|
{
|
|
|
/* Check if station was ever visited before */
|
|
|
if (!(st->had_vehicle_of_type & HVOT_SHIP)) {
|
|
|
uint32 flags;
|
|
|
|
|
|
st->had_vehicle_of_type |= HVOT_SHIP;
|
|
|
|
|
|
SetDParam(0, st->index);
|
|
|
flags = (v->owner == _local_player) ? NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_PLAYER, 0) : NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_OTHER, 0);
|
|
|
AddNewsItem(
|
|
|
STR_9833_CITIZENS_CELEBRATE_FIRST,
|
|
@@ -722,25 +678,25 @@ static void ShipController(Vehicle *v)
|
|
|
IsBuoyTile(v->dest_tile) &&
|
|
|
DistanceManhattan(v->dest_tile, gp.new_tile) <= 3) {
|
|
|
/* We got within 3 tiles of our target buoy, so let's skip to our
|
|
|
* next order */
|
|
|
v->cur_order_index++;
|
|
|
v->current_order.type = OT_DUMMY;
|
|
|
InvalidateVehicleOrder(v);
|
|
|
} else {
|
|
|
/* Non-buoy orders really need to reach the tile */
|
|
|
if (v->dest_tile == gp.new_tile) {
|
|
|
if (v->current_order.type == OT_GOTO_DEPOT) {
|
|
|
if ((gp.x&0xF)==8 && (gp.y&0xF)==8) {
|
|
|
ShipEnterDepot(v);
|
|
|
VehicleEnterDepot(v);
|
|
|
return;
|
|
|
}
|
|
|
} else if (v->current_order.type == OT_GOTO_STATION) {
|
|
|
Station *st;
|
|
|
|
|
|
v->last_station_visited = v->current_order.dest;
|
|
|
|
|
|
/* Process station in the orderlist. */
|
|
|
st = GetStation(v->current_order.dest);
|
|
|
if (st->facilities & FACIL_DOCK) { /* ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations */
|
|
|
v->current_order.type = OT_LOADING;
|
|
|
v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
|