diff --git a/libraries/fluidlite/src/fluid_voice.c b/libraries/fluidlite/src/fluid_voice.c index 8bf842e34..72ce7718a 100644 --- a/libraries/fluidlite/src/fluid_voice.c +++ b/libraries/fluidlite/src/fluid_voice.c @@ -600,6 +600,8 @@ fluid_voice_write(fluid_voice_t* voice, fluid_voice_off(voice); } + voice->dsp_buf = NULL; + post_process: voice->ticks += FLUID_BUFSIZE; return FLUID_OK; diff --git a/libraries/opalmidi/opal.cpp b/libraries/opalmidi/opal.cpp index e05d5c1ca..7dceac071 100644 --- a/libraries/opalmidi/opal.cpp +++ b/libraries/opalmidi/opal.cpp @@ -244,7 +244,7 @@ void Opal::Port(uint16_t reg_num, uint8_t val) { // The 4-op channels are 0, 1, 2, 9, 10, 11 - uint16_t chan = i < 3 ? i : i + 6; + uint16_t chan = i < 3 ? i : (i + 6); Channel *primary = &Chan[chan]; Channel *secondary = &Chan[chan + 3]; diff --git a/libraries/sokol/sokol_gfx.h b/libraries/sokol/sokol_gfx.h index 5d25fa8b2..68986ae53 100644 --- a/libraries/sokol/sokol_gfx.h +++ b/libraries/sokol/sokol_gfx.h @@ -4425,7 +4425,7 @@ SOKOL_GFX_API_DECL const void* sg_d3d11_device(void); // D3D11: return ID3D11DeviceContext SOKOL_GFX_API_DECL const void* sg_d3d11_device_context(void); // D3D11: return ID3D11DepthStencilView -SOKOL_GFX_API_DECL const void sg_d3d11_clear_depth(float value); +SOKOL_GFX_API_DECL void sg_d3d11_clear_depth(float value); // D3D11: get internal buffer resource objects SOKOL_GFX_API_DECL sg_d3d11_buffer_info sg_d3d11_query_buffer_info(sg_buffer buf); // D3D11: get internal image resource objects @@ -19523,7 +19523,7 @@ SOKOL_API_IMPL const void* sg_d3d11_device_context(void) { #endif } -SOKOL_API_IMPL const void sg_d3d11_clear_depth(float value) { +SOKOL_API_IMPL void sg_d3d11_clear_depth(float value) { #if defined(SOKOL_D3D11) _sg.d3d11.ctx->ClearDepthStencilView(_sg.d3d11.cur_pass.depth_stencil_view, D3D11_CLEAR_DEPTH, value, 0); #endif diff --git a/libraries/xxHash/xxhash.h b/libraries/xxHash/xxhash.h index c3ed99851..95b94be70 100644 --- a/libraries/xxHash/xxhash.h +++ b/libraries/xxHash/xxhash.h @@ -4492,7 +4492,7 @@ XXH3_mul128_fold64(xxh_u64 lhs, xxh_u64 rhs) XXH_FORCE_INLINE XXH_CONSTF xxh_u64 XXH_xorshift64(xxh_u64 v64, int shift) { XXH_ASSERT(0 <= shift && shift < 64); - return v64 ^ (v64 >> shift); + return v64 ^ (v64 >> (unsigned int)shift); } /* diff --git a/source_files/ajbsp/bsp.h b/source_files/ajbsp/bsp.h index bb90a7909..465c0fa0e 100644 --- a/source_files/ajbsp/bsp.h +++ b/source_files/ajbsp/bsp.h @@ -62,17 +62,17 @@ void ResetInfo(); // attempt to open a wad. on failure, the FatalError method in the // BuildInfo interface is called. -void OpenWad(std::string filename); +void OpenWad(const std::string &filename); // attempt to open a wad from memory; only intended for the use // of WAD files inside archives -void OpenMem(std::string filename, epi::File *memfile); +void OpenMem(const std::string &filename, epi::File *memfile); // close a previously opened wad. void CloseWad(); // create/finish an XWA file -void CreateXWA(std::string filename); +void CreateXWA(const std::string &filename); void FinishXWA(); // give the number of levels detected in the wad. diff --git a/source_files/ajbsp/bsp_level.cc b/source_files/ajbsp/bsp_level.cc index 2f0b2cbdd..18c6496a8 100644 --- a/source_files/ajbsp/bsp_level.cc +++ b/source_files/ajbsp/bsp_level.cc @@ -470,7 +470,7 @@ void GetLinedefs() /* ----- UDMF reading routines ------------------------- */ -void ParseThingField(Thing *thing, const int &key, epi::Scanner &lex) +static void ParseThingField(Thing *thing, const int &key, const epi::Scanner &lex) { // Do we need more precision than an int for things? I think this would only // be an issue if/when polyobjects happen, as I think other thing types are @@ -484,7 +484,7 @@ void ParseThingField(Thing *thing, const int &key, epi::Scanner &lex) thing->type = lex.state_.number; } -void ParseVertexField(Vertex *vertex, const int &key, epi::Scanner &lex) +static void ParseVertexField(Vertex *vertex, const int &key, const epi::Scanner &lex) { if (key == epi::kENameX) vertex->x_ = lex.state_.decimal; @@ -492,7 +492,7 @@ void ParseVertexField(Vertex *vertex, const int &key, epi::Scanner &lex) vertex->y_ = lex.state_.decimal; } -void ParseSidedefField(Sidedef *side, const int &key, epi::Scanner &lex) +static void ParseSidedefField(Sidedef *side, const int &key, const epi::Scanner &lex) { if (key == epi::kENameSector) { @@ -505,7 +505,7 @@ void ParseSidedefField(Sidedef *side, const int &key, epi::Scanner &lex) } } -void ParseLinedefField(Linedef *line, const int &key, epi::Scanner &lex) +static void ParseLinedefField(Linedef *line, const int &key, const epi::Scanner &lex) { switch (key) { @@ -992,7 +992,7 @@ void SaveXGL3Format(Lump *lump, Node *root_node) void LoadLevel() { - Lump *LEV = cur_wad->GetLump(level_current_start); + const Lump *LEV = cur_wad->GetLump(level_current_start); level_current_name = LEV->Name(); level_long_name = false; @@ -1201,21 +1201,21 @@ void ResetInfo() current_build_info.split_cost = kSplitCostDefault; } -void OpenWad(std::string filename) +void OpenWad(const std::string &filename) { cur_wad = WadFile::Open(filename, 'r'); if (cur_wad == nullptr) FatalError("AJBSP: Cannot open file: %s\n", filename.c_str()); } -void OpenMem(std::string filename, epi::File *memfile) +void OpenMem(const std::string &filename, epi::File *memfile) { cur_wad = WadFile::OpenMem(filename, memfile); if (cur_wad == nullptr) FatalError("AJBSP: Cannot open file from memory: %s\n", filename.c_str()); } -void CreateXWA(std::string filename) +void CreateXWA(const std::string &filename) { xwa_wad = WadFile::Open(filename, 'w'); if (xwa_wad == nullptr) diff --git a/source_files/ajbsp/bsp_wad.cc b/source_files/ajbsp/bsp_wad.cc index d76b410a2..7c8875af6 100644 --- a/source_files/ajbsp/bsp_wad.cc +++ b/source_files/ajbsp/bsp_wad.cc @@ -207,12 +207,12 @@ bool Lump::Finish() // WAD Reading Interface //------------------------------------------------------------------------ -WadFile::WadFile(std::string name, char mode, FILE *file_pointer, epi::File *memory_file_pointer) - : mode_(mode), file_pointer_(file_pointer), memory_file_pointer_(memory_file_pointer), kind_('P'), total_size_(0), +WadFile::WadFile(const std::string &name, char mode, FILE *file_pointer, epi::File *memory_file_pointer) + : filename_(name), mode_(mode), file_pointer_(file_pointer), memory_file_pointer_(memory_file_pointer), kind_('P'), total_size_(0), directory_(), directory_start_(0), directory_count_(0), levels_(), patches_(), sprites_(), flats_(), tx_textures_(), begun_write_(false), insert_point_(-1) { - filename_ = name; + } WadFile::~WadFile() @@ -236,7 +236,7 @@ WadFile::~WadFile() filename_.clear(); } -WadFile *WadFile::Open(std::string filename, char mode) +WadFile *WadFile::Open(const std::string &filename, char mode) { EPI_ASSERT(mode == 'r' || mode == 'w' || mode == 'a'); @@ -294,7 +294,7 @@ WadFile *WadFile::Open(std::string filename, char mode) return w; } -WadFile *WadFile::OpenMem(std::string filename, epi::File *memfile) +WadFile *WadFile::OpenMem(const std::string &filename, epi::File *memfile) { EPI_ASSERT(memfile); @@ -314,7 +314,7 @@ WadFile *WadFile::OpenMem(std::string filename, epi::File *memfile) return w; } -WadFile *WadFile::Create(std::string filename, char mode) +WadFile *WadFile::Create(const std::string &filename, char mode) { FileMessage("Creating new WAD file: %s\n", filename.c_str()); diff --git a/source_files/ajbsp/bsp_wad.h b/source_files/ajbsp/bsp_wad.h index 4b6148858..4685e5ef8 100644 --- a/source_files/ajbsp/bsp_wad.h +++ b/source_files/ajbsp/bsp_wad.h @@ -149,7 +149,7 @@ class WadFile int insert_point_; // constructor is private - WadFile(std::string name, char mode, FILE *file_pointer, epi::File *memory_file_pointer); + WadFile(const std::string &name, char mode, FILE *file_pointer, epi::File *memory_file_pointer); public: ~WadFile(); @@ -164,9 +164,9 @@ class WadFile // Note: if 'a' is used and the file is read-only, it will be // silently opened in 'r' mode instead. // - static WadFile *Open(std::string filename, char mode = 'a'); + static WadFile *Open(const std::string &filename, char mode = 'a'); - static WadFile *OpenMem(std::string filename, epi::File *memfile); + static WadFile *OpenMem(const std::string &filename, epi::File *memfile); bool IsReadOnly() const { @@ -235,7 +235,7 @@ class WadFile void InsertPoint(int index = -1); private: - static WadFile *Create(std::string filename, char mode); + static WadFile *Create(const std::string &filename, char mode); // read the existing directory. void ReadDirectory(); diff --git a/source_files/coal/c_compile.cc b/source_files/coal/c_compile.cc index 401a69f03..57c9de285 100644 --- a/source_files/coal/c_compile.cc +++ b/source_files/coal/c_compile.cc @@ -39,7 +39,7 @@ #include "epi.h" #include "stb_sprintf.h" -extern void FatalError(const char *error, ...); +[[noreturn]] extern void FatalError(const char *error, ...); namespace coal { diff --git a/source_files/coal/c_execute.cc b/source_files/coal/c_execute.cc index 4c93ed61f..14b5229eb 100644 --- a/source_files/coal/c_execute.cc +++ b/source_files/coal/c_execute.cc @@ -39,7 +39,7 @@ #include "epi.h" #include "stb_sprintf.h" -extern void FatalError(const char *error, ...); +[[noreturn]] extern void FatalError(const char *error, ...); namespace coal { diff --git a/source_files/ddf/ddf_anim.cc b/source_files/ddf/ddf_anim.cc index 30fdc1905..652ee66d7 100644 --- a/source_files/ddf/ddf_anim.cc +++ b/source_files/ddf/ddf_anim.cc @@ -222,7 +222,7 @@ AnimationDefinition::AnimationDefinition() : name_(), pics_() // // Copies all the detail with the exception of ddf info // -void AnimationDefinition::CopyDetail(AnimationDefinition &src) +void AnimationDefinition::CopyDetail(const AnimationDefinition &src) { type_ = src.type_; pics_ = src.pics_; diff --git a/source_files/ddf/ddf_anim.h b/source_files/ddf/ddf_anim.h index b1391c7b6..30a2722e5 100644 --- a/source_files/ddf/ddf_anim.h +++ b/source_files/ddf/ddf_anim.h @@ -29,7 +29,7 @@ class AnimationDefinition public: void Default(void); - void CopyDetail(AnimationDefinition &src); + void CopyDetail(const AnimationDefinition &src); std::string name_; diff --git a/source_files/ddf/ddf_attack.cc b/source_files/ddf/ddf_attack.cc index 5fd957fc8..2960e2c96 100644 --- a/source_files/ddf/ddf_attack.cc +++ b/source_files/ddf/ddf_attack.cc @@ -509,7 +509,7 @@ AttackDefinition::~AttackDefinition() // // AttackDefinition::CopyDetail() // -void AttackDefinition::CopyDetail(AttackDefinition &src) +void AttackDefinition::CopyDetail(const AttackDefinition &src) { attackstyle_ = src.attackstyle_; flags_ = src.flags_; diff --git a/source_files/ddf/ddf_colormap.cc b/source_files/ddf/ddf_colormap.cc index 2f0a30bb3..189852817 100644 --- a/source_files/ddf/ddf_colormap.cc +++ b/source_files/ddf/ddf_colormap.cc @@ -230,7 +230,7 @@ Colormap::~Colormap() // // Colormap::CopyDetail() // -void Colormap::CopyDetail(Colormap &src) +void Colormap::CopyDetail(const Colormap &src) { lump_name_ = src.lump_name_; pack_name_ = src.pack_name_; diff --git a/source_files/ddf/ddf_colormap.h b/source_files/ddf/ddf_colormap.h index 63ecbfdbb..f0c6c201b 100644 --- a/source_files/ddf/ddf_colormap.h +++ b/source_files/ddf/ddf_colormap.h @@ -44,7 +44,7 @@ class Colormap ~Colormap(); public: - void CopyDetail(Colormap &src); + void CopyDetail(const Colormap &src); void Default(); // Member vars... diff --git a/source_files/ddf/ddf_flat.cc b/source_files/ddf/ddf_flat.cc index eaf73b0ee..b363e7d9d 100644 --- a/source_files/ddf/ddf_flat.cc +++ b/source_files/ddf/ddf_flat.cc @@ -178,7 +178,7 @@ FlatDefinition::FlatDefinition() : name_() Default(); } -void FlatDefinition::CopyDetail(FlatDefinition &src) +void FlatDefinition::CopyDetail(const FlatDefinition &src) { liquid_ = src.liquid_; footstep_ = src.footstep_; diff --git a/source_files/ddf/ddf_flat.h b/source_files/ddf/ddf_flat.h index 6f4989aec..4f534b0b0 100644 --- a/source_files/ddf/ddf_flat.h +++ b/source_files/ddf/ddf_flat.h @@ -29,7 +29,7 @@ class FlatDefinition public: void Default(void); - void CopyDetail(FlatDefinition &src); + void CopyDetail(const FlatDefinition &src); // Member vars.... std::string name_; diff --git a/source_files/ddf/ddf_game.cc b/source_files/ddf/ddf_game.cc index 9a2bc27fd..94ac86639 100644 --- a/source_files/ddf/ddf_game.cc +++ b/source_files/ddf/ddf_game.cc @@ -320,7 +320,7 @@ IntermissionMapPositionInfo::IntermissionMapPositionInfo() // // wi_mapposdef_c Copy constructor // -IntermissionMapPositionInfo::IntermissionMapPositionInfo(IntermissionMapPositionInfo &rhs) +IntermissionMapPositionInfo::IntermissionMapPositionInfo(const IntermissionMapPositionInfo &rhs) { Copy(rhs); } @@ -335,7 +335,7 @@ IntermissionMapPositionInfo::~IntermissionMapPositionInfo() // // wi_mapposdef_c::Copy() // -void IntermissionMapPositionInfo::Copy(IntermissionMapPositionInfo &src) +void IntermissionMapPositionInfo::Copy(const IntermissionMapPositionInfo &src) { name_ = src.name_; x_ = src.x_; @@ -345,7 +345,7 @@ void IntermissionMapPositionInfo::Copy(IntermissionMapPositionInfo &src) // // wi_mapposdef_c assignment operator // -IntermissionMapPositionInfo &IntermissionMapPositionInfo::operator=(IntermissionMapPositionInfo &rhs) +IntermissionMapPositionInfo &IntermissionMapPositionInfo::operator=(const IntermissionMapPositionInfo &rhs) { if (&rhs != this) Copy(rhs); @@ -365,7 +365,7 @@ IntermissionMapPositionInfoContainer::IntermissionMapPositionInfoContainer() // // wi_mapposdef_container_c Copy constructor // -IntermissionMapPositionInfoContainer::IntermissionMapPositionInfoContainer(IntermissionMapPositionInfoContainer &rhs) +IntermissionMapPositionInfoContainer::IntermissionMapPositionInfoContainer(const IntermissionMapPositionInfoContainer &rhs) : std::vector() { Copy(rhs); @@ -388,7 +388,7 @@ IntermissionMapPositionInfoContainer::~IntermissionMapPositionInfoContainer() // // wi_mapposdef_container_c::Copy() // -void IntermissionMapPositionInfoContainer::Copy(IntermissionMapPositionInfoContainer &src) +void IntermissionMapPositionInfoContainer::Copy(const IntermissionMapPositionInfoContainer &src) { for (IntermissionMapPositionInfo *wi : src) { @@ -404,7 +404,7 @@ void IntermissionMapPositionInfoContainer::Copy(IntermissionMapPositionInfoConta // wi_mapposdef_container_c assignment operator // IntermissionMapPositionInfoContainer &IntermissionMapPositionInfoContainer::operator=( - IntermissionMapPositionInfoContainer &rhs) + const IntermissionMapPositionInfoContainer &rhs) { if (&rhs != this) { @@ -435,7 +435,7 @@ IntermissionFrameInfo::IntermissionFrameInfo() // // wi_framedef_c Copy constructor // -IntermissionFrameInfo::IntermissionFrameInfo(IntermissionFrameInfo &rhs) +IntermissionFrameInfo::IntermissionFrameInfo(const IntermissionFrameInfo &rhs) { Copy(rhs); } @@ -450,7 +450,7 @@ IntermissionFrameInfo::~IntermissionFrameInfo() // // wi_framedef_c::Copy() // -void IntermissionFrameInfo::Copy(IntermissionFrameInfo &src) +void IntermissionFrameInfo::Copy(const IntermissionFrameInfo &src) { pic_ = src.pic_; tics_ = src.tics_; @@ -471,7 +471,7 @@ void IntermissionFrameInfo::Default() // // wi_framedef_c assignment operator // -IntermissionFrameInfo &IntermissionFrameInfo::operator=(IntermissionFrameInfo &rhs) +IntermissionFrameInfo &IntermissionFrameInfo::operator=(const IntermissionFrameInfo &rhs) { if (&rhs != this) Copy(rhs); @@ -491,7 +491,7 @@ IntermissionFrameInfoContainer::IntermissionFrameInfoContainer() // // wi_framedef_container_c Copy constructor // -IntermissionFrameInfoContainer::IntermissionFrameInfoContainer(IntermissionFrameInfoContainer &rhs) +IntermissionFrameInfoContainer::IntermissionFrameInfoContainer(const IntermissionFrameInfoContainer &rhs) : std::vector() { Copy(rhs); @@ -513,7 +513,7 @@ IntermissionFrameInfoContainer::~IntermissionFrameInfoContainer() // // wi_framedef_container_c::Copy() // -void IntermissionFrameInfoContainer::Copy(IntermissionFrameInfoContainer &src) +void IntermissionFrameInfoContainer::Copy(const IntermissionFrameInfoContainer &src) { for (IntermissionFrameInfo *f : src) { @@ -528,7 +528,7 @@ void IntermissionFrameInfoContainer::Copy(IntermissionFrameInfoContainer &src) // // wi_framedef_container_c assignment operator // -IntermissionFrameInfoContainer &IntermissionFrameInfoContainer::operator=(IntermissionFrameInfoContainer &rhs) +IntermissionFrameInfoContainer &IntermissionFrameInfoContainer::operator=(const IntermissionFrameInfoContainer &rhs) { if (&rhs != this) { @@ -558,7 +558,7 @@ IntermissionAnimationInfo::IntermissionAnimationInfo() // // wi_animdef_c Copy constructor // -IntermissionAnimationInfo::IntermissionAnimationInfo(IntermissionAnimationInfo &rhs) +IntermissionAnimationInfo::IntermissionAnimationInfo(const IntermissionAnimationInfo &rhs) { Copy(rhs); } @@ -573,7 +573,7 @@ IntermissionAnimationInfo::~IntermissionAnimationInfo() // // void Copy() // -void IntermissionAnimationInfo::Copy(IntermissionAnimationInfo &src) +void IntermissionAnimationInfo::Copy(const IntermissionAnimationInfo &src) { type_ = src.type_; level_ = src.level_; @@ -599,7 +599,7 @@ void IntermissionAnimationInfo::Default() // // wi_animdef_c assignment operator // -IntermissionAnimationInfo &IntermissionAnimationInfo::operator=(IntermissionAnimationInfo &rhs) +IntermissionAnimationInfo &IntermissionAnimationInfo::operator=(const IntermissionAnimationInfo &rhs) { if (&rhs != this) Copy(rhs); @@ -619,7 +619,7 @@ IntermissionAnimationInfoContainer::IntermissionAnimationInfoContainer() // // wi_animdef_container_c Copy constructor // -IntermissionAnimationInfoContainer::IntermissionAnimationInfoContainer(IntermissionAnimationInfoContainer &rhs) +IntermissionAnimationInfoContainer::IntermissionAnimationInfoContainer(const IntermissionAnimationInfoContainer &rhs) : std::vector() { Copy(rhs); @@ -641,7 +641,7 @@ IntermissionAnimationInfoContainer::~IntermissionAnimationInfoContainer() // // wi_animdef_container_c::Copy() // -void IntermissionAnimationInfoContainer::Copy(IntermissionAnimationInfoContainer &src) +void IntermissionAnimationInfoContainer::Copy(const IntermissionAnimationInfoContainer &src) { for (IntermissionAnimationInfo *a : src) { @@ -657,7 +657,7 @@ void IntermissionAnimationInfoContainer::Copy(IntermissionAnimationInfoContainer // wi_animdef_container_c assignment operator // IntermissionAnimationInfoContainer &IntermissionAnimationInfoContainer::operator=( - IntermissionAnimationInfoContainer &rhs) + const IntermissionAnimationInfoContainer &rhs) { if (&rhs != this) { @@ -695,7 +695,7 @@ GameDefinition::~GameDefinition() // // gamedef_c::CopyDetail() // -void GameDefinition::CopyDetail(GameDefinition &src) +void GameDefinition::CopyDetail(const GameDefinition &src) { anims_ = src.anims_; mappos_ = src.mappos_; diff --git a/source_files/ddf/ddf_game.h b/source_files/ddf/ddf_game.h index 936074be1..a9e404f26 100644 --- a/source_files/ddf/ddf_game.h +++ b/source_files/ddf/ddf_game.h @@ -30,28 +30,28 @@ class IntermissionMapPositionInfo public: IntermissionMapPositionInfo(); - IntermissionMapPositionInfo(IntermissionMapPositionInfo &rhs); + IntermissionMapPositionInfo(const IntermissionMapPositionInfo &rhs); ~IntermissionMapPositionInfo(); public: - IntermissionMapPositionInfo &operator=(IntermissionMapPositionInfo &rhs); + IntermissionMapPositionInfo &operator=(const IntermissionMapPositionInfo &rhs); private: - void Copy(IntermissionMapPositionInfo &src); + void Copy(const IntermissionMapPositionInfo &src); }; class IntermissionMapPositionInfoContainer : public std::vector { public: IntermissionMapPositionInfoContainer(); - IntermissionMapPositionInfoContainer(IntermissionMapPositionInfoContainer &rhs); + IntermissionMapPositionInfoContainer(const IntermissionMapPositionInfoContainer &rhs); ~IntermissionMapPositionInfoContainer(); private: - void Copy(IntermissionMapPositionInfoContainer &src); + void Copy(const IntermissionMapPositionInfoContainer &src); public: - IntermissionMapPositionInfoContainer &operator=(IntermissionMapPositionInfoContainer &rhs); + IntermissionMapPositionInfoContainer &operator=(const IntermissionMapPositionInfoContainer &rhs); }; class IntermissionFrameInfo @@ -63,29 +63,29 @@ class IntermissionFrameInfo public: IntermissionFrameInfo(); - IntermissionFrameInfo(IntermissionFrameInfo &rhs); + IntermissionFrameInfo(const IntermissionFrameInfo &rhs); ~IntermissionFrameInfo(); public: void Default(void); - IntermissionFrameInfo &operator=(IntermissionFrameInfo &rhs); + IntermissionFrameInfo &operator=(const IntermissionFrameInfo &rhs); private: - void Copy(IntermissionFrameInfo &src); + void Copy(const IntermissionFrameInfo &src); }; class IntermissionFrameInfoContainer : public std::vector { public: IntermissionFrameInfoContainer(); - IntermissionFrameInfoContainer(IntermissionFrameInfoContainer &rhs); + IntermissionFrameInfoContainer(const IntermissionFrameInfoContainer &rhs); ~IntermissionFrameInfoContainer(); private: - void Copy(IntermissionFrameInfoContainer &rhs); + void Copy(const IntermissionFrameInfoContainer &rhs); public: - IntermissionFrameInfoContainer &operator=(IntermissionFrameInfoContainer &rhs); + IntermissionFrameInfoContainer &operator=(const IntermissionFrameInfoContainer &rhs); }; class IntermissionAnimationInfo @@ -105,29 +105,29 @@ class IntermissionAnimationInfo public: IntermissionAnimationInfo(); - IntermissionAnimationInfo(IntermissionAnimationInfo &rhs); + IntermissionAnimationInfo(const IntermissionAnimationInfo &rhs); ~IntermissionAnimationInfo(); public: - IntermissionAnimationInfo &operator=(IntermissionAnimationInfo &rhs); + IntermissionAnimationInfo &operator=(const IntermissionAnimationInfo &rhs); void Default(void); private: - void Copy(IntermissionAnimationInfo &rhs); + void Copy(const IntermissionAnimationInfo &rhs); }; class IntermissionAnimationInfoContainer : public std::vector { public: IntermissionAnimationInfoContainer(); - IntermissionAnimationInfoContainer(IntermissionAnimationInfoContainer &rhs); + IntermissionAnimationInfoContainer(const IntermissionAnimationInfoContainer &rhs); ~IntermissionAnimationInfoContainer(); private: - void Copy(IntermissionAnimationInfoContainer &src); + void Copy(const IntermissionAnimationInfoContainer &src); public: - IntermissionAnimationInfoContainer &operator=(IntermissionAnimationInfoContainer &rhs); + IntermissionAnimationInfoContainer &operator=(const IntermissionAnimationInfoContainer &rhs); }; enum LightingModel @@ -153,7 +153,7 @@ class GameDefinition public: void Default(void); - void CopyDetail(GameDefinition &src); + void CopyDetail(const GameDefinition &src); std::string name_; @@ -199,11 +199,11 @@ class GameDefinition private: // disable copy construct and assignment operator - explicit GameDefinition(GameDefinition &rhs) + explicit GameDefinition(const GameDefinition &rhs) { EPI_UNUSED(rhs); } - GameDefinition &operator=(GameDefinition &rhs) + GameDefinition &operator=(const GameDefinition &rhs) { EPI_UNUSED(rhs); return *this; diff --git a/source_files/ddf/ddf_level.cc b/source_files/ddf/ddf_level.cc index b1e7f2711..dc974425a 100644 --- a/source_files/ddf/ddf_level.cc +++ b/source_files/ddf/ddf_level.cc @@ -356,7 +356,7 @@ FinaleDefinition::FinaleDefinition() : pics_() Default(); } -FinaleDefinition::FinaleDefinition(FinaleDefinition &rhs) : pics_() +FinaleDefinition::FinaleDefinition(const FinaleDefinition &rhs) : pics_() { Copy(rhs); } @@ -365,7 +365,7 @@ FinaleDefinition::~FinaleDefinition() { } -void FinaleDefinition::Copy(FinaleDefinition &src) +void FinaleDefinition::Copy(const FinaleDefinition &src) { text_ = src.text_; @@ -404,7 +404,7 @@ void FinaleDefinition::Default() music_ = 0; } -FinaleDefinition &FinaleDefinition::operator=(FinaleDefinition &rhs) +FinaleDefinition &FinaleDefinition::operator=(const FinaleDefinition &rhs) { if (&rhs != this) Copy(rhs); @@ -423,7 +423,7 @@ MapDefinition::~MapDefinition() { } -void MapDefinition::CopyDetail(MapDefinition &src) +void MapDefinition::CopyDetail(const MapDefinition &src) { description_ = src.description_; namegraphic_ = src.namegraphic_; diff --git a/source_files/ddf/ddf_level.h b/source_files/ddf/ddf_level.h index 7e9164ada..24a7607a3 100644 --- a/source_files/ddf/ddf_level.h +++ b/source_files/ddf/ddf_level.h @@ -28,15 +28,15 @@ class FinaleDefinition { public: FinaleDefinition(); - FinaleDefinition(FinaleDefinition &rhs); + FinaleDefinition(const FinaleDefinition &rhs); ~FinaleDefinition(); private: - void Copy(FinaleDefinition &src); + void Copy(const FinaleDefinition &src); public: void Default(void); - FinaleDefinition &operator=(FinaleDefinition &rhs); + FinaleDefinition &operator=(const FinaleDefinition &rhs); // Text std::string text_; @@ -115,7 +115,7 @@ class MapDefinition public: void Default(void); - void CopyDetail(MapDefinition &src); + void CopyDetail(const MapDefinition &src); // Member vars.... std::string name_; diff --git a/source_files/ddf/ddf_line.cc b/source_files/ddf/ddf_line.cc index ce49b1d3c..4405093e9 100644 --- a/source_files/ddf/ddf_line.cc +++ b/source_files/ddf/ddf_line.cc @@ -1043,7 +1043,7 @@ DonutDefinition::DonutDefinition() // // donutdef_c Copy constructor // -DonutDefinition::DonutDefinition(DonutDefinition &rhs) +DonutDefinition::DonutDefinition(const DonutDefinition &rhs) { Copy(rhs); } @@ -1058,7 +1058,7 @@ DonutDefinition::~DonutDefinition() // // donutdef_c::Copy() // -void DonutDefinition::Copy(DonutDefinition &src) +void DonutDefinition::Copy(const DonutDefinition &src) { dodonut_ = src.dodonut_; @@ -1085,7 +1085,7 @@ void DonutDefinition::Default() // // donutdef_c assignment operator // -DonutDefinition &DonutDefinition::operator=(DonutDefinition &rhs) +DonutDefinition &DonutDefinition::operator=(const DonutDefinition &rhs) { if (&rhs != this) Copy(rhs); @@ -1105,7 +1105,7 @@ ExtraFloorDefinition::ExtraFloorDefinition() // // extrafloordef_c Copy constructor // -ExtraFloorDefinition::ExtraFloorDefinition(ExtraFloorDefinition &rhs) +ExtraFloorDefinition::ExtraFloorDefinition(const ExtraFloorDefinition &rhs) { Copy(rhs); } @@ -1120,7 +1120,7 @@ ExtraFloorDefinition::~ExtraFloorDefinition() // // extrafloordef_c::Copy() // -void ExtraFloorDefinition::Copy(ExtraFloorDefinition &src) +void ExtraFloorDefinition::Copy(const ExtraFloorDefinition &src) { control_ = src.control_; type_ = src.type_; @@ -1138,7 +1138,7 @@ void ExtraFloorDefinition::Default() // // extrafloordef_c assignment operator // -ExtraFloorDefinition &ExtraFloorDefinition::operator=(ExtraFloorDefinition &rhs) +ExtraFloorDefinition &ExtraFloorDefinition::operator=(const ExtraFloorDefinition &rhs) { if (&rhs != this) Copy(rhs); @@ -1158,7 +1158,7 @@ LadderDefinition::LadderDefinition() // // ladderdef_c Copy constructor // -LadderDefinition::LadderDefinition(LadderDefinition &rhs) +LadderDefinition::LadderDefinition(const LadderDefinition &rhs) { Copy(rhs); } @@ -1173,7 +1173,7 @@ LadderDefinition::~LadderDefinition() // // ladderdef_c::Copy() // -void LadderDefinition::Copy(LadderDefinition &src) +void LadderDefinition::Copy(const LadderDefinition &src) { height_ = src.height_; } @@ -1189,7 +1189,7 @@ void LadderDefinition::Default() // // ladderdef_c assignment operator // -LadderDefinition &LadderDefinition::operator=(LadderDefinition &rhs) +LadderDefinition &LadderDefinition::operator=(const LadderDefinition &rhs) { if (&rhs != this) Copy(rhs); @@ -1209,7 +1209,7 @@ LightSpecialDefinition::LightSpecialDefinition() // // lightdef_c Copy constructor // -LightSpecialDefinition::LightSpecialDefinition(LightSpecialDefinition &rhs) +LightSpecialDefinition::LightSpecialDefinition(const LightSpecialDefinition &rhs) { Copy(rhs); } @@ -1224,7 +1224,7 @@ LightSpecialDefinition::~LightSpecialDefinition() // // lightdef_c::Copy() // -void LightSpecialDefinition::Copy(LightSpecialDefinition &src) +void LightSpecialDefinition::Copy(const LightSpecialDefinition &src) { type_ = src.type_; level_ = src.level_; @@ -1252,7 +1252,7 @@ void LightSpecialDefinition::Default() // // lightdef_c assignment operator // -LightSpecialDefinition &LightSpecialDefinition::operator=(LightSpecialDefinition &rhs) +LightSpecialDefinition &LightSpecialDefinition::operator=(const LightSpecialDefinition &rhs) { if (&rhs != this) Copy(rhs); @@ -1272,7 +1272,7 @@ PlaneMoverDefinition::PlaneMoverDefinition() // // movplanedef_c Copy constructor // -PlaneMoverDefinition::PlaneMoverDefinition(PlaneMoverDefinition &rhs) +PlaneMoverDefinition::PlaneMoverDefinition(const PlaneMoverDefinition &rhs) { Copy(rhs); } @@ -1287,7 +1287,7 @@ PlaneMoverDefinition::~PlaneMoverDefinition() // // movplanedef_c::Copy() // -void PlaneMoverDefinition::Copy(PlaneMoverDefinition &src) +void PlaneMoverDefinition::Copy(const PlaneMoverDefinition &src) { type_ = src.type_; is_ceiling_ = src.is_ceiling_; @@ -1392,7 +1392,7 @@ void PlaneMoverDefinition::Default(PlaneMoverDefinition::PlaneMoverDefault def) // // movplanedef_c assignment operator // -PlaneMoverDefinition &PlaneMoverDefinition::operator=(PlaneMoverDefinition &rhs) +PlaneMoverDefinition &PlaneMoverDefinition::operator=(const PlaneMoverDefinition &rhs) { if (&rhs != this) Copy(rhs); @@ -1412,7 +1412,7 @@ SlidingDoor::SlidingDoor() // // sliding_door_c Copy constructor // -SlidingDoor::SlidingDoor(SlidingDoor &rhs) +SlidingDoor::SlidingDoor(const SlidingDoor &rhs) { Copy(rhs); } @@ -1427,7 +1427,7 @@ SlidingDoor::~SlidingDoor() // // sliding_door_c::Copy() // -void SlidingDoor::Copy(SlidingDoor &src) +void SlidingDoor::Copy(const SlidingDoor &src) { type_ = src.type_; speed_ = src.speed_; @@ -1459,7 +1459,7 @@ void SlidingDoor::Default() // // sliding_door_c assignment operator // -SlidingDoor &SlidingDoor::operator=(SlidingDoor &rhs) +SlidingDoor &SlidingDoor::operator=(const SlidingDoor &rhs) { if (&rhs != this) Copy(rhs); @@ -1479,7 +1479,7 @@ TeleportDefinition::TeleportDefinition() // // teleportdef_c Copy constructor // -TeleportDefinition::TeleportDefinition(TeleportDefinition &rhs) +TeleportDefinition::TeleportDefinition(const TeleportDefinition &rhs) { Copy(rhs); } @@ -1494,7 +1494,7 @@ TeleportDefinition::~TeleportDefinition() // // teleportdef_c::Copy() // -void TeleportDefinition::Copy(TeleportDefinition &src) +void TeleportDefinition::Copy(const TeleportDefinition &src) { teleport_ = src.teleport_; @@ -1528,7 +1528,7 @@ void TeleportDefinition::Default() // // teleportdef_c assignment operator // -TeleportDefinition &TeleportDefinition::operator=(TeleportDefinition &rhs) +TeleportDefinition &TeleportDefinition::operator=(const TeleportDefinition &rhs) { if (&rhs != this) Copy(rhs); @@ -1553,7 +1553,7 @@ LineType::~LineType() { } -void LineType::CopyDetail(LineType &src) +void LineType::CopyDetail(const LineType &src) { newtrignum_ = src.newtrignum_; type_ = src.type_; diff --git a/source_files/ddf/ddf_line.h b/source_files/ddf/ddf_line.h index d3569add2..e36a3be1a 100644 --- a/source_files/ddf/ddf_line.h +++ b/source_files/ddf/ddf_line.h @@ -181,15 +181,15 @@ class ExtraFloorDefinition { public: ExtraFloorDefinition(); - ExtraFloorDefinition(ExtraFloorDefinition &rhs); + ExtraFloorDefinition(const ExtraFloorDefinition &rhs); ~ExtraFloorDefinition(); private: - void Copy(ExtraFloorDefinition &src); + void Copy(const ExtraFloorDefinition &src); public: void Default(void); - ExtraFloorDefinition &operator=(ExtraFloorDefinition &src); + ExtraFloorDefinition &operator=(const ExtraFloorDefinition &src); ExtraFloorType type_; ExtraFloorControl control_; @@ -199,7 +199,7 @@ class PlaneMoverDefinition { public: PlaneMoverDefinition(); - PlaneMoverDefinition(PlaneMoverDefinition &rhs); + PlaneMoverDefinition(const PlaneMoverDefinition &rhs); ~PlaneMoverDefinition(); enum PlaneMoverDefault @@ -213,11 +213,11 @@ class PlaneMoverDefinition }; private: - void Copy(PlaneMoverDefinition &src); + void Copy(const PlaneMoverDefinition &src); public: void Default(PlaneMoverDefault def); - PlaneMoverDefinition &operator=(PlaneMoverDefinition &rhs); + PlaneMoverDefinition &operator=(const PlaneMoverDefinition &rhs); // Type of floor: raise/lower/etc PlaneMoverType type_; @@ -286,15 +286,15 @@ class SlidingDoor { public: SlidingDoor(); - SlidingDoor(SlidingDoor &rhs); + SlidingDoor(const SlidingDoor &rhs); ~SlidingDoor(); private: - void Copy(SlidingDoor &src); + void Copy(const SlidingDoor &src); public: void Default(void); - SlidingDoor &operator=(SlidingDoor &rhs); + SlidingDoor &operator=(const SlidingDoor &rhs); // type of slider, normally kSlidingDoorTypeNone SlidingDoorType type_; @@ -323,15 +323,15 @@ class DonutDefinition { public: DonutDefinition(); - DonutDefinition(DonutDefinition &rhs); + DonutDefinition(const DonutDefinition &rhs); ~DonutDefinition(); private: - void Copy(DonutDefinition &src); + void Copy(const DonutDefinition &src); public: void Default(void); - DonutDefinition &operator=(DonutDefinition &rhs); + DonutDefinition &operator=(const DonutDefinition &rhs); // Do Donut? @@ -372,15 +372,15 @@ class TeleportDefinition { public: TeleportDefinition(); - TeleportDefinition(TeleportDefinition &rhs); + TeleportDefinition(const TeleportDefinition &rhs); ~TeleportDefinition(); private: - void Copy(TeleportDefinition &src); + void Copy(const TeleportDefinition &src); public: void Default(void); - TeleportDefinition &operator=(TeleportDefinition &rhs); + TeleportDefinition &operator=(const TeleportDefinition &rhs); // If true, teleport activator // @@ -427,15 +427,15 @@ class LightSpecialDefinition { public: LightSpecialDefinition(); - LightSpecialDefinition(LightSpecialDefinition &rhs); + LightSpecialDefinition(const LightSpecialDefinition &rhs); ~LightSpecialDefinition(); private: - void Copy(LightSpecialDefinition &src); + void Copy(const LightSpecialDefinition &src); public: void Default(void); - LightSpecialDefinition &operator=(LightSpecialDefinition &rhs); + LightSpecialDefinition &operator=(const LightSpecialDefinition &rhs); LightSpecialType type_; @@ -460,15 +460,15 @@ class LadderDefinition { public: LadderDefinition(); - LadderDefinition(LadderDefinition &rhs); + LadderDefinition(const LadderDefinition &rhs); ~LadderDefinition(); private: - void Copy(LadderDefinition &src); + void Copy(const LadderDefinition &src); public: void Default(void); - LadderDefinition &operator=(LadderDefinition &rhs); + LadderDefinition &operator=(const LadderDefinition &rhs); // height of ladder itself. Zero or negative disables. Bottom of // ladder comes from Y_OFFSET on the linedef. @@ -602,7 +602,7 @@ class LineType public: void Default(void); - void CopyDetail(LineType &src); + void CopyDetail(const LineType &src); // Member vars.... int number_; @@ -796,7 +796,7 @@ class SectorType public: void Default(void); - void CopyDetail(SectorType &src); + void CopyDetail(const SectorType &src); // Member vars.... int number_; diff --git a/source_files/ddf/ddf_main.cc b/source_files/ddf/ddf_main.cc index 5e1228e61..b5a7fc48f 100644 --- a/source_files/ddf/ddf_main.cc +++ b/source_files/ddf/ddf_main.cc @@ -865,7 +865,7 @@ void DDFMainReadFile(DDFReadInfo *readinfo, const std::string &data) case kDDFReadCharReturnCommand: if (!token.empty()) - current_cmd = token.c_str(); + current_cmd = token; else current_cmd.clear(); @@ -1741,7 +1741,7 @@ DamageClass::DamageClass() // // DamageClass Copy constructor // -DamageClass::DamageClass(DamageClass &rhs) +DamageClass::DamageClass(const DamageClass &rhs) { Copy(rhs); } @@ -1756,7 +1756,7 @@ DamageClass::~DamageClass() // // DamageClass::Copy // -void DamageClass::Copy(DamageClass &src) +void DamageClass::Copy(const DamageClass &src) { nominal_ = src.nominal_; linear_max_ = src.linear_max_; @@ -1856,7 +1856,7 @@ void DamageClass::Default(DamageClassDefault def) // // DamageClass assignment operator // -DamageClass &DamageClass::operator=(DamageClass &rhs) +DamageClass &DamageClass::operator=(const DamageClass &rhs) { if (&rhs != this) Copy(rhs); @@ -1877,7 +1877,7 @@ LabelOffset::LabelOffset() // // LabelOffset Copy constructor // -LabelOffset::LabelOffset(LabelOffset &rhs) +LabelOffset::LabelOffset(const LabelOffset &rhs) { Copy(rhs); } @@ -1892,7 +1892,7 @@ LabelOffset::~LabelOffset() // // LabelOffset::Copy // -void LabelOffset::Copy(LabelOffset &src) +void LabelOffset::Copy(const LabelOffset &src) { label_ = src.label_; offset_ = src.offset_; @@ -1910,7 +1910,7 @@ void LabelOffset::Default() // // LabelOffset assignment operator // -LabelOffset &LabelOffset::operator=(LabelOffset &rhs) +LabelOffset &LabelOffset::operator=(const LabelOffset &rhs) { if (&rhs != this) Copy(rhs); @@ -1925,12 +1925,12 @@ DynamicLightDefinition::DynamicLightDefinition() Default(); } -DynamicLightDefinition::DynamicLightDefinition(DynamicLightDefinition &rhs) +DynamicLightDefinition::DynamicLightDefinition(const DynamicLightDefinition &rhs) { Copy(rhs); } -void DynamicLightDefinition::Copy(DynamicLightDefinition &src) +void DynamicLightDefinition::Copy(const DynamicLightDefinition &src) { type_ = src.type_; shape_ = src.shape_; @@ -1958,7 +1958,7 @@ void DynamicLightDefinition::Default() cache_data_ = nullptr; } -DynamicLightDefinition &DynamicLightDefinition::operator=(DynamicLightDefinition &rhs) +DynamicLightDefinition &DynamicLightDefinition::operator=(const DynamicLightDefinition &rhs) { if (this == &rhs) return *this; @@ -1975,12 +1975,12 @@ WeaknessDefinition::WeaknessDefinition() Default(); } -WeaknessDefinition::WeaknessDefinition(WeaknessDefinition &rhs) +WeaknessDefinition::WeaknessDefinition(const WeaknessDefinition &rhs) { Copy(rhs); } -void WeaknessDefinition::Copy(WeaknessDefinition &src) +void WeaknessDefinition::Copy(const WeaknessDefinition &src) { height_[0] = src.height_[0]; height_[1] = src.height_[1]; @@ -2005,7 +2005,7 @@ void WeaknessDefinition::Default() painchance_ = -1; // disabled } -WeaknessDefinition &WeaknessDefinition::operator=(WeaknessDefinition &rhs) +WeaknessDefinition &WeaknessDefinition::operator=(const WeaknessDefinition &rhs) { if (this == &rhs) return *this; diff --git a/source_files/ddf/ddf_playlist.cc b/source_files/ddf/ddf_playlist.cc index c0d82f0f2..0e83dd478 100644 --- a/source_files/ddf/ddf_playlist.cc +++ b/source_files/ddf/ddf_playlist.cc @@ -253,7 +253,7 @@ PlaylistEntry::~PlaylistEntry() // // Copy everything with exception ddf identifier // -void PlaylistEntry::CopyDetail(PlaylistEntry &src) +void PlaylistEntry::CopyDetail(const PlaylistEntry &src) { type_ = src.type_; infotype_ = src.infotype_; diff --git a/source_files/ddf/ddf_playlist.h b/source_files/ddf/ddf_playlist.h index 2ac530260..3b61bba30 100644 --- a/source_files/ddf/ddf_playlist.h +++ b/source_files/ddf/ddf_playlist.h @@ -61,7 +61,7 @@ class PlaylistEntry public: void Default(void); - void CopyDetail(PlaylistEntry &src); + void CopyDetail(const PlaylistEntry &src); // Member vars.... int number_; diff --git a/source_files/ddf/ddf_sector.cc b/source_files/ddf/ddf_sector.cc index d18b9b730..d9519cbe8 100644 --- a/source_files/ddf/ddf_sector.cc +++ b/source_files/ddf/ddf_sector.cc @@ -449,7 +449,7 @@ SectorType::~SectorType() // // SectorType::CopyDetail() // -void SectorType::CopyDetail(SectorType &src) +void SectorType::CopyDetail(const SectorType &src) { secret_ = src.secret_; hub_ = src.hub_; diff --git a/source_files/ddf/ddf_sfx.cc b/source_files/ddf/ddf_sfx.cc index aa79a6985..b18cac526 100644 --- a/source_files/ddf/ddf_sfx.cc +++ b/source_files/ddf/ddf_sfx.cc @@ -192,7 +192,7 @@ SoundEffectDefinition::~SoundEffectDefinition() // // SoundEffectDefinition::CopyDetail() // -void SoundEffectDefinition::CopyDetail(SoundEffectDefinition &src) +void SoundEffectDefinition::CopyDetail(const SoundEffectDefinition &src) { lump_name_ = src.lump_name_; pc_speaker_sound_ = src.pc_speaker_sound_; diff --git a/source_files/ddf/ddf_sfx.h b/source_files/ddf/ddf_sfx.h index f593fda8c..55e82b432 100644 --- a/source_files/ddf/ddf_sfx.h +++ b/source_files/ddf/ddf_sfx.h @@ -42,7 +42,7 @@ class SoundEffectDefinition public: void Default(void); - void CopyDetail(SoundEffectDefinition &src); + void CopyDetail(const SoundEffectDefinition &src); // Member vars.... std::string name_; diff --git a/source_files/ddf/ddf_switch.cc b/source_files/ddf/ddf_switch.cc index 4d76107c9..bda7097d2 100644 --- a/source_files/ddf/ddf_switch.cc +++ b/source_files/ddf/ddf_switch.cc @@ -176,7 +176,7 @@ SwitchDefinition::SwitchDefinition() : name_() // // Copies all the detail with the exception of ddf info // -void SwitchDefinition::CopyDetail(SwitchDefinition &src) +void SwitchDefinition::CopyDetail(const SwitchDefinition &src) { on_name_ = src.on_name_; off_name_ = src.off_name_; diff --git a/source_files/ddf/ddf_switch.h b/source_files/ddf/ddf_switch.h index 23c3822ab..f7ea7aa7f 100644 --- a/source_files/ddf/ddf_switch.h +++ b/source_files/ddf/ddf_switch.h @@ -35,7 +35,7 @@ class SwitchDefinition public: void Default(void); - void CopyDetail(SwitchDefinition &src); + void CopyDetail(const SwitchDefinition &src); // Member vars.... std::string name_; diff --git a/source_files/ddf/ddf_thing.cc b/source_files/ddf/ddf_thing.cc index 516e0f9aa..c156d34fb 100644 --- a/source_files/ddf/ddf_thing.cc +++ b/source_files/ddf/ddf_thing.cc @@ -642,7 +642,7 @@ static void ThingStartEntry(const char *buffer, bool extend) { // not found, create a new one dynamic_mobj = new MapObjectDefinition; - dynamic_mobj->name_ = name.c_str(); + dynamic_mobj->name_ = name; dynamic_mobj->number_ = number; mobjtypes.push_back(dynamic_mobj); @@ -2338,7 +2338,7 @@ MapObjectDefinition::~MapObjectDefinition() { } -void MapObjectDefinition::CopyDetail(MapObjectDefinition &src) +void MapObjectDefinition::CopyDetail(const MapObjectDefinition &src) { state_grp_.clear(); diff --git a/source_files/ddf/ddf_thing.h b/source_files/ddf/ddf_thing.h index 44827cad7..3dced505a 100644 --- a/source_files/ddf/ddf_thing.h +++ b/source_files/ddf/ddf_thing.h @@ -658,15 +658,15 @@ class DynamicLightDefinition { public: DynamicLightDefinition(); - DynamicLightDefinition(DynamicLightDefinition &rhs); + DynamicLightDefinition(const DynamicLightDefinition &rhs); ~DynamicLightDefinition() {}; private: - void Copy(DynamicLightDefinition &src); + void Copy(const DynamicLightDefinition &src); public: void Default(void); - DynamicLightDefinition &operator=(DynamicLightDefinition &rhs); + DynamicLightDefinition &operator=(const DynamicLightDefinition &rhs); DynamicLightType type_; std::string shape_; // IMAGES.DDF reference @@ -684,15 +684,15 @@ class WeaknessDefinition { public: WeaknessDefinition(); - WeaknessDefinition(WeaknessDefinition &rhs); + WeaknessDefinition(const WeaknessDefinition &rhs); ~WeaknessDefinition() {}; private: - void Copy(WeaknessDefinition &src); + void Copy(const WeaknessDefinition &src); public: void Default(void); - WeaknessDefinition &operator=(WeaknessDefinition &rhs); + WeaknessDefinition &operator=(const WeaknessDefinition &rhs); float height_[2]; BAMAngle angle_[2]; @@ -895,7 +895,7 @@ class MapObjectDefinition public: void Default(); - void CopyDetail(MapObjectDefinition &src); + void CopyDetail(const MapObjectDefinition &src); void DLightCompatibility(void); diff --git a/source_files/ddf/ddf_types.h b/source_files/ddf/ddf_types.h index 984d604f7..b68db497b 100644 --- a/source_files/ddf/ddf_types.h +++ b/source_files/ddf/ddf_types.h @@ -131,15 +131,15 @@ class LabelOffset { public: LabelOffset(); - LabelOffset(LabelOffset &rhs); + LabelOffset(const LabelOffset &rhs); ~LabelOffset(); private: - void Copy(LabelOffset &src); + void Copy(const LabelOffset &src); public: void Default(); - LabelOffset &operator=(LabelOffset &rhs); + LabelOffset &operator=(const LabelOffset &rhs); std::string label_; int offset_; @@ -149,7 +149,7 @@ class DamageClass { public: DamageClass(); - DamageClass(DamageClass &rhs); + DamageClass(const DamageClass &rhs); ~DamageClass(); enum DamageClassDefault @@ -162,11 +162,11 @@ class DamageClass }; private: - void Copy(DamageClass &src); + void Copy(const DamageClass &src); public: void Default(DamageClassDefault def); - DamageClass &operator=(DamageClass &rhs); + DamageClass &operator=(const DamageClass &rhs); // nominal damage amount (required) float nominal_; @@ -265,7 +265,7 @@ class AttackDefinition public: void Default(); - void CopyDetail(AttackDefinition &src); + void CopyDetail(const AttackDefinition &src); // Member vars std::string name_; @@ -473,7 +473,7 @@ class WeaponDefinition public: void Default(void); - void CopyDetail(WeaponDefinition &src); + void CopyDetail(const WeaponDefinition &src); // Weapon's name, etc... std::string name_; diff --git a/source_files/ddf/ddf_wadfixes.cc b/source_files/ddf/ddf_wadfixes.cc index a7f993ca2..83bbb711f 100644 --- a/source_files/ddf/ddf_wadfixes.cc +++ b/source_files/ddf/ddf_wadfixes.cc @@ -149,7 +149,7 @@ WadFixDefinition::WadFixDefinition() : name_() // // Copies all the detail with the exception of ddf info // -void WadFixDefinition::CopyDetail(WadFixDefinition &src) +void WadFixDefinition::CopyDetail(const WadFixDefinition &src) { md5_string_ = src.md5_string_; } diff --git a/source_files/ddf/ddf_wadfixes.h b/source_files/ddf/ddf_wadfixes.h index 95f4d169a..62019b36a 100644 --- a/source_files/ddf/ddf_wadfixes.h +++ b/source_files/ddf/ddf_wadfixes.h @@ -28,7 +28,7 @@ class WadFixDefinition public: void Default(void); - void CopyDetail(WadFixDefinition &src); + void CopyDetail(const WadFixDefinition &src); // Member vars.... std::string name_; diff --git a/source_files/ddf/ddf_weapon.cc b/source_files/ddf/ddf_weapon.cc index 289ef89de..1bc37aa60 100644 --- a/source_files/ddf/ddf_weapon.cc +++ b/source_files/ddf/ddf_weapon.cc @@ -1003,7 +1003,7 @@ WeaponDefinition::~WeaponDefinition() // // WeaponDefinition::CopyDetail() // -void WeaponDefinition::CopyDetail(WeaponDefinition &src) +void WeaponDefinition::CopyDetail(const WeaponDefinition &src) { state_grp_.clear(); diff --git a/source_files/dehacked/deh_text.cc b/source_files/dehacked/deh_text.cc index 747aa4f22..fa2299ca8 100644 --- a/source_files/dehacked/deh_text.cc +++ b/source_files/dehacked/deh_text.cc @@ -645,7 +645,7 @@ void text_strings::WriteTextString(const LanguageInfo *info) const char *text_strings::GetLDFForBex(const char *bex_name) { - for (auto entry : lang_list) + for (const dehacked::LanguageInfo &entry : lang_list) { if (entry.deh_name && epi::StringCaseCompareASCII(entry.deh_name, bex_name) == 0) return entry.ldf_name; diff --git a/source_files/dehacked/deh_things.cc b/source_files/dehacked/deh_things.cc index 9bea0e598..fa171c3d6 100644 --- a/source_files/dehacked/deh_things.cc +++ b/source_files/dehacked/deh_things.cc @@ -67,7 +67,7 @@ static constexpr char kExtraFlagNoRaise = 'R'; static constexpr char kExtraFlagNoGrudge = 'G'; static constexpr char kExtraFlagNoItemBk = 'I'; -static constexpr uint8_t kCastMaximum = 20; +static constexpr uint8_t kCastMaximum = 17; extern DehackedMapObjectDefinition mobjinfo[kTotalDehackedMapObjectTypesPortCompatibility]; @@ -1526,7 +1526,7 @@ void HandleItem(const DehackedMapObjectDefinition *info, int mt_num) wad::Printf("PICKUP_SOUND = %s;\n", sounds::GetSound(pu->sound)); } -const char *cast_titles[17] = { +const char *cast_titles[kCastMaximum] = { "OurHeroName", "ZombiemanName", "ShotgunGuyName", "HeavyWeaponDudeName", "ImpName", "DemonName", "LostSoulName", "CacodemonName", "HellKnightName", "BaronOfHellName", "ArachnotronName", "PainElementalName", "RevenantName", "MancubusName", "ArchVileName", "SpiderMastermindName", "CyberdemonName"}; diff --git a/source_files/edge/con_main.cc b/source_files/edge/con_main.cc index 6a831522f..cf9a3eec5 100644 --- a/source_files/edge/con_main.cc +++ b/source_files/edge/con_main.cc @@ -145,7 +145,7 @@ int ConsoleCommandReadme(char **argv, int argc) epi::File *readme_file = nullptr; // Check well known readme filenames - for (auto name : readme_names) + for (const std::string &name : readme_names) { readme_file = OpenFileFromPack(name); if (readme_file) diff --git a/source_files/edge/con_var.cc b/source_files/edge/con_var.cc index 671a67c55..89f178ada 100644 --- a/source_files/edge/con_var.cc +++ b/source_files/edge/con_var.cc @@ -100,20 +100,7 @@ ConsoleVariable &ConsoleVariable::operator=(float value) return *this; } -ConsoleVariable &ConsoleVariable::operator=(const char *value) -{ - s_ = value; - ParseString(); - - if (callback_) - { - callback_(this); - } - modified_++; - return *this; -} - -ConsoleVariable &ConsoleVariable::operator=(std::string value) +ConsoleVariable &ConsoleVariable::operator=(std::string_view value) { s_ = value; ParseString(); diff --git a/source_files/edge/con_var.h b/source_files/edge/con_var.h index 506c5fa13..25a4f05d2 100644 --- a/source_files/edge/con_var.h +++ b/source_files/edge/con_var.h @@ -77,8 +77,7 @@ class ConsoleVariable ConsoleVariable &operator=(int value); ConsoleVariable &operator=(float value); - ConsoleVariable &operator=(const char *value); - ConsoleVariable &operator=(std::string value); + ConsoleVariable &operator=(std::string_view value); inline const char *c_str() const { diff --git a/source_files/edge/e_main.cc b/source_files/edge/e_main.cc index 16fed6141..f5e6ed0b8 100644 --- a/source_files/edge/e_main.cc +++ b/source_files/edge/e_main.cc @@ -845,19 +845,20 @@ static void AutocolourForMapObject(MapObjectDefinition *mobj) const Image *img = ImageLookup(mobj->dlight_.autocolour_reference_.c_str()); if (img) { - const uint8_t *what_palette = (const uint8_t *)&playpal_data[0]; + const uint8_t *what_palette = nullptr; if (img->source_palette_ >= 0) what_palette = (const uint8_t *)LoadLumpIntoMemory(img->source_palette_); ImageData *tmp_img_data = ReadAsEpiBlock((Image *)img); if (tmp_img_data->depth_ == 1) { - ImageData *rgb_img_data = RGBFromPalettised(tmp_img_data, what_palette, img->opacity_); + ImageData *rgb_img_data = RGBFromPalettised(tmp_img_data, what_palette ? what_palette : + (const uint8_t *)&playpal_data[0], img->opacity_); delete tmp_img_data; tmp_img_data = rgb_img_data; } mobj->dlight_.colour_ = tmp_img_data->AverageHue(); delete tmp_img_data; - if (what_palette != (const uint8_t *)&playpal_data[0]) + if (what_palette) delete[] what_palette; mobj->dlight_.autocolour_reference_.clear(); } @@ -878,19 +879,20 @@ static void AutocolourForMapObject(MapObjectDefinition *mobj) } if (img) { - const uint8_t *what_palette = (const uint8_t *)&playpal_data[0]; + const uint8_t *what_palette = nullptr; if (img->source_palette_ >= 0) what_palette = (const uint8_t *)LoadLumpIntoMemory(img->source_palette_); ImageData *tmp_img_data = ReadAsEpiBlock((Image *)img); if (tmp_img_data->depth_ == 1) { - ImageData *rgb_img_data = RGBFromPalettised(tmp_img_data, what_palette, img->opacity_); + ImageData *rgb_img_data = RGBFromPalettised(tmp_img_data, what_palette ? what_palette : + (const uint8_t *)&playpal_data[0], img->opacity_); delete tmp_img_data; tmp_img_data = rgb_img_data; } mobj->dlight_.colour_ = tmp_img_data->AverageHue(); delete tmp_img_data; - if (what_palette != (const uint8_t *)&playpal_data[0]) + if (what_palette) delete[] what_palette; mobj->dlight_.autocolour_sprite_ = -1; } @@ -1322,7 +1324,7 @@ static void PurgeCache(void) // If a valid IWAD (or EDGEGAME) is found, return the appopriate game_base // string ("doom2", "heretic", etc) -static int CheckPackForGameFiles(std::string check_pack, FileKind check_kind) +static int CheckPackForGameFiles(std::string_view check_pack, FileKind check_kind) { DataFile *check_pack_df = new DataFile(check_pack, check_kind); EPI_ASSERT(check_pack_df); @@ -1517,7 +1519,7 @@ static void IdentifyVersion(void) if (!s.empty()) { - for (auto dir : epi::SeparatedStringVector(s, ':')) + for (const std::string &dir : epi::SeparatedStringVector(s, ':')) iwad_dir_vector.push_back(dir); } @@ -1962,7 +1964,7 @@ static void SetupLogAndDebugFiles(void) } } -static void AddSingleCommandLineFile(std::string name, bool ignore_unknown) +static void AddSingleCommandLineFile(const std::string &name, bool ignore_unknown) { if (epi::IsDirectory(name)) { diff --git a/source_files/edge/f_interm.cc b/source_files/edge/f_interm.cc index 7cc704829..0b2418474 100644 --- a/source_files/edge/f_interm.cc +++ b/source_files/edge/f_interm.cc @@ -603,8 +603,8 @@ static void DrawEnteringLevel(void) if (world_intermission.map_positions_[i].done) DrawOnLnode(&world_intermission.map_positions_[i], splat); - if (intermission_pointer_on && !epi::StringCompare(intermission_stats.next_level->name_.c_str(), - world_intermission.map_positions_[i].info->name_.c_str())) + if (intermission_pointer_on && !epi::StringCompare(intermission_stats.next_level->name_, + world_intermission.map_positions_[i].info->name_)) DrawOnLnode(&world_intermission.map_positions_[i], you_are_here); } @@ -913,8 +913,8 @@ static void ShowNextLocationInit(void) for (i = 0; i < world_intermission.total_map_positions_; i++) { - if (epi::StringCompare(world_intermission.map_positions_[i].info->name_.c_str(), - intermission_stats.current_level->name_.c_str()) == 0) + if (epi::StringCompare(world_intermission.map_positions_[i].info->name_, + intermission_stats.current_level->name_) == 0) world_intermission.map_positions_[i].done = true; } @@ -941,8 +941,8 @@ static void DrawShowNextLocation(void) DrawOnLnode(&world_intermission.map_positions_[i], splat); if (intermission_pointer_on && intermission_stats.next_level && - !epi::StringCompare(intermission_stats.next_level->name_.c_str(), - world_intermission.map_positions_[i].info->name_.c_str())) + !epi::StringCompare(intermission_stats.next_level->name_, + world_intermission.map_positions_[i].info->name_)) DrawOnLnode(&world_intermission.map_positions_[i], you_are_here); } } @@ -1836,8 +1836,8 @@ void IntermissionDrawer(void) { if (!intermission_stats.next_level) f = nullptr; - else if (!epi::StringCompare(intermission_stats.next_level->name_.c_str(), - a->info_->level_.c_str())) + else if (!epi::StringCompare(intermission_stats.next_level->name_, + a->info_->level_)) f = &a->frames_[a->frame_on_]; } else diff --git a/source_files/edge/g_game.cc b/source_files/edge/g_game.cc index f12a004a9..936f9e609 100644 --- a/source_files/edge/g_game.cc +++ b/source_files/edge/g_game.cc @@ -131,8 +131,8 @@ static void InitNew(NewGameParameters ¶ms); static void RespawnPlayer(Player *p); static void SpawnInitialPlayers(void); -static bool GameLoadGameFromFile(std::string filename, bool is_hub = false); -static bool GameSaveGameToFile(std::string filename, const char *description); +static bool GameLoadGameFromFile(const std::string &filename, bool is_hub = false); +static bool GameSaveGameToFile(const std::string &filename, const char *description); static void HandleLevelFlag(bool *special, MapFlag flag) { @@ -713,7 +713,7 @@ void DeferredLoadGame(int slot) game_action = kGameActionLoadGame; } -static bool GameLoadGameFromFile(std::string filename, bool is_hub) +static bool GameLoadGameFromFile(const std::string &filename, bool is_hub) { if (!SaveFileOpenRead(filename)) { @@ -874,7 +874,7 @@ void DeferredSaveGame(int slot, const char *description) game_action = kGameActionSaveGame; } -static bool GameSaveGameToFile(std::string filename, const char *description) +static bool GameSaveGameToFile(const std::string &filename, const char *description) { time_t cur_time; char timebuf[100]; diff --git a/source_files/edge/i_main.cc b/source_files/edge/i_main.cc index 97b2c823a..cc8b1c14f 100644 --- a/source_files/edge/i_main.cc +++ b/source_files/edge/i_main.cc @@ -16,6 +16,8 @@ // //---------------------------------------------------------------------------- +#include + #include "dm_defs.h" #include "e_main.h" #include "epi_filesystem.h" @@ -31,6 +33,9 @@ extern "C" { int main(int argc, char *argv[]) { + if (SDL_SetMemoryFunctions(mi_malloc, mi_calloc, mi_realloc, mi_free) != 0) + FatalError("Couldn't init SDL memory functions!!\n%s\n", SDL_GetError()); + if (SDL_Init(0) < 0) FatalError("Couldn't init SDL!!\n%s\n", SDL_GetError()); diff --git a/source_files/edge/i_movie.cc b/source_files/edge/i_movie.cc index 74c47f6a8..53b356b93 100644 --- a/source_files/edge/i_movie.cc +++ b/source_files/edge/i_movie.cc @@ -166,7 +166,7 @@ void PlayMovie(const std::string &name) movie_bytes = LoadLumpIntoMemory(movie->info_.c_str(), &length); else { - epi::File *mf = OpenFileFromPack(movie->info_.c_str()); + epi::File *mf = OpenFileFromPack(movie->info_); if (mf) { movie_bytes = mf->LoadIntoMemory(); diff --git a/source_files/edge/i_system.cc b/source_files/edge/i_system.cc index f2a21b250..7190064c4 100644 --- a/source_files/edge/i_system.cc +++ b/source_files/edge/i_system.cc @@ -70,7 +70,7 @@ void LogWarning(const char *warning, ...) LogPrint("WARNING: %s", message_buffer); } -void FatalError(const char *error, ...) +[[noreturn]] void FatalError(const char *error, ...) { va_list argptr; diff --git a/source_files/edge/i_system.h b/source_files/edge/i_system.h index 7b8e24116..42f929258 100644 --- a/source_files/edge/i_system.h +++ b/source_files/edge/i_system.h @@ -45,12 +45,12 @@ void SystemStartup(void); void LogPrint(const char *message, ...) __attribute__((format(printf, 1, 2))); void LogWarning(const char *warning, ...) __attribute__((format(printf, 1, 2))); void LogDebug(const char *message, ...) __attribute__((format(printf, 1, 2))); -void FatalError(const char *error, ...) __attribute__((format(printf, 1, 2))); +[[noreturn]] void FatalError(const char *error, ...) __attribute__((format(printf, 1, 2))); #else void LogPrint(const char *message, ...); void LogWarning(const char *warning, ...); void LogDebug(const char *message, ...); -void FatalError(const char *error, ...); +[[noreturn]] void FatalError(const char *error, ...); #endif // The opposite of the SystemStartup routine. This will shutdown diff --git a/source_files/edge/im_funcs.cc b/source_files/edge/im_funcs.cc index 5ca7a58f9..e9157d661 100644 --- a/source_files/edge/im_funcs.cc +++ b/source_files/edge/im_funcs.cc @@ -217,6 +217,9 @@ ImageAtlas *PackImages(const std::unordered_map &image_pack_da rect.id = im.first; rect.w = im.second->used_width_ + 2; rect.h = im.second->used_height_ + 2; + rect.x = 0; + rect.y = 0; + rect.was_packed = false; if (rect.w > atlas_w) { atlas_w = 1; @@ -289,7 +292,7 @@ bool GetImageInfo(epi::File *file, int *width, int *height, int *depth) //------------------------------------------------------------------------ -bool SavePNG(std::string filename, ImageData *image) +bool SavePNG(std::string_view filename, ImageData *image) { EPI_ASSERT(image->depth_ >= 3); diff --git a/source_files/edge/im_funcs.h b/source_files/edge/im_funcs.h index 5f8dd5de8..bd7948238 100644 --- a/source_files/edge/im_funcs.h +++ b/source_files/edge/im_funcs.h @@ -18,6 +18,7 @@ #pragma once +#include #include #include "epi_file.h" @@ -94,7 +95,7 @@ bool GetImageInfo(epi::File *file, int *width, int *height, int *depth); // saves the image (in PNG format) to the given file. // Returns false if failed to save (e.g. file already exists). // The image _MUST_ be RGB or RGBA. -bool SavePNG(std::string filename, ImageData *image); +bool SavePNG(std::string_view filename, ImageData *image); //--- editor settings --- // vi:ts=4:sw=4:noexpandtab diff --git a/source_files/edge/m_menu.cc b/source_files/edge/m_menu.cc index 4178209d4..75b1f9f7d 100644 --- a/source_files/edge/m_menu.cc +++ b/source_files/edge/m_menu.cc @@ -1748,7 +1748,7 @@ void ImmediateQuit() //---------------------------------------------------------------------------- void DrawMenuSlider(int x, int y, float slider_position, float increment, int div, float min, float max, - std::string format_string) + const std::string &format_string) { float basex = x; int step = (8 / div); @@ -1946,7 +1946,7 @@ bool MenuResponder(InputEvent *ev) if ((ch == kBackspace || ch == kDelete) && !input_string.empty()) { - std::string s = input_string.c_str(); + std::string s = input_string; if (input_string != "") { diff --git a/source_files/edge/m_menu.h b/source_files/edge/m_menu.h index b3f432056..deace61be 100644 --- a/source_files/edge/m_menu.h +++ b/source_files/edge/m_menu.h @@ -94,7 +94,7 @@ void MenuEndGame(int choice, ConsoleVariable *cvar = nullptr); void QuitEdge(int choice); void ImmediateQuit(void); void DrawMenuSlider(int x, int y, float slider_position, float increment, int div, float min, float max, - std::string format_string); + const std::string &format_string); void MenuClear(void); //--- editor settings --- diff --git a/source_files/edge/m_misc.cc b/source_files/edge/m_misc.cc index e7b103edb..af178cc7f 100644 --- a/source_files/edge/m_misc.cc +++ b/source_files/edge/m_misc.cc @@ -356,7 +356,7 @@ static void ParseConfig(const std::string &data, bool check_config_version) { for (int i = 0; i < total_defaults; i++) { - if (0 == epi::StringCompare(key.c_str(), defaults[i].name)) + if (0 == epi::StringCompare(key, defaults[i].name)) { if (defaults[i].type == kConfigBoolean) { diff --git a/source_files/edge/p_mobj.cc b/source_files/edge/p_mobj.cc index fbcff6d5c..091b36fa3 100644 --- a/source_files/edge/p_mobj.cc +++ b/source_files/edge/p_mobj.cc @@ -1736,9 +1736,7 @@ static void AddMobjToList(MapObject *mo) } map_object_list_head = mo; - - if (seen_monsters.count(mo->info_) == 0) - seen_monsters.insert(mo->info_); + seen_monsters.insert(mo->info_); #if (EDGE_DEBUG_MAP_OBJECTS > 0) LogDebug("tics=%05d ADD %p [%s]\n", level_time_elapsed, mo, mo->info_ ? mo->info_->name_.c_str() : "???"); diff --git a/source_files/edge/p_plane.cc b/source_files/edge/p_plane.cc index f8357bac2..d15538c74 100644 --- a/source_files/edge/p_plane.cc +++ b/source_files/edge/p_plane.cc @@ -731,6 +731,9 @@ static PlaneMover *P_SetupSectorAction(Sector *sector, const PlaneMoverDefinitio // 2023.08.01 - If already at dest height, run the // texture/type changes that were intended + plane->destination_height = dest; + plane->new_special = -1; + // change to surrounding if (def->tex_ != "" && def->tex_[0] == '-') { @@ -1479,7 +1482,7 @@ void RunActivePlanes(void) if (pmov->type->type_ == kPlaneMoverOnce || pmov->type->type_ == kPlaneMoverStairs || pmov->type->type_ == kPlaneMoverToggle) { - for (auto anim : sector_animations) + for (const SectorAnimation &anim : sector_animations) { if (anim.scroll_sector_reference && (anim.scroll_sector_reference->ceiling_move == pmov || @@ -1524,7 +1527,7 @@ void RunActivePlanes(void) } } } - for (auto anim : line_animations) + for (const LineAnimation &anim : line_animations) { if (anim.scroll_sector_reference && (anim.scroll_sector_reference->ceiling_move == pmov || diff --git a/source_files/edge/p_setup.cc b/source_files/edge/p_setup.cc index 639b35785..3024dd69b 100644 --- a/source_files/edge/p_setup.cc +++ b/source_files/edge/p_setup.cc @@ -2971,11 +2971,13 @@ void GroupLines(void) { sector->floor_vertex_slope_high_low = {{-40000, 40000}}; sector->ceiling_vertex_slope_high_low = {{-40000, 40000}}; + std::vector f_zverts; + std::vector c_zverts; for (j = 0; j < 3; j++) { Vertex *vert = sector->lines[j]->vertex_1; bool add_it = true; - for (HMM_Vec3 v : sector->floor_z_vertices) + for (HMM_Vec3 v : f_zverts) if (AlmostEquals(v.X, vert->X) && AlmostEquals(v.Y, vert->Y)) add_it = false; if (add_it) @@ -2983,29 +2985,29 @@ void GroupLines(void) if (vert->Z < 32767.0f && vert->Z > -32768.0f) { sector->floor_vertex_slope = true; - sector->floor_z_vertices.push_back({{vert->X, vert->Y, vert->Z}}); + f_zverts.push_back({{vert->X, vert->Y, vert->Z}}); if (vert->Z > sector->floor_vertex_slope_high_low.X) sector->floor_vertex_slope_high_low.X = vert->Z; if (vert->Z < sector->floor_vertex_slope_high_low.Y) sector->floor_vertex_slope_high_low.Y = vert->Z; } else - sector->floor_z_vertices.push_back({{vert->X, vert->Y, sector->floor_height}}); + f_zverts.push_back({{vert->X, vert->Y, sector->floor_height}}); if (vert->W < 32767.0f && vert->W > -32768.0f) { sector->ceiling_vertex_slope = true; - sector->ceiling_z_vertices.push_back({{vert->X, vert->Y, vert->W}}); + c_zverts.push_back({{vert->X, vert->Y, vert->W}}); if (vert->W > sector->ceiling_vertex_slope_high_low.X) sector->ceiling_vertex_slope_high_low.X = vert->W; if (vert->W < sector->ceiling_vertex_slope_high_low.Y) sector->ceiling_vertex_slope_high_low.Y = vert->W; } else - sector->ceiling_z_vertices.push_back({{vert->X, vert->Y, sector->ceiling_height}}); + c_zverts.push_back({{vert->X, vert->Y, sector->ceiling_height}}); } vert = sector->lines[j]->vertex_2; add_it = true; - for (HMM_Vec3 v : sector->floor_z_vertices) + for (HMM_Vec3 v : f_zverts) if (AlmostEquals(v.X, vert->X) && AlmostEquals(v.Y, vert->Y)) add_it = false; if (add_it) @@ -3013,31 +3015,30 @@ void GroupLines(void) if (vert->Z < 32767.0f && vert->Z > -32768.0f) { sector->floor_vertex_slope = true; - sector->floor_z_vertices.push_back({{vert->X, vert->Y, vert->Z}}); + f_zverts.push_back({{vert->X, vert->Y, vert->Z}}); if (vert->Z > sector->floor_vertex_slope_high_low.X) sector->floor_vertex_slope_high_low.X = vert->Z; if (vert->Z < sector->floor_vertex_slope_high_low.Y) sector->floor_vertex_slope_high_low.Y = vert->Z; } else - sector->floor_z_vertices.push_back({{vert->X, vert->Y, sector->floor_height}}); + f_zverts.push_back({{vert->X, vert->Y, sector->floor_height}}); if (vert->W < 32767.0f && vert->W > -32768.0f) { sector->ceiling_vertex_slope = true; - sector->ceiling_z_vertices.push_back({{vert->X, vert->Y, vert->W}}); + c_zverts.push_back({{vert->X, vert->Y, vert->W}}); if (vert->W > sector->ceiling_vertex_slope_high_low.X) sector->ceiling_vertex_slope_high_low.X = vert->W; if (vert->W < sector->ceiling_vertex_slope_high_low.Y) sector->ceiling_vertex_slope_high_low.Y = vert->W; } else - sector->ceiling_z_vertices.push_back({{vert->X, vert->Y, sector->ceiling_height}}); + c_zverts.push_back({{vert->X, vert->Y, sector->ceiling_height}}); } } - if (!sector->floor_vertex_slope) - sector->floor_z_vertices.clear(); - else + if (sector->floor_vertex_slope) { + memcpy(sector->floor_z_vertices, f_zverts.data(), 3 * sizeof(HMM_Vec3)); sector->floor_vertex_slope_normal = TripleCrossProduct( sector->floor_z_vertices[0], sector->floor_z_vertices[1], sector->floor_z_vertices[2]); if (sector->floor_height > sector->floor_vertex_slope_high_low.X) @@ -3045,10 +3046,9 @@ void GroupLines(void) if (sector->floor_height < sector->floor_vertex_slope_high_low.Y) sector->floor_vertex_slope_high_low.Y = sector->floor_height; } - if (!sector->ceiling_vertex_slope) - sector->ceiling_z_vertices.clear(); - else + if (sector->ceiling_vertex_slope) { + memcpy(sector->ceiling_z_vertices, c_zverts.data(), 3 * sizeof(HMM_Vec3)); sector->ceiling_vertex_slope_normal = TripleCrossProduct( sector->ceiling_z_vertices[0], sector->ceiling_z_vertices[1], sector->ceiling_z_vertices[2]); if (sector->ceiling_height < sector->ceiling_vertex_slope_high_low.Y) @@ -3063,63 +3063,65 @@ void GroupLines(void) int ceil_z_lines = 0; sector->floor_vertex_slope_high_low = {{-40000, 40000}}; sector->ceiling_vertex_slope_high_low = {{-40000, 40000}}; + std::vector f_zverts; + std::vector c_zverts; for (j = 0; j < 4; j++) { Vertex *vert = sector->lines[j]->vertex_1; Vertex *vert2 = sector->lines[j]->vertex_2; bool add_it_v1 = true; bool add_it_v2 = true; - for (HMM_Vec3 v : sector->floor_z_vertices) + for (HMM_Vec3 v : f_zverts) if (AlmostEquals(v.X, vert->X) && AlmostEquals(v.Y, vert->Y)) add_it_v1 = false; - for (HMM_Vec3 v : sector->floor_z_vertices) + for (HMM_Vec3 v : f_zverts) if (AlmostEquals(v.X, vert2->X) && AlmostEquals(v.Y, vert2->Y)) add_it_v2 = false; if (add_it_v1) { if (vert->Z < 32767.0f && vert->Z > -32768.0f) { - sector->floor_z_vertices.push_back({{vert->X, vert->Y, vert->Z}}); + f_zverts.push_back({{vert->X, vert->Y, vert->Z}}); if (vert->Z > sector->floor_vertex_slope_high_low.X) sector->floor_vertex_slope_high_low.X = vert->Z; if (vert->Z < sector->floor_vertex_slope_high_low.Y) sector->floor_vertex_slope_high_low.Y = vert->Z; } else - sector->floor_z_vertices.push_back({{vert->X, vert->Y, sector->floor_height}}); + f_zverts.push_back({{vert->X, vert->Y, sector->floor_height}}); if (vert->W < 32767.0f && vert->W > -32768.0f) { - sector->ceiling_z_vertices.push_back({{vert->X, vert->Y, vert->W}}); + c_zverts.push_back({{vert->X, vert->Y, vert->W}}); if (vert->W > sector->ceiling_vertex_slope_high_low.X) sector->ceiling_vertex_slope_high_low.X = vert->W; if (vert->W < sector->ceiling_vertex_slope_high_low.Y) sector->ceiling_vertex_slope_high_low.Y = vert->W; } else - sector->ceiling_z_vertices.push_back({{vert->X, vert->Y, sector->ceiling_height}}); + c_zverts.push_back({{vert->X, vert->Y, sector->ceiling_height}}); } if (add_it_v2) { if (vert2->Z < 32767.0f && vert2->Z > -32768.0f) { - sector->floor_z_vertices.push_back({{vert2->X, vert2->Y, vert2->Z}}); + f_zverts.push_back({{vert2->X, vert2->Y, vert2->Z}}); if (vert2->Z > sector->floor_vertex_slope_high_low.X) sector->floor_vertex_slope_high_low.X = vert2->Z; if (vert2->Z < sector->floor_vertex_slope_high_low.Y) sector->floor_vertex_slope_high_low.Y = vert2->Z; } else - sector->floor_z_vertices.push_back({{vert2->X, vert2->Y, sector->floor_height}}); + f_zverts.push_back({{vert2->X, vert2->Y, sector->floor_height}}); if (vert2->W < 32767.0f && vert2->W > -32768.0f) { - sector->ceiling_z_vertices.push_back({{vert2->X, vert2->Y, vert2->W}}); + c_zverts.push_back({{vert2->X, vert2->Y, vert2->W}}); if (vert2->W > sector->ceiling_vertex_slope_high_low.X) sector->ceiling_vertex_slope_high_low.X = vert2->W; if (vert2->W < sector->ceiling_vertex_slope_high_low.Y) sector->ceiling_vertex_slope_high_low.Y = vert2->W; } else - sector->ceiling_z_vertices.push_back({{vert2->X, vert2->Y, sector->ceiling_height}}); + c_zverts.push_back({{vert2->X, vert2->Y, sector->ceiling_height}}); } if ((vert->Z < 32767.0f && vert->Z > -32768.0f) && (vert2->Z < 32767.0f && vert2->Z > -32768.0f) && AlmostEquals(vert->Z, vert2->Z)) @@ -3132,9 +3134,13 @@ void GroupLines(void) ceil_z_lines++; } } - if (floor_z_lines == 1 && sector->floor_z_vertices.size() == 4) + if (floor_z_lines == 1 && f_zverts.size() == 4) { sector->floor_vertex_slope = true; + // Only need three of the verts, as with the way we regulate rectangular + // vert slopes, any 3 of the 4 vertices that comprise the sector + // will result in the same plane calculation + memcpy(sector->floor_z_vertices, f_zverts.data(), 3 * sizeof(HMM_Vec3)); sector->floor_vertex_slope_normal = TripleCrossProduct( sector->floor_z_vertices[0], sector->floor_z_vertices[1], sector->floor_z_vertices[2]); if (sector->floor_height > sector->floor_vertex_slope_high_low.X) @@ -3142,11 +3148,13 @@ void GroupLines(void) if (sector->floor_height < sector->floor_vertex_slope_high_low.Y) sector->floor_vertex_slope_high_low.Y = sector->floor_height; } - else - sector->floor_z_vertices.clear(); - if (ceil_z_lines == 1 && sector->ceiling_z_vertices.size() == 4) + if (ceil_z_lines == 1 && c_zverts.size() == 4) { sector->ceiling_vertex_slope = true; + // Only need three of the verts, as with the way we regulate rectangular + // vert slopes, any 3 of the 4 vertices that comprise the sector + // will result in the same plane calculation + memcpy(sector->ceiling_z_vertices, c_zverts.data(), 3 * sizeof(HMM_Vec3)); sector->ceiling_vertex_slope_normal = TripleCrossProduct( sector->ceiling_z_vertices[0], sector->ceiling_z_vertices[1], sector->ceiling_z_vertices[2]); if (sector->ceiling_height < sector->ceiling_vertex_slope_high_low.Y) @@ -3154,8 +3162,6 @@ void GroupLines(void) if (sector->ceiling_height > sector->ceiling_vertex_slope_high_low.X) sector->ceiling_vertex_slope_high_low.X = sector->ceiling_height; } - else - sector->ceiling_z_vertices.clear(); } // set the degenmobj_t to the middle of the bounding box diff --git a/source_files/edge/r_bsp.cc b/source_files/edge/r_bsp.cc index 2b658cb97..884196876 100644 --- a/source_files/edge/r_bsp.cc +++ b/source_files/edge/r_bsp.cc @@ -361,10 +361,10 @@ static void BSPWalkSeg(DrawSubsector *dsub, Seg *seg) float f_ch = 0; float b_fh = 0; float b_ch = 0; - MapSurface *f_floor = nullptr; - MapSurface *f_ceil = nullptr; - MapSurface *b_floor = nullptr; - MapSurface *b_ceil = nullptr; + const MapSurface *f_floor = nullptr; + const MapSurface *f_ceil = nullptr; + const MapSurface *b_floor = nullptr; + const MapSurface *b_ceil = nullptr; if (!fsector->height_sector) { @@ -490,7 +490,7 @@ static void BSPWalkSeg(DrawSubsector *dsub, Seg *seg) // Placed here to be close to BSPWalkSeg(), which has similiar angle // clipping stuff in it. // -static bool BSPCheckBBox(float *bspcoord) +static bool BSPCheckBBox(const float *bspcoord) { EDGE_ZoneScoped; diff --git a/source_files/edge/r_defs.h b/source_files/edge/r_defs.h index 820b9628c..63dc97911 100644 --- a/source_files/edge/r_defs.h +++ b/source_files/edge/r_defs.h @@ -269,8 +269,8 @@ struct Sector // UDMF vertex slope stuff bool floor_vertex_slope; bool ceiling_vertex_slope; - std::vector floor_z_vertices; - std::vector ceiling_z_vertices; + HMM_Vec3 floor_z_vertices[3]; + HMM_Vec3 ceiling_z_vertices[3]; HMM_Vec3 floor_vertex_slope_normal; HMM_Vec3 ceiling_vertex_slope_normal; HMM_Vec2 floor_vertex_slope_high_low; diff --git a/source_files/edge/r_doomtex.cc b/source_files/edge/r_doomtex.cc index 70cf8ca53..f1a6acdb6 100644 --- a/source_files/edge/r_doomtex.cc +++ b/source_files/edge/r_doomtex.cc @@ -82,7 +82,7 @@ static constexpr uint8_t dummy_graphic[kDummyImageSize * kDummyImageSize] = { // // UTILITY // -static void DrawColumnIntoEpiBlock(Image *rim, ImageData *img, const TexturePost *patchcol, int x, int y) +static void DrawColumnIntoEpiBlock(const Image *rim, const ImageData *img, const TexturePost *patchcol, int x, int y) { EPI_ASSERT(patchcol); @@ -460,7 +460,7 @@ epi::File *OpenUserFileOrLump(ImageDefinition *def) { case kImageDataFile: { // -AJA- 2005/01/15: filenames in DDF relative to APPDIR - std::string data_file = epi::PathAppendIfNotAbsolute(game_directory.c_str(), def->info_.c_str()); + std::string data_file = epi::PathAppendIfNotAbsolute(game_directory, def->info_); return epi::FileOpen(data_file, epi::kFileAccessRead | epi::kFileAccessBinary); } diff --git a/source_files/edge/r_image.cc b/source_files/edge/r_image.cc index 4f550a8d1..b9b566799 100644 --- a/source_files/edge/r_image.cc +++ b/source_files/edge/r_image.cc @@ -235,9 +235,8 @@ static void AddImageToMap(ImageMap &map, const char *name, Image *image) Image::Image() : actual_width_(0), actual_height_(0), total_width_(0), total_height_(0), width_ratio_(0.0), height_ratio_(0.0), - source_type_(kImageSourceDummy), source_palette_(-1), cache_() + name_("_UNINIT_"), source_type_(kImageSourceDummy), source_palette_(-1), cache_() { - name_ = "_UNINIT_"; EPI_CLEAR_MEMORY(&source_, ImageSource, 1); EPI_CLEAR_MEMORY(&animation_, ImageAnimation, 1); } @@ -932,7 +931,7 @@ static Image *AddImageUser(ImageDefinition *def) // NOTE: should only be called once, as it assumes none of the flats // in the list have names colliding with existing flat images. // -void CreateFlats(std::vector &lumps) +void CreateFlats(const std::vector &lumps) { for (size_t i = 0; i < lumps.size(); i++) { @@ -1000,7 +999,7 @@ const Image *CreateSprite(const char *name, int lump, bool is_weapon) return rim; } -const Image *CreatePackSprite(std::string packname, PackFile *pack, bool is_weapon) +const Image *CreatePackSprite(const std::string &packname, const PackFile *pack, bool is_weapon) { EPI_ASSERT(pack); @@ -1100,7 +1099,7 @@ const Image **GetUserSprites(int *count) { for (auto it = mitr->second.begin(); it != mitr->second.end(); it++) { - Image *rim = *it; + const Image *rim = *it; if (rim->source_type_ == kImageSourceUser || rim->source_.graphic.user_defined) (*count) += 1; @@ -1167,7 +1166,7 @@ static bool IM_ShouldClamp(const Image *rim) } } -static bool IM_ShouldMipmap(Image *rim) +static bool IM_ShouldMipmap(const Image *rim) { // the "SKY" check here is a hack... if (epi::StringPrefixCaseCompareASCII(rim->name_, "SKY") == 0) @@ -1199,7 +1198,7 @@ static bool IM_ShouldMipmap(Image *rim) } } -static bool IM_ShouldSmooth(Image *rim) +static bool IM_ShouldSmooth(const Image *rim) { if (!AlmostEquals(rim->blur_sigma_, 0.0f)) return true; @@ -1207,7 +1206,7 @@ static bool IM_ShouldSmooth(Image *rim) return image_smoothing ? true : false; } -static bool IM_ShouldHQ2X(Image *rim) +static bool IM_ShouldHQ2X(const Image *rim) { // Note: no need to check kImageSourceUser, since those images are // always PNG or JPEG (etc) and never palettised, hence @@ -1885,7 +1884,7 @@ void ImagePrecache(const Image *image) alt_name[2] = (alt_name[2] == '1') ? '2' : '1'; - Image *alt = ImageContainerLookupInternal(real_textures, epi::EName(alt_name.c_str())); + const Image *alt = ImageContainerLookupInternal(real_textures, epi::EName(alt_name)); if (alt) ImageCache(alt, false); diff --git a/source_files/edge/r_image.h b/source_files/edge/r_image.h index 8876179c3..063bcbdb9 100644 --- a/source_files/edge/r_image.h +++ b/source_files/edge/r_image.h @@ -274,10 +274,10 @@ bool InitializeImages(void); void AnimationTicker(void); void DeleteAllImages(void); -void CreateFlats(std::vector &lumps); +void CreateFlats(const std::vector &lumps); void CreateTextures(struct TextureDefinition **defs, int number); const Image *CreateSprite(const char *name, int lump, bool is_weapon); -const Image *CreatePackSprite(std::string packname, PackFile *pack, bool is_weapon); +const Image *CreatePackSprite(const std::string &packname, const PackFile *pack, bool is_weapon); void CreateUserImages(void); void ImageAddTxHx(int lump, const char *name, bool hires); void AnimateImageSet(const Image **images, int number, int speed); diff --git a/source_files/edge/r_mirror.h b/source_files/edge/r_mirror.h index 71c2dec3b..6d63dc45f 100644 --- a/source_files/edge/r_mirror.h +++ b/source_files/edge/r_mirror.h @@ -113,7 +113,7 @@ class MirrorSet return result; } - bool SegOnPortal(Seg *seg) + bool SegOnPortal(const Seg *seg) { if (active_ == 0) return false; @@ -121,7 +121,7 @@ class MirrorSet if (seg->miniseg) return false; - DrawMirror *def = active_mirrors_[active_ - 1].draw_mirror_; + const DrawMirror *def = active_mirrors_[active_ - 1].draw_mirror_; if (def->is_portal) { diff --git a/source_files/edge/r_modes.cc b/source_files/edge/r_modes.cc index a0f439082..b8ea66838 100644 --- a/source_files/edge/r_modes.cc +++ b/source_files/edge/r_modes.cc @@ -175,7 +175,7 @@ bool IncrementResolution(DisplayMode *mode, int what, int dir) return true; } - DisplayMode *best = nullptr; + const DisplayMode *best = nullptr; int best_diff = (1 << 30); for (int i = 0; i < (int)screen_modes.size(); i++) diff --git a/source_files/edge/r_sky.cc b/source_files/edge/r_sky.cc index cca42e2f9..605b01cb0 100644 --- a/source_files/edge/r_sky.cc +++ b/source_files/edge/r_sky.cc @@ -114,7 +114,7 @@ void ComputeSkyHeights(void) for (i = 0, ld = level_lines; i < total_level_lines; i++, ld++) { - Sector *sec1, *sec2; + const Sector *sec1, *sec2; SectorSkyRing *ring1, *ring2, *tmp_R; if (!ld->side[0] || !ld->side[1]) @@ -870,13 +870,14 @@ int UpdateSkyboxTextures(void) } // Set colors for culling fog and faux skybox caps - Dasho - const uint8_t *what_palette = (const uint8_t *)&playpal_data[0]; + const uint8_t *what_palette = nullptr; if (sky_image->source_palette_ >= 0) what_palette = (const uint8_t *)LoadLumpIntoMemory(sky_image->source_palette_); ImageData *tmp_img_data = ReadAsEpiBlock((Image *)sky_image); if (tmp_img_data->depth_ == 1) { - ImageData *rgb_img_data = RGBFromPalettised(tmp_img_data, what_palette, sky_image->opacity_); + ImageData *rgb_img_data = RGBFromPalettised(tmp_img_data, what_palette ? what_palette : + (const uint8_t *)&playpal_data[0], sky_image->opacity_); delete tmp_img_data; tmp_img_data = rgb_img_data; } @@ -885,7 +886,7 @@ int UpdateSkyboxTextures(void) sky_image->actual_height_); delete tmp_img_data; - if (what_palette != (const uint8_t *)&playpal_data[0]) + if (what_palette) delete[] what_palette; if (info->face[kSkyboxNorth]) diff --git a/source_files/edge/r_texgl.cc b/source_files/edge/r_texgl.cc index e5701a474..2895bc74a 100644 --- a/source_files/edge/r_texgl.cc +++ b/source_files/edge/r_texgl.cc @@ -224,7 +224,7 @@ GLuint UploadTexture(ImageData *img, int flags, int max_pix) //---------------------------------------------------------------------------- -void PaletteRemapRGBA(ImageData *img, const uint8_t *new_pal, const uint8_t *old_pal) +void PaletteRemapRGBA(const ImageData *img, const uint8_t *new_pal, const uint8_t *old_pal) { const int max_prev = 16; @@ -320,7 +320,7 @@ void PaletteRemapRGBA(ImageData *img, const uint8_t *new_pal, const uint8_t *old } } -int DetermineOpacity(ImageData *img, bool *is_empty_) +int DetermineOpacity(const ImageData *img, bool *is_empty_) { if (img->depth_ == 3) { diff --git a/source_files/edge/r_texgl.h b/source_files/edge/r_texgl.h index f6606353f..abb8151e0 100644 --- a/source_files/edge/r_texgl.h +++ b/source_files/edge/r_texgl.h @@ -35,9 +35,9 @@ GLuint UploadTexture(ImageData *img, int flags = kUploadNone, int max_pix = (1 < ImageData *RGBFromPalettised(ImageData *src, const uint8_t *palette, int opacity); -void PaletteRemapRGBA(ImageData *img, const uint8_t *new_pal, const uint8_t *old_pal); +void PaletteRemapRGBA(const ImageData *img, const uint8_t *new_pal, const uint8_t *old_pal); -int DetermineOpacity(ImageData *img, bool *is_empty_); +int DetermineOpacity(const ImageData *img, bool *is_empty_); void BlackenClearAreas(ImageData *img); diff --git a/source_files/edge/rad_act.cc b/source_files/edge/rad_act.cc index 3dbfa7da5..3a1b768b1 100644 --- a/source_files/edge/rad_act.cc +++ b/source_files/edge/rad_act.cc @@ -83,13 +83,16 @@ void InitializeScriptTips(void) ScriptDrawTip *current = tip_slots + i; // initial properties - EPI_CLEAR_MEMORY(current, ScriptDrawTip, 1); - + current->dirty = false; + current->tip_text = nullptr; + current->tip_graphic = nullptr; + current->playsound = false; + current->scale = 0.0f; + current->fade_time = 0; + current->fade_target = 0.0f; current->p = fixed_props[i % kFixedSlots]; - current->delay = -1; current->color = kRGBANoValue; - current->p.slot_num = i; } } diff --git a/source_files/edge/render/sokol/sokol_backend.cc b/source_files/edge/render/sokol/sokol_backend.cc index 15e60af44..3b3608c8a 100644 --- a/source_files/edge/render/sokol/sokol_backend.cc +++ b/source_files/edge/render/sokol/sokol_backend.cc @@ -94,6 +94,7 @@ class SokolRenderBackend : public RenderBackend pass_action.depth.load_action = SG_LOADACTION_CLEAR; pass_action.depth.clear_value = 1.0f; + pass_action.stencil = {SG_LOADACTION_CLEAR, SG_STOREACTION_DONTCARE, 0}; EPI_CLEAR_MEMORY(&pass_, sg_pass, 1); pass_.action = pass_action; diff --git a/source_files/edge/render/sokol/sokol_gl.h b/source_files/edge/render/sokol/sokol_gl.h index 0fbcbe2b2..dec9fe318 100644 --- a/source_files/edge/render/sokol/sokol_gl.h +++ b/source_files/edge/render/sokol/sokol_gl.h @@ -1066,7 +1066,7 @@ inline sgl_pipeline sgl_context_make_pipeline(sgl_context ctx, const sg_pipeline uv = mat4(vs_params[4], vs_params[5], vs_params[6], vs_params[7]) * vec4(texcoord0, 0.0, 1.0); color = color0; } -*/ + static const char* _sgl_vs_source_glsl410 = "#version 410 core\n\ uniform vec4 vs_params[12]; \ layout(location = 0) in vec4 position; \ @@ -1088,7 +1088,7 @@ static const char* _sgl_vs_source_glsl410 = "#version 410 core\n\ fog_src = vertex.z;\ }\ "; -/* + #version 410 uniform sampler2D tex_smp; @@ -1101,7 +1101,7 @@ static const char* _sgl_vs_source_glsl410 = "#version 410 core\n\ { frag_color = texture(tex_smp, uv.xy) * color; } -*/ + static const char* _sgl_fs_source_glsl410 = "#version 410 core\n\ \ @@ -1145,6 +1145,7 @@ static const char* _sgl_fs_source_glsl410 = "#version 410 core\n\ frag_color = c0;\ }\ "; +*/ #elif defined(SOKOL_GLES3) /* #version 300 es diff --git a/source_files/edge/render/sokol/sokol_units.cc b/source_files/edge/render/sokol/sokol_units.cc index 627b27149..6fca81b63 100644 --- a/source_files/edge/render/sokol/sokol_units.cc +++ b/source_files/edge/render/sokol/sokol_units.cc @@ -326,19 +326,13 @@ void RenderCurrentUnits(void) else if (!culling || (unit->blending & kBlendingNoFog)) render_state->Disable(GL_FOG); - // render_state->PolygonOffset(0, -unit->pass); - - bool blend = false; - if (unit->blending & kBlendingAdd) { - blend = true; render_state->Enable(GL_BLEND); render_state->BlendFunction(GL_SRC_ALPHA, GL_ONE); } else if (unit->blending & kBlendingAlpha) { - blend = true; render_state->Enable(GL_BLEND); render_state->BlendFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } diff --git a/source_files/edge/s_blit.h b/source_files/edge/s_blit.h index 32b371df3..150fa5348 100644 --- a/source_files/edge/s_blit.h +++ b/source_files/edge/s_blit.h @@ -48,11 +48,11 @@ class SoundChannel public: int state_; // CHAN_xxx - SoundData *data_; + const SoundData *data_; int category_; - SoundEffectDefinition *definition_; - Position *position_; + const SoundEffectDefinition *definition_; + const Position *position_; bool loop_; // will loop *one* more time bool boss_; diff --git a/source_files/edge/s_cache.cc b/source_files/edge/s_cache.cc index cbb04fcd9..36eb52536 100644 --- a/source_files/edge/s_cache.cc +++ b/source_files/edge/s_cache.cc @@ -67,16 +67,16 @@ static void LoadSilence(SoundData *buf) EPI_CLEAR_MEMORY(buf->data_, float, length * 2); } #ifdef EDGE_CLASSIC -static bool LoadDoom(SoundData *buf, uint8_t *lump, int length) +static bool LoadDoom(SoundData *buf, const uint8_t *lump, int length) { return LoadDoomSound(buf, lump, length); } -static bool LoadPCSpeaker(SoundData *buf, uint8_t *lump, int length) +static bool LoadPCSpeaker(SoundData *buf, const uint8_t *lump, int length) { return LoadPCSpeakerSound(buf, lump, length); } #endif -static bool LoadWav(SoundData *buf, uint8_t *lump, int length) +static bool LoadWav(SoundData *buf, const uint8_t *lump, int length) { return LoadWAVSound(buf, lump, length); } diff --git a/source_files/edge/s_doom.cc b/source_files/edge/s_doom.cc index b03b85b41..93ae9c239 100644 --- a/source_files/edge/s_doom.cc +++ b/source_files/edge/s_doom.cc @@ -29,7 +29,7 @@ extern int sound_device_frequency; -bool LoadDoomSound(SoundData *buf, uint8_t *data, int length) +bool LoadDoomSound(SoundData *buf, const uint8_t *data, int length) { buf->frequency_ = data[2] + (data[3] << 8); @@ -75,7 +75,7 @@ static constexpr uint16_t kFrequencyTable[128] = { 452, 439, 427, 415, 403, 391, 380, 369, 359, 348, 339, 329, 319, 310, 302, 293, 285, 276, 269, 261, 253, 246, 239, 232, 226, 219, 213, 207, 201, 195, 190, 184, 179}; -bool LoadPCSpeakerSound(SoundData *buf, uint8_t *data, int length) +bool LoadPCSpeakerSound(SoundData *buf, const uint8_t *data, int length) { if (length < 4) { @@ -83,7 +83,7 @@ bool LoadPCSpeakerSound(SoundData *buf, uint8_t *data, int length) return false; } int sign = -1; - uint32_t tone, i, phase_length, phase_tic = 0; + uint32_t i, phase_tic = 0; uint32_t samples_per_byte = sound_device_frequency / kPCRate; uint16_t zeroed, total_samples; memcpy(&zeroed, data, 2); @@ -109,10 +109,10 @@ bool LoadPCSpeakerSound(SoundData *buf, uint8_t *data, int length) LogWarning("Invalid PC Speaker Sound (bad tone value %d)\n", *data); return false; } - tone = kFrequencyTable[*data++]; - phase_length = (sound_device_frequency * tone) / (2 * kPCInterruptTimer); - uint8_t value = 0; + uint32_t tone = kFrequencyTable[*data++]; + uint32_t phase_length = (sound_device_frequency * tone) / (2 * kPCInterruptTimer); float float_value = 0; + uint8_t value; for (i = 0; i < samples_per_byte; i++) { if (tone) diff --git a/source_files/edge/s_doom.h b/source_files/edge/s_doom.h index 5f0474fe4..bda9fef22 100644 --- a/source_files/edge/s_doom.h +++ b/source_files/edge/s_doom.h @@ -22,9 +22,9 @@ #include "snd_data.h" -bool LoadDoomSound(SoundData *buf, uint8_t *data, int length); +bool LoadDoomSound(SoundData *buf, const uint8_t *data, int length); -bool LoadPCSpeakerSound(SoundData *buf, uint8_t *data, int length); +bool LoadPCSpeakerSound(SoundData *buf, const uint8_t *data, int length); //--- editor settings --- // vi:ts=4:sw=4:noexpandtab diff --git a/source_files/edge/s_flac.cc b/source_files/edge/s_flac.cc index 02f7bb251..dd17a9f10 100644 --- a/source_files/edge/s_flac.cc +++ b/source_files/edge/s_flac.cc @@ -39,7 +39,7 @@ class FLACPlayer : public AbstractMusicPlayer { public: FLACPlayer(); - ~FLACPlayer(); + ~FLACPlayer() override; private: uint8_t *flac_data_; @@ -47,15 +47,15 @@ class FLACPlayer : public AbstractMusicPlayer public: bool OpenMemory(uint8_t *data, int length); - virtual void Close(void); + void Close(void) override; - virtual void Play(bool loop); - virtual void Stop(void); + void Play(bool loop) override; + void Stop(void) override; - virtual void Pause(void); - virtual void Resume(void); + void Pause(void) override; + void Resume(void) override; - virtual void Ticker(void); + void Ticker(void) override; }; //---------------------------------------------------------------------------- diff --git a/source_files/edge/s_m4p.cc b/source_files/edge/s_m4p.cc index 9a50aad59..4e1479835 100644 --- a/source_files/edge/s_m4p.cc +++ b/source_files/edge/s_m4p.cc @@ -56,10 +56,10 @@ static ma_result ma_m4p_init_memory(const void *pData, size_t dataSize, const ma static void ma_m4p_uninit(ma_m4p *pM4P, const ma_allocation_callbacks *pAllocationCallbacks); static ma_result ma_m4p_read_pcm_frames(ma_m4p *pM4P, void *pFramesOut, ma_uint64 frameCount, ma_uint64 *pFramesRead); static ma_result ma_m4p_seek_to_pcm_frame(ma_m4p *pM4P, ma_uint64 frameIndex); -static ma_result ma_m4p_get_data_format(ma_m4p *pM4P, ma_format *pFormat, ma_uint32 *pChannels, ma_uint32 *pSampleRate, +static ma_result ma_m4p_get_data_format(const ma_m4p *pM4P, ma_format *pFormat, ma_uint32 *pChannels, ma_uint32 *pSampleRate, ma_channel *pChannelMap, size_t channelMapCap); -static ma_result ma_m4p_get_cursor_in_pcm_frames(ma_m4p *pM4P, ma_uint64 *pCursor); -static ma_result ma_m4p_get_length_in_pcm_frames(ma_m4p *pM4P, ma_uint64 *pLength); +static ma_result ma_m4p_get_cursor_in_pcm_frames(const ma_m4p *pM4P, ma_uint64 *pCursor); +static ma_result ma_m4p_get_length_in_pcm_frames(const ma_m4p *pM4P, ma_uint64 *pLength); static ma_result ma_m4p_ds_read(ma_data_source *pDataSource, void *pFramesOut, ma_uint64 frameCount, ma_uint64 *pFramesRead) @@ -270,7 +270,7 @@ static ma_result ma_m4p_seek_to_pcm_frame(ma_m4p *pM4P, ma_uint64 frameIndex) return MA_SUCCESS; } -static ma_result ma_m4p_get_data_format(ma_m4p *pM4P, ma_format *pFormat, ma_uint32 *pChannels, ma_uint32 *pSampleRate, +static ma_result ma_m4p_get_data_format(const ma_m4p *pM4P, ma_format *pFormat, ma_uint32 *pChannels, ma_uint32 *pSampleRate, ma_channel *pChannelMap, size_t channelMapCap) { /* Defaults for safety. */ @@ -319,7 +319,7 @@ static ma_result ma_m4p_get_data_format(ma_m4p *pM4P, ma_format *pFormat, ma_uin return MA_SUCCESS; } -static ma_result ma_m4p_get_cursor_in_pcm_frames(ma_m4p *pM4P, ma_uint64 *pCursor) +static ma_result ma_m4p_get_cursor_in_pcm_frames(const ma_m4p *pM4P, ma_uint64 *pCursor) { if (pCursor == NULL) { @@ -338,7 +338,7 @@ static ma_result ma_m4p_get_cursor_in_pcm_frames(ma_m4p *pM4P, ma_uint64 *pCurso return MA_SUCCESS; } -static ma_result ma_m4p_get_length_in_pcm_frames(ma_m4p *pM4P, ma_uint64 *pLength) +static ma_result ma_m4p_get_length_in_pcm_frames(const ma_m4p *pM4P, ma_uint64 *pLength) { if (pLength == NULL) { @@ -437,19 +437,19 @@ class M4PPlayer : public AbstractMusicPlayer { public: M4PPlayer(); - ~M4PPlayer(); + ~M4PPlayer() override; - bool OpenMemory(uint8_t *data, int length); + bool OpenMemory(const uint8_t *data, int length); - virtual void Close(void); + void Close(void) override; - virtual void Play(bool loop); - virtual void Stop(void); + void Play(bool loop) override; + void Stop(void) override; - virtual void Pause(void); - virtual void Resume(void); + void Pause(void) override; + void Resume(void) override; - virtual void Ticker(void); + void Ticker(void) override; }; //---------------------------------------------------------------------------- @@ -464,7 +464,7 @@ M4PPlayer::~M4PPlayer() Close(); } -bool M4PPlayer::OpenMemory(uint8_t *data, int length) +bool M4PPlayer::OpenMemory(const uint8_t *data, int length) { if (status_ != kNotLoaded) Close(); diff --git a/source_files/edge/s_midi.cc b/source_files/edge/s_midi.cc index bcb0e4277..ee36b5bd3 100644 --- a/source_files/edge/s_midi.cc +++ b/source_files/edge/s_midi.cc @@ -46,6 +46,7 @@ bool midi_disabled = false; static fluid_synth_t *edge_fluid = nullptr; static fluid_settings_t *edge_fluid_settings = nullptr; static fluid_sfloader_t *edge_fluid_sf2_loader = nullptr; +static int edge_fluid_sf2_index = -1; EDGE_DEFINE_CONSOLE_VARIABLE(midi_soundfont, "Default", kConsoleVariableFlagArchive) @@ -141,10 +142,7 @@ static long edge_fluid_ftell(void *handle) static int edge_fluid_free(fluid_fileapi_t* fileapi) { if (fileapi) - { delete fileapi; - fileapi = nullptr; - } return kFluidOk; } @@ -723,7 +721,9 @@ bool StartupMIDI(void) if (add_loader) fluid_synth_add_sfloader(edge_fluid, edge_fluid_sf2_loader); - if (fluid_synth_sfload(edge_fluid, midi_soundfont.c_str(), 1) == -1) + edge_fluid_sf2_index = fluid_synth_sfload(edge_fluid, midi_soundfont.c_str(), 1); + + if (edge_fluid_sf2_index == -1) { LogWarning("MIDI: Initialization failure.\n"); delete_fluid_synth(edge_fluid); @@ -750,7 +750,11 @@ void RestartMIDI(void) int old_entry = entry_playing; StopMusic(); - fluid_synth_sfunload(edge_fluid, 0, 1); + if (edge_fluid_sf2_index > -1) + { + fluid_synth_sfunload(edge_fluid, edge_fluid_sf2_index, 1); + edge_fluid_sf2_index = -1; + } if (!StartupMIDI()) { diff --git a/source_files/edge/s_midi_ec.cc b/source_files/edge/s_midi_ec.cc index a7fec31b5..25aa0a595 100644 --- a/source_files/edge/s_midi_ec.cc +++ b/source_files/edge/s_midi_ec.cc @@ -47,6 +47,7 @@ bool midi_disabled = false; static fluid_synth_t *edge_fluid = nullptr; static fluid_settings_t *edge_fluid_settings = nullptr; static fluid_sfloader_t *edge_fluid_sf2_loader = nullptr; +static int edge_fluid_sf2_index = -1; static OPLPlayer *edge_opl = nullptr; static bool opl_playback = false; static uint16_t imf_rate = 0; @@ -145,10 +146,7 @@ static long edge_fluid_ftell(void *handle) static int edge_fluid_free(fluid_fileapi_t* fileapi) { if (fileapi) - { delete fileapi; - fileapi = nullptr; - } return kFluidOk; } @@ -283,10 +281,10 @@ static void ma_midi_uninit(ma_midi *pMIDI, const ma_allocation_callbacks *p static ma_result ma_midi_read_pcm_frames(ma_midi *pMIDI, void *pFramesOut, ma_uint64 frameCount, ma_uint64 *pFramesRead); static ma_result ma_midi_seek_to_pcm_frame(ma_midi *pMIDI, ma_uint64 frameIndex); -static ma_result ma_midi_get_data_format(ma_midi *pMIDI, ma_format *pFormat, ma_uint32 *pChannels, +static ma_result ma_midi_get_data_format(const ma_midi *pMIDI, ma_format *pFormat, ma_uint32 *pChannels, ma_uint32 *pSampleRate, ma_channel *pChannelMap, size_t channelMapCap); -static ma_result ma_midi_get_cursor_in_pcm_frames(ma_midi *pMIDI, ma_uint64 *pCursor); -static ma_result ma_midi_get_length_in_pcm_frames(ma_midi *pMIDI, ma_uint64 *pLength); +static ma_result ma_midi_get_cursor_in_pcm_frames(const ma_midi *pMIDI, ma_uint64 *pCursor); +static ma_result ma_midi_get_length_in_pcm_frames(const ma_midi *pMIDI, ma_uint64 *pLength); static ma_result ma_midi_ds_read(ma_data_source *pDataSource, void *pFramesOut, ma_uint64 frameCount, ma_uint64 *pFramesRead) @@ -510,7 +508,7 @@ static ma_result ma_midi_seek_to_pcm_frame(ma_midi *pMIDI, ma_uint64 frameIndex) return MA_SUCCESS; } -static ma_result ma_midi_get_data_format(ma_midi *pMIDI, ma_format *pFormat, ma_uint32 *pChannels, +static ma_result ma_midi_get_data_format(const ma_midi *pMIDI, ma_format *pFormat, ma_uint32 *pChannels, ma_uint32 *pSampleRate, ma_channel *pChannelMap, size_t channelMapCap) { /* Defaults for safety. */ @@ -559,7 +557,7 @@ static ma_result ma_midi_get_data_format(ma_midi *pMIDI, ma_format *pFormat, ma_ return MA_SUCCESS; } -static ma_result ma_midi_get_cursor_in_pcm_frames(ma_midi *pMIDI, ma_uint64 *pCursor) +static ma_result ma_midi_get_cursor_in_pcm_frames(const ma_midi *pMIDI, ma_uint64 *pCursor) { if (pCursor == NULL) { @@ -578,7 +576,7 @@ static ma_result ma_midi_get_cursor_in_pcm_frames(ma_midi *pMIDI, ma_uint64 *pCu return MA_SUCCESS; } -static ma_result ma_midi_get_length_in_pcm_frames(ma_midi *pMIDI, ma_uint64 *pLength) +static ma_result ma_midi_get_length_in_pcm_frames(const ma_midi *pMIDI, ma_uint64 *pLength) { if (pLength == NULL) { @@ -763,7 +761,8 @@ bool StartupMIDI(void) if (epi::StringCompare(midi_soundfont.s_, "OPL Emulation") != 0) { - if (fluid_synth_sfload(edge_fluid, midi_soundfont.c_str(), 1) == -1) + edge_fluid_sf2_index = fluid_synth_sfload(edge_fluid, midi_soundfont.c_str(), 1); + if (edge_fluid_sf2_index == -1) { LogWarning("MIDI: Initialization failure.\n"); delete_fluid_synth(edge_fluid); @@ -827,7 +826,11 @@ void RestartMIDI(void) // We only unload the Fluidlite font, OPL instruments are determined once on startup, // no need to reload; just reset it edge_opl->reset(); - fluid_synth_sfunload(edge_fluid, 0, 1); + if (edge_fluid_sf2_index > -1) + { + fluid_synth_sfunload(edge_fluid, edge_fluid_sf2_index, 1); + edge_fluid_sf2_index = -1; + } if (!StartupMIDI()) { @@ -853,12 +856,12 @@ class MIDIPlayer : public AbstractMusicPlayer looping_ = looping; } - ~MIDIPlayer() + ~MIDIPlayer() override { Close(); } - bool OpenMemory(uint8_t *data, int length) + bool OpenMemory(const uint8_t *data, int length) { if (status_ != kNotLoaded) Close(); @@ -892,7 +895,7 @@ class MIDIPlayer : public AbstractMusicPlayer return true; } - void Close(void) + void Close(void) override { if (status_ == kNotLoaded) return; @@ -907,7 +910,7 @@ class MIDIPlayer : public AbstractMusicPlayer status_ = kNotLoaded; } - void Play(bool loop) + void Play(bool loop) override { looping_ = loop; @@ -923,7 +926,7 @@ class MIDIPlayer : public AbstractMusicPlayer } } - void Stop(void) + void Stop(void) override { if (status_ != kPlaying && status_ != kPaused) return; @@ -942,7 +945,7 @@ class MIDIPlayer : public AbstractMusicPlayer status_ = kStopped; } - void Pause(void) + void Pause(void) override { if (status_ != kPlaying) return; @@ -954,7 +957,7 @@ class MIDIPlayer : public AbstractMusicPlayer status_ = kPaused; } - void Resume(void) + void Resume(void) override { if (status_ != kPaused) return; @@ -964,7 +967,7 @@ class MIDIPlayer : public AbstractMusicPlayer status_ = kPlaying; } - void Ticker(void) + void Ticker(void) override { if (fluidlite_gain.CheckModified()) { diff --git a/source_files/edge/s_mp3.cc b/source_files/edge/s_mp3.cc index cc6bc4c7c..56129676c 100644 --- a/source_files/edge/s_mp3.cc +++ b/source_files/edge/s_mp3.cc @@ -37,23 +37,23 @@ class MP3Player : public AbstractMusicPlayer { public: MP3Player(); - ~MP3Player(); + ~MP3Player() override; private: - uint8_t *mp3_data_; + const uint8_t *mp3_data_; public: - bool OpenMemory(uint8_t *data, int length); + bool OpenMemory(const uint8_t *data, int length); - virtual void Close(void); + void Close(void) override; - virtual void Play(bool loop); - virtual void Stop(void); + void Play(bool loop) override; + void Stop(void) override; - virtual void Pause(void); - virtual void Resume(void); + void Pause(void) override; + void Resume(void) override; - virtual void Ticker(void); + void Ticker(void) override; }; //---------------------------------------------------------------------------- @@ -68,7 +68,7 @@ MP3Player::~MP3Player() Close(); } -bool MP3Player::OpenMemory(uint8_t *data, int length) +bool MP3Player::OpenMemory(const uint8_t *data, int length) { if (status_ != kNotLoaded) Close(); diff --git a/source_files/edge/s_ogg.cc b/source_files/edge/s_ogg.cc index 4fc19c9b0..36cbb4e79 100644 --- a/source_files/edge/s_ogg.cc +++ b/source_files/edge/s_ogg.cc @@ -50,15 +50,12 @@ static int ogg_epi_memseek(void *datasource, ogg_int64_t offset, int whence) { case SEEK_SET: { return d->Seek(offset, epi::File::kSeekpointStart) ? 0 : -1; - break; } case SEEK_CUR: { return d->Seek(offset, epi::File::kSeekpointCurrent) ? 0 : -1; - break; } case SEEK_END: { return d->Seek(-offset, epi::File::kSeekpointEnd) ? 0 : -1; - break; } default: { return -1; @@ -112,9 +109,9 @@ static void ma_stbvorbis_uninit(ma_stbvorbis *pVorbis, const ma_allocation_ static ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis *pVorbis, void *pFramesOut, ma_uint64 frameCount, ma_uint64 *pFramesRead); static ma_result ma_stbvorbis_seek_to_pcm_frame(ma_stbvorbis *pVorbis, ma_uint64 frameIndex); -static ma_result ma_stbvorbis_get_data_format(ma_stbvorbis *pVorbis, ma_format *pFormat, ma_uint32 *pChannels, +static ma_result ma_stbvorbis_get_data_format(const ma_stbvorbis *pVorbis, ma_format *pFormat, ma_uint32 *pChannels, ma_uint32 *pSampleRate, ma_channel *pChannelMap, size_t channelMapCap); -static ma_result ma_stbvorbis_get_cursor_in_pcm_frames(ma_stbvorbis *pVorbis, ma_uint64 *pCursor); +static ma_result ma_stbvorbis_get_cursor_in_pcm_frames(const ma_stbvorbis *pVorbis, ma_uint64 *pCursor); static ma_result ma_stbvorbis_get_length_in_pcm_frames(ma_stbvorbis *pVorbis, ma_uint64 *pLength); static ma_result ma_stbvorbis_ds_read(ma_data_source *pDataSource, void *pFramesOut, ma_uint64 frameCount, @@ -184,7 +181,7 @@ static ma_result ma_stbvorbis_post_init(ma_stbvorbis *pVorbis) { EPI_ASSERT(pVorbis != NULL); - vorbis_info *info = ov_info(&pVorbis->ogg, -1); + const vorbis_info *info = ov_info(&pVorbis->ogg, -1); if (info == NULL) { @@ -371,7 +368,7 @@ static ma_result ma_stbvorbis_seek_to_pcm_frame(ma_stbvorbis *pVorbis, ma_uint64 return MA_SUCCESS; } -static ma_result ma_stbvorbis_get_data_format(ma_stbvorbis *pVorbis, ma_format *pFormat, ma_uint32 *pChannels, +static ma_result ma_stbvorbis_get_data_format(const ma_stbvorbis *pVorbis, ma_format *pFormat, ma_uint32 *pChannels, ma_uint32 *pSampleRate, ma_channel *pChannelMap, size_t channelMapCap) { /* Defaults for safety. */ @@ -420,7 +417,7 @@ static ma_result ma_stbvorbis_get_data_format(ma_stbvorbis *pVorbis, ma_format * return MA_SUCCESS; } -static ma_result ma_stbvorbis_get_cursor_in_pcm_frames(ma_stbvorbis *pVorbis, ma_uint64 *pCursor) +static ma_result ma_stbvorbis_get_cursor_in_pcm_frames(const ma_stbvorbis *pVorbis, ma_uint64 *pCursor) { if (pCursor == NULL) { @@ -549,23 +546,23 @@ class OGGPlayer : public AbstractMusicPlayer { public: OGGPlayer(); - ~OGGPlayer(); + ~OGGPlayer() override; private: - uint8_t *ogg_data_; + const uint8_t *ogg_data_; public: - bool OpenMemory(uint8_t *data, int length); + bool OpenMemory(const uint8_t *data, int length); - virtual void Close(void); + void Close(void) override; - virtual void Play(bool loop); - virtual void Stop(void); + void Play(bool loop) override; + void Stop(void) override; - virtual void Pause(void); - virtual void Resume(void); + void Pause(void) override; + void Resume(void) override; - virtual void Ticker(void); + void Ticker(void) override; }; //---------------------------------------------------------------------------- @@ -580,7 +577,7 @@ OGGPlayer::~OGGPlayer() Close(); } -bool OGGPlayer::OpenMemory(uint8_t *data, int length) +bool OGGPlayer::OpenMemory(const uint8_t *data, int length) { if (status_ != kNotLoaded) Close(); diff --git a/source_files/edge/s_sound.cc b/source_files/edge/s_sound.cc index 7f3add704..07757c1bf 100644 --- a/source_files/edge/s_sound.cc +++ b/source_files/edge/s_sound.cc @@ -79,7 +79,7 @@ static int FindFreeChannel(void) { for (int i = 0; i < total_channels; i++) { - SoundChannel *chan = mix_channels[i]; + const SoundChannel *chan = mix_channels[i]; if (chan->state_ == kChannelFinished) KillSoundChannel(i); @@ -91,11 +91,11 @@ static int FindFreeChannel(void) return -1; // not found } -static int FindPlayingFX(SoundEffectDefinition *def, int cat, Position *pos) +static int FindPlayingFX(const SoundEffectDefinition *def, int cat, const Position *pos) { for (int i = 0; i < total_channels; i++) { - SoundChannel *chan = mix_channels[i]; + const SoundChannel *chan = mix_channels[i]; if (chan->state_ == kChannelPlaying && chan->category_ == cat && chan->position_ == pos) { @@ -145,14 +145,14 @@ static void CountPlayingCats(void) for (int i = 0; i < total_channels; i++) { - SoundChannel *chan = mix_channels[i]; + const SoundChannel *chan = mix_channels[i]; if (chan->state_ == kChannelPlaying) category_counts[chan->category_] += 1; } } -static int ChannelScore(SoundEffectDefinition *def, int category, Position *pos, bool boss) +static int ChannelScore(const SoundEffectDefinition *def, int category, const Position *pos, bool boss) { // for full-volume sounds, use the priority from DDF if (category <= kCategoryWeapon) @@ -179,7 +179,7 @@ static int FindChannelToKill(int kill_cat, int real_cat, int new_score) // new_score); for (int j = 0; j < total_channels; j++) { - SoundChannel *chan = mix_channels[j]; + const SoundChannel *chan = mix_channels[j]; if (chan->state_ != kChannelPlaying) continue; @@ -253,7 +253,7 @@ SoundEffectDefinition *LookupEffectDef(const SoundEffect *s) return sfxdefs[num]; } -static void S_PlaySound(int idx, SoundEffectDefinition *def, int category, Position *pos, int flags, SoundData *buf) +static void S_PlaySound(int idx, const SoundEffectDefinition *def, int category, const Position *pos, int flags, SoundData *buf) { SoundChannel *chan = mix_channels[idx]; @@ -323,7 +323,7 @@ static void S_PlaySound(int idx, SoundEffectDefinition *def, int category, Posit ma_sound_start(&chan->channel_sound_); } -static void DoStartFX(SoundEffectDefinition *def, int category, Position *pos, int flags, SoundData *buf) +static void DoStartFX(const SoundEffectDefinition *def, int category, const Position *pos, int flags, SoundData *buf) { CountPlayingCats(); @@ -386,7 +386,7 @@ static void DoStartFX(SoundEffectDefinition *def, int category, Position *pos, i S_PlaySound(k, def, category, pos, flags, buf); } -void StartSoundEffect(SoundEffect *sfx, int category, Position *pos, int flags) +void StartSoundEffect(const SoundEffect *sfx, int category, const Position *pos, int flags) { if (no_sound || !sfx) return; @@ -427,14 +427,14 @@ void StartSoundEffect(SoundEffect *sfx, int category, Position *pos, int flags) DoStartFX(def, category, pos, flags, buf); } -void StopSoundEffect(Position *pos) +void StopSoundEffect(const Position *pos) { if (no_sound) return; for (int i = 0; i < total_channels; i++) { - SoundChannel *chan = mix_channels[i]; + const SoundChannel *chan = mix_channels[i]; if (chan->state_ == kChannelPlaying && chan->position_ == pos) { @@ -451,7 +451,7 @@ void StopLevelSoundEffects(void) for (int i = 0; i < total_channels; i++) { - SoundChannel *chan = mix_channels[i]; + const SoundChannel *chan = mix_channels[i]; if (chan->state_ != kChannelEmpty && chan->category_ != kCategoryUi) { @@ -467,7 +467,7 @@ void StopAllSoundEffects(void) for (int i = 0; i < total_channels; i++) { - SoundChannel *chan = mix_channels[i]; + const SoundChannel *chan = mix_channels[i]; if (chan->state_ != kChannelEmpty) { diff --git a/source_files/edge/s_sound.h b/source_files/edge/s_sound.h index a805ee851..a032cdd34 100644 --- a/source_files/edge/s_sound.h +++ b/source_files/edge/s_sound.h @@ -78,9 +78,9 @@ enum SoundEffectFlag void InitializeSound(void); void ShutdownSound(void); -void StartSoundEffect(struct SoundEffect *sfx, int category = kCategoryUi, Position *pos = nullptr, int flags = 0); +void StartSoundEffect(const SoundEffect *sfx, int category = kCategoryUi, const Position *pos = nullptr, int flags = 0); -void StopSoundEffect(Position *pos); +void StopSoundEffect(const Position *pos); void StopLevelSoundEffects(void); void StopAllSoundEffects(void); diff --git a/source_files/edge/s_wav.cc b/source_files/edge/s_wav.cc index c38e01722..b1817d058 100644 --- a/source_files/edge/s_wav.cc +++ b/source_files/edge/s_wav.cc @@ -28,7 +28,7 @@ #include "snd_gather.h" #include "w_wad.h" -bool LoadWAVSound(SoundData *buf, uint8_t *data, int length) +bool LoadWAVSound(SoundData *buf, const uint8_t *data, int length) { ma_decoder_config decode_config = ma_decoder_config_init_default(); decode_config.format = ma_format_f32; diff --git a/source_files/edge/s_wav.h b/source_files/edge/s_wav.h index 976209a29..15c9ca485 100644 --- a/source_files/edge/s_wav.h +++ b/source_files/edge/s_wav.h @@ -22,7 +22,7 @@ #include "snd_data.h" -bool LoadWAVSound(SoundData *buf, uint8_t *data, int length); +bool LoadWAVSound(SoundData *buf, const uint8_t *data, int length); //--- editor settings --- // vi:ts=4:sw=4:noexpandtab diff --git a/source_files/edge/snd_gather.cc b/source_files/edge/snd_gather.cc index 13413f4ce..301e30efb 100644 --- a/source_files/edge/snd_gather.cc +++ b/source_files/edge/snd_gather.cc @@ -116,7 +116,7 @@ bool SoundGatherer::Finalise(SoundData *buf) return true; } -void SoundGatherer::TransferStereo(GatherChunk *chunk, SoundData *buf, int pos) +void SoundGatherer::TransferStereo(GatherChunk *chunk, const SoundData *buf, int pos) { int count = chunk->total_samples_; diff --git a/source_files/edge/snd_gather.h b/source_files/edge/snd_gather.h index 7b58e11c1..4c9a9eccd 100644 --- a/source_files/edge/snd_gather.h +++ b/source_files/edge/snd_gather.h @@ -62,7 +62,7 @@ class SoundGatherer // otherwise returns true (success). private: - void TransferStereo(GatherChunk *chunk, SoundData *buf, int pos); + void TransferStereo(GatherChunk *chunk, const SoundData *buf, int pos); }; //--- editor settings --- diff --git a/source_files/edge/sv_chunk.cc b/source_files/edge/sv_chunk.cc index 45e74072d..9bbfe9c2e 100644 --- a/source_files/edge/sv_chunk.cc +++ b/source_files/edge/sv_chunk.cc @@ -111,7 +111,7 @@ int SaveGetError(void) // READING PRIMITIVES //---------------------------------------------------------------------------- -bool SaveFileOpenRead(std::string filename) +bool SaveFileOpenRead(const std::string &filename) { LogDebug("Opening savegame file (R): %s\n", filename.c_str()); @@ -457,7 +457,7 @@ bool SaveSkipReadChunk(const char *id) // WRITING PRIMITIVES //---------------------------------------------------------------------------- -bool SaveFileOpenWrite(std::string filename, int version) +bool SaveFileOpenWrite(const std::string &filename, int version) { LogDebug("Opening savegame file (W): %s\n", filename.c_str()); diff --git a/source_files/edge/sv_chunk.h b/source_files/edge/sv_chunk.h index 2d383afb0..826fe1ccc 100644 --- a/source_files/edge/sv_chunk.h +++ b/source_files/edge/sv_chunk.h @@ -38,7 +38,7 @@ int SaveGetError(void); // READING // -bool SaveFileOpenRead(std::string filename); +bool SaveFileOpenRead(const std::string &filename); bool SaveFileCloseRead(void); bool SaveFileVerifyHeader(int *version); bool SaveFileVerifyContents(void); @@ -65,7 +65,7 @@ bool SaveChunkGetMarker(char id[5]); // WRITING // -bool SaveFileOpenWrite(std::string filename, int version); +bool SaveFileOpenWrite(const std::string &filename, int version); bool SaveFileCloseWrite(void); bool SavePushWriteChunk(const char *id); diff --git a/source_files/edge/sv_mobj.cc b/source_files/edge/sv_mobj.cc index f42e04eab..58212af6a 100644 --- a/source_files/edge/sv_mobj.cc +++ b/source_files/edge/sv_mobj.cc @@ -419,8 +419,7 @@ void SaveGameMapObjectFinaliseElems(void) // Lobo fix for RTS ONDEATH actions not working // when loading a game - if (seen_monsters.count(mo->info_) == 0) - seen_monsters.insert(mo->info_); + seen_monsters.insert(mo->info_); } } diff --git a/source_files/edge/w_epk.cc b/source_files/edge/w_epk.cc index 2f1c13b01..d4b9ca86e 100644 --- a/source_files/edge/w_epk.cc +++ b/source_files/edge/w_epk.cc @@ -295,7 +295,7 @@ void PackFile::SortEntries() // DIRECTORY READING //---------------------------------------------------------------------------- -static void ProcessSubDirectory(PackFile *pack, std::string &fullpath) +static void ProcessSubDirectory(PackFile *pack, const std::string &fullpath) { std::vector fsd; @@ -373,7 +373,7 @@ static PackFile *ProcessFolder(DataFile *df) epi::File *PackFile::OpenFolderEntry(size_t dir, size_t index) { - std::string &filename = directories_[dir].entries_[index].full_path_; + const std::string &filename = directories_[dir].entries_[index].full_path_; epi::File *F = epi::FileOpen(filename, epi::kFileAccessRead | epi::kFileAccessBinary); @@ -500,23 +500,23 @@ class ZIPFile : public epi::File EPI_ASSERT(iter); } - ~ZIPFile() + ~ZIPFile() override { if (iter != nullptr) mz_zip_reader_extract_iter_free(iter); } - int GetLength() + int GetLength() override { return (int)length; } - int GetPosition() + int GetPosition() override { return (int)pos; } - unsigned int Read(void *dest, unsigned int count) + unsigned int Read(void *dest, unsigned int count) override { if (pos >= length) return 0; @@ -532,7 +532,7 @@ class ZIPFile : public epi::File return got; } - unsigned int Write(const void *src, unsigned int count) + unsigned int Write(const void *src, unsigned int count) override { EPI_UNUSED(src); EPI_UNUSED(count); @@ -541,7 +541,7 @@ class ZIPFile : public epi::File return 0; } - bool Seek(int offset, int seekpoint) + bool Seek(int offset, int seekpoint) override { mz_uint want_pos = pos; @@ -649,7 +649,7 @@ static void ProcessDDFInPack(PackFile *pack) { for (size_t entry = 0; entry < pack->directories_[dir].entries_.size(); entry++) { - PackEntry &ent = pack->directories_[dir].entries_[entry]; + const PackEntry &ent = pack->directories_[dir].entries_[entry]; std::string source = ent.name_; source += " in "; @@ -1202,7 +1202,7 @@ epi::File *OpenPackMatch(PackFile *pack, const std::string &name, const std::vec auto results = pack->search_files_.equal_range(open_stem); for (auto file = results.first; file != results.second; ++file) { - for (auto ext : extensions) + for (const std::string &ext : extensions) { epi::ReplaceExtension(stem_match, ext); if (epi::StringCaseCompareASCII(stem_match, epi::GetFilename(file->second)) == 0) @@ -1304,7 +1304,7 @@ int CheckPackForIWADs(DataFile *df) { for (size_t i = 0; i < pack->directories_[d].entries_.size(); i++) { - PackEntry &entry = pack->directories_[d].entries_[i]; + const PackEntry &entry = pack->directories_[d].entries_[i]; if (!entry.HasExtension(".wad")) continue; diff --git a/source_files/edge/w_files.cc b/source_files/edge/w_files.cc index ee161d31a..acff4ebbc 100644 --- a/source_files/edge/w_files.cc +++ b/source_files/edge/w_files.cc @@ -57,7 +57,7 @@ std::vector data_files; -DataFile::DataFile(std::string name, FileKind kind) +DataFile::DataFile(std::string_view name, FileKind kind) : name_(name), kind_(kind), file_(nullptr), wad_(nullptr), pack_(nullptr) { } @@ -71,7 +71,7 @@ int GetTotalFiles() return (int)data_files.size(); } -size_t AddDataFile(std::string file, FileKind kind) +size_t AddDataFile(const std::string &file, FileKind kind) { LogDebug("Added filename: %s\n", file.c_str()); @@ -87,7 +87,7 @@ size_t AddDataFile(std::string file, FileKind kind) std::vector pending_files; -size_t AddPendingFile(std::string file, FileKind kind) +size_t AddPendingFile(std::string_view file, FileKind kind) { size_t index = pending_files.size(); @@ -103,7 +103,7 @@ extern void ProcessWad(DataFile *df, size_t file_index); extern std::string BuildXGLNodesForWAD(DataFile *df); #ifdef EDGE_CLASSIC -static void DEH_ConvertFile(std::string &filename) +static void DEH_ConvertFile(const std::string &filename) { epi::File *F = epi::FileOpen(filename, epi::kFileAccessRead | epi::kFileAccessBinary); if (F == nullptr) diff --git a/source_files/edge/w_files.h b/source_files/edge/w_files.h index d321c5145..13ba8b49b 100644 --- a/source_files/edge/w_files.h +++ b/source_files/edge/w_files.h @@ -73,18 +73,18 @@ class DataFile PackFile *pack_; public: - DataFile(std::string name, FileKind kind); + DataFile(std::string_view name, FileKind kind); ~DataFile(); }; extern std::vector data_files; -size_t AddDataFile(std::string file, FileKind kind); +size_t AddDataFile(const std::string &file, FileKind kind); int GetTotalFiles(); void ShowLoadedFiles(); void ProcessMultipleFiles(); -size_t AddPendingFile(std::string file, FileKind kind); +size_t AddPendingFile(std::string_view file, FileKind kind); void ProcessFile(DataFile *df); epi::File *OpenFileFromPack(const std::string &name); diff --git a/source_files/edge/w_flat.cc b/source_files/edge/w_flat.cc index 5cff7ddab..0f7abdec4 100644 --- a/source_files/edge/w_flat.cc +++ b/source_files/edge/w_flat.cc @@ -146,7 +146,7 @@ static void AddFlatAnimation(AnimationDefinition *anim) return; } - std::vector *lumps = GetFlatListForWAD(file); + const std::vector *lumps = GetFlatListForWAD(file); if (lumps == nullptr) return; diff --git a/source_files/edge/w_model.cc b/source_files/edge/w_model.cc index 0ce0ee9cb..922114fb2 100644 --- a/source_files/edge/w_model.cc +++ b/source_files/edge/w_model.cc @@ -284,10 +284,8 @@ ModelDefinition *LoadModelFromLump(int model_num) else FatalError("Missing model skin: %sSKN1\n", basename.c_str()); } - } - - if (def->md2_model_) FindModelFrameNames(def->md2_model_, model_num); + } if (def->mdl_model_) FindModelFrameNames(def->mdl_model_, model_num); @@ -390,7 +388,7 @@ void PrecacheModels(void) { LogDebug("Precaching model: %s\n", ddf_model_names[i].c_str()); - ModelDefinition *def = GetModel(i); + const ModelDefinition *def = GetModel(i); // precache skins too for (int n = 0; n < 10; n++) diff --git a/source_files/edge/w_sprite.cc b/source_files/edge/w_sprite.cc index 92d711be9..767da9ac4 100644 --- a/source_files/edge/w_sprite.cc +++ b/source_files/edge/w_sprite.cc @@ -63,9 +63,9 @@ class SpriteDefinition SpriteFrame *frames_; public: - SpriteDefinition(std::string name) : total_frames_(0), frames_(nullptr) + SpriteDefinition(std::string_view name) : name_(name), total_frames_(0), frames_(nullptr) { - name_ = name; + } ~SpriteDefinition() @@ -238,7 +238,7 @@ static void InstallSpriteLump(SpriteDefinition *def, int lump, const char *lumpn frame->finished_ = true; } -static void InstallSpritePack(SpriteDefinition *def, PackFile *pack, std::string spritebase, std::string packname, +static void InstallSpritePack(SpriteDefinition *def, PackFile *pack, const std::string &spritebase, const std::string &packname, int pos, uint8_t flip) { SpriteFrame *frame = WhatFrame(def, spritebase.c_str(), pos); @@ -296,7 +296,7 @@ static void FillSpriteFrames(int file) { if (data_files[file]->wad_) { - std::vector *lumps = GetSpriteListForWAD(file); + const std::vector *lumps = GetSpriteListForWAD(file); if (lumps == nullptr) return; @@ -490,7 +490,6 @@ static void MarkCompletedFrames(void) for (int f = 0; f < def->total_frames_; f++) { - char frame_ch = 'A' + f; SpriteFrame *frame = def->frames_ + f; if (frame->finished_) @@ -513,7 +512,7 @@ static void MarkCompletedFrames(void) if (rot_count < frame->rotations_) { - LogWarning("Sprite %s:%c is missing rotations (%d of %d).\n", def->name_.c_str(), frame_ch, + LogWarning("Sprite %s:%c is missing rotations (%d of %d).\n", def->name_.c_str(), 'A' + f, frame->rotations_ - rot_count, frame->rotations_); // try to fix cases where some dumbass used A1 instead of A0 @@ -632,10 +631,8 @@ void InitializeSprites(void) if (st->sprite == 0) continue; - SpriteDefinition *def = sprites[st->sprite]; - if (st->flags & kStateFrameFlagWeapon) - def->frames_[st->frame].is_weapon_ = true; + sprites[st->sprite]->frames_[st->frame].is_weapon_ = true; } // 5. Fill in frames using wad lumps + images.ddf diff --git a/source_files/edge/w_texture.cc b/source_files/edge/w_texture.cc index dc76d9eed..bf99c55fe 100644 --- a/source_files/edge/w_texture.cc +++ b/source_files/edge/w_texture.cc @@ -465,8 +465,8 @@ void InitializeTextures(void) for (int k = 1; k < numtextures; k++) { - TextureDefinition *a = textures[k - 1]; - TextureDefinition *b = textures[k]; + const TextureDefinition *a = textures[k - 1]; + const TextureDefinition *b = textures[k]; if (strcmp(a->name, b->name) == 0) { diff --git a/source_files/edge/w_wad.cc b/source_files/edge/w_wad.cc index 64a085987..fa7a43fb2 100644 --- a/source_files/edge/w_wad.cc +++ b/source_files/edge/w_wad.cc @@ -315,12 +315,12 @@ static bool IsP_END(char *name) // // Is the name a colourmap list start/end flag? // -static bool IsC_START(char *name) +static bool IsC_START(const char *name) { return (strncmp(name, "C_START", 8) == 0); } -static bool IsC_END(char *name) +static bool IsC_END(const char *name) { return (strncmp(name, "C_END", 8) == 0); } @@ -328,12 +328,12 @@ static bool IsC_END(char *name) // // Is the name a texture list start/end flag? // -static bool IsTX_START(char *name) +static bool IsTX_START(const char *name) { return (strncmp(name, "TX_START", 8) == 0); } -static bool IsTX_END(char *name) +static bool IsTX_END(const char *name) { return (strncmp(name, "TX_END", 8) == 0); } @@ -341,12 +341,12 @@ static bool IsTX_END(char *name) // // Is the name a high-resolution start/end flag? // -static bool IsHI_START(char *name) +static bool IsHI_START(const char *name) { return (strncmp(name, "HI_START", 8) == 0); } -static bool IsHI_END(char *name) +static bool IsHI_END(const char *name) { return (strncmp(name, "HI_END", 8) == 0); } @@ -354,12 +354,12 @@ static bool IsHI_END(char *name) // // Is the name a XGL nodes start/end flag? // -static bool IsXG_START(char *name) +static bool IsXG_START(const char *name) { return (strncmp(name, "XG_START", 8) == 0); } -static bool IsXG_END(char *name) +static bool IsXG_END(const char *name) { return (strncmp(name, "XG_END", 8) == 0); } @@ -884,7 +884,7 @@ int CheckForUniqueGameLumps(epi::File *file) if (lump1_found && lump2_found) break; - RawWadEntry &entry = raw_info[i]; + const RawWadEntry &entry = raw_info[i]; if (strncmp(lump0, entry.name, 8) == 0) { @@ -1042,7 +1042,7 @@ static void ProcessCOALInWad(DataFile *df) { std::string bare_filename = epi::GetFilename(df->name_); - WadFile *wad = df->wad_; + const WadFile *wad = df->wad_; if (wad->coal_huds_ >= 0) { @@ -1064,7 +1064,7 @@ static void ProcessLuaInWad(DataFile *df) { std::string bare_filename = epi::GetFilename(df->name_); - WadFile *wad = df->wad_; + const WadFile *wad = df->wad_; if (wad->lua_huds_ >= 0) { @@ -1160,7 +1160,7 @@ void ProcessWad(DataFile *df, size_t file_index) for (size_t i = 0; i < header.total_entries; i++) { - RawWadEntry &entry = raw_info[i]; + const RawWadEntry &entry = raw_info[i]; bool allow_ddf = (epi::StringCompare(game_base, "custom") == 0 || df->kind_ == kFileKindPWAD || df->kind_ == kFileKindPackWAD || df->kind_ == kFileKindIPK || df->kind_ == kFileKindIFolder); @@ -1787,7 +1787,7 @@ epi::File *LoadLumpAsFile(int lump) { EPI_ASSERT(IsLumpIndexValid(lump)); - LumpInfo *l = &lump_info[lump]; + const LumpInfo *l = &lump_info[lump]; DataFile *df = data_files[l->file]; @@ -2063,7 +2063,7 @@ int CheckPatchLumpNumberForName(const char *name) for (; i < (int)lump_info.size() && epi::StringCompareMax(lump_info[sorted_lumps[i]].name, buf, 8) == 0; i++) { - LumpInfo *L = &lump_info[sorted_lumps[i]]; + const LumpInfo *L = &lump_info[sorted_lumps[i]]; if (L->kind == kLumpPatch || L->kind == kLumpSprite || L->kind == kLumpNormal) { @@ -2453,16 +2453,15 @@ bool IsLumpInPwad(const char *name) // if we're here then check pwad lumps int lumpnum = CheckLumpNumberForName(name); - int filenum = -1; bool in_pwad = false; if (lumpnum != -1) { - filenum = GetDataFileIndexForLump(lumpnum); + int filenum = GetDataFileIndexForLump(lumpnum); if (filenum >= 2) // ignore edge_defs and the IWAD itself { - DataFile *df = data_files[filenum]; + const DataFile *df = data_files[filenum]; // we only want pwads if (df->kind_ == kFileKindPWAD || df->kind_ == kFileKindPackWAD) diff --git a/source_files/epi/epi.h b/source_files/epi/epi.h index 7496f1449..9f23a2b52 100644 --- a/source_files/epi/epi.h +++ b/source_files/epi/epi.h @@ -34,12 +34,12 @@ /* Important functions provided by Engine code */ #ifdef __GNUC__ -void FatalError(const char *error, ...) __attribute__((format(printf, 1, 2))); +[[noreturn]] void FatalError(const char *error, ...) __attribute__((format(printf, 1, 2))); void LogWarning(const char *warning, ...) __attribute__((format(printf, 1, 2))); void LogPrint(const char *message, ...) __attribute__((format(printf, 1, 2))); void LogDebug(const char *message, ...) __attribute__((format(printf, 1, 2))); #else -void FatalError(const char *error, ...); +[[noreturn]] void FatalError(const char *error, ...); void LogWarning(const char *warning, ...); void LogPrint(const char *message, ...); void LogDebug(const char *message, ...); diff --git a/source_files/epi/epi_file.h b/source_files/epi/epi_file.h index fcda0b811..352603c20 100644 --- a/source_files/epi/epi_file.h +++ b/source_files/epi/epi_file.h @@ -75,16 +75,16 @@ class ANSIFile : public File public: ANSIFile(FILE *filep); - ~ANSIFile(); + ~ANSIFile() override; public: - int GetLength(); - int GetPosition(); + int GetLength() override; + int GetPosition() override; - unsigned int Read(void *dest, unsigned int size); - unsigned int Write(const void *src, unsigned int size); + unsigned int Read(void *dest, unsigned int size) override; + unsigned int Write(const void *src, unsigned int size) override; - bool Seek(int offset, int seekpoint); + bool Seek(int offset, int seekpoint) override; }; class SubFile : public File @@ -98,21 +98,21 @@ class SubFile : public File public: SubFile(File *parent, int start, int len); - ~SubFile(); + ~SubFile() override; - int GetLength() + int GetLength() override { return length_; } - int GetPosition() + int GetPosition() override { return pos_; } - unsigned int Read(void *dest, unsigned int size); - unsigned int Write(const void *src, unsigned int size); + unsigned int Read(void *dest, unsigned int size) override; + unsigned int Write(const void *src, unsigned int size) override; - bool Seek(int offset, int seekpoint); + bool Seek(int offset, int seekpoint) override; }; class MemFile : public File @@ -126,21 +126,21 @@ class MemFile : public File public: MemFile(const uint8_t *block, int len, bool copy_it = true); - ~MemFile(); + ~MemFile() override; - int GetLength() + int GetLength() override { return length_; } - int GetPosition() + int GetPosition() override { return pos_; } - unsigned int Read(void *dest, unsigned int size); - unsigned int Write(const void *src, unsigned int size); + unsigned int Read(void *dest, unsigned int size) override; + unsigned int Write(const void *src, unsigned int size) override; - bool Seek(int offset, int seekpoint); + bool Seek(int offset, int seekpoint) override; }; } // namespace epi diff --git a/source_files/epi/epi_filesystem.cc b/source_files/epi/epi_filesystem.cc index 7b7d2a970..fe8d1640b 100644 --- a/source_files/epi/epi_filesystem.cc +++ b/source_files/epi/epi_filesystem.cc @@ -162,7 +162,7 @@ bool TestFileAccess(std::string_view name) else return false; } -bool ReadDirectory(std::vector &fsd, std::string &dir, const char *mask) +bool ReadDirectory(std::vector &fsd, const std::string &dir, const char *mask) { if (dir.empty() || !FileExists(dir) || !mask) return false; @@ -210,7 +210,7 @@ bool ReadDirectory(std::vector &fsd, std::string &dir, const cha CurrentDirectorySet(prev_dir); return true; } -bool WalkDirectory(std::vector &fsd, std::string &dir) +bool WalkDirectory(std::vector &fsd, const std::string &dir) { if (dir.empty() || !FileExists(dir)) return false; @@ -357,7 +357,7 @@ bool TestFileAccess(std::string_view name) EPI_ASSERT(!name.empty()); return access(std::string(name).c_str(), R_OK) == 0; } -bool ReadDirectory(std::vector &fsd, std::string &dir, const char *mask) +bool ReadDirectory(std::vector &fsd, const std::string &dir, const char *mask) { if (dir.empty() || !FileExists(dir) || !mask) return false; @@ -380,7 +380,7 @@ bool ReadDirectory(std::vector &fsd, std::string &dir, const cha for (;;) { - struct dirent *fdata = readdir(handle); + const struct dirent *fdata = readdir(handle); if (!fdata) break; @@ -433,7 +433,7 @@ static int WalkDirectoryCallback(const char *filename, const struct stat *stat_p } return 0; } -bool WalkDirectory(std::vector &fsd, std::string &dir) +bool WalkDirectory(std::vector &fsd, const std::string &dir) { if (dir.empty() || !FileExists(dir)) return false; @@ -619,7 +619,7 @@ void ReplaceExtension(std::string &path, std::string_view ext) // back up until a dot for (int p = path.size() - 1; p >= 0; p--) { - char &ch = path[p]; + const char &ch = path[p]; if (IsDirectorySeparator(ch)) break; diff --git a/source_files/epi/epi_filesystem.h b/source_files/epi/epi_filesystem.h index bc9075938..ba01b7949 100644 --- a/source_files/epi/epi_filesystem.h +++ b/source_files/epi/epi_filesystem.h @@ -61,8 +61,8 @@ void ReplaceExtension(std::string &path, std::string_view ext); bool CurrentDirectorySet(std::string_view dir); bool IsDirectory(std::string_view dir); bool MakeDirectory(std::string_view dir); -bool ReadDirectory(std::vector &fsd, std::string &dir, const char *mask); -bool WalkDirectory(std::vector &fsd, std::string &dir); +bool ReadDirectory(std::vector &fsd, const std::string &dir, const char *mask); +bool WalkDirectory(std::vector &fsd, const std::string &dir); bool OpenDirectory(const std::string &src); // Opens a directory in explorer, finder, etc // File Functions diff --git a/source_files/epi/epi_scanner.cpp b/source_files/epi/epi_scanner.cpp index 94f320038..9b9dbff51 100644 --- a/source_files/epi/epi_scanner.cpp +++ b/source_files/epi/epi_scanner.cpp @@ -361,7 +361,6 @@ bool Scanner::GetNextToken(bool expandState) unsigned int end = scan_position_; int integerBase = 10; bool floatHasDecimal = false; - bool floatHasExponent = false; bool stringFinished = false; // Strings are the only things that can have 0 length tokens. char cur = data_.at(scan_position_++); @@ -487,6 +486,7 @@ bool Scanner::GetNextToken(bool expandState) if (start == end) { + bool floatHasExponent = false; while (scan_position_ < length_) { cur = data_.at(scan_position_); diff --git a/source_files/epi/epi_str_compare.cc b/source_files/epi/epi_str_compare.cc index 6270e5000..fded5485b 100644 --- a/source_files/epi/epi_str_compare.cc +++ b/source_files/epi/epi_str_compare.cc @@ -33,8 +33,8 @@ int StringCompare(std::string_view A, std::string_view B) size_t B_pos = 0; size_t A_end = A.size(); size_t B_end = B.size(); - unsigned char AC = 0; - unsigned char BC = 0; + unsigned char AC; + unsigned char BC; for (;; A_pos++, B_pos++) { @@ -64,8 +64,8 @@ int StringCompareMax(std::string_view A, std::string_view B, size_t n) size_t B_pos = 0; size_t A_end = A.size(); size_t B_end = B.size(); - unsigned char AC = 0; - unsigned char BC = 0; + unsigned char AC; + unsigned char BC; for (;; A_pos++, B_pos++) { @@ -99,8 +99,8 @@ int StringCaseCompareASCII(std::string_view A, std::string_view B) size_t B_pos = 0; size_t A_end = A.size(); size_t B_end = B.size(); - unsigned char AC = 0; - unsigned char BC = 0; + unsigned char AC; + unsigned char BC; for (;; A_pos++, B_pos++) { @@ -138,8 +138,8 @@ int StringCaseCompareMaxASCII(std::string_view A, std::string_view B, size_t n) size_t B_pos = 0; size_t A_end = A.size(); size_t B_end = B.size(); - unsigned char AC = 0; - unsigned char BC = 0; + unsigned char AC; + unsigned char BC; for (;; A_pos++, B_pos++) { @@ -181,8 +181,8 @@ int StringPrefixCompare(std::string_view A, std::string_view B) size_t B_pos = 0; size_t A_end = A.size(); size_t B_end = B.size(); - unsigned char AC = 0; - unsigned char BC = 0; + unsigned char AC; + unsigned char BC; for (;; A_pos++, B_pos++) {