Merge branch 'master' into menu_for_real

This commit is contained in:
Christoph Oelckers 2019-11-26 19:19:21 +01:00
commit 0f4d80b5d3
21 changed files with 179 additions and 172 deletions

View file

@ -109,6 +109,7 @@ static FORCE_INLINE int FX_Pan3D(int handle, int angle, int distance)
return FX_CheckMVErr(MV_Pan3D(handle, angle, distance));
}
static FORCE_INLINE int FX_SoundActive(int handle) { return MV_VoicePlaying(handle); }
static FORCE_INLINE int FX_SoundValidAndActive(int handle) { return handle > 0 && MV_VoicePlaying(handle); }
static FORCE_INLINE int FX_SoundsPlaying(void) { return MV_VoicesPlaying(); }
static FORCE_INLINE int FX_StopSound(int handle) { return FX_CheckMVErr(MV_Kill(handle)); }
static FORCE_INLINE int FX_StopAllSounds(void) { return FX_CheckMVErr(MV_KillAllVoices()); }

View file

@ -1067,6 +1067,13 @@ FORCE_INLINE CONSTEXPR DivResult<T> divrhs(T lhs)
{
return divide(lhs, (T)base);
}
template <typename T, typename T2>
static FORCE_INLINE CONSTEXPR_CXX14 enable_if_t<is_signed<T>::value, T> NEGATE_ON_CONDITION(T value, T2 condition)
{
T const invert = !!condition;
return (value ^ -invert) + invert;
}
#endif
template <size_t base, typename T>
@ -1081,11 +1088,11 @@ CONSTEXPR size_t logbasenegative(T n)
return n > static_cast<T>(-(native_t)base) ? 1 : 1 + logbase<base>(n / static_cast<T>(-(native_t)base));
}
#endif
#define isPow2OrZero(v) (((v) & ((v) - 1)) == 0)
#define isPow2(v) (isPow2OrZero(v) && (v))
#endif
////////// Bitfield manipulation //////////
#if 0

View file

@ -650,7 +650,8 @@ static int32_t defsparser(scriptfile *script)
int32_t havexoffset = 0, haveyoffset = 0, haveextra = 0;
int32_t xoffset = 0, yoffset = 0;
int32_t istexture = 0;
int32_t tilecrc = 0, origcrc = 0;
int32_t tilecrc = 0;
uint8_t have_ifcrc = 0;
int32_t extra = 0;
static const tokenlist tilefromtexturetokens[] =
@ -695,6 +696,7 @@ static int32_t defsparser(scriptfile *script)
break;
case T_IFCRC:
scriptfile_getsymbol(script, &tilecrc);
have_ifcrc = 1;
break;
case T_TEXHITSCAN:
flags |= PICANM_TEXHITSCAN_BIT;
@ -721,9 +723,9 @@ static int32_t defsparser(scriptfile *script)
break;
}
if (tilecrc)
if (have_ifcrc)
{
origcrc = tileCRC(tile);
int32_t origcrc = tileCRC(tile);
if (origcrc != tilecrc)
{
//initprintf("CRC of tile %d doesn't match! CRC: %d, Expected: %d\n", tile, origcrc, tilecrc);

View file

@ -747,7 +747,7 @@ void videoSetPalette(char dabrightness, uint8_t dapalid, uint8_t flags)
int32_t palsumdidchange;
// uint32_t lastbright = curbrightness;
Bassert((flags & 4) == 0);
// Bassert((flags&4)==0); // What is so bad about this flag?
if (/*(unsigned)dapalid >= MAXBASEPALS ||*/ basepaltable[dapalid] == NULL)
dapalid = 0;

View file

@ -761,7 +761,6 @@ static FORCE_INLINE int __fastcall getvar__(int const gameVar, int const spriteN
int returnValue = 0;
int const varFlags = var.flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
int const invertResult = !!(gameVar & GV_FLAG_NEGATIVE);
if (!varFlags) returnValue = var.global;
else if (varFlags == GAMEVAR_PERACTOR)
@ -776,7 +775,7 @@ static FORCE_INLINE int __fastcall getvar__(int const gameVar, int const spriteN
case GAMEVAR_Q16PTR: returnValue = fix16_to_int(*(fix16_t *)var.global); break;
}
return (returnValue ^ -invertResult) + invertResult;
return NEGATE_ON_CONDITION(returnValue, gameVar & GV_FLAG_NEGATIVE);
}
}

View file

@ -663,7 +663,7 @@ static MenuEntry_t *MEL_DISPLAYSETUP_GL[] = {
static char const *MenuKeyNone = " -";
static char const MenuKeyNone[] = " -";
static char const *MEOSN_Keys[NUMKEYS];
static MenuCustom2Col_t MEO_KEYBOARDSETUPFUNCS_TEMPLATE = { 0, &MF_Minifont, NUMKEYS, 54<<16, 0 };
@ -1530,8 +1530,9 @@ void Menu_Init(void)
}
MEOS_Gamefuncs.numOptions = k;
for (i = 0; i < NUMKEYS; ++i)
for (i = 1; i < NUMKEYS-1; ++i)
MEOSN_Keys[i] = KB_ScanCodeToString(i);
MEOSN_Keys[0] = MenuKeyNone;
MEOSN_Keys[NUMKEYS-1] = MenuKeyNone;
// prepare levels

View file

@ -24,9 +24,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------
#include "ns.h"
// Added improved crosshair accuracy
// Added UsingMenus for fragbar
//
#include "build.h"

View file

@ -105,9 +105,6 @@ signed char MNU_InputString(char*, short);
SWBOOL IsCommand(const char* str);
SWBOOL MNU_StartNetGame(void);
const char* AppProperName = "VoidSW";
const char* AppTechnicalName = "voidsw";
#if DEBUG
#define BETA 0
@ -2304,6 +2301,9 @@ void BonusScreen(PLAYERp pp)
}
gStateControl(&State, &Tics);
videoClearViewableArea(0L);
rotatesprite(0, 0, RS_SCALE, 0, 5120, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
if (UserMapName[0])
@ -3908,7 +3908,6 @@ void GetHelpInput(PLAYERp pp)
}
short MirrorDelay;
int MouseYAxisMode = -1;
void getinput(SW_PACKET *loc)
{
@ -3927,16 +3926,11 @@ void getinput(SW_PACKET *loc)
#define MAXVEL ((NORMALKEYMOVE*2)+10)
#define MAXSVEL ((NORMALKEYMOVE*2)+10)
#define MAXANGVEL 100
#define MAXAIMVEL 128
#define SET_LOC_KEY(loc, sync_num, key_test) SET(loc, ((!!(key_test)) << (sync_num)))
ControlInfo info;
int32_t running;
int32_t turnamount;
static int32_t turnheldtime;
int32_t keymove;
int32_t momx, momy;
int aimvel;
int mouseaxis;
extern SWBOOL MenuButtonAutoRun;
extern SWBOOL MenuButtonAutoAim;
@ -3948,7 +3942,6 @@ void getinput(SW_PACKET *loc)
// reset all syncbits
loc->bits = 0;
svel = vel = angvel = aimvel = 0;
// MAKE SURE THIS WILL GET SET
SET_LOC_KEY(loc->bits, SK_QUIT_GAME, MultiPlayQuitFlag);
@ -3975,7 +3968,9 @@ void getinput(SW_PACKET *loc)
}
}
int const aimMode = TEST(pp->Flags, PF_MOUSE_AIMING_ON);
ControlInfo info;
CONTROL_GetInput(&info);
if (in_mousedeadzone)
@ -4062,39 +4057,10 @@ void getinput(SW_PACKET *loc)
SET_LOC_KEY(loc->bits, SK_SPACE_BAR, ((!!inputState.GetKeyStatus(KEYSC_SPACE)) | buttonMap.ButtonDown(gamefunc_Open)));
running = false;// G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
int const keyMove = running ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp
constexpr int const analogTurnAmount = (NORMALTURN << 1);
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
{
static int strafeyaw;
svel = -(info.mousex + strafeyaw) >> 3;
strafeyaw = (info.mousex + strafeyaw) % 8;
svel -= info.dyaw * keyMove / analogExtent;
}
else
{
angvel = fix16_div(fix16_from_int(info.mousex), F16(32));
angvel += fix16_from_int(info.dyaw) / analogExtent * (analogTurnAmount << 1);
angvel >>= 15;
}
aimvel = fix16_div(fix16_from_int(info.mousey), F16(64));
if (!in_mouseflip) // SW's mouse is inverted by default.
aimvel = -aimvel;
aimvel -= fix16_from_int(info.dpitch) / analogExtent * analogTurnAmount;
aimvel >>= 15;
svel -= info.dx * keyMove / analogExtent;
vel -= info.dz * keyMove / analogExtent;
int const running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
int32_t turnamount;
int32_t keymove;
constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp
if (running)
{
@ -4115,6 +4081,34 @@ void getinput(SW_PACKET *loc)
keymove = NORMALKEYMOVE;
}
info.dz = (info.dz * move_scale)>>8;
info.dyaw = (info.dyaw * turn_scale)>>8;
int32_t svel = 0, vel = 0, angvel = 0, aimvel = 0;
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
{
svel = -info.mousex;
svel -= info.dyaw * keymove / analogExtent;
}
else
{
angvel = info.mousex / 32;
angvel += info.dyaw * (turnamount << 1) / analogExtent;
}
if (true)//aimMode)
aimvel = -info.mousey / 64;
else
vel = -(info.mousey >> 6);
if (in_mouseflip)
aimvel = -aimvel;
aimvel -= info.dpitch * turnamount / analogExtent;
svel -= info.dx * keymove / analogExtent;
vel -= info.dz * keymove / analogExtent;
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
{
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
@ -4167,19 +4161,11 @@ void getinput(SW_PACKET *loc)
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
vel += -keymove;
vel = clamp(vel, -MAXVEL, MAXVEL);
svel = clamp(svel, -MAXSVEL, MAXSVEL);
if (vel < -MAXVEL)
vel = -MAXVEL;
if (vel > MAXVEL)
vel = MAXVEL;
if (svel < -MAXSVEL)
svel = -MAXSVEL;
if (svel > MAXSVEL)
svel = MAXSVEL;
if (angvel < -MAXANGVEL)
angvel = -MAXANGVEL;
if (angvel > MAXANGVEL)
angvel = MAXANGVEL;
angvel = clamp(angvel, -MAXANGVEL, MAXANGVEL);
aimvel = clamp(aimvel, -MAXAIMVEL, MAXAIMVEL);
momx = mulscale9(vel, sintable[NORM_ANGLE(newpp->pang + 512)]);
momy = mulscale9(vel, sintable[NORM_ANGLE(newpp->pang)]);

View file

@ -2251,7 +2251,6 @@ extern char keys[];
extern short screenpeek;
extern int dimensionmode, zoom;
extern int vel,svel,angvel;
#define STAT_DAMAGE_LIST_SIZE 20
extern int16_t StatDamageList[STAT_DAMAGE_LIST_SIZE];

View file

@ -578,7 +578,7 @@ JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz)
{
for (cnt = MAXMIRRORS - 1; cnt >= 0; cnt--)
//if (TEST_GOTPIC(cnt + MIRRORLABEL) || TEST_GOTPIC(cnt + CAMSPRITE))
if (TEST_GOTPIC(cnt + MIRRORLABEL) || TEST_GOTPIC(mirror[cnt].campic))
if (TEST_GOTPIC(cnt + MIRRORLABEL) || ((unsigned)mirror[cnt].campic < MAXTILES && TEST_GOTPIC(mirror[cnt].campic)))
{
bIsWallMirror = FALSE;
if (TEST_GOTPIC(cnt + MIRRORLABEL))
@ -587,7 +587,7 @@ JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz)
RESET_GOTPIC(cnt + MIRRORLABEL);
}
//else if (TEST_GOTPIC(cnt + CAMSPRITE))
else if (TEST_GOTPIC(mirror[cnt].campic))
else if ((unsigned)mirror[cnt].campic < MAXTILES && TEST_GOTPIC(mirror[cnt].campic))
{
//RESET_GOTPIC(cnt + CAMSPRITE);
RESET_GOTPIC(mirror[cnt].campic);

View file

@ -683,12 +683,6 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item)
{
inputState.ClearKeyStatus(inputState.GetLastScanCode());
//KeyboardKeys[currentkey][currentcol] = KB_GetLastScanCode();
#if 0 // [JM] Re-do this shit !CHECKME!
CONTROL_MapKey(currentkey,
KeyboardKeys[currentkey][0],
KeyboardKeys[currentkey][1]);
#endif
currentmode = 0;
}
@ -811,12 +805,12 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item)
MNU_DrawSmallString(OPT_XS, j, ds, (i==currentkey) ? 0 : 12, 16);
p = keyGetName(KeyboardKeys[i][0]);
if (!p || KeyboardKeys[i][0]==0xff) p = " -";
if (!p || !KeyboardKeys[i][0] || KeyboardKeys[i][0]==0xff) p = " -";
MNU_DrawSmallString(OPT_XSIDE, j, p, (i==currentkey) ? -5 : 12,
(i==currentkey && currentcol==0) ? 14 : 16);
p = keyGetName(KeyboardKeys[i][1]);
if (!p || KeyboardKeys[i][1]==0xff) p = " -";
if (!p || !KeyboardKeys[i][1] || KeyboardKeys[i][1]==0xff) p = " -";
MNU_DrawSmallString(OPT_XSIDE + 4*14, j, p, (i==currentkey) ? -5 : 12,
(i==currentkey && currentcol==1) ? 14 : 16);
#endif
@ -1276,7 +1270,7 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
//5261,
//5262
5114 // JBF: for my credits
5120 // 5114 // JBF: for my credits
};
static short SWOrderScreen[] =
{
@ -1288,7 +1282,7 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
5118,
4979,
5114 // JBF: for my credits
5120 // 5114 // JBF: for my credits
};
short *OrderScreen, OrderScreenSiz;
@ -1317,9 +1311,9 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
{
DidOrderSound = TRUE;
choose_snd = STD_RANDOM_RANGE(1000);
if (choose_snd > 500 && !FX_SoundActive(wanghandle))
if (choose_snd > 500 && !FX_SoundValidAndActive(wanghandle))
wanghandle = PlaySound(DIGI_WANGORDER1, &zero, &zero, &zero, v3df_dontpan);
else if (!FX_SoundActive(wanghandle))
else if (!FX_SoundValidAndActive(wanghandle))
wanghandle = PlaySound(DIGI_WANGORDER2, &zero, &zero, &zero, v3df_dontpan);
}
@ -1416,7 +1410,8 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
on_screen = 0;
// CTW MODIFICATION END
rotatesprite(0,0,RS_SCALE,0,OrderScreen[on_screen],0,0,
int const shade = on_screen == OrderScreenSiz-1 ? 8 : 0;
rotatesprite(0,0,RS_SCALE,0,OrderScreen[on_screen], shade, 0,
(ROTATE_SPRITE_CORNER|ROTATE_SPRITE_SCREEN_CLIP|ROTATE_SPRITE_NON_MASK|ROTATE_SPRITE_IGNORE_START_MOST),
0, 0, xdim-1, ydim-1);
@ -1427,38 +1422,31 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
static const char *jtitle = "^Port Credits";
static const char *jtext[] =
{
"*GAME AND ENGINE PORT",
"*Developers",
" Richard \"TerminX\" Gobeille",
" Evan \"Hendricks266\" Ramos",
" Alex \"pogokeen\" Dawson",
"*Retired developers",
" Pierre-Loup \"Plagman\" Griffais",
" Philipp \"Helixhorned\" Kutin",
"*Special thanks to",
" Jonathon \"JonoF\" Fowler",
"-",
"*\"POLYMOST\" 3D RENDERER",
"*NETWORKING, OTHER CODE",
"*Uses BUILD Engine technology by",
" Ken \"Awesoken\" Silverman",
"*Additional thanks to",
" Alexey \"Nuke.YKT\" Skrybykin",
" Jordon \"Striker\" Moss",
" Par \"Parkar\" Karlsson", // "Pär \"Parkar\" Karlsson",
" Ben \"ProAsm\" Smit",
" NY00123",
"-",
" Visit http://www.jonof.id.au/jfsw for the",
" source code, latest news, and updates of this port."
" Visit eduke32.com for news and updates"
};
#if 0
static const char *scroller[] =
{
"This program is free software; you can redistribute it",
"and/or modify it under the terms of the GNU General",
"Public License as published by the Free Software",
"Foundation; either version 2 of the License, or (at your",
"option) any later version.",
"",
"This program is distributed in the hope that it will be",
"useful but WITHOUT ANY WARRANTY; without even the implied",
"warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR",
"PURPOSE. See the GNU General Public License (GPL.TXT) for",
"more details.",
"",
"",
"",
"",
"Thanks to these people for their input and contributions:",
"",
"Richard \"TerminX\" Gobeille,",
"Par \"Parkar\" Karlsson", // "Pär \"Parkar\" Karlsson",
"Ben \"ProAsm\" Smit",
"",
"and all those who submitted bug reports and ",
"supported the project financially!",
@ -1470,9 +1458,9 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
"",
""
};
const int numscrollerlines = SIZ(scroller);
#endif
short dimx, dimy;
int ycur = 54;
int ycur = 20;
unsigned ji;
dimy = 0; MNU_MeasureString(jtitle, &dimx, &dimy);
@ -1502,6 +1490,8 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
}
}
#if 0
const int numscrollerlines = SIZ(scroller);
int m,i;
for (m=0, i=((int32_t) totalclock/104)%numscrollerlines; m<4; m++,i++)
{
@ -1511,6 +1501,7 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
MNU_MeasureSmallString(scroller[i], &dimx, &dimy);
MNU_DrawSmallString(160-(dimx>>1), 154+(m*7), scroller[i], 0, 8);
}
#endif
}
//inputState.ClearKeysDown();
@ -2893,11 +2884,8 @@ MNU_JoystickCheck(MenuItem *item)
static SWBOOL
MNU_TryMusicInit(void)
{
if (PlaySong(0, RedBookSong[Level], TRUE, FALSE))
{
if (currentmenu->cursor == 0)
MNU_MusicCheck(&currentmenu->items[currentmenu->cursor+1]);
}
return TRUE;
}
@ -3773,11 +3761,11 @@ static void MNU_DownLevel(MenuGroup * group)
static void MNU_UpLevel(void)
{
int zero = 0;
static int handle1=0;
static int handle1;
// if run out of menus then EXIT
if (!menuarrayptr)
{
if(!FX_SoundActive(handle1))
if (!FX_SoundValidAndActive(handle1))
handle1 = PlaySound(DIGI_STARCLINK,&zero,&zero,&zero,v3df_dontpan);
ExitMenus();
return;
@ -4118,7 +4106,7 @@ void MNU_DoMenu( CTLType type, PLAYERp pp )
SWBOOL resetitem;
unsigned char key;
int zero = 0;
static int handle2 = 0;
static int handle2;
static int limitmove=0;
static SWBOOL select_held=FALSE;
@ -4152,7 +4140,7 @@ void MNU_DoMenu( CTLType type, PLAYERp pp )
{
static int handle5=0;
I_GeneralTriggerClear();
if (!FX_SoundActive(handle5))
if (!FX_SoundValidAndActive(handle5))
handle5 = PlaySound(DIGI_SWORDSWOOSH,&zero,&zero,&zero,v3df_dontpan);
inputState.ClearKeysDown();
MNU_DoItem();
@ -4175,16 +4163,16 @@ void MNU_DoMenu( CTLType type, PLAYERp pp )
else if (I_ReturnTrigger())
{
I_ReturnTriggerClear();
static int handle3=0;
if (!FX_SoundActive(handle3))
static int handle3;
if (!FX_SoundValidAndActive(handle3))
handle3 = PlaySound(DIGI_SWORDSWOOSH,&zero,&zero,&zero,v3df_dontpan);
MNU_UpLevel();
resetitem = TRUE;
}
else if (MNU_DoHotkey())
{
static int handle4=0;
if (!FX_SoundActive(handle4))
static int handle4;
if (!FX_SoundValidAndActive(handle4))
handle4 = PlaySound(DIGI_STAR,&zero,&zero,&zero,v3df_dontpan);
resetitem = TRUE;
}

View file

@ -173,7 +173,7 @@ int DoToiletGirl(short SpriteNum)
choose_snd = RANDOM_P2(1024<<4)>>4;
if (!FX_SoundActive(handle))
if (!FX_SoundValidAndActive(handle))
{
if (choose_snd > 750)
handle = PlaySound(DIGI_TOILETGIRLFART1,&sp->x,&sp->y,&sp->z,v3df_dontpan);
@ -188,7 +188,7 @@ int DoToiletGirl(short SpriteNum)
{
static int madhandle;
if (!FX_SoundActive(madhandle))
if (!FX_SoundValidAndActive(madhandle))
{
if (RANDOM_RANGE(1000<<8)>>8 > 500)
madhandle = PlaySound(DIGI_ANIMEMAD1,&sp->x,&sp->y,&sp->z,v3df_dontpan);
@ -235,7 +235,7 @@ int NullToiletGirl(short SpriteNum)
{
static int madhandle;
if (!FX_SoundActive(madhandle))
if (!FX_SoundValidAndActive(madhandle))
{
if (RANDOM_RANGE(1000<<8)>>8 > 500)
madhandle = PlaySound(DIGI_ANIMEMAD1,&sp->x,&sp->y,&sp->z,v3df_dontpan);
@ -416,7 +416,7 @@ int DoWashGirl(short SpriteNum)
{
static int handle;
if (!FX_SoundActive(handle))
if (!FX_SoundValidAndActive(handle))
{
if (RANDOM_P2(1024<<4)>>4 > 500)
handle = PlaySound(DIGI_ANIMESING1,&sp->x,&sp->y,&sp->z,v3df_dontpan);
@ -446,7 +446,7 @@ int DoWashGirl(short SpriteNum)
{
static int madhandle;
if (!FX_SoundActive(madhandle))
if (!FX_SoundValidAndActive(madhandle))
{
if (RANDOM_RANGE(1000<<8)>>8 > 500)
madhandle = PlaySound(DIGI_ANIMEMAD1,&sp->x,&sp->y,&sp->z,v3df_dontpan);
@ -490,7 +490,7 @@ int NullWashGirl(short SpriteNum)
{
static int madhandle;
if (!FX_SoundActive(madhandle))
if (!FX_SoundValidAndActive(madhandle))
{
if (RANDOM_RANGE(1000<<8)>>8 > 500)
madhandle = PlaySound(DIGI_ANIMEMAD1,&sp->x,&sp->y,&sp->z,v3df_dontpan);
@ -1305,7 +1305,7 @@ int DoCarGirl(short SpriteNum)
{
static int madhandle;
if (!FX_SoundActive(madhandle))
if (!FX_SoundValidAndActive(madhandle))
{
short choose;
choose = RANDOM_RANGE(1000);
@ -1360,7 +1360,7 @@ int NullCarGirl(short SpriteNum)
{
static int madhandle;
if (!FX_SoundActive(madhandle))
if (!FX_SoundValidAndActive(madhandle))
{
short choose;
choose = RANDOM_RANGE(1000);
@ -1532,7 +1532,7 @@ int DoMechanicGirl(short SpriteNum)
{
static int madhandle;
if (!FX_SoundActive(madhandle))
if (!FX_SoundValidAndActive(madhandle))
{
short choose;
choose = RANDOM_RANGE(1000);
@ -1587,7 +1587,7 @@ int NullMechanicGirl(short SpriteNum)
{
static int madhandle;
if (!FX_SoundActive(madhandle))
if (!FX_SoundValidAndActive(madhandle))
{
short choose;
choose = RANDOM_RANGE(1000);
@ -1760,7 +1760,7 @@ int DoSailorGirl(short SpriteNum)
{
static int madhandle;
if (!FX_SoundActive(madhandle))
if (!FX_SoundValidAndActive(madhandle))
{
short choose;
choose = RANDOM_RANGE(1000);
@ -1820,7 +1820,7 @@ int NullSailorGirl(short SpriteNum)
{
static int madhandle;
if (!FX_SoundActive(madhandle))
if (!FX_SoundValidAndActive(madhandle))
{
short choose;
choose = RANDOM_RANGE(1000);
@ -1968,7 +1968,7 @@ int DoPruneGirl(short SpriteNum)
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;
short rnd_range = 0;
static int madhandle=0,coyhandle=0;
static int madhandle, coyhandle;
SWBOOL ICanSee = FALSE;
DoActorPickClosePlayer(SpriteNum);
@ -1978,7 +1978,7 @@ int DoPruneGirl(short SpriteNum)
{
if ((u->WaitTics -= ACTORMOVETICS) <= 0 && ICanSee)
{
if (!FX_SoundActive(madhandle))
if (!FX_SoundValidAndActive(madhandle))
{
short choose;
choose = STD_RANDOM_RANGE(1000);
@ -1998,7 +1998,7 @@ int DoPruneGirl(short SpriteNum)
}
else
{
if (!FX_SoundActive(coyhandle))
if (!FX_SoundValidAndActive(coyhandle))
{
short choose;
choose = STD_RANDOM_RANGE(1000);
@ -2049,7 +2049,7 @@ int NullPruneGirl(short SpriteNum)
{
static int madhandle;
if (!FX_SoundActive(madhandle))
if (!FX_SoundValidAndActive(madhandle))
{
short choose;
choose = RANDOM_RANGE(1000);

View file

@ -997,7 +997,11 @@ int WeaponOperate(PLAYERp pp)
if (pp->WpnRocketType != 2 || pp->CurWpn != pp->Wpn[WPN_MICRO])
{
pp->InitingNuke = FALSE;
FX_StopSound(pp->nukevochandle);
if (pp->nukevochandle > 0)
{
FX_StopSound(pp->nukevochandle);
pp->nukevochandle = 0;
}
}
return 0;

View file

@ -134,7 +134,6 @@ extern SWBOOL FinishedLevel;
char PlayerGravity = PLAYER_JUMP_GRAV;
#endif
int vel, svel, angvel;
extern SWBOOL DebugOperate;
//unsigned char synctics, lastsynctics;
@ -2405,7 +2404,6 @@ MoveScrollMode2D(PLAYERp pp)
#define MAXANGVEL 100
ControlInfo scrl_input;
int32_t running;
int32_t keymove;
int32_t momx, momy;
static int mfvel=0, mfsvel=0;
@ -2436,19 +2434,19 @@ MoveScrollMode2D(PLAYERp pp)
Follow_posy = pp->posy;
}
running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
if (buttonMap.ButtonDown(gamefunc_Strafe))
mfsvel -= scrl_input.dyaw>>2;
mfsvel -= scrl_input.dx>>2;
mfvel = -scrl_input.dz>>2;
#if 0
int const running = !!BUTTON(gamefunc_Run) ^ !!TEST(pp->Flags, PF_LOCK_RUN);
if (running)
{
//keymove = NORMALKEYMOVE << 1;
keymove = NORMALKEYMOVE;
keymove = NORMALKEYMOVE << 1;
}
else
#endif
{
keymove = NORMALKEYMOVE;
}
@ -3116,7 +3114,7 @@ DriveCrush(PLAYERp pp, int *x, int *y)
if (sp->z < sop->crush_z)
continue;
vel = FindDistance2D(pp->xvect>>8, pp->yvect>>8);
int32_t const vel = FindDistance2D(pp->xvect>>8, pp->yvect>>8);
if (vel < 9000)
{
DoActorBeginSlide(i, getangle(pp->xvect, pp->yvect), vel/8, 5);
@ -3738,7 +3736,7 @@ DoPlayerFall(PLAYERp pp)
PlaySound(DIGI_HITGROUND, &pp->posx, &pp->posy, &pp->posz, v3df_follow|v3df_dontpan);
}
if (handle && FX_SoundActive(handle))
if (FX_SoundValidAndActive(handle))
{
// My sound code will detect the sound has stopped and clean up
// for you.
@ -5168,9 +5166,10 @@ DoPlayerStopDiveNoWarp(PLAYERp pp)
if (!NoMeters) SetRedrawScreen(pp);
if (pp->TalkVocHandle && FX_SoundActive(pp->TalkVocHandle))
if (FX_SoundValidAndActive(pp->TalkVocHandle))
{
FX_StopSound(pp->TalkVocHandle);
pp->TalkVocHandle = 0;
pp->PlayerTalking = FALSE;
}
@ -5203,9 +5202,10 @@ DoPlayerStopDive(PLAYERp pp)
if (!NoMeters) SetRedrawScreen(pp);
if (pp->TalkVocHandle && FX_SoundActive(pp->TalkVocHandle))
if (FX_SoundValidAndActive(pp->TalkVocHandle))
{
FX_StopSound(pp->TalkVocHandle);
pp->TalkVocHandle = 0;
pp->PlayerTalking = FALSE;
}
@ -6505,7 +6505,7 @@ DoPlayerBeginDie(PLAYERp pp)
// Override any previous talking, death scream has precedance
if (pp->PlayerTalking)
{
if (FX_SoundActive(pp->TalkVocHandle))
if (FX_SoundValidAndActive(pp->TalkVocHandle))
FX_StopSound(pp->TalkVocHandle);
pp->PlayerTalking = FALSE;
pp->TalkVocnum = -1;

View file

@ -1246,11 +1246,11 @@ int DoRipper2StandHeart(short SpriteNum)
{
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum];
static int riphearthandle=0;
static int riphearthandle;
NullRipper2(SpriteNum);
if (!FX_SoundActive(riphearthandle))
if (!FX_SoundValidAndActive(riphearthandle))
riphearthandle = PlaySound(DIGI_RIPPER2HEARTOUT,&sp->x,&sp->y,&sp->z,v3df_none);
if ((u->WaitTics -= ACTORMOVETICS) <= 0)

View file

@ -830,9 +830,10 @@ GetUpperLowerSector(short match, int x, int y, short *upper, short *lower)
if (!found)
continue;
sectorlist[sln] = i;
if (sln < (int)SIZ(GlobStackSect))
GlobStackSect[sln] = i;
if (sln < (int)SIZ(sectorlist))
sectorlist[sln] = i;
sln++;
}
}
@ -845,10 +846,17 @@ GetUpperLowerSector(short match, int x, int y, short *upper, short *lower)
*lower = -1;
return;
}
else
// Map rooms have NOT been dragged on top of each other
else if (sln == 1)
{
*lower = sectorlist[0];
*upper = sectorlist[0];
return;
}
// Map rooms HAVE been dragged on top of each other
// inside will somtimes find that you are in two different sectors if the x,y
// is exactly on a sector line.
if (sln > 2)
else if (sln > 2)
{
//DSPRINTF(ds, "TOO MANY SECTORS FOUND: x=%d, y=%d, match=%d, num sectors %d, %d, %d, %d, %d, %d", x, y, match, sln, sectorlist[0], sectorlist[1], sectorlist[2], sectorlist[3], sectorlist[4]);
MONO_PRINT(ds);

View file

@ -493,6 +493,7 @@ int SaveGame(short save_num)
MWRITE(Track[i].TrackPoint, Track[i].NumPoints * sizeof(TRACK_POINT),1,fil);
}
int32_t svel = 0, vel = 0, angvel = 0;
MWRITE(&vel,sizeof(vel),1,fil);
MWRITE(&svel,sizeof(svel),1,fil);
MWRITE(&angvel,sizeof(angvel),1,fil);
@ -1013,6 +1014,7 @@ int LoadGame(short save_num)
}
}
int32_t svel, vel, angvel;
MREAD(&vel,sizeof(vel),1,fil);
MREAD(&svel,sizeof(svel),1,fil);
MREAD(&angvel,sizeof(angvel),1,fil);

View file

@ -197,8 +197,9 @@ WallSetup(void)
wall_num = wall[wall_num].point2)
{
SET(wall[wall_num].extra, WALLFX_LOOP_DONT_SPIN);
if (wall[wall_num].nextwall >= 0)
SET(wall[wall[wall_num].nextwall].extra, WALLFX_LOOP_DONT_SPIN);
auto const nextwall = wall[wall_num].nextwall;
if ((unsigned)nextwall < MAXSECTORS)
SET(wall[nextwall].extra, WALLFX_LOOP_DONT_SPIN);
}
break;

View file

@ -527,9 +527,10 @@ StopSong(void)
if (DemoMode)
return;
if (SongType == SongTypeWave && SongVoice >= 0)
if (SongType == SongTypeWave && SongVoice > 0)
{
FX_StopSound(SongVoice);
SongVoice = 0;
}
else if (SongType == SongTypeMIDI)
{
@ -553,7 +554,7 @@ PauseSong(SWBOOL pauseon)
{
if (!MusicEnabled()) return;
if (SongType == SongTypeWave && SongVoice >= 0)
if (SongType == SongTypeWave && SongVoice > 0)
{
FX_PauseVoice(SongVoice, pauseon);
}
@ -1313,9 +1314,10 @@ DeleteNoSoundOwner(short spritenum)
// Make sure to stop active
// sounds
if (FX_SoundActive(vp->handle))
if (FX_SoundValidAndActive(vp->handle))
{
FX_StopSound(vp->handle);
vp->handle = 0;
}
#if 0
@ -1372,9 +1374,10 @@ void DeleteNoFollowSoundOwner(short spritenum)
// If the follow flag is set, compare the x and y addresses.
if ((vp->flags & v3df_follow) && vp->x == &sp->x && vp->y == &sp->y)
{
if (FX_SoundActive(vp->handle))
if (FX_SoundValidAndActive(vp->handle))
{
FX_StopSound(vp->handle);
vp->handle = 0;
}
#if 0
@ -1529,7 +1532,7 @@ DoTimedSound(VOC3D_INFOp p)
if (p->tics >= p->maxtics)
{
if (!FX_SoundActive(p->handle))
if (!FX_SoundValidAndActive(p->handle))
{
// Check for special case ambient sounds
p->num = RandomizeAmbientSpecials(p->num);
@ -1549,7 +1552,7 @@ DoTimedSound(VOC3D_INFOp p)
p->deleted = TRUE; // Mark old sound for deletion
}
}
} // !FX_SoundActive
}
p->tics = 0;
//while (p->tics >= p->maxtics) // Really stupid thing to do!
@ -1577,8 +1580,11 @@ StopAmbientSound(void)
if (p->flags & v3df_kill)
{
if (FX_SoundActive(p->handle))
if (FX_SoundValidAndActive(p->handle))
{
FX_StopSound(p->handle); // Make sure to stop active sounds
p->handle = 0;
}
p->deleted = TRUE;
}
@ -1668,8 +1674,11 @@ DoUpdateSounds3D(void)
// Is the sound slated for death? Kill it, otherwise play it.
if (p->flags & v3df_kill)
{
if (FX_SoundActive(p->handle))
if (FX_SoundValidAndActive(p->handle))
{
FX_StopSound(p->handle); // Make sure to stop active sounds
p->handle = 0;
}
//DSPRINTF(ds,"%d had v3df_kill.\n",p->num);
//MONO_PRINT(ds);
@ -1677,7 +1686,7 @@ DoUpdateSounds3D(void)
}
else
{
if (!FX_SoundActive(p->handle) && !looping)
if (!FX_SoundValidAndActive(p->handle) && !looping)
{
if (p->flags & v3df_intermit)
{
@ -1691,7 +1700,7 @@ DoUpdateSounds3D(void)
p->deleted = TRUE;
}
}
else if (FX_SoundActive(p->handle))
else if (FX_SoundValidAndActive(p->handle))
{
if (p->flags & v3df_follow)
{
@ -1732,6 +1741,7 @@ DoUpdateSounds3D(void)
if (dist >= 255 && p->vp->voc_distance == DIST_NORMAL)
{
FX_StopSound(p->handle); // Make sure to stop active
p->handle = 0;
// sounds
}
else
@ -1770,7 +1780,7 @@ DoUpdateSounds3D(void)
}
}
}
else if (!FX_SoundActive(p->handle) && looping)
else if (!FX_SoundValidAndActive(p->handle) && looping)
{
if (p->flags & v3df_follow)
{
@ -1898,7 +1908,9 @@ Terminate3DSounds(void)
while (vp)
{
FX_StopSound(vp->handle); // Make sure to stop active sounds
if (vp->handle > 0)
FX_StopSound(vp->handle); // Make sure to stop active sounds
vp->handle = 0;
vp->deleted = TRUE;
vp = vp->next;
}

View file

@ -9251,7 +9251,7 @@ DoVulcanBoulder(int16_t Weapon)
u->ret = move_missile(Weapon, u->xchange, u->ychange, u->zchange,
u->ceiling_dist, u->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS);
vel = ksqrt(SQ(u->xchange) + SQ(u->ychange));
int32_t const vel = ksqrt(SQ(u->xchange) + SQ(u->ychange));
if (vel < 30)
{
@ -11268,7 +11268,7 @@ SpawnNuclearSecondaryExp(int16_t Weapon, short ang)
RESET(exp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
//ang = RANDOM_P2(2048);
vel = (2048+128) + RANDOM_RANGE(2048);
int32_t const vel = (2048+128) + RANDOM_RANGE(2048);
eu->xchange = MOVEx(vel, ang);
eu->ychange = MOVEy(vel, ang);
eu->Radius = 200; // was NUKE_RADIUS

View file

@ -725,7 +725,7 @@ int DoZillaMove(short SpriteNum)
//DoActorSlide(SpriteNum);
// Random Zilla taunts
if (!FX_SoundActive(handle))
if (!FX_SoundValidAndActive(handle))
{
choose = STD_RANDOM_RANGE(1000);
if (choose > 990)