This is an automated email from the git hooks/post-receive script. smcv pushed a commit to branch debian/master in repository openjk.
commit 5ba419855eb42eee7c5e7a17784fc3bcdc62a37d Author: bibendovsky <bibendov...@hotmail.com> Date: Mon Aug 29 16:12:40 2016 +0300 SG: Reduce usage of keyword 'auto' to minimum --- code/game/G_Timer.cpp | 4 +- code/game/g_savegame.cpp | 18 ++++----- code/icarus/IcarusImplementation.cpp | 8 ++-- code/rd-vanilla/G2_misc.cpp | 22 +++++------ code/server/sv_savegame.cpp | 10 ++--- codeJK2/game/g_savegame.cpp | 2 +- codeJK2/icarus/Sequence.cpp | 2 +- codeJK2/icarus/TaskManager.cpp | 2 +- shared/qcommon/ojk_saved_game.cpp | 70 +++++++++++++++++----------------- shared/qcommon/ojk_saved_game_helper.h | 42 ++++++++++---------- 10 files changed, 87 insertions(+), 93 deletions(-) diff --git a/code/game/G_Timer.cpp b/code/game/G_Timer.cpp index 90b5e3b..e7254c7 100644 --- a/code/game/G_Timer.cpp +++ b/code/game/G_Timer.cpp @@ -240,10 +240,10 @@ void TIMER_Load( void ) saved_game.read_chunk( INT_ID('T', 'M', 'I', 'D')); - auto sg_buffer_data = static_cast<const char*>( + const char* sg_buffer_data = static_cast<const char*>( saved_game.get_buffer_data()); - const auto sg_buffer_size = saved_game.get_buffer_size(); + const int sg_buffer_size = saved_game.get_buffer_size(); std::uninitialized_copy_n( sg_buffer_data, diff --git a/code/game/g_savegame.cpp b/code/game/g_savegame.cpp index a6c15b7..8a41940 100644 --- a/code/game/g_savegame.cpp +++ b/code/game/g_savegame.cpp @@ -515,7 +515,7 @@ static void EnumerateFields( { strList.clear(); - auto pbData = reinterpret_cast<const byte*>( + const byte* pbData = reinterpret_cast<const byte*>( src_instance); // enumerate all the fields... @@ -742,7 +742,7 @@ void saberInfoRetail_t::sg_export( //forbid all other styles dst.stylesForbidden = 0; - for (auto styleNum = SS_NONE + 1; styleNum < SS_NUM_SABER_STYLES; ++styleNum) + for (int styleNum = SS_NONE + 1; styleNum < SS_NUM_SABER_STYLES; ++styleNum) { if (styleNum != style) { @@ -768,14 +768,10 @@ static void copy_retail_gclient_to_current( const RetailGClient& src, gclient_t& dst) { - const auto src_pre_size = offsetof(RetailGClient, ps.saber[0]); - - const auto src_post_offset = - offsetof(RetailGClient, ps.dualSabers); - - const auto src_post_size = sizeof(RetailGClient) - src_post_offset; - - const auto dst_post_offset = offsetof(gclient_t, ps.dualSabers); + constexpr size_t src_pre_size = offsetof(RetailGClient, ps.saber[0]); + constexpr size_t src_post_offset = offsetof(RetailGClient, ps.dualSabers); + constexpr size_t src_post_size = sizeof(RetailGClient) - src_post_offset; + constexpr size_t dst_post_offset = offsetof(gclient_t, ps.dualSabers); ::memcpy( reinterpret_cast<char*>(&dst), @@ -801,7 +797,7 @@ static void EvaluateFields( byte* pbOriginalRefData, unsigned int ulChid) { - auto& instance = *pbData; + T& instance = *pbData; ojk::SavedGameHelper saved_game( ::gi.saved_game); diff --git a/code/icarus/IcarusImplementation.cpp b/code/icarus/IcarusImplementation.cpp index 2fe169a..ad66f77 100644 --- a/code/icarus/IcarusImplementation.cpp +++ b/code/icarus/IcarusImplementation.cpp @@ -713,10 +713,10 @@ int CIcarus::Load() saved_game.read_chunk( INT_ID('I','S','E','Q')); - auto sg_buffer_data = static_cast<const unsigned char*>( + const unsigned char* sg_buffer_data = static_cast<const unsigned char*>( saved_game.get_buffer_data()); - const auto sg_buffer_size = saved_game.get_buffer_size(); + const int sg_buffer_size = saved_game.get_buffer_size(); std::uninitialized_copy_n( sg_buffer_data, @@ -846,10 +846,10 @@ void CIcarus::BufferRead( void *pDstBuff, unsigned long ulNumBytesToRead ) saved_game.read_chunk( INT_ID('I', 'S', 'E', 'Q')); - auto sg_buffer_data = static_cast<const unsigned char*>( + const unsigned char* sg_buffer_data = static_cast<const unsigned char*>( saved_game.get_buffer_data()); - const auto sg_buffer_size = saved_game.get_buffer_size(); + const int sg_buffer_size = saved_game.get_buffer_size(); std::uninitialized_copy_n( sg_buffer_data, diff --git a/code/rd-vanilla/G2_misc.cpp b/code/rd-vanilla/G2_misc.cpp index b1aaad3..5d0b0fa 100644 --- a/code/rd-vanilla/G2_misc.cpp +++ b/code/rd-vanilla/G2_misc.cpp @@ -1807,51 +1807,51 @@ void G2_SaveGhoul2Models( // save out how many ghoul2 models we have - auto model_count = ghoul2.size(); + const int model_count = static_cast<int>(ghoul2.size()); saved_game.write<int32_t>( model_count); - for (decltype(model_count) i = 0; i < model_count; ++i) + for (int i = 0; i < model_count; ++i) { // first save out the ghoul2 details themselves ghoul2[i].sg_export( saved_game); // save out how many surfaces we have - auto surface_count = ghoul2[i].mSlist.size(); + const int surface_count = static_cast<int>(ghoul2[i].mSlist.size()); saved_game.write<int32_t>( surface_count); // now save the all the surface list info - for (decltype(surface_count) x = 0; x < surface_count; ++x) + for (int x = 0; x < surface_count; ++x) { ghoul2[i].mSlist[x].sg_export( saved_game); } // save out how many bones we have - auto bone_count = ghoul2[i].mBlist.size(); + const int bone_count = static_cast<int>(ghoul2[i].mBlist.size()); saved_game.write<int32_t>( bone_count); // now save the all the bone list info - for (decltype(bone_count) x = 0; x < bone_count; ++x) + for (int x = 0; x < bone_count; ++x) { ghoul2[i].mBlist[x].sg_export( saved_game); } // save out how many bolts we have - auto bolt_count = ghoul2[i].mBltlist.size(); + const int bolt_count = static_cast<int>(ghoul2[i].mBltlist.size()); saved_game.write<int32_t>( bolt_count); // lastly save the all the bolt list info - for (decltype(bolt_count) x = 0; x < bolt_count; ++x) + for (int x = 0; x < bolt_count; ++x) { ghoul2[i].mBltlist[x].sg_export( saved_game); @@ -1925,7 +1925,7 @@ void G2_LoadGhoul2Model( } // give us enough surfaces to load up the data - auto surface_count = 0; + int surface_count = 0; saved_game.read<int32_t>( surface_count); @@ -1940,7 +1940,7 @@ void G2_LoadGhoul2Model( } // give us enough bones to load up the data - auto bone_count = 0; + int bone_count = 0; saved_game.read<int32_t>( bone_count); @@ -1956,7 +1956,7 @@ void G2_LoadGhoul2Model( } // give us enough bolts to load up the data - auto bolt_count = 0; + int bolt_count = 0; saved_game.read<int32_t>( bolt_count); diff --git a/code/server/sv_savegame.cpp b/code/server/sv_savegame.cpp index 8dcedcd..a92af6f 100644 --- a/code/server/sv_savegame.cpp +++ b/code/server/sv_savegame.cpp @@ -749,7 +749,7 @@ int SG_GetSaveGameComment( char* sComment, char* sMapName) { - auto ret = 0; + int ret = 0; auto& saved_game = ojk::SavedGame::get_instance(); @@ -789,7 +789,7 @@ int SG_GetSaveGameComment( // Read timestamp // - auto tFileTime = ::SG_GetTime(0); + time_t tFileTime = ::SG_GetTime(0); if (is_succeed) { @@ -1196,7 +1196,7 @@ qboolean SG_WriteSavegame(const char *psPathlessBaseName, qboolean qbAutosave) } ge->WriteLevel(qbAutosave); // always done now, but ent saver only does player if auto - auto is_write_failed = saved_game.is_failed(); + bool is_write_failed = saved_game.is_failed(); saved_game.close(); @@ -1233,7 +1233,7 @@ qboolean SG_ReadSavegame( ojk::SavedGameHelper sgh( &saved_game); - const auto iPrevTestSave = ::sv_testsave->integer; + const int iPrevTestSave = ::sv_testsave->integer; ojk::ScopeGuard scope_guard( [&]() @@ -1297,7 +1297,7 @@ qboolean SG_ReadSavegame( ::SG_ReadCvars(); // read game state - const auto qbAutosave = ::ReadGame(); + const int qbAutosave = ::ReadGame(); ::eSavedGameJustLoaded = (qbAutosave ? eAUTO : eFULL); diff --git a/codeJK2/game/g_savegame.cpp b/codeJK2/game/g_savegame.cpp index cd0ee50..8456946 100644 --- a/codeJK2/game/g_savegame.cpp +++ b/codeJK2/game/g_savegame.cpp @@ -456,7 +456,7 @@ static void EnumerateFields( { strList.clear(); - auto pbData = reinterpret_cast<byte*>( + byte* pbData = reinterpret_cast<byte*>( src_instance); // enumerate all the fields... diff --git a/codeJK2/icarus/Sequence.cpp b/codeJK2/icarus/Sequence.cpp index ba43675..d3d8da5 100644 --- a/codeJK2/icarus/Sequence.cpp +++ b/codeJK2/icarus/Sequence.cpp @@ -386,7 +386,7 @@ int CSequence::SaveCommand( CBlock *block ) size); //Save out the raw data - auto raw_data = static_cast<const uint8_t*>(bm->GetData()); + const uint8_t* raw_data = static_cast<const uint8_t*>(bm->GetData()); saved_game.write_chunk( INT_ID('B', 'M', 'E', 'M'), diff --git a/codeJK2/icarus/TaskManager.cpp b/codeJK2/icarus/TaskManager.cpp index 7a247ba..f20984b 100644 --- a/codeJK2/icarus/TaskManager.cpp +++ b/codeJK2/icarus/TaskManager.cpp @@ -1683,7 +1683,7 @@ int CTaskManager::SaveCommand( CBlock *block ) size); //Save out the raw data - auto raw_data = static_cast<const uint8_t*>(bm->GetData()); + const uint8_t* raw_data = static_cast<const uint8_t*>(bm->GetData()); saved_game.write_chunk( INT_ID('B', 'M', 'E', 'M'), diff --git a/shared/qcommon/ojk_saved_game.cpp b/shared/qcommon/ojk_saved_game.cpp index ede9b5a..9b3fda2 100644 --- a/shared/qcommon/ojk_saved_game.cpp +++ b/shared/qcommon/ojk_saved_game.cpp @@ -39,7 +39,7 @@ bool SavedGame::open( close(); - const auto file_path = generate_path( + const std::string file_path = generate_path( base_file_name); bool is_succeed = true; @@ -116,7 +116,7 @@ bool SavedGame::create( remove( base_file_name); - const auto file_path = generate_path( + const std::string file_path = generate_path( base_file_name); file_handle_ = ::FS_FOpenFileWrite( @@ -124,7 +124,7 @@ bool SavedGame::create( if (file_handle_ == 0) { - const auto error_message = + const std::string error_message = S_COLOR_RED "Failed to create a saved game file: \"" + file_path + "\"."; @@ -138,7 +138,7 @@ bool SavedGame::create( is_writable_ = true; - const auto sg_version = iSAVEGAME_VERSION; + constexpr int sg_version = iSAVEGAME_VERSION; SavedGameHelper sgsh(this); @@ -192,7 +192,7 @@ bool SavedGame::read_chunk( io_buffer_offset_ = 0; - const auto chunk_id_string = get_chunk_id_string( + const std::string chunk_id_string = get_chunk_id_string( chunk_id); ::Com_DPrintf( @@ -202,7 +202,7 @@ bool SavedGame::read_chunk( uint32_t ulLoadedChid = 0; uint32_t uiLoadedLength = 0; - auto uiLoaded = ::FS_Read( + int uiLoaded = ::FS_Read( &ulLoadedChid, static_cast<int>(sizeof(ulLoadedChid)), file_handle_); @@ -225,7 +225,7 @@ bool SavedGame::read_chunk( { is_failed_ = true; - const auto loaded_chunk_id_string = get_chunk_id_string( + const std::string loaded_chunk_id_string = get_chunk_id_string( ulLoadedChid); error_message_ = @@ -316,7 +316,7 @@ bool SavedGame::read_chunk( // Make sure the checksums match... // - const auto uiCksum = ::Com_BlockChecksum( + const uint32_t uiCksum = ::Com_BlockChecksum( io_buffer_.data(), static_cast<int>(io_buffer_.size())); @@ -394,7 +394,7 @@ bool SavedGame::write_chunk( } - const auto chunk_id_string = get_chunk_id_string( + const std::string chunk_id_string = get_chunk_id_string( chunk_id); ::Com_DPrintf( @@ -406,9 +406,9 @@ bool SavedGame::write_chunk( return true; } - const auto src_size = static_cast<int>(io_buffer_.size()); + const int src_size = static_cast<int>(io_buffer_.size()); - const auto uiCksum = Com_BlockChecksum( + const uint32_t uiCksum = Com_BlockChecksum( io_buffer_.data(), src_size); @@ -417,7 +417,7 @@ bool SavedGame::write_chunk( static_cast<int>(sizeof(chunk_id)), file_handle_); - auto iCompressedLength = -1; + int iCompressedLength = -1; if (::sv_compress_saved_games->integer != 0) { @@ -432,12 +432,12 @@ bool SavedGame::write_chunk( } #ifdef JK2_MODE - const auto uiMagic = get_jo_magic_value(); + const int uiMagic = get_jo_magic_value(); #endif // JK2_MODE if (iCompressedLength > 0) { - const auto iLength = -static_cast<int>(io_buffer_.size()); + const int iLength = -static_cast<int>(io_buffer_.size()); uiSaved += ::FS_Write( &iLength, @@ -500,7 +500,7 @@ bool SavedGame::write_chunk( } else { - const auto iLength = static_cast<uint32_t>(io_buffer_.size()); + const uint32_t iLength = static_cast<uint32_t>(io_buffer_.size()); uiSaved += ::FS_Write( &iLength, @@ -660,7 +660,7 @@ bool SavedGame::write( return true; } - const auto new_buffer_size = io_buffer_offset_ + src_size; + const size_t new_buffer_size = io_buffer_offset_ + src_size; io_buffer_.resize( new_buffer_size); @@ -714,8 +714,8 @@ bool SavedGame::skip( return true; } - const auto new_offset = io_buffer_offset_ + count; - const auto buffer_size = io_buffer_.size(); + const size_t new_offset = io_buffer_offset_ + count; + const size_t buffer_size = io_buffer_.size(); if (new_offset > buffer_size) { @@ -766,13 +766,13 @@ void SavedGame::rename( const std::string& old_base_file_name, const std::string& new_base_file_name) { - const auto&& old_path = generate_path( + const std::string old_path = generate_path( old_base_file_name); - const auto&& new_path = generate_path( + const std::string new_path = generate_path( new_base_file_name); - const auto rename_result = ::FS_MoveUserGenFile( + const int rename_result = ::FS_MoveUserGenFile( old_path.c_str(), new_path.c_str()); @@ -788,7 +788,7 @@ void SavedGame::rename( void SavedGame::remove( const std::string& base_file_name) { - const auto&& path = generate_path( + const std::string path = generate_path( base_file_name); ::FS_DeleteUserGenFile( @@ -826,17 +826,17 @@ void SavedGame::compress( const Buffer& src_buffer, Buffer& dst_buffer) { - const auto src_size = static_cast<int>(src_buffer.size()); + const int src_size = static_cast<int>(src_buffer.size()); dst_buffer.resize(2 * src_size); - auto src_count = 0; - auto dst_index = 0; + int src_count = 0; + int dst_index = 0; while (src_count < src_size) { - auto src_index = src_count; - auto b = src_buffer[src_index++]; + int src_index = src_count; + uint8_t b = src_buffer[src_index++]; while (src_index < src_size && (src_index - src_count) < 127 && @@ -865,7 +865,7 @@ void SavedGame::compress( dst_buffer[dst_index++] = static_cast<uint8_t>(src_count - src_index); - for (auto i = src_count; i < src_index; ++i) + for (int i = src_count; i < src_index; ++i) { dst_buffer[dst_index++] = src_buffer[i]; } @@ -889,14 +889,14 @@ void SavedGame::decompress( const Buffer& src_buffer, Buffer& dst_buffer) { - auto src_index = 0; - auto dst_index = 0; + int src_index = 0; + int dst_index = 0; - auto remain_size = static_cast<int>(dst_buffer.size()); + int remain_size = static_cast<int>(dst_buffer.size()); while (remain_size > 0) { - auto count = static_cast<int8_t>(src_buffer[src_index++]); + int8_t count = static_cast<int8_t>(src_buffer[src_index++]); if (count > 0) { @@ -928,7 +928,7 @@ void SavedGame::decompress( std::string SavedGame::generate_path( const std::string& base_file_name) { - auto normalized_file_name = base_file_name; + std::string normalized_file_name = base_file_name; std::replace( normalized_file_name.begin(), @@ -936,9 +936,7 @@ std::string SavedGame::generate_path( '/', '_'); - auto&& path = "saves/" + normalized_file_name + ".sav"; - - return path; + return "saves/" + normalized_file_name + ".sav"; } std::string SavedGame::get_chunk_id_string( diff --git a/shared/qcommon/ojk_saved_game_helper.h b/shared/qcommon/ojk_saved_game_helper.h index b3c9754..00a7997 100644 --- a/shared/qcommon/ojk_saved_game_helper.h +++ b/shared/qcommon/ojk_saved_game_helper.h @@ -198,7 +198,7 @@ void SavedGameHelper::write_chunk_and_size( { saved_game_->save_buffer(); - auto data_size = saved_game_->get_buffer_size(); + const int data_size = saved_game_->get_buffer_size(); saved_game_->reset_buffer(); @@ -311,7 +311,7 @@ bool SavedGameHelper::try_read( TDst& dst_value, BooleanTag) { - constexpr auto src_size = static_cast<int>(sizeof(TSrc)); + constexpr int src_size = static_cast<int>(sizeof(TSrc)); TSrc src_value; @@ -335,7 +335,7 @@ bool SavedGameHelper::try_read( TDst& dst_value, NumericTag) { - constexpr auto src_size = static_cast<int>(sizeof(TSrc)); + constexpr int src_size = static_cast<int>(sizeof(TSrc)); TSrc src_value; @@ -370,7 +370,7 @@ bool SavedGameHelper::try_read( std::uintptr_t >::type; - auto dst_number = DstNumeric(); + DstNumeric dst_number; if (!try_read<TSrc>( dst_number, @@ -445,26 +445,26 @@ bool SavedGameHelper::try_read( TSrc >::type; - constexpr auto is_src_pure_numeric = + constexpr bool is_src_pure_numeric = std::is_arithmetic<Src>::value && (!std::is_same<Src, bool>::value) && (!std::is_enum<Src>::value); - constexpr auto is_dst_pure_numeric = + constexpr bool is_dst_pure_numeric = std::is_arithmetic<TDst>::value && (!std::is_same<TDst, bool>::value) && (!std::is_enum<TDst>::value); - constexpr auto is_src_float_point = + constexpr bool is_src_float_point = std::is_floating_point<Src>::value; - constexpr auto is_dst_float_point = + constexpr bool is_dst_float_point = std::is_floating_point<TDst>::value; - constexpr auto has_same_size = + constexpr bool has_same_size = (sizeof(Src) == sizeof(TDst)); - constexpr auto use_inplace = + constexpr bool use_inplace = is_src_pure_numeric && is_dst_pure_numeric && ((!is_src_float_point && !is_dst_float_point) || @@ -509,7 +509,7 @@ bool SavedGameHelper::try_read( int dst_count, InplaceTag) { - const auto dst_size = dst_count * static_cast<int>(sizeof(TDst)); + const int dst_size = dst_count * static_cast<int>(sizeof(TDst)); if (!saved_game_->read( dst_values, @@ -604,9 +604,9 @@ void SavedGameHelper::write( const TSrc& src_value, NumericTag) { - constexpr auto dst_size = static_cast<int>(sizeof(TDst)); + constexpr int dst_size = static_cast<int>(sizeof(TDst)); - auto dst_value = static_cast<TDst>(src_value); + const TDst dst_value = static_cast<TDst>(src_value); // FIXME Byte order // @@ -627,7 +627,7 @@ void SavedGameHelper::write( std::uintptr_t >::type; - auto dst_number = reinterpret_cast<DstNumeric>(src_value); + const DstNumeric dst_number = reinterpret_cast<DstNumeric>(src_value); write<TDst>( dst_number, @@ -692,26 +692,26 @@ void SavedGameHelper::write( TSrc, TDst>::type; - constexpr auto is_src_pure_numeric = + constexpr bool is_src_pure_numeric = std::is_arithmetic<TSrc>::value && (!std::is_same<TSrc, bool>::value) && (!std::is_enum<TSrc>::value); - constexpr auto is_dst_pure_numeric = + constexpr bool is_dst_pure_numeric = std::is_arithmetic<Dst>::value && (!std::is_same<Dst, bool>::value) && (!std::is_enum<Dst>::value); - constexpr auto is_src_float_point = + constexpr bool is_src_float_point = std::is_floating_point<TSrc>::value; - constexpr auto is_dst_float_point = + constexpr bool is_dst_float_point = std::is_floating_point<Dst>::value; - constexpr auto has_same_size = + constexpr bool has_same_size = (sizeof(TSrc) == sizeof(Dst)); - constexpr auto use_inplace = + constexpr bool use_inplace = is_src_pure_numeric && is_dst_pure_numeric && ((!is_src_float_point && !is_dst_float_point) || @@ -736,7 +736,7 @@ void SavedGameHelper::write( int src_count, InplaceTag) { - const auto src_size = src_count * static_cast<int>(sizeof(TSrc)); + const int src_size = src_count * static_cast<int>(sizeof(TSrc)); saved_game_->write( src_values, -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git _______________________________________________ Pkg-games-commits mailing list Pkg-games-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits