diff --git a/StepmaniaCore.cmake b/StepmaniaCore.cmake index fced180a02..cda64c097e 100644 --- a/StepmaniaCore.cmake +++ b/StepmaniaCore.cmake @@ -107,20 +107,14 @@ check_function_exists(waitpid HAVE_WAITPID) # Mostly universal symbols. check_cxx_symbol_exists(strtof cstdlib HAVE_STRTOF) -check_symbol_exists(size_t stddef.h HAVE_SIZE_T_STDDEF) -check_symbol_exists(size_t stdlib.h HAVE_SIZE_T_STDLIB) -check_symbol_exists(size_t stdio.h HAVE_SIZE_T_STDIO) check_symbol_exists(posix_fadvise fcntl.h HAVE_POSIX_FADVISE) # Checks to make it easier to work with 32-bit/64-bit builds if required. include(CheckTypeSize) -check_type_size(intptr_t SIZEOF_INTPTR_T) check_type_size(pid_t SIZEOF_PID_T) -check_type_size(size_t SIZEOF_SIZE_T) -check_type_size(ssize_t SIZEOF_SSIZE_T) if(WIN32) - if(SIZEOF_INTPTR_T EQUAL 8) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(SM_WIN32_ARCH "x64") else() set(SM_WIN32_ARCH "x86") diff --git a/extern/config.jpeg.in.h b/extern/config.jpeg.in.h index 50dead314a..d65d3dc556 100644 --- a/extern/config.jpeg.in.h +++ b/extern/config.jpeg.in.h @@ -17,16 +17,10 @@ #endif /* Defined to 1 if we have an unsigned char type. */ -#cmakedefine HAVE_SIZEOF_UNSIGNED_CHAR 1 -#if defined(HAVE_SIZEOF_UNSIGNED_CHAR) #define HAVE_UNSIGNED_CHAR 1 -#endif /* Defined to 1 if we have an unsigned short type. */ -#cmakedefine HAVE_SIZEOF_UNSIGNED_SHORT 1 -#if defined(HAVE_SIZEOF_UNSIGNED_SHORT) #define HAVE_UNSIGNED_SHORT 1 -#endif /* At some point, allow for defining CHAR_IS_UNSIGNED. */ diff --git a/src/Actor.cpp b/src/Actor.cpp index 501d9cfbd3..13f249fe00 100644 --- a/src/Actor.cpp +++ b/src/Actor.cpp @@ -15,6 +15,7 @@ #include "Preference.h" #include +#include #include static Preference g_bShowMasks("ShowMasks", false); @@ -173,7 +174,7 @@ Actor::~Actor() { StopTweening(); UnsubscribeAll(); - for(size_t i= 0; i < m_WrapperStates.size(); ++i) + for(std::size_t i= 0; i < m_WrapperStates.size(); ++i) { SAFE_DELETE(m_WrapperStates[i]); } @@ -194,7 +195,7 @@ Actor::Actor( const Actor &cpy ): CPY( m_pLuaInstance ); m_WrapperStates.resize(cpy.m_WrapperStates.size()); - for(size_t i= 0; i < m_WrapperStates.size(); ++i) + for(std::size_t i= 0; i < m_WrapperStates.size(); ++i) { m_WrapperStates[i]= new ActorFrame(*dynamic_cast(cpy.m_WrapperStates[i])); } @@ -402,7 +403,7 @@ void Actor::Draw() { m_FakeParent->BeginDraw(); } - size_t wrapper_states_used= 0; + std::size_t wrapper_states_used= 0; RageColor last_diffuse; RageColor last_glow; bool use_last_diffuse= false; @@ -418,7 +419,7 @@ void Actor::Draw() // wrapper[3] is the outermost frame. wrapper[2] is inside wrapper[3]. // wrapper[1] is inside wrapper[2]. The actor is inside wrapper[1]. // -Kyz - for(size_t i= m_WrapperStates.size(); i > 0 && dont_abort_draw; --i) + for(std::size_t i= m_WrapperStates.size(); i > 0 && dont_abort_draw; --i) { Actor* state= m_WrapperStates[i-1]; if(!state->m_bVisible || state->m_fHibernateSecondsLeft > 0 || @@ -467,7 +468,7 @@ void Actor::Draw() } this->PostDraw(); } - for(size_t i= 0; i < wrapper_states_used; ++i) + for(std::size_t i= 0; i < wrapper_states_used; ++i) { Actor* state= m_WrapperStates[i]; if(abort_with_end_draw) @@ -886,7 +887,7 @@ void Actor::Update( float fDeltaTime ) fDeltaTime = -m_fHibernateSecondsLeft; m_fHibernateSecondsLeft = 0; } - for(size_t i= 0; i < m_WrapperStates.size(); ++i) + for(std::size_t i= 0; i < m_WrapperStates.size(); ++i) { m_WrapperStates[i]->Update(fDeltaTime); } @@ -992,14 +993,14 @@ void Actor::AddWrapperState() m_WrapperStates.push_back(wrapper); } -void Actor::RemoveWrapperState(size_t i) +void Actor::RemoveWrapperState(std::size_t i) { ASSERT(i < m_WrapperStates.size()); SAFE_DELETE(m_WrapperStates[i]); m_WrapperStates.erase(m_WrapperStates.begin()+i); } -Actor* Actor::GetWrapperState(size_t i) +Actor* Actor::GetWrapperState(std::size_t i) { ASSERT(i < m_WrapperStates.size()); return m_WrapperStates[i]; @@ -1972,11 +1973,11 @@ public: p->GetWrapperState(p->GetNumWrapperStates()-1)->PushSelf(L); return 1; } - static size_t get_state_index(T* p, lua_State* L, int stack_index) + static std::size_t get_state_index(T* p, lua_State* L, int stack_index) { // Lua is one indexed. int i= IArg(stack_index)-1; - const size_t si= static_cast(i); + const std::size_t si= static_cast(i); if(i < 0 || si >= p->GetNumWrapperStates()) { luaL_error(L, "%d is not a valid wrapper state index.", i+1); @@ -1985,7 +1986,7 @@ public: } static int RemoveWrapperState(T* p, lua_State* L) { - size_t si= get_state_index(p, L, 1); + std::size_t si= get_state_index(p, L, 1); p->RemoveWrapperState(si); COMMON_RETURN_SELF; } @@ -1996,7 +1997,7 @@ public: } static int GetWrapperState(T* p, lua_State* L) { - size_t si= get_state_index(p, L, 1); + std::size_t si= get_state_index(p, L, 1); p->GetWrapperState(si)->PushSelf(L); return 1; } diff --git a/src/Actor.h b/src/Actor.h index 5fdfe69002..96f1a34979 100644 --- a/src/Actor.h +++ b/src/Actor.h @@ -13,6 +13,8 @@ class LuaClass; #include "MessageManager.h" #include "Tween.h" +#include + typedef AutoPtrCopyOnWrite apActorCommands; /** @brief The background layer. */ @@ -275,8 +277,8 @@ public: virtual void DrawPrimitives() {}; /** @brief Pop the transform from the world matrix stack. */ virtual void EndDraw(); - - // TODO: make Update non virtual and change all classes to override UpdateInternal + + // TODO: make Update non virtual and change all classes to override UpdateInternal // instead. bool IsFirstUpdate() const; virtual void Update( float fDeltaTime ); // this can short circuit UpdateInternal @@ -315,9 +317,9 @@ public: Actor* GetFakeParent() { return m_FakeParent; } void AddWrapperState(); - void RemoveWrapperState(size_t i); - Actor* GetWrapperState(size_t i); - size_t GetNumWrapperStates() const { return m_WrapperStates.size(); } + void RemoveWrapperState(std::size_t i); + Actor* GetWrapperState(std::size_t i); + std::size_t GetNumWrapperStates() const { return m_WrapperStates.size(); } /** * @brief Retrieve the Actor's x position. @@ -397,9 +399,9 @@ public: * @brief Set the zoom factor for all dimensions of the Actor. * @param zoom the zoom factor for all dimensions. */ void SetZoom( float zoom ) - { - DestTweenState().scale.x = zoom; - DestTweenState().scale.y = zoom; + { + DestTweenState().scale.x = zoom; + DestTweenState().scale.y = zoom; DestTweenState().scale.z = zoom; } /** @@ -497,7 +499,7 @@ public: /** @brief How do we handle stretching the Actor? */ enum StretchType - { + { fit_inside, /**< Have the Actor fit inside its parent, using the smaller zoom. */ cover /**< Have the Actor cover its parent, using the larger zoom. */ }; @@ -579,16 +581,16 @@ public: void StopAnimating() { this->EnableAnimation(false); } // render states - void SetBlendMode( BlendMode mode ) { m_BlendMode = mode; } + void SetBlendMode( BlendMode mode ) { m_BlendMode = mode; } void SetTextureTranslate( float x, float y ) { m_texTranslate.x = x; m_texTranslate.y = y; } - void SetTextureWrapping( bool b ) { m_bTextureWrapping = b; } - void SetTextureFiltering( bool b ) { m_bTextureFiltering = b; } - void SetClearZBuffer( bool b ) { m_bClearZBuffer = b; } - void SetUseZBuffer( bool b ) { SetZTestMode(b?ZTEST_WRITE_ON_PASS:ZTEST_OFF); SetZWrite(b); } - virtual void SetZTestMode( ZTestMode mode ) { m_ZTestMode = mode; } - virtual void SetZWrite( bool b ) { m_bZWrite = b; } + void SetTextureWrapping( bool b ) { m_bTextureWrapping = b; } + void SetTextureFiltering( bool b ) { m_bTextureFiltering = b; } + void SetClearZBuffer( bool b ) { m_bClearZBuffer = b; } + void SetUseZBuffer( bool b ) { SetZTestMode(b?ZTEST_WRITE_ON_PASS:ZTEST_OFF); SetZWrite(b); } + virtual void SetZTestMode( ZTestMode mode ) { m_ZTestMode = mode; } + virtual void SetZWrite( bool b ) { m_bZWrite = b; } void SetZBias( float f ) { m_fZBias = f; } - virtual void SetCullMode( CullMode mode ) { m_CullMode = mode; } + virtual void SetCullMode( CullMode mode ) { m_CullMode = mode; } // Lua virtual void PushSelf( lua_State *L ); @@ -761,7 +763,7 @@ private: * @author Chris Danford (c) 2001-2004 * @section LICENSE * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -771,7 +773,7 @@ private: * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/ActorMultiTexture.cpp b/src/ActorMultiTexture.cpp index 3fd83fd236..e7b52090a0 100644 --- a/src/ActorMultiTexture.cpp +++ b/src/ActorMultiTexture.cpp @@ -1,6 +1,4 @@ #include "global.h" -#include - #include "ActorMultiTexture.h" #include "RageTextureManager.h" #include "XmlFile.h" @@ -9,10 +7,12 @@ #include "RageTexture.h" #include "RageUtil.h" #include "ActorUtil.h" - #include "LuaBinding.h" #include "LuaManager.h" +#include +#include + REGISTER_ACTOR_CLASS( ActorMultiTexture ); @@ -98,7 +98,7 @@ void ActorMultiTexture::DrawPrimitives() quadVerticies.bottom = +m_size.y/2.0f; DISPLAY->ClearAllTextures(); - for( size_t i = 0; i < m_aTextureUnits.size(); ++i ) + for( std::size_t i = 0; i < m_aTextureUnits.size(); ++i ) { TextureUnit tu = enum_add2(TextureUnit_1, i); DISPLAY->SetTexture( tu, m_aTextureUnits[i].m_pTexture->GetTexHandle() ); @@ -127,7 +127,7 @@ void ActorMultiTexture::DrawPrimitives() DISPLAY->DrawQuad( v ); - for( size_t i = 0; i < m_aTextureUnits.size(); ++i ) + for( std::size_t i = 0; i < m_aTextureUnits.size(); ++i ) DISPLAY->SetTexture( enum_add2(TextureUnit_1, i), 0 ); DISPLAY->SetEffectMode( EffectMode_Normal ); @@ -142,7 +142,7 @@ bool ActorMultiTexture::EarlyAbortDraw() const // lua start #include "LuaBinding.h" -/** @brief Allow Lua to have access to the ActorMultiTexture. */ +/** @brief Allow Lua to have access to the ActorMultiTexture. */ class LunaActorMultiTexture: public Luna { public: @@ -200,7 +200,7 @@ LUA_REGISTER_DERIVED_CLASS( ActorMultiTexture, Actor ) /* * (c) 2001-2007 Glenn Maynard, Chris Danford * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -210,7 +210,7 @@ LUA_REGISTER_DERIVED_CLASS( ActorMultiTexture, Actor ) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/ActorMultiVertex.cpp b/src/ActorMultiVertex.cpp index dd67ce69a9..e6640b1297 100644 --- a/src/ActorMultiVertex.cpp +++ b/src/ActorMultiVertex.cpp @@ -1,6 +1,4 @@ #include "global.h" -#include - #include "ActorMultiVertex.h" #include "RageTextureManager.h" #include "XmlFile.h" @@ -14,6 +12,8 @@ #include "LuaManager.h" #include "LocalizedString.h" +#include +#include #include const float min_state_delay= 0.0001f; @@ -67,7 +67,7 @@ ActorMultiVertex::ActorMultiVertex() _EffectMode = EffectMode_Normal; _TextureMode = TextureMode_Modulate; _splines.resize(num_vert_splines); - for(size_t i= 0; i < num_vert_splines; ++i) + for(std::size_t i= 0; i < num_vert_splines; ++i) { _splines[i].redimension(3); _splines[i].m_owned_by_actor= true; @@ -156,11 +156,11 @@ void ActorMultiVertex::UnloadTexture() } } -void ActorMultiVertex::SetNumVertices( size_t n ) +void ActorMultiVertex::SetNumVertices( std::size_t n ) { if( n == 0 ) { - for( size_t i = 0; i < AMV_Tweens.size(); ++i ) + for( std::size_t i = 0; i < AMV_Tweens.size(); ++i ) { AMV_Tweens[i].vertices.clear(); } @@ -169,7 +169,7 @@ void ActorMultiVertex::SetNumVertices( size_t n ) } else { - for( size_t i = 0; i < AMV_Tweens.size(); ++i ) + for( std::size_t i = 0; i < AMV_Tweens.size(); ++i ) { AMV_Tweens[i].vertices.resize( n ); } @@ -180,7 +180,7 @@ void ActorMultiVertex::SetNumVertices( size_t n ) void ActorMultiVertex::AddVertex() { - for( size_t i = 0; i < AMV_Tweens.size(); ++i ) + for( std::size_t i = 0; i < AMV_Tweens.size(); ++i ) { AMV_Tweens[i].vertices.push_back( RageSpriteVertex() ); } @@ -192,7 +192,7 @@ void ActorMultiVertex::AddVertices( int Add ) { int size = AMV_DestTweenState().vertices.size(); size += Add; - for( size_t i = 0; i < AMV_Tweens.size(); ++i ) + for( std::size_t i = 0; i < AMV_Tweens.size(); ++i ) { AMV_Tweens[i].vertices.resize( size ); } @@ -224,7 +224,7 @@ void ActorMultiVertex::DrawPrimitives() Actor::SetTextureRenderStates(); DISPLAY->SetEffectMode( _EffectMode ); - + // set temporary diffuse and glow static AMV_TweenState TS; @@ -235,7 +235,7 @@ void ActorMultiVertex::DrawPrimitives() if( m_pTempState->diffuse[0] != RageColor(1, 1, 1, 1) && m_pTempState->diffuse[0].a > 0 ) { - for( size_t i=0; i < TS.vertices.size(); i++ ) + for( std::size_t i=0; i < TS.vertices.size(); i++ ) { // RageVColor uses a uint8_t for each channel. 0-255. // RageColor uses a float. 0-1. @@ -254,9 +254,9 @@ void ActorMultiVertex::DrawPrimitives() MULT_COLOR_ELEMENTS(TS.vertices[i].c.a, m_pTempState->diffuse[0].a); #undef MULT_COLOR_ELEMENTS } - + } - + // Draw diffuse pass. if( m_pTempState->diffuse[0].a > 0 ) { @@ -268,10 +268,10 @@ void ActorMultiVertex::DrawPrimitives() if( m_pTempState->glow.a > 0 ) { - for( size_t i=0; i < TS.vertices.size(); i++ ) + for( std::size_t i=0; i < TS.vertices.size(); i++ ) { TS.vertices[i].c = m_pTempState->glow; - } + } DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow ); DrawInternal( AMV_TempState ); @@ -343,19 +343,19 @@ bool ActorMultiVertex::EarlyAbortDraw() const return false; } -void ActorMultiVertex::SetVertsFromSplinesInternal(size_t num_splines, size_t offset) +void ActorMultiVertex::SetVertsFromSplinesInternal(std::size_t num_splines, std::size_t offset) { std::vector& verts= AMV_DestTweenState().vertices; - size_t first= AMV_DestTweenState().FirstToDraw + offset; - size_t num_verts= AMV_DestTweenState().GetSafeNumToDraw(AMV_DestTweenState()._DrawMode, AMV_DestTweenState().NumToDraw) - offset; + std::size_t first= AMV_DestTweenState().FirstToDraw + offset; + std::size_t num_verts= AMV_DestTweenState().GetSafeNumToDraw(AMV_DestTweenState()._DrawMode, AMV_DestTweenState().NumToDraw) - offset; std::vector tper(num_splines, 0.0f); float num_parts= (static_cast(num_verts) / static_cast(num_splines)) - 1.0f; - for(size_t i= 0; i < num_splines; ++i) + for(std::size_t i= 0; i < num_splines; ++i) { tper[i]= _splines[i].get_max_t() / num_parts; } - for(size_t v= 0; v < num_verts; ++v) + for(std::size_t v= 0; v < num_verts; ++v) { std::vector pos; const int spi= v%num_splines; @@ -395,7 +395,7 @@ void ActorMultiVertex::SetVertsFromSplines() } } -CubicSplineN* ActorMultiVertex::GetSpline(size_t i) +CubicSplineN* ActorMultiVertex::GetSpline(std::size_t i) { ASSERT(i < num_vert_splines); return &(_splines[i]); @@ -403,7 +403,7 @@ CubicSplineN* ActorMultiVertex::GetSpline(size_t i) void ActorMultiVertex::SetState(int i) { - ASSERT(i >= 0 && static_cast(i) < _states.size()); + ASSERT(i >= 0 && static_cast(i) < _states.size()); _cur_state= i; _secs_into_state= 0.0f; } @@ -439,7 +439,7 @@ void ActorMultiVertex::UpdateAnimationState(bool force_update) { AMV_TweenState& dest= AMV_DestTweenState(); std::vector& verts= dest.vertices; - std::vector& qs= dest.quad_states; + std::vector& qs= dest.quad_states; if(!_use_animation_state || _states.empty() || dest._DrawMode == DrawMode_LineStrip || qs.empty()) { return; } @@ -456,15 +456,15 @@ void ActorMultiVertex::UpdateAnimationState(bool force_update) } if(state_changed) { - size_t first= dest.FirstToDraw; - size_t last= first+dest.GetSafeNumToDraw(dest._DrawMode, dest.NumToDraw); -#define STATE_ID const size_t state_id= (_cur_state + qs[quad_id % qs.size()]) % _states.size(); + std::size_t first= dest.FirstToDraw; + std::size_t last= first+dest.GetSafeNumToDraw(dest._DrawMode, dest.NumToDraw); +#define STATE_ID const std::size_t state_id= (_cur_state + qs[quad_id % qs.size()]) % _states.size(); switch(AMV_DestTweenState()._DrawMode) { case DrawMode_Quads: - for(size_t i= first; i < last; ++i) + for(std::size_t i= first; i < last; ++i) { - const size_t quad_id= (i-first)/4; + const std::size_t quad_id= (i-first)/4; STATE_ID; switch((i-first)%4) { @@ -488,9 +488,9 @@ void ActorMultiVertex::UpdateAnimationState(bool force_update) } break; case DrawMode_QuadStrip: - for(size_t i= first; i < last; ++i) + for(std::size_t i= first; i < last; ++i) { - const size_t quad_id= (i-first)/2; + const std::size_t quad_id= (i-first)/2; STATE_ID; switch((i-first)%2) { @@ -507,18 +507,18 @@ void ActorMultiVertex::UpdateAnimationState(bool force_update) break; case DrawMode_Strip: case DrawMode_Fan: - for(size_t i= first; i < last; ++i) + for(std::size_t i= first; i < last; ++i) { - const size_t quad_id= (i-first); + const std::size_t quad_id= (i-first); STATE_ID; verts[i].t.x= _states[state_id].rect.left; verts[i].t.y= _states[state_id].rect.top; } break; case DrawMode_Triangles: - for(size_t i= first; i < last; ++i) + for(std::size_t i= first; i < last; ++i) { - const size_t quad_id= (i-first)/3; + const std::size_t quad_id= (i-first)/3; STATE_ID; switch((i-first)%3) { @@ -538,9 +538,9 @@ void ActorMultiVertex::UpdateAnimationState(bool force_update) } break; case DrawMode_SymmetricQuadStrip: - for(size_t i= first; i < last; ++i) + for(std::size_t i= first; i < last; ++i) { - const size_t quad_id= (i-first)/3; + const std::size_t quad_id= (i-first)/3; STATE_ID; switch((i-first)%3) { @@ -660,7 +660,7 @@ void ActorMultiVertex::AMV_TweenState::SetDrawState( DrawMode dm, int first, int void ActorMultiVertex::AMV_TweenState::MakeWeightedAverage(AMV_TweenState& average_out, const AMV_TweenState& ts1, const AMV_TweenState& ts2, float percent_between) { average_out.line_width= lerp(percent_between, ts1.line_width, ts2.line_width); - for(size_t v= 0; v < average_out.vertices.size(); ++v) + for(std::size_t v= 0; v < average_out.vertices.size(); ++v) { WeightedAvergeOfRSVs(average_out.vertices[v], ts1.vertices[v], ts2.vertices[v], percent_between); } @@ -685,7 +685,7 @@ int ActorMultiVertex::AMV_TweenState::GetSafeNumToDraw( DrawMode dm, int num ) c // lua start #include "LuaBinding.h" -/** @brief Allow Lua to have access to the ActorMultiVertex. */ +/** @brief Allow Lua to have access to the ActorMultiVertex. */ class LunaActorMultiVertex: public Luna { public: @@ -696,7 +696,7 @@ public: } static int GetNumVertices( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumVertices() ); return 1; } - static void SetVertexFromStack(T* p, lua_State* L, size_t VertexIndex, int DataStackIndex) + static void SetVertexFromStack(T* p, lua_State* L, std::size_t VertexIndex, int DataStackIndex) { // Use the number of arguments to determine which property a table is for if(lua_type(L, DataStackIndex) != LUA_TTABLE) @@ -704,13 +704,13 @@ public: LuaHelpers::ReportScriptErrorFmt("ActorMultiVertex::SetVertex: non-table parameter supplied. Table of tables of vertex data expected."); return; } - size_t NumDataParts = lua_objlen(L, DataStackIndex); - for(size_t i = 0; i < NumDataParts; ++i) + std::size_t NumDataParts = lua_objlen(L, DataStackIndex); + for(std::size_t i = 0; i < NumDataParts; ++i) { lua_pushnumber(L, i+1); lua_gettable(L, DataStackIndex); int DataPieceIndex = lua_gettop(L); - size_t DataPieceElements = lua_objlen(L, DataPieceIndex); + std::size_t DataPieceElements = lua_objlen(L, DataPieceIndex); if(lua_type(L, DataPieceIndex) != LUA_TTABLE) { LuaHelpers::ReportScriptErrorFmt( "ActorMultiVertex::SetVertex: non-table parameter %u supplied inside table of parameters, table expected.", (unsigned int)i ); @@ -889,7 +889,7 @@ public: lua_pushnumber(L, p->GetDestNumToDraw()); return 1; } - + static int GetCurrDrawMode( T* p, lua_State* L ) { Enum::Push(L, p->GetCurrDrawMode()); @@ -908,7 +908,7 @@ public: lua_pushnumber(L, p->GetCurrNumToDraw()); return 1; } - + static int LoadTexture( T* p, lua_State *L ) { if( lua_isnil(L, 1) ) @@ -928,7 +928,7 @@ public: static int GetSpline(T* p, lua_State* L) { - size_t i= static_cast(IArg(1)-1); + std::size_t i= static_cast(IArg(1)-1); if(i >= ActorMultiVertex::num_vert_splines) { luaL_error(L, "Spline index must be greater than 0 and less than or equal to %zu.", ActorMultiVertex::num_vert_splines); @@ -999,14 +999,14 @@ public: p->AddState(s); COMMON_RETURN_SELF; } - static size_t ValidStateIndex(T* p, lua_State *L, int pos) + static std::size_t ValidStateIndex(T* p, lua_State *L, int pos) { int index= IArg(pos)-1; if(index < 0 || index >= p->GetNumStates()) { luaL_error(L, "Invalid state index %d.", index+1); } - return static_cast(index); + return static_cast(index); } static int RemoveState(T* p, lua_State *L) { @@ -1069,9 +1069,9 @@ public: luaL_error(L, "The texture must be set before adding states."); } std::vector new_states; - size_t num_states= lua_objlen(L, 1); + std::size_t num_states= lua_objlen(L, 1); new_states.resize(num_states); - for(size_t i= 0; i < num_states; ++i) + for(std::size_t i= 0; i < num_states; ++i) { lua_rawgeti(L, 1, i+1); FillStateFromLua(L, new_states[i], tex, -1); @@ -1096,14 +1096,14 @@ public: lua_pushnumber(L, p->GetNumQuadStates()); return 1; } - static size_t QuadStateIndex(T* p, lua_State *L, int pos) + static std::size_t QuadStateIndex(T* p, lua_State *L, int pos) { int index= IArg(pos)-1; - if(index < 0 || static_cast(index) >= p->GetNumQuadStates()) + if(index < 0 || static_cast(index) >= p->GetNumQuadStates()) { luaL_error(L, "Invalid state index %d.", index+1); } - return static_cast(index); + return static_cast(index); } static int AddQuadState(T* p, lua_State *L) { @@ -1215,7 +1215,7 @@ LUA_REGISTER_DERIVED_CLASS( ActorMultiVertex, Actor ) /* * (c) 2014 Matthew Gardner and Eric Reese * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -1225,7 +1225,7 @@ LUA_REGISTER_DERIVED_CLASS( ActorMultiVertex, Actor ) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/ActorMultiVertex.h b/src/ActorMultiVertex.h index eedf94d9b4..d3df211ce3 100644 --- a/src/ActorMultiVertex.h +++ b/src/ActorMultiVertex.h @@ -6,6 +6,8 @@ #include "RageMath.h" #include "RageTextureID.h" +#include + enum DrawMode { DrawMode_Quads = 0, @@ -28,7 +30,7 @@ class RageTexture; class ActorMultiVertex: public Actor { public: - static const size_t num_vert_splines= 4; + static const std::size_t num_vert_splines= 4; ActorMultiVertex(); ActorMultiVertex( const ActorMultiVertex &cpy ); virtual ~ActorMultiVertex(); @@ -49,7 +51,7 @@ public: int GetSafeNumToDraw( DrawMode dm, int num ) const; std::vector vertices; - std::vector quad_states; + std::vector quad_states; DrawMode _DrawMode; int FirstToDraw; @@ -73,7 +75,7 @@ public: virtual bool EarlyAbortDraw() const override; virtual void DrawPrimitives() override; virtual void DrawInternal( const AMV_TweenState *TS ); - + void SetCurrentTweenStart() override; void EraseHeadTween() override; void UpdatePercentThroughTween( float PercentThroughTween ) override; @@ -81,13 +83,13 @@ public: void StopTweening() override; void FinishTweening() override; - + void SetTexture( RageTexture *Texture ); RageTexture* GetTexture() { return _Texture; }; void LoadFromTexture( RageTextureID ID ); void UnloadTexture(); - void SetNumVertices( size_t n ); + void SetNumVertices( std::size_t n ); void AddVertex(); void AddVertices( int Add ); @@ -104,15 +106,15 @@ public: DrawMode GetCurrDrawMode() const { return AMV_current._DrawMode; } int GetCurrFirstToDraw() const { return AMV_current.FirstToDraw; } int GetCurrNumToDraw() const { return AMV_current.NumToDraw; } - size_t GetNumVertices() { return AMV_DestTweenState().vertices.size(); } - + std::size_t GetNumVertices() { return AMV_DestTweenState().vertices.size(); } + void SetVertexPos( int index , float x , float y , float z ); void SetVertexColor( int index , RageColor c ); void SetVertexCoords( int index , float TexCoordX , float TexCoordY ); - inline void SetVertsFromSplinesInternal(size_t num_splines, size_t start_vert); + inline void SetVertsFromSplinesInternal(std::size_t num_splines, std::size_t start_vert); void SetVertsFromSplines(); - CubicSplineN* GetSpline(size_t i); + CubicSplineN* GetSpline(std::size_t i); struct State { @@ -121,12 +123,12 @@ public: }; int GetNumStates() const override { return _states.size(); } void AddState(const State& new_state) { _states.push_back(new_state); } - void RemoveState(size_t i) + void RemoveState(std::size_t i) { ASSERT(i < _states.size()); _states.erase(_states.begin()+i); } - size_t GetState() { return _cur_state; } - State& GetStateData(size_t i) + std::size_t GetState() { return _cur_state; } + State& GetStateData(std::size_t i) { ASSERT(i < _states.size()); return _states[i]; } - void SetStateData(size_t i, const State& s) + void SetStateData(std::size_t i, const State& s) { ASSERT(i < _states.size()); _states[i]= s; } void SetStateProperties(const std::vector& new_states) { _states= new_states; SetState(0); } @@ -135,15 +137,15 @@ public: float GetAnimationLengthSeconds() const override; void SetSecondsIntoAnimation(float seconds) override; void UpdateAnimationState(bool force_update= false); - size_t GetNumQuadStates() const + std::size_t GetNumQuadStates() const { return AMV_DestTweenState().quad_states.size(); } - void AddQuadState(size_t s) + void AddQuadState(std::size_t s) { AMV_DestTweenState().quad_states.push_back(s); } - void RemoveQuadState(size_t i) + void RemoveQuadState(std::size_t i) { AMV_DestTweenState().quad_states.erase(AMV_DestTweenState().quad_states.begin()+i); } - size_t GetQuadState(size_t i) + std::size_t GetQuadState(std::size_t i) { return AMV_DestTweenState().quad_states[i]; } - void SetQuadState(size_t i, size_t s) + void SetQuadState(std::size_t i, std::size_t s) { AMV_DestTweenState().quad_states[i]= s; } bool _use_animation_state; bool _decode_movie; @@ -160,7 +162,7 @@ private: // required to handle diffuse and glow AMV_TweenState *AMV_TempState; - + EffectMode _EffectMode; TextureMode _TextureMode; @@ -170,7 +172,7 @@ private: bool _skip_next_update; float _secs_into_state; - size_t _cur_state; + std::size_t _cur_state; std::vector _states; }; @@ -179,7 +181,7 @@ private: * @author Matthew Gardner and Eric Reese (c) 2014 * @section LICENSE * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -189,7 +191,7 @@ private: * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/AdjustSync.cpp b/src/AdjustSync.cpp index bf1917003e..132ab278cb 100644 --- a/src/AdjustSync.cpp +++ b/src/AdjustSync.cpp @@ -43,6 +43,7 @@ #include "ScreenManager.h" #include +#include std::vector AdjustSync::s_vpTimingDataOriginal; @@ -359,7 +360,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector &vsAddTo ) const std::vector &bpmTest = testing.GetTimingSegments(SEGMENT_BPM); const std::vector &bpmOrig = original.GetTimingSegments(SEGMENT_BPM); SEGMENTS_MISMATCH_MESSAGE(bpmOrig, bpmTest, bpm); - for(size_t i= 0; i < bpmTest.size() && i < bpmOrig.size(); i++) + for(std::size_t i= 0; i < bpmTest.size() && i < bpmOrig.size(); i++) { float fNew = Quantize( ToBPM(bpmTest[i])->GetBPM(), 0.001f ); float fOld = Quantize( ToBPM(bpmOrig[i])->GetBPM(), 0.001f ); @@ -383,7 +384,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector &vsAddTo ) const std::vector &stopOrig = original.GetTimingSegments(SEGMENT_STOP); SEGMENTS_MISMATCH_MESSAGE(stopOrig, stopTest, stop); - for(size_t i= 0; i < stopTest.size() && i < stopOrig.size(); i++) + for(std::size_t i= 0; i < stopTest.size() && i < stopOrig.size(); i++) { float fOld = Quantize( ToStop(stopOrig[i])->GetPause(), 0.001f ); float fNew = Quantize( ToStop(stopTest[i])->GetPause(), 0.001f ); @@ -406,7 +407,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector &vsAddTo ) const std::vector &delyOrig = original.GetTimingSegments(SEGMENT_DELAY); SEGMENTS_MISMATCH_MESSAGE(delyOrig, delyTest, delay); - for(size_t i= 0; i < delyTest.size() && i < delyOrig.size(); i++) + for(std::size_t i= 0; i < delyTest.size() && i < delyOrig.size(); i++) { if( delyTest[i] == delyOrig[i] ) continue; diff --git a/src/ArrowEffects.cpp b/src/ArrowEffects.cpp index 35e5a3ce8f..5ea304a8ab 100644 --- a/src/ArrowEffects.cpp +++ b/src/ArrowEffects.cpp @@ -15,6 +15,7 @@ #include #include +#include static char const dimension_names[4]= "XYZ"; @@ -50,15 +51,15 @@ static ThemeMetric TIPSY_OFFSET_TIMER_FREQUENCY( "ArrowEffects", "TipsyOf static ThemeMetric TIPSY_OFFSET_COLUMN_FREQUENCY( "ArrowEffects", "TipsyOffsetColumnFrequency" ); static ThemeMetric TIPSY_OFFSET_ARROW_MAGNITUDE( "ArrowEffects", "TipsyOffsetArrowMagnitude" ); -static RString TPSTL_NAME(size_t i) { return ssprintf("Tornado%cPositionScaleToLow", dimension_names[i]); } +static RString TPSTL_NAME(std::size_t i) { return ssprintf("Tornado%cPositionScaleToLow", dimension_names[i]); } static ThemeMetric1D TORNADO_POSITION_SCALE_TO_LOW("ArrowEffects", TPSTL_NAME, 3); -static RString TPSTH_NAME(size_t i) { return ssprintf("Tornado%cPositionScaleToHigh", dimension_names[i]); } +static RString TPSTH_NAME(std::size_t i) { return ssprintf("Tornado%cPositionScaleToHigh", dimension_names[i]); } static ThemeMetric1D TORNADO_POSITION_SCALE_TO_HIGH("ArrowEffects", TPSTH_NAME, 3); -static RString TOF_NAME(size_t i) { return ssprintf("Tornado%cOffsetFrequency", dimension_names[i]); } +static RString TOF_NAME(std::size_t i) { return ssprintf("Tornado%cOffsetFrequency", dimension_names[i]); } static ThemeMetric1D TORNADO_OFFSET_FREQUENCY("ArrowEffects", TOF_NAME, 3); -static RString TOSFL_NAME(size_t i) { return ssprintf("Tornado%cOffsetScaleFromLow", dimension_names[i]); } +static RString TOSFL_NAME(std::size_t i) { return ssprintf("Tornado%cOffsetScaleFromLow", dimension_names[i]); } static ThemeMetric1D TORNADO_OFFSET_SCALE_FROM_LOW("ArrowEffects", TOSFL_NAME, 3); -static RString TOSFH_NAME(size_t i) { return ssprintf("Tornado%cOffsetScaleFromHigh", dimension_names[i]); } +static RString TOSFH_NAME(std::size_t i) { return ssprintf("Tornado%cOffsetScaleFromHigh", dimension_names[i]); } static ThemeMetric1D TORNADO_OFFSET_SCALE_FROM_HIGH("ArrowEffects", TOSFH_NAME, 3); static ThemeMetric DRUNK_COLUMN_FREQUENCY( "ArrowEffects", "DrunkColumnFrequency" ); diff --git a/src/BitmapText.cpp b/src/BitmapText.cpp index e9e2baff8f..93374e0495 100644 --- a/src/BitmapText.cpp +++ b/src/BitmapText.cpp @@ -11,6 +11,7 @@ #include "LuaBinding.h" #include +#include REGISTER_ACTOR_CLASS( BitmapText ); @@ -643,13 +644,13 @@ bool BitmapText::StringWillUseAlternate( const RString& sText, const RString& sA return true; } -void BitmapText::CropLineToWidth(size_t l, int width) +void BitmapText::CropLineToWidth(std::size_t l, int width) { if(l < m_wTextLines.size()) { int used_width= width; std::wstring& line= m_wTextLines[l]; - const size_t fit= m_pFont->GetGlyphsThatFit(line, &used_width); + const std::size_t fit= m_pFont->GetGlyphsThatFit(line, &used_width); if(fit < line.size()) { line.erase(line.begin()+fit, line.end()); @@ -660,7 +661,7 @@ void BitmapText::CropLineToWidth(size_t l, int width) void BitmapText::CropToWidth(int width) { - for(size_t l= 0; l < m_wTextLines.size(); ++l) + for(std::size_t l= 0; l < m_wTextLines.size(); ++l) { CropLineToWidth(l, width); } @@ -721,12 +722,12 @@ void BitmapText::DrawPrimitives() } else { - size_t i = 0; - std::map::const_iterator iter = m_mAttributes.begin(); + std::size_t i = 0; + std::map::const_iterator iter = m_mAttributes.begin(); while( i < m_aVertices.size() ) { // Set the colors up to the next attribute. - size_t iEnd = iter == m_mAttributes.end()? m_aVertices.size():iter->first*4; + std::size_t iEnd = iter == m_mAttributes.end()? m_aVertices.size():iter->first*4; iEnd = std::min( iEnd, m_aVertices.size() ); for( ; i < iEnd; i += 4 ) { @@ -746,7 +747,7 @@ void BitmapText::DrawPrimitives() iEnd = i + attr.length*4; iEnd = std::min( iEnd, m_aVertices.size() ); std::vector temp_attr_diffuse(NUM_DIFFUSE_COLORS, m_internalDiffuse); - for(size_t c= 0; c < NUM_DIFFUSE_COLORS; ++c) + for(std::size_t c= 0; c < NUM_DIFFUSE_COLORS; ++c) { temp_attr_diffuse[c]*= attr.diffuse[c]; if(m_mult_attrs_with_diffuse) @@ -806,12 +807,12 @@ void BitmapText::DrawPrimitives() { DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow ); - size_t i = 0; - std::map::const_iterator iter = m_mAttributes.begin(); + std::size_t i = 0; + std::map::const_iterator iter = m_mAttributes.begin(); while( i < m_aVertices.size() ) { // Set the glow up to the next attribute. - size_t iEnd = iter == m_mAttributes.end()? m_aVertices.size():iter->first*4; + std::size_t iEnd = iter == m_mAttributes.end()? m_aVertices.size():iter->first*4; iEnd = std::min( iEnd, m_aVertices.size() ); for( ; i < iEnd; ++i ) m_aVertices[i].c = m_pTempState->glow; @@ -874,15 +875,15 @@ BitmapText::Attribute BitmapText::GetDefaultAttribute() const return attr; } -void BitmapText::AddAttribute( size_t iPos, const Attribute &attr ) +void BitmapText::AddAttribute( std::size_t iPos, const Attribute &attr ) { // Fixup position for new lines. int iLines = 0; - size_t iAdjustedPos = iPos; + std::size_t iAdjustedPos = iPos; for (std::wstring const & line : m_wTextLines) { - size_t length = line.length(); + std::size_t length = line.length(); if( length >= iAdjustedPos ) break; iAdjustedPos -= length; @@ -989,7 +990,7 @@ public: static int GetText( T* p, lua_State *L ) { lua_pushstring( L, p->GetText() ); return 1; } static int AddAttribute( T* p, lua_State *L ) { - size_t iPos = IArg(1); + std::size_t iPos = IArg(1); BitmapText::Attribute attr = p->GetDefaultAttribute(); attr.FromStack( L, 2 ); diff --git a/src/BitmapText.h b/src/BitmapText.h index f8288b9088..df57db64ae 100644 --- a/src/BitmapText.h +++ b/src/BitmapText.h @@ -2,6 +2,8 @@ #define BITMAP_TEXT_H #include "Actor.h" + +#include #include class RageTexture; @@ -62,7 +64,7 @@ public: void SetMaxHeight( float fMaxHeight ); void SetMaxDimUseZoom(bool use); void SetWrapWidthPixels( int iWrapWidthPixels ); - void CropLineToWidth(size_t l, int width); + void CropLineToWidth(std::size_t l, int width); void CropToWidth(int width); virtual bool EarlyAbortDraw() const override; @@ -103,7 +105,7 @@ public: }; Attribute GetDefaultAttribute() const; - void AddAttribute( size_t iPos, const Attribute &attr ); + void AddAttribute( std::size_t iPos, const Attribute &attr ); void ClearAttributes(); // Commands @@ -128,9 +130,9 @@ protected: std::vector m_aVertices; - std::vector m_vpFontPageTextures; - std::map m_mAttributes; - bool m_bHasGlowAttribute; + std::vector m_vpFontPageTextures; + std::map m_mAttributes; + bool m_bHasGlowAttribute; TextGlowMode m_TextGlowMode; @@ -153,7 +155,7 @@ private: * @author Chris Danford, Charles Lohr, Steve Checkoway (c) 2001-2007 * @section LICENSE * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -163,7 +165,7 @@ private: * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/CombinedLifeMeterTug.cpp b/src/CombinedLifeMeterTug.cpp index 3dfa6eab6b..1fc9f56c80 100644 --- a/src/CombinedLifeMeterTug.cpp +++ b/src/CombinedLifeMeterTug.cpp @@ -6,9 +6,11 @@ #include "ThemeMetric.h" #include "ActorUtil.h" +#include + ThemeMetric METER_WIDTH ("CombinedLifeMeterTug","MeterWidth"); -static void TugMeterPercentChangeInit( size_t /*ScoreEvent*/ i, RString &sNameOut, float &defaultValueOut ) +static void TugMeterPercentChangeInit( std::size_t /*ScoreEvent*/ i, RString &sNameOut, float &defaultValueOut ) { sNameOut = "TugMeterPercentChange" + ScoreEventToString( (ScoreEvent)i ); switch( i ) @@ -32,7 +34,7 @@ static void TugMeterPercentChangeInit( size_t /*ScoreEvent*/ i, RString &sNameOu static Preference1D g_fTugMeterPercentChange( TugMeterPercentChangeInit, NUM_ScoreEvent ); -CombinedLifeMeterTug::CombinedLifeMeterTug() +CombinedLifeMeterTug::CombinedLifeMeterTug() { FOREACH_PlayerNumber( p ) { @@ -92,7 +94,7 @@ void CombinedLifeMeterTug::ChangeLife( PlayerNumber pn, TapNoteScore score ) void CombinedLifeMeterTug::HandleTapScoreNone( PlayerNumber pn ) { - + } void CombinedLifeMeterTug::ChangeLife( PlayerNumber pn, HoldNoteScore score, TapNoteScore tscore ) @@ -155,7 +157,7 @@ void CombinedLifeMeterTug::SetLife(PlayerNumber pn, float value) /* * (c) 2003-2004 Chris Danford * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -165,7 +167,7 @@ void CombinedLifeMeterTug::SetLife(PlayerNumber pn, float value) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/Command.cpp b/src/Command.cpp index d2ee693673..d89b54e5b3 100644 --- a/src/Command.cpp +++ b/src/Command.cpp @@ -4,9 +4,10 @@ #include "RageLog.h" #include "arch/Dialog/Dialog.h" +#include #include -RString Command::GetName() const +RString Command::GetName() const { if( m_vsArgs.empty() ) return RString(); @@ -41,9 +42,9 @@ static void SplitWithQuotes( const RString sSource, const char Delimitor, std::v if( sSource.empty() ) return; - size_t startpos = 0; + std::size_t startpos = 0; do { - size_t pos = startpos; + std::size_t pos = startpos; while( pos < sSource.size() ) { if( sSource[pos] == Delimitor ) @@ -110,7 +111,7 @@ Commands ParseCommands( const RString &sCommands ) /* * (c) 2004 Chris Danford * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -120,7 +121,7 @@ Commands ParseCommands( const RString &sCommands ) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/Course.cpp b/src/Course.cpp index ba367f78a3..b77d002a24 100644 --- a/src/Course.cpp +++ b/src/Course.cpp @@ -1,4 +1,3 @@ -#include #include "global.h" #include "Course.h" #include "CourseLoaderCRS.h" @@ -19,6 +18,9 @@ #include "Game.h" #include "Style.h" +#include +#include + static Preference MAX_SONGS_IN_EDIT_COURSE( "MaxSongsInEditCourse", -1 ); static const char *SongSortNames[] = { @@ -49,7 +51,7 @@ RString CourseEntry::GetTextDescription() const std::vector vsEntryDescription; Song *pSong = songID.ToSong(); if( pSong ) - vsEntryDescription.push_back( pSong->GetTranslitFullTitle() ); + vsEntryDescription.push_back( pSong->GetTranslitFullTitle() ); else vsEntryDescription.push_back( "Random" ); if( !songCriteria.m_sGroupName.empty() ) @@ -89,7 +91,7 @@ int CourseEntry::GetNumModChanges() const Course::Course(): m_bIsAutogen(false), m_sPath(""), m_sMainTitle(""), m_sMainTitleTranslit(""), m_sSubTitle(""), m_sSubTitleTranslit(""), m_sScripter(""), m_sDescription(""), m_sBannerPath(""), m_sBackgroundPath(""), - m_sCDTitlePath(""), m_sGroupName(""), m_bRepeat(false), m_fGoalSeconds(0), + m_sCDTitlePath(""), m_sGroupName(""), m_bRepeat(false), m_fGoalSeconds(0), m_bShuffle(false), m_iLives(-1), m_bSortByMeter(false), m_bIncomplete(false), m_vEntries(), m_SortOrder_TotalDifficulty(0), m_SortOrder_Ranking(0), m_LoadedFromProfile(ProfileSlot_Invalid), @@ -104,7 +106,7 @@ CourseType Course::GetCourseType() const { if( m_bRepeat ) return COURSE_TYPE_ENDLESS; - if( m_iLives > 0 ) + if( m_iLives > 0 ) return COURSE_TYPE_ONI; if( !m_vEntries.empty() && m_vEntries[0].fGainSeconds > 0 ) return COURSE_TYPE_SURVIVAL; @@ -223,9 +225,9 @@ struct SortTrailEntry { TrailEntry entry; int SortMeter; - + SortTrailEntry(): entry(), SortMeter(0) {} - + bool operator< ( const SortTrailEntry &rhs ) const { return SortMeter < rhs.SortMeter; } }; @@ -445,7 +447,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) // Set to true if CourseDifficulty is able to change something. bool bCourseDifficultyIsSignificant = (cd == Difficulty_Medium); - + // Resolve each entry to a Song and Steps. if( trail.m_CourseType == COURSE_TYPE_ENDLESS ) @@ -743,7 +745,7 @@ void Course::GetTrailUnsortedEndless( const std::vector &entries, T ASSERT(e->iChooseIndex >= 0); // If we're trying to pick BEST100 when only 99 songs exist, // we have a problem, so bail out - if (static_cast(e->iChooseIndex) >= vpSongs.size()) { + if (static_cast(e->iChooseIndex) >= vpSongs.size()) { continue; } @@ -959,7 +961,7 @@ void Course::Invalidate( const Song *pStaleSong ) } // Invalidate any Trails that contain this song. - // If we find a Trail that contains this song, then it's part of a + // If we find a Trail that contains this song, then it's part of a // non-fixed entry. So, regenerating the Trail will force different // songs to be chosen. FOREACH_ENUM( StepsType,st ) @@ -980,8 +982,8 @@ void Course::Invalidate( const Song *pStaleSong ) void Course::RegenerateNonFixedTrails() const { // Only need to regen Trails if the Course has a random entry. - // We can create these Trails on demand because we don't - // calculate RadarValues for Trails with one or more non-fixed + // We can create these Trails on demand because we don't + // calculate RadarValues for Trails with one or more non-fixed // entry. if( AllSongsAreFixed() ) return; @@ -1003,7 +1005,7 @@ RageColor Course::GetColor() const case COURSE_SORT_PREFERRED: return SORT_PREFERRED_COLOR; //This will also be used for autogen'd courses in some cases. - case COURSE_SORT_SONGS: + case COURSE_SORT_SONGS: if( m_vEntries.size() >= 7 ) return SORT_LEVEL2_COLOR; else if( m_vEntries.size() >= 4 ) return SORT_LEVEL4_COLOR; else return SORT_LEVEL5_COLOR; @@ -1220,7 +1222,7 @@ bool Course::Matches( RString sGroup, RString sCourse ) const // lua start #include "LuaBinding.h" -/** @brief Allow Lua to have access to the CourseEntry. */ +/** @brief Allow Lua to have access to the CourseEntry. */ class LunaCourseEntry: public Luna { public: @@ -1240,7 +1242,7 @@ public: // GetTimedModifiers - table DEFINE_METHOD( GetNumModChanges, GetNumModChanges() ); DEFINE_METHOD( GetTextDescription, GetTextDescription() ); - + LunaCourseEntry() { ADD_METHOD( GetSong ); @@ -1259,7 +1261,7 @@ public: LUA_REGISTER_CLASS( CourseEntry ) // Now for the Course bindings: -/** @brief Allow Lua to have access to the Course. */ +/** @brief Allow Lua to have access to the Course. */ class LunaCourse: public Luna { public: @@ -1271,7 +1273,7 @@ public: DEFINE_METHOD( GetCourseType, GetCourseType() ) static int GetCourseEntry(T* p, lua_State* L) { - size_t id= static_cast(IArg(1)); + std::size_t id= static_cast(IArg(1)); if(id >= p->m_vEntries.size()) { lua_pushnil(L); @@ -1356,8 +1358,8 @@ public: ADD_METHOD( GetGroupName ); ADD_METHOD( IsAutogen ); ADD_METHOD( GetEstimatedNumStages ); - ADD_METHOD( GetScripter ); - ADD_METHOD( GetDescription ); + ADD_METHOD( GetScripter ); + ADD_METHOD( GetDescription ); ADD_METHOD( GetTotalSeconds ); ADD_METHOD( IsEndless ); ADD_METHOD( IsNonstop ); @@ -1379,7 +1381,7 @@ LUA_REGISTER_CLASS( Course ) /* * (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -1389,7 +1391,7 @@ LUA_REGISTER_CLASS( Course ) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/CreateZip.cpp b/src/CreateZip.cpp index bcb9eeaa5c..4fb5c6874b 100644 --- a/src/CreateZip.cpp +++ b/src/CreateZip.cpp @@ -1,6 +1,7 @@ #include "global.h" -#include +#include +#include #if defined(_WINDOWS) #include @@ -144,7 +145,7 @@ typedef char TCHAR; typedef unsigned char uch; // unsigned 8-bit value typedef unsigned short ush; // unsigned 16-bit value typedef unsigned long ulg; // unsigned 32-bit value -typedef size_t extent; // file size +typedef std::size_t extent; // file size typedef unsigned Pos; // must be at least 32 bits typedef unsigned IPos; // A Pos is an index in the character window. Pos is used only for parameter passing @@ -347,7 +348,7 @@ typedef struct iztimes { typedef struct zlist { ush vem, ver, flg, how; // See central header in zipfile.c for what vem..off are ulg tim, crc, siz, len; - size_t nam, ext, cext, com; // offset of ext must be >= LOCHEAD + std::size_t nam, ext, cext, com; // offset of ext must be >= LOCHEAD ush dsk, att, lflg; // offset of lflg must be >= LOCHEAD ulg atx, off; char name[MAX_PATH]; // File name in zip file @@ -400,12 +401,12 @@ int putlocal(struct zlist *z, WRITEFUNC wfunc,void *param) PUTLG(z->len, f); PUTSH(z->nam, f); PUTSH(z->ext, f); - size_t res = (size_t)wfunc(param, z->iname, (unsigned int)z->nam); + std::size_t res = (std::size_t)wfunc(param, z->iname, (unsigned int)z->nam); if (res!=z->nam) return ZE_TEMP; if (z->ext) { - res = (size_t)wfunc(param, z->extra, (unsigned int)z->ext); + res = (std::size_t)wfunc(param, z->extra, (unsigned int)z->ext); if (res!=z->ext) return ZE_TEMP; } @@ -441,15 +442,15 @@ int putcentral(struct zlist *z, WRITEFUNC wfunc, void *param) PUTSH(z->att, f); PUTLG(z->atx, f); PUTLG(z->off, f); - if ((size_t)wfunc(param, z->iname, (unsigned int)z->nam) != z->nam || - (z->cext && (size_t)wfunc(param, z->cextra, (unsigned int)z->cext) != z->cext) || - (z->com && (size_t)wfunc(param, z->comment, (unsigned int)z->com) != z->com)) + if ((std::size_t)wfunc(param, z->iname, (unsigned int)z->nam) != z->nam || + (z->cext && (std::size_t)wfunc(param, z->cextra, (unsigned int)z->cext) != z->cext) || + (z->com && (std::size_t)wfunc(param, z->comment, (unsigned int)z->com) != z->com)) return ZE_TEMP; return ZE_OK; } -int putend(int n, ulg s, ulg c, size_t m, char *z, WRITEFUNC wfunc, void *param) +int putend(int n, ulg s, ulg c, std::size_t m, char *z, WRITEFUNC wfunc, void *param) { // write the end of the central-directory-data to file *f. PUTLG(ENDSIG, f); @@ -530,7 +531,7 @@ const ulg crc_table[256] = { #define DO4(buf) DO2(buf); DO2(buf) #define DO8(buf) DO4(buf); DO4(buf) -ulg crc32(ulg crc, const uch *buf, size_t len) +ulg crc32(ulg crc, const uch *buf, std::size_t len) { if (buf== nullptr) return 0L; crc = crc ^ 0xffffffffL; diff --git a/src/CsvFile.cpp b/src/CsvFile.cpp index df62ba679c..7f534bb2eb 100644 --- a/src/CsvFile.cpp +++ b/src/CsvFile.cpp @@ -137,7 +137,7 @@ bool CsvFile::WriteFile( RageFileBasic &f ) const /* * (c) 2001-2004 Adam Clauss, Chris Danford * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -147,7 +147,7 @@ bool CsvFile::WriteFile( RageFileBasic &f ) const * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/CubicSpline.cpp b/src/CubicSpline.cpp index d2613faa32..123f690682 100644 --- a/src/CubicSpline.cpp +++ b/src/CubicSpline.cpp @@ -2,6 +2,8 @@ #include "CubicSpline.h" #include "RageLog.h" #include "RageUtil.h" + +#include #include // Spline solving optimization: @@ -27,29 +29,29 @@ struct SplineSolutionCache void solve_diagonals_straight(std::vector& diagonals, std::vector& multiples); void solve_diagonals_looped(std::vector& diagonals, std::vector& multiples); private: - void prep_inner(size_t last, std::vector& out); + void prep_inner(std::size_t last, std::vector& out); bool find_in_cache(std::list& cache, std::vector& outd, std::vector& outm); void add_to_cache(std::list& cache, std::vector& outd, std::vector& outm); std::list straight_diagonals; std::list looped_diagonals; }; -const size_t solution_cache_limit= 16; +const std::size_t solution_cache_limit= 16; bool SplineSolutionCache::find_in_cache(std::list& cache, std::vector& outd, std::vector& outm) { - size_t out_size= outd.size(); + std::size_t out_size= outd.size(); for(std::list::iterator entry= cache.begin(); entry != cache.end(); ++entry) { if(out_size == entry->diagonals.size()) { - for(size_t i= 0; i < out_size; ++i) + for(std::size_t i= 0; i < out_size; ++i) { outd[i]= entry->diagonals[i]; } outm.resize(entry->multiples.size()); - for(size_t i= 0; i < entry->multiples.size(); ++i) + for(std::size_t i= 0; i < entry->multiples.size(); ++i) { outm[i]= entry->multiples[i]; } @@ -70,9 +72,9 @@ void SplineSolutionCache::add_to_cache(std::list& cache, std::vector& out) +void SplineSolutionCache::prep_inner(std::size_t last, std::vector& out) { - for(size_t i= 1; i < last; ++i) + for(std::size_t i= 1; i < last; ++i) { out[i]= 4.0f; } @@ -98,7 +100,7 @@ void SplineSolutionCache::solve_diagonals_straight(std::vector& diagonals // | 0 0 b 0 | -> | 0 0 b 0 | -> | 0 0 b 0 | // | 0 0 0 c | -> | 0 0 0 c | -> | 0 0 0 c | - size_t last= diagonals.size(); + std::size_t last= diagonals.size(); diagonals[0]= 2.0f; prep_inner(last-1, diagonals); diagonals[last-1]= 2.0f; @@ -107,7 +109,7 @@ void SplineSolutionCache::solve_diagonals_straight(std::vector& diagonals // Operation: Add row[0] * -.5 to row[1] to zero [r1][c0]. diagonals[1]-= .5f; multiples.push_back(.5f); - for(size_t i= 1; i < last-1; ++i) + for(std::size_t i= 1; i < last-1; ++i) { // Operation: Add row[i] / -[ri][ci] to row[i+1] to zero [ri+1][ci]. const float diag_recip= 1.0f / diagonals[i]; @@ -115,7 +117,7 @@ void SplineSolutionCache::solve_diagonals_straight(std::vector& diagonals multiples.push_back(diag_recip); } // Stage two. - for(size_t i= last-1; i > 0; --i) + for(std::size_t i= last-1; i > 0; --i) { // Operation: Add row [i] / -[ri][ci] to row[i-1] to zero [ri-1][ci]. multiples.push_back(1.0f / diagonals[i]); @@ -160,7 +162,7 @@ void SplineSolutionCache::solve_diagonals_looped(std::vector& diagonals, // | 0 0 0 c w | -> | 0 0 0 c w | -> | 0 0 0 c w | -> | 0 0 0 c 0 | // | 0 0 0 0 f | -> | 0 0 0 0 f | -> | 0 0 0 0 f | -> | 0 0 0 0 f | - size_t last= diagonals.size(); + std::size_t last= diagonals.size(); diagonals[0]= 4.0f; prep_inner(last, diagonals); // right_column is sized to not store the diagonal . @@ -169,7 +171,7 @@ void SplineSolutionCache::solve_diagonals_looped(std::vector& diagonals, right_column[last-2]= 1.0f; // Stage one. - for(size_t i= 0; i < last-2; ++i) + for(std::size_t i= 0; i < last-2; ++i) { // Operation: Add row[i] / -[ri][ci] to row[i+1] to zero [ri+1][ci]. const float diag_recip= 1.0f / diagonals[i]; @@ -185,7 +187,7 @@ void SplineSolutionCache::solve_diagonals_looped(std::vector& diagonals, multiples.push_back(diag_recip); } // Stage two. - for(size_t i= last-2; i > 0; --i) + for(std::size_t i= last-2; i > 0; --i) { // Operation: Add row[i] / -[ri][ci] to row[i-1] to zero [ri-1][ci]. const float diag_recip= 1.0f / diagonals[i]; @@ -200,8 +202,8 @@ void SplineSolutionCache::solve_diagonals_looped(std::vector& diagonals, multiples.push_back(diag_recip); } // Stage three. - const size_t end= last-1; - for(size_t i= 0; i < end; ++i) + const std::size_t end= last-1; + for(std::size_t i= 0; i < end; ++i) { // Operation: Add row[e] * (right_column[i] / [re][ce]) to row[i] to // zero right_column[i]. @@ -251,7 +253,7 @@ float loop_space_difference(float a, float b, float spatial_extent) void CubicSpline::solve_looped() { if(check_minimum_size()) { return; } - size_t last= m_points.size(); + std::size_t last= m_points.size(); std::vector results(m_points.size()); std::vector diagonals(m_points.size()); std::vector multiples; @@ -268,14 +270,14 @@ void CubicSpline::solve_looped() // SplineSolutionCache's Stage one loop ends at last-2 because it has to // handle right_column. This does not handle right_column, so the loop // goes to last-1. - for(size_t i= 0; i < last-1; ++i) + for(std::size_t i= 0; i < last-1; ++i) { // Operation: Add row[i] * -multiples[i] to row[i+1]. results[i+1]-= results[i] * multiples[i]; } - size_t next_mult= last-1; + std::size_t next_mult= last-1; // Stage two. - for(size_t i= last-2; i > 0; --i) + for(std::size_t i= last-2; i > 0; --i) { // Operation: Add row[i] * -multiples[nm] to row[i-1]. results[i-1]-= results[i] * multiples[next_mult]; @@ -286,8 +288,8 @@ void CubicSpline::solve_looped() results[last-1]-= results[0] * multiples[next_mult]; ++next_mult; // Stage three. - const size_t end= last-1; - for(size_t i= 0; i < end; ++i) + const std::size_t end= last-1; + for(std::size_t i= 0; i < end; ++i) { // Operation: Add row[e] * -multiples[nm] to row[i]. results[i]-= results[end] * multiples[next_mult]; @@ -300,7 +302,7 @@ void CubicSpline::solve_looped() void CubicSpline::solve_straight() { if(check_minimum_size()) { return; } - size_t last= m_points.size(); + std::size_t last= m_points.size(); std::vector results(m_points.size()); std::vector diagonals(m_points.size()); std::vector multiples; @@ -313,14 +315,14 @@ void CubicSpline::solve_straight() // Steps explained in detail in SplineSolutionCache. // Only the operations on the results column are performed here. // Stage one. - for(size_t i= 0; i < last-1; ++i) + for(std::size_t i= 0; i < last-1; ++i) { // Operation: Add row[i] * -multiples[i] to row[i+1]. results[i+1]-= results[i] * multiples[i]; } - size_t next_mult= last-1; + std::size_t next_mult= last-1; // Stage two. - for(size_t i= last-1; i > 0; --i) + for(std::size_t i= last-1; i > 0; --i) { // Operation: Add row[i] * -multiples[nm] to row [i-1]. results[i-1]-= results[i] * multiples[next_mult]; @@ -333,8 +335,8 @@ void CubicSpline::solve_straight() void CubicSpline::solve_polygonal() { if(check_minimum_size()) { return; } - size_t last= m_points.size() - 1; - for(size_t i= 0; i < last; ++i) + std::size_t last= m_points.size() - 1; + for(std::size_t i= 0; i < last; ++i) { m_points[i].b= loop_space_difference( m_points[i+1].a, m_points[i].a, m_spatial_extent); @@ -345,7 +347,7 @@ void CubicSpline::solve_polygonal() bool CubicSpline::check_minimum_size() { - size_t last= m_points.size(); + std::size_t last= m_points.size(); if(last < 2) { m_points[0].b= m_points[0].c= m_points[0].d= 0.0f; @@ -364,7 +366,7 @@ bool CubicSpline::check_minimum_size() } float a= m_points[0].a; bool all_points_identical= true; - for(size_t i= 0; i < m_points.size(); ++i) + for(std::size_t i= 0; i < m_points.size(); ++i) { m_points[i].b= m_points[i].c= m_points[i].d= 0.0f; if(m_points[i].a != a) { all_points_identical= false; } @@ -372,27 +374,27 @@ bool CubicSpline::check_minimum_size() return all_points_identical; } -void CubicSpline::prep_inner(size_t last, std::vector& results) +void CubicSpline::prep_inner(std::size_t last, std::vector& results) { - for(size_t i= 1; i < last - 1; ++i) + for(std::size_t i= 1; i < last - 1; ++i) { results[i]= 3 * loop_space_difference( m_points[i+1].a, m_points[i-1].a, m_spatial_extent); } } -void CubicSpline::set_results(size_t last, std::vector& diagonals, std::vector& results) +void CubicSpline::set_results(std::size_t last, std::vector& diagonals, std::vector& results) { // No more operations left, everything not a diagonal should be zero now. - for(size_t i= 0; i < last; ++i) + for(std::size_t i= 0; i < last; ++i) { results[i]/= diagonals[i]; } // Now we can go through and set the b, c, d values of each point. // b, c, d values of the last point are not set because they are unused. - for(size_t i= 0; i < last; ++i) + for(std::size_t i= 0; i < last; ++i) { - size_t next= (i+1) % last; + std::size_t next= (i+1) % last; float diff= loop_space_difference( m_points[next].a, m_points[i].a, m_spatial_extent); m_points[i].b= results[i]; @@ -407,14 +409,14 @@ void CubicSpline::set_results(size_t last, std::vector& diagonals, std::v // Solving is now complete. } -void CubicSpline::p_and_tfrac_from_t(float t, bool loop, size_t& p, float& tfrac) const +void CubicSpline::p_and_tfrac_from_t(float t, bool loop, std::size_t& p, float& tfrac) const { if(loop) { float max_t= static_cast(m_points.size()); t= std::fmod(t, max_t); if(t < 0.0f) { t+= max_t; } - p= static_cast(t); + p= static_cast(t); tfrac= t - static_cast(p); } else @@ -425,14 +427,14 @@ void CubicSpline::p_and_tfrac_from_t(float t, bool loop, size_t& p, float& tfrac p= 0; tfrac= 0; } - else if(static_cast(flort) >= m_points.size() - 1) + else if(static_cast(flort) >= m_points.size() - 1) { p= m_points.size() - 1; tfrac= 0; } else { - p= static_cast(flort); + p= static_cast(flort); tfrac= t - static_cast(p); } } @@ -440,7 +442,7 @@ void CubicSpline::p_and_tfrac_from_t(float t, bool loop, size_t& p, float& tfrac #define RETURN_IF_EMPTY if(m_points.empty()) { return 0.0f; } #define DECLARE_P_AND_TFRAC \ -size_t p= 0; float tfrac= 0.0f; \ +std::size_t p= 0; float tfrac= 0.0f; \ p_and_tfrac_from_t(t, loop, p, tfrac); float CubicSpline::evaluate(float t, bool loop) const @@ -479,13 +481,13 @@ float CubicSpline::evaluate_third_derivative(float t, bool loop) const #undef RETURN_IF_EMPTY #undef DECLARE_P_AND_TFRAC -void CubicSpline::set_point(size_t i, float v) +void CubicSpline::set_point(std::size_t i, float v) { ASSERT_M(i < m_points.size(), "CubicSpline::set_point requires the index to be less than the number of points."); m_points[i].a= v; } -void CubicSpline::set_coefficients(size_t i, float b, float c, float d) +void CubicSpline::set_coefficients(std::size_t i, float b, float c, float d) { ASSERT_M(i < m_points.size(), "CubicSpline: point index must be less than the number of points."); m_points[i].b= b; @@ -493,7 +495,7 @@ void CubicSpline::set_coefficients(size_t i, float b, float c, float d) m_points[i].d= d; } -void CubicSpline::get_coefficients(size_t i, float& b, float& c, float& d) const +void CubicSpline::get_coefficients(std::size_t i, float& b, float& c, float& d) const { ASSERT_M(i < m_points.size(), "CubicSpline: point index must be less than the number of points."); b= m_points[i].b; @@ -501,26 +503,26 @@ void CubicSpline::get_coefficients(size_t i, float& b, float& c, float& d) const d= m_points[i].d; } -void CubicSpline::set_point_and_coefficients(size_t i, float a, float b, +void CubicSpline::set_point_and_coefficients(std::size_t i, float a, float b, float c, float d) { set_coefficients(i, b, c, d); m_points[i].a= a; } -void CubicSpline::get_point_and_coefficients(size_t i, float& a, float& b, +void CubicSpline::get_point_and_coefficients(std::size_t i, float& a, float& b, float& c, float& d) const { get_coefficients(i, b, c, d); a= m_points[i].a; } -void CubicSpline::resize(size_t s) +void CubicSpline::resize(std::size_t s) { m_points.resize(s); } -size_t CubicSpline::size() const +std::size_t CubicSpline::size() const { return m_points.size(); } @@ -551,27 +553,27 @@ void CubicSplineN::weighted_average(CubicSplineN& out, // Behavior for splines of different sizes: Use a size between the two. // Points that exist in both will be averaged. // Points that only exist in one will come only from that one. - const size_t from_size= from.size(); - const size_t to_size= to.size(); - size_t out_size= to_size; - size_t limit= to_size; + const std::size_t from_size= from.size(); + const std::size_t to_size= to.size(); + std::size_t out_size= to_size; + std::size_t limit= to_size; if(from_size < to_size) { - out_size= from_size + static_cast( + out_size= from_size + static_cast( static_cast(to_size - from_size) * between); } else if(to_size < from_size) { limit= from_size; - out_size= to_size + static_cast( + out_size= to_size + static_cast( static_cast(from_size - to_size) * between); } CLAMP(out_size, 0, limit); out.resize(out_size); - for(size_t spli= 0; spli < out.m_splines.size(); ++spli) + for(std::size_t spli= 0; spli < out.m_splines.size(); ++spli) { - for(size_t p= 0; p < out_size; ++p) + for(std::size_t p= 0; p < out_size; ++p) { float fc[4]= {0.0f, 0.0f, 0.0f, 0.0f}; float tc[4]= {0.0f, 0.0f, 0.0f, 0.0f}; @@ -679,42 +681,42 @@ CSN_EVAL_RV_SOMETHING(evaluate_derivative); #undef CSN_EVAL_RV_SOMETHING -void CubicSplineN::set_point(size_t i, const std::vector& v) +void CubicSplineN::set_point(std::size_t i, const std::vector& v) { ASSERT_M(v.size() == m_splines.size(), "CubicSplineN::set_point requires the passed point to be the same dimension as the spline."); - for(size_t n= 0; n < m_splines.size(); ++n) + for(std::size_t n= 0; n < m_splines.size(); ++n) { m_splines[n].set_point(i, v[n]); } m_dirty= true; } -void CubicSplineN::set_coefficients(size_t i, const std::vector& b, +void CubicSplineN::set_coefficients(std::size_t i, const std::vector& b, const std::vector& c, const std::vector& d) { ASSERT_M(b.size() == c.size() && c.size() == d.size() && d.size() == m_splines.size(), "CubicSplineN: coefficient vectors must be " "the same dimension as the spline."); - for(size_t n= 0; n < m_splines.size(); ++n) + for(std::size_t n= 0; n < m_splines.size(); ++n) { m_splines[n].set_coefficients(i, b[n], c[n], d[n]); } m_dirty= true; } -void CubicSplineN::get_coefficients(size_t i, std::vector& b, +void CubicSplineN::get_coefficients(std::size_t i, std::vector& b, std::vector& c, std::vector& d) { ASSERT_M(b.size() == c.size() && c.size() == d.size() && d.size() == m_splines.size(), "CubicSplineN: coefficient vectors must be " "the same dimension as the spline."); - for(size_t n= 0; n < m_splines.size(); ++n) + for(std::size_t n= 0; n < m_splines.size(); ++n) { m_splines[n].get_coefficients(i, b[n], c[n], d[n]); } } -void CubicSplineN::set_spatial_extent(size_t i, float extent) +void CubicSplineN::set_spatial_extent(std::size_t i, float extent) { ASSERT_M(i < m_splines.size(), "CubicSplineN: index of spline to set extent" " of is out of range."); @@ -722,14 +724,14 @@ void CubicSplineN::set_spatial_extent(size_t i, float extent) m_dirty= true; } -float CubicSplineN::get_spatial_extent(size_t i) +float CubicSplineN::get_spatial_extent(std::size_t i) { ASSERT_M(i < m_splines.size(), "CubicSplineN: index of spline to get extent" " of is out of range."); return m_splines[i].m_spatial_extent; } -void CubicSplineN::resize(size_t s) +void CubicSplineN::resize(std::size_t s) { for(spline_cont_t::iterator spline= m_splines.begin(); spline != m_splines.end(); ++spline) @@ -739,7 +741,7 @@ void CubicSplineN::resize(size_t s) m_dirty= true; } -size_t CubicSplineN::size() const +std::size_t CubicSplineN::size() const { if(!m_splines.empty()) { @@ -753,13 +755,13 @@ bool CubicSplineN::empty() const return m_splines.empty() || m_splines[0].empty(); } -void CubicSplineN::redimension(size_t d) +void CubicSplineN::redimension(std::size_t d) { m_splines.resize(d); m_dirty= true; } -size_t CubicSplineN::dimension() const +std::size_t CubicSplineN::dimension() const { return m_splines.size(); } @@ -787,18 +789,18 @@ SET_GET_MEM(m_dirty, dirty); struct LunaCubicSplineN : Luna { - static size_t dimension_index(T* p, lua_State* L, int s) + static std::size_t dimension_index(T* p, lua_State* L, int s) { - size_t i= static_cast(IArg(s)-1); + std::size_t i= static_cast(IArg(s)-1); if(i >= p->dimension()) { luaL_error(L, "Spline dimension index out of range."); } return i; } - static size_t point_index(T* p, lua_State* L, int s) + static std::size_t point_index(T* p, lua_State* L, int s) { - size_t i= static_cast(IArg(s)-1); + std::size_t i= static_cast(IArg(s)-1); if(i >= p->size()) { luaL_error(L, "Spline point index out of range."); @@ -816,7 +818,7 @@ struct LunaCubicSplineN : Luna std::vector pos; \ p->something(FArg(1), pos); \ lua_createtable(L, pos.size(), 0); \ - for(size_t i= 0; i < pos.size(); ++i) \ + for(std::size_t i= 0; i < pos.size(); ++i) \ { \ lua_pushnumber(L, pos[i]); \ lua_rawseti(L, -2, i+1); \ @@ -830,13 +832,13 @@ struct LunaCubicSplineN : Luna #undef LCSN_EVAL_SOMETHING static void get_element_table_from_stack(T* p, lua_State* L, int s, - size_t limit, std::vector& ret) + std::size_t limit, std::vector& ret) { - size_t elements= lua_objlen(L, s); + std::size_t elements= lua_objlen(L, s); // Too many elements is not an error because allowing it allows the user // to reuse the same position data set after changing the dimension size. // The same is true for too few elements. - for(size_t e= 0; e < elements; ++e) + for(std::size_t e= 0; e < elements; ++e) { lua_rawgeti(L, s, e+1); ret.push_back(FArg(-1)); @@ -847,7 +849,7 @@ struct LunaCubicSplineN : Luna } ret.resize(limit); } - static void set_point_from_stack(T* p, lua_State* L, size_t i, int s) + static void set_point_from_stack(T* p, lua_State* L, std::size_t i, int s) { if(!lua_istable(L, s)) { @@ -859,17 +861,17 @@ struct LunaCubicSplineN : Luna } static int set_point(T* p, lua_State* L) { - size_t i= point_index(p, L, 1); + std::size_t i= point_index(p, L, 1); set_point_from_stack(p, L, i, 2); COMMON_RETURN_SELF; } - static void set_coefficients_from_stack(T* p, lua_State* L, size_t i, int s) + static void set_coefficients_from_stack(T* p, lua_State* L, std::size_t i, int s) { if(!lua_istable(L, s) || !lua_istable(L, s+1) || !lua_istable(L, s+2)) { luaL_error(L, "Spline coefficient args must be three tables."); } - size_t limit= p->dimension(); + std::size_t limit= p->dimension(); std::vector b; get_element_table_from_stack(p, L, s, limit, b); std::vector c; get_element_table_from_stack(p, L, s+1, limit, c); std::vector d; get_element_table_from_stack(p, L, s+2, limit, d); @@ -877,24 +879,24 @@ struct LunaCubicSplineN : Luna } static int set_coefficients(T* p, lua_State* L) { - size_t i= point_index(p, L, 1); + std::size_t i= point_index(p, L, 1); set_coefficients_from_stack(p, L, i, 2); COMMON_RETURN_SELF; } static int get_coefficients(T* p, lua_State* L) { - size_t i= point_index(p, L, 1); - size_t limit= p->dimension(); + std::size_t i= point_index(p, L, 1); + std::size_t limit= p->dimension(); std::vector > coeff(3); coeff[0].resize(limit); coeff[1].resize(limit); coeff[2].resize(limit); p->get_coefficients(i, coeff[0], coeff[1], coeff[2]); lua_createtable(L, 3, 0); - for(size_t co= 0; co < coeff.size(); ++co) + for(std::size_t co= 0; co < coeff.size(); ++co) { lua_createtable(L, limit, 0); - for(size_t v= 0; v < limit; ++v) + for(std::size_t v= 0; v < limit; ++v) { lua_pushnumber(L, coeff[co][v]); lua_rawseti(L, -2, v+1); @@ -905,13 +907,13 @@ struct LunaCubicSplineN : Luna } static int set_spatial_extent(T* p, lua_State* L) { - size_t i= dimension_index(p, L, 1); + std::size_t i= dimension_index(p, L, 1); p->set_spatial_extent(i, FArg(2)); COMMON_RETURN_SELF; } static int get_spatial_extent(T* p, lua_State* L) { - size_t i= dimension_index(p, L, 1); + std::size_t i= dimension_index(p, L, 1); lua_pushnumber(L, p->get_spatial_extent(i)); return 1; } @@ -927,7 +929,7 @@ struct LunaCubicSplineN : Luna { luaL_error(L, "A spline cannot have less than 0 points."); } - p->resize(static_cast(siz)); + p->resize(static_cast(siz)); COMMON_RETURN_SELF; } static int get_size(T* p, lua_State* L) @@ -947,7 +949,7 @@ struct LunaCubicSplineN : Luna { luaL_error(L, "A spline cannot have less than 0 dimensions."); } - p->redimension(static_cast(dim)); + p->redimension(static_cast(dim)); COMMON_RETURN_SELF; } static int get_dimension(T* p, lua_State* L) diff --git a/src/CubicSpline.h b/src/CubicSpline.h index 11597e4dd7..c466681c6a 100644 --- a/src/CubicSpline.h +++ b/src/CubicSpline.h @@ -1,8 +1,11 @@ #ifndef CUBIC_SPLINE_H #define CUBIC_SPLINE_H -#include #include "RageTypes.h" + +#include +#include + struct lua_State; struct CubicSpline @@ -11,24 +14,24 @@ CubicSpline() :m_spatial_extent(0.0f) {} void solve_looped(); void solve_straight(); void solve_polygonal(); - void p_and_tfrac_from_t(float t, bool loop, size_t& p, float& tfrac) const; + void p_and_tfrac_from_t(float t, bool loop, std::size_t& p, float& tfrac) const; float evaluate(float t, bool loop) const; float evaluate_derivative(float t, bool loop) const; float evaluate_second_derivative(float t, bool loop) const; float evaluate_third_derivative(float t, bool loop) const; - void set_point(size_t i, float v); - void set_coefficients(size_t i, float b, float c, float d); - void get_coefficients(size_t i, float& b, float& c, float& d) const; - void set_point_and_coefficients(size_t i, float a, float b, float c, float d); - void get_point_and_coefficients(size_t i, float& a, float& b, float& c, float& d) const; - void resize(size_t s); - size_t size() const; + void set_point(std::size_t i, float v); + void set_coefficients(std::size_t i, float b, float c, float d); + void get_coefficients(std::size_t i, float& b, float& c, float& d) const; + void set_point_and_coefficients(std::size_t i, float a, float b, float c, float d); + void get_point_and_coefficients(std::size_t i, float& a, float& b, float& c, float& d) const; + void resize(std::size_t s); + std::size_t size() const; bool empty() const; float m_spatial_extent; private: bool check_minimum_size(); - void prep_inner(size_t last, std::vector& results); - void set_results(size_t last, std::vector& diagonals, std::vector& results); + void prep_inner(std::size_t last, std::vector& results); + void set_results(std::size_t last, std::vector& diagonals, std::vector& results); struct SplinePoint { @@ -51,17 +54,17 @@ struct CubicSplineN void evaluate_third_derivative(float t, std::vector& v) const; void evaluate(float t, RageVector3& v) const; void evaluate_derivative(float t, RageVector3& v) const; - void set_point(size_t i, const std::vector& v); - void set_coefficients(size_t i, const std::vector& b, + void set_point(std::size_t i, const std::vector& v); + void set_coefficients(std::size_t i, const std::vector& b, const std::vector& c, const std::vector& d); - void get_coefficients(size_t i, std::vector& b, + void get_coefficients(std::size_t i, std::vector& b, std::vector& c, std::vector& d); - void set_spatial_extent(size_t i, float extent); - float get_spatial_extent(size_t i); - void resize(size_t s); - size_t size() const; - void redimension(size_t d); - size_t dimension() const; + void set_spatial_extent(std::size_t i, float extent); + float get_spatial_extent(std::size_t i); + void resize(std::size_t s); + std::size_t size() const; + void redimension(std::size_t d); + std::size_t dimension() const; bool empty() const; float get_max_t() const { if(m_loop) { return static_cast(size()); } diff --git a/src/DifficultyList.cpp b/src/DifficultyList.cpp index 902157a150..6ffd6332e3 100644 --- a/src/DifficultyList.cpp +++ b/src/DifficultyList.cpp @@ -7,10 +7,11 @@ #include "StepsDisplay.h" #include "StepsUtil.h" #include "CommonMetrics.h" - #include "SongUtil.h" #include "XmlFile.h" +#include + /** @brief Specifies the max number of charts available for a song. * * This includes autogenned charts. */ @@ -213,13 +214,13 @@ void StepsDisplayList::UpdatePositions() void StepsDisplayList::PositionItems() { - for( size_t i = 0; i < MAX_METERS; ++i ) + for( std::size_t i = 0; i < MAX_METERS; ++i ) { bool bUnused = ( i >= m_Rows.size() ); m_Lines[i].m_Meter.SetVisible( !bUnused ); } - for( size_t m = 0; m < m_Rows.size(); ++m ) + for( std::size_t m = 0; m < m_Rows.size(); ++m ) { Row &row = m_Rows[m]; bool bHidden = row.m_bHidden; @@ -237,7 +238,7 @@ void StepsDisplayList::PositionItems() m_Lines[m].m_Meter.SetY( row.m_fY ); } - for( size_t m=0; m < MAX_METERS; ++m ) + for( std::size_t m=0; m < MAX_METERS; ++m ) { bool bHidden = true; if( m_bShown && m < m_Rows.size() ) @@ -270,7 +271,7 @@ void StepsDisplayList::SetFromGameState() if( pSong == nullptr ) { // FIXME: This clamps to between the min and the max difficulty, but - // it really should round to the nearest difficulty that's in + // it really should round to the nearest difficulty that's in // DIFFICULTIES_TO_SHOW. const std::vector& difficulties = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(); m_Rows.resize( difficulties.size() ); @@ -303,7 +304,7 @@ void StepsDisplayList::SetFromGameState() UpdatePositions(); PositionItems(); - for( size_t m = 0; m < MAX_METERS; ++m ) + for( std::size_t m = 0; m < MAX_METERS; ++m ) m_Lines[m].m_Meter.FinishTweening(); } @@ -323,7 +324,7 @@ void StepsDisplayList::TweenOnScreen() FOREACH_HumanPlayer( pn ) ON_COMMAND( m_Cursors[pn] ); - for( size_t m = 0; m < MAX_METERS; ++m ) + for( std::size_t m = 0; m < MAX_METERS; ++m ) ON_COMMAND( m_Lines[m].m_Meter ); this->SetHibernate( 0.5f ); @@ -374,7 +375,7 @@ void StepsDisplayList::HandleMessage( const Message &msg ) FOREACH_ENUM( PlayerNumber, pn ) { if( msg.GetName() == MessageIDToString((MessageID)(Message_CurrentStepsP1Changed+Enum::to_integral(pn))) || - msg.GetName() == MessageIDToString((MessageID)(Message_CurrentTrailP1Changed+Enum::to_integral(pn))) ) + msg.GetName() == MessageIDToString((MessageID)(Message_CurrentTrailP1Changed+Enum::to_integral(pn))) ) SetFromGameState(); } @@ -385,7 +386,7 @@ void StepsDisplayList::HandleMessage( const Message &msg ) // lua start #include "LuaBinding.h" -/** @brief Allow Lua to have access to the StepsDisplayList. */ +/** @brief Allow Lua to have access to the StepsDisplayList. */ class LunaStepsDisplayList: public Luna { public: @@ -403,7 +404,7 @@ LUA_REGISTER_DERIVED_CLASS( StepsDisplayList, ActorFrame ) /* * (c) 2003-2004 Glenn Maynard * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -413,7 +414,7 @@ LUA_REGISTER_DERIVED_CLASS( StepsDisplayList, ActorFrame ) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/DynamicActorScroller.cpp b/src/DynamicActorScroller.cpp index c323213430..51af902de0 100644 --- a/src/DynamicActorScroller.cpp +++ b/src/DynamicActorScroller.cpp @@ -8,6 +8,7 @@ #include "LuaBinding.h" #include +#include DynamicActorScroller *DynamicActorScroller::Copy() const { return new DynamicActorScroller(*this); } @@ -23,7 +24,7 @@ void DynamicActorScroller::LoadFromNode( const XNode *pNode ) { LuaHelpers::ReportScriptErrorFmt("%s: DynamicActorScroller: loaded %i nodes; require exactly one", ActorUtil::GetWhere(pNode).c_str(), (int)m_SubActors.size()); // Remove all but one. - for( size_t i=1; i + static const char *EditMenuRowNames[] = { "Group", "Song", @@ -37,8 +38,8 @@ XToString( EditMenuAction ); XToLocalizedString( EditMenuAction ); StringToX( EditMenuAction ); -static RString ARROWS_X_NAME( size_t i ) { return ssprintf("Arrows%dX",int(i+1)); } -static RString ROW_Y_NAME( size_t i ) { return ssprintf("Row%dY",int(i+1)); } +static RString ARROWS_X_NAME( std::size_t i ) { return ssprintf("Arrows%dX",int(i+1)); } +static RString ROW_Y_NAME( std::size_t i ) { return ssprintf("Row%dY",int(i+1)); } void EditMenu::StripLockedStepsAndDifficulty( std::vector &v ) { diff --git a/src/Font.cpp b/src/Font.cpp index cefa46f7ba..3ccd82a83c 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -12,6 +12,7 @@ #include "arch/Dialog/Dialog.h" #include +#include FontPage::FontPage(): m_iHeight(0), m_iLineSpacing(0), m_fVshift(0), m_iDrawExtraPixelsLeft(0), m_iDrawExtraPixelsRight(0), @@ -256,7 +257,7 @@ int Font::GetLineHeightInSourcePixels( const std::wstring &szLine ) const } // width is a pointer so that we can return the used width through it. -size_t Font::GetGlyphsThatFit(const std::wstring& line, int* width) const +std::size_t Font::GetGlyphsThatFit(const std::wstring& line, int* width) const { if(*width == 0) { @@ -264,7 +265,7 @@ size_t Font::GetGlyphsThatFit(const std::wstring& line, int* width) const return line.size(); } int curr_width= 0; - size_t i= 0; + std::size_t i= 0; for(i= 0; i < line.size() && curr_width < *width; ++i) { curr_width+= GetGlyph(line[i]).m_iHadvance; @@ -430,11 +431,11 @@ void Font::GetFontPaths( const RString &sFontIniPath, std::vector &asTe RString Font::GetPageNameFromFileName( const RString &sFilename ) { - size_t begin = sFilename.find_first_of( '[' ); + std::size_t begin = sFilename.find_first_of( '[' ); if( begin == std::string::npos ) return "main"; - size_t end = sFilename.find_first_of( ']', begin ); + std::size_t end = sFilename.find_first_of( ']', begin ); if( end == std::string::npos ) return "main"; diff --git a/src/Font.h b/src/Font.h index bdb79dd4d5..6ea2863994 100644 --- a/src/Font.h +++ b/src/Font.h @@ -6,6 +6,8 @@ #include "RageTextureID.h" #include "RageUtil.h" #include "RageTypes.h" + +#include #include class FontPage; @@ -57,7 +59,7 @@ struct glyph /** @brief Texture coordinate rect. */ RectF m_TexRect; - + /** @brief Set up the glyph with default values. */ glyph() : m_pPage(nullptr), m_FontPageTextures(), m_iHadvance(0), m_fWidth(0), m_fHeight(0), m_fHshift(0), m_TexRect() {} @@ -86,7 +88,7 @@ struct FontPageSettings /** @brief The initial settings for the FontPage. */ FontPageSettings(): m_sTexturePath(""), m_iDrawExtraPixelsLeft(0), m_iDrawExtraPixelsRight(0), - m_iAddToAllWidths(0), + m_iAddToAllWidths(0), m_iLineSpacing(-1), m_iTop(-1), m_iBaseline(-1), @@ -154,7 +156,7 @@ public: int GetLineWidthInSourcePixels( const std::wstring &szLine ) const; int GetLineHeightInSourcePixels( const std::wstring &szLine ) const; - size_t GetGlyphsThatFit(const std::wstring& line, int* width) const; + std::size_t GetGlyphsThatFit(const std::wstring& line, int* width) const; bool FontCompleteForString( const std::wstring &str ) const; @@ -192,8 +194,8 @@ private: /** * @brief This is the primary fontpage of this font. - * - * The font-wide height, center, etc. is pulled from it. + * + * The font-wide height, center, etc. is pulled from it. * (This is one of pages[].) */ FontPage *m_pDefault; @@ -205,10 +207,10 @@ private: /** * @brief True for Hebrew, Arabic, Urdu fonts. * - * This will also change the way glyphs from the default FontPage are rendered. + * This will also change the way glyphs from the default FontPage are rendered. * There may be a better way to handle this. */ bool m_bRightToLeft; - + bool m_bDistanceField; RageColor m_DefaultStrokeColor; @@ -219,14 +221,14 @@ private: void LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RString &sTexturePath, const RString &PageName, RString sChars ); static void GetFontPaths( const RString &sFontOrTextureFilePath, std::vector &sTexturePaths ); RString GetPageNameFromFileName( const RString &sFilename ); - + Font(const Font& rhs); Font& operator=(const Font& rhs); }; /** * @brief Last private-use Unicode character: - * + * * This is in the header to reduce file dependencies. */ const wchar_t FONT_DEFAULT_GLYPH = 0xF8FF; @@ -236,7 +238,7 @@ const wchar_t FONT_DEFAULT_GLYPH = 0xF8FF; * @file * @author Glenn Maynard, Chris Danford (c) 2001-2004 * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -246,7 +248,7 @@ const wchar_t FONT_DEFAULT_GLYPH = 0xF8FF; * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/GameCommand.cpp b/src/GameCommand.cpp index 09205ff431..7e0fd0452e 100644 --- a/src/GameCommand.cpp +++ b/src/GameCommand.cpp @@ -23,6 +23,8 @@ #include "arch/ArchHooks/ArchHooks.h" #include "ScreenPrompt.h" +#include + static LocalizedString COULD_NOT_LAUNCH_BROWSER( "GameCommand", "Could not launch web browser." ); REGISTER_CLASS_TRAITS( GameCommand, new GameCommand(*pCopy) ); @@ -86,8 +88,8 @@ bool GameCommand::DescribesCurrentMode( PlayerNumber pn ) const return false; if( m_pStyle && GAMESTATE->GetCurrentStyle(pn) != m_pStyle ) return false; - // HACK: don't compare m_dc if m_pSteps is set. This causes problems - // in ScreenSelectOptionsMaster::ImportOptions if m_PreferredDifficulty + // HACK: don't compare m_dc if m_pSteps is set. This causes problems + // in ScreenSelectOptionsMaster::ImportOptions if m_PreferredDifficulty // doesn't match the difficulty of m_pCurSteps. if( m_pSteps == nullptr && m_dc != Difficulty_Invalid ) { @@ -278,7 +280,7 @@ void GameCommand::LoadOne( const Command& cmd ) { CHECK_INVALID_COND(m_pSong, SONGMAN->FindSong(sValue), (SONGMAN->FindSong(sValue) == nullptr), - (ssprintf("Song \"%s\" not found", sValue.c_str()))); + (ssprintf("Song \"%s\" not found", sValue.c_str()))); } else if( sName == "steps" ) @@ -318,7 +320,7 @@ void GameCommand::LoadOne( const Command& cmd ) (SONGMAN->FindCourse("", sValue) == nullptr), (ssprintf( "Course \"%s\" not found", sValue.c_str()))); } - + else if( sName == "trail" ) { RString sTrail = sValue; @@ -348,7 +350,7 @@ void GameCommand::LoadOne( const Command& cmd ) } } } - + else if( sName == "setenv" ) { if((cmd.m_vsArgs.size() - 1) % 2 != 0) @@ -357,13 +359,13 @@ void GameCommand::LoadOne( const Command& cmd ) } else { - for(size_t i= 1; i < cmd.m_vsArgs.size(); i+= 2) + for(std::size_t i= 1; i < cmd.m_vsArgs.size(); i+= 2) { m_SetEnv[cmd.m_vsArgs[i]]= cmd.m_vsArgs[i+1]; } } } - + else if( sName == "songgroup" ) { CHECK_INVALID_COND(m_sSongGroup, sValue, (!SONGMAN->DoesSongGroupExist(sValue)), ("Song group \"" + sValue + "\" does not exist.")); @@ -447,7 +449,7 @@ void GameCommand::LoadOne( const Command& cmd ) } else { - for(size_t i= 1; i < cmd.m_vsArgs.size(); i+= 2) + for(std::size_t i= 1; i < cmd.m_vsArgs.size(); i+= 2) { if(IPreference::GetPreferenceByName(cmd.m_vsArgs[i]) == nullptr) { @@ -568,7 +570,7 @@ bool GameCommand::IsPlayable( RString *why ) const const int iNumCreditsPaid = GetNumCreditsPaid(); const int iNumCreditsRequired = GetCreditsRequiredToPlayStyle(m_pStyle); - + /* With PREFSMAN->m_bDelayedCreditsReconcile disabled, enough credits must * be paid. (This means that enough sides must be joined.) Enabled, simply * having enough credits lying in the machine is sufficient; we'll deduct the @@ -724,7 +726,7 @@ void GameCommand::ApplySelf( const std::vector &vpns ) const //Credit Used, make sure to update CoinsFile BOOKKEEPER->WriteCoinsFile(GAMESTATE->m_iCoins.Get()); } - + // If only one side is joined and we picked a style that requires both // sides, join the other side. switch( m_pStyle->m_StyleType ) @@ -871,7 +873,7 @@ void GameCommand::ApplySelf( const std::vector &vpns ) const GAMESTATE->GetDefaultSongOptions( so ); GAMESTATE->m_SongOptions.Assign( ModsLevel_Stage, so ); } - // HACK: Set life type to BATTERY just once here so it happens once and + // HACK: Set life type to BATTERY just once here so it happens once and // we don't override the user's changes if they back out. FOREACH_PlayerNumber(pn) { @@ -892,11 +894,11 @@ bool GameCommand::IsZero() const m_sAnnouncer != "" || m_sPreferredModifiers != "" || m_sStageModifiers != "" || - m_pSong != nullptr || - m_pSteps != nullptr || - m_pCourse != nullptr || - m_pTrail != nullptr || - m_pCharacter != nullptr || + m_pSong != nullptr || + m_pSteps != nullptr || + m_pCourse != nullptr || + m_pTrail != nullptr || + m_pCharacter != nullptr || m_CourseDifficulty != Difficulty_Invalid || !m_sSongGroup.empty() || m_SortOrder != SortOrder_Invalid || @@ -916,7 +918,7 @@ bool GameCommand::IsZero() const #include "Steps.h" #include "Character.h" -/** @brief Allow Lua to have access to the GameCommand. */ +/** @brief Allow Lua to have access to the GameCommand. */ class LunaGameCommand: public Luna { public: @@ -975,7 +977,7 @@ LUA_REGISTER_CLASS( GameCommand ) /* * (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -985,7 +987,7 @@ LUA_REGISTER_CLASS( GameCommand ) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/GameManager.cpp b/src/GameManager.cpp index ba24dee971..40ba54c727 100644 --- a/src/GameManager.cpp +++ b/src/GameManager.cpp @@ -14,9 +14,11 @@ #include "Game.h" #include "Style.h" +#include + GameManager* GAMEMAN = nullptr; // global and accessable from anywhere in our program -enum +enum { TRACK_1 = 0, TRACK_2, @@ -405,7 +407,7 @@ static const Style g_Style_Dance_ThreePanel = // todo: re-enable? (lol) /* static const Style g_Style_Dance_Solo_Versus = -{ // STYLE_DANCE_SOLO_VERSUS +{ // STYLE_DANCE_SOLO_VERSUS "dance-solo-versus", // m_szName StepsType_dance_solo, // m_StepsType ONE_PLAYER_ONE_CREDIT, // m_StyleType @@ -495,7 +497,7 @@ static const Style *g_apGame_Dance_Styles[] = nullptr }; -static const Game g_Game_Dance = +static const Game g_Game_Dance = { "dance", // m_szName g_apGame_Dance_Styles, // m_apStyles @@ -860,7 +862,7 @@ static const Style *g_apGame_Pump_Styles[] = nullptr }; -static const Game g_Game_Pump = +static const Game g_Game_Pump = { "pump", // m_szName g_apGame_Pump_Styles, // m_apStyles @@ -1041,7 +1043,7 @@ static const Style *g_apGame_KB7_Styles[] = nullptr }; -static const Game g_Game_KB7 = +static const Game g_Game_KB7 = { "kb7", // m_szName g_apGame_KB7_Styles, // m_apStyles @@ -1114,7 +1116,7 @@ static const Style g_Style_Ez2_Single = { 0, 4, 2, 1, 3, Style::END_MAPPING }, }, { // m_iColumnDrawOrder[MAX_COLS_PER_PLAYER]; - 2,0,4,1,3 // This should be from back to front: Down, UpLeft, UpRight, Upper Left Hand, Upper Right Hand + 2,0,4,1,3 // This should be from back to front: Down, UpLeft, UpRight, Upper Left Hand, Upper Right Hand }, false, // m_bCanUseBeginnerHelper false, // m_bLockDifficulties @@ -1134,18 +1136,18 @@ static const Style g_Style_Ez2_Real = { // PLAYER_1 { TRACK_1, -EZ2_REAL_COL_SPACING*2.3f, nullptr }, { TRACK_2, -EZ2_REAL_COL_SPACING*1.6f, nullptr }, - { TRACK_3, -EZ2_REAL_COL_SPACING*0.9f, nullptr }, + { TRACK_3, -EZ2_REAL_COL_SPACING*0.9f, nullptr }, { TRACK_4, +EZ2_REAL_COL_SPACING*0.0f, nullptr }, - { TRACK_5, +EZ2_REAL_COL_SPACING*0.9f, nullptr }, + { TRACK_5, +EZ2_REAL_COL_SPACING*0.9f, nullptr }, { TRACK_6, +EZ2_REAL_COL_SPACING*1.6f, nullptr }, { TRACK_7, +EZ2_REAL_COL_SPACING*2.3f, nullptr }, }, { // PLAYER_2 { TRACK_1, -EZ2_REAL_COL_SPACING*2.3f, nullptr }, { TRACK_2, -EZ2_REAL_COL_SPACING*1.6f, nullptr }, - { TRACK_3, -EZ2_REAL_COL_SPACING*0.9f, nullptr }, + { TRACK_3, -EZ2_REAL_COL_SPACING*0.9f, nullptr }, { TRACK_4, +EZ2_REAL_COL_SPACING*0.0f, nullptr }, - { TRACK_5, +EZ2_REAL_COL_SPACING*0.9f, nullptr }, + { TRACK_5, +EZ2_REAL_COL_SPACING*0.9f, nullptr }, { TRACK_6, +EZ2_REAL_COL_SPACING*1.6f, nullptr }, { TRACK_7, +EZ2_REAL_COL_SPACING*2.3f, nullptr }, }, @@ -1192,7 +1194,7 @@ static const Style g_Style_Ez2_Single_Versus = { 0, 4, 2, 1, 3, Style::END_MAPPING }, }, { // m_iColumnDrawOrder[MAX_COLS_PER_PLAYER]; - 2,0,4,1,3 // This should be from back to front: Down, UpLeft, UpRight, Upper Left Hand, Upper Right Hand + 2,0,4,1,3 // This should be from back to front: Down, UpLeft, UpRight, Upper Left Hand, Upper Right Hand }, false, // m_bCanUseBeginnerHelper false, // m_bLockDifficulties @@ -1212,18 +1214,18 @@ static const Style g_Style_Ez2_Real_Versus = { // PLAYER_1 { TRACK_1, -EZ2_REAL_COL_SPACING*2.3f, nullptr }, { TRACK_2, -EZ2_REAL_COL_SPACING*1.6f, nullptr }, - { TRACK_3, -EZ2_REAL_COL_SPACING*0.9f, nullptr }, + { TRACK_3, -EZ2_REAL_COL_SPACING*0.9f, nullptr }, { TRACK_4, +EZ2_REAL_COL_SPACING*0.0f, nullptr }, - { TRACK_5, +EZ2_REAL_COL_SPACING*0.9f, nullptr }, + { TRACK_5, +EZ2_REAL_COL_SPACING*0.9f, nullptr }, { TRACK_6, +EZ2_REAL_COL_SPACING*1.6f, nullptr }, { TRACK_7, +EZ2_REAL_COL_SPACING*2.3f, nullptr }, }, { // PLAYER_2 { TRACK_1, -EZ2_REAL_COL_SPACING*2.3f, nullptr }, { TRACK_2, -EZ2_REAL_COL_SPACING*1.6f, nullptr }, - { TRACK_3, -EZ2_REAL_COL_SPACING*0.9f, nullptr }, + { TRACK_3, -EZ2_REAL_COL_SPACING*0.9f, nullptr }, { TRACK_4, +EZ2_REAL_COL_SPACING*0.0f, nullptr }, - { TRACK_5, +EZ2_REAL_COL_SPACING*0.9f, nullptr }, + { TRACK_5, +EZ2_REAL_COL_SPACING*0.9f, nullptr }, { TRACK_6, +EZ2_REAL_COL_SPACING*1.6f, nullptr }, { TRACK_7, +EZ2_REAL_COL_SPACING*2.3f, nullptr }, }, @@ -1233,7 +1235,7 @@ static const Style g_Style_Ez2_Real_Versus = { 0, 6, 3, 2, 4, 1, 5, Style::END_MAPPING }, }, { // m_iColumnDrawOrder[MAX_COLS_PER_PLAYER]; - 3,0,6,2,4,1,5 // This should be from back to front: Down, UpLeft, UpRight, Lower Left Hand, Lower Right Hand, Upper Left Hand, Upper Right Hand + 3,0,6,2,4,1,5 // This should be from back to front: Down, UpLeft, UpRight, Lower Left Hand, Lower Right Hand, Upper Left Hand, Upper Right Hand }, false, // m_bCanUseBeginnerHelper false, // m_bLockDifficulties @@ -1280,7 +1282,7 @@ static const Style g_Style_Ez2_Double = { 5, 9, 7, 6, 8, Style::END_MAPPING }, }, { // m_iColumnDrawOrder[MAX_COLS_PER_PLAYER]; - 2,0,4,1,3,7,5,9,6,8 // This should be from back to front: Down, UpLeft, UpRight, Upper Left Hand, Upper Right Hand + 2,0,4,1,3,7,5,9,6,8 // This should be from back to front: Down, UpLeft, UpRight, Upper Left Hand, Upper Right Hand }, false, // m_bCanUseBeginnerHelper false, // m_bLockDifficulties @@ -1309,7 +1311,7 @@ static const AutoMappings g_AutoKeyMappings_Ez2 = AutoMappings ( AutoMappingEntry( 0, KEY_Cf, EZ2_BUTTON_HANDLRRIGHT, false ) ); -static const Game g_Game_Ez2 = +static const Game g_Game_Ez2 = { "ez2", // m_szName g_apGame_Ez2_Styles, // m_apStyles @@ -1380,7 +1382,7 @@ static const Style g_Style_Para_Single = { 0, 1, 2, 3, 4, Style::END_MAPPING }, }, { // m_iColumnDrawOrder[MAX_COLS_PER_PLAYER]; - 2,0,4,1,3 + 2,0,4,1,3 }, false, // m_bCanUseBeginnerHelper false, // m_bLockDifficulties @@ -1417,7 +1419,7 @@ static const Style g_Style_Para_Versus = { 0, 1, 2, 3, 4, Style::END_MAPPING }, }, { // m_iColumnDrawOrder[MAX_COLS_PER_PLAYER]; - 2,0,4,1,3 + 2,0,4,1,3 }, false, // m_bCanUseBeginnerHelper false, // m_bLockDifficulties @@ -1441,7 +1443,7 @@ static const AutoMappings g_AutoKeyMappings_Para = AutoMappings ( AutoMappingEntry( 0, KEY_Cb, PARA_BUTTON_RIGHT, false ) ); -static const Game g_Game_Para = +static const Game g_Game_Para = { "para", // m_szName g_apGame_Para_Styles, // m_apStyles @@ -1539,7 +1541,7 @@ static const AutoMappings g_AutoKeyMappings_DS3DDX = AutoMappings ( AutoMappingEntry( 0, KEY_Cd, DS3DDX_BUTTON_HANDRIGHT, false ) ); -static const Game g_Game_DS3DDX = +static const Game g_Game_DS3DDX = { "ds3ddx", // m_szName g_apGame_DS3DDX_Styles, // m_apStyles @@ -1880,7 +1882,7 @@ static const AutoMappings g_AutoKeyMappings_Beat = AutoMappings ( AutoMappingEntry( 0, KEY_SPACE, BEAT_BUTTON_SCRATCHUP, false ) ); -static const Game g_Game_Beat = +static const Game g_Game_Beat = { "beat", // m_szName g_apGame_Beat_Styles, // m_apStyles @@ -2058,7 +2060,7 @@ static const AutoMappings g_AutoKeyMappings_Maniax = AutoMappings ( AutoMappingEntry( 0, KEY_KP_C2, MANIAX_BUTTON_HANDLRRIGHT, true ) ); -static const Game g_Game_Maniax = +static const Game g_Game_Maniax = { "maniax", // m_szName g_apGame_Maniax_Styles, // m_apStyles @@ -2529,7 +2531,7 @@ static const AutoMappings g_AutoKeyMappings_Techno = AutoMappings ( AutoMappingEntry( 0, KEY_KP_C3, TECHNO_BUTTON_DOWNRIGHT,true ) ); -static const Game g_Game_Techno = +static const Game g_Game_Techno = { "techno", // m_szName g_apGame_Techno_Styles, // m_apStyles @@ -2572,9 +2574,9 @@ static const Game g_Game_Techno = /** popn *********************************************************************/ //ThemeMetric POPN5_COL_SPACING ("ColumnSpacing","Popn5"); -static const int POPN5_COL_SPACING = 32; +static const int POPN5_COL_SPACING = 32; //ThemeMetric POPN9_COL_SPACING ("ColumnSpacing","Popn9"); -static const int POPN9_COL_SPACING = 32; +static const int POPN9_COL_SPACING = 32; static const Style g_Style_Popn_Five = { // STYLE_POPN_FIVE true, // m_bUsedForGameplay @@ -2679,7 +2681,7 @@ static const AutoMappings g_AutoKeyMappings_Popn = AutoMappings ( AutoMappingEntry( 0, KEY_Cb, POPN_BUTTON_RIGHT_WHITE,false ) ); -static const Game g_Game_Popn = +static const Game g_Game_Popn = { "popn", // m_szName g_apGame_Popn_Styles, // m_apStyles @@ -2785,7 +2787,7 @@ static const Style *g_apGame_Lights_Styles[] = nullptr }; -static const Game g_Game_Lights = +static const Game g_Game_Lights = { "lights", // m_szName g_apGame_Lights_Styles, // m_apStyles @@ -3211,7 +3213,7 @@ static const Game g_Game_Kickbox = TNS_W5, // m_mapW5To }; -static const Game *g_Games[] = +static const Game *g_Games[] = { &g_Game_Dance, &g_Game_Pump, @@ -3252,12 +3254,12 @@ GameManager::~GameManager() void GameManager::GetStylesForGame( const Game *pGame, std::vector& aStylesAddTo, bool editor ) { - for( int s=0; pGame->m_apStyles[s]; ++s ) + for( int s=0; pGame->m_apStyles[s]; ++s ) { const Style *style = pGame->m_apStyles[s]; - if( !editor && !style->m_bUsedForGameplay ) + if( !editor && !style->m_bUsedForGameplay ) continue; - if( editor && !style->m_bUsedForEdit ) + if( editor && !style->m_bUsedForEdit ) continue; aStylesAddTo.push_back( style ); @@ -3266,10 +3268,10 @@ void GameManager::GetStylesForGame( const Game *pGame, std::vector const Game *GameManager::GetGameForStyle( const Style *pStyle ) { - for( size_t g=0; gm_apStyles[s]; ++s ) + for( int s=0; pGame->m_apStyles[s]; ++s ) { if( pGame->m_apStyles[s] == pStyle ) return pGame; @@ -3280,10 +3282,10 @@ const Game *GameManager::GetGameForStyle( const Style *pStyle ) const Style* GameManager::GetEditorStyleForStepsType( StepsType st ) { - for( size_t g=0; gm_apStyles[s]; ++s ) + for( int s=0; pGame->m_apStyles[s]; ++s ) { const Style *style = pGame->m_apStyles[s]; if( style->m_StepsType == st && style->m_bUsedForEdit ) @@ -3302,14 +3304,14 @@ void GameManager::GetStepsTypesForGame( const Game *pGame, std::vectorm_apStyles[i]->m_StepsType; ASSERT(st < NUM_StepsType); - + // Some Styles use the same StepsType (e.g. single and versus) so check // that we aren't doubling up. bool found = false; for( unsigned j=0; j < aStepsTypeAddTo.size(); j++ ) if( st == aStepsTypeAddTo[j] ) { found = true; break; } if(found) continue; - + aStepsTypeAddTo.push_back( st ); } } @@ -3318,19 +3320,19 @@ void GameManager::GetDemonstrationStylesForGame( const Game *pGame, std::vector< { vpStylesOut.clear(); - for( int s=0; pGame->m_apStyles[s]; ++s ) + for( int s=0; pGame->m_apStyles[s]; ++s ) { const Style *style = pGame->m_apStyles[s]; if( style->m_bUsedForDemonstration ) vpStylesOut.push_back( style ); } - + ASSERT( vpStylesOut.size()>0 ); // this Game is missing a Style that can be used with the demonstration } const Style* GameManager::GetHowToPlayStyleForGame( const Game *pGame ) { - for( int s=0; pGame->m_apStyles[s]; ++s ) + for( int s=0; pGame->m_apStyles[s]; ++s ) { const Style *style = pGame->m_apStyles[s]; if( style->m_bUsedForHowToPlay ) @@ -3361,7 +3363,7 @@ void GameManager::GetCompatibleStyles( const Game *pGame, int iNumPlayers, std:: if( iNumPlayers != iNumPlayersRequired ) continue; - for( int s=0; pGame->m_apStyles[s]; ++s ) + for( int s=0; pGame->m_apStyles[s]; ++s ) { const Style *style = pGame->m_apStyles[s]; if( style->m_StyleType != styleType ) @@ -3391,7 +3393,7 @@ const Style *GameManager::GetFirstCompatibleStyle( const Game *pGame, int iNumPl void GameManager::GetEnabledGames( std::vector& aGamesOut ) { - for( size_t g=0; gm_szName) ) return g_Games[i]; @@ -3478,7 +3480,7 @@ const Game* GameManager::StringToGame( RString sGame ) const Style* GameManager::GameAndStringToStyle( const Game *game, RString sStyle ) { - for( int s=0; game->m_apStyles[s]; ++s ) + for( int s=0; game->m_apStyles[s]; ++s ) { const Style* style = game->m_apStyles[s]; if( sStyle.CompareNoCase(style->m_szName) == 0 ) @@ -3491,7 +3493,7 @@ const Style* GameManager::GameAndStringToStyle( const Game *game, RString sStyle // lua start #include "LuaBinding.h" -/** @brief Allow Lua to have access to the GameManager. */ +/** @brief Allow Lua to have access to the GameManager. */ class LunaGameManager: public Luna { public: @@ -3504,7 +3506,7 @@ public: p->GetStepsTypesForGame( pGame, vstAddTo ); ASSERT( !vstAddTo.empty() ); StepsType st = vstAddTo[0]; - LuaHelpers::Push( L, st ); + LuaHelpers::Push( L, st ); return 1; } static int IsGameEnabled( T* p, lua_State *L ) @@ -3527,12 +3529,12 @@ public: } std::vector aStyles; lua_createtable(L, 0, 0); - for( int s=0; pGame->m_apStyles[s]; ++s ) + for( int s=0; pGame->m_apStyles[s]; ++s ) { Style *pStyle = const_cast