Planeshift
|
Handle all network messages inn and out of the NPC Client. More...
#include <networkmgr.h>
Public Member Functions | |
void | Authenticate (csString &host, int port, csString &user, csString &pass) |
void | CheckCommandsOverrun (size_t neededSize) |
Checks if the npc command message could overrun if the neededSize is tried to be added. | |
void | DequeueDRData (NPC *npc) |
Call to remove queued dr updates when entities are removed/deleted. | |
void | Disconnect () |
const char * | GetCommonString (uint32_t cstr_id) |
Convert a common string id into the corresponding string. | |
uint32_t | GetCommonStringID (const char *string) |
Convert a string into a common string id. | |
csStringHashReversible * | GetMsgStrings () |
Get the message string table. | |
virtual void | HandleMessage (MsgEntry *pMsg) |
Handle all messages from server and send them to specefic Handle functions for each message type. | |
bool | IsReady () |
NetworkManager (MsgHandler *mh, psNetConnection *conn, iEngine *engine) | |
Construct the network manager. | |
void | PrepareCommandMessage () |
Prepare a new command message allow for queuing of new commands. | |
void | QueueAnimationCommand (gemNPCActor *npc, const csString &cmd) |
Send an animation command to server. | |
void | QueueAssessCommand (gemNPCActor *entity, gemNPCObject *target, const csString &physicalAssessmentPerception, const csString &magicalAssessmentPerception, const csString &overallAssessmentPerception) |
Send a command to do an assessment. | |
void | QueueAttackCommand (gemNPCActor *attacker, gemNPCActor *target, const char *stance, const char *attack_type) |
Queue an Attack Command for an NPC to the server. | |
void | QueueBusyCommand (gemNPCActor *entity, bool busy) |
Send a command to change the busy state. | |
void | QueueCastCommand (gemNPCActor *entity, gemNPCObject *target, const csString &spell, float kFactor) |
Send a command to start cast a spell. | |
void | QueueControlCommand (gemNPCActor *controllingEntity, gemNPCActor *controlledEntity) |
Send a command start controll an entity. | |
void | QueueDeleteNPCCommand (NPC *npcx) |
Send a command to delete a npc. | |
void | QueueDequipCommand (gemNPCActor *entity, csString slot) |
Send a command to dequip an equipment. | |
void | QueueDRData (NPC *npc) |
Queue the NPC for an DR Update to the server. | |
void | QueueDRData2 (NPC *npc) |
Queue the NPC for an DR Update to the server. | |
void | QueueDropCommand (gemNPCActor *entity, csString slot) |
Send a command to drop the content of a slot. | |
void | QueueEmoteCommand (gemNPCActor *npc, gemNPCObject *target, const csString &cmd) |
Send an emote command to server. | |
void | QueueEquipCommand (gemNPCActor *entity, csString item, csString slot, int count) |
Send a command to equip an equipment. | |
void | QueueLootCommand (gemNPCActor *entity, EID targetEID, const csString &type) |
Send a command to loot selected target. | |
void | QueuePickupCommand (gemNPCActor *entity, gemNPCObject *item, int count) |
Queue a command to pickup a item. | |
void | QueueResurrectCommand (csVector3 where, float rot, iSector *sector, PID character_id) |
Send a command to resurrect. | |
void | QueueScriptCommand (gemNPCActor *npc, gemNPCObject *target, const csString &scriptName) |
Send a script command to server. | |
void | QueueSequenceCommand (csString name, int cmd, int count) |
Send a command to start a sequence. | |
void | QueueSitCommand (gemNPCActor *npc, gemNPCObject *target, bool sit) |
Send a sit command to server. | |
void | QueueSpawnBuildingCommand (gemNPCActor *spawner, csVector3 where, iSector *sector, const char *buildingName, int tribeID, bool pickupable) |
Send a spawn building command to server. | |
void | QueueSpawnCommand (gemNPCActor *mother, gemNPCActor *father, const csString &tribeMemberType) |
Send a spawn command to server. | |
void | QueueSystemInfoCommand (uint32_t clientNum, const char *reply,...) |
Send an system info command to the client. | |
void | QueueTalkCommand (gemNPCActor *speaker, gemNPCActor *target, psNPCCommandsMessage::PerceptionTalkType talkType, bool publicTalk, const char *text) |
Queue a talk command to the server. | |
void | QueueTemporarilyImperviousCommand (gemNPCActor *entity, bool impervious) |
Send a command to change the temporarily impervious status. | |
void | QueueTransferCommand (gemNPCActor *entity, csString item, int count, csString target) |
Send a command to transfere an item between two entities. | |
void | QueueUnbuildCommand (gemNPCActor *unbuilder, gemNPCItem *building) |
Send a unbuild command to server. | |
void | QueueVisibilityCommand (gemNPCActor *entity, bool status) |
Queue a change in visibility. | |
void | QueueWorkCommand (gemNPCActor *entity, const csString &type, const csString &resource) |
Send a command to start working. | |
void | ReAuthenticate () |
Reauthenicate with the server. | |
void | ReConnect () |
Reconnect to the server server. | |
void | SendAllCommands (bool final=false) |
Send the queued commands. | |
void | SendConsoleCommand (const char *cmd) |
Send a console command. | |
virtual | ~NetworkManager () |
Destructor. | |
Public Attributes | |
bool | reconnect |
Set to true if reconnect should be done. | |
Protected Member Functions | |
void | HandleActor (MsgEntry *msg) |
Handle an actor from server. | |
void | HandleAllEntities (MsgEntry *message) |
Handle list of all entities from server. | |
void | HandleConsoleCommand (MsgEntry *me) |
void | HandleDisconnect (MsgEntry *msg) |
Handle command to disconnect from server. | |
void | HandleHiredNPCScript (MsgEntry *me) |
Handle Hired npc script from server. | |
void | HandleItem (MsgEntry *me) |
Handle a new item from server. | |
void | HandleLocation (MsgEntry *me) |
Handle location changes from server. | |
bool | HandleMapList (MsgEntry *msg) |
Handle the map list received from server. | |
void | HandleNewNpc (MsgEntry *msg) |
Handle information from server about NPCs to use. | |
void | HandleNpcDeleted (MsgEntry *msg) |
Handle information from server about deleted NPC. | |
bool | HandleNPCList (MsgEntry *msg) |
Handle a list of npcs received from server. | |
void | HandleNPCWorkDone (MsgEntry *msg) |
Handle information from server that work is done. | |
void | HandleObjectRemoval (MsgEntry *me) |
Handle removal of an object from server. | |
void | HandlePathNetwork (MsgEntry *me) |
Handle changes to path network from server. | |
void | HandlePerceptions (MsgEntry *msg) |
Handle perceptions from the server. | |
void | HandlePersistMessage (MsgEntry *msg) |
Handle new entities from server. | |
void | HandlePositionUpdates (MsgEntry *msg) |
Handle update update of positions from server. | |
void | HandleRaceList (MsgEntry *me) |
Handle list of races from server. | |
void | HandleTimeUpdate (MsgEntry *msg) |
Handle time updates from server. | |
void | RequestAllObjects () |
Number of command messages queued. | |
Protected Attributes | |
int | cmd_count |
Entities queued for sending of DR. | |
csHash< NPC *, PID > | cmd_dr_outbound |
bool | connected |
psNetConnection * | connection |
csString | host |
MsgHandler * | msghandler |
psNPCCommandsMessage * | outbound |
csString | password |
int | port |
bool | ready |
csString | user |
Handle all network messages inn and out of the NPC Client.
Definition at line 56 of file networkmgr.h.
NetworkManager::NetworkManager | ( | MsgHandler * | mh, |
psNetConnection * | conn, | ||
iEngine * | engine | ||
) |
Construct the network manager.
virtual NetworkManager::~NetworkManager | ( | ) | [virtual] |
Destructor.
void NetworkManager::Authenticate | ( | csString & | host, |
int | port, | ||
csString & | user, | ||
csString & | pass | ||
) |
void NetworkManager::CheckCommandsOverrun | ( | size_t | neededSize | ) |
Checks if the npc command message could overrun if the neededSize is tried to be added.
Automatically sends the message in case it could overrun.
neededSize | The size of data we are going to attempt to add to the npc commands message. |
void NetworkManager::DequeueDRData | ( | NPC * | npc | ) |
Call to remove queued dr updates when entities are removed/deleted.
void NetworkManager::Disconnect | ( | ) |
const char* NetworkManager::GetCommonString | ( | uint32_t | cstr_id | ) |
Convert a common string id into the corresponding string.
uint32_t NetworkManager::GetCommonStringID | ( | const char * | string | ) |
Convert a string into a common string id.
csStringHashReversible* NetworkManager::GetMsgStrings | ( | ) |
Get the message string table.
void NetworkManager::HandleActor | ( | MsgEntry * | msg | ) | [protected] |
Handle an actor from server.
msg | The undecoded message to handle. |
void NetworkManager::HandleAllEntities | ( | MsgEntry * | message | ) | [protected] |
Handle list of all entities from server.
message | The undecoded message to handle. |
void NetworkManager::HandleConsoleCommand | ( | MsgEntry * | me | ) | [protected] |
me | The undecoded message to handle. |
void NetworkManager::HandleDisconnect | ( | MsgEntry * | msg | ) | [protected] |
Handle command to disconnect from server.
msg | The undecoded message to handle. |
void NetworkManager::HandleHiredNPCScript | ( | MsgEntry * | me | ) | [protected] |
Handle Hired npc script from server.
msg | The undecoded message to handle. |
void NetworkManager::HandleItem | ( | MsgEntry * | me | ) | [protected] |
Handle a new item from server.
me | The undecoded message to handle. |
void NetworkManager::HandleLocation | ( | MsgEntry * | me | ) | [protected] |
Handle location changes from server.
me | The undecoded message to handle. |
bool NetworkManager::HandleMapList | ( | MsgEntry * | msg | ) | [protected] |
Handle the map list received from server.
msg | The undecoded message to handle. |
virtual void NetworkManager::HandleMessage | ( | MsgEntry * | pMsg | ) | [virtual] |
Handle all messages from server and send them to specefic Handle functions for each message type.
pMsg | The undecoded message to handle. |
Implements psClientNetSubscriber.
void NetworkManager::HandleNewNpc | ( | MsgEntry * | msg | ) | [protected] |
Handle information from server about NPCs to use.
msg | The undecoded message to handle. |
void NetworkManager::HandleNpcDeleted | ( | MsgEntry * | msg | ) | [protected] |
Handle information from server about deleted NPC.
msg | The undecoded message to handle. |
bool NetworkManager::HandleNPCList | ( | MsgEntry * | msg | ) | [protected] |
Handle a list of npcs received from server.
msg | The undecoded message to handle. |
void NetworkManager::HandleNPCWorkDone | ( | MsgEntry * | msg | ) | [protected] |
Handle information from server that work is done.
msg | The undecoded message to handle. |
void NetworkManager::HandleObjectRemoval | ( | MsgEntry * | me | ) | [protected] |
Handle removal of an object from server.
me | The undecoded message to handle. |
void NetworkManager::HandlePathNetwork | ( | MsgEntry * | me | ) | [protected] |
Handle changes to path network from server.
me | The undecoded message to handle. |
void NetworkManager::HandlePerceptions | ( | MsgEntry * | msg | ) | [protected] |
Handle perceptions from the server.
msg | The undecoded message to handle. |
void NetworkManager::HandlePersistMessage | ( | MsgEntry * | msg | ) | [protected] |
Handle new entities from server.
msg | The undecoded message to handle. |
void NetworkManager::HandlePositionUpdates | ( | MsgEntry * | msg | ) | [protected] |
Handle update update of positions from server.
msg | The undecoded message to handle. |
void NetworkManager::HandleRaceList | ( | MsgEntry * | me | ) | [protected] |
Handle list of races from server.
me | The undecoded message to handle. |
void NetworkManager::HandleTimeUpdate | ( | MsgEntry * | msg | ) | [protected] |
Handle time updates from server.
msg | The undecoded message to handle. |
bool NetworkManager::IsReady | ( | ) | [inline] |
Definition at line 227 of file networkmgr.h.
void NetworkManager::PrepareCommandMessage | ( | ) |
Prepare a new command message allow for queuing of new commands.
void NetworkManager::QueueAnimationCommand | ( | gemNPCActor * | npc, |
const csString & | cmd | ||
) |
Send an animation command to server.
npc | The npc that has an animation |
cmd | The animation |
void NetworkManager::QueueAssessCommand | ( | gemNPCActor * | entity, |
gemNPCObject * | target, | ||
const csString & | physicalAssessmentPerception, | ||
const csString & | magicalAssessmentPerception, | ||
const csString & | overallAssessmentPerception | ||
) |
Send a command to do an assessment.
void NetworkManager::QueueAttackCommand | ( | gemNPCActor * | attacker, |
gemNPCActor * | target, | ||
const char * | stance, | ||
const char * | attack_type | ||
) |
void NetworkManager::QueueBusyCommand | ( | gemNPCActor * | entity, |
bool | busy | ||
) |
Send a command to change the busy state.
void NetworkManager::QueueCastCommand | ( | gemNPCActor * | entity, |
gemNPCObject * | target, | ||
const csString & | spell, | ||
float | kFactor | ||
) |
Send a command to start cast a spell.
void NetworkManager::QueueControlCommand | ( | gemNPCActor * | controllingEntity, |
gemNPCActor * | controlledEntity | ||
) |
Send a command start controll an entity.
void NetworkManager::QueueDeleteNPCCommand | ( | NPC * | npcx | ) |
Send a command to delete a npc.
void NetworkManager::QueueDequipCommand | ( | gemNPCActor * | entity, |
csString | slot | ||
) |
Send a command to dequip an equipment.
void NetworkManager::QueueDRData | ( | NPC * | npc | ) |
void NetworkManager::QueueDRData2 | ( | NPC * | npc | ) |
void NetworkManager::QueueDropCommand | ( | gemNPCActor * | entity, |
csString | slot | ||
) |
Send a command to drop the content of a slot.
void NetworkManager::QueueEmoteCommand | ( | gemNPCActor * | npc, |
gemNPCObject * | target, | ||
const csString & | cmd | ||
) |
Send an emote command to server.
npc | The npc that has an emotion |
target | The current target of then npc |
cmd | The emotion |
void NetworkManager::QueueEquipCommand | ( | gemNPCActor * | entity, |
csString | item, | ||
csString | slot, | ||
int | count | ||
) |
Send a command to equip an equipment.
void NetworkManager::QueueLootCommand | ( | gemNPCActor * | entity, |
EID | targetEID, | ||
const csString & | type | ||
) |
Send a command to loot selected target.
void NetworkManager::QueuePickupCommand | ( | gemNPCActor * | entity, |
gemNPCObject * | item, | ||
int | count | ||
) |
Queue a command to pickup a item.
entity | The entity that should pick up a item. |
item | The item to pick up. |
count | The number of items to pick up of a stack. |
void NetworkManager::QueueResurrectCommand | ( | csVector3 | where, |
float | rot, | ||
iSector * | sector, | ||
PID | character_id | ||
) |
Send a command to resurrect.
void NetworkManager::QueueScriptCommand | ( | gemNPCActor * | npc, |
gemNPCObject * | target, | ||
const csString & | scriptName | ||
) |
Send a script command to server.
npc | The npc that sit/stand |
target | The current target of then npc |
scriptName | The name of the progression script to run at server |
Send a command to start a sequence.
void NetworkManager::QueueSitCommand | ( | gemNPCActor * | npc, |
gemNPCObject * | target, | ||
bool | sit | ||
) |
Send a sit command to server.
npc | The npc that sit/stand |
target | The current target of then npc |
sit | True if sitting, false if standing |
void NetworkManager::QueueSpawnBuildingCommand | ( | gemNPCActor * | spawner, |
csVector3 | where, | ||
iSector * | sector, | ||
const char * | buildingName, | ||
int | tribeID, | ||
bool | pickupable | ||
) |
Send a spawn building command to server.
spawner | The entity that spawned the building |
where | Containing the desired location |
sector | The sector in which we want a spawn. |
buildingName | The name of the building. Or more exactly... of the mesh for it. |
tribeID | The owner of this building |
pickupable | Should the building be possible to pick up |
void NetworkManager::QueueSpawnCommand | ( | gemNPCActor * | mother, |
gemNPCActor * | father, | ||
const csString & | tribeMemberType | ||
) |
Send a spawn command to server.
mother | The mother of the spawn |
father | If the father is known point to the father, use mother if unknow. |
tribeMemberType | What type of tribe member is this. |
void NetworkManager::QueueSystemInfoCommand | ( | uint32_t | clientNum, |
const char * | reply, | ||
... | |||
) |
Send an system info command to the client.
clientNum | The client that should receive the system info. |
reply | The reply to send back. |
void NetworkManager::QueueTalkCommand | ( | gemNPCActor * | speaker, |
gemNPCActor * | target, | ||
psNPCCommandsMessage::PerceptionTalkType | talkType, | ||
bool | publicTalk, | ||
const char * | text | ||
) |
Queue a talk command to the server.
The speaker will send a talk event say/action to target or nearby targets.
speaker | The npc that speaks. |
target | The current target. |
talkType | What kind of talk is this. |
publicTalk | True if this should be published. False will be a wisper. |
text | The text to talk. |
void NetworkManager::QueueTemporarilyImperviousCommand | ( | gemNPCActor * | entity, |
bool | impervious | ||
) |
Send a command to change the temporarily impervious status.
'
entity | The entity to change. |
impervious | Set to true if temporarily impervious should be turned on. |
void NetworkManager::QueueTransferCommand | ( | gemNPCActor * | entity, |
csString | item, | ||
int | count, | ||
csString | target | ||
) |
Send a command to transfere an item between two entities.
void NetworkManager::QueueUnbuildCommand | ( | gemNPCActor * | unbuilder, |
gemNPCItem * | building | ||
) |
Send a unbuild command to server.
unbuilder | The entity that unbuild the building |
building | The building. |
void NetworkManager::QueueVisibilityCommand | ( | gemNPCActor * | entity, |
bool | status | ||
) |
Queue a change in visibility.
entity | The entity to change visibility. |
status | The new visibility status. True or False. |
void NetworkManager::QueueWorkCommand | ( | gemNPCActor * | entity, |
const csString & | type, | ||
const csString & | resource | ||
) |
Send a command to start working.
void NetworkManager::ReAuthenticate | ( | ) |
Reauthenicate with the server.
void NetworkManager::ReConnect | ( | ) |
Reconnect to the server server.
void NetworkManager::RequestAllObjects | ( | ) | [protected] |
Number of command messages queued.
void NetworkManager::SendAllCommands | ( | bool | final = false | ) |
Send the queued commands.
final | True if this is the final. And a forced sending should be done. |
void NetworkManager::SendConsoleCommand | ( | const char * | cmd | ) |
Send a console command.
cmd | The command to send. |
int NetworkManager::cmd_count [protected] |
Entities queued for sending of DR.
Definition at line 67 of file networkmgr.h.
csHash<NPC*,PID> NetworkManager::cmd_dr_outbound [protected] |
Definition at line 66 of file networkmgr.h.
bool NetworkManager::connected [protected] |
Definition at line 62 of file networkmgr.h.
psNetConnection* NetworkManager::connection [protected] |
Definition at line 60 of file networkmgr.h.
csString NetworkManager::host [protected] |
Definition at line 204 of file networkmgr.h.
MsgHandler* NetworkManager::msghandler [protected] |
Definition at line 59 of file networkmgr.h.
psNPCCommandsMessage* NetworkManager::outbound [protected] |
Definition at line 65 of file networkmgr.h.
csString NetworkManager::password [protected] |
Definition at line 204 of file networkmgr.h.
int NetworkManager::port [protected] |
Definition at line 205 of file networkmgr.h.
bool NetworkManager::ready [protected] |
Definition at line 61 of file networkmgr.h.
Set to true if reconnect should be done.
Definition at line 510 of file networkmgr.h.
csString NetworkManager::user [protected] |
Definition at line 204 of file networkmgr.h.