summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-02-20 09:26:07 +0000
committerpeter1138 <peter1138@openttd.org>2006-02-20 09:26:07 +0000
commit4f9ea7640a4c0df9c53791c51eed9d320be16327 (patch)
treee87fed6383d92b03125509e76c151eb73cdc1be6
parent4c8c1e8f6a60dcba011aaf495aa3f38b15c577e5 (diff)
downloadopenttd-4f9ea7640a4c0df9c53791c51eed9d320be16327.tar.xz
(svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles.
-rw-r--r--aircraft_gui.c6
-rw-r--r--roadveh_gui.c6
-rw-r--r--ship_gui.c7
-rw-r--r--train_gui.c7
-rw-r--r--vehicle.c8
-rw-r--r--vehicle.h14
-rw-r--r--vehicle_gui.c14
7 files changed, 40 insertions, 22 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index 249b66cff..b947854e5 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -65,7 +65,7 @@ void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number)
static void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection)
{
int image = GetAircraftImage(v, 6);
- uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner));
+ uint32 ormod = GetVehiclePalette(v);
if (v->vehstatus & VS_CRASHED) ormod = PALETTE_CRASH;
DrawSprite(image | ormod, x + 25, y + 10);
if (v->subtype == 0) DrawSprite(SPR_ROTOR_STOPPED, x + 25, y + 5);
@@ -126,7 +126,7 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
if (sel==0) selected_id = engine_id;
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
DrawString(x+62, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10);
- DrawAircraftEngine(x+29, y+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
+ DrawAircraftEngine(x+29, y+10, engine_id, GetEnginePalette(engine_id, _local_player));
y += 24;
}
sel--;
@@ -732,7 +732,7 @@ static void AircraftDepotClickAircraft(Window *w, int x, int y)
if (v != NULL) {
WP(w,traindepot_d).sel = v->index;
SetWindowDirty(w);
- SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetAircraftImage(v, 6), 4, w);
+ SetObjectToPlaceWnd(GetVehiclePalette(v) | GetAircraftImage(v, 6), 4, w);
}
break;
diff --git a/roadveh_gui.c b/roadveh_gui.c
index e54488024..2c90b38ae 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -65,7 +65,7 @@ void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number)
static void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection)
{
int image = GetRoadVehImage(v, 6);
- uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner));
+ uint32 ormod = GetVehiclePalette(v);
if (v->vehstatus & VS_CRASHED) ormod = PALETTE_CRASH;
DrawSprite(image | ormod, x + 14, y + 6);
@@ -412,7 +412,7 @@ static void DrawNewRoadVehWindow(Window *w)
if (sel==0) selected_id = engine_id;
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
DrawString(x+59, y+2, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10);
- DrawRoadVehEngine(x+29, y+6, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
+ DrawRoadVehEngine(x+29, y+6, engine_id, GetEnginePalette(engine_id, _local_player));
y += 14;
}
sel--;
@@ -638,7 +638,7 @@ static void RoadDepotClickVeh(Window *w, int x, int y)
if (v != NULL) {
WP(w,traindepot_d).sel = v->index;
SetWindowDirty(w);
- SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetRoadVehImage(v, 6), 4, w);
+ SetObjectToPlaceWnd(GetVehiclePalette(v) | GetRoadVehImage(v, 6), 4, w);
}
break;
diff --git a/ship_gui.c b/ship_gui.c
index 8960c64f6..394438c20 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -66,7 +66,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number)
static void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection)
{
int image = GetShipImage(v, 6);
- uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner));
+ uint32 ormod = GetVehiclePalette(v);
DrawSprite(image | ormod, x + 32, y + 10);
if (v->index == selection) {
@@ -354,7 +354,7 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
if (sel==0) selected_id = engine_id;
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
DrawString(x+75, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10);
- DrawShipEngine(x+35, y+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
+ DrawShipEngine(x+35, y+10, engine_id, GetEnginePalette(engine_id, _local_player));
y += 24;
}
sel--;
@@ -715,8 +715,7 @@ static void ShipDepotClick(Window *w, int x, int y)
if (v != NULL) {
WP(w,traindepot_d).sel = v->index;
SetWindowDirty(w);
- SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) +
- GetShipImage(v, 6), 4, w);
+ SetObjectToPlaceWnd(GetVehiclePalette(v) | GetShipImage(v, 6), 4, w);
}
break;
diff --git a/train_gui.c b/train_gui.c
index 68d06179e..4540ce902 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -186,8 +186,7 @@ static void engine_drawing_loop(int *x, int *y, int *pos, int *sel,
if (IS_INT_INSIDE(--*pos, -show_max, 0)) {
DrawString(*x + 59, *y + 2, GetCustomEngineName(i), *sel == 0 ? 0xC : 0x10);
- DrawTrainEngine(*x + 29, *y + 6, i,
- SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
+ DrawTrainEngine(*x + 29, *y + 6, i, GetEnginePalette(i, _local_player));
*y += 14;
}
--*sel;
@@ -360,7 +359,7 @@ static void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip,
do {
if (--skip < 0) {
int image = GetTrainImage(v, 6);
- uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner));
+ uint32 ormod = GetVehiclePalette(v);
int width = v->u.rail.cached_veh_length;
if (dx + width <= count) {
@@ -581,7 +580,7 @@ static void TrainDepotClickTrain(Window *w, int x, int y)
TrainDepotMoveVehicle(v, sel, gdvp.head);
} else if (v != NULL) {
WP(w,traindepot_d).sel = v->index;
- SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetTrainImage(v, 6), 4, w);
+ SetObjectToPlaceWnd(GetVehiclePalette(v) | GetTrainImage(v, 6), 4, w);
SetWindowDirty(w);
}
break;
diff --git a/vehicle.c b/vehicle.c
index cac8e3315..d05bfee56 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -698,7 +698,7 @@ static void DoDrawVehicle(const Vehicle *v)
if (v->vehstatus & VS_DISASTER) {
MAKE_TRANSPARENT(image);
} else if (v->vehstatus & VS_DEFPAL) {
- image |= (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner));
+ image |= (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
}
AddSortableSpriteToDraw(image, v->x_pos + v->x_offs, v->y_pos + v->y_offs,
@@ -2040,6 +2040,12 @@ UnitID GetFreeUnitNumber(byte type)
return unit;
}
+// XXX Temporary stub -- will be expanded
+PalSpriteID GetEngineColourMap(PlayerID player)
+{
+ return SPRITE_PALETTE(PLAYER_SPRITE_COLOR(player));
+}
+
// Save and load of vehicles
const SaveLoad _common_veh_desc[] = {
SLE_VAR(Vehicle,subtype, SLE_UINT8),
diff --git a/vehicle.h b/vehicle.h
index 05b8fd359..9e001d7bc 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -422,6 +422,20 @@ VARDEF uint16 _returned_refit_capacity;
#define INVALID_VEHICLE 0xFFFF
+// XXX Temporary interface -- will be expanded
+PalSpriteID GetEngineColourMap(PlayerID player);
+
+static inline PalSpriteID GetEnginePalette(EngineID engine_type, PlayerID player)
+{
+ return GetEngineColourMap(player);
+}
+
+static inline PalSpriteID GetVehiclePalette(const Vehicle *v)
+{
+ return GetEngineColourMap(v->owner);
+}
+
+
/* A lot of code calls for the invalidation of the status bar, which is widget 5.
* Best is to have a virtual value for it when it needs to change again */
#define STATUS_BAR 5
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 32c6ad164..25b0f6577 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -486,7 +486,7 @@ static void train_engine_drawing_loop(int *x, int *y, int *pos, int *sel, Engine
colour);
// show_outdated is true only for left side, which is where we show old replacements
DrawTrainEngine(*x + 29, *y + 6, i, (_player_num_engines[i] == 0 && show_outdated) ?
- PALETTE_CRASH : SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
+ PALETTE_CRASH : GetEnginePalette(i, _local_player));
if ( show_outdated ) {
SetDParam(0, _player_num_engines[i]);
DrawStringRightAligned(213, *y+5, STR_TINY_BLACK, 0);
@@ -670,7 +670,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
if (_player_num_engines[engine_id] > 0 || EngineHasReplacementForPlayer(p, engine_id)) {
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
DrawString(x+59, y+2, GetCustomEngineName(engine_id), sel[0]==0 ? 0xC : 0x10);
- DrawRoadVehEngine(x+29, y+6, engine_id, _player_num_engines[engine_id] > 0 ? SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)) : PALETTE_CRASH);
+ DrawRoadVehEngine(x+29, y+6, engine_id, _player_num_engines[engine_id] > 0 ? GetEnginePalette(engine_id, _local_player) : PALETTE_CRASH);
SetDParam(0, _player_num_engines[engine_id]);
DrawStringRightAligned(213, y+5, STR_TINY_BLACK, 0);
y += 14;
@@ -681,7 +681,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
if (RoadVehInfo(engine_id)->cargo_type == cargo && HASBIT(e->player_avail, _local_player)) {
if (IS_INT_INSIDE(--pos2, -w->vscroll.cap, 0) && RoadVehInfo(engine_id)->cargo_type == cargo) {
DrawString(x2+59, y2+2, GetCustomEngineName(engine_id), sel[1]==0 ? 0xC : 0x10);
- DrawRoadVehEngine(x2+29, y2+6, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
+ DrawRoadVehEngine(x2+29, y2+6, engine_id, GetEnginePalette(engine_id, _local_player));
y2 += 14;
}
sel[1]--;
@@ -705,7 +705,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
if (_player_num_engines[engine_id] > 0 || EngineHasReplacementForPlayer(p, engine_id)) {
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
DrawString(x+75, y+7, GetCustomEngineName(engine_id), sel[0]==0 ? 0xC : 0x10);
- DrawShipEngine(x+35, y+10, engine_id, _player_num_engines[engine_id] > 0 ? SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)) : PALETTE_CRASH);
+ DrawShipEngine(x+35, y+10, engine_id, _player_num_engines[engine_id] > 0 ? GetEnginePalette(engine_id, _local_player) : PALETTE_CRASH);
SetDParam(0, _player_num_engines[engine_id]);
DrawStringRightAligned(213, y+15, STR_TINY_BLACK, 0);
y += 24;
@@ -716,7 +716,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
if (HASBIT(e->player_avail, _local_player) && ( cargo == ShipVehInfo(engine_id)->cargo_type || refittable & ShipVehInfo(engine_id)->refittable)) {
if (IS_INT_INSIDE(--pos2, -w->vscroll.cap, 0)) {
DrawString(x2+75, y2+7, GetCustomEngineName(engine_id), sel[1]==0 ? 0xC : 0x10);
- DrawShipEngine(x2+35, y2+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
+ DrawShipEngine(x2+35, y2+10, engine_id, GetEnginePalette(engine_id, _local_player));
y2 += 24;
}
sel[1]--;
@@ -739,7 +739,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
if (sel[0] == 0) selected_id[0] = engine_id;
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
DrawString(x+62, y+7, GetCustomEngineName(engine_id), sel[0]==0 ? 0xC : 0x10);
- DrawAircraftEngine(x+29, y+10, engine_id, _player_num_engines[engine_id] > 0 ? SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)) : PALETTE_CRASH);
+ DrawAircraftEngine(x+29, y+10, engine_id, _player_num_engines[engine_id] > 0 ? GetEnginePalette(engine_id, _local_player) : PALETTE_CRASH);
SetDParam(0, _player_num_engines[engine_id]);
DrawStringRightAligned(213, y+15, STR_TINY_BLACK, 0);
y += 24;
@@ -751,7 +751,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
if (sel[1] == 0) selected_id[1] = engine_id;
if (IS_INT_INSIDE(--pos2, -w->vscroll.cap, 0)) {
DrawString(x2+62, y2+7, GetCustomEngineName(engine_id), sel[1]==0 ? 0xC : 0x10);
- DrawAircraftEngine(x2+29, y2+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
+ DrawAircraftEngine(x2+29, y2+10, engine_id, GetEnginePalette(engine_id, _local_player));
y2 += 24;
}
sel[1]--;