diff --git a/metamod/src/conf_meta.cpp b/metamod/src/conf_meta.cpp index 44bea7a..94c30c5 100644 --- a/metamod/src/conf_meta.cpp +++ b/metamod/src/conf_meta.cpp @@ -23,7 +23,7 @@ option_t *MConfig::find(const char* lookup) const } } - return NULL; + return nullptr; } bool MConfig::set(const char* key, const char* value) const @@ -97,18 +97,16 @@ bool MConfig::set(option_t* setp, const char* setstr) bool MConfig::load(const char* fn) { - FILE* fp; char loadfile[PATH_MAX]; char line[MAX_CONF_LEN]; char *optname, *optval; option_t* optp; - int ln; // Make full pathname (from gamedir if relative, collapse "..", // backslashes, etc). full_gamedir_path(fn, loadfile); - fp = fopen(loadfile, "r"); + FILE* fp = fopen(loadfile, "r"); if (!fp) { META_ERROR("unable to open config file '%s': %s", loadfile, strerror(errno)); @@ -116,7 +114,7 @@ bool MConfig::load(const char* fn) } META_DEBUG(2, "Loading from config file: %s", loadfile); - for (ln = 1; !feof(fp) && fgets(line, sizeof line, fp); ln++) + for (int ln = 1; !feof(fp) && fgets(line, sizeof line, fp); ln++) { if (line[0] == '#' || line[0] == ';' || !Q_strncmp(line, "//", 2)) continue; @@ -127,7 +125,7 @@ bool MConfig::load(const char* fn) continue; } - if (!(optval = strtok(NULL, "\r\n"))) + if (!(optval = strtok(nullptr, "\r\n"))) { META_ERROR("'%s' line %d: bad config format: missing value", loadfile, ln); continue; @@ -183,7 +181,7 @@ void MConfig::show() const void MConfig::set_directory() { #ifdef _WIN32 - HMODULE hModule = NULL; + HMODULE hModule = nullptr; GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCTSTR)GiveFnptrsToDll, &hModule); GetModuleFileName(hModule, m_directory, sizeof m_directory); #else diff --git a/metamod/src/conf_meta.h b/metamod/src/conf_meta.h index 6540fcb..17047e3 100644 --- a/metamod/src/conf_meta.h +++ b/metamod/src/conf_meta.h @@ -45,10 +45,6 @@ private: option_t *find(const char *lookup) const; static bool set(option_t *setp, const char *value); - // Private; to satisfy -Weffc++ "has pointer data members but does - // not override" copy/assignment constructor. - void operator=(const MConfig &src); - MConfig(const MConfig &src); }; inline const char *MConfig::directory() const diff --git a/metamod/src/game_support.cpp b/metamod/src/game_support.cpp index 513034a..6ab1568 100644 --- a/metamod/src/game_support.cpp +++ b/metamod/src/game_support.cpp @@ -14,7 +14,7 @@ const game_modinfo_t g_known_games[] = { { "czero", "cs.so", "mp.dll", "Counter-Strike:Condition Zero" }, // End of list terminator: - { NULL, NULL, NULL, NULL } + { nullptr, nullptr, nullptr, nullptr } }; // Find a modinfo corresponding to the given game name. diff --git a/metamod/src/jitasm.h b/metamod/src/jitasm.h index 1961c6a..6562d91 100644 --- a/metamod/src/jitasm.h +++ b/metamod/src/jitasm.h @@ -884,7 +884,7 @@ struct Backend size_t buffsize_; size_t size_; - Backend(void* pbuff = NULL, size_t buffsize = 0) : pbuff_((uint8*) pbuff), buffsize_(buffsize), size_(0) + Backend(void* pbuff = nullptr, size_t buffsize = 0) : pbuff_((uint8*) pbuff), buffsize_(buffsize), size_(0) { memset(pbuff, 0xCC, buffsize); // INT3 } @@ -1323,7 +1323,7 @@ namespace detail size_t buffsize_; public: - CodeBuffer() : pbuff_(NULL), codesize_(0), buffsize_(0) {} + CodeBuffer() : pbuff_(nullptr), codesize_(0), buffsize_(0) {} ~CodeBuffer() {Reset(0);} void* GetPointer() const {return pbuff_;} @@ -1338,13 +1338,13 @@ namespace detail #else munmap(pbuff_, buffsize_); #endif - pbuff_ = NULL; + pbuff_ = nullptr; codesize_ = 0; buffsize_ = 0; } if (codesize) { #if defined(JITASM_WIN) - void* pbuff = ::VirtualAlloc(NULL, codesize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + void* pbuff = ::VirtualAlloc(nullptr, codesize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (!pbuff) { JITASM_ASSERT(0); return false; @@ -1355,7 +1355,7 @@ namespace detail #else int pagesize = getpagesize(); size_t buffsize = (codesize + pagesize - 1) / pagesize * pagesize; - void* pbuff = mmap(NULL, buffsize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); + void* pbuff = mmap(nullptr, buffsize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); if (!pbuff) { JITASM_ASSERT(0); return false; @@ -5584,7 +5584,7 @@ namespace compiler } // build interval - BitVector *last_liveness = NULL; + BitVector *last_liveness = nullptr; std::vector reg_assignables; bool last_reg_constraints = false; bool last_stack_vars = false; @@ -5648,7 +5648,7 @@ namespace compiler for (size_t v = 0; v < use_points.size(); ++v) { RegUsePointRange range(use_points[v]); for (size_t i = 0; i < intervals.size(); ++i) { - const Interval *next_interval = i + 1 < intervals.size() ? &intervals[i + 1] : NULL; + const Interval *next_interval = i + 1 < intervals.size() ? &intervals[i + 1] : nullptr; intervals[i].UpdateUse(v, range, next_interval); } } @@ -5664,7 +5664,7 @@ namespace compiler for (size_t v = 0; v < use_points.size(); ++v) { RegUsePointRange range(use_points[v]); for (size_t i = interval_idx; i < interval_idx + 2; ++i) { - const Interval *next_interval = i + 1 < intervals.size() ? &intervals[i + 1] : NULL; + const Interval *next_interval = i + 1 < intervals.size() ? &intervals[i + 1] : nullptr; intervals[i].UpdateUse(v, range, next_interval); } } @@ -5921,7 +5921,7 @@ namespace compiler size_t loop_depth; ///< Loop nesting depth Lifetime lifetime[3]; ///< Variable lifetime (0: GP, 1: MMX, 2: XMM/YMM) - BasicBlock(size_t instr_begin_, size_t instr_end_, BasicBlock *successor0 = NULL, BasicBlock *successor1 = NULL) : instr_begin(instr_begin_), instr_end(instr_end_), depth((size_t)-1), dfs_parent(NULL), immediate_dominator(NULL), loop_depth(0) { + BasicBlock(size_t instr_begin_, size_t instr_end_, BasicBlock *successor0 = nullptr, BasicBlock *successor1 = nullptr) : instr_begin(instr_begin_), instr_end(instr_end_), depth((size_t)-1), dfs_parent(nullptr), immediate_dominator(nullptr), loop_depth(0) { successor[0] = successor0; successor[1] = successor1; } @@ -6054,7 +6054,7 @@ namespace compiler dom[w] = dom[dom[w]]; depth_first_blocks[w]->immediate_dominator = depth_first_blocks[dom[w]]; } - depth_first_blocks[0]->immediate_dominator = NULL; + depth_first_blocks[0]->immediate_dominator = nullptr; } }; @@ -6156,7 +6156,7 @@ namespace compiler new_block->successor[1] = target_block->successor[1]; new_block->predecessor.push_back(target_block); target_block->successor[0] = new_block; - target_block->successor[1] = NULL; + target_block->successor[1] = nullptr; target_block->instr_end = instr_idx; // replace predecessor of successors @@ -6584,14 +6584,14 @@ namespace compiler } uint32 used_reg = 0; - const Lifetime::Interval *last_interval = NULL; + const Lifetime::Interval *last_interval = nullptr; size_t last_loop_depth = 0; for (ControlFlowGraph::BlockList::iterator block = cfg.dfs_begin(); block != cfg.dfs_end(); ++block) { Lifetime& lifetime = (*block)->lifetime[reg_family]; const size_t loop_depth = (*block)->loop_depth; // Spill identification - lifetime.SpillIdentification(available_reg_count, total_spill_cost, (*block)->GetFrequency(), last_loop_depth == loop_depth ? last_interval : NULL, var_attrs); + lifetime.SpillIdentification(available_reg_count, total_spill_cost, (*block)->GetFrequency(), last_loop_depth == loop_depth ? last_interval : nullptr, var_attrs); // Register assignment used_reg |= lifetime.AssignRegister(available_reg, last_interval); diff --git a/metamod/src/metamod.cpp b/metamod/src/metamod.cpp index bc3cbb9..d71be2f 100644 --- a/metamod/src/metamod.cpp +++ b/metamod/src/metamod.cpp @@ -150,7 +150,6 @@ void metamod_startup() // until later. if (g_config->m_debuglevel != 0) CVAR_SET_FLOAT("meta_debug", g_config->m_debuglevel); - if (!g_config->m_clientmeta) disable_clientcommand_fwd(); diff --git a/metamod/src/mlist.cpp b/metamod/src/mlist.cpp index 5f103c5..764839b 100644 --- a/metamod/src/mlist.cpp +++ b/metamod/src/mlist.cpp @@ -243,7 +243,7 @@ MPlugin* MPluginList::add(MPlugin* padd) if (!iplug) { META_ERROR("Couldn't add plugin '%s' to list; reached max plugins (%d)", padd->m_file, MAX_PLUGINS); - return NULL; + return nullptr; } // copy filename into this free slot @@ -321,7 +321,7 @@ bool MPluginList::ini_startup() // Check for a matching platform with different platform specifics // level. - if (NULL != (pmatch = find_match(&m_plist[n]))) + if (nullptr != (pmatch = find_match(&m_plist[n]))) { if (pmatch->m_pfspecific >= m_plist[n].m_pfspecific) { @@ -390,7 +390,7 @@ bool MPluginList::ini_refresh() { // Check for a matching platform with higher platform specifics // level. - if (NULL != (pl_found = find_match(&pl_temp))) + if (nullptr != (pl_found = find_match(&pl_temp))) { if (pl_found->m_pfspecific >= pl_temp.m_pfspecific) { diff --git a/metamod/src/osdep.cpp b/metamod/src/osdep.cpp index 1cb5d05..e501070 100644 --- a/metamod/src/osdep.cpp +++ b/metamod/src/osdep.cpp @@ -133,7 +133,7 @@ const char* CSysModule::getloaderror() const char *str_GetLastError() { static char buf[MAX_STRBUF_LEN]; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buf, MAX_STRBUF_LEN - 1, NULL); + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buf, MAX_STRBUF_LEN - 1, nullptr); return buf; } #endif diff --git a/metamod/src/sdk_util.cpp b/metamod/src/sdk_util.cpp index d3325a9..4fa9c7c 100644 --- a/metamod/src/sdk_util.cpp +++ b/metamod/src/sdk_util.cpp @@ -45,7 +45,7 @@ void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, const ch if (FNullEnt(pEntity) || pEntity->free) return; - MESSAGE_BEGIN(MSG_ONE, SVC_TEMPENTITY, NULL, pEntity); + MESSAGE_BEGIN(MSG_ONE, SVC_TEMPENTITY, nullptr, pEntity); WRITE_BYTE(TE_TEXTMESSAGE); WRITE_BYTE(textparms.channel & 0xFF); diff --git a/metamod/src/utils.cpp b/metamod/src/utils.cpp index a91ca60..285bb77 100644 --- a/metamod/src/utils.cpp +++ b/metamod/src/utils.cpp @@ -17,7 +17,7 @@ char* ENTITY_KEYVALUE(edict_t* entity, char* key) const char* LOCALINFO(char* key) { - return ENTITY_KEYVALUE(NULL, key); + return ENTITY_KEYVALUE(nullptr, key); } static_allocator::static_allocator(memory_protection protection) : m_protection(protection) @@ -61,9 +61,9 @@ size_t static_allocator::memory_used() const void static_allocator::allocate_page() { #ifdef WIN32 - auto page = VirtualAlloc(NULL, Pagesize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + auto page = VirtualAlloc(nullptr, Pagesize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); #else - auto page = mmap(NULL, Pagesize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); + auto page = mmap(nullptr, Pagesize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); #endif m_used = 0; @@ -103,7 +103,7 @@ char *trimbuf(char *str) { char *ibuf; - if (str == NULL) return NULL; + if (str == nullptr) return nullptr; for (ibuf = str; *ibuf && (byte)(*ibuf) < (byte)0x80 && isspace(*ibuf); ++ibuf) ; @@ -147,20 +147,19 @@ bool IsAbsolutePath(const char *path) #ifdef _WIN32 char *realpath(const char *file_name, char *resolved_name) { - int ret = GetFullPathName(file_name, PATH_MAX, resolved_name, NULL); + int ret = GetFullPathName(file_name, PATH_MAX, resolved_name, nullptr); if (ret > PATH_MAX) { errno = ENAMETOOLONG; - return NULL; + return nullptr; } if (ret > 0) { - HANDLE handle; WIN32_FIND_DATA find_data; - handle = FindFirstFile(resolved_name, &find_data); + HANDLE handle = FindFirstFile(resolved_name, &find_data); if (INVALID_HANDLE_VALUE == handle) { errno = ENOENT; - return NULL; + return nullptr; } FindClose(handle); @@ -168,6 +167,6 @@ char *realpath(const char *file_name, char *resolved_name) return resolved_name; } - return NULL; + return nullptr; } #endif // _WIN32