00001 // 00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH) 00003 // 00004 // This program is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU General Public License 00006 // as published by the Free Software Foundation; either version 2 00007 // of the License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 // 00018 00025 #ifndef __SIMMUD_H_ 00026 #define __SIMMUD_H_ 00027 00028 #include "BaseApp.h" 00029 #include "SimMud_m.h" 00030 00031 #include "Vector2D.h" 00032 00033 class SimMud : public BaseApp 00034 { 00035 private: 00036 int currentRegionX; 00037 int currentRegionY; 00038 OverlayKey currentRegionID; 00039 std::set<OverlayKey> subscribedRegions; 00040 00041 int fieldSize; 00042 int numSubspaces; 00043 int regionSize; 00044 int AOIWidth; 00045 00046 int receivedMovementLists; 00047 int lostMovementLists; 00048 simtime_t maxMoveDelay; 00049 00050 int playerTimeout; 00051 cMessage* playerTimer; 00052 00053 struct PlayerInfo { 00054 Vector2D pos; 00055 bool update; 00056 }; 00057 00058 std::map <NodeHandle, PlayerInfo> playerMap; 00059 00060 public: 00061 SimMud( ); 00062 ~SimMud( ); 00063 00067 virtual void initializeApp( int stage ); 00068 00069 virtual void handleTimerEvent( cMessage *msg ); 00070 virtual void handleUpperMessage( cMessage *msg ); 00071 virtual void handleLowerMessage( cMessage *msg ); 00072 virtual void handleReadyMessage( CompReadyMessage *msg ); 00073 00074 virtual bool handleRpcCall( BaseCallMessage* msg ); 00075 virtual void handleRpcResponse( BaseResponseMessage* msg, 00076 cPolymorphic* context, 00077 int rpcId, simtime_t rtt ); 00078 00082 virtual void finishApp( ); 00083 00084 protected: 00085 void handleMove( GameAPIPositionMessage* msg ); 00086 void handleOtherPlayerMove( SimMudMoveMessage* msg ); 00087 }; 00088 00089 #endif