Planeshift
psactionlocationinfo.h
Go to the documentation of this file.
1 /*
2 * psactionlocationinfo.h
3 *
4 * Copyright (C) 2005 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5 *
6 * Credits :
7 * Michael Cummings <cummings.michael@gmail.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation (version 2
12 * of the License).
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 * Creation Date: 1/20/2005
22 * Description : Container for the action_locations db table.
23 *
24 */
25 #ifndef __PSACTIONLOCATION_H__
26 #define __PSACTIONLOCATION_H__
27 //=============================================================================
28 // Crystal Space Includes
29 //=============================================================================
30 #include <csutil/parray.h>
31 
32 //=============================================================================
33 // Project Includes
34 //=============================================================================
35 #include "util/poolallocator.h"
36 #include "util/psconst.h"
37 
38 #include <idal.h>
39 
40 //=============================================================================
41 // Local Includes
42 //=============================================================================
43 
44 class CacheManager;
45 class gemActionLocation;
46 class gemItem;
47 struct iDocumentNode;
48 class MathExpression;
49 
59 {
60 public:
61  typedef enum
62  {
66  } TriggerType;
67 
68  static const char* TriggerTypeStr[];
69 
72 
73  bool Load(iResultRow &row);
74  bool Load(csRef<iDocumentNode> root);
75  bool Save();
76  bool Delete();
77  csString ToXML() const;
78 
79  int IsMatch(psActionLocation* compare);
80 
83 
85 
86  const csVector3 &GetPosition()
87  {
88  return position;
89  }
90  const csString &GetSectorName()
91  {
92  return sectorname;
93  }
94  //void SetLocationInWorld(psSectorInfo *sectorinfo,float loc_x,float loc_y,float loc_z,float loc_yrot);
95  void Send(int clientnum);
96 
97  // Returns the result of the XML parsing of the action lcoation reponse string and
98  // the setting of the action location member variables
99  bool ParseResponse();
100 
104  {
105  return instanceID;
106  }
108  {
109  instanceID = newID;
110  }
111 
114  {
115  return enterScript;
116  }
117 
119  const csString &GetEntranceType() const
120  {
121  return entranceType;
122  }
123  void SetEntranceType(const csString &newType)
124  {
125  entranceType = newType;
126  }
127 
129  bool IsGameBoard() const
130  {
131  return isGameBoard;
132  }
133 
135  bool IsExamineScript() const
136  {
137  return isExamineScript;
138  }
139 
141  bool IsEntrance() const
142  {
143  return isEntrance;
144  }
145  void SetIsEntrance(bool flag)
146  {
147  isEntrance = flag;
148  }
149 
151  bool IsLockable() const
152  {
153  return isLockable;
154  }
155  void SetIsLockable(bool flag)
156  {
157  isLockable = flag;
158  }
159 
161  bool IsContainer() const
162  {
163  return isContainer;
164  }
165 
167  bool IsReturn() const
168  {
169  return isReturn;
170  }
171 
173  bool IsActive() const
174  {
175  return isActive;
176  }
177  void SetActive(bool flag)
178  {
179  isActive = flag;
180  }
181 
183  const csString &GetDescription() const
184  {
185  return description;
186  }
187  void SetDescription(const csString &newDescription)
188  {
189  description = newDescription;
190  }
191 
193  csVector3 GetEntrancePosition() const
194  {
195  return entrancePosition;
196  }
197  void SetEntrancePosition(csVector3 newPosition)
198  {
199  entrancePosition = newPosition;
200  }
201  float GetEntranceRotation() const
202  {
203  return entranceRot;
204  }
205  void SetEntranceRotation(float newRot)
206  {
207  entranceRot = newRot;
208  }
209  const csString &GetEntranceSector() const
210  {
211  return entranceSector;
212  }
213  void SetEntranceSector(const csString &newSector)
214  {
215  entranceSector = newSector;
216  }
219  {
220  return entranceInstance;
221  }
223  void SetEntranceInstance(const InstanceID newInstance)
224  {
225  entranceInstance = newInstance;
226  }
227 
229  csVector3 GetReturnPosition() const
230  {
231  return returnPosition;
232  }
233  void SetReturnPosition(csVector3 newPosition)
234  {
235  returnPosition = newPosition;
236  }
237  float GetReturnRotation() const
238  {
239  return returnRot;
240  }
241  void SetReturnRotation(float newRot)
242  {
243  returnRot = newRot;
244  }
245  const csString &GetReturnSector() const
246  {
247  return returnSector;
248  }
249  void SetReturnSector(const csString &newSector)
250  {
251  returnSector = newSector;
252  }
255  {
256  return returnInstance;
257  }
259  void SetReturnInstance(const InstanceID newInstance)
260  {
261  returnInstance = newInstance;
262  }
263 
265  void SetName(const csString &newname)
266  {
267  name = newname;
268  }
269  void SetSectorName(const csString &newsector)
270  {
271  sectorname = newsector;
272  }
273  void SetMeshName(const csString &newmeshname)
274  {
275  meshname = newmeshname;
276  }
277  void SetTriggerType(const TriggerType &newtrigger)
278  {
279  triggertype = newtrigger;
280  }
281  TriggerType GetTriggerType() const
282  {
283  return triggertype;
284  }
285  const char* GetTriggerTypeAsString() const
286  {
287  return TriggerTypeStr[triggertype];
288  }
289  void SetResponseType(const csString &newresponsetype)
290  {
291  responsetype = newresponsetype;
292  }
293  void SetResponse(const csString &newresponse)
294  {
295  response = newresponse;
296  }
297  void SetPosition(csVector3 newposition)
298  {
299  position = newposition;
300  }
301 
305  void SetInstance(const InstanceID instance)
306  {
307  pos_instance = instance;
308  }
310  {
311  return pos_instance;
312  }
313  void SetRadius(float newradius)
314  {
315  radius = newradius;
316  }
317 
319  void* operator new(size_t);
321  void operator delete(void*);
322 
324  csString GetScriptToRun()
325  {
326  return scriptToRun;
327  }
329  {
330  return scriptParameters;
331  }
332 
333  uint32 id;
334  size_t master_id;
335 
336  csString name;
337  csString sectorname;
338  csString meshname;
339  csString polygon;
340  csVector3 position;
342  float radius;
343  TriggerType triggertype;
344  csString responsetype;
345  csString response;
346 
348 
349 private:
351  static PoolAllocator<psActionLocation> actionpool;
352 
356  void SetupEntrance(csRef<iDocumentNode> entranceNode);
357  void SetupReturn(csRef<iDocumentNode> returnNode);
358  void SetupContainer(csRef<iDocumentNode> containerNode);
359  void SetupGameboard(csRef<iDocumentNode> boardNode);
360  void SetupScript(csRef<iDocumentNode> scriptNode);
361  void SetupDescription(csRef<iDocumentNode> descriptionNode);
362 
364  bool isContainer;
365 
367  bool isGameBoard;
368 
370  bool isEntrance;
371 
373  bool isLockable;
374 
376  bool isActive;
377 
379  bool isReturn;
380 
382  bool isExamineScript;
383 
385  csString scriptToRun;
386  csString scriptParameters;
387 
389  InstanceID instanceID;
390 
392  csString entranceType;
393 
394  // Position stuff for entrances
395  csVector3 entrancePosition;
396  float entranceRot;
397  csString entranceSector;
398  InstanceID entranceInstance;
399 
402  MathExpression* enterScript;
403 
404  // Possition stuff for returns
405  csVector3 returnPosition;
406  float returnRot;
407  csString returnSector;
408  InstanceID returnInstance;
409 
410 
412  csString description;
413 
414 
415  //DB Helper Functions
416  unsigned int Insert(const char* table, const char** fieldnames, psStringArray &fieldvalues);
417  bool UpdateByKey(const char* table, const char* idname, const char* idvalue, const char** fieldnames, psStringArray &fieldvalues);
418  bool DeleteByKey(const char* table, const char* idname, const char* idvalue);
419 };
420 
423 #endif
424 
void SetDescription(const csString &newDescription)
void SetGemObject(gemActionLocation *gemAction)
void SetResponseType(const csString &newresponsetype)
bool IsEntrance() const
Returns true if this action location is an entrance.
uint32 InstanceID
Definition: psconst.h:64
const csString & GetEntranceSector() const
TriggerType GetTriggerType() const
csString meshname
Mesh name.
gemActionLocation * GetGemObject(void)
const csString & GetDescription() const
Returns action location description.
csString polygon
Required if multiple mesh of same name in area.
bool IsContainer() const
Returns true if this action location is a container.
void SetEntranceType(const csString &newType)
void SetMeshName(const csString &newmeshname)
const csString & GetReturnSector() const
void SetRadius(float newradius)
void SetInstanceID(InstanceID newID)
bool IsReturn() const
Returns true if this action location has return tag.
csString ToXML() const
void SetIsEntrance(bool flag)
void SetName(const csString &newname)
Sets.
const csString & GetSectorName()
void SetReturnInstance(const InstanceID newInstance)
bool Load(iResultRow &row)
const csVector3 & GetPosition()
The base expression class.
Definition: mathscript.h:330
float GetReturnRotation() const
MathExpression * GetEnterScript() const
Returns the enter script in entrance action location response string.
void SetEntranceInstance(const InstanceID newInstance)
void SetResponse(const csString &newresponse)
InstanceID pos_instance
The instance from where this action location will be accesible.
void SetEntranceRotation(float newRot)
const csString & GetEntranceType() const
Returns the entrance type in entrance action location response string.
csVector3 GetEntrancePosition() const
Returns or sets entrance location memebers.
void SetIsLockable(bool flag)
gemItem * GetRealItem()
void SetReturnPosition(csVector3 newPosition)
void SetSectorName(const csString &newsector)
bool IsExamineScript() const
Returns true if this action location will run a script and can be examined.
bool IsActive() const
Returns true if this action location is actaive.
csString GetScriptToRun()
Get script to run.
void SetEntranceSector(const csString &newSector)
Get entrace Instance in the world if not defined number of the action location.
void SetReturnSector(const csString &newSector)
Get return Instance in the world if not defined 0.
Default initial value, should not exist after loaded.
void SetPosition(csVector3 newposition)
csString GetScriptParameters()
void Send(int clientnum)
csString sectorname
Sector Where item is located.
gemActionLocation * gemAction
void SetEntrancePosition(csVector3 newPosition)
This class manages the caching of data that is unchanging during server operation.
Definition: cachemanager.h:234
bool IsGameBoard() const
Returns true if this action location is a minigame board.
InstanceID GetInstanceID() const
Returns instance ID of referenced in action location response string This is either a container ID or...
This class stores all the properties of an action location Entrance, return location, name, response type, trigger.
const InstanceID GetReturnInstance() const
Set return Instance in the world if not defined 0.
void SetInstance(const InstanceID instance)
Sets the instance in the world of this action location, default INSTANCE_ALL.
static const char * TriggerTypeStr[]
A slightly improved version of csStringArray, sporting the handy FormatPush method.
Definition: stringarray.h:33
const char * GetTriggerTypeAsString() const
bool IsLockable() const
Returns true if this action location is an lockable entrance.
csVector3 position
x,y,z coordinates required for entrances
csVector3 GetReturnPosition() const
Returns or sets return location memebers.
Definition: gem.h:768
const InstanceID GetEntranceInstance() const
Set entrace Instance in the world if not defined number of the action location.
float GetEntranceRotation() const
void SetActive(bool flag)
void SetReturnRotation(float newRot)
int IsMatch(psActionLocation *compare)
void SetTriggerType(const TriggerType &newtrigger)