src/ship_cmd.cpp
changeset 7630 2cd754d7dfa4
parent 7592 48055c5dd43d
child 7631 e810ef25497e
equal deleted inserted replaced
7629:b7bbf31c33af 7630:2cd754d7dfa4
    88 
    88 
    89 	width  = spr->width;
    89 	width  = spr->width;
    90 	height = spr->height;
    90 	height = spr->height;
    91 }
    91 }
    92 
    92 
    93 int GetShipImage(const Vehicle* v, Direction direction)
    93 int Ship::GetImage(Direction direction) const
    94 {
    94 {
    95 	int spritenum = v->spritenum;
    95 	int spritenum = this->spritenum;
    96 
    96 
    97 	if (is_custom_sprite(spritenum)) {
    97 	if (is_custom_sprite(spritenum)) {
    98 		int sprite = GetCustomVehicleSprite(v, direction);
    98 		int sprite = GetCustomVehicleSprite(this, direction);
    99 
    99 
   100 		if (sprite != 0) return sprite;
   100 		if (sprite != 0) return sprite;
   101 		spritenum = orig_ship_vehicle_info[v->engine_type - SHIP_ENGINES_INDEX].image_index;
   101 		spritenum = orig_ship_vehicle_info[this->engine_type - SHIP_ENGINES_INDEX].image_index;
   102 	}
   102 	}
   103 	return _ship_sprites[spritenum] + direction;
   103 	return _ship_sprites[spritenum] + direction;
   104 }
   104 }
   105 
   105 
   106 static const Depot* FindClosestShipDepot(const Vehicle* v)
   106 static const Depot* FindClosestShipDepot(const Vehicle* v)
   231 	}
   231 	}
   232 }
   232 }
   233 
   233 
   234 void Ship::MarkDirty()
   234 void Ship::MarkDirty()
   235 {
   235 {
   236 	this->cur_image = GetShipImage(this, this->direction);
   236 	this->cur_image = this->GetImage(this->direction);
   237 	MarkAllViewportsDirty(this->left_coord, this->top_coord, this->right_coord + 1, this->bottom_coord + 1);
   237 	MarkAllViewportsDirty(this->left_coord, this->top_coord, this->right_coord + 1, this->bottom_coord + 1);
   238 }
   238 }
   239 
   239 
   240 static void PlayShipSound(const Vehicle *v)
   240 static void PlayShipSound(const Vehicle *v)
   241 {
   241 {
   335 }
   335 }
   336 
   336 
   337 void RecalcShipStuff(Vehicle *v)
   337 void RecalcShipStuff(Vehicle *v)
   338 {
   338 {
   339 	v->UpdateDeltaXY(v->direction);
   339 	v->UpdateDeltaXY(v->direction);
   340 	v->cur_image = GetShipImage(v, v->direction);
   340 	v->cur_image = v->GetImage(v->direction);
   341 	v->MarkDirty();
   341 	v->MarkDirty();
   342 	InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   342 	InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   343 }
   343 }
   344 
   344 
   345 static const TileIndexDiffC _ship_leave_depot_offs[] = {
   345 static const TileIndexDiffC _ship_leave_depot_offs[] = {
   768 	v->y_pos = gp.y;
   768 	v->y_pos = gp.y;
   769 	v->z_pos = GetSlopeZ(gp.x, gp.y);
   769 	v->z_pos = GetSlopeZ(gp.x, gp.y);
   770 
   770 
   771 getout:
   771 getout:
   772 	v->UpdateDeltaXY(dir);
   772 	v->UpdateDeltaXY(dir);
   773 	v->cur_image = GetShipImage(v, dir);
   773 	v->cur_image = v->GetImage(dir);
   774 	VehiclePositionChanged(v);
   774 	VehiclePositionChanged(v);
   775 	EndVehicleMove(v);
   775 	EndVehicleMove(v);
   776 	return;
   776 	return;
   777 
   777 
   778 reverse_direction:
   778 reverse_direction: