From 046b65291b89c3d3892b9fb5fba08ea6574bb8d0 Mon Sep 17 00:00:00 2001 From: neil <neil@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Sat, 5 Mar 2011 18:06:56 +0000 Subject: [PATCH] Handle different pointer sizes, particular on Mac git-svn-id: http://svn.net-core.org/repos/t-engine4@2947 51575b47-30f0-44d4-a5cc-537603b46e54 --- src/main.c | 11 ++++++++++- src/map.c | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 62940a0bcf..1020e43ccd 100644 --- a/src/main.c +++ b/src/main.c @@ -155,7 +155,16 @@ void stackDump (lua_State *L) { case LUA_TNUMBER: printf("%d: %g\n", i, lua_tonumber(L, i)); break; - default: printf("%d: %s // %x\n", i, lua_typename(L, t), lua_topointer(L, i)); break; + default: +#if defined(__PTRDIFF_TYPE__) + if((sizeof(__PTRDIFF_TYPE__) == sizeof(long int))) + printf("%d: %s // %lx\n", i, lua_typename(L, t), (unsigned long int)lua_topointer(L, i)); + else + printf("%d: %s // %x\n", i, lua_typename(L, t), (unsigned int)lua_topointer(L, i)); +#else + printf("%d: %s // %x\n", i, lua_typename(L, t), lua_topointer(L, i)); +#endif + break; } i--; } diff --git a/src/map.c b/src/map.c index b806146400..8c9811303c 100644 --- a/src/map.c +++ b/src/map.c @@ -624,7 +624,16 @@ static int map_set_grid(lua_State *L) // We use the pointer value directly as an index if (map->grids[x][y][i]) { +#if defined(__PTRDIFF_TYPE__) + if(sizeof(__PTRDIFF_TYPE__) == sizeof(long int)) + lua_pushnumber(L, (unsigned long int)map->grids[x][y][i]); + else if(sizeof(__PTRDIFF_TYPE__) == sizeof(long long)) + lua_pushnumber(L, (long long)map->grids[x][y][i]); + else + lua_pushnumber(L, (int)map->grids[x][y][i]); +#else lua_pushnumber(L, (long long)map->grids[x][y][i]); +#endif lua_pushnil(L); lua_settable(L, 5); // Access the list of all mos for the map } -- GitLab