Added serverGame library

This commit is contained in:
Anonymous
2014-01-15 03:59:18 -07:00
parent 89291fb38c
commit 0196cf51d0
1032 changed files with 256379 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,276 @@
// ======================================================================
//
// AiCreatureController.h
//
// copyright 2003, sony online entertainment
//
// ======================================================================
#ifndef INCLUDED_AiCreatureController_H
#define INCLUDED_AiCreatureController_H
//-----------------------------------------------------------------------
#include "serverGame/AiCreatureWeaponActions.h"
#include "serverGame/AiMovementBase.h"
#include "serverGame/CreatureController.h"
#include "serverGame/ServerCreatureObjectTemplate.h"
#include "sharedFoundation/MessageQueue.h"
#include "sharedGame/SharedCreatureObjectTemplate.h"
#include "sharedUtility/Location.h"
//----------------------------------------------------------------------
class AiMovementBase;
class AiCreatureData;
class AiDebugString;
class CrcString;
class CreatureObject;
class FloorLocator;
class TargetPathNode;
class WeightedTerrainPathEvaluator;
// ----------------------------------------------------------------------
class AICreatureController : public CreatureController
{
public:
static void install();
static AICreatureController * getAiCreatureController(NetworkId const & networkId);
static AICreatureController * asAiCreatureController(Controller * controller);
static AICreatureController const * asAiCreatureController(Controller const * controller);
static float getLeashRadius();
public:
explicit AICreatureController (CreatureObject * newOwner);
~AICreatureController ();
virtual AICreatureController * asAiCreatureController();
virtual AICreatureController const * asAiCreatureController() const;
virtual void handleMessage (int message, float value, const MessageQueue::Data *data, uint32 flags);
// ----------
// Script Hooks
void setCreatureName(std::string const & creatureName);
PersistentCrcString const & getCreatureName() const; // The "creatureName" column from creatures_datatable.xml
// Movement commands for scripting use - Action States
const AiMovementBase * getCurrentMovement() const;
void moveTo (CellProperty const * cell, Vector const & target_p, float const radius = 0.0f);
void moveTo (Unicode::String const & targetName);
void patrol ( stdvector<Location>::fwd const & locations, bool random, bool flip, bool repeat, int startPoint);
void patrol ( stdvector<Unicode::String>::fwd const & locations, bool random, bool flip, bool repeat, int startPoint);
bool wander ( float minLength, float maxLength, float minAngle, float maxAngle, float minDelay, float maxDelay );
void loiter (CellProperty const * homeCell, Vector const & home_p, float const minDistance, float const maxDistance, float const minDelay, float const maxDelay);
void loiter (NetworkId const & target, float const minDistance, float const maxDistance, float const minDelay, float const maxDelay);
bool follow ( NetworkId const & target, float minDistance, float maxDistance );
bool follow ( NetworkId const & target, Vector const & offset );
bool swarm ( NetworkId const & target );
bool swarm ( NetworkId const & target, float offset );
bool flee ( NetworkId const & target, float minDistance, float maxDistance );
bool faceTo ( CellProperty const * targetCell, Vector const & target_p );
bool faceTo ( NetworkId const & target );
void stop ();
void setMovementRun ( void );
void setMovementWalk ( void );
// ----------
void moveCreature ( CellProperty const * newCell, Vector const & newPosition, bool testMove );
void getBehaviorDebugInfo ( std::string & outString ) const;
void changeMovement (AiMovementBasePtr newMovement);
bool hasPendingMovement () const;
bool suspendMovement ();
bool resumeMovement ();
bool hasSuspendedMovement ();
float getSpeed () const;
void setSpeed (float const newSpeed);
bool isRunning ( void ) const;
float getAcceleration ( void ) const;
void moveTowards ( CellProperty const * cell, Vector const & position, float time );
bool moveAlongGround ( CellProperty const * cell, Vector const & target, float distance );
void turnToward ( CellProperty const * cell, Vector const & target );
float getDistanceToLocationSquared(CellProperty const * cell, Vector const & target) const;
bool reachedPoint ( CellProperty const * cell, Vector const & point, float radius ) const;
void warpToTarget ( void );
void warpToPathpoint ( void );
void warpToWaypoint ( void );
void warpTo ( CellProperty const * cell, Vector const & position );
void updateMovementType ( void );
// ----------
CreatureObject const * getCreature ( void ) const;
CreatureObject * getCreature ( void );
CellProperty const * getCreatureCell ( void ) const;
Vector getCreaturePosition_p ( void ) const;
Vector getCreaturePosition_w ( void ) const;
float getCreatureRadius ( void ) const;
// ----------
void triggerScriptsSimple ( int scriptId );
void triggerScriptsWithTarget( int scriptId, NetworkId const & targetId );
void triggerScriptsWithParam ( int scriptId, float & io_param );
void sleep ( float sleepTime );
virtual bool shouldHibernate ( void ) const;
virtual void setHibernate (bool hibernate);
void setHibernationDelay (float delay);
// float getHibernationDelay () const;
int getStuckCounter ( void ) const;
void setAuthority ( bool authority );
void forwardServerObjectSpecificBaselines() const;
void equipPrimaryWeapon();
void equipSecondaryWeapon();
void unEquipWeapons();
bool hasPrimaryWeapon() const;
bool hasSecondaryWeapon() const;
bool usingPrimaryWeapon();
bool usingSecondaryWeapon();
NetworkId const & getPrimaryWeapon() const;
NetworkId const & getSecondaryWeapon() const;
void setHomeLocation(Location const & homeLocation);
Location const & getHomeLocation() const;
void markCombatStartLocation();
Location const & getCombatStartLocation() const;
float getMovementSpeedPercent() const; // Percent relative to an unarmed player
void setFrozen(bool const frozen);
bool isFrozen() const;
void addServerNpAutoDeltaVariables(Archive::AutoDeltaByteStream & stream);
bool isAggressive() const;
bool isAssist() const;
bool isStalker() const;
bool isKiller() const;
void setRetreating(bool const retreating);
bool isRetreating() const;
bool isCombatAi() const;
void setLogging(bool const logging);
bool isLogging() const;
void setMovementPaused(bool const paused);
bool isMovementPaused() const;
float getAggroRadius() const;
float getRespectRadius(NetworkId const & target) const;
float getAssistRadius() const;
AiMovementType getMovementType() const;
AiMovementType getPendingMovementType() const;
PersistentCrcString const & getCombatAction();
time_t getKnockDownRecoveryTime() const;
std::string const getCombatActionsString();
protected:
static float getGroundDistance ( Vector const & A, Vector const & B );
virtual float realAlter ( float time );
private:
#ifdef _DEBUG
void sendDebugAiToClients(AiDebugString & aiDebugString);
#endif // _DEBUG
void setPrimaryWeapon(CrcString const & objectTemplate);
void setSecondaryWeapon(CrcString const & objectTemplate);
void destroyPrimaryWeapon();
void destroySecondaryWeapon();
void applyMovementChange();
void setupCreatureData(std::string const & creatureName);
NetworkId createWeapon(char const * const functionName, CrcString const & weaponName, bool const required);
NetworkId getUnarmedWeapon();
std::string getDebugInformation() const;
void sendMessageToAuthServer(GameControllerMessage const gameControllerMessage);
void sendMessageToAuthServer(GameControllerMessage const gameControllerMessage, MessageQueue::Data * messageQueue);
void sendMessageToProxyServer(GameControllerMessage const gameControllerMessage, MessageQueue::Data * messageQueue);
void onCreatureNameChanged(std::string const & creatureName);
struct CreatureNameChangedCallback
{
void modified(AICreatureController & target, std::string const & oldValue, std::string const & newValue, bool local) const;
};
friend struct CreatureNameChangedCallback;
AiMovementBasePtr m_movement;
AiMovementBasePtr m_pendingMovement;
AiMovementBasePtr m_suspendedMovement;
Vector m_lastStartPosition;
Vector m_lastEndPosition;
float m_sleepTimer;
bool m_inPathfindingRegion;
int m_stuckCounter;
bool m_authority;
float m_speed;
AiCreatureData const * m_aiCreatureData;
AiCreatureWeaponActions m_primaryWeaponActions;
AiCreatureWeaponActions m_secondaryWeaponActions;
Archive::AutoDeltaVariable<bool> m_running;
Archive::AutoDeltaVariable<Location> m_homeLocation;
Archive::AutoDeltaVariable<NetworkId> m_primaryWeapon;
Archive::AutoDeltaVariable<NetworkId> m_secondaryWeapon;
Archive::AutoDeltaVariable<bool> m_frozen;
Archive::AutoDeltaVariable<Location> m_combatStartLocation;
Archive::AutoDeltaVariable<bool> m_retreating;
Archive::AutoDeltaVariable<time_t> m_retreatingStartTime;
Archive::AutoDeltaVariable<bool> m_logging;
Archive::AutoDeltaVariableCallback<std::string, CreatureNameChangedCallback, AICreatureController> m_creatureName;
Archive::AutoDeltaVariable<float> m_hibernationDelay;
Archive::AutoDeltaVariable<float> m_hibernationTimer;
#ifdef _DEBUG
uint32 m_aiDebugStringCrc;
#endif // _DEBUG
bool m_invalidTarget;
private:
AICreatureController();
AICreatureController(AICreatureController const & rhs);
AICreatureController & operator =(AICreatureController const & rhs);
};
//-----------------------------------------------------------------------
inline const AiMovementBase * AICreatureController::getCurrentMovement() const
{
return m_movement.get();
}
//-----------------------------------------------------------------------
#endif // INCLUDED_AiCreatureController_H
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,235 @@
// ======================================================================
//
// AiShipController.h
// asommers
//
// copyright 2003, sony online entertainment
//
// ======================================================================
#ifndef INCLUDED_AiShipController_H
#define INCLUDED_AiShipController_H
// ======================================================================
#include "serverGame/AiShipBehaviorAttack.h"
#include "serverGame/ShipAiReactionManager.h"
#include "serverGame/ShipController.h"
#include "sharedFoundation/PersistentCrcString.h"
class AiDebugString;
class AiPilotManager;
class AiShipBehaviorAttack;
class AiShipBehaviorBase;
class AiShipBehaviorDock;
class CachedNetworkId;
class ShipObject;
class SpaceAttackSquad;
class SpacePath;
class SpaceSquad;
class Timer;
struct AiShipPilotData;
// ======================================================================
class AiShipController : public ShipController
{
public:
enum AttackOrders
{
AO_holdFire,
AO_returnFire,
AO_attackFreely,
AO_count
};
typedef stdvector<Transform>::fwd TransformList;
typedef stdvector<CachedNetworkId>::fwd CachedNetworkIdList;
typedef stdvector<NetworkId>::fwd NetworkIdList;
static void install();
static void setClientDebugEnabled(bool const enabled);
static bool isClientDebugEnabled();
static AiShipController * getAiShipController(NetworkId const & unit);
static AiShipController * asAiShipController(Controller * controller);
static AiShipController const * asAiShipController(Controller const * controller);
static void setAttackingEnabled(bool const enabled);
static float getGoalStopDistance();
static char const * getAttackOrdersString(AttackOrders const attackOrders);
public:
explicit AiShipController(ShipObject * const owner);
virtual ~AiShipController();
virtual AiShipController * asAiShipController();
virtual AiShipController const * asAiShipController() const;
virtual void endBaselines();
virtual void onTargetedByMissile(int const missileId);
virtual void onAttackTargetListEmpty();
void setSquad(SpaceSquad * const squad);
SpaceSquad & getSquad();
SpaceSquad const & getSquad() const;
bool isSquadLeader() const;
void setAttackSquad(SpaceAttackSquad * const attackSquad);
SpaceAttackSquad & getAttackSquad();
SpaceAttackSquad const & getAttackSquad() const;
bool isAttackSquadLeader() const;
PersistentCrcString const & getShipName() const;
void setPilotType(std::string const & pilotType);
std::string const & getPilotType() const;
AiShipPilotData const * getPilotData(void) const;
float getPilotSkill() const;
float getPilotAggression() const;
int getBehaviorType() const;
virtual bool addDamageTaken(NetworkId const & attackingUnit, float const damage, bool const verifyAttacker);
bool addDamageTaken(NetworkId const & attackingUnit, float const damage, bool const verifyAttacker, bool const notifySquad, bool const checkPlayerAttacker);
CachedNetworkId const & getPrimaryAttackTarget() const;
ShipObject const * getPrimaryAttackTargetShipObject() const;
virtual bool removeAttackTarget(NetworkId const & targetUnit);
bool isValidTarget(ShipObject const & unit) const;
bool isAttacking() const;
void setAttackOrders(AttackOrders const attackOrders);
AttackOrders getAttackOrders() const;
void setLeashRadius(float const radius);
void moveTo(SpacePath * const path);
void addPatrolPath(SpacePath * const path);
void clearPatrolPath();
void follow(NetworkId const & followedUnit, Vector const & direction_l, float const distance);
void idle();
void track(Object const & target);
void requestSlowDown();
virtual void dock(ShipObject & dockTarget, float const secondsAtDock);
float getAggroRadius() const;
void setAggroRadius(float const radius);
void moveTo(Vector const & position_w, float const throttle, float const deltaTime);
Vector const & getMoveToGoalPosition_w() const;
Vector getOwnerPosition_w() const;
Vector getOwnerObjectFrameK_w() const;
virtual bool shouldCheckForEnemies() const;
void setFormationPosition_l(Vector const & position_l);
Vector const & getFormationPosition_l() const;
void setAttackFormationPosition_l(Vector const & position_l);
Vector const & getAttackFormationPosition_l() const;
float getShipRadius() const;
SpacePath * getPath();
void setCurrentPathIndex(unsigned int const index);
unsigned int getCurrentPathIndex() const;
float calculateThrottleToPosition_w(Vector const & position_w, float const slowDownDistance) const;
void switchToFighterAttack();
void switchToBomberAttack();
AiPilotManager const & getPilotManagerInfo() const;
void clampPositionToZone(Vector & position_w) const;
void addExclusiveAggro(NetworkId const & unit);
void removeExclusiveAggro(NetworkId const & unit);
bool isExclusiveAggro(CreatureObject const & pilot) const;
bool hasExclusiveAggros() const;
ShipAiReactionManager::ShipClass getShipClass() const;
virtual float getTurretMissChance() const;
virtual float getTurretMissAngle() const;
#ifdef _DEBUG
bool debug_forceFighterAttackManeuver(int maneuverType);
#endif // _DEBUG
protected:
virtual float realAlter(float elapsedTime);
private:
typedef stdset<CachedNetworkId>::fwd CachedNetworkIdSet;
enum CountermeasureState
{
CS_none,
CS_reacting,
CS_launching
};
void triggerBehaviorChanged(AiShipBehaviorType const newBehavior);
void triggerEnterCombat(NetworkId const & attackTarget);
bool hasFunctionalEngines() const;
#ifdef _DEBUG
void sendDebugAiToClients(AiDebugString & aiDebugString);
#endif // _DEBUG
AiShipPilotData const * m_pilotData;
AiShipBehaviorBase * m_pendingNonAttackBehavior;
AiShipBehaviorBase * m_nonAttackBehavior;
AiShipBehaviorAttack * m_pendingAttackBehavior;
AiShipBehaviorAttack * m_attackBehavior;
PersistentCrcString m_shipName;
ShipAiReactionManager::ShipClass m_shipClass;
bool m_requestedSlowDown;
SpaceSquad * m_squad;
SpaceAttackSquad * m_attackSquad;
Vector m_formationPosition_l;
Vector m_attackFormationPosition_l;
SpacePath * m_path;
unsigned int m_currentPathIndex;
float m_aggroRadius;
CountermeasureState m_countermeasureState;
Timer * const m_reactToMissileTimer;
#ifdef _DEBUG
uint32 m_aiDebugStringCrc;
#endif // _DEBUG
Vector m_moveToGoalPosition_w;
int m_lastAttackUpdate;
AiPilotManager * const m_pilotManagerInfo;
AttackOrders m_attackOrders;
CachedNetworkIdSet * const m_exclusiveAggroSet;
// Disabled
AiShipController();
AiShipController(AiShipController const &);
AiShipController & operator =(AiShipController const &);
};
// ----------------------------------------------------------------------
inline AiShipPilotData const * AiShipController::getPilotData(void) const
{
return m_pilotData;
}
inline AiPilotManager const & AiShipController::getPilotManagerInfo() const
{
return *m_pilotManagerInfo;
}
// ======================================================================
#endif
@@ -0,0 +1,194 @@
// ======================================================================
//
// AiShipControllerInterface.cpp
//
// copyright 2004, sony online entertainment
//
// ======================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/AiShipControllerInterface.h"
#include "serverGame/AiShipController.h"
#include "serverGame/ConfigServerGame.h"
#include "sharedLog/Log.h"
// ======================================================================
//
// AiShipControllerInterface
//
// ======================================================================
// ----------------------------------------------------------------------
bool AiShipControllerInterface::addDamageTaken(NetworkId const & unit, NetworkId const & attackingUnit, float const damage, bool const notifySquad, bool const checkPlayerAttacker)
{
bool result = false;
AiShipController * const aiShipController = AiShipController::getAiShipController(unit);
if (aiShipController != NULL)
{
bool const verifyAttacker = false;
result = aiShipController->addDamageTaken(attackingUnit, damage, verifyAttacker, notifySquad, checkPlayerAttacker);
}
else
{
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("AiShipControllerInterface::addDamageTaken() ERROR: Unable to resolve networkId(%s) to AiShipController.", unit.getValueString().c_str()));
}
return result;
}
// ----------------------------------------------------------------------
bool AiShipControllerInterface::setAttackOrders(NetworkId const & unit, AiShipController::AttackOrders const attackOrders)
{
bool result = false;
AiShipController * const aiShipController = AiShipController::getAiShipController(unit);
if (aiShipController != NULL)
{
result = true;
aiShipController->setAttackOrders(attackOrders);
}
else
{
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("AiShipControllerInterface::setAttackOrders() ERROR: Unable to resolve networkId(%s) to AiShipController.", unit.getValueString().c_str()));
}
return result;
}
// ----------------------------------------------------------------------
bool AiShipControllerInterface::idle(NetworkId const & unit)
{
bool result = false;
AiShipController * const aiShipController = AiShipController::getAiShipController(unit);
if (aiShipController != NULL)
{
result = true;
aiShipController->idle();
}
else
{
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("AiShipControllerInterface::idle() ERROR: Unable to resolve networkId(%s) to AiShipController.", unit.getValueString().c_str()));
}
return result;
}
// ----------------------------------------------------------------------
bool AiShipControllerInterface::track(NetworkId const & unit, Object const & target)
{
bool result = false;
AiShipController * const aiShipController = AiShipController::getAiShipController(unit);
if (aiShipController != NULL)
{
result = true;
aiShipController->track(target);
}
else
{
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("AiShipControllerInterface::idle() ERROR: Unable to resolve networkId(%s) to AiShipController.", unit.getValueString().c_str()));
}
return result;
}
// ----------------------------------------------------------------------
bool AiShipControllerInterface::setLeashRadius(NetworkId const & unit, float const radius)
{
bool result = false;
AiShipController * const aiShipController = AiShipController::getAiShipController(unit);
if (aiShipController != NULL)
{
result = true;
aiShipController->setLeashRadius(radius);
}
else
{
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("AiShipControllerInterface::setLeashRadius() ERROR: Unable to resolve networkId(%s) to AiShipController.", unit.getValueString().c_str()));
}
return result;
}
// ----------------------------------------------------------------------
bool AiShipControllerInterface::follow(NetworkId const & unit, NetworkId const & followedUnit, Vector const & direction_o, float const direction)
{
bool result = false;
AiShipController * const aiShipController = AiShipController::getAiShipController(unit);
if (aiShipController != NULL)
{
result = true;
aiShipController->follow(followedUnit, direction_o, direction);
}
else
{
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("AiShipControllerInterface::follow() ERROR: Unable to resolve networkId(%s) to AiShipController.", unit.getValueString().c_str()));
}
return result;
}
// ----------------------------------------------------------------------
bool AiShipControllerInterface::addPatrolPath(NetworkId const & unit, SpacePath * const path)
{
bool result = false;
AiShipController * const aiShipController = AiShipController::getAiShipController(unit);
if (aiShipController != NULL)
{
result = true;
aiShipController->addPatrolPath(path);
}
else
{
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("AiShipControllerInterface::addPatrolPath() ERROR: Unable to resolve networkId(%s) to AiShipController.", unit.getValueString().c_str()));
}
return result;
}
// ----------------------------------------------------------------------
bool AiShipControllerInterface::clearPatrolPath(NetworkId const & unit)
{
bool result = false;
AiShipController * const aiShipController = AiShipController::getAiShipController(unit);
if (aiShipController != NULL)
{
result = true;
aiShipController->clearPatrolPath();
}
else
{
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("AiShipControllerInterface::clearPatrolPath() ERROR: Unable to resolve networkId(%s) to AiShipController.", unit.getValueString().c_str()));
}
return result;
}
// ----------------------------------------------------------------------
bool AiShipControllerInterface::moveTo(NetworkId const & unit, SpacePath * const path)
{
bool result = false;
AiShipController * const aiShipController = AiShipController::getAiShipController(unit);
if (aiShipController != NULL)
{
result = true;
aiShipController->moveTo(path);
}
else
{
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("AiShipControllerInterface::moveTo() ERROR: Unable to resolve networkId(%s) to AiShipController.", unit.getValueString().c_str()));
}
return result;
}
// ======================================================================
@@ -0,0 +1,45 @@
// ======================================================================
//
// AiShipControllerInterface.h
//
// copyright 2004, sony online entertainment
//
// ======================================================================
#ifndef INCLUDED_AiShipControllerInterface_H
#define INCLUDED_AiShipControllerInterface_H
#include "serverGame/AiShipController.h"
class NetworkId;
class Object;
class SpacePath;
class Vector;
// ----------------------------------------------------------------------
class AiShipControllerInterface
{
public:
static bool addDamageTaken(NetworkId const & unit, NetworkId const & attackingUnit, float const damage, bool const notifySquad, bool const checkPlayerAttacker);
static bool setAttackOrders(NetworkId const & unit, AiShipController::AttackOrders attackOrders);
static bool setLeashRadius(NetworkId const & unit, float radius);
static bool idle(NetworkId const & unit);
static bool track(NetworkId const & unit, Object const & target);
static bool follow(NetworkId const & unit, NetworkId const & followedUnit, Vector const & direction, float offset);
static bool addPatrolPath(NetworkId const & unit, SpacePath * const path);
static bool clearPatrolPath(NetworkId const & unit);
static bool moveTo(NetworkId const & unit, SpacePath * const path);
private:
// Disabled
AiShipControllerInterface();
AiShipControllerInterface(AiShipControllerInterface const &);
AiShipControllerInterface & operator =(AiShipControllerInterface const &);
};
// ======================================================================
#endif // INCLUDED_AiShipControllerInterface_H
@@ -0,0 +1,59 @@
// ======================================================================
//
// BattlefieldMarkerController.cpp
//
// Copyright 2003 Sony Online Entertainment
//
// ======================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/BattlefieldMarkerController.h"
#include "serverGame/BattlefieldMarkerObject.h"
#include "serverGame/ServerWorld.h"
#include "sharedFoundation/GameControllerMessage.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
// ======================================================================
BattlefieldMarkerController::BattlefieldMarkerController(BattlefieldMarkerObject *newOwner) :
TangibleController(newOwner)
{
}
// ----------------------------------------------------------------------
BattlefieldMarkerController::~BattlefieldMarkerController()
{
}
// ----------------------------------------------------------------------
void BattlefieldMarkerController::handleMessage(const int message, const float value, const MessageQueue::Data* const data, const uint32 flags)
{
BattlefieldMarkerObject *owner = dynamic_cast<BattlefieldMarkerObject *>(getOwner());
NOT_NULL(owner);
switch (message)
{
case CM_setBattlefieldParticipant:
{
MessageQueueGenericValueType<std::pair<NetworkId, uint32> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<NetworkId, uint32> > const *>(data);
owner->setBattlefieldParticipant(msg->getValue().first, msg->getValue().second);
}
break;
case CM_clearBattlefieldParticipants:
{
owner->clearBattlefieldParticipants();
}
break;
default:
TangibleController::handleMessage(message, value, data, flags);
break;
}
}
// ======================================================================
@@ -0,0 +1,40 @@
// ======================================================================
//
// BattlefieldMarkerController.h
//
// Copyright 2003 Sony Online Entertainment
//
// ======================================================================
#ifndef _INCLUDED_BattlefieldMarkerController_H
#define _INCLUDED_BattlefieldMarkerController_H
//-----------------------------------------------------------------------
#include "serverGame/TangibleController.h"
//----------------------------------------------------------------------
class BattlefieldMarkerObject;
//-----------------------------------------------------------------------
class BattlefieldMarkerController : public TangibleController
{
public:
explicit BattlefieldMarkerController(BattlefieldMarkerObject *newOwner);
virtual ~BattlefieldMarkerController();
protected:
virtual void handleMessage(int message, float value, const MessageQueue::Data* data, uint32 flags);
private:
BattlefieldMarkerController();
BattlefieldMarkerController(BattlefieldMarkerController const &);
BattlefieldMarkerController &operator=(BattlefieldMarkerController const &);
};
// ======================================================================
#endif
@@ -0,0 +1,88 @@
//BuildingController.cpp
//-----------------------------------------------------------------------
#include "serverGame/FirstServerGame.h"
#include "serverGame/BuildingController.h"
#include "serverGame/BuildingObject.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
//-----------------------------------------------------------------------
BuildingController::BuildingController(BuildingObject * newOwner) :
TangibleController(newOwner)
{
}
//-----------------------------------------------------------------------
BuildingController::~BuildingController()
{
}
//-----------------------------------------------------------------------
void BuildingController::handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags)
{
BuildingObject * owner = dynamic_cast<BuildingObject *>(getOwner());
NOT_NULL(owner);
switch (message)
{
case CM_addAllowed:
{
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
if(msg)
{
owner->addAllowed(msg->getValue());
}
}
break;
case CM_removeAllowed:
{
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
if(msg)
{
owner->removeAllowed(msg->getValue());
}
}
break;
case CM_addBanned:
{
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
if(msg)
{
owner->addBanned(msg->getValue());
}
}
break;
case CM_removeBanned:
{
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
if(msg)
{
owner->removeBanned(msg->getValue());
}
}
break;
case CM_setBuildingIsPublic:
{
MessageQueueGenericValueType<bool> const *msg = safe_cast<MessageQueueGenericValueType<bool> const *>(data);
if (msg)
owner->setIsPublic(msg->getValue());
}
break;
case CM_setBuildingCityId:
{
MessageQueueGenericValueType<int> const *msg = safe_cast<MessageQueueGenericValueType<int> const *>(data);
if (msg)
owner->setCityId(msg->getValue());
}
break;
default:
TangibleController::handleMessage(message, value, data, flags);
break;
}
}
//-----------------------------------------------------------------------
@@ -0,0 +1,33 @@
//BuildingController.h
#ifndef _BUILDING_CONTROLLER_H
#define _BUILDING_CONTROLLER_H
//-----------------------------------------------------------------------
#include "serverGame/TangibleController.h"
//----------------------------------------------------------------------
class BuildingObject;
//-----------------------------------------------------------------------
class BuildingController : public TangibleController
{
public:
explicit BuildingController (BuildingObject * newOwner);
~BuildingController (void);
protected:
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
private:
BuildingController (void);
BuildingController (const BuildingController & other);
BuildingController& operator= (const BuildingController & other);
};
//-----------------------------------------------------------------------
#endif
@@ -0,0 +1,84 @@
// CellController.cpp
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
//-----------------------------------------------------------------------
#include "serverGame/FirstServerGame.h"
#include "serverGame/CellController.h"
#include "serverGame/CellObject.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
//-----------------------------------------------------------------------
CellController::CellController(CellObject * newOwner) :
ServerController(newOwner)
{
}
//-----------------------------------------------------------------------
CellController::~CellController()
{
}
//-----------------------------------------------------------------------
void CellController::handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags)
{
CellObject * owner = dynamic_cast<CellObject *>(getOwner());
NOT_NULL(owner);
switch (message)
{
case CM_addAllowed:
{
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
if(msg)
{
owner->addAllowed(msg->getValue());
}
}
break;
case CM_removeAllowed:
{
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
if(msg)
{
owner->removeAllowed(msg->getValue());
}
}
break;
case CM_addBanned:
{
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
if(msg)
{
owner->addBanned(msg->getValue());
}
}
break;
case CM_removeBanned:
{
const MessageQueueGenericValueType<std::string> * const msg = safe_cast<const MessageQueueGenericValueType<std::string> *>(data);
if(msg)
{
owner->removeBanned(msg->getValue());
}
}
break;
default:
ServerController::handleMessage(message, value, data, flags);
break;
}
}
//-----------------------------------------------------------------------
void CellController::setGoal(Transform const & , ServerObject * )
{
DEBUG_WARNING(true, ("Cell setGoal was called for CellObject %s. Cells may not have goals!",getOwner()->getNetworkId().getValueString().c_str()));
}
//-----------------------------------------------------------------------
@@ -0,0 +1,34 @@
// CellController.h
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
#ifndef _INCLUDED_CellController_H
#define _INCLUDED_CellController_H
//-----------------------------------------------------------------------
#include "serverGame/ServerController.h"
class CellObject;
//-----------------------------------------------------------------------
class CellController : public ServerController
{
public:
explicit CellController(CellObject * newOwner);
~CellController();
protected:
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
virtual void setGoal (Transform const & newGoal, ServerObject * goalCellObject );
private:
CellController & operator = (const CellController & rhs);
CellController(const CellController & source);
};
//-----------------------------------------------------------------------
#endif // _INCLUDED_CellController_H
@@ -0,0 +1,238 @@
// ======================================================================
//
// CityController.cpp
//
// Copyright 2003 Sony Online Entertainment
//
// ======================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/CityController.h"
#include "serverGame/CityObject.h"
#include "sharedFoundation/GameControllerMessage.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
// ======================================================================
CityController::CityController(CityObject *newOwner) :
UniverseController(newOwner)
{
}
// ----------------------------------------------------------------------
CityController::~CityController()
{
}
// ----------------------------------------------------------------------
void CityController::handleMessage(const int message, const float value, const MessageQueue::Data* const data, const uint32 flags)
{
CityObject *owner = dynamic_cast<CityObject *>(getOwner());
NOT_NULL(owner);
switch (message)
{
case CM_cityCreate:
{
MessageQueueGenericValueType<std::pair<int, CityInfo> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, CityInfo> > const *>(data);
const CityInfo & ci = msg->getValue().second;
IGNORE_RETURN(owner->createCity(ci.getCityName(),
ci.getCityHallId(),
ci.getPlanet(),
ci.getX(),
ci.getZ(),
ci.getRadius(),
ci.getLeaderId(),
ci.getIncomeTax(),
ci.getPropertyTax(),
ci.getSalesTax(),
ci.getTravelLoc(),
ci.getTravelCost(),
ci.getTravelInterplanetary(),
ci.getCloneLoc(),
ci.getCloneRespawn(),
ci.getCloneRespawnCell(),
ci.getCloneId(),
msg->getValue().first));
}
break;
case CM_citySetName:
{
MessageQueueGenericValueType<std::pair<int, std::string> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, std::string> > const *>(data);
owner->setCityName(msg->getValue().first, msg->getValue().second);
}
break;
case CM_citySetCityHall:
{
MessageQueueGenericValueType<std::pair<int, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, NetworkId> > const *>(data);
owner->setCityHall(msg->getValue().first, msg->getValue().second);
}
break;
case CM_citySetLocation:
{
MessageQueueGenericValueType<std::pair<int, std::pair<std::string, std::pair<int, int> > > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, std::pair<std::string, std::pair<int, int> > > > const *>(data);
owner->setCityLocation(
msg->getValue().first,
msg->getValue().second.first,
msg->getValue().second.second.first,
msg->getValue().second.second.second);
}
break;
case CM_citySetRadius:
{
MessageQueueGenericValueType<std::pair<int, int> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, int> > const *>(data);
owner->setCityRadius(msg->getValue().first, msg->getValue().second);
}
break;
case CM_citySetFaction:
{
MessageQueueGenericValueType<std::pair<int, std::pair<uint32, bool> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, std::pair<uint32, bool> > > const *>(data);
owner->setCityFaction(msg->getValue().first, msg->getValue().second.first, msg->getValue().second.second);
}
break;
case CM_citySetGcwDefenderRegion:
{
MessageQueueGenericValueType<std::pair<std::pair<int, std::string>, std::pair<int, bool> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, std::string>, std::pair<int, bool> > > const *>(data);
owner->setCityGcwDefenderRegion(msg->getValue().first.first, msg->getValue().first.second, msg->getValue().second.first, msg->getValue().second.second);
}
break;
case CM_citySetCreationTime:
{
MessageQueueGenericValueType<std::pair<int, int> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, int> > const *>(data);
owner->setCityCreationTime(msg->getValue().first, msg->getValue().second);
}
break;
case CM_citySetLeader:
{
MessageQueueGenericValueType<std::pair<int, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, NetworkId> > const *>(data);
owner->setCityLeader(msg->getValue().first, msg->getValue().second);
}
break;
case CM_citySetIncomeTax:
{
MessageQueueGenericValueType<std::pair<int, int> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, int> > const *>(data);
owner->setCityIncomeTax(msg->getValue().first, msg->getValue().second);
}
break;
case CM_citySetPropertyTax:
{
MessageQueueGenericValueType<std::pair<int, int> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, int> > const *>(data);
owner->setCityPropertyTax(msg->getValue().first, msg->getValue().second);
}
break;
case CM_citySetSalesTax:
{
MessageQueueGenericValueType<std::pair<int, int> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, int> > const *>(data);
owner->setCitySalesTax(msg->getValue().first, msg->getValue().second);
}
break;
case CM_citySetTravelInfo:
{
MessageQueueGenericValueType<std::pair<int, std::pair<Vector, std::pair<int, bool> > > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, std::pair<Vector, std::pair<int, bool> > > > const *>(data);
owner->setCityTravelInfo(
msg->getValue().first,
msg->getValue().second.first,
msg->getValue().second.second.first,
msg->getValue().second.second.second);
}
break;
case CM_citySetCloneInfo:
{
MessageQueueGenericValueType<std::pair<int, std::pair<Vector, std::pair<Vector, std::pair<NetworkId, NetworkId> > > > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, std::pair<Vector, std::pair<Vector, std::pair<NetworkId, NetworkId> > > > > const *>(data);
owner->setCityCloneInfo(
msg->getValue().first,
msg->getValue().second.first,
msg->getValue().second.second.first,
msg->getValue().second.second.second.first,
msg->getValue().second.second.second.second);
}
break;
case CM_cityRemove:
{
MessageQueueGenericValueType<int> const *msg = safe_cast<MessageQueueGenericValueType<int> const *>(data);
owner->removeCity(msg->getValue());
}
break;
case CM_citySetCitizen:
{
MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, std::pair<NetworkId, int> > > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, std::pair<NetworkId, int> > > > const *>(data);
owner->setCitizen(msg->getValue().first.first, msg->getValue().first.second, msg->getValue().second.first, msg->getValue().second.second.first, msg->getValue().second.second.second);
}
break;
case CM_citySetCitizenProfessionInfo:
{
MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, int> > > const *>(data);
owner->setCitizenProfessionInfo(msg->getValue().first.first, msg->getValue().first.second, msg->getValue().second.first, msg->getValue().second.second);
}
break;
case CM_citySetCitizenAddRank:
{
MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *>(data);
owner->addCitizenRank(msg->getValue().second.second, msg->getValue().second.first, msg->getValue().first);
}
break;
case CM_citySetCitizenRemoveRank:
{
MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *>(data);
owner->removeCitizenRank(msg->getValue().second.second, msg->getValue().second.first, msg->getValue().first);
}
break;
case CM_citySetCitizenTitle:
{
MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *>(data);
owner->setCitizenTitle(msg->getValue().second.second, msg->getValue().second.first, msg->getValue().first);
}
break;
case CM_cityRemoveCitizen:
{
MessageQueueGenericValueType<std::pair<int, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, NetworkId> > const *>(data);
owner->removeCitizen(msg->getValue().first, msg->getValue().second);
}
break;
case CM_citySetStructure:
{
MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<int, bool> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<int, bool> > > const *>(data);
owner->setCityStructure(msg->getValue().first.first, msg->getValue().first.second, msg->getValue().second.first, msg->getValue().second.second);
}
break;
case CM_cityRemoveStructure:
{
MessageQueueGenericValueType<std::pair<int, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, NetworkId> > const *>(data);
owner->removeCityStructure(msg->getValue().first, msg->getValue().second);
}
break;
case CM_adjustPgcRating:
{
MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *>(data);
owner->adjustPgcRating(msg->getValue().second.first, msg->getValue().first, msg->getValue().second.second);
}
break;
case CM_adjustPgcRatingData:
{
MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, int> > > const *>(data);
owner->adjustPgcRatingData(msg->getValue().first.second, msg->getValue().second.first, msg->getValue().first.first, msg->getValue().second.second);
}
break;
case CM_setPgcRatingData:
{
MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, int> > > const *>(data);
owner->setPgcRatingData(msg->getValue().first.second, msg->getValue().second.first, msg->getValue().first.first, msg->getValue().second.second);
}
break;
case CM_fixPgcChroniclerName:
{
MessageQueueGenericValueType<std::pair<std::string, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::string, NetworkId> > const *>(data);
owner->verifyPgcChroniclerName(msg->getValue().second, msg->getValue().first);
}
break;
default:
UniverseController::handleMessage(message, value, data, flags);
break;
}
}
// ======================================================================
@@ -0,0 +1,40 @@
// ======================================================================
//
// CityController.h
//
// Copyright 2002 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_CityController_H
#define INCLUDED_CityController_H
// ======================================================================
#include "serverGame/UniverseController.h"
// ======================================================================
class CityObject;
// ======================================================================
class CityController: public UniverseController
{
public:
explicit CityController(CityObject *newOwner);
~CityController();
protected:
virtual void handleMessage(int message, float value, const MessageQueue::Data* data, uint32 flags);
private:
CityController();
CityController(CityController const &);
CityController& operator=(CityController const &);
};
// ======================================================================
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,120 @@
//========================================================================
//
// CreatureController.h
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#ifndef INCLUDED_CreatureController_H
#define INCLUDED_CreatureController_H
//-----------------------------------------------------------------------
#include "serverGame/TangibleController.h"
#include "swgSharedUtility/Behaviors.def"
#include "swgSharedUtility/MentalStates.def"
#include "swgSharedUtility/Locomotions.def"
#include "swgSharedUtility/Postures.def"
#include "swgSharedUtility/States.def"
//-----------------------------------------------------------------------
class AICreatureController;
class CellObject;
class CreatureObject;
class MessageQueueSecureTrade;
class MessageQueueCommandQueueEnqueue;
class MessageQueueCommandQueueEnqueueFwd;
class PlayerCreatureController;
class ServerSecureTrade;
class WeaponObject;
//-----------------------------------------------------------------------
class CreatureController : public TangibleController
{
public:
explicit CreatureController (CreatureObject * newOwner);
~CreatureController ();
static CreatureController * getCreatureController(NetworkId const & networkId);
static CreatureController * getCreatureController(Object * object);
static CreatureController const * asCreatureController(Controller const * controller);
static CreatureController * asCreatureController(Controller * controller);
virtual CreatureController * asCreatureController();
virtual CreatureController const * asCreatureController() const;
virtual PlayerCreatureController * asPlayerCreatureController();
virtual PlayerCreatureController const * asPlayerCreatureController() const;
virtual AICreatureController * asAiCreatureController();
virtual AICreatureController const * asAiCreatureController() const;
virtual void conclude ();
/** object modification functions that should only be called on authoritative
* objects
*/
bool setSlopeModAngle(float angle);
bool setSlopeModPercent(float percent);
bool setWaterModPercent(float percent);
bool setMovementScale(float scale);
bool setMovementPercent(float percent);
bool setAccelScale(float scale);
bool setAccelPercent(float percent);
void setAppearanceFromObjectTemplate(std::string const &serverObjectTemplateFilename);
virtual void setObjectStopWalkRun();
virtual void setOwner(Object *newOwner);
CreatureObject * getCreature();
CreatureObject const * getCreature() const;
virtual void endBaselines();
bool getHibernate() const;
virtual void setHibernate(bool hibernate);
virtual void updateHibernate();
private:
//-----------------------------------------------------------
// Secure Trade methods
public:
void setSecureTrade(ServerSecureTrade *);
ServerSecureTrade* getSecureTrade() const;
void handleSecureTradeMessage(const MessageQueueSecureTrade * data);
bool tradeRequested(CreatureObject&);
private:
ServerSecureTrade* m_secureTrade;
Watcher<CreatureObject> m_secureTradeInitiator;
protected:
virtual float realAlter(real time);
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
virtual void steeringChanged();
virtual bool shouldHibernate() const;
protected:
void sendGenericResponse (int responseType, int requestType, bool success, uint8 sequenceId);
private:
void calculateWaterState(bool& isSwimming,bool& isBurning,float& lavaResistance, float& waterHeight) const;
void onEnterSwimming();
void onExitSwimming();
// Disabled.
CreatureController (void);
CreatureController (const CreatureController & other);
CreatureController& operator= (const CreatureController & other);
};
//--------------------------------------------------------------------
#endif // INCLUDED_CreatureController_H
@@ -0,0 +1,46 @@
// FactoryController.cpp
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
//-----------------------------------------------------------------------
#include "serverGame/FirstServerGame.h"
#include "serverGame/FactoryController.h"
#include "serverGame/FactoryObject.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
#include "sharedObject/NetworkIdManager.h"
//-----------------------------------------------------------------------
FactoryController::FactoryController(FactoryObject * o) :
TangibleController(o)
{
}
//-----------------------------------------------------------------------
FactoryController::~FactoryController()
{
}
//-----------------------------------------------------------------------
void FactoryController::handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags)
{
FactoryObject * owner = safe_cast<FactoryObject *>(getOwner());
if(! owner)
{
TangibleController::handleMessage(message, value, data, flags);
return;
}
// switch(message)
// {
// default:
TangibleController::handleMessage(message, value, data, flags);
// break;
// }
}
//-----------------------------------------------------------------------
@@ -0,0 +1,33 @@
// FactoryController.h
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
#ifndef _INCLUDED_FactoryController_H
#define _INCLUDED_FactoryController_H
//-----------------------------------------------------------------------
#include "serverGame/TangibleController.h"
class FactoryObject;
//-----------------------------------------------------------------------
class FactoryController : public TangibleController
{
public:
explicit FactoryController(FactoryObject * owner);
~FactoryController();
protected:
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
private:
FactoryController & operator = (const FactoryController & rhs);
FactoryController(const FactoryController & source);
};
//-----------------------------------------------------------------------
#endif // _INCLUDED_FactoryController_H
@@ -0,0 +1,31 @@
// GroundVehicleController.cpp
// copyright 2000 Verant Interactive
//-----------------------------------------------------------------------
#include "serverGame/FirstServerGame.h"
#include "sharedFoundation/GameControllerMessage.h"
#include "serverGame/GroundVehicleController.h"
#include "serverGame/VehicleObject.h"
//-----------------------------------------------------------------------
GroundVehicleController::GroundVehicleController(VehicleObject * newOwner) :
VehicleController(newOwner),
yawPitchRollRates(convertDegreesToRadians(60.0f),
convertDegreesToRadians(60.0f),
convertDegreesToRadians(60.0f)
),
maxForwardVelocity(60)
{
}
//-----------------------------------------------------------------------
GroundVehicleController::~GroundVehicleController()
{
}
//-----------------------------------------------------------------------
@@ -0,0 +1,37 @@
// GroundVehicleController.h
// copyright 2000 Verant Interactive
// Author: Justin Randall
#ifndef _GroundVehicleController_H
#define _GroundVehicleController_H
//-----------------------------------------------------------------------
#include "serverGame/VehicleController.h"
#include "sharedMath/Vector.h"
//-----------------------------------------------------------------------
class VehicleObject;
//-----------------------------------------------------------------------
class GroundVehicleController : public VehicleController
{
public:
explicit GroundVehicleController (VehicleObject * newOwner);
~GroundVehicleController ();
protected:
Vector yawPitchRollRates;
real maxForwardVelocity;
private:
GroundVehicleController (void);
GroundVehicleController (const GroundVehicleController & other);
GroundVehicleController& operator= (const GroundVehicleController & other);
};
//-----------------------------------------------------------------------
#endif // _GroundVehicleController_H
@@ -0,0 +1,157 @@
// ======================================================================
//
// GroupController.cpp
//
// Copyright 2002 Sony Online Entertainment
//
// ======================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/GroupController.h"
#include "serverGame/GroupObject.h"
#include "serverNetworkMessages/GroupMemberParam.h"
#include "sharedFoundation/GameControllerMessage.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
// ======================================================================
GroupController::GroupController(GroupObject *newOwner) :
UniverseController(newOwner)
{
}
// ----------------------------------------------------------------------
GroupController::~GroupController()
{
}
// ----------------------------------------------------------------------
void GroupController::handleMessage(const int message, const float value, const MessageQueue::Data* const data, const uint32 flags)
{
GroupObject *owner = dynamic_cast<GroupObject *>(getOwner());
NOT_NULL(owner);
switch (message)
{
case CM_groupSetName:
{
MessageQueueGenericValueType<std::string> const *msg = safe_cast<MessageQueueGenericValueType<std::string> const *>(data);
if (msg)
owner->setGroupName(msg->getValue());
}
break;
case CM_groupAddMember:
{
MessageQueueGenericValueType<GroupMemberParam> const *msg = safe_cast<MessageQueueGenericValueType<GroupMemberParam> const *>(data);
if (msg)
{
owner->addGroupMember(msg->getValue());
}
}
break;
case CM_groupRemoveMember:
{
MessageQueueGenericValueType<NetworkId> const *msg = safe_cast<MessageQueueGenericValueType<NetworkId> const *>(data);
if (msg)
owner->removeGroupMember(msg->getValue());
}
break;
case CM_groupDisband:
{
owner->disbandGroup();
}
break;
case CM_groupMakeLeader:
{
MessageQueueGenericValueType<NetworkId> const *msg = safe_cast<MessageQueueGenericValueType<NetworkId> const *>(data);
if (msg)
owner->makeLeader(msg->getValue());
}
break;
case CM_setGroupMemberDifficulty:
{
MessageQueueGenericValueType<std::pair<NetworkId, int> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<NetworkId, int> > const *>(data);
if (msg)
owner->setMemberLevel(msg->getValue().first, msg->getValue().second);
}
break;
case CM_setGroupMemberProfession:
{
MessageQueueGenericValueType<std::pair<NetworkId, uint32> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<NetworkId, uint32> > const *>(data);
if (msg)
owner->setMemberProfession(msg->getValue().first, static_cast<uint8>(msg->getValue().second));
}
break;
case CM_setGroupShipForMember:
{
MessageQueueGenericValueType<std::pair<NetworkId, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<NetworkId, NetworkId> > const *>(data);
if (msg)
owner->setShipForMember(msg->getValue().first, msg->getValue().second);
}
break;
case CM_setGroupShipFormationSlotForMember:
{
MessageQueueGenericValueType<std::pair<NetworkId, int> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<NetworkId, int> > const *>(data);
if (msg)
owner->setShipFormationSlotForMember(msg->getValue().first, msg->getValue().second);
}
break;
case CM_addGroupPOBShipAndOwner:
{
MessageQueueGenericValueType<std::pair<NetworkId, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<NetworkId, NetworkId> > const *>(data);
if (msg)
owner->addPOBShipAndOwner(msg->getValue().first, msg->getValue().second);
}
break;
case CM_removeGroupPOBShip:
{
MessageQueueGenericValueType<NetworkId> const *msg = safe_cast<MessageQueueGenericValueType<NetworkId> const *>(data);
if (msg)
owner->removePOBShip(msg->getValue());
}
break;
case CM_groupMakeLootMaster:
{
MessageQueueGenericValueType<NetworkId> const *msg = safe_cast<MessageQueueGenericValueType<NetworkId> const *>(data);
if (msg)
owner->makeLootMaster(msg->getValue());
}
break;
case CM_groupSetLootRule:
{
MessageQueueGenericValueType<int> const *msg = safe_cast<MessageQueueGenericValueType<int> const *>(data);
if (msg)
owner->setLootRule(msg->getValue());
}
break;
case CM_setGroupPickupTimer:
{
MessageQueueGenericValueType<std::pair<int32, int32> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int32, int32> > const *>(data);
if (msg)
owner->setGroupPickupTimer(static_cast<time_t>(msg->getValue().first), static_cast<time_t>(msg->getValue().second));
}
break;
case CM_setGroupPickupLocation:
{
MessageQueueGenericValueType<std::pair<std::string, Vector> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::string, Vector> > const *>(data);
if (msg)
owner->setGroupPickupLocation(msg->getValue().first, msg->getValue().second);
}
break;
default:
UniverseController::handleMessage(message, value, data, flags);
break;
}
}
// ======================================================================
@@ -0,0 +1,40 @@
// ======================================================================
//
// GroupController.h
//
// Copyright 2002 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_GroupController_H
#define INCLUDED_GroupController_H
// ======================================================================
#include "serverGame/UniverseController.h"
// ======================================================================
class GroupObject;
// ======================================================================
class GroupController: public UniverseController
{
public:
explicit GroupController(GroupObject *newOwner);
~GroupController();
protected:
virtual void handleMessage(int message, float value, const MessageQueue::Data* data, uint32 flags);
private:
GroupController();
GroupController(GroupController const &);
GroupController& operator=(GroupController const &);
};
// ======================================================================
#endif
@@ -0,0 +1,177 @@
// ======================================================================
//
// GuildController.cpp
//
// Copyright 2002 Sony Online Entertainment
//
// ======================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/GuildController.h"
#include "serverGame/GuildObject.h"
#include "sharedFoundation/GameControllerMessage.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
// ======================================================================
GuildController::GuildController(GuildObject *newOwner) :
UniverseController(newOwner)
{
}
// ----------------------------------------------------------------------
GuildController::~GuildController()
{
}
// ----------------------------------------------------------------------
void GuildController::handleMessage(const int message, const float value, const MessageQueue::Data* const data, const uint32 flags)
{
GuildObject *owner = dynamic_cast<GuildObject *>(getOwner());
NOT_NULL(owner);
switch (message)
{
case CM_guildCreate:
{
MessageQueueGenericValueType<std::pair<int, std::pair<std::string, std::string> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, std::pair<std::string, std::string> > > const *>(data);
owner->createGuild(msg->getValue().second.first, msg->getValue().second.second, msg->getValue().first);
}
break;
case CM_guildDisband:
{
MessageQueueGenericValueType<int> const *msg = safe_cast<MessageQueueGenericValueType<int> const *>(data);
owner->disbandGuild(msg->getValue());
}
break;
case CM_guildRemoveMember:
{
MessageQueueGenericValueType<std::pair<int, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, NetworkId> > const *>(data);
owner->removeGuildMember(msg->getValue().first, msg->getValue().second);
}
break;
case CM_guildAddCreatorMember:
{
MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, std::pair<std::string, int> > > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, std::pair<std::string, int> > > > const *>(data);
owner->addGuildCreatorMember(msg->getValue().first.first, msg->getValue().first.second, msg->getValue().second.first, msg->getValue().second.second.first, msg->getValue().second.second.second);
}
break;
case CM_guildAddSponsorMember:
{
MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, std::pair<std::string, int> > > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, std::pair<std::string, int> > > > const *>(data);
owner->addGuildSponsorMember(msg->getValue().first.first, msg->getValue().first.second, msg->getValue().second.first, msg->getValue().second.second.first, msg->getValue().second.second.second);
}
break;
case CM_guildSetMemberPermission:
{
MessageQueueGenericValueType<std::pair<std::pair<int, int>, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, int>, NetworkId> > const *>(data);
owner->setGuildMemberPermission(msg->getValue().first.first, msg->getValue().second, msg->getValue().first.second);
}
break;
case CM_guildSetMemberTitle:
{
MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *>(data);
owner->setGuildMemberTitle(msg->getValue().second.second, msg->getValue().second.first, msg->getValue().first);
}
break;
case CM_guildSetMemberAllegiance:
{
MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, NetworkId> > const *>(data);
owner->setGuildMemberAllegiance(msg->getValue().first.first, msg->getValue().first.second, msg->getValue().second);
}
break;
case CM_guildSetMemberPermissionAndAllegiance:
{
MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<int, NetworkId> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<int, NetworkId> > > const *>(data);
owner->setGuildMemberPermissionAndAllegiance(msg->getValue().first.first, msg->getValue().first.second, msg->getValue().second.first, msg->getValue().second.second);
}
break;
case CM_guildSetMemberNameAndPermission:
{
MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, int> > > const *>(data);
owner->setGuildMemberNameAndPermision(msg->getValue().first.first, msg->getValue().first.second, msg->getValue().second.first, msg->getValue().second.second);
}
break;
case CM_guildSetMemberProfessionInfo:
{
MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, NetworkId>, std::pair<std::string, int> > > const *>(data);
owner->setGuildMemberProfessionInfo(msg->getValue().first.first, msg->getValue().first.second, msg->getValue().second.first, msg->getValue().second.second);
}
break;
case CM_guildAddMemberRank:
{
MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *>(data);
owner->addGuildMemberRank(msg->getValue().second.second, msg->getValue().second.first, msg->getValue().first);
}
break;
case CM_guildRemoveMemberRank:
{
MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::string, std::pair<NetworkId, int> > > const *>(data);
owner->removeGuildMemberRank(msg->getValue().second.second, msg->getValue().second.first, msg->getValue().first);
}
break;
case CM_guildSetLeader:
{
MessageQueueGenericValueType<std::pair<int, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, NetworkId> > const *>(data);
owner->setGuildLeader(msg->getValue().first, msg->getValue().second);
}
break;
case CM_guildSetGuildElectionEndTime:
{
MessageQueueGenericValueType<std::pair<std::pair<int, int>, int> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, int>, int> > const *>(data);
owner->setGuildElectionEndTime(msg->getValue().second, msg->getValue().first.first, msg->getValue().first.second);
}
break;
case CM_guildSetGuildFaction:
{
MessageQueueGenericValueType<std::pair<int, int> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, int> > const *>(data);
owner->setGuildFaction(msg->getValue().first, static_cast<uint32>(msg->getValue().second));
}
break;
case CM_guildSetGuildGcwDefenderRegion:
{
MessageQueueGenericValueType<std::pair<int, std::string> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, std::string> > const *>(data);
owner->setGuildGcwDefenderRegion(msg->getValue().first, msg->getValue().second);
}
break;
case CM_guildRemoveEnemy:
{
MessageQueueGenericValueType<std::pair<int, int> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, int> > const *>(data);
owner->removeGuildEnemy(msg->getValue().first, msg->getValue().second);
}
break;
case CM_guildSetEnemy:
{
MessageQueueGenericValueType<std::pair<int, int> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, int> > const *>(data);
owner->setGuildEnemy(msg->getValue().first, msg->getValue().second);
}
break;
case CM_guildUpdateGuildWarKillTrackingData:
{
MessageQueueGenericValueType<std::pair<std::pair<int, int>, std::pair<int, int> > > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<std::pair<int, int>, std::pair<int, int> > > const *>(data);
owner->modifyGuildWarKillTracking(msg->getValue().first.first, msg->getValue().first.second, msg->getValue().second.first, msg->getValue().second.second);
}
break;
case CM_guildSetName:
{
MessageQueueGenericValueType<std::pair<int, std::string> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, std::string> > const *>(data);
owner->setGuildName(msg->getValue().first, msg->getValue().second);
}
break;
case CM_guildSetAbbrev:
{
MessageQueueGenericValueType<std::pair<int, std::string> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, std::string> > const *>(data);
owner->setGuildAbbrev(msg->getValue().first, msg->getValue().second);
}
break;
default:
UniverseController::handleMessage(message, value, data, flags);
break;
}
}
// ======================================================================
@@ -0,0 +1,40 @@
// ======================================================================
//
// GuildController.h
//
// Copyright 2002 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_GuildController_H
#define INCLUDED_GuildController_H
// ======================================================================
#include "serverGame/UniverseController.h"
// ======================================================================
class GuildObject;
// ======================================================================
class GuildController: public UniverseController
{
public:
explicit GuildController(GuildObject *newOwner);
~GuildController();
protected:
virtual void handleMessage(int message, float value, const MessageQueue::Data* data, uint32 flags);
private:
GuildController();
GuildController(GuildController const &);
GuildController& operator=(GuildController const &);
};
// ======================================================================
#endif
@@ -0,0 +1,81 @@
//========================================================================
//
// HarvesterInstallationController.cpp
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/HarvesterInstallationController.h"
#include "serverGame/HarvesterInstallationObject.h"
#include "sharedFoundation/GameControllerMessage.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
#include "swgServerNetworkMessages/MessageQueueResourceAdd.h"
#include "swgServerNetworkMessages/MessageQueueResourceSetInstalledEfficiency.h"
//-----------------------------------------------------------------------
HarvesterInstallationController::HarvesterInstallationController(HarvesterInstallationObject * newOwner) :
InstallationController(newOwner)
{
}
//-----------------------------------------------------------------------
HarvesterInstallationController::~HarvesterInstallationController()
{
}
//-----------------------------------------------------------------------
void HarvesterInstallationController::handleMessage (const int message, const float value, const MessageQueue::Data* const data, const uint32 flags)
{
HarvesterInstallationObject* owner = dynamic_cast<HarvesterInstallationObject *>(getOwner());
NOT_NULL(owner);
switch (message)
{
case CM_resourceSetInstalledEfficiency:
{
const MessageQueueResourceSetInstalledEfficiency *msg=
dynamic_cast<const MessageQueueResourceSetInstalledEfficiency *>(data);
NOT_NULL(msg);
DEBUG_REPORT_LOG(true,("Got MessageQueueResourceSetInstalledEfficiency with value %f\n",msg->getInstalledEfficiency()));
owner->finishActivate(msg->getInstalledEfficiency(), msg->getTickCount());
}
break;
case CM_addResource:
{
const MessageQueueGenericValueType<std::pair<NetworkId, int> > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, int> > *>(data);
if(msg)
{
owner->addResource(msg->getValue().first, static_cast<float>(msg->getValue().second));
}
}
break;
case CM_resourceAdd:
{
if (owner->isAuthoritative())
{
const MessageQueueResourceAdd *msg=
dynamic_cast<const MessageQueueResourceAdd *>(data);
NOT_NULL(msg);
owner->addResource(msg->getResourceId(),static_cast<float>(msg->getAmount()));
}
}
break;
default:
InstallationController::handleMessage(message, value, data, flags);
break;
}
}
//-----------------------------------------------------------------------
@@ -0,0 +1,39 @@
//========================================================================
//
// HarvesterInstallationController.h
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#ifndef _INCLUDED_HarvesterInstallationController_H
#define _INCLUDED_HarvesterInstallationController_H
//-----------------------------------------------------------------------
#include "serverGame/InstallationController.h"
//----------------------------------------------------------------------
class HarvesterInstallationObject;
//-----------------------------------------------------------------------
class HarvesterInstallationController : public InstallationController
{
public:
explicit HarvesterInstallationController (HarvesterInstallationObject * newOwner);
virtual ~HarvesterInstallationController (void);
protected:
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
private:
HarvesterInstallationController (void);
HarvesterInstallationController (const HarvesterInstallationController & other);
HarvesterInstallationController& operator= (const HarvesterInstallationController & other);
};
//-----------------------------------------------------------------------
#endif
@@ -0,0 +1,78 @@
//========================================================================
//
// InstallationController.cpp
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/InstallationController.h"
#include "serverGame/InstallationObject.h"
#include "serverGame/ServerWorld.h"
#include "sharedFoundation/GameControllerMessage.h"
#include "swgServerNetworkMessages/MessageQueueActivateInstallation.h"
#include "swgServerNetworkMessages/MessageQueueDeactivateInstallation.h"
#include "swgServerNetworkMessages/MessageQueueInstallationHarvest.h"
//-----------------------------------------------------------------------
InstallationController::InstallationController(InstallationObject * newOwner) :
TangibleController(newOwner)
{
}
//-----------------------------------------------------------------------
InstallationController::~InstallationController()
{
}
//-----------------------------------------------------------------------
void InstallationController::handleMessage (const int message, const float value, const MessageQueue::Data* const data, const uint32 flags)
{
InstallationObject* owner = dynamic_cast<InstallationObject *>(getOwner());
NOT_NULL(owner);
switch (message)
{
case CM_activateInstallation:
{
const MessageQueueActivateInstallation *msg=
dynamic_cast<const MessageQueueActivateInstallation *>(data);
NOT_NULL(msg);
DEBUG_REPORT_LOG(true,("Got MessageQueueActivateInstallation\n"));
owner->activate(NetworkId::cms_invalid);
}
break;
case CM_installationHarvest:
{
const MessageQueueInstallationHarvest *msg=
dynamic_cast<const MessageQueueInstallationHarvest *>(data);
NOT_NULL(msg);
owner->harvest();
}
break;
case CM_deactivateInstallation:
{
const MessageQueueDeactivateInstallation *msg=
dynamic_cast<const MessageQueueDeactivateInstallation *>(data);
NOT_NULL(msg);
owner->deactivate();
}
break;
default:
TangibleController::handleMessage(message, value, data, flags);
break;
}
}
//-----------------------------------------------------------------------
@@ -0,0 +1,39 @@
//========================================================================
//
// InstallationController.h
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#ifndef _INCLUDED_InstallationController_H
#define _INCLUDED_InstallationController_H
//-----------------------------------------------------------------------
#include "serverGame/TangibleController.h"
//----------------------------------------------------------------------
class InstallationObject;
//-----------------------------------------------------------------------
class InstallationController : public TangibleController
{
public:
explicit InstallationController (InstallationObject * newOwner);
virtual ~InstallationController (void);
protected:
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
private:
InstallationController (void);
InstallationController (const InstallationController & other);
InstallationController& operator= (const InstallationController & other);
};
//-----------------------------------------------------------------------
#endif
@@ -0,0 +1,62 @@
// ManufactureInstallationController.cpp
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
//-----------------------------------------------------------------------
#include "serverGame/FirstServerGame.h"
#include "serverGame/ManufactureInstallationController.h"
#include "serverGame/ManufactureInstallationObject.h"
#include "serverGame/ManufactureSchematicObject.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
#include "sharedObject/NetworkIdManager.h"
//-----------------------------------------------------------------------
ManufactureInstallationController::ManufactureInstallationController(ManufactureInstallationObject * owner) :
InstallationController(owner)
{
}
//-----------------------------------------------------------------------
ManufactureInstallationController::~ManufactureInstallationController()
{
}
//-----------------------------------------------------------------------
void ManufactureInstallationController::handleMessage(int message, float value, const MessageQueue::Data * data, uint32 flags)
{
ManufactureInstallationObject * owner = safe_cast<ManufactureInstallationObject *>(getOwner());
NOT_NULL(owner);
switch(message)
{
case CM_addSchematic:
{
const MessageQueueGenericValueType<std::pair<NetworkId, NetworkId> > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, NetworkId> > *>(data);
if(msg)
{
ManufactureSchematicObject * schematic = safe_cast<ManufactureSchematicObject *>(NetworkIdManager::getObjectById(msg->getValue().first));
if(schematic)
{
ServerObject * transferer = safe_cast<ServerObject *>(NetworkIdManager::getObjectById(msg->getValue().second));
owner->addSchematic(*schematic, transferer);
}
}
}
break;
case CM_manufactureInstallationCreateObject:
{
owner->createObject();
}
break;
default:
InstallationController::handleMessage(message, value, data, flags);
break;
}
}
//-----------------------------------------------------------------------
@@ -0,0 +1,33 @@
// ManufactureInstallationController.h
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
#ifndef _INCLUDED_ManufactureInstallationController_H
#define _INCLUDED_ManufactureInstallationController_H
//-----------------------------------------------------------------------
#include "serverGame/InstallationController.h"
class ManufactureInstallationObject;
//-----------------------------------------------------------------------
class ManufactureInstallationController : public InstallationController
{
public:
explicit ManufactureInstallationController(ManufactureInstallationObject * owner);
~ManufactureInstallationController();
protected:
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
private:
ManufactureInstallationController & operator = (const ManufactureInstallationController & rhs);
ManufactureInstallationController(const ManufactureInstallationController & source);
};
//-----------------------------------------------------------------------
#endif // _INCLUDED_ManufactureInstallationController_H
@@ -0,0 +1,24 @@
// MissionTerminalController.cpp
// Copyright 2000-01, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
//-----------------------------------------------------------------------
#include "serverGame/FirstServerGame.h"
#include "serverGame/MissionTerminalController.h"
//-----------------------------------------------------------------------
MissionTerminalController::MissionTerminalController(TangibleObject * o) :
TangibleController(o)
{
}
//-----------------------------------------------------------------------
MissionTerminalController::~MissionTerminalController()
{
}
//-----------------------------------------------------------------------
@@ -0,0 +1,28 @@
// MissionTerminalController.h
// Copyright 2000-01, Sony Online Entertainment Inc., all rights reserved.
// Author: Justin Randall
#ifndef _INCLUDED_MissionTerminalController_H
#define _INCLUDED_MissionTerminalController_H
//-----------------------------------------------------------------------
#include "serverGame/TangibleController.h"
//-----------------------------------------------------------------------
class MissionTerminalController : public TangibleController
{
public:
MissionTerminalController(TangibleObject * owner);
~MissionTerminalController();
private:
MissionTerminalController & operator = (const MissionTerminalController & rhs);
MissionTerminalController(const MissionTerminalController & source);
};
//-----------------------------------------------------------------------
#endif // _INCLUDED_MissionTerminalController_H
@@ -0,0 +1,139 @@
//======================================================================
//
// MoveSimController.cpp
// copyright (c) 2003 Sony Online Entertainment
//
//======================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/MoveSimController.h"
#include "serverGame/CreatureObject.h"
#include "sharedObject/AlterResult.h"
#include "sharedTerrain/TerrainObject.h"
//-----------------------------------------------------------------------
/**
*
* @param centerPoint the point to wander around
* @param roamRadius the radius around the point to wander around, limited by the edges of the map
*/
MoveSimController::MoveSimController (CreatureObject * newOwner, const Vector & centerPoint, float roamRadius) :
CreatureController (newOwner),
m_centerPoint (centerPoint),
m_roamRadius (roamRadius),
m_lastPoint (),
m_lastUnstuckTimer (0.0f)
{
m_lastPoint = newOwner->getPosition_w ();
}
//-----------------------------------------------------------------------
/**
*
* Reverse the object's direction and bias it toward the center
*/
void MoveSimController::reverse (float towardsCenterFactor)
{
const CreatureObject * const creature = safe_cast<CreatureObject *>(getOwner ());
NOT_NULL (creature);
const Vector & pos_w = getOwner ()->getPosition_w ();
Vector heading = getOwner ()->getObjectFrameK_w ();
Vector vectorToCenter = m_centerPoint - pos_w;
vectorToCenter.normalize ();
heading = - heading;
heading += vectorToCenter * towardsCenterFactor;
heading.normalize ();
const float theta = heading.theta ();
getOwner ()->resetRotate_o2p ();
getOwner ()->yaw_o (theta);
}
//-----------------------------------------------------------------------
/**
*
* Keep the object moving my moving its goal ahead of it.
* If we are outside the desired area, reverse
*/
float MoveSimController::realAlter(float time)
{
const float retval = CreatureController::realAlter (time);
const CreatureObject * const creature = safe_cast<CreatureObject *>(getOwner ());
if (!creature || !creature->isAuthoritative ())
return retval;
const float runspeed = creature->getRunSpeed ();
const float frameDistance = runspeed * time;
const Vector & pos_w = getOwner ()->getPosition_w ();
const float magSquaredCenter = pos_w.magnitudeBetweenSquared (m_centerPoint);
Vector heading = getOwner ()->getObjectFrameK_w ();
float halfMapWidth = 32.0f;
TerrainObject * const terrainObject = TerrainObject::getInstance ();
if (terrainObject)
{
//- subtract a 512 meter invalid band around the edge of the map
halfMapWidth = (terrainObject->getMapWidthInMeters () * 0.5f) - 512.0f;
}
Vector vectorToCenter = m_centerPoint - pos_w;
vectorToCenter.normalize ();
const float heading_dot = vectorToCenter.dot (heading);
//-- if we've moved less than 1% of our frame distance last frame, then consider ourselves
//-- stuck, so turn around
const float stuckThresholdSquared = sqr (frameDistance * 0.01f);
if (m_lastUnstuckTimer < 0.0f && m_lastPoint.magnitudeBetweenSquared (pos_w) < stuckThresholdSquared)
{
reverse (2.0f);
//-- don't try to unstick for another 2 seconds
m_lastUnstuckTimer = 2.0f;
}
//-- if we're out of range and moving away from the center, turn around
else if (
magSquaredCenter > sqr (m_roamRadius) ||
pos_w.x < -halfMapWidth ||
pos_w.x > halfMapWidth ||
pos_w.z < -halfMapWidth ||
pos_w.z > halfMapWidth)
{
if (heading_dot < 0.0f)
reverse (2.0f);
else if (heading_dot < 0.5)
{
const float theta = vectorToCenter.theta ();
getOwner ()->resetRotate_o2p ();
getOwner ()->yaw_o (theta);
}
}
m_lastPoint = pos_w;
Transform t = getOwner ()->getTransform_o2w ();
//-multiply frame distance by 110% fudge factor
t.move_l (Vector::unitZ * frameDistance * 1.1f);
setGoal (t, 0);
m_lastUnstuckTimer -= time;
return AlterResult::cms_alterNextFrame;
}
//-----------------------------------------------------------------------
@@ -0,0 +1,39 @@
//========================================================================
//
// MoveSimController.h
//
// copyright 2003 Sony Online Entertainment
//
//========================================================================
#ifndef INCLUDED_MoveSimController_H
#define INCLUDED_MoveSimController_H
#include "serverGame/CreatureController.h"
class Vector;
//-----------------------------------------------------------------------
class MoveSimController : public CreatureController
{
public:
MoveSimController (CreatureObject * newOwner, const Vector & centerPoint, float roamRadius);
virtual float realAlter(real time);
private:
MoveSimController (const MoveSimController& rhs);
MoveSimController & operator= (const MoveSimController & rhs);
void reverse (float towardsCenterFactor);
Vector m_centerPoint;
float m_roamRadius;
Vector m_lastPoint;
float m_lastUnstuckTimer;
};
//-----------------------------------------------------------------------
#endif
@@ -0,0 +1,307 @@
//========================================================================
//
// PlanetController.cpp
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/PlanetController.h"
#include "serverGame/PlanetObject.h"
#include "serverGame/GameServer.h"
#include "serverScript/GameScriptObject.h"
#include "serverScript/ScriptParameters.h"
#include "sharedFoundation/DynamicVariable.h"
#include "sharedNetworkMessages/ObjectChannelMessages.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
#include "sharedFoundation/GameControllerMessage.h"
#include "sharedObject/AlterResult.h"
#include "sharedObject/Object.h"
#include "swgServerNetworkMessages/MessageQueuePlanetAddTravelPoint.h"
//-----------------------------------------------------------------------
PlanetController::PlanetController(PlanetObject * newOwner) :
UniverseController(newOwner)
{
}
//-----------------------------------------------------------------------
PlanetController::~PlanetController()
{
}
//-----------------------------------------------------------------------
void PlanetController::handleMessage (const int message, const float value, const MessageQueue::Data* const data, const uint32 flags)
{
PlanetObject* const owner = dynamic_cast<PlanetObject *>(getOwner());
NOT_NULL(owner);
switch(message)
{
case CM_planetAddTravelPoint:
{
const MessageQueuePlanetAddTravelPoint* const message = safe_cast<const MessageQueuePlanetAddTravelPoint*> (data);
if (message)
owner->addTravelPoint (message->getTravelPointName (), message->getPosition_w (), message->getCost (), message->getInterplanetary (), static_cast<TravelPoint::TravelPointType>(message->getType()));
}
break;
case CM_planetRemoveTravelPoint:
{
const MessageQueueGenericValueType<std::string>* const message = safe_cast<const MessageQueueGenericValueType<std::string>*> (data);
if (message)
owner->removeTravelPoint (message->getValue ());
}
break;
case CM_setWeather:
{
const MessageQueueGenericValueType<std::pair<int, Vector> >* const message = safe_cast<const MessageQueueGenericValueType<std::pair<int, Vector> >*> (data);
if (message != NULL)
{
owner->setWeather(
message->getValue().first,
message->getValue().second.x,
message->getValue().second.y,
message->getValue().second.z);
}
}
break;
case CM_serverRemovePlanetMapLocation:
{
const MessageQueueGenericValueType<NetworkId> * const message = safe_cast<const MessageQueueGenericValueType<NetworkId> *> (data);
if (message)
owner->removeMapLocation (message->getValue ());
}
break;
case CM_serverAddPlanetMapLocation:
{
const MessageQueueGenericValueType<std::pair<MapLocation, std::pair<int, int> > > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<MapLocation, std::pair<int, int> > > *> (data);
if (message)
owner->addMapLocation (message->getValue ().first, message->getValue ().second.first, (message->getValue ().second.second ? true : false));
}
break;
case CM_collectionRequestServerFirst:
{
const MessageQueueGenericValueType<std::pair<std::pair<std::string, NetworkId>, std::pair<Unicode::String, std::string> > > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<std::pair<std::string, NetworkId>, std::pair<Unicode::String, std::string> > > *> (data);
if (message)
{
CollectionsDataTable::CollectionInfoCollection const * const collectionInfo = CollectionsDataTable::getCollectionByName (message->getValue ().first.first);
if (collectionInfo)
owner->setCollectionServerFirst (*collectionInfo, message->getValue ().first.second, message->getValue ().second.first, message->getValue ().second.second);
}
}
break;
case CM_collectionRevokeServerFirst:
{
const MessageQueueGenericValueType<std::string> * const message = safe_cast<const MessageQueueGenericValueType<std::string> *> (data);
if (message)
{
CollectionsDataTable::CollectionInfoCollection const * const collectionInfo = CollectionsDataTable::getCollectionByName (message->getValue ());
if (collectionInfo)
owner->removeCollectionServerFirst (*collectionInfo);
}
}
break;
case CM_setConnectedCharacterLfgData:
{
const MessageQueueGenericValueType<std::pair<NetworkId, LfgCharacterData> > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, LfgCharacterData> > *> (data);
if (message)
{
owner->setConnectedCharacterLfgData(message->getValue().first, message->getValue().second);
}
}
break;
case CM_removeConnectedCharacterData:
{
const MessageQueueGenericValueType<NetworkId> * const message = safe_cast<const MessageQueueGenericValueType<NetworkId> *> (data);
if (message)
{
owner->removeConnectedCharacterData(message->getValue());
}
}
break;
case CM_setConnectedCharacterGroupData:
{
const MessageQueueGenericValueType<std::pair<NetworkId, NetworkId> > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, NetworkId> > *> (data);
if (message)
{
owner->setConnectedCharacterGroupData(message->getValue().first, message->getValue().second);
}
}
break;
case CM_setConnectedCharacterPlanetData:
{
const MessageQueueGenericValueType<std::pair<std::string, NetworkId> > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<std::string, NetworkId> > *> (data);
if (message)
{
owner->setConnectedCharacterPlanetData(message->getValue().second, message->getValue().first);
}
}
break;
case CM_setConnectedCharacterRegionData:
{
const MessageQueueGenericValueType<std::pair<std::string, NetworkId> > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<std::string, NetworkId> > *> (data);
if (message)
{
owner->setConnectedCharacterRegionData(message->getValue().second, message->getValue().first);
}
}
break;
case CM_setConnectedCharacterPlayerCityData:
{
const MessageQueueGenericValueType<std::pair<std::string, NetworkId> > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<std::string, NetworkId> > *> (data);
if (message)
{
owner->setConnectedCharacterPlayerCityData(message->getValue().second, message->getValue().first);
}
}
break;
case CM_setConnectedCharacterBiographyData:
{
const MessageQueueGenericValueType<std::pair<Unicode::String, NetworkId> > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<Unicode::String, NetworkId> > *> (data);
if (message)
{
owner->setConnectedCharacterBiographyData(message->getValue().second, message->getValue().first);
}
}
break;
case CM_removeConnectedCharacterBiographyData:
{
const MessageQueueGenericValueType<NetworkId> * const message = safe_cast<const MessageQueueGenericValueType<NetworkId> *> (data);
if (message)
{
owner->removeConnectedCharacterBiographyData(message->getValue());
}
}
break;
case CM_setConnectedCharacterLevelData:
{
const MessageQueueGenericValueType<std::pair<NetworkId, int> > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, int> > *> (data);
if (message)
{
owner->setConnectedCharacterLevelData(message->getValue().first, static_cast<int16>(message->getValue().second));
}
}
break;
case CM_setConnectedCharacterProfessionData:
{
const MessageQueueGenericValueType<std::pair<NetworkId, int> > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, int> > *> (data);
if (message)
{
owner->setConnectedCharacterProfessionData(message->getValue().first, static_cast<LfgCharacterData::Profession>(message->getValue().second));
}
}
break;
case CM_setConnectedCharacterSearchableByCtsSourceGalaxyData:
{
const MessageQueueGenericValueType<std::pair<NetworkId, int> > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, int> > *> (data);
if (message)
{
owner->setConnectedCharacterSearchableByCtsSourceGalaxyData(message->getValue().first, (message->getValue().second == 0) ? false : true);
}
}
break;
case CM_setConnectedCharacterDisplayLocationInSearchResultsData:
{
const MessageQueueGenericValueType<std::pair<NetworkId, int> > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, int> > *> (data);
if (message)
{
owner->setConnectedCharacterDisplayLocationInSearchResultsData(message->getValue().first, (message->getValue().second == 0) ? false : true);
}
}
break;
case CM_setConnectedCharacterAnonymousData:
{
const MessageQueueGenericValueType<std::pair<NetworkId, int> > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, int> > *> (data);
if (message)
{
owner->setConnectedCharacterAnonymousData(message->getValue().first, (message->getValue().second == 0) ? false : true);
}
}
break;
case CM_setConnectedCharacterInterestsData:
{
const MessageQueueGenericValueType<std::pair<NetworkId, BitArray> > * const message = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, BitArray> > *> (data);
if (message)
{
owner->setConnectedCharacterInterestsData(message->getValue().first, message->getValue().second);
}
}
break;
case CM_addUniverseEvent:
{
const MessageQueueGenericValueType<std::string> * const message = safe_cast<const MessageQueueGenericValueType<std::string> *> (data);
if (message)
{
owner->addUniverseEvent(message->getValue());
}
}
break;
case CM_removeUniverseEvent:
{
const MessageQueueGenericValueType<std::string> * const message = safe_cast<const MessageQueueGenericValueType<std::string> *> (data);
if (message)
{
owner->removeUniverseEvent(message->getValue());
}
}
break;
case CM_adjustGcwImperialScore:
{
const MessageQueueGenericValueType<std::map<std::string, int64> > * const message = safe_cast<const MessageQueueGenericValueType<std::map<std::string, int64> > *> (data);
if (message)
{
const std::map<std::string, int64> & data = message->getValue();
for (std::map<std::string, int64>::const_iterator iter = data.begin(); iter != data.end(); ++iter)
owner->adjustGcwImperialScore("CM_adjustGcwImperialScore", NULL, iter->first, iter->second);
}
}
break;
case CM_adjustGcwRebelScore:
{
const MessageQueueGenericValueType<std::map<std::string, int64> > * const message = safe_cast<const MessageQueueGenericValueType<std::map<std::string, int64> > *> (data);
if (message)
{
const std::map<std::string, int64> & data = message->getValue();
for (std::map<std::string, int64>::const_iterator iter = data.begin(); iter != data.end(); ++iter)
owner->adjustGcwRebelScore("CM_adjustGcwRebelScore", NULL, iter->first, iter->second);
}
}
break;
default:
UniverseController::handleMessage(message, value, data, flags);
break;
}
}
// ======================================================================
@@ -0,0 +1,37 @@
//========================================================================
//
// PlanetController.h
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#ifndef INCLUDED_PlanetController_H
#define INCLUDED_PlanetController_H
//-----------------------------------------------------------------------
#include "Archive/AutoDeltaByteStream.h"
#include "serverGame/PlanetObject.h"
#include "serverGame/UniverseController.h"
//-----------------------------------------------------------------------
class PlanetController : public UniverseController
{
public:
explicit PlanetController (PlanetObject * newOwner);
~PlanetController ();
protected:
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
private:
PlanetController (void);
PlanetController (const PlanetController & other);
PlanetController& operator= (const PlanetController & other);
};
//-----------------------------------------------------------------------
#endif // INCLUDED_PlanetController_H
@@ -0,0 +1,134 @@
// ======================================================================
//
// PlayerCreatureController.h
//
// Copyright 2002 Sony Online Entertainment
//
// ======================================================================
#ifndef PlayerCreatureController_H
#define PlayerCreatureController_H
// ======================================================================
#include "serverGame/CellObject.h"
#include "serverGame/CreatureController.h"
#include "serverUtility/RecentMaxSyncedValue.h"
// ======================================================================
class MessageQueueTeleportAck;
class MessageQueueObjectMenuRequest;
// ======================================================================
class PlayerCreatureController : public CreatureController
{
public:
explicit PlayerCreatureController(CreatureObject *newOwner);
virtual ~PlayerCreatureController();
static PlayerObject * getPlayerObject(CreatureObject *creature);
static PlayerObject const * getPlayerObject(CreatureObject const *creature);
static bool objectMenuRequestCanManipulateObject(CreatureObject const & player, ServerObject const & item, bool & blockedByNoTrade, bool & showPickUpMenu);
virtual PlayerCreatureController * asPlayerCreatureController();
virtual PlayerCreatureController const * asPlayerCreatureController() const;
virtual void teleport (Transform const &goal, ServerObject *goalObj);
virtual void setAuthoritative (bool newAuthoritative);
virtual void onClientReady ();
virtual void onClientLost ();
float getLastSpeed () const;
float const getServerSpeedForPlayer() const;
protected:
virtual float realAlter (float time);
virtual void onMoveFailed ();
virtual void updateHibernate();
virtual bool shouldHibernate() const;
private:
PlayerCreatureController(PlayerCreatureController const &);
PlayerCreatureController &operator=(PlayerCreatureController const &);
private:
class MoveSnapshot
{
public:
MoveSnapshot();
MoveSnapshot(Vector const &position_p, CellObject *cell, uint32 syncStamp);
MoveSnapshot(MoveSnapshot const &rhs);
MoveSnapshot &operator=(MoveSnapshot const &rhs);
void clear ();
CellObject * getCell ();
CellObject const *getCell () const;
bool isValid () const;
bool isAllowed (CreatureObject const &who) const;
Vector const getPosition_w () const;
Vector const & getPosition_p () const;
uint32 getSyncStamp () const;
private:
bool m_inited;
Watcher<CellObject> m_cell;
Vector m_position_p;
Vector m_position_w;
uint32 m_syncStamp;
};
bool isGod () const;
bool isTeleporting () const;
void handleTeleportAck (MessageQueueTeleportAck const &msg);
void preventMovementUpdates();
void resyncMovementUpdates();
bool shouldValidateMove () const;
bool checkValidMove (MoveSnapshot const &m, float reportedSpeed);
bool isLocationValid (Vector const &position_w, CellObject const *cell) const;
void logMoveFailed (char const *reason);
bool handleInvalidMove (char const *reason);
bool handleMove (Vector const &position_w, uint32 syncStamp, float reportedSpeed);
bool handleMove (Vector const &position_p, NetworkId const &cellObjectId, uint32 syncStamp, float reportedSpeed);
void updateMaxMoveSpeed ();
uint32 getCurSyncStamp () const;
void updateMovementType (float time);
void handleObjectMenuRequest(MessageQueueObjectMenuRequest const *msg);
void playerMovedAndNeedsToCancelWarmup( CreatureObject &owner );
static PlayerObject * getPlayerObjectInternal(CreatureObject const * creature);
protected:
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
private:
std::set<int> m_teleportIds;
MoveSnapshot m_lastVerifiedMove;
int64 m_lastTimeSynchronization;
int m_lastWeatherIndex;
Vector m_lastWeatherWindVelocity_w;
RecentMaxSyncedValue m_speedMaximum;
float m_movingTimeout;
uint32 m_lastMoveSyncStamp;
float m_lastSpeed;
time_t m_lastSpeedCheckFailureTime;
int m_speedCheckConsecutiveFailureCount;
bool m_resendSpeedMax;
};
// ----------------------------------------------------------------------
inline float const PlayerCreatureController::getServerSpeedForPlayer() const
{
return m_speedMaximum.getLastSetValue();
}
// ======================================================================
#endif // PlayerCreatureController_H
@@ -0,0 +1,827 @@
// ======================================================================
//
// PlayerShipController.cpp
// asommers
//
// copyright 2003, sony online entertainment
//
// ======================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/PlayerShipController.h"
#include "serverGame/AiShipBehaviorDock.h"
#include "serverGame/ConfigServerGame.h"
#include "serverGame/CreatureObject.h"
#include "serverGame/PlayerShipTurretTargetingSystem.h"
#include "serverGame/ServerShipObjectInterface.h"
#include "serverGame/ShipAiEnemySearchManager.h"
#include "serverGame/ShipClientUpdateTracker.h"
#include "serverGame/ShipObject.h"
#include "serverGame/TangibleObject.h"
#include "serverScript/GameScriptObject.h"
#include "serverScript/ScriptParameters.h"
#include "sharedDebug/DebugFlags.h"
#include "sharedFoundation/ConstCharCrcString.h"
#include "sharedFoundation/GameControllerMessage.h"
#include "sharedGame/ShipDynamicsModel.h"
#include "sharedLog/Log.h"
#include "sharedMathArchive/TransformArchive.h"
#include "sharedNetworkMessages/MessageQueueDataTransform.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
#include "sharedNetworkMessages/MessageQueueSpaceMiningSellResource.h"
#include "sharedNetworkMessages/MessageQueueTeleportAck.h"
#include "sharedNetworkMessages/ShipUpdateTransformCollisionMessage.h"
#include "sharedNetworkMessages/ShipUpdateTransformMessage.h"
#include "sharedObject/AlterResult.h"
#include "sharedObject/NetworkIdManager.h"
#include <map>
// ======================================================================
// PlayerShipControllerNamespace
// ======================================================================
namespace PlayerShipControllerNamespace
{
bool ms_logHandleNetUpdateTransform;
void remove();
float const s_targetedByAiExpireTime = 20.0f;
int syncStampLongDeltaTime(uint32 stamp1, uint32 stamp2)
{
uint32 const delta = stamp1 - stamp2;
if (delta > 0x7fffffff)
return static_cast<int>(0xffffffff-delta);
return static_cast<int>(delta);
}
}
using namespace PlayerShipControllerNamespace;
// ======================================================================
void PlayerShipController::install()
{
DebugFlags::registerFlag(ms_logHandleNetUpdateTransform, "ServerGame/RemoteShipController", "logHandleNetUpdateTransform*");
ExitChain::add(&remove, "PlayerShipController::remove");
}
// ----------------------------------------------------------------------
void PlayerShipControllerNamespace::remove()
{
DebugFlags::unregisterFlag(ms_logHandleNetUpdateTransform);
}
// ======================================================================
// PUBLIC PlayerShipController
// ======================================================================
PlayerShipController::PlayerShipController(ShipObject * const owner) :
ShipController(owner),
m_clientToServerLastSyncStamp(0),
m_teleportIds(),
m_shipAccelRate(owner->getShipActualAccelerationRate(), ConfigServerGame::getShipMoveCheckIntervalMs(), ConfigServerGame::getShipMoveCheckFudgeTimeMs()),
m_shipDecelRate(owner->getShipActualDecelerationRate(), ConfigServerGame::getShipMoveCheckIntervalMs(), ConfigServerGame::getShipMoveCheckFudgeTimeMs()),
m_shipYprMaximum(owner->getShipActualYprRateMaximum(), ConfigServerGame::getShipMoveCheckIntervalMs(), ConfigServerGame::getShipMoveCheckFudgeTimeMs()),
m_shipSpeedMaximum(owner->getShipActualSpeedMaximum(), ConfigServerGame::getShipMoveCheckIntervalMs(), ConfigServerGame::getShipMoveCheckFudgeTimeMs()),
m_lastVerifiedTransform(),
m_lastVerifiedSpeed(0.f),
m_lastVerifiedSyncStamp(0),
m_gunnerWeaponIndexList(new GunnerWeaponIndexList),
m_targetedByAiTimer(s_targetedByAiExpireTime)
{
preventMovementUpdates();
}
// ----------------------------------------------------------------------
PlayerShipController::~PlayerShipController()
{
delete m_gunnerWeaponIndexList;
}
// ----------------------------------------------------------------------
void PlayerShipController::endBaselines()
{
if (getAuthoritative())
{
ShipObject * const ship = getShipOwner();
ship->clearCondition(static_cast<int>(TangibleObject::C_docking));
m_shipAccelRate.setValue(ship->getShipActualAccelerationRate(), 0);
m_shipDecelRate.setValue(ship->getShipActualDecelerationRate(), 0);
m_shipYprMaximum.setValue(ship->getShipActualYprRateMaximum(), 0);
m_shipSpeedMaximum.setValue(ship->getShipActualSpeedMaximum(), 0);
}
m_yawPosition = 0.f;
m_pitchPosition = 0.f;
m_rollPosition = 0.f;
m_throttlePosition = 0.f;
ShipController::endBaselines();
}
// ----------------------------------------------------------------------
void PlayerShipController::setAuthoritative(bool newAuthoritative)
{
ShipController::setAuthoritative(newAuthoritative);
if (!newAuthoritative)
preventMovementUpdates();
else
{
ShipObject const * const ship = NON_NULL(getShipOwner());
if (ship->getClient())
resyncMovementUpdates();
m_shipAccelRate.setValue(ship->getShipActualAccelerationRate(), 0);
m_shipDecelRate.setValue(ship->getShipActualDecelerationRate(), 0);
m_shipYprMaximum.setValue(ship->getShipActualYprRateMaximum(), 0);
m_shipSpeedMaximum.setValue(ship->getShipActualSpeedMaximum(), 0);
}
}
// ----------------------------------------------------------------------
void PlayerShipController::onClientReady()
{
m_clientToServerLastSyncStamp = 0;
if (getAuthoritative())
resyncMovementUpdates();
}
// ----------------------------------------------------------------------
void PlayerShipController::onClientLost()
{
m_yawPosition = 0.f;
m_pitchPosition = 0.f;
m_rollPosition = 0.f;
m_throttlePosition = 0.f;
preventMovementUpdates();
unDock();
}
// ----------------------------------------------------------------------
void PlayerShipController::receiveTransform(ShipUpdateTransformMessage const & shipUpdateTransformMessage)
{
if (isTeleporting())
return;
ShipObject * const owner = NON_NULL(getShipOwner());
if (owner->hasCondition(static_cast<int>(TangibleObject::C_docking)))
return;
uint32 const syncStamp = shipUpdateTransformMessage.getSyncStampLong();
if ( m_clientToServerLastSyncStamp == 0
|| syncStampLongDeltaTime(m_clientToServerLastSyncStamp, syncStamp) > 0)
{
m_clientToServerLastSyncStamp = syncStamp;
Transform const &transform = shipUpdateTransformMessage.getTransform();
Vector const &velocity = shipUpdateTransformMessage.getVelocity();
float const speed = velocity.magnitude();
if (!checkValidMove(transform, velocity, speed, syncStamp))
teleport(m_lastVerifiedTransform, 0);
else
{
m_shipDynamicsModel->setTransform(transform);
m_shipDynamicsModel->setVelocity(velocity);
ServerShipObjectInterface const serverShipObjectInterface(owner);
//-- Transform speeds into throttle positions and compute delta time
m_throttlePosition = 0.f;
m_yawPosition = 0.f;
m_pitchPosition = 0.f;
m_rollPosition = 0.f;
float deltaTime = 0.f;
Client const * const client = owner->getClient();
if (client)
{
CreatureObject const * const pilot = safe_cast<CreatureObject const *>(client->getCharacterObject());
if (pilot && !pilot->getState(States::Frozen))
{
if (serverShipObjectInterface.getMaximumSpeed() > 0.f)
m_throttlePosition = clamp(0.f, speed / serverShipObjectInterface.getMaximumSpeed(), 1.f);
if (serverShipObjectInterface.getMaximumYaw() > 0.f)
m_yawPosition = clamp(-1.f, shipUpdateTransformMessage.getYawRate() / serverShipObjectInterface.getMaximumYaw(), 1.f);
if (serverShipObjectInterface.getMaximumPitch() > 0.f)
m_pitchPosition = clamp(-1.f, shipUpdateTransformMessage.getPitchRate() / serverShipObjectInterface.getMaximumPitch(), 1.f);
if (serverShipObjectInterface.getMaximumRoll() > 0.f)
m_rollPosition = clamp(-1.f, shipUpdateTransformMessage.getRollRate() / serverShipObjectInterface.getMaximumRoll(), 1.f);
deltaTime = client->computeDeltaTimeInSeconds(syncStamp);
}
}
//-- Advance by delta time
m_shipDynamicsModel->model(deltaTime, m_yawPosition, m_pitchPosition, m_rollPosition, m_throttlePosition, serverShipObjectInterface);
DEBUG_REPORT_LOG(ms_logHandleNetUpdateTransform, ("PlayerShipController::handleNetUpdateTransform[%s]: %1.2f\n", owner->getNetworkId().getValueString().c_str(), m_throttlePosition));
}
}
else
DEBUG_REPORT_LOG(true, ("PlayerShipController::handleNetUpdateTransform[%s]: disregarding older packet\n", owner->getNetworkId().getValueString().c_str()));
}
// ----------------------------------------------------------------------
void PlayerShipController::teleport(Transform const &goal, ServerObject *goalObj)
{
ShipObject * const ship = NON_NULL(getShipOwner());
Client * const client = ship->getClient();
if (client && !goalObj)
{
int const sequenceId = static_cast<int>(ship->getAndIncrementMoveSequenceNumber());
IGNORE_RETURN(m_teleportIds.insert(sequenceId));
appendMessage(
CM_netUpdateTransform,
0.f,
new MessageQueueDataTransform(0, sequenceId, goal, 0.f, 0.f, false),
GameControllerMessageFlags::RELIABLE|GameControllerMessageFlags::SEND|GameControllerMessageFlags::DEST_AUTH_CLIENT);
m_lastVerifiedTransform = goal;
m_lastVerifiedSpeed = 0;
m_lastVerifiedSyncStamp = getCurSyncStamp();
}
ShipController::teleport(goal, goalObj);
}
// ----------------------------------------------------------------------
void PlayerShipController::handleMessage(int const message, float const value, MessageQueue::Data const * const data, uint32 const flags)
{
switch (message)
{
case CM_teleportAck:
{
MessageQueueTeleportAck const * const msg = dynamic_cast<MessageQueueTeleportAck const *>(data);
if (msg)
handleTeleportAck(msg->getSequenceId());
}
break;
case CM_shipStopFiring:
{
ShipObject * const ship = NON_NULL(getShipOwner());
typedef MessageQueueGenericValueType<int> MessageType;
MessageType const * const msg = dynamic_cast<MessageType const *>(data);
if (msg)
{
int const weaponIndex = msg->getValue();
ship->stopFiringWeapon(weaponIndex);
}
}
break;
case CM_spaceMiningSaleSellResource:
{
MessageQueueSpaceMiningSellResource const * const msg = dynamic_cast<MessageQueueSpaceMiningSellResource const *>(data);
if (msg != NULL)
{
ServerObject * const spaceStation = safe_cast<ServerObject *>(NetworkIdManager::getObjectById(msg->m_spaceStationId));
if (NULL == spaceStation)
{
WARNING(true, ("PlayerCreatureController CM_spaceMiningSaleSellResource invalid station [%s]", msg->m_spaceStationId.getValueString().c_str()));
}
else
{
GameScriptObject * const scriptObject = spaceStation->getScriptObject();
if (scriptObject)
{
ScriptParams params;
params.addParam(getOwner()->getNetworkId());
params.addParam(msg->m_shipId);
params.addParam(msg->m_spaceStationId);
params.addParam(msg->m_resourceId);
params.addParam(msg->m_amount);
scriptObject->trigAllScripts(Scripting::TRIG_SPACE_MINING_SELL_RESOURCE, params);
}
}
}
}
break;
default:
ShipController::handleMessage(message, value, data, flags);
break;
}
}
// ----------------------------------------------------------------------
void PlayerShipController::onShipAccelerationRateChanged(float value)
{
m_shipAccelRate.setValue(value, getCurSyncStamp());
}
// ----------------------------------------------------------------------
void PlayerShipController::onShipDecelerationRateChanged(float value)
{
m_shipDecelRate.setValue(value, getCurSyncStamp());
}
// ----------------------------------------------------------------------
void PlayerShipController::onShipYprMaximumChanged(float value)
{
m_shipYprMaximum.setValue(value, getCurSyncStamp());
}
// ----------------------------------------------------------------------
void PlayerShipController::onShipSpeedMaximumChanged(float value)
{
m_shipSpeedMaximum.setValue(value, getCurSyncStamp());
}
// ----------------------------------------------------------------------
bool PlayerShipController::isTeleporting() const
{
return !m_teleportIds.empty();
}
// ======================================================================
// PROTECTED PlayerShipController
// ======================================================================
float PlayerShipController::realAlter(float const elapsedTime)
{
PROFILER_AUTO_BLOCK_DEFINE("PlayerShipController::realAlter");
ShipObject * const owner = getShipOwner();
if (!owner || !owner->isInWorld())
return ShipController::realAlter(elapsedTime);
if (owner && owner->isInitialized())
{
if (m_pendingDockingBehavior != NULL)
{
delete m_dockingBehavior;
m_dockingBehavior = m_pendingDockingBehavior;
m_pendingDockingBehavior = NULL;
getShipOwner()->setCondition(static_cast<int>(TangibleObject::C_docking));
Client * const client = owner->getClient();
if (client != NULL)
{
ShipClientUpdateTracker::queueForUpdate(*client, *owner);
}
else
{
unDock();
}
}
if ( (m_dockingBehavior != NULL)
&& m_dockingBehavior->isDockFinished())
{
delete m_dockingBehavior;
m_dockingBehavior = NULL;
getShipOwner()->clearCondition(static_cast<int>(TangibleObject::C_docking));
}
if (m_dockingBehavior != NULL)
{
//-- The docking behavior will calculate new values for m_yaw/m_pitch/m_roll/m_throttle[Position] implicitly through calling ShipController members
m_dockingBehavior->alter(elapsedTime);
}
//-- Update flight model
ServerShipObjectInterface const serverShipObjectInterface(owner);
m_shipDynamicsModel->model(elapsedTime, m_yawPosition, m_pitchPosition, m_rollPosition, m_throttlePosition, serverShipObjectInterface);
//-- Update the server position based on the model
owner->setTransform_o2p(m_shipDynamicsModel->getTransform());
// Request new enemies for any turrets
if ( hasTurretTargetingSystem()
&& !m_enemyCheckQueued)
{
m_enemyCheckQueued = true;
ShipAiEnemySearchManager::add(*owner);
}
if (m_targetedByAiTimer.updateNoReset(elapsedTime))
{
owner->clearCondition(static_cast<int>(TangibleObject::C_spaceCombatMusic));
}
}
//-- Chain back up to parent
float alterResult = ShipController::realAlter(elapsedTime);
AlterResult::incorporateAlterResult(alterResult, AlterResult::cms_alterNextFrame);
return alterResult;
}
// ----------------------------------------------------------------------
void PlayerShipController::handleNetUpdateTransform(MessageQueueDataTransform const & /*message*/)
{
//-- This message should be handled in handleMessage
DEBUG_FATAL(true, ("PlayerShipController::handleNetUpdateTransform: not implemented (nor should it be)"));
}
// ----------------------------------------------------------------------
void PlayerShipController::handleNetUpdateTransformWithParent(MessageQueueDataTransformWithParent const & /*message*/)
{
//-- This message should be handled in handleMessage
DEBUG_FATAL(true, ("PlayerShipController::handleNetUpdateTransformWithParent: not implemented (nor should it be)"));
}
// ======================================================================
// PRIVATE PlayerShipController
// ======================================================================
void PlayerShipController::preventMovementUpdates()
{
m_teleportIds.clear();
IGNORE_RETURN(m_teleportIds.insert(-1));
}
// ----------------------------------------------------------------------
void PlayerShipController::handleTeleportAck(int sequenceId)
{
IGNORE_RETURN(m_teleportIds.erase(sequenceId));
}
// ----------------------------------------------------------------------
void PlayerShipController::resyncMovementUpdates()
{
// We resync updates by doing a fake teleport, giving a negative
// sequence so the client does not actually do the movement.
// This locks out movement updates until the teleport is acknowledged.
ShipObject * const ship = NON_NULL(getShipOwner());
Client * const client = ship->getClient();
FATAL(!client || !ship->isAuthoritative(), ("Tried to resync ship movement updates either while nonauth or without a client!"));
m_teleportIds.clear();
int sequenceId = -1;
while (sequenceId == -1)
sequenceId = -static_cast<int>(ship->getAndIncrementMoveSequenceNumber());
IGNORE_RETURN(m_teleportIds.insert(sequenceId));
appendMessage(
CM_netUpdateTransform,
0.f,
new MessageQueueDataTransform(0, sequenceId, Transform::identity, 0.f, 0.f, false),
GameControllerMessageFlags::RELIABLE|GameControllerMessageFlags::SEND|GameControllerMessageFlags::DEST_AUTH_CLIENT);
m_lastVerifiedTransform = m_shipDynamicsModel->getTransform();
m_lastVerifiedSpeed = m_shipDynamicsModel->getSpeed();
m_lastVerifiedSyncStamp = getCurSyncStamp();
}
// ----------------------------------------------------------------------
void PlayerShipController::experiencedCollision()
{
ShipObject * const owner = getShipOwner();
if (owner != 0)
{
Client* client = owner->getClient();
if (client != 0)
{
ShipUpdateTransformCollisionMessage const collisionMessage(
owner->getNetworkId(),
getTransform(),
getVelocity(),
client->getServerSyncStampLong());
client->send(collisionMessage, false);
}
}
}
// ----------------------------------------------------------------------
uint32 PlayerShipController::getCurSyncStamp() const
{
Client const * const client = NON_NULL(getShipOwner())->getClient();
return client ? client->getServerSyncStampLong() : 0;
}
// ----------------------------------------------------------------------
void PlayerShipController::logMoveFail(char const *reasonFmt, ...) const
{
ShipObject const * const ship = NON_NULL(getShipOwner());
Client const * const client = NON_NULL(ship->getClient());
char reason[512];
va_list ap;
va_start(ap, reasonFmt);
IGNORE_RETURN(_vsnprintf(reason, sizeof(reason)-1, reasonFmt, ap));
reason[sizeof(reason)-1] = '\0';
LOG(
"shipmove",
(
"fail - ship %s creature %s stationId %u - %s",
ship->getNetworkId().getValueString().c_str(),
client->getCharacterObjectId().getValueString().c_str(),
client->getStationId(),
reason));
}
// ----------------------------------------------------------------------
bool PlayerShipController::checkValidMove(Transform const &transform, Vector const &velocity, float speed, uint32 const currentClientSyncStamp)
{
if (!ConfigServerGame::getShipMoveValidationEnabled())
return true;
ShipObject * const owner = NON_NULL(getShipOwner());
Client const * const client = NON_NULL(owner->getClient());
// gods can move however they like, and assume their moves are valid
if (!client->isGod())
{
uint32 const currentServerSyncStamp = client->getServerSyncStampLong();
uint32 const previousClientSyncStamp = m_lastVerifiedSyncStamp;
int const timeDiffMs = syncStampLongDeltaTime(previousClientSyncStamp, currentClientSyncStamp);
float const timeDiffSec = static_cast<float>(timeDiffMs)*0.001f;
float const tolerance = ConfigServerGame::getShipMoveCheckTolerance();
float const timeTolerance = ConfigServerGame::getShipMoveCheckTimeToleranceSeconds();
// is our new speed valid?
float const speedMaximum = m_shipSpeedMaximum.getRecentMaximum(currentServerSyncStamp);
if (speed > speedMaximum*tolerance)
{
logMoveFail("too fast (speed=%g, speedMax=%g, timeDiff=%g, time %u)", speed, speedMaximum, timeDiffSec, currentClientSyncStamp);
return false;
}
// Only do position/rotation validation periodically, since their timestamps
// can be affected by latency variation.
if (timeDiffMs < ConfigServerGame::getShipMoveCheckIntervalMs())
{
// assume we're ok to move, but don't update the last verified
return true;
}
// check for bogus timestamps, making sure to handle timestamp rollover
if (ConfigServerGame::getMoveValidationCheckForPastTimestamp())
{
// new timestamp from client must be greater than previous timestamp from client (i.e. cannot travel back in time)
if (currentClientSyncStamp < previousClientSyncStamp)
{
uint32 const rolloverFudgeFactor = static_cast<uint32>(100000); // 100 seconds
// pretty sure that timestamp did not rollover
if ((previousClientSyncStamp > rolloverFudgeFactor) && ((std::numeric_limits<uint32>::max() - rolloverFudgeFactor) > previousClientSyncStamp))
{
int const timeDiffMs = syncStampLongDeltaTime(previousClientSyncStamp, currentClientSyncStamp);
// only fail movement if the difference is beyond a certain threshold,
// to account for network latency, UDP unreliability, clock drift, etc.
if (timeDiffMs > ConfigServerGame::getMoveValidationPastTimestampThresholdMs())
{
logMoveFail("out of order timestamps (%dms), oss=%lu, css=%lu (%lud:%luh:%lum:%lus), ssc=%lu",
timeDiffMs,
previousClientSyncStamp,
currentServerSyncStamp,
(currentServerSyncStamp / 1000) / (60 * 60 * 24),
((currentServerSyncStamp / 1000) % (60 * 60 * 24)) / (60 * 60),
((currentServerSyncStamp / 1000) % (60 * 60)) / 60,
(currentServerSyncStamp / 1000) % 60,
currentClientSyncStamp);
return false;
}
}
}
}
// check for bogus timestamps, making sure to handle timestamp rollover
if (ConfigServerGame::getMoveValidationCheckForFutureTimestamp())
{
// new timestamp from client must be less than the current server timestamp (i.e. cannot travel into the future)
if (currentClientSyncStamp > currentServerSyncStamp)
{
uint32 const rolloverFudgeFactor = static_cast<uint32>(100000); // 100 seconds
// pretty sure that timestamp did not rollover
if ((currentServerSyncStamp > rolloverFudgeFactor) && ((std::numeric_limits<uint32>::max() - rolloverFudgeFactor) > currentServerSyncStamp))
{
int const timeDiffMs = syncStampLongDeltaTime(currentClientSyncStamp, currentServerSyncStamp);
// only fail movement if the difference is beyond a certain threshold,
// to account for network latency, UDP unreliability, clock drift, etc.
if (timeDiffMs > ConfigServerGame::getMoveValidationFutureTimestampThresholdMs())
{
logMoveFail("timestamp from the future (%dms), oss=%lu, css=%lu (%lud:%luh:%lum:%lus), ssc=%lu",
timeDiffMs,
previousClientSyncStamp,
currentServerSyncStamp,
(currentServerSyncStamp / 1000) / (60 * 60 * 24),
((currentServerSyncStamp / 1000) % (60 * 60 * 24)) / (60 * 60),
((currentServerSyncStamp / 1000) % (60 * 60)) / 60,
(currentServerSyncStamp / 1000) % 60,
currentClientSyncStamp);
return false;
}
}
}
}
// make sure the client and server time hasn't drifted too far apart
if (ConfigServerGame::getMoveValidationCheckForTimestampDrift())
{
int const clientServerTimeDiff = syncStampLongDeltaTime(currentClientSyncStamp, currentServerSyncStamp);
if (clientServerTimeDiff > ConfigServerGame::getMoveValidationTimestampDriftThresholdMs())
{
logMoveFail("timestamp drift (%dms), oss=%lu, css=%lu (%lud:%luh:%lum:%lus), ssc=%lu",
clientServerTimeDiff,
previousClientSyncStamp,
currentServerSyncStamp,
(currentServerSyncStamp / 1000) / (60 * 60 * 24),
((currentServerSyncStamp / 1000) % (60 * 60 * 24)) / (60 * 60),
((currentServerSyncStamp / 1000) % (60 * 60)) / 60,
(currentServerSyncStamp / 1000) % 60,
currentClientSyncStamp);
return false;
}
}
// could we possibly have changed position enough?
Vector const &lastPosition = m_lastVerifiedTransform.getPosition_p();
Vector const &position = transform.getPosition_p();
float const distanceSquared = lastPosition.magnitudeBetweenSquared(position);
if (distanceSquared > sqr(speedMaximum*(timeDiffSec+timeTolerance)*tolerance)+0.2f)
{
logMoveFail(
"too far (distSquared=%g, maxDistSquared=%g, timeDiff=%g from [%g,%g,%g] to [%g,%g,%g], time %u)",
distanceSquared, sqr(speedMaximum*timeDiffSec), timeDiffSec,
lastPosition.x, lastPosition.y, lastPosition.z,
position.x, position.y, position.z, currentClientSyncStamp);
return false;
}
// could we possibly have changed speeds enough?
float const oldSpeed = m_lastVerifiedSpeed;
if (speed > oldSpeed)
{
float const accel = (oldSpeed-speed)/(timeDiffSec+timeTolerance);
float const maxAccel = m_shipAccelRate.getRecentMaximum(currentServerSyncStamp);
if (accel > maxAccel*tolerance)
{
logMoveFail("too much acceleration (accel=%g, maxAccel=%g, time %u)", accel, maxAccel, currentClientSyncStamp);
return false;
}
}
else if (speed < oldSpeed)
{
float const decel = (speed-oldSpeed)/(timeDiffSec+timeTolerance);
float const maxDecel = m_shipDecelRate.getRecentMaximum(currentServerSyncStamp);
if (decel > maxDecel*tolerance)
{
logMoveFail("too much deceleration (decel=%g, maxDecel=%g, time %u)", decel, maxDecel, currentClientSyncStamp);
return false;
}
}
// could we possibly have changed orientation enough?
float const rotation = acos(transform.getLocalFrameK_p().dot(m_lastVerifiedTransform.getLocalFrameK_p()))/(timeDiffSec+timeTolerance);
float const maxRotation = m_shipYprMaximum.getRecentMaximum(currentServerSyncStamp);
// Actual max rotation is roughly sqrt(2*sqr(maxRotation))+0.001f, to allow
// for pitch/yaw/roll together being applied toward the same direction, and
// adjust slightly for precision.
if (sqr(rotation) > 2*sqr(maxRotation*tolerance)+0.001f)
{
logMoveFail("too much rotation (rotation=%g, maxRotation=%g, time %u)", rotation, maxRotation, currentClientSyncStamp);
return false;
}
}
UNREF(velocity);
m_lastVerifiedTransform = transform;
m_lastVerifiedSpeed = speed;
m_lastVerifiedSyncStamp = currentClientSyncStamp;
return true;
}
// ----------------------------------------------------------------------
PlayerShipController * PlayerShipController::asPlayerShipController()
{
return this;
}
// ----------------------------------------------------------------------
PlayerShipController const * PlayerShipController::asPlayerShipController() const
{
return this;
}
// ----------------------------------------------------------------------
bool PlayerShipController::shouldCheckForEnemies() const
{
return (getShipOwner()->hasTurrets());
}
// ----------------------------------------------------------------------
void PlayerShipController::updateGunnerWeaponIndex(NetworkId const & player, int const gunnerWeaponIndex)
{
GunnerWeaponIndexList::iterator iterGunnerWeaponIndexList = m_gunnerWeaponIndexList->find(player);
if (iterGunnerWeaponIndexList != m_gunnerWeaponIndexList->end())
{
int const previousGunnerWeaponIndex = iterGunnerWeaponIndexList->second;
iterGunnerWeaponIndexList->second = gunnerWeaponIndex;
if ( (previousGunnerWeaponIndex >= 0)
&& (gunnerWeaponIndex == -1))
{
// Gunner is exiting a gun
setWeaponIndexPlayerControlled(previousGunnerWeaponIndex, false);
m_gunnerWeaponIndexList->erase(iterGunnerWeaponIndexList);
}
else if (previousGunnerWeaponIndex != gunnerWeaponIndex)
{
// Gunner was previously in a gun and is moving to a new gun
setWeaponIndexPlayerControlled(previousGunnerWeaponIndex, false);
setWeaponIndexPlayerControlled(gunnerWeaponIndex, true);
}
}
else
{
if (gunnerWeaponIndex >= 0)
{
// Gunner is entering a gun and was previously not in a gun
setWeaponIndexPlayerControlled(gunnerWeaponIndex, true);
IGNORE_RETURN(m_gunnerWeaponIndexList->insert(std::make_pair(player, gunnerWeaponIndex)));
}
else
{
// Gunner is not entering a gun and was not previously in a gun
}
}
}
// ----------------------------------------------------------------------
void PlayerShipController::setWeaponIndexPlayerControlled(int const weaponIndex, bool const playerControlled)
{
DEBUG_FATAL((weaponIndex < 0), ("Invalid weaponIndex(%d)", weaponIndex));
if (m_turretTargetingSystem != NULL)
{
safe_cast<PlayerShipTurretTargetingSystem*>(m_turretTargetingSystem)->setWeaponIndexPlayerControlled(weaponIndex, playerControlled);
}
}
// ----------------------------------------------------------------------
void PlayerShipController::addAiTargetingMe(NetworkId const & unit)
{
ShipController::addAiTargetingMe(unit);
if (m_targetedByAiTimer.isExpired())
{
getShipOwner()->setCondition(static_cast<int>(TangibleObject::C_spaceCombatMusic));
}
m_targetedByAiTimer.reset();
}
// ======================================================================
@@ -0,0 +1,100 @@
// ======================================================================
//
// PlayerShipController.h
// asommers
//
// copyright 2004, sony online entertainment
//
// ======================================================================
#ifndef INCLUDED_PlayerShipController_H
#define INCLUDED_PlayerShipController_H
// ======================================================================
#include "serverGame/ShipController.h"
#include "serverUtility/RecentMaxSyncedValue.h"
#include "sharedFoundation/Timer.h"
// ======================================================================
class ShipUpdateTransformMessage;
// ======================================================================
class PlayerShipController : public ShipController
{
public:
static void install();
public:
explicit PlayerShipController(ShipObject * const owner);
virtual ~PlayerShipController();
virtual void endBaselines();
virtual void setAuthoritative(bool newAuthoritative);
virtual void onClientReady();
virtual void onClientLost();
virtual void teleport(Transform const &goal, ServerObject *goalObj);
virtual PlayerShipController * asPlayerShipController();
virtual PlayerShipController const * asPlayerShipController() const;
void receiveTransform(ShipUpdateTransformMessage const & shipUpdateTransformMessage);
void onShipAccelerationRateChanged(float value);
void onShipDecelerationRateChanged(float value);
void onShipYprMaximumChanged(float value);
void onShipSpeedMaximumChanged(float value);
virtual bool shouldCheckForEnemies() const;
void updateGunnerWeaponIndex(NetworkId const & player, int const gunnerWeaponIndex);
void setWeaponIndexPlayerControlled(int const weaponIndex, bool const playerControlled);
virtual void addAiTargetingMe(NetworkId const & unit);
bool isTeleporting() const;
protected:
virtual void handleMessage(int message, float value, const MessageQueue::Data* data, uint32 flags);
virtual float realAlter(float elapsedTime);
virtual void handleNetUpdateTransform(MessageQueueDataTransform const & message);
virtual void handleNetUpdateTransformWithParent(MessageQueueDataTransformWithParent const & message);
private:
PlayerShipController();
PlayerShipController(PlayerShipController const &);
PlayerShipController & operator=(PlayerShipController const &);
void preventMovementUpdates();
void handleTeleportAck(int sequenceId);
void resyncMovementUpdates();
virtual void experiencedCollision();
uint32 getCurSyncStamp() const;
bool checkValidMove(Transform const &transform, Vector const &velocity, float speed, uint32 syncStamp);
void logMoveFail(char const *reasonFmt, ...) const;
private:
typedef stdmap<NetworkId, int>::fwd GunnerWeaponIndexList;
uint32 m_clientToServerLastSyncStamp;
std::set<int> m_teleportIds;
RecentMaxSyncedValue m_shipAccelRate;
RecentMaxSyncedValue m_shipDecelRate;
RecentMaxSyncedValue m_shipYprMaximum;
RecentMaxSyncedValue m_shipSpeedMaximum;
Transform m_lastVerifiedTransform;
float m_lastVerifiedSpeed;
uint32 m_lastVerifiedSyncStamp;
GunnerWeaponIndexList * const m_gunnerWeaponIndexList;
Timer m_targetedByAiTimer;
};
// ======================================================================
#endif
@@ -0,0 +1,26 @@
// ======================================================================
//
// ResourceContainerController.cpp
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/ResourceContainerController.h"
#include "serverGame/ResourceContainerObject.h"
//-----------------------------------------------------------------------
ResourceContainerController::ResourceContainerController(ResourceContainerObject * newOwner) :
TangibleController(newOwner)
{
}
//-----------------------------------------------------------------------
ResourceContainerController::~ResourceContainerController()
{
}
//-----------------------------------------------------------------------
@@ -0,0 +1,30 @@
//ResourceContainerController.h
#ifndef _WEAPON_CONTROLLER_H
#define _WEAPON_CONTROLLER_H
//-----------------------------------------------------------------------
#include "serverGame/TangibleController.h"
//----------------------------------------------------------------------
class ResourceContainerObject;
//-----------------------------------------------------------------------
class ResourceContainerController : public TangibleController
{
public:
explicit ResourceContainerController (ResourceContainerObject * newOwner);
~ResourceContainerController (void);
private:
ResourceContainerController (void);
ResourceContainerController (const ResourceContainerController & other);
ResourceContainerController operator= (const ResourceContainerController & other);
};
//-----------------------------------------------------------------------
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,174 @@
// ======================================================================
//
// ServerController.h
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_ServerController_H
#define INCLUDED_ServerController_H
// ======================================================================
#include "serverGame/ServerObject.h"
#include "sharedFoundation/Watcher.h"
#include "sharedObject/NetworkController.h"
#include "sharedMath/Transform.h"
//-----------------------------------------------------------------------
class CellProperty;
//----------------------------------------------------------------------
/**
* The base class for server-side controllers.
*
*/
class ServerController : public NetworkController
{
public:
explicit ServerController (Object * newOwner);
virtual ~ServerController (void);
virtual void conclude ();
virtual void onClientReady ();
virtual void onClientLost ();
virtual void sendControllerMessage(const ObjControllerMessage& msg);
virtual const Vector & getCurrentVelocity() const;
virtual void setAuthoritative (bool newAuthoritative);
virtual void setOwner(Object *newOwner);
virtual void endBaselines();
virtual int elevatorMove (int nFloors);
virtual void teleport(Transform const &goal, ServerObject *goalObj);
/** object modification functions that should only be called on authoritative
* objects
*/
void setObjectName(const Unicode::String &name);
ServerObject * getServerOwner();
const ServerObject * getServerOwner() const;
virtual void onAppendMessage();
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
virtual ServerObject const * getGoalCellObject () const;
int getMoveSequenceNumber() const;
protected:
virtual float realAlter (float time);
virtual void onMoveFailed ();
virtual void handleNetUpdateTransform (const MessageQueueDataTransform& message);
virtual void handleNetUpdateTransformWithParent (const MessageQueueDataTransformWithParent& message);
virtual void setCurrentVelocity (const Vector & newVelocity);
virtual void setGoal (Transform const & newGoal, ServerObject * goalCellObject, bool teleport = false );
virtual void moveToGoal ();
virtual bool setObjectCell (ServerObject * newCellObject);
virtual Transform const & getGoalTransform () const;
virtual void synchronizeTransform();
protected:
bool m_sendReliableTransformThisFrame;
int m_moveSequenceNumber;
private:
ServerController ();
ServerController (const ServerController & other);
ServerController& operator= (const ServerController & rhs);
void updateTransform();
private:
class MessageQueueNotification: public MessageQueue::Notification
{
public:
MessageQueueNotification();
virtual ~MessageQueueNotification();
void setController(ServerController *serverController);
virtual void onChanged() const;
private:
MessageQueueNotification(MessageQueueNotification const &);
MessageQueueNotification& operator=(MessageQueueNotification const &);
private:
ServerController *m_serverController;
};
Vector m_currentVelocity;
Vector m_oldVelocity;
Transform m_goalTransform; // where the client wants to move the server object to
Watcher<ServerObject> m_goalCellObject;
bool m_bProcessingMessages; // true while the controller is processing its message queue
bool m_bHasGoal;
bool m_bAtGoal;
bool m_bTeleport;
bool m_alteredSinceConclude;
MessageQueueNotification m_notification;
};
// ----------------------------------------------------------------------
inline const Vector & ServerController::getCurrentVelocity() const
{
return m_currentVelocity;
}
//-----------------------------------------------------------------------
inline void ServerController::setCurrentVelocity(const Vector& v)
{
m_currentVelocity = v;
}
//-----------------------------------------------------------------------
inline const ServerObject * ServerController::getServerOwner() const
{
return safe_cast<const ServerObject *>(getOwner());
}
// ----------------------------------------------------------------------
inline ServerObject * ServerController::getServerOwner()
{
return safe_cast<ServerObject *>(getOwner());
}
// ----------------------------------------------------------------------
inline Transform const & ServerController::getGoalTransform() const
{
return m_goalTransform;
}
// ----------------------------------------------------------------------
inline ServerObject const * ServerController::getGoalCellObject() const
{
return m_goalCellObject;
}
// ======================================================================
#endif //_ServerController_H
@@ -0,0 +1,938 @@
// ======================================================================
//
// ShipController.cpp
// Copyright 2003 Sony Online Entertainment
//
// ======================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/ShipController.h"
#include "serverGame/AiServerShipObjectInterface.h"
#include "serverGame/AiShipAttackTargetList.h"
#include "serverGame/AiShipBehaviorDock.h"
#include "serverGame/AiShipController.h"
#include "serverGame/ConfigServerGame.h"
#include "serverGame/CreatureObject.h"
#include "serverGame/PlayerShipTurretTargetingSystem.h"
#include "serverGame/ServerShipObjectInterface.h"
#include "serverGame/ShipObject.h"
#include "serverGame/ShipTurretTargetingSystem.h"
#include "sharedGame/ShipDynamicsModel.h"
#include "sharedLog/Log.h"
#include "sharedMathArchive/TransformArchive.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
#include "sharedNetworkMessages/MessageQueueNetworkId.h"
#include "sharedNetworkMessages/ShipUpdateTransformMessage.h"
#include "sharedObject/NetworkIdManager.h"
#include <set>
// ======================================================================
//
// ShipControllerNamespace
//
// ======================================================================
namespace ShipControllerNamespace
{
typedef std::vector<CachedNetworkId> PurgeList;
static PurgeList s_purgeList;
time_t const s_maxTargetAge = 60 * 2;
// If we are less than 5 degrees from the target orientation, don't roll.
// This prevents "wobbling."
float const s_fastOrientationDeltaRadians = convertDegreesToRadians(5.0f);
}
using namespace ShipControllerNamespace;
// ======================================================================
// PUBLIC ShipController
// ======================================================================
ShipController::ShipController(ShipObject * newOwner) :
TangibleController(newOwner),
m_shipDynamicsModel(new ShipDynamicsModel),
m_yawPosition(0.0f),
m_pitchPosition(0.0f),
m_rollPosition(0.0f),
m_throttlePosition(0.0f),
m_pendingDockingBehavior(NULL),
m_dockingBehavior(NULL),
m_attackTargetList(new AiShipAttackTargetList(newOwner)),
m_attackTargetDecayTimer(new Timer(static_cast<float>(s_maxTargetAge))),
m_enemyCheckQueued(false),
m_turretTargetingSystem(NULL),
m_dockedByList(new DockedByList),
m_aiTargetingMeList(new CachedNetworkIdList)
{
m_attackTargetDecayTimer->setElapsedTime(Random::randomReal() * m_attackTargetDecayTimer->getExpireTime());
}
// ----------------------------------------------------------------------
ShipController::~ShipController()
{
// The turret targeting system must be deleted before clearAiTargetingMeList(), because
// otherwise it will try to acquire new targets as the list is being cleared
delete m_turretTargetingSystem;
m_turretTargetingSystem = NULL;
clearAiTargetingMeList();
delete m_shipDynamicsModel;
delete m_dockedByList;
delete m_aiTargetingMeList;
delete m_pendingDockingBehavior;
m_pendingDockingBehavior = NULL;
delete m_dockingBehavior;
m_dockingBehavior = NULL;
delete m_attackTargetList;
delete m_attackTargetDecayTimer;
}
// ----------------------------------------------------------------------
void ShipController::endBaselines()
{
Object const * const owner = getOwner();
if (owner)
{
m_shipDynamicsModel->setTransform(owner->getTransform_o2p());
m_shipDynamicsModel->makeStationary();
}
TangibleController::endBaselines();
}
// ----------------------------------------------------------------------
void ShipController::teleport(Transform const &goal, ServerObject *goalObj)
{
if (!goalObj)
m_shipDynamicsModel->setTransform(goal);
TangibleController::teleport(goal, goalObj);
}
// ----------------------------------------------------------------------
void ShipController::onAddedToWorld()
{
Object const * const owner = getOwner();
if (owner)
{
m_shipDynamicsModel->setTransform(owner->getTransform_o2p());
m_shipDynamicsModel->makeStationary();
}
}
// ----------------------------------------------------------------------
Transform const &ShipController::getTransform() const
{
return m_shipDynamicsModel->getTransform();
}
// ----------------------------------------------------------------------
Vector const &ShipController::getVelocity() const
{
return m_shipDynamicsModel->getVelocity();
}
// ----------------------------------------------------------------------
float ShipController::getSpeed() const
{
return m_shipDynamicsModel->getSpeed();
}
// ----------------------------------------------------------------------
float ShipController::getYawRate() const
{
return m_shipDynamicsModel->getYawRate();
}
// ----------------------------------------------------------------------
float ShipController::getPitchRate() const
{
return m_shipDynamicsModel->getPitchRate();
}
// ----------------------------------------------------------------------
float ShipController::getRollRate() const
{
return m_shipDynamicsModel->getRollRate();
}
// ----------------------------------------------------------------------
void ShipController::respondToCollision(Vector const & deltaToMove_p, Vector const & newReflection_p, Vector const & /* normalOfSurface_p */)
{
// this is identical to the clients ShipController::respondToCollision.
// the difference it that the server also must call the virtual method
// ShipController::experiencedCollision at the end of execution
Transform transform_p(m_shipDynamicsModel->getTransform());
transform_p.move_p(deltaToMove_p);
m_shipDynamicsModel->setTransform(transform_p);
m_shipDynamicsModel->setVelocity(newReflection_p * m_shipDynamicsModel->getVelocity().magnitude());
ShipObject * const owner = getShipOwner();
NOT_NULL(owner);
owner->setTransform_o2p(transform_p);
experiencedCollision();
}
// ----------------------------------------------------------------------
float ShipController::realAlter(float elapsedTime)
{
PROFILER_AUTO_BLOCK_DEFINE("ShipController::realAlter");
ShipObject const * const owner = getShipOwner();
if (owner->isInWorld())
{
if (m_turretTargetingSystem)
{
m_turretTargetingSystem->alter(elapsedTime);
}
// Decay the attack targets
if (m_attackTargetDecayTimer->updateZero(elapsedTime))
{
PROFILER_AUTO_BLOCK_DEFINE("attackTargetList");
m_attackTargetList->purge(s_maxTargetAge);
if (m_attackTargetList->isEmpty())
{
onAttackTargetListEmpty();
}
}
}
return TangibleController::realAlter(elapsedTime);
}
// ----------------------------------------------------------------------
void ShipController::handleMessage (const int message, const float value, const MessageQueue::Data* const data, const uint32 flags)
{
UNREF(flags);
UNREF(value);
ShipObject * const owner = getShipOwner();
DEBUG_FATAL(!owner, ("Owner is NULL in ShipController::handleMessage\n"));
switch(message)
{
case CM_clientLookAtTarget:
{
const MessageQueueNetworkId * const msg = NON_NULL (dynamic_cast<const MessageQueueNetworkId *>(data));
owner->setPilotLookAtTarget (msg->getNetworkId ());
}
break;
case CM_clientLookAtTargetComponent:
{
const MessageQueueGenericValueType<int> * const msg = NON_NULL (dynamic_cast<const MessageQueueGenericValueType<int> *>(data));
owner->setPilotLookAtTargetSlot (static_cast<ShipChassisSlotType::Type>(msg->getValue()));
}
break;
default:
ServerController::handleMessage(message, value, data, flags);
break;
}
}
// ----------------------------------------------------------------------
void ShipController::addTurretTargetingSystem(ShipTurretTargetingSystem * newSystem)
{
DEBUG_FATAL(&newSystem->getShipController() != this,("Programmer bug: called addTurretTargetingSystem with a ShipTurretTargetingSystem whose owner did not match the controller it tried to attach to."));
removeTurretTargetingSystem();
m_turretTargetingSystem = newSystem;
}
// ----------------------------------------------------------------------
void ShipController::removeTurretTargetingSystem()
{
delete m_turretTargetingSystem;
m_turretTargetingSystem = NULL;
}
// ----------------------------------------------------------------------
bool ShipController::isBeingDocked() const
{
return !m_dockedByList->empty();
}
// ----------------------------------------------------------------------
void ShipController::addDockedBy(Object const & unit)
{
IGNORE_RETURN(m_dockedByList->insert(CachedNetworkId(unit)));
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("ShipController::addDockedBy() owner(%s) dockedBy(%s) dockedByListSize(%u)", (getOwner() != NULL) ? getOwner()->getNetworkId().getValueString().c_str() : "NULL", unit.getNetworkId().getValueString().c_str(), m_dockedByList->size()));
}
// ----------------------------------------------------------------------
void ShipController::removeDockedBy(Object const & unit)
{
DockedByList::iterator iterDockedByList = m_dockedByList->find(CachedNetworkId(unit));
if (iterDockedByList != m_dockedByList->end())
{
m_dockedByList->erase(iterDockedByList);
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("ShipController::removeDockedBy() owner(%s) dockedBy(%s) dockedByListSize(%u)", (getOwner() != NULL) ? getOwner()->getNetworkId().getValueString().c_str() : "NULL", unit.getNetworkId().getValueString().c_str(), m_dockedByList->size()));
}
else
{
DEBUG_WARNING(true, ("debug_ai: ERROR: Trying to remove a docking unit(%s) that is not actually in the process of docking.", unit.getDebugInformation().c_str()));
}
}
// ----------------------------------------------------------------------
ShipController::DockedByList const & ShipController::getDockedByList() const
{
return *m_dockedByList;
}
// ----------------------------------------------------------------------
void ShipController::addAiTargetingMe(NetworkId const & unit)
{
//LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("ShipController::addAiTargetingMe() owner(%s) unit(%s) m_aiTargetingMeList->size(%u+1)", getOwner()->getNetworkId().getValueString().c_str(), unit.getValueString().c_str(), m_aiTargetingMeList->size()));
DEBUG_FATAL((NetworkIdManager::getObjectById(unit) == NULL), ("ShipController::addAiTargetingMe() owner(%s) unit(%s) ERROR: The Ai who is targeting you is not a valid networkId", getOwner()->getNetworkId().getValueString().c_str(), unit.getValueString().c_str()));
// Make sure this is a valid networkId of an alive object
IGNORE_RETURN(m_aiTargetingMeList->insert(CachedNetworkId(unit)));
}
// ----------------------------------------------------------------------
void ShipController::removeAiTargetingMe(NetworkId const & unit)
{
//LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("ShipController::removeAiTargetingMe() owner(%s) unit(%s) m_aiTargetingMeList->size(%u-1)", getOwner()->getNetworkId().getValueString().c_str(), unit.getValueString().c_str(), m_aiTargetingMeList->size()));
CachedNetworkIdList::iterator iterTargetByList = m_aiTargetingMeList->find(CachedNetworkId(unit));
if (iterTargetByList != m_aiTargetingMeList->end())
{
m_aiTargetingMeList->erase(iterTargetByList);
}
else
{
// If you hit this fatal, then there is an removeAiTargetingMe() called without a matching addAiTargetingMe().
DEBUG_FATAL(true, ("Unable to find unit."));
}
// If no one else is targeting me (player's only), stop combat music
if (m_aiTargetingMeList->empty())
{
ShipObject * const shipOwner = getShipOwner();
if (shipOwner != NULL)
{
CreatureObject * const pilotOwner = CreatureObject::asCreatureObject(shipOwner->getPilot());
if ( (pilotOwner != NULL)
&& pilotOwner->isPlayerControlled())
{
shipOwner->clearCondition(static_cast<int>(TangibleObject::C_spaceCombatMusic));
//LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("ShipController::removeAiTargetingMe() owner(%s) Clearing TangibleObject::C_spaceCombatMusic", getOwner()->getNetworkId().getValueString().c_str()));
}
}
}
}
// ----------------------------------------------------------------------
ShipController::CachedNetworkIdList const & ShipController::getAiTargetingMeList() const
{
return *m_aiTargetingMeList;
}
// ----------------------------------------------------------------------
void ShipController::setPosition_w(Vector const & position, bool const allowOrientation)
{
Transform transform(m_shipDynamicsModel->getTransform());
transform.setPosition_p(position);
m_shipDynamicsModel->setTransform(transform);
if (allowOrientation)
{
m_shipDynamicsModel->stop();
}
else
{
m_shipDynamicsModel->makeStationary();
}
}
// ----------------------------------------------------------------------
bool ShipController::face(Vector const & goalPosition_w, float elapsedTime)
{
//DEBUG_REPORT_LOG(true, ("ShipController::face() owner(%s)\n", getOwner()->getNetworkId().getValueString().c_str()));
ShipObject * const shipObject = NON_NULL(getShipOwner());
ServerShipObjectInterface const shipInterface(shipObject);
Transform shipTransform = shipObject->getTransform_o2w();
bool reachedYaw = false;
bool reachedPitch = false;
if (shipInterface.getMaximumYaw() > 0.f)
{
Vector const goal_o = shipTransform.rotateTranslate_p2l(goalPosition_w);
float const goalYaw = goal_o.theta();
float const goalYawRate = goalYaw / elapsedTime;
float const maxYawRate = shipInterface.getMaximumYaw();
if((goalYawRate >= -maxYawRate) && (goalYawRate <= maxYawRate))
reachedYaw = true;
float const actualYawRate = clamp(-maxYawRate, goalYawRate, maxYawRate);
float const actualYaw = actualYawRate * elapsedTime;
m_yawPosition = actualYawRate / maxYawRate;
shipTransform.yaw_l(actualYaw);
}
if (shipInterface.getMaximumPitch() > 0.f)
{
Vector const goal_o = shipTransform.rotateTranslate_p2l(goalPosition_w);
float const goalPitch = goal_o.phi();
float const goalPitchRate = goalPitch / elapsedTime;
float const maxPitchRate = shipInterface.getMaximumPitch();
if((goalPitchRate >= -maxPitchRate) && (goalPitchRate <= maxPitchRate))
reachedPitch = true;
float const actualPitchRate = clamp(-maxPitchRate, goalPitchRate, maxPitchRate);
float const actualPitch = actualPitchRate * elapsedTime;
m_pitchPosition = actualPitchRate / maxPitchRate;
shipTransform.pitch_l(actualPitch);
}
// If enabled, rotate on the "fast" axis of the ship.
bool isRollSet = false;
if (AiServerShipObjectInterface::isFastAxisEnabled())
{
bool useFastAxis = true;
AiShipController const * const aiShipController = asAiShipController();
if (aiShipController != NULL)
{
if ( (aiShipController->getShipClass() == ShipAiReactionManager::SC_capitalShip)
|| (aiShipController->getShipClass() == ShipAiReactionManager::SC_transport)
|| !aiShipController->isAttacking())
{
useFastAxis = false;
}
}
if (useFastAxis)
{
Vector desiredOrientation(m_pitchPosition, m_yawPosition, 0.0f);
Vector fastOrientation(shipInterface.getMaximumPitch(), shipInterface.getMaximumYaw(), 0.0f);
// Validate the normalized vectors and rotate along fast axis iff the vectors differ significantly.
if (desiredOrientation.normalize() && fastOrientation.normalize() && ((desiredOrientation.dot(fastOrientation) + s_fastOrientationDeltaRadians) < 1.0f))
{
Vector const & targetOrientation = desiredOrientation.cross(fastOrientation);
m_rollPosition = clamp(-1.0f, targetOrientation.z, 1.0f);
isRollSet = true;
}
}
}
// If the roll wasn't set, use the original roll calculation.
if (!isRollSet && shipInterface.getMaximumRoll() > 0.f)
{
Vector const goal_o = shipTransform.rotateTranslate_p2l(goalPosition_w);
float goalRoll = 0.f;
float const d = sqrt(sqr(goal_o.x) + sqr(goal_o.y));
float const phi = atan2(d,goal_o.z);
if(phi > convertDegreesToRadians(10.f))
{
goalRoll = -atan2(goal_o.x,goal_o.y);
}
else
{
// if we're not trying to align with the target, try to align with the Y axis,
// but only if we're not heading nearly straight up or down
Vector const upPoint_w = shipTransform.getPosition_p() + Vector::unitY;
Vector const upPoint_o = shipTransform.rotateTranslate_p2l(upPoint_w);
float d2 = sqrt(sqr(upPoint_o.x) + sqr(upPoint_o.y));
float phi2 = atan2(d2,abs(upPoint_o.z));
if(phi2 > convertDegreesToRadians(10.f))
{
goalRoll = -atan2(upPoint_o.x,upPoint_o.y);
}
}
float const goalRollRate = goalRoll / elapsedTime;
float const maxRollRate = shipInterface.getMaximumRoll();
float const actualRollRate = clamp(-maxRollRate, goalRollRate, maxRollRate);
//float const actualRoll = actualRollRate * elapsedTime;
m_rollPosition = actualRollRate / maxRollRate;
}
return reachedYaw && reachedPitch;
}
// ----------------------------------------------------------------------
bool ShipController::face(Vector const & goalPosition_w, Vector const & up_w, float const elapsedTime)
{
//DEBUG_REPORT_LOG(true, ("ShipController::face(up_w) owner(%s)\n", getOwner()->getNetworkId().getValueString().c_str()));
ShipObject * const shipObject = NON_NULL(getShipOwner());
ServerShipObjectInterface const shipInterface(shipObject);
Transform shipTransform(shipObject->getTransform_o2w());
// Yaw
bool reachedYaw = false;
{
if (shipInterface.getMaximumYaw() > 0.f)
{
Vector const goal_o = shipTransform.rotateTranslate_p2l(goalPosition_w);
float const goalYaw = goal_o.theta();
float const goalYawRate = goalYaw / elapsedTime;
float const maxYawRate = shipInterface.getMaximumYaw();
if((goalYawRate >= -maxYawRate) && (goalYawRate <= maxYawRate))
reachedYaw = true;
float const actualYawRate = clamp(-maxYawRate, goalYawRate, maxYawRate);
float const actualYaw = actualYawRate * elapsedTime;
m_yawPosition = actualYawRate / maxYawRate;
shipTransform.yaw_l(actualYaw);
}
}
// Pitch
bool reachedPitch = false;
{
if (shipInterface.getMaximumPitch() > 0.f)
{
Vector const goal_o = shipTransform.rotateTranslate_p2l(goalPosition_w);
float const goalPitch = goal_o.phi();
float const goalPitchRate = goalPitch / elapsedTime;
float const maxPitchRate = shipInterface.getMaximumPitch();
if((goalPitchRate >= -maxPitchRate) && (goalPitchRate <= maxPitchRate))
reachedPitch = true;
float const actualPitchRate = clamp(-maxPitchRate, goalPitchRate, maxPitchRate);
float const actualPitch = actualPitchRate * elapsedTime;
m_pitchPosition = actualPitchRate / maxPitchRate;
shipTransform.pitch_l(actualPitch);
}
}
// Roll
bool reachedRoll = false;
{
float const maxRollRate = shipInterface.getMaximumRoll();
if (maxRollRate > 0.f)
{
Vector goalUp_o = shipTransform.rotateTranslate_p2l(up_w);
goalUp_o.normalize();
float const dot = Vector::unitY.dot(goalUp_o);
float const angleBetween = acos(dot);
if ( (goalUp_o.y > 0.0f)
&& (angleBetween < convertDegreesToRadians(1.0f)))
{
m_rollPosition = 0.0f;
reachedRoll = true;
}
else if (goalUp_o.x > 0.0f)
{
m_rollPosition = -1.0f;
}
else if (goalUp_o.x < 0.0f)
{
m_rollPosition = 1.0f;
}
if ( (m_rollPosition > 0.0f)
|| (m_rollPosition < 0.0f))
{
float const goalRollRate = angleBetween * elapsedTime * 10.0f;
float const actualRollRate = clamp(-maxRollRate, goalRollRate, maxRollRate);
m_rollPosition *= actualRollRate / maxRollRate;
}
}
}
return reachedYaw && reachedPitch && reachedRoll;
}
// ----------------------------------------------------------------------
void ShipController::setThrottle(float throttle)
{
m_throttlePosition = clamp(0.0f,throttle,1.0f);
}
// ----------------------------------------------------------------------
float ShipController::getLargestTurnRadius() const
{
float result = 0.0f;
ShipObject const * const shipObject = getShipOwner();
if (shipObject != NULL)
{
float const maxYawRate = shipObject->getShipActualYawRateMaximum();
float const maxPitchRate = shipObject->getShipActualPitchRateMaximum();
float const maxRollRate = shipObject->getShipActualRollRateMaximum();
float const maxTurnRate = std::min(std::min(maxYawRate, maxPitchRate), maxRollRate);
float const speedMaximum = shipObject->getShipActualSpeedMaximum();
result = (maxTurnRate > 0.0f) ? (speedMaximum / maxTurnRate) : 0.0f;
}
return result;
}
// ----------------------------------------------------------------------
void ShipController::dock(ShipObject & dockTarget, float const secondsAtDock)
{
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("ShipController::dock() owner(%s) dockTarget(%s) secondsAtDock(%.2f)", getOwner()->getNetworkId().getValueString().c_str(), dockTarget.getNetworkId().getValueString().c_str(), secondsAtDock));
// Create the docking behavior
delete m_pendingDockingBehavior;
m_pendingDockingBehavior = new AiShipBehaviorDock(*this, dockTarget, secondsAtDock);
}
// ----------------------------------------------------------------------
void ShipController::unDock()
{
if (m_pendingDockingBehavior != NULL)
{
m_pendingDockingBehavior->unDock();
}
else if (m_dockingBehavior != NULL)
{
m_dockingBehavior->unDock();
}
}
// ----------------------------------------------------------------------
bool ShipController::isDocking() const
{
return (m_dockingBehavior != NULL) || (m_pendingDockingBehavior != NULL);
}
// ----------------------------------------------------------------------
bool ShipController::isDocked() const
{
return ((m_dockingBehavior != NULL) && m_dockingBehavior->isDocked());
}
// ----------------------------------------------------------------------
void ShipController::onTargetedByMissile(int const /*missileId*/)
{
}
//----------------------------------------------------------------------
ShipController * ShipController::asShipController()
{
return this;
}
//----------------------------------------------------------------------
ShipController const * ShipController::asShipController() const
{
return this;
}
// ----------------------------------------------------------------------
PlayerShipController * ShipController::asPlayerShipController()
{
return NULL;
}
// ----------------------------------------------------------------------
PlayerShipController const * ShipController::asPlayerShipController() const
{
return NULL;
}
// ----------------------------------------------------------------------
AiShipController * ShipController::asAiShipController()
{
return NULL;
}
// ----------------------------------------------------------------------
AiShipController const * ShipController::asAiShipController() const
{
return NULL;
}
// ----------------------------------------------------------------------
AiShipAttackTargetList const & ShipController::getAttackTargetList() const
{
return *m_attackTargetList;
}
// ----------------------------------------------------------------------
bool ShipController::addDamageTaken(NetworkId const & attackingUnit, float const damage, bool const verifyAttacker)
{
bool result = false;
ShipObject * const attackingUnitShipObject = ShipObject::asShipObject(NetworkIdManager::getObjectById(attackingUnit));
if ( (attackingUnitShipObject != NULL)
&& !attackingUnitShipObject->isDamageAggroImmune())
{
result = verifyAttacker ? Pvp::canAttack(*attackingUnitShipObject, *NON_NULL(getShipOwner())) : true;
if (result)
{
m_attackTargetList->add(*attackingUnitShipObject, damage);
}
}
return result;
}
// ----------------------------------------------------------------------
bool ShipController::hasTurretTargetingSystem() const
{
return (m_turretTargetingSystem != NULL);
}
// ----------------------------------------------------------------------
float ShipController::getTurretMissChance() const
{
return 0.5f;
}
// ----------------------------------------------------------------------
float ShipController::getTurretMissAngle() const
{
// Once player auto-turrets come online, this needs to be overloaded in PlayerShipController
return tan(convertDegreesToRadians(10.0f));
}
// ----------------------------------------------------------------------
void ShipController::clearEnemyCheckQueuedFlag()
{
m_enemyCheckQueued = false;
}
// ----------------------------------------------------------------------
bool ShipController::removeAttackTarget(NetworkId const & unit)
{
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("ShipController::removeAttackTarget() owner(%s) unit(%s)", getOwner()->getNetworkId().getValueString().c_str(), unit.getValueString().c_str()));
return m_attackTargetList->remove(unit);
}
// ----------------------------------------------------------------------
void ShipController::onAttackTargetChanged(NetworkId const & target)
{
if (m_turretTargetingSystem != NULL)
{
m_turretTargetingSystem->onTargetChanged(target);
}
}
// ----------------------------------------------------------------------
void ShipController::onAttackTargetLost(NetworkId const & target)
{
if (m_turretTargetingSystem != NULL)
{
m_turretTargetingSystem->onTargetLost(target);
}
}
// ----------------------------------------------------------------------
void ShipController::onAttackTargetListEmpty()
{
// This is intentionally left blank
}
// ----------------------------------------------------------------------
float ShipController::getThrottle() const
{
return m_throttlePosition;
}
// ----------------------------------------------------------------------
int ShipController::getNumberOfAiUnitsAttackingMe() const
{
int result = 0;
CachedNetworkIdList::const_iterator iterAiTargetingMeList = m_aiTargetingMeList->begin();
for (; iterAiTargetingMeList != m_aiTargetingMeList->end(); ++iterAiTargetingMeList)
{
CachedNetworkId const & ai = (*iterAiTargetingMeList);
Object const * const aiObject = ai.getObject();
if (aiObject != NULL)
{
ShipController const * const shipController = aiObject->getController()->asShipController();
AiShipController const * const aiShipController = (shipController != NULL) ? shipController->asAiShipController() : NULL;
if (aiShipController != NULL)
{
if (aiShipController->getPrimaryAttackTarget() == getOwner()->getNetworkId())
{
++result;
}
}
}
else
{
DEBUG_WARNING(true, ("ShipController::getNumberOfAiShipAttackingMe() ERROR: Why am I(%s) being targeted by a NULL object(%s)?", getOwner()->getDebugInformation().c_str(), ai.getValueString().c_str()));
}
}
return result;
}
// ======================================================================
// PROTECTED ShipController
// ======================================================================
ShipObject * ShipController::getShipOwner()
{
Object * const object = getOwner();
ServerObject * const serverObject = object ? object->asServerObject() : 0;
return serverObject ? serverObject->asShipObject() : 0;
}
// ----------------------------------------------------------------------
ShipObject const * ShipController::getShipOwner() const
{
return const_cast<ShipController *>(this)->getShipOwner();
}
// ======================================================================
// PRIVATE ShipController
// ======================================================================
void ShipController::synchronizeTransform()
{
}
// ----------------------------------------------------------------------
void ShipController::experiencedCollision()
{
}
// ----------------------------------------------------------------------
void ShipController::clearAiTargetingMeList()
{
// Notify all the ships targeting me that I am no longer valid
s_purgeList.clear();
CachedNetworkIdList::const_iterator iterTargetByAiList = m_aiTargetingMeList->begin();
for (; iterTargetByAiList != m_aiTargetingMeList->end(); ++iterTargetByAiList)
{
CachedNetworkId const & id = *iterTargetByAiList;
s_purgeList.push_back(id);
}
PurgeList::const_iterator iterPurgeList = s_purgeList.begin();
for (; iterPurgeList != s_purgeList.end(); ++iterPurgeList)
{
CachedNetworkId const & id = (*iterPurgeList);
if (id.getObject() != NULL)
{
ShipController * const shipController = id.getObject()->getController()->asShipController();
if (shipController != NULL)
{
IGNORE_RETURN(shipController->removeAttackTarget(getOwner()->getNetworkId()));
}
else
{
LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("ShipController::~ShipController() ERROR: owner(%s) targetedByUnit(%s) Why does this unit not have a ShipController?", getOwner()->getNetworkId().getValueString().c_str(), id.getValueString().c_str()));
}
}
}
}
// ----------------------------------------------------------------------
void ShipController::getApproximateFutureTransform(Transform & transform, Vector & velocity, float elapsedTime) const
{
ServerShipObjectInterface const serverShipObjectInterface(getShipOwner());
m_shipDynamicsModel->getApproximateFutureTransform(transform, velocity, elapsedTime, serverShipObjectInterface);
}
// ======================================================================
@@ -0,0 +1,140 @@
// ======================================================================
//
// ShipController.h
// Copyright 2003 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_ShipController_H
#define INCLUDED_ShipController_H
// ======================================================================
#include "serverGame/TangibleController.h"
#include "sharedFoundation/MessageQueue.h"
class AiShipAttackTargetList;
class AiShipBehaviorDock;
class AiShipController;
class CachedNetworkId;
class NetworkId;
class PlayerShipController;
class ShipDynamicsModel;
class ShipObject;
class ShipTurretTargetingSystem;
class Timer;
// ======================================================================
class ShipController : public TangibleController
{
public:
typedef stdset<CachedNetworkId>::fwd CachedNetworkIdList;
typedef stdmultiset<CachedNetworkId>::fwd DockedByList;
explicit ShipController(ShipObject * newOwner);
virtual ~ShipController();
virtual void endBaselines();
virtual void teleport(Transform const &goal, ServerObject *goalObj);
virtual void onAddedToWorld();
virtual void onTargetedByMissile(int const missileId);
virtual ShipController * asShipController();
virtual ShipController const * asShipController() const;
virtual PlayerShipController * asPlayerShipController();
virtual PlayerShipController const * asPlayerShipController() const;
virtual AiShipController * asAiShipController();
virtual AiShipController const * asAiShipController() const;
Transform const &getTransform() const;
Vector const &getVelocity() const;
float getSpeed() const;
float getYawRate() const;
float getPitchRate() const;
float getRollRate() const;
void respondToCollision(Vector const & deltaToMove_p, Vector const & newReflection_p, Vector const & normalOfSurface_p);
ShipObject * getShipOwner();
ShipObject const * getShipOwner() const;
void addTurretTargetingSystem(ShipTurretTargetingSystem * newSystem);
void removeTurretTargetingSystem();
bool hasTurretTargetingSystem() const;
virtual float getTurretMissChance() const;
virtual float getTurretMissAngle() const;
virtual void addAiTargetingMe(NetworkId const & unit);
void removeAiTargetingMe(NetworkId const & unit);
CachedNetworkIdList const & getAiTargetingMeList() const;
AiShipAttackTargetList const & getAttackTargetList() const;
int getNumberOfAiUnitsAttackingMe() const;
void setPosition_w(Vector const & position, bool allowOrientation);
bool face(Vector const & goalPosition_w, float const elapsedTime);
bool face(Vector const & goalPosition_w, Vector const & up_w, float const elapsedTime);
void setThrottle(float const position);
float getThrottle() const;
float getLargestTurnRadius() const;
virtual void dock(ShipObject & dockTarget, float const secondsAtDock);
void unDock();
bool isDocking() const;
bool isDocked() const;
bool isBeingDocked() const;
void addDockedBy(Object const & unit);
void removeDockedBy(Object const & unit);
DockedByList const & getDockedByList() const;
virtual bool addDamageTaken(NetworkId const & attackingUnit, float const damage, bool const verifyAttacker);
virtual bool removeAttackTarget(NetworkId const & targetUnit);
void clearEnemyCheckQueuedFlag();
virtual bool shouldCheckForEnemies() const = 0;
void onAttackTargetChanged(NetworkId const & target);
void onAttackTargetLost(NetworkId const & target);
virtual void onAttackTargetListEmpty();
void getApproximateFutureTransform(Transform & transform, Vector & velocity, float elapsedTime) const;
protected:
virtual float realAlter(float elapsedTime);
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
ShipDynamicsModel * const m_shipDynamicsModel;
float m_yawPosition; // [-1...1]
float m_pitchPosition; // [-1...1]
float m_rollPosition; // [-1...1]
float m_throttlePosition;
AiShipBehaviorDock * m_pendingDockingBehavior;
AiShipBehaviorDock * m_dockingBehavior;
AiShipAttackTargetList * const m_attackTargetList;
Timer * const m_attackTargetDecayTimer;
bool m_enemyCheckQueued;
ShipTurretTargetingSystem * m_turretTargetingSystem;
private:
DockedByList * const m_dockedByList;
CachedNetworkIdList * const m_aiTargetingMeList;
void clearAiTargetingMeList();
private:
ShipController();
ShipController(ShipController const &);
ShipController & operator=(ShipController const &);
protected:
virtual void synchronizeTransform();
virtual void experiencedCollision();
};
// ======================================================================
#endif
@@ -0,0 +1,735 @@
//========================================================================
//
// TangibleController.cpp
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/TangibleController.h"
#include "SwgGameServer/CombatEngine.h"
#include "serverGame/ContainerInterface.h"
#include "serverGame/CreatureObject.h"
#include "serverGame/GameServer.h"
#include "serverGame/ManufactureSchematicObject.h"
#include "serverGame/Pvp.h"
#include "serverGame/TangibleObject.h"
#include "serverNetworkMessages/MessageQueueCommandQueueEnqueueFwd.h"
#include "serverNetworkMessages/MessageQueueCommandQueueForceExecuteCommandFwd.h"
#include "serverNetworkMessages/MessageQueuePvpCommand.h"
#include "sharedFoundation/GameControllerMessage.h"
#include "sharedGame/CommandTable.h"
#include "sharedGame/ProsePackage.h"
#include "sharedLog/Log.h"
#include "sharedNetworkMessages/MessageQueueCommandQueueEnqueue.h"
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
#include "sharedNetworkMessages/MessageQueueNetworkId.h"
#include "sharedNetworkMessages/MessageQueueCommandQueueRemove.h"
#include "sharedNetworkMessages/MessageQueueStartNpcConversation.h"
#include "sharedNetworkMessages/ObjectChannelMessages.h"
#include "sharedObject/NetworkIdManager.h"
#include "swgServerNetworkMessages/MessageQueueCombatDamageList.h"
#include "swgServerNetworkMessages/MessageQueueDirectDamage.h"
#include "swgServerNetworkMessages/MessageQueueResourceAdd.h"
//-----------------------------------------------------------------------
TangibleController::TangibleController(TangibleObject *newOwner) :
ServerController(newOwner)
{
}
//-----------------------------------------------------------------------
TangibleController::~TangibleController()
{
}
//-----------------------------------------------------------------------
void TangibleController::setAuthoritative(bool newAuthoritative)
{
ServerController::setAuthoritative(newAuthoritative);
// pvp needs to be notified after an object is both initialized and made authoritative.
if (newAuthoritative)
{
TangibleObject* owner = dynamic_cast<TangibleObject *>(getOwner());
NOT_NULL(owner);
if (owner->isInitialized())
Pvp::handleAuthorityAcquire(*owner);
}
}
//-----------------------------------------------------------------------
void TangibleController::handleMessage (const int message, const float value, const MessageQueue::Data* const data, const uint32 flags)
{
TangibleObject * const owner = getTangibleOwner();
switch (message)
{
case CM_pvpMessage:
{
const MessageQueuePvpCommand *pvpMsg = dynamic_cast<const MessageQueuePvpCommand *>(data);
NOT_NULL(pvpMsg);
Pvp::handlePvpMessage(*owner, *pvpMsg);
}
break;
case CM_combatDamageList:
{
if (owner->isAuthoritative())
{
const MessageQueueCombatDamageList *damageListMessage =
dynamic_cast<const MessageQueueCombatDamageList *>(data);
NOT_NULL(damageListMessage);
const std::vector<CombatEngineData::DamageData> & damageList =
damageListMessage->getDamageList();
if (damageList.size() == 0)
break;
if (!owner->isInCombat())
{
WARNING(true, ("TangibleController setting owner %s to be in "
"combat to apply damage; we should be able to avoid doing "
"this!", owner->getNetworkId().getValueString().c_str()));
owner->setInCombat(true);
}
// put the damage on the object's current damage list
owner->createCombatData();
CombatEngineData::CombatData * combatData = owner->getCombatData();
for (std::vector<CombatEngineData::DamageData>::const_iterator
iter = damageList.begin(); iter != damageList.end(); ++iter)
{
combatData->defenseData.damage.push_back(*iter);
}
}
}
break;
case CM_directDamage:
{
const MessageQueueDirectDamage *damageMessage =
dynamic_cast<const MessageQueueDirectDamage *>(data);
NOT_NULL(damageMessage);
CombatEngine::damage(*owner,
static_cast<ServerWeaponObjectTemplate::DamageType>(damageMessage->getDamageType()),
static_cast<uint16>(damageMessage->getHitLocation()),
damageMessage->getDamageDone());
}
break;
case CM_setOwnerId:
{
const MessageQueueNetworkId * const msg = safe_cast<const MessageQueueNetworkId *>(data);
if(msg)
{
owner->setOwnerId(msg->getNetworkId());
}
}
break;
case CM_setMaxHitPoints:
{
const MessageQueueGenericValueType<int> * const msg = safe_cast<const MessageQueueGenericValueType<int> *>(data);
if(msg)
{
owner->setMaxHitPoints(msg->getValue());
}
}
break;
case CM_setVisible:
{
const MessageQueueGenericValueType<bool> * const msg = safe_cast<const MessageQueueGenericValueType<bool> *>(data);
if(msg)
{
owner->setVisible(msg->getValue());
}
}
break;
case CM_hideFromClient:
{
const MessageQueueGenericValueType<bool> * const msg = safe_cast<const MessageQueueGenericValueType<bool> *>(data);
if(msg)
{
owner->setHidden(msg->getValue());
}
}
break;
case CM_setInvulnerable:
{
const MessageQueueGenericValueType<bool> * const msg = safe_cast<const MessageQueueGenericValueType<bool> *>(data);
if(msg)
{
owner->setInvulnerable(msg->getValue());
}
}
break;
case CM_addLocationTarget:
{
const MessageQueueGenericValueType<LocationData> * const msg = safe_cast<const MessageQueueGenericValueType<LocationData> *>(data);
if(msg)
{
owner->addLocationTarget(msg->getValue());
}
}
break;
case CM_removeLocationTarget:
{
const MessageQueueGenericValueType<Unicode::String> * const msg = safe_cast<const MessageQueueGenericValueType<Unicode::String> *>(data);
if(msg)
{
owner->removeLocationTarget(msg->getValue());
}
}
break;
case CM_setInCombat:
{
const MessageQueueGenericValueType<bool> * const msg = safe_cast<const MessageQueueGenericValueType<bool> *>(data);
if(msg)
{
owner->setInCombat(msg->getValue());
}
}
break;
case CM_addAim:
{
owner->addAim();
}
break;
case CM_clearAims:
{
owner->clearAims();
}
break;
case CM_alterHitPoints:
{
const MessageQueueGenericValueType<std::pair<int, NetworkId> > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<int, NetworkId> > *>(data);
if(msg)
{
owner->alterHitPoints(msg->getValue().first, false, msg->getValue().second);
}
}
break;
case CM_addHate:
{
const MessageQueueGenericValueType<std::pair<NetworkId, float> > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, float> > *>(data);
WARNING((msg == NULL), ("TangibleController::handleMessage(CM_addHate) The message data should never be NULL"));
if(msg)
{
owner->addHate(msg->getValue().first, msg->getValue().second);
}
}
break;
case CM_setHate:
{
const MessageQueueGenericValueType<std::pair<NetworkId, float> > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, float> > *>(data);
WARNING((msg == NULL), ("TangibleController::handleMessage(CM_setHate) The message data should never be NULL"));
if(msg)
{
owner->setHate(msg->getValue().first, msg->getValue().second);
}
}
break;
case CM_removeHateTarget:
{
const MessageQueueGenericValueType<NetworkId> * const msg = safe_cast<const MessageQueueGenericValueType<NetworkId> *>(data);
WARNING((msg == NULL), ("TangibleController::handleMessage(CM_removeHateTarget) The message data should never be NULL"));
if(msg)
{
owner->removeHateTarget(msg->getValue());
}
}
break;
case CM_clearHateList:
{
owner->clearHateList();
}
break;
case CM_resetHateTimer:
{
owner->resetHateTimer();
}
break;
case CM_forceHateTarget:
{
const MessageQueueGenericValueType<NetworkId> * const msg = safe_cast<const MessageQueueGenericValueType<NetworkId> *>(data);
WARNING((msg == NULL), ("TangibleController::handleMessage(CM_removeHateTarget) The message data should never be NULL"));
if(msg)
{
owner->forceHateTarget(msg->getValue());
}
}
break;
case CM_autoExpireHateListTargetEnabled:
{
const MessageQueueGenericValueType<bool> * const msg = safe_cast<const MessageQueueGenericValueType<bool> *>(data);
WARNING((msg == NULL), ("TangibleController::handleMessage(CM_setHateListExpireTargetEnabled) The message data should never be NULL"));
if (msg != NULL)
{
owner->setHateListAutoExpireTargetEnabled(msg->getValue());
}
}
break;
case CM_setCraftedId:
{
const MessageQueueGenericValueType<NetworkId> * const msg = safe_cast<const MessageQueueGenericValueType<NetworkId> *>(data);
if(msg)
{
owner->setCraftedId(msg->getValue());
}
}
break;
case CM_startCraftingSession:
{
const MessageQueueGenericValueType<NetworkId> * const msg = safe_cast<const MessageQueueGenericValueType<NetworkId> *>(data);
if(msg)
{
CreatureObject * crafter = safe_cast<CreatureObject *>(NetworkIdManager::getObjectById(msg->getValue()));
DEBUG_FATAL(!crafter, ("%s:%s received startCraftingSession controller message for crafter %s, but crafter %s is not loaded on this server!", owner->getObjectTemplateName(), owner->getNetworkId().getValueString().c_str(), msg->getValue().getValueString().c_str(), msg->getValue().getValueString().c_str()));
if(crafter)
owner->startCraftingSession(*crafter);
}
}
break;
case CM_addObjectToOutputSlot:
{
const MessageQueueGenericValueType<std::pair<NetworkId, NetworkId> > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, NetworkId> > *>(data);
if(msg)
{
ServerObject * object = safe_cast<ServerObject *>(NetworkIdManager::getObjectById(msg->getValue().first));
DEBUG_FATAL(! object, ("%s:%s received addObjectToOutputSlot controller message, but the ingredient %s is not loaded on this server!", owner->getObjectTemplateName(), owner->getNetworkId().getValueString().c_str(), msg->getValue().first.getValueString().c_str()));
if(object)
{
ServerObject * transferer = safe_cast<ServerObject *>(NetworkIdManager::getObjectById(msg->getValue().second));
// transferer is allowed to be null
owner->addObjectToOutputSlot(*object, transferer);
}
}
}
break;
case CM_setCraftingManufactureSchematic:
{
const MessageQueueGenericValueType<NetworkId> * const msg = safe_cast<const MessageQueueGenericValueType<NetworkId> *>(data);
if(msg)
{
ManufactureSchematicObject * schematic = safe_cast<ManufactureSchematicObject *>(NetworkIdManager::getObjectById(msg->getValue()));
DEBUG_FATAL(! schematic, ("%s:%s received setCraftingManufactureSchematic controller message, but the ingredient %s is not loaded on this server!", owner->getObjectTemplateName(), owner->getNetworkId().getValueString().c_str(), msg->getValue().getValueString().c_str()));
if(schematic)
{
owner->setCraftingManufactureSchematic(*schematic);
}
}
}
break;
case CM_clearCraftingManufactureSchematic:
{
owner->clearCraftingManufactureSchematic();
}
break;
case CM_setCraftingPrototype:
{
const MessageQueueGenericValueType<NetworkId> * const msg = safe_cast<const MessageQueueGenericValueType<NetworkId> *>(data);
if(msg)
{
ServerObject * prototype = safe_cast<ServerObject *>(NetworkIdManager::getObjectById(msg->getValue()));
DEBUG_FATAL(! prototype, ("%s:%s received setCraftingPrototype controller message, but the ingredient %s is not loaded on this server!", owner->getObjectTemplateName(), owner->getNetworkId().getValueString().c_str(), msg->getValue().getValueString().c_str()));
if(prototype)
{
owner->setCraftingPrototype(*prototype);
}
}
}
break;
case CM_clearCraftingPrototype:
{
owner->clearCraftingPrototype();
}
break;
case CM_setCreatorId:
{
const MessageQueueGenericValueType<NetworkId> * const msg = safe_cast<const MessageQueueGenericValueType<NetworkId> *>(data);
if(msg)
{
owner->setCreatorId(msg->getValue());
}
}
break;
case CM_setCreatorXp:
{
const MessageQueueGenericValueType<int> * const msg = safe_cast<const MessageQueueGenericValueType<int> *>(data);
if(msg)
{
owner->setCreatorXp(msg->getValue());
}
}
break;
case CM_setCreatorXpType:
{
const MessageQueueGenericValueType<int> * const msg = safe_cast<const MessageQueueGenericValueType<int> *>(data);
if(msg)
{
owner->setCreatorXpType(msg->getValue());
}
}
break;
case CM_setVisibleComponents:
{
const MessageQueueGenericValueType<std::vector<int> > * const msg = safe_cast<const MessageQueueGenericValueType<std::vector<int> > *>(data);
if(msg)
{
owner->setVisibleComponents(msg->getValue());
}
}
break;
case CM_setCraftedType:
{
const MessageQueueGenericValueType<int> * const msg = safe_cast<const MessageQueueGenericValueType<int> *>(data);
if(msg)
{
owner->setCraftedType(msg->getValue());
}
}
break;
case CM_setCondition:
{
const MessageQueueGenericValueType<int> * const msg = safe_cast<const MessageQueueGenericValueType<int> *>(data);
if(msg)
{
owner->setCondition(msg->getValue());
}
}
break;
case CM_clearCondition:
{
const MessageQueueGenericValueType<int> * const msg = safe_cast<const MessageQueueGenericValueType<int> *>(data);
if(msg)
{
owner->clearCondition(msg->getValue());
}
}
break;
case CM_npcConversationStart:
{
const MessageQueueStartNpcConversation * const msg = NON_NULL(dynamic_cast<const MessageQueueStartNpcConversation *>(data));
const CachedNetworkId npcId (msg->getNpc ());
TangibleObject * const npcObject = dynamic_cast<TangibleObject *>(npcId.getObject ());
if (npcObject)
{
owner->startNpcConversation (*npcObject, msg->getConversationName().c_str(), msg->getStarter(), msg->getAppearanceOverrideTemplateCrc());
}
}
break;
case CM_npcConversationStop:
{
owner->endNpcConversation ();
}
break;
case CM_npcConversationSelect:
{
owner->respondToNpc (static_cast<int>(value));
}
break;
case CM_forwardNpcConversationMessage:
{
typedef std::pair<std::pair<StringId, ProsePackage>, Unicode::String> Payload;
const MessageQueueGenericValueType<Payload> * const msg = safe_cast<const MessageQueueGenericValueType<Payload> *>(data);
if(msg)
{
const Payload & payload = msg->getValue ();
owner->sendNpcConversationMessage(payload.first.first, payload.first.second, payload.second);
}
}
break;
case CM_addNpcConversationResponse:
{
typedef std::pair<StringId, ProsePackage> Payload;
const MessageQueueGenericValueType<Payload> * const msg = safe_cast<const MessageQueueGenericValueType<Payload> *>(data);
if(msg)
{
const Payload & payload = msg->getValue ();
owner->addNpcConversationResponse(payload.first, payload.second);
}
}
break;
case CM_removeNpcConversationResponse:
{
typedef std::pair<StringId, ProsePackage> Payload;
const MessageQueueGenericValueType<Payload> * const msg = safe_cast<const MessageQueueGenericValueType<Payload> *>(data);
if(msg)
{
const Payload & payload = msg->getValue ();
owner->removeNpcConversationResponse(payload.first, payload.second);
}
}
break;
case CM_sendNpcConversationResponses:
{
owner->sendNpcConversationResponses();
}
break;
case CM_playerResponseToNpcConversation:
{
typedef std::pair<std::string, std::pair<NetworkId, std::pair<StringId, ProsePackage> > > Payload;
const MessageQueueGenericValueType<Payload> * const msg = safe_cast<const MessageQueueGenericValueType<Payload> *>(data);
if(msg)
{
const Payload & payload = msg->getValue ();
owner->handlePlayerResponseToNpcConversation(payload.first, payload.second.first, payload.second.second.first, payload.second.second.second);
}
}
break;
case CM_setBioLink:
{
const MessageQueueGenericValueType<NetworkId> * const msg = safe_cast<const MessageQueueGenericValueType<NetworkId> *>(data);
if(msg)
{
const NetworkId & linkId = msg->getValue();
if (linkId != NetworkId::cms_invalid)
owner->setBioLink(linkId);
else
owner->clearBioLink();
}
}
break;
case CM_commandQueueForceExecuteCommandFwd:
{
MessageQueueCommandQueueForceExecuteCommandFwd const * const cmdMsg = dynamic_cast<const MessageQueueCommandQueueForceExecuteCommandFwd *>(data);
Command::ErrorCode status = static_cast<Command::ErrorCode>(cmdMsg->getStatus());
owner->forceExecuteCommand(CommandTable::getCommand(cmdMsg->getCommandHash()), cmdMsg->getTargetId(), cmdMsg->getParams(), status, cmdMsg->getCommandIsFromCommandQueue());
}
break;
case CM_commandQueueEnqueue:
{
handleCommandQueueEnqueue(dynamic_cast<const MessageQueueCommandQueueEnqueue *>(data));
}
break;
case CM_commandQueueRemove:
{
MessageQueueCommandQueueRemove const *msg = dynamic_cast<MessageQueueCommandQueueRemove const *>(data);
owner->commandQueueRemove(msg->getSequenceId());
}
break;
case CM_commandQueueEnqueueFwd:
{
handleCommandQueueEnqueueFwd(dynamic_cast<const MessageQueueCommandQueueEnqueueFwd *>(data));
}
break;
case CM_setAttackableOverride:
{
const MessageQueueGenericValueType<bool> * const msg = safe_cast<const MessageQueueGenericValueType<bool> *>(data);
if(msg)
{
owner->setAttackableOverride(msg->getValue());
}
}
break;
case CM_addPassiveReveal:
{
const MessageQueueGenericValueType<std::pair<std::pair<int, int>, NetworkId> > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<std::pair<int, int>, NetworkId> > *>(data);
if(msg)
{
owner->addPassiveReveal(msg->getValue().second, msg->getValue().first.first, (msg->getValue().first.second != 0));
}
}
break;
case CM_removePassiveReveal:
{
const MessageQueueGenericValueType<NetworkId> * const msg = safe_cast<const MessageQueueGenericValueType<NetworkId> *>(data);
if(msg)
{
owner->removePassiveReveal(msg->getValue());
}
}
break;
case CM_removeAllPassiveReveal:
{
owner->removeAllPassiveReveal();
}
break;
case CM_addHateOverTime:
{
const MessageQueueGenericValueType<std::pair<NetworkId, std::pair<int, float> > > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, std::pair<int, float> > > *>(data);
if(msg)
{
owner->addHateOverTime(msg->getValue().first, msg->getValue().second.second, msg->getValue().second.first);
}
}
break;
case CM_addUserToAccessList:
{
MessageQueueGenericValueType<std::pair<int, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, NetworkId> > const *>(data);
WARNING((msg == NULL), ("TangibleController::handleMessage(CM_addUserToAccessList) The message data should never be NULL"));
if(msg)
{
if(msg->getValue().first < 0)
owner->addUserToAccessList(msg->getValue().second);
else
owner->addGuildToAccessList(msg->getValue().first);
}
}
break;
case CM_removeUserFromAccessList:
{
MessageQueueGenericValueType<std::pair<int, NetworkId> > const *msg = safe_cast<MessageQueueGenericValueType<std::pair<int, NetworkId> > const *>(data);
WARNING((msg == NULL), ("TangibleController::handleMessage(CM_removeUserFromAccessList) The message data should never be NULL"));
if(msg)
{
if(msg->getValue().first < 0)
owner->removeUserFromAccessList(msg->getValue().second);
else
owner->removeGuildFromAccessList(msg->getValue().first);
}
}
break;
case CM_clearUserAccessList:
{
MessageQueueGenericValueType<bool> const *msg = safe_cast<MessageQueueGenericValueType<bool> const *>(data);
if(msg)
{
if(msg->getValue())
owner->clearGuildAccessList();
else
owner->clearUserAccessList();
}
}
break;
case CM_addObjectEffect:
{
MessageQueueGenericValueType<std::pair<std::string, std::pair<std::string, std::pair<std::string, std::pair<Vector, float > > > > > const * msg = safe_cast<MessageQueueGenericValueType<std::pair<std::string, std::pair<std::string, std::pair<std::string, std::pair<Vector, float > > > > > const *>(data);
if(msg)
{
owner->addObjectEffect(msg->getValue().second.first, msg->getValue().second.second.first, msg->getValue().second.second.second.first, msg->getValue().second.second.second.second, msg->getValue().first);
}
}
break;
case CM_removeObjectEffect:
{
MessageQueueGenericValueType<std::string> const * msg = safe_cast<MessageQueueGenericValueType<std::string> const *>(data);
if(msg)
{
owner->removeObjectEffect(msg->getValue());
}
}
break;
case CM_removeAllObjectEffect:
{
MessageQueueGenericValueType<bool> const *msg = safe_cast<MessageQueueGenericValueType<bool> const *>(data);
if(msg)
{
if(msg->getValue())
owner->removeAllObjectEffects();
}
}
break;
default:
ServerController::handleMessage(message, value, data, flags);
break;
}
}
//----------------------------------------------------------------------
void TangibleController::handleCommandQueueEnqueue(MessageQueueCommandQueueEnqueue const *msg)
{
if (!msg)
return;
TangibleObject * const owner = getTangibleOwner();
if (owner->getClient())
owner->getClient()->resetIdleTime();
owner->commandQueueEnqueue(
CommandTable::getCommand(msg->getCommandHash()),
msg->getTargetId(),
msg->getParams(),
msg->getSequenceId());
}
//----------------------------------------------------------------------
void TangibleController::handleCommandQueueEnqueueFwd(MessageQueueCommandQueueEnqueueFwd const *msg)
{
// this is an enqueue message forwarded from another server
if (!msg)
return;
TangibleObject * const owner = getTangibleOwner();
int priority = msg->getPriority();
if (priority < 0 || priority >= Command::CP_NumberOfPriorities)
priority = Command::CP_Default;
owner->commandQueueEnqueue(
CommandTable::getCommand(msg->getCommandHash()),
msg->getTargetId(),
msg->getParams(),
msg->getSequenceId(),
msg->getClearable(),
static_cast<Command::Priority>(priority),
msg->getFromServer());
}
//-----------------------------------------------------------------------
const TangibleObject * TangibleController::getTangibleOwner() const
{
return getServerOwner()->asTangibleObject();
}
// ----------------------------------------------------------------------
TangibleObject * TangibleController::getTangibleOwner()
{
return getServerOwner()->asTangibleObject();
}
//-----------------------------------------------------------------------
TangibleController * TangibleController::asTangibleController()
{
return this;
}
//----------------------------------------------------------------------
TangibleController const * TangibleController::asTangibleController() const
{
return this;
}
//----------------------------------------------------------------------
AiTurretController * TangibleController::asAiTurretController()
{
return NULL;
}
//----------------------------------------------------------------------
AiTurretController const * TangibleController::asAiTurretController() const
{
return NULL;
}
//========================================================================
@@ -0,0 +1,59 @@
//========================================================================
//
// TangibleController.h
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#ifndef INCLUDED_TangibleController_H
#define INCLUDED_TangibleController_H
//-----------------------------------------------------------------------
#include "serverGame/ServerController.h"
class AiTurretController;
//----------------------------------------------------------------------
class MessageQueueCommandQueueEnqueue;
class MessageQueueCommandQueueEnqueueFwd;
class TangibleObject;
//-----------------------------------------------------------------------
/**
* A generic controller for all Tangible Objects.
*/
class TangibleController : public ServerController
{
public:
explicit TangibleController (TangibleObject * newOwner);
~TangibleController (void);
virtual void setAuthoritative (bool newAuthoritative);
void handleCommandQueueEnqueue(MessageQueueCommandQueueEnqueue const * data);
void handleCommandQueueEnqueueFwd(MessageQueueCommandQueueEnqueueFwd const * data);
virtual TangibleController * asTangibleController();
virtual TangibleController const * asTangibleController() const;
virtual AiTurretController * asAiTurretController();
virtual AiTurretController const * asAiTurretController() const;
TangibleObject * getTangibleOwner();
const TangibleObject * getTangibleOwner() const;
protected:
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
private:
TangibleController (void);
TangibleController (const TangibleController & other);
TangibleController& operator= (const TangibleController & other);
};
//-----------------------------------------------------------------------
#endif // INCLUDED_TangibleController_H
@@ -0,0 +1,23 @@
//TurretController.cpp
//-----------------------------------------------------------------------
#include "serverGame/FirstServerGame.h"
#include "serverGame/TurretController.h"
#include "serverGame/WeaponObject.h"
//-----------------------------------------------------------------------
TurretController::TurretController(WeaponObject * newOwner) :
WeaponController(newOwner)
{
}
//-----------------------------------------------------------------------
TurretController::~TurretController()
{
}
//-----------------------------------------------------------------------
@@ -0,0 +1,30 @@
//TurretController.h
#ifndef _TURRET_CONTROLLER_H
#define _TURRET_CONTROLLER_H
//-----------------------------------------------------------------------
#include "serverGame/WeaponController.h"
//----------------------------------------------------------------------
class WeaponObject;
//-----------------------------------------------------------------------
class TurretController : public WeaponController
{
public:
explicit TurretController (WeaponObject * newOwner);
~TurretController (void);
private:
TurretController (void);
TurretController (const TurretController & other);
TurretController operator= (const TurretController & other);
};
//-----------------------------------------------------------------------
#endif
@@ -0,0 +1,27 @@
//========================================================================
//
// UniverseController.cpp
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/UniverseController.h"
#include "serverGame/UniverseObject.h"
// ======================================================================
UniverseController::UniverseController(UniverseObject *newOwner) :
ServerController(newOwner)
{
}
//-----------------------------------------------------------------------
UniverseController::~UniverseController()
{
}
// ======================================================================
@@ -0,0 +1,40 @@
//========================================================================
//
// UniverseController.h
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#ifndef INCLUDED_UniverseController_H
#define INCLUDED_UniverseController_H
//-----------------------------------------------------------------------
#include "serverGame/ServerController.h"
#include "serverGame/UniverseObject.h"
//----------------------------------------------------------------------
//class UniverseObject;
//-----------------------------------------------------------------------
/**
* A generic controller for all Universe Objects.
*/
class UniverseController : public ServerController
{
public:
explicit UniverseController (UniverseObject * newOwner);
~UniverseController (void);
private:
UniverseController (void);
UniverseController (const UniverseController & other);
UniverseController& operator= (const UniverseController & other);
};
//-----------------------------------------------------------------------
#endif // INCLUDED_UniverseController_H
@@ -0,0 +1,28 @@
//========================================================================
//
// VehicleController.cpp
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#include "serverGame/FirstServerGame.h"
#include "serverGame/VehicleController.h"
#include "serverGame/GameServer.h"
#include "serverGame/VehicleObject.h"
//-----------------------------------------------------------------------
VehicleController::VehicleController(VehicleObject * newOwner) :
TangibleController(newOwner)
{
}
//-----------------------------------------------------------------------
VehicleController::~VehicleController()
{
}
//-----------------------------------------------------------------------
@@ -0,0 +1,36 @@
//========================================================================
//
// VehicleController.h
//
// copyright 2001 Sony Online Entertainment
//
//========================================================================
#ifndef INCLUDED_VehicleController_H
#define INCLUDED_VehicleController_H
//-----------------------------------------------------------------------
#include "serverGame/TangibleController.h"
//-----------------------------------------------------------------------
class VehicleObject;
//-----------------------------------------------------------------------
class VehicleController : public TangibleController
{
public:
explicit VehicleController (VehicleObject * newOwner);
~VehicleController ();
private:
VehicleController (void);
VehicleController (const VehicleController & other);
VehicleController& operator= (const VehicleController & other);
};
//-----------------------------------------------------------------------
#endif // INCLUDED_VehicleController_H
@@ -0,0 +1,24 @@
//WeaponController.cpp
//-----------------------------------------------------------------------
#include "serverGame/FirstServerGame.h"
#include "serverGame/WeaponController.h"
#include "serverGame/WeaponObject.h"
//-----------------------------------------------------------------------
WeaponController::WeaponController(WeaponObject * newOwner) :
TangibleController(newOwner)
{
}
//-----------------------------------------------------------------------
WeaponController::~WeaponController()
{
}
//-----------------------------------------------------------------------
@@ -0,0 +1,30 @@
//WeaponController.h
#ifndef _WEAPON_CONTROLLER_H
#define _WEAPON_CONTROLLER_H
//-----------------------------------------------------------------------
#include "serverGame/TangibleController.h"
//----------------------------------------------------------------------
class WeaponObject;
//-----------------------------------------------------------------------
class WeaponController : public TangibleController
{
public:
explicit WeaponController (WeaponObject * newOwner);
~WeaponController (void);
private:
WeaponController (void);
WeaponController (const WeaponController & other);
WeaponController operator= (const WeaponController & other);
};
//-----------------------------------------------------------------------
#endif