Merge branch 'master' into powerslave

# Conflicts:
#	source/common/gamecontrol.cpp
#	source/common/version.h
#	wadsrc/static/engine/grpinfo.txt
This commit is contained in:
Christoph Oelckers 2019-12-26 14:46:14 +01:00
commit 6373b75d22
127 changed files with 637 additions and 519 deletions

View file

@ -115,9 +115,9 @@ function( add_pk3 PK3_NAME PK3_DIR )
assort_pk3_source_folder("Source Files" ${PK3_DIR}) assort_pk3_source_folder("Source Files" ${PK3_DIR})
# Phase 4: Add the resulting PK3 to the install target. # Phase 4: Add the resulting PK3 to the install target.
if( WIN32 ) if( WIN32 )
set( INSTALL_PK3_PATH . CACHE STRING "Directory where demolition.pk3 will be placed during install." ) set( INSTALL_PK3_PATH . CACHE STRING "Directory where engine data will be placed during install." )
else() else()
set( INSTALL_PK3_PATH share/games/doom CACHE STRING "Directory where demolition.pk3 will be placed during install." ) set( INSTALL_PK3_PATH share/games/doom CACHE STRING "Directory where engine data will be placed during install." )
endif() endif()
install(FILES "${PROJECT_BINARY_DIR}/${PK3_NAME}" install(FILES "${PROJECT_BINARY_DIR}/${PK3_NAME}"
DESTINATION ${INSTALL_PK3_PATH} DESTINATION ${INSTALL_PK3_PATH}
@ -140,7 +140,7 @@ IF( NOT CMAKE_BUILD_TYPE )
FORCE ) FORCE )
ENDIF() ENDIF()
set( DEMOLITION_OUTPUT_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Directory where demolition.pk3 and the executable will be created." ) set( DEMOLITION_OUTPUT_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Directory where engine data and the executable will be created." )
set( DEMOLITION_EXE_NAME "demolition" CACHE FILEPATH "Name of the executable to create" ) set( DEMOLITION_EXE_NAME "demolition" CACHE FILEPATH "Name of the executable to create" )
if( MSVC ) if( MSVC )
# Allow the user to use DEMOLITION_OUTPUT_DIR as a single release point. # Allow the user to use DEMOLITION_OUTPUT_DIR as a single release point.
@ -206,20 +206,6 @@ if( MSVC )
#set( ALL_C_FLAGS "${ALL_C_FLAGS} /arch:SSE2") # This is already the default #set( ALL_C_FLAGS "${ALL_C_FLAGS} /arch:SSE2") # This is already the default
# if( CMAKE_SIZEOF_VOID_P MATCHES "4")
# # SSE2 option (to allow x87 in 32 bit and disallow extended feature sets which have not yet been checked for precision)
# option (DEMOLITION_USE_SSE2 "Use SSE2 instruction set")
# if (DEMOLITION_USE_SSE2)
# set( ALL_C_FLAGS "${ALL_C_FLAGS} /arch:SSE2")
# else ()
# if (MSVC_VERSION GREATER 1699)
# # On Visual C++ 2012 and later SSE2 is the default, so we need to switch it off explicitly
# set( ALL_C_FLAGS "${ALL_C_FLAGS} /arch:IA32")
# endif ()
# endif ()
# else()
# set( ALL_C_FLAGS "${ALL_C_FLAGS} /arch:SSE2")
# endif()
# Avoid CRT DLL dependancies in release builds, optionally generate assembly output for checking crash locations. # Avoid CRT DLL dependancies in release builds, optionally generate assembly output for checking crash locations.
option( DEMOLITION_GENERATE_ASM "Generate assembly output." OFF ) option( DEMOLITION_GENERATE_ASM "Generate assembly output." OFF )

View file

@ -429,7 +429,7 @@ add_custom_target( revision_check ALL
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS updaterevision ) DEPENDS updaterevision )
# Libraries Demolition needs # required libraries
message( STATUS "Fluid synth libs: ${FLUIDSYNTH_LIBRARIES}" ) message( STATUS "Fluid synth libs: ${FLUIDSYNTH_LIBRARIES}" )
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${CMAKE_DL_LIBS}" ) set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${CMAKE_DL_LIBS}" )
@ -468,7 +468,7 @@ endif()
# Start defining source files for Demolition # Start defining source files
set( PLAT_WIN32_SOURCES set( PLAT_WIN32_SOURCES
platform/win32/base_sysfb.cpp platform/win32/base_sysfb.cpp
platform/win32/gl_sysfb.cpp platform/win32/gl_sysfb.cpp

View file

@ -1434,94 +1434,6 @@ static void parsedefinitions_game_include(const char *fileName, scriptfile *pScr
} }
} }
#if 0
static void parsedefinitions_game_animsounds(scriptfile *pScript, const char * blockEnd, char const * fileName, dukeanim_t * animPtr)
{
Bfree(animPtr->sounds);
size_t numPairs = 0, allocSize = 4;
animPtr->sounds = (animsound_t *)Xmalloc(allocSize * sizeof(animsound_t));
animPtr->numsounds = 0;
int defError = 1;
uint16_t lastFrameNum = 1;
while (pScript->textptr < blockEnd)
{
int32_t frameNum;
int32_t soundNum;
// HACK: we've reached the end of the list
// (hack because it relies on knowledge of
// how scriptfile_* preprocesses the text)
if (blockEnd - pScript->textptr == 1)
break;
// would produce error when it encounters the closing '}'
// without the above hack
if (scriptfile_getnumber(pScript, &frameNum))
break;
defError = 1;
if (scriptfile_getsymbol(pScript, &soundNum))
break;
// frame numbers start at 1 for us
if (frameNum <= 0)
{
initprintf("Error: frame number must be greater zero on line %s:%d\n", pScript->filename,
scriptfile_getlinum(pScript, pScript->ltextptr));
break;
}
if (frameNum < lastFrameNum)
{
initprintf("Error: frame numbers must be in (not necessarily strictly)"
" ascending order (line %s:%d)\n",
pScript->filename, scriptfile_getlinum(pScript, pScript->ltextptr));
break;
}
lastFrameNum = frameNum;
if ((unsigned)soundNum >= MAXSOUNDS && soundNum != -1)
{
initprintf("Error: sound number #%d invalid on line %s:%d\n", soundNum, pScript->filename,
scriptfile_getlinum(pScript, pScript->ltextptr));
break;
}
if (numPairs >= allocSize)
{
allocSize *= 2;
animPtr->sounds = (animsound_t *)Xrealloc(animPtr->sounds, allocSize * sizeof(animsound_t));
}
defError = 0;
animsound_t & sound = animPtr->sounds[numPairs];
sound.frame = frameNum;
sound.sound = soundNum;
++numPairs;
}
if (!defError)
{
animPtr->numsounds = numPairs;
// initprintf("Defined sound sequence for hi-anim \"%s\" with %d frame/sound pairs\n",
// hardcoded_anim_tokens[animnum].text, numpairs);
}
else
{
DO_FREE_AND_NULL(animPtr->sounds);
initprintf("Failed defining sound sequence for anim \"%s\".\n", fileName);
}
}
#endif
static int parsedefinitions_game(scriptfile *pScript, int firstPass) static int parsedefinitions_game(scriptfile *pScript, int firstPass)
{ {

View file

@ -161,22 +161,17 @@ void credReset(void)
DoUnFade(1); DoUnFade(1);
} }
FileReader credKOpen4Load(char *&pzFile) FileReader credKOpen4Load(FString pzFile)
{ {
int nLen = strlen(pzFile); int nLen = strlen(pzFile);
for (int i = 0; i < nLen; i++) FixPathSeperator(pzFile);
{
if (pzFile[i] == '\\')
pzFile[i] = '/';
}
auto nHandle = fileSystem.OpenFileReader(pzFile, 0); auto nHandle = fileSystem.OpenFileReader(pzFile, 0);
if (!nHandle.isOpen()) if (!nHandle.isOpen())
{ {
// Hack // Hack
if (nLen >= 3 && isalpha(pzFile[0]) && pzFile[1] == ':' && pzFile[2] == '/') if (nLen >= 3 && isalpha(pzFile[0]) && pzFile[1] == ':' && pzFile[2] == '/')
{ {
pzFile += 3; nHandle = fileSystem.OpenFileReader(pzFile.GetChars()+3, 0);
nHandle = fileSystem.OpenFileReader(pzFile, 0);
} }
} }
return nHandle; return nHandle;
@ -200,24 +195,18 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav)
} }
smkPlayer.sub_82E6C(pzSMK, pzWAV); smkPlayer.sub_82E6C(pzSMK, pzWAV);
#endif #endif
if (Bstrlen(_pzSMK) == 0) if (!_pzSMK || !*_pzSMK)
return; return;
char *pzSMK = Xstrdup(_pzSMK); FString pzSMK = _pzSMK;
char *pzWAV = Xstrdup(_pzWAV); FString pzWAV = _pzWAV;
char *pzSMK_ = pzSMK;
char *pzWAV_ = pzWAV;
auto nHandleSMK = credKOpen4Load(pzSMK); auto nHandleSMK = credKOpen4Load(pzSMK);
if (!nHandleSMK.isOpen()) if (!nHandleSMK.isOpen())
{ {
Bfree(pzSMK_);
Bfree(pzWAV_);
return; return;
} }
SmackerHandle hSMK = Smacker_Open(pzSMK); SmackerHandle hSMK = Smacker_Open(pzSMK);
if (!hSMK.isValid) if (!hSMK.isValid)
{ {
Bfree(pzSMK_);
Bfree(pzWAV_);
return; return;
} }
uint32_t nWidth, nHeight; uint32_t nWidth, nHeight;
@ -228,8 +217,6 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav)
if (!pFrame) if (!pFrame)
{ {
Smacker_Close(hSMK); Smacker_Close(hSMK);
Bfree(pzSMK_);
Bfree(pzWAV_);
return; return;
} }
int nFrameRate = Smacker_GetFrameRate(hSMK); int nFrameRate = Smacker_GetFrameRate(hSMK);
@ -295,8 +282,6 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav)
GLInterface.EnableNonTransparent255(false); GLInterface.EnableNonTransparent255(false);
videoSetPalette(0, 0, 8+2); videoSetPalette(0, 0, 8+2);
tileDelete(kSMKTile); tileDelete(kSMKTile);
Bfree(pzSMK_);
Bfree(pzWAV_);
} }
END_BLD_NS END_BLD_NS

View file

@ -177,7 +177,7 @@ bool GameInterface::LoadGame(FSaveGameNode* node)
gGameStarted = 1; gGameStarted = 1;
bVanilla = false; bVanilla = false;
MUS_ResumeSaved(); Mus_ResumeSaved();
netBroadcastPlayerInfo(myconnectindex); netBroadcastPlayerInfo(myconnectindex);
return true; return true;

View file

@ -337,7 +337,7 @@ typedef struct {
uint8_t filler; uint8_t filler;
float alpha; float alpha;
// NOTE: keep 'tspr' on an 8-byte boundary: // NOTE: keep 'tspr' on an 8-byte boundary:
uspritetype *tspr; tspriteptr_t tspr;
#if !defined UINTPTR_MAX #if !defined UINTPTR_MAX
# error Need UINTPTR_MAX define to select between 32- and 64-bit structs # error Need UINTPTR_MAX define to select between 32- and 64-bit structs
#endif #endif

View file

@ -126,11 +126,11 @@ enum
CSTAT_SPRITE_BLOCK_HITSCAN = 1u<<8u, CSTAT_SPRITE_BLOCK_HITSCAN = 1u<<8u,
CSTAT_SPRITE_TRANSLUCENT_INVERT = 1u<<9u, CSTAT_SPRITE_TRANSLUCENT_INVERT = 1u<<9u,
CSTAT_SPRITE_RESERVED1 = 1u<<10u, // game-side CSTAT_SPRITE_RESERVED1 = 1u<<10u, // used by Duke 3D (Polymost)
CSTAT_SPRITE_RESERVED2 = 1u<<11u, // game-side CSTAT_SPRITE_RESERVED2 = 1u<<11u, // used by Duke 3D (EDuke32 game code extension)
CSTAT_SPRITE_RESERVED3 = 1u<<12u, CSTAT_SPRITE_RESERVED3 = 1u<<12u, // used by Shadow Warrior, Blood
CSTAT_SPRITE_RESERVED4 = 1u<<13u, CSTAT_SPRITE_RESERVED4 = 1u<<13u, // used by Duke 3D (Polymer), Shadow Warrior, Blood
CSTAT_SPRITE_RESERVED5 = 1u<<14u, CSTAT_SPRITE_RESERVED5 = 1u<<14u, // used by Duke 3D (Polymer), Shadow Warrior, Blood
// TODO: Make these two Duke3D-only by translating them to bits in tspr // TODO: Make these two Duke3D-only by translating them to bits in tspr
CSTAT_SPRITE_NO_SHADOW = 1u<<13u, // re-defined in Shadow Warrior CSTAT_SPRITE_NO_SHADOW = 1u<<13u, // re-defined in Shadow Warrior
@ -160,9 +160,14 @@ enum
CSTAT_WALL_TRANSLUCENT = 1u<<7u, CSTAT_WALL_TRANSLUCENT = 1u<<7u,
CSTAT_WALL_YFLIP = 1u<<8u, CSTAT_WALL_YFLIP = 1u<<8u,
CSTAT_WALL_TRANS_FLIP = 1u<<9u, CSTAT_WALL_TRANS_FLIP = 1u<<9u,
CSTAT_WALL_YAX_UPWALL = 1u<<10u,
CSTAT_WALL_YAX_DOWNWALL = 1u<<11u, CSTAT_WALL_YAX_UPWALL = 1u<<10u, // EDuke32 extension
CSTAT_WALL_ROTATE_90 = 1u<<12u, CSTAT_WALL_YAX_DOWNWALL = 1u<<11u, // EDuke32 extension
CSTAT_WALL_ROTATE_90 = 1u<<12u, // EDuke32 extension
CSTAT_WALL_RESERVED1 = 1u<<13u,
CSTAT_WALL_RESERVED2 = 1u<<14u, // used by Shadow Warrior, Blood
CSTAT_WALL_RESERVED3 = 1u<<15u, // used by Shadow Warrior, Blood
}; };
#endif #endif

View file

@ -1229,7 +1229,7 @@ static FORCE_INLINE void *xrealloc(void * const ptr, const bsize_t size)
return (EDUKE32_PREDICT_TRUE(newptr != NULL || size == 0)) ? newptr: handle_memerr(ptr); return (EDUKE32_PREDICT_TRUE(newptr != NULL || size == 0)) ? newptr: handle_memerr(ptr);
} }
// This will throw up when BFee is no longer usable, I do not want to change all code right now that uses it to make future merges easier. // This will throw up when BFree is no longer usable, I do not want to change all code right now that uses it to make future merges easier.
static_assert(Bfree == free, "BFree must be free"); static_assert(Bfree == free, "BFree must be free");
static FORCE_INLINE void xfree(void *const ptr) { Bfree(ptr); } static FORCE_INLINE void xfree(void *const ptr) { Bfree(ptr); }
@ -1265,6 +1265,7 @@ static FORCE_INLINE void *xaligned_calloc(const bsize_t alignment, const bsize_t
# define EDUKE32_PRE_XALLOC # define EDUKE32_PRE_XALLOC
#endif #endif
#ifndef _DEBUG
#define Xstrdup(s) (EDUKE32_PRE_XALLOC xstrdup(s)) #define Xstrdup(s) (EDUKE32_PRE_XALLOC xstrdup(s))
#define Xmalloc(size) (EDUKE32_PRE_XALLOC xmalloc(size)) #define Xmalloc(size) (EDUKE32_PRE_XALLOC xmalloc(size))
#define Xcalloc(nmemb, size) (EDUKE32_PRE_XALLOC xcalloc(nmemb, size)) #define Xcalloc(nmemb, size) (EDUKE32_PRE_XALLOC xcalloc(nmemb, size))
@ -1273,6 +1274,17 @@ static FORCE_INLINE void *xaligned_calloc(const bsize_t alignment, const bsize_t
#define Xaligned_calloc(alignment, count, size) (EDUKE32_PRE_XALLOC xaligned_calloc(alignment, count, size)) #define Xaligned_calloc(alignment, count, size) (EDUKE32_PRE_XALLOC xaligned_calloc(alignment, count, size))
#define Xfree(ptr) (EDUKE32_PRE_XALLOC xfree(ptr)) #define Xfree(ptr) (EDUKE32_PRE_XALLOC xfree(ptr))
#define Xaligned_free(ptr) (EDUKE32_PRE_XALLOC xaligned_free(ptr)) #define Xaligned_free(ptr) (EDUKE32_PRE_XALLOC xaligned_free(ptr))
#else
// This is for allowing the compiler's heap checker to do its job. When wrapped it only points to the wrapper for a memory leak, not to the real location where the allocation takes place.
#define Xstrdup(s) (strdup(s))
#define Xmalloc(size) (malloc(size))
#define Xcalloc(nmemb, size) (calloc(nmemb, size))
#define Xrealloc(ptr, size) (realloc(ptr, size))
#define Xaligned_alloc(alignment, size) (malloc(size))
#define Xaligned_calloc(alignment, count, size) (calloc(count, size))
#define Xfree(ptr) (free(ptr))
#define Xaligned_free(ptr) (free(ptr))
#endif
////////// More utility functions ////////// ////////// More utility functions //////////

View file

@ -39,7 +39,7 @@ void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang
void polymost_completeMirror(); void polymost_completeMirror();
int32_t polymost_maskWallHasTranslucency(uwalltype const * const wall); int32_t polymost_maskWallHasTranslucency(uwalltype const * const wall);
int32_t polymost_spriteHasTranslucency(uspritetype const * const tspr); int32_t polymost_spriteHasTranslucency(tspritetype const * const tspr);
float* multiplyMatrix4f(float m0[4*4], const float m1[4*4]); float* multiplyMatrix4f(float m0[4*4], const float m1[4*4]);

View file

@ -28,6 +28,7 @@
#include "imgui.h" #include "imgui.h"
#include "stats.h" #include "stats.h"
#include "menu.h" #include "menu.h"
#include "version.h"
#ifdef USE_OPENGL #ifdef USE_OPENGL
# include "glsurface.h" # include "glsurface.h"
@ -823,7 +824,7 @@ static void yax_copytsprites()
if (spritesortcnt >= maxspritesonscreen) if (spritesortcnt >= maxspritesonscreen)
break; break;
Bmemcpy(&tsprite[spritesortcnt], spr, sizeof(spritetype)); Bmemcpy(&tsprite[spritesortcnt], spr, sizeof(tspritetype));
tsprite[spritesortcnt].owner = spritenum; tsprite[spritesortcnt].owner = spritenum;
tsprite[spritesortcnt].extra = 0; tsprite[spritesortcnt].extra = 0;
tsprite[spritesortcnt].sectnum = sectnum; // potentially tweak sectnum! tsprite[spritesortcnt].sectnum = sectnum; // potentially tweak sectnum!
@ -1454,8 +1455,8 @@ static int32_t bakrendmode;
#endif #endif
static int32_t baktile; static int32_t baktile;
#ifdef APPNAME #ifdef GAMENAME
char apptitle[256] = APPNAME; char apptitle[256] = GAMENAME;
#else #else
char apptitle[256] = "Build Engine"; char apptitle[256] = "Build Engine";
#endif #endif
@ -1478,7 +1479,7 @@ int32_t renderAddTsprite(int16_t z, int16_t sectnum)
if (spritesortcnt >= maxspritesonscreen) if (spritesortcnt >= maxspritesonscreen)
return 1; return 1;
Bmemcpy(&tsprite[spritesortcnt], spr, sizeof(spritetype)); Bmemcpy(&tsprite[spritesortcnt], spr, sizeof(tspritetype));
tsprite[spritesortcnt].extra = 0; tsprite[spritesortcnt].extra = 0;
tsprite[spritesortcnt++].owner = z; tsprite[spritesortcnt++].owner = z;
@ -2051,7 +2052,7 @@ int32_t wallfront(int32_t l1, int32_t l2)
// //
// spritewallfront (internal) // spritewallfront (internal)
// //
static inline int32_t spritewallfront(uspriteptr_t s, int32_t w) static inline int32_t spritewallfront(tspritetype const * const s, int32_t w)
{ {
auto const wal = (uwallptr_t)&wall[w]; auto const wal = (uwallptr_t)&wall[w];
auto const wal2 = (uwallptr_t)&wall[wal->point2]; auto const wal2 = (uwallptr_t)&wall[wal->point2];
@ -8863,7 +8864,7 @@ killsprite:
if ((tspr->cstat & 48) != 16) if ((tspr->cstat & 48) != 16)
tspriteptr[i]->ang = globalang; tspriteptr[i]->ang = globalang;
get_wallspr_points((uspriteptr_t)tspr, &xx[0], &xx[1], &yy[0], &yy[1]); get_wallspr_points(tspr, &xx[0], &xx[1], &yy[0], &yy[1]);
if (!playing_blood? ((tspr->cstat & 48) == 0) : ((tspr->cstat & 48) != 16)) if (!playing_blood? ((tspr->cstat & 48) == 0) : ((tspr->cstat & 48) != 16))
tspriteptr[i]->ang = oang; tspriteptr[i]->ang = oang;
@ -10604,70 +10605,6 @@ add_nextsector:
return 0; return 0;
} }
// x1, y1: in/out
// rest x/y: out
void get_wallspr_points(uspriteptr_t const spr, int32_t *x1, int32_t *x2,
int32_t *y1, int32_t *y2)
{
//These lines get the 2 points of the rotated sprite
//Given: (x1, y1) starts out as the center point
const int32_t tilenum=spr->picnum, ang=spr->ang;
const int32_t xrepeat = spr->xrepeat;
int32_t xoff = picanm[tilenum].xofs + spr->xoffset;
int32_t k, l, dax, day;
if (spr->cstat&4)
xoff = -xoff;
dax = sintable[ang&2047]*xrepeat;
day = sintable[(ang+1536)&2047]*xrepeat;
l = tilesiz[tilenum].x;
k = (l>>1)+xoff;
*x1 -= mulscale16(dax,k);
*x2 = *x1 + mulscale16(dax,l);
*y1 -= mulscale16(day,k);
*y2 = *y1 + mulscale16(day,l);
}
// x1, y1: in/out
// rest x/y: out
void get_floorspr_points(uspriteptr_t const spr, int32_t px, int32_t py,
int32_t *x1, int32_t *x2, int32_t *x3, int32_t *x4,
int32_t *y1, int32_t *y2, int32_t *y3, int32_t *y4)
{
const int32_t tilenum = spr->picnum;
const int32_t cosang = sintable[(spr->ang+512)&2047];
const int32_t sinang = sintable[spr->ang&2047];
vec2_t const span = { tilesiz[tilenum].x, tilesiz[tilenum].y};
vec2_t const repeat = { spr->xrepeat, spr->yrepeat };
vec2_t adjofs = { picanm[tilenum].xofs + spr->xoffset, picanm[tilenum].yofs + spr->yoffset };
if (spr->cstat & 4)
adjofs.x = -adjofs.x;
if (spr->cstat & 8)
adjofs.y = -adjofs.y;
vec2_t const center = { ((span.x >> 1) + adjofs.x) * repeat.x, ((span.y >> 1) + adjofs.y) * repeat.y };
vec2_t const rspan = { span.x * repeat.x, span.y * repeat.y };
vec2_t const ofs = { -mulscale16(cosang, rspan.y), -mulscale16(sinang, rspan.y) };
*x1 += dmulscale16(sinang, center.x, cosang, center.y) - px;
*y1 += dmulscale16(sinang, center.y, -cosang, center.x) - py;
*x2 = *x1 - mulscale16(sinang, rspan.x);
*y2 = *y1 + mulscale16(cosang, rspan.x);
*x3 = *x2 + ofs.x, *x4 = *x1 + ofs.x;
*y3 = *y2 + ofs.y, *y4 = *y1 + ofs.y;
}
// //
// neartag // neartag
// //

View file

@ -132,12 +132,6 @@ extern int16_t bunchp2[MAXWALLSB];
extern int16_t numscans, numbunches; extern int16_t numscans, numbunches;
extern int32_t rxi[8], ryi[8]; extern int32_t rxi[8], ryi[8];
extern void get_wallspr_points(uspriteptr_t spr, int32_t *x1, int32_t *x2,
int32_t *y1, int32_t *y2);
extern void get_floorspr_points(uspriteptr_t spr, int32_t px, int32_t py,
int32_t *x1, int32_t *x2, int32_t *x3, int32_t *x4,
int32_t *y1, int32_t *y2, int32_t *y3, int32_t *y4);
// int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dastat); // int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dastat);
int32_t wallfront(int32_t l1, int32_t l2); int32_t wallfront(int32_t l1, int32_t l2);
@ -239,4 +233,70 @@ template <typename T> static FORCE_INLINE void tileUpdatePicnum(T * const tilept
tile = RotTile(tile).newtile; tile = RotTile(tile).newtile;
} }
// x1, y1: in/out
// rest x/y: out
template <typename T>
static inline void get_wallspr_points(T const * const spr, int32_t *x1, int32_t *x2,
int32_t *y1, int32_t *y2)
{
//These lines get the 2 points of the rotated sprite
//Given: (x1, y1) starts out as the center point
const int32_t tilenum=spr->picnum, ang=spr->ang;
const int32_t xrepeat = spr->xrepeat;
int32_t xoff = picanm[tilenum].xofs + spr->xoffset;
int32_t k, l, dax, day;
if (spr->cstat&4)
xoff = -xoff;
dax = sintable[ang&2047]*xrepeat;
day = sintable[(ang+1536)&2047]*xrepeat;
l = tilesiz[tilenum].x;
k = (l>>1)+xoff;
*x1 -= mulscale16(dax,k);
*x2 = *x1 + mulscale16(dax,l);
*y1 -= mulscale16(day,k);
*y2 = *y1 + mulscale16(day,l);
}
// x1, y1: in/out
// rest x/y: out
template <typename T>
static inline void get_floorspr_points(T const * const spr, int32_t px, int32_t py,
int32_t *x1, int32_t *x2, int32_t *x3, int32_t *x4,
int32_t *y1, int32_t *y2, int32_t *y3, int32_t *y4)
{
const int32_t tilenum = spr->picnum;
const int32_t cosang = sintable[(spr->ang+512)&2047];
const int32_t sinang = sintable[spr->ang&2047];
vec2_t const span = { tilesiz[tilenum].x, tilesiz[tilenum].y};
vec2_t const repeat = { spr->xrepeat, spr->yrepeat };
vec2_t adjofs = { picanm[tilenum].xofs + spr->xoffset, picanm[tilenum].yofs + spr->yoffset };
if (spr->cstat & 4)
adjofs.x = -adjofs.x;
if (spr->cstat & 8)
adjofs.y = -adjofs.y;
vec2_t const center = { ((span.x >> 1) + adjofs.x) * repeat.x, ((span.y >> 1) + adjofs.y) * repeat.y };
vec2_t const rspan = { span.x * repeat.x, span.y * repeat.y };
vec2_t const ofs = { -mulscale16(cosang, rspan.y), -mulscale16(sinang, rspan.y) };
*x1 += dmulscale16(sinang, center.x, cosang, center.y) - px;
*y1 += dmulscale16(sinang, center.y, -cosang, center.x) - py;
*x2 = *x1 - mulscale16(sinang, rspan.x);
*y2 = *y1 + mulscale16(cosang, rspan.x);
*x3 = *x2 + ofs.x, *x4 = *x1 + ofs.x;
*y3 = *y2 + ofs.y, *y4 = *y1 + ofs.y;
}
#endif /* ENGINE_PRIV_H */ #endif /* ENGINE_PRIV_H */

View file

@ -416,7 +416,7 @@ int32_t polymost_maskWallHasTranslucency(uwalltype const * const wall)
return tex && tex->GetTranslucency(); return tex && tex->GetTranslucency();
} }
int32_t polymost_spriteHasTranslucency(uspritetype const * const tspr) int32_t polymost_spriteHasTranslucency(tspritetype const * const tspr)
{ {
if ((tspr->cstat & (CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_RESERVED1)) || if ((tspr->cstat & (CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_RESERVED1)) ||
((unsigned)tspr->owner < MAXSPRITES && spriteext[tspr->owner].alpha)) ((unsigned)tspr->owner < MAXSPRITES && spriteext[tspr->owner].alpha))
@ -3849,7 +3849,7 @@ void Polymost_prepare_loadboard(void)
Bmemset(wsprinfo, 0, sizeof(wsprinfo)); Bmemset(wsprinfo, 0, sizeof(wsprinfo));
} }
static inline int32_t polymost_findwall(uspriteptr_t const tspr, vec2_t const * const tsiz, int32_t * rd) static inline int32_t polymost_findwall(tspritetype const * const tspr, vec2_t const * const tsiz, int32_t * rd)
{ {
int32_t dist = 4, closest = -1; int32_t dist = 4, closest = -1;
auto const sect = (usectortype * )&sector[tspr->sectnum]; auto const sect = (usectortype * )&sector[tspr->sectnum];
@ -4573,8 +4573,7 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
vec3f_t vec1; vec3f_t vec1;
uspritetype tspr; tspritetype tspr{};
Bmemset(&tspr, 0, sizeof(spritetype));
hudtyp const * const hud = tile2model[tilenum].hudmem[(dastat&4)>>2]; hudtyp const * const hud = tile2model[tilenum].hudmem[(dastat&4)>>2];

View file

@ -905,7 +905,7 @@ voxmodel_t *loadkvxfrombuf(const char *kvxbuffer, int32_t length)
if (mip1leng > length - 4) if (mip1leng > length - 4)
{ {
// Invalid KVX file // Invalid KVX file
Bfree(buffer); Xfree(buffer);
return NULL; return NULL;
} }
memcpy(&voxsiz, longptr, sizeof(vec3_t)); memcpy(&voxsiz, longptr, sizeof(vec3_t));
@ -993,7 +993,7 @@ voxmodel_t *loadkvxfrombuf(const char *kvxbuffer, int32_t length)
DO_FREE_AND_NULL(vcol); DO_FREE_AND_NULL(vcol);
vnum = vmax = 0; vnum = vmax = 0;
DO_FREE_AND_NULL(vcolhashead); DO_FREE_AND_NULL(vcolhashead);
Bfree(buffer); Xfree(buffer);
return vm; return vm;
} }

View file

@ -682,7 +682,7 @@ void ReadBindings(int lump, bool override)
void CONFIG_SetDefaultKeys(const char* baseconfig) void CONFIG_SetDefaultKeys(const char* baseconfig)
{ {
auto lump = fileSystem.GetFile("demolition/commonbinds.txt", ELookupMode::FullName, 0); auto lump = fileSystem.GetFile("engine/commonbinds.txt", ELookupMode::FullName, 0);
if (lump >= 0) ReadBindings(lump, true); if (lump >= 0) ReadBindings(lump, true);
int lastlump = 0; int lastlump = 0;
@ -700,7 +700,7 @@ void CONFIG_SetDefaultKeys(const char* baseconfig)
void C_BindDefaults() void C_BindDefaults()
{ {
CONFIG_SetDefaultKeys(cl_defaultconfiguration == 1 ? "demolition/origbinds.txt" : cl_defaultconfiguration == 2 ? "demolition/leftbinds.txt" : "demolition/defbinds.txt"); CONFIG_SetDefaultKeys(cl_defaultconfiguration == 1 ? "engine/origbinds.txt" : cl_defaultconfiguration == 2 ? "engine/leftbinds.txt" : "engine/defbinds.txt");
} }
#if 0 #if 0

View file

@ -100,7 +100,7 @@ void FileSystem::DeleteAll ()
// //
//========================================================================== //==========================================================================
int FileSystem::InitMultipleFiles (TArray<FString> &filenames, const TArray<FString> &deletelumps) int FileSystem::InitMultipleFiles (TArray<FString> &filenames, const TArray<FString> &deletelumps, int maingamefiles)
{ {
int numfiles; int numfiles;
@ -126,6 +126,7 @@ int FileSystem::InitMultipleFiles (TArray<FString> &filenames, const TArray<FStr
{ {
return 0; return 0;
} }
DeleteStuff(deletelumps, maingamefiles);
// [RH] Set up hash table // [RH] Set up hash table
Hashes.Resize(NumLookupModes * 2 * NumEntries); Hashes.Resize(NumLookupModes * 2 * NumEntries);
@ -140,6 +141,34 @@ int FileSystem::InitMultipleFiles (TArray<FString> &filenames, const TArray<FStr
return NumEntries; return NumEntries;
} }
//==========================================================================
//
// Deletes unwanted content from the main game files
//
//==========================================================================
void FileSystem::DeleteStuff(const TArray<FString>& deletelumps, int numgamefiles)
{
// This must account for the game directory being inserted at index 2.
// Deletion may only occur in the main game file, the directory and the add-on, there are no secondary dependencies, i.e. more than two game files.
numgamefiles++;
if (deletelumps.Size())
for (uint32_t i = 0; i < FileInfo.Size(); i++)
{
if (FileInfo[i].rfnum >= 1 && FileInfo[i].rfnum <= numgamefiles)
{
auto cmp = FileInfo[i].lump->LumpName[FResourceLump::FullNameType].GetChars();
for (auto &str : deletelumps)
{
if (!str.CompareNoCase(cmp))
{
for (auto& n : FileInfo[i].lump->LumpName) n = NAME_None;
}
}
}
}
}
//========================================================================== //==========================================================================
// //
// AddFile // AddFile

View file

@ -81,7 +81,9 @@ public:
FileSystem () = default; FileSystem () = default;
~FileSystem (); ~FileSystem ();
int InitMultipleFiles (TArray<FString> &filenames, const TArray<FString> &todelete); int InitMultipleFiles (TArray<FString> &filenames, const TArray<FString> &todelete, int maingamefiles);
void DeleteStuff(const TArray<FString>& deletelumps, int numgamefiles);
void AddFile (const char *filename, FileReader *wadinfo = NULL, bool nosubdirflag = false); void AddFile (const char *filename, FileReader *wadinfo = NULL, bool nosubdirflag = false);
void AddAdditionalFile(const char* filename, FileReader* wadinfo = NULL) {} void AddAdditionalFile(const char* filename, FileReader* wadinfo = NULL) {}
int CheckIfResourceFileLoaded (const char *name) noexcept; int CheckIfResourceFileLoaded (const char *name) noexcept;

View file

@ -404,7 +404,7 @@ void V_InitFontColors ()
TranslationLookup.Clear(); TranslationLookup.Clear();
TranslationColors.Clear(); TranslationColors.Clear();
while ((lump = fileSystem.Iterate("demolition/textcolors.txt", &lastlump)) != -1) while ((lump = fileSystem.Iterate("engine/textcolors.txt", &lastlump)) != -1)
{ {
FScanner sc(lump); FScanner sc(lump);
while (sc.GetString()) while (sc.GetString())
@ -714,13 +714,13 @@ void V_InitFonts()
FFont *CreateHexLumpFont(const char *fontname, const char* lump); FFont *CreateHexLumpFont(const char *fontname, const char* lump);
FFont *CreateHexLumpFont2(const char *fontname, const char * lump); FFont *CreateHexLumpFont2(const char *fontname, const char * lump);
if (fileSystem.FindFile("demolition/newconsolefont.hex") < 0) if (fileSystem.FindFile("engine/newconsolefont.hex") < 0)
I_Error("newconsolefont.hex not found"); // This font is needed - do not start up without it. I_Error("newconsolefont.hex not found"); // This font is needed - do not start up without it.
NewConsoleFont = CreateHexLumpFont("NewConsoleFont", "demolition/newconsolefont.hex"); NewConsoleFont = CreateHexLumpFont("NewConsoleFont", "engine/newconsolefont.hex");
NewSmallFont = CreateHexLumpFont2("NewSmallFont", "demolition/newconsolefont.hex"); NewSmallFont = CreateHexLumpFont2("NewSmallFont", "engine/newconsolefont.hex");
CurrentConsoleFont = NewConsoleFont; CurrentConsoleFont = NewConsoleFont;
ConFont = V_GetFont("ConsoleFont", "demolition/confont.lmp"); // The con font is needed for the slider graphics ConFont = V_GetFont("ConsoleFont", "engine/confont.lmp"); // The con font is needed for the slider graphics
SmallFont = ConFont; // This is so that it doesn't crash and that it immediately gets seen as a proble. The SmallFont should later be mapped to the small game font. SmallFont = ConFont; // This is so that it doesn't crash and that it immediately gets seen as a proble. The SmallFont should later be mapped to the small game font.
} }

View file

@ -529,7 +529,7 @@ int RunGame()
FString logfile = Args->TakeValue("+logfile"); FString logfile = Args->TakeValue("+logfile");
// As long as this engine is still in prerelease mode let's always write a log file. // As long as this engine is still in prerelease mode let's always write a log file.
if (logfile.IsEmpty()) logfile.Format("%sdemolition.log", M_GetDocumentsPath().GetChars()); if (logfile.IsEmpty()) logfile.Format("%s" GAMENAMELOWERCASE ".log", M_GetDocumentsPath().GetChars());
if (logfile.IsNotEmpty()) if (logfile.IsNotEmpty())
{ {
@ -552,6 +552,13 @@ int RunGame()
InitFileSystem(usedgroups); InitFileSystem(usedgroups);
if (usedgroups.Size() == 0) return 0; if (usedgroups.Size() == 0) return 0;
if (g_gameType & GAMEFLAG_BLOOD)
{
UCVarValue v;
v.Bool = false;
mus_redbook.SetGenericRepDefault(v, CVAR_Bool); // Blood should default to CD Audio off - all other games must default to on.
}
G_ReadConfig(currentGame); G_ReadConfig(currentGame);
V_InitFontColors(); V_InitFontColors();
@ -577,7 +584,7 @@ int RunGame()
TileFiles.AddArt(addArt); TileFiles.AddArt(addArt);
inputState.ClearAllInput(); inputState.ClearAllInput();
CONFIG_SetDefaultKeys(cl_defaultconfiguration == 1 ? "demolition/origbinds.txt" : cl_defaultconfiguration == 2 ? "demolition/leftbinds.txt" : "demolition/defbinds.txt"); CONFIG_SetDefaultKeys(cl_defaultconfiguration == 1 ? "engine/origbinds.txt" : cl_defaultconfiguration == 2 ? "engine/leftbinds.txt" : "engine/defbinds.txt");
if (!GameConfig->IsInitialized()) if (!GameConfig->IsInitialized())
{ {
@ -590,7 +597,7 @@ int RunGame()
} }
V_InitFonts(); V_InitFonts();
C_CON_SetAliases(); C_CON_SetAliases();
sfx_empty = fileSystem.FindFile("demolition/dsempty.lmp"); // this must be done outside the sound code because it's initialized late. sfx_empty = fileSystem.FindFile("engine/dsempty.lmp"); // this must be done outside the sound code because it's initialized late.
Mus_Init(); Mus_Init();
InitStatistics(); InitStatistics();
M_Init(); M_Init();
@ -642,7 +649,7 @@ void CONFIG_ReadCombatMacros()
FScanner sc; FScanner sc;
try try
{ {
sc.Open("demolition/combatmacros.txt"); sc.Open("engine/combatmacros.txt");
for (auto s : CombatMacros) for (auto s : CombatMacros)
{ {
sc.MustGetToken(TK_StringConst); sc.MustGetToken(TK_StringConst);
@ -697,7 +704,7 @@ CCMD(snd_reset)
{ {
Mus_Stop(); Mus_Stop();
if (soundEngine) soundEngine->Reset(); if (soundEngine) soundEngine->Reset();
MUS_ResumeSaved(); Mus_ResumeSaved();
} }
//========================================================================== //==========================================================================

View file

@ -127,6 +127,7 @@ struct GrpInfo
int flags = 0; int flags = 0;
bool loaddirectory = false; bool loaddirectory = false;
TArray<FString> mustcontain; TArray<FString> mustcontain;
TArray<FString> tobedeleted;
TArray<FString> loadfiles; TArray<FString> loadfiles;
TArray<FString> loadart; TArray<FString> loadart;
}; };

View file

@ -134,7 +134,7 @@ CVARD(Bool, snd_tryformats, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enables/disab
CVARD(Bool, snd_doppler, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable 3d sound") CVARD(Bool, snd_doppler, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable 3d sound")
CVARD(Bool, mus_restartonload, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "restart the music when loading a saved game with the same map or not") // only implemented for Blood - todo: generalize CVARD(Bool, mus_restartonload, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "restart the music when loading a saved game with the same map or not") // only implemented for Blood - todo: generalize
CVARD(Bool, mus_redbook, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_FRONTEND_BLOOD, "enables/disables redbook audio (Blood only!)") // only Blood has assets for this. CVARD(Bool, mus_redbook, true, CVAR_ARCHIVE, "enables/disables redbook audio")
CUSTOM_CVARD(Int, snd_fxvolume, 255, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "controls volume for sound effects") CUSTOM_CVARD(Int, snd_fxvolume, 255, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "controls volume for sound effects")
{ {

View file

@ -41,6 +41,7 @@
#include "gameconfigfile.h" #include "gameconfigfile.h"
#include "printf.h" #include "printf.h"
#include "m_argv.h" #include "m_argv.h"
#include "version.h"
#include "../platform/win32/i_findfile.h" // This is a temporary direct path. Needs to be fixed when stuff gets cleaned up. #include "../platform/win32/i_findfile.h" // This is a temporary direct path. Needs to be fixed when stuff gets cleaned up.
#ifndef PATH_MAX #ifndef PATH_MAX
@ -296,7 +297,7 @@ void InitFileSystem(TArray<GrpEntry>& groups)
TArray<FString> Files; TArray<FString> Files;
// First comes the engine's own stuff. // First comes the engine's own stuff.
FString baseres = progdir + "demolition.pk3"; FString baseres = progdir + ENGINERES_FILE;
D_AddFile(Files, baseres); D_AddFile(Files, baseres);
bool insertdirectoriesafter = Args->CheckParm("-insertdirafter"); bool insertdirectoriesafter = Args->CheckParm("-insertdirafter");
@ -378,7 +379,11 @@ void InitFileSystem(TArray<GrpEntry>& groups)
} }
TArray<FString> todelete; TArray<FString> todelete;
fileSystem.InitMultipleFiles(Files, todelete); for (auto& g : groups)
{
todelete.Append(g.FileInfo.tobedeleted);
}
fileSystem.InitMultipleFiles(Files, todelete, groups.Size());
FILE* f = fopen("filesystem.dir", "wb"); FILE* f = fopen("filesystem.dir", "wb");
for (int i = 0; i < fileSystem.GetNumEntries(); i++) for (int i = 0; i < fileSystem.GetNumEntries(); i++)

View file

@ -266,7 +266,7 @@ bool DMenu::MouseEventBack(int type, int x, int y)
{ {
if (m_show_backbutton >= 0) if (m_show_backbutton >= 0)
{ {
FTexture* tex = TileFiles.GetTexture("demolition/graphics/m_back.png"); FTexture* tex = TileFiles.GetTexture("engine/graphics/m_back.png");
if (tex != NULL) if (tex != NULL)
{ {
if (m_show_backbutton&1) x -= screen->GetWidth() - tex->GetWidth() * CleanXfac; if (m_show_backbutton&1) x -= screen->GetWidth() - tex->GetWidth() * CleanXfac;
@ -322,7 +322,7 @@ void DMenu::Drawer ()
{ {
if (this == DMenu::CurrentMenu && BackbuttonAlpha > 0 && m_show_backbutton >= 0 && m_use_mouse) if (this == DMenu::CurrentMenu && BackbuttonAlpha > 0 && m_show_backbutton >= 0 && m_use_mouse)
{ {
FTexture* tex = TileFiles.GetTexture("demolition/graphics/m_back.png"); FTexture* tex = TileFiles.GetTexture("engine/graphics/m_back.png");
int w = tex->GetWidth() * CleanXfac; int w = tex->GetWidth() * CleanXfac;
int h = tex->GetHeight() * CleanYfac; int h = tex->GetHeight() * CleanYfac;
int x = (!(m_show_backbutton&1))? 0:screen->GetWidth() - w; int x = (!(m_show_backbutton&1))? 0:screen->GetWidth() - w;

View file

@ -1146,7 +1146,7 @@ void M_ParseMenuDefs()
DefaultOptionMenuSettings.Reset(); DefaultOptionMenuSettings.Reset();
M_DeinitMenus(); M_DeinitMenus();
while ((lump = fileSystem.Iterate("demolition/menudef.txt", &lastlump)) != -1) while ((lump = fileSystem.Iterate("engine/menudef.txt", &lastlump)) != -1)
{ {
FScanner sc(lump); FScanner sc(lump);
@ -1261,6 +1261,7 @@ static void BuildEpisodeMenu()
} }
} }
} }
#if 0 // this needs to be backed by a working selection menu, until that gets done it must be disabled.
if (!(g_gameType & GAMEFLAG_SHAREWARE)) if (!(g_gameType & GAMEFLAG_SHAREWARE))
{ {
//auto it = new FListMenuItemNativeStaticText(ld->mXpos, "", NIT_SmallFont); // empty entry as spacer. //auto it = new FListMenuItemNativeStaticText(ld->mXpos, "", NIT_SmallFont); // empty entry as spacer.
@ -1271,6 +1272,7 @@ static void BuildEpisodeMenu()
ld->mItems.Push(it); ld->mItems.Push(it);
addedVolumes++; addedVolumes++;
} }
#endif
if (addedVolumes == 1) if (addedVolumes == 1)
{ {
ld->mAutoselect = 0; ld->mAutoselect = 0;

View file

@ -226,7 +226,7 @@ static void SetupGenMidi()
{ {
// The OPL renderer should not care about where this comes from. // The OPL renderer should not care about where this comes from.
// Note: No I_Error here - this needs to be consistent with the rest of the music code. // Note: No I_Error here - this needs to be consistent with the rest of the music code.
auto lump = fileSystem.FindFile("demolition/genmidi.op2"); auto lump = fileSystem.FindFile("engine/genmidi.op2");
if (lump < 0) if (lump < 0)
{ {
Printf("No GENMIDI lump found. OPL playback not available."); Printf("No GENMIDI lump found. OPL playback not available.");

View file

@ -40,6 +40,7 @@
#include "filereadermusicinterface.h" #include "filereadermusicinterface.h"
#include "zmusic/zmusic.h" #include "zmusic/zmusic.h"
#include "resourcefile.h" #include "resourcefile.h"
#include "version.h"
#include "../platform/win32/i_findfile.h" // This is a temporary direct path. Needs to be fixed when stuff gets cleaned up. #include "../platform/win32/i_findfile.h" // This is a temporary direct path. Needs to be fixed when stuff gets cleaned up.
//========================================================================== //==========================================================================
@ -436,7 +437,7 @@ void FSoundFontManager::CollectSoundfonts()
if (soundfonts.Size() == 0) if (soundfonts.Size() == 0)
{ {
ProcessOneFile(NicePath("$PROGDIR/soundfonts/demolition.sf2")); ProcessOneFile(NicePath("$PROGDIR/soundfonts/" GAMENAMELOWERCASE ".sf2"));
} }
} }

View file

@ -536,7 +536,7 @@ CCMD (stopmus)
static FString lastMusicLevel, lastMusic; static FString lastMusicLevel, lastMusic;
int Mus_Play(const char *mapname, const char *fn, bool loop) int Mus_Play(const char *mapname, const char *fn, bool loop)
{ {
if (mus_blocked) return 0; if (mus_blocked) return 1; // Caller should believe it succeeded.
// Store the requested names for resuming. // Store the requested names for resuming.
lastMusicLevel = mapname; lastMusicLevel = mapname;
lastMusic = fn; lastMusic = fn;
@ -579,6 +579,11 @@ int Mus_Play(const char *mapname, const char *fn, bool loop)
return mus_playing.handle != nullptr; return mus_playing.handle != nullptr;
} }
bool Mus_IsPlaying()
{
return mus_playing.handle != nullptr;
}
void Mus_Stop() void Mus_Stop()
{ {
if (mus_blocked) return; if (mus_blocked) return;
@ -654,7 +659,7 @@ bool MUS_Restore()
return true; return true;
} }
void MUS_ResumeSaved() void Mus_ResumeSaved()
{ {
S_RestartMusic(); S_RestartMusic();
} }

View file

@ -38,6 +38,7 @@
#include <string> #include <string>
#include "c_cvars.h" #include "c_cvars.h"
#include "s_music.h" #include "s_music.h"
#include "version.h"
#include "zmusic/zmusic.h" #include "zmusic/zmusic.h"
//========================================================================== //==========================================================================
@ -74,7 +75,7 @@ CUSTOM_CVAR(String, fluid_lib, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_VIRTU
FORWARD_STRING_CVAR(fluid_lib); FORWARD_STRING_CVAR(fluid_lib);
} }
CUSTOM_CVAR(String, fluid_patchset, "demolition", CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_VIRTUAL) CUSTOM_CVAR(String, fluid_patchset, GAMENAMELOWERCASE, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_VIRTUAL)
{ {
FORWARD_STRING_CVAR(fluid_patchset); FORWARD_STRING_CVAR(fluid_patchset);
} }
@ -273,7 +274,7 @@ CUSTOM_CVAR(Float, min_sustain_time, 5000, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CV
FORWARD_CVAR(min_sustain_time); FORWARD_CVAR(min_sustain_time);
} }
CUSTOM_CVAR(String, timidity_config, "demolition", CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_VIRTUAL) CUSTOM_CVAR(String, timidity_config, GAMENAMELOWERCASE, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_VIRTUAL)
{ {
FORWARD_STRING_CVAR(timidity_config); FORWARD_STRING_CVAR(timidity_config);
} }

View file

@ -97,7 +97,7 @@ void S_ParseSndInfo ()
{ {
int lump, lastlump = 0; int lump, lastlump = 0;
while ((lump = fileSystem.Iterate("demolition/mussetting.txt", &lastlump)) >= 0) while ((lump = fileSystem.Iterate("engine/mussetting.txt", &lastlump)) >= 0)
{ {
S_AddSNDINFO (lump); S_AddSNDINFO (lump);
} }

View file

@ -5,6 +5,7 @@
void Mus_Init(); void Mus_Init();
int Mus_Play(const char *mapname, const char *fn, bool loop); int Mus_Play(const char *mapname, const char *fn, bool loop);
void Mus_Stop(); void Mus_Stop();
bool Mus_IsPlaying();
void Mus_Fade(double seconds); void Mus_Fade(double seconds);
void Mus_SetPaused(bool on); void Mus_SetPaused(bool on);
void MUS_ResumeSaved(); void Mus_ResumeSaved();

View file

@ -36,10 +36,3 @@
#endif #endif
#ifndef APPNAME
#define APPNAME "Demolition"
#endif
#ifndef APPBASENAME
#define APPBASENAME "demolition"
#endif

View file

@ -79,7 +79,7 @@ FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t const ismusic)
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic); auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen()) if (fp.isOpen())
{ {
Bfree(testfn); Xfree(testfn);
return fp; return fp;
} }
@ -95,7 +95,7 @@ FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t const ismusic)
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic); auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen()) if (fp.isOpen())
{ {
Bfree(testfn); Xfree(testfn);
return fp; return fp;
} }
} }
@ -107,12 +107,12 @@ FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t const ismusic)
auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic); auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp.isOpen()) if (fp.isOpen())
{ {
Bfree(testfn); Xfree(testfn);
return fp; return fp;
} }
} }
Bfree(testfn); Xfree(testfn);
return origfp; return origfp;
#endif #endif
} }

View file

@ -373,7 +373,7 @@ FString V_GetColorStringByName (const char *name, FScriptPosition *sc)
if (fileSystem.GetNumEntries()==0) return FString(); if (fileSystem.GetNumEntries()==0) return FString();
rgblump = fileSystem.FindFile ("demolition/X11R6RGB.txt"); rgblump = fileSystem.FindFile ("engine/X11R6RGB.txt");
if (rgblump == -1) if (rgblump == -1)
{ {
if (!sc) Printf ("X11R6RGB lump not found\n"); if (!sc) Printf ("X11R6RGB lump not found\n");

View file

@ -76,7 +76,7 @@ CVAR(String, screenshot_dir, "", CVAR_ARCHIVE) // same here.
static void WritePNGfile(FileWriter* file, const uint8_t* buffer, const PalEntry* palette, static void WritePNGfile(FileWriter* file, const uint8_t* buffer, const PalEntry* palette,
ESSType color_type, int width, int height, int pitch, float gamma) ESSType color_type, int width, int height, int pitch, float gamma)
{ {
FStringf software("Demolition %s", GetVersionString()); FStringf software(GAMENAME " %s", GetVersionString());
if (!M_CreatePNG(file, buffer, palette, color_type, width, height, pitch, gamma) || if (!M_CreatePNG(file, buffer, palette, color_type, width, height, pitch, gamma) ||
!M_AppendPNGText(file, "Software", software) || !M_AppendPNGText(file, "Software", software) ||
!M_FinishPNG(file)) !M_FinishPNG(file))

View file

@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "resourcefile.h" #include "resourcefile.h"
#include "printf.h" #include "printf.h"
#include "common.h" #include "common.h"
#include "version.h"
#include "gamecontrol.h" #include "gamecontrol.h"
#include "filesystem/filesystem.h" #include "filesystem/filesystem.h"
@ -799,6 +800,14 @@ static TArray<GrpInfo> ParseGrpInfo(const char *fn, FileReader &fr, TMap<FString
} }
while (sc.CheckToken(',')); while (sc.CheckToken(','));
} }
else if (sc.Compare("deletecontent"))
{
do
{
sc.MustGetToken(TK_StringConst);
grp.tobedeleted.Push(sc.String);
} while (sc.CheckToken(','));
}
else if (sc.Compare("loadgrp")) else if (sc.Compare("loadgrp"))
{ {
do do
@ -837,17 +846,17 @@ TArray<GrpInfo> ParseAllGrpInfos(TArray<FileEntry>& filelist)
extern FString progdir; extern FString progdir;
// This opens the base resource only for reading the grpinfo from it which we need before setting up the game state. // This opens the base resource only for reading the grpinfo from it which we need before setting up the game state.
std::unique_ptr<FResourceFile> engine_res; std::unique_ptr<FResourceFile> engine_res;
FString baseres = progdir + "demolition.pk3"; FString baseres = progdir + ENGINERES_FILE;
engine_res.reset(FResourceFile::OpenResourceFile(baseres, true, true)); engine_res.reset(FResourceFile::OpenResourceFile(baseres, true, true));
if (engine_res) if (engine_res)
{ {
auto basegrp = engine_res->FindLump("demolition/demolition.grpinfo"); auto basegrp = engine_res->FindLump("engine/grpinfo.txt");
if (basegrp) if (basegrp)
{ {
auto fr = basegrp->NewReader(); auto fr = basegrp->NewReader();
if (fr.isOpen()) if (fr.isOpen())
{ {
groups = ParseGrpInfo("demolition/demolition.grpinfo", fr, CRCMap); groups = ParseGrpInfo("engine/grpinfo.txt", fr, CRCMap);
} }
} }
} }
@ -1188,10 +1197,10 @@ bool AddINIFile(const char* pzFile, bool bForce = false)
if (findfrompath(pzFile, &pzFN)) return false; // failed to resolve the filename if (findfrompath(pzFile, &pzFN)) return false; // failed to resolve the filename
if (!FileExists(pzFN)) if (!FileExists(pzFN))
{ {
Bfree(pzFN); Xfree(pzFN);
return false; return false;
} // failed to stat the file } // failed to stat the file
Bfree(pzFN); Xfree(pzFN);
IniFile* pTempIni = new IniFile(pzFile); IniFile* pTempIni = new IniFile(pzFile);
if (!pTempIni->FindSection("Episode1")) if (!pTempIni->FindSection("Episode1"))
{ {

View file

@ -65,6 +65,7 @@ int sfx_empty = -1;
void SoundEngine::Init(TArray<uint8_t> &curve, int factor) void SoundEngine::Init(TArray<uint8_t> &curve, int factor)
{ {
StopAllChannels();
// Free all channels for use. // Free all channels for use.
while (Channels != NULL) while (Channels != NULL)
{ {
@ -1428,7 +1429,7 @@ void SoundEngine::StopChannel(FSoundChan *chan)
chan->Source = NULL; chan->Source = NULL;
} }
} }
GSnd->StopChannel(chan); if (GSnd) GSnd->StopChannel(chan);
} }
else else
{ {

View file

@ -274,7 +274,10 @@ protected:
virtual FSoundID ResolveSound(const void *ent, int srctype, FSoundID soundid, float &attenuation); virtual FSoundID ResolveSound(const void *ent, int srctype, FSoundID soundid, float &attenuation);
public: public:
virtual ~SoundEngine() = default; virtual ~SoundEngine()
{
Shutdown();
}
void EvictAllChannels(); void EvictAllChannels();
void StopChannel(FSoundChan* chan); void StopChannel(FSoundChan* chan);

View file

@ -48,9 +48,10 @@
#include "savegamehelp.h" #include "savegamehelp.h"
#include "sjson.h" #include "sjson.h"
#include "gstrings.h" #include "gstrings.h"
#include "version.h"
CVAR(Int, savestatistics, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Int, savestatistics, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(String, statfile, "demolitionstat.txt", CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(String, statfile, GAMENAMELOWERCASE "stat.txt", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
//========================================================================== //==========================================================================
// //

View file

@ -61,13 +61,13 @@ void FStringTable::LoadStrings ()
int lastlump, lump; int lastlump, lump;
lastlump = 0; lastlump = 0;
while ((lump = fileSystem.Iterate("demolition/lmacros", &lastlump, ELookupMode::NoExtension)) != -1) while ((lump = fileSystem.Iterate("engine/lmacros", &lastlump, ELookupMode::NoExtension)) != -1)
{ {
readMacros(lump); readMacros(lump);
} }
lastlump = 0; lastlump = 0;
while ((lump = fileSystem.Iterate ("demolition/language", &lastlump, ELookupMode::NoExtension)) != -1) while ((lump = fileSystem.Iterate ("engine/language", &lastlump, ELookupMode::NoExtension)) != -1)
{ {
auto lumpdata = fileSystem.GetFileData(lump); auto lumpdata = fileSystem.GetFileData(lump);

View file

@ -58,12 +58,13 @@ const char *GetVersionString();
#define GAMENAMELOWERCASE "demolition" #define GAMENAMELOWERCASE "demolition"
#define FORUM_URL "http://forum.zdoom.org/" #define FORUM_URL "http://forum.zdoom.org/"
#define BUGS_FORUM_URL "http://forum.zdoom.org/viewforum.php?f=2" // fixme before release!!! #define BUGS_FORUM_URL "http://forum.zdoom.org/viewforum.php?f=2" // fixme before release!!!
#define ENGINERES_FILE GAMENAMELOWERCASE ".pk3"
#define SAVESIG_DN3D "Demolition.Duke" #define SAVESIG_DN3D GAMENAME ".Duke"
#define SAVESIG_BLD "Demolition.Blood" #define SAVESIG_BLD GAMENAME "Blood"
#define SAVESIG_RR "Demolition.Redneck" #define SAVESIG_RR GAMENAME "Redneck"
#define SAVESIG_SW "Demolition.SW" #define SAVESIG_SW GAMENAME "SW"
#define SAVESIG_PS "Demolition.Powerslave" #define SAVESIG_PS GAMENAME "Powerslave"
#define MINSAVEVER_DN3D 1 #define MINSAVEVER_DN3D 1
#define MINSAVEVER_BLD 1 #define MINSAVEVER_BLD 1

View file

@ -36,8 +36,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "menu/menu.h" #include "menu/menu.h"
#include "memarena.h" #include "memarena.h"
#define HEAD2 APPNAME
#ifdef EDUKE32_STANDALONE #ifdef EDUKE32_STANDALONE
#define VOLUMEALL (1) #define VOLUMEALL (1)
#define PLUTOPAK (1) #define PLUTOPAK (1)

View file

@ -263,7 +263,7 @@ void G_GameExit(const char *msg)
{ {
if (!(msg[0] == ' ' && msg[1] == 0)) if (!(msg[0] == ' ' && msg[1] == 0))
{ {
I_Error("%s", msg); I_FatalError("%s", msg);
} }
} }
throw ExitEvent(0); throw ExitEvent(0);
@ -360,7 +360,7 @@ static void G_OROR_DupeSprites(spritetype const *sp)
if (sprite[k].picnum != SECTOREFFECTOR && sprite[k].z >= sp->z) if (sprite[k].picnum != SECTOREFFECTOR && sprite[k].z >= sp->z)
{ {
Bmemcpy(&tsprite[spritesortcnt], &sprite[k], sizeof(spritetype)); Bmemcpy(&tsprite[spritesortcnt], &sprite[k], sizeof(tspritetype));
tsprite[spritesortcnt].x += (refsp->x - sp->x); tsprite[spritesortcnt].x += (refsp->x - sp->x);
tsprite[spritesortcnt].y += (refsp->y - sp->y); tsprite[spritesortcnt].y += (refsp->y - sp->y);
@ -3621,6 +3621,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura
const int32_t i = t->owner; const int32_t i = t->owner;
// XXX: what's up with the (i < 0) check? // XXX: what's up with the (i < 0) check?
// NOTE: not const spritetype because set at SET_SPRITE_NOT_TSPRITE (see below). // NOTE: not const spritetype because set at SET_SPRITE_NOT_TSPRITE (see below).
EDUKE32_STATIC_ASSERT(sizeof(uspritetype) == sizeof(tspritetype)); // see TSPRITE_SIZE
auto const pSprite = (i < 0) ? (uspriteptr_t)&tsprite[j] : (uspriteptr_t)&sprite[i]; auto const pSprite = (i < 0) ? (uspriteptr_t)&tsprite[j] : (uspriteptr_t)&sprite[i];
#ifndef EDUKE32_STANDALONE #ifndef EDUKE32_STANDALONE
@ -3762,7 +3763,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura
{ {
auto const newt = &tsprite[spritesortcnt++]; auto const newt = &tsprite[spritesortcnt++];
Bmemcpy(newt, t, sizeof(spritetype)); *newt = *t;
newt->cstat |= 2|512; newt->cstat |= 2|512;
newt->x += (sintable[(newt->ang+512)&2047]>>12); newt->x += (sintable[(newt->ang+512)&2047]>>12);

View file

@ -462,23 +462,6 @@ static inline int G_GetMusicIdx(const char *str)
return (ep * MAXLEVELS) + lev; return (ep * MAXLEVELS) + lev;
} }
static inline int G_GetViewscreenSizeShift(uspriteptr_t const spr)
{
#if VIEWSCREENFACTOR == 0
UNREFERENCED_PARAMETER(spr);
return VIEWSCREENFACTOR;
#else
static const int mask = (1<<VIEWSCREENFACTOR)-1;
const int rem = (spr->xrepeat & mask) | (spr->yrepeat & mask);
for (int i=0; i < VIEWSCREENFACTOR; i++)
if (rem & (1<<i))
return i;
return VIEWSCREENFACTOR;
#endif
}
EXTERN_INLINE_HEADER void G_SetStatusBarScale(int32_t sc); EXTERN_INLINE_HEADER void G_SetStatusBarScale(int32_t sc);
@ -489,6 +472,24 @@ EXTERN_INLINE_HEADER void SetIfGreater(int32_t *variable, int32_t potentialValue
#ifndef ONLY_USERDEFS #ifndef ONLY_USERDEFS
template <typename T>
static inline int G_GetViewscreenSizeShift(T const * spr)
{
#if VIEWSCREENFACTOR == 0
UNREFERENCED_PARAMETER(spr);
return VIEWSCREENFACTOR;
#else
static CONSTEXPR int const mask = (1<<VIEWSCREENFACTOR)-1;
const int rem = (spr->xrepeat & mask) | (spr->yrepeat & mask);
for (int i=0; i < VIEWSCREENFACTOR; i++)
if (rem & (1<<i))
return i;
return VIEWSCREENFACTOR;
#endif
}
#if defined game_c_ || !defined DISABLE_INLINING #if defined game_c_ || !defined DISABLE_INLINING
EXTERN_INLINE void G_SetStatusBarScale(int32_t sc) EXTERN_INLINE void G_SetStatusBarScale(int32_t sc)

View file

@ -41,6 +41,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c_dispatch.h" #include "c_dispatch.h"
#include "quotemgr.h" #include "quotemgr.h"
#include "mapinfo.h" #include "mapinfo.h"
#include "version.h"
#include "debugbreak.h" #include "debugbreak.h"
extern bool rotatesprite_2doverride; extern bool rotatesprite_2doverride;
@ -3776,7 +3777,7 @@ badindex:
quoteMgr.InitializeQuote(q, g_player[vm.playerNum].user_name); quoteMgr.InitializeQuote(q, g_player[vm.playerNum].user_name);
break; break;
case STR_VERSION: case STR_VERSION:
Bsprintf(tempbuf, HEAD2 " %s", GetGitDescription()); Bsprintf(tempbuf, GAMENAME " %s", GetGitDescription());
quoteMgr.InitializeQuote(q, tempbuf); quoteMgr.InitializeQuote(q, tempbuf);
break; break;
case STR_GAMETYPE: quoteMgr.InitializeQuote(q, g_gametypeNames[ud.coop]); break; case STR_GAMETYPE: quoteMgr.InitializeQuote(q, g_gametypeNames[ud.coop]); break;
@ -6222,12 +6223,14 @@ badindex:
vmErrorCase: // you're not supposed to be here vmErrorCase: // you're not supposed to be here
VM_ScriptInfo(insptr, 64); VM_ScriptInfo(insptr, 64);
debug_break(); debug_break();
G_GameExit("An error has occurred in the " APPNAME " virtual machine.\n\n" G_GameExit("An error has occurred in the " GAMENAME " virtual machine.\n\n");
"If you are an end user, please e-mail the file " APPBASENAME ".log\n" #if 0
"If you are an end user, please e-mail the file " GAMENAMELOWERCASE ".log\n"
"along with links to any mods you're using to development@voidpoint.com.\n\n" "along with links to any mods you're using to development@voidpoint.com.\n\n"
"If you are a developer, please attach all of your script files\n" "If you are a developer, please attach all of your script files\n"
"along with instructions on how to reproduce this error.\n\n" "along with instructions on how to reproduce this error.\n\n"
"Thank you!"); "Thank you!");
#endif
} }
#ifndef CON_USE_COMPUTED_GOTO #ifndef CON_USE_COMPUTED_GOTO
} }

View file

@ -255,7 +255,7 @@ static FORCE_INLINE void __fastcall Gv_DivVar(int const id, int32_t const d)
{ {
case GAMEVAR_PERACTOR: iptr = &var.pValues[vm.spriteNum & (MAXSPRITES-1)]; goto jmp; case GAMEVAR_PERACTOR: iptr = &var.pValues[vm.spriteNum & (MAXSPRITES-1)]; goto jmp;
case GAMEVAR_PERPLAYER: iptr = &var.pValues[vm.playerNum & (MAXPLAYERS-1)]; fallthrough__; case GAMEVAR_PERPLAYER: iptr = &var.pValues[vm.playerNum & (MAXPLAYERS-1)]; fallthrough__;
jmp: default: *iptr = libdivide_s32_do(*iptr, dptr); break; default: jmp: *iptr = libdivide_s32_do(*iptr, dptr); break;
case GAMEVAR_INT32PTR: case GAMEVAR_INT32PTR:
{ {

View file

@ -1929,7 +1929,7 @@ static void postloadplayer(int32_t savegamep)
Bmemset(gotpic, 0, sizeof(gotpic)); Bmemset(gotpic, 0, sizeof(gotpic));
S_ClearSoundLocks(); S_ClearSoundLocks();
G_CacheMapData(); G_CacheMapData();
MUS_ResumeSaved(); Mus_ResumeSaved();
g_player[myconnectindex].ps->gm = MODE_GAME; g_player[myconnectindex].ps->gm = MODE_GAME;
ud.recstat = 0; ud.recstat = 0;

View file

@ -1994,7 +1994,7 @@ void G_BonusScreen(int32_t bonusonly)
videoClearScreen(0); videoClearScreen(0);
G_DisplayMPResultsScreen(); G_DisplayMPResultsScreen();
if (MusicEnabled()) if (MusicEnabled() && mus_enabled)
S_PlaySound(BONUSMUSIC); S_PlaySound(BONUSMUSIC);
videoNextPage(); videoNextPage();
@ -2033,7 +2033,7 @@ void G_BonusScreen(int32_t bonusonly)
gametext_center_shade(192, GStrings("PRESSKEY"), quotepulseshade); gametext_center_shade(192, GStrings("PRESSKEY"), quotepulseshade);
if (MusicEnabled()) if (MusicEnabled() && mus_enabled)
S_PlaySound(BONUSMUSIC); S_PlaySound(BONUSMUSIC);
videoNextPage(); videoNextPage();

View file

@ -98,8 +98,8 @@ void GLInstance::Init(int ydim)
ImGui_ImplOpenGL3_Init(); ImGui_ImplOpenGL3_Init();
if (!ttf.Size()) if (!ttf.Size())
{ {
//ttf = fileSystem.LoadFile("demolition/Capsmall_clean.ttf", 0); //ttf = fileSystem.LoadFile("engine/Capsmall_clean.ttf", 0);
ttf = fileSystem.LoadFile("demolition/Roboto-Regular.ttf", 0); ttf = fileSystem.LoadFile("engine/Roboto-Regular.ttf", 0);
} }
if (ttf.Size()) io.Fonts->AddFontFromMemoryTTF(ttf.Data(), ttf.Size(), std::clamp(ydim / 40, 10, 30)); if (ttf.Size()) io.Fonts->AddFontFromMemoryTTF(ttf.Data(), ttf.Size(), std::clamp(ydim / 40, 10, 30));
#endif #endif
@ -107,9 +107,9 @@ void GLInstance::Init(int ydim)
void GLInstance::LoadPolymostShader() void GLInstance::LoadPolymostShader()
{ {
auto fr1 = GetResource("demolition/shaders/glsl/polymost.vp"); auto fr1 = GetResource("engine/shaders/glsl/polymost.vp");
TArray<uint8_t> Vert = fr1.Read(); TArray<uint8_t> Vert = fr1.Read();
fr1 = GetResource("demolition/shaders/glsl/polymost.fp"); fr1 = GetResource("engine/shaders/glsl/polymost.fp");
TArray<uint8_t> Frag = fr1.Read(); TArray<uint8_t> Frag = fr1.Read();
// Zero-terminate both strings. // Zero-terminate both strings.
Vert.Push(0); Vert.Push(0);
@ -121,9 +121,9 @@ void GLInstance::LoadPolymostShader()
void GLInstance::LoadVPXShader() void GLInstance::LoadVPXShader()
{ {
auto fr1 = GetResource("demolition/shaders/glsl/animvpx.vp"); auto fr1 = GetResource("engine/shaders/glsl/animvpx.vp");
TArray<uint8_t> Vert = fr1.Read(); TArray<uint8_t> Vert = fr1.Read();
fr1 = GetResource("demolition/shaders/glsl/animvpx.fp"); fr1 = GetResource("engine/shaders/glsl/animvpx.fp");
TArray<uint8_t> Frag = fr1.Read(); TArray<uint8_t> Frag = fr1.Read();
// Zero-terminate both strings. // Zero-terminate both strings.
Vert.Push(0); Vert.Push(0);
@ -134,9 +134,9 @@ void GLInstance::LoadVPXShader()
void GLInstance::LoadSurfaceShader() void GLInstance::LoadSurfaceShader()
{ {
auto fr1 = GetResource("demolition/shaders/glsl/glsurface.vp"); auto fr1 = GetResource("engine/shaders/glsl/glsurface.vp");
TArray<uint8_t> Vert = fr1.Read(); TArray<uint8_t> Vert = fr1.Read();
fr1 = GetResource("demolition/shaders/glsl/glsurface.fp"); fr1 = GetResource("engine/shaders/glsl/glsurface.fp");
TArray<uint8_t> Frag = fr1.Read(); TArray<uint8_t> Frag = fr1.Read();
// Zero-terminate both strings. // Zero-terminate both strings.
Vert.Push(0); Vert.Push(0);

View file

@ -22,6 +22,7 @@
#include <stdint.h> #include <stdint.h>
#include "FileStream.h" #include "FileStream.h"
#include "tarray.h"
namespace SmackerCommon { namespace SmackerCommon {
@ -44,7 +45,7 @@ class BitReader
SmackerCommon::FileStream *file; SmackerCommon::FileStream *file;
uint8_t *cache; TArray<uint8_t> Cache;
void FillCache(); void FillCache();
}; };

View file

@ -29,13 +29,12 @@ BitReader::BitReader(SmackerCommon::FileStream &file, uint32_t size)
this->currentOffset = 0; this->currentOffset = 0;
this->bytesRead = 0; this->bytesRead = 0;
this->cache = (uint8_t*)Xmalloc(size); this->Cache.Resize(size);
file.ReadBytes(this->cache, size); file.ReadBytes(this->Cache.Data(), size);
} }
BitReader::~BitReader() BitReader::~BitReader()
{ {
Bfree(this->cache);
} }
void BitReader::FillCache() void BitReader::FillCache()
@ -54,7 +53,7 @@ uint32_t BitReader::GetPosition()
uint32_t BitReader::GetBit() uint32_t BitReader::GetBit()
{ {
uint32_t ret = (cache[currentOffset>>3]>>(currentOffset&7))&1; uint32_t ret = (Cache[currentOffset>>3]>>(currentOffset&7))&1;
currentOffset++; currentOffset++;
return ret; return ret;
} }

View file

@ -44,14 +44,11 @@
#include "i_findfile.h" #include "i_findfile.h"
#include "gamecontrol.h" #include "gamecontrol.h"
#include "m_argv.h" #include "m_argv.h"
//#include "version.h" // for GAMENAME #include "version.h" // for GAMENAME
// Stuff that needs to be set up later. // Stuff that needs to be set up later.
FString progdir; FString progdir;
static bool batchrun; static bool batchrun;
#define GAMENAMELOWERCASE "demolition"
#define GAMENAME "Demolition"
#define GAME_DIR "demolition"
// Vanilla MinGW does not have folder ids // Vanilla MinGW does not have folder ids
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
@ -136,8 +133,6 @@ FString M_GetAppDataPath(bool create)
{ // Failed (e.g. On Win9x): use program directory { // Failed (e.g. On Win9x): use program directory
path = progdir; path = progdir;
} }
// Don't use GAME_DIR and such so that demolition and its child ports can
// share the node cache.
path += "/" GAMENAMELOWERCASE; path += "/" GAMENAMELOWERCASE;
path.Substitute("//", "/"); // needed because progdir ends with a slash. path.Substitute("//", "/"); // needed because progdir ends with a slash.
if (create) if (create)
@ -165,8 +160,8 @@ FString M_GetAutoexecPath()
// M_GetConfigPath Windows // M_GetConfigPath Windows
// //
// Returns the path to the config file. On Windows, this can vary for reading // Returns the path to the config file. On Windows, this can vary for reading
// vs writing. i.e. If $PROGDIR/demolition-<user>.ini does not exist, it will try // vs writing. i.e. If the user specific ini does not exist, it will try
// to read from $PROGDIR/demolition.ini, but it will never write to demolition.ini. // to read from a neutral version, but never write to it.
// //
//=========================================================================== //===========================================================================
@ -190,7 +185,7 @@ FString M_GetConfigPath(bool for_reading)
path += "/" GAMENAMELOWERCASE ".ini"; path += "/" GAMENAMELOWERCASE ".ini";
} }
else else
{ // construct "$PROGDIR/demolition-$USER.ini" { // construct "$PROGDIR/-$USER.ini"
WCHAR uname[UNLEN+1]; WCHAR uname[UNLEN+1];
DWORD unamelen = UNLEN; DWORD unamelen = UNLEN;
@ -210,13 +205,13 @@ FString M_GetConfigPath(bool for_reading)
path << GAMENAMELOWERCASE "-" << FString(uname) << ".ini"; path << GAMENAMELOWERCASE "-" << FString(uname) << ".ini";
} }
else else
{ // Couldn't get user name, so just use demolition.ini { // Couldn't get user name, so just use base version.
path += GAMENAMELOWERCASE ".ini"; path += GAMENAMELOWERCASE ".ini";
} }
} }
// If we are reading the config file, check if it exists. If not, fallback // If we are reading the config file, check if it exists. If not, fallback
// to $PROGDIR/demolition.ini // to base version.
if (for_reading) if (for_reading)
{ {
if (!FileExists(path)) if (!FileExists(path))

View file

@ -38,8 +38,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_RR_NS BEGIN_RR_NS
#define HEAD2 APPNAME
#define VOLUMEALL (g_Shareware == 0) #define VOLUMEALL (g_Shareware == 0)
#define PLUTOPAK (g_scriptVersion >= 14) #define PLUTOPAK (g_scriptVersion >= 14)
#define VOLUMEONE (g_Shareware == 1) #define VOLUMEONE (g_Shareware == 1)

View file

@ -876,7 +876,7 @@ static void G_ReadGLFrame(void)
} }
} }
Bfree(frame); Xfree(frame);
} }
#endif #endif
@ -4678,7 +4678,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura
#endif #endif
for (j=spritesortcnt-1; j>=0; j--) for (j=spritesortcnt-1; j>=0; j--)
{ {
uspritetype *const t = &tsprite[j]; tspritetype *const t = &tsprite[j];
const int32_t i = t->owner; const int32_t i = t->owner;
const spritetype *const s = &sprite[i]; const spritetype *const s = &sprite[i];
@ -4707,7 +4707,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura
for (j=spritesortcnt-1; j>=0; j--) for (j=spritesortcnt-1; j>=0; j--)
{ {
uspritetype *const t = &tsprite[j]; tspritetype *const t = &tsprite[j];
const int32_t i = t->owner; const int32_t i = t->owner;
spritetype *const s = &sprite[i]; spritetype *const s = &sprite[i];
@ -4818,11 +4818,11 @@ default_case1:
int32_t curframe; int32_t curframe;
int32_t scrofs_action; int32_t scrofs_action;
//is the perfect time to animate sprites //is the perfect time to animate sprites
uspritetype *const t = &tsprite[j]; tspritetype *const t = &tsprite[j];
const int32_t i = t->owner; const int32_t i = t->owner;
// XXX: what's up with the (i < 0) check? // XXX: what's up with the (i < 0) check?
// NOTE: not const spritetype because set at SET_SPRITE_NOT_TSPRITE (see below). // NOTE: not const spritetype because set at SET_SPRITE_NOT_TSPRITE (see below).
uspritetype *const pSprite = (i < 0) ? &tsprite[j] : (uspritetype *)&sprite[i]; tspritetype *const pSprite = (i < 0) ? &tsprite[j] : (tspritetype *)&sprite[i];
if (adult_lockout && G_CheckAdultTile(DYNAMICTILEMAP(pSprite->picnum))) if (adult_lockout && G_CheckAdultTile(DYNAMICTILEMAP(pSprite->picnum)))
{ {
@ -6696,7 +6696,7 @@ int loaddefinitions_game(const char *fileName, int32_t firstPass)
static void G_FreeHashAnim(const char * /*string*/, intptr_t key) static void G_FreeHashAnim(const char * /*string*/, intptr_t key)
{ {
Bfree((void *)key); Xfree((void *)key);
} }
static void G_Cleanup(void) static void G_Cleanup(void)
@ -6712,17 +6712,17 @@ static void G_Cleanup(void)
for (i=MAXPLAYERS-1; i>=0; i--) for (i=MAXPLAYERS-1; i>=0; i--)
{ {
Bfree(g_player[i].ps); Xfree(g_player[i].ps);
Bfree(g_player[i].inputBits); Xfree(g_player[i].inputBits);
} }
if (label != (char *)&sprite[0]) Bfree(label); if (label != (char *)&sprite[0]) Xfree(label);
if (labelcode != (int32_t *)&sector[0]) Bfree(labelcode); if (labelcode != (int32_t *)&sector[0]) Xfree(labelcode);
if (labeltype != (int32_t*)&wall[0]) Bfree(labeltype); if (labeltype != (int32_t*)&wall[0]) Xfree(labeltype);
Bfree(apScript); Xfree(apScript);
Bfree(bitptr); Xfree(bitptr);
// Bfree(MusicPtr); // Xfree(MusicPtr);
hash_free(&h_labels); hash_free(&h_labels);
} }

View file

@ -334,7 +334,7 @@ static int32_t C_SetScriptSize(int32_t newsize)
else else
Bmemcpy(newbitptr,bitptr,sizeof(uint8_t) *((newsize+7)>>3)); Bmemcpy(newbitptr,bitptr,sizeof(uint8_t) *((newsize+7)>>3));
Bfree(bitptr); Xfree(bitptr);
bitptr = newbitptr; bitptr = newbitptr;
if (apScript != newscript) if (apScript != newscript)
{ {
@ -358,7 +358,7 @@ static int32_t C_SetScriptSize(int32_t newsize)
G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), apScript, P2I_BACK_NON0); G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), apScript, P2I_BACK_NON0);
G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), apScript, P2I_BACK_NON0); G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), apScript, P2I_BACK_NON0);
Bfree(scriptptrs); Xfree(scriptptrs);
return 0; return 0;
} }
@ -659,7 +659,7 @@ static int32_t C_GetNextValue(int32_t type)
{ {
char *gl = C_GetLabelType(labeltype[i]); char *gl = C_GetLabelType(labeltype[i]);
initprintf("%s:%d: debug: %s label `%s'.\n",g_scriptFileName,g_lineNumber,gl,label+(i<<6)); initprintf("%s:%d: debug: %s label `%s'.\n",g_scriptFileName,g_lineNumber,gl,label+(i<<6));
Bfree(gl); Xfree(gl);
} }
BITPTR_CLEAR(g_scriptPtr-apScript); BITPTR_CLEAR(g_scriptPtr-apScript);
@ -677,8 +677,8 @@ static int32_t C_GetNextValue(int32_t type)
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: warning: expected %s, found %s.\n",g_scriptFileName,g_lineNumber,el,gl); initprintf("%s:%d: warning: expected %s, found %s.\n",g_scriptFileName,g_lineNumber,el,gl);
g_warningCnt++; g_warningCnt++;
Bfree(el); Xfree(el);
Bfree(gl); Xfree(gl);
return -1; // valid label name, but wrong type return -1; // valid label name, but wrong type
} }
@ -829,7 +829,7 @@ static void C_Include(const char *confile)
textptr = origtptr; textptr = origtptr;
Bfree(mptr); Xfree(mptr);
} }
void G_DoGameStartup(const int32_t *params) void G_DoGameStartup(const int32_t *params)
@ -1001,7 +1001,7 @@ static int32_t C_ParseCommand(int32_t loop)
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: warning: expected state, found %s.\n", g_scriptFileName, g_lineNumber, gl); initprintf("%s:%d: warning: expected state, found %s.\n", g_scriptFileName, g_lineNumber, gl);
g_warningCnt++; g_warningCnt++;
Bfree(gl); Xfree(gl);
*(g_scriptPtr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions *(g_scriptPtr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions
BITPTR_CLEAR(g_scriptPtr-apScript-1); BITPTR_CLEAR(g_scriptPtr-apScript-1);
continue; // valid label name, but wrong type continue; // valid label name, but wrong type
@ -2226,7 +2226,7 @@ void C_Compile(const char *fileName)
g_scriptcrc = Bcrc32(NULL, 0, 0L); g_scriptcrc = Bcrc32(NULL, 0, 0L);
g_scriptcrc = Bcrc32(textptr, kFileLen, g_scriptcrc); g_scriptcrc = Bcrc32(textptr, kFileLen, g_scriptcrc);
Bfree(apScript); Xfree(apScript);
apScript = (intptr_t *)Xcalloc(1, g_scriptSize * sizeof(intptr_t)); apScript = (intptr_t *)Xcalloc(1, g_scriptSize * sizeof(intptr_t));
bitptr = (char *)Xcalloc(1, (((g_scriptSize + 7) >> 3) + 1) * sizeof(uint8_t)); bitptr = (char *)Xcalloc(1, (((g_scriptSize + 7) >> 3) + 1) * sizeof(uint8_t));

View file

@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "osdcmds.h" #include "osdcmds.h"
#include "savegame.h" #include "savegame.h"
#include "gamecvars.h" #include "gamecvars.h"
#include "version.h"
#include "debugbreak.h" #include "debugbreak.h"
extern bool rotatesprite_2doverride; extern bool rotatesprite_2doverride;
@ -2528,12 +2529,14 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
} }
debug_break(); debug_break();
VM_ScriptInfo(insptr, 64); VM_ScriptInfo(insptr, 64);
G_GameExit("An error has occurred in the " APPNAME " virtual machine.\n\n" G_GameExit("An error has occurred in the " GAMENAME " virtual machine.\n\n");
"If you are an end user, please e-mail the file " APPBASENAME ".log\n" #if 0
"If you are an end user, please e-mail the file " GAMENAMELOWERCASE ".log\n"
"along with links to any mods you're using to development@voidpoint.com.\n\n" "along with links to any mods you're using to development@voidpoint.com.\n\n"
"If you are a developer, please attach all of your script files\n" "If you are a developer, please attach all of your script files\n"
"along with instructions on how to reproduce this error.\n\n" "along with instructions on how to reproduce this error.\n\n"
"Thank you!"); "Thank you!");
#endif
break; break;
} }
} }

