Skip to content

Commit

Permalink
clang tidy 19 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lectem committed Feb 27, 2024
1 parent 81b5442 commit f016364
Show file tree
Hide file tree
Showing 53 changed files with 176 additions and 26 deletions.
1 change: 1 addition & 0 deletions source/.clang-tidy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
Checks: '-*,readability-inconsistent-declaration-parameter-name,bugprone-*,-bugprone-easily-swappable-parameters,-bugprone-narrowing-conversions,-clang-diagnostic-multichar,-clang-diagnostic-microsoft-cast'
CheckOptions:
bugprone-signed-char-misuse.CharTypedefsToIgnore: 'int8_t'
bugprone-signed-char-misuse.CharTypdefsToIgnore: 'int8_t'
WarningsAsErrors: '*,-clang-diagnostic-microsoft-cast,-clang-diagnostic-multichar'
HeaderFilterRegex: 'doctest.*'
Expand Down
8 changes: 4 additions & 4 deletions source/D2Common/src/D2Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3393,9 +3393,9 @@ int __fastcall UNITS_GetXPosition(D2UnitStrc* pUnit)
case UNIT_ITEM:
case UNIT_TILE:
return pUnit->pStaticPath ? pUnit->pStaticPath->tGameCoords.nX : 0;
default:
return 0;
}

return 0;
}

//D2Common.0x6FD92610
Expand All @@ -3412,7 +3412,7 @@ int __fastcall UNITS_GetYPosition(D2UnitStrc* pUnit)
case UNIT_ITEM:
case UNIT_TILE:
return pUnit->pStaticPath ? pUnit->pStaticPath->tGameCoords.nY : 0;
default:
return 0;
}

return 0;
}
6 changes: 6 additions & 0 deletions source/D2Common/src/Drlg/DrlgDrlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ D2DrlgStrc* __fastcall DRLG_AllocDrlg(D2DrlgActStrc* pAct, uint8_t nActNo, HD2AR
wsprintfA(szPath, "%s\\Tiles\\ACT3\\Kurast\\sets.dt1", "DATA\\GLOBAL");
D2CMP_10087_LoadTileLibrarySlot(pDrlg->pTiles, szPath);
break;
default:
break;
}

DRLGACTIVATE_InitializeRoomExStatusLists(pDrlg);
Expand Down Expand Up @@ -194,6 +196,8 @@ void __fastcall DRLG_FreeLevel(void* pMemPool, D2DrlgLevelStrc* pLevel, BOOL bAl
case DRLGTYPE_OUTDOOR:
DRLGOUTDOORS_FreeOutdoorInfo(pLevel, bAlloc);
break;
default:
D2_UNREACHABLE;
}

memset(pLevel->pTileInfo, 0x00, sizeof(pLevel->pTileInfo));
Expand Down Expand Up @@ -426,6 +430,8 @@ D2DrlgLevelStrc* __fastcall DRLG_AllocLevel(D2DrlgStrc* pDrlg, int nLevelId)
case DRLGTYPE_OUTDOOR:
DRLGOUTDOORS_AllocOutdoorInfo(pLevel);
break;
default:
D2_UNREACHABLE;
}

pLevel->pNextLevel = pDrlg->pLevel;
Expand Down
2 changes: 2 additions & 0 deletions source/D2Common/src/Drlg/DrlgMaze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2819,6 +2819,8 @@ void __fastcall DRLGMAZE_PlaceAct1Barracks(D2DrlgLevelStrc* pLevel)
nX += pOuterCloisterLevel->nWidth - pBarracksRoomEx->nTileXPos;
nY += pOuterCloisterLevel->nHeight / 2 - pBarracksRoomEx->nTileYPos + 1;
break;
default:
break;
}

if (SEED_RollRandomNumber(&pLevel->pSeed) & 1)
Expand Down
6 changes: 6 additions & 0 deletions source/D2Common/src/Drlg/DrlgOutPlace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ void __fastcall DRLGOUTPLACE_BuildKurast(D2DrlgLevelStrc* pLevel)
case LEVEL_UPPERKURAST:
DRLGOUTJUNG_BuildUpperKurast(pLevel);
break;
default:
break;
}

