diff options
| author | ModMaker101 <119018978+ModMaker101@users.noreply.github.com> | 2026-03-08 19:08:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-08 18:08:36 -0500 |
| commit | 28614b922fb77149a54da1a87bebfbc98736f296 (patch) | |
| tree | 7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.World/IntCache.cpp | |
| parent | 88798b501d0cf6287b6f87acb2592676e3cec58d (diff) | |
Modernize project codebase (#906)
* Fixed boats falling and a TP glitch #266
* Replaced every C-style cast with C++ ones
* Replaced every C-style cast with C++ ones
* Fixed boats falling and a TP glitch #266
* Updated NULL to nullptr and fixing some type issues
* Modernized and fixed a few bugs
- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.
* Fixing more conflicts
* Replace int loops with size_t and start work on overrides
* Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.World/IntCache.cpp')
| -rw-r--r-- | Minecraft.World/IntCache.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Minecraft.World/IntCache.cpp b/Minecraft.World/IntCache.cpp index 174d01d3..cd980d16 100644 --- a/Minecraft.World/IntCache.cpp +++ b/Minecraft.World/IntCache.cpp @@ -28,7 +28,7 @@ IntCache::ThreadStorage::~ThreadStorage() { delete [] allocated[i].data; } - for( int i = 0; i < toosmall.size(); i++ ) + for( size_t i = 0; i < toosmall.size(); i++ ) { delete [] toosmall[i].data; } @@ -36,7 +36,7 @@ IntCache::ThreadStorage::~ThreadStorage() void IntCache::ReleaseThreadStorage() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx)); delete tls; @@ -44,13 +44,13 @@ void IntCache::ReleaseThreadStorage() intArray IntCache::allocate(int size) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx)); if (size <= TINY_CUTOFF) { if (tls->tcache.empty()) { - intArray result = intArray(TINY_CUTOFF, true); + intArray result = intArray(static_cast<unsigned int>(TINY_CUTOFF), true); tls->tallocated.push_back(result); return result; } @@ -76,7 +76,7 @@ intArray IntCache::allocate(int size) tls->cache.clear(); tls->allocated.clear(); - intArray result = intArray(tls->maxSize, true); + intArray result = intArray(static_cast<unsigned int>(tls->maxSize), true); tls->allocated.push_back(result); return result; } @@ -84,7 +84,7 @@ intArray IntCache::allocate(int size) { if (tls->cache.empty()) { - intArray result = intArray(tls->maxSize, true); + intArray result = intArray(static_cast<unsigned int>(tls->maxSize), true); tls->allocated.push_back(result); return result; } @@ -100,10 +100,10 @@ intArray IntCache::allocate(int size) void IntCache::releaseAll() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx)); // 4J - added - we can now remove the vectors that were deemed as too small (see comment in IntCache::allocate) - for( int i = 0; i < tls->toosmall.size(); i++ ) + for( size_t i = 0; i < tls->toosmall.size(); i++ ) { delete [] tls->toosmall[i].data; } @@ -130,27 +130,27 @@ void IntCache::releaseAll() // 4J added so that we can fully reset between levels void IntCache::Reset() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx)); tls->maxSize = TINY_CUTOFF; - for( int i = 0; i < tls->allocated.size(); i++ ) + for( size_t i = 0; i < tls->allocated.size(); i++ ) { delete [] tls->allocated[i].data; } tls->allocated.clear(); - for( int i = 0; i < tls->cache.size(); i++ ) + for( size_t i = 0; i < tls->cache.size(); i++ ) { delete [] tls->cache[i].data; } tls->cache.clear(); - for( int i = 0; i < tls->tallocated.size(); i++ ) + for( size_t i = 0; i < tls->tallocated.size(); i++ ) { delete [] tls->tallocated[i].data; } tls->tallocated.clear(); - for( int i = 0; i < tls->tcache.size(); i++ ) + for( size_t i = 0; i < tls->tcache.size(); i++ ) { delete [] tls->tcache[i].data; } |
