changeset 4212:210c91e0eced draft

(svn r5723) - Move the declaration of DrawRoadDepotSprite() out of functions.h (but I'm not too happy with the new header) - Use DiagDirection instead of plain int for the orientation of the depot graphics - Rename the associated data tables with sprites to something more meaningful
author tron <tron@openttd.org>
date Thu, 03 Aug 2006 06:44:54 +0000
parents 9b4dcc3bcbdf
children 718d24b5be45
files functions.h road_cmd.c road_cmd.h road_gui.c table/road_land.h
diffstat 5 files changed, 28 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/functions.h
+++ b/functions.h
@@ -48,9 +48,6 @@
 void DrawClearLandFence(const TileInfo *ti);
 void TileLoopClearHelper(TileIndex tile);
 
-/* road_land.c */
-void DrawRoadDepotSprite(int x, int y, int image);
-
 /* water_land.c */
 void DrawShipDepotSprite(int x, int y, int image);
 void TileLoop_Water(TileIndex tile);
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -793,7 +793,7 @@
 			player = GetTileOwner(ti->tile);
 			if (player < MAX_PLAYERS) ormod = PLAYER_SPRITE_COLOR(player);
 
-			drss = _road_display_datas[GetRoadDepotDirection(ti->tile)];
+			drss = _road_depot[GetRoadDepotDirection(ti->tile)];
 
 			DrawGroundSprite(drss++->image);
 
@@ -813,9 +813,9 @@
 	}
 }
 
-void DrawRoadDepotSprite(int x, int y, int image)
+void DrawRoadDepotSprite(int x, int y, DiagDirection dir)
 {
-	const DrawRoadSeqStruct* dtss = _road_display_datas[image];
+	const DrawRoadSeqStruct* dtss = _road_depot[dir];
 	uint32 ormod = PLAYER_SPRITE_COLOR(_local_player);
 
 	x += 33;
@@ -825,8 +825,8 @@
 
 	for (; dtss->image != 0; dtss++) {
 		Point pt = RemapCoords(dtss->subcoord_x, dtss->subcoord_y, 0);
+		uint32 image = dtss->image;
 
-		image = dtss->image;
 		if (image & PALETTE_MODIFIER_COLOR) image |= ormod;
 
 		DrawSprite(image, x + pt.x, y + pt.y);
new file mode 100644
--- /dev/null
+++ b/road_cmd.h
@@ -0,0 +1,10 @@
+/* $Id$ */
+
+#ifndef ROAD_CMD_H
+#define ROAD_CMD_H
+
+#include "direction.h"
+
+void DrawRoadDepotSprite(int x, int y, DiagDirection dir);
+
+#endif
--- a/road_gui.c
+++ b/road_gui.c
@@ -2,6 +2,7 @@
 
 #include "stdafx.h"
 #include "openttd.h"
+#include "road_cmd.h"
 #include "road_map.h"
 #include "table/sprites.h"
 #include "table/strings.h"
@@ -353,10 +354,10 @@
 		w->click_state = (1<<3) << _road_depot_orientation;
 		DrawWindowWidgets(w);
 
-		DrawRoadDepotSprite(70, 17, 0);
-		DrawRoadDepotSprite(70, 69, 1);
-		DrawRoadDepotSprite( 2, 69, 2);
-		DrawRoadDepotSprite( 2, 17, 3);
+		DrawRoadDepotSprite(70, 17, DIAGDIR_NE);
+		DrawRoadDepotSprite(70, 69, DIAGDIR_SE);
+		DrawRoadDepotSprite( 2, 69, DIAGDIR_SW);
+		DrawRoadDepotSprite( 2, 17, DIAGDIR_NW);
 		break;
 
 	case WE_CLICK: {
--- a/table/road_land.h
+++ b/table/road_land.h
@@ -4,37 +4,37 @@
 #define TILE_SEQ_LINE(a, b, c, d, e) { a, b, c, d, e },
 #define TILE_SEQ_END() { 0, 0, 0, 0, 0 }
 
-static const DrawRoadSeqStruct _road_display_datas_0[] = {
+static const DrawRoadSeqStruct _road_depot_NE[] = {
 	TILE_SEQ_BEGIN(0xA4A)
 	TILE_SEQ_LINE(0x584 | PALETTE_MODIFIER_COLOR, 0, 15, 16, 1)
 	TILE_SEQ_END()
 };
 
-static const DrawRoadSeqStruct _road_display_datas_1[] = {
+static const DrawRoadSeqStruct _road_depot_SE[] = {
 	TILE_SEQ_BEGIN(0xA4A)
 	TILE_SEQ_LINE(0x580, 0, 0, 1, 16)
 	TILE_SEQ_LINE(0x581 | PALETTE_MODIFIER_COLOR, 15, 0, 1, 16)
 	TILE_SEQ_END()
 };
 
-static const DrawRoadSeqStruct _road_display_datas_2[] = {
+static const DrawRoadSeqStruct _road_depot_SW[] = {
 	TILE_SEQ_BEGIN(0xA4A)
 	TILE_SEQ_LINE(0x582, 0, 0, 16, 1)
 	TILE_SEQ_LINE(0x583 | PALETTE_MODIFIER_COLOR, 0, 15, 16, 1)
 	TILE_SEQ_END()
 };
 
-static const DrawRoadSeqStruct _road_display_datas_3[] = {
+static const DrawRoadSeqStruct _road_depot_NW[] = {
 	TILE_SEQ_BEGIN(0xA4A)
 	TILE_SEQ_LINE(0x585 | PALETTE_MODIFIER_COLOR, 15, 0, 1, 16)
 	TILE_SEQ_END()
 };
 
-static const DrawRoadSeqStruct* const _road_display_datas[] = {
-	_road_display_datas_0,
-	_road_display_datas_1,
-	_road_display_datas_2,
-	_road_display_datas_3,
+static const DrawRoadSeqStruct* const _road_depot[] = {
+	_road_depot_NE,
+	_road_depot_SE,
+	_road_depot_SW,
+	_road_depot_NW
 };
 
 #undef TILE_SEQ_BEGIN