|
@@ -831,97 +831,97 @@ static void AgeShipCargo(Vehicle *v)
|
|
|
|
|
|
void Ship_Tick(Vehicle *v)
|
|
|
{
|
|
|
AgeShipCargo(v);
|
|
|
ShipController(v);
|
|
|
}
|
|
|
|
|
|
void HandleClickOnShip(Vehicle *v)
|
|
|
{
|
|
|
ShowShipViewWindow(v);
|
|
|
}
|
|
|
|
|
|
void ShipsYearlyLoop(void)
|
|
|
{
|
|
|
Vehicle *v;
|
|
|
|
|
|
FOR_ALL_VEHICLES(v) {
|
|
|
if (v->type == VEH_Ship) {
|
|
|
v->profit_last_year = v->profit_this_year;
|
|
|
v->profit_this_year = 0;
|
|
|
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/** Build a ship.
|
|
|
* @param x,y tile coordinates of depot where ship is built
|
|
|
* @param p1 ship type being built (engine)
|
|
|
* @param p2 unused
|
|
|
*/
|
|
|
int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
int32 value;
|
|
|
Vehicle *v;
|
|
|
UnitID unit_num;
|
|
|
TileIndex tile = TILE_FROM_XY(x,y);
|
|
|
Engine *e;
|
|
|
|
|
|
if (!IsEngineBuildable(p1, VEH_Ship)) return CMD_ERROR;
|
|
|
|
|
|
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
|
|
|
|
|
value = EstimateShipCost(p1);
|
|
|
if (flags & DC_QUERY_COST) return value;
|
|
|
|
|
|
/* The ai_new queries the vehicle cost before building the route,
|
|
|
* so we must check against cheaters no sooner than now. --pasky */
|
|
|
if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR;
|
|
|
if (_map_owner[tile] != _current_player) return CMD_ERROR;
|
|
|
if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
|
|
|
|
|
|
v = AllocateVehicle();
|
|
|
if (v == NULL || IsOrderPoolFull() ||
|
|
|
(unit_num = GetFreeUnitNumber(VEH_Ship)) > _patches.max_ships)
|
|
|
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
const ShipVehicleInfo *svi = ShipVehInfo(p1);
|
|
|
|
|
|
v->unitnumber = unit_num;
|
|
|
|
|
|
v->owner = _current_player;
|
|
|
v->tile = tile;
|
|
|
x = TileX(tile) * 16 + 8;
|
|
|
y = TileY(tile) * 16 + 8;
|
|
|
v->x_pos = x;
|
|
|
v->y_pos = y;
|
|
|
v->z_pos = GetSlopeZ(x,y);
|
|
|
|
|
|
v->z_height = 6;
|
|
|
v->sprite_width = 6;
|
|
|
v->sprite_height = 6;
|
|
|
v->x_offs = -3;
|
|
|
v->y_offs = -3;
|
|
|
v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
|
|
|
|
|
|
v->spritenum = svi->image_index;
|
|
|
v->cargo_type = svi->cargo_type;
|
|
|
v->cargo_cap = svi->capacity;
|
|
|
v->value = value;
|
|
|
|
|
|
v->last_station_visited = INVALID_STATION;
|
|
|
v->max_speed = svi->max_speed;
|
|
|
v->engine_type = (byte)p1;
|
|
|
|
|
|
e = &_engines[p1];
|
|
|
v->reliability = e->reliability;
|
|
|
v->reliability_spd_dec = e->reliability_spd_dec;
|
|
|
v->max_age = e->lifelength * 366;
|
|
|
_new_ship_id = v->index;
|
|
|
|
|
|
v->string_id = STR_SV_SHIP_NAME;
|
|
|
v->u.ship.state = 0x80;
|
|
|
|
|
|
v->service_interval = _patches.servint_ships;
|
|
|
v->date_of_last_service = _date;
|
|
|
v->build_year = _cur_year;
|
|
|
v->cur_image = 0x0E5E;
|