Planeshift

psactionlocationinfo.h

Go to the documentation of this file.
00001 /*
00002 * psactionlocationinfo.h
00003 *
00004 * Copyright (C) 2005 Atomic Blue ([email protected], http://www.atomicblue.org)
00005 *
00006 * Credits :
00007 *            Michael Cummings <[email protected]>
00008 *
00009 * This program is free software; you can redistribute it and/or
00010 * modify it under the terms of the GNU General Public License
00011 * as published by the Free Software Foundation (version 2
00012 * of the License).
00013 * This program is distributed in the hope that it will be useful,
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016 * GNU General Public License for more details.
00017 * You should have received a copy of the GNU General Public License
00018 * along with this program; if not, write to the Free Software
00019 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00020 *
00021 * Creation Date: 1/20/2005
00022 * Description : Container for the action_locations db table.
00023 *
00024 */
00025 #ifndef __PSACTIONLOCATION_H__
00026 #define __PSACTIONLOCATION_H__
00027 //=============================================================================
00028 // Crystal Space Includes
00029 //=============================================================================
00030 #include <csutil/parray.h>
00031 
00032 //=============================================================================
00033 // Project Includes
00034 //=============================================================================
00035 #include "util/poolallocator.h"
00036 #include "util/psconst.h"
00037 
00038 #include <idal.h>
00039 
00040 //=============================================================================
00041 // Local Includes
00042 //=============================================================================
00043 
00044 class CacheManager;
00045 class gemActionLocation;
00046 class gemItem;
00047 struct iDocumentNode;
00048 class MathExpression;
00049 
00060 class psActionLocation
00061 {
00062 public:
00063     typedef enum
00064     {
00065         TRIGGERTYPE_NONE,   
00066         TRIGGERTYPE_SELECT,
00067         TRIGGERTYPE_PROXIMITY
00068     } TriggerType;
00069 
00070     static const char* TriggerTypeStr[];
00071 
00072     psActionLocation();
00073     ~psActionLocation();
00074 
00075     bool Load(iResultRow &row);
00076     bool Load(csRef<iDocumentNode> root);
00077     bool Save();
00078     bool Delete();
00079     csString ToXML() const;
00080 
00081     int IsMatch(psActionLocation* compare);
00082 
00083     void SetGemObject(gemActionLocation* gemAction);
00084     gemActionLocation* GetGemObject(void);
00085 
00086     gemItem* GetRealItem();
00087 
00088     const csVector3 &GetPosition()
00089     {
00090         return position;
00091     }
00092     const csString &GetSectorName()
00093     {
00094         return sectorname;
00095     }
00096     //void SetLocationInWorld(psSectorInfo *sectorinfo,float loc_x,float loc_y,float loc_z,float loc_yrot);
00097     void Send(int clientnum);
00098 
00099     // Returns the result of the XML parsing of the action lcoation reponse string and
00100     //  the setting of the action location member variables
00101     bool ParseResponse();
00102 
00105     InstanceID GetInstanceID() const
00106     {
00107         return instanceID;
00108     }
00109     void SetInstanceID(InstanceID newID)
00110     {
00111         instanceID = newID;
00112     }
00113 
00115     MathExpression* GetEnterScript() const
00116     {
00117         return enterScript;
00118     }
00119 
00121     const csString &GetEntranceType() const
00122     {
00123         return entranceType;
00124     }
00125     void SetEntranceType(const csString &newType)
00126     {
00127         entranceType = newType;
00128     }
00129 
00131     bool IsGameBoard() const
00132     {
00133         return isGameBoard;
00134     }
00135 
00137     bool IsExamineScript() const
00138     {
00139         return isExamineScript;
00140     }
00141 
00143     bool IsEntrance() const
00144     {
00145         return isEntrance;
00146     }
00147     void SetIsEntrance(bool flag)
00148     {
00149         isEntrance = flag;
00150     }
00151 
00153     bool IsLockable() const
00154     {
00155         return isLockable;
00156     }
00157     void SetIsLockable(bool flag)
00158     {
00159         isLockable = flag;
00160     }
00161 
00163     bool IsContainer() const
00164     {
00165         return isContainer;
00166     }
00167 
00169     bool IsReturn() const
00170     {
00171         return isReturn;
00172     }
00173 
00175     bool IsActive() const
00176     {
00177         return isActive;
00178     }
00179     void SetActive(bool flag)
00180     {
00181         isActive = flag;
00182     }
00183 
00185     const csString &GetDescription() const
00186     {
00187         return description;
00188     }
00189     void SetDescription(const csString &newDescription)
00190     {
00191         description = newDescription;
00192     }
00193 
00195     csVector3 GetEntrancePosition() const
00196     {
00197         return entrancePosition;
00198     }
00199     void SetEntrancePosition(csVector3 newPosition)
00200     {
00201         entrancePosition = newPosition;
00202     }
00203     float GetEntranceRotation() const
00204     {
00205         return entranceRot;
00206     }
00207     void SetEntranceRotation(float newRot)
00208     {
00209         entranceRot = newRot;
00210     }
00211     const csString &GetEntranceSector() const
00212     {
00213         return entranceSector;
00214     }
00215     void SetEntranceSector(const csString &newSector)
00216     {
00217         entranceSector = newSector;
00218     }
00220     const InstanceID GetEntranceInstance() const
00221     {
00222         return entranceInstance;
00223     }
00225     void SetEntranceInstance(const InstanceID newInstance)
00226     {
00227         entranceInstance = newInstance;
00228     }
00229 
00231     csVector3 GetReturnPosition() const
00232     {
00233         return returnPosition;
00234     }
00235     void SetReturnPosition(csVector3 newPosition)
00236     {
00237         returnPosition = newPosition;
00238     }
00239     float GetReturnRotation() const
00240     {
00241         return returnRot;
00242     }
00243     void SetReturnRotation(float newRot)
00244     {
00245         returnRot = newRot;
00246     }
00247     const csString &GetReturnSector() const
00248     {
00249         return returnSector;
00250     }
00251     void SetReturnSector(const csString &newSector)
00252     {
00253         returnSector = newSector;
00254     }
00256     const InstanceID GetReturnInstance() const
00257     {
00258         return returnInstance;
00259     }
00261     void SetReturnInstance(const InstanceID newInstance)
00262     {
00263         returnInstance = newInstance;
00264     }
00265 
00267     void SetName(const csString &newname)
00268     {
00269         name = newname;
00270     }
00271     void SetSectorName(const csString &newsector)
00272     {
00273         sectorname = newsector;
00274     }
00275     void SetMeshName(const csString &newmeshname)
00276     {
00277         meshname = newmeshname;
00278     }
00279     void SetTriggerType(const TriggerType &newtrigger)
00280     {
00281         triggertype = newtrigger;
00282     }
00283     TriggerType GetTriggerType() const
00284     {
00285         return triggertype;
00286     }
00287     const char* GetTriggerTypeAsString() const
00288     {
00289         return TriggerTypeStr[triggertype];
00290     }
00291     void SetResponseType(const csString &newresponsetype)
00292     {
00293         responsetype = newresponsetype;
00294     }
00295     void SetResponse(const csString &newresponse)
00296     {
00297         response = newresponse;
00298     }
00299     void SetPosition(csVector3 newposition)
00300     {
00301         position = newposition;
00302     }
00303 
00307     void SetInstance(const InstanceID instance)
00308     {
00309         pos_instance = instance;
00310     }
00311     InstanceID GetInstance()
00312     {
00313         return pos_instance;
00314     }
00315     void SetRadius(float newradius)
00316     {
00317         radius = newradius;
00318     }
00319 
00321     void* operator new(size_t);
00323     void operator delete(void*);
00324 
00326     csString GetScriptToRun()
00327     {
00328         return scriptToRun;
00329     }
00330     csString GetScriptParameters()
00331     {
00332         return scriptParameters;
00333     }
00334 
00335     uint32 id;
00336     size_t master_id;
00337 
00338     csString name;
00339     csString sectorname; 
00340     csString meshname; 
00341     csString polygon; 
00342     csVector3 position; 
00343     InstanceID pos_instance; 
00344     float radius;
00345     TriggerType triggertype;
00346     csString responsetype;
00347     csString response;
00348 
00349     gemActionLocation* gemAction;
00350 
00351 private:
00353     static PoolAllocator<psActionLocation> actionpool;
00354 
00358     void SetupEntrance(csRef<iDocumentNode> entranceNode);
00359     void SetupReturn(csRef<iDocumentNode> returnNode);
00360     void SetupContainer(csRef<iDocumentNode> containerNode);
00361     void SetupGameboard(csRef<iDocumentNode> boardNode);
00362     void SetupScript(csRef<iDocumentNode> scriptNode);
00363     void SetupDescription(csRef<iDocumentNode> descriptionNode);
00364 
00366     bool isContainer;
00367 
00369     bool isGameBoard;
00370 
00372     bool isEntrance;
00373 
00375     bool isLockable;
00376 
00378     bool isActive;
00379 
00381     bool isReturn;
00382 
00384     bool isExamineScript;
00385 
00387     csString scriptToRun;
00388     csString scriptParameters;
00389 
00391     InstanceID instanceID;
00392 
00394     csString entranceType;
00395 
00396     // Position stuff for entrances
00397     csVector3 entrancePosition;
00398     float entranceRot;
00399     csString entranceSector;
00400     InstanceID entranceInstance;
00401 
00404     MathExpression* enterScript;
00405 
00406     // Possition stuff for returns
00407     csVector3 returnPosition;
00408     float returnRot;
00409     csString returnSector;
00410     InstanceID returnInstance;
00411 
00412 
00414     csString description;
00415 
00416 
00417     //DB Helper Functions
00418     unsigned int Insert(const char* table, const char** fieldnames, psStringArray &fieldvalues);
00419     bool         UpdateByKey(const char* table, const char* idname, const char* idvalue, const char** fieldnames, psStringArray &fieldvalues);
00420     bool         DeleteByKey(const char* table, const char* idname, const char* idvalue);
00421 };
00422 
00425 #endif
00426