From 3a73a9f8edef67946cc4d72831e8c05e4e500b84 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 7 Nov 2021 14:36:39 +0100 Subject: [PATCH] - Duke/RR: replaced more local short variables with ints. --- source/games/duke/src/animatesprites_d.cpp | 6 ++---- source/games/duke/src/d_menu.cpp | 4 ++-- source/games/duke/src/funct.h | 2 +- source/games/duke/src/gameexec.cpp | 4 ++-- source/games/duke/src/hudweapon_d.cpp | 2 +- source/games/duke/src/hudweapon_r.cpp | 20 +++++++++--------- source/games/duke/src/player_d.cpp | 8 ++++---- source/games/duke/src/player_r.cpp | 24 +++++++++++----------- source/games/duke/src/player_w.cpp | 4 ++-- source/games/duke/src/spawn.cpp | 2 +- 10 files changed, 37 insertions(+), 39 deletions(-) diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index e57007d22..93554f006 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -215,13 +215,11 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int case FORCESPHERE: if (t->statnum == STAT_MISC && Owner) { - short sqa, sqb; - - sqa = + int sqa = getangle( Owner->x - ps[screenpeek].pos.x, Owner->y - ps[screenpeek].pos.y); - sqb = + int sqb = getangle( Owner->x - t->x, Owner->y - t->y); diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index ea3ea9a23..6b3b39168 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -99,8 +99,8 @@ bool GameInterface::StartGame(FNewGameStartup& gs) { int32_t skillsound = PISTOL_BODYHIT; - static const short sounds_d[] = { JIBBED_ACTOR6, BONUS_SPEECH1, DUKE_GETWEAPON2, JIBBED_ACTOR5, JIBBED_ACTOR5 }; - static const short sounds_r[] = { 427, 428, 196, 195, 197 }; + static const uint16_t sounds_d[] = { JIBBED_ACTOR6, BONUS_SPEECH1, DUKE_GETWEAPON2, JIBBED_ACTOR5, JIBBED_ACTOR5 }; + static const uint16_t sounds_r[] = { 427, 428, 196, 195, 197 }; if (gs.Skill >=0 && gs.Skill <= 5) skillsound = isRR()? sounds_r[gs.Skill] : sounds_d[gs.Skill]; if (menu_sounds && skillsound >= 0 && SoundEnabled() && !netgame) diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index dc54f64ac..f60a1adac 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -169,7 +169,7 @@ int furthestangle(DDukeActor* snum, int angDiv); void getglobalz(DDukeActor* s); void OnEvent(int id, int pnum = -1, DDukeActor* snum = nullptr, int dist = -1); -DDukeActor* EGS(short whatsect, int s_x, int s_y, int s_z, short s_pn, int8_t s_s, int8_t s_xr, int8_t s_yr, short s_a, short s_ve, int s_zv, DDukeActor* s_ow, int8_t s_ss); +DDukeActor* EGS(int whatsect, int s_x, int s_y, int s_z, int s_pn, int8_t s_s, int8_t s_xr, int8_t s_yr, int s_a, int s_ve, int s_zv, DDukeActor* s_ow, int8_t s_ss); void ceilingglass(DDukeActor* snum, int sectnum, int cnt); void spriteglass(DDukeActor* snum, int cnt); void lotsofcolourglass(DDukeActor* snum, int wallNum, int cnt); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 18990826e..c9e1add4b 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2163,7 +2163,7 @@ int ParseState::parse(void) break; case concmd_debris: { - short dnum; + int dnum; insptr++; dnum = *insptr; @@ -3111,7 +3111,7 @@ int ParseState::parse(void) case concmd_getangletotarget: { int i; - short ang; + int ang; insptr++; i = *(insptr++); // ID of def diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index 72da33f27..111a54b87 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -88,7 +88,7 @@ void displayloogie(player_struct* p) int animatefist(int gs, player_struct* p, double look_anghalf, double looking_arc, double plravel, int fistpal) { - short fisti; + int fisti; double fistzoom; double fistz; diff --git a/source/games/duke/src/hudweapon_r.cpp b/source/games/duke/src/hudweapon_r.cpp index 527544d5c..5a5459e5a 100644 --- a/source/games/duke/src/hudweapon_r.cpp +++ b/source/games/duke/src/hudweapon_r.cpp @@ -322,7 +322,7 @@ void displayweapon_r(int snum, double smoothratio) static const uint16_t kb_ox[] = { 310,342,364,418,350,316,282,288,0,0 }; static const uint16_t kb_oy[] = { 300,362,320,268,248,248,277,420,0,0 }; double x; - short y; + int y; x = weapon_xoffset + ((kb_ox[kb_frames[*kb]] >> 1) - 12); y = 200 - (244 - kb_oy[kb_frames[*kb]]); hud_drawpal(x - look_anghalf, looking_arc + y - gun_pos, @@ -341,7 +341,7 @@ void displayweapon_r(int snum, double smoothratio) static const uint16_t kb_ox[] = { 580,676,310,491,356,210,310,614 }; static const uint16_t kb_oy[] = { 369,363,300,323,371,400,300,440 }; double x; - short y; + int y; x = weapon_xoffset + ((kb_ox[kb_frames[*kb]] >> 1) - 12); y = 210 - (244 - kb_oy[kb_frames[*kb]]); hud_drawpal(x - look_anghalf + 20, looking_arc + y - gun_pos - 80, @@ -491,13 +491,13 @@ void displayweapon_r(int snum, double smoothratio) { double x; - short y; + int y; static const uint8_t kb_frames3[] = { 0,0,1,1,2,2,5,5,6,6,7,7,8,8,0,0,0,0,0,0,0 }; static const uint8_t kb_frames2[] = { 0,0,3,3,4,4,5,5,6,6,7,7,8,8,0,0,20,20,21,21,21,21,20,20,20,20,0,0 }; static const uint8_t kb_frames[] = { 0,0,1,1,2,2,3,3,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,0,0,20,20,21,21,21,21,20,20,20,20,0,0 }; static const uint16_t kb_ox[] = { 300,300,300,300,300,330,320,310,305,306,302 }; static const uint16_t kb_oy[] = { 315,300,302,305,302,302,303,306,302,404,384 }; - short tm; + int tm; tm = 180; if (p->shotgun_state[1]) { @@ -635,7 +635,7 @@ void displayweapon_r(int snum, double smoothratio) static const uint16_t kb_ox[] = { 194,190,185,208,215,215,216,216,201,170 }; static const uint16_t kb_oy[] = { 256,249,248,238,228,218,208,256,245,258 }; double x; - short y; + int y; x = weapon_xoffset + (kb_ox[kb_frames[*kb]] - 12); y = 244 - (244 - kb_oy[kb_frames[*kb]]); @@ -652,9 +652,9 @@ void displayweapon_r(int snum, double smoothratio) static const uint16_t kb_ox[] = { 244,244,244 }; static const uint16_t kb_oy[] = { 256,249,248 }; double x; - short dx; - short y; - short dy; + int dx; + int y; + int dy; x = weapon_xoffset + (kb_ox[kb_frames[(*kb) - 22]] - 12); y = 244 - (244 - kb_oy[kb_frames[(*kb) - 22]]); @@ -825,8 +825,8 @@ void displayweapon_r(int snum, double smoothratio) } else { - int8_t kb_frames[] = { 1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0 }; - short frm = kb_frames[*kb]; + static const int8_t kb_frames[] = { 1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0 }; + int frm = kb_frames[*kb]; rd2myospal(weapon_xoffset + 184 - look_anghalf, looking_arc + 240 - gun_pos, SHRINKER + frm, shade, o, 0); } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index f48962187..d78276609 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -564,7 +564,7 @@ static void shootstuff(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, spritetype* const s = actor->s; int sect = s->sectnum; int vel, zvel; - short l, scount; + int l, scount; if (s->extra >= 0) s->shade = -96; @@ -675,7 +675,7 @@ static void shootrpg(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, i auto s = actor->s; int sect = s->sectnum; int vel, zvel; - short l, scount; + int l, scount; if (s->extra >= 0) s->shade = -96; @@ -996,7 +996,7 @@ void shoot_d(DDukeActor* actor, int atwith) { spritetype* const s = actor->s; - short sect, l, j; + int sect, l, j; int sx, sy, sz, sa, p, vel, zvel, x, dal; if (s->picnum == TILE_APLAYER) { @@ -1622,7 +1622,7 @@ int doincrements_d(struct player_struct* p) void checkweapons_d(struct player_struct* p) { - static const short weapon_sprites[MAX_WEAPONS] = { KNEE, FIRSTGUNSPRITE, SHOTGUNSPRITE, + static const uint16_t weapon_sprites[MAX_WEAPONS] = { KNEE, FIRSTGUNSPRITE, SHOTGUNSPRITE, CHAINGUNSPRITE, RPGSPRITE, HEAVYHBOMB, SHRINKERSPRITE, DEVISTATORSPRITE, TRIPBOMBSPRITE, FREEZESPRITE, HEAVYHBOMB, SHRINKERSPRITE }; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index b9e494cd9..bc3db6746 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -44,7 +44,7 @@ BEGIN_DUKE_NS void incur_damage_r(struct player_struct* p) { int damage = 0, unk = 0, shield_damage = 0; - short gut = 0; + int gut = 0; p->GetActor()->s->extra -= p->extra_extra8 >> 8; @@ -604,7 +604,7 @@ static void shootrpg(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, i auto s = actor->s; int sect = s->sectnum; int vel, zvel; - short l, scount; + int l, scount; DDukeActor* act90 = nullptr; if (s->extra >= 0) s->shade = -96; @@ -756,7 +756,7 @@ static void shootwhip(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, auto s = actor->s; int sect = s->sectnum; int vel, zvel; - short scount; + int scount; if (s->extra >= 0) s->shade = -96; @@ -830,7 +830,7 @@ void shoot_r(DDukeActor* actor, int atwith) { spritetype* const s = actor->s; - short sect, sa, p; + int sect, sa, p; int sx, sy, sz, vel, zvel, x; @@ -1578,7 +1578,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) auto p = &ps[snum]; auto pact = p->GetActor(); - short rng; + int rng; if (p->MotoSpeed < 0) p->MotoSpeed = 0; @@ -1747,7 +1747,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) } int currSpeed = int(p->MotoSpeed); - short velAdjustment; + int velAdjustment; if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight)) { velAdjustment = p->vehTurnLeft ? -10 : 10; @@ -1816,7 +1816,7 @@ static void onBoat(int snum, ESyncBits &actions) auto pact = p->GetActor(); bool heeltoe; - short rng; + int rng; if (p->NotOnWater) { @@ -2017,7 +2017,7 @@ static void onBoat(int snum, ESyncBits &actions) if (p->MotoSpeed > 0 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight)) { int currSpeed = int(p->MotoSpeed * 4.); - short velAdjustment = p->vehTurnLeft ? -10 : 10; + int velAdjustment = p->vehTurnLeft ? -10 : 10; auto angAdjustment = (velAdjustment < 0 ? 350 : -350) << BAMBITS; if (p->moto_do_bump) @@ -2357,8 +2357,8 @@ void onMotorcycleMove(int snum, int psect, int j) auto pact = p->GetActor(); auto s = pact->s; int psectlotag = sector[psect].lotag; - short angleDelta = abs(p->angle.ang.asbuild() - getangle(wall[wall[j].point2].x - wall[j].x, wall[wall[j].point2].y - wall[j].y)); - short damageAmount; + int angleDelta = abs(p->angle.ang.asbuild() - getangle(wall[wall[j].point2].x - wall[j].x, wall[wall[j].point2].y - wall[j].y)); + int damageAmount; p->angle.addadjustment(p->MotoSpeed / (krand() & 1 ? -2 : 2)); @@ -2412,7 +2412,7 @@ void onBoatMove(int snum, int psect, int j) auto p = &ps[snum]; auto pact = p->GetActor(); int psectlotag = sector[psect].lotag; - short angleDelta = abs(p->angle.ang.asbuild() - getangle(wall[wall[j].point2].x - wall[j].x, wall[wall[j].point2].y - wall[j].y)); + int angleDelta = abs(p->angle.ang.asbuild() - getangle(wall[wall[j].point2].x - wall[j].x, wall[wall[j].point2].y - wall[j].y)); p->angle.addadjustment(p->MotoSpeed / (krand() & 1 ? -4 : 4)); @@ -3968,7 +3968,7 @@ HORIZONLY: } if (p->recoil && p->kickback_pic == 0) { - short d = p->recoil >> 1; + int d = p->recoil >> 1; if (!d) d = 1; p->recoil -= d; diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index 73ba08542..dc83e2667 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -49,7 +49,7 @@ int operateTripbomb(int snum); // //--------------------------------------------------------------------------- -void DoFire(struct player_struct* p, short snum) +void DoFire(struct player_struct* p, int snum) { int i; @@ -106,7 +106,7 @@ void DoFire(struct player_struct* p, short snum) // //--------------------------------------------------------------------------- -void DoSpawn(struct player_struct *p, short snum) +void DoSpawn(struct player_struct *p, int snum) { if(!aplWeaponSpawn[p->curr_weapon][snum]) return; diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index a1b505c19..c0a9edad2 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -49,7 +49,7 @@ BEGIN_DUKE_NS // //--------------------------------------------------------------------------- -DDukeActor* EGS(short whatsect, int s_x, int s_y, int s_z, short s_pn, int8_t s_s, int8_t s_xr, int8_t s_yr, short s_a, short s_ve, int s_zv, DDukeActor* s_ow, int8_t s_ss) +DDukeActor* EGS(int whatsect, int s_x, int s_y, int s_z, int s_pn, int8_t s_s, int8_t s_xr, int8_t s_yr, int s_a, int s_ve, int s_zv, DDukeActor* s_ow, int8_t s_ss) { int const i = insertsprite(whatsect, s_ss);