Skip to content

Commit

Permalink
Fix clang-tidy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed May 19, 2020
1 parent d3f9fbc commit b71b87d
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 183 deletions.
7 changes: 1 addition & 6 deletions CGame_Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ void CGame::EventHandling(SDL_Event* Event)

switch(Event->key.keysym.sym)
{
case SDLK_F2:
if(fullscreen)
fullscreen = false;
else
fullscreen = true;
break;
case SDLK_F2: fullscreen = !fullscreen; break;

#ifdef _ADMINMODE
case SDLK_F3: // if CTRL and ALT are pressed
Expand Down
5 changes: 1 addition & 4 deletions CIO/CFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ void* CFile::open_file(const std::string& filename, char filetype, bool only_loa
{
void* return_value = nullptr;

if(filename.empty() || !bmpArray || !shadowArray || !palArray || !palActual)
return nullptr;

else if(!(fp = boost::nowide::fopen(filename.c_str(), "rb")))
if(filename.empty() || !bmpArray || !shadowArray || !palArray || !palActual || !(fp = boost::nowide::fopen(filename.c_str(), "rb")))
return nullptr;

if(only_loadPAL)
Expand Down
3 changes: 1 addition & 2 deletions CIO/CFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ unsigned getIndexForChar(uint8_t c)
else if(c == 252)
return 88;
// chiffre not available, use '_' instead
else
return 60;
return 60;
}

unsigned getIndexForChar(uint8_t c, unsigned fontsize, unsigned color)
Expand Down
10 changes: 2 additions & 8 deletions CIO/CTextfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ void CTextfield::setMouseData(SDL_MouseButtonEvent button)
// if mouse button is pressed ON the textfield, set active=true
if(button.state == SDL_PRESSED)
{
if((button.x >= x_) && (button.x < x_ + w) && (button.y >= y_) && (button.y < y_ + h))
active = true;
else
active = false;
active = (button.x >= x_) && (button.x < x_ + w) && (button.y >= y_) && (button.y < y_ + h);
}
}
needRender = true;
Expand Down Expand Up @@ -207,7 +204,7 @@ void CTextfield::setKeyboardData(const SDL_KeyboardEvent& key)
break;
}
// decide which chiffre to save
if((key.keysym.sym >= 48 && key.keysym.sym <= 57) || key.keysym.sym == 32)
if((key.keysym.sym >= 48 && key.keysym.sym <= 57) || key.keysym.sym == 32 || key.keysym.sym == 46 || key.keysym.sym == 47)
chiffre = (unsigned char)key.keysym.sym;
else if(key.keysym.sym >= 97 && key.keysym.sym <= 122)
{
Expand All @@ -221,9 +218,6 @@ void CTextfield::setKeyboardData(const SDL_KeyboardEvent& key)
// test for '_' ('-' and shift pressed)
if(key.keysym.mod & KMOD_SHIFT)
chiffre = 95;
} else if(key.keysym.sym == 46 || key.keysym.sym == 47)
{
chiffre = (unsigned char)key.keysym.sym;
}

