Fix some static analysis issues (coverity)

moveref
scrawl 10 years ago
parent 1b9209df4a
commit f931ba2efc

@ -150,34 +150,33 @@ int extractAll(Bsa::BSAFile& bsa, Arguments& info);
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
Arguments info;
if(!parseOptions (argc, argv, info))
return 1;
// Open file
Bsa::BSAFile bsa;
try try
{ {
Arguments info;
if(!parseOptions (argc, argv, info))
return 1;
// Open file
Bsa::BSAFile bsa;
bsa.open(info.filename); bsa.open(info.filename);
if (info.mode == "list")
return list(bsa, info);
else if (info.mode == "extract")
return extract(bsa, info);
else if (info.mode == "extractall")
return extractAll(bsa, info);
else
{
std::cout << "Unsupported mode. That is not supposed to happen." << std::endl;
return 1;
}
} }
catch(std::exception &e) catch (std::exception& e)
{ {
std::cout << "ERROR reading BSA archive '" << info.filename std::cerr << "ERROR reading BSA archive\nDetails:\n" << e.what() << std::endl;
<< "'\nDetails:\n" << e.what() << std::endl;
return 2; return 2;
} }
if (info.mode == "list")
return list(bsa, info);
else if (info.mode == "extract")
return extract(bsa, info);
else if (info.mode == "extractall")
return extractAll(bsa, info);
else
{
std::cout << "Unsupported mode. That is not supposed to happen." << std::endl;
return 1;
}
} }
int list(Bsa::BSAFile& bsa, Arguments& info) int list(Bsa::BSAFile& bsa, Arguments& info)
@ -189,9 +188,11 @@ int list(Bsa::BSAFile& bsa, Arguments& info)
if(info.longformat) if(info.longformat)
{ {
// Long format // Long format
std::ios::fmtflags f(std::cout.flags());
std::cout << std::setw(50) << std::left << files[i].name; std::cout << std::setw(50) << std::left << files[i].name;
std::cout << std::setw(8) << std::left << std::dec << files[i].fileSize; std::cout << std::setw(8) << std::left << std::dec << files[i].fileSize;
std::cout << "@ 0x" << std::hex << files[i].offset << std::endl; std::cout << "@ 0x" << std::hex << files[i].offset << std::endl;
std::cout.flags(f);
} }
else else
std::cout << files[i].name << std::endl; std::cout << files[i].name << std::endl;

@ -203,19 +203,27 @@ int comp(Arguments& info);
int main(int argc, char**argv) int main(int argc, char**argv)
{ {
Arguments info; try
if(!parseOptions (argc, argv, info)) {
return 1; Arguments info;
if(!parseOptions (argc, argv, info))
if (info.mode == "dump") return 1;
return load(info);
else if (info.mode == "clone") if (info.mode == "dump")
return clone(info); return load(info);
else if (info.mode == "comp") else if (info.mode == "clone")
return comp(info); return clone(info);
else else if (info.mode == "comp")
return comp(info);
else
{
std::cout << "Invalid or no mode specified, dying horribly. Have a nice day." << std::endl;
return 1;
}
}
catch (std::exception& e)
{ {
std::cout << "Invalid or no mode specified, dying horribly. Have a nice day." << std::endl; std::cerr << "ERROR: " << e.what() << std::endl;
return 1; return 1;
} }
@ -273,8 +281,10 @@ void printRaw(ESM::ESMReader &esm)
esm.getSubName(); esm.getSubName();
esm.skipHSub(); esm.skipHSub();
n = esm.retSubName(); n = esm.retSubName();
std::ios::fmtflags f(std::cout.flags());
std::cout << " " << n.toString() << " - " << esm.getSubSize() std::cout << " " << n.toString() << " - " << esm.getSubSize()
<< " bytes @ 0x" << std::hex << offs << "\n"; << " bytes @ 0x" << std::hex << offs << "\n";
std::cout.flags(f);
} }
} }
} }

