diff options
author | rubidium <rubidium@openttd.org> | 2008-04-01 21:12:51 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-04-01 21:12:51 +0000 |
commit | 8e8362799187dab20c81aca4f19b6f6a218306be (patch) | |
tree | 8b8b47a627fbcb06ab1faeb36727a71765a27279 /src/viewport.cpp | |
parent | 81b6125ac2adf4aeac327aa6a80cced3f4c84f35 (diff) | |
download | openttd-8e8362799187dab20c81aca4f19b6f6a218306be.tar.xz |
(svn r12536) -Codechange: some stack allocations were too large for NDS, so use the SmallStackSafeStackAlloc wrapper. Allocate on the stack by default and on the heap for NDS (or other devices that have a very small stack).
Diffstat (limited to 'src/viewport.cpp')
-rw-r--r-- | src/viewport.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp index 659834fd1..934cd18c9 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -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; @@ -1541,8 +1545,8 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom 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 +1570,9 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom 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; |