diff --git a/CMakeLists.txt b/CMakeLists.txt index 00902fa..30331d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ add_subdirectory(test) # main add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES}) -set(FLAGS "-m32 -O2 -fvisibility=hidden -flto -fPIC") +set(FLAGS "-m32 -O3 -pipe -fvisibility-inlines-hidden -fvisibility=hidden -flto -fPIC") set_target_properties( ${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${FLAGS} \ @@ -33,7 +33,8 @@ set_target_properties( -ffunction-sections \ -Wall \ -Wextra \ - -Wzero-as-null-pointer-constant \ + -Werror \ + -Wstrict-aliasing \ -Weffc++ \ -Wunknown-pragmas" ) diff --git a/src/config.cpp b/src/config.cpp index 22f8940..509bc2c 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -37,7 +37,7 @@ #include #include -Config::Config(const std::shared_ptr &logger) +Config::Config(const up::shared_ptr &logger) : logger_(logger), options_(), @@ -59,19 +59,10 @@ bool Config::addOption(const std::string &title, Config::OptionType type, const bool Config::deleteOption(const std::string &title) { + bool hasSomethingToDelete = defaultOptions_.find(title) != defaultOptions_.end(); options_.erase(title); - auto end = defaultOptions_.end(); - auto newEnd = std::remove_if(defaultOptions_.begin(), end, [&title](const decltype(defaultOptions_)::value_type &e) -> bool - { - if(e.first == title) - return true; - return false; - }); - if(end == newEnd) - return false; - - defaultOptions_.erase(newEnd, end); - return true; + defaultOptions_.erase(title); + return hasSomethingToDelete; } bool Config::addOption(const std::string &title, Config::OptionType type, const bool &defaultValue) @@ -94,15 +85,13 @@ bool Config::addOptionVariant(const std::string &title, Config::OptionType type, if(!checkVariant(type, defaultValue)) return false; - try { - options_.at(title); - } - catch (std::exception&) { + if(options_.find(title) != options_.end()) { + return false; + } else { options_[title] = {type, defaultValue}; - defaultOptions_.push_back({title , defaultValue}); + defaultOptions_[title] = defaultValue; return true; } - return false; } std::pair Config::getOption(const std::string &title) const @@ -112,16 +101,16 @@ std::pair Config::getOption(const std:: bool Config::setOption(const std::string &title, const Config::VariantType &newValue) { - decltype(options_)::iterator position = options_.find(title); + auto position = options_.find(title); if(position == options_.end()) return false; - const OptionType type = (*position).second.first; + const OptionType type = position->second.first; if(!checkVariant(type, newValue)) return false; - (*position).second.second = newValue; + position->second.second = newValue; return true; } @@ -148,8 +137,7 @@ bool Config::setOption(const std::string &title, const std::string &newValue) void Config::loadConfig(const std::string &path) { - std::ifstream file; - file.open(path); + std::ifstream file(path); if(!file) file.open(path, std::ios::out | std::ios::in | std::ios::trunc); @@ -172,17 +160,17 @@ void Config::loadConfig(const std::string &path) file.close(); } -std::shared_ptr Config::getLogger() const +up::shared_ptr Config::getLogger() const { return logger_; } -std::shared_ptr &Config::getLoggerRef() +up::shared_ptr &Config::getLoggerRef() { return logger_; } -void Config::setLogger(const std::shared_ptr &logger) +void Config::setLogger(const up::shared_ptr &logger) { logger_ = logger; } @@ -214,12 +202,10 @@ void Config::resetOptionsToDefaults() { for(auto &curPair : defaultOptions_) { - decltype (options_)::iterator position = options_.find(curPair.first); - (*position).second.second = curPair.second; + options_.find(curPair.first)->second.second = curPair.second; } } - bool Config::readLine(const std::string &lineRef) { std::string line = trim(removeComments(lineRef)); @@ -240,31 +226,38 @@ bool Config::readLine(const std::string &lineRef) logger_->debug(FNAME + " Left right: " + left + " = " + right); try { - decltype(options_)::mapped_type &value = options_.at(left); + auto &value = options_.at(left); const auto BooleanFunction = [&value, this](const std::string &checkString) -> bool { - const auto assignBool = [&value, this](bool assignValue){ value.second = assignValue; }; - const std::unordered_map> switchMap = - {{"true",std::bind(assignBool, true)}, - {"1",std::bind(assignBool, true)}, - {"yes",std::bind(assignBool, true)}, - {"yeah",std::bind(assignBool, true)}, + const auto assignBool = [&value](bool assignValue) { + value.second = assignValue; + }; - {"false",std::bind(assignBool, false)}, - {"0",std::bind(assignBool, false)}, - {"no",std::bind(assignBool, false)}, - {"mazdan",std::bind(assignBool, false)}}; + const std::unordered_map> switchMap = + { + {"true", std::bind(assignBool, true) }, + {"1", std::bind(assignBool, true) }, + {"yes", std::bind(assignBool, true) }, + {"yeah", std::bind(assignBool, true) }, + {"false", std::bind(assignBool, false) }, + {"0", std::bind(assignBool, false) }, + {"no", std::bind(assignBool, false) }, + {"mazdan", std::bind(assignBool, false) } + }; std::string localCopy; + localCopy.reserve(checkString.size()); + std::transform(checkString.begin(), checkString.end(), std::back_inserter(localCopy), ::tolower); - try { - switchMap.at(localCopy)(); - } catch (std::exception&) { - logger_->error(FNAME + " Exception occured. Return from BF"); + + auto it = switchMap.find(localCopy); + if(it != switchMap.end()) { + it->second(); + return true; + } else { return false; } - return true; }; switch (value.first) diff --git a/src/config.h b/src/config.h index 2baf594..4e33d4e 100644 --- a/src/config.h +++ b/src/config.h @@ -30,21 +30,23 @@ * */ +#pragma once #ifndef CONFIG_H #define CONFIG_H -#include #include #include #include #include + #include "logger.h" +#include "helper/shared.h" class Config { public: - Config(const std::shared_ptr &logger); + explicit Config(const up::shared_ptr &logger); enum class OptionType { @@ -55,7 +57,7 @@ class Config typedef boost::variant VariantType; bool addOption(const std::string &title, Config::OptionType type, const VariantType &defaultValue); - bool addOption(const std::string &title, OptionType type, const char* defaultValue); + bool addOption(const std::string &title, Config::OptionType type, const char* defaultValue); bool addOption(const std::string &title, Config::OptionType type, const bool &defaultValue); bool addOption(const std::string &title, Config::OptionType type, const int &defaultValue); bool addOption(const std::string &title, Config::OptionType type, const std::string &defaultValue); @@ -71,16 +73,16 @@ class Config void loadConfig(const std::string &path); void resetOptionsToDefaults(); bool readLine(const std::string &lineRef); - std::shared_ptr getLogger() const; - std::shared_ptr &getLoggerRef(); - void setLogger(const std::shared_ptr &logger); + up::shared_ptr getLogger() const; + up::shared_ptr &getLoggerRef(); + void setLogger(const up::shared_ptr &logger); private: bool checkVariant(const OptionType type, const VariantType &variant) const; bool addOptionVariant(const std::string &title, OptionType type, const VariantType &defaultValue); - std::shared_ptr logger_; + up::shared_ptr logger_; std::unordered_map> options_; - std::vector> defaultOptions_; + std::unordered_map defaultOptions_; bool configWasLoadedOnce_; }; diff --git a/src/helper/external_api.h b/src/helper/external_api.h index ba4af5c..e447576 100644 --- a/src/helper/external_api.h +++ b/src/helper/external_api.h @@ -1,3 +1,4 @@ +#pragma once #ifndef EXTERNAL_API_H #define EXTERNAL_API_H diff --git a/src/helper/shared.h b/src/helper/shared.h index 7aea19e..8939711 100644 --- a/src/helper/shared.h +++ b/src/helper/shared.h @@ -1,3 +1,4 @@ +#pragma once #ifndef SHARED_H #define SHARED_H @@ -15,6 +16,21 @@ #define COLD #endif +#include +#include + +namespace up +{ + template + using shared_ptr = boost::local_shared_ptr; + + template + inline auto make_shared(Args&&... args) + { + return boost::make_local_shared(std::forward(args)...); + } + +} // Here we can put typedefs that shared by many files #endif // SHARED_H diff --git a/src/helper/string_utils.cpp b/src/helper/string_utils.cpp index 08d8b24..43ce5f7 100644 --- a/src/helper/string_utils.cpp +++ b/src/helper/string_utils.cpp @@ -35,11 +35,11 @@ #include #include #include + std::vector parseString(const std::string &inputString, bool removeQuotes/*=true*/, bool anySpaceCharacters/*=true*/) noexcept { std::vector returnVector; - auto start = inputString.begin(); auto end = inputString.end(); @@ -59,7 +59,7 @@ std::vector parseString(const std::string &inputString, bool remove case '"': case '\'': { if(!removeQuotes) - insertString+=*index; + insertString += *index; if(status == PARSING_STATUS::PARSING_QUOTE) { @@ -78,7 +78,7 @@ std::vector parseString(const std::string &inputString, bool remove (!anySpaceCharacters && *index == ' ')) { if(status == PARSING_STATUS::PARSING_QUOTE) - insertString+=*index; + insertString += *index; else if(status == PARSING_STATUS::PARSING_STARTED) { returnVector.push_back(insertString); @@ -88,7 +88,7 @@ std::vector parseString(const std::string &inputString, bool remove } else { - insertString+=*index; + insertString += *index; if(status != PARSING_STATUS::PARSING_QUOTE) status = PARSING_STATUS::PARSING_STARTED; } @@ -165,12 +165,10 @@ std::string trim(const std::string &str) noexcept std::string::size_type lastNonWhiteSpace = str.size(); + auto crend = str.crend(); + for(auto it = str.crbegin(); it != crend && std::isspace(*it); ++it) { - auto crend = str.crend(); - for(auto it = str.crbegin(); it != crend && std::isspace(*it); ++it) - { - --lastNonWhiteSpace; - } + --lastNonWhiteSpace; } return str.substr(firstNonWhiteSpace, lastNonWhiteSpace - firstNonWhiteSpace); diff --git a/src/helper/string_utils.h b/src/helper/string_utils.h index 7b66da1..471d6d7 100644 --- a/src/helper/string_utils.h +++ b/src/helper/string_utils.h @@ -30,12 +30,14 @@ * */ +#pragma once #ifndef STRING_UTILS_H #define STRING_UTILS_H #include #include #include + std::vector parseString(const std::string &inputString, bool removeQuotes = true, bool anySpaceCharacters = true) noexcept; bool starts_with(const std::string &input,const std::string &prefix) noexcept; bool is_string_whitespaces(const std::string &input) noexcept; diff --git a/src/logger.cpp b/src/logger.cpp index c9b73f1..dbf0f15 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -101,22 +101,22 @@ bool Logger::log(const Logger::CategoryType &category, const std::string &str) c switch (category) { case Logger::CategoryType::Debug: - endMessage="Debug: "; + endMessage = "Debug: "; break; case Logger::CategoryType::Info: - endMessage="Info: "; + endMessage = "Info: "; break; case Logger::CategoryType::Warning: - endMessage="Warning: "; + endMessage = "Warning: "; break; case Logger::CategoryType::Error: - endMessage="Error: "; + endMessage = "Error: "; break; case Logger::CategoryType::CriticalError: - endMessage="Critical error: "; + endMessage = "Critical error: "; break; } - endMessage+=str; + endMessage += str; switch(outputType_) { diff --git a/src/logger.h b/src/logger.h index 5c82d77..3fa716b 100644 --- a/src/logger.h +++ b/src/logger.h @@ -30,10 +30,10 @@ * */ +#pragma once #ifndef LOGGER_H #define LOGGER_H -#include #include #include #include @@ -73,7 +73,7 @@ class Logger return static_cast(value); } public: - Logger(const OutputType &outputType = OutputType::NoOutput); + explicit Logger(const OutputType &outputType = OutputType::NoOutput); bool log(const CategoryType &category, const std::string &str) const noexcept; diff --git a/src/main.cpp b/src/main.cpp index cb2bf62..f6be9ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,6 +39,7 @@ #include #include #include +#include Module* module = nullptr; @@ -63,7 +64,7 @@ static META_FUNCTIONS gMetaFunctionTable = { plugin_info_t Plugin_info = { META_INTERFACE_VERSION, "Ultimate Unprecacher", - "Beta 2.5.1", + "Beta 2.5.2", "2016/05/18", "Alik Aslanyan ", "https://github.com/in-line/metamod_unprecacher", @@ -137,7 +138,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME /* now */, *configPath = *pluginDirPath + "/" + "config.ini"; module = new Module(); - module->getConfigRef().addOption(MODULE_CHECKS, Config::OptionType::String, "abcde"); + module->getConfigMut().addOption(MODULE_CHECKS, Config::OptionType::String, "abcde"); return(TRUE); } @@ -152,13 +153,20 @@ C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME, PL_UNLOAD_REASON) inline HOT void handleUnprecacheOptions(edict_t *eEnt, const std::function &&replaceFunction) { const UnprecacheOptions &options = module->getLastHitPoint(); - if(unlikely(options.isNotDefault())) + if(options.isNotDefault()) { - if(likely(eEnt) && options.deleteEntity()) + if(likely(!FNullEnt(eEnt)) && options.deleteEntity()) { auto entIndex = ENTINDEX(eEnt); - if(likely((entIndex > 33 && entIndex > 0) || !options.notDeleteHuman())) + + if(unlikely(entIndex < 0)) { + return; + } + + if(entIndex > gpGlobals->maxClients || !options.notDeleteHuman()) { eEnt->v.flags |= FL_KILLME; + } + } else if(options.replace()) { @@ -169,16 +177,17 @@ inline HOT void handleUnprecacheOptions(edict_t *eEnt, const std::functionmapname)); + mapName->assign(STRING(gpGlobals->mapname)); + mkdir((*pluginDirPath + "/" + "logs").c_str(), 0700); { memset(&moduleFunctions[0], false, sizeof(ModuleFunctions) * sizeof(moduleFunctions[0])); module->loadConfig(*configPath); - std::string functionsStr = boost::get(module->getConfigRef().getOption(MODULE_CHECKS).second); + std::string functionsStr = boost::get(module->getConfig().getOption(MODULE_CHECKS).second); for(auto &c : functionsStr) { constexpr std::size_t size = static_cast(ModuleFunctions::LastElement); - if(c>='a' && std::size_t(c)<=('a'+size)) + if(c >= 'a' && std::size_t(c) <= ('a' + size)) { moduleFunctions[c - 'a'] = true; } @@ -414,7 +423,7 @@ int pfnSpawn(edict_t*) { if(pairValue.second.replace()) { - PRECACHE_MODEL((char*)STRING(ALLOC_STRING(pairValue.second.replacedPath().c_str()))); + PRECACHE_MODEL(STRING(ALLOC_STRING(pairValue.second.replacedPath().c_str()))); } } } @@ -431,7 +440,7 @@ int pfnSpawn(edict_t*) replacePath = replacePath.substr(sound.size(), std::string::npos); } - PRECACHE_SOUND((char*)STRING(ALLOC_STRING(replacePath.c_str()))); + PRECACHE_SOUND(STRING(ALLOC_STRING(replacePath.c_str()))); } } } diff --git a/src/module.cpp b/src/module.cpp index f3ca4a6..6dd73b6 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -40,27 +40,27 @@ #include #include -std::shared_ptr Module::getLogger() const +up::shared_ptr Module::getLogger() const { return logger_; } -std::shared_ptr &Module::getLoggerRef() +up::shared_ptr &Module::getLoggerRef() { return logger_; } -void Module::setLogger(const std::shared_ptr &logger) +void Module::setLogger(const up::shared_ptr &logger) { logger_ = logger; } -Config Module::getConfig() const +const Config &Module::getConfig() const { return config_; } -Config &Module::getConfigRef() +Config &Module::getConfigMut() { return config_; } @@ -197,7 +197,6 @@ void Module::loadLists(const std::string &path) loadListFromFile(path, [this](const std::string &line) { this->readLine(line); }); - this->revalidateEnds(); } void Module::loadListFromFile(const std::string &path, std::function onLineRead) @@ -222,17 +221,16 @@ void Module::loadListFromFile(const std::string &path, std::functiondebug(FNAME + " Start file reading"); - std::string line; - while(getline(inputFile, line)) - { - onLineRead(line); - } - logger_->debug(FNAME + " Input file close"); - inputFile.close(); + logger_->debug(FNAME + " Start file reading"); + + std::string line; + while(getline(inputFile, line)) + { + onLineRead(line); } + logger_->debug(FNAME + " Input file close"); + inputFile.close(); } void Module::loadWhiteList(const std::string &path) @@ -258,7 +256,6 @@ void Module::loadWhiteList(const std::string &path) maps_[MAP_SOUNDS].erase(line.substr(sound.size(), std::string::npos)); } } - this->revalidateEnds(); } @@ -269,13 +266,6 @@ void Module::clearLists() maps_[MAP_SOUNDS].clear(); } -void Module::revalidateEnds() -{ - mapsEnds_[MAP_MODELS] = maps_[MAP_MODELS].end(); - mapsEnds_[MAP_SPRITES] = maps_[MAP_SPRITES].end(); - mapsEnds_[MAP_SOUNDS] = maps_[MAP_SOUNDS].end(); -} - void Module::loadConfig(const std::string &path) { config_.loadConfig(path); @@ -296,7 +286,6 @@ const Module::UnprecacheMap& Module::getModelsMap() const void Module::setModelsMap(const Module::UnprecacheMap &modelsMap) { maps_[MAP_MODELS] = modelsMap; - mapsEnds_[MAP_MODELS] = maps_[MAP_MODELS].end(); } const Module::UnprecacheMap& Module::getSpritesMap() const @@ -307,7 +296,6 @@ const Module::UnprecacheMap& Module::getSpritesMap() const void Module::setSpritesMap(const Module::UnprecacheMap &spritesMap) { maps_[MAP_SPRITES] = spritesMap; - mapsEnds_[MAP_SPRITES] = maps_[MAP_SPRITES].end(); } const Module::UnprecacheMap& Module::getSoundsMap() const @@ -318,7 +306,6 @@ const Module::UnprecacheMap& Module::getSoundsMap() const void Module::setSoundsMap(const Module::UnprecacheMap &soundsMap) { maps_[MAP_SOUNDS] = soundsMap; - mapsEnds_[MAP_SOUNDS] = maps_[MAP_SOUNDS].end(); } const UnprecacheOptions& Module::getLastHitPoint() const diff --git a/src/module.h b/src/module.h index 6065312..a65bfe4 100644 --- a/src/module.h +++ b/src/module.h @@ -30,6 +30,7 @@ * */ +#pragma once #ifndef MODULE_H #define MODULE_H @@ -44,7 +45,6 @@ #include #include -#include #include @@ -64,7 +64,7 @@ class Module inline HOT bool checkPathInMap(const std::string &path, MAP mapType) { const UnprecacheMap::const_iterator &result = maps_[mapType].find(path); - if(result != mapsEnds_[mapType]) + if(result != maps_[mapType].end()) { #ifdef _DEBUG logger_->debug(FNAME + " Match. " + path + " -> " + result->first); @@ -76,10 +76,9 @@ class Module } UnprecacheMap maps_[MAP_SIZE]; - UnprecacheMap::const_iterator mapsEnds_[MAP_SIZE]; const UnprecacheOptions *lastHitPoint_; - std::shared_ptr logger_; + up::shared_ptr logger_; Config config_; #define LOGGER_VERBOSITY "logger_verbosity" @@ -87,7 +86,7 @@ class Module void loadListFromFile(const std::string &path, std::function onLineRead); public: - Module(const Logger::OutputType &outputType = Logger::OutputType::NoOutput); + explicit Module(const Logger::OutputType &outputType = Logger::OutputType::NoOutput); Module(const Module&) = delete; Module(const Module&&) = delete; const Module& operator =(const Module&) = delete; @@ -106,7 +105,6 @@ class Module void loadWhiteList(const std::string &path); void clearLists(); - void revalidateEnds(); void loadConfig(const std::string &path); void updateSettings(); @@ -122,12 +120,13 @@ class Module const HOT UnprecacheOptions &getLastHitPoint() const; - std::shared_ptr getLogger() const; - std::shared_ptr &getLoggerRef(); - void setLogger(const std::shared_ptr &logger); + up::shared_ptr getLogger() const; + up::shared_ptr &getLoggerRef(); + void setLogger(const up::shared_ptr &logger); + + const Config &getConfig() const; + Config &getConfigMut(); - Config getConfig() const; - Config &getConfigRef(); void setConfig(const Config &config); void analyzeLoggerStringPattern(const std::string &str); diff --git a/src/unprecacheoptions.cpp b/src/unprecacheoptions.cpp index ca6e1c6..49069ee 100644 --- a/src/unprecacheoptions.cpp +++ b/src/unprecacheoptions.cpp @@ -105,13 +105,13 @@ void UnprecacheOptions::setDeleteEntity(bool deleteEntity) deleteEntity_ = deleteEntity; } -UnprecacheOptions UnprecacheOptions::stringPatternToOptions(std::string pattern) +UnprecacheOptions UnprecacheOptions::stringPatternToOptions(const std::string &pattern) { // a - delete entity // b - not delete human entities // c - replace UnprecacheOptions returnOptions; - for(char& character : pattern) + for(char character : pattern) { switch(character) { diff --git a/src/unprecacheoptions.h b/src/unprecacheoptions.h index 0ff2605..735763f 100644 --- a/src/unprecacheoptions.h +++ b/src/unprecacheoptions.h @@ -30,6 +30,7 @@ * */ +#pragma once #ifndef UNPRECACHEOPTIONS_H #define UNPRECACHEOPTIONS_H @@ -58,7 +59,7 @@ class UnprecacheOptions const std::string& replacedPath() const; void setReplacedPath(const std::string &replacedPath); - static UnprecacheOptions stringPatternToOptions(std::string pattern); + static UnprecacheOptions stringPatternToOptions(const std::string &pattern); bool isNotDefault() const; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2fef3ae..9741406 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,16 +1,14 @@ cmake_minimum_required(VERSION 2.8) project(tester) -set(CMAKE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") set(CMAKE_CXX_STANDARD 17) find_package(CxxTest REQUIRED) -#cmake_policy(SET CMP0040 NEW) if(CXXTEST_FOUND) enable_testing() file(GLOB_RECURSE TESTES ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) CXXTEST_ADD_TEST(${PROJECT_NAME} runner.cpp ${TESTES}) target_link_libraries(${PROJECT_NAME} unprecacher_static) - set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") + set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m32 -O0" LINK_FLAGS "-m32 -O0") add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ./${PROJECT_NAME}) endif() diff --git a/test/test_config.h b/test/test_config.h index c2aa398..7452faa 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -35,13 +35,14 @@ #include #include "../src/config.h" +#include "../src/helper/shared.h" class TestConfig : public CxxTest::TestSuite { private: - std::shared_ptr createLogger() + up::shared_ptr createLogger() { - auto logger = std::make_shared(); + auto logger = up::make_shared(); logger->setCategoryDisplayed(Logger::CategoryType::CriticalError, true); logger->setCategoryDisplayed(Logger::CategoryType::Error, true); logger->setCategoryDisplayed(Logger::CategoryType::Warning, true); @@ -131,12 +132,12 @@ class TestConfig : public CxxTest::TestSuite TS_ASSERT(!config.addOption("test_option_bool", Config::OptionType::Boolean, false)); TS_ASSERT(!config.deleteOption("test_option_mb1234")); + TS_ASSERT_THROWS_NOTHING(config.getOption("test_option_bool")); TS_ASSERT(config.deleteOption("test_option_bool")); TS_ASSERT_THROWS_ANYTHING(config.getOption("test_option_bool")); TS_ASSERT(!config.deleteOption("test_option_bool")); - } }; diff --git a/test/test_module.h b/test/test_module.h index 8bb5100..b870828 100644 --- a/test/test_module.h +++ b/test/test_module.h @@ -55,7 +55,6 @@ class TestModule : public CxxTest::TestSuite TS_ASSERT(module.readLine("models/w_usp.mdl abc models/v_knife_custom.something")); TS_ASSERT(module.readLine("sprites/w_usp.spr abc models/v_knife_custom.something")); TS_ASSERT(module.readLine("sound/w_usp.wav abc models/v_knife_custom.something")); - module.revalidateEnds(); UnprecacheOptions o = UnprecacheOptions::stringPatternToOptions("abc"); o.setReplacedPath("models/v_knife_custom.something");