@ -15,53 +15,61 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software"); try
SDL_SetMainReady();
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{ {
qDebug() << "SDL_Init failed: " << QString::fromStdString(SDL_GetError()); SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
return 0; SDL_SetMainReady();
} if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
qDebug() << "SDL_Init failed: " << QString::fromStdString(SDL_GetError());
return 0;
}
QApplication app(argc, argv); QApplication app(argc, argv);
// Now we make sure the current dir is set to application path // Now we make sure the current dir is set to application path
QDir dir(QCoreApplication::applicationDirPath()); QDir dir(QCoreApplication::applicationDirPath());
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
if (dir.dirName() == "MacOS") { if (dir.dirName() == "MacOS") {
dir.cdUp(); dir.cdUp();
dir.cdUp(); dir.cdUp();
dir.cdUp(); dir.cdUp();
} }
// force Qt to load only LOCAL plugins, don't touch system Qt installation // force Qt to load only LOCAL plugins, don't touch system Qt installation
QDir pluginsPath(QCoreApplication::applicationDirPath()); QDir pluginsPath(QCoreApplication::applicationDirPath());
pluginsPath.cdUp(); pluginsPath.cdUp();
pluginsPath.cd("Plugins"); pluginsPath.cd("Plugins");
QStringList libraryPaths; QStringList libraryPaths;
libraryPaths << pluginsPath.path() << QCoreApplication::applicationDirPath(); libraryPaths << pluginsPath.path() << QCoreApplication::applicationDirPath();
app.setLibraryPaths(libraryPaths); app.setLibraryPaths(libraryPaths);
#endif #endif
QDir::setCurrent(dir.absolutePath()); QDir::setCurrent(dir.absolutePath());
// Support non-latin characters // Support non-latin characters
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
Launcher::MainDialog mainWin; Launcher::MainDialog mainWin;
if (!mainWin.showFirstRunDialog()) if (!mainWin.showFirstRunDialog())
return 0; return 0;
// if (!mainWin.setup()) { // if (!mainWin.setup()) {
// return 0; // return 0;
// } // }
mainWin.show(); mainWin.show();
int returnValue = app.exec(); int returnValue = app.exec();
SDL_Quit(); SDL_Quit();
return returnValue; return returnValue;
}
catch (std::exception& e)
{
std::cerr << "ERROR: " << e.what() << std::endl;
return 0;
}
} }

@ -56,93 +56,87 @@ int wmain(int argc, wchar_t *wargv[]) {
char **argv = converter.get(); char **argv = converter.get();
boost::filesystem::path::imbue(boost::locale::generator().generate("")); boost::filesystem::path::imbue(boost::locale::generator().generate(""));
#endif #endif
bpo::options_description desc("Syntax: mwiniimporter <options> inifile configfile\nAllowed options");
bpo::positional_options_description p_desc;
desc.add_options()
("help,h", "produce help message")
("verbose,v", "verbose output")
("ini,i", bpo::value<std::string>(), "morrowind.ini file")
("cfg,c", bpo::value<std::string>(), "openmw.cfg file")
("output,o", bpo::value<std::string>()->default_value(""), "openmw.cfg file")
("game-files,g", "import esm and esp files")
("no-archives,A", "disable bsa archives import")
("encoding,e", bpo::value<std::string>()-> default_value("win1252"),
"Character encoding used in OpenMW game messages:\n"
"\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
"\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n"
"\n\twin1252 - Western European (Latin) alphabet, used by default")
;
p_desc.add("ini", 1).add("cfg", 1);
bpo::variables_map vm;
try try
{ {
bpo::options_description desc("Syntax: mwiniimporter <options> inifile configfile\nAllowed options");
bpo::positional_options_description p_desc;
desc.add_options()
("help,h", "produce help message")
("verbose,v", "verbose output")
("ini,i", bpo::value<std::string>(), "morrowind.ini file")
("cfg,c", bpo::value<std::string>(), "openmw.cfg file")
("output,o", bpo::value<std::string>()->default_value(""), "openmw.cfg file")
("game-files,g", "import esm and esp files")
("no-archives,A", "disable bsa archives import")
("encoding,e", bpo::value<std::string>()-> default_value("win1252"),
"Character encoding used in OpenMW game messages:\n"
"\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
"\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n"
"\n\twin1252 - Western European (Latin) alphabet, used by default")
;
p_desc.add("ini", 1).add("cfg", 1);
bpo::variables_map vm;
bpo::parsed_options parsed = bpo::command_line_parser(argc, argv) bpo::parsed_options parsed = bpo::command_line_parser(argc, argv)
.options(desc) .options(desc)
.positional(p_desc) .positional(p_desc)
.run(); .run();
bpo::store(parsed, vm); bpo::store(parsed, vm);
}
catch(boost::program_options::unknown_option & x)
{
std::cerr << "ERROR: " << x.what() << std::endl;
return false;
}
catch(boost::program_options::invalid_command_line_syntax & x)
{
std::cerr << "ERROR: " << x.what() << std::endl;
return false;
}
if(vm.count("help") || !vm.count("ini") || !vm.count("cfg")) {
std::cout << desc;
return 0;
}
bpo::notify(vm); if(vm.count("help") || !vm.count("ini") || !vm.count("cfg")) {
std::cout << desc;
return 0;
}
std::string iniFile = vm["ini"].as<std::string>(); bpo::notify(vm);
std::string cfgFile = vm["cfg"].as<std::string>();
// if no output is given, write back to cfg file std::string iniFile = vm["ini"].as<std::string>();
std::string outputFile(vm["output"].as<std::string>()); std::string cfgFile = vm["cfg"].as<std::string>();
if(vm["output"].defaulted()) {
outputFile = vm["cfg"].as<std::string>();
}
if(!boost::filesystem::exists(iniFile)) { // if no output is given, write back to cfg file
std::cerr << "ini file does not exist" << std::endl; std::string outputFile(vm["output"].as<std::string>());
return -3; if(vm["output"].defaulted()) {
} outputFile = vm["cfg"].as<std::string>();
if(!boost::filesystem::exists(cfgFile)) }
std::cerr << "cfg file does not exist" << std::endl;
MwIniImporter importer; if(!boost::filesystem::exists(iniFile)) {
importer.setVerbose(vm.count("verbose")); std::cerr << "ini file does not exist" << std::endl;
return -3;
}
if(!boost::filesystem::exists(cfgFile))
std::cerr << "cfg file does not exist" << std::endl;
// Font encoding settings MwIniImporter importer;
std::string encoding(vm["encoding"].as<std::string>()); importer.setVerbose(vm.count("verbose"));
importer.setInputEncoding(ToUTF8::calculateEncoding(encoding));
MwIniImporter::multistrmap ini = importer.loadIniFile(iniFile); // Font encoding settings
MwIniImporter::multistrmap cfg = importer.loadCfgFile(cfgFile); std::string encoding(vm["encoding"].as<std::string>());
importer.setInputEncoding(ToUTF8::calculateEncoding(encoding));
importer.merge(cfg, ini); MwIniImporter::multistrmap ini = importer.loadIniFile(iniFile);
importer.mergeFallback(cfg, ini); MwIniImporter::multistrmap cfg = importer.loadCfgFile(cfgFile);
if(vm.count("game-files")) { importer.merge(cfg, ini);
importer.importGameFiles(cfg, ini); importer.mergeFallback(cfg, ini);
}
if(!vm.count("no-archives")) { if(vm.count("game-files")) {
importer.importArchives(cfg, ini); importer.importGameFiles(cfg, ini);
} }
std::cout << "write to: " << outputFile << std::endl; if(!vm.count("no-archives")) {
bfs::ofstream file((bfs::path(outputFile))); importer.importArchives(cfg, ini);
importer.writeToFile(file, cfg); }
std::cout << "write to: " << outputFile << std::endl;
bfs::ofstream file((bfs::path(outputFile)));
importer.writeToFile(file, cfg);
}
catch (std::exception& e)
{
std::cerr << "ERROR: " << e.what() << std::endl;
}
return 0; return 0;
} }

