diff --git a/CMakeLists.txt b/CMakeLists.txt index f2b1fcd4e0..9fc37b413a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ include (OpenMWMacros) # Version set (OPENMW_VERSION_MAJOR 0) -set (OPENMW_VERSION_MINOR 24) +set (OPENMW_VERSION_MINOR 25) set (OPENMW_VERSION_RELEASE 0) set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") @@ -53,18 +53,16 @@ option(OPENMW_OSX_DEPLOYMENT OFF) find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems") # Location of morrowind data files -if(DPKG_PROGRAM) +if (APPLE) + set(MORROWIND_DATA_FILES "./data" CACHE PATH "location of Morrowind data files") + set(MORROWIND_RESOURCE_FILES "./resources" CACHE PATH "location of OpenMW resources files") +elseif(UNIX) set(MORROWIND_DATA_FILES "/usr/share/games/openmw/data/" CACHE PATH "location of Morrowind data files") set(MORROWIND_RESOURCE_FILES "/usr/share/games/openmw/resources/" CACHE PATH "location of OpenMW resources files") else() - if (APPLE) - set(MORROWIND_DATA_FILES "./data" CACHE PATH "location of Morrowind data files") - set(MORROWIND_RESOURCE_FILES "./resources" CACHE PATH "location of OpenMW resources files") - else() - set(MORROWIND_DATA_FILES "data" CACHE PATH "location of Morrowind data files") - set(MORROWIND_RESOURCE_FILES "resources" CACHE PATH "location of OpenMW resources files") - endif(APPLE) -endif(DPKG_PROGRAM) + set(MORROWIND_DATA_FILES "data" CACHE PATH "location of Morrowind data files") + set(MORROWIND_RESOURCE_FILES "resources" CACHE PATH "location of OpenMW resources files") +endif(APPLE) if (WIN32) option(USE_DEBUG_CONSOLE "whether a debug console should be enabled for debug builds, if false debug output is redirected to Visual Studio output" ON) @@ -85,10 +83,6 @@ set(OENGINE_OGRE ${LIBDIR}/openengine/ogre/imagerotate.cpp ) -if (APPLE) - set(OENGINE_OGRE ${OENGINE_OGRE} ${LIBDIR}/openengine/ogre/osx_utils.mm) -endif () - set(OENGINE_GUI ${LIBDIR}/openengine/gui/manager.cpp ) @@ -333,60 +327,104 @@ if (CMAKE_COMPILER_IS_GNUCC) endif("${GCC_VERSION}" VERSION_GREATER 4.6 OR "${GCC_VERSION}" VERSION_EQUAL 4.6) endif (CMAKE_COMPILER_IS_GNUCC) -if(DPKG_PROGRAM) - SET(CMAKE_INSTALL_PREFIX "/usr") +IF(NOT WIN32 AND NOT APPLE) + ## Debian and non debian Linux building + # Paths + IF (DPKG_PROGRAM) + ## Debian specific + SET(CMAKE_INSTALL_PREFIX "/usr") + SET(SYSCONFDIR "../etc/openmw" CACHE PATH "Set config dir") + ELSE () + ## Non debian specific + SET(SYSCONFDIR "/etc/openmw" CACHE PATH "Set config dir") + SET(BINDIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Where to install binaries") + SET(LICDIR "${CMAKE_INSTALL_PREFIX}/share/licenses/openmw" CACHE PATH "Sets the openmw license directory to a non-default location.") - if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git") - exec_program("git" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "describe" OUTPUT_VARIABLE GIT_VERSION ) - STRING(REGEX REPLACE "openmw-" "" VERSION_STRING "${GIT_VERSION}") - exec_program("git" ARGS "config --get user.name" OUTPUT_VARIABLE GIT_NAME ) - exec_program("git" ARGS "config --get user.email" OUTPUT_VARIABLE GIT_EMAIL) - set(PACKAGE_MAINTAINER "${GIT_NAME} <${GIT_EMAIL}>") - else() - set(VERSION_STRING "${OPENMW_VERSION}") - set(PACKAGE_MAINTAINER "unknown") - endif() + # Install binaries + INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/openmw" DESTINATION "${BINDIR}" ) + IF(BUILD_LAUNCHER) + INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/omwlauncher" DESTINATION "${BINDIR}" ) + ENDIF(BUILD_LAUNCHER) + IF(BUILD_BSATOOL) + INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/bsatool" DESTINATION "${BINDIR}" ) + ENDIF(BUILD_BSATOOL) + IF(BUILD_ESMTOOL) + INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/esmtool" DESTINATION "${BINDIR}" ) + ENDIF(BUILD_ESMTOOL) + IF(BUILD_MWINIIMPORTER) + INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/mwiniimport" DESTINATION "${BINDIR}" ) + ENDIF(BUILD_MWINIIMPORTER) + IF(BUILD_OPENCS) + INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/opencs" DESTINATION "${BINDIR}" ) + ENDIF(BUILD_OPENCS) - #Install icon and desktop file + # Install licenses + INSTALL(FILES "DejaVu Font License.txt" DESTINATION "${LICDIR}" ) + INSTALL(FILES "Daedric Font License.txt" DESTINATION "${LICDIR}" ) + INSTALL(FILES "OFL.txt" DESTINATION "${LICDIR}" ) + INSTALL(FILES "extern/shiny/License.txt" DESTINATION "${LICDIR}" RENAME "Shiny License.txt" ) + ENDIF (DPKG_PROGRAM) + + # Install icon and desktop file INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.desktop" DESTINATION "share/applications/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") INSTALL(FILES "${OpenMW_SOURCE_DIR}/files/launcher/images/openmw.png" DESTINATION "share/pixmaps/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") + IF(BUILD_OPENCS) + INSTALL(FILES "${OpenMW_BINARY_DIR}/opencs.desktop" DESTINATION "share/applications/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "opencs") + INSTALL(FILES "${OpenMW_SOURCE_DIR}/files/opencs/opencs.png" DESTINATION "share/pixmaps/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "opencs") + ENDIF(BUILD_OPENCS) - #Install global configuration files - INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") - INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") - INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "../etc/openmw/" RENAME "openmw.cfg" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") - INSTALL(FILES "${OpenMW_BINARY_DIR}/opencs.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") + # Install global configuration files + INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${SYSCONFDIR}" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") + INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${SYSCONFDIR}" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") + INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "${SYSCONFDIR}" RENAME "openmw.cfg" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") + IF(BUILD_OPENCS) + INSTALL(FILES "${OpenMW_BINARY_DIR}/opencs.cfg" DESTINATION "${SYSCONFDIR}" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "opencs") + ENDIF(BUILD_OPENCS) - #Install resources + # Install resources INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "share/games/openmw/" FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT "Resources") INSTALL(DIRECTORY DESTINATION "share/games/openmw/data/" COMPONENT "Resources") - SET(CPACK_GENERATOR "DEB") - SET(CPACK_PACKAGE_NAME "openmw") - SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://openmw.org") - SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") - SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "${PACKAGE_MAINTAINER}") - SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "A reimplementation of The Elder Scrolls III: Morrowind + IF (DPKG_PROGRAM) + ## Debian Specific + IF(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git") + EXEC_PROGRAM("git" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "describe" OUTPUT_VARIABLE GIT_VERSION ) + STRING(REGEX REPLACE "openmw-" "" VERSION_STRING "${GIT_VERSION}") + EXEC_PROGRAM("git" ARGS "config --get user.name" OUTPUT_VARIABLE GIT_NAME ) + EXEC_PROGRAM("git" ARGS "config --get user.email" OUTPUT_VARIABLE GIT_EMAIL) + SET(PACKAGE_MAINTAINER "${GIT_NAME} <${GIT_EMAIL}>") + ELSE() + SET(VERSION_STRING "${OPENMW_VERSION}") + SET(PACKAGE_MAINTAINER "unknown") + ENDIF() + + SET(CPACK_GENERATOR "DEB") + SET(CPACK_PACKAGE_NAME "openmw") + SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://openmw.org") + SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") + SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "${PACKAGE_MAINTAINER}") + SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "A reimplementation of The Elder Scrolls III: Morrowind OpenMW is a reimplementation of the Bethesda Game Studios game The Elder Scrolls III: Morrowind. Data files from the original game is required to run it.") - SET(CPACK_DEBIAN_PACKAGE_NAME "openmw") - SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}") - SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW bsatool;Bsatool esmtool;Esmtool omwlauncher;OMWLauncher mwiniimporter;MWiniImporter") - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)") + SET(CPACK_DEBIAN_PACKAGE_NAME "openmw") + SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}") + SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW bsatool;Bsatool esmtool;Esmtool omwlauncher;OMWLauncher mwiniimporter;MWiniImporter") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)") - SET(CPACK_DEBIAN_PACKAGE_SECTION "Games") + SET(CPACK_DEBIAN_PACKAGE_SECTION "Games") - string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE) - execute_process( - COMMAND ${DPKG_PROGRAM} --print-architecture - OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") + STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE) + EXECUTE_PROCESS( + COMMAND ${DPKG_PROGRAM} --print-architecture + OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") - include(CPack) -endif(DPKG_PROGRAM) + INCLUDE(CPack) + ENDIF(DPKG_PROGRAM) +ENDIF(NOT WIN32 AND NOT APPLE) if(WIN32) FILE(GLOB dll_files "${OpenMW_BINARY_DIR}/Release/*.dll") @@ -669,50 +707,3 @@ if (APPLE) include(CPack) endif (APPLE) -if (NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE) - ## Non Debian based Linux building - # paths - set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Where to install binaries") - set(DATAROOTDIR "${CMAKE_INSTALL_PREFIX}/share" CACHE PATH "Sets the root of data directories to a non-default location") - set(DATADIR "${DATAROOTDIR}/games/openmw" CACHE PATH "Sets the openmw data directories to a non-default location") - set(DOCDIR "${DATAROOTDIR}/doc/openmw" CACHE PATH "Sets the doc directory to a non-default location.") - set(MANDIR "${DATAROOTDIR}/man" CACHE PATH "Where to install manpages") - set(SYSCONFDIR "/etc/openmw" CACHE PATH "Set config dir") - set(ICONDIR "${DATAROOTDIR}/pixmaps" CACHE PATH "Set icon dir") - - # Install binaries - INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/openmw" DESTINATION "${BINDIR}" ) - IF(BUILD_LAUNCHER) - INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/omwlauncher" DESTINATION "${BINDIR}" ) - ENDIF(BUILD_LAUNCHER) - IF(BUILD_BSATOOL) - INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/bsatool" DESTINATION "${BINDIR}" ) - ENDIF(BUILD_BSATOOL) - IF(BUILD_ESMTOOL) - INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/esmtool" DESTINATION "${BINDIR}" ) - ENDIF(BUILD_ESMTOOL) - IF(BUILD_MWINIIMPORTER) - INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/mwiniimport" DESTINATION "${BINDIR}" ) - ENDIF(BUILD_MWINIIMPORTER) - IF(BUILD_OPENCS) - INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/opencs" DESTINATION "${BINDIR}" ) - ENDIF(BUILD_OPENCS) - - # Install icon and .desktop - INSTALL(FILES "${OpenMW_SOURCE_DIR}/files/launcher/images/openmw.png" DESTINATION "${ICONDIR}") - INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.desktop" DESTINATION "${DATAROOTDIR}/applications") - IF(BUILD_OPENCS) - INSTALL(FILES "${OpenMW_SOURCE_DIR}/files/opencs/opencs.png" DESTINATION "${ICONDIR}") - INSTALL(FILES "${OpenMW_BINARY_DIR}/opencs.desktop" DESTINATION "${DATAROOTDIR}/applications") - ENDIF(BUILD_OPENCS) - - # Install global configuration files - INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "${SYSCONFDIR}" RENAME "openmw.cfg" ) - #INSTALL(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "${SYSCONFDIR}" ) - INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${SYSCONFDIR}" ) - INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${SYSCONFDIR}" ) - INSTALL(FILES "${OpenMW_BINARY_DIR}/opencs.cfg" DESTINATION "${SYSCONFDIR}" ) - - # Install resources - INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${DATADIR}" ) -endif(NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE) diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index d5d6a3c845..8732b3eab3 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -690,6 +690,10 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::string& filenam std::string key(section + ":" + line.substr(0,pos)); std::string value(line.substr(pos+1)); + if(value.empty()) { + std::cout << "Warning: ignored empty value for key '" << key << "'." << std::endl; + continue; + } multistrmap::iterator it; if((it = map.find(key)) == map.end()) { diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 1050c17174..b35d693a6b 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -141,6 +141,10 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) , mFSStrict (false) , mScriptConsoleMode (false) , mCfgMgr(configurationManager) + , mEncoding(ToUTF8::WINDOWS_1252) + , mEncoder(NULL) + , mActivationDistanceOverride(-1) + { std::srand ( std::time(NULL) ); MWClass::registerClasses(); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index f11d153b4a..27afd734ae 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -54,7 +54,7 @@ void validate(boost::any &v, std::vector const &tokens, FallbackMap FallbackMap *map = boost::any_cast(&v); std::map::iterator mapIt; - for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); it++) + for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); ++it) { int sep = it->find(","); if(sep < 1 || sep == (int)it->length()-1) @@ -204,7 +204,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat // fallback archives StringsVector archives = variables["fallback-archive"].as(); - for (StringsVector::const_iterator it = archives.begin(); it != archives.end(); it++) + for (StringsVector::const_iterator it = archives.begin(); it != archives.end(); ++it) { engine.addArchive(*it); } diff --git a/apps/openmw/mwbase/soundmanager.hpp b/apps/openmw/mwbase/soundmanager.hpp index 2a3ef980c0..e1ca8e7456 100644 --- a/apps/openmw/mwbase/soundmanager.hpp +++ b/apps/openmw/mwbase/soundmanager.hpp @@ -103,13 +103,16 @@ namespace MWBase ///< Play a 2D audio track, using a custom decoder virtual SoundPtr playSound(const std::string& soundId, float volume, float pitch, - PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal) = 0; + PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal, + float offset=0) = 0; ///< Play a sound, independently of 3D-position + ///< @param offset Value from [0,1] meaning from which fraction the sound the playback starts. virtual SoundPtr playSound3D(const MWWorld::Ptr &reference, const std::string& soundId, float volume, float pitch, PlayType type=Play_TypeSfx, - PlayMode mode=Play_Normal) = 0; + PlayMode mode=Play_Normal, float offset=0) = 0; ///< Play a sound from an object + ///< @param offset Value from [0,1] meaning from which fraction the sound the playback starts. virtual void stopSound3D(const MWWorld::Ptr &reference, const std::string& soundId) = 0; ///< Stop the given object from playing the given sound, @@ -123,6 +126,12 @@ namespace MWBase virtual void stopSound(const std::string& soundId) = 0; ///< Stop a non-3d looping sound + virtual void fadeOutSound3D(const MWWorld::Ptr &reference, const std::string& soundId, float duration) = 0; + ///< Fade out given sound (that is already playing) of given object + ///< @param reference Reference to object, whose sound is faded out + ///< @param soundId ID of the sound to fade out. + ///< @param duration Time until volume reaches 0. + virtual bool getSoundPlaying(const MWWorld::Ptr &reference, const std::string& soundId) const = 0; ///< Is the given sound currently playing on the given object? diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 9c9c448edc..81ef9ee79d 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -188,6 +188,7 @@ namespace MWBase virtual void setMinimapVisibility(bool visible) = 0; virtual void setWeaponVisibility(bool visible) = 0; virtual void setSpellVisibility(bool visible) = 0; + virtual void setSneakVisibility(bool visible) = 0; virtual void activateQuickKey (int index) = 0; diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 4ee95b96e1..8180cb6864 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -46,7 +46,11 @@ namespace MWClass { std::auto_ptr data (new CustomData); - // \todo add initial container content + MWWorld::LiveCellRef *ref = + ptr.get(); + + data->mContainerStore.fill( + ref->mBase->mInventory, ptr.getCellRef().mOwner, MWBase::Environment::get().getWorld()->getStore()); // store ptr.getRefData().setCustomData (data.release()); diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 960f574309..911d049d26 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -79,6 +79,8 @@ namespace MWClass data->mCreatureStats.setLevel(ref->mBase->mData.mLevel); + data->mCreatureStats.getAiSequence().fill(ref->mBase->mAiPackage); + data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello); data->mCreatureStats.setAiSetting (1, ref->mBase->mAiData.mFight); data->mCreatureStats.setAiSetting (2, ref->mBase->mAiData.mFlee); @@ -89,6 +91,10 @@ namespace MWClass iter!=ref->mBase->mSpells.mList.end(); ++iter) data->mCreatureStats.getSpells().add (*iter); + // inventory + data->mContainerStore.fill(ref->mBase->mInventory, getId(ptr), + MWBase::Environment::get().getWorld()->getStore()); + // store ptr.getRefData().setCustomData (data.release()); } @@ -370,13 +376,13 @@ namespace MWClass MWWorld::Store::iterator sound = store.begin(); while(sound != store.end()) { - if(type == sound->mType && sound->mCreature.size() > 0 && + if(type == sound->mType && !sound->mCreature.empty() && Misc::StringUtils::ciEqual(ptrid.substr(0, sound->mCreature.size()), sound->mCreature)) sounds.push_back(&*sound); - sound++; + ++sound; } - if(sounds.size() > 0) + if(!sounds.empty()) return sounds[(int)(rand()/(RAND_MAX+1.0)*sounds.size())]->mSound; } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 91d38b8eff..381ffa2330 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -6,6 +6,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwbase/soundmanager.hpp" #include "../mwworld/player.hpp" #include "../mwworld/ptr.hpp" @@ -142,9 +143,23 @@ namespace MWClass // animated door boost::shared_ptr action(new MWWorld::ActionDoor(ptr)); if (MWBase::Environment::get().getWorld()->getOpenOrCloseDoor(ptr)) + { + MWBase::Environment::get().getSoundManager()->fadeOutSound3D(ptr, + closeSound, 0.5); + float offset = ptr.getRefData().getLocalRotation().rot[2]/ 3.14159265 * 2.0; + action->setSoundOffset(offset); action->setSound(openSound); + } else + { + MWBase::Environment::get().getSoundManager()->fadeOutSound3D(ptr, + openSound, 0.5); + float offset = 1.0 - ptr.getRefData().getLocalRotation().rot[2]/ 3.14159265 * 2.0; + //most if not all door have closing bang somewhere in the middle of the sound, + //so we divide offset by two + action->setSoundOffset(offset * 0.5); action->setSound(closeSound); + } return action; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index e91055f1d6..4dd4f6f365 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -215,6 +215,8 @@ namespace MWClass autoCalculateAttributes(ref->mBase, data->mCreatureStats); } + data->mCreatureStats.getAiSequence().fill(ref->mBase->mAiPackage); + data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello); data->mCreatureStats.setAiSetting (1, ref->mBase->mAiData.mFight); data->mCreatureStats.setAiSetting (2, ref->mBase->mAiData.mFlee); @@ -225,8 +227,14 @@ namespace MWClass iter!=ref->mBase->mSpells.mList.end(); ++iter) data->mCreatureStats.getSpells().add (*iter); + // inventory + data->mInventoryStore.fill(ref->mBase->mInventory, getId(ptr), + MWBase::Environment::get().getWorld()->getStore()); + // store ptr.getRefData().setCustomData (data.release()); + + getInventoryStore(ptr).autoEquip(ptr); } } @@ -266,10 +274,10 @@ namespace MWClass ptr.get(); assert(ref->mBase != NULL); - std::string headID = ref->mBase->mHead; + //std::string headID = ref->mBase->mHead; - int end = headID.find_last_of("head_") - 4; - std::string bodyRaceID = headID.substr(0, end); + //int end = headID.find_last_of("head_") - 4; + //std::string bodyRaceID = headID.substr(0, end); std::string model = "meshes\\base_anim.nif"; const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(ref->mBase->mRace); @@ -323,18 +331,18 @@ namespace MWClass return; const MWWorld::Class &othercls = MWWorld::Class::get(victim); - if(!othercls.isActor() || othercls.getCreatureStats(victim).isDead()) - { - // Can't hit non-actors, or dead actors + if(!othercls.isActor()) // Can't hit non-actors + return; + MWMechanics::CreatureStats &otherstats = getCreatureStats(victim); + if(otherstats.isDead()) // Can't hit dead actors return; - } if(ptr.getRefData().getHandle() == "player") - MWBase::Environment::get().getWindowManager()->setEnemy(ptr); + MWBase::Environment::get().getWindowManager()->setEnemy(victim); int weapskill = ESM::Skill::HandToHand; if(!weapon.isEmpty()) - weapskill = MWWorld::Class::get(weapon).getEquipmentSkill(weapon); + weapskill = get(weapon).getEquipmentSkill(weapon); MWMechanics::CreatureStats &crstats = getCreatureStats(ptr); MWMechanics::NpcStats &npcstats = getNpcStats(ptr); @@ -345,7 +353,7 @@ namespace MWClass hitchance *= crstats.getFatigueTerm(); hitchance += mageffects.get(MWMechanics::EffectKey(ESM::MagicEffect::FortifyAttack)).mMagnitude - mageffects.get(MWMechanics::EffectKey(ESM::MagicEffect::Blind)).mMagnitude; - hitchance -= othercls.getEvasion(victim); + hitchance -= otherstats.getEvasion(); if((::rand()/(RAND_MAX+1.0)) > hitchance/100.0f) { @@ -404,8 +412,7 @@ namespace MWClass MWBase::Environment::get().getSoundManager()->playSound3D(victim, "critical damage", 1.0f, 1.0f); } - healthdmg = (othercls.getCreatureStats(victim).getFatigue().getCurrent() < 1.0f || - npcstats.isWerewolf()); + healthdmg = (otherstats.getFatigue().getCurrent() < 1.0f || npcstats.isWerewolf()); if(healthdmg) damage *= gmst.find("fHandtoHandHealthPer")->getFloat(); } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 06a6e335dc..52493bf765 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -172,7 +172,6 @@ namespace MWDialogue win->addResponse (Interpreter::fixDefinesDialog(info->mResponse, interpreterContext)); executeScript (info->mResultScript); mLastTopic = Misc::StringUtils::lowerCase(it->mId); - mLastDialogue = *info; break; } } @@ -293,7 +292,6 @@ namespace MWDialogue executeScript (info->mResultScript); mLastTopic = topic; - mLastDialogue = *info; } else { @@ -455,7 +453,6 @@ namespace MWDialogue MWBase::Environment::get().getWindowManager()->getDialogueWindow()->addResponse (Interpreter::fixDefinesDialog(text, interpreterContext)); MWBase::Environment::get().getJournal()->addTopic (mLastTopic, info->mId); executeScript (info->mResultScript); - mLastDialogue = *info; } } } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index 13bab4dae1..1b7abed45a 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -31,7 +31,6 @@ namespace MWDialogue int mChoice; std::string mLastTopic; - ESM::DialInfo mLastDialogue; bool mIsInChoice; float mTemporaryDispositionChange; diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 136cb7c981..1e203dcd0b 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -47,6 +47,8 @@ namespace MWGui , mIngredients (4) , mSortModel(NULL) { + mAlchemy.setAlchemist (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); + getWidget(mCreateButton, "CreateButton"); getWidget(mCancelButton, "CancelButton"); getWidget(mIngredients[0], "Ingredient1"); @@ -150,10 +152,10 @@ namespace MWGui mNameEdit->setCaption(""); - mAlchemy.setAlchemist (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); - int index = 0; + mAlchemy.setAlchemist (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); + for (MWMechanics::Alchemy::TToolsIterator iter (mAlchemy.beginTools()); iter!=mAlchemy.endTools() && index (mApparatus.size()); ++iter, ++index) { diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index 94f834a4d2..694970e23d 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -108,7 +108,7 @@ struct TypesetBookImpl : TypesetBook { Contents::iterator i = mContents.insert (mContents.end (), Content (text.first, text.second)); - if (i->size () == 0) + if (i->empty()) return Range (Utf8Point (NULL), Utf8Point (NULL)); Utf8Point begin = &i->front (); @@ -768,6 +768,11 @@ public: PageDisplay () { mPage = -1; + mViewTop = 0; + mViewBottom = 0; + mFocusItem = NULL; + mItemActive = false; + mNode = NULL; } void dirtyFocusItem () @@ -1093,7 +1098,6 @@ class BookPageImpl : public BookPage MYGUI_RTTI_DERIVED(BookPage) public: - void showPage (TypesetBook::Ptr book, size_t page) { if (PageDisplay* pd = dynamic_cast (getSubWidgetText ())) diff --git a/apps/openmw/mwgui/bookwindow.cpp b/apps/openmw/mwgui/bookwindow.cpp index 849f6052be..efe089689b 100644 --- a/apps/openmw/mwgui/bookwindow.cpp +++ b/apps/openmw/mwgui/bookwindow.cpp @@ -19,6 +19,7 @@ namespace MWGui : WindowBase("openmw_book.layout") , mTakeButtonShow(true) , mTakeButtonAllowed(true) + , mCurrentPage(0) { getWidget(mCloseButton, "CloseButton"); mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onCloseButtonClicked); diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index d1e103dd35..816f42e3d1 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -70,6 +70,9 @@ namespace MWGui , mGenerateClassStep(0) { mCreationStage = CSE_NotStarted; + mGenerateClassSpecializations[0] = 0; + mGenerateClassSpecializations[1] = 0; + mGenerateClassSpecializations[2] = 0; } void CharacterCreation::setValue (const std::string& id, const MWMechanics::Stat& value) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 2f00918b00..c33e54d6b4 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -372,6 +372,8 @@ namespace MWGui , mAttribDialog(NULL) , mSkillDialog(NULL) , mDescDialog(NULL) + , mAffectedAttribute(NULL) + , mAffectedSkill(NULL) { // Centre dialog center(); @@ -718,6 +720,7 @@ namespace MWGui SelectAttributeDialog::SelectAttributeDialog() : WindowModal("openmw_chargen_select_attribute.layout") + , mAttributeId(ESM::Attribute::Strength) { // Centre dialog center(); diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 3bc0de4cb3..ff774b531e 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -217,7 +217,7 @@ namespace MWGui mCommandLine->setCaption(complete( mCommandLine->getCaption(), matches )); #if 0 int i = 0; - for(std::vector::iterator it=matches.begin(); it < matches.end(); it++,i++ ) + for(std::vector::iterator it=matches.begin(); it < matches.end(); ++it,++i ) { printOK( *it ); if( i == 50 ) @@ -237,7 +237,7 @@ namespace MWGui if(mCurrent != mCommandHistory.begin()) { - mCurrent--; + --mCurrent; mCommandLine->setCaption(*mCurrent); } } @@ -245,7 +245,7 @@ namespace MWGui { if(mCurrent != mCommandHistory.end()) { - mCurrent++; + --mCurrent; if(mCurrent != mCommandHistory.end()) mCommandLine->setCaption(*mCurrent); @@ -333,7 +333,7 @@ namespace MWGui continue; /* Is the beginning of the string different from the input string? If yes skip it. */ - for( std::string::iterator iter=tmp.begin(), iter2=(*it).begin(); iter < tmp.end();iter++, iter2++) { + for( std::string::iterator iter=tmp.begin(), iter2=(*it).begin(); iter < tmp.end();++iter, ++iter2) { if( tolower(*iter) != tolower(*iter2) ) { string_different=true; break; @@ -372,7 +372,7 @@ namespace MWGui /* Check if all matching strings match further than input. If yes complete to this match. */ int i = tmp.length(); - for(std::string::iterator iter=matches.front().begin()+tmp.length(); iter < matches.front().end(); iter++, i++) { + for(std::string::iterator iter=matches.front().begin()+tmp.length(); iter < matches.front().end(); ++iter, ++i) { for(std::vector::iterator it=matches.begin(); it < matches.end();++it) { if( tolower((*it)[i]) != tolower(*iter) ) { /* Append the longest match to the end of the output string*/ diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index 58d963ce83..bd75c078c0 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -78,7 +78,7 @@ namespace return string.getChar(0); } - bool is_not_empty(const std::string s) { + bool is_not_empty(const std::string& s) { std::string temp = s; boost::algorithm::trim(temp); return !temp.empty(); diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 4eea0d0d0d..f5cb12e058 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -84,6 +84,9 @@ namespace MWGui mSpellBoxBaseLeft = mSpellBox->getLeft(); mSpellBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked); + getWidget(mSneakBox, "SneakBox"); + mSneakBoxBaseLeft = mSneakBox->getLeft(); + getWidget(mEffectBox, "EffectBox"); mEffectBoxBaseRight = viewSize.width - mEffectBox->getRight(); @@ -503,6 +506,12 @@ namespace MWGui updatePositions(); } + void HUD::setSneakVisible(bool visible) + { + mSneakBox->setVisible(visible); + updatePositions(); + } + void HUD::setEffectVisible(bool visible) { mEffectBox->setVisible (visible); @@ -517,12 +526,18 @@ namespace MWGui void HUD::updatePositions() { - int weapDx = 0, spellDx = 0; + int weapDx = 0, spellDx = 0, sneakDx = 0; if (!mHealth->getVisible()) - spellDx = weapDx = mWeapBoxBaseLeft - mHealthManaStaminaBaseLeft; + sneakDx = spellDx = weapDx = mWeapBoxBaseLeft - mHealthManaStaminaBaseLeft; if (!mWeapBox->getVisible()) + { spellDx += mSpellBoxBaseLeft - mWeapBoxBaseLeft; + sneakDx = spellDx; + } + + if (!mSpellBox->getVisible()) + sneakDx += mSneakBoxBaseLeft - mSpellBoxBaseLeft; mWeaponVisible = mWeapBox->getVisible(); mSpellVisible = mSpellBox->getVisible(); @@ -531,6 +546,7 @@ namespace MWGui mWeapBox->setPosition(mWeapBoxBaseLeft - weapDx, mWeapBox->getTop()); mSpellBox->setPosition(mSpellBoxBaseLeft - spellDx, mSpellBox->getTop()); + mSneakBox->setPosition(mSneakBoxBaseLeft - sneakDx, mSneakBox->getTop()); const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize(); diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp index 76d8782696..a3cab2c93a 100644 --- a/apps/openmw/mwgui/hud.hpp +++ b/apps/openmw/mwgui/hud.hpp @@ -21,6 +21,7 @@ namespace MWGui void setHmsVisible(bool visible); void setWeapVisible(bool visible); void setSpellVisible(bool visible); + void setSneakVisible(bool visible); void setEffectVisible(bool visible); void setMinimapVisible(bool visible); @@ -51,7 +52,7 @@ namespace MWGui private: MyGUI::ProgressBar *mHealth, *mMagicka, *mStamina, *mEnemyHealth; MyGUI::Widget* mHealthFrame; - MyGUI::Widget *mWeapBox, *mSpellBox; + MyGUI::Widget *mWeapBox, *mSpellBox, *mSneakBox; MyGUI::ImageBox *mWeapImage, *mSpellImage; MyGUI::ProgressBar *mWeapStatus, *mSpellStatus; MyGUI::Widget *mEffectBox, *mMinimapBox; @@ -70,7 +71,7 @@ namespace MWGui MyGUI::TextBox* mBatchCounter; // bottom left elements - int mHealthManaStaminaBaseLeft, mWeapBoxBaseLeft, mSpellBoxBaseLeft; + int mHealthManaStaminaBaseLeft, mWeapBoxBaseLeft, mSpellBoxBaseLeft, mSneakBoxBaseLeft; // bottom right elements int mMinimapBoxBaseRight, mEffectBoxBaseRight; diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 9fa87c4b85..7ad17fab07 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -36,6 +36,12 @@ namespace MWGui , mPreview(MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ()) , mPreviewDirty(true) , mDragAndDrop(dragAndDrop) + , mSelectedItem(-1) + , mPositionInventory(0, 342, 498, 258) + , mPositionContainer(0, 342, 498, 258) + , mPositionCompanion(0, 342, 498, 258) + , mPositionBarter(0, 342, 498, 258) + , mGuiMode(GM_Inventory) { static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize); @@ -67,7 +73,7 @@ namespace MWGui mFilterAll->setStateSelected(true); - setCoord(0, 342, 498, 258); + setCoord(mPositionInventory.left, mPositionInventory.top, mPositionInventory.width, mPositionInventory.height); onWindowResize(static_cast(mMainWidget)); mPreview.setup(); @@ -83,6 +89,27 @@ namespace MWGui mPreview.setup(); } + void InventoryWindow::setGuiMode(GuiMode mode) + { + mGuiMode = mode; + switch(mode) { + case GM_Container: + mMainWidget->setCoord(mPositionContainer); + break; + case GM_Companion: + mMainWidget->setCoord(mPositionCompanion); + break; + case GM_Barter: + mMainWidget->setCoord(mPositionBarter); + break; + case GM_Inventory: + default: + mMainWidget->setCoord(mPositionInventory); + break; + } + onWindowResize(static_cast(mMainWidget)); + } + TradeItemModel* InventoryWindow::getTradeModel() { return mTradeModel; @@ -210,6 +237,21 @@ namespace MWGui _sender->getSize().width - 12 - (_sender->getSize().height-44) * aspect - 15, _sender->getSize().height-44 ); + switch(mGuiMode) { + case GM_Container: + mPositionContainer = _sender->getCoord(); + break; + case GM_Companion: + mPositionCompanion = _sender->getCoord(); + break; + case GM_Barter: + mPositionBarter = _sender->getCoord(); + break; + case GM_Inventory: + default: + mPositionInventory = _sender->getCoord(); + } + if (mMainWidget->getSize().width != mLastXSize || mMainWidget->getSize().height != mLastYSize) { mLastXSize = mMainWidget->getSize().width; diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index 13c1189130..35140437d1 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -5,6 +5,7 @@ #include "windowpinnablebase.hpp" #include "widgets.hpp" +#include "mode.hpp" namespace MWGui { @@ -47,6 +48,8 @@ namespace MWGui void updatePlayer(); + void setGuiMode(GuiMode mode); + private: DragAndDrop* mDragAndDrop; @@ -73,6 +76,13 @@ namespace MWGui MyGUI::Button* mFilterMagic; MyGUI::Button* mFilterMisc; + MyGUI::IntCoord mPositionInventory; + MyGUI::IntCoord mPositionContainer; + MyGUI::IntCoord mPositionCompanion; + MyGUI::IntCoord mPositionBarter; + + GuiMode mGuiMode; + int mLastXSize; int mLastYSize; diff --git a/apps/openmw/mwgui/itemselection.cpp b/apps/openmw/mwgui/itemselection.cpp index a57c6d81f1..01ea3429c3 100644 --- a/apps/openmw/mwgui/itemselection.cpp +++ b/apps/openmw/mwgui/itemselection.cpp @@ -9,6 +9,8 @@ namespace MWGui ItemSelectionDialog::ItemSelectionDialog(const std::string &label) : WindowModal("openmw_itemselection_dialog.layout") + , mSortModel(NULL) + , mModel(NULL) { getWidget(mItemView, "ItemView"); mItemView->eventItemClicked += MyGUI::newDelegate(this, &ItemSelectionDialog::onSelectedItem); diff --git a/apps/openmw/mwgui/itemview.cpp b/apps/openmw/mwgui/itemview.cpp index 5155d27120..466ecbdcc0 100644 --- a/apps/openmw/mwgui/itemview.cpp +++ b/apps/openmw/mwgui/itemview.cpp @@ -32,6 +32,7 @@ namespace MWGui ItemView::ItemView() : mModel(NULL) + , mScrollView(NULL) { } diff --git a/apps/openmw/mwgui/keywordsearch.hpp b/apps/openmw/mwgui/keywordsearch.hpp index 13d3318e59..a9fb6daaba 100644 --- a/apps/openmw/mwgui/keywordsearch.hpp +++ b/apps/openmw/mwgui/keywordsearch.hpp @@ -101,7 +101,7 @@ public: candidates.push_back(std::make_pair((j-i), candidate)); } - if (!candidates.size()) + if (candidates.empty()) continue; // didn't match enough to disambiguate, on to next character // shorter candidates will be added to the vector first. however, we want to check against longer candidates first diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index d4b06b2ab6..547d2fe29d 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -24,6 +24,10 @@ namespace MWGui , mLastWallpaperChangeTime(0.f) , mFirstLoad(true) , mTotalRefsLoading(0) + , mCurrentCellLoading(0) + , mTotalCellsLoading(0) + , mCurrentRefLoading(0) + , mCurrentRefList(0) { getWidget(mLoadingText, "LoadingText"); getWidget(mProgressBar, "ProgressBar"); diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 7098853af8..0ccfb7e88c 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -89,9 +89,6 @@ namespace MWGui { for (int my=0; my<3; ++my) { - std::string name = "Map_" + boost::lexical_cast(mx) + "_" - + boost::lexical_cast(my); - std::string image = mPrefix+"_"+ boost::lexical_cast(mCurX + (mx-1)) + "_" + boost::lexical_cast(mCurY + (-1*(my-1))); MyGUI::ImageBox* fog = mFogWidgets[my + 3*mx]; @@ -135,9 +132,6 @@ namespace MWGui std::string image = mPrefix+"_"+ boost::lexical_cast(x + (mx-1)) + "_" + boost::lexical_cast(y + (-1*(my-1))); - std::string name = "Map_" + boost::lexical_cast(mx) + "_" - + boost::lexical_cast(my); - MyGUI::ImageBox* box = mMapWidgets[my + 3*mx]; if (MyGUI::RenderManager::getInstance().getTexture(image) != 0) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 3a969c7ca3..45da1bf17e 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -49,7 +49,7 @@ namespace MWGui else { (*it2)->update(height); height += (*it2)->getHeight(); - it2++; + ++it2; } } } @@ -57,7 +57,7 @@ namespace MWGui } else { - it++; + ++it; } } @@ -226,6 +226,7 @@ namespace MWGui : WindowModal("openmw_interactive_messagebox.layout") , mMessageBoxManager(parMessageBoxManager) , mButtonPressed(-1) + , mTextButtonPadding(0) { WindowModal::open(); diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 877f7b7003..a5fc2ca5d7 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -44,6 +44,7 @@ namespace MWGui , mAssignDialog(0) , mItemSelectionDialog(0) , mMagicSelectionDialog(0) + , mSelectedIndex(-1) { getWidget(mOkButton, "OKButton"); getWidget(mInstructionLabel, "InstructionLabel"); diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index ba06c8d105..2c73226e3d 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -33,6 +33,7 @@ namespace MWGui , mHairIndex(0) , mCurrentAngle(0) , mPreviewDirty(true) + , mPreview(NULL) { // Centre dialog center(); diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 824929b67e..dfc86a547b 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -18,7 +18,6 @@ namespace MWGui ReviewDialog::ReviewDialog() : WindowModal("openmw_chargen_review.layout") - , mLastPos(0) { // Centre dialog center(); @@ -321,9 +320,7 @@ namespace MWGui if (!mMiscSkills.empty()) addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); - mClientHeight = coord1.top; - - mSkillView->setCanvasSize (mSkillView->getWidth(), std::max(mSkillView->getHeight(), mClientHeight)); + mSkillView->setCanvasSize (mSkillView->getWidth(), std::max(mSkillView->getHeight(), coord1.top)); } // widget controls diff --git a/apps/openmw/mwgui/review.hpp b/apps/openmw/mwgui/review.hpp index 87d6fedfa7..1c24fec745 100644 --- a/apps/openmw/mwgui/review.hpp +++ b/apps/openmw/mwgui/review.hpp @@ -79,7 +79,6 @@ namespace MWGui MyGUI::TextBox *mNameWidget, *mRaceWidget, *mClassWidget, *mBirthSignWidget; MyGUI::ScrollView* mSkillView; - int mLastPos, mClientHeight; Widgets::MWDynamicStatPtr mHealth, mMagicka, mFatigue; diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index c4c1be711e..dc86fd825f 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -81,6 +81,15 @@ namespace MWGui mDeleteButton->setVisible (false); mEffect.mRange = ESM::RT_Self; + if (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastSelf)) + mEffect.mRange = ESM::RT_Touch; + if (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch)) + mEffect.mRange = ESM::RT_Target; + mEffect.mMagnMin = 1; + mEffect.mMagnMax = 1; + mEffect.mDuration = 1; + mEffect.mArea = 0; + eventEffectAdded(mEffect); onRangeButtonClicked(mRangeButton); @@ -93,11 +102,6 @@ namespace MWGui mMagnitudeMinValue->setCaption("1"); mMagnitudeMaxValue->setCaption("- 1"); mAreaValue->setCaption("0"); - - mEffect.mMagnMin = 1; - mEffect.mMagnMax = 1; - mEffect.mDuration = 1; - mEffect.mArea = 0; } void EditEffectDialog::editEffect (ESM::ENAMstruct effect) @@ -106,7 +110,7 @@ namespace MWGui MWBase::Environment::get().getWorld()->getStore().get().find(effect.mEffectID); setMagicEffect(magicEffect); - + mOldEffect = effect; mEffect = effect; mEditing = true; @@ -121,6 +125,7 @@ namespace MWGui onMagnitudeMaxChanged (mMagnitudeMinSlider, effect.mMagnMax-1); onAreaChanged (mAreaSlider, effect.mArea); onDurationChanged (mDurationSlider, effect.mDuration-1); + eventEffectModified(mEffect); } void EditEffectDialog::setMagicEffect (const ESM::MagicEffect *effect) @@ -163,7 +168,7 @@ namespace MWGui mDurationBox->setVisible (true); curY += mDurationBox->getSize().height; } - if (mEffect.mRange == ESM::RT_Target) + if (mEffect.mRange != ESM::RT_Self) { mAreaBox->setPosition(mAreaBox->getPosition().left, curY); mAreaBox->setVisible (true); @@ -182,9 +187,6 @@ namespace MWGui else if (mEffect.mRange == ESM::RT_Touch) mRangeButton->setCaptionWithReplacing ("#{sRangeTouch}"); - mAreaSlider->setVisible (mEffect.mRange != ESM::RT_Self); - mAreaText->setVisible (mEffect.mRange != ESM::RT_Self); - // cycle through range types until we find something that's allowed if (mEffect.mRange == ESM::RT_Target && !(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTarget)) onRangeButtonClicked(sender); @@ -193,7 +195,13 @@ namespace MWGui if (mEffect.mRange == ESM::RT_Touch && !(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch)) onRangeButtonClicked(sender); + if(mEffect.mRange == ESM::RT_Self) + { + mAreaSlider->setScrollPosition(0); + onAreaChanged(mAreaSlider,0); + } updateBoxes(); + eventEffectModified(mEffect); } void EditEffectDialog::onDeleteButtonClicked (MyGUI::Widget* sender) @@ -206,26 +214,27 @@ namespace MWGui void EditEffectDialog::onOkButtonClicked (MyGUI::Widget* sender) { setVisible(false); - - if (mEditing) - eventEffectModified(mEffect); - else - eventEffectAdded(mEffect); } void EditEffectDialog::onCancelButtonClicked (MyGUI::Widget* sender) { setVisible(false); + if(mEditing) + eventEffectModified(mOldEffect); + else + eventEffectRemoved(mEffect); } void EditEffectDialog::setSkill (int skill) { mEffect.mSkill = skill; + eventEffectModified(mEffect); } void EditEffectDialog::setAttribute (int attribute) { mEffect.mAttribute = attribute; + eventEffectModified(mEffect); } void EditEffectDialog::onMagnitudeMinChanged (MyGUI::ScrollBar* sender, size_t pos) @@ -235,6 +244,7 @@ namespace MWGui // trigger the check again (see below) onMagnitudeMaxChanged(mMagnitudeMaxSlider, mMagnitudeMaxSlider->getScrollPosition ()); + eventEffectModified(mEffect); } void EditEffectDialog::onMagnitudeMaxChanged (MyGUI::ScrollBar* sender, size_t pos) @@ -250,18 +260,22 @@ namespace MWGui mEffect.mMagnMax = pos+1; mMagnitudeMaxValue->setCaption("- " + boost::lexical_cast(pos+1)); + + eventEffectModified(mEffect); } void EditEffectDialog::onDurationChanged (MyGUI::ScrollBar* sender, size_t pos) { mDurationValue->setCaption(boost::lexical_cast(pos+1)); mEffect.mDuration = pos+1; + eventEffectModified(mEffect); } void EditEffectDialog::onAreaChanged (MyGUI::ScrollBar* sender, size_t pos) { mAreaValue->setCaption(boost::lexical_cast(pos)); mEffect.mArea = pos; + eventEffectModified(mEffect); } // ------------------------------------------------------------------------------------------------ @@ -615,6 +629,7 @@ namespace MWGui void EffectEditorBase::onEffectAdded (ESM::ENAMstruct effect) { mEffects.push_back(effect); + mSelectedEffect=mEffects.size()-1; updateEffectsView(); } diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp index 61b8884917..e424d73957 100644 --- a/apps/openmw/mwgui/spellcreationdialog.hpp +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -75,6 +75,7 @@ namespace MWGui protected: ESM::ENAMstruct mEffect; + ESM::ENAMstruct mOldEffect; const ESM::MagicEffect* mMagicEffect; }; diff --git a/apps/openmw/mwgui/spellicons.cpp b/apps/openmw/mwgui/spellicons.cpp index e762cc6105..5e7ed498d3 100644 --- a/apps/openmw/mwgui/spellicons.cpp +++ b/apps/openmw/mwgui/spellicons.cpp @@ -139,7 +139,7 @@ namespace MWGui if (adjustSize) { int s = effects.size() * 16+4; - if (!effects.size()) + if (effects.empty()) s = 0; int diff = parent->getWidth() - s; parent->setSize(s, parent->getHeight()); diff --git a/apps/openmw/mwgui/spellicons.hpp b/apps/openmw/mwgui/spellicons.hpp index af600e3474..818d67b5bb 100644 --- a/apps/openmw/mwgui/spellicons.hpp +++ b/apps/openmw/mwgui/spellicons.hpp @@ -22,7 +22,11 @@ namespace MWGui // information about a single magic effect source as required for display in the tooltip struct MagicEffectInfo { - MagicEffectInfo() : mPermanent(false) {} + MagicEffectInfo() + : mPermanent(false) + , mMagnitude(0) + , mRemainingTime(0) + {} std::string mSource; // display name for effect source (e.g. potion name) MWMechanics::EffectKey mKey; int mMagnitude; diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index 1134767f14..79c94b27e2 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -21,7 +21,6 @@ namespace MWGui StatsWindow::StatsWindow () : WindowPinnableBase("openmw_stats_window.layout") , mSkillView(NULL) - , mClientHeight(0) , mMajorSkills() , mMinorSkills() , mMiscSkills() @@ -82,7 +81,7 @@ namespace MWGui { mLeftPane->setCoord( MyGUI::IntCoord(0, 0, 0.44*window->getSize().width, window->getSize().height) ); mRightPane->setCoord( MyGUI::IntCoord(0.44*window->getSize().width, 0, 0.56*window->getSize().width, window->getSize().height) ); - mSkillView->setCanvasSize (mSkillView->getWidth(), std::max(mSkillView->getHeight(), mClientHeight)); + mSkillView->setCanvasSize (mSkillView->getWidth(), mSkillView->getCanvasSize().height); } void StatsWindow::setBar(const std::string& name, const std::string& tname, int val, int max) @@ -422,7 +421,6 @@ namespace MWGui mSkillWidgets.clear(); mSkillView->setViewOffset (MyGUI::IntPoint(0,0)); - mClientHeight = 0; const int valueSize = 40; MyGUI::IntCoord coord1(10, 0, mSkillView->getWidth() - (10 + valueSize) - 24, 18); @@ -565,9 +563,7 @@ namespace MWGui mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sCrimeHelp}"); } - mClientHeight = coord1.top; - - mSkillView->setCanvasSize (mSkillView->getWidth(), std::max(mSkillView->getHeight(), mClientHeight)); + mSkillView->setCanvasSize (mSkillView->getWidth(), std::max(mSkillView->getHeight(), coord1.top)); } void StatsWindow::onPinToggled() diff --git a/apps/openmw/mwgui/statswindow.hpp b/apps/openmw/mwgui/statswindow.hpp index bec42d029b..ac8319bdcd 100644 --- a/apps/openmw/mwgui/statswindow.hpp +++ b/apps/openmw/mwgui/statswindow.hpp @@ -57,7 +57,6 @@ namespace MWGui MyGUI::Widget* mRightPane; MyGUI::ScrollView* mSkillView; - int mLastPos, mClientHeight; SkillList mMajorSkills, mMinorSkills, mMiscSkills; std::map > mSkillValues; diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index ad5418ebd5..5e65c762de 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -149,7 +149,6 @@ namespace MWGui } std::string type = focus->getUserString("ToolTipType"); - std::string text = focus->getUserString("ToolTipText"); if (type == "") { diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 01f7e2419f..498fbace87 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -36,6 +36,9 @@ namespace MWGui , mBalanceButtonsState(BBS_None) , mBalanceChangePause(0.0) , mItemToSell(-1) + , mTradeModel(NULL) + , mSortModel(NULL) + , mCurrentMerchantOffer(0) { getWidget(mFilterAll, "AllButton"); getWidget(mFilterWeapon, "WeaponButton"); diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index 97c869b07d..e159a826ec 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -47,6 +47,8 @@ namespace MWGui , mSleeping(false) , mHours(1) , mRemainingTime(0.05) + , mCurHour(0) + , mManualHours(1) { getWidget(mDateTimeText, "DateTimeText"); getWidget(mRestText, "RestText"); @@ -216,7 +218,13 @@ namespace MWGui void WaitDialog::setCanRest (bool canRest) { - mUntilHealedButton->setVisible(canRest); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); + bool full = (stats.getFatigue().getCurrent() >= stats.getFatigue().getModified()) + && (stats.getHealth().getCurrent() >= stats.getHealth().getModified()) + && (stats.getMagicka().getCurrent() >= stats.getMagicka().getModified()); + + mUntilHealedButton->setVisible(canRest && !full); mWaitButton->setCaptionWithReplacing (canRest ? "#{sRest}" : "#{sWait}"); mRestText->setCaptionWithReplacing (canRest ? "#{sRestMenu3}" : "#{sRestIllegal}"); diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 04ef0e7cbb..dea64ae8cf 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -899,6 +899,7 @@ namespace MWGui : mEnableRepeat(true) , mRepeatTriggerTime(0.5) , mRepeatStepTime(0.1) + , mIsIncreasing(true) { } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 72d44cda5d..7924310387 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -441,16 +441,19 @@ namespace MWGui mMap ->setVisible(eff & GW_Map); mStatsWindow ->setVisible(eff & GW_Stats); mInventoryWindow->setVisible(eff & GW_Inventory); + mInventoryWindow->setGuiMode(mode); mSpellWindow ->setVisible(eff & GW_Magic); break; } case GM_Container: mContainerWindow->setVisible(true); mInventoryWindow->setVisible(true); + mInventoryWindow->setGuiMode(mode); break; case GM_Companion: mCompanionWindow->setVisible(true); mInventoryWindow->setVisible(true); + mInventoryWindow->setGuiMode(mode); break; case GM_Dialogue: mDialogueWindow->setVisible(true); @@ -458,6 +461,7 @@ namespace MWGui case GM_Barter: mInventoryWindow->setVisible(true); mInventoryWindow->setTrading(true); + mInventoryWindow->setGuiMode(mode); mTradeWindow->setVisible(true); break; case GM_SpellBuying: @@ -830,6 +834,11 @@ namespace MWGui mHud->setEffectVisible (visible); } + void WindowManager::setSneakVisibility(bool visible) + { + mHud->setSneakVisible(visible); + } + void WindowManager::setDragDrop(bool dragDrop) { mToolTips->setEnabled(!dragDrop); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index cc1eb6df13..a178dc621b 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -179,6 +179,7 @@ namespace MWGui virtual void setMinimapVisibility(bool visible); virtual void setWeaponVisibility(bool visible); virtual void setSpellVisibility(bool visible); + virtual void setSneakVisibility(bool visible); virtual void activateQuickKey (int index); diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 973089d752..02b8520ab0 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -844,8 +844,8 @@ namespace MWInput defaultKeyBindings[A_QuickKey8] = SDLK_8; defaultKeyBindings[A_QuickKey9] = SDLK_9; defaultKeyBindings[A_QuickKey10] = SDLK_0; - defaultKeyBindings[A_Screenshot] = SDLK_PRINTSCREEN; - defaultKeyBindings[A_ToggleHUD] = SDLK_F12; + defaultKeyBindings[A_Screenshot] = SDLK_F12; + defaultKeyBindings[A_ToggleHUD] = SDLK_F11; defaultKeyBindings[A_AlwaysRun] = SDLK_y; std::map defaultMouseButtonBindings; @@ -880,12 +880,20 @@ namespace MWInput mInputBinder->addMouseButtonBinding (control, defaultMouseButtonBindings[i], ICS::Control::INCREASE); } } + + // Printscreen key should not be allowed because it's captured by system screenshot function + // We check this explicitely here to fix up pre-0.26 config files. Can be removed after a few versions + if (mInputBinder->getKeyBinding(mInputBinder->getControl(A_Screenshot), ICS::Control::INCREASE) == SDLK_PRINTSCREEN) + mInputBinder->addKeyBinding(mInputBinder->getControl(A_Screenshot), SDLK_F12, ICS::Control::INCREASE); } std::string InputManager::getActionDescription (int action) { std::map descriptions; + if (action == A_Screenshot) + return "Screenshot"; + descriptions[A_Use] = "sUse"; descriptions[A_Activate] = "sActivate"; descriptions[A_MoveBackward] = "sBack"; @@ -958,6 +966,7 @@ namespace MWInput ret.push_back(A_Journal); ret.push_back(A_Rest); ret.push_back(A_Console); + ret.push_back(A_Screenshot); ret.push_back(A_QuickKeysMenu); ret.push_back(A_QuickKey1); ret.push_back(A_QuickKey2); diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index 6af87e8bd2..556e0b1267 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -29,6 +29,8 @@ namespace MWMechanics { AiEscort::AiEscort(const std::string &actorId, int duration, float x, float y, float z) : mActorId(actorId), mX(x), mY(y), mZ(z), mDuration(duration) + , cellX(std::numeric_limits::max()) + , cellY(std::numeric_limits::max()) { mMaxDist = 470; @@ -46,6 +48,8 @@ namespace MWMechanics AiEscort::AiEscort(const std::string &actorId, const std::string &cellId,int duration, float x, float y, float z) : mActorId(actorId), mCellId(cellId), mX(x), mY(y), mZ(z), mDuration(duration) + , cellX(std::numeric_limits::max()) + , cellY(std::numeric_limits::max()) { mMaxDist = 470; diff --git a/apps/openmw/mwmechanics/aisequence.cpp b/apps/openmw/mwmechanics/aisequence.cpp index c4dcf89af4..2f06b849a3 100644 --- a/apps/openmw/mwmechanics/aisequence.cpp +++ b/apps/openmw/mwmechanics/aisequence.cpp @@ -3,6 +3,12 @@ #include "aipackage.hpp" +#include "aiwander.hpp" +#include "aiescort.hpp" +#include "aitravel.hpp" +#include "aifollow.hpp" +#include "aiactivate.hpp" + void MWMechanics::AiSequence::copy (const AiSequence& sequence) { for (std::list::const_iterator iter (sequence.mPackages.begin()); @@ -77,3 +83,40 @@ void MWMechanics::AiSequence::queue (const AiPackage& package) { mPackages.push_back (package.clone()); } + +void MWMechanics::AiSequence::fill(const ESM::AIPackageList &list) +{ + for (std::vector::const_iterator it = list.mList.begin(); it != list.mList.end(); ++it) + { + MWMechanics::AiPackage* package; + if (it->mType == ESM::AI_Wander) + { + ESM::AIWander data = it->mWander; + std::vector idles; + for (int i=0; i<8; ++i) + idles.push_back(data.mIdle[i]); + package = new MWMechanics::AiWander(data.mDistance, data.mDuration, data.mTimeOfDay, idles, data.mUnk); + } + else if (it->mType == ESM::AI_Escort) + { + ESM::AITarget data = it->mTarget; + package = new MWMechanics::AiEscort(data.mId.toString(), data.mDuration, data.mX, data.mY, data.mZ); + } + else if (it->mType == ESM::AI_Travel) + { + ESM::AITravel data = it->mTravel; + package = new MWMechanics::AiTravel(data.mX, data.mY, data.mZ); + } + else if (it->mType == ESM::AI_Activate) + { + ESM::AIActivate data = it->mActivate; + package = new MWMechanics::AiActivate(data.mName.toString()); + } + else //if (it->mType == ESM::AI_Follow) + { + ESM::AITarget data = it->mTarget; + package = new MWMechanics::AiFollow(data.mId.toString(), data.mDuration, data.mX, data.mY, data.mZ); + } + mPackages.push_back(package); + } +} diff --git a/apps/openmw/mwmechanics/aisequence.hpp b/apps/openmw/mwmechanics/aisequence.hpp index b9ec9d6151..9f70daeb83 100644 --- a/apps/openmw/mwmechanics/aisequence.hpp +++ b/apps/openmw/mwmechanics/aisequence.hpp @@ -3,6 +3,8 @@ #include +#include + namespace MWWorld { class Ptr; @@ -48,6 +50,8 @@ namespace MWMechanics void queue (const AiPackage& package); ///< Add \a package to the end of the sequence (executed after all other packages have been /// completed) + + void fill (const ESM::AIPackageList& list); }; } diff --git a/apps/openmw/mwmechanics/aitravel.cpp b/apps/openmw/mwmechanics/aitravel.cpp index 90365c16b6..6b43a36f69 100644 --- a/apps/openmw/mwmechanics/aitravel.cpp +++ b/apps/openmw/mwmechanics/aitravel.cpp @@ -21,6 +21,8 @@ namespace MWMechanics { AiTravel::AiTravel(float x, float y, float z) : mX(x),mY(y),mZ(z),mPathFinder() + , cellX(std::numeric_limits::max()) + , cellY(std::numeric_limits::max()) { } diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 8f79262360..c4f32f5dce 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -24,6 +24,13 @@ namespace MWMechanics { AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector& idle, bool repeat): mDistance(distance), mDuration(duration), mTimeOfDay(timeOfDay), mIdle(idle), mRepeat(repeat) + , mCellX(std::numeric_limits::max()) + , mCellY(std::numeric_limits::max()) + , mXCell(0) + , mYCell(0) + , mX(0) + , mY(0) + , mZ(0) { for(unsigned short counter = 0; counter < mIdle.size(); counter++) { @@ -38,7 +45,6 @@ namespace MWMechanics if(mDuration == 0) mTimeOfDay = 0; - srand(time(NULL)); mStartTime = MWBase::Environment::get().getWorld()->getTimeStamp(); mPlayedIdle = 0; mPathgrid = NULL; @@ -182,13 +188,13 @@ namespace MWMechanics mPlayedIdle = 0; unsigned short idleRoll = 0; - for(unsigned int counter = 1; counter < mIdle.size(); counter++) + for(unsigned int counter = 0; counter < mIdle.size(); counter++) { unsigned short idleChance = mIdleChanceMultiplier * mIdle[counter]; unsigned short randSelect = (int)(rand() / ((double)RAND_MAX + 1) * int(100 / mIdleChanceMultiplier)); if(randSelect < idleChance && randSelect > idleRoll) { - mPlayedIdle = counter; + mPlayedIdle = counter+2; idleRoll = randSelect; } } @@ -203,7 +209,7 @@ namespace MWMechanics // Play idle animation and recreate vanilla (broken?) behavior of resetting start time of AIWander: MWWorld::TimeStamp currentTime = MWBase::Environment::get().getWorld()->getTimeStamp(); mStartTime = currentTime; - playIdle(actor, mPlayedIdle + 1); + playIdle(actor, mPlayedIdle); mChooseAction = false; mIdleNow = true; } @@ -211,7 +217,7 @@ namespace MWMechanics if(mIdleNow) { - if(!checkIdle(actor, mPlayedIdle + 1)) + if(!checkIdle(actor, mPlayedIdle)) { mPlayedIdle = 0; mIdleNow = false; diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 5bfdcf0a71..468e9641d1 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -501,9 +501,12 @@ bool CharacterController::updateNpcState() if(mAttackType != "shoot") { MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); - // NOTE: SwishL, SwishM, SwishS - large, medium, small. - // Based on weapon weight, speed, or attack strength? - sndMgr->playSound3D(mPtr, "SwishL", 1.0f, 1.0f); + if(complete < 0.5f) + sndMgr->playSound3D(mPtr, "SwishM", 1.0f, 0.8f); //Weak attack + else if(complete < 1.0f) + sndMgr->playSound3D(mPtr, "SwishM", 1.0f, 1.0f); //Medium attack + else + sndMgr->playSound3D(mPtr, "SwishM", 1.0f, 1.2f); //Strong attack } stats.setAttackStrength(complete); @@ -560,10 +563,18 @@ bool CharacterController::updateNpcState() weapSpeed, mAttackType+" follow start", mAttackType+" follow stop", 0.0f, 0); else + { + float str = stats.getAttackStrength(); + std::string start = mAttackType+((str < 0.5f) ? " small follow start" + : (str < 1.0f) ? " medium follow start" + : " large follow start"); + std::string stop = mAttackType+((str < 0.5f) ? " small follow stop" + : (str < 1.0f) ? " medium follow stop" + : " large follow stop"); mAnimation->play(mCurrentWeapon, Priority_Weapon, MWRender::Animation::Group_UpperBody, true, - weapSpeed, mAttackType+" large follow start", mAttackType+" large follow stop", - 0.0f, 0); + weapSpeed, start, stop, 0.0f, 0); + } mUpperBodyState = UpperCharState_FollowStartToFollowStop; } } @@ -699,7 +710,7 @@ void CharacterController::update(float duration, Movement &movement) if(movestate != CharState_None) clearAnimQueue(); - if(mAnimQueue.size() == 0) + if(mAnimQueue.empty()) idlestate = (inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle)); else if(mAnimQueue.size() > 1) { @@ -765,7 +776,7 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int else { count = std::max(count, 1); - if(mode != 0 || mAnimQueue.size() == 0) + if(mode != 0 || mAnimQueue.empty()) { clearAnimQueue(); mAnimQueue.push_back(std::make_pair(groupname, count-1)); @@ -801,7 +812,7 @@ bool CharacterController::isAnimPlaying(const std::string &groupName) void CharacterController::clearAnimQueue() { - if(mAnimQueue.size() > 0) + if(!mAnimQueue.empty()) mAnimation->disable(mAnimQueue.front().first); mAnimQueue.clear(); } diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 5b4621905d..93fe495c94 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -13,7 +13,7 @@ namespace MWMechanics : mLevel (0), mLevelHealthBonus(0.f), mDead (false), mDied (false), mFriendlyHits (0), mTalkedTo (false), mAlarmed (false), mAttacked (false), mHostile (false), - mAttackingOrSpell(false) + mAttackingOrSpell(false), mAttackType(AT_Chop) { for (int i=0; i<4; ++i) mAiSettings[i] = 0; @@ -319,6 +319,16 @@ namespace MWMechanics return false; } + float CreatureStats::getEvasion() const + { + float evasion = (getAttribute(ESM::Attribute::Agility).getModified() / 5.0f) + + (getAttribute(ESM::Attribute::Luck).getModified() / 10.0f); + evasion *= getFatigueTerm(); + evasion += mMagicEffects.get(EffectKey(ESM::MagicEffect::Sanctuary)).mMagnitude; + + return evasion; + } + void CreatureStats::setLastHitObject(const std::string& objectid) { mLastHitObject = objectid; diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index fe46ed072a..4e18faf9a3 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -158,6 +158,8 @@ namespace MWMechanics bool getCreatureTargetted() const; + float getEvasion() const; + void setLastHitObject(const std::string &objectid); const std::string &getLastHitObject() const; }; diff --git a/apps/openmw/mwmechanics/enchanting.cpp b/apps/openmw/mwmechanics/enchanting.cpp index faa450df7a..e1b416efba 100644 --- a/apps/openmw/mwmechanics/enchanting.cpp +++ b/apps/openmw/mwmechanics/enchanting.cpp @@ -11,8 +11,10 @@ namespace MWMechanics { - Enchanting::Enchanting(): - mCastStyle(ESM::Enchantment::CastOnce) + Enchanting::Enchanting() + : mCastStyle(ESM::Enchantment::CastOnce) + , mSelfEnchanting(false) + , mOldItemCount(0) {} void Enchanting::setOldItem(MWWorld::Ptr oldItem) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 29880291d2..7aa347d6ef 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -416,7 +416,7 @@ namespace MWMechanics if (playerNpcStats.getFactionRanks().find(Misc::StringUtils::lowerCase(npcFaction)) != playerNpcStats.getFactionRanks().end()) { for(std::vector::const_iterator it = MWBase::Environment::get().getWorld()->getStore().get().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.begin(); - it != MWBase::Environment::get().getWorld()->getStore().get().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.end(); it++) + it != MWBase::Environment::get().getWorld()->getStore().get().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.end(); ++it) { if(Misc::StringUtils::lowerCase(it->mFaction) == Misc::StringUtils::lowerCase(npcFaction)) reaction = it->mReaction; } @@ -425,7 +425,7 @@ namespace MWMechanics else if (npcFaction != "") { for(std::vector::const_iterator it = MWBase::Environment::get().getWorld()->getStore().get().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.begin(); - it != MWBase::Environment::get().getWorld()->getStore().get().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.end();it++) + it != MWBase::Environment::get().getWorld()->getStore().get().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.end();++it) { if(playerNpcStats.getFactionRanks().find(Misc::StringUtils::lowerCase(it->mFaction)) != playerNpcStats.getFactionRanks().end() ) { diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index 986595a9af..da9d52e446 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -119,7 +119,7 @@ namespace boost::predecessor_map(&p[0]).distance_map(&d[0]).visitor(goalVisited(end))); } - catch(found_path fg) + catch(found_path& fg) { for(PointID v = end; ; v = p[v]) { diff --git a/apps/openmw/mwrender/actors.hpp b/apps/openmw/mwrender/actors.hpp index bba2d945c2..af58883983 100644 --- a/apps/openmw/mwrender/actors.hpp +++ b/apps/openmw/mwrender/actors.hpp @@ -31,6 +31,7 @@ namespace MWRender Actors(OEngine::Render::OgreRenderer& _rend, MWRender::RenderingManager* rendering) : mRend(_rend) , mRendering(rendering) + , mRootNode(NULL) {} ~Actors(); diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 843e5367e7..0bb7485723 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -74,7 +74,7 @@ Animation::~Animation() void Animation::setObjectRoot(Ogre::SceneNode *node, const std::string &model, bool baseonly) { - OgreAssert(mAnimSources.size() == 0, "Setting object root while animation sources are set!"); + OgreAssert(mAnimSources.empty(), "Setting object root while animation sources are set!"); if(!mInsert) mInsert = node->createChildSceneNode(); @@ -126,7 +126,7 @@ void Animation::setObjectRoot(Ogre::SceneNode *node, const std::string &model, b else { mSkelBase->attachObjectToBone(iter->second, iter->first); - iter++; + ++iter; } } } @@ -214,7 +214,7 @@ void Animation::addAnimSource(const std::string &model) std::vector > ctrls; Ogre::SharedPtr animsrc(OGRE_NEW AnimSource); NifOgre::Loader::createKfControllers(mSkelBase, kfname, animsrc->mTextKeys, ctrls); - if(animsrc->mTextKeys.size() == 0 || ctrls.size() == 0) + if(animsrc->mTextKeys.empty() || ctrls.empty()) return; mAnimSources.push_back(animsrc); @@ -497,7 +497,7 @@ bool Animation::reset(AnimState &state, const NifOgre::TextKeyMap &keys, const s void Animation::handleTextKey(AnimState &state, const std::string &groupname, const NifOgre::TextKeyMap::const_iterator &key) { - float time = key->first; + //float time = key->first; const std::string &evt = key->second; if(evt.compare(0, 7, "sound: ") == 0) @@ -550,7 +550,7 @@ void Animation::handleTextKey(AnimState &state, const std::string &groupname, co void Animation::play(const std::string &groupname, int priority, int groups, bool autodisable, float speedmult, const std::string &start, const std::string &stop, float startpoint, size_t loops) { - if(!mSkelBase || mAnimSources.size() == 0) + if(!mSkelBase || mAnimSources.empty()) return; if(groupname.empty()) @@ -567,7 +567,7 @@ void Animation::play(const std::string &groupname, int priority, int groups, boo if(stateiter->second.mPriority == priority) mStates.erase(stateiter++); else - stateiter++; + ++stateiter; } stateiter = mStates.find(groupname); @@ -642,7 +642,7 @@ void Animation::resetActiveGroups() AnimStateMap::const_iterator active = mStates.end(); AnimStateMap::const_iterator state = mStates.begin(); - for(;state != mStates.end();state++) + for(;state != mStates.end();++state) { if(!(state->second.mGroups&(1<setListenerPosDir(pos, dir, up); } - void Camera::update(float duration) + void Camera::update(float duration, bool paused) { updateListener(); + if (paused) + return; // only show the crosshair in game mode and in first person mode. MWBase::WindowManager *wm = MWBase::Environment::get().getWindowManager(); diff --git a/apps/openmw/mwrender/camera.hpp b/apps/openmw/mwrender/camera.hpp index cbfbd09197..dc552371e6 100644 --- a/apps/openmw/mwrender/camera.hpp +++ b/apps/openmw/mwrender/camera.hpp @@ -84,7 +84,7 @@ namespace MWRender void processViewChange(); - void update(float duration); + void update(float duration, bool paused=false); /// Set camera distance for current mode. Don't work on 1st person view. /// \param adjust Indicates should distance be adjusted or set. diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index 88d8704451..a4b0c0560c 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -22,7 +22,6 @@ namespace MWRender CharacterPreview::CharacterPreview(MWWorld::Ptr character, int sizeX, int sizeY, const std::string& name, Ogre::Vector3 position, Ogre::Vector3 lookAt) - : mSceneMgr (0) , mPosition(position) , mLookAt(lookAt) @@ -31,6 +30,10 @@ namespace MWRender , mName(name) , mSizeX(sizeX) , mSizeY(sizeY) + , mRenderTarget(NULL) + , mViewport(NULL) + , mCamera(NULL) + , mNode(NULL) { } diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 055faaa1f7..1ff99dda8c 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -22,6 +22,8 @@ namespace MWRender : mCacheDir(cacheDir) , mMinX(0), mMaxX(0) , mMinY(0), mMaxY(0) + , mWidth(0) + , mHeight(0) { } @@ -91,15 +93,13 @@ namespace MWRender Ogre::ColourValue mountainColour(0.05, 0.05, 0.05); Ogre::ColourValue hillColour(0.16, 0.12, 0.08); - float mountainHeight = 15000.f; - float hillHeight = 2500.f; - unsigned char r,g,b; if (land) { - float landHeight = land->mLandData->mHeights[vertexY * ESM::Land::LAND_SIZE + vertexX]; - + const float landHeight = land->mLandData->mHeights[vertexY * ESM::Land::LAND_SIZE + vertexX]; + const float mountainHeight = 15000.f; + const float hillHeight = 2500.f; if (landHeight >= 0) { diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index df95e9f472..e63a101602 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -286,7 +286,7 @@ void NpcAnimation::updateParts(bool forceupdate) { typedef std::multimap BodyPartMapType; static BodyPartMapType sBodyPartMap; - if(sBodyPartMap.size() == 0) + if(sBodyPartMap.empty()) { sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Neck, ESM::PRT_Neck)); sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Chest, ESM::PRT_Cuirass)); @@ -345,7 +345,7 @@ void NpcAnimation::updateParts(bool forceupdate) { if(!parts[bIt->second]) parts[bIt->second] = &*it; - bIt++; + ++bIt; } } continue; @@ -354,7 +354,7 @@ void NpcAnimation::updateParts(bool forceupdate) while(bIt != sBodyPartMap.end() && bIt->first == bodypart.mData.mPart) { parts[bIt->second] = &*it; - bIt++; + ++bIt; } } } diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 3456e1c16a..b92b17ba80 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -159,7 +159,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool } if(!mIsStatic || !Settings::Manager::getBool("use static geometry", "Objects") || - anyTransparency || objects.mParticles.size() > 0) + anyTransparency || !objects.mParticles.empty()) { for(size_t i = 0;i < objects.mEntities.size();i++) { @@ -233,7 +233,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool (*iter)->detachFromParent(); mRenderer.getScene()->destroyEntity(*iter); - iter++; + ++iter; } } diff --git a/apps/openmw/mwrender/objects.hpp b/apps/openmw/mwrender/objects.hpp index cfe5243061..d428aae96f 100644 --- a/apps/openmw/mwrender/objects.hpp +++ b/apps/openmw/mwrender/objects.hpp @@ -71,7 +71,12 @@ class Objects{ ///< Remove all movable objects from \a node. public: - Objects(OEngine::Render::OgreRenderer& renderer, MWWorld::Fallback* fallback): mRenderer (renderer), mIsStatic(false), mFallback(fallback) {} + Objects(OEngine::Render::OgreRenderer& renderer, MWWorld::Fallback* fallback) + : mRenderer (renderer) + , mIsStatic(false) + , mFallback(fallback) + , mRootNode(NULL) + {} ~Objects(){} void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_); void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool light=false); diff --git a/apps/openmw/mwrender/occlusionquery.cpp b/apps/openmw/mwrender/occlusionquery.cpp index 477e382154..a69511acd7 100644 --- a/apps/openmw/mwrender/occlusionquery.cpp +++ b/apps/openmw/mwrender/occlusionquery.cpp @@ -32,7 +32,7 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod mSupported = (mSunTotalAreaQuery != 0) && (mSunVisibleAreaQuery != 0); } - catch (Ogre::Exception e) + catch (Ogre::Exception& e) { mSupported = false; } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 2f48a0ce91..65fe5014cf 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -351,11 +351,11 @@ void RenderingManager::update (float duration, bool paused) applyFog(world->isUnderwater(player.getCell(), cam)); + mCamera->update(duration, paused); + if(paused) return; - mCamera->update(duration); - mActors.update (duration); mObjects.update (duration); diff --git a/apps/openmw/mwrender/videoplayer.cpp b/apps/openmw/mwrender/videoplayer.cpp index bc9bef5311..8c557ee998 100644 --- a/apps/openmw/mwrender/videoplayer.cpp +++ b/apps/openmw/mwrender/videoplayer.cpp @@ -1042,6 +1042,8 @@ VideoPlayer::VideoPlayer(Ogre::SceneManager* sceneMgr, Ogre::RenderWindow* windo , mNode(NULL) , mAllowSkipping(false) , mWindow(window) + , mWidth(0) + , mHeight(0) { mVideoMaterial = Ogre::MaterialManager::getSingleton().getByName("VideoMaterial", "General"); if (mVideoMaterial.isNull ()) diff --git a/apps/openmw/mwrender/water.hpp b/apps/openmw/mwrender/water.hpp index a21d03ad6a..bc15b4980a 100644 --- a/apps/openmw/mwrender/water.hpp +++ b/apps/openmw/mwrender/water.hpp @@ -43,6 +43,8 @@ namespace MWRender { Reflection(Ogre::SceneManager* sceneManager) : mSceneMgr(sceneManager) , mIsUnderwater(false) + , mCamera(NULL) + , mParentCamera(NULL) {} virtual ~Reflection() {} diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index bba5cb4ade..b8fc9ed477 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -297,7 +297,7 @@ namespace MWScript std::map ranks = MWWorld::Class::get (player).getNpcStats (player).getFactionRanks(); - if (ranks.size()) + if (!ranks.empty()) { std::map::const_iterator it = ranks.begin(); diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 690b07331c..4ee754b35d 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -225,7 +225,7 @@ struct OpenAL_Output::StreamThread { if((*iter)->process() == false) iter = mStreams.erase(iter); else - iter++; + ++iter; } mMutex.unlock(); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); @@ -491,6 +491,7 @@ public: virtual void stop(); virtual bool isPlaying(); virtual double getTimeOffset(); + virtual double getLength(); virtual void update(); }; @@ -554,6 +555,17 @@ double OpenAL_Sound::getTimeOffset() return t; } +double OpenAL_Sound::getLength() +{ + ALint bufferSize, frequency, channels, bitsPerSample; + alGetBufferi(mBuffer, AL_SIZE, &bufferSize); + alGetBufferi(mBuffer, AL_FREQUENCY, &frequency); + alGetBufferi(mBuffer, AL_CHANNELS, &channels); + alGetBufferi(mBuffer, AL_BITS, &bitsPerSample); + + return (8.0*bufferSize)/(frequency*channels*bitsPerSample); +} + void OpenAL_Sound::updateAll(bool local) { alSourcef(mSource, AL_REFERENCE_DISTANCE, mMinDistance); @@ -797,7 +809,7 @@ ALuint OpenAL_Output::getBuffer(const std::string &fname) if(nameiter->second == oldbuf) mBufferCache.erase(nameiter++); else - nameiter++; + ++nameiter; } bufsize = 0; @@ -817,8 +829,7 @@ void OpenAL_Output::bufferFinished(ALuint buf) } } - -MWBase::SoundPtr OpenAL_Output::playSound(const std::string &fname, float vol, float basevol, float pitch, int flags) +MWBase::SoundPtr OpenAL_Output::playSound(const std::string &fname, float vol, float basevol, float pitch, int flags,float offset) { boost::shared_ptr sound; ALuint src=0, buf=0; @@ -843,8 +854,13 @@ MWBase::SoundPtr OpenAL_Output::playSound(const std::string &fname, float vol, f } sound->updateAll(true); + if(offset<0) + offset=0; + if(offset>1) + offset=1; alSourcei(src, AL_BUFFER, buf); + alSourcef(src, AL_SEC_OFFSET, sound->getLength()*offset/pitch); alSourcePlay(src); throwALerror(); @@ -852,7 +868,7 @@ MWBase::SoundPtr OpenAL_Output::playSound(const std::string &fname, float vol, f } MWBase::SoundPtr OpenAL_Output::playSound3D(const std::string &fname, const Ogre::Vector3 &pos, float vol, float basevol, float pitch, - float min, float max, int flags) + float min, float max, int flags, float offset) { boost::shared_ptr sound; ALuint src=0, buf=0; @@ -878,7 +894,14 @@ MWBase::SoundPtr OpenAL_Output::playSound3D(const std::string &fname, const Ogre sound->updateAll(false); + if(offset<0) + offset=0; + if(offset>1) + offset=1; + alSourcei(src, AL_BUFFER, buf); + alSourcef(src, AL_SEC_OFFSET, sound->getLength()*offset/pitch); + alSourcePlay(src); throwALerror(); @@ -951,9 +974,9 @@ void OpenAL_Output::pauseSounds(int types) if(sound && sound->mSource && (sound->getPlayType()&types)) sources.push_back(sound->mSource); } - iter++; + ++iter; } - if(sources.size() > 0) + if(!sources.empty()) { alSourcePausev(sources.size(), &sources[0]); throwALerror(); @@ -978,9 +1001,9 @@ void OpenAL_Output::resumeSounds(int types) if(sound && sound->mSource && (sound->getPlayType()&types)) sources.push_back(sound->mSource); } - iter++; + ++iter; } - if(sources.size() > 0) + if(!sources.empty()) { alSourcePlayv(sources.size(), &sources[0]); throwALerror(); diff --git a/apps/openmw/mwsound/openal_output.hpp b/apps/openmw/mwsound/openal_output.hpp index 02706b50ca..31edf73599 100644 --- a/apps/openmw/mwsound/openal_output.hpp +++ b/apps/openmw/mwsound/openal_output.hpp @@ -45,9 +45,11 @@ namespace MWSound virtual void init(const std::string &devname=""); virtual void deinit(); - virtual MWBase::SoundPtr playSound(const std::string &fname, float vol, float basevol, float pitch, int flags); + /// @param offset Value from [0,1] meaning from which fraction the sound the playback starts. + virtual MWBase::SoundPtr playSound(const std::string &fname, float vol, float basevol, float pitch, int flags, float offset); + /// @param offset Value from [0,1] meaning from which fraction the sound the playback starts. virtual MWBase::SoundPtr playSound3D(const std::string &fname, const Ogre::Vector3 &pos, - float vol, float basevol, float pitch, float min, float max, int flags); + float vol, float basevol, float pitch, float min, float max, int flags, float offset); virtual MWBase::SoundPtr streamSound(DecoderPtr decoder, float volume, float pitch, int flags); virtual void updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir, Environment env); diff --git a/apps/openmw/mwsound/sound.hpp b/apps/openmw/mwsound/sound.hpp index 8deaf26a64..670002a30f 100644 --- a/apps/openmw/mwsound/sound.hpp +++ b/apps/openmw/mwsound/sound.hpp @@ -22,6 +22,7 @@ namespace MWSound float mMinDistance; float mMaxDistance; int mFlags; + float mFadeOutTime; public: virtual void stop() = 0; @@ -29,7 +30,7 @@ namespace MWSound virtual double getTimeOffset() = 0; void setPosition(const Ogre::Vector3 &pos) { mPos = pos; } void setVolume(float volume) { mVolume = volume; } - + void setFadeout(float duration) { mFadeOutTime=duration; } MWBase::SoundManager::PlayType getPlayType() const { return (MWBase::SoundManager::PlayType)(mFlags&MWBase::SoundManager::Play_TypeMask); } @@ -42,6 +43,7 @@ namespace MWSound , mMinDistance(mindist) , mMaxDistance(maxdist) , mFlags(flags) + , mFadeOutTime(0) { } virtual ~Sound() { } diff --git a/apps/openmw/mwsound/sound_output.hpp b/apps/openmw/mwsound/sound_output.hpp index b5ccc946af..91e25db521 100644 --- a/apps/openmw/mwsound/sound_output.hpp +++ b/apps/openmw/mwsound/sound_output.hpp @@ -24,9 +24,11 @@ namespace MWSound virtual void init(const std::string &devname="") = 0; virtual void deinit() = 0; - virtual MWBase::SoundPtr playSound(const std::string &fname, float vol, float basevol, float pitch, int flags) = 0; + /// @param offset Value from [0,1] meaning from which fraction the sound the playback starts. + virtual MWBase::SoundPtr playSound(const std::string &fname, float vol, float basevol, float pitch, int flags, float offset) = 0; + /// @param offset Value from [0,1] meaning from which fraction the sound the playback starts. virtual MWBase::SoundPtr playSound3D(const std::string &fname, const Ogre::Vector3 &pos, - float vol, float basevol, float pitch, float min, float max, int flags) = 0; + float vol, float basevol, float pitch, float min, float max, int flags, float offset) = 0; virtual MWBase::SoundPtr streamSound(DecoderPtr decoder, float volume, float pitch, int flags) = 0; virtual void updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir, Environment env) = 0; diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 1e431d54a1..226b5ec3b2 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -53,6 +53,9 @@ namespace MWSound , mFootstepsVolume(1.0f) , mVoiceVolume(1.0f) , mPausedSoundTypes(0) + , mListenerPos(0,0,0) + , mListenerDir(1,0,0) + , mListenerUp(0,0,1) { if(!useSound) return; @@ -170,7 +173,7 @@ namespace MWSound { if(snditer->second.first == ptr && snditer->second.second == id) return snditer->first->isPlaying(); - snditer++; + ++snditer; } return false; } @@ -252,7 +255,7 @@ namespace MWSound const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]); MWBase::SoundPtr sound = mOutput->playSound3D(filePath, objpos, 1.0f, basevol, 1.0f, - 20.0f, 12750.0f, Play_Normal|Play_TypeVoice); + 20.0f, 12750.0f, Play_Normal|Play_TypeVoice, 0); mActiveSounds[sound] = std::make_pair(ptr, std::string("_say_sound")); } catch(std::exception &e) @@ -270,7 +273,7 @@ namespace MWSound float basevol = volumeFromType(Play_TypeVoice); std::string filePath = "Sound/"+filename; - MWBase::SoundPtr sound = mOutput->playSound(filePath, 1.0f, basevol, 1.0f, Play_Normal|Play_TypeVoice); + MWBase::SoundPtr sound = mOutput->playSound(filePath, 1.0f, basevol, 1.0f, Play_Normal|Play_TypeVoice, 0); mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), std::string("_say_sound")); } catch(std::exception &e) @@ -295,7 +298,7 @@ namespace MWSound mActiveSounds.erase(snditer++); } else - snditer++; + ++snditer; } } @@ -317,7 +320,7 @@ namespace MWSound } - MWBase::SoundPtr SoundManager::playSound(const std::string& soundId, float volume, float pitch, PlayType type, PlayMode mode) + MWBase::SoundPtr SoundManager::playSound(const std::string& soundId, float volume, float pitch, PlayType type, PlayMode mode, float offset) { MWBase::SoundPtr sound; if(!mOutput->isInitialized()) @@ -328,7 +331,7 @@ namespace MWSound float min, max; std::string file = lookup(soundId, volume, min, max); - sound = mOutput->playSound(file, volume, basevol, pitch, mode|type); + sound = mOutput->playSound(file, volume, basevol, pitch, mode|type, offset); mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId); } catch(std::exception &e) @@ -339,7 +342,7 @@ namespace MWSound } MWBase::SoundPtr SoundManager::playSound3D(const MWWorld::Ptr &ptr, const std::string& soundId, - float volume, float pitch, PlayType type, PlayMode mode) + float volume, float pitch, PlayType type, PlayMode mode, float offset) { MWBase::SoundPtr sound; if(!mOutput->isInitialized()) @@ -350,10 +353,10 @@ namespace MWSound float basevol = volumeFromType(type); float min, max; std::string file = lookup(soundId, volume, min, max); - const ESM::Position &pos = ptr.getRefData().getPosition();; + const ESM::Position &pos = ptr.getRefData().getPosition(); const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]); - sound = mOutput->playSound3D(file, objpos, volume, basevol, pitch, min, max, mode|type); + sound = mOutput->playSound3D(file, objpos, volume, basevol, pitch, min, max, mode|type, offset); if((mode&Play_NoTrack)) mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId); else @@ -377,7 +380,7 @@ namespace MWSound mActiveSounds.erase(snditer++); } else - snditer++; + ++snditer; } } @@ -392,7 +395,7 @@ namespace MWSound mActiveSounds.erase(snditer++); } else - snditer++; + ++snditer; } } @@ -408,7 +411,7 @@ namespace MWSound mActiveSounds.erase(snditer++); } else - snditer++; + ++snditer; } } @@ -424,7 +427,21 @@ namespace MWSound mActiveSounds.erase(snditer++); } else - snditer++; + ++snditer; + } + } + + void SoundManager::fadeOutSound3D(const MWWorld::Ptr &ptr, + const std::string& soundId, float duration) + { + SoundMap::iterator snditer = mActiveSounds.begin(); + while(snditer != mActiveSounds.end()) + { + if(snditer->second.first == ptr && snditer->second.second == soundId) + { + snditer->first->setFadeout(duration); + } + snditer++; } } @@ -487,7 +504,7 @@ namespace MWSound while(soundIter != regn->mSoundList.end()) { total += (int)soundIter->mChance; - soundIter++; + ++soundIter; } if(total == 0) return; @@ -506,7 +523,7 @@ namespace MWSound } pos += soundIter->mChance; - soundIter++; + ++soundIter; } } @@ -517,6 +534,7 @@ namespace MWSound timePassed += duration; if(timePassed < (1.0f/30.0f)) return; + duration = timePassed; timePassed = 0.0f; // Make sure music is still playing @@ -539,6 +557,7 @@ namespace MWSound ); // Check if any sounds are finished playing, and trash them + // Lower volume on fading out sounds SoundMap::iterator snditer = mActiveSounds.begin(); while(snditer != mActiveSounds.end()) { @@ -553,8 +572,18 @@ namespace MWSound const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]); snditer->first->setPosition(objpos); } + //update fade out + if(snditer->first->mFadeOutTime>0) + { + float soundDuration=duration; + if(soundDuration>snditer->first->mFadeOutTime) + soundDuration=snditer->first->mFadeOutTime; + snditer->first->setVolume(snditer->first->mVolume + - soundDuration / snditer->first->mFadeOutTime * snditer->first->mVolume); + snditer->first->mFadeOutTime -= soundDuration; + } snditer->first->update(); - snditer++; + ++snditer; } } } @@ -581,7 +610,7 @@ namespace MWSound { snditer->first->mBaseVolume = volumeFromType(snditer->first->getPlayType()); snditer->first->update(); - snditer++; + ++snditer; } if(mMusic) { diff --git a/apps/openmw/mwsound/soundmanagerimp.hpp b/apps/openmw/mwsound/soundmanagerimp.hpp index 5fcab14e22..2450ba5c37 100644 --- a/apps/openmw/mwsound/soundmanagerimp.hpp +++ b/apps/openmw/mwsound/soundmanagerimp.hpp @@ -106,13 +106,15 @@ namespace MWSound virtual MWBase::SoundPtr playTrack(const DecoderPtr& decoder, PlayType type); ///< Play a 2D audio track, using a custom decoder - virtual MWBase::SoundPtr playSound(const std::string& soundId, float volume, float pitch, PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal); + virtual MWBase::SoundPtr playSound(const std::string& soundId, float volume, float pitch, PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal, float offset=0); ///< Play a sound, independently of 3D-position + ///< @param offset value from [0,1], when to start playback. 0 is beginning, 1 is end. virtual MWBase::SoundPtr playSound3D(const MWWorld::Ptr &reference, const std::string& soundId, float volume, float pitch, PlayType type=Play_TypeSfx, - PlayMode mode=Play_Normal); + PlayMode mode=Play_Normal, float offset=0); ///< Play a sound from an object + ///< @param offset value from [0,1], when to start playback. 0 is beginning, 1 is end. virtual void stopSound3D(const MWWorld::Ptr &reference, const std::string& soundId); ///< Stop the given object from playing the given sound, @@ -126,6 +128,12 @@ namespace MWSound virtual void stopSound(const std::string& soundId); ///< Stop a non-3d looping sound + virtual void fadeOutSound3D(const MWWorld::Ptr &reference, const std::string& soundId, float duration); + ///< Fade out given sound (that is already playing) of given object + ///< @param reference Reference to object, whose sound is faded out + ///< @param soundId ID of the sound to fade out. + ///< @param duration Time until volume reaches 0. + virtual bool getSoundPlaying(const MWWorld::Ptr &reference, const std::string& soundId) const; ///< Is the given sound currently playing on the given object? diff --git a/apps/openmw/mwworld/action.cpp b/apps/openmw/mwworld/action.cpp index a37d007271..0fe061e5ce 100644 --- a/apps/openmw/mwworld/action.cpp +++ b/apps/openmw/mwworld/action.cpp @@ -11,7 +11,7 @@ const MWWorld::Ptr& MWWorld::Action::getTarget() const return mTarget; } -MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSound), mTarget (target) +MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSound), mTarget (target), mSoundOffset(0) {} MWWorld::Action::~Action() {} @@ -21,14 +21,16 @@ void MWWorld::Action::execute (const Ptr& actor) if (!mSoundId.empty()) { if (mKeepSound && actor.getRefData().getHandle()=="player") - MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0, + MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Normal,mSoundOffset); else { bool local = mTarget.isEmpty() || !mTarget.isInCell(); // no usable target MWBase::Environment::get().getSoundManager()->playSound3D(local ? actor : mTarget, mSoundId, 1.0, 1.0, MWBase::SoundManager::Play_TypeSfx, - mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal); + mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal, + mSoundOffset); } } @@ -39,3 +41,8 @@ void MWWorld::Action::setSound (const std::string& id) { mSoundId = id; } + +void MWWorld::Action::setSoundOffset(float offset) +{ + mSoundOffset=offset; +} diff --git a/apps/openmw/mwworld/action.hpp b/apps/openmw/mwworld/action.hpp index d8e5d93bb2..3e0e8ad1bd 100644 --- a/apps/openmw/mwworld/action.hpp +++ b/apps/openmw/mwworld/action.hpp @@ -12,6 +12,7 @@ namespace MWWorld { std::string mSoundId; bool mKeepSound; + float mSoundOffset; Ptr mTarget; // not implemented @@ -34,6 +35,7 @@ namespace MWWorld void execute (const Ptr& actor); void setSound (const std::string& id); + void setSoundOffset(float offset); }; } diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index cb2e49ca08..3495bdc06f 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -44,39 +44,6 @@ void MWWorld::Cells::clear() mIdCacheIndex = 0; } -void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore) -{ - for (CellRefList::List::iterator iter ( - cellStore.mContainers.mList.begin()); - iter!=cellStore.mContainers.mList.end(); ++iter) - { - Ptr container (&*iter, &cellStore); - - Class::get (container).getContainerStore (container).fill ( - iter->mBase->mInventory, container.getCellRef().mOwner, mStore); - } - - for (CellRefList::List::iterator iter ( - cellStore.mCreatures.mList.begin()); - iter!=cellStore.mCreatures.mList.end(); ++iter) - { - Ptr container (&*iter, &cellStore); - - Class::get (container).getContainerStore (container).fill ( - iter->mBase->mInventory, Class::get(container).getId(container), mStore); - } - - for (CellRefList::List::iterator iter ( - cellStore.mNpcs.mList.begin()); - iter!=cellStore.mNpcs.mList.end(); ++iter) - { - Ptr container (&*iter, &cellStore); - - Class::get (container).getContainerStore (container).fill ( - iter->mBase->mInventory, Class::get(container).getId(container), mStore); - } -} - MWWorld::Ptr MWWorld::Cells::getPtrAndCache (const std::string& name, Ptr::CellStore& cellStore) { Ptr ptr = getPtr (name, cellStore); @@ -129,7 +96,6 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y) { // Multiple plugin support for landscape data is much easier than for references. The last plugin wins. result->second.load (mStore, mReader); - fillContainers (result->second); } return &result->second; @@ -150,7 +116,6 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getInterior (const std::string& name) if (result->second.mState!=Ptr::CellStore::State_Loaded) { result->second.load (mStore, mReader); - fillContainers (result->second); } return &result->second; @@ -168,7 +133,6 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, Ptr::CellStore& ce if (std::binary_search (cell.mIds.begin(), cell.mIds.end(), lowerCase)) { cell.load (mStore, mReader); - fillContainers (cell); } else return Ptr(); diff --git a/apps/openmw/mwworld/cells.hpp b/apps/openmw/mwworld/cells.hpp index 53c72bb754..6f9c649fb2 100644 --- a/apps/openmw/mwworld/cells.hpp +++ b/apps/openmw/mwworld/cells.hpp @@ -31,8 +31,6 @@ namespace MWWorld CellStore *getCellStore (const ESM::Cell *cell); - void fillContainers (CellStore& cellStore); - Ptr getPtrAndCache (const std::string& name, CellStore& cellStore); public: diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index baf4fea324..44915a7c5b 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -80,7 +80,7 @@ namespace MWWorld { assert (mCell); - if (mCell->mContextList.size() == 0) + if (mCell->mContextList.empty()) return; // this is a dynamically generated cell -> skipping. // Load references from all plugins that do something with this cell. @@ -113,7 +113,7 @@ namespace MWWorld { assert (mCell); - if (mCell->mContextList.size() == 0) + if (mCell->mContextList.empty()) return; // this is a dynamically generated cell -> skipping. // Load references from all plugins that do something with this cell. @@ -174,7 +174,7 @@ namespace MWWorld } // Load moved references, from separately tracked list. - for (ESM::CellRefTracker::const_iterator it = mCell->mLeasedRefs.begin(); it != mCell->mLeasedRefs.end(); it++) + for (ESM::CellRefTracker::const_iterator it = mCell->mLeasedRefs.begin(); it != mCell->mLeasedRefs.end(); ++it) { // Doesn't seem to work in one line... huh? Too sleepy to check... ESM::CellRef &ref = const_cast(*it); diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 123027c9c7..296008578e 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -79,18 +79,6 @@ namespace MWWorld throw std::runtime_error ("class does not have item health"); } - float Class::getEvasion(const Ptr& ptr) const - { - MWMechanics::CreatureStats &crstats = getCreatureStats(ptr); - const MWMechanics::MagicEffects &mageffects = crstats.getMagicEffects(); - float evasion = (crstats.getAttribute(ESM::Attribute::Agility).getModified() / 5.0f) + - (crstats.getAttribute(ESM::Attribute::Luck).getModified() / 10.0f); - evasion *= crstats.getFatigueTerm(); - evasion += mageffects.get(MWMechanics::EffectKey(ESM::MagicEffect::Sanctuary)).mMagnitude; - - return evasion; - } - void Class::hit(const Ptr& ptr, int type) const { throw std::runtime_error("class cannot hit"); @@ -244,11 +232,6 @@ namespace MWWorld return *iter->second; } - const Class& Class::get (const Ptr& ptr) - { - return get (ptr.getTypeName()); - } - bool Class::isPersistent(const Ptr &ptr) const { throw std::runtime_error ("class does not support persistence"); diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index bfeeaba9f5..2751a4130a 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -105,9 +105,6 @@ namespace MWWorld ///< Return item max health or throw an exception, if class does not have item health /// (default implementation: throw an exceoption) - virtual float getEvasion(const Ptr& ptr) const; - ///< Gets the chance the given object can evade an attack - virtual void hit(const Ptr& ptr, int type=-1) const; ///< Execute a melee hit, using the current weapon. This will check the relevant skills /// of the given attacker, and whoever is hit. @@ -230,7 +227,10 @@ namespace MWWorld static const Class& get (const std::string& key); ///< If there is no class for this \a key, an exception is thrown. - static const Class& get (const Ptr& ptr); + static const Class& get (const Ptr& ptr) + { + return get (ptr.getTypeName()); + } ///< If there is no class for this pointer, an exception is thrown. static void registerClass (const std::string& key, boost::shared_ptr instance); diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 6682f072a4..a9d57c128f 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -237,7 +237,7 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std:: } } - if (!candidates.size()) + if (candidates.empty()) return; std::string item = candidates[std::rand()%candidates.size()]; addInitialItem(item, owner, count, failChance, false); diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 9cf944656c..60fa8d82b4 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -118,7 +118,8 @@ namespace MWWorld newPosition = trace.endpos; physicActor->setOnGround(hit && getSlope(trace.planenormal) <= sMaxSlope); - physicActor->enableCollisions(wasCollisionMode); + if (wasCollisionMode) + physicActor->enableCollisions(true); if (hit) return newPosition+Ogre::Vector3(0,0,4); @@ -148,6 +149,7 @@ namespace MWWorld float remainingTime = time; bool isInterior = !ptr.getCell()->isExterior(); Ogre::Vector3 halfExtents = physicActor->getHalfExtents();// + Vector3(1,1,1); + bool wasCollisionMode = physicActor->getCollisionMode(); physicActor->enableCollisions(false); Ogre::Quaternion orient = Ogre::Quaternion(Ogre::Radian(ptr.getRefData().getPosition().rot[2]), Ogre::Vector3::UNIT_Z); Ogre::Vector3 velocity; @@ -228,7 +230,8 @@ namespace MWWorld } physicActor->setOnGround(onground); physicActor->setVerticalForce(!onground ? clippedVelocity.z - time*627.2f : 0.0f); - physicActor->enableCollisions(true); + if (wasCollisionMode) + physicActor->enableCollisions(true); return newPosition; } }; @@ -507,7 +510,7 @@ namespace MWWorld bool PhysicsSystem::toggleCollisionMode() { - for(std::map::iterator it = mEngine->mActorMap.begin(); it != mEngine->mActorMap.end();it++) + for(std::map::iterator it = mEngine->mActorMap.begin(); it != mEngine->mActorMap.end();++it) { if (it->first=="player") { diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 4d6f50ffd2..0d9399c616 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -123,6 +123,9 @@ namespace MWWorld MWWorld::Ptr ptr = getPlayer(); MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Sneak, sneak); + + // TODO show sneak indicator only when the player is not detected by any actor + MWBase::Environment::get().getWindowManager()->setSneakVisibility(sneak); } void Player::yaw(float yaw) diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index ebc7ef03f6..512883f1a3 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -74,7 +74,7 @@ void Store::load(ESM::ESMReader &esm, const std::string &id) // copy list into new cell cell->mContextList = oldcell->mContextList; // merge lists of leased references, use newer data in case of conflict - for (ESM::MovedCellRefTracker::const_iterator it = cell->mMovedRefs.begin(); it != cell->mMovedRefs.end(); it++) { + for (ESM::MovedCellRefTracker::const_iterator it = cell->mMovedRefs.begin(); it != cell->mMovedRefs.end(); ++it) { // remove reference from current leased ref tracker and add it to new cell ESM::MovedCellRefTracker::iterator itold = std::find(oldcell->mMovedRefs.begin(), oldcell->mMovedRefs.end(), it->mRefnum); if (itold != oldcell->mMovedRefs.end()) { diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 4ccd0e6892..8ee71474fc 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -49,7 +49,7 @@ namespace MWWorld SharedIterator operator++(int) { SharedIterator iter = *this; - mIter++; + ++mIter; return iter; } @@ -61,7 +61,7 @@ namespace MWWorld SharedIterator operator--(int) { SharedIterator iter = *this; - mIter--; + --mIter; return iter; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 33d4719c09..f396157a40 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -165,8 +165,9 @@ namespace MWWorld ToUTF8::Utf8Encoder* encoder, const std::map& fallbackMap, int mActivationDistanceOverride) : mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), mSky (true), mCells (mStore, mEsm), - mNumFacing(0), mActivationDistanceOverride (mActivationDistanceOverride), - mFallback(fallbackMap), mPlayIntro(0), mTeleportEnabled(true) + mActivationDistanceOverride (mActivationDistanceOverride), + mFallback(fallbackMap), mPlayIntro(0), mTeleportEnabled(true), + mFacedDistance(FLT_MAX) { mPhysics = new PhysicsSystem(renderer); mPhysEngine = mPhysics->getEngine(); @@ -235,7 +236,6 @@ namespace MWWorld // Rebuild player setupPlayer(); - const ESM::NPC* playerNpc = mStore.get().find("player"); MWWorld::Ptr player = mPlayer->getPlayer(); renderPlayer(); mRendering->resetCamera(); @@ -246,9 +246,6 @@ namespace MWWorld // make sure to do this so that local scripts from items that were in the players inventory are removed mLocalScripts.clear(); - MWWorld::Class::get(player).getContainerStore(player).fill(playerNpc->mInventory, "", mStore); - MWWorld::Class::get(player).getInventoryStore(player).autoEquip(player); - MWBase::Environment::get().getWindowManager()->updatePlayer(); ESM::Position pos; @@ -1117,7 +1114,7 @@ namespace MWWorld bool World::castRay (float x1, float y1, float z1, float x2, float y2, float z2) { - Ogre::Vector3 a(x1,y1,z1);std::cout << x1 << " " << x2; + Ogre::Vector3 a(x1,y1,z1); Ogre::Vector3 b(x2,y2,z2); return mPhysics->castRay(a,b,false,true); } @@ -1329,7 +1326,7 @@ namespace MWWorld ++it; } - if (results.size() == 0) + if (results.empty()) { mFacedHandle = ""; mFacedDistance = FLT_MAX; @@ -1717,8 +1714,6 @@ namespace MWWorld void World::getContainersOwnedBy (const MWWorld::Ptr& npc, std::vector& out) { - std::string refId = npc.getCellRef().mRefID; - const Scene::CellStoreCollection& collection = mWorldScene->getActiveCells(); for (Scene::CellStoreCollection::const_iterator cellIt = collection.begin(); cellIt != collection.end(); ++cellIt) { @@ -1764,14 +1759,7 @@ namespace MWWorld { OEngine::Physic::PhysicActor *physicActor = mPhysEngine->getCharacter(actor.getRefData().getHandle()); - if (enable) - { - physicActor->enableCollisionBody(); - } - else - { - physicActor->disableCollisionBody(); - } + physicActor->enableCollisions(enable); } bool World::findInteriorPosition(const std::string &name, ESM::Position &pos) diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 252248e406..6d8caad219 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -77,13 +77,6 @@ namespace MWWorld int mActivationDistanceOverride; std::string mFacedHandle; float mFacedDistance; - Ptr mFaced1; - Ptr mFaced2; - std::string mFaced1Name; - std::string mFaced2Name; - float mFaced1Distance; - float mFaced2Distance; - int mNumFacing; std::map mDoorStates; ///< only holds doors that are currently moving. 0 means closing, 1 opening diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 7d3df15908..8f07b9e503 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -130,7 +130,7 @@ public: { std::string normalizedPattern = normalize_path(pattern.begin(), pattern.end()); StringVectorPtr ptr = StringVectorPtr(new StringVector()); - for(index::const_iterator iter = mIndex.begin();iter != mIndex.end();iter++) + for(index::const_iterator iter = mIndex.begin();iter != mIndex.end();++iter) { if(Ogre::StringUtil::match(iter->first, normalizedPattern) || (recursive && Ogre::StringUtil::match(iter->first, "*/"+normalizedPattern))) @@ -169,7 +169,7 @@ public: } else { - for(index::const_iterator iter = mIndex.begin();iter != mIndex.end();iter++) + for(index::const_iterator iter = mIndex.begin();iter != mIndex.end();++iter) { if(Ogre::StringUtil::match(iter->first, normalizedPattern) || (recursive && Ogre::StringUtil::match(iter->first, "*/"+normalizedPattern))) @@ -249,7 +249,7 @@ public: std::string normalizedPattern = normalize_path(pattern.begin(), pattern.end()); const Bsa::BSAFile::FileList &filelist = arc.getList(); StringVectorPtr ptr = StringVectorPtr(new StringVector()); - for(Bsa::BSAFile::FileList::const_iterator iter = filelist.begin();iter != filelist.end();iter++) + for(Bsa::BSAFile::FileList::const_iterator iter = filelist.begin();iter != filelist.end();++iter) { std::string ent = normalize_path(iter->name, iter->name+std::strlen(iter->name)); if(Ogre::StringUtil::match(ent, normalizedPattern) || @@ -266,7 +266,7 @@ public: FileInfoListPtr ptr = FileInfoListPtr(new FileInfoList()); const Bsa::BSAFile::FileList &filelist = arc.getList(); - for(Bsa::BSAFile::FileList::const_iterator iter = filelist.begin();iter != filelist.end();iter++) + for(Bsa::BSAFile::FileList::const_iterator iter = filelist.begin();iter != filelist.end();++iter) { std::string ent = normalize_path(iter->name, iter->name+std::strlen(iter->name)); if(Ogre::StringUtil::match(ent, normalizedPattern) || diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 40462c4881..3d9ac0a93a 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -52,7 +52,7 @@ namespace Compiler Literals& literals, std::vector& code, bool allowExpression) : Parser (errorHandler, context), mLocals (locals), mLiterals (literals), mCode (code), mState (BeginState), mExprParser (errorHandler, context, locals, literals), - mAllowExpression (allowExpression) + mAllowExpression (allowExpression), mButtons(0), mType(0) {} bool LineParser::parseInt (int value, const TokenLoc& loc, Scanner& scanner) diff --git a/components/compiler/scanner.cpp b/components/compiler/scanner.cpp index 08791d0eae..816443c447 100644 --- a/components/compiler/scanner.cpp +++ b/components/compiler/scanner.cpp @@ -509,7 +509,7 @@ namespace Compiler Scanner::Scanner (ErrorHandler& errorHandler, std::istream& inputStream, const Extensions *extensions) : mErrorHandler (errorHandler), mStream (inputStream), mExtensions (extensions), - mPutback (Putback_None) + mPutback (Putback_None), mPutbackCode(0), mPutbackInteger(0), mPutbackFloat(0) { } diff --git a/components/esm/esmreader.cpp b/components/esm/esmreader.cpp index 0a4c1a3fee..51d86a2eeb 100644 --- a/components/esm/esmreader.cpp +++ b/components/esm/esmreader.cpp @@ -18,6 +18,9 @@ ESM_Context ESMReader::getContext() ESMReader::ESMReader() : mBuffer(50*1024) , mRecordFlags(0) + , mIdx(0) + , mGlobalReaderList(NULL) + , mEncoder(NULL) { } diff --git a/components/esm/loadland.cpp b/components/esm/loadland.cpp index 89b48c27d8..60c475040f 100644 --- a/components/esm/loadland.cpp +++ b/components/esm/loadland.cpp @@ -66,10 +66,11 @@ Land::Land() , mX(0) , mY(0) , mEsm(NULL) -// , hasData(false) , mDataTypes(0) , mDataLoaded(false) , mLandData(NULL) + , mPlugin(0) + , mHasData(false) { } diff --git a/components/esm/loadpgrd.cpp b/components/esm/loadpgrd.cpp index 56c2f8c74f..882addcb9d 100644 --- a/components/esm/loadpgrd.cpp +++ b/components/esm/loadpgrd.cpp @@ -56,14 +56,14 @@ void Pathgrid::load(ESMReader &esm) std::vector::const_iterator rawIt = rawConnections.begin(); int pointIndex = 0; mEdges.reserve(edgeCount); - for(PointList::const_iterator it = mPoints.begin(); it != mPoints.end(); it++, pointIndex++) + for(PointList::const_iterator it = mPoints.begin(); it != mPoints.end(); ++it, ++pointIndex) { unsigned char connectionNum = (*it).mConnectionNum; for (int i = 0; i < connectionNum; ++i) { Edge edge; edge.mV0 = pointIndex; edge.mV1 = *rawIt; - rawIt++; + ++rawIt; mEdges.push_back(edge); } } diff --git a/components/interpreter/defines.cpp b/components/interpreter/defines.cpp index 52f892b420..5774c96aec 100644 --- a/components/interpreter/defines.cpp +++ b/components/interpreter/defines.cpp @@ -7,7 +7,7 @@ namespace Interpreter{ - bool Check(const std::string str, const std::string escword, unsigned int* i, unsigned int* start){ + bool Check(const std::string& str, const std::string& escword, unsigned int* i, unsigned int* start){ bool retval = str.find(escword) == 0; if(retval){ (*i) += escword.length(); @@ -18,7 +18,7 @@ namespace Interpreter{ std::vector globals; - bool longerStr(const std::string a, const std::string b){ + bool longerStr(const std::string& a, const std::string& b){ return a.length() > b.length(); } diff --git a/components/interpreter/runtime.cpp b/components/interpreter/runtime.cpp index 8814ca7ffc..bb0dffb87f 100644 --- a/components/interpreter/runtime.cpp +++ b/components/interpreter/runtime.cpp @@ -7,7 +7,7 @@ namespace Interpreter { - Runtime::Runtime() : mContext (0), mCode (0), mPC (0) {} + Runtime::Runtime() : mContext (0), mCode (0), mPC (0), mCodeSize(0) {} int Runtime::getPC() const { diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index a1e2cd8d18..9c4fee7a09 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -75,12 +75,12 @@ btVector3 ManualBulletShapeLoader::getbtVector(Ogre::Vector3 const &v) void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) { - cShape = static_cast(resource); - resourceName = cShape->getName(); - cShape->mCollide = false; + mShape = static_cast(resource); + mResourceName = mShape->getName(); + mShape->mCollide = false; mBoundingBox = NULL; - cShape->mBoxTranslation = Ogre::Vector3(0,0,0); - cShape->mBoxRotation = Ogre::Quaternion::IDENTITY; + mShape->mBoxTranslation = Ogre::Vector3(0,0,0); + mShape->mBoxRotation = Ogre::Quaternion::IDENTITY; mHasShape = false; btTriangleMesh* mesh1 = new btTriangleMesh(); @@ -89,7 +89,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) // of the early stages of development. Right now we WANT to catch // every error as early and intrusively as possible, as it's most // likely a sign of incomplete code rather than faulty input. - Nif::NIFFile::ptr pnif (Nif::NIFFile::create (resourceName.substr(0, resourceName.length()-7))); + Nif::NIFFile::ptr pnif (Nif::NIFFile::create (mResourceName.substr(0, mResourceName.length()-7))); Nif::NIFFile & nif = *pnif.get (); if (nif.numRoots() < 1) { @@ -108,29 +108,29 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) return; } - cShape->mHasCollisionNode = hasRootCollisionNode(node); + mShape->mHasCollisionNode = hasRootCollisionNode(node); //do a first pass handleNode(mesh1, node,0,false,false,false); if(mBoundingBox != NULL) { - cShape->mCollisionShape = mBoundingBox; + mShape->mCollisionShape = mBoundingBox; delete mesh1; } - else if (mHasShape && cShape->mCollide) + else if (mHasShape && mShape->mCollide) { - cShape->mCollisionShape = new TriangleMeshShape(mesh1,true); + mShape->mCollisionShape = new TriangleMeshShape(mesh1,true); } else delete mesh1; //second pass which create a shape for raycasting. - resourceName = cShape->getName(); - cShape->mCollide = false; + mResourceName = mShape->getName(); + mShape->mCollide = false; mBoundingBox = NULL; - cShape->mBoxTranslation = Ogre::Vector3(0,0,0); - cShape->mBoxRotation = Ogre::Quaternion::IDENTITY; + mShape->mBoxTranslation = Ogre::Vector3(0,0,0); + mShape->mBoxRotation = Ogre::Quaternion::IDENTITY; mHasShape = false; btTriangleMesh* mesh2 = new btTriangleMesh(); @@ -139,12 +139,12 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) if(mBoundingBox != NULL) { - cShape->mRaycastingShape = mBoundingBox; + mShape->mRaycastingShape = mBoundingBox; delete mesh2; } else if (mHasShape) { - cShape->mRaycastingShape = new TriangleMeshShape(mesh2,true); + mShape->mRaycastingShape = new TriangleMeshShape(mesh2,true); } else delete mesh2; @@ -224,18 +224,18 @@ void ManualBulletShapeLoader::handleNode(btTriangleMesh* mesh, const Nif::Node * } } - if ( (isCollisionNode || (!cShape->mHasCollisionNode && !raycasting)) - && (!isMarker || (cShape->mHasCollisionNode && !raycasting))) + if ( (isCollisionNode || (!mShape->mHasCollisionNode && !raycasting)) + && (!isMarker || (mShape->mHasCollisionNode && !raycasting))) { if(node->hasBounds) { - cShape->mBoxTranslation = node->boundPos; - cShape->mBoxRotation = node->boundRot; + mShape->mBoxTranslation = node->boundPos; + mShape->mBoxRotation = node->boundRot; mBoundingBox = new btBoxShape(getbtVector(node->boundXYZ)); } else if(node->recType == Nif::RC_NiTriShape) { - cShape->mCollide = !(flags&0x800); + mShape->mCollide = !(flags&0x800); handleNiTriShape(mesh, static_cast(node), flags, node->getWorldTransform(), raycasting); } } diff --git a/components/nifbullet/bulletnifloader.hpp b/components/nifbullet/bulletnifloader.hpp index 7958f3b7cb..d1e8763053 100644 --- a/components/nifbullet/bulletnifloader.hpp +++ b/components/nifbullet/bulletnifloader.hpp @@ -50,7 +50,13 @@ namespace NifBullet class ManualBulletShapeLoader : public OEngine::Physic::BulletShapeLoader { public: - ManualBulletShapeLoader():resourceGroup("General"){} + ManualBulletShapeLoader() + : mShape(NULL) + , mBoundingBox(NULL) + , mHasShape(false) + { + } + virtual ~ManualBulletShapeLoader(); void warn(const std::string &msg) @@ -94,10 +100,9 @@ private: */ void handleNiTriShape(btTriangleMesh* mesh, const Nif::NiTriShape *shape, int flags, const Ogre::Matrix4 &transform, bool raycasting); - std::string resourceName; - std::string resourceGroup; + std::string mResourceName; - OEngine::Physic::BulletShape* cShape;//current shape + OEngine::Physic::BulletShape* mShape;//current shape btBoxShape *mBoundingBox; bool mHasShape; diff --git a/extern/oics/ICSControl.cpp b/extern/oics/ICSControl.cpp index d43733727f..934c661c93 100644 --- a/extern/oics/ICSControl.cpp +++ b/extern/oics/ICSControl.cpp @@ -30,7 +30,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace ICS { - Control::Control(const std::string name, bool autoChangeDirectionOnLimitsAfterStop, bool autoReverseToInitialValue + Control::Control(const std::string& name, bool autoChangeDirectionOnLimitsAfterStop, bool autoReverseToInitialValue , float initialValue, float stepSize, float stepsPerSeconds, bool axisBindable) : mName(name) , mValue(initialValue) diff --git a/extern/oics/ICSControl.h b/extern/oics/ICSControl.h index 73f1d5494b..7939c86b95 100644 --- a/extern/oics/ICSControl.h +++ b/extern/oics/ICSControl.h @@ -35,7 +35,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace ICS { - class DllExport Control + class DllExport Control { public: @@ -44,7 +44,7 @@ namespace ICS DECREASE = -1, STOP = 0, INCREASE = 1 }; - Control(const std::string name, bool autoChangeDirectionOnLimitsAfterStop = false, bool autoReverseToInitialValue = false, float initialValue = 0.5, float stepSize = 0.1, float stepsPerSeconds = 2.0, bool axisBindable = true); + Control(const std::string& name, bool autoChangeDirectionOnLimitsAfterStop = false, bool autoReverseToInitialValue = false, float initialValue = 0.5, float stepSize = 0.1, float stepsPerSeconds = 2.0, bool axisBindable = true); ~Control(); void setChangingDirection(ControlChangingDirection direction); @@ -104,4 +104,4 @@ namespace ICS } -#endif \ No newline at end of file +#endif diff --git a/extern/sdl4ogre/CMakeLists.txt b/extern/sdl4ogre/CMakeLists.txt index 5b31974e5f..fb0832f712 100644 --- a/extern/sdl4ogre/CMakeLists.txt +++ b/extern/sdl4ogre/CMakeLists.txt @@ -8,6 +8,10 @@ set(SDL4OGRE_SOURCE_FILES sdlwindowhelper.cpp ) +if (APPLE) + set(SDL4OGRE_SOURCE_FILES ${SDL4OGRE_SOURCE_FILES} osx_utils.mm) +endif () + set(SDL4OGRE_HEADER_FILES OISCompat.h cursormanager.hpp diff --git a/extern/sdl4ogre/osx_utils.h b/extern/sdl4ogre/osx_utils.h new file mode 100644 index 0000000000..48149827ab --- /dev/null +++ b/extern/sdl4ogre/osx_utils.h @@ -0,0 +1,12 @@ +#ifndef SDL4OGRE_OSX_UTILS_H +#define SDL4OGRE_OSX_UTILS_H + +#include + +namespace SFO { + +extern unsigned long WindowContentViewHandle(SDL_SysWMinfo &info); + +} + +#endif // SDL4OGRE_OSX_UTILS_H diff --git a/extern/sdl4ogre/osx_utils.mm b/extern/sdl4ogre/osx_utils.mm new file mode 100644 index 0000000000..4069959cbd --- /dev/null +++ b/extern/sdl4ogre/osx_utils.mm @@ -0,0 +1,15 @@ +#include "osx_utils.h" +#import + + +namespace SFO { + +unsigned long WindowContentViewHandle(SDL_SysWMinfo &info) +{ + NSWindow *window = info.info.cocoa.window; + NSView *view = [window contentView]; + + return (unsigned long)view; +} + +} diff --git a/extern/sdl4ogre/sdlcursormanager.hpp b/extern/sdl4ogre/sdlcursormanager.hpp index 3dae42f42f..8940220d41 100644 --- a/extern/sdl4ogre/sdlcursormanager.hpp +++ b/extern/sdl4ogre/sdlcursormanager.hpp @@ -31,7 +31,6 @@ namespace SFO typedef std::map CursorMap; CursorMap mCursorMap; - SDL_Cursor* mDebugCursor; std::string mCurrentCursor; bool mEnabled; bool mInitialized; diff --git a/extern/sdl4ogre/sdlinputwrapper.cpp b/extern/sdl4ogre/sdlinputwrapper.cpp index a30f10d6a3..a3e99c187f 100644 --- a/extern/sdl4ogre/sdlinputwrapper.cpp +++ b/extern/sdl4ogre/sdlinputwrapper.cpp @@ -19,11 +19,11 @@ namespace SFO mMouseZ(0), mMouseY(0), mMouseX(0), - mMouseInWindow(true), - mJoyListener(NULL), - mKeyboardListener(NULL), - mMouseListener(NULL), - mWindowListener(NULL) + mMouseInWindow(true), + mJoyListener(NULL), + mKeyboardListener(NULL), + mMouseListener(NULL), + mWindowListener(NULL) { _setupOISKeys(); } @@ -72,25 +72,25 @@ namespace SFO case SDL_TEXTINPUT: mKeyboardListener->textInput(evt.text); break; - case SDL_JOYAXISMOTION: - if (mJoyListener) - mJoyListener->axisMoved(evt.jaxis, evt.jaxis.axis); - break; - case SDL_JOYBUTTONDOWN: - if (mJoyListener) - mJoyListener->buttonPressed(evt.jbutton, evt.jbutton.button); - break; - case SDL_JOYBUTTONUP: - if (mJoyListener) - mJoyListener->buttonReleased(evt.jbutton, evt.jbutton.button); - break; - case SDL_JOYDEVICEADDED: - //SDL_JoystickOpen(evt.jdevice.which); - //std::cout << "Detected a new joystick: " << SDL_JoystickNameForIndex(evt.jdevice.which) << std::endl; - break; - case SDL_JOYDEVICEREMOVED: - //std::cout << "A joystick has been removed" << std::endl; - break; + case SDL_JOYAXISMOTION: + if (mJoyListener) + mJoyListener->axisMoved(evt.jaxis, evt.jaxis.axis); + break; + case SDL_JOYBUTTONDOWN: + if (mJoyListener) + mJoyListener->buttonPressed(evt.jbutton, evt.jbutton.button); + break; + case SDL_JOYBUTTONUP: + if (mJoyListener) + mJoyListener->buttonReleased(evt.jbutton, evt.jbutton.button); + break; + case SDL_JOYDEVICEADDED: + //SDL_JoystickOpen(evt.jdevice.which); + //std::cout << "Detected a new joystick: " << SDL_JoystickNameForIndex(evt.jdevice.which) << std::endl; + break; + case SDL_JOYDEVICEREMOVED: + //std::cout << "A joystick has been removed" << std::endl; + break; case SDL_WINDOWEVENT: handleWindowEvent(evt); break; @@ -115,61 +115,62 @@ namespace SFO SDL_SetWindowGrab(mSDLWindow, SDL_FALSE); SDL_SetRelativeMouseMode(SDL_FALSE); break; - case SDL_WINDOWEVENT_SIZE_CHANGED: - int w,h; - SDL_GetWindowSize(mSDLWindow, &w, &h); - // TODO: Fix Ogre to handle this more consistently -#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 - mOgreWindow->windowMovedOrResized(); + case SDL_WINDOWEVENT_SIZE_CHANGED: + int w,h; + SDL_GetWindowSize(mSDLWindow, &w, &h); + // TODO: Fix Ogre to handle this more consistently +#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX + mOgreWindow->resize(w, h); #else - mOgreWindow->resize(w, h); + mOgreWindow->windowMovedOrResized(); #endif - if (mWindowListener) - mWindowListener->windowResized(evt.window.data1, evt.window.data2); + if (mWindowListener) + mWindowListener->windowResized(evt.window.data1, evt.window.data2); + break; - case SDL_WINDOWEVENT_RESIZED: - // TODO: Fix Ogre to handle this more consistently - #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 - mOgreWindow->windowMovedOrResized(); - #else - mOgreWindow->resize(evt.window.data1, evt.window.data2); - #endif - if (mWindowListener) - mWindowListener->windowResized(evt.window.data1, evt.window.data2); - break; + case SDL_WINDOWEVENT_RESIZED: + // TODO: Fix Ogre to handle this more consistently +#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX + mOgreWindow->resize(evt.window.data1, evt.window.data2); +#else + mOgreWindow->windowMovedOrResized(); +#endif + if (mWindowListener) + mWindowListener->windowResized(evt.window.data1, evt.window.data2); + break; case SDL_WINDOWEVENT_FOCUS_GAINED: - if (mWindowListener) - mWindowListener->windowFocusChange(true); - break; + if (mWindowListener) + mWindowListener->windowFocusChange(true); + break; case SDL_WINDOWEVENT_FOCUS_LOST: - if (mWindowListener) - mWindowListener->windowFocusChange(false); - break; + if (mWindowListener) + mWindowListener->windowFocusChange(false); + break; case SDL_WINDOWEVENT_CLOSE: break; case SDL_WINDOWEVENT_SHOWN: mOgreWindow->setVisible(true); - if (mWindowListener) - mWindowListener->windowVisibilityChange(true); + if (mWindowListener) + mWindowListener->windowVisibilityChange(true); break; case SDL_WINDOWEVENT_HIDDEN: mOgreWindow->setVisible(false); - if (mWindowListener) - mWindowListener->windowVisibilityChange(false); + if (mWindowListener) + mWindowListener->windowVisibilityChange(false); break; } } - bool InputWrapper::isModifierHeld(SDL_Keymod mod) + bool InputWrapper::isModifierHeld(SDL_Keymod mod) { return SDL_GetModState() & mod; } - bool InputWrapper::isKeyDown(SDL_Scancode key) - { - return SDL_GetKeyboardState(NULL)[key]; - } + bool InputWrapper::isKeyDown(SDL_Scancode key) + { + return SDL_GetKeyboardState(NULL)[key]; + } /// \brief Moves the mouse to the specified point within the viewport void InputWrapper::warpMouse(int x, int y) diff --git a/extern/sdl4ogre/sdlwindowhelper.cpp b/extern/sdl4ogre/sdlwindowhelper.cpp index 14371c947d..f819043cfd 100644 --- a/extern/sdl4ogre/sdlwindowhelper.cpp +++ b/extern/sdl4ogre/sdlwindowhelper.cpp @@ -6,6 +6,10 @@ #include #include +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE +#include "osx_utils.h" +#endif + namespace SFO { @@ -17,7 +21,7 @@ SDLWindowHelper::SDLWindowHelper (SDL_Window* window, int w, int h, struct SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); - if (SDL_GetWindowWMInfo(mSDLWindow, &wmInfo) == -1) + if (SDL_GetWindowWMInfo(mSDLWindow, &wmInfo) == SDL_FALSE) throw std::runtime_error("Couldn't get WM Info!"); Ogre::String winHandle; diff --git a/files/mygui/openmw_hud.layout b/files/mygui/openmw_hud.layout index c69323fe56..16b9f2c205 100644 --- a/files/mygui/openmw_hud.layout +++ b/files/mygui/openmw_hud.layout @@ -65,6 +65,17 @@ + + + + + + + + + + + @@ -102,31 +113,50 @@ - + - + - + - + + + - - + + - + - - + + - + + + + - + + + + + + + + + + + + + + + + + diff --git a/files/openmw.cfg b/files/openmw.cfg index b37e5a22bd..15fde1bcb9 100644 --- a/files/openmw.cfg +++ b/files/openmw.cfg @@ -1,4 +1,4 @@ data="?global?data" data="?mw?Data Files" -data-local="?local?data" +data-local="?user?data" resources=${MORROWIND_RESOURCE_FILES} diff --git a/libs/openengine/bullet/BtOgre.cpp b/libs/openengine/bullet/BtOgre.cpp index f504651592..b0fa07fd60 100644 --- a/libs/openengine/bullet/BtOgre.cpp +++ b/libs/openengine/bullet/BtOgre.cpp @@ -293,7 +293,7 @@ namespace BtOgre { { const Ogre::Vector3 sz = getSize(); - assert((sz.x > 0.0) && (sz.y > 0.0) && (sz.y > 0.0) && + assert((sz.x > 0.0) && (sz.y > 0.0) && (sz.z > 0.0) && ("Size of box must be greater than zero on all axes")); btBoxShape* shape = new btBoxShape(Convert::toBullet(sz * 0.5)); @@ -308,7 +308,7 @@ namespace BtOgre { { const Ogre::Vector3 sz = getSize(); - assert((sz.x > 0.0) && (sz.y > 0.0) && (sz.y > 0.0) && + assert((sz.x > 0.0) && (sz.y > 0.0) && (sz.z > 0.0) && ("Size of Cylinder must be greater than zero on all axes")); btCylinderShape* shape = new btCylinderShapeX(Convert::toBullet(sz * 0.5)); diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 66ee077ee0..968d2fbe7d 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -45,8 +45,8 @@ namespace Physic void PhysicActor::enableCollisions(bool collision) { assert(mBody); - if(collision && !collisionMode) mBody->translate(btVector3(0,0,-1000)); - if(!collision && collisionMode) mBody->translate(btVector3(0,0,1000)); + if(collision && !collisionMode) enableCollisionBody(); + if(!collision && collisionMode) disableCollisionBody(); collisionMode = collision; } @@ -150,7 +150,7 @@ namespace Physic void PhysicActor::enableCollisionBody() { - mEngine->dynamicsWorld->addRigidBody(mBody); + mEngine->dynamicsWorld->addRigidBody(mBody,CollisionType_Actor,CollisionType_World|CollisionType_HeightMap); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -178,6 +178,7 @@ namespace Physic PhysicEngine::PhysicEngine(BulletShapeLoader* shapeLoader) : mDebugActive(0) + , mSceneMgr(NULL) { // Set up the collision configuration and dispatcher collisionConfiguration = new btDefaultCollisionConfiguration(); @@ -531,8 +532,10 @@ namespace Physic const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1) { const RigidBody* body = dynamic_cast(colObj0Wrap->m_collisionObject); - if (body) + if (body && !(colObj0Wrap->m_collisionObject->getBroadphaseHandle()->m_collisionFilterGroup + & CollisionType_Raycasting)) mResult.push_back(body->mName); + return 0.f; } #else @@ -540,7 +543,8 @@ namespace Physic const btCollisionObject* col1, int partId1, int index1) { const RigidBody* body = dynamic_cast(col0); - if (body) + if (body && !(col0->getBroadphaseHandle()->m_collisionFilterGroup + & CollisionType_Raycasting)) mResult.push_back(body->mName); return 0.f; } @@ -617,7 +621,6 @@ namespace Physic std::string name = ""; float d = -1; - float d1 = 10000.; btCollisionWorld::ClosestRayResultCallback resultCallback1(from, to); if(raycastingObjectOnly) resultCallback1.m_collisionFilterMask = CollisionType_Raycasting; @@ -630,8 +633,7 @@ namespace Physic if (resultCallback1.hasHit()) { name = static_cast(*resultCallback1.m_collisionObject).mName; - d1 = resultCallback1.m_closestHitFraction; - d = d1; + d = resultCallback1.m_closestHitFraction;; } return std::pair(name,d); diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index baeb316785..a1d4816d3b 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -129,9 +129,10 @@ namespace Physic bool getOnGround() const; + private: void disableCollisionBody(); void enableCollisionBody(); - +public: //HACK: in Visual Studio 2010 and presumably above, this structures alignment // must be 16, but the built in operator new & delete don't properly // perform this alignment. diff --git a/libs/openengine/gui/manager.cpp b/libs/openengine/gui/manager.cpp index 9fd57e2c15..91937d24bc 100644 --- a/libs/openengine/gui/manager.cpp +++ b/libs/openengine/gui/manager.cpp @@ -91,7 +91,11 @@ public: mRenderSystem(nullptr), mIsInitialise(false), mManualRender(false), - mCountBatch(0) + mCountBatch(0), + mVertexProgramNoTexture(NULL), + mFragmentProgramNoTexture(NULL), + mVertexProgramOneTexture(NULL), + mFragmentProgramOneTexture(NULL) { } diff --git a/libs/openengine/input/dispatch_map.hpp b/libs/openengine/input/dispatch_map.hpp deleted file mode 100644 index be13e7f018..0000000000 --- a/libs/openengine/input/dispatch_map.hpp +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef OENGINE_INPUT_DISPATCHMAP_H -#define OENGINE_INPUT_DISPATCHMAP_H - -#include -#include -#include - -namespace OEngine { -namespace Input { - -/** - DispatchMap is a simple connection system that connects incomming - signals with outgoing signals. - - The signals can be connected one-to-one, many-to-one, one-to-many - or many-to-many. - - The dispatch map is completely system agnostic. It is a pure data - structure and all signals are just integer indices. It does not - delegate any actions, but used together with Dispatcher it can be - used to build an event system. - */ -struct DispatchMap -{ - typedef std::set OutList; - typedef std::map InMap; - - typedef OutList::iterator Oit; - typedef InMap::iterator Iit; - - InMap map; - - void bind(int in, int out) - { - map[in].insert(out); - } - - void unbind(int in, int out) - { - Iit it = map.find(in); - if(it != map.end()) - { - it->second.erase(out); - - // If there are no more elements, then remove the entire list - if(it->second.empty()) - map.erase(it); - } - } - - /// Check if a given input is bound to anything - bool isBound(int in) const - { - return map.find(in) != map.end(); - } - - /** - Get the list of outputs bound to the given input. Only call this - on inputs that you know are bound to something. - - The returned set is only intended for immediate iteration. Do not - store references to it. - */ - const OutList &getList(int in) const - { - assert(isBound(in)); - InMap::const_iterator it = map.find(in); - assert(it != map.end()); - const OutList &out = it->second; - assert(!out.empty()); - return out; - } -}; -}} -#endif diff --git a/libs/openengine/input/dispatcher.hpp b/libs/openengine/input/dispatcher.hpp deleted file mode 100644 index a8d480d4b0..0000000000 --- a/libs/openengine/input/dispatcher.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef OENGINE_INPUT_DISPATCHER_H -#define OENGINE_INPUT_DISPATCHER_H - -#include -#include - -#include - -#include "dispatch_map.hpp" -#include "func_binder.hpp" - -namespace OEngine { -namespace Input { - -struct Dispatcher : Mangle::Input::Event -{ - DispatchMap map; - FuncBinder funcs; - - /** - Constructor. Takes the number of actions and passes it to - FuncBinder. - */ - Dispatcher(int actions) : funcs(actions) {} - - void bind(unsigned int action, int key) - { - assert(action < funcs.getSize()); - map.bind(key, action); - } - void unbind(unsigned int action, int key) - { - assert(action < funcs.getSize()); - map.unbind(key, action); - } - bool isBound(int key) const { return map.isBound(key); } - - /** - Instigate an event. It is translated through the dispatch map and - sent to the function bindings. - */ - typedef DispatchMap::OutList _O; - void event(Type type, int index, const void* p) - { - // No bindings, nothing happens - if(!isBound(index)) - return; - - // Get the mapped actions and execute them - const _O &list = map.getList(index); - _O::const_iterator it; - for(it = list.begin(); it != list.end(); it++) - { - //catch exceptions thrown in the input handlers so that pressing a key - //doesn't cause OpenMw to crash - try - { - funcs.call(*it, p); - } - catch(const std::exception& e) - { - std::cerr << "Exception in input handler: " << e.what() << std::endl; - } - catch(...) - { - std::cerr << "Unknown exception in input handler" << std::endl; - } - - } - } -}; - -// This helps us play nice with Mangle's EventPtr, but it should -// really be defined for all the classes in OEngine. - typedef boost::shared_ptr DispatcherPtr; - -}} -#endif diff --git a/libs/openengine/input/func_binder.hpp b/libs/openengine/input/func_binder.hpp deleted file mode 100644 index a815ba0ceb..0000000000 --- a/libs/openengine/input/func_binder.hpp +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef OENGINE_INPUT_FUNCBINDER_H -#define OENGINE_INPUT_FUNCBINDER_H - -#include -#include -#include -#include - -namespace OEngine { -namespace Input { - -/** - An Action defines the user defined action corresponding to a - binding. - - The first parameter is the action index that invoked this call. You - can assign the same function to multiple actions, and this can help - you keep track of which action was invoked. - - The second parameter is an optional user-defined parameter, - represented by a void pointer. In many cases it is practical to - point this to temporaries (stack values), so make sure not to store - permanent references to it unless you've planning for this on the - calling side as well. - */ -typedef boost::function Action; - -/** - The FuncBinder is a simple struct that binds user-defined indices - to functions. It is useful for binding eg. keyboard events to - specific actions in your program, but can potentially have many - other uses as well. - */ -class FuncBinder -{ - struct FuncBinding - { - std::string name; - Action action; - }; - - std::vector bindings; - -public: - /** - Constructor. Initialize the struct by telling it how many action - indices you intend to bind. - - The indices you use should be 0 <= i < number. - */ - FuncBinder(int number) : bindings(number) {} - - unsigned int getSize() { return bindings.size(); } - - /** - Bind an action to an index. - */ - void bind(int index, Action action, const std::string &name="") - { - assert(index >= 0 && index < (int)bindings.size()); - - FuncBinding &fb = bindings[index]; - fb.action = action; - fb.name = name; - } - - /** - Unbind an index, reverting a previous bind(). - */ - void unbind(int index) - { - assert(index >= 0 && index < (int)bindings.size()); - - bindings[index] = FuncBinding(); - } - - /** - Call a specific action. Takes an optional parameter that is - passed to the action. - */ - void call(int index, const void *p=NULL) const - { - assert(index >= 0 && index < (int)bindings.size()); - - const FuncBinding &fb = bindings[index]; - if(fb.action) fb.action(index, p); - } - - /// Check if a given index is bound to anything - bool isBound(int index) const - { - assert(index >= 0 && index < (int)bindings.size()); - - return !bindings[index].action.empty(); - } - - /// Return the name associated with an action (empty if not bound) - const std::string &getName(int index) const - { - assert(index >= 0 && index < (int)bindings.size()); - - return bindings[index].name; - } -}; -}} -#endif diff --git a/libs/openengine/input/poller.hpp b/libs/openengine/input/poller.hpp deleted file mode 100644 index c544aed529..0000000000 --- a/libs/openengine/input/poller.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef OENGINE_INPUT_POLLER_H -#define OENGINE_INPUT_POLLER_H - -#include "dispatch_map.hpp" -#include - -namespace OEngine { -namespace Input { - -/** The poller is used to check (poll) for keys rather than waiting - for events. */ -struct Poller -{ - DispatchMap map; - Mangle::Input::Driver &input; - - Poller(Mangle::Input::Driver &drv) - : input(drv) {} - - /** Bind or unbind a given action with a key. The action is the first - parameter, the key is the second. - */ - void bind(int in, int out) { map.bind(in, out); } - void unbind(int in, int out) { map.unbind(in, out); } - bool isBound(int in) const { return map.isBound(in); } - - /// Check whether a given action button is currently pressed. - typedef DispatchMap::OutList _O; - bool isDown(int index) const - { - // No bindings, no action - if(!isBound(index)) - return false; - - // Get all the keys bound to this action, and check them. - const _O &list = map.getList(index); - _O::const_iterator it; - for(it = list.begin(); it != list.end(); it++) - // If there's any match, we're good to go. - if(input.isDown(*it)) return true; - - return false; - } -}; -}} -#endif diff --git a/libs/openengine/input/tests/Makefile b/libs/openengine/input/tests/Makefile deleted file mode 100644 index 91a0b26636..0000000000 --- a/libs/openengine/input/tests/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -GCC=g++ - -all: funcbind_test dispatch_map_test sdl_driver_test sdl_binder_test - -funcbind_test: funcbind_test.cpp ../func_binder.hpp - $(GCC) $< -o $@ - -dispatch_map_test: dispatch_map_test.cpp ../dispatch_map.hpp - $(GCC) $< -o $@ - -sdl_driver_test: sdl_driver_test.cpp - $(GCC) $< ../../mangle/input/servers/sdl_driver.cpp -o $@ -I/usr/include/SDL/ -lSDL -I../../ - -sdl_binder_test: sdl_binder_test.cpp - $(GCC) $< ../../mangle/input/servers/sdl_driver.cpp -o $@ -I/usr/include/SDL/ -lSDL -I../../ - -clean: - rm *_test diff --git a/libs/openengine/input/tests/dispatch_map_test.cpp b/libs/openengine/input/tests/dispatch_map_test.cpp deleted file mode 100644 index 5f262494e5..0000000000 --- a/libs/openengine/input/tests/dispatch_map_test.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include -using namespace std; - -#include "../dispatch_map.hpp" - -using namespace OEngine::Input; - -typedef DispatchMap::OutList OutList; -typedef OutList::const_iterator Cit; - -void showList(const DispatchMap::OutList &out) -{ - for(Cit it = out.begin(); - it != out.end(); it++) - { - cout << " " << *it << endl; - } -} - -void showAll(DispatchMap &map) -{ - cout << "\nPrinting everything:\n"; - for(DispatchMap::Iit it = map.map.begin(); - it != map.map.end(); it++) - { - cout << it->first << ":\n"; - showList(map.getList(it->first)); - } -} - -int main() -{ - cout << "Testing the dispatch map\n"; - - DispatchMap dsp; - - dsp.bind(1,9); - dsp.bind(2,-5); - dsp.bind(2,9); - dsp.bind(3,10); - dsp.bind(3,12); - dsp.bind(3,10); - - showAll(dsp); - - dsp.unbind(1,9); - dsp.unbind(5,8); - dsp.unbind(3,11); - dsp.unbind(3,12); - dsp.unbind(3,12); - - showAll(dsp); - return 0; -} diff --git a/libs/openengine/input/tests/funcbind_test.cpp b/libs/openengine/input/tests/funcbind_test.cpp deleted file mode 100644 index bb4ad34e18..0000000000 --- a/libs/openengine/input/tests/funcbind_test.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include -using namespace std; - -#include "../func_binder.hpp" - -void f1(int i, const void *p) -{ - cout << " F1 i=" << i << endl; - - if(p) - cout << " Got a nice gift: " - << *((const float*)p) << endl; -} - -void f2(int i, const void *p) -{ - cout << " F2 i=" << i << endl; -} - -using namespace OEngine::Input; - -int main() -{ - cout << "This will test the function binding system\n"; - - FuncBinder bnd(5); - - bnd.bind(0, &f1, "This is action 1"); - bnd.bind(1, &f2); - bnd.bind(2, &f1, "This is action 3"); - bnd.bind(3, &f2, "This is action 4"); - - bnd.unbind(2); - - for(int i=0; i<5; i++) - { - cout << "Calling " << i << ": '" << bnd.getName(i) << "'\n"; - bnd.call(i); - if(!bnd.isBound(i)) cout << " (not bound)\n"; - } - - cout << "\nCalling with parameter:\n"; - float f = 3.1415; - bnd.call(0, &f); - - return 0; -} diff --git a/libs/openengine/input/tests/output/dispatch_map_test.out b/libs/openengine/input/tests/output/dispatch_map_test.out deleted file mode 100644 index 01aa9d9d93..0000000000 --- a/libs/openengine/input/tests/output/dispatch_map_test.out +++ /dev/null @@ -1,18 +0,0 @@ -Testing the dispatch map - -Printing everything: -1: - 9 -2: - -5 - 9 -3: - 10 - 12 - -Printing everything: -2: - -5 - 9 -3: - 10 diff --git a/libs/openengine/input/tests/output/funcbind_test.out b/libs/openengine/input/tests/output/funcbind_test.out deleted file mode 100644 index 862c5c9729..0000000000 --- a/libs/openengine/input/tests/output/funcbind_test.out +++ /dev/null @@ -1,15 +0,0 @@ -This will test the function binding system -Calling 0: 'This is action 1' - F1 i=0 -Calling 1: '' - F2 i=1 -Calling 2: '' - (not bound) -Calling 3: 'This is action 4' - F2 i=3 -Calling 4: '' - (not bound) - -Calling with parameter: - F1 i=0 - Got a nice gift: 3.1415 diff --git a/libs/openengine/input/tests/output/sdl_binder_test.out b/libs/openengine/input/tests/output/sdl_binder_test.out deleted file mode 100644 index fd4eb90e3e..0000000000 --- a/libs/openengine/input/tests/output/sdl_binder_test.out +++ /dev/null @@ -1,4 +0,0 @@ -Hold the Q key to quit: -You are running in script mode, aborting. Run this test with a parameter (any at all) to test the input loop properly - -Bye bye! diff --git a/libs/openengine/input/tests/output/sdl_driver_test.out b/libs/openengine/input/tests/output/sdl_driver_test.out deleted file mode 100644 index fd4eb90e3e..0000000000 --- a/libs/openengine/input/tests/output/sdl_driver_test.out +++ /dev/null @@ -1,4 +0,0 @@ -Hold the Q key to quit: -You are running in script mode, aborting. Run this test with a parameter (any at all) to test the input loop properly - -Bye bye! diff --git a/libs/openengine/input/tests/sdl_binder_test.cpp b/libs/openengine/input/tests/sdl_binder_test.cpp deleted file mode 100644 index 7de5f5d4fd..0000000000 --- a/libs/openengine/input/tests/sdl_binder_test.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include -#include -#include "../dispatcher.hpp" -#include "../poller.hpp" - -using namespace std; -using namespace Mangle::Input; -using namespace OEngine::Input; - -enum Actions - { - A_Quit, - A_Left, - A_Right, - - A_LAST - }; - -bool quit=false; - -void doExit(int,const void*) -{ - quit = true; -} - -void goLeft(int,const void*) -{ - cout << "Going left\n"; -} - -int main(int argc, char** argv) -{ - SDL_Init(SDL_INIT_VIDEO); - SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE); - SDLDriver input; - Dispatcher *disp = new Dispatcher(A_LAST); - Poller poll(input); - - input.setEvent(EventPtr(disp)); - - disp->funcs.bind(A_Quit, &doExit); - disp->funcs.bind(A_Left, &goLeft); - - disp->bind(A_Quit, SDLK_q); - disp->bind(A_Left, SDLK_a); - disp->bind(A_Left, SDLK_LEFT); - - poll.bind(A_Right, SDLK_d); - poll.bind(A_Right, SDLK_RIGHT); - - cout << "Hold the Q key to quit:\n"; - //input->setEvent(&mycb); - while(!quit) - { - input.capture(); - if(poll.isDown(A_Right)) - cout << "We're going right!\n"; - SDL_Delay(20); - - if(argc == 1) - { - cout << "You are running in script mode, aborting. Run this test with a parameter (any at all) to test the input loop properly\n"; - break; - } - } - cout << "\nBye bye!\n"; - - SDL_Quit(); - return 0; -} diff --git a/libs/openengine/input/tests/sdl_driver_test.cpp b/libs/openengine/input/tests/sdl_driver_test.cpp deleted file mode 100644 index 1771bcfe40..0000000000 --- a/libs/openengine/input/tests/sdl_driver_test.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#include - -using namespace std; -using namespace Mangle::Input; - -int main(int argc, char** argv) -{ - SDL_Init(SDL_INIT_VIDEO); - SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE); - SDLDriver input; - - cout << "Hold the Q key to quit:\n"; - //input->setEvent(&mycb); - while(!input.isDown(SDLK_q)) - { - input.capture(); - SDL_Delay(20); - - if(argc == 1) - { - cout << "You are running in script mode, aborting. Run this test with a parameter (any at all) to test the input loop properly\n"; - break; - } - } - cout << "\nBye bye!\n"; - - SDL_Quit(); - return 0; -} diff --git a/libs/openengine/input/tests/test.sh b/libs/openengine/input/tests/test.sh deleted file mode 100755 index 2d07708adc..0000000000 --- a/libs/openengine/input/tests/test.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -make || exit - -mkdir -p output - -PROGS=*_test - -for a in $PROGS; do - if [ -f "output/$a.out" ]; then - echo "Running $a:" - ./$a | diff output/$a.out - - else - echo "Creating $a.out" - ./$a > "output/$a.out" - git add "output/$a.out" - fi -done diff --git a/libs/openengine/ogre/osx_utils.h b/libs/openengine/ogre/osx_utils.h deleted file mode 100644 index f651db6046..0000000000 --- a/libs/openengine/ogre/osx_utils.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef OENGINE_OGRE_OSX_UTILS_H -#define OENGINE_OGRE_OSX_UTILS_H - -#include - -namespace OEngine { -namespace Render { - -extern unsigned long WindowContentViewHandle(SDL_SysWMinfo &info); - -} -} - -#endif diff --git a/libs/openengine/ogre/osx_utils.mm b/libs/openengine/ogre/osx_utils.mm deleted file mode 100644 index 7e56601461..0000000000 --- a/libs/openengine/ogre/osx_utils.mm +++ /dev/null @@ -1,16 +0,0 @@ -#include "osx_utils.h" - -#import - -namespace OEngine { -namespace Render { - -unsigned long WindowContentViewHandle(SDL_SysWMinfo &info) -{ - NSWindow *window = info.info.cocoa.window; - NSView *view = [window contentView]; - return (unsigned long)view; -} - -} -} diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index cda35b16c4..0834a2cd16 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -24,10 +24,6 @@ #include #include -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE -#include "osx_utils.h" -#endif - using namespace Ogre; using namespace OEngine::Render; @@ -108,12 +104,12 @@ void OgreRenderer::loadPlugins() void OgreRenderer::unloadPlugins() { std::vector::iterator ei; - for(ei = mEmitterFactories.begin();ei != mEmitterFactories.end();ei++) + for(ei = mEmitterFactories.begin();ei != mEmitterFactories.end();++ei) OGRE_DELETE (*ei); mEmitterFactories.clear(); std::vector::iterator ai; - for(ai = mAffectorFactories.begin();ai != mAffectorFactories.end();ai++) + for(ai = mAffectorFactories.begin();ai != mAffectorFactories.end();++ai) OGRE_DELETE (*ai); mAffectorFactories.clear(); diff --git a/readme.txt b/readme.txt index 67c02cc61e..b9f34c1d72 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ OpenMW: A reimplementation of The Elder Scrolls III: Morrowind OpenMW is an attempt at recreating the engine for the popular role-playing game Morrowind by Bethesda Softworks. You need to own and install the original game for OpenMW to work. -Version: 0.24.0 +Version: 0.25.0 License: GPL (see GPL3.txt for more information) Website: http://www.openmw.org @@ -94,6 +94,36 @@ Allowed options: CHANGELOG +0.25.0 + +Bug #411: Launcher crash on OS X < 10.8 +Bug #604: Terrible performance drop in the Census and Excise Office. +Bug #676: Start Scripts fail to load +Bug #677: OpenMW does not accept script names with - +Bug #766: Extra space in front of topic links +Bug #793: AIWander Isn't Being Passed The Repeat Parameter +Bug #795: Sound playing with drawn weapon and crossing cell-border +Bug #800: can't select weapon for enchantment +Bug #801: Player can move while over-encumbered +Bug #802: Dead Keys not working +Bug #808: mouse capture +Bug #809: ini Importer does not work without an existing cfg file +Bug #812: Launcher will run OpenMW with no ESM or ESP selected +Bug #813: OpenMW defaults to Morrowind.ESM with no ESM or ESP selected +Bug #817: Dead NPCs and Creatures still have collision boxes +Bug #820: Incorrect sorting of answers (Dialogue) +Bug #826: mwinimport dumps core when given an unknown parameter +Bug #833: getting stuck in door +Bug #835: Journals/books not showing up properly. +Feature #38: SoundGen +Feature #105: AI Package: Wander +Feature #230: 64-bit compatibility for OS X +Feature #263: Hardware mouse cursors +Feature #449: Allow mouse outside of window while paused +Feature #736: First person animations +Feature #750: Using mouse wheel in third person mode +Feature #822: Autorepeat for slider buttons + 0.24.0 Bug #284: Book's text misalignment