Changeset 198 for trunk/src/lua/lua_map_area.cc
- Timestamp:
- 08/11/13 17:19:03 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_map_area.cc
r179 r198 15 15 typedef nv::flags<512> cell_set; 16 16 17 nv::uint32 nlua_to_cell_id( lua_State* L, int index, nv::map_area* map )17 static nv::uint32 nlua_to_cell_id( lua_State* L, int index, nv::map_area* map ) 18 18 { 19 19 if ( lua_type( L, index ) == LUA_TSTRING ) 20 20 return map->string_to_id( lua_tostring( L, index ) ); 21 21 else 22 return (nv::uint32)lua_tointeger( L, index );23 } 24 25 cell_set nlua_to_cell_set( lua_State* L, int index, nv::map_area* map )26 {27 cell_set result;28 switch ( lua_type( L, index ) )29 {30 case LUA_TTABLE :31 {32 lua_pushnil( L );33 while ( lua_next( L, index ) != 0 )34 {35 if ( lua_type( L, -1 ) == LUA_TSTRING )36 result.set( map->string_to_id( lua_tostring( L, -1 ) ), true );37 else38 result.set( lua_tointeger( L, -1 ), true );39 lua_pop( L, 1 );40 }41 } break;42 case LUA_TSTRING : result.set( map->string_to_id( lua_tostring( L, index ) ), true ); break;43 case LUA_TNUMBER : result.set( lua_tointeger( L, index ), true ); break;44 }45 return result;46 }22 return lua_tounsigned( L, index ); 23 } 24 25 // static cell_set nlua_to_cell_set( lua_State* L, int index, nv::map_area* map ) 26 // { 27 // cell_set result; 28 // switch ( lua_type( L, index ) ) 29 // { 30 // case LUA_TTABLE : 31 // { 32 // lua_pushnil( L ); 33 // while ( lua_next( L, index ) != 0 ) 34 // { 35 // if ( lua_type( L, -1 ) == LUA_TSTRING ) 36 // result.set( map->string_to_id( lua_tostring( L, -1 ) ), true ); 37 // else 38 // result.set( lua_tounsigned( L, -1 ), true ); 39 // lua_pop( L, 1 ); 40 // } 41 // } break; 42 // case LUA_TSTRING : result.set( map->string_to_id( lua_tostring( L, index ) ), true ); break; 43 // case LUA_TNUMBER : result.set( lua_tounsigned( L, index ), true ); break; 44 // } 45 // return result; 46 // } 47 47 48 48 bool nlua_is_map_area( lua_State* L, int index ) … … 118 118 { 119 119 nv::map_area* ma = nlua_to_map_area( L, 1 ); 120 lua_push integer( L, ma->get_cell( nlua_to_coord( L, 2 ) ) );120 lua_pushunsigned( L, ma->get_cell( nlua_to_coord( L, 2 ) ) ); 121 121 return 1; 122 122 } … … 125 125 { 126 126 nv::map_area* ma = nlua_to_map_area( L, 1 ); 127 ma->set_cell( nlua_to_coord( L, 2 ), lua_to integer( L, 3 ) );127 ma->set_cell( nlua_to_coord( L, 2 ), lua_tounsigned( L, 3 ) ); 128 128 return 0; 129 129 } … … 140 140 else 141 141 { 142 lua_push integer( L, ma->get_cell( nlua_to_coord( L, 2 ) ) );142 lua_pushunsigned( L, ma->get_cell( nlua_to_coord( L, 2 ) ) ); 143 143 } 144 144 return 1; … … 148 148 { 149 149 nv::map_area* ma = nlua_to_map_area( L, 1 ); 150 ma->set_cell( nlua_to_coord( L, 2 ), lua_to integer( L, 3 ) );150 ma->set_cell( nlua_to_coord( L, 2 ), lua_tounsigned( L, 3 ) ); 151 151 return 0; 152 152 } … … 179 179 }; 180 180 181 int luaopen_map_area( lua_State * L )181 static int luaopen_map_area( lua_State * L ) 182 182 { 183 183 luaL_newmetatable( L, NLUA_MAP_AREA_METATABLE );
Note: See TracChangeset
for help on using the changeset viewer.