@ -46,47 +46,55 @@ class Application : public QApplication
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
Q_INIT_RESOURCE (resources); try
{
Q_INIT_RESOURCE (resources);
qRegisterMetaType<std::string> ("std::string"); qRegisterMetaType<std::string> ("std::string");
qRegisterMetaType<CSMWorld::UniversalId> ("CSMWorld::UniversalId"); qRegisterMetaType<CSMWorld::UniversalId> ("CSMWorld::UniversalId");
OgreInit::OgreInit ogreInit; OgreInit::OgreInit ogreInit;
std::auto_ptr<sh::Factory> shinyFactory; std::auto_ptr<sh::Factory> shinyFactory;
Application application (argc, argv); Application application (argc, argv);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
QDir dir(QCoreApplication::applicationDirPath()); QDir dir(QCoreApplication::applicationDirPath());
if (dir.dirName() == "MacOS") { if (dir.dirName() == "MacOS") {
dir.cdUp(); dir.cdUp();
dir.cdUp(); dir.cdUp();
dir.cdUp(); dir.cdUp();
} }
QDir::setCurrent(dir.absolutePath()); QDir::setCurrent(dir.absolutePath());
// force Qt to load only LOCAL plugins, don't touch system Qt installation // force Qt to load only LOCAL plugins, don't touch system Qt installation
QDir pluginsPath(QCoreApplication::applicationDirPath()); QDir pluginsPath(QCoreApplication::applicationDirPath());
pluginsPath.cdUp(); pluginsPath.cdUp();
pluginsPath.cd("Plugins"); pluginsPath.cd("Plugins");
QStringList libraryPaths; QStringList libraryPaths;
libraryPaths << pluginsPath.path() << QCoreApplication::applicationDirPath(); libraryPaths << pluginsPath.path() << QCoreApplication::applicationDirPath();
application.setLibraryPaths(libraryPaths); application.setLibraryPaths(libraryPaths);
#endif #endif
application.setWindowIcon (QIcon (":./opencs.png")); application.setWindowIcon (QIcon (":./opencs.png"));
CS::Editor editor (ogreInit); CS::Editor editor (ogreInit);
if(!editor.makeIPCServer()) if(!editor.makeIPCServer())
{
editor.connectToIPCServer();
return 0;
}
shinyFactory = editor.setupGraphics();
return editor.run();
}
catch (std::exception& e)
{ {
editor.connectToIPCServer(); std::cerr << "ERROR: " << e.what() << std::endl;
return 0; return 0;
} }
shinyFactory = editor.setupGraphics();
return editor.run();
} }

