- Timestamp:
- 08/11/13 17:19:03 (12 years ago)
- Location:
- trunk
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/formats/md2_loader.hh
r189 r198 34 34 // virtual const md3_tag* get_tag( const std::string& name ) const; 35 35 // virtual mat4 get_tag( sint32 frame, const std::string& name ) const; 36 si nt32get_max_frames() const;36 size_t get_max_frames() const; 37 37 // void load_tag_names( std::vector< std::string >& tags ); 38 38 // void load_tags( std::vector<mat4>& t, const std::string& tag ); -
trunk/nv/formats/md3_loader.hh
r190 r198 31 31 { 32 32 public: 33 virtual si nt32get_max_frames() const = 0;33 virtual size_t get_max_frames() const = 0; 34 34 virtual void load_positions( std::vector<vec3>& p, sint32 frame =-1 ) = 0; 35 35 virtual void load_normals( std::vector<vec3>& n, sint32 frame =-1 ) = 0; … … 50 50 virtual const md3_tag* get_tag( const std::string& name ) const; 51 51 virtual mat4 get_tag( sint32 frame, const std::string& name ) const; 52 si nt32get_max_frames() const;52 size_t get_max_frames() const; 53 53 void load_tag_names( std::vector< std::string >& tags ); 54 54 void load_tags( std::vector<mat4>& t, const std::string& tag ); … … 70 70 71 71 keyframed_mesh_data( keyframed_loader* loader ); 72 size_t get_frame_count() const { return m_frames; } ;73 size_t get_index_count() const { return m_indices.size(); } ;74 size_t get_vertex_count() const { return m_texcoords.size(); } ;72 size_t get_frame_count() const { return m_frames; } 73 size_t get_index_count() const { return m_indices.size(); } 74 size_t get_vertex_count() const { return m_texcoords.size(); } 75 75 const std::vector< vec3 >& get_positions() { return m_positions; } 76 76 const std::vector< vec3 >& get_normals() { return m_normals; } -
trunk/nv/formats/md5_loader.hh
r191 r198 86 86 } 87 87 88 int get_num_joints() const88 size_t get_num_joints() const 89 89 { 90 90 return m_num_joints; … … 111 111 112 112 private: 113 int m_md5_version;114 int m_num_frames;115 int m_num_joints;116 int m_frame_rate;117 int m_num_animated_components;113 size_t m_md5_version; 114 size_t m_num_frames; 115 size_t m_num_joints; 116 size_t m_frame_rate; 117 size_t m_num_animated_components; 118 118 119 119 float m_anim_duration; … … 126 126 { 127 127 public: 128 md5_loader() {} ;129 virtual ~md5_loader() {} ;128 md5_loader() {} 129 virtual ~md5_loader() {} 130 130 virtual bool load( stream& source ); 131 131 virtual size_t get_size(); 132 132 virtual mesh* release_mesh(); 133 virtual mesh* get_frame( sint32 frame) { return nullptr; }133 virtual mesh* get_frame( sint32 /*frame*/ ) { return nullptr; } 134 134 bool check_animation( const md5_animation& animation ) const; 135 135 void apply( const md5_animation& animation ); 136 136 // virtual const md3_tag* get_tag( const std::string& name ) const; 137 137 // virtual mat4 get_tag( sint32 frame, const std::string& name ) const; 138 // si nt32get_max_frames() const;138 // size_t get_max_frames() const; 139 139 // void load_tag_names( std::vector< std::string >& tags ); 140 140 // void load_tags( std::vector<mat4>& t, const std::string& tag ); … … 154 154 glm::vec3 tangent; 155 155 glm::vec2 texcoord; 156 intstart_weight;157 intweight_count;156 size_t start_weight; 157 size_t weight_count; 158 158 }; 159 159 -
trunk/nv/interface/audio.hh
r194 r198 35 35 virtual channel* play_sound( sound* a_sound ) = 0; 36 36 virtual sound* load_sound( const std::string& a_path ) = 0; 37 virtual void update() {} ;37 virtual void update() {} 38 38 virtual ~audio() {} 39 39 }; -
trunk/nv/interface/map_area.hh
r179 r198 26 26 virtual uint32 get_cell( const position& p ) const = 0; 27 27 virtual void set_cell( const position& p, uint32 value ) = 0; 28 virtual uint32 string_to_id( const nv::string& ) const { return 0; } ;29 virtual nv::string id_to_string( uint32 ) const { return nv::string(); } ;28 virtual uint32 string_to_id( const nv::string& ) const { return 0; } 29 virtual nv::string id_to_string( uint32 ) const { return nv::string(); } 30 30 virtual dimension get_size() const = 0; 31 31 virtual position get_shift() const { return position(); } … … 43 43 virtual dimension get_size() const { return m_area.get_size(); } 44 44 virtual position get_shift() const { return m_area.ul + m_map_area->get_shift(); } 45 virtual uint32 string_to_id( const nv::string& s ) const { return m_map_area->string_to_id( s ); } ;46 virtual nv::string id_to_string( uint32 id ) const { return m_map_area->id_to_string( id ); } ;45 virtual uint32 string_to_id( const nv::string& s ) const { return m_map_area->string_to_id( s ); } 46 virtual nv::string id_to_string( uint32 id ) const { return m_map_area->id_to_string( id ); } 47 47 private: 48 48 map_area* m_map_area; -
trunk/nv/interface/stream.hh
r148 r198 33 33 virtual size_t read( void* buffer, size_t size, size_t count ) = 0; 34 34 virtual size_t write( void* buffer, size_t size, size_t count ) = 0; 35 virtual bool seek( size_toffset, origin orig ) = 0;35 virtual bool seek( long offset, origin orig ) = 0; 36 36 virtual size_t tell() = 0; 37 37 virtual size_t size() = 0; -
trunk/nv/io/c_stream.hh
r134 r198 30 30 virtual size_t read( void* buffer, size_t size, size_t count ); 31 31 virtual size_t write( void* buffer, size_t size, size_t count ); 32 virtual bool seek( size_toffset, origin orig );32 virtual bool seek( long offset, origin orig ); 33 33 virtual size_t tell(); 34 34 virtual size_t size(); -
trunk/nv/lib/lua.hh
r172 r198 367 367 extern int LUA_VERSION_NUM; 368 368 #define lua_upvalueindex(i) (LUA_UPVALUEINDEX-(i)) 369 #define lua_tounsigned(L,idx) (lua_ Number)lua_tointeger(L,idx)369 #define lua_tounsigned(L,idx) (lua_Unsigned)lua_tointeger(L,idx) 370 370 #define lua_pushunsigned(L,u) lua_pushinteger(L,(lua_Integer)u) 371 371 #define lua_objlen lua_rawlen -
trunk/nv/lib/sdl.hh
r171 r198 876 876 SDL_HINT_OVERRIDE 877 877 } SDL_HintPriority; 878 #endif ;878 #endif 879 879 880 880 #if NV_SDL_VERSION == NV_SDL_20 -
trunk/nv/lua/lua_function.hh
r185 r198 25 25 { 26 26 public: 27 function_base( lua_State* L, const path& a_path, boolglobal = true );27 function_base( lua_State* a_L, const path& a_path, bool a_global = true ); 28 28 function_base( const function_base& func ); 29 29 function_base& operator=( const function_base& func ); … … 42 42 { 43 43 public: 44 function( lua_State * L, const path& a_path, boolglobal = true )45 : function_base( L, a_path,global )44 function( lua_State *a_L, const path& a_path, bool a_global = true ) 45 : function_base( a_L, a_path, a_global ) 46 46 { 47 47 } -
trunk/nv/lua/lua_map_area.hh
r179 r198 18 18 void nlua_register_map_area( lua_State* L ); 19 19 void nlua_register_map_area_interface( lua_State* L, int index ); 20 bool nlua_is_map_area( lua_State* L, int index ); 21 nv::map_area* nlua_to_map_area( lua_State* L, int index ); 22 void nlua_push_map_area( lua_State* L, nv::map_area* c ); 20 23 21 24 -
trunk/nv/lua/lua_path.hh
r188 r198 32 32 path( nv::string p ); 33 33 path( const char* p ); 34 path( inti );34 path( unsigned i ); 35 35 36 36 template < typename T1, typename T2 > -
trunk/nv/lua/lua_raw.hh
r162 r198 13 13 #include <map> 14 14 15 void nlua_toflags_ flat( lua_State *L, int index, nv::uint8* data, nv::uint32 count );15 void nlua_toflags_set( lua_State *L, int index, nv::uint8* data, nv::uint32 count ); 16 16 void nlua_toflags_array( lua_State *L, int index, nv::uint8* data, nv::uint32 count ); 17 17 void nlua_toflags( lua_State *L, int index, nv::uint8* data, nv::uint32 count ); -
trunk/src/formats/md2_loader.cc
r189 r198 17 17 18 18 // assuming low-endian 19 #define MD2_MAGIC "IDP2"20 19 #define MD2_MAX_FRAMES 512 21 20 #define MD2_MAX_SKINS 32 … … 75 74 struct md2_vertex_t 76 75 { 77 u nsigned charv[3];78 u nsigned charn;76 uint8 v[3]; 77 uint8 n; 79 78 }; 80 79 … … 127 126 } 128 127 129 static bool read_md2_frame( md2_frame_t* frame, intvcount, nv::stream& source )128 static bool read_md2_frame( md2_frame_t* frame, unsigned vcount, nv::stream& source ) 130 129 { 131 130 frame->vertices = new md2_vertex_t[ vcount ]; … … 170 169 171 170 source.seek( md2->header.offset_skins, origin::SET ); 172 source.read( md2->skins, sizeof(md2_skin_t), md2->header.num_skins);171 source.read( md2->skins, sizeof(md2_skin_t), static_cast<size_t>( md2->header.num_skins ) ); 173 172 174 173 source.seek( md2->header.offset_st, origin::SET ); 175 source.read( md2->texcoords, sizeof(md2_texcoord_t), md2->header.num_st);174 source.read( md2->texcoords, sizeof(md2_texcoord_t), static_cast<size_t>( md2->header.num_st ) ); 176 175 177 176 source.seek( md2->header.offset_tris, origin::SET ); 178 source.read( md2->triangles, sizeof(md2_triangle_t), md2->header.num_tris);177 source.read( md2->triangles, sizeof(md2_triangle_t), static_cast<size_t>( md2->header.num_tris ) ); 179 178 180 179 source.seek( md2->header.offset_glcmds, origin::SET); 181 source.read( md2->glcmds, sizeof(int), md2->header.num_glcmds);180 source.read( md2->glcmds, sizeof(int), static_cast<size_t>( md2->header.num_glcmds ) ); 182 181 183 182 md2->frames = new md2_frame_t [ md2->header.num_frames ]; … … 185 184 for ( int i = 0; i < md2->header.num_frames; ++i ) 186 185 { 187 if (!read_md2_frame( &(md2->frames[i]), md2->header.num_vertices, source ) ) return false;186 if (!read_md2_frame( &(md2->frames[i]), static_cast<unsigned>( md2->header.num_vertices ), source ) ) return false; 188 187 } 189 188 … … 197 196 } 198 197 199 static inline vec3 md2_normal( charnormal )198 static inline vec3 md2_normal( uint8 normal ) 200 199 { 201 200 return md2_vec3( md2_normal_table[normal] ); … … 269 268 } 270 269 271 si nt32md2_loader::get_max_frames() const272 { 273 return ((md2_t*)m_md2)->header.num_frames;270 size_t md2_loader::get_max_frames() const 271 { 272 return static_cast< size_t >( ((md2_t*)m_md2)->header.num_frames ); 274 273 } 275 274 … … 277 276 { 278 277 md2_t* md2 = (md2_t*)m_md2; 279 si nt32 num_frames = md2->header.num_frames;280 si nt32 num_verts =m_new_vindexes.size();278 size_t num_frames = static_cast< size_t >( md2->header.num_frames ); 279 size_t num_verts = m_new_vindexes.size(); 281 280 p.clear(); 282 si nt32 current_frame = ( frame == -1 ? 0 : frame);283 si nt32frame_count = ( frame == -1 ? num_frames : 1 );281 size_t current_frame = ( frame == -1 ? 0 : static_cast< size_t >( frame ) ); 282 size_t frame_count = ( frame == -1 ? num_frames : 1 ); 284 283 285 284 p.reserve( num_verts * frame_count ); … … 287 286 while ( frame_count > 0 ) 288 287 { 289 const md2_frame_t& frame = md2->frames[current_frame];290 NV_LOG( LOG_INFO, "FrameID = " << frame.name );291 292 vec3 scale = md2_vec3( frame.scale );293 vec3 translate = md2_vec3( frame.translate );294 295 for (si nt32i = 0; i < num_verts; ++i )288 const md2_frame_t& cframe = md2->frames[current_frame]; 289 NV_LOG( LOG_INFO, "FrameID = " << cframe.name ); 290 291 vec3 scale = md2_vec3( cframe.scale ); 292 vec3 translate = md2_vec3( cframe.translate ); 293 294 for (size_t i = 0; i < num_verts; ++i ) 296 295 { 297 const md2_vertex_t& v = frame.vertices[ m_new_vindexes[ i ] ];296 const md2_vertex_t& v = cframe.vertices[ m_new_vindexes[ i ] ]; 298 297 p.push_back( vec3( v.v[0], v.v[2], v.v[1] ) * scale + translate ); 299 298 } … … 306 305 { 307 306 md2_t* md2 = (md2_t*)m_md2; 308 si nt32 num_frames = md2->header.num_frames;309 si nt32num_verts = m_new_vindexes.size();307 size_t num_frames = static_cast< size_t >( md2->header.num_frames ); 308 size_t num_verts = m_new_vindexes.size(); 310 309 n.clear(); 311 si nt32 current_frame = ( frame == -1 ? 0 : frame);312 si nt32frame_count = ( frame == -1 ? num_frames : 1 );310 size_t current_frame = ( frame == -1 ? 0 : static_cast< size_t>( frame ) ); 311 size_t frame_count = ( frame == -1 ? num_frames : 1 ); 313 312 314 313 n.reserve( num_verts * frame_count ); … … 316 315 while ( frame_count > 0 ) 317 316 { 318 const md2_frame_t& frame = md2->frames[current_frame];319 320 for (si nt32i = 0; i < num_verts; ++i )317 const md2_frame_t& cframe = md2->frames[current_frame]; 318 319 for (size_t i = 0; i < num_verts; ++i ) 321 320 { 322 const md2_vertex_t& v = frame.vertices[ m_new_vindexes[ i ] ];321 const md2_vertex_t& v = cframe.vertices[ m_new_vindexes[ i ] ]; 323 322 n.push_back( s_md2_normal_cache[ v.n ] ); 324 323 } … … 331 330 { 332 331 md2_t* md2 = (md2_t*)m_md2; 333 si nt32num_verts = m_new_vindexes.size();332 size_t num_verts = m_new_vindexes.size(); 334 333 335 334 t.clear(); … … 338 337 vec2 scale( 1.0f / (float) md2->header.skinwidth, 1.0f / (float) md2->header.skinheight ); 339 338 340 for (si nt32i = 0; i < num_verts; ++i )339 for (size_t i = 0; i < num_verts; ++i ) 341 340 { 342 341 const md2_texcoord_t& st = md2->texcoords[ m_new_tindexes[ i ] ]; … … 354 353 { 355 354 md2_t* md2 = (md2_t*)m_md2; 356 uint32 num_indexes = md2->header.num_tris * 3;355 uint32 num_indexes = static_cast< uint32 >( md2->header.num_tris * 3 ); 357 356 358 357 uint32 stats_reuse = 0; … … 373 372 for ( int j = 0; j < 3; ++j ) 374 373 { 375 shortindex = t.vertex[j];376 shorttindex = t.st[j];374 uint16 index = t.vertex[j]; 375 uint16 tindex = t.st[j]; 377 376 378 377 if ( index_translation[ index ] != -1 ) 379 378 { 380 uint16 prev = index_translation[ index ];379 uint16 prev = static_cast< uint16 >( index_translation[ index ] ); 381 380 if ( m_new_tindexes[ prev ] == tindex ) 382 381 { -
trunk/src/formats/md3_loader.cc
r189 r198 17 17 18 18 // assuming low-endian 19 #define MD3_MAGIC "IDP3"20 19 #define MD3_MAX_FRAMES 1024 21 20 #define MD3_MAX_TAGS 16 … … 149 148 static bool read_surface( md3_surface_t * surface, nv::stream& source ) 150 149 { 151 sint32 pos = s ource.tell();150 sint32 pos = static_cast< sint32 >( source.tell() ); 152 151 source.read( &surface->header, sizeof(md3_surface_header_t), 1 ); 153 152 … … 164 163 165 164 source.seek( pos + surface->header.ofs_shaders, origin::SET ); 166 source.read( surface->shaders, sizeof( md3_shader_t ), s urface->header.num_shaders);165 source.read( surface->shaders, sizeof( md3_shader_t ), static_cast<size_t>( surface->header.num_shaders ) ); 167 166 168 167 source.seek( pos + surface->header.ofs_triangles, origin::SET ); 169 source.read( surface->triangles, sizeof( md3_triangle_t ), s urface->header.num_triangles);168 source.read( surface->triangles, sizeof( md3_triangle_t ), static_cast<size_t>( surface->header.num_triangles ) ); 170 169 171 170 source.seek( pos + surface->header.ofs_st, origin::SET ); 172 source.read( surface->st, sizeof( md3_texcoord_t ), s urface->header.num_verts);171 source.read( surface->st, sizeof( md3_texcoord_t ), static_cast<size_t>( surface->header.num_verts ) ); 173 172 174 173 source.seek( pos + surface->header.ofs_xyznormal, origin::SET ); 175 source.read( surface->vertices, sizeof( md3_vertex_t ), s urface->header.num_verts * surface->header.num_frames);174 source.read( surface->vertices, sizeof( md3_vertex_t ), static_cast<size_t>( surface->header.num_verts * surface->header.num_frames ) ); 176 175 177 176 if ( source.tell() != static_cast<std::size_t>( pos + surface->header.ofs_end ) ) return false; … … 201 200 md3->tags = new md3_tag_t [ md3->header.num_tags * md3->header.num_frames ]; 202 201 md3->surfaces = new md3_surface_t[ md3->header.num_surfaces ]; 203 std::memset( md3->surfaces, 0, md3->header.num_surfaces* sizeof(md3_surface_t) );202 std::memset( md3->surfaces, 0, static_cast< size_t >( md3->header.num_surfaces ) * sizeof(md3_surface_t) ); 204 203 205 204 source.seek( md3->header.ofs_frames, origin::SET ); 206 source.read( md3->frames, sizeof( md3_frame_t ), md3->header.num_frames);205 source.read( md3->frames, sizeof( md3_frame_t ), static_cast<size_t>( md3->header.num_frames ) ); 207 206 208 207 source.seek( md3->header.ofs_tags, origin::SET ); 209 source.read( md3->tags, sizeof( md3_tag_t ), md3->header.num_tags * md3->header.num_frames);208 source.read( md3->tags, sizeof( md3_tag_t ), static_cast<size_t>( md3->header.num_tags * md3->header.num_frames ) ); 210 209 211 210 source.seek( md3->header.ofs_surfaces, origin::SET ); … … 351 350 } 352 351 353 si nt32md3_loader::get_max_frames() const354 { 355 return ((md3_t*)m_md3)->header.num_frames;352 size_t md3_loader::get_max_frames() const 353 { 354 return static_cast< size_t >( ((md3_t*)m_md3)->header.num_frames ); 356 355 } 357 356 … … 401 400 sint32 frame_count = ( frame == -1 ? md3->header.num_frames : 1 ); 402 401 403 p.reserve( md3->vertices_per_frame * frame_count);402 p.reserve( static_cast< size_t >( md3->vertices_per_frame * frame_count ) ); 404 403 405 404 while ( frame_count > 0 ) … … 430 429 sint32 frame_count = ( frame == -1 ? md3->header.num_frames : 1 ); 431 430 432 n.reserve( md3->vertices_per_frame * frame_count);431 n.reserve( static_cast< size_t >( md3->vertices_per_frame * frame_count ) ); 433 432 434 433 while ( frame_count > 0 ) … … 476 475 { 477 476 const md3_surface_t& surface = md3->surfaces[i]; 478 const si nt32 tcount = surface.header.num_triangles;477 const size_t tcount = static_cast< size_t >( surface.header.num_triangles ); 479 478 480 479 idx.reserve( idx.size() + tcount * 3 ); 481 for (si nt32j = 0; j < tcount; ++j )480 for (size_t j = 0; j < tcount; ++j ) 482 481 { 483 482 const md3_triangle_t& t = surface.triangles[j]; -
trunk/src/formats/md5_loader.cc
r197 r198 36 36 } 37 37 38 void unit_quat_w( glm::quat& quat )38 static void unit_quat_w( glm::quat& quat ) 39 39 { 40 40 float t = 1.0f - ( quat.x * quat.x ) - ( quat.y * quat.y ) - ( quat.z * quat.z ); … … 354 354 { 355 355 discard( sstream, "{" ); 356 for ( int i = 0; i < m_num_joints; ++i )356 for ( size_t i = 0; i < m_num_joints; ++i ) 357 357 { 358 358 md5_joint_info joint; … … 368 368 discard( sstream, "{" ); 369 369 next_line( sstream ); 370 for ( int i = 0; i < m_num_frames; ++i )370 for ( size_t i = 0; i < m_num_frames; ++i ) 371 371 { 372 372 md5_bound bound; … … 390 390 next_line( sstream ); 391 391 392 for ( int i = 0; i < m_num_joints; ++i )392 for ( size_t i = 0; i < m_num_joints; ++i ) 393 393 { 394 394 md5_base_frame base_frame; … … 412 412 next_line( sstream ); 413 413 414 for ( int i = 0; i < m_num_animated_components; ++i )414 for ( size_t i = 0; i < m_num_animated_components; ++i ) 415 415 { 416 416 float frameData; … … 436 436 m_anim_time = 0.0f; 437 437 438 assert( m_joint_infos.size() == (size_t)m_num_joints );439 assert( m_bounds.size() == (size_t)m_num_frames );440 assert( m_base_frames.size() == (size_t)m_num_joints );441 assert( m_frames.size() == (size_t)m_num_frames );442 assert( m_skeletons.size() == (size_t)m_num_frames );438 assert( m_joint_infos.size() == m_num_joints ); 439 assert( m_bounds.size() == m_num_frames ); 440 assert( m_base_frames.size() == m_num_joints ); 441 assert( m_frames.size() == m_num_frames ); 442 assert( m_skeletons.size() == m_num_frames ); 443 443 444 444 return true; … … 506 506 void md5_animation::interpolate_skeletons( md5_frame_skeleton& final_skeleton, const md5_frame_skeleton& skeleton0, const md5_frame_skeleton& skeleton1, float interpolate ) 507 507 { 508 for ( int i = 0; i < m_num_joints; ++i )508 for ( size_t i = 0; i < m_num_joints; ++i ) 509 509 { 510 510 md5_skeleton_joint& final_joint = final_skeleton.joints[i]; -
trunk/src/formats/obj_loader.cc
r161 r198 119 119 struct mesh_obj_reader : public obj_reader 120 120 { 121 mesh_obj_reader( mesh* m ) : m_ mesh( m ), m_position( nullptr ), m_normal( nullptr ), m_tex_coord( nullptr ), m_tangent( nullptr) {}121 mesh_obj_reader( mesh* m ) : m_position( nullptr ), m_normal( nullptr ), m_tex_coord( nullptr ), m_tangent( nullptr ), m_mesh( m ) {} 122 122 virtual std::size_t add_face( uint32* v, uint32* t, uint32* n, size_t count ); 123 123 virtual void calculate_tangents(); … … 206 206 vec3 xyz1 = v2 - v1; 207 207 vec3 xyz2 = v3 - v1; 208 vec2 st1 = w2 - w1;209 vec2 st2 = w3 - w1;208 //vec2 st1 = w2 - w1; 209 //vec2 st2 = w3 - w1; 210 210 211 211 float s1 = w2.x - w1.x; -
trunk/src/gfx/texture_atlas.cc
r146 r198 15 15 : image( size, depth ), m_used( 0 ), m_border( border ) 16 16 { 17 m_nodes.push_back( glm::ivec3( m_border, m_border, m_size.x - 2 * m_border) );17 m_nodes.push_back( glm::ivec3( m_border, m_border, m_size.x - 2 * static_cast<int>( m_border ) ) ); 18 18 fill( 0 ); 19 19 } -
trunk/src/gl/gl_context.cc
r171 r198 363 363 #else 364 364 NV_UNUSED( a_win_handle ); 365 NV_UNUSED( m_handle ); 365 366 #endif 366 367 -
trunk/src/io/c_stream.cc
r125 r198 46 46 } 47 47 48 bool c_stream::seek( size_toffset, origin orig )48 bool c_stream::seek( long offset, origin orig ) 49 49 { 50 50 return m_file != nullptr && ( ::fseek( (FILE*)m_file, (long)offset, static_cast<int>(orig) ) == 0 ); … … 53 53 size_t c_stream::tell() 54 54 { 55 return m_file != nullptr ? ::ftell( (FILE*)m_file) : 0;55 return m_file != nullptr ? static_cast< size_t >( ::ftell( (FILE*)m_file ) ) : 0; 56 56 } 57 57 -
trunk/src/io/std_stream.cc
r138 r198 15 15 : m_stream( source ) 16 16 , m_owner( owner ) 17 , m_buffer( std::max(bsize, put_back) + put_back ) 17 18 , m_put_back( std::max( put_back, std::size_t( 1 ) ) ) 18 , m_buffer( std::max(bsize, put_back) + put_back )19 19 { 20 20 char *end = &m_buffer.front() + m_buffer.size(); … … 49 49 50 50 // start is now the start of the buffer, proper. 51 size_t n = m_stream->read( start, 1, m_buffer.size() - (start - base) );51 size_t n = m_stream->read( start, 1, m_buffer.size() - static_cast<size_t>(start - base) ); 52 52 if (n == 0) 53 53 { -
trunk/src/lib/lua.cc
r173 r198 66 66 67 67 // only loaded in 5.1 mode to implement lua_compare 68 int (*lua_equal) (lua_State *L, int idx1, int idx2) = nullptr;69 int (*lua_lessthan) (lua_State *L, int idx1, int idx2) = nullptr;68 static int (*lua_equal) (lua_State *L, int idx1, int idx2) = nullptr; 69 static int (*lua_lessthan) (lua_State *L, int idx1, int idx2) = nullptr; 70 70 71 71 … … 75 75 76 76 # define NV_LUA_COMPAT_FUN( rt, fn, fp, rt2, fn2, fp2,arg,ret ) \ 77 rt call_##fn2##_compat fp { ret fn2##_compat arg; }77 static rt call_##fn2##_compat fp { ret fn2##_compat arg; } 78 78 # include <nv/lib/detail/lua_functions_compat.inc> 79 79 # undef NV_LUA_COMPAT_FUN … … 85 85 # define LUA_GLOBALSINDEX_52 2 86 86 # define LUA_REGISTRYINDEX_51 (-10000) 87 # define lua_upvalueindex_51(i) (LUA_GLOBALSINDEX_51-(i)) 88 # define lua_upvalueindex_52(i) (LUA_REGISTRYINDEX_52-(i)) 89 90 int lua_absindex_51 (lua_State *L, int idx) { return (idx > 0 ? idx : idx + lua_gettop(L) + 1); }; 91 void lua_getglobal_51 (lua_State *L, const char *var) { lua_getfield(L, LUA_GLOBALSINDEX_51, var ); }; 92 void lua_setglobal_51 (lua_State *L, const char *var) { lua_setfield(L, LUA_GLOBALSINDEX_51, var ); }; 93 void luaL_requiref_51 (lua_State *L, const char *modname, lua_CFunction openf, int glb) 87 88 static int lua_absindex_51 (lua_State *L, int idx) { return (idx > 0 ? idx : idx + lua_gettop(L) + 1); }; 89 static void lua_getglobal_51 (lua_State *L, const char *var) { lua_getfield(L, LUA_GLOBALSINDEX_51, var ); }; 90 static void lua_setglobal_51 (lua_State *L, const char *var) { lua_setfield(L, LUA_GLOBALSINDEX_51, var ); }; 91 static void luaL_requiref_51 (lua_State *L, const char *modname, lua_CFunction openf, int glb) 94 92 { 95 93 lua_pushcfunction(L, openf); … … 105 103 } 106 104 107 void luaL_setmetatable_51 (lua_State *L, const char *tname)105 static void luaL_setmetatable_51 (lua_State *L, const char *tname) 108 106 { 109 107 luaL_getmetatable(L, tname); … … 111 109 } 112 110 113 void *luaL_testudata_51 (lua_State *L, int ud, const char *tname)111 static void *luaL_testudata_51 (lua_State *L, int ud, const char *tname) 114 112 { 115 113 void *p = lua_touserdata(L, ud); … … 128 126 } 129 127 130 const lua_Number *lua_version_51 (lua_State*)128 static const lua_Number *lua_version_51 (lua_State*) 131 129 { 132 130 static const lua_Number version = (lua_Number)LUA_VERSION_NUM; … … 134 132 } 135 133 136 void lua_copy_51 (lua_State *L, int fromidx, int toidx)134 static void lua_copy_51 (lua_State *L, int fromidx, int toidx) 137 135 { 138 136 toidx = lua_absindex( L, toidx ); … … 141 139 } 142 140 143 int lua_compare_51(lua_State *L, int idx1, int idx2, int op)141 static int lua_compare_51(lua_State *L, int idx1, int idx2, int op) 144 142 { 145 143 switch (op) … … 153 151 } 154 152 155 void lua_rawgetp_51(lua_State *L, int idx, const void *p)153 static void lua_rawgetp_51(lua_State *L, int idx, const void *p) 156 154 { 157 155 idx = lua_absindex( L, idx ); … … 161 159 } 162 160 163 void lua_rawsetp_51(lua_State *L, int idx, const void *p)161 static void lua_rawsetp_51(lua_State *L, int idx, const void *p) 164 162 { 165 163 idx = lua_absindex( L, idx ); … … 170 168 } 171 169 172 int luaL_getsubtable_51(lua_State *L, int idx, const char *fname)170 static int luaL_getsubtable_51(lua_State *L, int idx, const char *fname) 173 171 { 174 172 lua_getfield(L, idx, fname); … … 184 182 } 185 183 186 void luaL_setfuncs_51(lua_State *L, const luaL_Reg *l, int nup)184 static void luaL_setfuncs_51(lua_State *L, const luaL_Reg *l, int nup) 187 185 { 188 186 luaL_checkstack(L, nup, "too many upvalues"); … … 199 197 } 200 198 201 void lua_pushglobaltable_51(lua_State* L)199 static void lua_pushglobaltable_51(lua_State* L) 202 200 { 203 201 lua_pushvalue( L, LUA_GLOBALSINDEX_51 ); 204 202 } 205 203 206 void lua_pushglobaltable_52(lua_State* L)204 static void lua_pushglobaltable_52(lua_State* L) 207 205 { 208 206 lua_rawgeti( L, LUA_REGISTRYINDEX_52, LUA_GLOBALSINDEX_52 ); -
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; -
trunk/src/random.cc
r175 r198 47 47 uint32 random::urand( uint32 val ) 48 48 { 49 std::uniform_int_distribution< sint32> dist( 0, val - 1 );49 std::uniform_int_distribution<uint32> dist( 0, val - 1 ); 50 50 return dist( rng ); 51 51 } … … 65 65 uint32 random::urange( uint32 min, uint32 max ) 66 66 { 67 std::uniform_int_distribution< sint32> dist( min, max );67 std::uniform_int_distribution<uint32> dist( min, max ); 68 68 return dist( rng ); 69 69 }
Note: See TracChangeset
for help on using the changeset viewer.