mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 20:20:40 +00:00
- the beginning of sector.cpp
The math backend functions have been moved out of Build because they originally have a good license. # Conflicts: # source/build/src/mdsprite.cpp # source/build/src/polymost.cpp
This commit is contained in:
parent
9c3189475a
commit
c8cb0e4efd
17 changed files with 644 additions and 413 deletions
|
@ -784,6 +784,7 @@ set (PCH_SOURCES
|
|||
build/src/voxmodel.cpp
|
||||
|
||||
core/animlib.cpp
|
||||
core/mathutil.cpp
|
||||
core/rts.cpp
|
||||
core/gameconfigfile.cpp
|
||||
core/gamecvars.cpp
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "compat.h"
|
||||
#include "pragmas.h" // klabs
|
||||
#include "scriptfile.h"
|
||||
#include "mathutil.h"
|
||||
|
||||
extern bool playing_rr;
|
||||
extern bool playing_blood;
|
||||
|
@ -65,45 +66,6 @@ int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens);
|
|||
|
||||
int32_t maybe_append_ext(char *wbuf, int32_t wbufsiz, const char *fn, const char *ext);
|
||||
|
||||
// Approximations to 2D and 3D Euclidean distances. Initial EDuke32 SVN import says
|
||||
// in mact/src/mathutil.c: "Ken's reverse-engineering job".
|
||||
// Note that mathutil.c contains practically the same code, but where the
|
||||
// individual x/y(/z) distances are passed instead.
|
||||
static inline int32_t sepldist(const int32_t dx, const int32_t dy)
|
||||
{
|
||||
vec2_t d = { klabs(dx), klabs(dy) };
|
||||
|
||||
if (!d.y) return d.x;
|
||||
if (!d.x) return d.y;
|
||||
|
||||
if (d.x < d.y)
|
||||
swaplong(&d.x, &d.y);
|
||||
|
||||
d.y += (d.y>>1);
|
||||
|
||||
return d.x - (d.x>>5) - (d.x>>7) + (d.y>>2) + (d.y>>6);
|
||||
}
|
||||
|
||||
// dz: in Build coordinates
|
||||
static inline int32_t sepdist(const int32_t dx, const int32_t dy, const int32_t dz)
|
||||
{
|
||||
vec3_t d = { klabs(dx), klabs(dy), klabs(dz>>4) };
|
||||
|
||||
if (d.x < d.y)
|
||||
swaplong(&d.x, &d.y);
|
||||
|
||||
if (d.x < d.z)
|
||||
swaplong(&d.x, &d.z);
|
||||
|
||||
d.y += d.z;
|
||||
|
||||
return d.x - (d.x>>4) + (d.y>>2) + (d.y>>3);
|
||||
}
|
||||
|
||||
int32_t FindDistance2D(int32_t dx, int32_t dy);
|
||||
int32_t FindDistance3D(int32_t dx, int32_t dy, int32_t dz);
|
||||
int32_t ldist(const void *s1, const void *s2);
|
||||
int32_t dist(const void *s1, const void *s2);
|
||||
|
||||
void COMMON_clearbackground(int32_t numcols, int32_t numrows);
|
||||
|
||||
|
|
|
@ -67,27 +67,3 @@ int32_t maybe_append_ext(char *wbuf, int32_t wbufsiz, const char *fn, const char
|
|||
}
|
||||
|
||||
|
||||
int32_t ldist(const void *s1, const void *s2)
|
||||
{
|
||||
auto sp1 = (vec2_t const *)s1;
|
||||
auto sp2 = (vec2_t const *)s2;
|
||||
return sepldist(sp1->x - sp2->x, sp1->y - sp2->y)
|
||||
+ (enginecompatibility_mode != ENGINECOMPATIBILITY_NONE ? 1 : 0);
|
||||
}
|
||||
|
||||
int32_t dist(const void *s1, const void *s2)
|
||||
{
|
||||
auto sp1 = (vec3_t const *)s1;
|
||||
auto sp2 = (vec3_t const *)s2;
|
||||
return sepdist(sp1->x - sp2->x, sp1->y - sp2->y, sp1->z - sp2->z);
|
||||
}
|
||||
|
||||
int32_t FindDistance2D(int32_t x, int32_t y)
|
||||
{
|
||||
return sepldist(x, y);
|
||||
}
|
||||
|
||||
int32_t FindDistance3D(int32_t x, int32_t y, int32_t z)
|
||||
{
|
||||
return sepdist(x, y, z);
|
||||
}
|
||||
|
|
|
@ -1587,10 +1587,11 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
|
|||
// to use Z-buffer hacks to hide overdraw problems with the flat-tsprite-on-floor shadows,
|
||||
// also disabling detail, glow, normal, and specular maps.
|
||||
|
||||
// WTF??? This should be done with proper math.
|
||||
if (tspr->clipdist & TSPR_FLAGS_MDHACK)
|
||||
{
|
||||
double f = (double) (tspr->owner + 1) * (std::numeric_limits<double>::epsilon() * 8.0);
|
||||
if (f != 0.0) f *= 1.0/(double) (sepldist(globalposx - tspr->x, globalposy - tspr->y)>>5);
|
||||
if (f != 0.0) f *= 1.0/(double) (FindDistance2D(globalposx - tspr->x, globalposy - tspr->y)>>5);
|
||||
GLInterface.SetDepthFunc(DF_LEqual);
|
||||
}
|
||||
|
||||
|
|
70
source/core/mathutil.cpp
Normal file
70
source/core/mathutil.cpp
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* mathutil.c
|
||||
* Mathematical utility functions to emulate MACT
|
||||
*
|
||||
* by Jonathon Fowler
|
||||
*
|
||||
* Since we weren't given the source for MACT386.LIB so I've had to do some
|
||||
* creative interpolation here.
|
||||
*
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment
|
||||
|
||||
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
|
||||
|
||||
Duke Nukem 3D 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include <algorithm>
|
||||
#include "types.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
// This extracted from the Rise of the Triad source RT_UTIL.C :-|
|
||||
|
||||
int FindDistance2D(int x, int y)
|
||||
{
|
||||
x= abs(x); /* absolute values */
|
||||
y= abs(y);
|
||||
|
||||
if (x<y)
|
||||
std::swap(x,y);
|
||||
|
||||
int t = y + (y>>1);
|
||||
|
||||
return (x - (x>>5) - (x>>7) + (t>>2) + (t>>6));
|
||||
}
|
||||
|
||||
|
||||
int FindDistance3D(int x, int y, int z)
|
||||
{
|
||||
x= abs(x); /* absolute values */
|
||||
y= abs(y);
|
||||
z= abs(z);
|
||||
|
||||
if (x<y)
|
||||
std::swap(x,y);
|
||||
|
||||
if (x<z)
|
||||
std::swap(x,z);
|
||||
|
||||
int t = y + z;
|
||||
|
||||
return (x - (x>>4) + (t>>2) + (t>>3));
|
||||
}
|
||||
|
4
source/core/mathutil.h
Normal file
4
source/core/mathutil.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
int FindDistance2D(int x, int y);
|
||||
int FindDistance3D(int x, int y, int z);
|
|
@ -6,6 +6,9 @@ set( PCH_SOURCES
|
|||
src/actors_lava.cpp
|
||||
src/bowling.cpp
|
||||
src/zz_actors.cpp
|
||||
src/sectors.cpp
|
||||
src/sectors_d.cpp
|
||||
src/sectors_r.cpp
|
||||
src/zz_anim.cpp
|
||||
src/zz_cheats.cpp
|
||||
src/zz_cmdline.cpp
|
||||
|
|
|
@ -106,6 +106,7 @@ G_EXTERN int32_t g_networkBroadcastMode, g_movesPerPacket;
|
|||
|
||||
G_EXTERN int32_t g_animWallCnt;
|
||||
G_EXTERN int32_t g_animateCnt;
|
||||
#define animatecnt g_animateCnt
|
||||
G_EXTERN int32_t g_cloudCnt;
|
||||
G_EXTERN int32_t g_curViewscreen;
|
||||
#define camsprite g_curViewscreen
|
||||
|
@ -138,6 +139,7 @@ G_EXTERN int32_t g_tripbombLaserMode;
|
|||
G_EXTERN int32_t screenpeek;
|
||||
|
||||
G_EXTERN int16_t g_animateSect[MAXANIMATES];
|
||||
#define animatesect g_animateSect
|
||||
G_EXTERN int32_t *g_animatePtr[MAXANIMATES];
|
||||
G_EXTERN int32_t g_animateGoal[MAXANIMATES];
|
||||
G_EXTERN int32_t g_animateVel[MAXANIMATES];
|
||||
|
|
|
@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "macros.h"
|
||||
#include "namesdyn.h" // for G_GetForcefieldPicnum()
|
||||
#include "player.h" // playerspawn_t
|
||||
#include "mathutil.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
@ -109,12 +110,8 @@ inline void activatebysector(int s, int sn)
|
|||
G_ActivateBySector(s, sn);
|
||||
}
|
||||
int S_FindMusicSFX(int sectNum, int *sndptr);
|
||||
void A_CallSound2(int soundNum, int playerNum);
|
||||
int A_CallSound(int sectNum,int spriteNum);
|
||||
inline int callsound(int s, int sp)
|
||||
{
|
||||
return A_CallSound(s, sp);
|
||||
}
|
||||
void callsound2(int soundNum, int playerNum);
|
||||
int callsound(int sectNum,int spriteNum);
|
||||
int A_CheckHitSprite(int spriteNum,int16_t *hitSprite);
|
||||
inline int hitasprite(int s, int16_t* h)
|
||||
{
|
||||
|
@ -137,8 +134,8 @@ inline int findplayer(const spritetype* pSprite, int32_t* dist)
|
|||
return A_FindPlayer(pSprite, dist);
|
||||
}
|
||||
void G_AlignWarpElevators(void);
|
||||
int CheckDoorTile(int tileNum);
|
||||
int CheckBlockDoorTile(int tileNum);
|
||||
bool isadoorwall(int tileNum);
|
||||
bool isablockdoor(int tileNum);
|
||||
void G_AnimateCamSprite(int smoothRatio);
|
||||
void G_AnimateWalls(void);
|
||||
int G_ActivateWarpElevators(int s,int warpDir);
|
||||
|
@ -146,11 +143,7 @@ inline int activatewarpelevators(int s, int w)
|
|||
{
|
||||
return G_ActivateWarpElevators(s, w);
|
||||
}
|
||||
int G_CheckActivatorMotion(int lotag);
|
||||
inline int check_activator_motion(int lotag)
|
||||
{
|
||||
return G_CheckActivatorMotion(lotag);
|
||||
}
|
||||
int check_activator_motion(int lotag);
|
||||
void G_DoSectorAnimations(void);
|
||||
void G_OperateActivators(int lotag, int playerNum);
|
||||
inline void operateactivators(int l, int w)
|
||||
|
@ -179,8 +172,8 @@ inline int getanimationgoal(const int32_t* animPtr)
|
|||
{
|
||||
return GetAnimationGoal(animPtr);
|
||||
}
|
||||
int isanearoperator(int lotag);
|
||||
int isanunderoperator(int lotag);
|
||||
bool isanearoperator(int lotag);
|
||||
bool isanunderoperator(int lotag);
|
||||
int P_ActivateSwitch(int playerNum, int wallOrSprite, int nSwitchType);
|
||||
void P_CheckSectors(int playerNum);
|
||||
void Sect_DamageCeiling(int sectNum);
|
||||
|
@ -236,6 +229,23 @@ inline int checkcursectnums(int se)
|
|||
return G_CheckPlayerInSector(se);
|
||||
}
|
||||
|
||||
inline int ldist(const spritetype* s1, const spritetype* s2)
|
||||
{
|
||||
int vx, vy;
|
||||
vx = s1->x - s2->x;
|
||||
vy = s1->y - s2->y;
|
||||
return(FindDistance2D(vx, vy) + 1);
|
||||
}
|
||||
|
||||
inline int dist(const spritetype* s1, const spritetype* s2)
|
||||
{
|
||||
int vx, vy, vz;
|
||||
vx = s1->x - s2->x;
|
||||
vy = s1->y - s2->y;
|
||||
vz = s1->z - s2->z;
|
||||
return(FindDistance3D(vx, vy, vz >> 4));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
217
source/games/duke/src/sectors.cpp
Normal file
217
source/games/duke/src/sectors.cpp
Normal file
|
@ -0,0 +1,217 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
||||
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
|
||||
|
||||
This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition
|
||||
|
||||
Duke Nukem 3D 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Original Source: 1996 - Todd Replogle
|
||||
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
||||
|
||||
EDuke enhancements integrated: 04/13/2003 - Matt Saettler
|
||||
|
||||
Note: EDuke source was in transition. Changes are in-progress in the
|
||||
source as it is released.
|
||||
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include "ns.h"
|
||||
#include "global.h"
|
||||
#include "sounds_common.h"
|
||||
|
||||
// PRIMITIVE
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// game dependent dispatchers
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool isadoorwall_d(int dapic);
|
||||
bool isadoorwall_r(int dapic);
|
||||
|
||||
bool isadoorwall(int dapic)
|
||||
{
|
||||
return isRR() ? isadoorwall_r(dapic) : isadoorwall_d(dapic);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
static bool haltsoundhack;
|
||||
|
||||
int callsound(int sn, int whatsprite)
|
||||
{
|
||||
if (!isRRRA() && haltsoundhack)
|
||||
{
|
||||
haltsoundhack = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int i = headspritesect[sn];
|
||||
while (i >= 0)
|
||||
{
|
||||
if (sprite[i].picnum == MUSICANDSFX && sprite[i].lotag < 1000)
|
||||
{
|
||||
if (whatsprite == -1) whatsprite = i;
|
||||
|
||||
int snum = sprite[i].lotag;
|
||||
auto flags = S_GetUserFlags(snum);
|
||||
if (hittype[i].temp_data[0] == 0)
|
||||
{
|
||||
if ((flags & (SF_GLOBAL | SF_DTAG)) != SF_GLOBAL)
|
||||
{
|
||||
if (snum)
|
||||
{
|
||||
if (sprite[i].hitag && snum != sprite[i].hitag)
|
||||
S_StopEnvSound(sprite[i].hitag, hittype[i].temp_data[5]); // changed to only stop the sound on the same actor, not all of them.
|
||||
spritesound(snum, whatsprite);
|
||||
hittype[i].temp_data[5] = whatsprite;
|
||||
}
|
||||
|
||||
if ((sector[sprite[i].sectnum].lotag & 0xff) != ST_22_SPLITTING_DOOR)
|
||||
hittype[i].temp_data[0] = 1;
|
||||
}
|
||||
}
|
||||
else if (S_IsSoundValid(sprite[i].hitag))
|
||||
{
|
||||
if ((flags & SF_LOOP) || (sprite[i].hitag && sprite[i].hitag != sprite[i].lotag))
|
||||
S_StopEnvSound(sprite[i].lotag, hittype[i].temp_data[5]); // changed to only stop the sound on the same actor, not all of them.
|
||||
if (sprite[i].hitag) spritesound(sprite[i].hitag, whatsprite);
|
||||
hittype[i].temp_data[0] = 0;
|
||||
hittype[i].temp_data[5] = whatsprite;
|
||||
}
|
||||
return sprite[i].lotag;
|
||||
}
|
||||
i = nextspritesect[i];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int check_activator_motion(int lotag)
|
||||
{
|
||||
int i, j;
|
||||
spritetype* s;
|
||||
|
||||
i = headspritestat[STAT_ACTIVATOR];
|
||||
while (i >= 0)
|
||||
{
|
||||
if (sprite[i].lotag == lotag)
|
||||
{
|
||||
s = &sprite[i];
|
||||
|
||||
for (j = animatecnt - 1; j >= 0; j--)
|
||||
if (s->sectnum == animatesect[j])
|
||||
return(1);
|
||||
|
||||
j = headspritestat[STAT_EFFECTOR];
|
||||
while (j >= 0)
|
||||
{
|
||||
if (s->sectnum == sprite[j].sectnum)
|
||||
switch (sprite[j].lotag)
|
||||
{
|
||||
case SE_11_SWINGING_DOOR:
|
||||
case SE_30_TWO_WAY_TRAIN:
|
||||
if (hittype[j].temp_data[4])
|
||||
return(1);
|
||||
break;
|
||||
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
|
||||
if (isRRRA()) break;
|
||||
case SE_20_STRETCH_BRIDGE:
|
||||
case SE_31_FLOOR_RISE_FALL:
|
||||
case SE_32_CEILING_RISE_FALL:
|
||||
if (hittype[j].temp_data[0])
|
||||
return(1);
|
||||
break;
|
||||
}
|
||||
|
||||
j = nextspritestat[j];
|
||||
}
|
||||
}
|
||||
i = nextspritestat[i];
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool isanunderoperator(int lotag)
|
||||
{
|
||||
switch (lotag & 0xff)
|
||||
{
|
||||
case ST_15_WARP_ELEVATOR:
|
||||
case ST_16_PLATFORM_DOWN:
|
||||
case ST_17_PLATFORM_UP:
|
||||
case ST_18_ELEVATOR_DOWN:
|
||||
case ST_19_ELEVATOR_UP:
|
||||
case ST_26_SPLITTING_ST_DOOR:
|
||||
return true;
|
||||
case ST_22_SPLITTING_DOOR:
|
||||
return !isRR();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool isanearoperator(int lotag)
|
||||
{
|
||||
switch (lotag & 0xff)
|
||||
{
|
||||
case ST_9_SLIDING_ST_DOOR:
|
||||
case ST_15_WARP_ELEVATOR:
|
||||
case ST_16_PLATFORM_DOWN:
|
||||
case ST_17_PLATFORM_UP:
|
||||
case ST_18_ELEVATOR_DOWN:
|
||||
case ST_19_ELEVATOR_UP:
|
||||
case ST_20_CEILING_DOOR:
|
||||
case ST_21_FLOOR_DOOR:
|
||||
case ST_22_SPLITTING_DOOR:
|
||||
case ST_23_SWINGING_DOOR:
|
||||
case ST_25_SLIDING_DOOR:
|
||||
case ST_26_SPLITTING_ST_DOOR:
|
||||
case ST_29_TEETH_DOOR:
|
||||
return true;
|
||||
case 41:
|
||||
return isRR();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
END_DUKE_NS
|
|
@ -31,6 +31,55 @@ source as it is released.
|
|||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include "duke3d.h"
|
||||
#include "ns.h"
|
||||
#include "global.h"
|
||||
#include "sounds_common.h"
|
||||
#include "names.h"
|
||||
|
||||
// PRIMITIVE
|
||||
BEGIN_DUKE_NS
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool isadoorwall_d(int dapic)
|
||||
{
|
||||
switch(dapic)
|
||||
{
|
||||
case DOORTILE1:
|
||||
case DOORTILE2:
|
||||
case DOORTILE3:
|
||||
case DOORTILE4:
|
||||
case DOORTILE5:
|
||||
case DOORTILE6:
|
||||
case DOORTILE7:
|
||||
case DOORTILE8:
|
||||
case DOORTILE9:
|
||||
case DOORTILE10:
|
||||
case DOORTILE11:
|
||||
case DOORTILE12:
|
||||
case DOORTILE14:
|
||||
case DOORTILE15:
|
||||
case DOORTILE16:
|
||||
case DOORTILE17:
|
||||
case DOORTILE18:
|
||||
case DOORTILE19:
|
||||
case DOORTILE20:
|
||||
case DOORTILE21:
|
||||
case DOORTILE22:
|
||||
case DOORTILE23:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
END_DUKE_NS
|
192
source/games/duke/src/sectors_r.cpp
Normal file
192
source/games/duke/src/sectors_r.cpp
Normal file
|
@ -0,0 +1,192 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
||||
Copyright (C) 2017-2019 Nuke.YKT
|
||||
|
||||
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
|
||||
|
||||
Duke Nukem 3D 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Original Source: 1996 - Todd Replogle
|
||||
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include "ns.h"
|
||||
#include "global.h"
|
||||
#include "sounds_common.h"
|
||||
#include "names_rr.h"
|
||||
|
||||
// PRIMITIVE
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool isadoorwall_r(int dapic)
|
||||
{
|
||||
switch(dapic)
|
||||
{
|
||||
case DOORTILE1:
|
||||
case DOORTILE2:
|
||||
case DOORTILE3:
|
||||
case DOORTILE4:
|
||||
case DOORTILE5:
|
||||
case DOORTILE6:
|
||||
case DOORTILE7:
|
||||
case DOORTILE8:
|
||||
case DOORTILE9:
|
||||
case DOORTILE10:
|
||||
case DOORTILE11:
|
||||
case DOORTILE12:
|
||||
case DOORTILE14:
|
||||
case DOORTILE15:
|
||||
case DOORTILE16:
|
||||
case DOORTILE17:
|
||||
case DOORTILE18:
|
||||
case DOORTILE19:
|
||||
case DOORTILE20:
|
||||
case DOORTILE21:
|
||||
case DOORTILE22:
|
||||
case RRTILE1856:
|
||||
case RRTILE1877:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool isablockdoor(int dapic)
|
||||
{
|
||||
switch (dapic)
|
||||
{
|
||||
case RRTILE1792:
|
||||
case RRTILE1801:
|
||||
case RRTILE1805:
|
||||
case RRTILE1807:
|
||||
case RRTILE1808:
|
||||
case RRTILE1812:
|
||||
case RRTILE1821:
|
||||
case RRTILE1826:
|
||||
case RRTILE1850:
|
||||
case RRTILE1851:
|
||||
case RRTILE1856:
|
||||
case RRTILE1877:
|
||||
case RRTILE1938:
|
||||
case RRTILE1942:
|
||||
case RRTILE1944:
|
||||
case RRTILE1945:
|
||||
case RRTILE1951:
|
||||
case RRTILE1961:
|
||||
case RRTILE1964:
|
||||
case RRTILE1985:
|
||||
case RRTILE1995:
|
||||
case RRTILE2022:
|
||||
case RRTILE2052:
|
||||
case RRTILE2053:
|
||||
case RRTILE2060:
|
||||
case RRTILE2074:
|
||||
case RRTILE2132:
|
||||
case RRTILE2136:
|
||||
case RRTILE2139:
|
||||
case RRTILE2150:
|
||||
case RRTILE2178:
|
||||
case RRTILE2186:
|
||||
case RRTILE2319:
|
||||
case RRTILE2321:
|
||||
case RRTILE2326:
|
||||
case RRTILE2329:
|
||||
case RRTILE2578:
|
||||
case RRTILE2581:
|
||||
case RRTILE2610:
|
||||
case RRTILE2613:
|
||||
case RRTILE2621:
|
||||
case RRTILE2622:
|
||||
case RRTILE2676:
|
||||
case RRTILE2732:
|
||||
case RRTILE2831:
|
||||
case RRTILE2832:
|
||||
case RRTILE2842:
|
||||
case RRTILE2940:
|
||||
case RRTILE2970:
|
||||
case RRTILE3083:
|
||||
case RRTILE3100:
|
||||
case RRTILE3155:
|
||||
case RRTILE3195:
|
||||
case RRTILE3232:
|
||||
case RRTILE3600:
|
||||
case RRTILE3631:
|
||||
case RRTILE3635:
|
||||
case RRTILE3637:
|
||||
case RRTILE3643+2:
|
||||
case RRTILE3643+3:
|
||||
case RRTILE3647:
|
||||
case RRTILE3652:
|
||||
case RRTILE3653:
|
||||
case RRTILE3671:
|
||||
case RRTILE3673:
|
||||
case RRTILE3684:
|
||||
case RRTILE3708:
|
||||
case RRTILE3714:
|
||||
case RRTILE3716:
|
||||
case RRTILE3723:
|
||||
case RRTILE3725:
|
||||
case RRTILE3737:
|
||||
case RRTILE3754:
|
||||
case RRTILE3762:
|
||||
case RRTILE3763:
|
||||
case RRTILE3764:
|
||||
case RRTILE3765:
|
||||
case RRTILE3767:
|
||||
case RRTILE3793:
|
||||
case RRTILE3814:
|
||||
case RRTILE3815:
|
||||
case RRTILE3819:
|
||||
case RRTILE3827:
|
||||
case RRTILE3837:
|
||||
return true;
|
||||
|
||||
case RRTILE1996:
|
||||
case RRTILE2382:
|
||||
case RRTILE2961:
|
||||
case RRTILE3804:
|
||||
case RRTILE7430:
|
||||
case RRTILE7467:
|
||||
case RRTILE7469:
|
||||
case RRTILE7470:
|
||||
case RRTILE7475:
|
||||
case RRTILE7566:
|
||||
case RRTILE7576:
|
||||
case RRTILE7716:
|
||||
case RRTILE8063:
|
||||
case RRTILE8067:
|
||||
case RRTILE8076:
|
||||
case RRTILE8106:
|
||||
case RRTILE8379:
|
||||
case RRTILE8380:
|
||||
case RRTILE8565:
|
||||
case RRTILE8605:
|
||||
return isRRRA();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
END_DUKE_NS
|
|
@ -85,11 +85,19 @@ int S_DefineSound(unsigned index, const char* filename, int ps, int pe, int pr,
|
|||
void S_InitSound();
|
||||
void S_PlayRRMusic(int newTrack = -1);
|
||||
|
||||
static inline bool S_IsAmbientSFX(int spriteNum)
|
||||
inline bool S_IsAmbientSFX(int spriteNum)
|
||||
{
|
||||
return (sprite[spriteNum].picnum == TILE_MUSICANDSFX && sprite[spriteNum].lotag < 999);
|
||||
}
|
||||
|
||||
inline bool S_IsSoundValid(int num)
|
||||
{
|
||||
return (!soundEngine->isValidSoundId(num + 1));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
END_DUKE_NS
|
||||
|
||||
#endif
|
||||
|
|
|
@ -294,7 +294,7 @@ static int CheckShootSwitchTile(int tileNum)
|
|||
|
||||
static int32_t safeldist(int32_t spriteNum, const void *pSprite)
|
||||
{
|
||||
int32_t distance = ldist(&sprite[spriteNum], pSprite);
|
||||
int32_t distance = ldist(&sprite[spriteNum], (const spritetype*)pSprite);
|
||||
return distance ? distance : 1;
|
||||
}
|
||||
|
||||
|
@ -782,10 +782,10 @@ growspark_rr:
|
|||
|
||||
A_Spawn(spawnedSprite, TILE_SMALLSMOKE);
|
||||
|
||||
if (CheckDoorTile(hitWall->picnum) == 1)
|
||||
if (isadoorwall(hitWall->picnum) == 1)
|
||||
goto SKIPBULLETHOLE;
|
||||
|
||||
if (RR && CheckBlockDoorTile(hitWall->picnum) == 1)
|
||||
if (RR && isablockdoor(hitWall->picnum) == 1)
|
||||
goto SKIPBULLETHOLE;
|
||||
|
||||
if (playerNum >= 0 && CheckShootSwitchTile(hitWall->picnum))
|
||||
|
|
|
@ -38,14 +38,14 @@ static int g_haltSoundHack = 0;
|
|||
|
||||
uint8_t g_shadedSector[MAXSECTORS];
|
||||
|
||||
int S_FindMusicSFX(int sectNum, int *sndptr)
|
||||
int S_FindMusicSFX(int sectNum, int* sndptr)
|
||||
{
|
||||
for (bssize_t SPRITES_OF_SECT(sectNum, spriteNum))
|
||||
{
|
||||
const int32_t snd = sprite[spriteNum].lotag;
|
||||
EDUKE32_STATIC_ASSERT(MAXSOUNDS >= 1000);
|
||||
|
||||
if (PN(spriteNum) == TILE_MUSICANDSFX && (unsigned)snd < 1000) // XXX: in other places, 999
|
||||
if (PN(spriteNum) == MUSICANDSFX && (unsigned)snd < 1000) // XXX: in other places, 999
|
||||
{
|
||||
*sndptr = snd;
|
||||
return spriteNum;
|
||||
|
@ -56,307 +56,6 @@ int S_FindMusicSFX(int sectNum, int *sndptr)
|
|||
return -1;
|
||||
}
|
||||
|
||||
void A_CallSound2(int soundNum, int playerNum)
|
||||
{
|
||||
A_PlaySound(soundNum, g_player[playerNum].ps->i);
|
||||
}
|
||||
|
||||
// this function activates a sector's TILE_MUSICANDSFX sprite
|
||||
int A_CallSound(int sectNum, int spriteNum)
|
||||
{
|
||||
if (!RR && g_haltSoundHack)
|
||||
{
|
||||
g_haltSoundHack = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int soundNum;
|
||||
int const SFXsprite = S_FindMusicSFX(sectNum, &soundNum);
|
||||
|
||||
if (SFXsprite >= 0)
|
||||
{
|
||||
if (spriteNum == -1)
|
||||
spriteNum = SFXsprite;
|
||||
|
||||
auto flags = S_GetUserFlags(soundNum);
|
||||
if (T1(SFXsprite) == 0)
|
||||
{
|
||||
if ((flags & (SF_GLOBAL | SF_DTAG)) != SF_GLOBAL)
|
||||
{
|
||||
if (soundNum)
|
||||
{
|
||||
A_PlaySound(soundNum, spriteNum);
|
||||
|
||||
if (SHT(SFXsprite) && soundNum != SHT(SFXsprite) && SHT(SFXsprite) < MAXSOUNDS)
|
||||
S_StopEnvSound(SHT(SFXsprite),T6(SFXsprite));
|
||||
|
||||
T6(SFXsprite) = spriteNum;
|
||||
}
|
||||
|
||||
if ((sector[SECT(SFXsprite)].lotag&0xff) != ST_22_SPLITTING_DOOR)
|
||||
T1(SFXsprite) = 1;
|
||||
}
|
||||
}
|
||||
else if (SHT(SFXsprite) < MAXSOUNDS)
|
||||
{
|
||||
if (SHT(SFXsprite))
|
||||
A_PlaySound(SHT(SFXsprite), spriteNum);
|
||||
|
||||
if ((flags & SF_LOOP) || (SHT(SFXsprite) && SHT(SFXsprite) != soundNum))
|
||||
S_StopEnvSound(soundNum, T6(SFXsprite));
|
||||
|
||||
T6(SFXsprite) = spriteNum;
|
||||
T1(SFXsprite) = 0;
|
||||
}
|
||||
|
||||
return soundNum;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int G_CheckActivatorMotion(int lotag)
|
||||
{
|
||||
int spriteNum = headspritestat[STAT_ACTIVATOR];
|
||||
|
||||
while (spriteNum >= 0)
|
||||
{
|
||||
if (sprite[spriteNum].lotag == lotag)
|
||||
{
|
||||
spritetype *const pSprite = &sprite[spriteNum];
|
||||
|
||||
for (bssize_t j = g_animateCnt - 1; j >= 0; j--)
|
||||
if (pSprite->sectnum == g_animateSect[j])
|
||||
return 1;
|
||||
|
||||
int sectorEffector = headspritestat[STAT_EFFECTOR];
|
||||
|
||||
while (sectorEffector >= 0)
|
||||
{
|
||||
if (pSprite->sectnum == sprite[sectorEffector].sectnum)
|
||||
{
|
||||
switch (sprite[sectorEffector].lotag)
|
||||
{
|
||||
case SE_11_SWINGING_DOOR:
|
||||
case SE_30_TWO_WAY_TRAIN:
|
||||
if (actor[sectorEffector].t_data[4])
|
||||
return 1;
|
||||
break;
|
||||
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
|
||||
if (RRRA)
|
||||
break;
|
||||
fallthrough__;
|
||||
case SE_20_STRETCH_BRIDGE:
|
||||
case SE_31_FLOOR_RISE_FALL:
|
||||
case SE_32_CEILING_RISE_FALL:
|
||||
if (actor[sectorEffector].t_data[0])
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sectorEffector = nextspritestat[sectorEffector];
|
||||
}
|
||||
}
|
||||
spriteNum = nextspritestat[spriteNum];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CheckDoorTile(int tileNum)
|
||||
{
|
||||
switch (DYNAMICTILEMAP(tileNum))
|
||||
{
|
||||
case DOORTILE23__STATIC:
|
||||
return !RR;
|
||||
case DOORTILE1__STATIC:
|
||||
case DOORTILE2__STATIC:
|
||||
case DOORTILE3__STATIC:
|
||||
case DOORTILE4__STATIC:
|
||||
case DOORTILE5__STATIC:
|
||||
case DOORTILE6__STATIC:
|
||||
case DOORTILE7__STATIC:
|
||||
case DOORTILE8__STATIC:
|
||||
case DOORTILE9__STATIC:
|
||||
case DOORTILE10__STATIC:
|
||||
case DOORTILE11__STATIC:
|
||||
case DOORTILE12__STATIC:
|
||||
case DOORTILE14__STATIC:
|
||||
case DOORTILE15__STATIC:
|
||||
case DOORTILE16__STATIC:
|
||||
case DOORTILE17__STATIC:
|
||||
case DOORTILE18__STATIC:
|
||||
case DOORTILE19__STATIC:
|
||||
case DOORTILE20__STATIC:
|
||||
case DOORTILE21__STATIC:
|
||||
case DOORTILE22__STATIC:
|
||||
case RRTILE1856__STATICRR:
|
||||
case RRTILE1877__STATICRR:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CheckBlockDoorTile(int tileNum)
|
||||
{
|
||||
if (tileNum == TILE_RRTILE3643)
|
||||
return 0;
|
||||
if (tileNum >= TILE_RRTILE3643+2 && tileNum <= TILE_RRTILE3643+3)
|
||||
tileNum = TILE_RRTILE3643;
|
||||
|
||||
switch (DYNAMICTILEMAP(tileNum))
|
||||
{
|
||||
case RRTILE1996__STATICRR:
|
||||
case RRTILE2382__STATICRR:
|
||||
case RRTILE2961__STATICRR:
|
||||
case RRTILE3804__STATICRR:
|
||||
case RRTILE7430__STATICRR:
|
||||
case RRTILE7467__STATICRR:
|
||||
case RRTILE7469__STATICRR:
|
||||
case RRTILE7470__STATICRR:
|
||||
case RRTILE7475__STATICRR:
|
||||
case RRTILE7566__STATICRR:
|
||||
case RRTILE7576__STATICRR:
|
||||
case RRTILE7716__STATICRR:
|
||||
case RRTILE8063__STATICRR:
|
||||
case RRTILE8067__STATICRR:
|
||||
case RRTILE8076__STATICRR:
|
||||
case RRTILE8106__STATICRR:
|
||||
case RRTILE8379__STATICRR:
|
||||
case RRTILE8380__STATICRR:
|
||||
case RRTILE8565__STATICRR:
|
||||
case RRTILE8605__STATICRR:
|
||||
return RRRA;
|
||||
case RRTILE1792__STATICRR:
|
||||
case RRTILE1801__STATICRR:
|
||||
case RRTILE1805__STATICRR:
|
||||
case RRTILE1807__STATICRR:
|
||||
case RRTILE1808__STATICRR:
|
||||
case RRTILE1812__STATICRR:
|
||||
case RRTILE1821__STATICRR:
|
||||
case RRTILE1826__STATICRR:
|
||||
case RRTILE1850__STATICRR:
|
||||
case RRTILE1851__STATICRR:
|
||||
case RRTILE1856__STATICRR:
|
||||
case RRTILE1877__STATICRR:
|
||||
case RRTILE1938__STATICRR:
|
||||
case RRTILE1942__STATICRR:
|
||||
case RRTILE1944__STATICRR:
|
||||
case RRTILE1945__STATICRR:
|
||||
case RRTILE1951__STATICRR:
|
||||
case RRTILE1961__STATICRR:
|
||||
case RRTILE1964__STATICRR:
|
||||
case RRTILE1985__STATICRR:
|
||||
case RRTILE1995__STATICRR:
|
||||
case RRTILE2022__STATICRR:
|
||||
case RRTILE2052__STATICRR:
|
||||
case RRTILE2053__STATICRR:
|
||||
case RRTILE2060__STATICRR:
|
||||
case RRTILE2074__STATICRR:
|
||||
case RRTILE2132__STATICRR:
|
||||
case RRTILE2136__STATICRR:
|
||||
case RRTILE2139__STATICRR:
|
||||
case RRTILE2150__STATICRR:
|
||||
case RRTILE2178__STATICRR:
|
||||
case RRTILE2186__STATICRR:
|
||||
case RRTILE2319__STATICRR:
|
||||
case RRTILE2321__STATICRR:
|
||||
case RRTILE2326__STATICRR:
|
||||
case RRTILE2329__STATICRR:
|
||||
case RRTILE2578__STATICRR:
|
||||
case RRTILE2581__STATICRR:
|
||||
case RRTILE2610__STATICRR:
|
||||
case RRTILE2613__STATICRR:
|
||||
case RRTILE2621__STATICRR:
|
||||
case RRTILE2622__STATICRR:
|
||||
case RRTILE2676__STATICRR:
|
||||
case RRTILE2732__STATICRR:
|
||||
case RRTILE2831__STATICRR:
|
||||
case RRTILE2832__STATICRR:
|
||||
case RRTILE2842__STATICRR:
|
||||
case RRTILE2940__STATICRR:
|
||||
case RRTILE2970__STATICRR:
|
||||
case RRTILE3083__STATICRR:
|
||||
case RRTILE3100__STATICRR:
|
||||
case RRTILE3155__STATICRR:
|
||||
case RRTILE3195__STATICRR:
|
||||
case RRTILE3232__STATICRR:
|
||||
case RRTILE3600__STATICRR:
|
||||
case RRTILE3631__STATICRR:
|
||||
case RRTILE3635__STATICRR:
|
||||
case RRTILE3637__STATICRR:
|
||||
case RRTILE3643__STATICRR:
|
||||
case RRTILE3647__STATICRR:
|
||||
case RRTILE3652__STATICRR:
|
||||
case RRTILE3653__STATICRR:
|
||||
case RRTILE3671__STATICRR:
|
||||
case RRTILE3673__STATICRR:
|
||||
case RRTILE3684__STATICRR:
|
||||
case RRTILE3708__STATICRR:
|
||||
case RRTILE3714__STATICRR:
|
||||
case RRTILE3716__STATICRR:
|
||||
case RRTILE3723__STATICRR:
|
||||
case RRTILE3725__STATICRR:
|
||||
case RRTILE3737__STATICRR:
|
||||
case RRTILE3754__STATICRR:
|
||||
case RRTILE3762__STATICRR:
|
||||
case RRTILE3763__STATICRR:
|
||||
case RRTILE3764__STATICRR:
|
||||
case RRTILE3765__STATICRR:
|
||||
case RRTILE3767__STATICRR:
|
||||
case RRTILE3793__STATICRR:
|
||||
case RRTILE3814__STATICRR:
|
||||
case RRTILE3815__STATICRR:
|
||||
case RRTILE3819__STATICRR:
|
||||
case RRTILE3827__STATICRR:
|
||||
case RRTILE3837__STATICRR:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int isanunderoperator(int lotag)
|
||||
{
|
||||
switch (lotag & 0xff)
|
||||
{
|
||||
case ST_22_SPLITTING_DOOR:
|
||||
if (RR) return 0;
|
||||
fallthrough__;
|
||||
case ST_15_WARP_ELEVATOR:
|
||||
case ST_16_PLATFORM_DOWN:
|
||||
case ST_17_PLATFORM_UP:
|
||||
case ST_18_ELEVATOR_DOWN:
|
||||
case ST_19_ELEVATOR_UP:
|
||||
case ST_26_SPLITTING_ST_DOOR:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int isanearoperator(int lotag)
|
||||
{
|
||||
switch (lotag & 0xff)
|
||||
{
|
||||
case 41:
|
||||
if (!RR) return 0;
|
||||
fallthrough__;
|
||||
case ST_9_SLIDING_ST_DOOR:
|
||||
case ST_15_WARP_ELEVATOR:
|
||||
case ST_16_PLATFORM_DOWN:
|
||||
case ST_17_PLATFORM_UP:
|
||||
case ST_18_ELEVATOR_DOWN:
|
||||
case ST_19_ELEVATOR_UP:
|
||||
case ST_20_CEILING_DOOR:
|
||||
case ST_21_FLOOR_DOOR:
|
||||
case ST_22_SPLITTING_DOOR:
|
||||
case ST_23_SWINGING_DOOR:
|
||||
case ST_25_SLIDING_DOOR:
|
||||
case ST_26_SPLITTING_ST_DOOR:
|
||||
case ST_29_TEETH_DOOR:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int32_t A_FP_ManhattanDist(const DukePlayer_t *pPlayer, const spritetype *pSprite)
|
||||
{
|
||||
|
@ -422,7 +121,7 @@ void G_DoSectorAnimations(void)
|
|||
continue;
|
||||
|
||||
if ((sector[animSect].lotag&0xff) != ST_22_SPLITTING_DOOR)
|
||||
A_CallSound(animSect,-1);
|
||||
callsound(animSect,-1);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -703,7 +402,7 @@ void G_OperateSectors(int sectNum, int spriteNum)
|
|||
if (E_SpriteIsValid(j))
|
||||
{
|
||||
if (actor[j].tempang == 0 || actor[j].tempang == 256)
|
||||
A_CallSound(sectNum,spriteNum);
|
||||
callsound(sectNum,spriteNum);
|
||||
sprite[j].extra = (sprite[j].extra == 1) ? 3 : 1;
|
||||
}
|
||||
break;
|
||||
|
@ -716,7 +415,7 @@ void G_OperateSectors(int sectNum, int spriteNum)
|
|||
if (actor[j].t_data[4] == 0)
|
||||
actor[j].t_data[4] = 1;
|
||||
|
||||
A_CallSound(sectNum,spriteNum);
|
||||
callsound(sectNum,spriteNum);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -796,7 +495,7 @@ void G_OperateSectors(int sectNum, int spriteNum)
|
|||
SetAnimation(sectNum, &wall[foundWall].x, wall[foundWall].x + vect2.x, doorSpeed);
|
||||
SetAnimation(sectNum, &wall[i].x, wall[i].x + vect2.x, doorSpeed);
|
||||
SetAnimation(sectNum, &wall[wall[foundWall].point2].x, wall[wall[foundWall].point2].x + vect2.x, doorSpeed);
|
||||
A_CallSound(sectNum, spriteNum);
|
||||
callsound(sectNum, spriteNum);
|
||||
}
|
||||
else if (vect2.y != 0)
|
||||
{
|
||||
|
@ -805,7 +504,7 @@ void G_OperateSectors(int sectNum, int spriteNum)
|
|||
SetAnimation(sectNum, &wall[foundWall].y, wall[foundWall].y + vect2.y, doorSpeed);
|
||||
SetAnimation(sectNum, &wall[i].y, wall[i].y + vect2.y, doorSpeed);
|
||||
SetAnimation(sectNum, &wall[wall[foundWall].point2].y, wall[wall[foundWall].point2].y + vect2.y, doorSpeed);
|
||||
A_CallSound(sectNum, spriteNum);
|
||||
callsound(sectNum, spriteNum);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -815,14 +514,14 @@ void G_OperateSectors(int sectNum, int spriteNum)
|
|||
SetAnimation(sectNum, &wall[foundWall].x, vect.x, doorSpeed);
|
||||
SetAnimation(sectNum, &wall[i].x, vect.x + vect2.x, doorSpeed);
|
||||
SetAnimation(sectNum, &wall[wall[foundWall].point2].x, vect.x + vect2.x, doorSpeed);
|
||||
A_CallSound(sectNum, spriteNum);
|
||||
callsound(sectNum, spriteNum);
|
||||
}
|
||||
else if (vect2.y != 0)
|
||||
{
|
||||
SetAnimation(sectNum, &wall[foundWall].y, vect.y, doorSpeed);
|
||||
SetAnimation(sectNum, &wall[i].y, vect.y + vect2.y, doorSpeed);
|
||||
SetAnimation(sectNum, &wall[wall[foundWall].point2].y, vect.y + vect2.y, doorSpeed);
|
||||
A_CallSound(sectNum, spriteNum);
|
||||
callsound(sectNum, spriteNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -878,7 +577,7 @@ void G_OperateSectors(int sectNum, int spriteNum)
|
|||
j = sector[i].floorz;
|
||||
SetAnimation(sectNum,&pSector->floorz,j,pSector->extra);
|
||||
}
|
||||
A_CallSound(sectNum,spriteNum);
|
||||
callsound(sectNum,spriteNum);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -905,7 +604,7 @@ void G_OperateSectors(int sectNum, int spriteNum)
|
|||
|
||||
SetAnimation(sectNum, &pSector->floorz, j, sectorExtra);
|
||||
SetAnimation(sectNum, &pSector->ceilingz, j + zDiff, sectorExtra);
|
||||
A_CallSound(sectNum, spriteNum);
|
||||
callsound(sectNum, spriteNum);
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -920,7 +619,7 @@ void G_OperateSectors(int sectNum, int spriteNum)
|
|||
T2(i) = 1;
|
||||
}
|
||||
|
||||
A_CallSound(sectNum, spriteNum);
|
||||
callsound(sectNum, spriteNum);
|
||||
|
||||
pSector->lotag ^= 0x8000u;
|
||||
|
||||
|
@ -981,7 +680,7 @@ REDODOOR:
|
|||
pSector->lotag ^= 0x8000u;
|
||||
|
||||
SetAnimation(sectNum,&pSector->ceilingz,j,pSector->extra);
|
||||
A_CallSound(sectNum,spriteNum);
|
||||
callsound(sectNum,spriteNum);
|
||||
|
||||
return;
|
||||
|
||||
|
@ -1002,7 +701,7 @@ REDODOOR:
|
|||
pSector->lotag ^= 0x8000u;
|
||||
|
||||
if (SetAnimation(sectNum,&pSector->floorz,j,pSector->extra) >= 0)
|
||||
A_CallSound(sectNum,spriteNum);
|
||||
callsound(sectNum,spriteNum);
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -1034,7 +733,7 @@ REDODOOR:
|
|||
|
||||
pSector->lotag ^= 0x8000u;
|
||||
|
||||
A_CallSound(sectNum,spriteNum);
|
||||
callsound(sectNum,spriteNum);
|
||||
|
||||
return;
|
||||
|
||||
|
@ -1070,7 +769,7 @@ REDODOOR:
|
|||
|
||||
if (!soundPlayed)
|
||||
{
|
||||
A_CallSound(sectNum, i);
|
||||
callsound(sectNum, i);
|
||||
soundPlayed = 1;
|
||||
}
|
||||
}
|
||||
|
@ -1097,8 +796,8 @@ REDODOOR:
|
|||
SA(i) += 1024;
|
||||
|
||||
if (T5(i))
|
||||
A_CallSound(SECT(i),i);
|
||||
A_CallSound(SECT(i),i);
|
||||
callsound(SECT(i),i);
|
||||
callsound(SECT(i),i);
|
||||
|
||||
T5(i) = (sector[SECT(i)].lotag & 0x8000u) ? 1 : 2;
|
||||
}
|
||||
|
@ -1115,7 +814,7 @@ REDODOOR:
|
|||
// Highest bit now set means we're opening.
|
||||
|
||||
actor[j].t_data[0] = (sector[sectNum].lotag & 0x8000u) ? 1 : 2;
|
||||
A_CallSound(sectNum,spriteNum);
|
||||
callsound(sectNum,spriteNum);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1139,7 +838,7 @@ REDODOOR:
|
|||
actor[l].t_data[0] = 1;
|
||||
}
|
||||
|
||||
A_CallSound(sectNum,spriteNum);
|
||||
callsound(sectNum,spriteNum);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -1232,7 +931,7 @@ void G_OperateActivators(int lotag, int playerNum)
|
|||
case SE_31_FLOOR_RISE_FALL:
|
||||
case SE_32_CEILING_RISE_FALL:
|
||||
actor[foundSprite].t_data[0] = 1 - actor[foundSprite].t_data[0];
|
||||
A_CallSound(SECT(spriteNum), foundSprite);
|
||||
callsound(SECT(spriteNum), foundSprite);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1240,7 +939,7 @@ void G_OperateActivators(int lotag, int playerNum)
|
|||
}
|
||||
|
||||
if (soundPlayed == -1 && (sector[SECT(spriteNum)].lotag&0xff) == ST_22_SPLITTING_DOOR)
|
||||
soundPlayed = A_CallSound(SECT(spriteNum),spriteNum);
|
||||
soundPlayed = callsound(SECT(spriteNum),spriteNum);
|
||||
|
||||
G_OperateSectors(SECT(spriteNum),spriteNum);
|
||||
}
|
||||
|
@ -1446,13 +1145,13 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType)
|
|||
case REST_SWITCH_CASES:
|
||||
if (!RR && nSwitchPicnum == TILE_NUKEBUTTON) goto default_case;
|
||||
if (RR && !RRRA && (nSwitchPicnum == TILE_MULTISWITCH2 || nSwitchPicnum == TILE_RRTILE8464 || nSwitchPicnum == TILE_RRTILE8660)) goto default_case;
|
||||
if (G_CheckActivatorMotion(lotag))
|
||||
if (check_activator_motion(lotag))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
default_case:
|
||||
if (CheckDoorTile(nSwitchPicnum) == 0)
|
||||
if (isadoorwall(nSwitchPicnum) == 0)
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
@ -1634,7 +1333,7 @@ default_case:
|
|||
switch (DYNAMICTILEMAP(basePicnum))
|
||||
{
|
||||
default:
|
||||
if (CheckDoorTile(nSwitchPicnum) == 0)
|
||||
if (isadoorwall(nSwitchPicnum) == 0)
|
||||
break;
|
||||
fallthrough__;
|
||||
case DIPSWITCH_LIKE_CASES:
|
||||
|
@ -1764,7 +1463,7 @@ default_case:
|
|||
if (G_IsLikeDipswitch(nSwitchPicnum))
|
||||
return 1;
|
||||
|
||||
if (!hitag && CheckDoorTile(nSwitchPicnum) == 0)
|
||||
if (!hitag && isadoorwall(nSwitchPicnum) == 0)
|
||||
S_PlaySound3D(SWITCH_ON, (switchType == SWITCH_SPRITE) ? wallOrSprite : g_player[playerNum].ps->i, &davector);
|
||||
else if (hitag)
|
||||
{
|
||||
|
@ -4734,7 +4433,7 @@ void P_CheckSectors(int playerNum)
|
|||
|
||||
if (nearWall >= 0)
|
||||
{
|
||||
if (wall[nearWall].lotag > 0 && CheckDoorTile(wall[nearWall].picnum))
|
||||
if (wall[nearWall].lotag > 0 && isadoorwall(wall[nearWall].picnum))
|
||||
{
|
||||
if (foundWall == nearWall || foundWall == -1)
|
||||
{
|
||||
|
|
|
@ -295,7 +295,7 @@ static int CheckShootSwitchTile(int tileNum)
|
|||
|
||||
static int32_t safeldist(int32_t spriteNum, const void *pSprite)
|
||||
{
|
||||
int32_t distance = ldist(&sprite[spriteNum], pSprite);
|
||||
int32_t distance = ldist(&sprite[spriteNum], (const spritetype*)pSprite);
|
||||
return distance ? distance : 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "macros.h"
|
||||
#include "namesdyn.h" // for G_GetForcefieldPicnum()
|
||||
#include "player.h" // playerspawn_t
|
||||
#include "mathutil.h"
|
||||
|
||||
BEGIN_RR_NS
|
||||
|
||||
|
@ -178,6 +179,42 @@ EXTERN_INLINE int32_t G_CheckPlayerInSector(int32_t sect)
|
|||
|
||||
#endif
|
||||
|
||||
// These are from duke's sector.c
|
||||
inline int ldist(const spritetype* s1, const spritetype* s2)
|
||||
{
|
||||
int vx, vy;
|
||||
vx = s1->x - s2->x;
|
||||
vy = s1->y - s2->y;
|
||||
return(FindDistance2D(vx, vy) + 1);
|
||||
}
|
||||
|
||||
inline int dist(const spritetype* s1, const spritetype* s2)
|
||||
{
|
||||
int vx, vy, vz;
|
||||
vx = s1->x - s2->x;
|
||||
vy = s1->y - s2->y;
|
||||
vz = s1->z - s2->z;
|
||||
return(FindDistance3D(vx, vy, vz >> 4));
|
||||
}
|
||||
|
||||
inline int dist(const uspritetype* s1, const uspritetype* s2)
|
||||
{
|
||||
int vx, vy, vz;
|
||||
vx = s1->x - s2->x;
|
||||
vy = s1->y - s2->y;
|
||||
vz = s1->z - s2->z;
|
||||
return(FindDistance3D(vx, vy, vz >> 4));
|
||||
}
|
||||
|
||||
inline int dist(const uspritetype* s1, const spritetype* s2)
|
||||
{
|
||||
int vx, vy, vz;
|
||||
vx = s1->x - s2->x;
|
||||
vy = s1->y - s2->y;
|
||||
vz = s1->z - s2->z;
|
||||
return(FindDistance3D(vx, vy, vz >> 4));
|
||||
}
|
||||
|
||||
END_RR_NS
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue