Changeset 198 for trunk/src/lua
- Timestamp:
- 08/11/13 17:19:03 (12 years ago)
- Location:
- trunk/src/lua
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_area.cc
r179 r198 34 34 } 35 35 36 void nlua_area_construct( lua_State* L, int sidx )36 static void nlua_area_construct( lua_State* L, int sidx ) 37 37 { 38 38 if ( nlua_is_coord( L, sidx ) ) … … 412 412 413 413 414 int luaopen_area( lua_State * L )414 static int luaopen_area( lua_State * L ) 415 415 { 416 416 static const struct luaL_Reg nlua_area_sf [] = { -
trunk/src/lua/lua_aux.cc
r180 r198 95 95 if ( dice < 1 ) luaL_argerror( L, 1, "die count lower than 1!" ); 96 96 if ( sides < 1 ) luaL_argerror( L, 2, "side count lower than 1!" ); 97 lua_pushnumber( L, nv::random::get().dice( dice, sides) );97 lua_pushnumber( L, nv::random::get().dice( static_cast< nv::uint32 >( dice ), static_cast< nv::uint32 >( sides ) ) ); 98 98 return 1; 99 99 } … … 111 111 int arg1 = luaL_checkinteger( L, 1 ); 112 112 if ( arg1 < 1 ) arg1 = 1; 113 lua_pushunsigned( L, nv::random::get().urange( 1, arg1) );113 lua_pushunsigned( L, nv::random::get().urange( 1, static_cast<nv::uint32>( arg1 ) ) ); 114 114 } 115 115 else … … 126 126 static int nluaaux_math_randomseed( lua_State* L ) 127 127 { 128 nv::random::get().set_seed( static_cast< nv::uint32 >( L, 1 ) );128 nv::random::get().set_seed( lua_tounsigned( L, 1 ) ); 129 129 return 0; 130 130 } -
trunk/src/lua/lua_function.cc
r182 r198 11 11 using namespace nv; 12 12 13 lua::function_base::function_base( lua_State* L, const path& a_path, bool global /*= true*/ ) : L(L)13 lua::function_base::function_base( lua_State* a_L, const path& a_path, bool a_global /*= true*/ ) : L(a_L) 14 14 { 15 if ( !a_path.resolve( L, global ) )15 if ( !a_path.resolve( L, a_global ) ) 16 16 { 17 17 lua_pop( L, 1 ); … … 27 27 } 28 28 29 lua::function_base::function_base( const function_base& func ) : L( L)29 lua::function_base::function_base( const function_base& func ) : L(func.L) 30 30 { 31 31 lua_rawgeti( L, LUA_REGISTRYINDEX, func.m_ref ); -
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 ); -
trunk/src/lua/lua_path.cc
r181 r198 23 23 } 24 24 25 lua::path::path( inti )25 lua::path::path( unsigned i ) 26 26 : m_count(0) 27 27 { … … 88 88 else 89 89 { 90 lua_push integer( L, m_elements[i].value );90 lua_pushunsigned( L, m_elements[i].value ); 91 91 } 92 92 lua_gettable( L, -2 ); -
trunk/src/lua/lua_state.cc
r188 r198 257 257 { 258 258 lua_getfield( L->L, -1, element.c_str() ); 259 intresult = lua_type( L->L, -1 ) == LUA_TNUMBER ? lua_tounsigned( L->L, -1 ) : defval;259 unsigned result = lua_type( L->L, -1 ) == LUA_TNUMBER ? lua_tounsigned( L->L, -1 ) : defval; 260 260 lua_pop( L->L, 1 ); 261 261 return result;
Note: See TracChangeset
for help on using the changeset viewer.