From 206de278b3c812cafb85c14cdc83e83c77943d30 Mon Sep 17 00:00:00 2001 From: dashodanger Date: Mon, 24 Jun 2024 15:23:12 -0600 Subject: [PATCH] First pass of string work --- source/bsp.cc | 4 +-- source/bsp.h | 4 +-- source/bsp_level.cc | 8 ++++- source/bsp_node.cc | 4 +++ source/csg_doom.cc | 4 +-- source/csg_local.h | 2 -- source/csg_main.cc | 28 +++++++-------- source/csg_main.h | 20 +++++------ source/ff_main.cc | 13 +++---- source/g_doom.cc | 14 ++++---- source/g_doom.h | 12 +++---- source/images.h | 24 ++++++------- source/lib_wad.cc | 8 ++--- source/lib_wad.h | 6 ++-- source/lib_zip.cc | 4 +-- source/lib_zip.h | 4 +-- source/m_addons.cc | 54 ++-------------------------- source/m_addons.h | 5 ++- source/m_cookie.cc | 53 ++++----------------------- source/m_cookie.h | 18 +++++----- source/m_lua.cc | 62 ++++++++++++-------------------- source/m_lua.h | 10 +++--- source/m_options.cc | 9 +++-- source/m_theme.cc | 4 +-- source/m_trans.cc | 41 +++++++++------------ source/main.cc | 2 +- source/slump.cc | 2 +- source/slump.h | 4 +-- source/slump_main.cc | 2 +- source/sys_macro.h | 4 +++ source/ui_build.cc | 9 +++-- source/ui_build.h | 4 +-- source/ui_game.cc | 6 ++-- source/ui_game.h | 6 ++-- source/ui_map.cc | 2 +- source/ui_map.h | 2 +- source/ui_module.cc | 86 ++++++++++++++++++++++---------------------- source/ui_module.h | 74 +++++++++++++++++++------------------- source/ui_widgets.cc | 19 +++++----- source/ui_widgets.h | 18 +++++----- 40 files changed, 269 insertions(+), 386 deletions(-) diff --git a/source/bsp.cc b/source/bsp.cc index 1e5298917..448ad1537 100644 --- a/source/bsp.cc +++ b/source/bsp.cc @@ -159,7 +159,7 @@ build_result_e BuildFile(buildinfo_t *build_info) return BUILD_OK; } -void VisitFile(std::string filename, buildinfo_t *build_info) +static void VisitFile(const std::string &filename, buildinfo_t *build_info) { LogPrint("\n"); LogPrint("Building %s\n", filename.c_str()); @@ -308,7 +308,7 @@ void CheckTypeSizes(buildinfo_t *build_info) assert_size(raw_vertex_t, 4); } -int AJBSP_BuildNodes(std::string filename, buildinfo_t *build_info) +int AJBSP_BuildNodes(const std::string &filename, buildinfo_t *build_info) { // need this early, especially for fatal errors in utility/wad code ajbsp::SetInfo(build_info); diff --git a/source/bsp.h b/source/bsp.h index 5715fb40a..2ab4694b4 100644 --- a/source/bsp.h +++ b/source/bsp.h @@ -87,7 +87,7 @@ typedef enum BUILD_LumpOverflow } build_result_e; -int AJBSP_BuildNodes(std::string filename, buildinfo_t *build_info); +int AJBSP_BuildNodes(const std::string &filename, buildinfo_t *build_info); namespace ajbsp { @@ -97,7 +97,7 @@ void SetInfo(buildinfo_t *info); // attempt to open a wad. on failure, the FatalError method in the // buildinfo_t interface is called. -void OpenWad(std::string filename); +void OpenWad(const std::string &filename); // close a previously opened wad. void CloseWad(); diff --git a/source/bsp_level.cc b/source/bsp_level.cc index 326327df8..88ac3f6d9 100644 --- a/source/bsp_level.cc +++ b/source/bsp_level.cc @@ -1220,6 +1220,9 @@ void GetLinedefs() num_real_lines++; line->self_ref = (line->left && line->right && (line->left->sector == line->right->sector)); + + if (line->self_ref) + line->is_precious = true; } } @@ -1482,6 +1485,9 @@ void ParseUDMF_Block(ajparse::lexer_c &lex, int cur_type) num_real_lines++; line->self_ref = (line->left && line->right && (line->left->sector == line->right->sector)); + + if (line->self_ref) + line->is_precious = true; } } @@ -2817,7 +2823,7 @@ void SetInfo(buildinfo_t *info) cur_info = info; } -void OpenWad(std::string filename) +void OpenWad(const std::string &filename) { cur_wad = Wad_file::Open(filename.c_str(), 'a'); if (cur_wad == NULL) diff --git a/source/bsp_node.cc b/source/bsp_node.cc index 1f0fad75c..a04870e12 100644 --- a/source/bsp_node.cc +++ b/source/bsp_node.cc @@ -532,6 +532,10 @@ void EvaluateFastWorker(quadtree_c *tree, seg_t **best_H, seg_t **best_V, int mi if (part->linedef == NULL) continue; + /* ignore self-ref and polyobj stuff as partition candidates */ + if (part->linedef->is_precious) + continue; + if (part->pdy == 0) { // horizontal seg diff --git a/source/csg_doom.cc b/source/csg_doom.cc index 9ab59b2fe..7ad491751 100644 --- a/source/csg_doom.cc +++ b/source/csg_doom.cc @@ -2268,7 +2268,7 @@ class dummy_line_info_c int flags; public: - dummy_line_info_c(std::string _tex, int _special = 0, int _tag = 0, int _flags = 0) + dummy_line_info_c(std::string_view _tex, int _special = 0, int _tag = 0, int _flags = 0) : tex(_tex), special(_special), tag(_tag), flags(_flags) { } @@ -2311,7 +2311,7 @@ class dummy_sector_c return (share_count >= DUMMY_MAX_SHARE); } - void AddInfo(std::string &tex, int special, int tag, int flags) + void AddInfo(std::string_view tex, int special, int tag, int flags) { SYS_ASSERT(!isFull()); diff --git a/source/csg_local.h b/source/csg_local.h index 87dc99096..24c4dc2b4 100644 --- a/source/csg_local.h +++ b/source/csg_local.h @@ -158,8 +158,6 @@ class region_c void ComputeMidPoint(); void ComputeBounds(); void ClockwiseSnags(); // requires CalcMidPoint() - - void DebugDump(); }; class gap_c diff --git a/source/csg_main.cc b/source/csg_main.cc index 21da88357..ba3cba251 100644 --- a/source/csg_main.cc +++ b/source/csg_main.cc @@ -203,36 +203,36 @@ extern int q_low_light; extern void SPOT_FillPolygon(uint8_t content, const int *shape, int count); -void csg_property_set_c::Add(std::string key, std::string value) +void csg_property_set_c::Add(const std::string &key, std::string_view value) { - dict[key] = std::string(value); + dict[key] = value; } -void csg_property_set_c::Remove(std::string key) +void csg_property_set_c::Remove(const std::string &key) { dict.erase(key); } -std::string csg_property_set_c::getStr(std::string key, std::string def_val) const +std::string csg_property_set_c::getStr(const std::string &key, std::string_view def_val) const { std::map::const_iterator PI = dict.find(key); if (PI == dict.end()) { - return def_val; + return std::string(def_val); } - return PI->second.c_str(); + return PI->second; } -double csg_property_set_c::getDouble(std::string key, double def_val) const +double csg_property_set_c::getDouble(const std::string &key, double def_val) const { std::string str = getStr(key); return !str.empty() ? StringToDouble(str) : def_val; } -int csg_property_set_c::getInt(std::string key, int def_val) const +int csg_property_set_c::getInt(const std::string &key, int def_val) const { std::string str = getStr(key); @@ -649,7 +649,7 @@ csg_entity_c::~csg_entity_c() { } -bool csg_entity_c::Match(std::string want_name) const +bool csg_entity_c::Match(std::string_view want_name) const { return (StringCompare(id, want_name) == 0); } @@ -779,7 +779,7 @@ class brush_quad_node_c private: bool IntersectBrush(const csg_brush_c *B, double x1, double y1, double z1, double x2, double y2, double z2, - std::string mode) + std::string_view mode) { if (mode[0] == 'v') { @@ -833,7 +833,7 @@ class brush_quad_node_c } public: - bool TraceRay(double x1, double y1, double z1, double x2, double y2, double z2, std::string mode) + bool TraceRay(double x1, double y1, double z1, double x2, double y2, double z2, std::string_view mode) { for (unsigned int k = 0; k < brushes.size(); k++) { @@ -1611,7 +1611,7 @@ int CSG_trace_ray(lua_State *L) return 1; } -bool CSG_TraceRay(double x1, double y1, double z1, double x2, double y2, double z2, std::string mode) +bool CSG_TraceRay(double x1, double y1, double z1, double x2, double y2, double z2, std::string_view mode) { SYS_ASSERT(brush_quad_tree); @@ -1644,7 +1644,7 @@ void CSG_spot_processing(int x1, int y1, int x2, int y2, int floor_h) //------------------------------------------------------------------------ -csg_property_set_c *CSG_LookupTexProps(std::string name) +csg_property_set_c *CSG_LookupTexProps(const std::string &name) { std::map::iterator TPI; @@ -1672,7 +1672,7 @@ static void CSG_FreeTexProps() all_tex_props.clear(); } -void CSG_LinkBrushToEntity(csg_brush_c *B, std::string link_key) +void CSG_LinkBrushToEntity(csg_brush_c *B, const std::string &link_key) { for (unsigned int k = 0; k < all_entities.size(); k++) { diff --git a/source/csg_main.h b/source/csg_main.h index 0ebb409e7..1f5b0696f 100644 --- a/source/csg_main.h +++ b/source/csg_main.h @@ -69,18 +69,16 @@ class csg_property_set_c { } - void Add(std::string key, std::string value); - void Remove(std::string key); + void Add(const std::string &key, std::string_view value); + void Remove(const std::string &key); - std::string getStr(std::string key, std::string def_val = "") const; + std::string getStr(const std::string &key, std::string_view def_val = "") const; - double getDouble(std::string key, double def_val = 0) const; - int getInt(std::string key, int def_val = 0) const; + double getDouble(const std::string &key, double def_val = 0) const; + int getInt(const std::string &key, int def_val = 0) const; void getHexenArgs(uint8_t *arg5) const; - void DebugDump(); - public: typedef std::map::iterator iterator; @@ -252,7 +250,7 @@ class csg_entity_c csg_entity_c(); ~csg_entity_c(); - bool Match(std::string want_name) const; + bool Match(std::string_view want_name) const; }; /***** VARIABLES ****************/ @@ -268,13 +266,13 @@ extern std::string dummy_plane_tex; void CSG_Main_Free(); -bool CSG_TraceRay(double x1, double y1, double z1, double x2, double y2, double z2, std::string mode); +bool CSG_TraceRay(double x1, double y1, double z1, double x2, double y2, double z2, std::string_view mode); int CSG_BrushContents(double x, double y, double z, double *liquid_depth = NULL); -csg_property_set_c *CSG_LookupTexProps(std::string name); +csg_property_set_c *CSG_LookupTexProps(const std::string &name); -void CSG_LinkBrushToEntity(csg_brush_c *B, std::string link_key); +void CSG_LinkBrushToEntity(csg_brush_c *B, const std::string &link_key); //--- editor settings --- // vi:ts=4:sw=4:noexpandtab diff --git a/source/ff_main.cc b/source/ff_main.cc index ff84dd5a8..670990ea4 100644 --- a/source/ff_main.cc +++ b/source/ff_main.cc @@ -5,6 +5,7 @@ #include #include "ff.h" +#include "lib_util.h" extern "C" { @@ -22,32 +23,32 @@ std::string result; void year() { - result.append(std::to_string(now.tm_year + 1900)); + result.append(NumToString(now.tm_year + 1900)); } void month() { - result.append(std::to_string(now.tm_mon + 1)); + result.append(NumToString(now.tm_mon + 1)); } void day() { - result.append(std::to_string(now.tm_mday)); + result.append(NumToString(now.tm_mday)); } void hour() { - result.append(std::to_string(now.tm_hour)); + result.append(NumToString(now.tm_hour)); } void minute() { - result.append(std::to_string(now.tm_min)); + result.append(NumToString(now.tm_min)); } void second() { - result.append(std::to_string(now.tm_sec)); + result.append(NumToString(now.tm_sec)); } void game() diff --git a/source/g_doom.cc b/source/g_doom.cc index 6676e28fb..ace0bdf99 100644 --- a/source/g_doom.cc +++ b/source/g_doom.cc @@ -345,7 +345,7 @@ bool BuildNodes(std::string filename) namespace Doom { -void WriteLump(std::string name, const void *data, uint32_t len) +void WriteLump(std::string_view name, const void *data, uint32_t len) { SYS_ASSERT(name.size() <= 8); @@ -363,7 +363,7 @@ void WriteLump(std::string name, const void *data, uint32_t len) } } // namespace Doom -void Doom::WriteLump(std::string name, qLump_c *lump) +void Doom::WriteLump(std::string_view name, qLump_c *lump) { WriteLump(name, lump->GetBuffer(), lump->GetSize()); } @@ -429,7 +429,7 @@ static void WriteSections() } // namespace Doom -void Doom::AddSectionLump(char ch, std::string name, qLump_c *lump) +void Doom::AddSectionLump(char ch, std::string_view name, qLump_c *lump) { int k; switch (ch) @@ -459,7 +459,7 @@ void Doom::AddSectionLump(char ch, std::string name, qLump_c *lump) sections[k]->push_back(lump); } -bool Doom::StartWAD(std::string filename) +bool Doom::StartWAD(const std::string &filename) { if (!WAD_OpenWrite(filename)) { @@ -562,7 +562,7 @@ int Doom::v094_begin_level(lua_State *L) return 0; } -void Doom::EndLevel(std::string level_name) +void Doom::EndLevel(const std::string &level_name) { // terminate header lump with trailing NUL if (header_lump->GetSize() > 0) @@ -695,7 +695,7 @@ int Doom::v094_add_vertex(lua_State *L) return 0; } -void Doom::AddSector(int f_h, std::string f_tex, int c_h, std::string c_tex, int light, int special, int tag) +void Doom::AddSector(int f_h, const std::string &f_tex, int c_h, const std::string &c_tex, int light, int special, int tag) { if (!UDMF_mode) { @@ -740,7 +740,7 @@ int Doom::v094_add_sector(lua_State *L) return 0; } -void Doom::AddSidedef(int sector, std::string l_tex, std::string m_tex, std::string u_tex, int x_offset, int y_offset) +void Doom::AddSidedef(int sector, const std::string &l_tex, const std::string &m_tex, const std::string &u_tex, int x_offset, int y_offset) { if (!UDMF_mode) { diff --git a/source/g_doom.h b/source/g_doom.h index 15c598bf7..e0fa8300d 100644 --- a/source/g_doom.h +++ b/source/g_doom.h @@ -78,27 +78,27 @@ extern int sub_format; /***** FUNCTIONS ****************/ -bool StartWAD(std::string filename); +bool StartWAD(const std::string &filename); bool EndWAD(); void BeginLevel(); -void EndLevel(std::string level_name); +void EndLevel(const std::string &level_name); -void WriteLump(std::string name, qLump_c *lump); +void WriteLump(std::string_view name, qLump_c *lump); // the section parameter can be: // 'P' : patches // 'F' : flats // 'S' : sprites // 'C' : colormaps (Boom) // 'T' : textures (Zdoom) -void AddSectionLump(char section, std::string name, qLump_c *lump); +void AddSectionLump(char section, std::string_view name, qLump_c *lump); void HeaderPrintf(const char *str, ...); void AddVertex(int x, int y); -void AddSector(int f_h, std::string f_tex, int c_h, std::string c_tex, int light, int special, int tag); +void AddSector(int f_h, const std::string &f_tex, int c_h, const std::string &c_tex, int light, int special, int tag); -void AddSidedef(int sector, std::string l_tex, std::string m_tex, std::string u_tex, int x_offset, int y_offset); +void AddSidedef(int sector, const std::string &l_tex, const std::string &m_tex, const std::string &u_tex, int x_offset, int y_offset); void AddLinedef(int vert1, int vert2, int side1, int side2, int type, int flags, int tag, const uint8_t *args); diff --git a/source/images.h b/source/images.h index efe9b2efb..4cb8e3f55 100644 --- a/source/images.h +++ b/source/images.h @@ -3,7 +3,7 @@ #pragma once #ifndef _WIN32 -static const char *obsidian_icon[] = { +static constexpr char *obsidian_icon[] = { "64 64 928 2", " c #000000", ". c #010101", @@ -1065,7 +1065,7 @@ static const char *obsidian_icon[] = { #endif /* XPM */ -static const char *clippy_xpm[] = { +static constexpr char *clippy_xpm[] = { "476 225 956 2", " c None", ". c #51514F", @@ -4164,7 +4164,7 @@ typedef struct // //------------------------------------------------------------------------ -const uint8_t image_data_BOLT[64 * 64] = { +constexpr uint8_t image_data_BOLT[64 * 64] = { 70, 70, 70, 70, 68, 68, 68, 68, 68, 68, 68, 52, 63, 68, 68, 70, 68, 68, 68, 68, 68, 68, 70, 70, 79, 79, 79, 79, 85, 93, 100, 108, 108, 108, 121, 121, 121, 121, 121, 121, 121, 114, 108, 108, 108, 93, 93, 93, 93, 93, 93, 93, 85, 79, 79, 79, 79, 79, 79, 70, 70, 70, 79, 79, 70, 70, 70, 70, 70, @@ -4345,7 +4345,7 @@ const uint8_t image_data_BOLT[64 * 64] = { 108, 100, 100, 100, 100, 93, 85, 85, 85, 85, 85, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 70, 70, 70, 68}; -const logo_image_t logo_BOLT = {"BOLT", 64, 64, image_data_BOLT}; +constexpr logo_image_t logo_BOLT = {"BOLT", 64, 64, image_data_BOLT}; //------------------------------------------------------------------------ // LOGO Data : "CARVE" image @@ -4370,7 +4370,7 @@ const logo_image_t logo_BOLT = {"BOLT", 64, 64, image_data_BOLT}; // Same as the RELIEF image for now -const uint8_t image_data_CARVE[64 * 64] = { +constexpr uint8_t image_data_CARVE[64 * 64] = { 17, 20, 20, 20, 20, 20, 20, 20, 21, 20, 17, 17, 17, 17, 17, 20, 20, 20, 20, 17, 17, 17, 17, 17, 17, 20, 20, 20, 17, 17, 17, 21, 20, 20, 20, 20, 20, 24, 17, 17, 20, 17, 17, 20, 17, 31, 20, 17, 31, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, @@ -4551,7 +4551,7 @@ const uint8_t image_data_CARVE[64 * 64] = { 31, 17, 17, 17, 20, 20, 20, 20, 20, 20, 20, 17, 20, 20, 20, 20, 20, 20, 17, 17, 20, 20, 20, 20, 20}; -const logo_image_t logo_CARVE = {"CARVE", 64, 64, image_data_CARVE}; +constexpr logo_image_t logo_CARVE = {"CARVE", 64, 64, image_data_CARVE}; //------------------------------------------------------------------------ // FONT Data : "CWILV" @@ -4573,7 +4573,7 @@ const logo_image_t logo_CARVE = {"CARVE", 64, 64, image_data_CARVE}; // //------------------------------------------------------------------------ -const uint8_t image_data_CWILV[99 * 64] = { +constexpr uint8_t image_data_CWILV[99 * 64] = { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, @@ -4851,7 +4851,7 @@ const uint8_t image_data_CWILV[99 * 64] = { 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 7, 28, 21, 4, 0, 0, 0, 0, 0}; -const logo_image_t font_CWILV = {"CWILV", 99, 64, image_data_CWILV}; +constexpr logo_image_t font_CWILV = {"CWILV", 99, 64, image_data_CWILV}; //------------------------------------------------------------------------ // LOGO Data : "PILL" image @@ -4874,7 +4874,7 @@ const logo_image_t font_CWILV = {"CWILV", 99, 64, image_data_CWILV}; // //------------------------------------------------------------------------ -const uint8_t image_data_PILL[128 * 32] = { +constexpr uint8_t image_data_PILL[128 * 32] = { 17, 9, 9, 9, 17, 17, 17, 17, 12, 12, 12, 12, 12, 12, 12, 12, 12, 20, 12, 12, 20, 20, 14, 14, 14, 17, 22, 22, 17, 17, 20, 20, 20, 20, 20, 20, 52, 20, 20, 22, 22, 52, 52, 52, 52, 52, 22, 20, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, @@ -5055,7 +5055,7 @@ const uint8_t image_data_PILL[128 * 32] = { 20, 20, 17, 17, 17, 17, 20, 20, 20, 20, 20, 12, 12, 12, 12, 12, 20, 12, 12, 12, 12, 5, 5, 9, 9}; -const logo_image_t logo_PILL = {"PILL", 128, 32, image_data_PILL}; +constexpr logo_image_t logo_PILL = {"PILL", 128, 32, image_data_PILL}; //------------------------------------------------------------------------ // LOGO Data : "RELIEF" image @@ -5078,7 +5078,7 @@ const logo_image_t logo_PILL = {"PILL", 128, 32, image_data_PILL}; // //------------------------------------------------------------------------ -const uint8_t image_data_RELIEF[64 * 64] = { +constexpr uint8_t image_data_RELIEF[64 * 64] = { 17, 20, 20, 20, 20, 20, 20, 20, 21, 20, 17, 17, 17, 17, 17, 20, 20, 20, 20, 17, 17, 17, 17, 17, 17, 20, 20, 20, 17, 17, 17, 21, 20, 20, 20, 20, 20, 24, 17, 17, 20, 17, 17, 20, 17, 31, 20, 17, 31, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, @@ -5259,4 +5259,4 @@ const uint8_t image_data_RELIEF[64 * 64] = { 31, 17, 17, 17, 20, 20, 20, 20, 20, 20, 20, 17, 20, 20, 20, 20, 20, 20, 17, 17, 20, 20, 20, 20, 20}; -const logo_image_t logo_RELIEF = {"RELIEF", 64, 64, image_data_RELIEF}; \ No newline at end of file +constexpr logo_image_t logo_RELIEF = {"RELIEF", 64, 64, image_data_RELIEF}; \ No newline at end of file diff --git a/source/lib_wad.cc b/source/lib_wad.cc index d4daf133a..931041d59 100644 --- a/source/lib_wad.cc +++ b/source/lib_wad.cc @@ -38,7 +38,7 @@ static PHYSFS_File *wad_R_fp; static raw_wad_header_t wad_R_header; static raw_wad_entry_t *wad_R_dir; -bool WAD_OpenRead(std::string filename) +bool WAD_OpenRead(const std::string &filename) { wad_R_fp = PHYSFS_openRead(filename.c_str()); @@ -198,7 +198,7 @@ static std::list wad_W_directory; static raw_wad_entry_t wad_W_lump; -bool WAD_OpenWrite(std::string filename) +bool WAD_OpenWrite(const std::string &filename) { wad_W_fp = FileOpen(filename, "wb"); @@ -267,11 +267,11 @@ void WAD_CloseWrite(void) wad_W_directory.clear(); } -void WAD_NewLump(std::string name) +void WAD_NewLump(std::string_view name) { if (name.size() > 8) { - FatalError("WAD_NewLump: name too long: '%s'\n", name.c_str()); + FatalError("WAD_NewLump: name too long: '%s'\n", std::string(name).c_str()); } memset(&wad_W_lump, 0, sizeof(wad_W_lump)); diff --git a/source/lib_wad.h b/source/lib_wad.h index 8ba0c5b05..72973860c 100644 --- a/source/lib_wad.h +++ b/source/lib_wad.h @@ -27,7 +27,7 @@ #include -bool WAD_OpenRead(std::string filename); +bool WAD_OpenRead(const std::string &filename); void WAD_CloseRead(); int WAD_NumEntries(); @@ -39,10 +39,10 @@ bool WAD_ReadData(int entry, int offset, int length, void *buffer); /* WAD writing */ -bool WAD_OpenWrite(std::string filename); +bool WAD_OpenWrite(const std::string &filename); void WAD_CloseWrite(); -void WAD_NewLump(std::string name); +void WAD_NewLump(std::string_view name); bool WAD_AppendData(const void *data, int length); void WAD_FinishLump(); diff --git a/source/lib_zip.cc b/source/lib_zip.cc index 3153037f8..28b9639a0 100644 --- a/source/lib_zip.cc +++ b/source/lib_zip.cc @@ -59,7 +59,7 @@ bool ZIPF_OpenWrite(const std::string &filename) return true; } -bool ZIPF_AddFile(const std::string &filename, std::string directory) +bool ZIPF_AddFile(const std::string &filename, std::string_view directory) { if (!zip_writer) { @@ -71,7 +71,7 @@ bool ZIPF_AddFile(const std::string &filename, std::string directory) } // Calling function is responsible for freeing *data -bool ZIPF_AddMem(std::string name, uint8_t *data, size_t length) +bool ZIPF_AddMem(const std::string &name, uint8_t *data, size_t length) { if (!zip_writer) { diff --git a/source/lib_zip.h b/source/lib_zip.h index c5dbb1f15..061e99142 100644 --- a/source/lib_zip.h +++ b/source/lib_zip.h @@ -28,8 +28,8 @@ /* ZIP writing */ bool ZIPF_OpenWrite(const std::string &filename); -bool ZIPF_AddFile(const std::string &filename, std::string directory); -bool ZIPF_AddMem(std::string name, uint8_t *data, size_t length); +bool ZIPF_AddFile(const std::string &filename, std::string_view directory); +bool ZIPF_AddMem(const std::string &name, uint8_t *data, size_t length); bool ZIPF_CloseWrite(); //--- editor settings --- diff --git a/source/m_addons.cc b/source/m_addons.cc index 8af947320..362be4250 100644 --- a/source/m_addons.cc +++ b/source/m_addons.cc @@ -103,7 +103,7 @@ bool VFS_AddArchive(std::string filename, bool options_file) return true; // Ok } -void VFS_InitAddons(std::string search_dir) +void VFS_InitAddons() { LogPrint("Initializing VFS...\n"); @@ -146,7 +146,7 @@ void VFS_ParseCommandLine() LogPrint("DONE\n\n"); } -void VFS_OptParse(std::string name) +void VFS_OptParse(const std::string &name) { // just remember it now if (initial_enabled_addons.find(name) == initial_enabled_addons.end()) @@ -269,56 +269,6 @@ void VFS_ScanForAddons() //---------------------------------------------------------------------- -// -// this is useful to "extract" something out of virtual FS to the real -// file system so we can use normal stdio file operations on it -// [ especially a _library_ that uses stdio.h ] -// -bool VFS_CopyFile(const char *src_name, const char *dest_name) -{ - char buffer[1024]; - - PHYSFS_file *src = PHYSFS_openRead(src_name); - if (!src) - { - return false; - } - - FILE *dest = FileOpen(dest_name, "wb"); - if (!dest) - { - PHYSFS_close(src); - return false; - } - - bool was_OK = true; - - while (was_OK) - { - int rlen = (int)(PHYSFS_readBytes(src, buffer, sizeof(buffer)) / sizeof(buffer)); - if (rlen < 0) - { - was_OK = false; - } - - if (rlen <= 0) - { - break; - } - - int wlen = fwrite(buffer, 1, rlen, dest); - if (wlen < rlen || ferror(dest)) - { - was_OK = false; - } - } - - fclose(dest); - PHYSFS_close(src); - - return was_OK; -} - uint8_t *VFS_LoadFile(const char *filename, int *length) { *length = 0; diff --git a/source/m_addons.h b/source/m_addons.h index d7484ed9f..72920b579 100644 --- a/source/m_addons.h +++ b/source/m_addons.h @@ -28,16 +28,15 @@ #include #include -void VFS_InitAddons(std::string search_dir); +void VFS_InitAddons(); void VFS_ParseCommandLine(); void VFS_ScanForAddons(); void VFS_ScanForPresets(); -void VFS_OptParse(std::string name); +void VFS_OptParse(const std::string &name); void VFS_OptWrite(FILE *fp); // util functions -bool VFS_CopyFile(const char *src_name, const char *dest_name); uint8_t *VFS_LoadFile(const char *filename, int *length); void VFS_FreeFile(const uint8_t *mem); diff --git a/source/m_cookie.cc b/source/m_cookie.cc index 9739bcf40..196bb91e3 100644 --- a/source/m_cookie.cc +++ b/source/m_cookie.cc @@ -44,7 +44,7 @@ static std::string active_module; static bool keep_seed; -static void Cookie_SetValue(std::string name, std::string value) +static void Cookie_SetValue(std::string name, const std::string &value) { if (context == cookie_context_e::Load) { @@ -113,7 +113,7 @@ static void Cookie_SetValue(std::string name, std::string value) ob_set_config(name, value); } -static bool Cookie_ParseLine(std::string buf) +static bool Cookie_ParseLine(std::string &buf) { if (buf.find('=') == std::string::npos) { @@ -163,7 +163,7 @@ static bool Cookie_ParseLine(std::string buf) //---------------------------------------------------------------------- -bool Cookie_Load(std::string filename) +bool Cookie_Load(const std::string &filename) { context = cookie_context_e::Load; @@ -226,7 +226,7 @@ bool Cookie_Load(std::string filename) return true; } -bool Cookie_LoadString(std::string str, bool _keep_seed) +bool Cookie_LoadString(const std::string &str, bool _keep_seed) { context = cookie_context_e::Load; keep_seed = _keep_seed; @@ -251,7 +251,7 @@ bool Cookie_LoadString(std::string str, bool _keep_seed) return true; } -bool Cookie_Save(std::string filename) +bool Cookie_Save(const std::string &filename) { context = cookie_context_e::Save; setlocale(LC_NUMERIC, "C"); @@ -487,7 +487,7 @@ class RecentFiles_c } } - bool get_name(int index, std::string buffer, bool for_menu) const + bool get_name(int index, std::string &buffer, bool for_menu) const { if (index >= size) { @@ -531,7 +531,7 @@ void Recent_Write(FILE *fp) recent_configs.write_all(fp, "recent_config"); } -void Recent_AddFile(int group, std::string filename) +void Recent_AddFile(int group, const std::string &filename) { SYS_ASSERT(0 <= group && group < RECG_NUM_GROUPS); @@ -553,44 +553,5 @@ void Recent_AddFile(int group, std::string filename) } } -void Recent_RemoveFile(int group, std::string filename) -{ - SYS_ASSERT(0 <= group && group < RECG_NUM_GROUPS); - - switch (group) - { - case RECG_Output: - recent_wads.remove(filename); - break; - - case RECG_Config: - recent_configs.remove(filename); - break; - } - - // push to disk now -- why wait? - if (!batch_mode) - { - Options_Save(options_file); - } -} - -bool Recent_GetName(int group, int index, std::string name_buf, bool for_menu) -{ - SYS_ASSERT(0 <= group && group < RECG_NUM_GROUPS); - SYS_ASSERT(index >= 0); - - switch (group) - { - case RECG_Output: - return recent_wads.get_name(index, name_buf, for_menu); - - case RECG_Config: - return recent_configs.get_name(index, name_buf, for_menu); - } - - return false; -} - //--- editor settings --- // vi:ts=4:sw=4:noexpandtab diff --git a/source/m_cookie.h b/source/m_cookie.h index eebe316c4..d7a24064d 100644 --- a/source/m_cookie.h +++ b/source/m_cookie.h @@ -25,20 +25,20 @@ #include -bool Cookie_Load(std::string filename); -bool Cookie_Save(std::string filename); +bool Cookie_Load(const std::string &filename); +bool Cookie_Save(const std::string &filename); -bool Cookie_LoadString(std::string str, bool _keep_seed); +bool Cookie_LoadString(const std::string &str, bool _keep_seed); void Cookie_ParseArguments(void); /* option stuff */ void Parse_Option(const std::string &name, const std::string &value); -bool Options_Load(std::string filename); -bool Options_Save(std::string filename); -bool Theme_Options_Load(std::string filename); -bool Theme_Options_Save(std::string filename); +bool Options_Load(const std::string &filename); +bool Options_Save(const std::string &filename); +bool Theme_Options_Load(const std::string &filename); +bool Theme_Options_Save(const std::string &filename); /* recent file stuff */ @@ -54,9 +54,7 @@ typedef enum } recent_group_e; -void Recent_AddFile(int group, std::string filename); -void Recent_RemoveFile(int group, std::string filename); -bool Recent_GetName(int group, int index, std::string name_buf, bool for_menu = false); +void Recent_AddFile(int group, const std::string &filename); //--- editor settings --- // vi:ts=4:sw=4:noexpandtab diff --git a/source/m_lua.cc b/source/m_lua.cc index 19d6f6f32..25a594e05 100644 --- a/source/m_lua.cc +++ b/source/m_lua.cc @@ -66,16 +66,16 @@ int gui_format_prefix(lua_State *L) format = custom_prefix.c_str(); } - const char *result = ff_main(levelcount, game, port, theme, OBSIDIAN_SHORT_VERSION, format.c_str()); + std::string result = ff_main(levelcount, game, port, theme, OBSIDIAN_SHORT_VERSION, format.c_str()); - if (!result) + if (result.empty()) { lua_pushstring(L, "FF_ERROR_"); // Will help people notice issues return 1; } else { - lua_pushstring(L, result); + lua_pushstring(L, result.c_str()); return 1; } @@ -1681,7 +1681,7 @@ static int p_init_lua(lua_State *L) return 0; } -static bool Script_CallFunc(std::string func_name, int nresult = 0, std::string *params = NULL) +static bool Script_CallFunc(const std::string &func_name, int nresult = 0, const std::vector ¶ms = {}) { // Note: the results of the function will be on the Lua stack @@ -1700,12 +1700,10 @@ static bool Script_CallFunc(std::string func_name, int nresult = 0, std::string } int nargs = 0; - if (params) + for (const std::string& param : params) { - for (; !params->empty(); params++, nargs++) - { - lua_pushstring(LUA_ST, params->c_str()); - } + lua_pushstring(LUA_ST, param.c_str()); + nargs++; } int status = lua_pcall(LUA_ST, nargs, nresult, -2 - nargs); @@ -1947,7 +1945,7 @@ void Script_Close() // WRAPPERS TO LUA FUNCTIONS //------------------------------------------------------------------------ -bool ob_set_config(std::string key, std::string value) +bool ob_set_config(const std::string &key, const std::string &value) { // See the document 'doc/Config_Flow.txt' for a good // description of the flow of configuration values @@ -1959,16 +1957,10 @@ bool ob_set_config(std::string key, std::string value) return false; } - std::string params[3] = { - key, - value, - "", - }; - - return Script_CallFunc("ob_set_config", 0, ¶ms[0]); + return Script_CallFunc("ob_set_config", 0, {key, value}); } -bool ob_set_mod_option(std::string module, std::string option, std::string value) +bool ob_set_mod_option(const std::string &module, const std::string &option, const std::string &value) { if (!has_loaded) { @@ -1976,9 +1968,7 @@ bool ob_set_mod_option(std::string module, std::string option, std::string value return false; } - std::string params[4] = {module, option, value, ""}; - - return Script_CallFunc("ob_set_mod_option", 0, ¶ms[0]); + return Script_CallFunc("ob_set_mod_option", 0, {module, option, value}); } bool ob_read_all_config(std::vector *lines, bool need_full) @@ -1991,12 +1981,12 @@ bool ob_read_all_config(std::vector *lines, bool need_full) conf_line_buffer = lines; - std::string params[2]; + std::vector params; - params[0] = need_full ? "need_full" : ""; - params[1] = ""; // end of list + if (need_full) + params.push_back("need_full"); - bool result = Script_CallFunc("ob_read_all_config", 0, ¶ms[0]); + bool result = Script_CallFunc("ob_read_all_config", 0, params); conf_line_buffer = NULL; @@ -2048,11 +2038,9 @@ std::string ob_game_format() return res; } -std::string ob_get_param(std::string parameter) +std::string ob_get_param(const std::string ¶meter) { - std::string params[2] = {parameter, ""}; - - if (!Script_CallFunc("ob_get_param", 1, ¶ms[0])) + if (!Script_CallFunc("ob_get_param", 1, {parameter})) { return ""; } @@ -2067,9 +2055,7 @@ std::string ob_get_param(std::string parameter) bool ob_hexen_ceiling_check(int thing_id) { - std::string params[2] = {NumToString(thing_id), ""}; - - if (!Script_CallFunc("ob_hexen_ceiling_check", 1, ¶ms[0])) + if (!Script_CallFunc("ob_hexen_ceiling_check", 1, {NumToString(thing_id)})) { return false; } @@ -2082,11 +2068,9 @@ bool ob_hexen_ceiling_check(int thing_id) return StringToInt(param); } -bool ob_mod_enabled(std::string module_name) +bool ob_mod_enabled(const std::string &module_name) { - std::string params[2] = {module_name, ""}; - - if (!Script_CallFunc("ob_mod_enabled", 1, ¶ms[0])) + if (!Script_CallFunc("ob_mod_enabled", 1, {module_name})) { return false; } @@ -2152,11 +2136,9 @@ void ob_print_reference_json() } } -void ob_invoke_hook(std::string hookname) +void ob_invoke_hook(const std::string &hookname) { - std::string params[2] = {hookname, ""}; - - if (!Script_CallFunc("ob_invoke_hook", 0, ¶ms[0])) + if (!Script_CallFunc("ob_invoke_hook", 0, {hookname})) { ProgStatus("%s", _("Script Error")); } diff --git a/source/m_lua.h b/source/m_lua.h index cb7eaa5fe..a35d4463a 100644 --- a/source/m_lua.h +++ b/source/m_lua.h @@ -42,15 +42,15 @@ extern color_mapping_t color_mappings[MAX_COLOR_MAPS]; // Wrappers which call Lua functions: -bool ob_set_config(std::string key, std::string value); -bool ob_set_mod_option(std::string module, std::string option, std::string value); +bool ob_set_config(const std::string &key, const std::string &value); +bool ob_set_mod_option(const std::string &module, const std::string &option, const std::string &value); bool ob_read_all_config(std::vector *lines, bool need_full); -std::string ob_get_param(std::string parameter); -bool ob_mod_enabled(std::string module_name); +std::string ob_get_param(const std::string ¶meter); +bool ob_mod_enabled(const std::string &module_name); bool ob_hexen_ceiling_check(int thing_id); -void ob_invoke_hook(std::string hookname); +void ob_invoke_hook(const std::string &hookname); void ob_print_reference(); void ob_print_reference_json(); diff --git a/source/m_options.cc b/source/m_options.cc index fe011295b..f43db5d0b 100644 --- a/source/m_options.cc +++ b/source/m_options.cc @@ -30,6 +30,7 @@ #include "m_lua.h" #include "m_trans.h" #include "main.h" +#include "sys_macro.h" extern std::string BestDirectory(); @@ -145,7 +146,7 @@ static bool Options_ParseLine(const std::string &buf) return true; } -bool Options_Load(std::string filename) +bool Options_Load(const std::string &filename) { FILE *option_fp = FileOpen(filename, "r"); @@ -179,7 +180,7 @@ bool Options_Load(std::string filename) return true; } -bool Options_Save(std::string filename) +bool Options_Save(const std::string &filename) { FILE *option_fp = FileOpen(filename, "w"); @@ -610,9 +611,7 @@ class UI_OptionsWin : public Fl_Window default_output_path = dir_name; UI_OptionsWin *that = (UI_OptionsWin *)data; - std::string blanker; - blanker.append(250, ' '); - that->opt_current_output_path->copy_label(blanker.c_str()); + that->opt_current_output_path->label(BLANKOUT); that->opt_current_output_path->redraw_label(); that->opt_current_output_path->copy_label( StringFormat("%s: %s", _("Current Path"), BestDirectory().c_str()).c_str()); diff --git a/source/m_theme.cc b/source/m_theme.cc index 49cb85bbf..db8a5d367 100644 --- a/source/m_theme.cc +++ b/source/m_theme.cc @@ -296,7 +296,7 @@ static bool Theme_Options_ParseLine(std::string buf) return true; } -bool Theme_Options_Load(std::string filename) +bool Theme_Options_Load(const std::string &filename) { FILE *option_fp = FileOpen(filename, "r"); @@ -346,7 +346,7 @@ bool Theme_Options_Load(std::string filename) return true; } -bool Theme_Options_Save(std::string filename) +bool Theme_Options_Save(const std::string &filename) { FILE *option_fp = FileOpen(filename, "w"); diff --git a/source/m_trans.cc b/source/m_trans.cc index 5cbdac247..9c9a873f1 100644 --- a/source/m_trans.cc +++ b/source/m_trans.cc @@ -49,6 +49,7 @@ #include static std::map trans_store; +static std::map::iterator trans_iter; // current Options setting std::string t_language = _("AUTO"); @@ -395,25 +396,22 @@ std::string t_language = _("AUTO"); #endif #endif -static std::string remove_codeset(std::string langcode) +static std::string remove_codeset(std::string_view langcode) { - if (langcode.find('.') != std::string::npos) - { - auto p = std::find(langcode.begin(), langcode.end(), '.'); - langcode.resize(p - langcode.begin()); - } - - return langcode; + size_t pos = langcode.find('.'); + if (pos != std::string_view::npos) + return std::string(langcode.substr(0, pos)); + else + return std::string(langcode); } -static std::string remove_territory(std::string langcode) +static std::string remove_territory(std::string_view langcode) { - if (langcode.find('_') != std::string::npos) - { - langcode.resize(std::find(langcode.begin(), langcode.end(), '_') - langcode.begin()); - } - - return langcode; + size_t pos = langcode.find('_'); + if (pos != std::string_view::npos) + return std::string(langcode.substr(0, pos)); + else + return std::string(langcode); } /* DETERMINE CURRENT LANGUAGE */ @@ -1162,11 +1160,6 @@ void Trans_SetLanguage() path = StringFormat("%s/language/%s.po", install_dir.c_str(), lang_plain.c_str()); } - if (!FileExists(path)) - { - FatalError("WTF: %s\n", path.c_str()); - } - FILE *fp = FileOpen(path, "rb"); if (!fp) { @@ -1222,13 +1215,11 @@ void Trans_UnInit() const char *ob_gettext(const char *s) { - std::map::iterator IT; - - IT = trans_store.find(s); + trans_iter = trans_store.find(s); - if (IT != trans_store.end()) + if (trans_iter != trans_store.end()) { - return IT->second.c_str(); + return trans_iter->second.c_str(); } return s; diff --git a/source/main.cc b/source/main.cc index 14a04b861..b06a5728f 100644 --- a/source/main.cc +++ b/source/main.cc @@ -1482,7 +1482,7 @@ softrestart:; if (main_action != MAIN_SOFT_RESTART) { - VFS_InitAddons(install_dir); + VFS_InitAddons(); if (const int load_arg = argv::Find('l', "load"); load_arg >= 0) { diff --git a/source/slump.cc b/source/slump.cc index 82cbd156d..70c9fbbbb 100644 --- a/source/slump.cc +++ b/source/slump.cc @@ -1342,7 +1342,7 @@ void secretize_config(config *c) /* 3. Parse the arglist to get overrides to switches, */ /* 4. Read the config for non-switches (flats, themes, etc). */ /* 5. Do postproduction defaults and calculations and such. */ -config *get_config(std::string filename) +config *get_config(const std::string &filename) { config *answer; int i; diff --git a/source/slump.h b/source/slump.h index 6f1f21392..2bd952bd5 100644 --- a/source/slump.h +++ b/source/slump.h @@ -37,7 +37,7 @@ #include #include -bool slump_main(std::string filename); +bool slump_main(const std::string &filename); /* Slump 0.003.02 */ #define SOURCE_VERSION (0) @@ -941,7 +941,7 @@ typedef struct s_config /* Lots and lots and lots of functions */ /* And this isn't even all of 'em! */ -config *get_config(std::string filename); +config *get_config(const std::string &filename); void NewLevel(level *l, haa *init_haa, config *c); void DumpLevel(dumphandle dh, config *c, level *l, int episode, int mission, int map); void FreeLevel(level *l); diff --git a/source/slump_main.cc b/source/slump_main.cc index 50797825f..2ef210197 100644 --- a/source/slump_main.cc +++ b/source/slump_main.cc @@ -63,7 +63,7 @@ void machioize(config *c, float amount) } } -bool slump_main(std::string filename) +bool slump_main(const std::string &filename) { /* A stubby but functional main() */ diff --git a/source/sys_macro.h b/source/sys_macro.h index 93ad2cfa4..a0f725f3f 100644 --- a/source/sys_macro.h +++ b/source/sys_macro.h @@ -24,6 +24,10 @@ #include #include +constexpr char *BLANKOUT = " " + " " + " "; + // basic constants #define OBSIDIAN_MSG_BUF_LEN 2000 #define OBSIDIAN_DIST_EPSILON (1.0 / 1024.0) diff --git a/source/ui_build.cc b/source/ui_build.cc index a5904c58e..264ab2ed0 100644 --- a/source/ui_build.cc +++ b/source/ui_build.cc @@ -23,6 +23,7 @@ #include "m_trans.h" #include "main.h" #include "sys_assert.h" +#include "sys_macro.h" UI_Build::UI_Build(int X, int Y, int W, int H, const char *label) : Fl_Group(X, Y, W, H, label) { @@ -365,7 +366,7 @@ void UI_Build::ParseSteps(const char *names) } } -int UI_Build::FindStep(std::string name) +int UI_Build::FindStep(std::string_view name) { for (int i = 0; i < (int)step_names.size(); i++) { @@ -378,12 +379,10 @@ int UI_Build::FindStep(std::string name) return -1; // not found } -void UI_Build::AddStatusStep(std::string name) +void UI_Build::AddStatusStep(const std::string &name) { // modifies the current status string to show the current step - std::string blankout; - blankout.append(200, ' '); - status->copy_label(blankout.c_str()); + status->label(BLANKOUT); status->copy_label(StringFormat("%s : %s", status_label.c_str(), name.c_str()).c_str()); status->redraw(); } diff --git a/source/ui_build.h b/source/ui_build.h index 1fd82c5c8..fe8baf1df 100644 --- a/source/ui_build.h +++ b/source/ui_build.h @@ -67,12 +67,12 @@ class UI_Build : public Fl_Group void SetStatus(std::string_view msg); - void AddStatusStep(std::string name); + void AddStatusStep(const std::string &name); private: void resize(int X, int Y, int W, int H); - int FindStep(std::string name); // -1 if not found + int FindStep(std::string_view name); // -1 if not found }; //--- editor settings --- diff --git a/source/ui_game.cc b/source/ui_game.cc index 6251eff32..4cefb079a 100644 --- a/source/ui_game.cc +++ b/source/ui_game.cc @@ -289,7 +289,7 @@ void UI_Game::Locked(bool value) } } -bool UI_Game::AddChoice(std::string button, std::string id, std::string label) +bool UI_Game::AddChoice(const std::string &button, const std::string &id, const std::string &label) { if (!StringCompare(button, "engine")) { @@ -323,7 +323,7 @@ bool UI_Game::AddChoice(std::string button, std::string id, std::string label) return false; // unknown button } -bool UI_Game::EnableChoice(std::string button, std::string id, bool enable_it) +bool UI_Game::EnableChoice(const std::string &button, const std::string &id, bool enable_it) { if (!StringCompare(button, "engine")) { @@ -354,7 +354,7 @@ bool UI_Game::EnableChoice(std::string button, std::string id, bool enable_it) return false; // unknown button } -bool UI_Game::SetButton(std::string button, std::string id) +bool UI_Game::SetButton(const std::string &button, const std::string &id) { if (!StringCompare(button, "engine")) { diff --git a/source/ui_game.h b/source/ui_game.h index 82c7b88de..48946da06 100644 --- a/source/ui_game.h +++ b/source/ui_game.h @@ -53,9 +53,9 @@ class UI_Game : public Fl_Group void Locked(bool value); // these return false if 'button' is not valid - bool AddChoice(std::string button, std::string id, std::string label); - bool EnableChoice(std::string button, std::string id, bool enable_it); - bool SetButton(std::string button, std::string id); + bool AddChoice(const std::string &button, const std::string &id, const std::string &label); + bool EnableChoice(const std::string &button, const std::string &id, bool enable_it); + bool SetButton(const std::string &button, const std::string &id); void SetAbortButton(bool abort); diff --git a/source/ui_map.cc b/source/ui_map.cc index 210b76120..18e43c3ce 100644 --- a/source/ui_map.cc +++ b/source/ui_map.cc @@ -352,7 +352,7 @@ void UI_MiniMap::DrawEntity(int x, int y, uint8_t r, uint8_t g, uint8_t b) RawPixel(x, y + 1, r, g, b); } -void UI_MiniMap::GifStart(std::string filename, int delay) +void UI_MiniMap::GifStart(std::string_view filename, int delay) { gif_writer = new GifWriter; gif_delay = delay; diff --git a/source/ui_map.h b/source/ui_map.h index 37b41834a..00884bd41 100644 --- a/source/ui_map.h +++ b/source/ui_map.h @@ -62,7 +62,7 @@ class UI_MiniMap : public Fl_Box void MapClear(); - void GifStart(std::string filename, int delay); + void GifStart(std::string_view filename, int delay); void GifFrame(); void GifFinish(); diff --git a/source/ui_module.cc b/source/ui_module.cc index 6c1513438..f26c22627 100644 --- a/source/ui_module.cc +++ b/source/ui_module.cc @@ -32,7 +32,7 @@ #include "sys_macro.h" #include "sys_xoshiro.h" -UI_Module::UI_Module(int X, int Y, int W, int H, std::string id, std::string label, std::string tip, int red, int green, +UI_Module::UI_Module(int X, int Y, int W, int H, const std::string &id, const std::string &label, const std::string &tip, int red, int green, int blue, bool suboptions) : Fl_Group(X, Y, W, H), choice_map(), cur_opt_y(0) { @@ -96,7 +96,7 @@ bool UI_Module::Is_UI() const return (!StringCompare(id_name.substr(0, 3), "ui_")); } -void UI_Module::AddHeader(std::string opt, std::string label, int gap) +void UI_Module::AddHeader(const std::string &opt, const std::string &label, int gap) { int nw = this->parent()->w(); @@ -126,7 +126,7 @@ void UI_Module::AddHeader(std::string opt, std::string label, int gap) choice_map_header[opt] = rhead; } -void UI_Module::AddUrl(std::string opt, std::string label, std::string url, int gap) +void UI_Module::AddUrl(const std::string &opt, const std::string &label, const std::string &url, int gap) { int nw = this->parent()->w(); @@ -156,8 +156,8 @@ void UI_Module::AddUrl(std::string opt, std::string label, std::string url, int choice_map_url[opt] = rurl; } -void UI_Module::AddOption(std::string opt, std::string label, std::string tip, std::string longtip, int gap, - std::string randomize_group, std::string default_value) +void UI_Module::AddOption(const std::string &opt, const std::string &label, const std::string &tip, std::string &longtip, int gap, + const std::string &randomize_group, const std::string &default_value) { int nw = this->parent()->w(); // int nh = kf_h(30); @@ -221,9 +221,9 @@ void UI_Module::AddOption(std::string opt, std::string label, std::string tip, s choice_map[opt] = rch; } -void UI_Module::AddSliderOption(std::string opt, std::string label, std::string tip, std::string longtip, int gap, - double min, double max, double inc, std::string units, std::string presets, - std::string nan, std::string randomize_group, std::string default_value) +void UI_Module::AddSliderOption(const std::string &opt, std::string &label, const std::string &tip, std::string &longtip, int gap, + double min, double max, double inc, const std::string &units, const std::string &presets, + const std::string &nan, const std::string &randomize_group, const std::string &default_value) { int nw = this->parent()->w(); // int nh = kf_h(30); @@ -408,8 +408,8 @@ void UI_Module::AddSliderOption(std::string opt, std::string label, std::string choice_map_slider[opt] = rsl; } -void UI_Module::AddButtonOption(std::string opt, std::string label, std::string tip, std::string longtip, int gap, - std::string randomize_group, std::string default_value) +void UI_Module::AddButtonOption(const std::string &opt, const std::string &label, const std::string &tip, std::string &longtip, int gap, + const std::string &randomize_group, const std::string &default_value) { int nw = this->parent()->w(); // int nh = kf_h(30); @@ -625,7 +625,7 @@ void UI_Module::randomize_Values(std::vector selected_randomize_gro } } -void UI_Module::AddOptionChoice(std::string option, std::string id, std::string label) +void UI_Module::AddOptionChoice(const std::string &option, const std::string &id, const std::string &label) { UI_RChoice *rch = FindOpt(option); @@ -640,7 +640,7 @@ void UI_Module::AddOptionChoice(std::string option, std::string id, std::string rch->mod_menu->EnableChoice(id, 1); } -bool UI_Module::SetOption(std::string option, std::string value) +bool UI_Module::SetOption(const std::string &option, const std::string &value) { UI_RChoice *rch = FindOpt(option); @@ -654,7 +654,7 @@ bool UI_Module::SetOption(std::string option, std::string value) return true; } -bool UI_Module::SetSliderOption(std::string option, std::string value) +bool UI_Module::SetSliderOption(const std::string &option, const std::string &value) { UI_RSlide *rsl = FindSliderOpt(option); @@ -700,7 +700,7 @@ bool UI_Module::SetSliderOption(std::string option, std::string value) return true; } -bool UI_Module::SetButtonOption(std::string option, int value) +bool UI_Module::SetButtonOption(const std::string &option, int value) { UI_RButton *rbt = FindButtonOpt(option); @@ -713,7 +713,7 @@ bool UI_Module::SetButtonOption(std::string option, int value) return true; } -UI_RChoice *UI_Module::FindOpt(std::string option) +UI_RChoice *UI_Module::FindOpt(const std::string &option) { if (choice_map.find(option) == choice_map.end()) { @@ -723,7 +723,7 @@ UI_RChoice *UI_Module::FindOpt(std::string option) return choice_map[option]; } -UI_RSlide *UI_Module::FindSliderOpt(std::string option) +UI_RSlide *UI_Module::FindSliderOpt(const std::string &option) { if (choice_map_slider.find(option) == choice_map_slider.end()) { @@ -733,7 +733,7 @@ UI_RSlide *UI_Module::FindSliderOpt(std::string option) return choice_map_slider[option]; } -UI_RButton *UI_Module::FindButtonOpt(std::string option) +UI_RButton *UI_Module::FindButtonOpt(const std::string &option) { if (choice_map_button.find(option) == choice_map_button.end()) { @@ -743,7 +743,7 @@ UI_RButton *UI_Module::FindButtonOpt(std::string option) return choice_map_button[option]; } -UI_RHeader *UI_Module::FindHeaderOpt(std::string option) +UI_RHeader *UI_Module::FindHeaderOpt(const std::string &option) { if (choice_map_header.find(option) == choice_map_header.end()) { @@ -753,7 +753,7 @@ UI_RHeader *UI_Module::FindHeaderOpt(std::string option) return choice_map_header[option]; } -UI_RLink *UI_Module::FindUrlOpt(std::string option) +UI_RLink *UI_Module::FindUrlOpt(const std::string &option) { if (choice_map_url.find(option) == choice_map_url.end()) { @@ -838,10 +838,9 @@ void UI_Module::callback_PresetCheck(Fl_Widget *w, void *data) std::string new_label; - current_slider->unit_label->copy_label(new_label.append(50, ' ').c_str()); // To prevent visual errors with - // labels of different lengths - // Check against the preset_choices map + current_slider->unit_label->label(BLANKOUT); + // Check against the preset_choices map if (current_slider->preset_choices.count(value) == 1) { new_label = current_slider->preset_choices[value]; @@ -1047,8 +1046,7 @@ void UI_Module::callback_NanOptions(Fl_Widget *w, void *data) if (temp_value > 0) { std::string new_label; - current_slider->unit_label->copy_label(new_label.append(50, ' ').c_str()); // To prevent visual errors with - // labels of different lengths + current_slider->unit_label->label(BLANKOUT); new_label = nan_options->text(temp_value); current_slider->unit_label->copy_label(new_label.c_str()); current_slider->prev_button->deactivate(); @@ -1068,7 +1066,7 @@ void UI_Module::callback_NanOptions(Fl_Widget *w, void *data) //---------------------------------------------------------------- -UI_CustomMods::UI_CustomMods(int X, int Y, int W, int H, std::string label) : Fl_Group(X, Y, W, H) +UI_CustomMods::UI_CustomMods(int X, int Y, int W, int H, const std::string &label) : Fl_Group(X, Y, W, H) { box(FL_FLAT_BOX); @@ -1120,7 +1118,7 @@ typedef struct UI_CustomMods *parent; } mod_enable_callback_data_t; -void UI_CustomMods::AddModule(std::string id, std::string label, std::string tip, int red, int green, int blue, +void UI_CustomMods::AddModule(const std::string &id, const std::string &label, const std::string &tip, int red, int green, int blue, bool suboptions) { UI_Module *M = new UI_Module(mx, my, mw - 4, kf_h(34), id, label, tip, red, green, blue, suboptions); @@ -1139,7 +1137,7 @@ void UI_CustomMods::AddModule(std::string id, std::string label, std::string tip PositionAll(); } -bool UI_CustomMods::AddHeader(std::string module, std::string option, std::string label, int gap) +bool UI_CustomMods::AddHeader(const std::string &module, const std::string &option, const std::string &label, int gap) { UI_Module *M = FindID(module); @@ -1155,7 +1153,7 @@ bool UI_CustomMods::AddHeader(std::string module, std::string option, std::strin return true; } -bool UI_CustomMods::AddUrl(std::string module, std::string option, std::string label, std::string url, int gap) +bool UI_CustomMods::AddUrl(const std::string &module, const std::string &option, const std::string &label, const std::string &url, int gap) { UI_Module *M = FindID(module); @@ -1171,8 +1169,8 @@ bool UI_CustomMods::AddUrl(std::string module, std::string option, std::string l return true; } -bool UI_CustomMods::AddOption(std::string module, std::string option, std::string label, std::string tip, - std::string longtip, int gap, std::string randomize_group, std::string default_value) +bool UI_CustomMods::AddOption(const std::string &module, const std::string &option, const std::string &label, const std::string &tip, + std::string &longtip, int gap, const std::string &randomize_group, const std::string &default_value) { UI_Module *M = FindID(module); @@ -1188,10 +1186,10 @@ bool UI_CustomMods::AddOption(std::string module, std::string option, std::strin return true; } -bool UI_CustomMods::AddSliderOption(std::string module, std::string option, std::string label, std::string tip, - std::string longtip, int gap, double min, double max, double inc, std::string units, - std::string presets, std::string nan, std::string randomize_group, - std::string default_value) +bool UI_CustomMods::AddSliderOption(const std::string &module, const std::string &option, std::string &label, const std::string &tip, + std::string &longtip, int gap, double min, double max, double inc, const std::string &units, + const std::string &presets, const std::string &nan, const std::string &randomize_group, + const std::string &default_value) { UI_Module *M = FindID(module); @@ -1208,9 +1206,9 @@ bool UI_CustomMods::AddSliderOption(std::string module, std::string option, std: return true; } -bool UI_CustomMods::AddButtonOption(std::string module, std::string option, std::string label, std::string tip, - std::string longtip, int gap, std::string randomize_group, - std::string default_value) +bool UI_CustomMods::AddButtonOption(const std::string &module, const std::string &option, const std::string &label, const std::string &tip, + std::string &longtip, int gap, const std::string &randomize_group, + const std::string &default_value) { UI_Module *M = FindID(module); @@ -1226,7 +1224,7 @@ bool UI_CustomMods::AddButtonOption(std::string module, std::string option, std: return true; } -bool UI_CustomMods::AddOptionChoice(std::string module, std::string option, std::string id, std::string label) +bool UI_CustomMods::AddOptionChoice(const std::string &module, const std::string &option, const std::string &id, const std::string &label) { UI_Module *M = FindID(module); @@ -1240,7 +1238,7 @@ bool UI_CustomMods::AddOptionChoice(std::string module, std::string option, std: return true; } -bool UI_CustomMods::ShowModule(std::string id, bool new_shown) +bool UI_CustomMods::ShowModule(const std::string &id, bool new_shown) { SYS_ASSERT(!id.empty()); @@ -1272,7 +1270,7 @@ bool UI_CustomMods::ShowModule(std::string id, bool new_shown) return true; } -bool UI_CustomMods::SetOption(std::string module, std::string option, std::string value) +bool UI_CustomMods::SetOption(const std::string &module, const std::string &option, const std::string &value) { UI_Module *M = FindID(module); @@ -1284,7 +1282,7 @@ bool UI_CustomMods::SetOption(std::string module, std::string option, std::strin return M->SetOption(option, value); } -bool UI_CustomMods::SetSliderOption(std::string module, std::string option, std::string value) +bool UI_CustomMods::SetSliderOption(const std::string &module, const std::string &option, const std::string &value) { UI_Module *M = FindID(module); @@ -1296,7 +1294,7 @@ bool UI_CustomMods::SetSliderOption(std::string module, std::string option, std: return M->SetSliderOption(option, value); } -bool UI_CustomMods::SetButtonOption(std::string module, std::string option, int value) +bool UI_CustomMods::SetButtonOption(const std::string &module, const std::string &option, int value) { UI_Module *M = FindID(module); @@ -1308,7 +1306,7 @@ bool UI_CustomMods::SetButtonOption(std::string module, std::string option, int return M->SetButtonOption(option, value); } -bool UI_CustomMods::EnableMod(std::string id, bool enable) +bool UI_CustomMods::EnableMod(const std::string &id, bool enable) { SYS_ASSERT(!id.empty()); @@ -1777,7 +1775,7 @@ void UI_CustomMods::callback_ModEnable(Fl_Widget *w, void *data) ob_set_mod_option(M->id_name, "self", M->mod_button->value() ? "true" : "false"); } -UI_Module *UI_CustomMods::FindID(std::string id) const +UI_Module *UI_CustomMods::FindID(const std::string &id) const { for (int j = 0; j < mod_pack->children(); j++) { diff --git a/source/ui_module.h b/source/ui_module.h index a50ff1d5f..b9521f89f 100644 --- a/source/ui_module.h +++ b/source/ui_module.h @@ -60,31 +60,31 @@ class UI_Module : public Fl_Group int cur_opt_y; public: - UI_Module(int X, int Y, int W, int H, std::string id, std::string label, std::string tip, int red, int green, + UI_Module(int X, int Y, int W, int H, const std::string &id, const std::string &label, const std::string &tip, int red, int green, int blue, bool suboptions); virtual ~UI_Module(); - void AddOption(std::string option, std::string label, std::string tip, std::string longtip, int gap, - std::string randomize_group, std::string default_value); + void AddOption(const std::string &option, const std::string &label, const std::string &tip, std::string &longtip, int gap, + const std::string &randomize_group, const std::string &default_value); - void AddHeader(std::string option, std::string label, int gap); + void AddHeader(const std::string &option, const std::string &label, int gap); - void AddUrl(std::string option, std::string label, std::string url, int gap); + void AddUrl(const std::string &option, const std::string &label, const std::string &url, int gap); - void AddSliderOption(std::string option, std::string label, std::string tip, std::string longtip, int gap, - double min, double max, double inc, std::string units, std::string presets, std::string nan, - std::string randomize_group, std::string default_value); + void AddSliderOption(const std::string &option, std::string &label, const std::string &tip, std::string &longtip, int gap, + double min, double max, double inc, const std::string &units, const std::string &presets, const std::string &nan, + const std::string &randomize_group, const std::string &default_value); - void AddButtonOption(std::string opt, std::string label, std::string tip, std::string longtip, int gap, - std::string randomize_group, std::string default_value); + void AddButtonOption(const std::string &opt, const std::string &label, const std::string &tip, std::string &longtip, int gap, + const std::string &randomize_group, const std::string &default_value); - void AddOptionChoice(std::string option, std::string id, std::string label); + void AddOptionChoice(const std::string &option, const std::string &id, const std::string &label); - bool SetOption(std::string option, std::string value); + bool SetOption(const std::string &option, const std::string &value); - bool SetSliderOption(std::string option, std::string value); + bool SetSliderOption(const std::string &option, const std::string &value); - bool SetButtonOption(std::string option, int value); + bool SetButtonOption(const std::string &option, int value); bool Is_UI() const; @@ -95,15 +95,15 @@ class UI_Module : public Fl_Group void randomize_Values(std::vector selected_randomize_groups); - UI_RChoice *FindOpt(std::string opt); // const; + UI_RChoice *FindOpt(const std::string &opt); // const; - UI_RSlide *FindSliderOpt(std::string opt); // const; + UI_RSlide *FindSliderOpt(const std::string &opt); // const; - UI_RButton *FindButtonOpt(std::string opt); // const; + UI_RButton *FindButtonOpt(const std::string &opt); // const; - UI_RHeader *FindHeaderOpt(std::string opt); // const; + UI_RHeader *FindHeaderOpt(const std::string &opt); // const; - UI_RLink *FindUrlOpt(std::string opt); // const; + UI_RLink *FindUrlOpt(const std::string &opt); // const; protected: private: @@ -139,43 +139,43 @@ class UI_CustomMods : public Fl_Group int total_h; public: - UI_CustomMods(int X, int Y, int W, int H, std::string label); + UI_CustomMods(int X, int Y, int W, int H, const std::string &label); virtual ~UI_CustomMods(); public: - void AddModule(std::string id, std::string label, std::string tip, int red, int green, int blue, bool suboptions); + void AddModule(const std::string &id, const std::string &label, const std::string &tip, int red, int green, int blue, bool suboptions); // these return false if module is unknown - bool ShowModule(std::string id, bool new_shown); - bool EnableMod(std::string id, bool enable); + bool ShowModule(const std::string &id, bool new_shown); + bool EnableMod(const std::string &id, bool enable); - bool AddHeader(std::string module, std::string option, std::string label, int gap); + bool AddHeader(const std::string &module, const std::string &option, const std::string &label, int gap); - bool AddUrl(std::string module, std::string option, std::string label, std::string url, int gap); + bool AddUrl(const std::string &module, const std::string &option, const std::string &label, const std::string &url, int gap); - bool AddOption(std::string module, std::string option, std::string label, std::string tip, std::string longtip, - int gap, std::string randomize_group, std::string default_value); + bool AddOption(const std::string &module, const std::string &option, const std::string &label, const std::string &tip, std::string &longtip, + int gap, const std::string &randomize_group, const std::string &default_value); - bool AddSliderOption(std::string module, std::string option, std::string label, std::string tip, - std::string longtip, int gap, double min, double max, double inc, std::string units, - std::string presets, std::string nan, std::string randomize_group, std::string default_value); + bool AddSliderOption(const std::string &module, const std::string &option, std::string &label, const std::string &tip, + std::string &longtip, int gap, double min, double max, double inc, const std::string &units, + const std::string &presets, const std::string &nan, const std::string &randomize_group, const std::string &default_value); - bool AddButtonOption(std::string module, std::string option, std::string label, std::string tip, - std::string longtip, int gap, std::string randomize_group, std::string default_value); + bool AddButtonOption(const std::string &module, const std::string &option, const std::string &label, const std::string &tip, + std::string &longtip, int gap, const std::string &randomize_group, const std::string &default_value); - bool AddOptionChoice(std::string module, std::string option, std::string id, std::string label); + bool AddOptionChoice(const std::string &module, const std::string &option, const std::string &id, const std::string &label); - bool SetOption(std::string module, std::string option, std::string value); + bool SetOption(const std::string &module, const std::string &option, const std::string &value); - bool SetSliderOption(std::string module, std::string option, std::string value); + bool SetSliderOption(const std::string &module, const std::string &option, const std::string &value); - bool SetButtonOption(std::string module, std::string option, int value); + bool SetButtonOption(const std::string &module, const std::string &option, int value); void Locked(bool value); void SurpriseMe(); - UI_Module *FindID(std::string id) const; + UI_Module *FindID(const std::string &id) const; private: void PositionAll(UI_Module *focus = NULL); diff --git a/source/ui_widgets.cc b/source/ui_widgets.cc index 7de38de8e..0057d7431 100644 --- a/source/ui_widgets.cc +++ b/source/ui_widgets.cc @@ -25,7 +25,7 @@ #include "main.h" #include "sys_assert.h" -choice_data_c::choice_data_c(std::string _id, std::string _label) : enabled(false), mapped(-1), widget(NULL) +choice_data_c::choice_data_c(std::string_view _id, std::string_view _label) : enabled(false), mapped(-1), widget(NULL) { if (!_id.empty()) { @@ -49,7 +49,7 @@ choice_data_c::~choice_data_c() //---------------------------------------------------------------- -UI_RChoiceMenu::UI_RChoiceMenu(int x, int y, int w, int h, std::string label) +UI_RChoiceMenu::UI_RChoiceMenu(int x, int y, int w, int h, const std::string &label) : UI_CustomMenu(x, y, w, h, label), opt_list() { visible_focus(0); @@ -65,7 +65,7 @@ UI_RChoiceMenu::~UI_RChoiceMenu() } } -void UI_RChoiceMenu::AddChoice(std::string id, std::string label) +void UI_RChoiceMenu::AddChoice(const std::string &id, const std::string &label) { choice_data_c *opt = FindID(id); @@ -83,13 +83,10 @@ void UI_RChoiceMenu::AddChoice(std::string id, std::string label) opt = new choice_data_c(id, label); opt_list.push_back(opt); - - // no need to call Recreate() here since new pairs are always - // hidden (enabled == false). } } -bool UI_RChoiceMenu::EnableChoice(std::string id, bool enable_it) +bool UI_RChoiceMenu::EnableChoice(const std::string &id, bool enable_it) { SYS_ASSERT(!id.empty()); @@ -123,7 +120,7 @@ std::string UI_RChoiceMenu::GetLabel() const return P ? P->label : ""; } -bool UI_RChoiceMenu::ChangeTo(std::string id) +bool UI_RChoiceMenu::ChangeTo(const std::string &id) { SYS_ASSERT(!id.empty()); @@ -181,7 +178,7 @@ void UI_RChoiceMenu::Recreate() value(0); } -choice_data_c *UI_RChoiceMenu::FindID(std::string id) const +choice_data_c *UI_RChoiceMenu::FindID(std::string_view id) const { for (unsigned int j = 0; j < opt_list.size(); j++) { @@ -344,7 +341,7 @@ UI_RButton::~UI_RButton() //---------------------------------------------------------------- -UI_CustomCheckBox::UI_CustomCheckBox(int x, int y, int w, int h, std::string label) +UI_CustomCheckBox::UI_CustomCheckBox(int x, int y, int w, int h, const std::string &label) : Fl_Check_Button(x, y, w, h, label.empty() ? "" : label.c_str()) { visible_focus(0); @@ -881,7 +878,7 @@ void UI_ManualEntry::draw() //---------------------------------------------------------------- -UI_CustomMenu::UI_CustomMenu(int x, int y, int w, int h, std::string label) +UI_CustomMenu::UI_CustomMenu(int x, int y, int w, int h, const std::string &label) : Fl_Choice(x, y, w, h, label.empty() ? "" : label.c_str()) { visible_focus(0); diff --git a/source/ui_widgets.h b/source/ui_widgets.h index 688042977..8c54cf8ce 100644 --- a/source/ui_widgets.h +++ b/source/ui_widgets.h @@ -63,7 +63,7 @@ class choice_data_c Fl_Check_Button *widget; public: - choice_data_c(std::string _id, std::string _label); + choice_data_c(std::string_view _id, std::string_view _label); ~choice_data_c(); }; @@ -152,7 +152,7 @@ class UI_CustomMenu : public Fl_Choice { private: public: - UI_CustomMenu(int x, int y, int w, int h, std::string label = ""); + UI_CustomMenu(int x, int y, int w, int h, const std::string &label = ""); virtual ~UI_CustomMenu(); private: @@ -165,19 +165,19 @@ class UI_RChoiceMenu : public UI_CustomMenu std::vector opt_list; public: - UI_RChoiceMenu(int x, int y, int w, int h, std::string label = ""); + UI_RChoiceMenu(int x, int y, int w, int h, const std::string &label = ""); virtual ~UI_RChoiceMenu(); public: // add a new choice to the list. If a choice with the same 'id' // already exists, it is just replaced instead. // The choice will begin disabled (shown == false). - void AddChoice(std::string id, std::string label); + void AddChoice(const std::string &id, const std::string &label); // finds the option with the given ID, and update its 'enabled' // value. Returns true if successful, or false if no such // option exists. Any change will call Recreate(). - bool EnableChoice(std::string id, bool enable_it); + bool EnableChoice(const std::string &id, bool enable_it); // get the id string for the currently shown value. // Returns the string "none" if there are no choices. @@ -185,11 +185,11 @@ class UI_RChoiceMenu : public UI_CustomMenu // change the currently shown value via the new 'id'. // If does not exist, returns false and nothing was changed. - bool ChangeTo(std::string id); + bool ChangeTo(const std::string &id); std::string GetLabel() const; - choice_data_c *FindID(std::string id) const; + choice_data_c *FindID(std::string_view id) const; private: choice_data_c *FindMapped() const; @@ -201,8 +201,6 @@ class UI_RChoiceMenu : public UI_CustomMenu // first entry. void Recreate(); - // const char *GetLabel() const; // ???? - void GotoPrevious(); void GotoNext(); }; @@ -344,7 +342,7 @@ class UI_CustomCheckBox : public Fl_Check_Button { private: public: - UI_CustomCheckBox(int x, int y, int w, int h, std::string label = ""); + UI_CustomCheckBox(int x, int y, int w, int h, const std::string &label = ""); virtual ~UI_CustomCheckBox(); private: