|
@@ -325,25 +325,25 @@ void UpdateVehiclePosHash(Vehicle *v, in
|
|
|
int old_y = v->top_coord;
|
|
|
Vehicle *u;
|
|
|
|
|
|
new_hash = (x == INVALID_COORD) ? NULL : &_vehicle_position_hash[GEN_HASH(x,y)];
|
|
|
old_hash = (old_x == INVALID_COORD) ? NULL : &_vehicle_position_hash[GEN_HASH(old_x, old_y)];
|
|
|
|
|
|
if (old_hash == new_hash)
|
|
|
return;
|
|
|
|
|
|
/* remove from hash table? */
|
|
|
if (old_hash != NULL) {
|
|
|
Vehicle *last = NULL;
|
|
|
int idx = *old_hash;
|
|
|
VehicleID idx = *old_hash;
|
|
|
while ((u = GetVehicle(idx)) != v) {
|
|
|
idx = u->next_hash;
|
|
|
assert(idx != INVALID_VEHICLE);
|
|
|
last = u;
|
|
|
}
|
|
|
|
|
|
if (last == NULL)
|
|
|
*old_hash = v->next_hash;
|
|
|
else
|
|
|
last->next_hash = v->next_hash;
|
|
|
}
|
|
|
|
|
@@ -1449,25 +1449,25 @@ int32 ReplaceVehicle(Vehicle *v)
|
|
|
if ( u->engine_type == old_engine_type && RailVehInfo(old_engine_type)->flags & RVI_MULTIHEAD) {
|
|
|
if (v->next != NULL) rear_engine_cost = -(int32)u->value;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* Check if there is money for the upgrade.. if not, give a nice news-item
|
|
|
(that is needed, because this CMD is called automaticly) */
|
|
|
if ( p->money64 < (int32)(p->engine_renew_money + build_cost + rear_engine_cost - v->value)) {
|
|
|
if (( _local_player == v->owner ) && ( v->unitnumber != 0 )) { //v->unitnumber = 0 for train cars
|
|
|
int message;
|
|
|
StringID message;
|
|
|
SetDParam(0, v->unitnumber);
|
|
|
switch (v->type) {
|
|
|
case VEH_Train: message = STR_TRAIN_AUTORENEW_FAILED; break;
|
|
|
case VEH_Road: message = STR_ROADVEHICLE_AUTORENEW_FAILED; break;
|
|
|
case VEH_Ship: message = STR_SHIP_AUTORENEW_FAILED; break;
|
|
|
case VEH_Aircraft: message = STR_AIRCRAFT_AUTORENEW_FAILED; break;
|
|
|
// This should never happen
|
|
|
default: message = 0; break;
|
|
|
}
|
|
|
|
|
|
AddNewsItem(message, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0);
|
|
|
}
|