From fe6370aff8dc7afe6ff05c6d6dc74b296b2fb017 Mon Sep 17 00:00:00 2001 From: janwas Date: Thu, 17 Jul 2008 17:00:00 +0000 Subject: [PATCH] more dehydra. disabled lockfree module (not in use). This was SVN commit r6240. --- source/i18n/StringBuffer.cpp | 2 ++ source/lib/file/archive/archive_zip.cpp | 3 +- source/lib/file/common/file_stats.cpp | 2 +- source/lib/file/io/block_cache.cpp | 2 +- source/lib/lockfree.cpp | 5 ++- source/lib/res/graphics/cursor.cpp | 3 +- source/lib/res/graphics/unifont.cpp | 5 ++- source/lib/sysdep/os/linux/dir_watch_fam.cpp | 1 + source/lib/tests/test_lockfree.h | 9 ++++++ source/main.cpp | 4 +-- source/ps/CStr.cpp | 8 +++-- source/ps/GameSetup/CmdLineArgs.cpp | 2 +- source/ps/GameSetup/CmdLineArgs.h | 2 +- source/ps/GameSetup/Config.cpp | 2 +- source/ps/GameSetup/GameSetup.cpp | 4 --- source/ps/GameSetup/tests/test_CmdLineArgs.h | 10 +++--- source/ps/Util.cpp | 2 +- source/ps/XML/Xeromyces.cpp | 2 +- source/simulation/AStarEngine.cpp | 4 +-- source/simulation/EntityHandles.cpp | 4 +-- source/simulation/EntityHandles.h | 2 +- source/simulation/EntityManager.cpp | 32 ++++++++++---------- source/simulation/EntityManager.h | 8 ++--- source/simulation/Formation.cpp | 3 +- source/simulation/Formation.h | 2 +- source/simulation/PathfindEngine.cpp | 6 ++-- source/simulation/TRAStarEngine.cpp | 2 +- 27 files changed, 76 insertions(+), 55 deletions(-) diff --git a/source/i18n/StringBuffer.cpp b/source/i18n/StringBuffer.cpp index b399743416..31bb3c14a2 100644 --- a/source/i18n/StringBuffer.cpp +++ b/source/i18n/StringBuffer.cpp @@ -36,10 +36,12 @@ I18n::StringBuffer::operator Str() } if (String->VarCount == 0) + { if (String->Parts.size()) return String->Parts[0]->ToString(Locale, Variables).str(); else return Str(); + } Str ret; diff --git a/source/lib/file/archive/archive_zip.cpp b/source/lib/file/archive/archive_zip.cpp index b91ac15539..4345b1e9e8 100644 --- a/source/lib/file/archive/archive_zip.cpp +++ b/source/lib/file/archive/archive_zip.cpp @@ -368,7 +368,8 @@ public: FileInfo fileInfo; s_fileSystemPosix.GetFileInfo(pathname, &fileInfo); m_fileSize = fileInfo.Size(); - debug_assert(m_fileSize >= sizeof(LFH)+sizeof(CDFH)+sizeof(ECDR)); + const size_t minFileSize = sizeof(LFH)+sizeof(CDFH)+sizeof(ECDR); + debug_assert(m_fileSize >= off_t(minFileSize)); } virtual LibError ReadEntries(ArchiveEntryCallback cb, uintptr_t cbData) diff --git a/source/lib/file/common/file_stats.cpp b/source/lib/file/common/file_stats.cpp index 78ceb16a25..bba35e6f1d 100644 --- a/source/lib/file/common/file_stats.cpp +++ b/source/lib/file/common/file_stats.cpp @@ -42,7 +42,7 @@ static size_t io_seeks; static size_t cache_count[2]; static double cache_size_total[2]; static size_t conflict_misses; -static double conflict_miss_size_total; +//static double conflict_miss_size_total; // JW: currently not used nor computed static size_t block_cache_count[2]; // archive builder diff --git a/source/lib/file/io/block_cache.cpp b/source/lib/file/io/block_cache.cpp index 6a913e4049..e0e803689d 100644 --- a/source/lib/file/io/block_cache.cpp +++ b/source/lib/file/io/block_cache.cpp @@ -32,7 +32,7 @@ BlockId::BlockId(const Path& pathname, off_t ofs) const size_t indexBits = 16; m_id <<= indexBits; const off_t blockIndex = ofs / BLOCK_SIZE; - debug_assert(blockIndex < (1ul << indexBits)); + debug_assert(blockIndex < off_t(1ul << indexBits)); m_id |= blockIndex; } diff --git a/source/lib/lockfree.cpp b/source/lib/lockfree.cpp index c6b893da97..6fd2e80d5c 100644 --- a/source/lib/lockfree.cpp +++ b/source/lib/lockfree.cpp @@ -9,6 +9,7 @@ // license: GPL; see lib/license.txt #include "precompiled.h" +#if 0 // JW: disabled, not used #include "lockfree.h" #include @@ -258,7 +259,7 @@ retry: // for each participating thread: for(TLS* t = tls_list; t; t = t->next) // for each of its non-NULL hazard pointers: - for(int i = 0; i < NUM_HPS; i++) + for(size_t i = 0; i < NUM_HPS; i++) { void* hp = t->hp[i]; if(!hp) @@ -707,3 +708,5 @@ void lockfree_Shutdown() smr_shutdown(); } + +#endif diff --git a/source/lib/res/graphics/cursor.cpp b/source/lib/res/graphics/cursor.cpp index 0fddfbdca2..21650961ad 100644 --- a/source/lib/res/graphics/cursor.cpp +++ b/source/lib/res/graphics/cursor.cpp @@ -37,6 +37,7 @@ static LibError load_sys_cursor(const VfsPath& pathname, int hx, int hy, sys_cur UNUSED2(pathname); UNUSED2(hx); UNUSED2(hy); + UNUSED2(cursor); return ERR::FAIL; #else @@ -115,7 +116,7 @@ public: LibError validate() const { - const size_t A = 128; // no cursor is expected to get this big + const GLint A = 128; // no cursor is expected to get this big if(w > A || h > A || hotspotx > A || hotspoty > A) WARN_RETURN(ERR::_1); if(ht < 0) diff --git a/source/lib/res/graphics/unifont.cpp b/source/lib/res/graphics/unifont.cpp index a9fdb9cf4a..b555f8ce51 100644 --- a/source/lib/res/graphics/unifont.cpp +++ b/source/lib/res/graphics/unifont.cpp @@ -181,7 +181,10 @@ static LibError UniFont_validate(const UniFont* f) static LibError UniFont_to_string(const UniFont* f, char* buf) { if (f->ht) // not true if this is called after dtor (which it is) - snprintf(buf, H_STRING_LEN, "Font %s", h_filename(f->ht)); + { + const VfsPath& path = h_filename(f->ht); + snprintf(buf, H_STRING_LEN, "Font %s", path.string().c_str()); + } else snprintf(buf, H_STRING_LEN, "Font"); return INFO::OK; diff --git a/source/lib/sysdep/os/linux/dir_watch_fam.cpp b/source/lib/sysdep/os/linux/dir_watch_fam.cpp index 8c2de333d0..9f6d5ed9e1 100644 --- a/source/lib/sysdep/os/linux/dir_watch_fam.cpp +++ b/source/lib/sysdep/os/linux/dir_watch_fam.cpp @@ -109,6 +109,7 @@ LibError dir_get_changed_file(char* fn) char n_path[PATH_MAX]; const char* dir = dirs[e.fr.reqnum].c_str(); snprintf(n_path, PATH_MAX, "%s%c%s", dir, SYS_DIR_SEP, e.filename); + UNUSED2(fn); // we ought to copy to fn, but this code is apparently disabled.. return ERR::AGAIN; } } diff --git a/source/lib/tests/test_lockfree.h b/source/lib/tests/test_lockfree.h index 4e2c0243c3..250ef6ccf3 100644 --- a/source/lib/tests/test_lockfree.h +++ b/source/lib/tests/test_lockfree.h @@ -9,6 +9,10 @@ class TestLockfreeBasic : public CxxTest::TestSuite { public: +// note: the lockfree module is no longer part of the build, but cxxtestgen +// still sees this class and its methods despite them being commented out +// (#if 0 doesn't help, either). we therefore need to disable their bodies. +#if 0 void setUp() { lockfree_Init(); @@ -18,9 +22,11 @@ public: { lockfree_Shutdown(); } +#endif void test_basic_single_threaded() { +#if 0 void* user_data; const size_t ENTRIES = 50; // should be more than max # retired nodes to test release..() code @@ -61,6 +67,7 @@ public: lfl_free(&list); lfh_free(&hash); +#endif } }; @@ -68,6 +75,7 @@ public: // known to fail on P4 due to mem reordering and lack of membars. class TestMultithread : public CxxTest::TestSuite { +#if 0 void setUp() { lockfree_Init(); @@ -247,4 +255,5 @@ public: lfh_free(&hash); TS_ASSERT_OK(pthread_mutex_destroy(&mutex)); } +#endif }; diff --git a/source/main.cpp b/source/main.cpp index 257017cdae..d6db78d36c 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -358,7 +358,7 @@ void kill_mainloop() // moved into a helper function to ensure args is destroyed before // exit(), which may result in a memory leak. -static void RunGameOrAtlas(int argc, char* argv[]) +static void RunGameOrAtlas(int argc, const char* argv[]) { CmdLineArgs args(argc, argv); @@ -386,7 +386,7 @@ int main(int argc, char* argv[]) { EarlyInit(); // must come at beginning of main - RunGameOrAtlas(argc, argv); + RunGameOrAtlas(argc, const_cast(argv)); exit(EXIT_SUCCESS); } diff --git a/source/ps/CStr.cpp b/source/ps/CStr.cpp index a8feae43c6..3ddb173657 100644 --- a/source/ps/CStr.cpp +++ b/source/ps/CStr.cpp @@ -520,12 +520,16 @@ CStr CStr::Pad(PS_TRIM_MODE Mode, size_t Length) const CStr CStr::operator+(const CStr& Str) { - return std::operator+(*this, std::tstring(Str)); + CStr tmp(*this); + tmp += Str; + return tmp; } CStr CStr::operator+(const tchar* Str) { - return std::operator+(*this, std::tstring(Str)); + CStr tmp(*this); + tmp += Str; + return tmp; } // Joining ASCII and Unicode strings: diff --git a/source/ps/GameSetup/CmdLineArgs.cpp b/source/ps/GameSetup/CmdLineArgs.cpp index 51abd5f8f6..dca94c69f5 100644 --- a/source/ps/GameSetup/CmdLineArgs.cpp +++ b/source/ps/GameSetup/CmdLineArgs.cpp @@ -2,7 +2,7 @@ #include "CmdLineArgs.h" -CmdLineArgs::CmdLineArgs(int argc, char* argv[]) +CmdLineArgs::CmdLineArgs(int argc, const char* argv[]) { if (argc >= 1) m_Arg0 = argv[0]; diff --git a/source/ps/GameSetup/CmdLineArgs.h b/source/ps/GameSetup/CmdLineArgs.h index acfb1c773c..8e93c53c57 100644 --- a/source/ps/GameSetup/CmdLineArgs.h +++ b/source/ps/GameSetup/CmdLineArgs.h @@ -16,7 +16,7 @@ public: * @param argc size of argv array * @param argv array of arguments; argv[0] should be the program's name */ - CmdLineArgs(int argc, char* argv[]); + CmdLineArgs(int argc, const char* argv[]); /** * Test whether the given name was specified, as either -name or diff --git a/source/ps/GameSetup/Config.cpp b/source/ps/GameSetup/Config.cpp index bf63ac3be8..a59784b8bf 100644 --- a/source/ps/GameSetup/Config.cpp +++ b/source/ps/GameSetup/Config.cpp @@ -56,7 +56,7 @@ CStr g_AutostartMap = ""; static void LoadProfile( const CStr& profile ) { - VfsPath path = VfsPath("profiles") / (std::string)profile; + VfsPath path = VfsPath("profiles") / profile; VfsPath configFilename = path / "settings/user.cfg"; g_ConfigDB.SetConfigFile(CFG_USER, true, configFilename.string().c_str()); diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index 44d439c920..8c7d32e7af 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -827,8 +827,6 @@ void Shutdown(int flags) SAFE_DELETE(g_Logger); delete &g_Profiler; delete &g_ProfileViewer; - - lockfree_Shutdown(); TIMER_END("shutdown misc"); } @@ -843,8 +841,6 @@ void EarlyInit() // add all debug_printf "tags" that we are interested in: debug_filter_add("TIMER"); - lockfree_Init(); - cpu_ConfigureFloatingPoint(); timer_LatchStartTime(); diff --git a/source/ps/GameSetup/tests/test_CmdLineArgs.h b/source/ps/GameSetup/tests/test_CmdLineArgs.h index 5f3a58bc9c..496bec475f 100644 --- a/source/ps/GameSetup/tests/test_CmdLineArgs.h +++ b/source/ps/GameSetup/tests/test_CmdLineArgs.h @@ -7,7 +7,7 @@ class TestCmdLineArgs : public CxxTest::TestSuite public: void test_has() { - char* argv[] = { "program", "-test2" }; + const char* argv[] = { "program", "-test2" }; CmdLineArgs c(ARRAY_SIZE(argv), argv); TS_ASSERT(!c.Has("test1")); TS_ASSERT(c.Has("test2")); @@ -17,7 +17,7 @@ public: void test_get() { - char* argv[] = { "program", "-test1=", "-test2=x", "-test3=-y=y-", "-=z" }; + const char* argv[] = { "program", "-test1=", "-test2=x", "-test3=-y=y-", "-=z" }; CmdLineArgs c(ARRAY_SIZE(argv), argv); TS_ASSERT_STR_EQUALS(c.Get("test0"), ""); TS_ASSERT_STR_EQUALS(c.Get("test1"), ""); @@ -28,7 +28,7 @@ public: void test_multiple() { - char* argv[] = { "program", "-test1=one", "-test1=two", "-test2=none", "-test1=three" }; + const char* argv[] = { "program", "-test1=one", "-test1=two", "-test2=none", "-test1=three" }; CmdLineArgs c(ARRAY_SIZE(argv), argv); TS_ASSERT_STR_EQUALS(c.Get("test1"), "one"); @@ -48,7 +48,7 @@ public: void test_get_invalid() { - char* argv[] = { "-test1", "-test2", "test3", " -test4" }; + const char* argv[] = { "-test1", "-test2", "test3", " -test4" }; CmdLineArgs c(ARRAY_SIZE(argv), argv); TS_ASSERT(!c.Has("test1")); @@ -59,7 +59,7 @@ public: void test_arg0() { - char* argv[] = { "program" }; + const char* argv[] = { "program" }; CmdLineArgs c(ARRAY_SIZE(argv), argv); TS_ASSERT_STR_EQUALS(c.GetArg0(), "program"); diff --git a/source/ps/Util.cpp b/source/ps/Util.cpp index 261ee9f423..62b74fff99 100644 --- a/source/ps/Util.cpp +++ b/source/ps/Util.cpp @@ -89,7 +89,7 @@ void WriteSystemInfo() fprintf(f, "\n"); // memory - fprintf(f, "Memory : %lu MiB; %lu MiB free\n", os_cpu_MemorySize()/MiB, os_cpu_MemoryAvailable()/MiB); + fprintf(f, "Memory : %u MiB; %u MiB free\n", os_cpu_MemorySize(), os_cpu_MemoryAvailable()); // graphics fprintf(f, "Graphics Card : %s\n", gfx_card); diff --git a/source/ps/XML/Xeromyces.cpp b/source/ps/XML/Xeromyces.cpp index d54dd533f7..7579bb8bdd 100644 --- a/source/ps/XML/Xeromyces.cpp +++ b/source/ps/XML/Xeromyces.cpp @@ -228,7 +228,7 @@ PSRETURN CXeromyces::Load(const VfsPath& filename) if (errorHandler.GetSawErrors()) { - LOG(CLogger::Error, LOG_CATEGORY, "CXeromyces: Errors in XML file '%s'", filename); + LOG(CLogger::Error, LOG_CATEGORY, "CXeromyces: Errors in XML file '%s'", filename.string().c_str()); return PSRETURN_Xeromyces_XMLParseError; // The internal tree of the XeroHandler will be cleaned up automatically } diff --git a/source/simulation/AStarEngine.cpp b/source/simulation/AStarEngine.cpp index bf8f1a0732..0c9e5027e5 100644 --- a/source/simulation/AStarEngine.cpp +++ b/source/simulation/AStarEngine.cpp @@ -45,7 +45,7 @@ public: char random[1021]; std::vector aPath; - void setPath(std::vector _aPath) + void setPath(const std::vector& _aPath) { aPath =_aPath; @@ -269,7 +269,7 @@ bool CAStarEngine::FindPath( //switch on/off grid path drawing by command line arg "-showOverlay" //it's guarded here to stop setting the drawing path in pathfindingOverlay. //(efficiency issue) - //the drawing is disable in the render() function in TerraiOverlay.cpp + //the drawing is disabled in the render() function in TerrainOverlay.cpp if(g_ShowPathfindingOverlay) { pathfindingOverlay->setPath(mPath); diff --git a/source/simulation/EntityHandles.cpp b/source/simulation/EntityHandles.cpp index 9f43fd7e16..89d679a467 100644 --- a/source/simulation/EntityHandles.cpp +++ b/source/simulation/EntityHandles.cpp @@ -12,9 +12,9 @@ CHandle::CHandle() m_refcount = 0; } -HEntity::HEntity( u16 index ) +HEntity::HEntity( size_t index ) { - m_handle = index; + m_handle = (u16)index; AddRef(); } diff --git a/source/simulation/EntityHandles.h b/source/simulation/EntityHandles.h index 1832814d3e..f157750347 100644 --- a/source/simulation/EntityHandles.h +++ b/source/simulation/EntityHandles.h @@ -42,7 +42,7 @@ class HEntity private: void AddRef(); void DecRef(); - HEntity( u16 index ); + HEntity( size_t index ); public: HEntity(); HEntity( const HEntity& copy ); diff --git a/source/simulation/EntityManager.cpp b/source/simulation/EntityManager.cpp index 3eb87a4a32..8d92cd48a0 100644 --- a/source/simulation/EntityManager.cpp +++ b/source/simulation/EntityManager.cpp @@ -44,7 +44,7 @@ CEntityManager::CEntityManager() void CEntityManager::DeleteAllHelper() { - for( int i = 0; i < MAX_HANDLES; i++ ) + for( size_t i = 0; i < MAX_HANDLES; i++ ) { if( m_entities[i].m_refcount ) { @@ -195,7 +195,7 @@ HEntity CEntityManager::Create(CEntityTemplate* base, CVector3D position, float return HEntity(); // Find an unused handle for the unit - int pos = 0; + size_t pos = 0; while( m_entities[m_nextalloc].m_refcount ) { m_nextalloc++; @@ -272,13 +272,13 @@ HEntity CEntityManager::CreateFoundation( const CStrW& templateName, CPlayer* pl return Create( foundation, position, orientation, selections, &templateName ); } -HEntity* CEntityManager::GetByHandle( u16 index ) +HEntity* CEntityManager::GetByHandle( size_t index ) { if( index >= MAX_HANDLES ) return( NULL ); if( !m_entities[index].m_refcount ) return( NULL ); return( new HEntity( index ) ); } -CHandle *CEntityManager::GetHandle( int index ) +CHandle *CEntityManager::GetHandle( size_t index ) { if (!m_entities[index].m_refcount ) return NULL; @@ -288,7 +288,7 @@ CHandle *CEntityManager::GetHandle( int index ) void CEntityManager::GetMatchingAsHandles(std::vector& matchlist, EntityPredicate predicate, void* userdata) { matchlist.clear(); - for( int i = 0; i < MAX_HANDLES; i++ ) + for( size_t i = 0; i < MAX_HANDLES; i++ ) { if( IsEntityRefd(i) ) if( predicate( m_entities[i].m_entity, userdata ) ) @@ -299,7 +299,7 @@ void CEntityManager::GetMatchingAsHandles(std::vector& matchlist, Entit void CEntityManager::GetExtantAsHandles( std::vector& results ) { results.clear(); - for( int i = 0; i < MAX_HANDLES; i++ ) + for( size_t i = 0; i < MAX_HANDLES; i++ ) if( IsEntityRefd(i) ) results.push_back( HEntity( i ) ); } @@ -307,7 +307,7 @@ void CEntityManager::GetExtantAsHandles( std::vector& results ) void CEntityManager::GetExtant( std::vector& results ) { results.clear(); - for( int i = 0; i < MAX_HANDLES; i++ ) + for( size_t i = 0; i < MAX_HANDLES; i++ ) if( IsEntityRefd(i) && m_entities[i].m_entity->m_extant ) results.push_back( m_entities[i].m_entity ); } @@ -356,7 +356,7 @@ void CEntityManager::GetInLOS( CEntity* entity, std::vector& results ) /* void CEntityManager::dispatchAll( CMessage* msg ) { - for( int i = 0; i < MAX_HANDLES; i++ ) + for( size_t i = 0; i < MAX_HANDLES; i++ ) if( m_entities[i].m_refcount && m_entities[i].m_entity->m_extant ) m_entities[i].m_entity->dispatch( msg ); } @@ -374,7 +374,7 @@ void CEntityManager::InitializeAll() debug_assert(! m_collisionPatches); m_collisionPatches = new std::vector[m_collisionPatchesPerSide * m_collisionPatchesPerSide]; - for( int i = 0; i < MAX_HANDLES; i++ ) + for( size_t i = 0; i < MAX_HANDLES; i++ ) { if( IsEntityRefd(i) ) { @@ -391,7 +391,7 @@ void CEntityManager::InitializeAll() /* void CEntityManager::TickAll() { - for( int i = 0; i < MAX_HANDLES; i++ ) + for( size_t i = 0; i < MAX_HANDLES; i++ ) if( IsEntityRefd(i) && m_entities[i].m_entity->m_extant ) m_entities[i].m_entity->Tick(); } @@ -421,7 +421,7 @@ void CEntityManager::UpdateAll( int timestep ) */ PROFILE_START( "update all" ); - for( int i = 0; i < MAX_HANDLES; i++ ) + for( size_t i = 0; i < MAX_HANDLES; i++ ) if( IsEntityRefd(i) ) m_entities[i].m_entity->Update( timestep ); PROFILE_END( "update all" ); @@ -429,7 +429,7 @@ void CEntityManager::UpdateAll( int timestep ) void CEntityManager::InterpolateAll( float relativeoffset ) { - for( int i = 0; i < MAX_HANDLES; i++ ) + for( size_t i = 0; i < MAX_HANDLES; i++ ) // This needs to handle all entities, including destroyed/non-extant ones // (mainly dead bodies), so it can't use IsEntityRefd if( m_entities[i].m_refcount ) @@ -438,7 +438,7 @@ void CEntityManager::InterpolateAll( float relativeoffset ) void CEntityManager::RenderAll() { - for( int i = 0; i < MAX_HANDLES; i++ ) + for( size_t i = 0; i < MAX_HANDLES; i++ ) if( IsEntityRefd(i) ) m_entities[i].m_entity->Render(); } @@ -446,7 +446,7 @@ void CEntityManager::RenderAll() void CEntityManager::ConformAll() { PROFILE_START("conform all"); - for ( int i=0; i < MAX_HANDLES; i++ ) + for ( size_t i=0; i < MAX_HANDLES; i++ ) { if( IsEntityRefd(i) ) { @@ -459,7 +459,7 @@ void CEntityManager::ConformAll() void CEntityManager::InvalidateAll() { - for( int i = 0; i < MAX_HANDLES; i++ ) + for( size_t i = 0; i < MAX_HANDLES; i++ ) if( IsEntityRefd(i) ) m_entities[i].m_entity->InvalidateActor(); } @@ -477,7 +477,7 @@ void CEntityManager::RemoveUnitCount(CEntity* ent) } --m_entityClassData[playerID][className]; } -void CEntityManager::Destroy( u16 handle ) +void CEntityManager::Destroy( size_t handle ) { m_reaper.push_back( m_entities[handle].m_entity ); } diff --git a/source/simulation/EntityManager.h b/source/simulation/EntityManager.h index cd8b80c111..d70cfbbe2a 100644 --- a/source/simulation/EntityManager.h +++ b/source/simulation/EntityManager.h @@ -55,10 +55,10 @@ friend class CHandle; //Optimized data for triggers. key = playerID, nested key = entity class, value = frequency std::map > m_entityClassData; - void Destroy( u16 handle ); + void Destroy( size_t handle ); void DeleteAllHelper(); - inline bool IsEntityRefd( u16 index ) + inline bool IsEntityRefd( size_t index ) { return m_refd[index]; //return m_entities[index].m_refcount && !m_entities[index].m_entity->entf_get(ENTF_DESTROYED); @@ -79,8 +79,8 @@ public: HEntity CreateFoundation( const CStrW& templateName, CPlayer* player, CVector3D position, float orientation ); - HEntity* GetByHandle( u16 index ); - CHandle *GetHandle( int index ); + HEntity* GetByHandle( size_t index ); + CHandle *GetHandle( size_t index ); inline int GetPlayerUnitCount( size_t player, const CStrW& name ) { diff --git a/source/simulation/Formation.cpp b/source/simulation/Formation.cpp index 2e876c14f4..8829326c8c 100644 --- a/source/simulation/Formation.cpp +++ b/source/simulation/Formation.cpp @@ -192,8 +192,9 @@ bool CFormation::LoadXml(const CStr& filename) return true; } -void CFormation::AssignCategory(size_t order, CStr category) +void CFormation::AssignCategory(size_t order, const CStr& category_) { + CStr category(category_); category.Remove( CStr(",") ); category = category + " "; //So the final word will be pushed as well CStr temp; diff --git a/source/simulation/Formation.h b/source/simulation/Formation.h index b6ae0e6ab7..cf1520cf9f 100644 --- a/source/simulation/Formation.h +++ b/source/simulation/Formation.h @@ -75,6 +75,6 @@ private: std::map m_slots; bool LoadXml(const CStr& filename); - void AssignCategory(size_t order, CStr category); //takes care of formatting strings + void AssignCategory(size_t order, const CStr& category); //takes care of formatting strings }; #endif diff --git a/source/simulation/PathfindEngine.cpp b/source/simulation/PathfindEngine.cpp index 7446a57bf5..e49002a6bc 100644 --- a/source/simulation/PathfindEngine.cpp +++ b/source/simulation/PathfindEngine.cpp @@ -109,17 +109,17 @@ public: } } - void setCurrentPath(SrPolygon _CurPath) + void setCurrentPath(const SrPolygon& _CurPath) { CurPath = _CurPath; } - void setConstrainedEdges(SrArray _constr) + void setConstrainedEdges(const SrArray& _constr) { constr = _constr; } - void setUnconstrainedEdges(SrArray _unconstr) + void setUnconstrainedEdges(const SrArray& _unconstr) { unconstr = _unconstr; } diff --git a/source/simulation/TRAStarEngine.cpp b/source/simulation/TRAStarEngine.cpp index 034641bba7..93f873579d 100644 --- a/source/simulation/TRAStarEngine.cpp +++ b/source/simulation/TRAStarEngine.cpp @@ -12,7 +12,7 @@ CTRAStarEngine::~CTRAStarEngine(void) delete mGoal; } -bool CTRAStarEngine::FindPath(const CVector2D &src, const CVector2D &dest, HEntity entity, SeDcdt& dcdtPathfinder, float radius ) +bool CTRAStarEngine::FindPath(const CVector2D &src, const CVector2D &dest, HEntity UNUSED(entity), SeDcdt& dcdtPathfinder, float radius ) { bool found = dcdtPathfinder.SearchPathFast(src.x, src.y, dest.x, dest.y, radius); return found;