Skip to content

Commit

Permalink
code maint
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Dec 1, 2018
1 parent 49baed2 commit 58de944
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
28 changes: 9 additions & 19 deletions src/RageTextureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <map>

RageTextureManager* TEXTUREMAN =
NULL; // global and accessible from anywhere in our program
nullptr; // global and accessible from anywhere in our program

namespace {
map<RageTextureID, RageTexture*> m_mapPathToTexture;
Expand Down Expand Up @@ -74,9 +74,8 @@ RageTextureManager::Update(float fDeltaTime)
}
}

FOREACHM(RageTextureID, RageTexture*, m_textures_to_update, i)
{
RageTexture* pTexture = i->second;
for (auto& id : m_textures_to_update) {
RageTexture* pTexture = id.second;
pTexture->Update(fDeltaTime);
}
}
Expand Down Expand Up @@ -108,9 +107,7 @@ RageTextureManager::RegisterTexture(RageTextureID ID, RageTexture* pTexture)

/* Make sure we don't already have a texture with this ID. If we do, the
* caller should have used it. */
std::map<RageTextureID, RageTexture*>::iterator p =
m_mapPathToTexture.find(ID);
if (p != m_mapPathToTexture.end()) {
if (m_mapPathToTexture.count(ID) == 1) {
/* Oops, found the texture. */
RageException::Throw("Custom texture \"%s\" already registered!",
ID.filename.c_str());
Expand Down Expand Up @@ -234,7 +231,7 @@ RageTextureManager::VolatileTexture(const RageTextureID& ID)
void
RageTextureManager::UnloadTexture(RageTexture* t)
{
if (t == NULL)
if (t == nullptr)
return;

t->m_iRefCount--;
Expand Down Expand Up @@ -314,14 +311,8 @@ RageTextureManager::GarbageCollect(GCType type)
if (PREFSMAN->m_verbose_log > 1)
LOG->Trace("Performing texture garbage collection.");

for (std::map<RageTextureID, RageTexture*>::iterator i =
m_mapPathToTexture.begin();
i != m_mapPathToTexture.end();) {
std::map<RageTextureID, RageTexture*>::iterator j = i;
i++;

RString sPath = j->first.filename;
RageTexture* t = j->second;
for (auto ID : m_mapPathToTexture) {
RageTexture* t = ID.second;

if (t->m_iRefCount)
continue; /* Can't unload textures that are still referenced. */
Expand Down Expand Up @@ -368,9 +359,8 @@ RageTextureManager::ReloadAll()
* ton of cached data that we're not necessarily going to use. */
DoDelayedDelete();

FOREACHM(RageTextureID, RageTexture*, m_mapPathToTexture, i)
{
i->second->Reload();
for (auto ID : m_mapPathToTexture) {
ID.second->Reload();
}

EnableOddDimensionWarning();
Expand Down
2 changes: 1 addition & 1 deletion src/RageTextureManager.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* RageTextureManager - Interface for loading textures. */
/* RageTextureManager - Interface for loading textures. */

#ifndef RAGE_TEXTURE_MANAGER_H
#define RAGE_TEXTURE_MANAGER_H
Expand Down

0 comments on commit 58de944

Please sign in to comment.