00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ArmageTron_NETGAME_H
00029 #define ArmageTron_NETGAME_H
00030
00031 #include "nNetObject.h"
00032 #include "eGameObject.h"
00033 #include "tCallback.h"
00034
00035
00036 extern int sn_pingCharityServer;
00037
00038 class ePlayerNetID;
00039
00040
00041 class eNetGameObject:public eGameObject,public nNetObject{
00042 friend class ePlayerNetID;
00043
00044 void MyInitAfterCreation();
00045 protected:
00046 REAL lastClientsideAction;
00047 REAL lastAttemptedSyncTime;
00048 REAL pingOverflow;
00049
00050 tCHECKED_PTR(ePlayerNetID) player;
00051
00052 REAL laggometer;
00053 REAL laggometerSmooth;
00054
00055
00056 virtual void ReceiveControlNet(nMessage &m);
00057
00058 virtual ~eNetGameObject();
00059
00060 void SetPlayer(ePlayerNetID* player);
00061
00062 virtual nMachine & DoGetMachine() const;
00063 public:
00064 virtual bool ActionOnQuit(){
00065
00066 return false;
00067 }
00068
00069 virtual void ActionOnDelete(){
00070 RemoveFromGame();
00071 }
00072
00073 virtual void InitAfterCreation();
00074
00075 eNetGameObject(eGrid *grid, const eCoord &pos,const eCoord &dir,ePlayerNetID* p,bool autodelete=false);
00076 eNetGameObject(nMessage &m);
00077
00078 virtual void DoRemoveFromGame();
00079
00080 virtual void WriteCreate(nMessage &m);
00081 virtual void WriteSync(nMessage &m);
00082 virtual void ReadSync(nMessage &m);
00083
00084 virtual bool ClearToTransmit(int user) const;
00085 virtual bool SyncIsNew(nMessage &m);
00086
00087 virtual void AddRef();
00088 virtual void Release();
00089
00090
00091 virtual void SendControl(REAL time,uActionPlayer *Act,REAL x);
00092
00093
00094 virtual void ReceiveControl(REAL time,uActionPlayer *Act,REAL x);
00095
00096
00097 virtual bool Timestep(REAL currentTime);
00098
00099 ePlayerNetID *Player()const{return player;}
00100
00101 void clientside_action(){lastClientsideAction=lastTime;}
00102
00103 virtual REAL Lag() const;
00104 virtual REAL LagThreshold() const;
00105 };
00106
00107 nMessage &operator << (nMessage &m, const eCoord &x);
00108 nMessage &operator >> (nMessage &m, eCoord &x);
00109
00110 class eTransferInhibitor: public tCallbackOr{
00111 static int user;
00112 public:
00113 static int User(){return user;}
00114
00115 eTransferInhibitor(BOOLRETFUNC *f);
00116 static bool no_transfer(int user);
00117 };
00118
00119 #endif
00120