View file

@ -2398,7 +2398,7 @@ void Net_Connect(const char *srvaddr)
event.type == ENET_EVENT_TYPE_CONNECT) event.type == ENET_EVENT_TYPE_CONNECT)
{ {
initprintf("Connection to %s:%d succeeded.\n", oursrvaddr, address.port); initprintf("Connection to %s:%d succeeded.\n", oursrvaddr, address.port);
Bfree(oursrvaddr); Xfree(oursrvaddr);
return; return;
} }
else else
@ -2412,7 +2412,7 @@ void Net_Connect(const char *srvaddr)
initprintf(i ? "Retrying...\n" : "Giving up connection attempt.\n"); initprintf(i ? "Retrying...\n" : "Giving up connection attempt.\n");
} }
Bfree(oursrvaddr); Xfree(oursrvaddr);
Net_Disconnect(); Net_Disconnect();
} }

View file

@ -1669,7 +1669,7 @@ static void prelevel(char g)
actor[j].t_data[0] = 1; actor[j].t_data[0] = 1;
} }
Bfree(tagbitmap); Xfree(tagbitmap);
g_mirrorCount = 0; g_mirrorCount = 0;
@ -2413,6 +2413,10 @@ int G_EnterLevel(int gameMode)
G_CacheMapData(); G_CacheMapData();
// G_FadeLoad(0,0,0, 0,252, 28, 4, -2); // G_FadeLoad(0,0,0, 0,252, 28, 4, -2);
// Try this first so that it can disable the CD player if no tracks are found.
if (RR && !(gameMode & MODE_DEMO))
S_PlayRRMusic();
if (ud.recstat != 2) if (ud.recstat != 2)
{ {
if (Menu_HaveUserMap()) if (Menu_HaveUserMap())
@ -2422,9 +2426,6 @@ int G_EnterLevel(int gameMode)
else S_PlayLevelMusicOrNothing(mii); else S_PlayLevelMusicOrNothing(mii);
} }
if (RR && !(gameMode & MODE_DEMO))
S_PlayRRMusic();
if (gameMode & (MODE_GAME|MODE_EOL)) if (gameMode & (MODE_GAME|MODE_EOL))
{ {
for (TRAVERSE_CONNECT(i)) for (TRAVERSE_CONNECT(i))

View file

@ -1543,7 +1543,7 @@ static void postloadplayer(int32_t savegamep)
Bmemset(gotpic, 0, sizeof(gotpic)); Bmemset(gotpic, 0, sizeof(gotpic));
S_ClearSoundLocks(); S_ClearSoundLocks();
G_CacheMapData(); G_CacheMapData();
MUS_ResumeSaved(); Mus_ResumeSaved();
Mus_SetPaused(false); Mus_SetPaused(false);
g_player[myconnectindex].ps->gm = MODE_GAME; g_player[myconnectindex].ps->gm = MODE_GAME;

View file

@ -2000,7 +2000,7 @@ void G_BonusScreen(int32_t bonusonly)
videoClearScreen(0); videoClearScreen(0);
G_DisplayMPResultsScreen(); G_DisplayMPResultsScreen();
if (MusicEnabled()) if (MusicEnabled() && mus_enabled)
S_PlaySound(BONUSMUSIC); S_PlaySound(BONUSMUSIC);
videoNextPage(); videoNextPage();
@ -2042,7 +2042,7 @@ void G_BonusScreen(int32_t bonusonly)
gametext_center_shade(192, GStrings("PRESSKEY"), quotepulseshade); gametext_center_shade(192, GStrings("PRESSKEY"), quotepulseshade);
if (MusicEnabled()) if (MusicEnabled() && mus_enabled)
S_PlaySound(BONUSMUSIC); S_PlaySound(BONUSMUSIC);
} }
else else
@ -2579,7 +2579,7 @@ void G_BonusScreenRRRA(int32_t bonusonly)
videoClearScreen(0); videoClearScreen(0);
G_DisplayMPResultsScreen(); G_DisplayMPResultsScreen();
if (MusicEnabled()) if (MusicEnabled() && mus_enabled)
S_PlaySound(BONUSMUSIC); S_PlaySound(BONUSMUSIC);
videoNextPage(); videoNextPage();

View file

@ -541,7 +541,7 @@ vec2_t G_ScreenText(const int32_t font,
linewidth = G_ScreenTextSize(font, x, y, z, blockangle, line, o | ROTATESPRITE_FULL16, xspace_orig, yline_orig, (f & TEXT_XJUSTIFY) ? 0 : xbetween_orig, (f & TEXT_YJUSTIFY) ? 0 : ybetween_orig, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY|TEXT_BACKWARDS), x1, y1, x2, y2).x; linewidth = G_ScreenTextSize(font, x, y, z, blockangle, line, o | ROTATESPRITE_FULL16, xspace_orig, yline_orig, (f & TEXT_XJUSTIFY) ? 0 : xbetween_orig, (f & TEXT_YJUSTIFY) ? 0 : ybetween_orig, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY|TEXT_BACKWARDS), x1, y1, x2, y2).x;
Bfree(line); Xfree(line);
} }
if (f & TEXT_XJUSTIFY) if (f & TEXT_XJUSTIFY)
@ -733,7 +733,7 @@ vec2_t G_ScreenText(const int32_t font,
int32_t linewidth = G_ScreenTextSize(font, x, y, z, blockangle, line, o | ROTATESPRITE_FULL16, xspace_orig, yline_orig, (f & TEXT_XJUSTIFY) ? 0 : xbetween_orig, (f & TEXT_YJUSTIFY) ? 0 : ybetween_orig, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY|TEXT_BACKWARDS), x1, y1, x2, y2).x; int32_t linewidth = G_ScreenTextSize(font, x, y, z, blockangle, line, o | ROTATESPRITE_FULL16, xspace_orig, yline_orig, (f & TEXT_XJUSTIFY) ? 0 : xbetween_orig, (f & TEXT_YJUSTIFY) ? 0 : ybetween_orig, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY|TEXT_BACKWARDS), x1, y1, x2, y2).x;
Bfree(line); Xfree(line);
if (f & TEXT_XJUSTIFY) if (f & TEXT_XJUSTIFY)
{ {

View file

@ -314,10 +314,8 @@ void S_Update(void)
vec3_t* c; vec3_t* c;
int32_t ca, cs; int32_t ca, cs;
#if 0 if (RR && Mus_IsPlaying())
if (RR /*&& todo: fix the conditions here */ )
S_PlayRRMusic(); S_PlayRRMusic();
#endif
S_GetCamera(&c, &ca, &cs); S_GetCamera(&c, &ca, &cs);
@ -552,6 +550,8 @@ void S_MenuSound(void)
// //
//========================================================================== //==========================================================================
static bool cd_disabled = false; // This is in case mus_redbook is enabled but no tracks found so that the regular music system can be switched on.
static void S_SetMusicIndex(unsigned int m) static void S_SetMusicIndex(unsigned int m)
{ {
ud.music_episode = m / MAXLEVELS; ud.music_episode = m / MAXLEVELS;
@ -560,6 +560,7 @@ static void S_SetMusicIndex(unsigned int m)
void S_PlayLevelMusicOrNothing(unsigned int m) void S_PlayLevelMusicOrNothing(unsigned int m)
{ {
if (RR && mus_redbook && !cd_disabled) return;
auto& mr = m == USERMAPMUSICFAKESLOT ? userMapRecord : mapList[m]; auto& mr = m == USERMAPMUSICFAKESLOT ? userMapRecord : mapList[m];
Mus_Play(mr.labelName, mr.music, true); Mus_Play(mr.labelName, mr.music, true);
S_SetMusicIndex(m); S_SetMusicIndex(m);
@ -567,6 +568,7 @@ void S_PlayLevelMusicOrNothing(unsigned int m)
int S_TryPlaySpecialMusic(unsigned int m) int S_TryPlaySpecialMusic(unsigned int m)
{ {
if (RR) return 0; // Can only be MUS_LOADING, RR does not use it.
auto& musicfn = mapList[m].music; auto& musicfn = mapList[m].music;
if (musicfn.IsNotEmpty()) if (musicfn.IsNotEmpty())
{ {
@ -590,16 +592,21 @@ void S_PlaySpecialMusicOrNothing(unsigned int m)
void S_PlayRRMusic(int newTrack) void S_PlayRRMusic(int newTrack)
{ {
char fileName[16]; if (!RR || !mus_redbook || cd_disabled)
if (!RR || !mus_redbook)
return; return;
Mus_Stop(); Mus_Stop();
for (int i = 0; i < 10; i++)
{
g_cdTrack = newTrack != -1 ? newTrack : g_cdTrack + 1; g_cdTrack = newTrack != -1 ? newTrack : g_cdTrack + 1;
if (newTrack != 10 && (g_cdTrack > 9 || g_cdTrack < 2)) if (newTrack != 10 && (g_cdTrack > 9 || g_cdTrack < 2))
g_cdTrack = 2; g_cdTrack = 2;
Bsprintf(fileName, "track%.2d.ogg", g_cdTrack); FStringf filename("track%02d.ogg", g_cdTrack);
Mus_Play(fileName, 0, true); if (Mus_Play(nullptr, 0, false)) return;
}
// If none of the tracks managed to start, disable the CD music for this session so that regular music can play if defined.
cd_disabled = true;
} }

View file

@ -81,7 +81,7 @@ void DrawCompass(PLAYERp pp);
#if 1 #if 1
void void
ShadeSprite(uspritetype * tsp) ShadeSprite(tspriteptr_t tsp)
{ {
// set shade of sprite // set shade of sprite
tsp->shade = sector[tsp->sectnum].floorshade - 25; tsp->shade = sector[tsp->sectnum].floorshade - 25;
@ -104,7 +104,7 @@ GetRotation(short tSpriteNum, int viewx, int viewy)
short rotation; short rotation;
extern short screenpeek; extern short screenpeek;
uspritetype * tsp = &tsprite[tSpriteNum]; tspriteptr_t tsp = &tsprite[tSpriteNum];
USERp tu = User[tsp->owner]; USERp tu = User[tsp->owner];
PLAYERp pp = Player + screenpeek; PLAYERp pp = Player + screenpeek;
short angle2; short angle2;
@ -172,7 +172,7 @@ directions was not standardized.
int int
SetActorRotation(short tSpriteNum, int viewx, int viewy) SetActorRotation(short tSpriteNum, int viewx, int viewy)
{ {
uspritetype * tsp = &tsprite[tSpriteNum]; tspriteptr_t tsp = &tsprite[tSpriteNum];
USERp tu = User[tsp->owner]; USERp tu = User[tsp->owner];
short StateOffset, Rotation; short StateOffset, Rotation;
@ -233,7 +233,7 @@ SetActorRotation(short tSpriteNum, int viewx, int viewy)
} }
int int
DoShadowFindGroundPoint(uspritetype * sp) DoShadowFindGroundPoint(tspriteptr_t sp)
{ {
// USES TSPRITE !!!!! // USES TSPRITE !!!!!
USERp u = User[sp->owner]; USERp u = User[sp->owner];
@ -369,9 +369,9 @@ DoVoxelShadow(SPRITEp tspr)
#endif #endif
void void
DoShadows(uspritetype * tsp, int viewz) DoShadows(tspriteptr_t tsp, int viewz)
{ {
uspritetype * New = &tsprite[spritesortcnt]; tspriteptr_t New = &tsprite[spritesortcnt];
USERp tu = User[tsp->owner]; USERp tu = User[tsp->owner];
int ground_dist = 0; int ground_dist = 0;
int view_dist = 0; int view_dist = 0;
@ -396,7 +396,7 @@ DoShadows(uspritetype * tsp, int viewz)
} }
tsp->sectnum = sectnum; tsp->sectnum = sectnum;
memcpy(New, tsp, sizeof(SPRITE)); *New = *tsp;
// shadow is ALWAYS draw last - status is priority // shadow is ALWAYS draw last - status is priority
New->statnum = MAXSTATUS; New->statnum = MAXSTATUS;
New->sectnum = sectnum; New->sectnum = sectnum;
@ -464,9 +464,8 @@ DoShadows(uspritetype * tsp, int viewz)
} }
void void
DoMotionBlur(uspritetype const * tsp) DoMotionBlur(tspritetype const * const tsp)
{ {
uspritetype * New;
USERp tu = User[tsp->owner]; USERp tu = User[tsp->owner];
int nx,ny,nz = 0,dx,dy,dz; int nx,ny,nz = 0,dx,dy,dz;
short i, ang; short i, ang;
@ -537,8 +536,8 @@ DoMotionBlur(uspritetype const * tsp)
for (i = 0; i < tu->motion_blur_num; i++) for (i = 0; i < tu->motion_blur_num; i++)
{ {
New = &tsprite[spritesortcnt]; tspriteptr_t New = &tsprite[spritesortcnt];
memcpy(New, tsp, sizeof(SPRITE)); *New = *tsp;
SET(New->cstat, CSTAT_SPRITE_TRANSLUCENT|CSTAT_SPRITE_TRANSLUCENT_INVERT); SET(New->cstat, CSTAT_SPRITE_TRANSLUCENT|CSTAT_SPRITE_TRANSLUCENT_INVERT);
New->x += dx; New->x += dx;
@ -569,7 +568,6 @@ void SetVoxelSprite(SPRITEp sp, short pic)
void WarpCopySprite(void) void WarpCopySprite(void)
{ {
SPRITEp sp1, sp2, sp; SPRITEp sp1, sp2, sp;
uspritetype * New;
short sn, nsn; short sn, nsn;
short sn2, nsn2; short sn2, nsn2;
short spnum, next_spnum; short spnum, next_spnum;
@ -602,8 +600,8 @@ void WarpCopySprite(void)
if (sprite[spnum].picnum == ST1) if (sprite[spnum].picnum == ST1)
continue; continue;
New = &tsprite[spritesortcnt]; tspriteptr_t New = &tsprite[spritesortcnt];
memcpy(New, &sprite[spnum], sizeof(SPRITE)); memcpy(New, &sprite[spnum], sizeof(tspritetype));
spritesortcnt++; spritesortcnt++;
New->owner = spnum; New->owner = spnum;
New->statnum = 0; New->statnum = 0;
@ -626,8 +624,8 @@ void WarpCopySprite(void)
if (sprite[spnum].picnum == ST1) if (sprite[spnum].picnum == ST1)
continue; continue;
New = &tsprite[spritesortcnt]; tspriteptr_t New = &tsprite[spritesortcnt];
memcpy(New, &sprite[spnum], sizeof(SPRITE)); memcpy(New, &sprite[spnum], sizeof(tspritetype));
spritesortcnt++; spritesortcnt++;
New->owner = spnum; New->owner = spnum;
New->statnum = 0; New->statnum = 0;
@ -646,7 +644,7 @@ void WarpCopySprite(void)
} }
} }
void DoStarView(uspritetype * tsp, USERp tu, int viewz) void DoStarView(tspriteptr_t tsp, USERp tu, int viewz)
{ {
extern STATE s_Star[], s_StarDown[]; extern STATE s_Star[], s_StarDown[];
extern STATE s_StarStuck[], s_StarDownStuck[]; extern STATE s_StarStuck[], s_StarDownStuck[];
@ -675,7 +673,6 @@ analyzesprites(int viewx, int viewy, int viewz, SWBOOL mirror)
int tSpriteNum, j, k; int tSpriteNum, j, k;
short SpriteNum, pnum; short SpriteNum, pnum;
int smr4, smr2; int smr4, smr2;
uspritetype * tsp;
USERp tu; USERp tu;
static int ang = 0; static int ang = 0;
PLAYERp pp = Player + screenpeek; PLAYERp pp = Player + screenpeek;
@ -690,7 +687,7 @@ analyzesprites(int viewx, int viewy, int viewz, SWBOOL mirror)
for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--) for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--)
{ {
SpriteNum = tsprite[tSpriteNum].owner; SpriteNum = tsprite[tSpriteNum].owner;
tsp = &tsprite[tSpriteNum]; tspriteptr_t tsp = &tsprite[tSpriteNum];
tu = User[SpriteNum]; tu = User[SpriteNum];
//if(tsp->statnum == STAT_GENERIC_QUEUE) //if(tsp->statnum == STAT_GENERIC_QUEUE)
@ -901,7 +898,8 @@ analyzesprites(int viewx, int viewy, int viewz, SWBOOL mirror)
if (OverlapDraw && FAF_ConnectArea(tsp->sectnum) && tsp->owner >= 0) if (OverlapDraw && FAF_ConnectArea(tsp->sectnum) && tsp->owner >= 0)
{ {
ConnectCopySprite(tsp); EDUKE32_STATIC_ASSERT(sizeof(uspritetype) == sizeof(tspritetype)); // see TSPRITE_SIZE
ConnectCopySprite((uspriteptr_t)tsp);
} }
// //
@ -977,8 +975,7 @@ analyzesprites(int viewx, int viewy, int viewz, SWBOOL mirror)
} }
#if 1 #if 1
uspritetype * tspriteptr_t get_tsprite(short SpriteNum)
get_tsprite(short SpriteNum)
{ {
int tSpriteNum; int tSpriteNum;
@ -996,14 +993,13 @@ post_analyzesprites(void)
{ {
int tSpriteNum; int tSpriteNum;
short SpriteNum; short SpriteNum;
uspritetype * tsp;
USERp tu; USERp tu;
for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--) for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--)
{ {
SpriteNum = tsprite[tSpriteNum].owner; SpriteNum = tsprite[tSpriteNum].owner;
if (SpriteNum < 0) continue; // JBF: verify this is safe if (SpriteNum < 0) continue; // JBF: verify this is safe
tsp = &tsprite[tSpriteNum]; tspriteptr_t tsp = &tsprite[tSpriteNum];
tu = User[SpriteNum]; tu = User[SpriteNum];
if (tu) if (tu)
@ -1011,7 +1007,7 @@ post_analyzesprites(void)
if (tu->ID == FIREBALL_FLAMES && tu->Attach >= 0) if (tu->ID == FIREBALL_FLAMES && tu->Attach >= 0)
{ {
//uspritetype * const atsp = &sprite[tu->Attach]; //uspritetype * const atsp = &sprite[tu->Attach];
uspritetype * const atsp = get_tsprite(tu->Attach); tspriteptr_t const atsp = get_tsprite(tu->Attach);
if (!atsp) if (!atsp)
{ {
@ -1496,7 +1492,7 @@ void SpriteSortList2D(int tx, int ty)
if (dist < 22000) if (dist < 22000)
{ {
memcpy(&tsprite[spritesortcnt], sp, sizeof(SPRITE)); memcpy(&tsprite[spritesortcnt], sp, sizeof(tspritetype));
tsprite[spritesortcnt++].owner = i; tsprite[spritesortcnt++].owner = i;
} }
} }
@ -1633,10 +1629,9 @@ void DrawCrosshair(PLAYERp pp)
{ {
//NORMALXHAIR: //NORMALXHAIR:
rotatesprite(CrosshairX, CrosshairY, (1 << 16), 0, rotatesprite(160<<16, 100<<16, (1 << 16), 0,
2326, 10, 0, 2326, 10, 0,
//ROTATE_SPRITE_VIEW_CLIP|ROTATE_SPRITE_CORNER, 0, 0, xdim - 1, ydim - 1); ROTATE_SPRITE_VIEW_CLIP, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y);
ROTATE_SPRITE_SCREEN_CLIP|ROTATE_SPRITE_CORNER, 0, 0, xdim - 1, ydim - 1);
} }
//#define TITLE_ROT_FLAGS (ROTATE_SPRITE_CORNER|ROTATE_SPRITE_SCREEN_CLIP|ROTATE_SPRITE_NON_MASK) //#define TITLE_ROT_FLAGS (ROTATE_SPRITE_CORNER|ROTATE_SPRITE_SCREEN_CLIP|ROTATE_SPRITE_NON_MASK)

View file

@ -443,12 +443,19 @@ AllocMem(int size)
void * void *
ReAllocMem(void *ptr, int size) ReAllocMem(void *ptr, int size)
{ {
if (ptr == nullptr)
return AllocMem(size);
if (size == 0)
{
FreeMem(ptr);
return nullptr;
}
uint8_t* bp; uint8_t* bp;
MEM_HDRp mhp; MEM_HDRp mhp;
uint8_t* check; uint8_t* check;
ASSERT(size != 0);
ASSERT(ValidPtr(ptr)); ASSERT(ValidPtr(ptr));
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR)); mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
@ -506,11 +513,12 @@ CallocMem(int size, int num)
void void
FreeMem(void *ptr) FreeMem(void *ptr)
{ {
if (ptr == nullptr)
return;
MEM_HDRp mhp; MEM_HDRp mhp;
uint8_t* check; uint8_t* check;
ASSERT(ptr != NULL);
ASSERT(ValidPtr(ptr)); ASSERT(ValidPtr(ptr));
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR)); mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
@ -521,39 +529,6 @@ FreeMem(void *ptr)
free(mhp); free(mhp);
} }
#else
SWBOOL
ValidPtr(void *ptr)
{
return TRUE;
}
#if 0
void *
AllocMem(int size)
{
return malloc(size);
}
void *
CallocMem(int size, int num)
{
return calloc(size, num);
}
void *
ReAllocMem(void *ptr, int size)
{
return realloc(ptr, size);
}
void
FreeMem(void *ptr)
{
free(ptr);
}
#endif
#endif #endif
int PointOnLine(int x, int y, int x1, int y1, int x2, int y2) int PointOnLine(int x, int y, int x1, int y1, int x2, int y2)
@ -877,7 +852,7 @@ bool InitGame()
LoadKVXFromScript("swvoxfil.txt"); // Load voxels from script file LoadKVXFromScript("swvoxfil.txt"); // Load voxels from script file
LoadPLockFromScript("swplock.txt"); // Get Parental Lock setup info LoadPLockFromScript("swplock.txt"); // Get Parental Lock setup info
LoadCustomInfoFromScript("demolition/swcustom.txt"); // load the internal definitions. These also apply to the shareware version. LoadCustomInfoFromScript("engine/swcustom.txt"); // load the internal definitions. These also apply to the shareware version.
if (!SW_SHAREWARE) if (!SW_SHAREWARE)
{ {
LoadCustomInfoFromScript("swcustom.txt"); // Load user customisation information LoadCustomInfoFromScript("swcustom.txt"); // Load user customisation information

View file

@ -1754,18 +1754,18 @@ typedef struct
unsigned int size, checksum; unsigned int size, checksum;
} MEM_HDR,*MEM_HDRp; } MEM_HDR,*MEM_HDRp;
#if !DEBUG
# define ValidPtr(ptr) ((SWBOOL)(TRUE))
# define AllocMem(size) Xmalloc(size)
# define CallocMem(size, num) Xcalloc(size, num)
# define ReAllocMem(ptr, size) Xrealloc(ptr, size)
# define FreeMem(ptr) Xfree(ptr)
#else
SWBOOL ValidPtr(void *ptr); SWBOOL ValidPtr(void *ptr);
#if 0
void *AllocMem(int size); void *AllocMem(int size);
void *CallocMem(int size, int num); void *CallocMem(int size, int num);
void *ReAllocMem(void *ptr, int size); void *ReAllocMem(void *ptr, int size);
void FreeMem(void *ptr); void FreeMem(void *ptr);
#else
// Make these #defines so that MSVC's allocation tracker gets correct line numbers
#define AllocMem malloc
#define CallocMem calloc
#define ReAllocMem realloc
#define FreeMem free
#endif #endif
typedef struct typedef struct

View file

@ -806,7 +806,7 @@ JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz)
} }
void void
DoAutoSize(uspritetype * tspr) DoAutoSize(tspriteptr_t tspr)
{ {
short i; short i;
@ -957,7 +957,8 @@ DoAutoSize(uspritetype * tspr)
// Rotation angles for sprites // Rotation angles for sprites
short rotang = 0; short rotang = 0;
void JAnalyzeSprites(uspritetype * tspr) void
JAnalyzeSprites(tspriteptr_t tspr)
{ {
int i, currsprite; int i, currsprite;

View file

@ -70,7 +70,7 @@ extern short floormirrorsector[MAXMIRRORS];
extern SWBOOL mirrorinview; extern SWBOOL mirrorinview;
extern short NormalVisibility; extern short NormalVisibility;
void JAnalyzeSprites(uspritetype * tspr); void JAnalyzeSprites(tspriteptr_t tspr);
void JS_DrawMirrors(PLAYERp pp,int tx,int ty,int tz,short tpang,int tphoriz); void JS_DrawMirrors(PLAYERp pp,int tx,int ty,int tz,short tpang,int tphoriz);
void JS_InitMirrors(void); void JS_InitMirrors(void);
void JS_InitLockouts(void); void JS_InitLockouts(void);

View file

@ -2188,7 +2188,7 @@ DoFlagRangeTest(short Weapon, short range)
if (!FAFcansee(sp->x, sp->y, sp->z, sp->sectnum, wp->x, wp->y, wp->z, wp->sectnum)) if (!FAFcansee(sp->x, sp->y, sp->z, sp->sectnum, wp->x, wp->y, wp->z, wp->sectnum))
continue; continue;
dist = FindDistance3D(wp->x - sp->x, wp->y - sp->y, (wp->z - sp->z) >> 4); dist = FindDistance3D(wp->x - sp->x, wp->y - sp->y, wp->z - sp->z);
if (dist > range) if (dist > range)
continue; continue;

View file

@ -1219,7 +1219,7 @@ DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, SWBOOL skip_targets)
// Only look at closest ones // Only look at closest ones
//if ((dist = Distance(sp->x, sp->y, ep->x, ep->y)) > PICK_DIST) //if ((dist = Distance(sp->x, sp->y, ep->x, ep->y)) > PICK_DIST)
if ((dist = FindDistance3D(sp->x - ep->x, sp->y - ep->y, (sp->z - ep->z)>>4)) > PICK_DIST) if ((dist = FindDistance3D(sp->x - ep->x, sp->y - ep->y, sp->z - ep->z)) > PICK_DIST)
continue; continue;
if (skip_targets != 2) // Used for spriteinfo mode if (skip_targets != 2) // Used for spriteinfo mode
@ -8178,7 +8178,7 @@ int SearchSpawnPosition(PLAYERp pp)
if (opp != pp) // don't test for yourself if (opp != pp) // don't test for yourself
{ {
if (FindDistance3D(sp->x - opp->posx, sp->y - opp->posy, (sp->z - opp->posz)>>4) < 1000) if (FindDistance3D(sp->x - opp->posx, sp->y - opp->posy, sp->z - opp->posz) < 1000)
{ {
blocked = TRUE; blocked = TRUE;
break; break;

View file

@ -200,7 +200,7 @@ void QuakeViewChange(PLAYERp pp, int *z_diff, int *x_diff, int *y_diff, short *a
{ {
sp = &sprite[i]; sp = &sprite[i];
dist = FindDistance3D(pp->posx - sp->x, pp->posy - sp->y, (pp->posz - sp->z)>>4); dist = FindDistance3D(pp->posx - sp->x, pp->posy - sp->y, pp->posz - sp->z);
// shake whole level // shake whole level
if (QUAKE_TestDontTaper(sp)) if (QUAKE_TestDontTaper(sp))

View file

@ -1209,7 +1209,7 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
screenpeek = myconnectindex; screenpeek = myconnectindex;
PlayingLevel = Level; PlayingLevel = Level;
MUS_ResumeSaved(); Mus_ResumeSaved();
if (snd_ambience) if (snd_ambience)
StartAmbientSound(); StartAmbientSound();

View file

@ -616,25 +616,24 @@ void LoadCustomInfoFromScript(const char *filename)
case CM_BESTTIME: case CM_BESTTIME:
{ {
int n; int n;
char s[10];
if (scriptfile_getnumber(script, &n)) break; if (scriptfile_getnumber(script, &n)) break;
mapList[curmap].designerTime = (int)strtoll(s, nullptr, 0); mapList[curmap].designerTime = n;
break; break;
} }
case CM_PARTIME: case CM_PARTIME:
{ {
int n; int n;
char s[10];
if (scriptfile_getnumber(script, &n)) break; if (scriptfile_getnumber(script, &n)) break;
mapList[curmap].parTime = (int)strtoll(s, nullptr, 0); mapList[curmap].parTime = n;
break; break;
} }
case CM_CDATRACK: case CM_CDATRACK:
{ {
int n; int n;
if (scriptfile_getnumber(script, &n)) break; if (scriptfile_getnumber(script, &n)) break;
mapList[curmap].cdSongId = n;
break; break;
} }
default: default:

View file

@ -1424,7 +1424,7 @@ WeaponExplodeSectorInRange(short weapon)
sp = &sprite[i]; sp = &sprite[i];
// test to see if explosion is close to crack sprite // test to see if explosion is close to crack sprite
dist = FindDistance3D(wp->x - sp->x, wp->y - sp->y, (wp->z - sp->z)>>4); dist = FindDistance3D(wp->x - sp->x, wp->y - sp->y, wp->z - sp->z);
if (sp->clipdist == 0) if (sp->clipdist == 0)
continue; continue;
@ -2568,7 +2568,7 @@ int DoPlayerGrabStar(PLAYERp pp)
{ {
sp = &sprite[StarQueue[i]]; sp = &sprite[StarQueue[i]];
if (FindDistance3D(sp->x - pp->posx, sp->y - pp->posy, (sp->z - pp->posz + Z(12))>>4) < 500) if (FindDistance3D(sp->x - pp->posx, sp->y - pp->posy, sp->z - pp->posz + Z(12)) < 500)
{ {
break; break;
} }

View file

@ -922,7 +922,6 @@ int PlayerYellVocs[] =
//========================================================================== //==========================================================================
extern short Level; extern short Level;
CVAR(Bool, sw_nothememidi, false, CVAR_ARCHIVE)
SWBOOL PlaySong(const char* mapname, const char* song_file_name, int cdaudio_track, bool isThemeTrack) //(nullptr, nullptr, -1, false) starts the normal level music. SWBOOL PlaySong(const char* mapname, const char* song_file_name, int cdaudio_track, bool isThemeTrack) //(nullptr, nullptr, -1, false) starts the normal level music.
{ {
@ -935,13 +934,18 @@ SWBOOL PlaySong(const char* mapname, const char* song_file_name, int cdaudio_tra
if (cdaudio_track >= 0 && mus_redbook) if (cdaudio_track >= 0 && mus_redbook)
{ {
FStringf trackname("track%02d.ogg", cdaudio_track); FStringf trackname("track%02d.ogg", cdaudio_track);
if (!Mus_Play(nullptr, trackname, true)) if (!Mus_Play(mapname, trackname, true))
{ {
buildprintf("Can't find CD track %i!\n", cdaudio_track); buildprintf("Can't find CD track %i!\n", cdaudio_track);
} }
} }
else if (isThemeTrack && sw_nothememidi) return false; // The original SW source only used CD Audio for theme tracks, so this is optional. if (!Mus_Play(mapname, song_file_name, true))
return Mus_Play(nullptr, song_file_name, true); {
// try the CD track anyway if no MIDI could be found (the original game doesn't have any MIDI, it was CD Audio only, this avoids no music playing id mus_redbook is off.)
FStringf trackname("track%02d.ogg", cdaudio_track);
if (!Mus_Play(nullptr, trackname, true)) return false;
}
return true;
} }
void StopSound(void) void StopSound(void)

View file

@ -7857,7 +7857,7 @@ int DoExpDamageTest(short Weapon)
{ {
int zdist=0; int zdist=0;
if ((unsigned)FindDistance3D(sp->x - wp->x, sp->y - wp->y, (sp->z - wp->z)>>4) > wu->Radius + u->Radius) if ((unsigned)FindDistance3D(sp->x - wp->x, sp->y - wp->y, sp->z - wp->z) > wu->Radius + u->Radius)
continue; continue;
// added hitscan block because mines no long clip against actors/players // added hitscan block because mines no long clip against actors/players
@ -7894,7 +7894,7 @@ int DoExpDamageTest(short Weapon)
if ((unsigned)dist > wu->Radius) if ((unsigned)dist > wu->Radius)
continue; continue;
dist = FindDistance3D(sp->x - wp->x, sp->y - wp->y, (SPRITEp_MID(sp) - wp->z)>>4); dist = FindDistance3D(sp->x - wp->x, sp->y - wp->y, SPRITEp_MID(sp) - wp->z);
if ((unsigned)dist > wu->Radius) if ((unsigned)dist > wu->Radius)
continue; continue;
@ -9020,7 +9020,7 @@ DoGrenade(int16_t Weapon)
if (TEST(u->Flags, SPR_UNDERWATER) && (RANDOM_P2(1024 << 4) >> 4) < 256) if (TEST(u->Flags, SPR_UNDERWATER) && (RANDOM_P2(1024 << 4) >> 4) < 256)
SpawnBubble(Weapon); SpawnBubble(Weapon);
////DSPRINTF(ds, "dist %d, u->ret %d", FindDistance3D(u->xchange, u->ychange, u->zchange>>4), u->ret); ////DSPRINTF(ds, "dist %d, u->ret %d", FindDistance3D(u->xchange, u->ychange, u->zchange), u->ret);
//MONO_PRINT(ds); //MONO_PRINT(ds);
if (u->ret) if (u->ret)
@ -9453,7 +9453,7 @@ DoMineRangeTest(short Weapon, short range)
if (u->ID == GIRLNINJA_RUN_R0 && !ownerisplayer) if (u->ID == GIRLNINJA_RUN_R0 && !ownerisplayer)
continue; continue;
dist = FindDistance3D(wp->x - sp->x, wp->y - sp->y, (wp->z - sp->z)>>4); dist = FindDistance3D(wp->x - sp->x, wp->y - sp->y, wp->z - sp->z);
if (dist > range) if (dist > range)
continue; continue;
@ -11281,7 +11281,7 @@ SpawnNuclearSecondaryExp(int16_t Weapon, short ang)
eu->ret = move_missile(explosion, eu->xchange, eu->ychange, 0, eu->ret = move_missile(explosion, eu->xchange, eu->ychange, 0,
eu->ceiling_dist, eu->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS); eu->ceiling_dist, eu->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS);
if (FindDistance3D(exp->x - sp->x, exp->y - sp->y, (exp->z - sp->z)>>4) < 1024) if (FindDistance3D(exp->x - sp->x, exp->y - sp->y, exp->z - sp->z) < 1024)
{ {
KillSprite(explosion); KillSprite(explosion);
return -1; return -1;
@ -11627,7 +11627,7 @@ SpawnGrenadeSecondaryExp(int16_t Weapon, short ang)
eu->ret = move_missile(explosion, eu->xchange, eu->ychange, 0, eu->ret = move_missile(explosion, eu->xchange, eu->ychange, 0,
eu->ceiling_dist, eu->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS); eu->ceiling_dist, eu->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS);
if (FindDistance3D(exp->x - sp->x, exp->y - sp->y, (exp->z - sp->z)>>4) < 1024) if (FindDistance3D(exp->x - sp->x, exp->y - sp->y, exp->z - sp->z) < 1024)
{ {
KillSprite(explosion); KillSprite(explosion);
return -1; return -1;
@ -13925,7 +13925,7 @@ InitSwordAttack(PLAYERp pp)
if (hitinfo.sect < 0) if (hitinfo.sect < 0)
return 0; return 0;
if (FindDistance3D(pp->posx - hitinfo.pos.x, pp->posy - hitinfo.pos.y, (pp->posz - hitinfo.pos.z)>>4) < 700) if (FindDistance3D(pp->posx - hitinfo.pos.x, pp->posy - hitinfo.pos.y, pp->posz - hitinfo.pos.z) < 700)
{ {
if (hitinfo.sprite >= 0) if (hitinfo.sprite >= 0)
@ -14117,7 +14117,7 @@ InitFistAttack(PLAYERp pp)
if (hitinfo.sect < 0) if (hitinfo.sect < 0)
return 0; return 0;
if (FindDistance3D(pp->posx - hitinfo.pos.x, pp->posy - hitinfo.pos.y, (pp->posz - hitinfo.pos.z)>>4) < 700) if (FindDistance3D(pp->posx - hitinfo.pos.x, pp->posy - hitinfo.pos.y, pp->posz - hitinfo.pos.z) < 700)
{ {
if (hitinfo.sprite >= 0) if (hitinfo.sprite >= 0)
@ -16155,7 +16155,7 @@ InitRipperSlash(short SpriteNum)
if (i == SpriteNum) if (i == SpriteNum)
break; break;
if ((unsigned)FindDistance3D(sp->x - hp->x, sp->y - hp->y, (sp->z - hp->z)>>4) > hu->Radius + u->Radius) if ((unsigned)FindDistance3D(sp->x - hp->x, sp->y - hp->y, sp->z - hp->z) > hu->Radius + u->Radius)
continue; continue;
DISTANCE(hp->x, hp->y, sp->x, sp->y, dist, a, b, c); DISTANCE(hp->x, hp->y, sp->x, sp->y, dist, a, b, c);
@ -16304,7 +16304,7 @@ DoBladeDamage(short SpriteNum)
if (dist > 2000) if (dist > 2000)
continue; continue;
dist = FindDistance3D(sp->x - hp->x, sp->y - hp->y, (sp->z - hp->z)>>4); dist = FindDistance3D(sp->x - hp->x, sp->y - hp->y, sp->z - hp->z);
if (dist > 2000) if (dist > 2000)
continue; continue;
@ -16347,7 +16347,7 @@ DoStaticFlamesDamage(short SpriteNum)
if (dist > 2000) if (dist > 2000)
continue; continue;
dist = FindDistance3D(sp->x - hp->x, sp->y - hp->y, (sp->z - hp->z)>>4); dist = FindDistance3D(sp->x - hp->x, sp->y - hp->y, sp->z - hp->z);
if (dist > 2000) if (dist > 2000)
continue; continue;
@ -17365,7 +17365,7 @@ InitEelFire(short SpriteNum)
if (hp != u->tgt_sp) if (hp != u->tgt_sp)
continue; continue;
if ((unsigned)FindDistance3D(sp->x - hp->x, sp->y - hp->y, (sp->z - hp->z)>>4) > hu->Radius + u->Radius) if ((unsigned)FindDistance3D(sp->x - hp->x, sp->y - hp->y, sp->z - hp->z) > hu->Radius + u->Radius)
continue; continue;
DISTANCE(hp->x, hp->y, sp->x, sp->y, dist, a, b, c); DISTANCE(hp->x, hp->y, sp->x, sp->y, dist, a, b, c);

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -397,6 +397,36 @@ grpinfo
gamefilter "ShadowWarrior.ShadowWarrior" gamefilter "ShadowWarrior.ShadowWarrior"
} }
grpinfo
{
name "Shadow Warrior (Europe)"
flags GAMEFLAG_SW
crc 0xD4A1E153
size 47536148
defname "sw.def"
gamefilter "ShadowWarrior.ShadowWarrior"
}
grpinfo
{
name "Shadow Warrior (UK)"
flags GAMEFLAG_SW
crc 0x3EE68767
size 47536148
defname "sw.def"
gamefilter "ShadowWarrior.ShadowWarrior"
}
grpinfo
{
name "Shadow Warrior (Censored)"
flags GAMEFLAG_SW
crc 0x1A8776D2
size 47537951
defname "sw.def"
gamefilter "ShadowWarrior.ShadowWarrior"
}
grpinfo grpinfo
{ {
name "Shadow Warrior Shareware 1.0" name "Shadow Warrior Shareware 1.0"
@ -457,8 +487,21 @@ grpinfo
defname "twindrag.def" // included in the GRP defname "twindrag.def" // included in the GRP
dependency SWREG12_CRC dependency SWREG12_CRC
gamefilter "ShadowWarrior.TwinDragon" gamefilter "ShadowWarrior.TwinDragon"
deletecontent "swcustom.txt" // not localizable and also not present in the alternative package.
} }
grpinfo
{
name "Shadow Warrior: Twin Dragon"
flags GAMEFLAG_SW|GAMEFLAG_ADDON
crc 0xB5B71277
size 6236287
defname "twindrag.def" // included in the GRP
dependency SWREG12_CRC
gamefilter "ShadowWarrior.TwinDragon"
}
grpinfo grpinfo
{ {

View file

@ -2060,7 +2060,7 @@ Ruins of the Ronin (CTF),TXTS_MAP27,,,,,,,,,,,,,,,,,,,,,,
Killing Fields (CTF),TXTS_MAP28,,,,,,,,,,,,,,,,,,,,,, Killing Fields (CTF),TXTS_MAP28,,,,,,,,,,,,,,,,,,,,,,
Chinatown,TXTS_W_MAP01,,,,,,,,,,,,,,,,,,,,,, Chinatown,TXTS_W_MAP01,,,,,,,,,,,,,,,,,,,,,,
Monastery,TXTS_W_MAP02,,,,,,,,,,,,,,,,,,,,,, Monastery,TXTS_W_MAP02,,,,,,,,,,,,,,,,,,,,,,
Trolly Yard,TXTS_W_MAP03,,,,,,,,,,,,,,,,,,,,,, Trolley Yard,TXTS_W_MAP03,,,,,,,,,,,,,,,,,,,,,,
Restaurant,TXTS_W_MAP04,,,,,,,,,,,,,,,,,,,,,, Restaurant,TXTS_W_MAP04,,,,,,,,,,,,,,,,,,,,,,
Skyscraper,TXTS_W_MAP05,,,,,,,,,,,,,,,,,,,,,, Skyscraper,TXTS_W_MAP05,,,,,,,,,,,,,,,,,,,,,,
Airplane,TXTS_W_MAP06,,,,,,,,,,,,,,,,,,,,,, Airplane,TXTS_W_MAP06,,,,,,,,,,,,,,,,,,,,,,
@ -2075,38 +2075,20 @@ Wanton DM 1 (DM only),TXTS_W_MAP14,,,,,,,,,,,,,,,,,,,,,,
Wanton DM2 (DM only),TXTS_W_MAP15,,,,,,,,,,,,,,,,,,,,,, Wanton DM2 (DM only),TXTS_W_MAP15,,,,,,,,,,,,,,,,,,,,,,
Wanton CTF (CTF),TXTS_W_MAP16,,,,,,,,,,,,,,,,,,,,,, Wanton CTF (CTF),TXTS_W_MAP16,,,,,,,,,,,,,,,,,,,,,,
Wanton Destruction,TXTS_W_EP,,,,,,,,,,,,,,,,,,,,,, Wanton Destruction,TXTS_W_EP,,,,,,,,,,,,,,,,,,,,,,
Home Sweet Home,Home Sweet Home,"Twin Dragon Home Sweet Home,TXTS_T_MAP05,"Twin Dragon",,,,,,,,,,,,,,,,,,,,,
","ShadowWarrior City of Dispair,TXTS_T_MAP06,,,,,,,,,,,,,,,,,,,,,,
",,,,,,,,,,,,,,,,,,,, Emergency Room,TXTS_T_MAP07,,,,,,,,,,,,,,,,,,,,,,
City of Dispair,City of Dispair,already contains,"ShadowWarrior Hide and Seek,TXTS_T_MAP08,,,,,,,,,,,,,,,,,,,,,,
",,,,,,,,,,,,,,,,,,,, Warehouse Madness,TXTS_T_MAP09,,,,,,,,,,,,,,,,,,,,,,
Emergency Room,Emergency Room,SWCUSTOM.TXT,"ShadowWarrior Weapons Research Center,TXTS_T_MAP10,,,,,,,,,,,,,,,,,,,,,,
",,,,,,,,,,,,,,,,,,,, Toxic Waste Facility,TXTS_T_MAP11,,,,,,,,,,,,,,,,,,,,,,
Hide and Seek,Hide and Seek,,"ShadowWarrior Silver Bullet,TXTS_T_MAP12,,,,,,,,,,,,,,,,,,,,,,
",,,,,,,,,,,,,,,,,,,, Fishing Village,TXTS_T_MAP13,,,,,,,,,,,,,,,,,,,,,,
Warehouse Madness,Warehouse Madness,,"ShadowWarrior Secret Garden,TXTS_T_MAP14,,,,,,,,,,,,,,,,,,,,,,
",,,,,,,,,,,,,,,,,,,, Hung Lo's Fortress,TXTS_T_MAP15,,,,,,,,,,,,,,,,,,,,,,
Weapons Research Center,Weapons Research Center,,"ShadowWarrior Hung Lo's Palace,TXTS_T_MAP20,,,,,,,,,,,,,,,,,,,,,,
",,,,,,,,,,,,,,,,,,,, Prison Camp (secret level),TXTS_T_MAP21,,,,,,,,,,,,,,,,,,,,,,
Toxic Waste Facility,Toxic Waste Facility,,"ShadowWarrior Ninja Training Camp (dm),TXTS_T_MAP23,,,,,,,,,,,,,,,,,,,,,,
",,,,,,,,,,,,,,,,,,,, The Morgue/mortuary (dm),TXTS_T_MAP24,,,,,,,,,,,,,,,,,,,,,,
Silver Bullet,Silver Bullet,,"ShadowWarrior Island Caves (dm),TXTS_T_MAP25,,,,,,,,,,,,,,,,,,,,,,
",,,,,,,,,,,,,,,,,,,, Twin Dragon,TXTS_T_TITLE,,,,,,,,,,,,,,,,,,,,,,
Fishing Village,Fishing Village,,"ShadowWarrior
",,,,,,,,,,,,,,,,,,,,
Secret Garden,Secret Garden,,"ShadowWarrior
",,,,,,,,,,,,,,,,,,,,
Hung Lo's Fortress,Hung Lo's Fortress,,"ShadowWarrior
",,,,,,,,,,,,,,,,,,,,
Hung Lo's Palace,Hung Lo's Palace,,"ShadowWarrior
",,,,,,,,,,,,,,,,,,,,
Prison Camp (secret level),Prison Camp (secret level),,"ShadowWarrior
",,,,,,,,,,,,,,,,,,,,
Ninja Training Camp (dm),Ninja Training Camp (dm),,"ShadowWarrior
",,,,,,,,,,,,,,,,,,,,
The Morgue/mortuary (dm),The Morgue/mortuary (dm),,"ShadowWarrior
",,,,,,,,,,,,,,,,,,,,
Island Caves (dm),Island Caves (dm),,"ShadowWarrior
",,,,,,,,,,,,,,,,,,,,
Twin Dragon,Twin Dragon,,"ShadowWarrior
",,,,,,,,,,,,,,,,,,,,
1 default Identifier Remarks Filter eng enc ena enz eni ens enj enb enl ent enw cs de el eo es esm esn esg esc esa esd esv eso esr ess esf esl esy esz esb ese esh esi esu fi fr hu it jp ko nl pl pt ptg ro ru sr
2060
2061
2062
2063
2064
2065
2066
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094

Some files were not shown because too many files have changed in this diff Show more