@@ -306,97 +306,101 @@ static bool RailVehicleChangeInfo(uint e
case 0x18: { /* AI rank */
/* TODO: _railveh_score should be merged to _rail_vehicle_info. */
FOR_EACH_OBJECT {
grf_load_byte(&buf);
}
ret = true;
} break;
case 0x19: { /* Engine traction type */
/* TODO: What do the individual numbers mean?
* XXX: And in what base are they, in fact? --pasky */
uint8 traction = grf_load_byte(&buf);
int engclass;
if (traction <= 0x07)
engclass = 0;
else if (traction <= 0x27)
engclass = 1;
else if (traction <= 0x31)
engclass = 2;
else
break;
rvi[i].engclass = engclass;
case 0x1D: { /* Refit cargo */
uint32 refit_mask = grf_load_dword(&buf);
_engine_refit_masks[engine + i] = refit_mask;
/* TODO */
/* Fall-through for unimplemented two bytes long properties. */
case 0x1B: /* Powered wagons power bonus */
/* Fall-through for unimplemented one byte long properties. */
case 0x1A: /* Sort order */
case 0x1C: /* Refit cost */
case 0x1E: /* Callback */
case 0x1F: /* Tractive effort */
case 0x20: /* Air drag */
case 0x21: /* Shorter tenders */
case 0x22: /* Visual */
case 0x23: {/* Powered wagons weight bonus */
case 0x23: /* Powered wagons weight bonus */
case 0x24: /* High byte of vehicle weight */
case 0x25: /* User-defined bit mask to set when checking veh. var. 42 */
case 0x26: /* Retire vehicle early */
{
default:
*bufp = buf;
return ret;
static bool RoadVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len)
RoadVehicleInfo *rvi = &_road_vehicle_info[engine];
byte *buf = *bufp;
int i;
bool ret = false;
switch (prop) {
case 0x08: { /* Speed */
uint8 speed = grf_load_byte(&buf);
rvi[i].max_speed = speed; // ?? units
case 0x09: { /* Running cost factor */
uint8 runcost = grf_load_byte(&buf);
rvi[i].running_cost = runcost;
case 0x0A: /* Running cost base */
/* TODO: I have no idea. --pasky */
case 0x0E: { /* Sprite ID */
uint8 spriteid = grf_load_byte(&buf);
if (spriteid == 0xFF)
spriteid = 0xFD; // cars have different custom id in the GRF file
@@ -412,96 +416,100 @@ static bool RoadVehicleChangeInfo(uint e
case 0x0F: { /* Cargo capacity */
uint16 capacity = grf_load_word(&buf);
rvi[i].capacity = capacity;
case 0x10: { /* Cargo type */
uint8 cargo = grf_load_byte(&buf);
rvi[i].cargo_type = cargo;
case 0x11: { /* Cost factor */
uint8 cost_factor = grf_load_byte(&buf);
rvi[i].base_cost = cost_factor; // ?? is it base_cost?
case 0x12: { /* SFX */
uint8 sfx = grf_load_byte(&buf);
rvi[i].sfx = sfx;
case 0x13: /* Power in 10hp */
case 0x14: /* Weight in 1/4 tons */
case 0x15: /* Speed in mph*0.8 */
/* TODO: Support for road vehicles realistic power
* computations (called rvpower in TTDPatch) is just
* missing in OTTD yet. --pasky */
case 0x16: { /* Cargos available for refitting */
_engine_refit_masks[ROAD_ENGINES_INDEX + engine + i] = refit_mask;
case 0x17: /* Callback */
case 0x18: /* Tractive effort */
case 0x19: /* Air drag */
case 0x1A: /* Refit cost */
case 0x1B: /* Retire vehicle early */
static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len)
ShipVehicleInfo *svi = &_ship_vehicle_info[engine];
//printf("e %x prop %x?\n", engine, prop);
case 0x08: { /* Sprite ID */
spriteid = 0xFD; // ships have different custom id in the GRF file
// This is currently not used but there's no reason
// in not having it here for the future.
if (spriteid == 0xFD && svi[i].image_index != 0xFD)
_engine_original_sprites[SHIP_ENGINES_INDEX + engine + i] = svi[i].image_index;
svi[i].image_index = spriteid;
case 0x09: { /* Refittable */
uint8 refittable = grf_load_byte(&buf);
svi[i].refittable = refittable;
case 0x0A: { /* Cost factor */
@@ -513,97 +521,106 @@ static bool ShipVehicleChangeInfo(uint e
svi[i].max_speed = speed; // ?? units
case 0x0C: { /* Cargo type */
// XXX: Need to consult this with patchman yet.
#if 0
// Documentation claims this is already the
// per-landscape cargo type id, but newships.grf
// assume otherwise.
cargo = local_cargo_id_ctype[cargo];
#endif
svi[i].cargo_type = cargo;
case 0x0D: { /* Cargo capacity */
svi[i].capacity = capacity;
case 0x0F: { /* Running cost factor */
svi[i].running_cost = runcost;
case 0x10: { /* SFX */
svi[i].sfx = sfx;
case 0x11: { /* Cargos available for refitting */
_engine_refit_masks[SHIP_ENGINES_INDEX + engine + i] = refit_mask;
case 0x12: { /* Callback TODO */
case 0x12: /* Callback */
case 0x13: /* Refit cost */
case 0x14: /* Ocean speed fraction */
case 0x15: /* Canal speed fraction */
case 0x16: /* Retire vehicle early */
static bool AircraftVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len)
AircraftVehicleInfo *avi = &_aircraft_vehicle_info[engine];
if (spriteid == 0xFD && avi[i].image_index != 0xFD)
_engine_original_sprites[AIRCRAFT_ENGINES_INDEX + engine + i] = avi[i].image_index;
avi[i].image_index = spriteid;
case 0x09: { /* Helicopter */
uint8 heli = grf_load_byte(&buf);
avi[i].subtype &= ~0x01; // remove old property
avi[i].subtype |= (heli == 0) ? 0 : 1;
case 0x0A: { /* Large */
uint8 large = grf_load_byte(&buf);
avi[i].subtype &= ~0x02; // remove old property
avi[i].subtype |= (large == 1) ? 2 : 0;
@@ -618,97 +635,104 @@ static bool AircraftVehicleChangeInfo(ui
avi[i].max_speed = speed; // ?? units
case 0x0D: { /* Acceleration */
uint8 accel = grf_load_byte(&buf);
avi[i].acceleration = accel;
case 0x0E: { /* Running cost factor */
avi[i].running_cost = runcost;
case 0x0F: { /* Passenger capacity */
avi[i].passenger_capacity = capacity;
case 0x11: { /* Mail capacity */
uint8 capacity = grf_load_byte(&buf);
avi[i].mail_capacity = capacity;
avi[i].sfx = sfx;
case 0x13: { /* Cargos available for refitting */
_engine_refit_masks[AIRCRAFT_ENGINES_INDEX + engine + i] = refit_mask;
case 0x14: { /* Callback TODO */
case 0x14: /* Callback */
case 0x15: /* Refit cost */
static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int len)
int ret = 0;
/* This is one single huge TODO. It doesn't handle anything more than
* just waypoints for now. */
//printf("sci %d %d [0x%02x]\n", stid, numinfo, prop);
case 0x08:
{ /* Class ID */
StationSpec *stat = &_cur_grffile->stations[stid + i];
uint32 classid;
/* classid, for a change, is always little-endian */
classid = *(buf++) << 24;
classid |= *(buf++) << 16;
classid |= *(buf++) << 8;
classid |= *(buf++);
switch (classid) {
case 'DFLT':
stat->sclass = STAT_CLASS_DFLT;
case 'WAYP':
stat->sclass = STAT_CLASS_WAYP;
/* TODO: No support for custom
* classes for now, so stuff
* everything to the single
* default one. --pasky */
//stat->sclass = STAT_CLASS_CUSTOM;
Status change: