MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DisasterVehicle

Method DisasterVehicle

src/disaster_vehicle.cpp:127–175  ·  view source on GitHub ↗

* Construct the disaster vehicle. * @param x The X coordinate. * @param y The Y coordinate. * @param direction The direction the vehicle is facing. * @param subtype The sub type of vehicle. * @param big_ufo_destroyer_target The target for the UFO destroyer. */

Source from the content-addressed store, hash-verified

125 * @param big_ufo_destroyer_target The target for the UFO destroyer.
126 */
127DisasterVehicle::DisasterVehicle(int x, int y, Direction direction, DisasterSubType subtype, VehicleID big_ufo_destroyer_target) :
128 SpecializedVehicleBase(), big_ufo_destroyer_target(big_ufo_destroyer_target)
129{
130 this->vehstatus = VehState::Unclickable;
131
132 this->x_pos = x;
133 this->y_pos = y;
134 switch (subtype) {
135 case ST_ZEPPELINER:
136 case ST_SMALL_UFO:
137 case ST_AIRPLANE:
138 case ST_HELICOPTER:
139 case ST_BIG_UFO:
140 case ST_BIG_UFO_DESTROYER:
141 GetAircraftFlightLevelBounds(this, &this->z_pos, nullptr);
142 break;
143
144 case ST_HELICOPTER_ROTORS:
145 GetAircraftFlightLevelBounds(this, &this->z_pos, nullptr);
146 this->z_pos += ROTOR_Z_OFFSET;
147 break;
148
149 case ST_SMALL_SUBMARINE:
150 case ST_BIG_SUBMARINE:
151 this->z_pos = 0;
152 break;
153
154 case ST_ZEPPELINER_SHADOW:
155 case ST_SMALL_UFO_SHADOW:
156 case ST_AIRPLANE_SHADOW:
157 case ST_HELICOPTER_SHADOW:
158 case ST_BIG_UFO_SHADOW:
159 case ST_BIG_UFO_DESTROYER_SHADOW:
160 this->z_pos = 0;
161 this->vehstatus.Set(VehState::Shadow);
162 break;
163 }
164
165 this->direction = direction;
166 this->tile = TileVirtXY(x, y);
167 this->subtype = subtype;
168 this->UpdateDeltaXY();
169 this->owner = OWNER_NONE;
170 this->image_override = 0;
171 this->state = 0;
172
173 this->UpdateImage();
174 this->UpdatePositionAndViewport();
175}
176
177/**
178 * Update the position of the vehicle.

Callers

nothing calls this directly

Calls 6

UpdateDeltaXYMethod · 0.95
UpdateImageMethod · 0.95
TileVirtXYFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected