Merge branch 'develop' into whaven

This commit is contained in:
Christoph Oelckers 2021-11-29 01:14:57 +01:00
commit a01d6c9069
372 changed files with 21512 additions and 24834 deletions

View file

@ -29,7 +29,8 @@ typedef enum EMIDIType_
MIDI_MIDI, MIDI_MIDI,
MIDI_HMI, MIDI_HMI,
MIDI_XMI, MIDI_XMI,
MIDI_MUS MIDI_MUS,
MIDI_MIDS
} EMIDIType; } EMIDIType;
typedef enum EMidiDevice_ typedef enum EMidiDevice_
@ -66,7 +67,8 @@ typedef struct SoundStreamInfo_
typedef enum SampleType_ typedef enum SampleType_
{ {
SampleType_UInt8, SampleType_UInt8,
SampleType_Int16 SampleType_Int16,
SampleType_Float32
} SampleType; } SampleType;
typedef enum ChannelConfig_ typedef enum ChannelConfig_
@ -75,6 +77,15 @@ typedef enum ChannelConfig_
ChannelConfig_Stereo ChannelConfig_Stereo
} ChannelConfig; } ChannelConfig;
typedef struct SoundStreamInfoEx_
{
int mBufferSize; // If mBufferSize is 0, the song doesn't use streaming but plays through a different interface.
int mSampleRate;
SampleType mSampleType;
ChannelConfig mChannelConfig;
} SoundStreamInfoEx;
typedef enum EIntConfigKey_ typedef enum EIntConfigKey_
{ {
zmusic_adl_chips_count, zmusic_adl_chips_count,
@ -263,14 +274,14 @@ typedef struct ZMusicConfigurationSetting_
#ifndef ZMUSIC_INTERNAL #ifndef ZMUSIC_INTERNAL
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(ZMUSIC_STATIC)
#define DLL_IMPORT _declspec(dllimport) #define DLL_IMPORT _declspec(dllimport)
#else // !_MSC_VER #else
#define DLL_IMPORT #define DLL_IMPORT
#endif // _MSC_VER #endif
// Note that the internal 'class' definitions are not C compatible! // Note that the internal 'class' definitions are not C compatible!
typedef struct { int zm1; } *ZMusic_MidiSource; typedef struct _ZMusic_MidiSource_Struct { int zm1; } *ZMusic_MidiSource;
typedef struct { int zm2; } *ZMusic_MusicStream; typedef struct _ZMusic_MusicStream_Struct { int zm2; } *ZMusic_MusicStream;
struct SoundDecoder; struct SoundDecoder;
#endif #endif
@ -313,10 +324,12 @@ extern "C"
DLL_IMPORT void ZMusic_Close(ZMusic_MusicStream song); DLL_IMPORT void ZMusic_Close(ZMusic_MusicStream song);
DLL_IMPORT zmusic_bool ZMusic_SetSubsong(ZMusic_MusicStream song, int subsong); DLL_IMPORT zmusic_bool ZMusic_SetSubsong(ZMusic_MusicStream song, int subsong);
DLL_IMPORT zmusic_bool ZMusic_IsLooping(ZMusic_MusicStream song); DLL_IMPORT zmusic_bool ZMusic_IsLooping(ZMusic_MusicStream song);
DLL_IMPORT int ZMusic_GetDeviceType(ZMusic_MusicStream song);
DLL_IMPORT zmusic_bool ZMusic_IsMIDI(ZMusic_MusicStream song); DLL_IMPORT zmusic_bool ZMusic_IsMIDI(ZMusic_MusicStream song);
DLL_IMPORT void ZMusic_VolumeChanged(ZMusic_MusicStream song); DLL_IMPORT void ZMusic_VolumeChanged(ZMusic_MusicStream song);
DLL_IMPORT zmusic_bool ZMusic_WriteSMF(ZMusic_MidiSource source, const char* fn, int looplimit); DLL_IMPORT zmusic_bool ZMusic_WriteSMF(ZMusic_MidiSource source, const char* fn, int looplimit);
DLL_IMPORT void ZMusic_GetStreamInfo(ZMusic_MusicStream song, SoundStreamInfo *info); DLL_IMPORT void ZMusic_GetStreamInfo(ZMusic_MusicStream song, SoundStreamInfo *info);
DLL_IMPORT void ZMusic_GetStreamInfoEx(ZMusic_MusicStream song, SoundStreamInfoEx *info);
// Configuration interface. The return value specifies if a music restart is needed. // Configuration interface. The return value specifies if a music restart is needed.
// RealValue should be written back to the CVAR or whatever other method the client uses to store configuration state. // RealValue should be written back to the CVAR or whatever other method the client uses to store configuration state.
DLL_IMPORT zmusic_bool ChangeMusicSettingInt(EIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue); DLL_IMPORT zmusic_bool ChangeMusicSettingInt(EIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue);
@ -404,6 +417,7 @@ typedef zmusic_bool (*pfn_ZMusic_IsMIDI)(ZMusic_MusicStream song);
typedef void (*pfn_ZMusic_VolumeChanged)(ZMusic_MusicStream song); typedef void (*pfn_ZMusic_VolumeChanged)(ZMusic_MusicStream song);
typedef zmusic_bool (*pfn_ZMusic_WriteSMF)(ZMusic_MidiSource source, const char* fn, int looplimit); typedef zmusic_bool (*pfn_ZMusic_WriteSMF)(ZMusic_MidiSource source, const char* fn, int looplimit);
typedef void (*pfn_ZMusic_GetStreamInfo)(ZMusic_MusicStream song, SoundStreamInfo *info); typedef void (*pfn_ZMusic_GetStreamInfo)(ZMusic_MusicStream song, SoundStreamInfo *info);
typedef void (*pfn_ZMusic_GetStreamInfoEx)(ZMusic_MusicStream song, SoundStreamInfoEx *info);
typedef zmusic_bool (*pfn_ChangeMusicSettingInt)(EIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue); typedef zmusic_bool (*pfn_ChangeMusicSettingInt)(EIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue);
typedef zmusic_bool (*pfn_ChangeMusicSettingFloat)(EFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue); typedef zmusic_bool (*pfn_ChangeMusicSettingFloat)(EFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue);
typedef zmusic_bool (*pfn_ChangeMusicSettingString)(EStringConfigKey key, ZMusic_MusicStream song, const char* value); typedef zmusic_bool (*pfn_ChangeMusicSettingString)(EStringConfigKey key, ZMusic_MusicStream song, const char* value);
@ -417,4 +431,4 @@ typedef const ZMusicMidiOutDevice *(*pfn_ZMusic_GetMidiDevices)(int *pAmount);
#endif #endif

View file

@ -13,11 +13,11 @@ endif(WIN32)
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
-Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions) -Wno-unused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions)
add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over. add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
-Wunused-parameter -Wunused-value -Wunused-variable) -Wno-unused-parameter -Wunused-value -Wunused-variable)
add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over. add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
endif() endif()

View file

@ -23,9 +23,10 @@ if( DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
endif() endif()
endif() endif()
# Build does not work with signed chars! # Build does not work with signed chars! Also set a stricter warning level, but silence the pointless and annoying parts of level 4 (Intentionally only for C++! The C code we use is too old and would warn too much)
if (MSVC) if (MSVC)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /J" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /J /W4 /wd4100 /wd4127 /wd4131 /wd4201 /wd4210 /wd4244 /wd4245 /wd4324 /wd4389 /wd4505 /wd4706 /wd4456 /wd4457 /wd4458 /wd4459 /wd4703" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4189" ) # "unused initialized local variable" - useful warning that creates too much noise in external or macro based code. Can be enabled for cleanup passes on the code.
else() else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char -Wno-missing-braces -Wno-char-subscripts -Wno-unused-variable" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char -Wno-missing-braces -Wno-char-subscripts -Wno-unused-variable" )
endif() endif()

View file

@ -156,7 +156,11 @@ EXTERN int leveltimer;
inline sectortype* spritetype::sector() const inline sectortype* spritetype::sector() const
{ {
#ifdef _DEBUG
return sectnum < 0? nullptr : &::sector[sectnum];
#else
return &::sector[sectnum]; return &::sector[sectnum];
#endif
} }
inline sectortype* walltype::nextSector() const inline sectortype* walltype::nextSector() const
@ -379,6 +383,7 @@ int32_t engineInit(void);
void engineUnInit(void); void engineUnInit(void);
void initspritelists(void); void initspritelists(void);
void allocateMapArrays(int numsprites);
void ValidateSprite(spritetype& spr); void ValidateSprite(spritetype& spr);
void engineLoadBoard(const char *filename, int flags, vec3_t *dapos, int16_t *daang, int *dacursectnum); void engineLoadBoard(const char *filename, int flags, vec3_t *dapos, int16_t *daang, int *dacursectnum);
void loadMapBackup(const char* filename); void loadMapBackup(const char* filename);
@ -413,9 +418,9 @@ inline int hitscan(int x, int y, int z, int16_t sectnum, int32_t vx, int32_t vy,
vec3_t v{ x,y,z }; vec3_t v{ x,y,z };
hitdata_t hd{}; hitdata_t hd{};
int res = hitscan(&v, sectnum, vx, vy, vz, &hd, cliptype); int res = hitscan(&v, sectnum, vx, vy, vz, &hd, cliptype);
*hitsect = hd.sect; if (hitsect) *hitsect = hd.sect;
*hitwall = hd.wall; if (hitwall) *hitwall = hd.wall;
*hitspr = hd.sprite; if (hitspr) *hitspr = hd.sprite;
*hitx = hd.pos.x; *hitx = hd.pos.x;
*hity = hd.pos.y; *hity = hd.pos.y;
*hitz = hd.pos.z ; *hitz = hd.pos.z ;
@ -429,7 +434,7 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange
int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1,
int32_t x2, int32_t y2, int32_t z2, int16_t sect2); int32_t x2, int32_t y2, int32_t z2, int16_t sect2);
int32_t inside(int32_t x, int32_t y, int sectnum); int32_t inside(int32_t x, int32_t y, int sectnum);
void dragpoint(int pointhighlight, int32_t dax, int32_t day, uint8_t flags = 0); void dragpoint(int pointhighlight, int32_t dax, int32_t day);
int32_t try_facespr_intersect(uspriteptr_t const spr, vec3_t const in, int32_t try_facespr_intersect(uspriteptr_t const spr, vec3_t const in,
int32_t vx, int32_t vy, int32_t vz, int32_t vx, int32_t vy, int32_t vz,
vec3_t * const intp, int32_t strictly_smaller_than_p); vec3_t * const intp, int32_t strictly_smaller_than_p);
@ -437,12 +442,19 @@ int32_t try_facespr_intersect(uspriteptr_t const spr, vec3_t const in,
#define MAXUPDATESECTORDIST 1536 #define MAXUPDATESECTORDIST 1536
#define INITIALUPDATESECTORDIST 256 #define INITIALUPDATESECTORDIST 256
void updatesector(int const x, int const y, int * const sectnum) ATTRIBUTE((nonnull(3))); void updatesector(int const x, int const y, int * const sectnum) ATTRIBUTE((nonnull(3)));
inline void updatesector(int const x, int const y, sectortype** const sectp)
{
int sectno = *sectp? (*sectp) - sector : -1;
updatesector(x, y, &sectno);
*sectp = &sector[sectno];
}
void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int * const sectnum) ATTRIBUTE((nonnull(4))); void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int * const sectnum) ATTRIBUTE((nonnull(4)));
void updatesectorneighbor(int32_t const x, int32_t const y, int * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(3))); void updatesectorneighbor(int32_t const x, int32_t const y, int * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(3)));
void updatesectorneighborz(int32_t const x, int32_t const y, int32_t const z, int * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(4))); void updatesectorneighborz(int32_t const x, int32_t const y, int32_t const z, int * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(4)));
int findwallbetweensectors(int sect1, int sect2); int findwallbetweensectors(int sect1, int sect2);
inline int sectoradjacent(int sect1, int sect2) { return findwallbetweensectors(sect1, sect2) != -1; } inline int sectoradjacent(int sect1, int sect2) { return findwallbetweensectors(sect1, sect2) != -1; }
int32_t getsectordist(vec2_t const in, int const sectnum, vec2_t * const out = nullptr); int32_t getsectordist(vec2_t const in, int const sectnum, vec2_t * const out = nullptr);
extern const int16_t *chsecptr_onextwall; extern const int16_t *chsecptr_onextwall;
@ -685,10 +697,7 @@ extern int32_t rintersect(int32_t x1, int32_t y1, int32_t z1,
extern int32_t(*animateoffs_replace)(int const tilenum, int fakevar); extern int32_t(*animateoffs_replace)(int const tilenum, int fakevar);
extern void(*initspritelists_replace)(void); extern void(*initspritelists_replace)(void);
extern int32_t(*insertsprite_replace)(int16_t sectnum, int16_t statnum);
extern int32_t(*deletesprite_replace)(int16_t spritenum);
extern int32_t(*changespritesect_replace)(int16_t spritenum, int16_t newsectnum); extern int32_t(*changespritesect_replace)(int16_t spritenum, int16_t newsectnum);
extern int32_t(*changespritestat_replace)(int16_t spritenum, int16_t newstatnum);
// Masking these into the object index to keep it in 16 bit was probably the single most dumbest and pointless thing Build ever did. // Masking these into the object index to keep it in 16 bit was probably the single most dumbest and pointless thing Build ever did.
// Gonna be fun to globally replace these to finally lift the limit this imposes on map size. // Gonna be fun to globally replace these to finally lift the limit this imposes on map size.

View file

@ -139,6 +139,10 @@ struct walltype
sectortype* nextSector() const; sectortype* nextSector() const;
walltype* nextWall() const; walltype* nextWall() const;
walltype* point2Wall() const; walltype* point2Wall() const;
vec2_t delta() const { return point2Wall()->pos - pos; }
vec2_t center() const { return(point2Wall()->pos + pos) / 2; }
int deltax() const { return point2Wall()->x - x; }
int deltay() const { return point2Wall()->y - y; }
bool twoSided() const { return nextsector >= 0; } bool twoSided() const { return nextsector >= 0; }
#if 0 #if 0
@ -291,7 +295,9 @@ struct spritetype
#endif #endif
void clear() void clear()
{ {
int save = time; // this may not be cleared ever!!!
memset(this, 0, sizeof(*this)); memset(this, 0, sizeof(*this));
time = save;
} }
void backupx() void backupx()

View file

@ -19,7 +19,7 @@ typedef struct
int32_t x1, y1, x2, y2; int32_t x1, y1, x2, y2;
} linetype; } linetype;
extern int16_t clipsectorlist[MAXCLIPSECTORS]; extern int clipsectorlist[MAXCLIPSECTORS];
int clipinsidebox(vec2_t *vect, int wallnum, int walldist); int clipinsidebox(vec2_t *vect, int wallnum, int walldist);
inline int clipinsidebox(int x, int y, int wall, int dist) inline int clipinsidebox(int x, int y, int wall, int dist)

View file