@ -18,7 +18,7 @@
#include "adjusterwidget.hpp" #include "adjusterwidget.hpp"
CSVDoc::FileDialog::FileDialog(QWidget *parent) : CSVDoc::FileDialog::FileDialog(QWidget *parent) :
QDialog(parent), mSelector (0), mFileWidget (0), mAdjusterWidget (0), mDialogBuilt(false) QDialog(parent), mSelector (0), mFileWidget (0), mAdjusterWidget (0), mDialogBuilt(false), mAction(ContentAction_Undefined)
{ {
ui.setupUi (this); ui.setupUi (this);
resize(400, 400); resize(400, 400);

@ -61,7 +61,7 @@ bool CSVRender::Cell::addObjects (int start, int end)
CSVRender::Cell::Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager, CSVRender::Cell::Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager,
const std::string& id, boost::shared_ptr<CSVWorld::PhysicsSystem> physics, const Ogre::Vector3& origin) const std::string& id, boost::shared_ptr<CSVWorld::PhysicsSystem> physics, const Ogre::Vector3& origin)
: mData (data), mId (Misc::StringUtils::lowerCase (id)), mSceneMgr(sceneManager), mPhysics(physics) : mData (data), mId (Misc::StringUtils::lowerCase (id)), mSceneMgr(sceneManager), mPhysics(physics), mX(0), mY(0)
{ {
mCellNode = sceneManager->getRootSceneNode()->createChildSceneNode(); mCellNode = sceneManager->getRootSceneNode()->createChildSceneNode();
mCellNode->setPosition (origin); mCellNode->setPosition (origin);
@ -77,15 +77,14 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager,
int landIndex = land.searchId(mId); int landIndex = land.searchId(mId);
if (landIndex != -1) if (landIndex != -1)
{ {
mTerrain.reset(new Terrain::TerrainGrid(sceneManager, new TerrainStorage(mData), Element_Terrain, true,
Terrain::Align_XY));
const ESM::Land* esmLand = land.getRecord(mId).get().mLand.get(); const ESM::Land* esmLand = land.getRecord(mId).get().mLand.get();
mTerrain->loadCell(esmLand->mX,
esmLand->mY);
if(esmLand) if(esmLand)
{ {
mTerrain.reset(new Terrain::TerrainGrid(sceneManager, new TerrainStorage(mData), Element_Terrain, true,
Terrain::Align_XY));
mTerrain->loadCell(esmLand->mX,
esmLand->mY);
float verts = ESM::Land::LAND_SIZE; float verts = ESM::Land::LAND_SIZE;
float worldsize = ESM::Land::REAL_SIZE; float worldsize = ESM::Land::REAL_SIZE;
mX = esmLand->mX; mX = esmLand->mX;
@ -98,7 +97,8 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager,
CSVRender::Cell::~Cell() CSVRender::Cell::~Cell()
{ {
mPhysics->removeHeightField(mSceneMgr, mX, mY); if (mTerrain.get())
mPhysics->removeHeightField(mSceneMgr, mX, mY);
for (std::map<std::string, Object *>::iterator iter (mObjects.begin()); for (std::map<std::string, Object *>::iterator iter (mObjects.begin());
iter!=mObjects.end(); ++iter) iter!=mObjects.end(); ++iter)

@ -346,7 +346,7 @@ namespace CSVRender
//plane X, upvector Y, mOffset x : x-z plane, wheel closer/further //plane X, upvector Y, mOffset x : x-z plane, wheel closer/further
std::pair<Ogre::Vector3, Ogre::Vector3> MouseState::planeAxis() std::pair<Ogre::Vector3, Ogre::Vector3> MouseState::planeAxis()
{ {
bool screenCoord = true; const bool screenCoord = true;
Ogre::Vector3 dir = getCamera()->getDerivedDirection(); Ogre::Vector3 dir = getCamera()->getDerivedDirection();
QString wheelDir = "Closer/Further"; QString wheelDir = "Closer/Further";

@ -639,7 +639,8 @@ namespace
MyGUI::Vertex* vertices, RenderXform const & renderXform) : MyGUI::Vertex* vertices, RenderXform const & renderXform) :
mZ(Z), mOrigin (left, top), mZ(Z), mOrigin (left, top),
mFont (font), mVertices (vertices), mFont (font), mVertices (vertices),
mRenderXform (renderXform) mRenderXform (renderXform),
mC(0)
{ {
mVertexColourType = MyGUI::RenderManager::getInstance().getVertexFormat(); mVertexColourType = MyGUI::RenderManager::getInstance().getVertexFormat();
} }

@ -770,6 +770,7 @@ namespace MWGui
SelectSkillDialog::SelectSkillDialog() SelectSkillDialog::SelectSkillDialog()
: WindowModal("openmw_chargen_select_skill.layout") : WindowModal("openmw_chargen_select_skill.layout")
, mSkillId(ESM::Skill::Block)
{ {
// Centre dialog // Centre dialog
center(); center();

@ -60,7 +60,7 @@ void ItemView::layoutWidgets()
int rows = maxHeight/42; int rows = maxHeight/42;
rows = std::max(rows, 1); rows = std::max(rows, 1);
bool showScrollbar = std::ceil(dragArea->getChildCount()/float(rows)) > mScrollView->getWidth()/42; bool showScrollbar = int(std::ceil(dragArea->getChildCount()/float(rows))) > mScrollView->getWidth()/42;
if (showScrollbar) if (showScrollbar)
maxHeight -= 18; maxHeight -= 18;

@ -176,13 +176,16 @@ namespace MWGui
int screenHeight = viewSize.height; int screenHeight = viewSize.height;
mVideoBackground->setSize(screenWidth, screenHeight); mVideoBackground->setSize(screenWidth, screenHeight);
double imageaspect = static_cast<double>(mVideo->getVideoWidth())/mVideo->getVideoHeight(); if (mVideo->getVideoHeight() > 0)
{
double imageaspect = static_cast<double>(mVideo->getVideoWidth())/mVideo->getVideoHeight();
int leftPadding = std::max(0.0, (screenWidth - screenHeight * imageaspect) / 2); int leftPadding = std::max(0.0, (screenWidth - screenHeight * imageaspect) / 2);
int topPadding = std::max(0.0, (screenHeight - screenWidth / imageaspect) / 2); int topPadding = std::max(0.0, (screenHeight - screenWidth / imageaspect) / 2);
mVideo->setCoord(leftPadding, topPadding, mVideo->setCoord(leftPadding, topPadding,
screenWidth - leftPadding*2, screenHeight - topPadding*2); screenWidth - leftPadding*2, screenHeight - topPadding*2);
}
mVideo->setVisible(true); mVideo->setVisible(true);
} }

@ -304,7 +304,7 @@ namespace MWGui
mOkButton->setEnabled(pos != MyGUI::ITEM_NONE || mSaving); mOkButton->setEnabled(pos != MyGUI::ITEM_NONE || mSaving);
mDeleteButton->setEnabled(pos != MyGUI::ITEM_NONE); mDeleteButton->setEnabled(pos != MyGUI::ITEM_NONE);
if (pos == MyGUI::ITEM_NONE) if (pos == MyGUI::ITEM_NONE || !mCurrentCharacter)
{ {
mCurrentSlot = NULL; mCurrentSlot = NULL;
mInfoText->setCaption(""); mInfoText->setCaption("");

@ -26,6 +26,7 @@ namespace MWGui
Spell() Spell()
: mSelected(false) : mSelected(false)
, mActive(false) , mActive(false)
, mType(Type_Spell)
{ {
} }
}; };

@ -1691,13 +1691,16 @@ namespace MWGui
// Use black bars to correct aspect ratio // Use black bars to correct aspect ratio
mVideoBackground->setSize(screenWidth, screenHeight); mVideoBackground->setSize(screenWidth, screenHeight);
double imageaspect = static_cast<double>(mVideoWidget->getVideoWidth())/mVideoWidget->getVideoHeight(); if (mVideoWidget->getVideoHeight() > 0)
{
double imageaspect = static_cast<double>(mVideoWidget->getVideoWidth())/mVideoWidget->getVideoHeight();
int leftPadding = std::max(0.0, (screenWidth - screenHeight * imageaspect) / 2); int leftPadding = std::max(0.0, (screenWidth - screenHeight * imageaspect) / 2);
int topPadding = std::max(0.0, (screenHeight - screenWidth / imageaspect) / 2); int topPadding = std::max(0.0, (screenHeight - screenWidth / imageaspect) / 2);
mVideoWidget->setCoord(leftPadding, topPadding, mVideoWidget->setCoord(leftPadding, topPadding,
screenWidth - leftPadding*2, screenHeight - topPadding*2); screenWidth - leftPadding*2, screenHeight - topPadding*2);
}
} }
WindowModal* WindowManager::getCurrentModal() const WindowModal* WindowManager::getCurrentModal() const

@ -286,7 +286,8 @@ void MWMechanics::Alchemy::addPotion (const std::string& name)
if (!iter->isEmpty()) if (!iter->isEmpty())
newRecord.mData.mWeight += iter->get<ESM::Ingredient>()->mBase->mData.mWeight; newRecord.mData.mWeight += iter->get<ESM::Ingredient>()->mBase->mData.mWeight;
newRecord.mData.mWeight /= countIngredients(); if (countIngredients() > 0)
newRecord.mData.mWeight /= countIngredients();
newRecord.mData.mValue = mValue; newRecord.mData.mValue = mValue;
newRecord.mData.mAutoCalc = 0; newRecord.mData.mAutoCalc = 0;

@ -1644,7 +1644,7 @@ void CharacterController::update(float duration)
world->queueMovement(mPtr, Ogre::Vector3(0.0f)); world->queueMovement(mPtr, Ogre::Vector3(0.0f));
} }
if(mAnimation && !mSkipAnim) if(!mSkipAnim)
{ {
Ogre::Vector3 moved = mAnimation->runAnimation(duration); Ogre::Vector3 moved = mAnimation->runAnimation(duration);
if(duration > 0.0f) if(duration > 0.0f)
@ -1762,10 +1762,7 @@ bool CharacterController::kill()
playRandomDeath(); playRandomDeath();
if(mAnimation) mAnimation->disable(mCurrentIdle);
{
mAnimation->disable(mCurrentIdle);
}
mIdleState = CharState_None; mIdleState = CharState_None;
mCurrentIdle.clear(); mCurrentIdle.clear();

@ -687,12 +687,11 @@ namespace MWMechanics
// Failure sound // Failure sound
int school = 0; int school = 0;
for (std::vector<ESM::ENAMstruct>::const_iterator effectIt (enchantment->mEffects.mList.begin()); if (!enchantment->mEffects.mList.empty())
effectIt!=enchantment->mEffects.mList.end(); ++effectIt)
{ {
const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectIt->mEffectID); short effectId = enchantment->mEffects.mList.front().mEffectID;
const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectId);
school = magicEffect->mData.mSchool; school = magicEffect->mData.mSchool;
break;
} }
static const std::string schools[] = { static const std::string schools[] = {
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"

@ -330,7 +330,10 @@ namespace MWRender
void RaceSelectionPreview::updateCamera() void RaceSelectionPreview::updateCamera()
{ {
Ogre::Vector3 scale = mNode->getScale(); Ogre::Vector3 scale = mNode->getScale();
Ogre::Vector3 headOffset = mAnimation->getNode("Bip01 Head")->_getDerivedPosition(); Ogre::Node* headNode = mAnimation->getNode("Bip01 Head");
if (!headNode)
return;
Ogre::Vector3 headOffset = headNode->_getDerivedPosition();
headOffset = mNode->convertLocalToWorldPosition(headOffset); headOffset = mNode->convertLocalToWorldPosition(headOffset);
mCamera->setPosition(headOffset + mPosition * scale); mCamera->setPosition(headOffset + mPosition * scale);

@ -24,8 +24,9 @@
using namespace MWRender; using namespace MWRender;
using namespace Ogre; using namespace Ogre;
LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManager* rendering) : LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManager* rendering)
mInterior(false) : mInterior(false)
, mAngle(0.f)
{ {
mRendering = rend; mRendering = rend;
mRenderingManager = rendering; mRenderingManager = rendering;

@ -104,7 +104,7 @@ BillboardObject::BillboardObject( const String& textureName,
} }
BillboardObject::BillboardObject() BillboardObject::BillboardObject()
: mNode(NULL), mMaterial(NULL), mEntity(NULL) : mNode(NULL), mMaterial(NULL), mEntity(NULL), mVisibility(1.f)
{ {
} }
@ -186,6 +186,7 @@ Moon::Moon( const String& textureName,
SceneNode* rootNode, SceneNode* rootNode,
const std::string& material) const std::string& material)
: BillboardObject(textureName, initialSize, position, rootNode, material) : BillboardObject(textureName, initialSize, position, rootNode, material)
, mType(Type_Masser)
{ {
setVisibility(1.0); setVisibility(1.0);

@ -283,10 +283,13 @@ namespace MWWorld
return position; return position;
OEngine::Physic::PhysicActor *physicActor = engine->getCharacter(ptr.getRefData().getHandle()); OEngine::Physic::PhysicActor *physicActor = engine->getCharacter(ptr.getRefData().getHandle());
if (!physicActor)
return position;
// Reset per-frame data // Reset per-frame data
physicActor->setWalkingOnWater(false); physicActor->setWalkingOnWater(false);
/* Anything to collide with? */ /* Anything to collide with? */
if(!physicActor || !physicActor->getCollisionMode()) if(!physicActor->getCollisionMode())
{ {
return position + (Ogre::Quaternion(Ogre::Radian(refpos.rot[2]), Ogre::Vector3::NEGATIVE_UNIT_Z) * return position + (Ogre::Quaternion(Ogre::Radian(refpos.rot[2]), Ogre::Vector3::NEGATIVE_UNIT_Z) *
Ogre::Quaternion(Ogre::Radian(refpos.rot[0]), Ogre::Vector3::NEGATIVE_UNIT_X)) Ogre::Quaternion(Ogre::Radian(refpos.rot[0]), Ogre::Vector3::NEGATIVE_UNIT_X))

@ -630,9 +630,6 @@ namespace MWWorld
} }
const ESM::Cell *searchOrCreate(int x, int y) { const ESM::Cell *searchOrCreate(int x, int y) {
ESM::Cell cell;
cell.mData.mX = x, cell.mData.mY = y;
std::pair<int, int> key(x, y); std::pair<int, int> key(x, y);
DynamicExt::const_iterator it = mExt.find(key); DynamicExt::const_iterator it = mExt.find(key);
if (it != mExt.end()) { if (it != mExt.end()) {
@ -644,13 +641,15 @@ namespace MWWorld
return &dit->second; return &dit->second;
} }
ESM::Cell *newCell = new ESM::Cell; ESM::Cell newCell;
newCell->mData.mX = x; newCell.mData.mX = x;
newCell->mData.mY = y; newCell.mData.mY = y;
mExt[std::make_pair(x, y)] = *newCell; newCell.mData.mFlags = ESM::Cell::HasWater;
delete newCell; newCell.mAmbi.mAmbient = 0;
newCell.mAmbi.mSunlight = 0;
return &mExt[std::make_pair(x, y)]; newCell.mAmbi.mFog = 0;
newCell.mAmbi.mFogDensity = 0;
return &mExt.insert(std::make_pair(key, newCell)).first->second;
} }
const ESM::Cell *find(const std::string &id) const { const ESM::Cell *find(const std::string &id) const {
@ -853,6 +852,11 @@ namespace MWWorld
public: public:
Store<ESM::Pathgrid>()
: mCells(NULL)
{
}
void setCells(Store<ESM::Cell>& cells) void setCells(Store<ESM::Cell>& cells)
{ {
mCells = &cells; mCells = &cells;

@ -2554,7 +2554,7 @@ namespace MWWorld
if (!selectedSpell.empty()) if (!selectedSpell.empty())
{ {
const ESM::Spell* spell = getStore().get<ESM::Spell>().search(selectedSpell); const ESM::Spell* spell = getStore().get<ESM::Spell>().find(selectedSpell);
// Check mana // Check mana
MWMechanics::DynamicStat<float> magicka = stats.getMagicka(); MWMechanics::DynamicStat<float> magicka = stats.getMagicka();
@ -2641,7 +2641,7 @@ namespace MWWorld
if (!selectedSpell.empty()) if (!selectedSpell.empty())
{ {
const ESM::Spell* spell = getStore().get<ESM::Spell>().search(selectedSpell); const ESM::Spell* spell = getStore().get<ESM::Spell>().find(selectedSpell);
// A power can be used once per 24h // A power can be used once per 24h
if (spell->mData.mType == ESM::Spell::ST_Power) if (spell->mData.mType == ESM::Spell::ST_Power)

@ -177,7 +177,6 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex &index, int
return file->fileProperty(static_cast<const EsmFile::FileProperty>(column)); return file->fileProperty(static_cast<const EsmFile::FileProperty>(column));
return QVariant(); return QVariant();
break;
} }
case Qt::TextAlignmentRole: case Qt::TextAlignmentRole:
@ -193,8 +192,6 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex &index, int
default: default:
return Qt::AlignLeft + Qt::AlignVCenter; return Qt::AlignLeft + Qt::AlignVCenter;
} }
return QVariant();
break;
} }
case Qt::ToolTipRole: case Qt::ToolTipRole:
@ -203,7 +200,6 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex &index, int
return QVariant(); return QVariant();
return file->toolTip(); return file->toolTip();
break;
} }
case Qt::CheckStateRole: case Qt::CheckStateRole:
@ -212,8 +208,6 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex &index, int
return QVariant(); return QVariant();
return mCheckStates[file->filePath()]; return mCheckStates[file->filePath()];
break;
} }
case Qt::UserRole: case Qt::UserRole:
@ -229,7 +223,6 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex &index, int
case Qt::UserRole + 1: case Qt::UserRole + 1:
return isChecked(file->filePath()); return isChecked(file->filePath());
break;
} }
return QVariant(); return QVariant();
} }

@ -30,7 +30,7 @@ void ContentSelectorView::ComboBox::paintEvent(QPaintEvent *)
// draw the icon and text // draw the icon and text
if (!opt.editable && currentIndex() == -1) // <<< we adjust the text displayed when nothing is selected if (!opt.editable && currentIndex() == -1) // <<< we adjust the text displayed when nothing is selected
opt.currentText = mPlaceholderText; opt.currentText = mPlaceholderText;
painter.drawControl(QStyle::CE_ComboBoxLabel, opt); painter.drawControl(QStyle::CE_ComboBoxLabel, opt);
} }
void ContentSelectorView::ComboBox::setPlaceholderText(const QString &text) void ContentSelectorView::ComboBox::setPlaceholderText(const QString &text)