if(chiffre != '\0')
Expand Down
14 changes: 4 additions & 10 deletions CIO/CWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,15 @@ void CWindow::setMouseData(SDL_MouseMotionEvent motion)
if(canClose)
{
// cursor is on the button (+/-2 is only for the optic)
if((motion.x >= x_ + 2) && (motion.x < x_ + global::bmpArray[WINDOW_BUTTON_CLOSE].w - 2) && (motion.y >= y_ + 2)
&& (motion.y < y_ + global::bmpArray[WINDOW_BUTTON_CLOSE].h - 2))
canClose_marked = true;
else
canClose_marked = false;
canClose_marked = (motion.x >= x_ + 2) && (motion.x < x_ + global::bmpArray[WINDOW_BUTTON_CLOSE].w - 2) && (motion.y >= y_ + 2)
&& (motion.y < y_ + global::bmpArray[WINDOW_BUTTON_CLOSE].h - 2);
}
// check whats happen to the minimize button
if(canMinimize)
{
// cursor is on the button (+/-2 is only for the optic)
if((motion.x >= x_ + w_ - global::bmpArray[WINDOW_BUTTON_MINIMIZE].w + 2) && (motion.x < x_ + w_ - 2) && (motion.y >= y_ + 2)
&& (motion.y < y_ + global::bmpArray[WINDOW_BUTTON_MINIMIZE].h - 2))
canMinimize_marked = true;
else
canMinimize_marked = false;
canMinimize_marked = (motion.x >= x_ + w_ - global::bmpArray[WINDOW_BUTTON_MINIMIZE].w + 2) && (motion.x < x_ + w_ - 2)
&& (motion.y >= y_ + 2) && (motion.y < y_ + global::bmpArray[WINDOW_BUTTON_MINIMIZE].h - 2);
}
// check whats happen to the resize button
if(canResize)
Expand Down
24 changes: 3 additions & 21 deletions CMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,10 +972,6 @@ void CMap::setKeyboardData(const SDL_KeyboardEvent& key)
mode = lastMode;
break;
case SDLK_b: // user probably released EDITOR_MODE_HEIGHT_MAKE_BIG_HOUSE
mode = lastMode;
ChangeSection_ = lastChangeSection;
setupVerticesActivity();
break;
case SDLK_h: // user probably released EDITOR_MODE_TEXTURE_MAKE_HARBOUR
mode = lastMode;
ChangeSection_ = lastChangeSection;
Expand Down Expand Up @@ -1116,7 +1112,7 @@ void CMap::render()
case EDITOR_MODE_TEXTURE: symbol_index = CURSOR_SYMBOL_TEXTURE; break;
case EDITOR_MODE_TEXTURE_MAKE_HARBOUR: symbol_index = MAPPIC_ARROWCROSS_RED_HOUSE_HARBOUR; break;
case EDITOR_MODE_LANDSCAPE: symbol_index = CURSOR_SYMBOL_LANDSCAPE; break;
case EDITOR_MODE_FLAG: symbol_index = CURSOR_SYMBOL_FLAG; break;
case EDITOR_MODE_FLAG:
case EDITOR_MODE_FLAG_DELETE: symbol_index = CURSOR_SYMBOL_FLAG; break;
case EDITOR_MODE_RESOURCE_REDUCE: symbol_index = CURSOR_SYMBOL_PICKAXE_MINUS; break;
case EDITOR_MODE_RESOURCE_RAISE: symbol_index = CURSOR_SYMBOL_PICKAXE_PLUS; break;
Expand Down Expand Up @@ -2484,14 +2480,6 @@ void CMap::modifyPlayer(int VertexX, int VertexY)
}
}

int CMap::getActiveVertices(int tempChangeSection)
{
int total = 0;
for(int i = tempChangeSection; i > 0; i--)
total += i;
return (6 * total + 1);
}

void CMap::calculateVertices()
{
const bool even = Vertex_.y % 2 == 0;
Expand Down Expand Up @@ -2708,21 +2696,15 @@ void CMap::setupVerticesActivity()
// we are in square mode
else
{
// if we are at the last lower row
if(i == ChangeSection_)
// if we are at the last lower row or right vertex of the row
if(i == ChangeSection_ || j == ChangeSection_)
{
Vertices[index].fill_rsu = false;
Vertices[index].fill_usd = false;
}
// left vertex of the row
else if(j == -ChangeSection_)
Vertices[index].fill_rsu = false;
// right vertex of the row
else if(j == ChangeSection_)
{
Vertices[index].fill_rsu = false;
Vertices[index].fill_usd = false;
}
}
}
} else
Expand Down
4 changes: 1 addition & 3 deletions CMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class CMap
int border_texture);
void destructMap();
void loadMapPics();
void unloadMapPics();
static void unloadMapPics();

void moveMap(Position offset);
void setMouseData(const SDL_MouseMotionEvent& motion);
Expand Down Expand Up @@ -186,8 +186,6 @@ class CMap
bool getVertexActivityRandom() { return VertexActivityRandom; }