@ -52,10 +52,6 @@
////////// Platform headers ////////// ////////// Platform headers //////////
#if !defined __APPLE__ && (!defined EDUKE32_BSD || !__STDC__) && !defined __OpenBSD__ && !defined __DragonFly__
# include <malloc.h>
#endif
#include "engineerrors.h" #include "engineerrors.h"
typedef intptr_t bssize_t; typedef intptr_t bssize_t;
@ -83,36 +79,9 @@ typedef struct {
static_assert(sizeof(vec3f_t) == sizeof(float) * 3); static_assert(sizeof(vec3f_t) == sizeof(float) * 3);
////////// Language tricks that depend on size_t //////////
#include "basics.h" #include "basics.h"
////////// Bitfield manipulation ////////// ////////// Bitfield manipulation //////////
inline void bitmap_set(uint8_t *const ptr, int const n) { ptr[n>>3] |= 1 << (n&7); }
inline char bitmap_test(uint8_t const *const ptr, int const n) { return ptr[n>>3] & (1 << (n&7)); }
////////// Utility functions //////////
// breadth-first search helpers
template <typename T>
void bfirst_search_init(T *const list, uint8_t *const bitmap, T *const eltnumptr, int const maxelts, int const firstelt)
{
memset(bitmap, 0, (maxelts+7)>>3);
list[0] = firstelt;
bitmap_set(bitmap, firstelt);
*eltnumptr = 1;
}
template <typename T>
void bfirst_search_try(T *const list, uint8_t *const bitmap, T *const eltnumptr, int const elt)
{
if (!bitmap_test(bitmap, elt))
{
bitmap_set(bitmap, elt);
list[(*eltnumptr)++] = elt;
}
}
#endif // compat_h_ #endif // compat_h_

View file

@ -14,17 +14,19 @@
enum { MAXCLIPDIST = 1024 }; enum { MAXCLIPDIST = 1024 };
static int16_t clipnum; static int clipnum;
static linetype clipit[MAXCLIPNUM]; static linetype clipit[MAXCLIPNUM];
static int32_t clipsectnum, origclipsectnum, clipspritenum; static int32_t clipsectnum, origclipsectnum, clipspritenum;
int16_t clipsectorlist[MAXCLIPSECTORS]; int clipsectorlist[MAXCLIPSECTORS];
static int16_t origclipsectorlist[MAXCLIPSECTORS]; static int origclipsectorlist[MAXCLIPSECTORS];
static uint8_t clipsectormap[(MAXSECTORS+7)>>3]; static uint8_t clipsectormap[(MAXSECTORS+7)>>3];
static uint8_t origclipsectormap[(MAXSECTORS+7)>>3]; static uint8_t origclipsectormap[(MAXSECTORS+7)>>3];
static int16_t clipobjectval[MAXCLIPNUM]; static int16_t clipobjectval[MAXCLIPNUM];
static uint8_t clipignore[(MAXCLIPNUM+7)>>3]; static uint8_t clipignore[(MAXCLIPNUM+7)>>3];
static int32_t rxi[8], ryi[8]; static int32_t rxi[8], ryi[8];
inline void bitmap_set(uint8_t* const ptr, int const n) { ptr[n >> 3] |= 1 << (n & 7); }
inline char bitmap_test(uint8_t const* const ptr, int const n) { return ptr[n >> 3] & (1 << (n & 7)); }
int32_t quickloadboard=0; int32_t quickloadboard=0;
@ -397,52 +399,41 @@ static void clipupdatesector(vec2_t const pos, int * const sectnum, int walldist
walldist = 0x7fff; walldist = 0x7fff;
} }
static int16_t sectlist[MAXSECTORS];
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, *sectnum);
for (int sectcnt = 0; sectcnt < nsecs; sectcnt++)
{ {
int const listsectnum = sectlist[sectcnt]; BFSSearch search(numsectors, *sectnum);
if (inside_p(pos.x, pos.y, listsectnum)) for (unsigned listsectnum; (listsectnum = search.GetNext()) != BFSSearch::EOL;)
SET_AND_RETURN(*sectnum, listsectnum); {
if (inside_p(pos.x, pos.y, listsectnum))
{
*sectnum = listsectnum;
return;
}
auto const sec = &sector[listsectnum]; for (auto& wal : wallsofsector(listsectnum))
int const startwall = sec->wallptr; {
int const endwall = sec->wallptr + sec->wallnum; if (wal.nextsector >= 0 && bitmap_test(clipsectormap, wal.nextsector))
auto uwal = (uwallptr_t)&wall[startwall]; search.Add(wal.nextsector);
}
for (int j = startwall; j < endwall; j++, uwal++) }
if (uwal->nextsector >= 0 && bitmap_test(clipsectormap, uwal->nextsector))
bfirst_search_try(sectlist, sectbitmap, &nsecs, uwal->nextsector);
} }
bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, *sectnum);
for (int sectcnt = 0; sectcnt < nsecs; sectcnt++)
{ {
int const listsectnum = sectlist[sectcnt]; BFSSearch search(numsectors, *sectnum);
if (inside_p(pos.x, pos.y, listsectnum)) for (unsigned listsectnum; (listsectnum = search.GetNext()) != BFSSearch::EOL;)
{ {
// add sector to clipping list so the next call to clipupdatesector() if (inside_p(pos.x, pos.y, listsectnum))
// finishes in the loop above this one {
addclipsect(listsectnum); *sectnum = listsectnum;
SET_AND_RETURN(*sectnum, listsectnum); return;
}
for (auto& wal : wallsofsector(listsectnum))
{
if (wal.nextsector >= 0 && getwalldist(pos, wallnum(&wal)) <= (walldist + 8))
search.Add(wal.nextsector);
}
} }
auto const sec = &sector[listsectnum];
int const startwall = sec->wallptr;
int const endwall = sec->wallptr + sec->wallnum;
auto uwal = (uwallptr_t)&wall[startwall];
// check floor curbs here?
for (int j = startwall; j < endwall; j++, uwal++)
if (uwal->nextsector >= 0 && getwalldist(pos, j) <= (walldist + 8))
bfirst_search_try(sectlist, sectbitmap, &nsecs, uwal->nextsector);
} }
*sectnum = -1; *sectnum = -1;
@ -474,7 +465,6 @@ int32_t clipmove(vec3_t * const pos, int * const sectnum, int32_t xvect, int32_t
vec2_t const clipMin = { cent.x - rad, cent.y - rad }; vec2_t const clipMin = { cent.x - rad, cent.y - rad };
vec2_t const clipMax = { cent.x + rad, cent.y + rad }; vec2_t const clipMax = { cent.x + rad, cent.y + rad };
int clipshapeidx = -1;
int clipsectcnt = 0; int clipsectcnt = 0;
int clipspritecnt = 0; int clipspritecnt = 0;
@ -958,8 +948,7 @@ void getzrange(const vec3_t *pos, int16_t sectnum,
int32_t clipsectcnt = 0; int32_t clipsectcnt = 0;
uspriteptr_t curspr=NULL; // non-NULL when handling sprite with sector-like clipping int32_t clipspritecnt = 0;
int32_t curidx=-1, clipspritecnt = 0;
//Extra walldist for sprites on sector lines //Extra walldist for sprites on sector lines
const int32_t extradist = walldist+MAXCLIPDIST+1; const int32_t extradist = walldist+MAXCLIPDIST+1;
@ -1058,12 +1047,12 @@ void getzrange(const vec3_t *pos, int16_t sectnum,
for (bssize_t i=0; i<clipsectnum; i++) for (bssize_t i=0; i<clipsectnum; i++)
{ {
int j; int j;
if (clipsectorlist[i] == MAXSECTORS) continue; // we got a deleted sprite in here somewhere. Skip this entry. if (!validSectorIndex(clipsectorlist[i])) continue; // we got a deleted sprite in here somewhere. Skip this entry.
SectIterator it(clipsectorlist[i]); SectIterator it(clipsectorlist[i]);
while ((j = it.NextIndex()) >= 0) while ((j = it.NextIndex()) >= 0)
{ {
const int32_t cstat = sprite[j].cstat; const int32_t cstat = sprite[j].cstat;
int32_t daz, daz2; int32_t daz = 0, daz2 = 0;
if (sprite[j].cstat2 & CSTAT2_SPRITE_NOFIND) continue; if (sprite[j].cstat2 & CSTAT2_SPRITE_NOFIND) continue;
if (cstat&dasprclipmask) if (cstat&dasprclipmask)
@ -1203,7 +1192,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *
int32_t vx, int32_t vy, int32_t vz, int32_t vx, int32_t vy, int32_t vz,
uint16_t stat, int16_t heinum, int32_t z, int32_t how, const intptr_t *tmp) uint16_t stat, int16_t heinum, int32_t z, int32_t how, const intptr_t *tmp)
{ {
int32_t x1 = INT32_MAX, y1, z1; int32_t x1 = INT32_MAX, y1 = 0, z1 = 0;
int32_t i; int32_t i;
if (stat&2) if (stat&2)
@ -1244,9 +1233,9 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *
{ {
if (tmp==NULL) if (tmp==NULL)
{ {
if (inside(x1,y1,int(sec-sector)) == 1) if (inside(x1,y1,sectnum(sec)) == 1)
{ {
hit_set(hit, int(sec-sector), -1, -1, x1, y1, z1); hit_set(hit, sectnum(sec), -1, -1, x1, y1, z1);
hitscan_hitsectcf = (how+1)>>1; hitscan_hitsectcf = (how+1)>>1;
} }
} }
@ -1258,7 +1247,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *
if (!thislastsec) if (!thislastsec)
{ {
if (inside(x1,y1,int(sec-sector)) == 1) if (inside(x1,y1,sectnum(sec)) == 1)
hit_set(hit, int(curspr->sectnum), -1, int(curspr-sprite), x1, y1, z1); hit_set(hit, int(curspr->sectnum), -1, int(curspr-sprite), x1, y1, z1);
} }
} }
@ -1278,7 +1267,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32
int16_t tempshortcnt, tempshortnum; int16_t tempshortcnt, tempshortnum;
uspriteptr_t curspr = NULL; uspriteptr_t curspr = NULL;
int32_t clipspritecnt, curidx=-1; int32_t clipspritecnt;
// tmp: { (int32_t)curidx, (spritetype *)curspr, (!=0 if outer sector) } // tmp: { (int32_t)curidx, (spritetype *)curspr, (!=0 if outer sector) }
intptr_t *tmpptr=NULL; intptr_t *tmpptr=NULL;
const int32_t dawalclipmask = (cliptype&65535); const int32_t dawalclipmask = (cliptype&65535);

View file

@ -62,8 +62,6 @@ int16_t pskybits_override = -1;
static int32_t beforedrawrooms = 1; static int32_t beforedrawrooms = 1;
static int8_t tempbuf[MAXWALLS];
static int32_t no_radarang2 = 0; static int32_t no_radarang2 = 0;
static int16_t radarang[1280]; static int16_t radarang[1280];
@ -314,11 +312,8 @@ static void do_deletespritestat(int16_t deleteme)
// //
// insertsprite // insertsprite
// //
int32_t(*insertsprite_replace)(int16_t sectnum, int16_t statnum) = NULL;
int32_t insertsprite(int16_t sectnum, int16_t statnum) int32_t insertsprite(int16_t sectnum, int16_t statnum)
{ {
if (insertsprite_replace)
return insertsprite_replace(sectnum, statnum);
// TODO: guard against bad sectnum? // TODO: guard against bad sectnum?
int32_t const newspritenum = insertspritestat(statnum); int32_t const newspritenum = insertspritestat(statnum);
@ -338,12 +333,9 @@ int32_t insertsprite(int16_t sectnum, int16_t statnum)
// //
// deletesprite // deletesprite
// //
int32_t (*deletesprite_replace)(int16_t spritenum) = NULL;
int32_t deletesprite(int16_t spritenum) int32_t deletesprite(int16_t spritenum)
{ {
Polymost::polymost_deletesprite(spritenum); Polymost::polymost_deletesprite(spritenum);
if (deletesprite_replace)
return deletesprite_replace(spritenum);
assert((sprite[spritenum].statnum == MAXSTATUS) assert((sprite[spritenum].statnum == MAXSTATUS)
== (sprite[spritenum].sectnum == MAXSECTORS)); == (sprite[spritenum].sectnum == MAXSECTORS));
@ -401,11 +393,8 @@ int32_t changespritesect(int16_t spritenum, int16_t newsectnum)
// //
// changespritestat // changespritestat
// //
int32_t (*changespritestat_replace)(int16_t spritenum, int16_t newstatnum) = NULL;
int32_t changespritestat(int16_t spritenum, int16_t newstatnum) int32_t changespritestat(int16_t spritenum, int16_t newstatnum)
{ {
if (changespritestat_replace)
return changespritestat_replace(spritenum, newstatnum);
// XXX: NOTE: MAXSTATUS is allowed // XXX: NOTE: MAXSTATUS is allowed
if ((newstatnum < 0 || newstatnum > MAXSTATUS) || (sprite[spritenum].statnum == MAXSTATUS)) if ((newstatnum < 0 || newstatnum > MAXSTATUS) || (sprite[spritenum].statnum == MAXSTATUS))
return -1; // can't set the statnum of a sprite not in the world return -1; // can't set the statnum of a sprite not in the world
@ -866,62 +855,18 @@ int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, in
// //
// cansee // cansee
// //
int32_t cansee_old(int32_t xs, int32_t ys, int32_t zs, int16_t sectnums, int32_t xe, int32_t ye, int32_t ze, int16_t sectnume)
{
sectortype *sec, *nsec;
walltype *wal, *wal2;
int32_t intx, inty, intz, i, cnt, nextsector, dasectnum, dacnt, danum;
if ((xs == xe) && (ys == ye) && (sectnums == sectnume)) return 1;
clipsectorlist[0] = sectnums; danum = 1;
for(dacnt=0;dacnt<danum;dacnt++)
{
dasectnum = clipsectorlist[dacnt]; sec = &sector[dasectnum];
for(cnt=sec->wallnum,wal=&wall[sec->wallptr];cnt>0;cnt--,wal++)
{
wal2 = &wall[wal->point2];
if (lintersect(xs,ys,zs,xe,ye,ze,wal->x,wal->y,wal2->x,wal2->y,&intx,&inty,&intz) != 0)
{
nextsector = wal->nextsector; if (nextsector < 0) return 0;
if (intz <= sec->ceilingz) return 0;
if (intz >= sec->floorz) return 0;
nsec = &sector[nextsector];
if (intz <= nsec->ceilingz) return 0;
if (intz >= nsec->floorz) return 0;
for(i=danum-1;i>=0;i--)
if (clipsectorlist[i] == nextsector) break;
if (i < 0) clipsectorlist[danum++] = nextsector;
}
}
if (clipsectorlist[dacnt] == sectnume)
return 1;
}
return 0;
}
int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, int32_t y2, int32_t z2, int16_t sect2) int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, int32_t y2, int32_t z2, int16_t sect2)
{ {
if (enginecompatibility_mode == ENGINECOMPATIBILITY_19950829)
return cansee_old(x1, y1, z1, sect1, x2, y2, z2, sect2);
int32_t dacnt, danum;
const int32_t x21 = x2-x1, y21 = y2-y1, z21 = z2-z1; const int32_t x21 = x2-x1, y21 = y2-y1, z21 = z2-z1;
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
memset(sectbitmap, 0, sizeof(sectbitmap));
if (x1 == x2 && y1 == y2) if (x1 == x2 && y1 == y2)
return (sect1 == sect2); return (sect1 == sect2);
sectbitmap[sect1>>3] |= (1 << (sect1&7)); BFSSearch search(numsectors, sect1);
clipsectorlist[0] = sect1; danum = 1;
for (dacnt=0; dacnt<danum; dacnt++) for (int dasectnum; (dasectnum = search.GetNext()) != BFSSearch::EOL;)
{ {
const int32_t dasectnum = clipsectorlist[dacnt];
auto const sec = (usectorptr_t)&sector[dasectnum]; auto const sec = (usectorptr_t)&sector[dasectnum];
uwallptr_t wal; uwallptr_t wal;
bssize_t cnt; bssize_t cnt;
@ -964,19 +909,11 @@ int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, in
if (z <= cfz[0] || z >= cfz[1]) if (z <= cfz[0] || z >= cfz[1])
return 0; return 0;
if (!(sectbitmap[nexts>>3] & (1 << (nexts&7)))) search.Add(nexts);
{
sectbitmap[nexts>>3] |= (1 << (nexts&7));
clipsectorlist[danum++] = nexts;
}
} }
} }
return search.Check(sect2);
if (sectbitmap[sect2>>3] & (1<<(sect2&7)))
return 1;
return 0;
} }
// //
@ -1084,73 +1021,56 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
// //
// dragpoint // dragpoint
// //
// flags: void dragpoint(int w, int32_t dax, int32_t day)
// 1: don't reset walbitmap[] (the bitmap of already dragged vertices)
// 2: In the editor, do wall[].cstat |= (1<<14) also for the lastwall().
void dragpoint(int pointhighlight, int32_t dax, int32_t day, uint8_t flags)
{ {
int32_t i, numyaxwalls=0; BFSSearch walbitmap(numwalls);
static int16_t yaxwalls[MAXWALLS]; int clockwise = 0;
const int tmpstartwall = w;
int cnt = 16384; // limit the number of iterations.
uint8_t *const walbitmap = (uint8_t *)tempbuf; while (1)
if ((flags&1)==0)
memset(walbitmap, 0, (numwalls+7)>>3);
yaxwalls[numyaxwalls++] = pointhighlight;
for (i=0; i<numyaxwalls; i++)
{ {
int32_t clockwise = 0; sector[wall[w].sector].dirty = 255;
int32_t w = yaxwalls[i]; wall[w].x = dax;
const int32_t tmpstartwall = w; wall[w].y = day;
walbitmap.Set(w);
bssize_t cnt = MAXWALLS; if (!clockwise) //search points CCW
while (1)
{ {
sector[wall[w].sector].dirty = 255; if (wall[w].nextwall >= 0)
wall[w].x = dax; w = wall[wall[w].nextwall].point2;
wall[w].y = day; else
walbitmap[w>>3] |= (1<<(w&7));
if (!clockwise) //search points CCW
{ {
if (wall[w].nextwall >= 0)
w = wall[wall[w].nextwall].point2;
else
{
w = tmpstartwall;
clockwise = 1;
}
}
cnt--;
if (cnt==0)
{
Printf("dragpoint %d: infloop!\n", pointhighlight);
i = numyaxwalls;
break;
}
if (clockwise)
{
int32_t thelastwall = lastwall(w);
if (wall[thelastwall].nextwall >= 0)
w = wall[thelastwall].nextwall;
else
break;
}
if ((walbitmap[w>>3] & (1<<(w&7))))
{
if (clockwise)
break;
w = tmpstartwall; w = tmpstartwall;
clockwise = 1; clockwise = 1;
continue;
} }
} }
cnt--;
if (cnt==0)
{
Printf("dragpoint %d: infinite loop!\n", w);
break;
}
if (clockwise)
{
int32_t thelastwall = lastwall(w);
if (wall[thelastwall].nextwall >= 0)
w = wall[thelastwall].nextwall;
else
break;
}
if (walbitmap.Check(w))
{
if (clockwise)
break;
w = tmpstartwall;
clockwise = 1;
continue;
}
} }
} }
@ -1186,11 +1106,6 @@ int32_t lastwall(int16_t point)
* NOTE: The redundant bound checks are expected to be optimized away in the * NOTE: The redundant bound checks are expected to be optimized away in the
* inlined code. */ * inlined code. */
static inline int inside_exclude_p(int32_t const x, int32_t const y, int const sectnum, const uint8_t *excludesectbitmap)
{
return (sectnum>=0 && !bitmap_test(excludesectbitmap, sectnum) && inside_p(x, y, sectnum));
}
/* NOTE: no bound check */ /* NOTE: no bound check */
static inline int inside_z_p(int32_t const x, int32_t const y, int32_t const z, int const sectnum) static inline int inside_z_p(int32_t const x, int32_t const y, int32_t const z, int const sectnum)
{ {
@ -1317,27 +1232,21 @@ void updatesectorneighbor(int32_t const x, int32_t const y, int * const sectnum,
if (inside_p(x, y, initialsectnum)) if (inside_p(x, y, initialsectnum))
return; return;
static int16_t sectlist[MAXSECTORS]; BFSSearch search(numsectors, *sectnum);
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
int16_t nsecs;
bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, initialsectnum); for (unsigned listsectnum; (listsectnum = search.GetNext()) != BFSSearch::EOL;)
for (int sectcnt=0; sectcnt<nsecs; sectcnt++)
{ {
int const listsectnum = sectlist[sectcnt];
if (inside_p(x, y, listsectnum)) if (inside_p(x, y, listsectnum))
SET_AND_RETURN(*sectnum, listsectnum); {
*sectnum = listsectnum;
return;
}
auto const sec = &sector[listsectnum]; for (auto& wal : wallsofsector(listsectnum))
int const startwall = sec->wallptr; {
int const endwall = sec->wallptr + sec->wallnum; if (wal.nextsector >= 0 && getsectordist({ x, y }, wal.nextsector) <= maxDistance)
auto uwal = (uwallptr_t)&wall[startwall]; search.Add(wal.nextsector);
}
for (int j=startwall; j<endwall; j++, uwal++)
if (uwal->nextsector >= 0 && getsectordist({x, y}, uwal->nextsector) <= maxDistance)
bfirst_search_try(sectlist, sectbitmap, &nsecs, uwal->nextsector);
} }
} }

View file

@ -359,7 +359,6 @@ FGameTexture *mdloadskin(idmodel_t *m, int32_t number, int32_t pal, int32_t surf
{ {
int32_t i; int32_t i;
mdskinmap_t *sk, *skzero = NULL; mdskinmap_t *sk, *skzero = NULL;
int32_t doalloc = 1;
if (m->mdnum == 2) if (m->mdnum == 2)
surf = 0; surf = 0;
@ -418,7 +417,7 @@ static void updateanimation(md2model_t *m, tspriteptr_t tspr, uint8_t lpal)
int32_t const smoothdurationp = (hw_animsmoothing && (tile2model[tile].smoothduration != 0)); int32_t const smoothdurationp = (hw_animsmoothing && (tile2model[tile].smoothduration != 0));
spritesmooth_t * const smooth = &spritesmooth[((unsigned)tspr->owner < MAXSPRITES+MAXUNIQHUDID) ? tspr->owner : MAXSPRITES+MAXUNIQHUDID-1]; spritesmooth_t * const smooth = &spritesmooth[((unsigned)tspr->owner < MAXSPRITES+MAXUNIQHUDID) ? tspr->owner : MAXSPRITES+MAXUNIQHUDID-1];
spriteext_t * const sprext = &spriteext[((unsigned)tspr->owner < MAXSPRITES+MAXUNIQHUDID) ? tspr->owner : MAXSPRITES+MAXUNIQHUDID-1]; spriteext_t * const sprext = &spriteext[((unsigned)tspr->owner < MAXSPRITES) ? tspr->owner : MAXSPRITES-1];
const mdanim_t *anim; const mdanim_t *anim;
for (anim = m->animations; anim && anim->startframe != m->cframe; anim = anim->next) for (anim = m->animations; anim && anim->startframe != m->cframe; anim = anim->next)
@ -1147,7 +1146,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
// int32_t texunits = GL_TEXTURE0; // int32_t texunits = GL_TEXTURE0;
const int32_t owner = tspr->owner; const int32_t owner = tspr->owner;
const spriteext_t *const sext = &spriteext[((unsigned)owner < MAXSPRITES+MAXUNIQHUDID) ? owner : MAXSPRITES+MAXUNIQHUDID-1]; const spriteext_t *const sext = &spriteext[((unsigned)owner < MAXSPRITES) ? owner : MAXSPRITES-1];
const uint8_t lpal = ((unsigned)owner < MAXSPRITES) ? sprite[tspr->owner].pal : tspr->pal; const uint8_t lpal = ((unsigned)owner < MAXSPRITES) ? sprite[tspr->owner].pal : tspr->pal;
const int32_t sizyrep = tileHeight(tspr->picnum) * tspr->yrepeat; const int32_t sizyrep = tileHeight(tspr->picnum) * tspr->yrepeat;
@ -1361,9 +1360,6 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
if (!tex) if (!tex)
continue; continue;
FGameTexture *det = nullptr, *glow = nullptr;
float detscale = 1.f;
int palid = TRANSLATION(Translation_Remap + curbasepal, globalpal); int palid = TRANSLATION(Translation_Remap + curbasepal, globalpal);
GLInterface.SetFade(sector[tspr->sectnum].floorpal); GLInterface.SetFade(sector[tspr->sectnum].floorpal);
GLInterface.SetTexture(tex, palid, CLAMP_XY); GLInterface.SetTexture(tex, palid, CLAMP_XY);
@ -1558,7 +1554,7 @@ void updateModelInterpolation()
omdtims = mdtims; omdtims = mdtims;
mdtims = I_msTime(); mdtims = I_msTime();
for (native_t i = 0; i < MAXSPRITES + MAXUNIQHUDID; ++i) for (native_t i = 0; i < MAXSPRITES; ++i)
if ((mdpause && spriteext[i].mdanimtims) || (spriteext[i].flags & SPREXT_NOMDANIM)) if ((mdpause && spriteext[i].mdanimtims) || (spriteext[i].flags & SPREXT_NOMDANIM))
spriteext[i].mdanimtims += mdtims - omdtims; spriteext[i].mdanimtims += mdtims - omdtims;
} }

View file

@ -400,7 +400,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
int palid = TRANSLATION(Translation_Remap + curbasepal, globalpal); int palid = TRANSLATION(Translation_Remap + curbasepal, globalpal);
GLInterface.SetFade(globalfloorpal); GLInterface.SetFade(globalfloorpal);
bool success = GLInterface.SetTexture(globalskytex? globalskytex : tileGetTexture(globalpicnum), globalskytex? 0 : palid, sampleroverride); bool success = GLInterface.SetTexture(globalskytex? globalskytex : tileGetTexture(globalpicnum), !hw_int_useindexedcolortextures && globalskytex ? 0 : palid, sampleroverride);
if (!success) if (!success)
{ {
tsiz.x = tsiz.y = 1; tsiz.x = tsiz.y = 1;
@ -3921,13 +3921,35 @@ int32_t polymost_voxdraw(voxmodel_t* m, tspriteptr_t const tspr, bool rotate)
GLInterface.SetMatrix(Matrix_Model, mat); GLInterface.SetMatrix(Matrix_Model, mat);
int palId = TRANSLATION(Translation_Remap + curbasepal, globalpal);
GLInterface.SetPalswap(globalpal); GLInterface.SetPalswap(globalpal);
GLInterface.SetFade(sector[tspr->sectnum].floorpal); GLInterface.SetFade(sector[tspr->sectnum].floorpal);
auto tex = TexMan.GetGameTexture(m->model->GetPaletteTexture()); auto tex = TexMan.GetGameTexture(m->model->GetPaletteTexture());
GLInterface.SetTexture(tex, TRANSLATION(Translation_Remap + curbasepal, globalpal), CLAMP_NOFILTER_XY, true); GLInterface.SetTexture(tex, TRANSLATION(Translation_Remap + curbasepal, globalpal), CLAMP_NOFILTER_XY, true);
GLInterface.SetModel(m->model, 0, 0, 0); GLInterface.SetModel(m->model, 0, 0, 0);
// The shade rgb from the tint is ignored here.
pc[0] = (float)globalr * (1.f / 255.f);
pc[1] = (float)globalg * (1.f / 255.f);
pc[2] = (float)globalb * (1.f / 255.f);
bool trans = (tspr->cstat & CSTAT_SPRITE_TRANSLUCENT);
float alpha;
FRenderStyle RenderStyle;
if (trans)
{
RenderStyle = GetRenderStyle(0, !!(tspr->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT));
alpha = GetAlphaFromBlend((tspr->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT) ? DAMETH_TRANS2 : DAMETH_TRANS1, 0);
}
else
{
RenderStyle = LegacyRenderStyles[STYLE_Translucent];
alpha = 1.f;
}
alpha *= 1.f - spriteext[tspr->owner].alpha;
GLInterface.SetRenderStyle(RenderStyle);
GLInterface.SetColor(pc[0], pc[1], pc[2], alpha);
GLInterface.Draw(DT_Triangles, 0, 0); GLInterface.Draw(DT_Triangles, 0, 0);
GLInterface.SetModel(nullptr, 0, 0, 0); GLInterface.SetModel(nullptr, 0, 0, 0);
GLInterface.SetCull(Cull_None); GLInterface.SetCull(Cull_None);

View file

@ -749,7 +749,6 @@ void F2DDrawer::AddPoly(FGameTexture *texture, FVector2 *points, int npoints,
void F2DDrawer::AddPoly(FGameTexture* img, FVector4* vt, size_t vtcount, const unsigned int* ind, size_t idxcount, int translation, PalEntry color, FRenderStyle style, int clipx1, int clipy1, int clipx2, int clipy2) void F2DDrawer::AddPoly(FGameTexture* img, FVector4* vt, size_t vtcount, const unsigned int* ind, size_t idxcount, int translation, PalEntry color, FRenderStyle style, int clipx1, int clipy1, int clipx2, int clipy2)
{ {
RenderCommand dg; RenderCommand dg;
int method = 0;
if (!img || !img->isValid()) return; if (!img || !img->isValid()) return;
@ -835,13 +834,13 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu
dg.mFlags = DTF_Wrap; dg.mFlags = DTF_Wrap;
float fs = 1.f / float(flatscale); float fs = 1.f / float(flatscale);
bool flipc = false;
float sw = GetClassicFlatScalarWidth(); float sw = GetClassicFlatScalarWidth();
float sh = GetClassicFlatScalarHeight(); float sh = GetClassicFlatScalarHeight();
switch (local_origin) switch (local_origin)
{ {
default:
case 0: case 0:
fU1 = float(left) / (float)src->GetDisplayWidth() * fs; fU1 = float(left) / (float)src->GetDisplayWidth() * fs;
fV1 = float(top) / (float)src->GetDisplayHeight() * fs; fV1 = float(top) / (float)src->GetDisplayHeight() * fs;

View file

@ -144,7 +144,7 @@ int GetUIScale(F2DDrawer *drawer, int altval)
// Default should try to scale to 640x400 // Default should try to scale to 640x400
int vscale = drawer->GetHeight() / 400; int vscale = drawer->GetHeight() / 400;
int hscale = drawer->GetWidth() / 640; int hscale = drawer->GetWidth() / 640;
scaleval = clamp(vscale, 1, hscale); scaleval = max(1, min(vscale, hscale));
} }
else scaleval = uiscale; else scaleval = uiscale;
@ -165,7 +165,7 @@ int GetConScale(F2DDrawer* drawer, int altval)
// Default should try to scale to 640x400 // Default should try to scale to 640x400
int vscale = drawer->GetHeight() / 800; int vscale = drawer->GetHeight() / 800;
int hscale = drawer->GetWidth() / 1280; int hscale = drawer->GetWidth() / 1280;
scaleval = clamp(vscale, 1, hscale); scaleval = max(1, min(vscale, hscale));
} }
else scaleval = (uiscale+1) / 2; else scaleval = (uiscale+1) / 2;
@ -671,7 +671,6 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
{ {
INTBOOL boolval; INTBOOL boolval;
int intval; int intval;
bool translationset = false;
bool fillcolorset = false; bool fillcolorset = false;
if (!fortext) if (!fortext)
@ -1016,10 +1015,16 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
case DTA_CenterOffsetRel: case DTA_CenterOffsetRel:
assert(fortext == false); assert(fortext == false);
if (fortext) return false; if (fortext) return false;
if (ListGetInt(tags)) intval = ListGetInt(tags);
if (intval == 1)
{ {
parms->left = img->GetDisplayLeftOffset() + img->GetDisplayWidth() * 0.5; parms->left = img->GetDisplayLeftOffset() + (img->GetDisplayWidth() * 0.5);
parms->top = img->GetDisplayTopOffset() + img->GetDisplayHeight() * 0.5; parms->top = img->GetDisplayTopOffset() + (img->GetDisplayHeight() * 0.5);
}
else if (intval == 2)
{
parms->left = img->GetDisplayLeftOffset() + floor(img->GetDisplayWidth() * 0.5);
parms->top = img->GetDisplayTopOffset() + floor(img->GetDisplayHeight() * 0.5);
} }
break; break;

View file

@ -684,8 +684,6 @@ bool S_ChangeMusic(const char* musicname, int order, bool looping, bool force)
return true; return true;
} }
int lumpnum = -1;
int length = 0;
ZMusic_MusicStream handle = nullptr; ZMusic_MusicStream handle = nullptr;
MidiDeviceSetting* devp = MidiDevices.CheckKey(musicname); MidiDeviceSetting* devp = MidiDevices.CheckKey(musicname);

View file

@ -329,7 +329,6 @@ public:
virtual FString GetStats() virtual FString GetStats()
{ {
FString stats; FString stats;
size_t pos = 0, len = 0;
ALfloat volume; ALfloat volume;
ALint offset; ALint offset;
ALint processed; ALint processed;

View file

@ -530,7 +530,7 @@ void S_ReadReverbDef (FScanner &sc)
{ {
const ReverbContainer *def; const ReverbContainer *def;
ReverbContainer *newenv; ReverbContainer *newenv;
REVERB_PROPERTIES props; REVERB_PROPERTIES props = {};
char *name; char *name;
int id1, id2, i, j; int id1, id2, i, j;
bool inited[NUM_REVERB_FIELDS]; bool inited[NUM_REVERB_FIELDS];

View file

@ -309,7 +309,6 @@ DEFINE_ACTION_FUNCTION(DReverbEdit, GetValue)
} }
} }
ACTION_RETURN_FLOAT(v); ACTION_RETURN_FLOAT(v);
return 1;
} }
DEFINE_ACTION_FUNCTION(DReverbEdit, SetValue) DEFINE_ACTION_FUNCTION(DReverbEdit, SetValue)
@ -337,14 +336,12 @@ DEFINE_ACTION_FUNCTION(DReverbEdit, SetValue)
} }
ACTION_RETURN_FLOAT(v); ACTION_RETURN_FLOAT(v);
return 1;
} }
DEFINE_ACTION_FUNCTION(DReverbEdit, GrayCheck) DEFINE_ACTION_FUNCTION(DReverbEdit, GrayCheck)
{ {
PARAM_PROLOGUE; PARAM_PROLOGUE;
ACTION_RETURN_BOOL(CurrentEnv->Builtin); ACTION_RETURN_BOOL(CurrentEnv->Builtin);
return 1;
} }
DEFINE_ACTION_FUNCTION(DReverbEdit, GetSelectedEnvironment) DEFINE_ACTION_FUNCTION(DReverbEdit, GetSelectedEnvironment)

View file

@ -164,7 +164,6 @@ void SoundEngine::CacheSound (sfxinfo_t *sfx)
{ {
if (GSnd && !sfx->bTentative) if (GSnd && !sfx->bTentative)
{ {
sfxinfo_t *orig = sfx;
while (!sfx->bRandomHeader && sfx->link != sfxinfo_t::NO_LINK) while (!sfx->bRandomHeader && sfx->link != sfxinfo_t::NO_LINK)
{ {
sfx = &S_sfx[sfx->link]; sfx = &S_sfx[sfx->link];

View file

@ -333,6 +333,7 @@ UCVarValue FBaseCVar::FromBool (bool value, ECVarType type)
break; break;
default: default:
ret.Int = 0;
break; break;
} }
@ -363,6 +364,7 @@ UCVarValue FBaseCVar::FromInt (int value, ECVarType type)
break; break;
default: default:
ret.Int = 0;
break; break;
} }
@ -395,6 +397,7 @@ UCVarValue FBaseCVar::FromFloat (float value, ECVarType type)
break; break;
default: default:
ret.Int = 0;
break; break;
} }
@ -456,6 +459,7 @@ UCVarValue FBaseCVar::FromString (const char *value, ECVarType type)
break; break;
default: default:
ret.Int = 0;
break; break;
} }
@ -1643,7 +1647,6 @@ CCMD (archivecvar)
void C_ListCVarsWithoutDescription() void C_ListCVarsWithoutDescription()
{ {
FBaseCVar* var = CVars; FBaseCVar* var = CVars;
int count = 0;
while (var) while (var)
{ {

View file

@ -1014,7 +1014,6 @@ void FExecList::AddPullins(TArray<FString> &wads, FConfigFile *config) const
FExecList *C_ParseExecFile(const char *file, FExecList *exec) FExecList *C_ParseExecFile(const char *file, FExecList *exec)
{ {
char cmd[4096]; char cmd[4096];
int retval = 0;
FileReader fr; FileReader fr;

View file

@ -805,7 +805,6 @@ DEFINE_ACTION_FUNCTION(_MoviePlayer, Frame)
PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer); PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer);
PARAM_FLOAT(clock); PARAM_FLOAT(clock);
ACTION_RETURN_INT(self->Frame(int64_t(clock))); ACTION_RETURN_INT(self->Frame(int64_t(clock)));
return 0;
} }
DEFINE_ACTION_FUNCTION(_MoviePlayer, Destroy) DEFINE_ACTION_FUNCTION(_MoviePlayer, Destroy)

View file

@ -948,7 +948,7 @@ void InterplayDecoder::DecodeBlock13(int32_t offset)
{ {
// 4-color block encoding: each 4x4 block is a different color // 4-color block encoding: each 4x4 block is a different color
uint8_t* pBuffer = GetCurrentFrame() + (intptr_t)offset; uint8_t* pBuffer = GetCurrentFrame() + (intptr_t)offset;
uint8_t P[2]; uint8_t P[2] = {};
for (int y = 0; y < 8; y++) for (int y = 0; y < 8; y++)
{ {

View file

@ -144,7 +144,6 @@ DObject* CreateRunner(bool clearbefore)
void AddGenericVideo(DObject* runner, const FString& fn, int soundid, int fps) void AddGenericVideo(DObject* runner, const FString& fn, int soundid, int fps)
{ {
auto obj = runnerclass->CreateNew();
auto func = LookupFunction("ScreenJobRunner.AddGenericVideo", false); auto func = LookupFunction("ScreenJobRunner.AddGenericVideo", false);
VMValue val[] = { runner, &fn, soundid, fps }; VMValue val[] = { runner, &fn, soundid, fps };
VMCall(func, val, 4, nullptr, 0); VMCall(func, val, 4, nullptr, 0);

View file

@ -67,11 +67,21 @@ CVAR(Bool, m_filter, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
void D_ProcessEvents (void) void D_ProcessEvents (void)
{ {
event_t *ev; FixedBitArray<NUM_KEYS> keywasdown;
TArray<event_t> delayedevents;
keywasdown.Zero();
while (eventtail != eventhead) while (eventtail != eventhead)
{ {
ev = &events[eventtail]; event_t *ev = &events[eventtail];
eventtail = (eventtail + 1) & (MAXEVENTS - 1); eventtail = (eventtail + 1) & (MAXEVENTS - 1);
if (ev->type == EV_KeyUp && keywasdown[ev->data1])
{
delayedevents.Push(*ev);
continue;
}
if (ev->type == EV_None) if (ev->type == EV_None)
continue; continue;
if (ev->type == EV_DeviceChange) if (ev->type == EV_DeviceChange)
@ -85,7 +95,12 @@ void D_ProcessEvents (void)
continue; // menu ate the event continue; // menu ate the event
} }
G_Responder (ev); if (G_Responder(ev) && ev->type == EV_KeyDown) keywasdown.Set(ev->data1);
}
for (auto& ev: delayedevents)
{
D_PostEvent(&ev);
} }
} }

View file

@ -234,7 +234,7 @@ void PaletteContainer::UpdateTranslation(int trans, FRemapTable* remap)
int PaletteContainer::AddTranslation(int slot, FRemapTable* remap, int count) int PaletteContainer::AddTranslation(int slot, FRemapTable* remap, int count)
{ {
uint32_t id; uint32_t id = 0;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
auto newremap = AddRemap(&remap[i]); auto newremap = AddRemap(&remap[i]);
@ -265,7 +265,7 @@ FRemapTable *PaletteContainer::TranslationToTable(int translation)
unsigned int type = GetTranslationType(translation); unsigned int type = GetTranslationType(translation);
unsigned int index = GetTranslationIndex(translation); unsigned int index = GetTranslationIndex(translation);
if (type < 0 || type >= TranslationTables.Size() || index >= NumTranslations(type)) if (type >= TranslationTables.Size() || index >= NumTranslations(type))
{ {
return uniqueRemaps[0]; // this is the identity table. return uniqueRemaps[0]; // this is the identity table.
} }
@ -649,7 +649,6 @@ bool FRemapTable::AddTint(int start, int end, int r, int g, int b, int amount)
bool FRemapTable::AddToTranslation(const char *range) bool FRemapTable::AddToTranslation(const char *range)
{ {
int start,end; int start,end;
bool desaturated = false;
FScanner sc; FScanner sc;
sc.OpenMem("translation", range, int(strlen(range))); sc.OpenMem("translation", range, int(strlen(range)));

View file

@ -619,7 +619,6 @@ void FSerializer::ReadObjects(bool hubtravel)
if (BeginObject(nullptr)) if (BeginObject(nullptr))
{ {
FString clsname; // do not deserialize the class type directly so that we can print appropriate errors. FString clsname; // do not deserialize the class type directly so that we can print appropriate errors.
int pindex = -1;
Serialize(*this, "classtype", clsname, nullptr); Serialize(*this, "classtype", clsname, nullptr);
PClass *cls = PClass::FindClass(clsname); PClass *cls = PClass::FindClass(clsname);
@ -652,7 +651,6 @@ void FSerializer::ReadObjects(bool hubtravel)
{ {
if (obj != nullptr) if (obj != nullptr)
{ {
int pindex = -1;
try try
{ {
obj->SerializeUserVars(*this); obj->SerializeUserVars(*this);

View file

@ -428,18 +428,19 @@ void FWadFile::SkinHack ()
namespc++; namespc++;
} }
} }
// needless to say, this check is entirely useless these days as map names can be more diverse..
if ((lump->getName()[0] == 'M' && if ((lump->getName()[0] == 'M' &&
lump->getName()[1] == 'A' && lump->getName()[1] == 'A' &&
lump->getName()[2] == 'P' && lump->getName()[2] == 'P' &&
lump->getName()[3] >= '0' && lump->getName()[3] <= '9' && lump->getName()[3] >= '0' && lump->getName()[3] <= '9' &&
lump->getName()[4] >= '0' && lump->getName()[4] <= '9' && lump->getName()[4] >= '0' && lump->getName()[4] <= '9' &&
lump->getName()[5] >= '\0') lump->getName()[5] == '\0')
|| ||
(lump->getName()[0] == 'E' && (lump->getName()[0] == 'E' &&
lump->getName()[1] >= '0' && lump->getName()[1] <= '9' && lump->getName()[1] >= '0' && lump->getName()[1] <= '9' &&
lump->getName()[2] == 'M' && lump->getName()[2] == 'M' &&
lump->getName()[3] >= '0' && lump->getName()[3] <= '9' && lump->getName()[3] >= '0' && lump->getName()[3] <= '9' &&
lump->getName()[4] >= '\0')) lump->getName()[4] == '\0'))
{ {
hasmap = true; hasmap = true;
} }

View file

@ -218,7 +218,6 @@ void FileSystem::InitMultipleFiles (TArray<FString> &filenames, bool quiet, Lump
for(unsigned i=0;i<filenames.Size(); i++) for(unsigned i=0;i<filenames.Size(); i++)
{ {
int baselump = NumEntries;
AddFile (filenames[i], nullptr, quiet, filter); AddFile (filenames[i], nullptr, quiet, filter);
if (i == (unsigned)MaxIwadIndex) MoveLumpsInFolder("after_iwad/"); if (i == (unsigned)MaxIwadIndex) MoveLumpsInFolder("after_iwad/");

View file

@ -491,7 +491,7 @@ bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize
{ {
uint32_t min, max, mid, inside; uint32_t min, max, mid, inside;
FResourceLump *lump; FResourceLump *lump;
int cmp; int cmp = 0;
end = start = 0; end = start = 0;
@ -500,7 +500,7 @@ bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize
lumps = (uint8_t *)lumps - lumpsize; lumps = (uint8_t *)lumps - lumpsize;
// Binary search to find any match at all. // Binary search to find any match at all.
min = 1, max = maxlump; mid = min = 1, max = maxlump;
while (min <= max) while (min <= max)
{ {
mid = min + (max - min) / 2; mid = min + (max - min) / 2;

View file

@ -424,7 +424,6 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
LastChar = maxchar; LastChar = maxchar;
auto count = maxchar - minchar + 1; auto count = maxchar - minchar + 1;
Chars.Resize(count); Chars.Resize(count);
int fontheight = 0;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {

View file

@ -88,7 +88,6 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
{ {
if (*string == '[') if (*string == '[')
{ {
const uint8_t* start = string;
while (*string != ']' && *string != '\0') while (*string != ']' && *string != '\0')
{ {
string++; string++;

View file

@ -205,7 +205,6 @@ void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3
float PivotX = mVoxel->Mips[0].Pivot.X; float PivotX = mVoxel->Mips[0].Pivot.X;
float PivotY = mVoxel->Mips[0].Pivot.Y; float PivotY = mVoxel->Mips[0].Pivot.Y;
float PivotZ = mVoxel->Mips[0].Pivot.Z; float PivotZ = mVoxel->Mips[0].Pivot.Z;
int h = mVoxel->Mips[0].SizeZ;
FModelVertex vert; FModelVertex vert;
unsigned int indx[4]; unsigned int indx[4];

View file

@ -67,6 +67,7 @@ void I_InitGraphics ()
#ifdef __APPLE__ #ifdef __APPLE__
SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, "0"); SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, "0");
#endif // __APPLE__ #endif // __APPLE__
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0) if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0)
{ {

View file

@ -182,7 +182,9 @@ void I_PrintStr(const char *cp)
if (*srcp == 0x1c && con_printansi && terminal) if (*srcp == 0x1c && con_printansi && terminal)
{ {
srcp += 1; srcp += 1;
EColorRange range = V_ParseFontColor((const uint8_t*&)srcp, CR_UNTRANSLATED, CR_YELLOW); const uint8_t* scratch = (const uint8_t*)srcp; // GCC does not like direct casting of the parameter.
EColorRange range = V_ParseFontColor(scratch, CR_UNTRANSLATED, CR_YELLOW);
srcp = (char*)scratch;
if (range != CR_UNDEFINED) if (range != CR_UNDEFINED)
{ {
PalEntry color = V_LogColorFromColorRange(range); PalEntry color = V_LogColorFromColorRange(range);

View file

@ -279,7 +279,7 @@ void SystemBaseFrameBuffer::PositionWindow(bool fullscreen, bool initialcall)
RECT r; RECT r;
LONG style, exStyle; LONG style, exStyle;
RECT monRect; RECT monRect = {};
if (!m_Fullscreen && fullscreen && !initialcall) SaveWindowedPos(); if (!m_Fullscreen && fullscreen && !initialcall) SaveWindowedPos();
if (m_Monitor) if (m_Monitor)

View file

@ -340,7 +340,7 @@ static HANDLE WriteMyMiniDump (void)
MINIDUMP_EXCEPTION_INFORMATION exceptor = { DbgThreadID, &CrashPointers, FALSE }; MINIDUMP_EXCEPTION_INFORMATION exceptor = { DbgThreadID, &CrashPointers, FALSE };
WCHAR dbghelpPath[MAX_PATH+12], *bs; WCHAR dbghelpPath[MAX_PATH+12], *bs;
WRITEDUMP pMiniDumpWriteDump; WRITEDUMP pMiniDumpWriteDump;
HANDLE file; HANDLE file = INVALID_HANDLE_VALUE;
BOOL good = FALSE; BOOL good = FALSE;
HMODULE dbghelp = NULL; HMODULE dbghelp = NULL;

View file

@ -281,14 +281,6 @@ CUSTOM_CVAR(Bool, joy_dinput, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_NOINITCA
static const uint8_t POVButtons[9] = { 0x01, 0x03, 0x02, 0x06, 0x04, 0x0C, 0x08, 0x09, 0x00 }; static const uint8_t POVButtons[9] = { 0x01, 0x03, 0x02, 0x06, 0x04, 0x0C, 0x08, 0x09, 0x00 };
//("dc12a687-737f-11cf-884d-00aa004b2e24")
static const IID IID_IWbemLocator = { 0xdc12a687, 0x737f, 0x11cf,
{ 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24 } };
//("4590f811-1d3a-11d0-891f-00aa004b2e24")
static const CLSID CLSID_WbemLocator = { 0x4590f811, 0x1d3a, 0x11d0,
{ 0x89, 0x1f, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24 } };
// CODE -------------------------------------------------------------------- // CODE --------------------------------------------------------------------
//=========================================================================== //===========================================================================

View file

@ -514,8 +514,6 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_WTSSESSION_CHANGE: case WM_WTSSESSION_CHANGE:
case WM_POWERBROADCAST: case WM_POWERBROADCAST:
{ {
int oldstate = SessionState;
if (message == WM_WTSSESSION_CHANGE && lParam == (LPARAM)SessionID) if (message == WM_WTSSESSION_CHANGE && lParam == (LPARAM)SessionID)
{ {
#ifdef _DEBUG #ifdef _DEBUG

View file

@ -268,7 +268,6 @@ void I_CheckNativeMouse(bool preferNative, bool eventhandlerresult)
} }
else else
{ {
bool pauseState = false;
bool captureModeInGame = sysCallbacks.CaptureModeInGame && sysCallbacks.CaptureModeInGame(); bool captureModeInGame = sysCallbacks.CaptureModeInGame && sysCallbacks.CaptureModeInGame();
want_native = ((!m_use_mouse || menuactive != MENU_WaitKey) && want_native = ((!m_use_mouse || menuactive != MENU_WaitKey) &&
(!captureModeInGame || GUICapture)); (!captureModeInGame || GUICapture));

View file

@ -288,8 +288,8 @@ static void DoPrintStr(const char *cpt, HWND edit, HANDLE StdOut)
wchar_t wbuf[256]; wchar_t wbuf[256];
int bpos = 0; int bpos = 0;
CHARRANGE selection; CHARRANGE selection = {};
CHARRANGE endselection; CHARRANGE endselection = {};
LONG lines_before = 0, lines_after; LONG lines_before = 0, lines_after;
CHARFORMAT format; CHARFORMAT format;

View file

@ -113,7 +113,7 @@ CUSTOM_CVAR(Int, showendoom, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
FStartupScreen *FStartupScreen::CreateInstance(int max_progress) FStartupScreen *FStartupScreen::CreateInstance(int max_progress)
{ {
FStartupScreen *scr = NULL; FStartupScreen *scr = NULL;
HRESULT hr; HRESULT hr = -1;
if (!Args->CheckParm("-nostartup")) if (!Args->CheckParm("-nostartup"))
{ {

View file

@ -751,9 +751,9 @@ FStrifeStartupScreen::FStrifeStartupScreen(int max_progress, long& hr)
if (lumpnum >= 0 && (lumplen = fileSystem.FileLength(lumpnum)) == StrifeStartupPicSizes[i]) if (lumpnum >= 0 && (lumplen = fileSystem.FileLength(lumpnum)) == StrifeStartupPicSizes[i])
{ {
auto lumpr = fileSystem.OpenFileReader(lumpnum); auto lumpr1 = fileSystem.OpenFileReader(lumpnum);
StartupPics[i] = new uint8_t[lumplen]; StartupPics[i] = new uint8_t[lumplen];
lumpr.Read(StartupPics[i], lumplen); lumpr1.Read(StartupPics[i], lumplen);
} }
} }

View file

@ -423,8 +423,6 @@ bool Win32GLVideo::InitHardware(HWND Window, int multisample)
} }
int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
const char *version = Args->CheckValue("-glversion");
for (; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++) for (; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++)
{ {

View file

@ -326,7 +326,6 @@ void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
{ {
if (mat->Source()->GetUseType() == ETextureType::SWCanvas) return; if (mat->Source()->GetUseType() == ETextureType::SWCanvas) return;
int flags = mat->GetScaleFlags();
int numLayers = mat->NumLayers(); int numLayers = mat->NumLayers();
MaterialLayerInfo* layer; MaterialLayerInfo* layer;
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation, &layer)); auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation, &layer));

View file

@ -301,8 +301,6 @@ void FHardwareTexture::BindToFrameBuffer(int width, int height)
bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags) bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags)
{ {
int usebright = false;
bool needmipmap = (clampmode <= CLAMP_XY) && !forcenofilter; bool needmipmap = (clampmode <= CLAMP_XY) && !forcenofilter;
// Bind it to the system. // Bind it to the system.

View file

@ -444,8 +444,6 @@ bool FGLRenderBuffers::CheckFrameBufferCompleteness()
if (result == GL_FRAMEBUFFER_COMPLETE) if (result == GL_FRAMEBUFFER_COMPLETE)
return true; return true;
bool FailedCreate = true;
if (gl_debug_level > 0) if (gl_debug_level > 0)
{ {
FString error = "glCheckFramebufferStatus failed: "; FString error = "glCheckFramebufferStatus failed: ";

View file

@ -318,7 +318,6 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
lastClamp = clampmode; lastClamp = clampmode;
lastTranslation = translation; lastTranslation = translation;
int usebright = false;
int maxbound = 0; int maxbound = 0;
int numLayers = mat->NumLayers(); int numLayers = mat->NumLayers();

View file

@ -286,7 +286,6 @@ void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
{ {
if (mat->Source()->GetUseType() == ETextureType::SWCanvas) return; if (mat->Source()->GetUseType() == ETextureType::SWCanvas) return;
int flags = mat->GetScaleFlags();
int numLayers = mat->NumLayers(); int numLayers = mat->NumLayers();
MaterialLayerInfo* layer; MaterialLayerInfo* layer;
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation, &layer)); auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation, &layer));

View file

@ -166,9 +166,6 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
void FHardwareTexture::AllocateBuffer(int w, int h, int texelsize) void FHardwareTexture::AllocateBuffer(int w, int h, int texelsize)
{ {
int rw = GetTexDimension(w);
int rh = GetTexDimension(h);
if (texelsize < 1 || texelsize > 4) texelsize = 4; if (texelsize < 1 || texelsize > 4) texelsize = 4;
glTextureBytes = texelsize; glTextureBytes = texelsize;
bufferpitch = w; bufferpitch = w;
@ -287,8 +284,6 @@ void FHardwareTexture::BindToFrameBuffer(int width, int height)
bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags) bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags)
{ {
int usebright = false;
bool needmipmap = (clampmode <= CLAMP_XY) && !forcenofilter; bool needmipmap = (clampmode <= CLAMP_XY) && !forcenofilter;
// Bind it to the system. // Bind it to the system.

View file

@ -161,7 +161,6 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma)
for (size_t n = 0; n < mPresentShader->Uniforms.mFields.size(); n++) for (size_t n = 0; n < mPresentShader->Uniforms.mFields.size(); n++)
{ {
int index = -1;
UniformFieldDesc desc = mPresentShader->Uniforms.mFields[n]; UniformFieldDesc desc = mPresentShader->Uniforms.mFields[n];
int loc = mPresentShader->Uniforms.UniformLocation[n]; int loc = mPresentShader->Uniforms.UniformLocation[n];
switch (desc.Type) switch (desc.Type)

View file

@ -302,9 +302,6 @@ namespace OpenGLESRenderer
if (result == GL_FRAMEBUFFER_COMPLETE) if (result == GL_FRAMEBUFFER_COMPLETE)
return true; return true;
bool FailedCreate = true;
FString error = "glCheckFramebufferStatus failed: "; FString error = "glCheckFramebufferStatus failed: ";
switch (result) switch (result)
{ {

View file

@ -110,7 +110,6 @@ FGLRenderer::~FGLRenderer()
bool FGLRenderer::StartOffscreen() bool FGLRenderer::StartOffscreen()
{ {
bool firstBind = (mFBID == 0);
if (mFBID == 0) if (mFBID == 0)
glGenFramebuffers(1, &mFBID); glGenFramebuffers(1, &mFBID);
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mOldFBID); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mOldFBID);

View file

@ -458,7 +458,6 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
lastClamp = clampmode; lastClamp = clampmode;
lastTranslation = translation; lastTranslation = translation;
int usebright = false;
int maxbound = 0; int maxbound = 0;
int numLayers = mat->NumLayers(); int numLayers = mat->NumLayers();

View file

@ -392,7 +392,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
assert(screen->mLights != NULL); assert(screen->mLights != NULL);
bool lightbuffertype = screen->mLights->GetBufferType();
unsigned int lightbuffersize = screen->mLights->GetBlockSize(); unsigned int lightbuffersize = screen->mLights->GetBlockSize();
vp_comb.Format("#version 100\n#define NUM_UBO_LIGHTS %d\n#define NO_CLIPDISTANCE_SUPPORT\n", lightbuffersize); vp_comb.Format("#version 100\n#define NUM_UBO_LIGHTS %d\n#define NO_CLIPDISTANCE_SUPPORT\n", lightbuffersize);
@ -851,7 +850,7 @@ void FShaderCollection::CompileShaders(EPassType passType)
mMaterialShaders.Push(shc); mMaterialShaders.Push(shc);
if (i < SHADER_NoTexture) if (i < SHADER_NoTexture)
{ {
FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, defaultshaders[i].lightfunc, defaultshaders[i].Defines, false, passType); shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, defaultshaders[i].lightfunc, defaultshaders[i].Defines, false, passType);
mMaterialShadersNAT.Push(shc); mMaterialShadersNAT.Push(shc);
} }
} }

View file

@ -149,7 +149,6 @@ std::pair<FFlatVertex *, unsigned int> FFlatVertexBuffer::AllocVertices(unsigned
{ {
FFlatVertex *p = GetBuffer(); FFlatVertex *p = GetBuffer();
auto index = mCurIndex.fetch_add(count); auto index = mCurIndex.fetch_add(count);
auto offset = index;
if (index + count >= BUFFER_SIZE_TO_USE) if (index + count >= BUFFER_SIZE_TO_USE)
{ {
// If a single scene needs 2'000'000 vertices there must be something very wrong. // If a single scene needs 2'000'000 vertices there must be something very wrong.

View file

@ -152,7 +152,7 @@ FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &sam
char *chars = code.LockBuffer(); char *chars = code.LockBuffer();
ptrdiff_t startIndex = 0; ptrdiff_t startIndex = 0;
ptrdiff_t startpos, endpos; ptrdiff_t startpos, endpos = 0;
while (true) while (true)
{ {
ptrdiff_t matchIndex = code.IndexOf("layout(binding", startIndex); ptrdiff_t matchIndex = code.IndexOf("layout(binding", startIndex);
@ -216,7 +216,6 @@ FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &sam
FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword) FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword)
{ {
ptrdiff_t len = code.Len();
char *chars = code.LockBuffer(); char *chars = code.LockBuffer();
ptrdiff_t startIndex = 0; ptrdiff_t startIndex = 0;

View file

@ -89,7 +89,6 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
for(auto &cmd : commands) for(auto &cmd : commands)
{ {
int gltrans = -1;
state.SetRenderStyle(cmd.mRenderStyle); state.SetRenderStyle(cmd.mRenderStyle);
state.EnableBrightmap(!(cmd.mRenderStyle.Flags & STYLEF_ColorIsFixed)); state.EnableBrightmap(!(cmd.mRenderStyle.Flags & STYLEF_ColorIsFixed));
state.EnableFog(2); // Special 2D mode 'fog'. state.EnableFog(2); // Special 2D mode 'fog'.

View file

@ -22,7 +22,7 @@
#include "v_video.h" #include "v_video.h"
#include "m_png.h" #include "m_png.h"
#include "templates.h"
#include "r_videoscale.h" #include "r_videoscale.h"
#include "i_time.h" #include "i_time.h"
#include "v_text.h" #include "v_text.h"

View file

@ -20,7 +20,7 @@
** **
*/ */
#include "templates.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "hw_material.h" #include "hw_material.h"
#include "hw_cvars.h" #include "hw_cvars.h"

View file

@ -23,7 +23,7 @@
#include "polyrenderer/backend/poly_renderstate.h" #include "polyrenderer/backend/poly_renderstate.h"
#include "polyrenderer/backend/poly_framebuffer.h" #include "polyrenderer/backend/poly_framebuffer.h"
#include "polyrenderer/backend/poly_hwtexture.h" #include "polyrenderer/backend/poly_hwtexture.h"
#include "templates.h"
#include "hw_skydome.h" #include "hw_skydome.h"
#include "hw_viewpointuniforms.h" #include "hw_viewpointuniforms.h"
#include "hw_lightbuffer.h" #include "hw_lightbuffer.h"

View file

@ -21,7 +21,7 @@
*/ */
#include <stddef.h> #include <stddef.h>
#include "templates.h"
#include "filesystem.h" #include "filesystem.h"
#include "v_video.h" #include "v_video.h"

View file

@ -21,7 +21,7 @@
*/ */
#include <stddef.h> #include <stddef.h>
#include "templates.h"
#include "filesystem.h" #include "filesystem.h"
#include "v_video.h" #include "v_video.h"

View file

@ -21,7 +21,7 @@
*/ */
#include <stddef.h> #include <stddef.h>
#include "templates.h"
#include "poly_thread.h" #include "poly_thread.h"
#include "screen_scanline_setup.h" #include "screen_scanline_setup.h"
#include <cmath> #include <cmath>

View file

@ -21,7 +21,6 @@
*/ */
#include <stddef.h> #include <stddef.h>
#include "templates.h"
#include "poly_thread.h" #include "poly_thread.h"
#include "screen_scanline_setup.h" #include "screen_scanline_setup.h"
#include <cmath> #include <cmath>

View file

@ -21,7 +21,6 @@
*/ */
#include <stddef.h> #include <stddef.h>
#include "templates.h"
#include "filesystem.h" #include "filesystem.h"
#include "v_video.h" #include "v_video.h"

View file

@ -105,7 +105,6 @@ namespace
// minimum set in GZDoom 4.0.0, but only while those fonts are required. // minimum set in GZDoom 4.0.0, but only while those fonts are required.
static bool lastspecialUI = false; static bool lastspecialUI = false;
bool isInActualMenu = false;
bool specialUI = (!sysCallbacks.IsSpecialUI || sysCallbacks.IsSpecialUI()); bool specialUI = (!sysCallbacks.IsSpecialUI || sysCallbacks.IsSpecialUI());

View file

@ -374,8 +374,6 @@ void V_InitScreen()
void V_Init2() void V_Init2()
{ {
float gamma = static_cast<DDummyFrameBuffer *>(screen)->Gamma;
{ {
DFrameBuffer *s = screen; DFrameBuffer *s = screen;
screen = NULL; screen = NULL;

View file

@ -347,8 +347,6 @@ void VulkanDevice::CreateInstance()
VkBool32 VulkanDevice::DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* callbackData, void* userData) VkBool32 VulkanDevice::DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* callbackData, void* userData)
{ {
VulkanDevice *device = (VulkanDevice*)userData;
static std::mutex mtx; static std::mutex mtx;
static std::set<FString> seenMessages; static std::set<FString> seenMessages;
static int totalMessages; static int totalMessages;

View file

@ -421,7 +421,6 @@ IDataBuffer *VulkanFrameBuffer::CreateDataBuffer(int bindingpoint, bool ssbo, bo
{ {
auto buffer = new VKDataBuffer(bindingpoint, ssbo, needsresize); auto buffer = new VKDataBuffer(bindingpoint, ssbo, needsresize);
auto fb = GetVulkanFrameBuffer();
switch (bindingpoint) switch (bindingpoint)
{ {
case LIGHTBUF_BINDINGPOINT: LightBufferSSO = buffer; break; case LIGHTBUF_BINDINGPOINT: LightBufferSSO = buffer; break;

View file

@ -2436,7 +2436,7 @@ ExpEmit FxAssign::Emit(VMFunctionBuilder *build)
ExpEmit result; ExpEmit result;
bool intconst = false; bool intconst = false;
int intconstval; int intconstval = 0;
if (Right->isConstant() && Right->ValueType->GetRegType() == REGT_INT) if (Right->isConstant() && Right->ValueType->GetRegType() == REGT_INT)
{ {
@ -4396,7 +4396,7 @@ ExpEmit FxBinaryLogical::Emit(VMFunctionBuilder *build)
build->Emit(OP_LI, to.RegNum, (Operator == TK_AndAnd) ? 1 : 0); build->Emit(OP_LI, to.RegNum, (Operator == TK_AndAnd) ? 1 : 0);
build->Emit(OP_JMP, 1); build->Emit(OP_JMP, 1);
build->BackpatchListToHere(no); build->BackpatchListToHere(no);
auto ctarget = build->Emit(OP_LI, to.RegNum, (Operator == TK_AndAnd) ? 0 : 1); build->Emit(OP_LI, to.RegNum, (Operator == TK_AndAnd) ? 0 : 1);
list.DeleteAndClear(); list.DeleteAndClear();
list.ShrinkToFit(); list.ShrinkToFit();
return to; return to;
@ -8036,7 +8036,7 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
} }
// No need to create a dedicated node here, all builtins map directly to trivial operations. // No need to create a dedicated node here, all builtins map directly to trivial operations.
Self->ValueType = TypeSInt32; // all builtins treat the texture index as integer. Self->ValueType = TypeSInt32; // all builtins treat the texture index as integer.
FxExpression *x; FxExpression *x = nullptr;
switch (MethodName.GetIndex()) switch (MethodName.GetIndex())
{ {
case NAME_IsValid: case NAME_IsValid:

View file

@ -114,7 +114,7 @@ template<class T, int fill = 1> void ArrayResize(T *self, int amount)
{ {
// This must ensure that all new entries get cleared. // This must ensure that all new entries get cleared.
const int fillCount = int(self->Size() - oldSize); const int fillCount = int(self->Size() - oldSize);
if (fillCount > 0) memset(&(*self)[oldSize], 0, sizeof(*self)[0] * fillCount); if (fillCount > 0) memset((void*)&(*self)[oldSize], 0, sizeof(*self)[0] * fillCount);
} }
} }

View file

@ -265,7 +265,7 @@ void VMDumpConstants(FILE *out, const VMScriptFunction *func)
void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction *func) void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction *func)
{ {
VMFunction *callfunc; VMFunction *callfunc = nullptr;
const char *name; const char *name;
int col; int col;
int mode; int mode;
@ -526,7 +526,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction
{ {
printf_wrapper(out, ",%d\n", code[++i].i24); printf_wrapper(out, ",%d\n", code[++i].i24);
} }
else if (code[i].op == OP_CALL_K) else if (code[i].op == OP_CALL_K && callfunc)
{ {
printf_wrapper(out, " [%s]\n", callfunc->PrintableName.GetChars()); printf_wrapper(out, " [%s]\n", callfunc->PrintableName.GetChars());
} }
@ -665,7 +665,6 @@ static int print_reg(FILE *out, int col, int arg, int mode, int immshift, const
default: default:
return col+printf_wrapper(out, "$%d", arg); return col+printf_wrapper(out, "$%d", arg);
} }
return col;
} }
//========================================================================== //==========================================================================

View file

@ -475,7 +475,7 @@ ZCCCompiler::ZCCCompiler(ZCC_AST &ast, DObject *_outer, PSymbolTable &_symbols,
if (ast.TopNode != NULL) if (ast.TopNode != NULL)
{ {
ZCC_TreeNode *node = ast.TopNode; ZCC_TreeNode *node = ast.TopNode;
PSymbolTreeNode *tnode; PSymbolTreeNode *tnode = nullptr;
// [pbeta] Anything that must be processed before classes, structs, etc. should go here. // [pbeta] Anything that must be processed before classes, structs, etc. should go here.
do do

View file

@ -1302,12 +1302,10 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
ASSERTF(a); ASSERTF(B); ASSERTKF(C); ASSERTF(a); ASSERTF(B); ASSERTKF(C);
fb = reg.f[B]; fc = konstf[C]; fb = reg.f[B]; fc = konstf[C];
goto Do_MODF; goto Do_MODF;
NEXTOP;
OP(MODF_KR): OP(MODF_KR):
ASSERTF(a); ASSERTKF(B); ASSERTF(C); ASSERTF(a); ASSERTKF(B); ASSERTF(C);
fb = konstf[B]; fc = reg.f[C]; fb = konstf[B]; fc = reg.f[C];
goto Do_MODF; goto Do_MODF;
NEXTOP;
OP(POWF_RR): OP(POWF_RR):
ASSERTF(a); ASSERTF(B); ASSERTF(C); ASSERTF(a); ASSERTF(B); ASSERTF(C);
@ -1712,7 +1710,6 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
// PrintParameters(reg.param + f->NumParam - B, B); // PrintParameters(reg.param + f->NumParam - B, B);
throw; throw;
} }
return 0;
} }
static double DoFLOP(int flop, double v) static double DoFLOP(int flop, double v)

View file

@ -694,7 +694,6 @@ void ThrowAbortException(EVMAbortException reason, const char *moreinfo, ...)
va_list ap; va_list ap;
va_start(ap, moreinfo); va_start(ap, moreinfo);
throw CVMAbortException(reason, moreinfo, ap); throw CVMAbortException(reason, moreinfo, ap);
va_end(ap);
} }
void ThrowAbortException(VMScriptFunction *sfunc, VMOP *line, EVMAbortException reason, const char *moreinfo, ...) void ThrowAbortException(VMScriptFunction *sfunc, VMOP *line, EVMAbortException reason, const char *moreinfo, ...)
@ -706,7 +705,6 @@ void ThrowAbortException(VMScriptFunction *sfunc, VMOP *line, EVMAbortException
err.stacktrace.AppendFormat("Called from %s at %s, line %d\n", sfunc->PrintableName.GetChars(), sfunc->SourceFileName.GetChars(), sfunc->PCToLine(line)); err.stacktrace.AppendFormat("Called from %s at %s, line %d\n", sfunc->PrintableName.GetChars(), sfunc->SourceFileName.GetChars(), sfunc->PCToLine(line));
throw err; throw err;
va_end(ap);
} }
DEFINE_ACTION_FUNCTION(DObject, ThrowAbortException) DEFINE_ACTION_FUNCTION(DObject, ThrowAbortException)

View file

@ -467,7 +467,7 @@ void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flag
double texheight = tex->GetDisplayHeight() * scaleY; double texheight = tex->GetDisplayHeight() * scaleY;
double texleftoffs = tex->GetDisplayLeftOffset() * scaleY; double texleftoffs = tex->GetDisplayLeftOffset() * scaleY;
double textopoffs = tex->GetDisplayTopOffset() * scaleY; double textopoffs = tex->GetDisplayTopOffset() * scaleY;
double boxleftoffs, boxtopoffs; double boxleftoffs = 0, boxtopoffs = 0;
if (boxwidth > 0 || boxheight > 0) if (boxwidth > 0 || boxheight > 0)
{ {
@ -618,8 +618,6 @@ void DStatusBarCore::DrawRotated(FGameTexture* tex, double x, double y, int flag
{ {
double texwidth = tex->GetDisplayWidth() * scaleX; double texwidth = tex->GetDisplayWidth() * scaleX;
double texheight = tex->GetDisplayHeight() * scaleY; double texheight = tex->GetDisplayHeight() * scaleY;
double texleftoffs = tex->GetDisplayLeftOffset() * scaleY;
double textopoffs = tex->GetDisplayTopOffset() * scaleY;
// resolve auto-alignment before making any adjustments to the position values. // resolve auto-alignment before making any adjustments to the position values.
if (!(flags & DI_SCREEN_MANUAL_ALIGN)) if (!(flags & DI_SCREEN_MANUAL_ALIGN))

View file

@ -296,7 +296,7 @@ TArray<uint8_t> FJPEGTexture::CreatePalettedPixels(int conversion)
while (cinfo.output_scanline < cinfo.output_height) while (cinfo.output_scanline < cinfo.output_height)
{ {
int num_scanlines = jpeg_read_scanlines(&cinfo, &buff, 1); jpeg_read_scanlines(&cinfo, &buff, 1);
uint8_t *in = buff; uint8_t *in = buff;
uint8_t *out = Pixels.Data() + y; uint8_t *out = Pixels.Data() + y;
switch (cinfo.out_color_space) switch (cinfo.out_color_space)

View file

@ -383,7 +383,7 @@ TArray<uint8_t> FPCXTexture::CreatePalettedPixels(int conversion)
else if (bitcount == 8) else if (bitcount == 8)
{ {
lump.Seek(-769, FileReader::SeekEnd); lump.Seek(-769, FileReader::SeekEnd);
uint8_t c = lump.ReadUInt8(); lump.ReadUInt8();
//if (c !=0x0c) memcpy(PaletteMap, GrayMap, 256); // Fallback for files without palette //if (c !=0x0c) memcpy(PaletteMap, GrayMap, 256); // Fallback for files without palette
//else //else
for(int i=0;i<256;i++) for(int i=0;i<256;i++)

View file

@ -136,8 +136,12 @@ public:
void SetSpriteRect(); void SetSpriteRect();
ETextureType GetUseType() const { return UseType; } ETextureType GetUseType() const { return UseType; }
void SetUpscaleFlag(int what) { shouldUpscaleFlag = what; } void SetUpscaleFlag(int what, bool manual = false)
int GetUpscaleFlag() { return shouldUpscaleFlag == 1; } {
if ((shouldUpscaleFlag & 2) && !manual) return; // if set manually this may not be reset.
shouldUpscaleFlag = what | (manual? 2 : 0);
}
int GetUpscaleFlag() { return shouldUpscaleFlag & 1; }
FTexture* GetTexture() { return Base.get(); } FTexture* GetTexture() { return Base.get(); }
int GetSourceLump() const { return Base->GetSourceLump(); } int GetSourceLump() const { return Base->GetSourceLump(); }

View file

@ -85,7 +85,6 @@ PalettedPixels FImageSource::GetCachedPalettedPixels(int conversion)
FString name; FString name;
fileSystem.GetFileShortName(name, SourceLump); fileSystem.GetFileShortName(name, SourceLump);
std::pair<int, int> *info = nullptr;
auto imageID = ImageID; auto imageID = ImageID;
// Do we have this image in the cache? // Do we have this image in the cache?
@ -201,7 +200,6 @@ FBitmap FImageSource::GetCachedBitmap(const PalEntry *remap, int conversion, int
int trans = -1; int trans = -1;
fileSystem.GetFileShortName(name, SourceLump); fileSystem.GetFileShortName(name, SourceLump);
std::pair<int, int> *info = nullptr;
auto imageID = ImageID; auto imageID = ImageID;
if (remap != nullptr) if (remap != nullptr)

View file

@ -90,7 +90,7 @@ FBitmap FImageTexture::GetBgraBitmap(const PalEntry *p, int *trans)
TArray<uint8_t> FImageTexture::Get8BitPixels(bool alpha) TArray<uint8_t> FImageTexture::Get8BitPixels(bool alpha)
{ {
return mImage->GetPalettedPixels(alpha? alpha : bNoRemap0 ? FImageSource::noremap0 : FImageSource::normal); return mImage->GetPalettedPixels(alpha? FImageSource::luminance : bNoRemap0 ? FImageSource::noremap0 : FImageSource::normal);
} }
//=========================================================================== //===========================================================================

View file

@ -853,7 +853,6 @@ void FMultipatchTextureBuilder::ResolveAllPatches()
ResolvePatches(bi); ResolvePatches(bi);
} }
// Now try to resolve the images. We only can do this at the end when all multipatch textures are set up. // Now try to resolve the images. We only can do this at the end when all multipatch textures are set up.
int i = 0;
// reverse the list so that the Delete operation in the loop below deletes at the end. // reverse the list so that the Delete operation in the loop below deletes at the end.
// For normal sized lists this is of no real concern, but Total Chaos has over 250000 textures where this becomes a performance issue. // For normal sized lists this is of no real concern, but Total Chaos has over 250000 textures where this becomes a performance issue.

View file

@ -717,7 +717,7 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build
sc.String[8]=0; sc.String[8]=0;
tlist.Clear(); tlist.Clear();
int amount = ListTextures(sc.String, tlist); ListTextures(sc.String, tlist);
FName texname = sc.String; FName texname = sc.String;
sc.MustGetString(); sc.MustGetString();
@ -919,7 +919,6 @@ void FTextureManager::LoadTextureX(int wadnum, FMultipatchTextureBuilder &build)
void FTextureManager::AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &build) void FTextureManager::AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &build)
{ {
int firsttexture = Textures.Size(); int firsttexture = Textures.Size();
int lumpcount = fileSystem.GetNumEntries();
bool iwad = wadnum >= fileSystem.GetIwadNum() && wadnum <= fileSystem.GetMaxIwadNum(); bool iwad = wadnum >= fileSystem.GetIwadNum() && wadnum <= fileSystem.GetMaxIwadNum();
FirstTextureForFile.Push(firsttexture); FirstTextureForFile.Push(firsttexture);
@ -1190,8 +1189,12 @@ void FTextureManager::Init(void (*progressFunc_)(), void (*checkForHacks)(BuildI
AddGameTexture(CreateShaderTexture(true, false)); AddGameTexture(CreateShaderTexture(true, false));
AddGameTexture(CreateShaderTexture(true, true)); AddGameTexture(CreateShaderTexture(true, true));
// Add two animtexture entries so that movie playback can call functions using texture IDs. // Add two animtexture entries so that movie playback can call functions using texture IDs.
AddGameTexture(MakeGameTexture(new AnimTexture(), "AnimTextureFrame1", ETextureType::Override)); auto mt = MakeGameTexture(new AnimTexture(), "AnimTextureFrame1", ETextureType::Override);
AddGameTexture(MakeGameTexture(new AnimTexture(), "AnimTextureFrame2", ETextureType::Override)); mt->SetUpscaleFlag(false, true);
AddGameTexture(mt);
mt = MakeGameTexture(new AnimTexture(), "AnimTextureFrame2", ETextureType::Override);
mt->SetUpscaleFlag(false, true);
AddGameTexture(mt);
int wadcnt = fileSystem.GetNumWads(); int wadcnt = fileSystem.GetNumWads();

View file

@ -111,41 +111,41 @@
#endif #endif
static const Float_t ABYule[][2 * YULE_ORDER + 1] = { static const Float_t ABYule[][2 * YULE_ORDER + 1] = {
{(const Float_t) 0.006471345933032, (const Float_t) -7.22103125152679, (const Float_t) -0.02567678242161, (const Float_t) 24.7034187975904, (const Float_t) 0.049805860704367, (const Float_t) -52.6825833623896, (const Float_t) -0.05823001743528, (const Float_t) 77.4825736677539, (const Float_t) 0.040611847441914, (const Float_t) -82.0074753444205, (const Float_t) -0.010912036887501, (const Float_t) 63.1566097101925, (const Float_t) -0.00901635868667, (const Float_t) -34.889569769245, (const Float_t) 0.012448886238123, (const Float_t) 13.2126852760198, (const Float_t) -0.007206683749426, (const Float_t) -3.09445623301669, (const Float_t) 0.002167156433951, (const Float_t) 0.340344741393305, (const Float_t) -0.000261819276949}, {(Float_t) 0.006471345933032, (Float_t) -7.22103125152679, (Float_t) -0.02567678242161, (Float_t) 24.7034187975904, (Float_t) 0.049805860704367, (Float_t) -52.6825833623896, (Float_t) -0.05823001743528, (Float_t) 77.4825736677539, (Float_t) 0.040611847441914, (Float_t) -82.0074753444205, (Float_t) -0.010912036887501, (Float_t) 63.1566097101925, (Float_t) -0.00901635868667, (Float_t) -34.889569769245, (Float_t) 0.012448886238123, (Float_t) 13.2126852760198, (Float_t) -0.007206683749426, (Float_t) -3.09445623301669, (Float_t) 0.002167156433951, (Float_t) 0.340344741393305, (Float_t) -0.000261819276949},
{(const Float_t) 0.015415414474287, (const Float_t) -7.19001570087017, (const Float_t) -0.07691359399407, (const Float_t) 24.4109412087159, (const Float_t) 0.196677418516518, (const Float_t) -51.6306373580801, (const Float_t) -0.338855114128061, (const Float_t) 75.3978476863163, (const Float_t) 0.430094579594561, (const Float_t) -79.4164552507386, (const Float_t) -0.415015413747894, (const Float_t) 61.0373661948115, (const Float_t) 0.304942508151101, (const Float_t) -33.7446462547014, (const Float_t) -0.166191795926663, (const Float_t) 12.8168791146274, (const Float_t) 0.063198189938739, (const Float_t) -3.01332198541437, (const Float_t) -0.015003978694525, (const Float_t) 0.223619893831468, (const Float_t) 0.001748085184539}, {(Float_t) 0.015415414474287, (Float_t) -7.19001570087017, (Float_t) -0.07691359399407, (Float_t) 24.4109412087159, (Float_t) 0.196677418516518, (Float_t) -51.6306373580801, (Float_t) -0.338855114128061, (Float_t) 75.3978476863163, (Float_t) 0.430094579594561, (Float_t) -79.4164552507386, (Float_t) -0.415015413747894, (Float_t) 61.0373661948115, (Float_t) 0.304942508151101, (Float_t) -33.7446462547014, (Float_t) -0.166191795926663, (Float_t) 12.8168791146274, (Float_t) 0.063198189938739, (Float_t) -3.01332198541437, (Float_t) -0.015003978694525, (Float_t) 0.223619893831468, (Float_t) 0.001748085184539},
{(const Float_t) 0.021776466467053, (const Float_t) -5.74819833657784, (const Float_t) -0.062376961003801, (const Float_t) 16.246507961894, (const Float_t) 0.107731165328514, (const Float_t) -29.9691822642542, (const Float_t) -0.150994515142316, (const Float_t) 40.027597579378, (const Float_t) 0.170334807313632, (const Float_t) -40.3209196052655, (const Float_t) -0.157984942890531, (const Float_t) 30.8542077487718, (const Float_t) 0.121639833268721, (const Float_t) -17.5965138737281, (const Float_t) -0.074094040816409, (const Float_t) 7.10690214103873, (const Float_t) 0.031282852041061, (const Float_t) -1.82175564515191, (const Float_t) -0.00755421235941, (const Float_t) 0.223619893831468, (const Float_t) 0.00117925454213}, {(Float_t) 0.021776466467053, (Float_t) -5.74819833657784, (Float_t) -0.062376961003801, (Float_t) 16.246507961894, (Float_t) 0.107731165328514, (Float_t) -29.9691822642542, (Float_t) -0.150994515142316, (Float_t) 40.027597579378, (Float_t) 0.170334807313632, (Float_t) -40.3209196052655, (Float_t) -0.157984942890531, (Float_t) 30.8542077487718, (Float_t) 0.121639833268721, (Float_t) -17.5965138737281, (Float_t) -0.074094040816409, (Float_t) 7.10690214103873, (Float_t) 0.031282852041061, (Float_t) -1.82175564515191, (Float_t) -0.00755421235941, (Float_t) 0.223619893831468, (Float_t) 0.00117925454213},
{(const Float_t) 0.03857599435200, (const Float_t) -3.84664617118067, (const Float_t) -0.02160367184185, (const Float_t) 7.81501653005538, (const Float_t) -0.00123395316851, (const Float_t) -11.34170355132042, (const Float_t) -0.00009291677959, (const Float_t) 13.05504219327545, (const Float_t) -0.01655260341619, (const Float_t) -12.28759895145294, (const Float_t) 0.02161526843274, (const Float_t) 9.48293806319790, (const Float_t) -0.02074045215285, (const Float_t) -5.87257861775999, (const Float_t) 0.00594298065125, (const Float_t) 2.75465861874613, (const Float_t) 0.00306428023191, (const Float_t) -0.86984376593551, (const Float_t) 0.00012025322027, (const Float_t) 0.13919314567432, (const Float_t) 0.00288463683916}, {(Float_t) 0.03857599435200, (Float_t) -3.84664617118067, (Float_t) -0.02160367184185, (Float_t) 7.81501653005538, (Float_t) -0.00123395316851, (Float_t) -11.34170355132042, (Float_t) -0.00009291677959, (Float_t) 13.05504219327545, (Float_t) -0.01655260341619, (Float_t) -12.28759895145294, (Float_t) 0.02161526843274, (Float_t) 9.48293806319790, (Float_t) -0.02074045215285, (Float_t) -5.87257861775999, (Float_t) 0.00594298065125, (Float_t) 2.75465861874613, (Float_t) 0.00306428023191, (Float_t) -0.86984376593551, (Float_t) 0.00012025322027, (Float_t) 0.13919314567432, (Float_t) 0.00288463683916},
{(const Float_t) 0.05418656406430, (const Float_t) -3.47845948550071, (const Float_t) -0.02911007808948, (const Float_t) 6.36317777566148, (const Float_t) -0.00848709379851, (const Float_t) -8.54751527471874, (const Float_t) -0.00851165645469, (const Float_t) 9.47693607801280, (const Float_t) -0.00834990904936, (const Float_t) -8.81498681370155, (const Float_t) 0.02245293253339, (const Float_t) 6.85401540936998, (const Float_t) -0.02596338512915, (const Float_t) -4.39470996079559, (const Float_t) 0.01624864962975, (const Float_t) 2.19611684890774, (const Float_t) -0.00240879051584, (const Float_t) -0.75104302451432, (const Float_t) 0.00674613682247, (const Float_t) 0.13149317958808, (const Float_t) -0.00187763777362}, {(Float_t) 0.05418656406430, (Float_t) -3.47845948550071, (Float_t) -0.02911007808948, (Float_t) 6.36317777566148, (Float_t) -0.00848709379851, (Float_t) -8.54751527471874, (Float_t) -0.00851165645469, (Float_t) 9.47693607801280, (Float_t) -0.00834990904936, (Float_t) -8.81498681370155, (Float_t) 0.02245293253339, (Float_t) 6.85401540936998, (Float_t) -0.02596338512915, (Float_t) -4.39470996079559, (Float_t) 0.01624864962975, (Float_t) 2.19611684890774, (Float_t) -0.00240879051584, (Float_t) -0.75104302451432, (Float_t) 0.00674613682247, (Float_t) 0.13149317958808, (Float_t) -0.00187763777362},
{(const Float_t) 0.15457299681924, (const Float_t) -2.37898834973084, (const Float_t) -0.09331049056315, (const Float_t) 2.84868151156327, (const Float_t) -0.06247880153653, (const Float_t) -2.64577170229825, (const Float_t) 0.02163541888798, (const Float_t) 2.23697657451713, (const Float_t) -0.05588393329856, (const Float_t) -1.67148153367602, (const Float_t) 0.04781476674921, (const Float_t) 1.00595954808547, (const Float_t) 0.00222312597743, (const Float_t) -0.45953458054983, (const Float_t) 0.03174092540049, (const Float_t) 0.16378164858596, (const Float_t) -0.01390589421898, (const Float_t) -0.05032077717131, (const Float_t) 0.00651420667831, (const Float_t) 0.02347897407020, (const Float_t) -0.00881362733839}, {(Float_t) 0.15457299681924, (Float_t) -2.37898834973084, (Float_t) -0.09331049056315, (Float_t) 2.84868151156327, (Float_t) -0.06247880153653, (Float_t) -2.64577170229825, (Float_t) 0.02163541888798, (Float_t) 2.23697657451713, (Float_t) -0.05588393329856, (Float_t) -1.67148153367602, (Float_t) 0.04781476674921, (Float_t) 1.00595954808547, (Float_t) 0.00222312597743, (Float_t) -0.45953458054983, (Float_t) 0.03174092540049, (Float_t) 0.16378164858596, (Float_t) -0.01390589421898, (Float_t) -0.05032077717131, (Float_t) 0.00651420667831, (Float_t) 0.02347897407020, (Float_t) -0.00881362733839},
{(const Float_t) 0.30296907319327, (const Float_t) -1.61273165137247, (const Float_t) -0.22613988682123, (const Float_t) 1.07977492259970, (const Float_t) -0.08587323730772, (const Float_t) -0.25656257754070, (const Float_t) 0.03282930172664, (const Float_t) -0.16276719120440, (const Float_t) -0.00915702933434, (const Float_t) -0.22638893773906, (const Float_t) -0.02364141202522, (const Float_t) 0.39120800788284, (const Float_t) -0.00584456039913, (const Float_t) -0.22138138954925, (const Float_t) 0.06276101321749, (const Float_t) 0.04500235387352, (const Float_t) -0.00000828086748, (const Float_t) 0.02005851806501, (const Float_t) 0.00205861885564, (const Float_t) 0.00302439095741, (const Float_t) -0.02950134983287}, {(Float_t) 0.30296907319327, (Float_t) -1.61273165137247, (Float_t) -0.22613988682123, (Float_t) 1.07977492259970, (Float_t) -0.08587323730772, (Float_t) -0.25656257754070, (Float_t) 0.03282930172664, (Float_t) -0.16276719120440, (Float_t) -0.00915702933434, (Float_t) -0.22638893773906, (Float_t) -0.02364141202522, (Float_t) 0.39120800788284, (Float_t) -0.00584456039913, (Float_t) -0.22138138954925, (Float_t) 0.06276101321749, (Float_t) 0.04500235387352, (Float_t) -0.00000828086748, (Float_t) 0.02005851806501, (Float_t) 0.00205861885564, (Float_t) 0.00302439095741, (Float_t) -0.02950134983287},
{(const Float_t) 0.33642304856132, (const Float_t) -1.49858979367799, (const Float_t) -0.25572241425570, (const Float_t) 0.87350271418188, (const Float_t) -0.11828570177555, (const Float_t) 0.12205022308084, (const Float_t) 0.11921148675203, (const Float_t) -0.80774944671438, (const Float_t) -0.07834489609479, (const Float_t) 0.47854794562326, (const Float_t) -0.00469977914380, (const Float_t) -0.12453458140019, (const Float_t) -0.00589500224440, (const Float_t) -0.04067510197014, (const Float_t) 0.05724228140351, (const Float_t) 0.08333755284107, (const Float_t) 0.00832043980773, (const Float_t) -0.04237348025746, (const Float_t) -0.01635381384540, (const Float_t) 0.02977207319925, (const Float_t) -0.01760176568150}, {(Float_t) 0.33642304856132, (Float_t) -1.49858979367799, (Float_t) -0.25572241425570, (Float_t) 0.87350271418188, (Float_t) -0.11828570177555, (Float_t) 0.12205022308084, (Float_t) 0.11921148675203, (Float_t) -0.80774944671438, (Float_t) -0.07834489609479, (Float_t) 0.47854794562326, (Float_t) -0.00469977914380, (Float_t) -0.12453458140019, (Float_t) -0.00589500224440, (Float_t) -0.04067510197014, (Float_t) 0.05724228140351, (Float_t) 0.08333755284107, (Float_t) 0.00832043980773, (Float_t) -0.04237348025746, (Float_t) -0.01635381384540, (Float_t) 0.02977207319925, (Float_t) -0.01760176568150},
{(const Float_t) 0.44915256608450, (const Float_t) -0.62820619233671, (const Float_t) -0.14351757464547, (const Float_t) 0.29661783706366, (const Float_t) -0.22784394429749, (const Float_t) -0.37256372942400, (const Float_t) -0.01419140100551, (const Float_t) 0.00213767857124, (const Float_t) 0.04078262797139, (const Float_t) -0.42029820170918, (const Float_t) -0.12398163381748, (const Float_t) 0.22199650564824, (const Float_t) 0.04097565135648, (const Float_t) 0.00613424350682, (const Float_t) 0.10478503600251, (const Float_t) 0.06747620744683, (const Float_t) -0.01863887810927, (const Float_t) 0.05784820375801, (const Float_t) -0.03193428438915, (const Float_t) 0.03222754072173, (const Float_t) 0.00541907748707}, {(Float_t) 0.44915256608450, (Float_t) -0.62820619233671, (Float_t) -0.14351757464547, (Float_t) 0.29661783706366, (Float_t) -0.22784394429749, (Float_t) -0.37256372942400, (Float_t) -0.01419140100551, (Float_t) 0.00213767857124, (Float_t) 0.04078262797139, (Float_t) -0.42029820170918, (Float_t) -0.12398163381748, (Float_t) 0.22199650564824, (Float_t) 0.04097565135648, (Float_t) 0.00613424350682, (Float_t) 0.10478503600251, (Float_t) 0.06747620744683, (Float_t) -0.01863887810927, (Float_t) 0.05784820375801, (Float_t) -0.03193428438915, (Float_t) 0.03222754072173, (Float_t) 0.00541907748707},
{(const Float_t) 0.56619470757641, (const Float_t) -1.04800335126349, (const Float_t) -0.75464456939302, (const Float_t) 0.29156311971249, (const Float_t) 0.16242137742230, (const Float_t) -0.26806001042947, (const Float_t) 0.16744243493672, (const Float_t) 0.00819999645858, (const Float_t) -0.18901604199609, (const Float_t) 0.45054734505008, (const Float_t) 0.30931782841830, (const Float_t) -0.33032403314006, (const Float_t) -0.27562961986224, (const Float_t) 0.06739368333110, (const Float_t) 0.00647310677246, (const Float_t) -0.04784254229033, (const Float_t) 0.08647503780351, (const Float_t) 0.01639907836189, (const Float_t) -0.03788984554840, (const Float_t) 0.01807364323573, (const Float_t) -0.00588215443421}, {(Float_t) 0.56619470757641, (Float_t) -1.04800335126349, (Float_t) -0.75464456939302, (Float_t) 0.29156311971249, (Float_t) 0.16242137742230, (Float_t) -0.26806001042947, (Float_t) 0.16744243493672, (Float_t) 0.00819999645858, (Float_t) -0.18901604199609, (Float_t) 0.45054734505008, (Float_t) 0.30931782841830, (Float_t) -0.33032403314006, (Float_t) -0.27562961986224, (Float_t) 0.06739368333110, (Float_t) 0.00647310677246, (Float_t) -0.04784254229033, (Float_t) 0.08647503780351, (Float_t) 0.01639907836189, (Float_t) -0.03788984554840, (Float_t) 0.01807364323573, (Float_t) -0.00588215443421},
{(const Float_t) 0.58100494960553, (const Float_t) -0.51035327095184, (const Float_t) -0.53174909058578, (const Float_t) -0.31863563325245, (const Float_t) -0.14289799034253, (const Float_t) -0.20256413484477, (const Float_t) 0.17520704835522, (const Float_t) 0.14728154134330, (const Float_t) 0.02377945217615, (const Float_t) 0.38952639978999, (const Float_t) 0.15558449135573, (const Float_t) -0.23313271880868, (const Float_t) -0.25344790059353, (const Float_t) -0.05246019024463, (const Float_t) 0.01628462406333, (const Float_t) -0.02505961724053, (const Float_t) 0.06920467763959, (const Float_t) 0.02442357316099, (const Float_t) -0.03721611395801, (const Float_t) 0.01818801111503, (const Float_t) -0.00749618797172}, {(Float_t) 0.58100494960553, (Float_t) -0.51035327095184, (Float_t) -0.53174909058578, (Float_t) -0.31863563325245, (Float_t) -0.14289799034253, (Float_t) -0.20256413484477, (Float_t) 0.17520704835522, (Float_t) 0.14728154134330, (Float_t) 0.02377945217615, (Float_t) 0.38952639978999, (Float_t) 0.15558449135573, (Float_t) -0.23313271880868, (Float_t) -0.25344790059353, (Float_t) -0.05246019024463, (Float_t) 0.01628462406333, (Float_t) -0.02505961724053, (Float_t) 0.06920467763959, (Float_t) 0.02442357316099, (Float_t) -0.03721611395801, (Float_t) 0.01818801111503, (Float_t) -0.00749618797172},
{(const Float_t) 0.53648789255105, (const Float_t) -0.25049871956020, (const Float_t) -0.42163034350696, (const Float_t) -0.43193942311114, (const Float_t) -0.00275953611929, (const Float_t) -0.03424681017675, (const Float_t) 0.04267842219415, (const Float_t) -0.04678328784242, (const Float_t) -0.10214864179676, (const Float_t) 0.26408300200955, (const Float_t) 0.14590772289388, (const Float_t) 0.15113130533216, (const Float_t) -0.02459864859345, (const Float_t) -0.17556493366449, (const Float_t) -0.11202315195388, (const Float_t) -0.18823009262115, (const Float_t) -0.04060034127000, (const Float_t) 0.05477720428674, (const Float_t) 0.04788665548180, (const Float_t) 0.04704409688120, (const Float_t) -0.02217936801134}, {(Float_t) 0.53648789255105, (Float_t) -0.25049871956020, (Float_t) -0.42163034350696, (Float_t) -0.43193942311114, (Float_t) -0.00275953611929, (Float_t) -0.03424681017675, (Float_t) 0.04267842219415, (Float_t) -0.04678328784242, (Float_t) -0.10214864179676, (Float_t) 0.26408300200955, (Float_t) 0.14590772289388, (Float_t) 0.15113130533216, (Float_t) -0.02459864859345, (Float_t) -0.17556493366449, (Float_t) -0.11202315195388, (Float_t) -0.18823009262115, (Float_t) -0.04060034127000, (Float_t) 0.05477720428674, (Float_t) 0.04788665548180, (Float_t) 0.04704409688120, (Float_t) -0.02217936801134},
{(const Float_t) 0.38524531015142, (const Float_t) -1.29708918404534, (const Float_t) -0.27682212062067, (const Float_t) 0.90399339674203, (const Float_t)-0.09980181488805, (const Float_t) -0.29613799017877, (const Float_t) 0.09951486755646, (const Float_t)-0.42326645916207, (const Float_t) -0.08934020156622, (const Float_t) 0.37934887402200, (const Float_t) -0.00322369330199, (const Float_t) -0.37919795944938, (const Float_t) -0.00110329090689, (const Float_t) 0.23410283284785, (const Float_t) 0.03784509844682, (const Float_t) -0.03892971758879, (const Float_t) 0.01683906213303, (const Float_t) 0.00403009552351, (const Float_t) -0.01147039862572, (const Float_t) 0.03640166626278, (const Float_t) -0.01941767987192 }, {(Float_t) 0.38524531015142, (Float_t) -1.29708918404534, (Float_t) -0.27682212062067, (Float_t) 0.90399339674203, (Float_t)-0.09980181488805, (Float_t) -0.29613799017877, (Float_t) 0.09951486755646, (Float_t)-0.42326645916207, (Float_t) -0.08934020156622, (Float_t) 0.37934887402200, (Float_t) -0.00322369330199, (Float_t) -0.37919795944938, (Float_t) -0.00110329090689, (Float_t) 0.23410283284785, (Float_t) 0.03784509844682, (Float_t) -0.03892971758879, (Float_t) 0.01683906213303, (Float_t) 0.00403009552351, (Float_t) -0.01147039862572, (Float_t) 0.03640166626278, (Float_t) -0.01941767987192 },
{(const Float_t)0.08717879977844, (const Float_t)-2.62816311472146, (const Float_t)-0.01000374016172, (const Float_t)3.53734535817992, (const Float_t)-0.06265852122368, (const Float_t)-3.81003448678921, (const Float_t)-0.01119328800950, (const Float_t)3.91291636730132, (const Float_t)-0.00114279372960, (const Float_t)-3.53518605896288, (const Float_t)0.02081333954769, (const Float_t)2.71356866157873, (const Float_t)-0.01603261863207, (const Float_t)-1.86723311846592, (const Float_t)0.01936763028546, (const Float_t)1.12075382367659, (const Float_t)0.00760044736442, (const Float_t)-0.48574086886890, (const Float_t)-0.00303979112271, (const Float_t)0.11330544663849, (const Float_t)-0.00075088605788 }, {(Float_t)0.08717879977844, (Float_t)-2.62816311472146, (Float_t)-0.01000374016172, (Float_t)3.53734535817992, (Float_t)-0.06265852122368, (Float_t)-3.81003448678921, (Float_t)-0.01119328800950, (Float_t)3.91291636730132, (Float_t)-0.00114279372960, (Float_t)-3.53518605896288, (Float_t)0.02081333954769, (Float_t)2.71356866157873, (Float_t)-0.01603261863207, (Float_t)-1.86723311846592, (Float_t)0.01936763028546, (Float_t)1.12075382367659, (Float_t)0.00760044736442, (Float_t)-0.48574086886890, (Float_t)-0.00303979112271, (Float_t)0.11330544663849, (Float_t)-0.00075088605788 },
}; };
static const Float_t ABButter[][2 * BUTTER_ORDER + 1] = { static const Float_t ABButter[][2 * BUTTER_ORDER + 1] = {
{(const Float_t) 0.99308203517541, (const Float_t) -1.98611621154089, (const Float_t) -1.98616407035082, (const Float_t) 0.986211929160751, (const Float_t) 0.99308203517541}, {(Float_t) 0.99308203517541, (Float_t) -1.98611621154089, (Float_t) -1.98616407035082, (Float_t) 0.986211929160751, (Float_t) 0.99308203517541},
{(const Float_t) 0.992472550461293, (const Float_t) -1.98488843762334, (const Float_t) -1.98494510092258, (const Float_t) 0.979389350028798, (const Float_t) 0.992472550461293}, {(Float_t) 0.992472550461293, (Float_t) -1.98488843762334, (Float_t) -1.98494510092258, (Float_t) 0.979389350028798, (Float_t) 0.992472550461293},
{(const Float_t) 0.989641019334721, (const Float_t) -1.97917472731008, (const Float_t) -1.97928203866944, (const Float_t) 0.979389350028798, (const Float_t) 0.989641019334721}, {(Float_t) 0.989641019334721, (Float_t) -1.97917472731008, (Float_t) -1.97928203866944, (Float_t) 0.979389350028798, (Float_t) 0.989641019334721},
{(const Float_t) 0.98621192462708, (const Float_t) -1.97223372919527, (const Float_t) -1.97242384925416, (const Float_t) 0.97261396931306, (const Float_t) 0.98621192462708}, {(Float_t) 0.98621192462708, (Float_t) -1.97223372919527, (Float_t) -1.97242384925416, (Float_t) 0.97261396931306, (Float_t) 0.98621192462708},
{(const Float_t) 0.98500175787242, (const Float_t) -1.96977855582618, (const Float_t) -1.97000351574484, (const Float_t) 0.97022847566350, (const Float_t) 0.98500175787242}, {(Float_t) 0.98500175787242, (Float_t) -1.96977855582618, (Float_t) -1.97000351574484, (Float_t) 0.97022847566350, (Float_t) 0.98500175787242},
{(const Float_t) 0.97938932735214, (const Float_t) -1.95835380975398, (const Float_t) -1.95877865470428, (const Float_t) 0.95920349965459, (const Float_t) 0.97938932735214}, {(Float_t) 0.97938932735214, (Float_t) -1.95835380975398, (Float_t) -1.95877865470428, (Float_t) 0.95920349965459, (Float_t) 0.97938932735214},
{(const Float_t) 0.97531843204928, (const Float_t) -1.95002759149878, (const Float_t) -1.95063686409857, (const Float_t) 0.95124613669835, (const Float_t) 0.97531843204928}, {(Float_t) 0.97531843204928, (Float_t) -1.95002759149878, (Float_t) -1.95063686409857, (Float_t) 0.95124613669835, (Float_t) 0.97531843204928},
{(const Float_t) 0.97316523498161, (const Float_t) -1.94561023566527, (const Float_t) -1.94633046996323, (const Float_t) 0.94705070426118, (const Float_t) 0.97316523498161}, {(Float_t) 0.97316523498161, (Float_t) -1.94561023566527, (Float_t) -1.94633046996323, (Float_t) 0.94705070426118, (Float_t) 0.97316523498161},
{(const Float_t) 0.96454515552826, (const Float_t) -1.92783286977036, (const Float_t) -1.92909031105652, (const Float_t) 0.93034775234268, (const Float_t) 0.96454515552826}, {(Float_t) 0.96454515552826, (Float_t) -1.92783286977036, (Float_t) -1.92909031105652, (Float_t) 0.93034775234268, (Float_t) 0.96454515552826},
{(const Float_t) 0.96009142950541, (const Float_t) -1.91858953033784, (const Float_t) -1.92018285901082, (const Float_t) 0.92177618768381, (const Float_t) 0.96009142950541}, {(Float_t) 0.96009142950541, (Float_t) -1.91858953033784, (Float_t) -1.92018285901082, (Float_t) 0.92177618768381, (Float_t) 0.96009142950541},
{(const Float_t) 0.95856916599601, (const Float_t) -1.91542108074780, (const Float_t) -1.91713833199203, (const Float_t) 0.91885558323625, (const Float_t) 0.95856916599601}, {(Float_t) 0.95856916599601, (Float_t) -1.91542108074780, (Float_t) -1.91713833199203, (Float_t) 0.91885558323625, (Float_t) 0.95856916599601},
{(const Float_t) 0.94597685600279, (const Float_t) -1.88903307939452, (const Float_t) -1.89195371200558, (const Float_t) 0.89487434461664, (const Float_t) 0.94597685600279}, {(Float_t) 0.94597685600279, (Float_t) -1.88903307939452, (Float_t) -1.89195371200558, (Float_t) 0.89487434461664, (Float_t) 0.94597685600279},
{(const Float_t)0.96535326815829, (const Float_t)-1.92950577983524, (const Float_t)-1.93070653631658, (const Float_t)0.93190729279793, (const Float_t)0.96535326815829 }, {(Float_t)0.96535326815829, (Float_t)-1.92950577983524, (Float_t)-1.93070653631658, (Float_t)0.93190729279793, (Float_t)0.96535326815829 },
{(const Float_t)0.98252400815195, (const Float_t)-1.96474258269041, (const Float_t)-1.96504801630391, (const Float_t)0.96535344991740, (const Float_t)0.98252400815195 }, {(Float_t)0.98252400815195, (Float_t)-1.96474258269041, (Float_t)-1.96504801630391, (Float_t)0.96535344991740, (Float_t)0.98252400815195 },
}; };

View file

@ -243,9 +243,9 @@ const char *kSMK4iD = "SMK4";
* Context used for code reconstructing * Context used for code reconstructing
*/ */
typedef struct HuffContext { typedef struct HuffContext {
int length; int length = 0;
int maxlength; int maxlength = 0;
int current; int current = 0;
std::vector<uint32_t> bits; std::vector<uint32_t> bits;
std::vector<int> lengths; std::vector<int> lengths;
@ -987,8 +987,6 @@ int SmackerDecoder::DecodeAudio(uint32_t size, SmackerAudioTrack &track)
return -1; return -1;
} }
memset(h, 0, sizeof(HuffContext) * 4);
// Initialize // Initialize
for (i = 0; i < (1 << (sampleBits + stereo)); i++) { for (i = 0; i < (1 << (sampleBits + stereo)); i++) {
h[i].length = 256; h[i].length = 256;

View file

@ -1937,7 +1937,7 @@ private:
if (count) { if (count) {
GenericValue* e = static_cast<GenericValue*>(allocator.Malloc(count * sizeof(GenericValue))); GenericValue* e = static_cast<GenericValue*>(allocator.Malloc(count * sizeof(GenericValue)));
SetElementsPointer(e); SetElementsPointer(e);
std::memcpy(e, values, count * sizeof(GenericValue)); std::memcpy((void*)e, (void*)values, count * sizeof(GenericValue));
} }
else else
SetElementsPointer(0); SetElementsPointer(0);
@ -1950,7 +1950,7 @@ private:
if (count) { if (count) {
Member* m = static_cast<Member*>(allocator.Malloc(count * sizeof(Member))); Member* m = static_cast<Member*>(allocator.Malloc(count * sizeof(Member)));
SetMembersPointer(m); SetMembersPointer(m);
std::memcpy(m, members, count * sizeof(Member)); std::memcpy((void*)m, (void*)members, count * sizeof(Member));
} }
else else
SetMembersPointer(0); SetMembersPointer(0);

View file

@ -85,8 +85,6 @@ compare_right(nat_char const *a, nat_char const *b)
} else if (!*a && !*b) } else if (!*a && !*b)
return bias; return bias;
} }
return 0;
} }
@ -107,8 +105,6 @@ compare_left(nat_char const *a, nat_char const *b)
else if (*a > *b) else if (*a > *b)
return +1; return +1;
} }
return 0;
} }

View file

@ -359,7 +359,7 @@ FString StripExtension(const char* path)
src = path + strlen(path) - 1; src = path + strlen(path) - 1;
// //
// back up until a . and abort on a \ // back up until a . and abort on a '/'
// //
while (src != path && !IsSeperator(*(src - 1))) while (src != path && !IsSeperator(*(src - 1)))
{ {
@ -866,6 +866,10 @@ FString ExpandEnvVars(const char *searchpathstring)
FString NicePath(const char *path) FString NicePath(const char *path)
{ {
#ifdef _WIN32 #ifdef _WIN32
if (*path == '\0')
{
return FString(".");
}
return ExpandEnvVars(path); return ExpandEnvVars(path);
#else #else
if (path == NULL || *path == '\0') if (path == NULL || *path == '\0')

View file

@ -46,6 +46,7 @@
static uint64_t FirstFrameStartTime; static uint64_t FirstFrameStartTime;
static uint64_t CurrentFrameStartTime; static uint64_t CurrentFrameStartTime;
static uint64_t FreezeTime; static uint64_t FreezeTime;
static double lastinputtime;
int GameTicRate = 35; // make sure it is not 0, even if the client doesn't set it. int GameTicRate = 35; // make sure it is not 0, even if the client doesn't set it.
double TimeScale = 1.0; double TimeScale = 1.0;
@ -195,3 +196,39 @@ void I_ResetFrameTime()
I_SetFrameTime(); I_SetFrameTime();
FirstFrameStartTime += (CurrentFrameStartTime - ft); FirstFrameStartTime += (CurrentFrameStartTime - ft);
} }
double I_GetInputFrac(bool const synchronised, double const ticrate)
{
if (!synchronised)
{
const double max = 1000. / ticrate;
const double now = I_msTimeF();
const double elapsedInputTicks = std::min(now - lastinputtime, max);
lastinputtime = now;
if (elapsedInputTicks < max)
{
// Calculate an amplification to apply to the result before returning,
// factoring in the game's ticrate and the value of the result.
// This rectifies a deviation of 100+ ms or more depending on the length
// of the operation to be within 1-2 ms of synchronised input
// from 60 fps to at least 1000 fps at ticrates of 30 and 40 Hz.
const double result = elapsedInputTicks * ticrate / 1000.;
return result * (1. + 0.35 * (1. - ticrate / 50.) * (1. - result));
}
else
{
return 1;
}
}
else
{
return 1;
}
}
void I_ResetInputTime()
{
// Reset lastinputtime to current time.
lastinputtime = I_msTimeF();
}

View file

@ -38,3 +38,9 @@ uint64_t I_nsTime();
// Reset the timer after a lengthy operation // Reset the timer after a lengthy operation
void I_ResetFrameTime(); void I_ResetFrameTime();
// Return a decimal fraction to scale input operations at framerate
double I_GetInputFrac(bool const synchronised, double const ticrate = GameTicRate);
// Reset the last input check to after a lengthy operation
void I_ResetInputTime();

View file

@ -12,6 +12,7 @@
struct PalEntry struct PalEntry
{ {
PalEntry() = default; PalEntry() = default;
PalEntry(const PalEntry&) = default;
constexpr PalEntry (uint32_t argb) : d(argb) { } constexpr PalEntry (uint32_t argb) : d(argb) { }
operator uint32_t () const { return d; } operator uint32_t () const { return d; }
void SetRGB(PalEntry other) void SetRGB(PalEntry other)

View file

@ -903,7 +903,6 @@ int ReadPalette(int lumpnum, uint8_t* buffer)
fr.Seek(33, FileReader::SeekSet); fr.Seek(33, FileReader::SeekSet);
fr.Read(&len, 4); fr.Read(&len, 4);
fr.Read(&id, 4); fr.Read(&id, 4);
bool succeeded = false;
while (id != MAKE_ID('I', 'D', 'A', 'T') && id != MAKE_ID('I', 'E', 'N', 'D')) while (id != MAKE_ID('I', 'D', 'A', 'T') && id != MAKE_ID('I', 'E', 'N', 'D'))
{ {
len = BigLong((unsigned int)len); len = BigLong((unsigned int)len);

View file

@ -1683,6 +1683,12 @@ public:
return !!(bytes[index >> 3] & (1 << (index & 7))); return !!(bytes[index >> 3] & (1 << (index & 7)));
} }
// for when array syntax cannot be used.
bool Check(size_t index) const
{
return !!(bytes[index >> 3] & (1 << (index & 7)));
}
void Set(size_t index, bool set = true) void Set(size_t index, bool set = true)
{ {
if (!set) Clear(index); if (!set) Clear(index);

View file

@ -59,19 +59,19 @@ public:
TFlags (ZeroDummy*) : Value (0) {} TFlags (ZeroDummy*) : Value (0) {}
// Relation operators // Relation operators
Self operator| (Self other) const { return Self::FromInt (Value | other.GetValue()); } Self operator| (const Self& other) const { return Self::FromInt (Value | other.GetValue()); }
Self operator& (Self other) const { return Self::FromInt (Value & other.GetValue()); } Self operator& (const Self& other) const { return Self::FromInt (Value & other.GetValue()); }
Self operator^ (Self other) const { return Self::FromInt (Value ^ other.GetValue()); } Self operator^ (const Self& other) const { return Self::FromInt (Value ^ other.GetValue()); }
Self operator| (T value) const { return Self::FromInt (Value | value); } Self operator| (T value) const { return Self::FromInt (Value | value); }
Self operator& (T value) const { return Self::FromInt (Value & value); } Self operator& (T value) const { return Self::FromInt (Value & value); }
Self operator^ (T value) const { return Self::FromInt (Value ^ value); } Self operator^ (T value) const { return Self::FromInt (Value ^ value); }
Self operator~() const { return Self::FromInt (~Value); } Self operator~() const { return Self::FromInt (~Value); }
// Assignment operators // Assignment operators
Self& operator= (Self other) { Value = other.GetValue(); return *this; } Self& operator= (const Self& other) = default;
Self& operator|= (Self other) { Value |= other.GetValue(); return *this; } Self& operator|= (const Self& other) { Value |= other.GetValue(); return *this; }
Self& operator&= (Self other) { Value &= other.GetValue(); return *this; } Self& operator&= (const Self& other) { Value &= other.GetValue(); return *this; }
Self& operator^= (Self other) { Value ^= other.GetValue(); return *this; } Self& operator^= (const Self& other) { Value ^= other.GetValue(); return *this; }
Self& operator= (T value) { Value = value; return *this; } Self& operator= (T value) { Value = value; return *this; }
Self& operator|= (T value) { Value |= value; return *this; } Self& operator|= (T value) { Value |= value; return *this; }
Self& operator&= (T value) { Value &= value; return *this; } Self& operator&= (T value) { Value &= value; return *this; }

View file

@ -428,7 +428,6 @@ int getAlternative(int code)
case 0x457: return 0xef; case 0x457: return 0xef;
case 0x458: return 'j'; case 0x458: return 'j';
} }
return code;
} }
//========================================================================== //==========================================================================

View file

@ -318,9 +318,9 @@ namespace StringFormat
*/ */
const char *decimal_point = ".";/* locale specific decimal point */ const char *decimal_point = ".";/* locale specific decimal point */
int signflag; /* true if float is negative */ int signflag; /* true if float is negative */
int expt; /* integer value of exponent */ int expt = 0; /* integer value of exponent */
char expchar = 'e'; /* exponent character: [eEpP\0] */ char expchar = 'e'; /* exponent character: [eEpP\0] */
char *dtoaend; /* pointer to end of converted digits */ char* dtoaend = nullptr; /* pointer to end of converted digits */
int expsize = 0; /* character count for expstr */ int expsize = 0; /* character count for expstr */
int ndig = 0; /* actual number of digits returned by dtoa */ int ndig = 0; /* actual number of digits returned by dtoa */
char expstr[MAXEXPDIG+2]; /* buffer for exponent string: e+ZZZ */ char expstr[MAXEXPDIG+2]; /* buffer for exponent string: e+ZZZ */

View file

@ -680,18 +680,15 @@ void DrawOverheadMap(int pl_x, int pl_y, int pl_angle, double const smoothratio)
int y = follow_y; int y = follow_y;
follow_a = am_rotate ? pl_angle : 0; follow_a = am_rotate ? pl_angle : 0;
AutomapControl(); AutomapControl();
int width = screen->GetWidth();
if (automapMode == am_full) if (automapMode == am_full)
{ {
twod->ClearScreen(); twod->ClearScreen();
renderDrawMapView(x, y, gZoom, follow_a); renderDrawMapView(x, y, gZoom, follow_a);
} }
int32_t tmpydim = (width * 5) / 8;
drawredlines(x, y, gZoom, follow_a); drawredlines(x, y, gZoom, follow_a);
drawwhitelines(x, y, gZoom, follow_a); drawwhitelines(x, y, gZoom, follow_a);
if (!gi->DrawAutomapPlayer(x, y, gZoom, follow_a, smoothratio)) if (!gi->DrawAutomapPlayer(pl_x, pl_y, x, y, gZoom, follow_a, smoothratio))
DrawPlayerArrow(x, y, follow_a, pl_x, pl_y, gZoom, -pl_angle); DrawPlayerArrow(x, y, follow_a, pl_x, pl_y, gZoom, -pl_angle);
} }

View file

@ -129,6 +129,7 @@ class binangle
public: public:
binangle() = default; binangle() = default;
binangle(const binangle &other) = default; binangle(const binangle &other) = default;
binangle& operator=(const binangle& other) = default;
// This class intentionally makes no allowances for implicit type conversions because those would render it ineffective. // This class intentionally makes no allowances for implicit type conversions because those would render it ineffective.
constexpr short asbuild() const { return value >> BAMBITS; } constexpr short asbuild() const { return value >> BAMBITS; }
constexpr double asbuildf() const { return value * (1. / +BAMUNIT); } constexpr double asbuildf() const { return value * (1. / +BAMUNIT); }

View file

@ -530,20 +530,35 @@ CCMD(skill)
} }
else if (argsCount == 2) else if (argsCount == 2)
{ {
// Get maximum valid skills for loaded game.
auto maxvalidskills = 0;
for (auto i = 0; i < MAXSKILLS; i++)
{
if (gSkillNames[i].IsNotEmpty())
{
maxvalidskills++;
}
}
// Test and set skill if its legal.
auto newSkill = atoi(argv[1]); auto newSkill = atoi(argv[1]);
if (newSkill >= 0 and newSkill < MAXSKILLS) if (newSkill >= 0 && newSkill < maxvalidskills)
{ {
g_nextskill = newSkill; g_nextskill = newSkill;
Printf("Skill will be changed for next game.\n"); Printf("Skill will be changed for next game.\n");
} }
else else
{ {
Printf("Please specify a skill level between 0 and %d\n", MAXSKILLS - 1); Printf("Please specify a skill level between 0 and %d\n", maxvalidskills - 1);
for (auto i = 0; i < maxvalidskills; i++)
{
Printf("%d = '%s'\n", i, GStrings.localize(gSkillNames[i]));
}
} }
} }
else if (argsCount > 2) else if (argsCount > 2)
{ {
Printf(PRINT_BOLD, "skill <newskill>: returns the current skill level, and optionally sets the skill level for the next game.\n"); Printf(PRINT_BOLD, "skill <level>: returns the current skill level, and optionally sets the skill level for the next game if provided and is valid.\n");
} }
} }
else else

View file

@ -1983,6 +1983,7 @@ void Net_SkipCommand (int cmd, uint8_t **stream)
void Net_ClearFifo(void) void Net_ClearFifo(void)
{ {
I_SetFrameTime(); I_SetFrameTime();
I_ResetInputTime();
gametime = I_GetTime(); gametime = I_GetTime();
} }

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