From 8e86d2930158048d90e01461ab3aba024f8cffbc Mon Sep 17 00:00:00 2001 From: janwas Date: Thu, 17 Jul 2008 14:23:51 +0000 Subject: [PATCH] dehydra fixes (mostly copy-ctor warnings) This was SVN commit r6239. --- source/graphics/Model.cpp | 2 +- source/graphics/Model.h | 2 +- source/lib/cache_adt.h | 38 +++++++++---------- source/lib/file/archive/archive_zip.cpp | 8 ++-- source/lib/file/archive/stream.cpp | 2 +- source/lib/file/archive/stream.h | 2 +- source/lib/file/common/file_loader.h | 2 +- source/lib/file/common/real_directory.cpp | 6 +-- source/lib/file/common/real_directory.h | 6 +-- source/lib/file/io/block_cache.cpp | 6 +-- source/lib/file/io/block_cache.h | 2 +- source/lib/file/io/io.cpp | 12 +++--- source/lib/file/io/io.h | 8 ++-- source/lib/file/io/write_buffer.cpp | 2 +- source/lib/file/io/write_buffer.h | 2 +- source/lib/file/vfs/file_cache.cpp | 8 ++-- source/lib/file/vfs/file_cache.h | 2 +- source/lib/file/vfs/vfs.cpp | 6 +-- source/lib/file/vfs/vfs.h | 2 +- source/lib/file/vfs/vfs_lookup.cpp | 4 +- source/lib/file/vfs/vfs_tree.cpp | 4 +- source/lib/file/vfs/vfs_tree.h | 6 +-- source/lib/tex/tex.cpp | 4 +- source/lib/tex/tex.h | 4 +- source/ps/XML/Xeromyces.cpp | 2 +- source/ps/XML/Xeromyces.h | 2 +- .../renderer/FixedFunctionModelRenderer.cpp | 8 ++-- source/renderer/FixedFunctionModelRenderer.h | 2 +- source/renderer/HWLightingModelRenderer.cpp | 6 +-- source/renderer/HWLightingModelRenderer.h | 2 +- source/renderer/InstancingModelRenderer.cpp | 6 +-- source/renderer/InstancingModelRenderer.h | 2 +- source/renderer/ModelRenderer.cpp | 34 ++++++++--------- source/renderer/ModelRenderer.h | 24 ++++++------ source/renderer/ModelVertexRenderer.h | 2 +- source/renderer/TransparencyRenderer.cpp | 8 ++-- source/renderer/TransparencyRenderer.h | 4 +- 37 files changed, 120 insertions(+), 122 deletions(-) diff --git a/source/graphics/Model.cpp b/source/graphics/Model.cpp index 742fd7421c..04d61f20cd 100644 --- a/source/graphics/Model.cpp +++ b/source/graphics/Model.cpp @@ -79,7 +79,7 @@ void CModel::ReleaseData() ///////////////////////////////////////////////////////////////////////////////////////////////////////////// // InitModel: setup model from given geometry -bool CModel::InitModel(CModelDefPtr modeldef) +bool CModel::InitModel(const CModelDefPtr& modeldef) { // clean up any existing data first ReleaseData(); diff --git a/source/graphics/Model.h b/source/graphics/Model.h index 900d30d588..0c5b7a8a13 100644 --- a/source/graphics/Model.h +++ b/source/graphics/Model.h @@ -50,7 +50,7 @@ public: ~CModel(); // setup model from given geometry - bool InitModel(CModelDefPtr modeldef); + bool InitModel(const CModelDefPtr& modeldef); // calculate the world space bounds of this model void CalcBounds(); // update this model's state; 'time' is the time since the last update, in MS diff --git a/source/lib/cache_adt.h b/source/lib/cache_adt.h index c21dcd19c0..27d73f0f25 100644 --- a/source/lib/cache_adt.h +++ b/source/lib/cache_adt.h @@ -41,16 +41,16 @@ Manager is a template parameterized on typename Key and class Entry. bool empty() const; // add (key, entry) to cache. - void add(Key key, const Entry& entry); + void add(const Key& key, const Entry& entry); // if the entry identified by is not in cache, return false; // otherwise return true and pass back a pointer to it. - bool find(Key key, const Entry** pentry) const; + bool find(const Key& key, const Entry** pentry) const; // remove an entry from cache, which is assumed to exist! // this makes sense because callers will typically first use find() to // return info about the entry; this also checks if present. - void remove(Key key); + void remove(const Key& key); // mark as just accessed for purpose of cache management. // it will tend to be kept in cache longer. @@ -215,13 +215,13 @@ public: return map.empty(); } - void add(Key key, const Entry& entry) + void add(const Key& key, const Entry& entry) { // adapter for add_ (which returns an iterator) (void)add_(key, entry); } - bool find(Key key, const Entry** pentry) const + bool find(const Key& key, const Entry** pentry) const { MapCIt it = map.find(key); if(it == map.end()) @@ -230,7 +230,7 @@ public: return true; } - void remove(Key key) + void remove(const Key& key) { MapIt it = map.find(key); // note: don't complain if not in the cache: this happens after @@ -304,7 +304,7 @@ protected: Map map; // add entry and return iterator pointing to it. - MapIt add_(Key key, const Entry& entry) + MapIt add_(const Key& key, const Entry& entry) { typedef std::pair PairIB; typename Map::value_type val = std::make_pair(key, entry); @@ -379,7 +379,7 @@ class Landlord_Lazy : public Landlord_Naive public: Landlord_Lazy() { pending_delta = 0.0f; } - void add(Key key, const Entry& entry) + void add(const Key& key, const Entry& entry) { // we must apply pending_delta now - otherwise, the existing delta // would later be applied to this newly added item (incorrect). @@ -389,7 +389,7 @@ public: pri_q.push(it); } - void remove(Key key) + void remove(const Key& key) { Parent::remove(key); @@ -531,12 +531,12 @@ public: return lru.empty(); } - void add(Key key, const Entry& entry) + void add(const Key& key, const Entry& entry) { lru.push_back(KeyAndEntry(key, entry)); } - bool find(Key key, const Entry** pentry) const + bool find(const Key& key, const Entry** pentry) const { CIt it = std::find_if(lru.begin(), lru.end(), KeyEq(key)); if(it == lru.end()) @@ -545,7 +545,7 @@ public: return true; } - void remove(Key key) + void remove(const Key& key) { std::remove_if(lru.begin(), lru.end(), KeyEq(key)); } @@ -575,14 +575,14 @@ private: { Key key; Entry entry; - KeyAndEntry(Key key_, const Entry& entry_) + KeyAndEntry(const Key& key_, const Entry& entry_) : key(key_), entry(entry_) {} }; class KeyEq { Key key; public: - KeyEq(Key key_) : key(key_) {} + KeyEq(const Key& key_) : key(key_) {} bool operator()(const KeyAndEntry& ke) const { return ke.key == key; @@ -613,7 +613,7 @@ template struct CacheEntry { } - CacheEntry(Item item_, size_t size_, size_t cost_) + CacheEntry(const Item& item_, size_t size_, size_t cost_) : item(item_), divider((float)size_) { size = size_; @@ -647,7 +647,7 @@ class Cache public: Cache() : mgr() {} - void add(Key key, Item item, size_t size, size_t cost) + void add(const Key& key, const Item& item, size_t size, size_t cost) { return mgr.add(key, Entry(item, size, cost)); } @@ -656,7 +656,7 @@ public: // if present and determine size via retrieve(), so no need for // error checking. // useful for invalidating single cache entries. - void remove(Key key) + void remove(const Key& key) { mgr.remove(key); } @@ -668,7 +668,7 @@ public: // tending to keep it in cache longer. this parameter is not used in // normal operation - it's only for special cases where we need to // make an end run around the cache accounting (e.g. for cache simulator). - bool retrieve(Key key, Item& item, size_t* psize = 0, bool refill_credit = true) + bool retrieve(const Key& key, Item& item, size_t* psize = 0, bool refill_credit = true) { const Entry* entry; if(!mgr.find(key, &entry)) @@ -684,7 +684,7 @@ public: return true; } - bool peek(Key key, Item& item, size_t* psize = 0) + bool peek(const Key& key, Item& item, size_t* psize = 0) { return retrieve(key, item, psize, false); } diff --git a/source/lib/file/archive/archive_zip.cpp b/source/lib/file/archive/archive_zip.cpp index 9d19bc557b..b91ac15539 100644 --- a/source/lib/file/archive/archive_zip.cpp +++ b/source/lib/file/archive/archive_zip.cpp @@ -231,7 +231,7 @@ cassert(sizeof(ECDR) == 22); class ArchiveFile_Zip : public IArchiveFile { public: - ArchiveFile_Zip(PIFile file, off_t ofs, off_t csize, u32 checksum, ZipMethod method) + ArchiveFile_Zip(const PIFile& file, off_t ofs, off_t csize, u32 checksum, ZipMethod method) : m_file(file), m_ofs(ofs) , m_csize(csize), m_checksum(checksum), m_method((u16)method) , m_flags(NeedsFixup) @@ -248,7 +248,7 @@ public: return 'A'; } - virtual LibError Load(const std::string& UNUSED(name), shared_ptr buf, size_t size) const + virtual LibError Load(const std::string& UNUSED(name), const shared_ptr& buf, size_t size) const { AdjustOffset(); @@ -439,7 +439,7 @@ private: // search for ECDR in the last bytes of the file. // if found, fill with a copy of the (little-endian) ECDR and // return INFO::OK, otherwise IO error or ERR::CORRUPTED. - static LibError ScanForEcdr(PIFile file, off_t fileSize, u8* buf, off_t maxScanSize, size_t& cd_numEntries, off_t& cd_ofs, off_t& cd_size) + static LibError ScanForEcdr(const PIFile& file, off_t fileSize, u8* buf, off_t maxScanSize, size_t& cd_numEntries, off_t& cd_ofs, off_t& cd_size) { // don't scan more than the entire file const off_t scanSize = std::min(maxScanSize, fileSize); @@ -458,7 +458,7 @@ private: return INFO::OK; } - static LibError LocateCentralDirectory(PIFile file, off_t fileSize, off_t& cd_ofs, size_t& cd_numEntries, off_t& cd_size) + static LibError LocateCentralDirectory(const PIFile& file, off_t fileSize, off_t& cd_ofs, size_t& cd_numEntries, off_t& cd_size) { const off_t maxScanSize = 66000u; // see below shared_ptr buf = io_Allocate(maxScanSize, BLOCK_SIZE-1); // assume worst-case for alignment diff --git a/source/lib/file/archive/stream.cpp b/source/lib/file/archive/stream.cpp index f89db0c834..dc1cbc9375 100644 --- a/source/lib/file/archive/stream.cpp +++ b/source/lib/file/archive/stream.cpp @@ -82,7 +82,7 @@ bool OutputBufferManager::IsAllowableBuffer(u8* buffer, size_t size) //----------------------------------------------------------------------------- -Stream::Stream(PICodec codec) +Stream::Stream(const PICodec& codec) : m_codec(codec) , m_inConsumed(0), m_outProduced(0) { diff --git a/source/lib/file/archive/stream.h b/source/lib/file/archive/stream.h index 5e98e8426e..98a1e3c40c 100644 --- a/source/lib/file/archive/stream.h +++ b/source/lib/file/archive/stream.h @@ -62,7 +62,7 @@ private: class Stream { public: - Stream(PICodec codec); + Stream(const PICodec& codec); void SetOutputBuffer(u8* out, size_t outSize); diff --git a/source/lib/file/common/file_loader.h b/source/lib/file/common/file_loader.h index 90e084362b..6050098fe5 100644 --- a/source/lib/file/common/file_loader.h +++ b/source/lib/file/common/file_loader.h @@ -8,7 +8,7 @@ struct IFileLoader virtual size_t Precedence() const = 0; virtual char LocationCode() const = 0; - virtual LibError Load(const std::string& name, shared_ptr buf, size_t size) const = 0; + virtual LibError Load(const std::string& name, const shared_ptr& buf, size_t size) const = 0; }; typedef shared_ptr PIFileLoader; diff --git a/source/lib/file/common/real_directory.cpp b/source/lib/file/common/real_directory.cpp index d5e89e1cf6..1d9dcef7bc 100644 --- a/source/lib/file/common/real_directory.cpp +++ b/source/lib/file/common/real_directory.cpp @@ -24,7 +24,7 @@ RealDirectory::RealDirectory(const Path& path, size_t priority, int flags) } -/*virtual*/ LibError RealDirectory::Load(const std::string& name, shared_ptr buf, size_t size) const +/*virtual*/ LibError RealDirectory::Load(const std::string& name, const shared_ptr& buf, size_t size) const { PIFile file = CreateFile_Posix(); RETURN_ERR(file->Open(m_path/name, 'r')); @@ -34,7 +34,7 @@ RealDirectory::RealDirectory(const Path& path, size_t priority, int flags) } -LibError RealDirectory::Store(const std::string& name, shared_ptr fileContents, size_t size) +LibError RealDirectory::Store(const std::string& name, const shared_ptr& fileContents, size_t size) { const Path pathname(m_path/name); @@ -60,7 +60,7 @@ void RealDirectory::Watch() } -PRealDirectory CreateRealSubdirectory(PRealDirectory realDirectory, const std::string& subdirectoryName) +PRealDirectory CreateRealSubdirectory(const PRealDirectory& realDirectory, const std::string& subdirectoryName) { const Path path(realDirectory->GetPath()/subdirectoryName); return PRealDirectory(new RealDirectory(path, realDirectory->Priority(), realDirectory->Flags())); diff --git a/source/lib/file/common/real_directory.h b/source/lib/file/common/real_directory.h index 639b2971c7..b42a3b0918 100644 --- a/source/lib/file/common/real_directory.h +++ b/source/lib/file/common/real_directory.h @@ -27,9 +27,9 @@ public: // IFileLoader virtual size_t Precedence() const; virtual char LocationCode() const; - virtual LibError Load(const std::string& name, shared_ptr buf, size_t size) const; + virtual LibError Load(const std::string& name, const shared_ptr& buf, size_t size) const; - LibError Store(const std::string& name, shared_ptr fileContents, size_t size); + LibError Store(const std::string& name, const shared_ptr& fileContents, size_t size); void Watch(); @@ -53,6 +53,6 @@ private: typedef shared_ptr PRealDirectory; -extern PRealDirectory CreateRealSubdirectory(PRealDirectory realDirectory, const std::string& subdirectoryName); +extern PRealDirectory CreateRealSubdirectory(const PRealDirectory& realDirectory, const std::string& subdirectoryName); #endif // #ifndef INCLUDED_REAL_DIRECTORY diff --git a/source/lib/file/io/block_cache.cpp b/source/lib/file/io/block_cache.cpp index 5ff661d9a4..6a913e4049 100644 --- a/source/lib/file/io/block_cache.cpp +++ b/source/lib/file/io/block_cache.cpp @@ -51,7 +51,7 @@ bool BlockId::operator!=(const BlockId& rhs) const struct Block { - Block(BlockId id, shared_ptr buf) + Block(BlockId id, const shared_ptr& buf) { this->id = id; this->buf = buf; @@ -76,7 +76,7 @@ public: { } - void Add(BlockId id, shared_ptr buf) + void Add(BlockId id, const shared_ptr& buf) { if(m_blocks.size() > m_maxBlocks) { @@ -129,7 +129,7 @@ BlockCache::BlockCache(size_t numBlocks) { } -void BlockCache::Add(BlockId id, shared_ptr buf) +void BlockCache::Add(BlockId id, const shared_ptr& buf) { impl->Add(id, buf); } diff --git a/source/lib/file/io/block_cache.h b/source/lib/file/io/block_cache.h index 7e66163b82..cc7cb1d04c 100644 --- a/source/lib/file/io/block_cache.h +++ b/source/lib/file/io/block_cache.h @@ -56,7 +56,7 @@ public: * satisfy subsequent Retrieve calls for the same id. * if CONFIG2_CACHE_READ_ONLY, the memory is made read-only. **/ - void Add(BlockId id, shared_ptr buf); + void Add(BlockId id, const shared_ptr& buf); /** * Attempt to retrieve a block's contents. diff --git a/source/lib/file/io/io.cpp b/source/lib/file/io/io.cpp index bdb61b2ec8..bd06f32411 100644 --- a/source/lib/file/io/io.cpp +++ b/source/lib/file/io/io.cpp @@ -114,7 +114,7 @@ shared_ptr io_Allocate(size_t size, off_t ofs) class BlockIo { public: - LibError Issue(PIFile file, off_t alignedOfs, u8* alignedBuf) + LibError Issue(const PIFile& file, off_t alignedOfs, u8* alignedBuf) { m_file = file; m_blockId = BlockId(file->Pathname(), alignedOfs); @@ -210,7 +210,7 @@ public: m_misalignment = ofs - m_alignedOfs; } - LibError Run(PIFile file, IoCallback cb = 0, uintptr_t cbData = 0) + LibError Run(const PIFile& file, IoCallback cb = 0, uintptr_t cbData = 0) { ScopedIoMonitor monitor; @@ -289,7 +289,7 @@ private: }; -LibError io_Scan(PIFile file, off_t ofs, off_t size, IoCallback cb, uintptr_t cbData) +LibError io_Scan(const PIFile& file, off_t ofs, off_t size, IoCallback cb, uintptr_t cbData) { u8* alignedBuf = 0; // use temporary block buffers IoSplitter splitter(ofs, alignedBuf, size); @@ -297,7 +297,7 @@ LibError io_Scan(PIFile file, off_t ofs, off_t size, IoCallback cb, uintptr_t cb } -LibError io_Read(PIFile file, off_t ofs, u8* alignedBuf, size_t size, u8*& data) +LibError io_Read(const PIFile& file, off_t ofs, u8* alignedBuf, size_t size, u8*& data) { IoSplitter splitter(ofs, alignedBuf, (off_t)size); RETURN_ERR(splitter.Run(file)); @@ -306,7 +306,7 @@ LibError io_Read(PIFile file, off_t ofs, u8* alignedBuf, size_t size, u8*& data) } -LibError io_WriteAligned(PIFile file, off_t alignedOfs, const u8* alignedData, size_t size) +LibError io_WriteAligned(const PIFile& file, off_t alignedOfs, const u8* alignedData, size_t size) { debug_assert(IsAligned_Offset(alignedOfs)); debug_assert(IsAligned_Data(alignedData)); @@ -316,7 +316,7 @@ LibError io_WriteAligned(PIFile file, off_t alignedOfs, const u8* alignedData, s } -LibError io_ReadAligned(PIFile file, off_t alignedOfs, u8* alignedBuf, size_t size) +LibError io_ReadAligned(const PIFile& file, off_t alignedOfs, u8* alignedBuf, size_t size) { debug_assert(IsAligned_Offset(alignedOfs)); debug_assert(IsAligned_Data(alignedBuf)); diff --git a/source/lib/file/io/io.h b/source/lib/file/io/io.h index 79f4281b0f..8806171747 100644 --- a/source/lib/file/io/io.h +++ b/source/lib/file/io/io.h @@ -28,11 +28,11 @@ LIB_API shared_ptr io_Allocate(size_t size, off_t ofs = 0); **/ typedef LibError (*IoCallback)(uintptr_t cbData, const u8* block, size_t blockSize); -LIB_API LibError io_Scan(PIFile file, off_t ofs, off_t size, IoCallback cb, uintptr_t cbData); +LIB_API LibError io_Scan(const PIFile& file, off_t ofs, off_t size, IoCallback cb, uintptr_t cbData); -LIB_API LibError io_Read(PIFile file, off_t ofs, u8* alignedBuf, size_t size, u8*& data); +LIB_API LibError io_Read(const PIFile& file, off_t ofs, u8* alignedBuf, size_t size, u8*& data); -LIB_API LibError io_WriteAligned(PIFile file, off_t alignedOfs, const u8* alignedData, size_t size); -LIB_API LibError io_ReadAligned(PIFile file, off_t alignedOfs, u8* alignedBuf, size_t size); +LIB_API LibError io_WriteAligned(const PIFile& file, off_t alignedOfs, const u8* alignedData, size_t size); +LIB_API LibError io_ReadAligned(const PIFile& file, off_t alignedOfs, u8* alignedBuf, size_t size); #endif // #ifndef INCLUDED_IO diff --git a/source/lib/file/io/write_buffer.cpp b/source/lib/file/io/write_buffer.cpp index 7bed880b05..61ec97eedf 100644 --- a/source/lib/file/io/write_buffer.cpp +++ b/source/lib/file/io/write_buffer.cpp @@ -39,7 +39,7 @@ void WriteBuffer::Overwrite(const void* data, size_t size, size_t offset) // UnalignedWriter //----------------------------------------------------------------------------- -UnalignedWriter::UnalignedWriter(PIFile file, off_t ofs) +UnalignedWriter::UnalignedWriter(const PIFile& file, off_t ofs) : m_file(file), m_alignedBuf(io_Allocate(BLOCK_SIZE)) { m_alignedOfs = AlignedOffset(ofs); diff --git a/source/lib/file/io/write_buffer.h b/source/lib/file/io/write_buffer.h index cde4b9accf..c036a2bccf 100644 --- a/source/lib/file/io/write_buffer.h +++ b/source/lib/file/io/write_buffer.h @@ -32,7 +32,7 @@ private: class UnalignedWriter : public noncopyable { public: - UnalignedWriter(PIFile file, off_t ofs); + UnalignedWriter(const PIFile& file, off_t ofs); ~UnalignedWriter(); /** diff --git a/source/lib/file/vfs/file_cache.cpp b/source/lib/file/vfs/file_cache.cpp index 7b89fdb553..831de77893 100644 --- a/source/lib/file/vfs/file_cache.cpp +++ b/source/lib/file/vfs/file_cache.cpp @@ -55,7 +55,7 @@ typedef shared_ptr PAllocator; class FileCacheDeleter { public: - FileCacheDeleter(size_t size, PAllocator allocator) + FileCacheDeleter(size_t size, const PAllocator& allocator) : m_size(size), m_allocator(allocator) { } @@ -78,7 +78,7 @@ public: { } - shared_ptr Allocate(size_t size, PAllocator pthis) + shared_ptr Allocate(size_t size, const PAllocator& pthis) { const size_t alignedSize = round_up(size, BLOCK_SIZE); @@ -171,7 +171,7 @@ public: } } - void Add(const VfsPath& pathname, shared_ptr data, size_t size, size_t cost) + void Add(const VfsPath& pathname, const shared_ptr& data, size_t size, size_t cost) { // zero-copy cache => all users share the contents => must not // allow changes. this will be reverted when deallocating. @@ -217,7 +217,7 @@ shared_ptr FileCache::Reserve(size_t size) return impl->Reserve(size); } -void FileCache::Add(const VfsPath& pathname, shared_ptr data, size_t size, size_t cost) +void FileCache::Add(const VfsPath& pathname, const shared_ptr& data, size_t size, size_t cost) { impl->Add(pathname, data, size, cost); } diff --git a/source/lib/file/vfs/file_cache.h b/source/lib/file/vfs/file_cache.h index bc9239a523..b0c70254b2 100644 --- a/source/lib/file/vfs/file_cache.h +++ b/source/lib/file/vfs/file_cache.h @@ -61,7 +61,7 @@ public: * @param cost is the expected cost of retrieving the file again and * influences how/when it is evicted from the cache. **/ - void Add(const VfsPath& pathname, shared_ptr data, size_t size, size_t cost = 1); + void Add(const VfsPath& pathname, const shared_ptr& data, size_t size, size_t cost = 1); /** * Remove a file's contents from the cache (if it exists). diff --git a/source/lib/file/vfs/vfs.cpp b/source/lib/file/vfs/vfs.cpp index 3309846516..9e7b379e60 100644 --- a/source/lib/file/vfs/vfs.cpp +++ b/source/lib/file/vfs/vfs.cpp @@ -65,12 +65,12 @@ public: // note: only allowing either reads or writes simplifies file cache // coherency (need only invalidate when closing a FILE_WRITE file). - virtual LibError CreateFile(const VfsPath& pathname, shared_ptr fileContents, size_t size) + virtual LibError CreateFile(const VfsPath& pathname, const shared_ptr& fileContents, size_t size) { VfsDirectory* directory; CHECK_ERR(vfs_Lookup(pathname, &m_rootDirectory, directory, 0, VFS_LOOKUP_ADD|VFS_LOOKUP_CREATE)); - PRealDirectory realDirectory = directory->AssociatedDirectory(); + const PRealDirectory& realDirectory = directory->AssociatedDirectory(); const std::string& name = pathname.leaf(); RETURN_ERR(realDirectory->Store(name, fileContents, size)); @@ -146,7 +146,7 @@ public: { VfsDirectory* directory; CHECK_ERR(vfs_Lookup(pathname, &m_rootDirectory, directory, 0)); - PRealDirectory realDirectory = directory->AssociatedDirectory(); + const PRealDirectory& realDirectory = directory->AssociatedDirectory(); realPathname = realDirectory->GetPath() / pathname.leaf(); return INFO::OK; } diff --git a/source/lib/file/vfs/vfs.h b/source/lib/file/vfs/vfs.h index db8219157f..abe1593331 100644 --- a/source/lib/file/vfs/vfs.h +++ b/source/lib/file/vfs/vfs.h @@ -85,7 +85,7 @@ struct IVFS * rationale: disallowing partial writes simplifies file cache coherency * (need only be invalidated when closing a FILE_WRITE file). **/ - virtual LibError CreateFile(const VfsPath& pathname, shared_ptr fileContents, size_t size) = 0; + virtual LibError CreateFile(const VfsPath& pathname, const shared_ptr& fileContents, size_t size) = 0; /** * read an entire file into memory. diff --git a/source/lib/file/vfs/vfs_lookup.cpp b/source/lib/file/vfs/vfs_lookup.cpp index ae2c1922af..fe30fabf66 100644 --- a/source/lib/file/vfs/vfs_lookup.cpp +++ b/source/lib/file/vfs/vfs_lookup.cpp @@ -32,7 +32,7 @@ static size_t s_numArchivedFiles; class PopulateHelper : noncopyable { public: - PopulateHelper(VfsDirectory* directory, PRealDirectory realDirectory) + PopulateHelper(VfsDirectory* directory, const PRealDirectory& realDirectory) : m_directory(directory), m_realDirectory(realDirectory) { } @@ -121,7 +121,7 @@ static LibError Populate(VfsDirectory* directory) if(!directory->ShouldPopulate()) return INFO::OK; - PRealDirectory realDirectory = directory->AssociatedDirectory(); + const PRealDirectory& realDirectory = directory->AssociatedDirectory(); if(realDirectory->Flags() & VFS_MOUNT_WATCH) realDirectory->Watch(); diff --git a/source/lib/file/vfs/vfs_tree.cpp b/source/lib/file/vfs/vfs_tree.cpp index 31643bd779..d7c82fc345 100644 --- a/source/lib/file/vfs/vfs_tree.cpp +++ b/source/lib/file/vfs/vfs_tree.cpp @@ -17,7 +17,7 @@ //----------------------------------------------------------------------------- -VfsFile::VfsFile(const std::string& name, off_t size, time_t mtime, size_t priority, PIFileLoader loader) +VfsFile::VfsFile(const std::string& name, off_t size, time_t mtime, size_t priority, const PIFileLoader& loader) : m_name(name), m_size(size), m_mtime(mtime), m_priority(priority), m_loader(loader) { } @@ -62,7 +62,7 @@ void VfsFile::GenerateDescription(char* text, size_t maxChars) const } -LibError VfsFile::Load(shared_ptr buf) const +LibError VfsFile::Load(const shared_ptr& buf) const { return m_loader->Load(Name(), buf, Size()); } diff --git a/source/lib/file/vfs/vfs_tree.h b/source/lib/file/vfs/vfs_tree.h index 0ad1993be0..008ebbf97e 100644 --- a/source/lib/file/vfs/vfs_tree.h +++ b/source/lib/file/vfs/vfs_tree.h @@ -18,7 +18,7 @@ class VfsFile { public: - VfsFile(const std::string& name, off_t size, time_t mtime, size_t priority, PIFileLoader provider); + VfsFile(const std::string& name, off_t size, time_t mtime, size_t priority, const PIFileLoader& provider); const std::string& Name() const { @@ -39,7 +39,7 @@ public: void GenerateDescription(char* text, size_t maxChars) const; - LibError Load(shared_ptr buf) const; + LibError Load(const shared_ptr& buf) const; private: std::string m_name; @@ -80,7 +80,7 @@ public: void Attach(const PRealDirectory& realDirectory); - PRealDirectory AssociatedDirectory() const + const PRealDirectory& AssociatedDirectory() const { return m_realDirectory; } diff --git a/source/lib/tex/tex.cpp b/source/lib/tex/tex.cpp index f828605e26..5d51cf17f8 100644 --- a/source/lib/tex/tex.cpp +++ b/source/lib/tex/tex.cpp @@ -496,7 +496,7 @@ bool tex_is_known_extension(const char* filename) // // we need only add bookkeeping information and "wrap" it in // our Tex struct, hence the name. -LibError tex_wrap(size_t w, size_t h, size_t bpp, int flags, shared_ptr data, size_t ofs, Tex* t) +LibError tex_wrap(size_t w, size_t h, size_t bpp, int flags, const shared_ptr& data, size_t ofs, Tex* t) { t->w = w; t->h = h; @@ -587,7 +587,7 @@ size_t tex_hdr_size(const VfsPath& filename) // read/write from memory and disk //----------------------------------------------------------------------------- -LibError tex_decode(shared_ptr data, size_t data_size, Tex* t) +LibError tex_decode(const shared_ptr& data, size_t data_size, Tex* t) { const TexCodecVTbl* c; RETURN_ERR(tex_codec_for_header(data.get(), data_size, &c)); diff --git a/source/lib/tex/tex.h b/source/lib/tex/tex.h index 8b54613da7..3b37f46272 100644 --- a/source/lib/tex/tex.h +++ b/source/lib/tex/tex.h @@ -255,7 +255,7 @@ extern void tex_codec_register_all(); * @param t output texture object. * @return LibError. **/ -extern LibError tex_decode(shared_ptr data, size_t data_size, Tex* t); +extern LibError tex_decode(const shared_ptr& data, size_t data_size, Tex* t); /** * encode a texture into a memory buffer in the desired file format. @@ -291,7 +291,7 @@ extern LibError tex_encode(Tex* t, const std::string& extension, DynArray* da); * @param t output texture object. * @return LibError **/ -extern LibError tex_wrap(size_t w, size_t h, size_t bpp, int flags, shared_ptr data, size_t ofs, Tex* t); +extern LibError tex_wrap(size_t w, size_t h, size_t bpp, int flags, const shared_ptr& data, size_t ofs, Tex* t); /** * free all resources associated with the image and make further diff --git a/source/ps/XML/Xeromyces.cpp b/source/ps/XML/Xeromyces.cpp index 27ce173287..d54dd533f7 100644 --- a/source/ps/XML/Xeromyces.cpp +++ b/source/ps/XML/Xeromyces.cpp @@ -98,7 +98,7 @@ void CXeromyces::Terminate() // Find out write location of the XMB file corresponding to xmlFilename -void CXeromyces::GetXMBPath(PIVFS vfs, const VfsPath& xmlFilename, const VfsPath& xmbFilename, VfsPath& xmbActualPath) +void CXeromyces::GetXMBPath(const PIVFS& vfs, const VfsPath& xmlFilename, const VfsPath& xmbFilename, VfsPath& xmbActualPath) { // rationale: // - it is necessary to write out XMB files into a subdirectory diff --git a/source/ps/XML/Xeromyces.h b/source/ps/XML/Xeromyces.h index f816125dec..59a2b68e53 100644 --- a/source/ps/XML/Xeromyces.h +++ b/source/ps/XML/Xeromyces.h @@ -31,7 +31,7 @@ public: private: // Find out write location of the XMB file corresponding to xmlFilename - static void GetXMBPath(PIVFS vfs, const VfsPath& xmlFilename, const VfsPath& xmbFilename, VfsPath& xmbActualPath); + static void GetXMBPath(const PIVFS& vfs, const VfsPath& xmlFilename, const VfsPath& xmbFilename, VfsPath& xmbActualPath); bool ReadXMBFile(const VfsPath& filename); diff --git a/source/renderer/FixedFunctionModelRenderer.cpp b/source/renderer/FixedFunctionModelRenderer.cpp index f06d95ec1a..410b797107 100644 --- a/source/renderer/FixedFunctionModelRenderer.cpp +++ b/source/renderer/FixedFunctionModelRenderer.cpp @@ -41,12 +41,12 @@ struct FFModelDef : public CModelDefRPrivate /// UV coordinates are stored in the static array VertexArray::Attribute m_UV; - FFModelDef(CModelDefPtr mdef); + FFModelDef(const CModelDefPtr& mdef); ~FFModelDef() { delete[] m_Indices; } }; -FFModelDef::FFModelDef(CModelDefPtr mdef) +FFModelDef::FFModelDef(const CModelDefPtr& mdef) : m_Array(false) { size_t numVertices = mdef->GetNumVertices(); @@ -230,7 +230,7 @@ void FixedFunctionModelRenderer::EndPass(int streamflags) // Prepare UV coordinates for this modeldef -void FixedFunctionModelRenderer::PrepareModelDef(int streamflags, CModelDefPtr def) +void FixedFunctionModelRenderer::PrepareModelDef(int streamflags, const CModelDefPtr& def) { m->ffmodeldef = (FFModelDef*)def->GetRenderData(m); @@ -279,5 +279,3 @@ void FixedFunctionModelRenderer::RenderModel(int streamflags, CModel* model, voi g_Renderer.m_Stats.m_DrawCalls++; g_Renderer.m_Stats.m_ModelTris += numFaces; } - - diff --git a/source/renderer/FixedFunctionModelRenderer.h b/source/renderer/FixedFunctionModelRenderer.h index de20d41896..0f9a41998c 100644 --- a/source/renderer/FixedFunctionModelRenderer.h +++ b/source/renderer/FixedFunctionModelRenderer.h @@ -37,7 +37,7 @@ public: void BeginPass(int streamflags, const CMatrix3D* texturematrix); void EndPass(int streamflags); - void PrepareModelDef(int streamflags, CModelDefPtr def); + void PrepareModelDef(int streamflags, const CModelDefPtr& def); void RenderModel(int streamflags, CModel* model, void* data); private: diff --git a/source/renderer/HWLightingModelRenderer.cpp b/source/renderer/HWLightingModelRenderer.cpp index d0e999a4aa..b099eb0c93 100644 --- a/source/renderer/HWLightingModelRenderer.cpp +++ b/source/renderer/HWLightingModelRenderer.cpp @@ -39,12 +39,12 @@ struct HWLModelDef : public CModelDefRPrivate u16* m_Indices; - HWLModelDef(CModelDefPtr mdef); + HWLModelDef(const CModelDefPtr& mdef); ~HWLModelDef() { delete[] m_Indices; } }; -HWLModelDef::HWLModelDef(CModelDefPtr mdef) +HWLModelDef::HWLModelDef(const CModelDefPtr& mdef) { m_Indices = new u16[mdef->GetNumFaces()*3]; ModelRenderer::BuildIndices(mdef, m_Indices); @@ -272,7 +272,7 @@ void HWLightingModelRenderer::EndPass(int streamflags) // Prepare UV coordinates for this modeldef -void HWLightingModelRenderer::PrepareModelDef(int UNUSED(streamflags), CModelDefPtr def) +void HWLightingModelRenderer::PrepareModelDef(int UNUSED(streamflags), const CModelDefPtr& def) { m->hwlmodeldef = (HWLModelDef*)def->GetRenderData(m); diff --git a/source/renderer/HWLightingModelRenderer.h b/source/renderer/HWLightingModelRenderer.h index 87e73275fa..dc60f028c0 100644 --- a/source/renderer/HWLightingModelRenderer.h +++ b/source/renderer/HWLightingModelRenderer.h @@ -40,7 +40,7 @@ public: void BeginPass(int streamflags, const CMatrix3D* texturematrix); void EndPass(int streamflags); - void PrepareModelDef(int streamflags, CModelDefPtr def); + void PrepareModelDef(int streamflags, const CModelDefPtr& def); void RenderModel(int streamflags, CModel* model, void* data); /** diff --git a/source/renderer/InstancingModelRenderer.cpp b/source/renderer/InstancingModelRenderer.cpp index 82d813804e..5975a5dec6 100644 --- a/source/renderer/InstancingModelRenderer.cpp +++ b/source/renderer/InstancingModelRenderer.cpp @@ -47,12 +47,12 @@ struct IModelDef : public CModelDefRPrivate u16* m_Indices; - IModelDef(CModelDefPtr mdef); + IModelDef(const CModelDefPtr& mdef); ~IModelDef() { delete[] m_Indices; } }; -IModelDef::IModelDef(CModelDefPtr mdef) +IModelDef::IModelDef(const CModelDefPtr& mdef) : m_Array(false) { size_t numVertices = mdef->GetNumVertices(); @@ -222,7 +222,7 @@ void InstancingModelRenderer::EndPass(int streamflags) // Prepare UV coordinates for this modeldef -void InstancingModelRenderer::PrepareModelDef(int streamflags, CModelDefPtr def) +void InstancingModelRenderer::PrepareModelDef(int streamflags, const CModelDefPtr& def) { m->imodeldef = (IModelDef*)def->GetRenderData(m); diff --git a/source/renderer/InstancingModelRenderer.h b/source/renderer/InstancingModelRenderer.h index c8458c78f1..3adae18a07 100644 --- a/source/renderer/InstancingModelRenderer.h +++ b/source/renderer/InstancingModelRenderer.h @@ -40,7 +40,7 @@ public: void BeginPass(int streamflags, const CMatrix3D* texturematrix); void EndPass(int streamflags); - void PrepareModelDef(int streamflags, CModelDefPtr def); + void PrepareModelDef(int streamflags, const CModelDefPtr& def); void RenderModel(int streamflags, CModel* model, void* data); /** diff --git a/source/renderer/ModelRenderer.cpp b/source/renderer/ModelRenderer.cpp index d45d1f4442..dd431ecb2f 100644 --- a/source/renderer/ModelRenderer.cpp +++ b/source/renderer/ModelRenderer.cpp @@ -35,9 +35,9 @@ // Helper function to copy object-space position and normal vectors into arrays. void ModelRenderer::CopyPositionAndNormals( - CModelDefPtr mdef, - VertexArrayIterator Position, - VertexArrayIterator Normal) + const CModelDefPtr& mdef, + const VertexArrayIterator& Position, + const VertexArrayIterator& Normal) { size_t numVertices = mdef->GetNumVertices(); SModelVertex* vertices = mdef->GetVertices(); @@ -52,8 +52,8 @@ void ModelRenderer::CopyPositionAndNormals( // Helper function to transform position and normal vectors into world-space. void ModelRenderer::BuildPositionAndNormals( CModel* model, - VertexArrayIterator Position, - VertexArrayIterator Normal) + const VertexArrayIterator& Position, + const VertexArrayIterator& Normal) { CModelDefPtr mdef = model->GetModelDef(); size_t numVertices = mdef->GetNumVertices(); @@ -96,8 +96,8 @@ void ModelRenderer::BuildPositionAndNormals( // Helper function for lighting void ModelRenderer::BuildColor4ub( CModel* model, - VertexArrayIterator Normal, - VertexArrayIterator Color, + const VertexArrayIterator& Normal, + const VertexArrayIterator& Color, bool onlyDiffuse) { PROFILE( "lighting vertices" ); @@ -135,23 +135,23 @@ void ModelRenderer::BuildColor4ub( // Copy UV coordinates void ModelRenderer::BuildUV( - CModelDefPtr mdef, - VertexArrayIterator UV) + const CModelDefPtr& mdef, + const VertexArrayIterator& UV) { size_t numVertices = mdef->GetNumVertices(); SModelVertex* vertices = mdef->GetVertices(); - for (size_t j=0; j < numVertices; ++j, ++UV) + for (size_t j=0; j < numVertices; ++j) { - (*UV)[0] = vertices[j].m_U; - (*UV)[1] = 1.0-vertices[j].m_V; + UV[j][0] = vertices[j].m_U; + UV[j][1] = 1.0-vertices[j].m_V; } } // Build default indices array. void ModelRenderer::BuildIndices( - CModelDefPtr mdef, + const CModelDefPtr& mdef, u16* Indices) { size_t idxidx = 0; @@ -209,7 +209,7 @@ struct BMRModelData : public CModelRData */ struct BMRModelDefTracker : public CModelDefRPrivate { - BMRModelDefTracker(CModelDefPtr mdef) + BMRModelDefTracker(const CModelDefPtr& mdef) : m_ModelDef(mdef), m_Next(0), m_Slots(0) { } /// Back-link to the CModelDef object @@ -258,7 +258,7 @@ struct BatchModelRendererInternals vertexRenderer->DestroyModelData(model, data); } - void RenderAllModels(RenderModifierPtr modifier, int filterflags, int pass, int streamflags); + void RenderAllModels(const RenderModifierPtr& modifier, int filterflags, int pass, int streamflags); }; BMRModelData::~BMRModelData() @@ -406,7 +406,7 @@ bool BatchModelRenderer::HaveSubmissions() // Render models, outer loop for multi-passing -void BatchModelRenderer::Render(RenderModifierPtr modifier, int flags) +void BatchModelRenderer::Render(const RenderModifierPtr& modifier, int flags) { debug_assert(m->phase == BMRRender); @@ -434,7 +434,7 @@ void BatchModelRenderer::Render(RenderModifierPtr modifier, int flags) // Render one frame worth of models void BatchModelRendererInternals::RenderAllModels( - RenderModifierPtr modifier, int filterflags, + const RenderModifierPtr& modifier, int filterflags, int pass, int streamflags) { for(BMRModelDefTracker* mdeftracker = submissions; mdeftracker; mdeftracker = mdeftracker->m_Next) diff --git a/source/renderer/ModelRenderer.h b/source/renderer/ModelRenderer.h index 841e678fbf..58920fbb9c 100644 --- a/source/renderer/ModelRenderer.h +++ b/source/renderer/ModelRenderer.h @@ -153,7 +153,7 @@ public: * If flags is non-zero, only models that contain flags in their * CModel::GetFlags() are rendered. */ - virtual void Render(RenderModifierPtr modifier, int flags) = 0; + virtual void Render(const RenderModifierPtr& modifier, int flags) = 0; /** * CopyPositionAndNormals: Copy unanimated object-space vertices and @@ -168,9 +168,9 @@ public: * The array behind the iterator must be as large as the Position array. */ static void CopyPositionAndNormals( - CModelDefPtr mdef, - VertexArrayIterator Position, - VertexArrayIterator Normal); + const CModelDefPtr& mdef, + const VertexArrayIterator& Position, + const VertexArrayIterator& Normal); /** * BuildPositionAndNormals: Build animated vertices and normals, @@ -187,8 +187,8 @@ public: */ static void BuildPositionAndNormals( CModel* model, - VertexArrayIterator Position, - VertexArrayIterator Normal); + const VertexArrayIterator& Position, + const VertexArrayIterator& Normal); /** * BuildColor4ub: Build lighting colors for the given model, @@ -205,8 +205,8 @@ public: */ static void BuildColor4ub( CModel* model, - VertexArrayIterator Normal, - VertexArrayIterator Color, + const VertexArrayIterator& Normal, + const VertexArrayIterator& Color, bool onlyDiffuse); /** @@ -218,8 +218,8 @@ public: * mdef->GetNumVertices() vertices. */ static void BuildUV( - CModelDefPtr mdef, - VertexArrayIterator UV); + const CModelDefPtr& mdef, + const VertexArrayIterator& UV); /** * BuildIndices: Create the indices array for the given CModelDef. @@ -229,7 +229,7 @@ public: * mdef->GetNumFaces()*3 elements. */ static void BuildIndices( - CModelDefPtr mdef, + const CModelDefPtr& mdef, u16* Indices); }; @@ -257,7 +257,7 @@ public: virtual void PrepareModels(); virtual void EndFrame(); virtual bool HaveSubmissions(); - virtual void Render(RenderModifierPtr modifier, int flags); + virtual void Render(const RenderModifierPtr& modifier, int flags); private: BatchModelRendererInternals* m; diff --git a/source/renderer/ModelVertexRenderer.h b/source/renderer/ModelVertexRenderer.h index c0aea48338..788881b6e9 100644 --- a/source/renderer/ModelVertexRenderer.h +++ b/source/renderer/ModelVertexRenderer.h @@ -137,7 +137,7 @@ public: * BeginPass. * @param def The model definition. */ - virtual void PrepareModelDef(int streamflags, CModelDefPtr def) = 0; + virtual void PrepareModelDef(int streamflags, const CModelDefPtr& def) = 0; /** diff --git a/source/renderer/TransparencyRenderer.cpp b/source/renderer/TransparencyRenderer.cpp index 74100132a6..12db90dfc2 100644 --- a/source/renderer/TransparencyRenderer.cpp +++ b/source/renderer/TransparencyRenderer.cpp @@ -39,7 +39,7 @@ */ struct PSModelDef : public CModelDefRPrivate { - PSModelDef(CModelDefPtr mdef); + PSModelDef(const CModelDefPtr& mdef); /// Static vertex array VertexArray m_Array; @@ -48,7 +48,7 @@ struct PSModelDef : public CModelDefRPrivate VertexArray::Attribute m_UV; }; -PSModelDef::PSModelDef(CModelDefPtr mdef) +PSModelDef::PSModelDef(const CModelDefPtr& mdef) : m_Array(false) { m_UV.type = GL_FLOAT; @@ -315,7 +315,7 @@ void PolygonSortModelRenderer::EndPass(int streamflags) // Prepare for rendering models using this CModelDef -void PolygonSortModelRenderer::PrepareModelDef(int streamflags, CModelDefPtr def) +void PolygonSortModelRenderer::PrepareModelDef(int streamflags, const CModelDefPtr& def) { if (streamflags & STREAM_UV0) { @@ -510,7 +510,7 @@ bool SortModelRenderer::HaveSubmissions() // Render submitted models (filtered by flags) using the given modifier -void SortModelRenderer::Render(RenderModifierPtr modifier, int flags) +void SortModelRenderer::Render(const RenderModifierPtr& modifier, int flags) { int pass = 0; diff --git a/source/renderer/TransparencyRenderer.h b/source/renderer/TransparencyRenderer.h index e081268861..ab17f3f70d 100644 --- a/source/renderer/TransparencyRenderer.h +++ b/source/renderer/TransparencyRenderer.h @@ -39,7 +39,7 @@ public: void BeginPass(int streamflags, const CMatrix3D* texturematrix); void EndPass(int streamflags); - void PrepareModelDef(int streamflags, CModelDefPtr def); + void PrepareModelDef(int streamflags, const CModelDefPtr& def); void RenderModel(int streamflags, CModel* model, void* data); private: @@ -72,7 +72,7 @@ public: void PrepareModels(); void EndFrame(); bool HaveSubmissions(); - void Render(RenderModifierPtr modifier, int flags); + void Render(const RenderModifierPtr& modifier, int flags); private: SortModelRendererInternals* m;