@ -242,6 +242,8 @@ bool Cell::getNextMVRF(ESMReader &esm, MovedCellRef &mref)
else else
{ {
id.mWorldspace = Misc::StringUtils::lowerCase (mName); id.mWorldspace = Misc::StringUtils::lowerCase (mName);
id.mIndex.mX = 0;
id.mIndex.mY = 0;
} }
return id; return id;

@ -928,6 +928,8 @@ class NIFObjectLoader
particledata = static_cast<const Nif::NiAutoNormalParticles*>(partnode)->data.getPtr(); particledata = static_cast<const Nif::NiAutoNormalParticles*>(partnode)->data.getPtr();
else if(partnode->recType == Nif::RC_NiRotatingParticles) else if(partnode->recType == Nif::RC_NiRotatingParticles)
particledata = static_cast<const Nif::NiRotatingParticles*>(partnode)->data.getPtr(); particledata = static_cast<const Nif::NiRotatingParticles*>(partnode)->data.getPtr();
else
throw std::runtime_error("Unexpected particle node type");
std::string fullname = name+"@index="+Ogre::StringConverter::toString(partnode->recIndex); std::string fullname = name+"@index="+Ogre::StringConverter::toString(partnode->recIndex);
if(partnode->name.length() > 0) if(partnode->name.length() > 0)

