duncan
Mom and Dad were wrong!
|
00001 #ifndef SERVER_WORLD_H_ 00002 #define SERVER_WORLD_H_ 00003 00004 extern bool g_serverpath; 00005 00006 #include <algorithm> 00007 #include <tr1/memory> 00008 #include <cstring> 00009 #include <queue> 00010 #include <iostream> 00011 #include <sstream> 00012 #include "charlist.h" 00013 #include "player.h" 00014 #include "npc.h" 00015 #include "playerpacket.h" 00016 #include "map.h" 00017 #include "pathworld.h" 00018 #include "pathfinder.h" 00019 00020 namespace server { 00021 00032 class World : public PathWorld { 00033 public: 00034 typedef CharList<Character> CList; 00035 private: 00037 const static double kPositionPacketInterval=0.1; 00038 00040 const static double kPathPacketInterval=1.5; 00041 00043 const static double kTreeRebuildInterval=1; 00044 00046 double tree_age_; 00047 00049 std::queue<PlayerPacket::pointer_t> outgoing_; 00050 00052 Character* charlist_[net::kMaxCharacters]; 00053 00055 std::queue<net::index_t> available_; 00056 00058 CList chars_; 00059 00060 typedef std::vector<Player*> PList; 00062 PList players_; 00063 00064 typedef std::vector<std::tr1::shared_ptr<NPC> > NPCList; 00066 NPCList npcs_; 00067 00068 std::queue<Player*> to_join_; 00069 std::pair<Character*,std::pair<double,double> > to_move_[net::kMaxCharacters]; 00070 00071 PlayerPacket::pointer_t player_packet(Player*); 00072 PlayerPacket::pointer_t demand_player_packet(Player*); 00073 00074 std::string mapname_; 00075 ServerMap map_; 00076 net::maphash_t maphash_; 00077 00078 PathFinder path_finder_; 00079 00080 void send_disconnect(net::index_t); 00081 void send_names(Player*); 00082 void send_positions(Player*); 00083 void send_path_request(Player*,NPC*); 00084 00085 void chat(Player*,const std::string&); 00086 00087 void next_join(); 00088 public: 00089 World(const std::string&); 00090 World(const World&); 00091 const World& operator=(const World&); 00092 00093 void name_changed(Player*); 00094 const PlayerPacket::pointer_t next_outgoing(); 00095 void pop_outgoing(); 00096 void update(double); 00097 void join(Player*); 00098 void disconnect(Player*); 00099 void packet(net::data_t*, size_t, Player*); 00100 00101 net::maphash_t maphash(); 00102 const std::string& mapname(); 00103 bool is_vacant(double,double,Character*) const; 00104 size_t width() const; 00105 size_t height() const; 00106 }; 00107 00108 } 00109 00110 #endif