Skip to content

Commit

Permalink
Upgrade to C++14
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Jan 4, 2019
1 parent 4b5b0f0 commit f33510a
Show file tree
Hide file tree
Showing 36 changed files with 855 additions and 851 deletions.
310 changes: 155 additions & 155 deletions CDebug.cpp

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ CGame::CGame()

msWait = 0;

Surf_Display = NULL;
Surf_DisplayGL = NULL;
Surf_Display = nullptr;
Surf_DisplayGL = nullptr;
Running = true;
// mouse cursor data
Cursor.x = 0;
Expand All @@ -43,12 +43,12 @@ CGame::CGame()
Cursor.button.right = false;

for(int i = 0; i < MAXMENUS; i++)
Menus[i] = NULL;
Menus[i] = nullptr;
for(int i = 0; i < MAXWINDOWS; i++)
Windows[i] = NULL;
Windows[i] = nullptr;
for(int i = 0; i < MAXCALLBACKS; i++)
Callbacks[i] = NULL;
MapObj = NULL;
Callbacks[i] = nullptr;
MapObj = nullptr;
}

CGame::~CGame() {}
Expand Down Expand Up @@ -78,42 +78,42 @@ bool CGame::RegisterMenu(CMenu* Menu)
{
bool success = false;

if(Menu == NULL)
if(Menu == nullptr)
return success;
for(int i = 0; i < MAXMENUS; i++)
{
if(!success && Menus[i] == NULL)
if(!success && Menus[i] == nullptr)
{
Menus[i] = Menu;
Menus[i]->setActive();
success = true;
#ifdef _ADMINMODE
RegisteredMenus++;
#endif
} else if(Menus[i] != NULL)
} else if(Menus[i] != nullptr)
Menus[i]->setInactive();
}
return success;
}

