src/engine/eNetGameObject.h

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
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 // max ping to equalize;
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; // the player controlling this cycle.
00051     // NULL means the AI.
00052     REAL laggometer;        
00053     REAL laggometerSmooth;  
00054 
00055     // used to implement the control functions
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         //    this->Kill();
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(); // just remove it from the lists and unregister it
00079 
00080     virtual void WriteCreate(nMessage &m);
00081     virtual void WriteSync(nMessage &m);
00082     virtual void ReadSync(nMessage &m);
00083     //virtual nDescriptor &CreatorDescriptor() const;
00084     virtual bool ClearToTransmit(int user) const;
00085     virtual bool SyncIsNew(nMessage &m);
00086 
00087     virtual void AddRef();          
00088     virtual void Release();         
00089 
00090     // control functions: (were once part of nNetObject.h)
00091     virtual void SendControl(REAL time,uActionPlayer *Act,REAL x);
00092     // is called on the client whenever a control key is pressed. This
00093     // sends a message to the server, who will call
00094     virtual void ReceiveControl(REAL time,uActionPlayer *Act,REAL x);
00095     // on his instance of the nNetObject.
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 

Generated on Sat Mar 15 22:55:45 2008 for Armagetron Advanced by  doxygen 1.5.4