switch (pLevel->nLevelId)
Expand Down Expand Up @@ -1061,6 +1063,8 @@ void __fastcall sub_6FD81430(D2DrlgCoordStrc* pDrlgCoord1, D2DrlgCoordStrc* pDrl
case 3:
pDrlgCoord2->nPosY += 8;
break;
default:
break;
}
break;

Expand Down Expand Up @@ -1277,6 +1281,8 @@ void __fastcall sub_6FD81850(D2DrlgCoordStrc* pDrlgCoord1, D2DrlgCoordStrc* pDrl
case 3:
pDrlgCoord2->nPosY -= 8;
break;
default:
break;
}
break;

Expand Down
2 changes: 2 additions & 0 deletions source/D2Common/src/Drlg/DrlgPreset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ void __fastcall DRLGPRESET_ParseDS1File(D2DrlgFileStrc* pDrlgFile, HD2ARCHIVE hA
}
nMode = IMODE_ONGROUND;
break;
default:
break;
}

int nX = ReadInt32(pData);
Expand Down
2 changes: 2 additions & 0 deletions source/D2Common/src/Drlg/DrlgRoomTile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,8 @@ void __fastcall DRLGROOMTILE_CountWallWarpTiles(D2DrlgRoomStrc* pDrlgRoom, D2Drl
++pDrlgRoom->pTileGrid->pTiles.nWalls;
}
break;
default:
break;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions source/D2Common/src/Monsters/Monsters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,8 @@ int __stdcall MONSTERS_GetHirelingTypeId(D2UnitStrc* pHireling)
case MONSTER_ACT5HIRE1:
case MONSTER_ACT5HIRE2:
return 4;
default:
break;
}
}

Expand Down
2 changes: 2 additions & 0 deletions source/D2Common/src/Path/PathWF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ int __fastcall PATH_FindSubpathWithoutObstacles(D2PathInfoStrc* pInfo, D2PathPoi
nMajorDirectionDistance = tSubPathStart.X - (pCurPath->tTargetCoord).X;
break;
}
default:
break;
}

if (nMajorDirectionDistance > 0)
Expand Down
2 changes: 2 additions & 0 deletions source/D2Common/src/Units/UnitRoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ void __stdcall UNITROOM_UpdatePath(D2UnitStrc* pUnit)
pUnit->pStaticPath->pRoom = NULL;
}
break;
default:
break;
}
}

Expand Down
2 changes: 2 additions & 0 deletions source/D2Common/src/Units/Units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3557,6 +3557,8 @@ BOOL __stdcall UNITS_CanDualWield(D2UnitStrc* pUnit)
return TRUE;
}
break;
default:
break;
}
}

Expand Down
1 change: 1 addition & 0 deletions source/D2Debugger/src/D2Debugger.Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ bool D2DebugGame(D2GameStrc* pGame)
case DIFFMODE_NORMAL:ImGui::Text("Normal"); break;
case DIFFMODE_NIGHTMARE:ImGui::Text("Nightmare"); break;
case DIFFMODE_HELL:ImGui::Text("Hell"); break;
default: D2_UNREACHABLE;
}
ImGui::Text("Init seed: 0x%x", pGame->dwInitSeed);
ImGui::Text("Frame %d", pGame->dwGameFrame);
Expand Down
2 changes: 2 additions & 0 deletions source/D2Debugger/src/D2Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ BOOL __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
break;
case DLL_THREAD_DETACH:
break;
default:
break;
}

return TRUE;
Expand Down
3 changes: 2 additions & 1 deletion source/D2Debugger/src/D2Debugger.imgui.d3d9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_DESTROY:
::PostQuitMessage(0);
return 0;
default:
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
}
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
}
4 changes: 4 additions & 0 deletions source/D2Game/src/AI/AiGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ void __fastcall AIGENERAL_SetAiControlParam(D2UnitStrc* pMonster, int32_t nIndex
case 3:
pAiControl->dwAiParam[2] = nParamValue;
break;
default:
break;
}
}