bool CGame::UnregisterMenu(CMenu* Menu)
{
if(Menu == NULL)
if(Menu == nullptr)
return false;
for(int i = 0; i < MAXMENUS; i++)
{
if(Menus[i] == Menu)
{
for(int j = i - 1; j >= 0; j--)
{
if(Menus[j] != NULL)
if(Menus[j] != nullptr)
{
Menus[j]->setActive();
break;
}
}
delete Menus[i];
Menus[i] = NULL;
Menus[i] = nullptr;
#ifdef _ADMINMODE
RegisteredMenus--;
#endif
Expand All @@ -131,15 +131,15 @@ bool CGame::RegisterWindow(CWindow* Window)
// first find the highest priority
for(int i = 0; i < MAXWINDOWS; i++)
{
if(Windows[i] != NULL && Windows[i]->getPriority() > highestPriority)
if(Windows[i] != nullptr && Windows[i]->getPriority() > highestPriority)
highestPriority = Windows[i]->getPriority();
}

if(Window == NULL)
if(Window == nullptr)
return success;
for(int i = 0; i < MAXWINDOWS; i++)
{
if(!success && Windows[i] == NULL)
if(!success && Windows[i] == nullptr)
{
Windows[i] = Window;
Windows[i]->setActive();
Expand All @@ -148,30 +148,30 @@ bool CGame::RegisterWindow(CWindow* Window)
#ifdef _ADMINMODE
RegisteredWindows++;
#endif
} else if(Windows[i] != NULL)
} else if(Windows[i] != nullptr)
Windows[i]->setInactive();
}
return success;
}

bool CGame::UnregisterWindow(CWindow* Window)
{
if(Window == NULL)
if(Window == nullptr)
return false;
for(int i = 0; i < MAXWINDOWS; i++)
{
if(Windows[i] == Window)
{
for(int j = i - 1; j >= 0; j--)
{
if(Windows[j] != NULL)
if(Windows[j] != nullptr)
{
Windows[j]->setActive();
break;
}
}
delete Windows[i];
Windows[i] = NULL;
Windows[i] = nullptr;
#ifdef _ADMINMODE
RegisteredWindows--;
#endif
Expand All @@ -183,11 +183,11 @@ bool CGame::UnregisterWindow(CWindow* Window)

bool CGame::RegisterCallback(void (*callback)(int))
{
if(callback == NULL)
if(callback == nullptr)
return false;
for(int i = 0; i < MAXCALLBACKS; i++)
{
if(Callbacks[i] == NULL)
if(Callbacks[i] == nullptr)
{
Callbacks[i] = callback;
#ifdef _ADMINMODE
Expand All @@ -201,13 +201,13 @@ bool CGame::RegisterCallback(void (*callback)(int))

bool CGame::UnregisterCallback(void (*callback)(int))
{
if(callback == NULL)
if(callback == nullptr)
return false;
for(int i = 0; i < MAXCALLBACKS; i++)
{
if(Callbacks[i] == callback)
{
Callbacks[i] = NULL;
Callbacks[i] = nullptr;
#ifdef _ADMINMODE
RegisteredCallbacks--;
#endif
Expand All @@ -220,7 +220,7 @@ bool CGame::UnregisterCallback(void (*callback)(int))
void CGame::delMapObj()
{
delete MapObj;
MapObj = NULL;
MapObj = nullptr;
}

void WaitForEnter()
Expand Down
10 changes: 5 additions & 5 deletions CGame_Cleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ void CGame::Cleanup()
// unregister menus
for(int i = 0; i < MAXMENUS; i++)
{
if(Menus[i] != NULL)
if(Menus[i] != nullptr)
CSurface::Draw(Surf_Display, Menus[i]->getSurface(), 0, 0);
}
// unregister windows
for(int i = 0; i < MAXWINDOWS; i++)
{
if(Windows[i] != NULL)
if(Windows[i] != nullptr)
CSurface::Draw(Surf_Display, Windows[i]->getSurface(), 0, 0);
}

// free all picture surfaces
for(int i = 0; i < MAXBOBBMP; i++)
{
if(global::bmpArray[i].surface != NULL)
if(global::bmpArray[i].surface != nullptr)
SDL_FreeSurface(global::bmpArray[i].surface);
}
// free all shadow surfaces
for(int i = 0; i < MAXBOBSHADOW; i++)
{
if(global::shadowArray[i].surface != NULL)
if(global::shadowArray[i].surface != nullptr)
SDL_FreeSurface(global::shadowArray[i].surface);
}

SDL_FreeSurface(Surf_Display);
if(Surf_DisplayGL != NULL)
if(Surf_DisplayGL != nullptr)
SDL_FreeSurface(Surf_DisplayGL);

SDL_Quit();
Expand Down
38 changes: 19 additions & 19 deletions CGame_Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ void CGame::EventHandling(SDL_Event* Event)
int highestPriority = 0;
for(int j = 0; j < MAXWINDOWS; j++)
{
if(Windows[j] != NULL && Windows[j]->getPriority() > highestPriority)
if(Windows[j] != nullptr && Windows[j]->getPriority() > highestPriority)
highestPriority = Windows[j]->getPriority();
}

for(int i = 0; i < MAXWINDOWS; i++)
{
if(Windows[i] != NULL && !Windows[i]->isWaste() && Windows[i]->isMarked() && Windows[i]->getPriority() == highestPriority
if(Windows[i] != nullptr && !Windows[i]->isWaste() && Windows[i]->isMarked() && Windows[i]->getPriority() == highestPriority
&& Windows[i]->hasActiveInputElement())
{
Windows[i]->setKeyboardData(Event->key);
Expand All @@ -40,7 +40,7 @@ void CGame::EventHandling(SDL_Event* Event)
// deliver keyboard data to map if active
if(!delivered)
{
if(MapObj != NULL && MapObj->isActive())
if(MapObj != nullptr && MapObj->isActive())
{
MapObj->setKeyboardData(Event->key);
// data has been delivered to map, so no menu is in the foreground --> stop delivering
Expand All @@ -50,7 +50,7 @@ void CGame::EventHandling(SDL_Event* Event)
// deliver keyboard data to active menus
for(int i = 0; i < MAXMENUS; i++)
{
if(Menus[i] != NULL && Menus[i]->isActive() && !Menus[i]->isWaste())
if(Menus[i] != nullptr && Menus[i]->isActive() && !Menus[i]->isWaste())
Menus[i]->setKeyboardData(Event->key);
}
}
Expand Down Expand Up @@ -126,7 +126,7 @@ void CGame::EventHandling(SDL_Event* Event)
case SDL_KEYUP:
{
// deliver keyboard data to map
if(MapObj != NULL)
if(MapObj != nullptr)
MapObj->setKeyboardData(Event->key);

break;
Expand All @@ -135,7 +135,7 @@ void CGame::EventHandling(SDL_Event* Event)
case SDL_MOUSEMOTION:
{
// setup mouse cursor data
if(MapObj != NULL && MapObj->isActive())
if(MapObj != nullptr && MapObj->isActive())
{
if((Event->motion.state & SDL_BUTTON(SDL_BUTTON_RIGHT)) == 0)
{
Expand All @@ -154,7 +154,7 @@ void CGame::EventHandling(SDL_Event* Event)
//deliver mouse motion data to the active window
for (int i = 0; i < MAXWINDOWS; i++)
{
if (Windows[i] != NULL && Windows[i]->isActive() && !Windows[i]->isWaste())
if (Windows[i] != nullptr && Windows[i]->isActive() && !Windows[i]->isWaste())
{
Windows[i]->setMouseData(Event->motion);
if ( (Event->motion.x >= Windows[i]->getX()) && (Event->motion.x < Windows[i]->getX() + Windows[i]->getW())
Expand All @@ -173,15 +173,15 @@ void CGame::EventHandling(SDL_Event* Event)
int highestPriority = 0;
for(int j = 0; j < MAXWINDOWS; j++)
{
if(Windows[j] != NULL && Windows[j]->getPriority() > highestPriority)
if(Windows[j] != nullptr && Windows[j]->getPriority() > highestPriority)
highestPriority = Windows[j]->getPriority();
}

for(int actualPriority = highestPriority; actualPriority >= 0; actualPriority--)
{
for(int i = 0; i < MAXWINDOWS; i++)
{
if(Windows[i] != NULL && !Windows[i]->isWaste() && Windows[i]->getPriority() == actualPriority)
if(Windows[i] != nullptr && !Windows[i]->isWaste() && Windows[i]->getPriority() == actualPriority)
{
// is the cursor INSIDE the window or does the user move or resize the window?
if(((Event->motion.x >= Windows[i]->getX()) && (Event->motion.x < Windows[i]->getX() + Windows[i]->getW())
Expand All @@ -204,7 +204,7 @@ void CGame::EventHandling(SDL_Event* Event)
break;

// deliver mouse motion data to map if active
if(MapObj != NULL && MapObj->isActive())
if(MapObj != nullptr && MapObj->isActive())
{
MapObj->setMouseData(Event->motion);
// data has been delivered to map, so no menu is in the foreground --> stop delivering
Expand All @@ -214,7 +214,7 @@ void CGame::EventHandling(SDL_Event* Event)
// deliver mouse motion data to active menus
for(int i = 0; i < MAXMENUS; i++)
{
if(Menus[i] != NULL && Menus[i]->isActive() && !Menus[i]->isWaste())
if(Menus[i] != nullptr && Menus[i]->isActive() && !Menus[i]->isWaste())
{
Menus[i]->setMouseData(Event->motion);
break;
Expand Down Expand Up @@ -251,15 +251,15 @@ void CGame::EventHandling(SDL_Event* Event)
int highestPriority = 0;
for(int j = 0; j < MAXWINDOWS; j++)
{
if(Windows[j] != NULL && Windows[j]->getPriority() > highestPriority)
if(Windows[j] != nullptr && Windows[j]->getPriority() > highestPriority)
highestPriority = Windows[j]->getPriority();
}

for(int actualPriority = highestPriority; actualPriority >= 0; actualPriority--)
{
for(int i = 0; i < MAXWINDOWS; i++)
{
if(Windows[i] != NULL && !Windows[i]->isWaste() && Windows[i]->getPriority() == actualPriority)
if(Windows[i] != nullptr && !Windows[i]->isWaste() && Windows[i]->getPriority() == actualPriority)
{
// is the cursor INSIDE the window?
if((Event->button.x >= Windows[i]->getX()) && (Event->button.x < Windows[i]->getX() + Windows[i]->getW())
Expand All @@ -282,7 +282,7 @@ void CGame::EventHandling(SDL_Event* Event)
break;

// deliver mouse button data to map if active
if(MapObj != NULL && MapObj->isActive())
if(MapObj != nullptr && MapObj->isActive())
{
MapObj->setMouseData(Event->button);
// data has been delivered to map, so no menu is in the foreground --> stop delivering
Expand All @@ -292,7 +292,7 @@ void CGame::EventHandling(SDL_Event* Event)
// deliver mouse button data to active menus
for(int i = 0; i < MAXMENUS; i++)
{
if(Menus[i] != NULL && Menus[i]->isActive() && !Menus[i]->isWaste())
if(Menus[i] != nullptr && Menus[i]->isActive() && !Menus[i]->isWaste())
Menus[i]->setMouseData(Event->button);
}

Expand All @@ -312,15 +312,15 @@ void CGame::EventHandling(SDL_Event* Event)
int highestPriority = 0;
for(int j = 0; j < MAXWINDOWS; j++)
{
if(Windows[j] != NULL && Windows[j]->getPriority() > highestPriority)
if(Windows[j] != nullptr && Windows[j]->getPriority() > highestPriority)
highestPriority = Windows[j]->getPriority();
}

for(int actualPriority = highestPriority; actualPriority >= 0; actualPriority--)
{
for(int i = 0; i < MAXWINDOWS; i++)
{
if(Windows[i] != NULL && !Windows[i]->isWaste() && Windows[i]->getPriority() == actualPriority)
if(Windows[i] != nullptr && !Windows[i]->isWaste() && Windows[i]->getPriority() == actualPriority)
{
// is the cursor INSIDE the window?
if((Event->button.x >= Windows[i]->getX()) && (Event->button.x < Windows[i]->getX() + Windows[i]->getW())
Expand Down Expand Up @@ -349,7 +349,7 @@ void CGame::EventHandling(SDL_Event* Event)
// if still not delivered, keep delivering to secondary elements like menu or map

// deliver mouse button data to map if active
if(MapObj != NULL && MapObj->isActive())
if(MapObj != nullptr && MapObj->isActive())
{
MapObj->setMouseData(Event->button);
// data has been delivered to map, so no menu is in the foreground --> stop delivering
Expand All @@ -363,7 +363,7 @@ void CGame::EventHandling(SDL_Event* Event)
// deliver mouse button data to active menus
for(int i = 0; i < MAXMENUS; i++)
{
if(Menus[i] != NULL && Menus[i]->isActive() && !Menus[i]->isWaste())
if(Menus[i] != nullptr && Menus[i]->isActive() && !Menus[i]->isWaste())
Menus[i]->setMouseData(Event->button);
}
break;
Expand Down
6 changes: 3 additions & 3 deletions CGame_GameLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ void CGame::GameLoop()
{
for(int i = 0; i < MAXCALLBACKS; i++)
{
if(Callbacks[i] != NULL)
if(Callbacks[i] != nullptr)
Callbacks[i](CALL_FROM_GAMELOOP);
}
for(int i = 0; i < MAXMENUS; i++)
{
if(Menus[i] != NULL && Menus[i]->isWaste())
if(Menus[i] != nullptr && Menus[i]->isWaste())
UnregisterMenu(Menus[i]);
}
for(int i = 0; i < MAXWINDOWS; i++)
{
if(Windows[i] != NULL && Windows[i]->isWaste())
if(Windows[i] != nullptr && Windows[i]->isWaste())
UnregisterWindow(Windows[i]);
}
}
Loading

0 comments on commit f33510a

Please sign in to comment.