Planeshift
psproxlist.h
Go to the documentation of this file.
1 /*
2  * psproxlist.h
3  *
4  * Copyright (C) 2001 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  */
20 #ifndef __PS_IMP_PROXIMITYLIST__
21 #define __PS_IMP_PROXIMITYLIST__
22 
23 //=============================================================================
24 // Crystal Space Includes
25 //=============================================================================
26 #include <cstypes.h>
27 #include <iutil/comp.h>
28 #include <csutil/hash.h>
29 #include <csutil/scf.h>
30 #include <net/netbase.h>
31 
32 //=============================================================================
33 // Project Includes
34 //=============================================================================
35 #include "util/psconst.h"
36 
37 //=============================================================================
38 // Local Includes
39 //=============================================================================
40 
41 class gemObject;
42 struct iObjectRegistry;
43 class EntityManager;
44 
45 /* ProximityList must maintain following properties:
46  * - values in objectsThatWatchMe are unique
47  * - values in objectsThatIWatch are unique
48  * - object X is in objectsThatWatchMe of object Y <===> object Y must be in objectsThatIWatch of X
49  * - objects with GetClientID()==0 have empty objectsThatIWatch
50  * - correspondence between objectsThatWatchMe and objectsThatWatchMe_touched
51  * objectsThatIWatch and objectsThatIWatch_touched
52  */
53 
55 {
56 protected:
57  gemObject* self;
58 
59  csArray<PublishDestination> objectsThatWatchMe;
60  csArray<gemObject*> objectsThatIWatch;
61  csArray<csTicks> destRangeTimer;
62 
65 
66  int clientnum;
67  bool firstFrame;
68  csVector3 oldPos;
70 
72 
74  void AddWatcher(gemObject* interestedobject, float range);
75 
77  void RemoveWatcher(gemObject* object);
78 
79  bool IsNear(iSector* sector,csVector3 &pos,gemObject* object,float radius);
80  bool FindObject(gemObject* object);
82  bool FindObjectThatIWatch(gemObject* object);
83 
84  void TouchObjectThatWatchesMe(gemObject* object,float newrange);
85 
86 
88  gemObject* myself,
89  gemObject* object,
90  uint objIdx,
91  float newrange);
92 
93 public:
94  ProximityList(iObjectRegistry* object_reg, gemObject* parent, EntityManager* entitymanager);
96 
97  bool Initialize(int cnum,gemObject* parent);
98 
101  bool StartWatching(gemObject* object, float range);
102 
104  void EndWatching(gemObject* object);
105 
107  bool StartMutualWatching(int othercnum, gemObject* otherObject,float range);
108 
110  bool EndMutualWatching(gemObject* fromobject);
111 
112  csArray<PublishDestination> &GetClients()
113  {
114  return objectsThatWatchMe;
115  }
117  {
118  return clientnum;
119  }
120 
121  bool FindClient(uint32_t cnum);
122  gemObject* FindObjectName(const char* name);
123 
127  bool CheckUpdateRequired();
128  float RangeTo(gemObject* object, bool ignoreY = false, bool ignoreInstance = false);
129  void DebugDumpContents(csString &out);
130 
131  void ClearTouched();
134 };
135 
136 #endif
137 
uint32 InstanceID
Definition: psconst.h:64
Manages CEL entities on the server.
Definition: entitymanager.h:77
bool EndMutualWatching(gemObject *fromobject)
Deletes relation watcher –> watched in both directions between our object and given object...
gemObject * FindObjectName(const char *name)
int GetClientID()
Definition: psproxlist.h:116
bool Initialize(int cnum, gemObject *parent)
EntityManager * entityManager
Definition: psproxlist.h:71
void UpdatePublishDestRange(PublishDestination *pd, gemObject *myself, gemObject *object, uint objIdx, float newrange)
bool GetUntouched_ObjectThatWatchesMe(gemObject *&object)
csArray< bool > objectsThatIWatch_touched
Definition: psproxlist.h:64
csArray< gemObject * > objectsThatIWatch
What objects am I subscribed to myself?
Definition: psproxlist.h:60
void EndWatching(gemObject *object)
Deletes relation watcher –> watched between our object and given object.
float RangeTo(gemObject *object, bool ignoreY=false, bool ignoreInstance=false)
void TouchObjectThatWatchesMe(gemObject *object, float newrange)
bool StartWatching(gemObject *object, float range)
Creates relation watcher –> watched between our object and given object Returns: true if new relatio...
bool IsNear(iSector *sector, csVector3 &pos, gemObject *object, float radius)
void RemoveWatcher(gemObject *object)
Removes &#39;interestedobject&#39; from &#39;objectsThatWatchMe&#39;.
PublishDestination * FindObjectThatWatchesMe(gemObject *object, uint &x)
void ClearTouched()
csArray< csTicks > destRangeTimer
Per-object timeout on dest range checks.
Definition: psproxlist.h:61
bool FindObject(gemObject *object)
ProximityList(iObjectRegistry *object_reg, gemObject *parent, EntityManager *entitymanager)
csArray< PublishDestination > & GetClients()
Definition: psproxlist.h:112
bool StartMutualWatching(int othercnum, gemObject *otherObject, float range)
Creates relation watcher –> watched in both directions between our object and given object...
csArray< PublishDestination > objectsThatWatchMe
What players are subscribed to my updates?
Definition: psproxlist.h:59
InstanceID oldInstance
Definition: psproxlist.h:69
bool FindClient(uint32_t cnum)
bool firstFrame
Definition: psproxlist.h:67
A gemObject is any solid, graphical object visible in PS with normal physics and normal collision det...
Definition: gem.h:314
void DebugDumpContents(csString &out)
bool GetUntouched_ObjectThatIWatch(gemObject *&object)
csArray< bool > objectsThatWatchMe_touched
Definition: psproxlist.h:63
bool CheckUpdateRequired()
Check if an update is required for this object based on moved range and changed instance.
bool FindObjectThatIWatch(gemObject *object)
void AddWatcher(gemObject *interestedobject, float range)
Adds &#39;interestedobject&#39; to &#39;objectsThatWatchMe&#39;.
csVector3 oldPos
Definition: psproxlist.h:68