From ca14c809f9dd3fcddeb4e7ab9e43c191c071ba9f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 24 Dec 2021 12:08:50 +0100 Subject: [PATCH] - cleaned up some random crap with loops and bad variable types I just randomly found. --- source/CMakeLists.txt | 2 +- source/games/sw/src/weapon.cpp | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 2ce068d43..d45b85c7a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -25,7 +25,7 @@ endif() # Build does not work with signed chars! Also set a stricter warning level, but silence the pointless and annoying parts of level 4 (Intentionally only for C++! The C code we use is too old and would warn too much) if (MSVC) - set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /J /W4 /wd4100 /wd4127 /wd4131 /wd4201 /wd4210 /wd4244 /wd4245 /wd4324 /wd4389 /wd4505 /wd4706 /wd4458 /wd4459 /wd4703" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /J /W4 /wd4100 /wd4127 /wd4131 /wd4201 /wd4210 /wd4244 /wd4245 /wd4324 /wd4389 /wd4505 /wd4706 /wd4458 /wd4459" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4189" ) # "unused initialized local variable" - useful warning that creates too much noise in external or macro based code. Can be enabled for cleanup passes on the code. else() set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char -Wno-missing-braces -Wno-char-subscripts -Wno-unused-variable" ) diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index d2d88206d..31d83c395 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -12465,7 +12465,7 @@ int InitSwordAttack(PLAYERp pp) -256, -128, 0, 128, 256 }; - for (int i = 0; i < (int)SIZ(dangs); i++) + for (size_t i = 0; i < countof(dangs); i++) { if (RandomRange(1000) < 500) continue; // Don't spawn bubbles every time bubble = SpawnBubble(pp->Actor()); @@ -12646,7 +12646,7 @@ int InitFistAttack(PLAYERp pp) -128,128 }; - for (int i = 0; i < (int)SIZ(dangs); i++) + for (size_t i = 0; i < countof(dangs); i++) { bubble = SpawnBubble(pp->Actor()); if (bubble != nullptr) @@ -12837,7 +12837,7 @@ int InitSumoNapalm(DSWActor* actor) SPRITEp sp = &actor->s(), wp; USERp u = actor->u(), wu; short dist; - short i,j,ang; + short ang; typedef struct { @@ -12853,18 +12853,18 @@ int InitSumoNapalm(DSWActor* actor) PlaySound(DIGI_NAPFIRE, actor, v3df_none); ang = sp->ang; - for (j=0; j<4; j++) + for (int j = 0; j < 4; j++) { - for (i = 0; i < (int)SIZ(mp); i++) + for (size_t i = 0; i < countof(mp); i++) { auto wActor = SpawnActor(STAT_MISSILE, FIREBALL1, s_Napalm, sp->sector(), - sp->pos.X, sp->pos.Y, GetSpriteZOfTop(sp), ang, NAPALM_VELOCITY); + sp->pos.X, sp->pos.Y, GetSpriteZOfTop(sp), ang, NAPALM_VELOCITY); wp = &wActor->s(); wu = wActor->u(); wp->hitag = LUMINOUS; //Always full brightness - if (i==0) // Only attach sound to first projectile + if (i == 0) // Only attach sound to first projectile { PlaySound(DIGI_NAPWIZ, wActor, v3df_follow); } @@ -13316,7 +13316,6 @@ int InitStar(PLAYERp pp) int zvel; static short dang[] = {-12, 12}; - uint8_t i; SPRITEp np; USERp nu; const int STAR_REPEAT = 26; @@ -13380,7 +13379,7 @@ int InitStar(PLAYERp pp) wp->backuppos(); - for (i = 0; i < (int)SIZ(dang); i++) + for (size_t i = 0; i < countof(dang); i++) { auto actorNew2 = SpawnActor(STAT_MISSILE, STAR1, s_Star, pp->cursector, nx, ny, nz, NORM_ANGLE(wp->ang + dang[i]), wp->xvel); np = &actorNew2->s();