From 16a4df25d6128c98b96b355d58d7bb4070281af1 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 9 Jul 2018 21:51:38 +0400 Subject: [PATCH 1/3] Make void function to do not return value --- components/crashcatcher/crashcatcher.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/crashcatcher/crashcatcher.hpp b/components/crashcatcher/crashcatcher.hpp index e2390df9c..fd8f0d154 100644 --- a/components/crashcatcher/crashcatcher.hpp +++ b/components/crashcatcher/crashcatcher.hpp @@ -12,7 +12,9 @@ #if USE_CRASH_CATCHER extern void crashCatcherInstall(int argc, char **argv, const std::string &crashLogPath); #else -inline void crashCatcherInstall(int, char **, const std::string &crashLogPath) { return 0; } +inline void crashCatcherInstall(int, char **, const std::string &crashLogPath) +{ +} #endif #endif From 27a5da59baa005f8b645b97fbc138b4ea015aa1d Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Tue, 10 Jul 2018 10:05:13 +0400 Subject: [PATCH 2/3] Fix MSVC warnings C4456 --- apps/mwiniimporter/importer.cpp | 3 +-- apps/opencs/view/render/object.cpp | 4 ++-- apps/opencs/view/render/worldspacewidget.cpp | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index 6f5c2e2cd..4fbe97720 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -874,7 +874,6 @@ void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, co { std::vector> contentFiles; std::string baseGameFile("Game Files:GameFile"); - std::string gameFile(""); std::time_t defaultTime = 0; ToUTF8::Utf8Encoder encoder(mEncoding); @@ -890,7 +889,7 @@ void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, co multistrmap::const_iterator it = ini.begin(); for (int i=0; it != ini.end(); i++) { - gameFile = baseGameFile; + std::string gameFile = baseGameFile; gameFile.append(std::to_string(i)); it = ini.find(gameFile); diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index dae6467c5..204bf4c2f 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -372,10 +372,10 @@ osg::ref_ptr CSVRender::Object::makeRotateMarker (int axis) indices[j] -= VertexCount; } - size_t offset = i * IndicesPerSegment; + size_t elementOffset = i * IndicesPerSegment; for (size_t j = 0; j < IndicesPerSegment; ++j) { - primitives->setElement(offset++, indices[IndexPattern[j]]); + primitives->setElement(elementOffset++, indices[IndexPattern[j]]); } } diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 084fb87e6..5b825fab1 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -651,7 +651,6 @@ void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event) if (mDragMode == InteractionType_PrimaryEdit) { - EditMode& editMode = dynamic_cast (*mEditMode->getCurrent()); editMode.drag (event->pos(), mDragX, mDragY, mDragFactor); // note: terraintexturemode only uses pos } } From c921d1c7e91bd37048f33b491fadcaede007cf2c Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Tue, 10 Jul 2018 13:32:52 +0400 Subject: [PATCH 3/3] Refactor NifStream class (eliminate LNK4221 MSVC warning) --- components/nif/nifstream.cpp | 24 +++++++-- components/nif/nifstream.hpp | 99 ++++++++++++++++++++---------------- 2 files changed, 75 insertions(+), 48 deletions(-) diff --git a/components/nif/nifstream.cpp b/components/nif/nifstream.cpp index 08a7466fa..3811d05ee 100644 --- a/components/nif/nifstream.cpp +++ b/components/nif/nifstream.cpp @@ -4,10 +4,24 @@ namespace Nif { + osg::Quat NIFStream::getQuaternion() + { + float f[4]; + readLittleEndianBufferOfType<4, float,uint32_t>(inp, (float*)&f); + osg::Quat quat; + quat.w() = f[0]; + quat.x() = f[1]; + quat.y() = f[2]; + quat.z() = f[3]; + return quat; + } -//Private functions - - -//Public functions - + Transformation NIFStream::getTrafo() + { + Transformation t; + t.pos = getVector3(); + t.rotation = getMatrix3(); + t.scale = getFloat(); + return t; + } } diff --git a/components/nif/nifstream.hpp b/components/nif/nifstream.hpp index d00069be7..0fdf4b440 100644 --- a/components/nif/nifstream.hpp +++ b/components/nif/nifstream.hpp @@ -80,8 +80,8 @@ template type inline readLittleEndianType(File return val; } -class NIFStream { - +class NIFStream +{ /// Input stream Files::IStreamPtr inp; @@ -93,71 +93,71 @@ public: void skip(size_t size) { inp->ignore(size); } - char getChar() + char getChar() { - return readLittleEndianType(inp); + return readLittleEndianType(inp); } - short getShort() - { + + short getShort() + { return readLittleEndianType(inp); } - unsigned short getUShort() - { + + unsigned short getUShort() + { return readLittleEndianType(inp); } - int getInt() + + int getInt() { return readLittleEndianType(inp); } - unsigned int getUInt() - { + + unsigned int getUInt() + { return readLittleEndianType(inp); } - float getFloat() - { + + float getFloat() + { return readLittleEndianType(inp); } - osg::Vec2f getVector2() { + osg::Vec2f getVector2() + { osg::Vec2f vec; readLittleEndianBufferOfType<2,float,uint32_t>(inp, (float*)&vec._v[0]); return vec; } - osg::Vec3f getVector3() { + + osg::Vec3f getVector3() + { osg::Vec3f vec; readLittleEndianBufferOfType<3, float,uint32_t>(inp, (float*)&vec._v[0]); return vec; } - osg::Vec4f getVector4() { + + osg::Vec4f getVector4() + { osg::Vec4f vec; readLittleEndianBufferOfType<4, float,uint32_t>(inp, (float*)&vec._v[0]); return vec; } - Matrix3 getMatrix3() { + + Matrix3 getMatrix3() + { Matrix3 mat; readLittleEndianBufferOfType<9, float,uint32_t>(inp, (float*)&mat.mValues); return mat; } - osg::Quat getQuaternion() { - float f[4]; - readLittleEndianBufferOfType<4, float,uint32_t>(inp, (float*)&f); - osg::Quat quat; - quat.w() = f[0]; - quat.x() = f[1]; - quat.y() = f[2]; - quat.z() = f[3]; - return quat; - } - Transformation getTrafo() { - Transformation t; - t.pos = getVector3(); - t.rotation = getMatrix3(); - t.scale = getFloat(); - return t; - } + + osg::Quat getQuaternion(); + + Transformation getTrafo(); ///Read in a string of the given length - std::string getString(size_t length) { + std::string getString(size_t length) + { std::vector str(length + 1, 0); inp->read(&str[0], length); @@ -165,41 +165,54 @@ public: return &str[0]; } ///Read in a string of the length specified in the file - std::string getString() { + std::string getString() + { size_t size = readLittleEndianType(inp); return getString(size); } ///This is special since the version string doesn't start with a number, and ends with "\n" - std::string getVersionString() { + std::string getVersionString() + { std::string result; std::getline(*inp, result); return result; } - void getUShorts(std::vector &vec, size_t size) { + void getUShorts(std::vector &vec, size_t size) + { vec.resize(size); readLittleEndianDynamicBufferOfType(inp, &vec.front(), size); } - void getFloats(std::vector &vec, size_t size) { + + void getFloats(std::vector &vec, size_t size) + { vec.resize(size); readLittleEndianDynamicBufferOfType(inp, &vec.front(), size); } - void getVector2s(std::vector &vec, size_t size) { + + void getVector2s(std::vector &vec, size_t size) + { vec.resize(size); /* The packed storage of each Vec2f is 2 floats exactly */ readLittleEndianDynamicBufferOfType(inp,(float*) &vec.front(), size*2); } - void getVector3s(std::vector &vec, size_t size) { + + void getVector3s(std::vector &vec, size_t size) + { vec.resize(size); /* The packed storage of each Vec3f is 3 floats exactly */ readLittleEndianDynamicBufferOfType(inp, (float*) &vec.front(), size*3); } - void getVector4s(std::vector &vec, size_t size) { + + void getVector4s(std::vector &vec, size_t size) + { vec.resize(size); /* The packed storage of each Vec4f is 4 floats exactly */ readLittleEndianDynamicBufferOfType(inp, (float*) &vec.front(), size*4); } - void getQuaternions(std::vector &quat, size_t size) { + + void getQuaternions(std::vector &quat, size_t size) + { quat.resize(size); for (size_t i = 0;i < quat.size();i++) quat[i] = getQuaternion();