Ignore:
Timestamp:
06/20/15 00:05:17 (10 years ago)
Author:
epyon
Message:
  • code compiles cleanly on maximum warning level
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lua/lua_map_tile.cc

    r395 r406  
    4040static map_tile* nlua_to_pmap_tile( lua_State* L, int index )
    4141{
    42         return (map_tile*)luaL_checkudata( L, index, NLUA_MAP_TILE_METATABLE );
     42        return reinterpret_cast<map_tile*>( luaL_checkudata( L, index, NLUA_MAP_TILE_METATABLE ) );
    4343}
    4444
    4545static void nlua_push_map_tile( lua_State* L, const map_tile& tile )
    4646{
    47         map_tile* result = (map_tile*)lua_newuserdata( L, sizeof(map_tile) );
     47        map_tile* result = reinterpret_cast<map_tile*>( lua_newuserdata( L, sizeof(map_tile) ) );
    4848        *result = tile;
    4949        luaL_setmetatable( L, NLUA_MAP_TILE_METATABLE );
     
    6565        map_tile tile;
    6666
    67         tile.size_y = (nv::uint16)( nv::count( code.begin(), code.end(), '\n' ) + 1 );
    68         tile.size_x = (nv::uint16)( code.find( '\n' ) );
     67        tile.size_y = nv::uint16( nv::count( code.begin(), code.end(), '\n' ) + 1 );
     68        tile.size_x = nv::uint16( code.find( '\n' ) );
    6969        if ( tile.size_x == 0 )
    7070        {
    71                 tile.size_x = (nv::uint16)code.length();
     71                tile.size_x = nv::uint16( code.length() );
    7272        }
    7373        tile.data  = new nv::uint8[ tile.size_x * tile.size_y ];
     
    8585                        if ( lua_isstring( L, -2 ) && lua_objlen( L, -2 ) == 1 )
    8686                        {
    87                                 translation[ (nv::uint8)( lua_tostring( L, -2 )[0] ) ] = nv::uint8( map_area->string_to_id( lua_tostring( L, -1 ) ) );
     87                                translation[ nv::uint8( lua_tostring( L, -2 )[0] ) ] = nv::uint8( map_area->string_to_id( lua_tostring( L, -1 ) ) );
    8888                        }
    8989                        // removes 'value'; keeps 'key' for next iteration */
     
    9595                for ( nv::uint16 row = 0; row < tile.size_y; row++ )
    9696                {
    97                         nv::uchar8 gylph = (nv::uchar8)code[ row * ( tile.size_x + 1 ) + line ];
     97                        nv::uchar8 gylph = nv::uchar8( code[ row * ( tile.size_x + 1 ) + line ] );
    9898                        // TODO: check for errors
    9999                        tile.data[ row * tile.size_x + line ] = translation[ gylph ];
     
    108108{
    109109        map_tile* old_tile = nlua_to_pmap_tile( L, 1 );
    110         map_tile* new_tile = (map_tile*) lua_newuserdata( L, sizeof( map_tile ) );
     110        map_tile* new_tile = reinterpret_cast<map_tile*>( lua_newuserdata( L, sizeof( map_tile ) ) );
    111111        new_tile->size_x = old_tile->size_x;
    112112        new_tile->size_y = old_tile->size_y;
     
    246246        nv::uint16 org_x = tile->size_x;
    247247        nv::uint16 org_y = tile->size_y;
    248         nv::uint16 new_x = ( nv::uint16 )nv::accumulate( sizes_x.begin(), sizes_x.end(), 0 );
    249         nv::uint16 new_y = ( nv::uint16 )nv::accumulate( sizes_y.begin(), sizes_y.end(), 0 );
     248        nv::uint16 new_x = nv::uint16( nv::accumulate( sizes_x.begin(), sizes_x.end(), 0 ) );
     249        nv::uint16 new_y = nv::uint16( nv::accumulate( sizes_y.begin(), sizes_y.end(), 0 ) );
    250250
    251251        nv::uint8* data = new nv::uint8[ new_x * new_y ];
     
    274274static int nlua_map_tile_raw_get( lua_State* L )
    275275{
    276         map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
     276        map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
    277277        if ( lua_type( L, 2 ) == LUA_TNUMBER )
    278278        {
     
    289289static int nlua_map_tile_raw_set( lua_State* L )
    290290{
    291         map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
     291        map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
    292292        if ( lua_type( L, 2 ) == LUA_TNUMBER )
    293293        {
    294                 tile->data[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3 );
     294                tile->data[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) );
    295295        }
    296296        else
    297297        {
    298298                nv::ivec2 coord = nv::lua::detail::to_coord( L, 2 );
    299                 tile->data[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3 );
     299                tile->data[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) );
    300300        }
    301301        return 0;
     
    304304static int nlua_map_tile_ascii_get( lua_State* L )
    305305{
    306         map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
     306        map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
    307307        if ( lua_type( L, 2 ) == LUA_TNUMBER )
    308308        {
     
    319319static int nlua_map_tile_ascii_set( lua_State* L )
    320320{
    321         map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
     321        map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
    322322        if ( lua_type( L, 2 ) == LUA_TNUMBER )
    323323        {
    324                 tile->ascii[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3 );
     324                tile->ascii[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) );
    325325        }
    326326        else
    327327        {
    328328                nv::ivec2 coord = nv::lua::detail::to_coord( L, 2 );
    329                 tile->ascii[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3 );
     329                tile->ascii[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) );
    330330        }
    331331        return 0;
     
    334334static int nlua_map_tile_gc( lua_State* L )
    335335{
    336         map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
     336        map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
    337337        if ( tile != nullptr )
    338338        {
Note: See TracChangeset for help on using the changeset viewer.