private:
// returns count of the vertices that are involved in changes (editor mode) -->THIS FUNCTION IS OUTDATED
int getActiveVertices(int tempChangeSection);
// this will calculate ALL vertices for the whole square
void calculateVertices();
// this will calculate the vertices two sections around one vertex (like a great hexagon) --> necessary to calculate the possible
Expand Down
36 changes: 0 additions & 36 deletions CSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,51 +620,15 @@ void CSurface::GetTerrainTextureCoords(MapType mapType, TriangleTerrainType text
}
break;
case TRIANGLE_TEXTURE_STEPPE:
upper = Point16(65, 0);
left = Point16(48, 30);
right = Point16(83, 30);
break;
case TRIANGLE_TEXTURE_STEPPE_:
upper = Point16(65, 0);
left = Point16(48, 30);
right = Point16(83, 30);
break;
case TRIANGLE_TEXTURE_STEPPE__:
upper = Point16(65, 0);
left = Point16(48, 30);
right = Point16(83, 30);
break;
case TRIANGLE_TEXTURE_STEPPE___:
upper = Point16(65, 0);
left = Point16(48, 30);
right = Point16(83, 30);
break;
case TRIANGLE_TEXTURE_WATER:
if(isRSU)
{
upper = Point16(231, 61) + animOffset;
left = Point16(207, 62) + animOffset;
right = Point16(223, 78) + animOffset;
} else
{
upper = Point16(224, 79) + animOffset;
left = Point16(232, 62) + animOffset;
right = Point16(245, 76) + animOffset;
}
break;
case TRIANGLE_TEXTURE_WATER_:
if(isRSU)
{
upper = Point16(231, 61) + animOffset;
left = Point16(207, 62) + animOffset;
right = Point16(223, 78) + animOffset;
} else
{
upper = Point16(224, 79) + animOffset;
left = Point16(232, 62) + animOffset;
right = Point16(245, 76) + animOffset;
}
break;
case TRIANGLE_TEXTURE_WATER__:
if(isRSU)
{
Expand Down
95 changes: 2 additions & 93 deletions callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,7 @@ void callback::submenuOptions(int Param)
break;

case FULLSCREEN:
if(global::s2->fullscreen)
global::s2->fullscreen = false;
else
global::s2->fullscreen = true;
global::s2->fullscreen = !global::s2->fullscreen;

submenuOptions(GRAPHICS_CHANGE);
break;
Expand Down Expand Up @@ -655,23 +652,7 @@ void callback::EditorHelpMenu(int Param)

case WINDOW_QUIT_MESSAGE: // this is the global window quit message, callback is explicit called with this value, so destroy the
// window
if(WNDHelp)
{
WNDHelp->setWaste();
WNDHelp = nullptr;
SelectBoxHelp = nullptr;
}
break;

case WINDOWQUIT: // this is the own window quit message of the callback
if(WNDHelp)
{
WNDHelp->setWaste();
WNDHelp = nullptr;
SelectBoxHelp = nullptr;
}
break;

case WINDOWQUIT: // this is the own window quit message of the callback
case MAP_QUIT: // this is the global window quit message, callback is explicit called with this value, so destroy the window
if(WNDHelp)
{
Expand Down Expand Up @@ -711,13 +692,6 @@ void callback::EditorMainMenu(int Param)
break;

case WINDOWQUIT:
if(WNDMain)
{
WNDMain->setWaste();
WNDMain = nullptr;
}
break;

case MAP_QUIT:
if(WNDMain)
{
Expand Down Expand Up @@ -773,13 +747,6 @@ void callback::EditorLoadMenu(int Param)
break;
}
case WINDOWQUIT:
if(WNDLoad)
{
WNDLoad->setWaste();
WNDLoad = nullptr;
}
break;

case MAP_QUIT:
if(WNDLoad)
{
Expand Down Expand Up @@ -874,16 +841,6 @@ void callback::EditorSaveMenu(int Param)
break;
}
case WINDOWQUIT:
if(WNDSave)
{
WNDSave->setWaste();
WNDSave = nullptr;
}
TXTF_Filename = nullptr;
TXTF_Mapname = nullptr;
TXTF_Author = nullptr;
break;

case MAP_QUIT:
if(WNDSave)
{
Expand Down Expand Up @@ -1968,20 +1925,6 @@ void callback::EditorCursorMenu(int Param)
case WINDOW_CLICKED_CALL: break;

case WINDOWQUIT:
if(WNDCursor)
{
Pos = WNDCursor->getPos();
WNDCursor->setWaste();
WNDCursor = nullptr;
}
MapObj = nullptr;
trianglePictureArrowUp = -1;
trianglePictureArrowDown = -1;
trianglePictureRandom = -1;
CursorModeButton = nullptr;
CursorRandomButton = nullptr;
break;

case MAP_QUIT:
// we do the same like in case WINDOWQUIT
if(WNDCursor)
Expand Down Expand Up @@ -2699,29 +2642,6 @@ void callback::EditorCreateMenu(int Param)
break;

case MAP_QUIT:
if(WNDCreate)
{
Pos = WNDCreate->getPos();
WNDCreate->setWaste();
WNDCreate = nullptr;
}
MapObj = nullptr;
TextWidth = nullptr;
width = 32;
TextHeight = nullptr;
height = 32;
ButtonLandscape = nullptr;
LandscapeType = 0;
PicTextureIndex = -1;
PicTextureIndexGlobal = PICTURE_GREENLAND_TEXTURE_SNOW;
texture = TRIANGLE_TEXTURE_SNOW;
PicBorderTextureIndex = -1;
PicBorderTextureIndexGlobal = PICTURE_GREENLAND_TEXTURE_SNOW;
TextBorder = nullptr;
border = 0;
border_texture = TRIANGLE_TEXTURE_SNOW;
break;

case WINDOWQUIT:
if(WNDCreate)
{
Expand Down Expand Up @@ -2818,18 +2738,7 @@ void callback::MinimapMenu(int Param)
break;

case WINDOWQUIT:
if(WNDMinimap)
{
WNDMinimap->setWaste();
WNDMinimap = nullptr;
}
MapObj = nullptr;
WndSurface = nullptr;
global::s2->UnregisterCallback(MinimapMenu);
break;

case MAP_QUIT:
// we do the same like in case WINDOWQUIT
if(WNDMinimap)
{
WNDMinimap->setWaste();
Expand Down

0 comments on commit b71b87d

Please sign in to comment.