Planeshift
npcmessages.h
Go to the documentation of this file.
1 /*
2 * npcmessages.h
3 *
4 * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5 *
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation (version 2 of the License)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 */
19 #ifndef __NPCMESSAGES_H__
20 #define __NPCMESSAGES_H__
21 
22 #include "net/message.h"
23 #include "net/messages.h"
24 #include <csutil/csstring.h>
25 #include <csutil/databuf.h>
26 #include <csgeom/vector3.h>
27 #include "util/psstring.h"
28 
29 
30 // Forward declarations
31 class Location;
32 class LocationType;
33 class Waypoint;
34 class WaypointAlias;
35 class psPath;
36 class psPathPoint;
37 struct iSector;
38 
47 {
48 public:
49 
55  psNPCAuthenticationMessage(uint32_t clientnum,
56  const char *userid,
57  const char *password);
58 
65 
67 
68  bool NetVersionOk();
69 };
70 
77 {
78 public:
79 
81 
83  psNPCListMessage(uint32_t clientToken,int size);
84 
86  psNPCListMessage(MsgEntry *message);
87 
89 
96  virtual csString ToString(NetBase::AccessPointers * accessPointers);
97 };
98 
104 {
105 public:
108 
110  psNPCReadyMessage(MsgEntry *message);
111 
113 
120  virtual csString ToString(NetBase::AccessPointers * accessPointers);
121 };
122 
129 {
130 public:
131 
132  csArray<csString> map;
133 
135  psMapListMessage(uint32_t clientToken,csString& str);
136 
138  psMapListMessage(MsgEntry *message);
139 
141 
148  virtual csString ToString(NetBase::AccessPointers * accessPointers);
149 };
150 
156 {
157 public:
158 
159  typedef struct
160  {
161  csString name;
162  float walkSpeed;
163  float runSpeed;
164  csVector3 size;
165  float scale;
166  } NPCRaceInfo_t;
167 
168 
169  csArray<NPCRaceInfo_t> raceInfo;
170 
172  psNPCRaceListMessage(uint32_t clientToken,int count);
173 
175  psNPCRaceListMessage(MsgEntry *message);
176 
178 
182  void AddRace(csString& name, float walkSpeed, float runSpeed, const csVector3& size, float scale, bool last);
183 
190  virtual csString ToString(NetBase::AccessPointers * accessPointers);
191 };
192 
199 {
200 public:
201 
202  enum Flags
203  {
204  NONE = 0,
205  INVISIBLE = 1 << 0,
206  INVINCIBLE = 1 << 1,
207  IS_ALIVE = 1 << 2
208  };
209 
211  {
212  // Commands go from superclient to server
230  CMD_SCRIPT, // used for superclient to request a progress script to be run at server
233  CMD_SPAWN_BUILDING, // used for superclient to request a new building
236  CMD_UNBUILD, // used for superclient to request a building to be tearn down
241  // Perceptions go from server to superclient
253  PCPT_INFO_REQUEST, // Command to superclient, not a perception
269  PCPT_CHANGE_OWNER, // Command to superclient, not a perception
270  };
271 
273  {
277  TALK_NARRATE
278  };
279 
281  psNPCCommandsMessage(uint32_t clientToken, int size);
282 
284  psNPCCommandsMessage(MsgEntry *message);
285 
287 
293  virtual csString ToString(NetBase::AccessPointers * accessPointers);
294 };
295 
296 
297 //helpers for message splitting
298 #define ALLENTITYPOS_SIZE_PER_ENTITY (4 * sizeof(float) + sizeof(bool) + sizeof(uint32_t) + 100*sizeof(char))
299 #define ALLENTITYPOS_MAX_AMOUNT (MAX_MESSAGE_SIZE-2)/ALLENTITYPOS_SIZE_PER_ENTITY
300 
307 {
308 public:
310  int count;
311 
313  psAllEntityPosMessage() { count = 0; msg=NULL; }
314 
317 
319 
326  virtual csString ToString(NetBase::AccessPointers * accessPointers);
327 
329  void SetLength(int size,int client);
330 
332  void Add(EID id, csVector3 & pos, iSector* & sector, InstanceID instance, csStringSet* msgstrings, bool forced = false);
333 
335  EID Get(csVector3 & pos, iSector* & sector, InstanceID & instance, bool &forced, csStringSet* msgstrings,
336  csStringHashReversible* msgstringshash, iEngine* engine);
337 };
338 
344 {
345 public:
346  EID npcEID;
347  const char* resource;
348  const char* nick;
349 
350  psNPCWorkDoneMessage(uint32_t clientToken, EID npcEID, const char* resource, const char* nick);
351 
352  psNPCWorkDoneMessage(MsgEntry *message);
353 
355 
356  virtual csString ToString(NetBase::AccessPointers* accessPointers);
357 };
358 
364 {
365 public:
366  PID new_npc_id, master_id, owner_id;
367 
369  psNewNPCCreatedMessage(uint32_t clientToken, PID new_npc_id, PID master_id, PID owner_id);
370 
373 
375 
382  virtual csString ToString(NetBase::AccessPointers * accessPointers);
383 };
384 
390 {
391 public:
392  PID npc_id;
393 
395  psNPCDeletedMessage(uint32_t clientToken, PID npc_id);
396 
398  psNPCDeletedMessage(MsgEntry *message);
399 
401 
408  virtual csString ToString(NetBase::AccessPointers * accessPointers);
409 };
410 
416 {
417 public:
418 
419  typedef enum
420  {
433  CMD_LAST // LAST command, insert new commands before this
434  } PetCommand_t;
435 
436  static const char *petCommandString[];
437 
438  int command;
441 
443  psPETCommandMessage(uint32_t clientToken, int cmd, const char * target, const char * options);
444 
446  psPETCommandMessage(MsgEntry *message);
447 
449 
456  virtual csString ToString(NetBase::AccessPointers * accessPointers);
457 };
458 
464 {
465 public:
466 
468 
470  psServerCommandMessage(uint32_t clientToken, const char * target);
471 
474 
476 
483  virtual csString ToString(NetBase::AccessPointers* accessPointers);
484 };
485 
489 {
490 public:
491 
492  typedef enum
493  {
507  WAYPOINT_SET_FLAG
508  } Command;
509 
510  Command command;
511  uint32_t id;
512  csVector3 position;
513  iSector* sector;
514  csString string;
515  bool enable;
516  float radius;
517  csString flags;
518  uint32_t startId;
519  uint32_t stopId;
520  uint32_t secondId;
522  uint32_t aliasID;
523 
524  // Create psMessageBytes struct for outbound use
525 
528  psPathNetworkMessage(Command command, const psPath* path);
529 
532  psPathNetworkMessage(Command command, const psPath* path, const psPathPoint* point);
533 
536  psPathNetworkMessage(Command command, const psPath* path, int secondId);
537 
538 
541  psPathNetworkMessage(Command command, const psPath* path, const csString& string, bool enable);
542 
545  psPathNetworkMessage(Command command, const psPathPoint* point);
546 
549  psPathNetworkMessage(Command command, const Waypoint* waypoint);
550 
553  psPathNetworkMessage(Command command, const Waypoint* waypoint, const WaypointAlias* alias);
554 
557  psPathNetworkMessage(Command command, const Waypoint* waypoint, const csString& string);
558 
561  psPathNetworkMessage(Command command, const Waypoint* waypoint, const csString& string, bool enable);
562 
563 
565  psPathNetworkMessage(MsgEntry *message);
566 
568 
575  virtual csString ToString(NetBase::AccessPointers* accessPointers);
576 };
577 
581 {
582 public:
583 
584  typedef enum
585  {
594  LOCATION_TYPE_REMOVE
595  } Command;
596 
597  Command command;
598  uint32_t id;
599  csVector3 position;
600  iSector* sector;
601  bool enable;
602  float radius;
604  csString flags;
605  csString typeName;
606  csString name;
607  uint32_t prevID;
608 
609  // Create psMessageBytes struct for outbound use
610 
613  psLocationMessage(Command command, const Location* location);
614 
617  psLocationMessage(Command command, const LocationType* locationType);
618 
621  psLocationMessage(Command command, const csString& name);
622 
624  psLocationMessage(MsgEntry *message);
625 
627 
634  virtual csString ToString(NetBase::AccessPointers* accessPointers);
635 };
636 
639 #endif
640 
The 3rd message sent from server to superclient after successful login.
Definition: npcmessages.h:155
csString flags
String with flags.
Definition: npcmessages.h:604
uint32 InstanceID
Definition: psconst.h:64
bool enable
Enable or disable flags.
Definition: npcmessages.h:515
The message sent from server to superclient after successful NPC Creation.
Definition: npcmessages.h:363
Class to hold information regarding aliases for waypoints.
Definition: waypoint.h:38
Command to superclient used to change the brain of a npc.
Definition: npcmessages.h:245
csArray< csString > map
Definition: npcmessages.h:132
The message sent from superclient to server after receiving all entities.
Definition: npcmessages.h:103
virtual csString ToString(NetBase::AccessPointers *accessPointers)
Converts the message into human readable string.
Struct used by MessageCracker and ToString to distribute a number of access pointers.
Definition: netbase.h:125
Definition: pspath.h:152
csString name
Name.
Definition: npcmessages.h:606
const char * nick
Definition: npcmessages.h:348
uint32_t aliasID
The id of aliases.
Definition: npcmessages.h:522
The message sent from server to superclient every 2.5 seconds.
Definition: npcmessages.h:306
csString string
The string for add alias/flag set.
Definition: npcmessages.h:514
csArray< NPCRaceInfo_t > raceInfo
Definition: npcmessages.h:169
psAllEntityPosMessage()
Create psMessageBytes struct for outbound use.
Definition: npcmessages.h:313
float scale
The scale override of this race.
Definition: npcmessages.h:165
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
The message sent from client to server on login.
Definition: messages.h:587
A waypoint is a specified circle on the map with a name, location, and a list of waypoints it is conn...
Definition: waypoint.h:81
iSector * sector
The sector for new or adjusted elements.
Definition: npcmessages.h:600
uint32_t prevID
ID of previous point in a region.
Definition: npcmessages.h:607
bool enable
Enable or disable flags.
Definition: npcmessages.h:601
The message sent from superclient to server on login.
Definition: npcmessages.h:46
The message sent from server to superclient after successful login.
Definition: npcmessages.h:76
float radius
The radius.
Definition: npcmessages.h:516
This stores a vector of positions listing a set of points defining a common type of location...
Definition: location.h:275
The message sent from client to server to control the players pet.
Definition: npcmessages.h:415
Command the superclient to change the debug level of a tribe.
Definition: npcmessages.h:248
csVector3 position
The position for new or adjusted elements.
Definition: npcmessages.h:512
int count
Hold the number of entity positions after the message is cracked.
Definition: npcmessages.h:310
const char * resource
Definition: npcmessages.h:347
Handle PathNetwork changes from server to superclient.
Definition: npcmessages.h:488
csVector3 position
The position for new or adjusted elements.
Definition: npcmessages.h:599
All net messages inherit from this class.
Definition: messages.h:343
psNPCAuthenticationMessage(uint32_t clientnum, const char *userid, const char *password)
This function creates a PS Message struct given a userid and password to send out.
iSector * sector
The sector for new or adjusted elements.
Definition: npcmessages.h:513
Handle Location changes from server to superclient.
Definition: npcmessages.h:580
csString flags
String with flags.
Definition: npcmessages.h:517
Server command message is for using npcclient as a remote command and debugging console for psserver...
Definition: npcmessages.h:463
The message sent from server to superclient upon a successful work done.
Definition: npcmessages.h:343
uint32_t id
ID of the location/location type.
Definition: npcmessages.h:598
float rotationAngle
The rotation angle for this element.
Definition: npcmessages.h:603
The message sent from server to superclient when a NPC is deleted from the server.
Definition: npcmessages.h:389
Command the superclient to change the debug level of a npc.
Definition: npcmessages.h:247
uint32_t id
ID of waypoint/point/segment.
Definition: npcmessages.h:511
csString name
On average the name should not exceed 100 characters.
Definition: npcmessages.h:161
csRef< MsgEntry > msg
Definition: messages.h:348
csString typeName
Type name.
Definition: npcmessages.h:605
float radius
The radius.
Definition: npcmessages.h:602
A Location is a named place on the map, located dynamically by NPCs as scripted.
Definition: location.h:48
float rotationAngle
The rotation angle for aliases.
Definition: npcmessages.h:521
Represents a point on a path between two waypoints.
Definition: pspath.h:58
The 2nd message sent from server to superclient after successful login.
Definition: npcmessages.h:128
The message sent from server to superclient after successful login.
Definition: npcmessages.h:198