Browse Source

🎨 strip redundant else

pull/1639/head
Anders Jenbo 5 years ago
parent
commit
1e3ed903be
  1. 6
      Source/DiabloUI/diabloui.cpp
  2. 3
      Source/DiabloUI/selhero.cpp
  3. 3
      Source/DiabloUI/text.cpp
  4. 5
      Source/DiabloUI/ttf_render_wrapped.cpp
  5. 3
      Source/controls/plrctrls.cpp
  6. 2
      Source/controls/touch.cpp
  7. 6
      Source/diablo.cpp
  8. 12
      Source/drlg_l1.cpp
  9. 6
      Source/drlg_l4.cpp
  10. 13
      Source/dvlnet/base.cpp
  11. 4
      Source/dvlnet/frame_queue.cpp
  12. 6
      Source/dvlnet/protocol_zt.cpp
  13. 3
      Source/dvlnet/tcp_server.cpp
  14. 9
      Source/engine.cpp
  15. 3
      Source/gmenu.cpp
  16. 18
      Source/inv.cpp
  17. 4
      Source/lighting.cpp
  18. 3
      Source/loadsave.cpp
  19. 3
      Source/miniwin/misc_msg.cpp
  20. 19
      Source/missiles.cpp
  21. 4
      Source/monster.cpp
  22. 5
      Source/mpqapi.cpp
  23. 8
      Source/msg.cpp
  24. 11
      Source/multi.cpp
  25. 23
      Source/nthread.cpp
  26. 4
      Source/objects.cpp
  27. 16
      Source/player.cpp
  28. 4
      Source/portal.cpp
  29. 6
      Source/scrollrt.cpp
  30. 3
      Source/sha.cpp

6
Source/DiabloUI/diabloui.cpp

@ -864,7 +864,8 @@ bool HandleMouseEventScrollBar(const SDL_Event &event, const UiScrollBar *ui_sb)
if (scrollBarState.upArrowPressed && IsInsideRect(event, UpArrowRect(ui_sb))) {
UiFocusUp();
return true;
} else if (scrollBarState.downArrowPressed && IsInsideRect(event, DownArrowRect(ui_sb))) {
}
if (scrollBarState.downArrowPressed && IsInsideRect(event, DownArrowRect(ui_sb))) {
UiFocusDown();
return true;
}
@ -878,7 +879,8 @@ bool HandleMouseEventScrollBar(const SDL_Event &event, const UiScrollBar *ui_sb)
UiFocusPageDown();
}
return true;
} else if (IsInsideRect(event, UpArrowRect(ui_sb))) {
}
if (IsInsideRect(event, UpArrowRect(ui_sb))) {
scrollBarState.upArrowPressed = true;
return true;
} else if (IsInsideRect(event, DownArrowRect(ui_sb))) {

3
Source/DiabloUI/selhero.cpp

@ -352,9 +352,8 @@ void selhero_Name_Select(int value)
if (gfnHeroCreate(&selhero_heroInfo)) {
selhero_Load_Select(1);
return;
} else {
UiErrorOkDialog("Unable to create character.", vecSelDlgItems);
}
UiErrorOkDialog("Unable to create character.", vecSelDlgItems);
}
}

3
Source/DiabloUI/text.cpp

@ -25,7 +25,8 @@ void WordWrapArtStr(char *text, std::size_t width)
if (text[i] == '\n') {
lineStart = i + 1;
continue;
} else if (text[i] != ' ' && i != len) {
}
if (text[i] != ' ' && i != len) {
continue;
}

5
Source/DiabloUI/ttf_render_wrapped.cpp

@ -102,10 +102,9 @@ SDL_Surface *RenderUTF8_Solid_Wrapped(TTF_Font *font, const char *text, SDL_Colo
TTF_SizeUTF8(font, tok, &w, &h);
if ((Uint32)w <= wrapLength) {
break;
} else {
/* Back up and try again... */
*spot = delim;
}
/* Back up and try again... */
*spot = delim;
while (spot > tok && !CharacterIsDelimiter(spot[-1], wrapDelims)) {
--spot;

3
Source/controls/plrctrls.cpp

@ -859,7 +859,8 @@ HandleLeftStickOrDPadFn GetLeftStickOrDPadGameUIHandler()
{
if (invflag) {
return &InvMove;
} else if (chrflag && plr[myplr]._pStatPts > 0) {
}
if (chrflag && plr[myplr]._pStatPts > 0) {
return &AttrIncBtnSnap;
} else if (spselflag) {
return &HotSpellMove;

2
Source/controls/touch.cpp

@ -16,7 +16,7 @@ inline T clip(T v, T amin, T amax)
{
if (v < amin)
return amin;
else if (v > amax)
if (v > amax)
return amax;
else
return v;

6
Source/diablo.cpp

@ -2116,10 +2116,10 @@ void game_loop(bool bStartup)
if (!multi_handle_delta()) {
timeout_cursor(true);
break;
} else {
timeout_cursor(false);
game_logic();
}
timeout_cursor(false);
game_logic();
if (!gbRunGame || !gbIsMultiplayer || !nthread_has_500ms_passed())
break;
}

12
Source/drlg_l1.cpp

@ -1048,8 +1048,8 @@ static int DRLG_PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, in
return 1;
if (sx < cx && sy > cy)
return 2;
else
return 3;
return 3;
}
static void DRLG_L1Floor()
@ -1575,8 +1575,8 @@ static int L5HWallOk(int i, int j)
if (wallok)
return x;
else
return -1;
return -1;
}
static int L5VWallOk(int i, int j)
@ -1601,8 +1601,8 @@ static int L5VWallOk(int i, int j)
if (wallok)
return y;
else
return -1;
return -1;
}
static void L5HorizWall(int i, int j, char p, int dx)

6
Source/drlg_l4.cpp

@ -306,9 +306,8 @@ static int L4HWallOk(int i, int j)
if (wallok) {
return x;
} else {
return -1;
}
return -1;
}
static int L4VWallOk(int i, int j)
@ -360,9 +359,8 @@ static int L4VWallOk(int i, int j)
if (wallok) {
return y;
} else {
return -1;
}
return -1;
}
static void L4HorizWall(int i, int j, int dx)

13
Source/dvlnet/base.cpp

@ -163,16 +163,15 @@ bool base::SNetReceiveTurns(char **data, unsigned int *size, DWORD *status)
}
}
return true;
} else {
for (auto i = 0; i < MAX_PLRS; ++i) {
if (connected_table[i]) {
if (!turn_queue[i].empty()) {
status[i] |= PS_ACTIVE;
}
}
for (auto i = 0; i < MAX_PLRS; ++i) {
if (connected_table[i]) {
if (!turn_queue[i].empty()) {
status[i] |= PS_ACTIVE;
}
}
return false;
}
return false;
}
bool base::SNetSendTurn(char *data, unsigned int size)

4
Source/dvlnet/frame_queue.cpp

@ -53,8 +53,8 @@ bool frame_queue::packet_ready()
}
if (size() >= nextsize)
return true;
else
return false;
return false;
}
buffer_t frame_queue::read_packet()

6
Source/dvlnet/protocol_zt.cpp

@ -127,7 +127,8 @@ bool protocol_zt::send_queued_peer(const endpoint &peer)
if (r < 0) {
// handle error
return false;
} else if (decltype(len)(r) < len) {
}
if (decltype(len)(r) < len) {
// partial send
auto it = peer_list[peer].send_queue.front().begin();
peer_list[peer].send_queue.front().erase(it, it + r);
@ -151,9 +152,8 @@ bool protocol_zt::recv_peer(const endpoint &peer)
} else {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
return true;
} else {
return false;
}
return false;
}
}
}

3
Source/dvlnet/tcp_server.cpp

@ -26,7 +26,8 @@ std::string tcp_server::localhost_self()
if (addr.is_unspecified()) {
if (addr.is_v4()) {
return asio::ip::address_v4::loopback().to_string();
} else if (addr.is_v6()) {
}
if (addr.is_v6()) {
return asio::ip::address_v6::loopback().to_string();
}
ABORT();

9
Source/engine.cpp

@ -816,9 +816,8 @@ static void Cl2BlitSafe(CelOutputBuffer out, int sx, int sy, BYTE *pRLEBytes, in
dst -= out.pitch() + w;
}
continue;
} else {
src += width;
}
src += width;
}
}
while (width) {
@ -903,9 +902,8 @@ static void Cl2BlitOutlineSafe(CelOutputBuffer out, int sx, int sy, BYTE *pRLEBy
dst -= out.pitch() + w;
}
continue;
} else {
src += width;
}
src += width;
}
}
while (width) {
@ -985,9 +983,8 @@ static void Cl2BlitLightSafe(CelOutputBuffer out, int sx, int sy, BYTE *pRLEByte
dst -= out.pitch() + w;
}
continue;
} else {
src += width;
}
src += width;
}
}
while (width) {

3
Source/gmenu.cpp

@ -353,9 +353,8 @@ bool gmenu_left_mouse(bool isDown)
if (mouseNavigation) {
mouseNavigation = false;
return true;
} else {
return false;
}
return false;
}
if (!sgpCurrentMenu) {

18
Source/inv.cpp

@ -2348,16 +2348,16 @@ bool UseInvItem(int pnum, int cii)
}
RemoveSpdBarItem(pnum, c);
return true;
} else {
if (plr[pnum].InvList[c]._iMiscId == IMISC_MAPOFDOOM)
return true;
if (plr[pnum].InvList[c]._iMiscId == IMISC_NOTE) {
InitQTextMsg(TEXT_BOOK9);
invflag = false;
return true;
}
RemoveInvItem(pnum, c);
}
if (plr[pnum].InvList[c]._iMiscId == IMISC_MAPOFDOOM)
return true;
if (plr[pnum].InvList[c]._iMiscId == IMISC_NOTE) {
InitQTextMsg(TEXT_BOOK9);
invflag = false;
return true;
}
RemoveInvItem(pnum, c);
return true;
}

4
Source/lighting.cpp

@ -488,8 +488,8 @@ char GetLight(int x, int y)
{
if (LoadMapObjsFlag)
return dPreLight[x][y];
else
return dLight[x][y];
return dLight[x][y];
}
void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum)

3
Source/loadsave.cpp

@ -840,7 +840,8 @@ bool IsHeaderValid(Uint32 magicNumber)
gbIsHellfireSaveGame = false;
if (magicNumber == LOAD_LE32("SHAR")) {
return true;
} else if (magicNumber == LOAD_LE32("SHLF")) {
}
if (magicNumber == LOAD_LE32("SHLF")) {
gbIsHellfireSaveGame = true;
return true;
} else if (!gbIsSpawn && magicNumber == LOAD_LE32("RETL")) {

3
Source/miniwin/misc_msg.cpp

@ -443,7 +443,8 @@ bool FetchMessage(LPMSG lpMsg)
}
return true;
#ifndef USE_SDL1
} else if (e.type < SDL_JOYAXISMOTION || (e.type >= SDL_FINGERDOWN && e.type < SDL_DOLLARGESTURE)) {
}
if (e.type < SDL_JOYAXISMOTION || (e.type >= SDL_FINGERDOWN && e.type < SDL_DOLLARGESTURE)) {
#else
} else if (e.type < SDL_JOYAXISMOTION) {
#endif

19
Source/missiles.cpp

@ -579,7 +579,7 @@ bool MonsterTrapHit(int m, int mindam, int maxdam, int dist, int t, bool shift)
return ret;
}
#ifdef _DEBUG
else if (hit < hper || debug_mode_dollar_sign || debug_mode_key_inverted_v || monster[m]._mmode == MM_STONE) {
if (hit < hper || debug_mode_dollar_sign || debug_mode_key_inverted_v || monster[m]._mmode == MM_STONE) {
#else
else if (hit < hper || monster[m]._mmode == MM_STONE) {
#endif
@ -983,17 +983,16 @@ bool Plr2PlrMHit(int pnum, int p, int mindam, int maxdam, int dist, int mtype, b
NetSendCmdDamage(true, p, dam);
plr[pnum].PlaySpeach(69);
return true;
}
if (blkper < blk) {
StartPlrBlock(p, GetDirection(plr[p]._px, plr[p]._py, plr[pnum]._px, plr[pnum]._py));
*blocked = true;
} else {
if (blkper < blk) {
StartPlrBlock(p, GetDirection(plr[p]._px, plr[p]._py, plr[pnum]._px, plr[pnum]._py));
*blocked = true;
} else {
if (pnum == myplr)
NetSendCmdDamage(true, p, dam);
StartPlrHit(p, dam, false);
}
return true;
if (pnum == myplr)
NetSendCmdDamage(true, p, dam);
StartPlrHit(p, dam, false);
}
return true;
}
return false;
}

4
Source/monster.cpp

@ -5661,8 +5661,8 @@ int encode_enemy(int m)
{
if (monster[m]._mFlags & MFLAG_TARGETS_MONSTER)
return monster[m]._menemy + MAX_PLRS;
else
return monster[m]._menemy;
return monster[m]._menemy;
}
void decode_enemy(int m, int enemy)

5
Source/mpqapi.cpp

@ -203,11 +203,10 @@ struct Archive {
if (GetFileSize(name, &size) == 0) {
SDL_Log("GetFileSize(\"%s\") failed with \"%s\"", name, std::strerror(errno));
return false;
}
#ifdef _DEBUG
} else {
SDL_Log("GetFileSize(\"%s\") = %" PRIuMAX, name, size);
SDL_Log("GetFileSize(\"%s\") = %" PRIuMAX, name, size);
#endif
}
} else {
mode |= std::ios::trunc;
}

8
Source/msg.cpp

@ -404,7 +404,8 @@ static DWORD On_DLEVEL(int pnum, TCmd *pCmd)
if (p->bCmd == CMD_DLEVEL_END) {
sgbDeltaChunks = MAX_CHUNKS - 1;
return p->wBytes + sizeof(*p);
} else if (p->bCmd == CMD_DLEVEL_0 && p->wOffset == 0) {
}
if (p->bCmd == CMD_DLEVEL_0 && p->wOffset == 0) {
sgdwRecvOffset = 0;
sgbRecvCmd = p->bCmd;
} else {
@ -416,10 +417,9 @@ static DWORD On_DLEVEL(int pnum, TCmd *pCmd)
sgbDeltaChunks = MAX_CHUNKS - 1;
sgbRecvCmd = CMD_DLEVEL_END;
return p->wBytes + sizeof(*p);
} else {
sgdwRecvOffset = 0;
sgbRecvCmd = p->bCmd;
}
sgdwRecvOffset = 0;
sgbRecvCmd = p->bCmd;
}
assert(p->wOffset == sgdwRecvOffset);

11
Source/multi.cpp

@ -823,14 +823,13 @@ bool multi_init_multi(GameData *gameData)
if ((DWORD)playerId >= MAX_PLRS) {
return false;
} else {
myplr = playerId;
gbIsMultiplayer = true;
}
myplr = playerId;
gbIsMultiplayer = true;
pfile_read_player_from_save();
pfile_read_player_from_save();
return true;
}
return true;
}
void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, bool recv)

23
Source/nthread.cpp

@ -39,7 +39,8 @@ void nthread_terminate_game(const char *pszFcn)
sErr = SErrGetLastError();
if (sErr == STORM_ERROR_INVALID_PLAYER) {
return;
} else if (sErr == STORM_ERROR_GAME_TERMINATED) {
}
if (sErr == STORM_ERROR_GAME_TERMINATED) {
gbGameDestroyed = true;
} else if (sErr == STORM_ERROR_NOT_IN_GAME) {
gbGameDestroyed = true;
@ -103,17 +104,17 @@ bool nthread_recv_turns(bool *pfSendAsync)
sgbSyncCountdown = 1;
sgbPacketCountdown = 1;
return false;
} else {
if (!sgbTicsOutOfSync) {
sgbTicsOutOfSync = true;
last_tick = SDL_GetTicks();
}
sgbSyncCountdown = 4;
multi_msg_countdown();
*pfSendAsync = true;
last_tick += gnTickDelay;
return true;
}
if (!sgbTicsOutOfSync) {
sgbTicsOutOfSync = true;
last_tick = SDL_GetTicks();
}
sgbSyncCountdown = 4;
multi_msg_countdown();
*pfSendAsync = true;
last_tick += gnTickDelay;
return true;
#endif
}

4
Source/objects.cpp

@ -352,8 +352,8 @@ static bool WallTrapLocOkK(int xp, int yp)
if (nTrapTable[dPiece[xp][yp]])
return true;
else
return false;
return false;
}
void InitRndLocObj(int min, int max, _object_id objtype)

16
Source/player.cpp

@ -2324,10 +2324,9 @@ bool PM_DoWalk(int pnum, int variant)
AutoGoldPickup(pnum);
return true;
} else { //We didn't reach new tile so update player's "sub-tile" position
PM_ChangeOffset(pnum);
return false;
}
} //We didn't reach new tile so update player's "sub-tile" position
PM_ChangeOffset(pnum);
return false;
}
static bool WeaponDurDecay(int pnum, int ii)
@ -2880,9 +2879,8 @@ bool PM_DoAttack(int pnum)
StartStand(pnum, plr[pnum]._pdir);
ClearPlrPVars(pnum);
return true;
} else {
return false;
}
return false;
}
bool PM_DoRangeAttack(int pnum)
@ -2964,9 +2962,8 @@ bool PM_DoRangeAttack(int pnum)
StartStand(pnum, plr[pnum]._pdir);
ClearPlrPVars(pnum);
return true;
} else {
return false;
}
return false;
}
void ShieldDur(int pnum)
@ -3512,7 +3509,8 @@ bool PlrDeathModeOK(int p)
if (plr[p]._pmode == PM_DEATH) {
return true;
} else if (plr[p]._pmode == PM_QUIT) {
}
if (plr[p]._pmode == PM_QUIT) {
return true;
} else if (plr[p]._pmode == PM_NEWLVL) {
return true;

4
Source/portal.cpp

@ -107,8 +107,8 @@ bool PortalOnLevel(int i)
{
if (portal[i].level == currlevel)
return true;
else
return currlevel == 0;
return currlevel == 0;
}
void RemovePortalMissile(int id)

6
Source/scrollrt.cpp

@ -175,13 +175,15 @@ static void scrollrt_draw_cursor_item(CelOutputBuffer out)
mx = MouseX - 1;
if (mx < 0 - cursW - 1) {
return;
} else if (mx > gnScreenWidth - 1) {
}
if (mx > gnScreenWidth - 1) {
return;
}
my = MouseY - 1;
if (my < 0 - cursH - 1) {
return;
} else if (my > gnScreenHeight - 1) {
}
if (my > gnScreenHeight - 1) {
return;
}

3
Source/sha.cpp

@ -29,9 +29,8 @@ uint32_t SHA1CircularShift(uint32_t bits, uint32_t word)
//moving this part to a separate volatile variable fixes saves in x64-release build in visual studio 2017
volatile uint32_t tmp = ((~word) >> (32 - bits));
return (word << bits) | (~tmp);
} else {
return (word << bits) | (word >> (32 - bits));
}
return (word << bits) | (word >> (32 - bits));
}
} // namespace

Loading…
Cancel
Save