equal
deleted
inserted
replaced
20 return r | r >> 8; |
20 return r | r >> 8; |
21 } |
21 } |
22 |
22 |
23 void DrawShipEngine(int x, int y, int engine, uint32 image_ormod) |
23 void DrawShipEngine(int x, int y, int engine, uint32 image_ormod) |
24 { |
24 { |
25 int spritenum = ship_vehicle_info(engine).image_index; |
25 int spritenum = ShipVehInfo(engine)->image_index; |
26 |
26 |
27 if (is_custom_sprite(spritenum)) { |
27 if (is_custom_sprite(spritenum)) { |
28 int sprite = GetCustomVehicleIcon(engine, 6); |
28 int sprite = GetCustomVehicleIcon(engine, 6); |
29 |
29 |
30 if (sprite) { |
30 if (sprite) { |
36 DrawSprite((6 + _ship_sprites[spritenum]) | image_ormod, x, y); |
36 DrawSprite((6 + _ship_sprites[spritenum]) | image_ormod, x, y); |
37 } |
37 } |
38 |
38 |
39 void DrawShipEngineInfo(int engine, int x, int y, int maxw) |
39 void DrawShipEngineInfo(int engine, int x, int y, int maxw) |
40 { |
40 { |
41 ShipVehicleInfo *svi = &ship_vehicle_info(engine); |
41 const ShipVehicleInfo *svi = ShipVehInfo(engine); |
42 SetDParam(0, svi->base_cost * (_price.ship_base>>3)>>5); |
42 SetDParam(0, svi->base_cost * (_price.ship_base>>3)>>5); |
43 SetDParam(1, svi->max_speed * 10 >> 5); |
43 SetDParam(1, svi->max_speed * 10 >> 5); |
44 SetDParam(2, _cargoc.names_long_p[svi->cargo_type]); |
44 SetDParam(2, _cargoc.names_long_p[svi->cargo_type]); |
45 SetDParam(3, svi->capacity); |
45 SetDParam(3, svi->capacity); |
46 SetDParam(4, svi->running_cost * _price.ship_running >> 8); |
46 SetDParam(4, svi->running_cost * _price.ship_running >> 8); |
133 if (v->vehstatus & VS_STOPPED) |
133 if (v->vehstatus & VS_STOPPED) |
134 return; |
134 return; |
135 |
135 |
136 |
136 |
137 |
137 |
138 cost = ship_vehicle_info(v->engine_type).running_cost * _price.ship_running / 364; |
138 cost = ShipVehInfo(v->engine_type)->running_cost * _price.ship_running / 364; |
139 v->profit_this_year -= cost >> 8; |
139 v->profit_this_year -= cost >> 8; |
140 |
140 |
141 SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN); |
141 SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN); |
142 SubtractMoneyFromPlayerFract(v->owner, cost); |
142 SubtractMoneyFromPlayerFract(v->owner, cost); |
143 |
143 |
180 MarkAllViewportsDirty(v->left_coord, v->top_coord, v->right_coord + 1, v->bottom_coord + 1); |
180 MarkAllViewportsDirty(v->left_coord, v->top_coord, v->right_coord + 1, v->bottom_coord + 1); |
181 } |
181 } |
182 |
182 |
183 static void PlayShipSound(Vehicle *v) |
183 static void PlayShipSound(Vehicle *v) |
184 { |
184 { |
185 SndPlayVehicleFx(ship_vehicle_info(v->engine_type).sfx, v); |
185 SndPlayVehicleFx(ShipVehInfo(v->engine_type)->sfx, v); |
186 } |
186 } |
187 |
187 |
188 static const TileIndexDiff _dock_offs[] = { |
188 static const TileIndexDiff _dock_offs[] = { |
189 TILE_XY(2, 0), |
189 TILE_XY(2, 0), |
190 TILE_XY(-2, 0), |
190 TILE_XY(-2, 0), |
780 } |
780 } |
781 } |
781 } |
782 |
782 |
783 static int32 EstimateShipCost(uint16 engine_type) |
783 static int32 EstimateShipCost(uint16 engine_type) |
784 { |
784 { |
785 return ship_vehicle_info(engine_type).base_cost * (_price.ship_base>>3)>>5; |
785 return ShipVehInfo(engine_type)->base_cost * (_price.ship_base>>3)>>5; |
786 } |
786 } |
787 |
787 |
788 // p1 = type to build |
788 // p1 = type to build |
789 int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
789 int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
790 { |
790 { |
804 if (v == NULL || _ptr_to_next_order >= endof(_order_array) || |
804 if (v == NULL || _ptr_to_next_order >= endof(_order_array) || |
805 (unit_num = GetFreeUnitNumber(VEH_Ship)) > _patches.max_ships) |
805 (unit_num = GetFreeUnitNumber(VEH_Ship)) > _patches.max_ships) |
806 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
806 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
807 |
807 |
808 if (flags & DC_EXEC) { |
808 if (flags & DC_EXEC) { |
|
809 const ShipVehicleInfo *svi = ShipVehInfo(p1); |
|
810 |
809 v->unitnumber = unit_num; |
811 v->unitnumber = unit_num; |
810 |
812 |
811 v->owner = _current_player; |
813 v->owner = _current_player; |
812 v->tile = tile; |
814 v->tile = tile; |
813 x = GET_TILE_X(tile)*16 + 8; |
815 x = GET_TILE_X(tile)*16 + 8; |
821 v->sprite_height = 6; |
823 v->sprite_height = 6; |
822 v->x_offs = -3; |
824 v->x_offs = -3; |
823 v->y_offs = -3; |
825 v->y_offs = -3; |
824 v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL; |
826 v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL; |
825 |
827 |
826 v->spritenum = ship_vehicle_info(p1).image_index; |
828 v->spritenum = svi->image_index; |
827 v->cargo_type = ship_vehicle_info(p1).cargo_type; |
829 v->cargo_type = svi->cargo_type; |
828 v->cargo_cap = ship_vehicle_info(p1).capacity; |
830 v->cargo_cap = svi->capacity; |
829 v->value = value; |
831 v->value = value; |
830 |
832 |
831 v->last_station_visited = 255; |
833 v->last_station_visited = 255; |
832 v->max_speed = ship_vehicle_info(p1).max_speed; |
834 v->max_speed = svi->max_speed; |
833 v->engine_type = (byte)p1; |
835 v->engine_type = (byte)p1; |
834 |
836 |
835 e = &_engines[p1]; |
837 e = &_engines[p1]; |
836 v->reliability = e->reliability; |
838 v->reliability = e->reliability; |
837 v->reliability_spd_dec = e->reliability_spd_dec; |
839 v->reliability_spd_dec = e->reliability_spd_dec; |