Expand All @@ -65,6 +67,8 @@ int32_t __fastcall AIGENERAL_GetAiControlParam(D2UnitStrc* pUnit, int32_t nIndex

case 3:
return pAiControl->dwAiParam[2];
default:
break;
}

return 0;
Expand Down
4 changes: 2 additions & 2 deletions source/D2Game/src/AI/AiTactics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,9 @@ D2UnitStrc* __fastcall AITACTICS_GetTargetMinion(D2GameStrc* pGame, D2UnitStrc*
}

return pTarget;
default:
return nullptr;
}

return nullptr;
}

//D2Game.0x6FCD1490
Expand Down
2 changes: 2 additions & 0 deletions source/D2Game/src/AI/AiThink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9489,6 +9489,8 @@ void __fastcall sub_6FCE4830(D2GameStrc* pGame, D2UnitStrc* pUnit, int32_t nMons
return;
}

break;
default:
break;
}

Expand Down
4 changes: 2 additions & 2 deletions source/D2Game/src/AI/AiUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,9 @@ D2UnitStrc* __fastcall sub_6FCF1E80(D2GameStrc* pGame, D2UnitStrc* pUnit, void*

return nullptr;
}
default:
return nullptr;
}

return nullptr;
}

//D2Game.0x6FCF20E0
Expand Down
4 changes: 4 additions & 0 deletions source/D2Game/src/GAME/Clients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,8 @@ int32_t __fastcall CLIENTS_GetUnitX(D2UnitStrc* pUnit)
case UNIT_ITEM:
case UNIT_TILE:
return pUnit->pStaticPath ? pUnit->pStaticPath->tGameCoords.nX : 0;
default:
break;
}

return 0;
Expand All @@ -1015,6 +1017,8 @@ int32_t __fastcall CLIENTS_GetUnitY(D2UnitStrc* pUnit)
case UNIT_ITEM:
case UNIT_TILE:
return pUnit->pStaticPath ? pUnit->pStaticPath->tGameCoords.nY : 0;
default:
break;
}

return 0;
Expand Down
2 changes: 2 additions & 0 deletions source/D2Game/src/ITEMS/ItemMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6010,6 +6010,8 @@ void __fastcall D2GAME_ITEMMODE_Unk_6FC4BC10(D2GameStrc* pGame, D2UnitStrc* pUni
ITEMS_RemoveFromAllPlayers(pGame, pItem);
return;
}
default:
break;
}
}

Expand Down
2 changes: 2 additions & 0 deletions source/D2Game/src/ITEMS/ItemsMagic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ int16_t __fastcall ITEMS_RollMagicAffixesNew(D2UnitStrc* pItem, int32_t bRequire
case ITEMQUAL_TEMPERED:
// Ignore magic-only affixes for rare/crafted objects.
continue;
default:
break;
}
}

Expand Down
4 changes: 4 additions & 0 deletions source/D2Game/src/MISSILES/MissMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ int32_t __fastcall MISSMODE_GetDamageValue(D2GameStrc* pGame, D2UnitStrc* pAttac
pDamage->dwFrzLen = STATLIST_UnitGetStatValue(pAttacker, STAT_COLDLENGTH, 0);
return pDamage->dwColdDamage;
}
default:
break;
}

return 0;
Expand Down Expand Up @@ -519,6 +521,8 @@ void __fastcall MISSMODE_AddDamageValue(D2GameStrc* pGame, D2UnitStrc* pMissile,
case ELEMTYPE_FREEZE:
pDamage->dwColdDamage = nDamage;
break;
default:
break;
}
}

Expand Down
3 changes: 2 additions & 1 deletion source/D2Game/src/MONSTER/MonsterMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,8 @@ const D2MonModeCallbackTableStrc* __fastcall MONSTERMODE_GetCallbackTableRecord(
return &gMonModeCallbacks[7];
}
break;

default:
break;
}
}

