src/viewport.cpp
branchnoai
changeset 9869 6404afe43575
parent 9837 c9ec4f82e0d0
child 10181 54df587fef5d
--- a/src/viewport.cpp	Sun Apr 06 14:12:19 2008 +0000
+++ b/src/viewport.cpp	Sun Apr 06 23:07:42 2008 +0000
@@ -27,11 +27,15 @@
 #include "player_func.h"
 #include "settings_type.h"
 #include "station_func.h"
+#include "core/alloc_func.hpp"
 
 #include "table/sprites.h"
 #include "table/strings.h"
 
-#define VIEWPORT_DRAW_MEM (65536 * 2)
+enum {
+	VIEWPORT_DRAW_MEM = (65536 * 2),
+	PARENT_LIST_SIZE  = 6144,
+};
 
 PlaceProc *_place_proc;
 Point _tile_fract_coords;
@@ -1226,8 +1230,8 @@
 	const Sign *si;
 	int left, top, right, bottom;
 
-	if (!HasBit(_display_opt, DO_SHOW_SIGNS))
-		return;
+	/* Signs are turned off or are invisible */
+	if (!HasBit(_display_opt, DO_SHOW_SIGNS) || IsInvisibilitySet(TO_SIGNS)) return;
 
 	left = dpi->left;
 	top = dpi->top;
@@ -1491,6 +1495,12 @@
 		uint16 colour;
 
 		if (ss->width != 0) {
+			/* Do not draw signs nor station names if they are set invisible */
+			if (IsInvisibilitySet(TO_SIGNS) && ss->string != STR_2806) {
+				ss = ss->next;
+				continue;
+			}
+
 			int x = UnScaleByZoom(ss->x, zoom) - 1;
 			int y = UnScaleByZoom(ss->y, zoom) - 1;
 			int bottom = y + 11;
@@ -1541,8 +1551,8 @@
 	int y;
 	DrawPixelInfo *old_dpi;
 
-	byte mem[VIEWPORT_DRAW_MEM];
-	ParentSpriteToDraw *parent_list[6144];
+	SmallStackSafeStackAlloc<byte, VIEWPORT_DRAW_MEM> mem;
+	SmallStackSafeStackAlloc<ParentSpriteToDraw*, PARENT_LIST_SIZE> parent_list;
 
 	_cur_vd = &vd;
 
@@ -1566,9 +1576,9 @@
 	vd.dpi.dst_ptr = BlitterFactoryBase::GetCurrentBlitter()->MoveTo(old_dpi->dst_ptr, x - old_dpi->left, y - old_dpi->top);
 
 	vd.parent_list = parent_list;
-	vd.eof_parent_list = endof(parent_list);
+	vd.eof_parent_list = parent_list.EndOf();
 	vd.spritelist_mem = mem;
-	vd.eof_spritelist_mem = endof(mem) - sizeof(LARGEST_SPRITELIST_STRUCT);
+	vd.eof_spritelist_mem = mem.EndOf() - sizeof(LARGEST_SPRITELIST_STRUCT);
 	vd.last_string = &vd.first_string;
 	vd.first_string = NULL;
 	vd.last_tile = &vd.first_tile;
@@ -1954,7 +1964,8 @@
 {
 	const Sign *si;
 
-	if (!HasBit(_display_opt, DO_SHOW_SIGNS) || _current_player == PLAYER_SPECTATOR) return false;
+	/* Signs are turned off, or they are transparent and invisibility is ON, or player is a spectator */
+	if (!HasBit(_display_opt, DO_SHOW_SIGNS) || IsInvisibilitySet(TO_SIGNS) || _current_player == PLAYER_SPECTATOR) return false;
 
 	switch (vp->zoom) {
 		case ZOOM_LVL_NORMAL: