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 __SIMPLEGAMECLIENT_H_ 00026 #define __SIMPLEGAMECLIENT_H_ 00027 00028 #include <map> 00029 #include <Vector2D.h> 00030 #include <BaseApp.h> 00031 #include <string> 00032 00033 #include <GlobalCoordinator.h> 00034 #include <GlobalStatisticsAccess.h> 00035 #include <MovementGenerator.h> 00036 #include <randomRoaming.h> 00037 #include <groupRoaming.h> 00038 #include <hotspotRoaming.h> 00039 #include <traverseRoaming.h> 00040 #include <greatGathering.h> 00041 #include <realWorldRoaming.h> 00042 #include "SCPacket.h" 00043 #include "SimpleGameClient_m.h" 00044 00045 #include <tunoutscheduler.h> 00046 #include <realtimescheduler.h> 00047 00049 00053 class SimpleGameClient : public BaseApp 00054 { 00055 public: 00056 // OMNeT++ 00057 virtual ~SimpleGameClient(); 00058 virtual void initializeApp(int stage); 00059 virtual void handleTimerEvent(cMessage* msg); 00060 virtual void handleLowerMessage(cMessage* msg); 00061 virtual void handleReadyMessage(CompReadyMessage* msg); 00062 00063 Vector2D getPosition() {return position;}; 00064 double getAOI() {return AOIWidth;}; 00065 bool isOverlayReady() {return overlayReady;}; 00066 NodeHandle getThisNode() {return overlay->getThisNode();}; 00067 00068 NeighborMap Neighbors; 00069 00070 protected: 00071 GlobalCoordinator* coordinator; 00072 CollisionList CollisionRect; 00073 00074 void updateNeighbors(GameAPIListMessage* sgcMsg); 00075 void updatePosition(); 00076 00077 // parameters 00078 simtime_t movementDelay; 00079 double areaDimension, movementSpeed, movementRate, AOIWidth; 00080 bool useScenery; 00081 bool overlayReady; 00082 Vector2D position; 00083 MovementGenerator *Generator; 00084 bool logAOI; 00085 00086 NeighborMap::iterator itNeighbors; 00087 std::string GeneratorType; 00088 00089 // timers 00090 cMessage* move_timer; 00091 00092 // realworld 00093 void handleRealworldPacket(char *buf, uint32_t len); 00094 cMessage* packetNotification; // used by TunOutScheduler to notify about new packets 00095 RealtimeScheduler::PacketBuffer packetBuffer; // received packets are stored here 00096 RealtimeScheduler* scheduler; 00097 unsigned int mtu; 00098 SOCKET appFd; 00099 bool doRealworld; 00100 bool frozen; 00101 }; 00102 00103 #endif