Expand Down
6 changes: 4 additions & 2 deletions source/D2Game/src/MONSTER/MonsterRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,9 @@ int32_t __fastcall sub_6FC670A0(int32_t nMonsterId)
case MONSTER_WINDOW1:
case MONSTER_WINDOW2:
return 0;
default:
return 1;
}

return 1;
}

//D2Game.0x6FC67190
Expand Down Expand Up @@ -1049,6 +1049,8 @@ D2MonRegDataStrc* __fastcall sub_6FC67FA0(D2MonsterRegionStrc** ppMonsterRegion,
case MONSTER_ACT3MALE:
case MONSTER_ACT3FEMALE:
return nullptr;
default:
break;
}

D2MonsterRegionStrc* pMonsterRegion = ppMonsterRegion[DUNGEON_GetLevelIdFromRoom(pRoom)];
Expand Down
20 changes: 13 additions & 7 deletions source/D2Game/src/MONSTER/MonsterUnique.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ void __fastcall MONSTERUNIQUE_UMod8_Resistant(D2UnitStrc* pUnit, int32_t nUMod,
case 28:
STATLIST_SetUnitStat(pUnit, STAT_DAMAGERESIST, nDamageResist + 50, 0);
break;
default:
break;
}
}
}
Expand Down Expand Up @@ -1519,11 +1521,15 @@ void __fastcall MONSTERUNIQUE_QuestCompleteModeChange(D2GameStrc* pGame, D2UnitS
QUESTSFX_ShenkTheOverseer(pGame, pUnit);
}
break;
//case MONSTER_ANCIENTBARB1:
//case MONSTER_ANCIENTBARB2:
//case MONSTER_ANCIENTBARB3:
// D2Game_10061_Return();
// break;
#if 0
case MONSTER_ANCIENTBARB1:
case MONSTER_ANCIENTBARB2:
case MONSTER_ANCIENTBARB3:
D2Game_10061_Return();
break;
#endif
default:
break;
}
}

Expand Down Expand Up @@ -2275,9 +2281,9 @@ int32_t __fastcall sub_6FC6EC10(D2UnitStrc* pUnit, D2MonUModTxt* pMonUModTxtReco

break;
}
default:
return 1;
}

return 1;
}

//D2Game.0x6FC6EE90
Expand Down
6 changes: 6 additions & 0 deletions source/D2Game/src/OBJECTS/ObjMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ void __fastcall sub_6FC750D0(D2GameStrc* pGame, D2UnitStrc* pObject)
case 3u:
UNITS_ChangeAnimMode(pObject, 4);
break;
default:
break;
}
}

Expand Down Expand Up @@ -2958,6 +2960,8 @@ int32_t __fastcall OBJECTS_OperateHandler(D2GameStrc* pGame, D2UnitStrc* pPlayer
case OBJECT_JERHYN_PLACEHOLDER1:
case OBJECT_JERHYN_PLACEHOLDER2:
return 0;
default:
break;
}

const ObjOperateFunction pOperateFn = gpObjOperateFnTable[pObjectTxtRecord->nOperateFn];
Expand Down Expand Up @@ -3643,6 +3647,8 @@ void __fastcall sub_6FC79B50(D2GameStrc* pGame, D2UnitStrc* pUnit, D2UnitStrc* p
UNITS_ChangeAnimMode(pObject, OBJMODE_NEUTRAL);
break;
}
default:
break;
}
}

Expand Down
2 changes: 2 additions & 0 deletions source/D2Game/src/OBJECTS/Objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ void __fastcall OBJECTS_InitFunction01_Shrine(D2ObjInitFnStrc* pOp)
case 16:
nShrineId = 18;
break;
default:
break;
}

pOp->pObject->pObjectData->InteractType = nShrineId;
Expand Down
4 changes: 2 additions & 2 deletions source/D2Game/src/PLAYER/PlayerStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ int32_t __fastcall PLAYERSTATS_SpendStatPoint(D2UnitStrc* pUnit, int32_t nStatId
}
return 1;
}
default:
return 0;
}

return 0;
}
Loading

0 comments on commit f016364

Please sign in to comment.