[Orxonox-commit 6426] r11083 - in code/trunk/src: libraries/core libraries/core/class libraries/core/input libraries/network libraries/network/packet libraries/util modules/gametypes modules/hover modules/invader modules/objects modules/objects/triggers modules/overlays/hud modules/pickup/items modules/pong modules/questsystem modules/questsystem/effects modules/tetris modules/towerdefense modules/weapons/projectiles orxonox/chat orxonox/controllers orxonox/gametypes orxonox/graphics orxonox/weaponsystem orxonox/worldentities orxonox/worldentities/pawns
muemart at orxonox.net
muemart at orxonox.net
Thu Jan 21 13:59:05 CET 2016
Author: muemart
Date: 2016-01-21 13:59:04 +0100 (Thu, 21 Jan 2016)
New Revision: 11083
Modified:
code/trunk/src/libraries/core/GUIManager.cc
code/trunk/src/libraries/core/class/SubclassIdentifier.h
code/trunk/src/libraries/core/input/KeyBinder.cc
code/trunk/src/libraries/network/MasterServer.cc
code/trunk/src/libraries/network/packet/Gamestate.cc
code/trunk/src/libraries/network/packet/ServerInformation.cc
code/trunk/src/libraries/util/Serialise.h
code/trunk/src/modules/gametypes/SpaceRaceController.cc
code/trunk/src/modules/hover/TimeHUD.cc
code/trunk/src/modules/invader/Invader.cc
code/trunk/src/modules/invader/InvaderEnemy.cc
code/trunk/src/modules/invader/InvaderEnemy.h
code/trunk/src/modules/invader/InvaderEnemyShooter.cc
code/trunk/src/modules/objects/ForceField.cc
code/trunk/src/modules/objects/ForceField.h
code/trunk/src/modules/objects/SpaceBoundaries.cc
code/trunk/src/modules/objects/triggers/DistanceTrigger.h
code/trunk/src/modules/objects/triggers/EventTrigger.h
code/trunk/src/modules/overlays/hud/ChatOverlay.cc
code/trunk/src/modules/pickup/items/ShrinkPickup.cc
code/trunk/src/modules/pong/Pong.cc
code/trunk/src/modules/questsystem/QuestListener.cc
code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.h
code/trunk/src/modules/tetris/Tetris.cc
code/trunk/src/modules/tetris/TetrisBrick.cc
code/trunk/src/modules/tetris/TetrisStone.cc
code/trunk/src/modules/towerdefense/TDCoordinate.cc
code/trunk/src/modules/towerdefense/TowerDefense.cc
code/trunk/src/modules/weapons/projectiles/GravityBombField.cc
code/trunk/src/orxonox/chat/ChatInputHandler.cc
code/trunk/src/orxonox/controllers/ActionpointController.cc
code/trunk/src/orxonox/controllers/DivisionController.cc
code/trunk/src/orxonox/controllers/FightingController.cc
code/trunk/src/orxonox/controllers/ScriptController.cc
code/trunk/src/orxonox/controllers/SectionController.cc
code/trunk/src/orxonox/controllers/WingmanController.cc
code/trunk/src/orxonox/gametypes/LastManStanding.cc
code/trunk/src/orxonox/gametypes/LastTeamStanding.cc
code/trunk/src/orxonox/graphics/LensFlare.cc
code/trunk/src/orxonox/graphics/LensFlare.h
code/trunk/src/orxonox/weaponsystem/Munition.cc
code/trunk/src/orxonox/worldentities/StaticEntity.cc
code/trunk/src/orxonox/worldentities/WorldEntity.cc
code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.h
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
Log:
Fix some clang-tidy warnings.
Also, Serialise.h was doing some C-style casts that ended up being const casts. I moved those const casts as close to the source as possible and changed the loadAndIncrease functions to not do that.
Modified: code/trunk/src/libraries/core/GUIManager.cc
===================================================================
--- code/trunk/src/libraries/core/GUIManager.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/libraries/core/GUIManager.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -103,6 +103,8 @@
#include "util/Math.h"
#include "util/OrxAssert.h"
#include "util/output/BaseWriter.h"
+#include "util/StringUtils.h"
+#include "util/SubString.h"
#include "config/ConfigValueIncludes.h"
#include "Core.h"
#include "CoreIncludes.h"
Modified: code/trunk/src/libraries/core/class/SubclassIdentifier.h
===================================================================
--- code/trunk/src/libraries/core/class/SubclassIdentifier.h 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/libraries/core/class/SubclassIdentifier.h 2016-01-21 12:59:04 UTC (rev 11083)
@@ -91,20 +91,20 @@
{
public:
/// Constructor: Automaticaly assigns the Identifier of the given class.
- SubclassIdentifier()
+ SubclassIdentifier() : identifier_(nullptr)
{
this->identifier_ = ClassIdentifier<T>::getIdentifier();
}
/// Constructor: Assigns the given Identifier.
- SubclassIdentifier(Identifier* identifier)
+ SubclassIdentifier(Identifier* identifier) : identifier_(nullptr)
{
this->operator=(identifier);
}
/// Copyconstructor: Assigns the identifier of another SubclassIdentifier.
template <class O>
- SubclassIdentifier(const SubclassIdentifier<O>& identifier)
+ SubclassIdentifier(const SubclassIdentifier<O>& identifier) : identifier_(nullptr)
{
this->operator=(identifier.getIdentifier());
}
Modified: code/trunk/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinder.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/libraries/core/input/KeyBinder.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -66,7 +66,7 @@
// keys
for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++)
{
- const std::string& keyname = KeyCode::ByString[i];
+ const std::string keyname = KeyCode::ByString[i];
if (!keyname.empty())
keys_[i].name_ = std::string("Key") + keyname;
else
Modified: code/trunk/src/libraries/network/MasterServer.cc
===================================================================
--- code/trunk/src/libraries/network/MasterServer.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/libraries/network/MasterServer.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -252,14 +252,14 @@
enet_address_get_host_ip( &(event->peer->address), addrconv, 49 );
/* convert to string */
std::string ip = std::string( addrconv );
+ /* output debug info about the data that has come */
+ helper_output_debug(event, addrconv);
/* delete addrconv */
if( addrconv ) free( addrconv );
/* pointer to full packet data */
char * packetdata = (char *)event->packet->data;
- /* output debug info about the data that has come */
- helper_output_debug( event, addrconv );
/* GAME SERVER OR CLIENT CONNECTION? */
if( !strncmp(packetdata, MSPROTO_GAME_SERVER, MSPROTO_GAME_SERVER_LEN ) )
@@ -331,7 +331,7 @@
MasterServer::run()
{
/***** ENTER MAIN LOOP *****/
- ENetEvent *event = (ENetEvent *)calloc(sizeof(ENetEvent), sizeof(char));
+ ENetEvent *event = (ENetEvent *)calloc(1, sizeof(ENetEvent));
if( event == nullptr )
{
orxout(user_error, context::master_server) << "Could not create ENetEvent structure, exiting." << endl;
Modified: code/trunk/src/libraries/network/packet/Gamestate.cc
===================================================================
--- code/trunk/src/libraries/network/packet/Gamestate.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/libraries/network/packet/Gamestate.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -488,7 +488,7 @@
Gamestate* Gamestate::diffVariables(Gamestate *base)
{
- assert(this && base); assert(data_ && base->data_);
+ assert(base); assert(data_ && base->data_);
assert(!header_.isCompressed() && !base->header_.isCompressed());
assert(!header_.isDiffed());
assert( header_.getDataSize() && base->header_.getDataSize() );
Modified: code/trunk/src/libraries/network/packet/ServerInformation.cc
===================================================================
--- code/trunk/src/libraries/network/packet/ServerInformation.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/libraries/network/packet/ServerInformation.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -54,7 +54,7 @@
this->serverIP_ = std::string(serverIP);
// Save ACK
uint8_t* temp = event->packet->data;
- char* ack = new char[strlen(LAN_DISCOVERY_ACK)+1];
+ char* ack = nullptr;
loadAndIncrease((char*&)ack, temp);
/* Fabian, what is this used for? it crashes the masterserver, hence commenting it */
@@ -63,6 +63,7 @@
// Save Server Name
loadAndIncrease(this->serverName_, temp);
+ delete[] ack;
}
ServerInformation::~ServerInformation()
@@ -73,10 +74,10 @@
void ServerInformation::send(ENetPeer* peer)
{
std::string payload = this->serverName_ + Ogre::StringConverter::toString(this->clientNumber_);
- uint32_t size = returnSize((char*&)LAN_DISCOVERY_ACK) + returnSize(payload);
+ uint32_t size = returnSize(LAN_DISCOVERY_ACK) + returnSize(payload);
uint8_t* temp = new uint8_t[size];
uint8_t* temp2 = temp;
- saveAndIncrease((char*&)LAN_DISCOVERY_ACK, temp2);
+ saveAndIncrease(LAN_DISCOVERY_ACK, temp2);
saveAndIncrease(payload, temp2);
ENetPacket* packet = enet_packet_create( temp, size, 0 );
enet_peer_send(peer, 0, packet);
Modified: code/trunk/src/libraries/util/Serialise.h
===================================================================
--- code/trunk/src/libraries/util/Serialise.h 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/libraries/util/Serialise.h 2016-01-21 12:59:04 UTC (rev 11083)
@@ -47,7 +47,7 @@
/** @brief returns the size of the variable in a datastream */
template <class T> inline uint32_t returnSize( const T& variable );
/** @brief loads the value of a variable out of the bytestream and increases the mem pointer */
- template <class T> inline void loadAndIncrease( const T& variable, uint8_t*& mem );
+ template <class T> inline void loadAndIncrease( T& variable, uint8_t*& mem );
/** @brief saves the value of a variable into the bytestream and increases the mem pointer */
template <class T> inline void saveAndIncrease( const T& variable, uint8_t*& mem );
/** @brief checks whether the variable of type T is the same as in the bytestream */
@@ -56,24 +56,25 @@
// =========== char*
- inline uint32_t returnSize( char*& variable )
+ inline uint32_t returnSize(const char*& variable )
{
return strlen(variable)+1;
}
- inline void saveAndIncrease( char*& variable, uint8_t*& mem )
+ inline void saveAndIncrease(const char*& variable, uint8_t*& mem )
{
- strcpy((char*)mem, variable);
- mem += returnSize(variable);
+ uint32_t len = returnSize(variable);
+ std::memcpy(mem, variable, len);
+ mem += len;
}
inline void loadAndIncrease( char*& variable, uint8_t*& mem )
{
if( variable )
delete variable;
- uint32_t len = strlen((char*)mem)+1;
+ uint32_t len = returnSize((const char*&)mem);
variable = new char[len];
- strcpy((char*)variable, (char*)mem);
+ std::memcpy(variable, mem, len);
mem += len;
}
@@ -91,7 +92,7 @@
return sizeof(uint8_t);
}
- template <> inline void loadAndIncrease( const bool& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( bool& variable, uint8_t*& mem )
{
*(uint8_t*)( &variable ) = *static_cast<uint8_t*>(mem);
mem += returnSize( variable );
@@ -115,7 +116,7 @@
return sizeof(uint8_t);
}
- template <> inline void loadAndIncrease( const char& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( char& variable, uint8_t*& mem )
{
*(uint8_t*)( &variable ) = *static_cast<uint8_t*>(mem);
mem += returnSize( variable );
@@ -139,7 +140,7 @@
return sizeof(uint8_t);
}
- template <> inline void loadAndIncrease( const unsigned char& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( unsigned char& variable, uint8_t*& mem )
{
*(uint8_t*)( &variable ) = *static_cast<uint8_t*>(mem);
mem += returnSize( variable );
@@ -163,7 +164,7 @@
return sizeof(int16_t);
}
- template <> inline void loadAndIncrease( const short& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( short& variable, uint8_t*& mem )
{
*(short*)( &variable ) = *(int16_t*)(mem);
mem += returnSize( variable );
@@ -187,7 +188,7 @@
return sizeof(uint16_t);
}
- template <> inline void loadAndIncrease( const unsigned short& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( unsigned short& variable, uint8_t*& mem )
{
*(unsigned short*)( &variable ) = *(uint16_t*)(mem);
mem += returnSize( variable );
@@ -211,7 +212,7 @@
return sizeof(int32_t);
}
- template <> inline void loadAndIncrease( const int& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( int& variable, uint8_t*& mem )
{
*(int *)( &variable ) = *(int32_t*)(mem);
mem += returnSize( variable );
@@ -235,7 +236,7 @@
return sizeof(uint32_t);
}
- template <> inline void loadAndIncrease( const unsigned int& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( unsigned int& variable, uint8_t*& mem )
{
*(unsigned int*)( &variable ) = *(uint32_t*)(mem);
mem += returnSize( variable );
@@ -259,7 +260,7 @@
return sizeof(int32_t);
}
- template <> inline void loadAndIncrease( const long& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( long& variable, uint8_t*& mem )
{
*(long*)( &variable ) = *(int32_t*)(mem);
mem += returnSize( variable );
@@ -283,7 +284,7 @@
return sizeof(uint32_t);
}
- template <> inline void loadAndIncrease( const unsigned long& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( unsigned long& variable, uint8_t*& mem )
{
*(unsigned long*)( &variable ) = *(uint32_t*)(mem);
mem += returnSize( variable );
@@ -307,7 +308,7 @@
return sizeof(int64_t);
}
- template <> inline void loadAndIncrease( const long long& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( long long& variable, uint8_t*& mem )
{
*(long long*)( &variable ) = *(int64_t*)(mem);
mem += returnSize( variable );
@@ -331,7 +332,7 @@
return sizeof(uint64_t);
}
- template <> inline void loadAndIncrease( const unsigned long long& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( unsigned long long& variable, uint8_t*& mem )
{
*(unsigned long long*)( &variable ) = *(uint64_t*)(mem);
mem += returnSize( variable );
@@ -355,7 +356,7 @@
return sizeof(uint32_t);
}
- template <> inline void loadAndIncrease( const float& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( float& variable, uint8_t*& mem )
{
*(uint32_t*)( &variable ) = *(uint32_t*)(mem);
mem += returnSize( variable );
@@ -379,7 +380,7 @@
return sizeof(uint64_t);
}
- template <> inline void loadAndIncrease( const double& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( double& variable, uint8_t*& mem )
{
*(uint64_t*)( &variable ) = *(uint64_t*)(mem);
mem += returnSize( variable );
@@ -403,7 +404,7 @@
return sizeof(uint64_t);
}
- template <> inline void loadAndIncrease( const long double& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( long double& variable, uint8_t*& mem )
{
double temp;
memcpy(&temp, mem, sizeof(uint64_t));
@@ -437,7 +438,7 @@
mem += variable.length()+1;
}
- template <> inline void loadAndIncrease( const std::string& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( std::string& variable, uint8_t*& mem )
{
*(std::string*)( &variable ) = (const char *)mem;
mem += variable.length()+1;
@@ -463,7 +464,7 @@
mem += returnSize( variable );
}
- template <> inline void loadAndIncrease( const Degree& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( Degree& variable, uint8_t*& mem )
{
Ogre::Real* r = (Ogre::Real*)mem;
(Degree&)variable = *r;
@@ -490,7 +491,7 @@
mem += returnSize( variable );
}
- template <> inline void loadAndIncrease( const Radian& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( Radian& variable, uint8_t*& mem )
{
Ogre::Real* r = (Ogre::Real*)mem;
(Radian&)variable = *r;
@@ -516,7 +517,7 @@
saveAndIncrease( variable.y, mem );
}
- template <> inline void loadAndIncrease( const Vector2& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( Vector2& variable, uint8_t*& mem )
{
loadAndIncrease( variable.x, mem );
loadAndIncrease( variable.y, mem );
@@ -541,7 +542,7 @@
saveAndIncrease( variable.z, mem );
}
- template <> inline void loadAndIncrease( const Vector3& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( Vector3& variable, uint8_t*& mem )
{
loadAndIncrease( variable.x, mem );
loadAndIncrease( variable.y, mem );
@@ -569,7 +570,7 @@
saveAndIncrease( variable.z, mem );
}
- template <> inline void loadAndIncrease( const Vector4& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( Vector4& variable, uint8_t*& mem )
{
loadAndIncrease( variable.w, mem );
loadAndIncrease( variable.x, mem );
@@ -599,7 +600,7 @@
saveAndIncrease( variable.z, mem );
}
- template <> inline void loadAndIncrease( const Quaternion& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( Quaternion& variable, uint8_t*& mem )
{
loadAndIncrease( variable.w, mem );
loadAndIncrease( variable.x, mem );
@@ -629,7 +630,7 @@
saveAndIncrease( variable.a, mem );
}
- template <> inline void loadAndIncrease( const ColourValue& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( ColourValue& variable, uint8_t*& mem )
{
loadAndIncrease( variable.r, mem );
loadAndIncrease( variable.g, mem );
@@ -656,7 +657,7 @@
saveAndIncrease( (unsigned char&)((mbool&)variable).getMemory(), mem );
}
- template <> inline void loadAndIncrease( const mbool& variable, uint8_t*& mem )
+ template <> inline void loadAndIncrease( mbool& variable, uint8_t*& mem )
{
loadAndIncrease( (unsigned char&)((mbool&)variable).getMemory(), mem );
}
Modified: code/trunk/src/modules/gametypes/SpaceRaceController.cc
===================================================================
--- code/trunk/src/modules/gametypes/SpaceRaceController.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/gametypes/SpaceRaceController.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -396,11 +396,11 @@
// True if a coordinate of 'pointToPoint' is smaller then the corresponding coordinate of 'groesse'
bool SpaceRaceController::vergleicheQuader(const Vector3& pointToPoint, const Vector3& groesse)
{
- if(abs(pointToPoint.x) < groesse.x)
+ if(std::abs(pointToPoint.x) < groesse.x)
return true;
- if(abs(pointToPoint.y) < groesse.y)
+ if(std::abs(pointToPoint.y) < groesse.y)
return true;
- if(abs(pointToPoint.z) < groesse.z)
+ if(std::abs(pointToPoint.z) < groesse.z)
return true;
return false;
Modified: code/trunk/src/modules/hover/TimeHUD.cc
===================================================================
--- code/trunk/src/modules/hover/TimeHUD.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/hover/TimeHUD.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -81,9 +81,9 @@
if (this->hoverGame_)
{
this->setCaption(getTimeString(this->time_));
+ if (this->hoverGame_->getNumberOfFlags() == 0)
+ setRunning(false);
}
- if(this->hoverGame_->getNumberOfFlags() == 0)
- setRunning(false);
}
Modified: code/trunk/src/modules/invader/Invader.cc
===================================================================
--- code/trunk/src/modules/invader/Invader.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/invader/Invader.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -128,7 +128,7 @@
newPawn = new InvaderEnemy(this->center_->getContext());
newPawn->addTemplate("enemyinvader");
}
- newPawn->setPlayer(player);
+ newPawn->setInvaderPlayer(player);
newPawn->level = level;
// spawn enemy at random points in front of player.
newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200));
Modified: code/trunk/src/modules/invader/InvaderEnemy.cc
===================================================================
--- code/trunk/src/modules/invader/InvaderEnemy.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/invader/InvaderEnemy.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -57,7 +57,7 @@
if (player != nullptr)
{
- float newZ = 2/(pow(abs(getPosition().x - player->getPosition().x) * 0.01f, 2) + 1) * (player->getPosition().z - getPosition().z);
+ float newZ = 2/(pow(std::abs(getPosition().x - player->getPosition().x) * 0.01f, 2) + 1) * (player->getPosition().z - getPosition().z);
setVelocity(Vector3(1000.f - level * 100 , 0, newZ));
}
SUPER(InvaderEnemy, tick, dt);
Modified: code/trunk/src/modules/invader/InvaderEnemy.h
===================================================================
--- code/trunk/src/modules/invader/InvaderEnemy.h 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/invader/InvaderEnemy.h 2016-01-21 12:59:04 UTC (rev 11083)
@@ -48,7 +48,7 @@
virtual void tick(float dt) override;
virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) override;
- virtual void setPlayer(InvaderShip* player){this->player = player;}
+ virtual void setInvaderPlayer(InvaderShip* player){this->player = player;}
int level;
protected:
Modified: code/trunk/src/modules/invader/InvaderEnemyShooter.cc
===================================================================
--- code/trunk/src/modules/invader/InvaderEnemyShooter.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/invader/InvaderEnemyShooter.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -62,8 +62,8 @@
{
float distPlayer = player->getPosition().z - getPosition().z;
// orxout() << "i'm different!" << endl;
- float newZ = 2/(pow(abs(getPosition().x - player->getPosition().x) * 0.01f, 2) + 1) * distPlayer;
- setVelocity(Vector3(950 - abs(distPlayer), 0, newZ));
+ float newZ = 2/(pow(std::abs(getPosition().x - player->getPosition().x) * 0.01f, 2) + 1) * distPlayer;
+ setVelocity(Vector3(950 - std::abs(distPlayer), 0, newZ));
}
Pawn::tick(dt);
}
Modified: code/trunk/src/modules/objects/ForceField.cc
===================================================================
--- code/trunk/src/modules/objects/ForceField.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/objects/ForceField.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -62,7 +62,7 @@
//Standard Values
this->setDirection(Vector3::ZERO);
- this->setVelocity(100);
+ this->setFieldVelocity(100);
this->setDiameter(500);
this->setMassDiameter(0); //! We allow point-masses
this->setLength(2000);
@@ -87,7 +87,7 @@
{
SUPER(ForceField, XMLPort, xmlelement, mode);
- XMLPortParam(ForceField, "velocity", setVelocity, getVelocity, xmlelement, mode).defaultValues(100);
+ XMLPortParam(ForceField, "velocity", setFieldVelocity, getFieldVelocity, xmlelement, mode).defaultValues(100);
XMLPortParam(ForceField, "diameter", setDiameter, getDiameter, xmlelement, mode).defaultValues(500);
XMLPortParam(ForceField, "massDiameter", setMassDiameter, getMassDiameter, xmlelement, mode).defaultValues(0);
XMLPortParam(ForceField, "length", setLength , getLength , xmlelement, mode).defaultValues(2000);
Modified: code/trunk/src/modules/objects/ForceField.h
===================================================================
--- code/trunk/src/modules/objects/ForceField.h 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/objects/ForceField.h 2016-01-21 12:59:04 UTC (rev 11083)
@@ -97,13 +97,13 @@
@brief Set the velocity of the ForceField.
@param vel The velocity to be set.
*/
- inline void setVelocity(float vel)
+ inline void setFieldVelocity(float vel)
{ this->velocity_ = vel; }
/**
@brief Get the velocity of the ForceField.
@return Returns the velocity of the ForceField.
*/
- inline float getVelocity()
+ inline float getFieldVelocity()
{ return this->velocity_; }
/**
Modified: code/trunk/src/modules/objects/SpaceBoundaries.cc
===================================================================
--- code/trunk/src/modules/objects/SpaceBoundaries.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/objects/SpaceBoundaries.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -220,7 +220,7 @@
this->displayWarning("Attention! You are close to the boundary!");
}
}
- if(/* humanItem &&*/ abs(this->maxDistance_ - distance) < this->showDistance_ )
+ if(/* humanItem &&*/ std::abs(this->maxDistance_ - distance) < this->showDistance_ )
{
this->displayBoundaries(currentPawn, 1.0f - fabs(this->maxDistance_ - distance) / this->showDistance_); // Show the boundary
}
Modified: code/trunk/src/modules/objects/triggers/DistanceTrigger.h
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceTrigger.h 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/objects/triggers/DistanceTrigger.h 2016-01-21 12:59:04 UTC (rev 11083)
@@ -96,7 +96,7 @@
DistanceTrigger(Context* context); // Constructor. Registers and initializes the object.
virtual ~DistanceTrigger();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); // Method for creating a DistanceTrigger object through XML.
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; // Method for creating a DistanceTrigger object through XML.
void addTarget(const std::string& targets); // Add some target to the DistanceTrigger.
void removeTarget(const std::string& targets); // Remove some target from the DistanceTrigger.
Modified: code/trunk/src/modules/objects/triggers/EventTrigger.h
===================================================================
--- code/trunk/src/modules/objects/triggers/EventTrigger.h 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/objects/triggers/EventTrigger.h 2016-01-21 12:59:04 UTC (rev 11083)
@@ -72,7 +72,7 @@
EventTrigger(Context* context); // Constructor. Registers and initializes the object.
virtual ~EventTrigger();
- virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); // Creates an event port.
+ virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override; // Creates an event port.
/**
@brief Method that is called when a new event comes in.
Modified: code/trunk/src/modules/overlays/hud/ChatOverlay.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/ChatOverlay.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/overlays/hud/ChatOverlay.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -72,7 +72,7 @@
Timer* timer = new Timer();
this->timers_.insert(timer); // store the timer in a set to destroy it in the destructor
- const ExecutorPtr& executor = createExecutor(createFunctor(&ChatOverlay::dropMessage, this));
+ const ExecutorPtr executor = createExecutor(createFunctor(&ChatOverlay::dropMessage, this));
executor->setDefaultValues(timer);
timer->setTimer(this->displayTime_, false, executor, true);
Modified: code/trunk/src/modules/pickup/items/ShrinkPickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/ShrinkPickup.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/pickup/items/ShrinkPickup.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -276,8 +276,11 @@
else if(this->isTerminating_) // Grow until the ship reaches its default scale.
{
Pawn* pawn = this->carrierToPawnHelper();
- if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
+ if (pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
+ {
this->Pickupable::destroy();
+ return;
+ }
this->timeRemainig_ -= dt;
Modified: code/trunk/src/modules/pong/Pong.cc
===================================================================
--- code/trunk/src/modules/pong/Pong.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/pong/Pong.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -325,7 +325,7 @@
*/
PlayerInfo* Pong::getLeftPlayer() const
{
- if (this->bat_ != nullptr && this->bat_[0] != nullptr)
+ if (this->bat_[0] != nullptr)
return this->bat_[0]->getPlayer();
else
return nullptr;
@@ -339,7 +339,7 @@
*/
PlayerInfo* Pong::getRightPlayer() const
{
- if (this->bat_ != nullptr && this->bat_[1] != nullptr)
+ if (this->bat_[1] != nullptr)
return this->bat_[1]->getPlayer();
else
return nullptr;
Modified: code/trunk/src/modules/questsystem/QuestListener.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestListener.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/questsystem/QuestListener.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -80,10 +80,15 @@
XMLPortParam(QuestListener, "questId", setQuestId, getQuestId, xmlelement, mode);
XMLPortParam(QuestListener, "mode", setMode, getMode, xmlelement, mode);
- if(this->quest_ != nullptr)
+ std::string questid;
+
+ if (this->quest_ != nullptr)
+ {
this->quest_->addListener(this); // Adds the QuestListener to the Quests list of listeners.
+ questid = this->quest_->getId();
+ }
- orxout(verbose, context::quests) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << endl;
+ orxout(verbose, context::quests) << "QuestListener created for quest: {" << questid << "} with mode '" << this->getMode() << "'." << endl;
}
/**
Modified: code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.h
===================================================================
--- code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.h 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.h 2016-01-21 12:59:04 UTC (rev 11083)
@@ -60,8 +60,6 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Method for creating a ChangeQuestStatus object through XML.
- virtual bool invoke(PlayerInfo* player) = 0; //!< Invokes the QuestEffect.
-
protected:
/**
@brief Returns the id of the Quest.
Modified: code/trunk/src/modules/tetris/Tetris.cc
===================================================================
--- code/trunk/src/modules/tetris/Tetris.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/tetris/Tetris.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -139,7 +139,7 @@
{
const Vector3& currentStonePosition = someStone->getPosition(); //!< Saves the position of the currentStone
- if((position.x == currentStonePosition.x) && abs(position.y-currentStonePosition.y) < this->center_->getStoneSize())
+ if((position.x == currentStonePosition.x) && std::abs(position.y-currentStonePosition.y) < this->center_->getStoneSize())
return false;
}
@@ -221,9 +221,9 @@
assert(stone);
if(position.y < this->center_->getStoneSize()/2.0f) //!< If the stone has reached the bottom of the level
{
- float baseOffset = abs(stone->getPosition().y);
+ float baseOffset = std::abs(stone->getPosition().y);
if (this->activeBrick_->getRotationCount() == 1 || this->activeBrick_->getRotationCount() == 3)
- baseOffset = abs(stone->getPosition().x);
+ baseOffset = std::abs(stone->getPosition().x);
float yOffset = baseOffset + this->center_->getStoneSize()/2.0f;//calculate offset
if(yOffset < 0) //catch brake-throughs
yOffset = 0;
Modified: code/trunk/src/modules/tetris/TetrisBrick.cc
===================================================================
--- code/trunk/src/modules/tetris/TetrisBrick.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/tetris/TetrisBrick.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -212,7 +212,7 @@
if(!this->delay_)
{
const Vector3& position = this->getPosition();
- Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
+ Vector3 newPos = Vector3(position.x+value.x/std::abs(value.x)*this->size_, position.y, position.z);
if(!this->isValidMove(newPos))
return;
Modified: code/trunk/src/modules/tetris/TetrisStone.cc
===================================================================
--- code/trunk/src/modules/tetris/TetrisStone.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/tetris/TetrisStone.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -91,7 +91,7 @@
if(!this->delay_)
{
const Vector3& position = this->getPosition();
- Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
+ Vector3 newPos = Vector3(position.x+value.x/std::abs(value.x)*this->size_, position.y, position.z);
if(!this->tetris_->isValidMove(this, newPos))
return;
Modified: code/trunk/src/modules/towerdefense/TDCoordinate.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TDCoordinate.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/towerdefense/TDCoordinate.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -65,11 +65,11 @@
{
float tileScale = 100;
- Vector3 *coord = new Vector3();
- coord->x= (_x-8) * tileScale;
- coord->y= (_y-8) * tileScale;
- coord->z=0;
+ Vector3 coord;
+ coord.x= (_x-8) * tileScale;
+ coord.y= (_y-8) * tileScale;
+ coord.z=0;
- return *coord;
+ return coord;
}
}
Modified: code/trunk/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefense.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/towerdefense/TowerDefense.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -376,13 +376,14 @@
TDCoordinate* TowerDefense::getNextStreetCoord(TDCoordinate* thisCoord)
{
TowerDefenseField* thisField = fields_[thisCoord->GetX()][thisCoord->GetY()];
- TDCoordinate* nextCoord = new TDCoordinate(0,0);
if (thisField->getType() != TowerDefenseFieldType::STREET && thisField->getType() != TowerDefenseFieldType::START)
{
return nullptr;
}
+ TDCoordinate* nextCoord = new TDCoordinate(0, 0);
+
if (thisField->getAngle() == 0)
{
nextCoord->Set(thisCoord->GetX(), thisCoord->GetY() - 1);
@@ -405,6 +406,7 @@
return nextCoord;
}
+ delete nextCoord;
return nullptr;
}
}
Modified: code/trunk/src/modules/weapons/projectiles/GravityBombField.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/GravityBombField.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/modules/weapons/projectiles/GravityBombField.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -33,7 +33,7 @@
modelScaling_ = 1;
fieldExploded_ = false;
- setVelocity(FORCE_SPHERE_START_STRENGTH);
+ setFieldVelocity(FORCE_SPHERE_START_STRENGTH);
setDiameter(2*FORCE_SPHERE_START_RADIUS);
setMode(modeSphere_s);
setCollisionResponse(false);
@@ -157,7 +157,7 @@
}
setDiameter(forceSphereRadius_*2);
- setVelocity(forceStrength_);
+ setFieldVelocity(forceStrength_);
if(lifetime_>0) particleSphere_->setScale(forceSphereRadius_/FORCE_SPHERE_START_RADIUS);
bombModel_->setScale(modelScaling_);
Modified: code/trunk/src/orxonox/chat/ChatInputHandler.cc
===================================================================
--- code/trunk/src/orxonox/chat/ChatInputHandler.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/chat/ChatInputHandler.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -213,9 +213,12 @@
std::string name )
{
/* sanity checks */
- if( !tocolor )
- orxout(internal_warning) << "Empty ListBoxTextItem given to "
- "ChatInputhandler::sub_setcolor()." << endl;
+ if (!tocolor)
+ {
+ orxout(internal_warning) << "Empty ListBoxTextItem given to "
+ "ChatInputhandler::sub_setcolor()." << endl;
+ return;
+ }
/* "hash" the name */
int hash = 0;
Modified: code/trunk/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/ActionpointController.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/controllers/ActionpointController.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -73,7 +73,7 @@
}
void ActionpointController::tick(float dt)
{
- if (!this || !this->getControllableEntity() || !this->isActive())
+ if (!this->getControllableEntity() || !this->isActive())
return;
//count ticks, ticks_ is unsigned, so overflow is not a problem
@@ -85,8 +85,6 @@
std::reverse(actionpoints_.begin(), actionpoints_.end());
}
- if (!this || !this->getControllableEntity())
- return;
//fly
if (this->bHasTargetPosition_)
{
@@ -97,9 +95,6 @@
this->lookAtTarget(dt);
}
-
- if (!this || !this->getControllableEntity())
- return;
//don't fire rocket each tick
if (timeout_ <= 0)
{
@@ -110,8 +105,6 @@
--this->timeout_;
}
- if (!this || !this->getControllableEntity())
- return;
//sometimes dodge, sometimes attack
if (this->ticks_ % 80 <= 10)
{
@@ -122,8 +115,6 @@
this->bDodge_ = true;
}
- if (!this || !this->getControllableEntity())
- return;
//fire if you can
if (this->bShooting_)
{
@@ -139,7 +130,7 @@
void ActionpointController::action()
{
- if (!this || !this->getControllableEntity() || !this->isActive())
+ if (!this->getControllableEntity() || !this->isActive())
return;
//deltaHp is used to know if this got attacked
@@ -151,8 +142,6 @@
{
this->startAttackingEnemiesThatAreClose();
}
- if (!this || !this->getControllableEntity())
- return;
//No action -> pop one from stack
if (this->action_ == Action::NONE || this->bTakenOver_)
@@ -160,20 +149,12 @@
//if default behaviour is fighting all, push it onto the stack
if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty() && this->bDefaultFightAll_)
{
- if (!this || !this->getControllableEntity())
- return;
Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
this->parsedActionpoints_.push_back (p);
}
- if (!this || !this->getControllableEntity())
- return;
this->executeActionpoint();
- if (!this || !this->getControllableEntity())
- return;
this->bTakenOver_ = false;
}
- if (!this || !this->getControllableEntity())
- return;
//Action fightall -> fight till nobody alive
if (this->action_ == Action::FIGHTALL)
@@ -184,17 +165,11 @@
ControllableEntity* newTarget = this->closestTarget();
if (newTarget)
{
- if (!this || !this->getControllableEntity())
- return;
this->setAction (Action::FIGHTALL, newTarget);
}
else
{
- if (!this || !this->getControllableEntity())
- return;
this->nextActionpoint();
- if (!this || !this->getControllableEntity())
- return;
this->executeActionpoint();
}
@@ -206,23 +181,15 @@
if (!this->hasTarget() )
{
//----find a target----
- ControllableEntity* newTarget = this->closestTarget();
- if (!this || !this->getControllableEntity())
- return;
+ ControllableEntity* newTarget = this->closestTarget();
if (newTarget &&
CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
{
- if (!this || !this->getControllableEntity())
- return;
this->setAction (Action::FIGHT, newTarget);
}
else
{
- if (!this || !this->getControllableEntity())
- return;
this->nextActionpoint();
- if (!this || !this->getControllableEntity())
- return;
this->executeActionpoint();
}
}
@@ -234,22 +201,14 @@
if (diffVector.length() > this->attackRange_)
{
ControllableEntity* newTarget = this->closestTarget();
- if (!this || !this->getControllableEntity())
- return;
if (newTarget &&
CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
{
- if (!this || !this->getControllableEntity())
- return;
this->setAction (Action::FIGHT, newTarget);
}
else
{
- if (!this || !this->getControllableEntity())
- return;
this->nextActionpoint();
- if (!this || !this->getControllableEntity())
- return;
this->executeActionpoint();
}
}
@@ -259,11 +218,7 @@
{
if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
{
- if (!this || !this->getControllableEntity())
- return;
this->nextActionpoint();
- if (!this || !this->getControllableEntity())
- return;
this->executeActionpoint();
}
}
@@ -271,28 +226,16 @@
{
if (!this->getProtect())
{
- if (!this || !this->getControllableEntity())
- return;
this->nextActionpoint();
- if (!this || !this->getControllableEntity())
- return;
this->executeActionpoint();
}
- if (!this || !this->getControllableEntity())
- return;
this->stayNearProtect();
}
else if (this->action_ == Action::ATTACK)
{
- if (!this || !this->getControllableEntity())
- return;
if (!this->hasTarget())
{
- if (!this || !this->getControllableEntity())
- return;
this->nextActionpoint();
- if (!this || !this->getControllableEntity())
- return;
this->executeActionpoint();
}
}
@@ -407,7 +350,7 @@
//set action and target/protect
void ActionpointController::setAction (Action action, ControllableEntity* target)
{
- if (!this || !this->getControllableEntity())
+ if (!this->getControllableEntity())
return;
this->action_ = action;
if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK)
@@ -424,7 +367,7 @@
//set action and target position
void ActionpointController::setAction (Action action, const Vector3& target)
{
- if (!this || !this->getControllableEntity())
+ if (!this->getControllableEntity())
return;
this->action_ = action;
if (action == Action::FLY)
@@ -435,7 +378,7 @@
//set action and target position and orientation
void ActionpointController::setAction (Action action, const Vector3& target, const Quaternion& orient )
{
- if (!this || !this->getControllableEntity())
+ if (!this->getControllableEntity())
return;
this->action_ = action;
if (action == Action::FLY)
@@ -453,7 +396,7 @@
//if last element was failed to be parsed, next element will be executed.
void ActionpointController::executeActionpoint()
{
- if (!this || !this->getControllableEntity())
+ if (!this->getControllableEntity())
return;
Point p;
@@ -472,31 +415,20 @@
}
else
{
- if (!this || !this->getControllableEntity())
- return;
-
this->setTarget(nullptr);
this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
this->action_ = Action::NONE;
return;
}
- if (!this || !this->getControllableEntity())
- return;
if (!this->bLoop_ && this->parsedActionpoints_.back().inLoop)
{
//MOVES all points that are in loop to a loop vector
this->fillLoop();
- if (!this || !this->getControllableEntity())
- return;
this->bLoop_ = true;
executeActionpoint();
return;
}
- if (!this || !this->getControllableEntity())
- return;
this->setAction (p.action);
- if (!this || !this->getControllableEntity())
- return;
switch (this->action_)
{
@@ -507,8 +439,6 @@
break;
for (Pawn* pawn : ObjectList<Pawn>())
{
- if (!this || !this->getControllableEntity())
- return;
if (CommonController::getName(pawn) == targetName)
{
this->setTarget (static_cast<ControllableEntity*>(pawn));
@@ -519,23 +449,15 @@
case Action::FLY:
{
this->setTargetPosition( p.position );
- if (!this || !this->getControllableEntity())
- return;
if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
{
- if (!this || !this->getControllableEntity())
- return;
this->nextActionpoint();
- if (!this || !this->getControllableEntity())
- return;
this->executeActionpoint();
}
break;
}
case Action::PROTECT:
{
- if (!this || !this->getControllableEntity())
- return;
std::string protectName = p.name;
if (protectName == "reservedKeyword:human")
@@ -581,16 +503,12 @@
{
if (CommonController::getName(pawn) == targetName)
{
- if (!this || !this->getControllableEntity())
- return;
this->setTarget (static_cast<ControllableEntity*>(pawn));
}
}
if (!this->hasTarget())
{
this->nextActionpoint();
- if (!this || !this->getControllableEntity())
- return;
this->executeActionpoint();
}
break;
@@ -603,7 +521,7 @@
//calculate where in world coordinates this ship has to be, so that it keeps distance to protect_, and fly there
void ActionpointController::stayNearProtect()
{
- if (!this || !this->getControllableEntity())
+ if (!this->getControllableEntity())
return;
Vector3 targetRelativePosition(0, 300, 300);
@@ -625,8 +543,6 @@
//remove current point from the stack
void ActionpointController::nextActionpoint()
{
- if (!this || !this->getControllableEntity())
- return;
if (this->bLoop_)
{
if (this->bPatrolling_)
@@ -652,7 +568,7 @@
//if looping, instead of erasing point, move it to the top (back is what gets executed, so it's kinda reversed stack)
void ActionpointController::moveBackToTop()
{
- if (!this || !this->getControllableEntity())
+ if (!this->getControllableEntity())
return;
Point temp = loopActionpoints_.back();
@@ -683,11 +599,9 @@
//copy other ship's stacks so that if it dies, this can finish that ship's actions
void ActionpointController::takeActionpoints (const std::vector<Point>& vector, const std::vector<Point>& loop, bool b)
{
- if (!this || !this->getControllableEntity())
+ if (!this->getControllableEntity())
return;
this->parsedActionpoints_ = vector;
- if (!this || !this->getControllableEntity())
- return;
this->loopActionpoints_ = loop;
this->bLoop_ = b;
this->bTakenOver_ = true;
@@ -700,7 +614,7 @@
//find closest target
Pawn* ActionpointController::closestTarget()
{
- if (!this || !this->getControllableEntity())
+ if (!this->getControllableEntity())
return nullptr;
Pawn* closestTarget = nullptr;
@@ -708,8 +622,6 @@
Gametype* gt = this->getGametype();
for (Pawn* pawn : ObjectList<Pawn>())
{
- if (!this || !this->getControllableEntity())
- return nullptr;
if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), gt) )
continue;
@@ -729,20 +641,16 @@
//push action FIGHT to the stack and set target to the closest enemy
void ActionpointController::startAttackingEnemiesThatAreClose()
{
- if (!this || !this->getControllableEntity())
+ if (!this->getControllableEntity())
return;
if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_))
{
- if (!this || !this->getControllableEntity())
- return;
Pawn* newTarget = this->closestTarget();
if ( newTarget &&
CommonController::distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
<= this->attackRange_ )
{
- if (!this || !this->getControllableEntity())
- return;
this->setTarget(newTarget);
if (this->bLoop_ && !this->bPatrolling_)
{
Modified: code/trunk/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/DivisionController.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/controllers/DivisionController.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -56,12 +56,10 @@
}
void DivisionController::action()
{
- if (!this || !this->getControllableEntity() || !this->isActive())
+ if (!this->getControllableEntity() || !this->isActive())
return;
ActionpointController::action();
- if (!this || !this->getControllableEntity())
- return;
if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
{
//when this dies, its follower will execute all its actionpoints, if follower dies before this, wingman will do this
Modified: code/trunk/src/orxonox/controllers/FightingController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/FightingController.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/controllers/FightingController.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -57,7 +57,7 @@
}
void FightingController::lookAtTarget(float dt)
{
- if (!this || !this->getControllableEntity())
+ if (!this->getControllableEntity())
return;
ControllableEntity* entity = this->getControllableEntity();
if ( !entity )
@@ -123,9 +123,6 @@
float diffLength = diffVector.length();
Vector3 diffUnit = diffVector/diffLength;
- if (!this || !this->getControllableEntity())
- return;
-
//too far? well, come closer then
if (diffLength > this->attackRange_)
{
@@ -141,8 +138,6 @@
|| this->deltaHp < 0;
this->bKeepFormation_ = false;
- if (!this || !this->getControllableEntity())
- return;
if (!this->bDodge_)
{
this->bStartedDodging_ = false;
@@ -216,7 +211,7 @@
float FightingController::squaredDistanceToTarget() const
{
- if (!this || !this->getControllableEntity())
+ if (!this->getControllableEntity())
return 0;
if (!this->target_ || !this->getControllableEntity())
return (this->getControllableEntity()->getPosition().squaredDistance(this->targetPosition_));
@@ -236,7 +231,7 @@
Pawn* FightingController::closestTarget() const
{
- if (!this || !this->getControllableEntity())
+ if (!this->getControllableEntity())
return nullptr;
Pawn* closestTarget = nullptr;
Modified: code/trunk/src/orxonox/controllers/ScriptController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/ScriptController.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/controllers/ScriptController.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -226,26 +226,26 @@
if (this->currentEvent.fctName == "ral")
{
// Specify the axis
- Vector3* a;
+ Vector3 a;
switch ((int) currentEvent.d) {
case 3:
- a = new Vector3(this->currentEvent.v1.x + this->currentEvent.e*cos(2*math::pi*dl),
+ a = Vector3(this->currentEvent.v1.x + this->currentEvent.e*cos(2*math::pi*dl),
this->currentEvent.v1.y + this->currentEvent.e*sin(2*math::pi*dl),
this->currentEvent.v1.z);
break;
case 2:
- a = new Vector3(this->currentEvent.v1.x + this->currentEvent.e*sin(2*math::pi*dl),
+ a = Vector3(this->currentEvent.v1.x + this->currentEvent.e*sin(2*math::pi*dl),
this->currentEvent.v1.y,
this->currentEvent.v1.z + this->currentEvent.e*cos(2*math::pi*dl));
break;
case 1:
- a = new Vector3(this->currentEvent.v1.x,
+ a = Vector3(this->currentEvent.v1.x,
this->currentEvent.v1.y + this->currentEvent.e*sin(2*math::pi*dl),
this->currentEvent.v1.z + this->currentEvent.e*cos(2*math::pi*dl));
break;
}
- this->entity_->setPosition(*a);
+ this->entity_->setPosition(a);
/* Look at the specified position */
this->entity_->lookAt(this->currentEvent.v1);
Modified: code/trunk/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/SectionController.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/controllers/SectionController.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -58,15 +58,13 @@
void SectionController::action()
{
- if (!this || !this->getControllableEntity() || !this->isActive())
+ if (!this->getControllableEntity() || !this->isActive())
return;
//----If no leader, find one----
if (!myDivisionLeader_)
{
ActionpointController* newDivisionLeader = findNewDivisionLeader();
- if (!this || !this->getControllableEntity())
- return;
this->myDivisionLeader_ = newDivisionLeader;
}
@@ -77,8 +75,6 @@
if (!myDivisionLeader_)
{
ActionpointController::action();
- if (!this || !this->getControllableEntity())
- return;
if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
{
if (this->myWingman_)
@@ -97,8 +93,6 @@
}
else if (!this->myDivisionLeader_->bKeepFormation_)
{
- if (!this || !this->getControllableEntity())
- return;
if (!this->hasTarget())
{
@@ -120,7 +114,7 @@
if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK)
{
- Pawn* target;
+ Pawn* target = nullptr;
//----if he has a target----
if (this->myDivisionLeader_->hasTarget())
{
Modified: code/trunk/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/WingmanController.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/controllers/WingmanController.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -57,14 +57,12 @@
//----action for hard calculations----
void WingmanController::action()
{
- if (!this || !this->getControllableEntity() || !this->isActive())
+ if (!this->getControllableEntity() || !this->isActive())
return;
//----If no leader, find one----
if (!this->myLeader_)
{
ActionpointController* newLeader = (findNewLeader());
- if (!this || !this->getControllableEntity())
- return;
this->myLeader_ = newLeader;
if (this->myLeader_)
@@ -91,8 +89,6 @@
}
else if (!this->myLeader_->bKeepFormation_)
{
- if (!this || !this->getControllableEntity())
- return;
if (!this->hasTarget())
{
Modified: code/trunk/src/orxonox/gametypes/LastManStanding.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/LastManStanding.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/gametypes/LastManStanding.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -87,7 +87,7 @@
{
if (it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
return true;
- const std::string& message = ""; // resets Camper-Warning-message
+ const std::string message = ""; // resets Camper-Warning-message
this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
}
}
@@ -194,7 +194,7 @@
{
if (it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
return;
- const std::string& message = ""; // resets Camper-Warning-message
+ const std::string message = ""; // resets Camper-Warning-message
this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
}
}
@@ -261,7 +261,7 @@
this->punishPlayer(mapEntry.first);
if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
return;
- const std::string& message = ""; // resets Camper-Warning-message
+ const std::string message = ""; // resets Camper-Warning-message
this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID());
}
}
@@ -269,7 +269,7 @@
{
if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
continue;
- const std::string& message = "Camper Warning! Don't forget to shoot.";
+ const std::string message = "Camper Warning! Don't forget to shoot.";
this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID());
}
}
Modified: code/trunk/src/orxonox/gametypes/LastTeamStanding.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/LastTeamStanding.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/gametypes/LastTeamStanding.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -135,7 +135,7 @@
{
if (it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
return true;
- const std::string& message = ""; // resets Camper-Warning-message
+ const std::string message = ""; // resets Camper-Warning-message
this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
}
}
@@ -169,7 +169,7 @@
{
if (it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
return;
- const std::string& message = ""; // resets Camper-Warning-message
+ const std::string message = ""; // resets Camper-Warning-message
this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
}
}
@@ -208,7 +208,7 @@
this->punishPlayer(mapEntry.first);
if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
return;
- const std::string& message = ""; // resets Camper-Warning-message
+ const std::string message = ""; // resets Camper-Warning-message
this->gtinfo_->sendFadingMessage(message, mapEntry.first->getClientID());
}
}
@@ -216,7 +216,7 @@
{
if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
continue;
- const std::string& message = "Camper Warning! Don't forget to shoot.";
+ const std::string message = "Camper Warning! Don't forget to shoot.";
this->gtinfo_->sendFadingMessage(message, mapEntry.first->getClientID());
}
}
Modified: code/trunk/src/orxonox/graphics/LensFlare.cc
===================================================================
--- code/trunk/src/orxonox/graphics/LensFlare.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/graphics/LensFlare.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -33,13 +33,17 @@
#include "LensFlare.h"
+#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
#include "graphics/Billboard.h"
#include "CameraManager.h"
+#include "Camera.h"
#include "RenderQueueListener.h"
+#include "Scene.h"
#include <OgreSphere.h>
#include <OgreRenderWindow.h>
+#include <OgreCamera.h>
namespace orxonox
{
Modified: code/trunk/src/orxonox/graphics/LensFlare.h
===================================================================
--- code/trunk/src/orxonox/graphics/LensFlare.h 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/graphics/LensFlare.h 2016-01-21 12:59:04 UTC (rev 11083)
@@ -40,6 +40,7 @@
#include "core/GraphicsManager.h"
#include "util/Math.h"
+#include "tools/interfaces/Tickable.h"
#include "worldentities/StaticEntity.h"
#include "graphics/Billboard.h"
Modified: code/trunk/src/orxonox/weaponsystem/Munition.cc
===================================================================
--- code/trunk/src/orxonox/weaponsystem/Munition.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/weaponsystem/Munition.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -543,7 +543,7 @@
if (bUseReloadTime && munition->reloadTime_ > 0 && munition->deployment_ != MunitionDeployment::Stack)
{
- const ExecutorPtr& executor = createExecutor(createFunctor(&Magazine::loaded, this));
+ const ExecutorPtr executor = createExecutor(createFunctor(&Magazine::loaded, this));
executor->setDefaultValues(munition);
this->loadTimer_.setTimer(munition->reloadTime_, false, executor);
Modified: code/trunk/src/orxonox/worldentities/StaticEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/StaticEntity.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/worldentities/StaticEntity.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -53,8 +53,9 @@
void StaticEntity::registerVariables()
{
- registerVariable(this->getPosition(), VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
- registerVariable(this->getOrientation(), VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
+ // Ugly const casts, but are valid because position and orientation are not actually const
+ registerVariable(const_cast<Vector3&>(this->getPosition()), VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
+ registerVariable(const_cast<Quaternion&>(this->getOrientation()), VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
}
Modified: code/trunk/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/WorldEntity.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/worldentities/WorldEntity.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -189,7 +189,8 @@
registerVariable(this->bActive_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
registerVariable(this->bVisible_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
- registerVariable(this->getScale3D(), VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::scaleChanged));
+ // Ugly const cast, but is valid because the scale is not actually const
+ registerVariable(const_cast<Vector3&>(this->getScale3D()), VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::scaleChanged));
// Physics stuff
registerVariable(this->mass_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::massChanged));
Modified: code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.h
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.h 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.h 2016-01-21 12:59:04 UTC (rev 11083)
@@ -45,18 +45,18 @@
FpsPlayer(Context* context);
virtual ~FpsPlayer();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- virtual void tick(float dt);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+ virtual void tick(float dt) override;
void registerVariables();
void setConfigValues();
- virtual void moveFrontBack(const Vector2& value);
- virtual void moveRightLeft(const Vector2& value);
- virtual void moveUpDown(const Vector2& value);
+ virtual void moveFrontBack(const Vector2& value) override;
+ virtual void moveRightLeft(const Vector2& value) override;
+ virtual void moveUpDown(const Vector2& value) override;
- virtual void rotateYaw(const Vector2& value);
- virtual void rotatePitch(const Vector2& value);
- virtual void rotateRoll(const Vector2& value);
+ virtual void rotateYaw(const Vector2& value) override;
+ virtual void rotatePitch(const Vector2& value) override;
+ virtual void rotateRoll(const Vector2& value) override;
inline void setMeshSource(const std::string& meshname)
@@ -64,17 +64,17 @@
inline const std::string& getMeshSource() const
{ return this->meshSrc_; }
- void boost(bool bBoost); //acctually jump
+ void boost(bool bBoost) override; //actually jump
virtual void fire();
virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
- virtual void addedWeaponPack(WeaponPack* wPack);
+ virtual void addedWeaponPack(WeaponPack* wPack) override;
protected:
- virtual void setPlayer(PlayerInfo* player);
- virtual void startLocalHumanControl();
+ virtual void setPlayer(PlayerInfo* player) override;
+ virtual void startLocalHumanControl() override;
bool bInvertYAxis_;
bool bBoost_;
@@ -88,7 +88,7 @@
btVector3 localAngularAcceleration_;
private:
- virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
+ virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const override;
float speed_;
void changedMesh();
Modified: code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc 2016-01-20 22:05:10 UTC (rev 11082)
+++ code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc 2016-01-21 12:59:04 UTC (rev 11083)
@@ -234,8 +234,8 @@
Pawn::rotateYaw(value);
// This function call adds a lift to the ship when it is rotating to make it's movement more "realistic" and enhance the feeling.
- if (this->getLocalVelocity().z < 0 && abs(this->getLocalVelocity().z) < stallSpeed_)
- this->moveRightLeft(-lift_ / 5.0f * value * sqrt(abs(this->getLocalVelocity().z)));
+ if (this->getLocalVelocity().z < 0 && std::abs(this->getLocalVelocity().z) < stallSpeed_)
+ this->moveRightLeft(-lift_ / 5.0f * value * sqrt(std::abs(this->getLocalVelocity().z)));
}
/**
@@ -256,8 +256,8 @@
Pawn::rotatePitch(pitch);
// This function call adds a lift to the ship when it is pitching to make it's movement more "realistic" and enhance the feeling.
- if (this->getLocalVelocity().z < 0 && abs(this->getLocalVelocity().z) < stallSpeed_)
- this->moveUpDown(lift_ / 5.0f * pitch * sqrt(abs(this->getLocalVelocity().z)));
+ if (this->getLocalVelocity().z < 0 && std::abs(this->getLocalVelocity().z) < stallSpeed_)
+ this->moveUpDown(lift_ / 5.0f * pitch * sqrt(std::abs(this->getLocalVelocity().z)));
}
/**
@@ -504,7 +504,7 @@
{
this->shakeDt_ += dt;
- float frequency = this->shakeFrequency_ * (square(abs(this->getLocalVelocity().z)));
+ float frequency = this->shakeFrequency_ * (square(std::abs(this->getLocalVelocity().z)));
if (this->shakeDt_ >= 1.0f/frequency)
this->shakeDt_ -= 1.0f/frequency;
More information about the Orxonox-commit
mailing list