Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
some fixes and planned fixes thanks to pvs studio
Browse files Browse the repository at this point in the history
  • Loading branch information
Ybalrid committed Dec 21, 2017
1 parent 1689218 commit f6e1383
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 11 deletions.
2 changes: 2 additions & 0 deletions include/AnnEvents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ namespace Annwvyn
AnnStickEvent();
///Destroy a stick event object
~AnnStickEvent();


///Number of buttons this controller has
size_t getNbButtons() const;

Expand Down
2 changes: 1 addition & 1 deletion include/AnnPlayerBody.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Annwvyn
{
enum AnnPlayerMode { STANDING, ROOMSCALE };
enum AnnPlayerMode { STANDING, ROOMSCALE, UNKNOWN };
class AnnEngine; //pre-declaration of AnnEngine

///Correspondence between array position and walk direction for the "walking" array
Expand Down
2 changes: 2 additions & 0 deletions pch/stdafx.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#include "stdafx.h"
//This file is only here to construct pre-compiled headers for the project.
2 changes: 2 additions & 0 deletions pch/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@
#include <GLFW/glfw3.h>

//Chaisript interpretor
#pragma warning (push)
#pragma warning (disable : 4602)
#include <chaiscript.hpp>
#include <chaiscript_defines.hpp>
#include <chaiscript_stdlib.hpp>
#include <chaiscript_threading.hpp>
#pragma warning (default: 4602)
#pragma warning (pop)
10 changes: 4 additions & 6 deletions src/AnnEventManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void AnnEventManager::processKeyboardEvents()
{
//for each key of the keyboard
for (size_t c(0); c < KeyCode::SIZE; c++)
if ((Keyboard->isKeyDown(OIS::KeyCode(c)) && !previousKeyStates[c]) ||
if ((Keyboard->isKeyDown(OIS::KeyCode(c)) && !previousKeyStates[c]) || //TODO: V728 https://www.viva64.com/en/w/V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression.
(!Keyboard->isKeyDown(OIS::KeyCode(c)) && previousKeyStates[c]))
{
//create a corresponding key event
Expand Down Expand Up @@ -289,10 +289,10 @@ void AnnEventManager::processJoystickEvents()
{
const auto& state(Joystick.oisJoystick->getJoyStickState());
AnnStickEvent stickEvent;
stickEvent.vendor = Joystick.oisJoystick->vendor();
stickEvent.stickID = Joystick.getID();

//Get all buttons immediate data
//stickEvent.buttons = state.mButtons;

const auto buttonSize = state.mButtons.size();
stickEvent.buttons.resize(buttonSize);
for (auto i = 0u; i < buttonSize; ++i)
Expand All @@ -303,9 +303,6 @@ void AnnEventManager::processJoystickEvents()
stickEvent.buttons[i] = 0;
}

stickEvent.vendor = Joystick.oisJoystick->vendor();
stickEvent.stickID = Joystick.getID();

//Get all axes immediate data
auto axisID = 0;
for (const auto& axis : state.mAxes)
Expand Down Expand Up @@ -443,6 +440,7 @@ size_t AnnEventManager::getNbStick() const
return Joysticks.size();
}


AnnEventListener::~AnnEventListener()
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/AnnEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ StickAxisId AnnStickAxis::getAxisId() const
return id;
}

AnnStickAxis::AnnStickAxis(StickAxisId ax, int rel, int abs)
AnnStickAxis::AnnStickAxis(StickAxisId ax, int rel, int abs) //TODO: V730 https://www.viva64.com/en/w/V730 It is possible that not all members of a class are initialized inside the constructor. Consider inspecting: noRel.
{
setAxis(ax);
setRelValue(rel);
Expand Down
2 changes: 1 addition & 1 deletion src/AnnFilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fileReader(nullptr)
// ReSharper disable CppDeprecatedEntity
pathToUserDir = getenv("USERPROFILE");
// ReSharper restore CppDeprecatedEntity
#pragma warning (default : 4996)
#pragma warning (default : 4996) //TODO: V665 https://www.viva64.com/en/w/V665 Possibly, the usage of '#pragma warning(default: X)' is incorrect in this context. The '#pragma warning(push/pop)' should be used instead. Check lines: 99, 103.
#endif

#ifdef __linux__
Expand Down
9 changes: 8 additions & 1 deletion src/AnnOgreOculusRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ currentSessionStatusFrameIndex{ 0 },
debugSmgr{ nullptr },
debugCam{ nullptr },
debugCamNode{ nullptr },
debugPlaneNode{ nullptr }
debugPlaneNode{ nullptr },
texSizeL{},
texSizeR{},
eyeRenderDescArray{},
hmdSize{},
oculusRenderTexturesSeparatedGLID{0},
ogreRenderTexturesSeparatedGLID{0}

{
rendererName = "OpenGL/Oculus";
oculusSelf = static_cast<AnnOgreOculusRenderer*>(self);
Expand Down
2 changes: 2 additions & 0 deletions src/AnnPlayerBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ AnnPlayerBody::AnnPlayerBody()
contactWithGround = false;
RoomReferenceNode = nullptr;
needNewRoomTranslateReference = false;

mode = UNKNOWN;
}

void AnnPlayerBody::setActuator(AnnPlayerActuator* act)
Expand Down
2 changes: 1 addition & 1 deletion src/AnnScriptManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ void AnnScriptManager::registerApi()
chai.add(fun([](const AnnColor& s) {AnnDebug() << logFromScript << s; }), "AnnDebugLog");
chai.add(fun([](KeyCode::code c) {AnnDebug() << logFromScript << "keycode:" << c; }), "AnnDebugLog");
chai.add(fun([](MouseAxisId c) {AnnDebug() << logFromScript << "mouseAxis:" << c; }), "AnnDebugLog");
chai.add(fun([](bool b) {string s("true"); if (!b) s = "false"; AnnDebug() << logFromScript << "bool:" << s; }), "AnnDebugLog");
chai.add(fun([](bool b) {string s("true"); if (!b) { s = "false"; } AnnDebug() << logFromScript << "bool:" << s; }), "AnnDebugLog");
chai.add(fun([](int i) {AnnDebug() << logFromScript << "int:" << i; }), "AnnDebugLog");
chai.add(fun([](float f) {AnnDebug() << logFromScript << "float:" << f; }), "AnnDebugLog");

Expand Down
2 changes: 2 additions & 0 deletions tests/pch/stdafx.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#include "stdafx.h"

0 comments on commit f6e1383

Please sign in to comment.