Skip to content

Commit

Permalink
Fix issues reported by PVS-Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
ziggi committed Dec 25, 2018
1 parent efb05d4 commit a3dd415
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 18 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")

# flags
set (USE_MSVC_RUNTIME_LIBRARY_DLL true)
set (CMAKE_C_FLAGS "/Zp1 /W4 /MT")
set (CMAKE_CXX_FLAGS "/Zp1 /W4 /EHsc /MT")
set (CMAKE_C_FLAGS "/Zp1 /W4")
set (CMAKE_CXX_FLAGS "/Zp1 /W4 /EHsc")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set (CMAKE_SHARED_LINKER_FLAGS "/NOLOGO /MACHINE:X86")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_definitions (-DLINUX -DSYSTEM_NAME="GNU/Linux")
Expand Down
2 changes: 1 addition & 1 deletion src/CFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ WORD CFunctions::GetClosestMapPointInBetween(const CVector &vecHitOrigin, const
}


WORD CFunctions::RayCastLine(const CVector vecStart, const CVector vecEnd, CVector *vecResult)
WORD CFunctions::RayCastLine(const CVector &vecStart, const CVector &vecEnd, CVector *vecResult)
{
btVector3 Start = btVector3(btScalar(vecStart.fX + 0.00001), btScalar(vecStart.fY + 0.00001), btScalar(vecStart.fZ + 0.00001));
btVector3 End = btVector3(btScalar(vecEnd.fX), btScalar(vecEnd.fY), btScalar(vecEnd.fZ));
Expand Down
2 changes: 1 addition & 1 deletion src/CFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CFunctions
static void PlayerShoot(WORD wPlayerId, WORD wHitId, BYTE byteHitType, BYTE byteWeaponId, const CVector &vecPoint, const CVector &vecOffsetFrom, bool bIsHit, BYTE byteBetweenCheckFlags);
static WORD GetClosestEntityInBetween(const CVector &vecHitOrigin, const CVector &vecHitTarget, float fRange, BYTE byteBetweenCheckFlags, WORD wPlayerId, WORD wTargetId, BYTE &byteEntityType, WORD &wPlayerObjectOwnerId, CVector &vecHitMap);

static WORD RayCastLine(const CVector vecStart, const CVector vecEnd, CVector *vecResult);
static WORD RayCastLine(const CVector &vecStart, const CVector &vecEnd, CVector *vecResult);

// Functions
static ClientJoin_RPC_t pfn__ClientJoin_RPC;
Expand Down
2 changes: 1 addition & 1 deletion src/vendor/ColAndreas/ColAndreasDatabaseReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void DeleteCollisionData()
delete ModelPlacements;
}

bool ReadColandreasDatabaseFile(const std::string FileLocation)
bool ReadColandreasDatabaseFile(const std::string &FileLocation)
{
bool returnValue = false;

Expand Down
2 changes: 1 addition & 1 deletion src/vendor/ColAndreas/ColAndreasDatabaseReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pass a refrence to the collisionmodel and itemplacment array's. The function wil
returns a boolean true if function suceeded, otherwise false.
*/

bool ReadColandreasDatabaseFile(const std::string FileLocation);
bool ReadColandreasDatabaseFile(const std::string &FileLocation);
extern CollisionModelstructure* CollisionModels;
extern ItemPlacementstructure* ModelPlacements;
extern uint16_t ModelCount;
Expand Down
11 changes: 5 additions & 6 deletions src/vendor/ColAndreas/ColObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ bool LoadCollisionData(btDynamicsWorld* collisionWorld)
ColAndreasColObject* convex = new ColAndreasColObject(i, true); //true for convex mesh
colObjects.push_back(colObject);
colConvex.push_back(convex->getCompoundShape()); //storing convex bodies
delete convex;
}
return true;
}
Expand All @@ -86,7 +87,7 @@ bool LoadCollisionData(btDynamicsWorld* collisionWorld)

ColAndreasMapObject::ColAndreasMapObject(uint16_t modelid, const btQuaternion& objectRot, const btVector3& objectPos, btDynamicsWorld* world)
{
colindex = ModelRef[modelid];
uint16_t colindex = ModelRef[modelid];

collisionWorld = world;

Expand Down Expand Up @@ -298,7 +299,7 @@ RemovedBuildingManager::RemovedBuildingManager()
{
}

bool RemovedBuildingManager::isRemoved(uint16_t model, const Vector position)
bool RemovedBuildingManager::isRemoved(uint16_t model, const Vector &position)
{
for (uint16_t i = 0; i < removedBuildings.size(); i++) {
if (model == removedBuildings[i].r_Model) {
Expand All @@ -313,7 +314,7 @@ bool RemovedBuildingManager::isRemoved(uint16_t model, const Vector position)
return 0;
}

void RemovedBuildingManager::addBuilding(const removeBuildingData removeData)
void RemovedBuildingManager::addBuilding(const removeBuildingData &removeData)
{
removedBuildings.push_back(removeData);
}
Expand All @@ -336,9 +337,7 @@ void InitCollisionMap(btDynamicsWorld* collisionWorld, RemovedBuildingManager* r
// Continue if model has no collision
if (index == 65535) continue;

ColAndreasMapObject* tmpObject;
tmpObject = new ColAndreasMapObject(ModelPlacements[i].Modelid, btQuaternion(ModelPlacements[i].Rotation.x, ModelPlacements[i].Rotation.y, ModelPlacements[i].Rotation.z, ModelPlacements[i].Rotation.w), btVector3(ModelPlacements[i].Position.x, ModelPlacements[i].Position.y, ModelPlacements[i].Position.z), collisionWorld);

ColAndreasMapObject(ModelPlacements[i].Modelid, btQuaternion(ModelPlacements[i].Rotation.x, ModelPlacements[i].Rotation.y, ModelPlacements[i].Rotation.z, ModelPlacements[i].Rotation.w), btVector3(ModelPlacements[i].Position.x, ModelPlacements[i].Position.y, ModelPlacements[i].Position.z), collisionWorld);
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/vendor/ColAndreas/ColObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ struct removeBuildingData
float r_Radius;
};

static uint16_t colindex = 0;

// Data structure to track in-game objects with respect to their colindex
struct ColAndreasObjectTracker
{
Expand Down Expand Up @@ -112,8 +110,8 @@ class RemovedBuildingManager
{
public:
RemovedBuildingManager();
bool isRemoved(uint16_t model, const Vector position);
void addBuilding(const removeBuildingData removeData);
bool isRemoved(uint16_t model, const Vector &position);
void addBuilding(const removeBuildingData &removeData);
private:
std::vector <removeBuildingData> removedBuildings;
};
Expand Down
2 changes: 1 addition & 1 deletion src/vendor/ColAndreas/DynamicWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void ColAndreasWorld::colandreasInitMap()
InitCollisionMap(this->dynamicsWorld, this->removedManager);
}

uint16_t ColAndreasWorld::createColAndreasMapObject(uint16_t addtomanager, uint16_t modelid, const btQuaternion& objectRot, const btVector3& objectPos)
int ColAndreasWorld::createColAndreasMapObject(uint16_t addtomanager, uint16_t modelid, const btQuaternion& objectRot, const btVector3& objectPos)
{
if (addtomanager) {
return this->objectManager->addObjectManager(new ColAndreasMapObject(modelid, objectRot, objectPos, this->dynamicsWorld));
Expand Down
2 changes: 1 addition & 1 deletion src/vendor/ColAndreas/DynamicWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ColAndreasWorld
int performRayTestNormal(const btVector3& Start, const btVector3& End, btVector3& Result, btVector3& Normal, uint16_t& model);
int performContactTest(uint16_t modelid, btVector3& objectPos, btQuaternion& objectRot);

uint16_t createColAndreasMapObject(uint16_t addtomanager, uint16_t modelid, const btQuaternion& objectRot, const btVector3& objectPos);
int createColAndreasMapObject(uint16_t addtomanager, uint16_t modelid, const btQuaternion& objectRot, const btVector3& objectPos);
uint16_t getModelRef(uint16_t model);
void colandreasInitMap();
bool loadCollisionData();
Expand Down

0 comments on commit a3dd415

Please sign in to comment.