From 319022d962197b73f09d47418ff29ede2f6dcc2d Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 23 Mar 2012 15:24:39 +0100 Subject: [PATCH 01/28] speed up dialogue start-up. --- apps/openmw/mwdialogue/dialoguemanager.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 91785819f..451c49b1e 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -531,6 +531,13 @@ namespace MWDialogue mChoice = -1; mIsInChoice = false; mCompilerContext.setExtensions (&extensions); + mDialogueMap.clear(); + actorKnownTopics.clear(); + ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + { + mDialogueMap[it->first] = it->second; + } } void DialogueManager::addTopic(std::string topic) @@ -566,13 +573,7 @@ namespace MWDialogue mActor = actor; - mDialogueMap.clear(); actorKnownTopics.clear(); - ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) - { - mDialogueMap[it->first] = it->second; - } //initialise the GUI mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue); @@ -585,6 +586,7 @@ namespace MWDialogue //greeting bool greetingFound = false; //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; From ae989040e58a6b8c688d545a0b6278868e7ce9b7 Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Sun, 1 Apr 2012 21:29:49 +0200 Subject: [PATCH 02/28] Issue #225: Fix for memleak when loading terrain. --- apps/openmw/mwrender/terrain.cpp | 11 +++++++++-- components/esm/loadland.cpp | 18 ++++++++++++++++++ components/esm/loadland.hpp | 3 +++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index 887721565..0b8f933a2 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -98,7 +98,10 @@ namespace MWRender ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY); if ( land != NULL ) { - land->loadData(); + if (!land->dataLoaded) + { + land->loadData(); + } } //split the cell terrain into four segments @@ -420,7 +423,11 @@ namespace MWRender ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY); if ( land != NULL ) { - land->loadData(); + if (!land->dataLoaded) + { + land->loadData(); + } + return land->landData ->textures[y * ESM::Land::LAND_TEXTURE_SIZE + x]; } diff --git a/components/esm/loadland.cpp b/components/esm/loadland.cpp index cd2cf1d91..96afdf831 100644 --- a/components/esm/loadland.cpp +++ b/components/esm/loadland.cpp @@ -2,6 +2,24 @@ namespace ESM { + +Land::Land() + : flags(0) + , X(0) + , Y(0) + , mEsm(NULL) + , hasData(false) + , dataLoaded(false) + , landData(NULL) +{ +} + +Land::~Land() +{ + delete landData; +} + + void Land::load(ESMReader &esm) { mEsm = &esm; diff --git a/components/esm/loadland.hpp b/components/esm/loadland.hpp index 5ccd966d9..64baecd34 100644 --- a/components/esm/loadland.hpp +++ b/components/esm/loadland.hpp @@ -11,6 +11,9 @@ namespace ESM struct Land { + Land(); + ~Land(); + int flags; // Only first four bits seem to be used, don't know what // they mean. int X, Y; // Map coordinates. From 89565bacd17453c1ce2a8cff7cf6ea5822a262f5 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Mon, 2 Apr 2012 14:34:21 +0200 Subject: [PATCH 03/28] since the default method is not available in older boost we should check by ourselfs if the options are given and dont use notify --- apps/mwiniimporter/main.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/apps/mwiniimporter/main.cpp b/apps/mwiniimporter/main.cpp index 9a6e61645..43b17b76a 100644 --- a/apps/mwiniimporter/main.cpp +++ b/apps/mwiniimporter/main.cpp @@ -9,7 +9,7 @@ namespace bpo = boost::program_options; int main(int argc, char *argv[]) { - bpo::options_description desc("Syntax: mwiniimporter \nAllowed options"); + bpo::options_description desc("Syntax: mwiniimporter -i inifile -c configfile \nAllowed options"); desc.add_options() ("help,h", "produce help message") ("verbose,v", "verbose output") @@ -20,25 +20,11 @@ int main(int argc, char *argv[]) { ; bpo::variables_map vm; - try { - bpo::store(boost::program_options::parse_command_line(argc, argv, desc), vm); + bpo::store(boost::program_options::parse_command_line(argc, argv, desc), vm); - // parse help before calling notify because we dont want it to throw an error if help is set - if(vm.count("help")) { - std::cout << desc; - return 0; - } - - bpo::notify(vm); - - } - catch(std::exception& e) { - std::cerr << "Error:" << e.what() << std::endl; - return -1; - } - catch(...) { - std::cerr << "Error" << std::endl; - return -2; + if(vm.count("help") || !vm.count("ini") || !vm.count("cfg")) { + std::cout << desc; + return 0; } std::string iniFile = vm["ini"].as(); From 16674ad141661ea77b5903b1cba0716bd19ea7d2 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Mon, 2 Apr 2012 14:42:01 +0200 Subject: [PATCH 04/28] open file for writing AFTER reading it :) --- apps/mwiniimporter/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/mwiniimporter/main.cpp b/apps/mwiniimporter/main.cpp index 43b17b76a..836f84eb0 100644 --- a/apps/mwiniimporter/main.cpp +++ b/apps/mwiniimporter/main.cpp @@ -47,7 +47,6 @@ int main(int argc, char *argv[]) { MwIniImporter importer; importer.setVerbose(vm.count("verbose")); - boost::iostreams::stream file(outputFile); MwIniImporter::multistrmap ini = importer.loadIniFile(iniFile); MwIniImporter::multistrmap cfg = importer.loadCfgFile(cfgFile); @@ -59,6 +58,7 @@ int main(int argc, char *argv[]) { } std::cout << "write to: " << outputFile << std::endl; + boost::iostreams::stream file(outputFile); importer.writeToFile(file, cfg); return 0; From 6e19076dc55b20bdd71a9ba4e680dee5018721ed Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Mon, 2 Apr 2012 17:07:18 +0200 Subject: [PATCH 05/28] fallback for ini importer --- apps/mwiniimporter/importer.cpp | 39 ++++++++++++++++++++++++++++----- apps/mwiniimporter/importer.hpp | 4 +++- apps/mwiniimporter/main.cpp | 9 ++++++-- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index 08b05f417..80ec4a5fd 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -14,10 +14,19 @@ MwIniImporter::MwIniImporter() { { "fps", "General:Show FPS" }, { 0, 0 } }; + const char *fallback[][2] = { + { "Weather_Sunrise_Time", "Weather:Sunrise Time" }, + { "Weather_Sunset_Time", "Weather:Sunset Time" }, + { 0, 0 } + }; for(int i=0; map[i][0]; i++) { mMergeMap.insert(std::make_pair(map[i][0], map[i][1])); } + + for(int i=0; fallback[i][0]; i++) { + mMergeFallback.insert(std::make_pair(fallback[i][0], fallback[i][1])); + } } void MwIniImporter::setVerbose(bool verbose) { @@ -116,16 +125,36 @@ void MwIniImporter::merge(multistrmap &cfg, multistrmap &ini) { multistrmap::iterator iniIt; for(strmap::iterator it=mMergeMap.begin(); it!=mMergeMap.end(); it++) { if((iniIt = ini.find(it->second)) != ini.end()) { - cfg.erase(it->first); - if(!this->specialMerge(it->first, it->second, cfg, ini)) { - cfg.insert(std::make_pair >(it->first, iniIt->second)); + for(std::vector::iterator vc = iniIt->second.begin(); vc != iniIt->second.end(); vc++) { + cfg.erase(it->first); + insertMultistrmap(cfg, it->first, *vc); } } } } -bool MwIniImporter::specialMerge(std::string cfgKey, std::string iniKey, multistrmap &cfg, multistrmap &ini) { - return false; +void MwIniImporter::mergeFallback(multistrmap &cfg, multistrmap &ini) { + cfg.erase("fallback"); + + multistrmap::iterator cfgIt; + multistrmap::iterator iniIt; + for(strmap::iterator it=mMergeFallback.begin(); it!=mMergeFallback.end(); it++) { + if((iniIt = ini.find(it->second)) != ini.end()) { + for(std::vector::iterator vc = iniIt->second.begin(); vc != iniIt->second.end(); vc++) { + std::string value("\""); + value.append(it->first).append("=").append(vc->substr(0,vc->length()-1)).append("\""); + insertMultistrmap(cfg, "fallback", value); + } + } + } +}; + +void MwIniImporter::insertMultistrmap(multistrmap &cfg, std::string key, std::string value) { + multistrmap::iterator it = cfg.find(key); + if(it == cfg.end()) { + cfg.insert(std::make_pair >(key, std::vector() )); + } + cfg[key].push_back(value); } void MwIniImporter::importGameFiles(multistrmap &cfg, multistrmap &ini) { diff --git a/apps/mwiniimporter/importer.hpp b/apps/mwiniimporter/importer.hpp index 988f10255..9ef7b6703 100644 --- a/apps/mwiniimporter/importer.hpp +++ b/apps/mwiniimporter/importer.hpp @@ -18,14 +18,16 @@ class MwIniImporter { multistrmap loadIniFile(std::string filename); multistrmap loadCfgFile(std::string filename); void merge(multistrmap &cfg, multistrmap &ini); + void mergeFallback(multistrmap &cfg, multistrmap &ini); void importGameFiles(multistrmap &cfg, multistrmap &ini); void writeToFile(boost::iostreams::stream &out, multistrmap &cfg); private: - bool specialMerge(std::string cfgKey, std::string iniKey, multistrmap &cfg, multistrmap &ini); + void insertMultistrmap(multistrmap &cfg, std::string key, std::string value); std::string numberToString(int n); bool mVerbose; strmap mMergeMap; + strmap mMergeFallback; }; diff --git a/apps/mwiniimporter/main.cpp b/apps/mwiniimporter/main.cpp index 836f84eb0..c5409b812 100644 --- a/apps/mwiniimporter/main.cpp +++ b/apps/mwiniimporter/main.cpp @@ -16,6 +16,7 @@ int main(int argc, char *argv[]) { ("ini,i", bpo::value(), "morrowind.ini file") ("cfg,c", bpo::value(), "openmw.cfg file") ("output,o", bpo::value()->default_value(""), "openmw.cfg file") + ("fallback,f", "import fallback settings") ("game-files,g", "import esm and esp files") ; @@ -44,7 +45,7 @@ int main(int argc, char *argv[]) { std::cerr << "cfg file does not exist" << std::endl; return -4; } - + MwIniImporter importer; importer.setVerbose(vm.count("verbose")); @@ -52,7 +53,11 @@ int main(int argc, char *argv[]) { MwIniImporter::multistrmap cfg = importer.loadCfgFile(cfgFile); importer.merge(cfg, ini); - + + if(vm.count("fallback")) { + importer.mergeFallback(cfg, ini); + } + if(vm.count("game-files")) { importer.importGameFiles(cfg, ini); } From ab9c4306328446807bde837a0befbe45ed3c1381 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Mon, 2 Apr 2012 20:47:09 +0200 Subject: [PATCH 06/28] fallback in apps/openmw; fix for apps/mwiniimporter --- apps/mwiniimporter/importer.cpp | 4 ++-- apps/mwiniimporter/main.cpp | 2 ++ apps/openmw/engine.cpp | 7 ++++++- apps/openmw/engine.hpp | 3 +++ apps/openmw/main.cpp | 25 ++++++++++++++---------- apps/openmw/mwworld/world.cpp | 34 ++++++++++++++++++++++++++++++++- apps/openmw/mwworld/world.hpp | 7 ++++++- 7 files changed, 67 insertions(+), 15 deletions(-) diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index 80ec4a5fd..e8fafab44 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -141,8 +141,8 @@ void MwIniImporter::mergeFallback(multistrmap &cfg, multistrmap &ini) { for(strmap::iterator it=mMergeFallback.begin(); it!=mMergeFallback.end(); it++) { if((iniIt = ini.find(it->second)) != ini.end()) { for(std::vector::iterator vc = iniIt->second.begin(); vc != iniIt->second.end(); vc++) { - std::string value("\""); - value.append(it->first).append("=").append(vc->substr(0,vc->length()-1)).append("\""); + std::string value(it->first); + value.append("=").append(vc->substr(0,vc->length()-1)); insertMultistrmap(cfg, "fallback", value); } } diff --git a/apps/mwiniimporter/main.cpp b/apps/mwiniimporter/main.cpp index c5409b812..dc9bbcd0a 100644 --- a/apps/mwiniimporter/main.cpp +++ b/apps/mwiniimporter/main.cpp @@ -28,6 +28,8 @@ int main(int argc, char *argv[]) { return 0; } + bpo::notify(vm); + std::string iniFile = vm["ini"].as(); std::string cfgFile = vm["cfg"].as(); diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 2dab53ecc..c6684593e 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -341,7 +341,7 @@ void OMW::Engine::go() // Create the world mEnvironment.mWorld = new MWWorld::World (*mOgre, mFileCollections, mMaster, - mResDir, mNewGame, mEnvironment, mEncoding); + mResDir, mNewGame, mEnvironment, mEncoding, mFallbackPairs); // Create window manager - this manages all the MW-specific GUI windows MWScript::registerExtensions (mExtensions); @@ -508,3 +508,8 @@ void OMW::Engine::setEncoding(const std::string& encoding) { mEncoding = encoding; } + +void OMW::Engine::setFallbackValues(std::vector pairs) +{ + mFallbackPairs = pairs; +} diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 690430784..f1df98f4c 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -76,6 +76,7 @@ namespace OMW bool mReportFocus; float mFocusTDiff; std::string mFocusName; + std::vector mFallbackPairs; MWWorld::Environment mEnvironment; Compiler::Extensions mExtensions; @@ -163,6 +164,8 @@ namespace OMW void setAnimationVerbose(bool animverbose); + void setFallbackValues(std::vector pairs); + private: Files::ConfigurationManager& mCfgMgr; }; diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index cd1e0e26e..0dc534377 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -92,39 +92,43 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("plugin", bpo::value()->default_value(StringsVector(), "") ->multitoken(), "plugin file(s)") - ("fps", boost::program_options::value()->implicit_value(1) + ("fps", bpo::value()->implicit_value(1) ->default_value(0), "fps counter detail (0 = off, 1 = fps counter, 2 = full detail)") - ("anim-verbose", boost::program_options::value()->implicit_value(true) + ("anim-verbose", bpo::value()->implicit_value(true) ->default_value(false), "output animation indices files") - ("debug", boost::program_options::value()->implicit_value(true) + ("debug", bpo::value()->implicit_value(true) ->default_value(false), "debug mode") - ("nosound", boost::program_options::value()->implicit_value(true) + ("nosound", bpo::value()->implicit_value(true) ->default_value(false), "disable all sounds") - ("script-verbose", boost::program_options::value()->implicit_value(true) + ("script-verbose", bpo::value()->implicit_value(true) ->default_value(false), "verbose script output") - ("new-game", boost::program_options::value()->implicit_value(true) + ("new-game", bpo::value()->implicit_value(true) ->default_value(false), "activate char gen/new game mechanics") - ("script-all", boost::program_options::value()->implicit_value(true) + ("script-all", bpo::value()->implicit_value(true) ->default_value(false), "compile all scripts (excluding dialogue scripts) at startup") - ("fs-strict", boost::program_options::value()->implicit_value(true) + ("fs-strict", bpo::value()->implicit_value(true) ->default_value(false), "strict file system handling (no case folding)") - ( "encoding", boost::program_options::value()-> + ( "encoding", bpo::value()-> default_value("win1252"), "Character encoding used in OpenMW game messages:\n" "\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n" "\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n" "\n\twin1252 - Western European (Latin) alphabet, used by default") - ("report-focus", boost::program_options::value()->implicit_value(true) + ("report-focus", bpo::value()->implicit_value(true) ->default_value(false), "write name of focussed object to cout") + + ("fallback", bpo::value()->default_value(StringsVector(), "") + ->multitoken()->composing(), "fallback values") + ; bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv) @@ -232,6 +236,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setCompileAll(variables["script-all"].as()); engine.setReportFocus(variables["report-focus"].as()); engine.setAnimationVerbose(variables["anim-verbose"].as()); + engine.setFallbackValues(variables["fallback"].as >()); return true; } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 3a15f42ba..093c3fef0 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -152,10 +152,40 @@ namespace MWWorld mRendering->skyDisable(); } + void World::setFallbackValues(std::vector pairs) + { + for(std::vector::iterator it = pairs.begin(); it != pairs.end(); it++) + { + std::string kv = *it; + int seperator = kv.find("="); + if(seperator < 1 || seperator == (kv.length()-1)) + { + continue; + } + + std::string key = it->substr(0,seperator); + std::string value = it->substr(seperator+1); + if(mFallback.find(key) == mFallback.end()) { + std::cout << "insert " << key << ":" << value << std::endl; + mFallback.insert(std::make_pair(key,value)); + } + } + } + + std::string World::getFallback(std::string key) + { + std::map::iterator it; + if((it = mFallback.find(key)) == mFallback.end()) + { + return std::string(""); + } + return it->second; + } + World::World (OEngine::Render::OgreRenderer& renderer, const Files::Collections& fileCollections, const std::string& master, const boost::filesystem::path& resDir, - bool newGame, Environment& environment, const std::string& encoding) + bool newGame, Environment& environment, const std::string& encoding, std::vector fallbackPairs) : mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), mSky (true), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm, *this), mNumFacing(0) @@ -190,6 +220,8 @@ namespace MWWorld } mWorldScene = new Scene(environment, this, *mRendering, mPhysics); + + setFallbackValues(fallbackPairs); } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 0d46fe4e8..d6b422141 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -100,6 +100,7 @@ namespace MWWorld std::string mFaced1Name; std::string mFaced2Name; int mNumFacing; + std::map mFallback; int getDaysPerMonth (int month) const; @@ -110,7 +111,7 @@ namespace MWWorld World (OEngine::Render::OgreRenderer& renderer, const Files::Collections& fileCollections, const std::string& master, const boost::filesystem::path& resDir, bool newGame, - Environment& environment, const std::string& encoding); + Environment& environment, const std::string& encoding, std::vector fallbackPairs); ~World(); @@ -125,6 +126,10 @@ namespace MWWorld void adjustSky(); + void setFallbackValues(std::vector pairs); + + std::string getFallback(std::string key); + MWWorld::Player& getPlayer(); const ESMS::ESMStore& getStore() const; From 0e5c90d3e783cd471197637ae281494de4dd0b08 Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Mon, 2 Apr 2012 23:50:53 +0200 Subject: [PATCH 07/28] Issue #225: Correction to commit ae98904. Changed pointer to LandData struct to simple member variable. --- apps/openmw/mwrender/terrain.cpp | 25 +++++++------------- components/esm/loadland.cpp | 40 +++++++++----------------------- components/esm/loadland.hpp | 8 +------ 3 files changed, 20 insertions(+), 53 deletions(-) diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index 0b8f933a2..f1920490d 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -98,10 +98,7 @@ namespace MWRender ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY); if ( land != NULL ) { - if (!land->dataLoaded) - { - land->loadData(); - } + land->loadData(); } //split the cell terrain into four segments @@ -136,7 +133,7 @@ namespace MWRender const size_t xOffset = x * (mLandSize-1); memcpy(&terrainData.inputFloat[terrainCopyY*mLandSize], - &land->landData->heights[yOffset + xOffset], + &land->landData.heights[yOffset + xOffset], mLandSize*sizeof(float)); } } @@ -163,7 +160,7 @@ namespace MWRender numTextures, indexes); - if ( land && land->landData->usingColours ) + if ( land && land->landData.usingColours ) { // disable or enable global colour map (depends on available vertex colours) mActiveProfile->setGlobalColourMapEnabled(true); @@ -423,18 +420,12 @@ namespace MWRender ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY); if ( land != NULL ) { - if (!land->dataLoaded) - { - land->loadData(); - } + land->loadData(); - return land->landData - ->textures[y * ESM::Land::LAND_TEXTURE_SIZE + x]; - } - else - { - return 0; + return land->landData.textures[y * ESM::Land::LAND_TEXTURE_SIZE + x]; } + + return 0; } //---------------------------------------------------------------------------------------------- @@ -473,7 +464,7 @@ namespace MWRender if ( land != NULL ) { - const char* const colours = land->landData->colours; + const char* const colours = land->landData.colours; for ( int y = 0; y < size; y++ ) { for ( int x = 0; x < size; x++ ) diff --git a/components/esm/loadland.cpp b/components/esm/loadland.cpp index 96afdf831..c6dc3c6f2 100644 --- a/components/esm/loadland.cpp +++ b/components/esm/loadland.cpp @@ -10,16 +10,10 @@ Land::Land() , mEsm(NULL) , hasData(false) , dataLoaded(false) - , landData(NULL) { + memset(&landData, 0, sizeof(landData)); } -Land::~Land() -{ - delete landData; -} - - void Land::load(ESMReader &esm) { mEsm = &esm; @@ -68,7 +62,6 @@ void Land::load(ESMReader &esm) hasData = (cnt == 3); dataLoaded = false; - landData = NULL; } void Land::loadData() @@ -78,8 +71,6 @@ void Land::loadData() return; } - landData = new LandData; - if (hasData) { mEsm->restoreContext(context); @@ -91,19 +82,20 @@ void Land::loadData() } VHGT rawHeights; + memset(&rawHeights, 0, sizeof(rawHeights)); mEsm->getHNExact(&rawHeights, sizeof(VHGT), "VHGT"); int currentHeightOffset = rawHeights.heightOffset; for (int y = 0; y < LAND_SIZE; y++) { currentHeightOffset += rawHeights.heightData[y * LAND_SIZE]; - landData->heights[y * LAND_SIZE] = currentHeightOffset * HEIGHT_SCALE; + landData.heights[y * LAND_SIZE] = currentHeightOffset * HEIGHT_SCALE; int tempOffset = currentHeightOffset; for (int x = 1; x < LAND_SIZE; x++) { tempOffset += rawHeights.heightData[y * LAND_SIZE + x]; - landData->heights[x + y * LAND_SIZE] = tempOffset * HEIGHT_SCALE; + landData.heights[x + y * LAND_SIZE] = tempOffset * HEIGHT_SCALE; } } @@ -113,10 +105,10 @@ void Land::loadData() } if (mEsm->isNextSub("VCLR")) { - landData->usingColours = true; - mEsm->getHExact(&landData->colours, 3*LAND_NUM_VERTS); + landData.usingColours = true; + mEsm->getHExact(&landData.colours, 3*LAND_NUM_VERTS); }else{ - landData->usingColours = false; + landData.usingColours = false; } //TODO fix magic numbers uint16_t vtex[512]; @@ -127,29 +119,19 @@ void Land::loadData() for ( int x1 = 0; x1 < 4; x1++ ) for ( int y2 = 0; y2 < 4; y2++) for ( int x2 = 0; x2 < 4; x2++ ) - landData->textures[(y1*4+y2)*16+(x1*4+x2)] = vtex[readPos++]; + landData.textures[(y1*4+y2)*16+(x1*4+x2)] = vtex[readPos++]; } else { - landData->usingColours = false; - memset(&landData->textures, 0, 512 * sizeof(uint16_t)); + landData.usingColours = false; + memset(landData.textures, 0, sizeof(landData.textures)); for (int i = 0; i < LAND_NUM_VERTS; i++) { - landData->heights[i] = -256.0f * HEIGHT_SCALE; + landData.heights[i] = -256.0f * HEIGHT_SCALE; } } dataLoaded = true; } -void Land::unloadData() -{ - if (dataLoaded) - { - delete landData; - landData = NULL; - dataLoaded = false; - } -} - } diff --git a/components/esm/loadland.hpp b/components/esm/loadland.hpp index 64baecd34..86f37d575 100644 --- a/components/esm/loadland.hpp +++ b/components/esm/loadland.hpp @@ -12,7 +12,6 @@ namespace ESM struct Land { Land(); - ~Land(); int flags; // Only first four bits seem to be used, don't know what // they mean. @@ -67,7 +66,7 @@ struct Land char colours[3 * LAND_NUM_VERTS]; }; - LandData *landData; + LandData landData; void load(ESMReader &esm); @@ -75,11 +74,6 @@ struct Land * Actually loads data */ void loadData(); - - /** - * Frees memory allocated for land data - */ - void unloadData(); }; } #endif From 2d23d79fd5d7dc954c1228a5a8197ad46692a311 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 3 Apr 2012 00:44:26 +0200 Subject: [PATCH 08/28] allways merge fallback; better syntax --- apps/mwiniimporter/importer.cpp | 20 ++++++++++---------- apps/mwiniimporter/importer.hpp | 2 +- apps/mwiniimporter/main.cpp | 6 +----- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index e8fafab44..60f2c620d 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -14,18 +14,16 @@ MwIniImporter::MwIniImporter() { { "fps", "General:Show FPS" }, { 0, 0 } }; - const char *fallback[][2] = { - { "Weather_Sunrise_Time", "Weather:Sunrise Time" }, - { "Weather_Sunset_Time", "Weather:Sunset Time" }, - { 0, 0 } + const char *fallback[] = { + "Weather:Sunrise Time", "Weather_Sunset_Time", 0 }; for(int i=0; map[i][0]; i++) { mMergeMap.insert(std::make_pair(map[i][0], map[i][1])); } - for(int i=0; fallback[i][0]; i++) { - mMergeFallback.insert(std::make_pair(fallback[i][0], fallback[i][1])); + for(int i=0; fallback[i]; i++) { + mMergeFallback.push_back(fallback[i]); } } @@ -138,11 +136,13 @@ void MwIniImporter::mergeFallback(multistrmap &cfg, multistrmap &ini) { multistrmap::iterator cfgIt; multistrmap::iterator iniIt; - for(strmap::iterator it=mMergeFallback.begin(); it!=mMergeFallback.end(); it++) { - if((iniIt = ini.find(it->second)) != ini.end()) { + for(std::vector::iterator it=mMergeFallback.begin(); it!=mMergeFallback.end(); it++) { + if((iniIt = ini.find(*it)) != ini.end()) { for(std::vector::iterator vc = iniIt->second.begin(); vc != iniIt->second.end(); vc++) { - std::string value(it->first); - value.append("=").append(vc->substr(0,vc->length()-1)); + std::string value(*it); + std::replace( value.begin(), value.end(), ' ', '_' ); + std::replace( value.begin(), value.end(), ':', '_' ); + value.append(",").append(vc->substr(0,vc->length()-1)); insertMultistrmap(cfg, "fallback", value); } } diff --git a/apps/mwiniimporter/importer.hpp b/apps/mwiniimporter/importer.hpp index 9ef7b6703..ced332a72 100644 --- a/apps/mwiniimporter/importer.hpp +++ b/apps/mwiniimporter/importer.hpp @@ -27,7 +27,7 @@ class MwIniImporter { std::string numberToString(int n); bool mVerbose; strmap mMergeMap; - strmap mMergeFallback; + std::vector mMergeFallback; }; diff --git a/apps/mwiniimporter/main.cpp b/apps/mwiniimporter/main.cpp index dc9bbcd0a..051e7db2b 100644 --- a/apps/mwiniimporter/main.cpp +++ b/apps/mwiniimporter/main.cpp @@ -16,7 +16,6 @@ int main(int argc, char *argv[]) { ("ini,i", bpo::value(), "morrowind.ini file") ("cfg,c", bpo::value(), "openmw.cfg file") ("output,o", bpo::value()->default_value(""), "openmw.cfg file") - ("fallback,f", "import fallback settings") ("game-files,g", "import esm and esp files") ; @@ -55,10 +54,7 @@ int main(int argc, char *argv[]) { MwIniImporter::multistrmap cfg = importer.loadCfgFile(cfgFile); importer.merge(cfg, ini); - - if(vm.count("fallback")) { - importer.mergeFallback(cfg, ini); - } + importer.mergeFallback(cfg, ini); if(vm.count("game-files")) { importer.importGameFiles(cfg, ini); From d87dffa948af48002863efd1a92837ba88574068 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 3 Apr 2012 01:47:43 +0200 Subject: [PATCH 09/28] should work... but does not even compile --- apps/openmw/main.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 0dc534377..e1ddb03e7 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -54,6 +54,35 @@ inline boost::filesystem::path lexical_cast mMap; + + static void + validate(boost::any &v, std::vector const &tokens) + { + if(v.empty()) + { + v = boost::any(FallbackMap()); + } + + FallbackMap *map = boost::any_cast(&v); + + std::map::iterator mapIt; + for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); it++) + { + int sep = it->find(","); + std::string key(it->substr(0,sep-1)); + std::string value(it->substr(sep)); + + if((mapIt = map->mMap.find(key)) == map->mMap.end()) + { + map->mMap.insert(std::make_pair(key,value)); + } + } + } +}; + + /** * \brief Parses application command line and calls \ref Cfg::ConfigurationManager * to parse configuration files. @@ -126,7 +155,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("report-focus", bpo::value()->implicit_value(true) ->default_value(false), "write name of focussed object to cout") - ("fallback", bpo::value()->default_value(StringsVector(), "") + ("fallback", bpo::value() ->multitoken()->composing(), "fallback values") ; @@ -236,7 +265,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setCompileAll(variables["script-all"].as()); engine.setReportFocus(variables["report-focus"].as()); engine.setAnimationVerbose(variables["anim-verbose"].as()); - engine.setFallbackValues(variables["fallback"].as >()); + //engine.setFallbackValues(variables["fallback"].as >()); return true; } From 73705dadf6036323bbbe79e2da0dbe7c52f7991d Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 3 Apr 2012 02:14:39 +0200 Subject: [PATCH 10/28] parse fallback with boost program option custom validators --- apps/openmw/engine.cpp | 6 ++-- apps/openmw/engine.hpp | 4 +-- apps/openmw/main.cpp | 52 ++++++++++++++++++----------------- apps/openmw/mwworld/world.cpp | 24 ++++------------ apps/openmw/mwworld/world.hpp | 4 +-- 5 files changed, 39 insertions(+), 51 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index c6684593e..dae5aaff1 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -341,7 +341,7 @@ void OMW::Engine::go() // Create the world mEnvironment.mWorld = new MWWorld::World (*mOgre, mFileCollections, mMaster, - mResDir, mNewGame, mEnvironment, mEncoding, mFallbackPairs); + mResDir, mNewGame, mEnvironment, mEncoding, mFallbackMap); // Create window manager - this manages all the MW-specific GUI windows MWScript::registerExtensions (mExtensions); @@ -509,7 +509,7 @@ void OMW::Engine::setEncoding(const std::string& encoding) mEncoding = encoding; } -void OMW::Engine::setFallbackValues(std::vector pairs) +void OMW::Engine::setFallbackValues(std::map fallbackMap) { - mFallbackPairs = pairs; + mFallbackMap = fallbackMap; } diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index f1df98f4c..6eae20cc0 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -76,7 +76,7 @@ namespace OMW bool mReportFocus; float mFocusTDiff; std::string mFocusName; - std::vector mFallbackPairs; + std::map mFallbackMap; MWWorld::Environment mEnvironment; Compiler::Extensions mExtensions; @@ -164,7 +164,7 @@ namespace OMW void setAnimationVerbose(bool animverbose); - void setFallbackValues(std::vector pairs); + void setFallbackValues(std::map map); private: Files::ConfigurationManager& mCfgMgr; diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index e1ddb03e7..b541ea0d3 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -56,32 +56,34 @@ using namespace std; struct FallbackMap { std::map mMap; - - static void - validate(boost::any &v, std::vector const &tokens) - { - if(v.empty()) - { - v = boost::any(FallbackMap()); - } - - FallbackMap *map = boost::any_cast(&v); - - std::map::iterator mapIt; - for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); it++) - { - int sep = it->find(","); - std::string key(it->substr(0,sep-1)); - std::string value(it->substr(sep)); - - if((mapIt = map->mMap.find(key)) == map->mMap.end()) - { - map->mMap.insert(std::make_pair(key,value)); - } - } - } }; +void validate(boost::any &v, std::vector const &tokens, FallbackMap*, int) +{ + if(v.empty()) + { + v = boost::any(FallbackMap()); + } + + FallbackMap *map = boost::any_cast(&v); + + std::map::iterator mapIt; + for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); it++) + { + int sep = it->find(","); + if(sep < 1) + continue; + + std::string key(it->substr(0,sep)); + std::string value(it->substr(sep+1)); + + if((mapIt = map->mMap.find(key)) == map->mMap.end()) + { + map->mMap.insert(std::make_pair(key,value)); + } + } +} + /** * \brief Parses application command line and calls \ref Cfg::ConfigurationManager @@ -265,7 +267,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setCompileAll(variables["script-all"].as()); engine.setReportFocus(variables["report-focus"].as()); engine.setAnimationVerbose(variables["anim-verbose"].as()); - //engine.setFallbackValues(variables["fallback"].as >()); + engine.setFallbackValues(variables["fallback"].as().mMap); return true; } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 093c3fef0..596adcf6b 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -152,24 +152,9 @@ namespace MWWorld mRendering->skyDisable(); } - void World::setFallbackValues(std::vector pairs) + void World::setFallbackValues(std::map fallbackMap) { - for(std::vector::iterator it = pairs.begin(); it != pairs.end(); it++) - { - std::string kv = *it; - int seperator = kv.find("="); - if(seperator < 1 || seperator == (kv.length()-1)) - { - continue; - } - - std::string key = it->substr(0,seperator); - std::string value = it->substr(seperator+1); - if(mFallback.find(key) == mFallback.end()) { - std::cout << "insert " << key << ":" << value << std::endl; - mFallback.insert(std::make_pair(key,value)); - } - } + mFallback = fallbackMap; } std::string World::getFallback(std::string key) @@ -185,7 +170,7 @@ namespace MWWorld World::World (OEngine::Render::OgreRenderer& renderer, const Files::Collections& fileCollections, const std::string& master, const boost::filesystem::path& resDir, - bool newGame, Environment& environment, const std::string& encoding, std::vector fallbackPairs) + bool newGame, Environment& environment, const std::string& encoding, std::map fallbackMap) : mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), mSky (true), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm, *this), mNumFacing(0) @@ -221,7 +206,8 @@ namespace MWWorld mWorldScene = new Scene(environment, this, *mRendering, mPhysics); - setFallbackValues(fallbackPairs); + setFallbackValues(fallbackMap); + std::cout << "Weather_Sunrise_Time=" << getFallback("Weather_Sunrise_Time") << std::endl; } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index d6b422141..7f18762f5 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -111,7 +111,7 @@ namespace MWWorld World (OEngine::Render::OgreRenderer& renderer, const Files::Collections& fileCollections, const std::string& master, const boost::filesystem::path& resDir, bool newGame, - Environment& environment, const std::string& encoding, std::vector fallbackPairs); + Environment& environment, const std::string& encoding, std::map fallbackMap); ~World(); @@ -126,7 +126,7 @@ namespace MWWorld void adjustSky(); - void setFallbackValues(std::vector pairs); + void setFallbackValues(std::map fallbackMap); std::string getFallback(std::string key); From 329d59e52bc7256bb30fa24bd8a0ab01e36d189c Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 3 Apr 2012 02:17:15 +0200 Subject: [PATCH 11/28] typo --- apps/mwiniimporter/importer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index 60f2c620d..f1cec0479 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -15,7 +15,9 @@ MwIniImporter::MwIniImporter() { { 0, 0 } }; const char *fallback[] = { - "Weather:Sunrise Time", "Weather_Sunset_Time", 0 + "Weather:Sunrise Time", + "Weather:Sunset Time", + 0 }; for(int i=0; map[i][0]; i++) { From 329ba24eab7ee016bd103367c061f87f04f6d282 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 4 Apr 2012 15:11:30 +0200 Subject: [PATCH 12/28] streamlined command line options --- apps/mwiniimporter/main.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/mwiniimporter/main.cpp b/apps/mwiniimporter/main.cpp index 051e7db2b..234d7d57d 100644 --- a/apps/mwiniimporter/main.cpp +++ b/apps/mwiniimporter/main.cpp @@ -9,7 +9,8 @@ namespace bpo = boost::program_options; int main(int argc, char *argv[]) { - bpo::options_description desc("Syntax: mwiniimporter -i inifile -c configfile \nAllowed options"); + bpo::options_description desc("Syntax: mwiniimporter inifile configfile\nAllowed options"); + bpo::positional_options_description p_desc; desc.add_options() ("help,h", "produce help message") ("verbose,v", "verbose output") @@ -18,9 +19,15 @@ int main(int argc, char *argv[]) { ("output,o", bpo::value()->default_value(""), "openmw.cfg file") ("game-files,g", "import esm and esp files") ; + p_desc.add("ini", 1).add("cfg", 1); bpo::variables_map vm; - bpo::store(boost::program_options::parse_command_line(argc, argv, desc), vm); + bpo::parsed_options parsed = bpo::command_line_parser(argc, argv) + .options(desc) + .positional(p_desc) + .run(); + + bpo::store(parsed, vm); if(vm.count("help") || !vm.count("ini") || !vm.count("cfg")) { std::cout << desc; From de510d445b328f5315a3aff4ac00d610bb23fa8e Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 4 Apr 2012 15:23:14 +0200 Subject: [PATCH 13/28] throw an error if the --fallback syntax is wrong --- apps/openmw/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index b541ea0d3..cdc4af4b0 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -71,8 +71,8 @@ void validate(boost::any &v, std::vector const &tokens, FallbackMap for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); it++) { int sep = it->find(","); - if(sep < 1) - continue; + if(sep < 1 || sep = it->length()-1) + throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value); std::string key(it->substr(0,sep)); std::string value(it->substr(sep+1)); From 16e7bf353a50a0188cf1790417751d89ea24d83e Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 4 Apr 2012 16:08:46 +0200 Subject: [PATCH 14/28] remove debug message --- apps/openmw/mwworld/world.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 596adcf6b..7f4169b9d 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -205,9 +205,8 @@ namespace MWWorld } mWorldScene = new Scene(environment, this, *mRendering, mPhysics); - + setFallbackValues(fallbackMap); - std::cout << "Weather_Sunrise_Time=" << getFallback("Weather_Sunrise_Time") << std::endl; } From 48b7b03453197ff5069aee6b9714838bc95085be Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 4 Apr 2012 16:15:15 +0200 Subject: [PATCH 15/28] typo; World::getFallback(std::string key, std::string def) --- apps/openmw/main.cpp | 2 +- apps/openmw/mwworld/world.cpp | 7 ++++++- apps/openmw/mwworld/world.hpp | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index cdc4af4b0..06b068621 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -71,7 +71,7 @@ void validate(boost::any &v, std::vector const &tokens, FallbackMap for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); it++) { int sep = it->find(","); - if(sep < 1 || sep = it->length()-1) + if(sep < 1 || sep == (it->length()-1)) throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value); std::string key(it->substr(0,sep)); diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 7f4169b9d..431a7a18c 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -158,11 +158,16 @@ namespace MWWorld } std::string World::getFallback(std::string key) + { + return getFallback(key, ""); + } + + std::string World::getFallback(std::string key, std::string def) { std::map::iterator it; if((it = mFallback.find(key)) == mFallback.end()) { - return std::string(""); + return def; } return it->second; } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 7f18762f5..799b0d094 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -130,6 +130,8 @@ namespace MWWorld std::string getFallback(std::string key); + std::string getFallback(std::string key, std::string def); + MWWorld::Player& getPlayer(); const ESMS::ESMStore& getStore() const; From 94a220dcdd9d222b1799c6731898da768c496fac Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 4 Apr 2012 19:52:07 +0200 Subject: [PATCH 16/28] set a default value for --fallback --- apps/openmw/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 06b068621..2e56d528b 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -267,7 +267,11 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setCompileAll(variables["script-all"].as()); engine.setReportFocus(variables["report-focus"].as()); engine.setAnimationVerbose(variables["anim-verbose"].as()); - engine.setFallbackValues(variables["fallback"].as().mMap); + + if(variables.count("fallback")) + { + engine.setFallbackValues(variables["fallback"].as().mMap); + } return true; } From a974d88cf1fab6f5d5d18b7762f943ea6c101fb6 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 4 Apr 2012 19:58:04 +0200 Subject: [PATCH 17/28] Revert "set a default value for --fallback" This reverts commit 94a220dcdd9d222b1799c6731898da768c496fac. --- apps/openmw/main.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 2e56d528b..06b068621 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -267,11 +267,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setCompileAll(variables["script-all"].as()); engine.setReportFocus(variables["report-focus"].as()); engine.setAnimationVerbose(variables["anim-verbose"].as()); - - if(variables.count("fallback")) - { - engine.setFallbackValues(variables["fallback"].as().mMap); - } + engine.setFallbackValues(variables["fallback"].as().mMap); return true; } From d3a6484bbc052706949fd176a01ada7c549d9853 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 4 Apr 2012 19:59:46 +0200 Subject: [PATCH 18/28] set the default value for --fallback the right way --- apps/openmw/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 06b068621..545014206 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -157,7 +157,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("report-focus", bpo::value()->implicit_value(true) ->default_value(false), "write name of focussed object to cout") - ("fallback", bpo::value() + ("fallback", bpo::value()->default_value(FallbackMap(), "") ->multitoken()->composing(), "fallback values") ; From 6ccb32d26c55808b55f2c637b250e977144a3d07 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 4 Apr 2012 20:06:31 +0200 Subject: [PATCH 19/28] import nosound option --- apps/mwiniimporter/importer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index f1cec0479..5503a7c1a 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -12,6 +12,7 @@ MwIniImporter::MwIniImporter() { const char *map[][2] = { { "fps", "General:Show FPS" }, + { "nosound", "General:Disable Audio" }, { 0, 0 } }; const char *fallback[] = { From 5dd65c11ee85f43cca92caea85fa22fb8b82c07b Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 4 Apr 2012 21:04:52 +0200 Subject: [PATCH 20/28] forgot to save the file --- apps/openmw/main.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 0a2d35699..bc6159e2a 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -123,14 +123,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("plugin", bpo::value()->default_value(StringsVector(), "") ->multitoken(), "plugin file(s)") -<<<<<<< HEAD - ("fps", bpo::value()->implicit_value(1) - ->default_value(0), "fps counter detail (0 = off, 1 = fps counter, 2 = full detail)") - ("anim-verbose", bpo::value()->implicit_value(true) -======= - ("anim-verbose", boost::program_options::value()->implicit_value(true) ->>>>>>> e403c7158acfb118bed01a08a46431b24cff8747 ->default_value(false), "output animation indices files") ("debug", bpo::value()->implicit_value(true) From cd2789b15abdcf65c934a64327ef53a43bc1f4b9 Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Wed, 4 Apr 2012 21:05:19 +0200 Subject: [PATCH 21/28] Revert "Issue #225: Correction to commit ae98904." This reverts commit 0e5c90d3e783cd471197637ae281494de4dd0b08. --- apps/openmw/mwrender/terrain.cpp | 25 +++++++++++++------- components/esm/loadland.cpp | 40 +++++++++++++++++++++++--------- components/esm/loadland.hpp | 8 ++++++- 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index f1920490d..0b8f933a2 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -98,7 +98,10 @@ namespace MWRender ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY); if ( land != NULL ) { - land->loadData(); + if (!land->dataLoaded) + { + land->loadData(); + } } //split the cell terrain into four segments @@ -133,7 +136,7 @@ namespace MWRender const size_t xOffset = x * (mLandSize-1); memcpy(&terrainData.inputFloat[terrainCopyY*mLandSize], - &land->landData.heights[yOffset + xOffset], + &land->landData->heights[yOffset + xOffset], mLandSize*sizeof(float)); } } @@ -160,7 +163,7 @@ namespace MWRender numTextures, indexes); - if ( land && land->landData.usingColours ) + if ( land && land->landData->usingColours ) { // disable or enable global colour map (depends on available vertex colours) mActiveProfile->setGlobalColourMapEnabled(true); @@ -420,12 +423,18 @@ namespace MWRender ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY); if ( land != NULL ) { - land->loadData(); + if (!land->dataLoaded) + { + land->loadData(); + } - return land->landData.textures[y * ESM::Land::LAND_TEXTURE_SIZE + x]; + return land->landData + ->textures[y * ESM::Land::LAND_TEXTURE_SIZE + x]; + } + else + { + return 0; } - - return 0; } //---------------------------------------------------------------------------------------------- @@ -464,7 +473,7 @@ namespace MWRender if ( land != NULL ) { - const char* const colours = land->landData.colours; + const char* const colours = land->landData->colours; for ( int y = 0; y < size; y++ ) { for ( int x = 0; x < size; x++ ) diff --git a/components/esm/loadland.cpp b/components/esm/loadland.cpp index c6dc3c6f2..96afdf831 100644 --- a/components/esm/loadland.cpp +++ b/components/esm/loadland.cpp @@ -10,10 +10,16 @@ Land::Land() , mEsm(NULL) , hasData(false) , dataLoaded(false) + , landData(NULL) { - memset(&landData, 0, sizeof(landData)); } +Land::~Land() +{ + delete landData; +} + + void Land::load(ESMReader &esm) { mEsm = &esm; @@ -62,6 +68,7 @@ void Land::load(ESMReader &esm) hasData = (cnt == 3); dataLoaded = false; + landData = NULL; } void Land::loadData() @@ -71,6 +78,8 @@ void Land::loadData() return; } + landData = new LandData; + if (hasData) { mEsm->restoreContext(context); @@ -82,20 +91,19 @@ void Land::loadData() } VHGT rawHeights; - memset(&rawHeights, 0, sizeof(rawHeights)); mEsm->getHNExact(&rawHeights, sizeof(VHGT), "VHGT"); int currentHeightOffset = rawHeights.heightOffset; for (int y = 0; y < LAND_SIZE; y++) { currentHeightOffset += rawHeights.heightData[y * LAND_SIZE]; - landData.heights[y * LAND_SIZE] = currentHeightOffset * HEIGHT_SCALE; + landData->heights[y * LAND_SIZE] = currentHeightOffset * HEIGHT_SCALE; int tempOffset = currentHeightOffset; for (int x = 1; x < LAND_SIZE; x++) { tempOffset += rawHeights.heightData[y * LAND_SIZE + x]; - landData.heights[x + y * LAND_SIZE] = tempOffset * HEIGHT_SCALE; + landData->heights[x + y * LAND_SIZE] = tempOffset * HEIGHT_SCALE; } } @@ -105,10 +113,10 @@ void Land::loadData() } if (mEsm->isNextSub("VCLR")) { - landData.usingColours = true; - mEsm->getHExact(&landData.colours, 3*LAND_NUM_VERTS); + landData->usingColours = true; + mEsm->getHExact(&landData->colours, 3*LAND_NUM_VERTS); }else{ - landData.usingColours = false; + landData->usingColours = false; } //TODO fix magic numbers uint16_t vtex[512]; @@ -119,19 +127,29 @@ void Land::loadData() for ( int x1 = 0; x1 < 4; x1++ ) for ( int y2 = 0; y2 < 4; y2++) for ( int x2 = 0; x2 < 4; x2++ ) - landData.textures[(y1*4+y2)*16+(x1*4+x2)] = vtex[readPos++]; + landData->textures[(y1*4+y2)*16+(x1*4+x2)] = vtex[readPos++]; } else { - landData.usingColours = false; - memset(landData.textures, 0, sizeof(landData.textures)); + landData->usingColours = false; + memset(&landData->textures, 0, 512 * sizeof(uint16_t)); for (int i = 0; i < LAND_NUM_VERTS; i++) { - landData.heights[i] = -256.0f * HEIGHT_SCALE; + landData->heights[i] = -256.0f * HEIGHT_SCALE; } } dataLoaded = true; } +void Land::unloadData() +{ + if (dataLoaded) + { + delete landData; + landData = NULL; + dataLoaded = false; + } +} + } diff --git a/components/esm/loadland.hpp b/components/esm/loadland.hpp index 86f37d575..64baecd34 100644 --- a/components/esm/loadland.hpp +++ b/components/esm/loadland.hpp @@ -12,6 +12,7 @@ namespace ESM struct Land { Land(); + ~Land(); int flags; // Only first four bits seem to be used, don't know what // they mean. @@ -66,7 +67,7 @@ struct Land char colours[3 * LAND_NUM_VERTS]; }; - LandData landData; + LandData *landData; void load(ESMReader &esm); @@ -74,6 +75,11 @@ struct Land * Actually loads data */ void loadData(); + + /** + * Frees memory allocated for land data + */ + void unloadData(); }; } #endif From ea8e5cb6f876fa8bbee83ce0c40028c7957be66c Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Wed, 4 Apr 2012 21:39:21 +0200 Subject: [PATCH 22/28] Issue #225: Land struct is not copyable. Disabled copy constructor and assignment operator in Land structure. --- components/esm/loadland.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/esm/loadland.hpp b/components/esm/loadland.hpp index 64baecd34..ebc314a28 100644 --- a/components/esm/loadland.hpp +++ b/components/esm/loadland.hpp @@ -80,6 +80,11 @@ struct Land * Frees memory allocated for land data */ void unloadData(); + + private: + Land(const Land& land); + Land& operator=(const Land& land); }; + } #endif From 8c84f68dab58b36a4a8a7d51a634cc2192788798 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 4 Apr 2012 23:51:22 +0200 Subject: [PATCH 23/28] fix for older boost versions; unsigned warning --- apps/openmw/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index bc6159e2a..11efc2867 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -71,8 +71,12 @@ void validate(boost::any &v, std::vector const &tokens, FallbackMap for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); it++) { int sep = it->find(","); - if(sep < 1 || sep == (it->length()-1)) + if(sep < 1 || sep == (int)it->length()-1) +#if (BOOST_VERSION <= 104200) + throw boost::program_options::validation_error("invalid value"); +#else throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value); +#endif /* #if (BOOST_VERSION <= 104200) */ std::string key(it->substr(0,sep)); std::string value(it->substr(sep+1)); From 56c9992b29f63a01c887a42a38d2174d4922d6bf Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 4 Apr 2012 23:52:42 +0200 Subject: [PATCH 24/28] typo --- apps/openmw/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 11efc2867..11516d43c 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -72,11 +72,11 @@ void validate(boost::any &v, std::vector const &tokens, FallbackMap { int sep = it->find(","); if(sep < 1 || sep == (int)it->length()-1) -#if (BOOST_VERSION <= 104200) +#if (BOOST_VERSION < 104200) throw boost::program_options::validation_error("invalid value"); #else throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value); -#endif /* #if (BOOST_VERSION <= 104200) */ +#endif/ std::string key(it->substr(0,sep)); std::string value(it->substr(sep+1)); From f7bfea586198dc97df92bd2b96e4c1c50ed7710d Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Thu, 5 Apr 2012 00:16:44 +0200 Subject: [PATCH 25/28] typo 2 -.- --- apps/openmw/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 11516d43c..df52faab1 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -76,7 +76,7 @@ void validate(boost::any &v, std::vector const &tokens, FallbackMap throw boost::program_options::validation_error("invalid value"); #else throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value); -#endif/ +#endif std::string key(it->substr(0,sep)); std::string value(it->substr(sep+1)); From f2c4e513a426f1215ed0df37a60e3b41e787788c Mon Sep 17 00:00:00 2001 From: k1ll Date: Thu, 5 Apr 2012 13:01:09 +0200 Subject: [PATCH 26/28] Add support for building with a static build of the MyGui Libraries. --- CMakeLists.txt | 1 + cmake/FindMyGUI.cmake | 45 +++++++++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0f67e4bf..71f36fe3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,7 @@ set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VE configure_file ("${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp.cmake" "${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp") +option(MYGUI_STATIC "Link static build of Mygui into the binaries" FALSE) option(OGRE_STATIC "Link static build of Ogre and Ogre Plugins into the binaries" FALSE) # Sound source selection diff --git a/cmake/FindMyGUI.cmake b/cmake/FindMyGUI.cmake index cc9799208..6731d584c 100644 --- a/cmake/FindMyGUI.cmake +++ b/cmake/FindMyGUI.cmake @@ -82,20 +82,37 @@ findpkg_finish ( "MYGUI" ) ELSE (WIN32) #Unix CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR) FIND_PACKAGE(PkgConfig) - PKG_SEARCH_MODULE(MYGUI MYGUI MyGUI) - IF (MYGUI_INCLUDE_DIRS) - SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS}) - SET(MYGUI_LIB_DIR ${MYGUI_LIBDIR}) - SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "") - SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") - ELSE (MYGUI_INCLUDE_DIRS) - FIND_PATH(MYGUI_INCLUDE_DIRS MyGUI.h PATHS /usr/local/include /usr/include PATH_SUFFIXES MyGUI MYGUI) - FIND_LIBRARY(MYGUI_LIBRARIES mygui PATHS /usr/lib /usr/local/lib) - SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") - SET(MYGUI_LIB_DIR ${MYGUI_LIBRARIES}) - STRING(REGEX REPLACE "(.*)/.*" "\\1" MYGUI_LIB_DIR "${MYGUI_LIB_DIR}") - STRING(REGEX REPLACE ".*/" "" MYGUI_LIBRARIES "${MYGUI_LIBRARIES}") - ENDIF (MYGUI_INCLUDE_DIRS) + IF(MYGUI_STATIC) + PKG_SEARCH_MODULE(MYGUI MYGUIStatic MyGUIStatic) + IF (MYGUI_INCLUDE_DIRS) + SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS}) + SET(MYGUI_LIB_DIR ${MYGUI_LIBDIR}) + SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "") + SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") + ELSE (MYGUI_INCLUDE_DIRS) + FIND_PATH(MYGUI_INCLUDE_DIRS MyGUI.h PATHS /usr/local/include /usr/include PATH_SUFFIXES MyGUI MYGUI) + FIND_LIBRARY(MYGUI_LIBRARIES myguistatic PATHS /usr/lib /usr/local/lib) + SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") + SET(MYGUI_LIB_DIR ${MYGUI_LIBRARIES}) + STRING(REGEX REPLACE "(.*)/.*" "\\1" MYGUI_LIB_DIR "${MYGUI_LIB_DIR}") + STRING(REGEX REPLACE ".*/" "" MYGUI_LIBRARIES "${MYGUI_LIBRARIES}") + ENDIF (MYGUI_INCLUDE_DIRS) + ELSE(MYGUI_STATIC) + PKG_SEARCH_MODULE(MYGUI MYGUI MyGUI) + IF (MYGUI_INCLUDE_DIRS) + SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS}) + SET(MYGUI_LIB_DIR ${MYGUI_LIBDIR}) + SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "") + SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") + ELSE (MYGUI_INCLUDE_DIRS) + FIND_PATH(MYGUI_INCLUDE_DIRS MyGUI.h PATHS /usr/local/include /usr/include PATH_SUFFIXES MyGUI MYGUI) + FIND_LIBRARY(MYGUI_LIBRARIES mygui PATHS /usr/lib /usr/local/lib) + SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") + SET(MYGUI_LIB_DIR ${MYGUI_LIBRARIES}) + STRING(REGEX REPLACE "(.*)/.*" "\\1" MYGUI_LIB_DIR "${MYGUI_LIB_DIR}") + STRING(REGEX REPLACE ".*/" "" MYGUI_LIBRARIES "${MYGUI_LIBRARIES}") + ENDIF (MYGUI_INCLUDE_DIRS) + ENDIF(MYGUI_STATIC) ENDIF (WIN32) #Do some preparation From 01500e979a09cb4d2012a20a207cab85e367fbc2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 5 Apr 2012 14:27:39 +0200 Subject: [PATCH 27/28] another fix for optional arguments --- components/compiler/parser.cpp | 11 +++++++++++ components/compiler/stringparser.cpp | 5 ----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/components/compiler/parser.cpp b/components/compiler/parser.cpp index 73cadfeba..90368eee0 100644 --- a/components/compiler/parser.cpp +++ b/components/compiler/parser.cpp @@ -7,6 +7,7 @@ #include "errorhandler.hpp" #include "exception.hpp" +#include "scanner.hpp" namespace Compiler { @@ -81,6 +82,8 @@ namespace Compiler { if (!(mOptional && mEmpty)) reportSeriousError ("Unexpected numeric value", loc); + else + scanner.putbackInt (value, loc); return false; } @@ -94,6 +97,8 @@ namespace Compiler { if (!(mOptional && mEmpty)) reportSeriousError ("Unexpected floating point value", loc); + else + scanner.putbackFloat (value, loc); return false; } @@ -108,6 +113,8 @@ namespace Compiler { if (!(mOptional && mEmpty)) reportSeriousError ("Unexpected name", loc); + else + scanner.putbackName (name, loc); return false; } @@ -121,6 +128,8 @@ namespace Compiler { if (!(mOptional && mEmpty)) reportSeriousError ("Unexpected keyword", loc); + else + scanner.putbackKeyword (keyword, loc); return false; } @@ -134,6 +143,8 @@ namespace Compiler { if (!(mOptional && mEmpty)) reportSeriousError ("Unexpected special token", loc); + else + scanner.putbackSpecial (code, loc); return false; } diff --git a/components/compiler/stringparser.cpp b/components/compiler/stringparser.cpp index fe7bd30b9..396a88c78 100644 --- a/components/compiler/stringparser.cpp +++ b/components/compiler/stringparser.cpp @@ -39,11 +39,6 @@ namespace Compiler mState = CommaState; return true; } - else if (code==Scanner::S_newline && mState==StartState) - { - scanner.putbackSpecial (code, loc); - return false; - } return Parser::parseSpecial (code, loc, scanner); } From 84b475130a88e32398120c5eb86bcfed5d6c0ff1 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Thu, 5 Apr 2012 13:19:51 +0400 Subject: [PATCH 28/28] Add missing include --- apps/openmw/mwrender/occlusionquery.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwrender/occlusionquery.cpp b/apps/openmw/mwrender/occlusionquery.cpp index 781b522b6..0c917cda1 100644 --- a/apps/openmw/mwrender/occlusionquery.cpp +++ b/apps/openmw/mwrender/occlusionquery.cpp @@ -6,6 +6,7 @@ #include #include #include +#include using namespace MWRender; using namespace Ogre;