src/train_gui.cpp
branchnoai
changeset 9629 66dde6412125
parent 9624 b71483f2330f
child 9631 8a2d1c2ceb88
--- a/src/train_gui.cpp	Sun Jun 17 21:31:00 2007 +0000
+++ b/src/train_gui.cpp	Tue Jun 26 23:40:58 2007 +0000
@@ -169,8 +169,7 @@
 		}
 
 		/* draw widgets & caption */
-		SetDParam(0, v->string_id);
-		SetDParam(1, v->unitnumber);
+		SetDParam(0, v->index);
 		DrawWindowWidgets(w);
 
 		if (v->u.rail.crash_anim_pos != 0) {
@@ -283,6 +282,7 @@
 		DeleteWindowById(WC_VEHICLE_REFIT, w->window_number);
 		DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number);
 		DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
+		DeleteWindowById(WC_VEHICLE_TIMETABLE, w->window_number);
 		break;
 
 	case WE_MOUSELOOP: {
@@ -327,13 +327,12 @@
 static void TrainDetailsCargoTab(const Vehicle *v, int x, int y)
 {
 	if (v->cargo_cap != 0) {
-		uint num = v->cargo_count;
 		StringID str = STR_8812_EMPTY;
 
-		if (num != 0) {
+		if (!v->cargo.Empty()) {
 			SetDParam(0, v->cargo_type);
-			SetDParam(1, num);
-			SetDParam(2, v->cargo_source);
+			SetDParam(1, v->cargo.Count());
+			SetDParam(2, v->cargo.Source());
 			SetDParam(3, _patches.freight_trains);
 			str = FreightWagonMult(v->cargo_type) > 1 ? STR_FROM_MULT : STR_8813_FROM;
 		}
@@ -344,11 +343,11 @@
 static void TrainDetailsInfoTab(const Vehicle *v, int x, int y)
 {
 	if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) {
-		SetDParam(0, GetCustomEngineName(v->engine_type));
+		SetDParam(0, v->engine_type);
 		SetDParam(1, v->value);
 		DrawString(x, y, STR_882D_VALUE, 0x10);
 	} else {
-		SetDParam(0, GetCustomEngineName(v->engine_type));
+		SetDParam(0, v->engine_type);
 		SetDParam(1, v->build_year);
 		SetDParam(2, v->value);
 		DrawString(x, y, STR_882C_BUILT_VALUE, 0x10);
@@ -387,7 +386,7 @@
 		}
 
 		do {
-			act_cargo[u->cargo_type] += u->cargo_count;
+			act_cargo[u->cargo_type] += u->cargo.Count();
 			max_cargo[u->cargo_type] += u->cargo_cap;
 		} while ((u = u->next) != NULL);
 
@@ -413,8 +412,7 @@
 	SetWindowWidgetDisabledState(w, 6, !_patches.servint_trains);
 	SetWindowWidgetDisabledState(w, 7, !_patches.servint_trains);
 
-	SetDParam(0, v->string_id);
-	SetDParam(1, v->unitnumber);
+	SetDParam(0, v->index);
 	DrawWindowWidgets(w);
 
 	SetDParam(1, v->age / 366);
@@ -504,7 +502,7 @@
 				DrawString(x, y + 2, FreightWagonMult(i) > 1 ? STR_TOTAL_CAPACITY_MULT : STR_013F_TOTAL_CAPACITY, 0);
 			}
 		}
-		SetDParam(0, v->cargo_feeder_share);
+		SetDParam(0, v->cargo.FeederShare());
 		DrawString(x, y + 15, STR_FEEDER_CARGO_VALUE, 0);
 	}
 }
@@ -521,8 +519,8 @@
 		switch (e->we.click.widget) {
 		case 2: /* name train */
 			v = GetVehicle(w->window_number);
-			SetDParam(0, v->unitnumber);
-			ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w, CS_ALPHANUMERAL);
+			SetDParam(0, v->index);
+			ShowQueryString(STR_VEHICLE_NAME, STR_8865_NAME_TRAIN, 31, 150, w, CS_ALPHANUMERAL);
 			break;
 		case 6: /* inc serv interval */
 			mod = _ctrl_pressed? 5 : 10;