@ -319,7 +319,9 @@ void Utf8Encoder::copyFromArray2(const char*& chp, char* &out)
} }
} }
std::ios::fmtflags f(std::cout.flags());
std::cout << "Could not find glyph " << std::hex << (int)ch << " " << (int)ch2 << " " << (int)ch3 << std::endl; std::cout << "Could not find glyph " << std::hex << (int)ch << " " << (int)ch2 << " " << (int)ch3 << std::endl;
std::cout.flags(f);
*(out++) = ch; // Could not find glyph, just put whatever *(out++) = ch; // Could not find glyph, just put whatever
} }

@ -299,7 +299,7 @@ namespace ICS
{ {
if(it->second.find(axis) != it->second.end()) if(it->second.find(axis) != it->second.end())
{ {
mControlsJoystickPOVBinderMap[deviceId].find(index)->second.erase( it->second.find(axis) ); it->second.erase( it->second.find(axis) );
} }
} }
} }

@ -28,7 +28,9 @@ namespace SFO
mWantGrab(false), mWantGrab(false),
mWantRelative(false), mWantRelative(false),
mWantMouseVisible(false), mWantMouseVisible(false),
mAllowGrab(grab) mAllowGrab(grab),
mWarpX(0),
mWarpY(0)
{ {
_setupOISKeys(); _setupOISKeys();
} }
@ -117,7 +119,9 @@ namespace SFO
case SDL_CLIPBOARDUPDATE: case SDL_CLIPBOARDUPDATE:
break; // We don't need this event, clipboard is retrieved on demand break; // We don't need this event, clipboard is retrieved on demand
default: default:
std::ios::fmtflags f(std::cerr.flags());
std::cerr << "Unhandled SDL event of type 0x" << std::hex << evt.type << std::endl; std::cerr << "Unhandled SDL event of type 0x" << std::hex << evt.type << std::endl;
std::cerr.flags(f);
break; break;
} }
} }

Loading…
Cancel
Save