00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef SESSION_H
00019 #define SESSION_H
00020
00021 #include "constants.h"
00022 #include "userconfiguration.h"
00023 #include "map.h"
00024
00025 #include "party.h"
00026 #include "item.h"
00027 #include "creature.h"
00028 #include "shape.h"
00029 #include "rpg/character.h"
00030 #include "rpg/monster.h"
00031 #include "rpg/rpgitem.h"
00032 #include "rpg/spell.h"
00033 #include "net/server.h"
00034 #include "net/client.h"
00035 #include "net/gamestatehandler.h"
00036 #include "net/commands.h"
00037 #include "gameadapter.h"
00038
00039 using namespace std;
00040
00041 #ifdef HAVE_SDL_NET
00042 class Server;
00043 class Client;
00044 #endif
00045 class Mission;
00046 class Board;
00047 class Party;
00048 class Map;
00049 class Item;
00050 class Creature;
00051 class GameAdapter;
00052 class UserConfiguration;
00053
00058 class Session {
00059 private:
00060 ShapePalette *shapePal;
00061 GameAdapter *adapter;
00062 Party *party;
00063 Map *map;
00064 Board *board;
00065 #ifdef HAVE_SDL_NET
00066 Server *server;
00067 Client *client;
00068 #endif
00069 bool multiplayerGame;
00070 Mission *currentMission;
00071 Item *newItems[500];
00072 Creature *creatures[500];
00073 int itemCount;
00074 int creatureCount;
00075
00076 public:
00077 Session(GameAdapter *adapter);
00078 virtual ~Session();
00079
00080 void initialize();
00081
00082 virtual void start();
00083 virtual void quit(int value);
00084 #ifdef HAVE_SDL_NET
00085 virtual void runClient(char *host, int port, char *userName);
00086 virtual void runServer(int port);
00087 virtual inline Server *getServer() { return server; }
00088 virtual inline Client *getClient() { return client; }
00089 virtual void startServer(GameStateHandler *gsh, int port);
00090 virtual void startClient(GameStateHandler *gsh, CommandInterpreter *ci, char *host, int port, char *username);
00091 virtual void stopClientServer();
00092 #endif
00093
00103 virtual Item *newItem(RpgItem *rpgItem, int level=1, Spell *spell=NULL, bool loading=false);
00104
00114
00115
00124 virtual Creature *newCreature(Monster *monster, GLShape *shape);
00125 virtual void deleteCreaturesAndItems(bool missionItemsOnly=false);
00126 inline bool isMultiPlayerGame() { return multiplayerGame; }
00127 inline void setMultiPlayerGame(bool b) { multiplayerGame = b; }
00128
00129 inline GameAdapter *getGameAdapter() { return adapter; }
00130 inline ShapePalette *getShapePalette() { return shapePal; }
00131 inline Map *getMap() { return map; }
00132 inline Board *getBoard() { return board; }
00133 inline Party *getParty() { return party; }
00134 inline UserConfiguration *getUserConfiguration() { return getGameAdapter()->getUserConfiguration(); }
00135 inline int getCreatureCount() { return creatureCount; }
00136 inline Creature *getCreature(int index) { return creatures[index]; }
00137 inline int getItemCount() { return itemCount; }
00138 inline Item *getItem(int index) { return newItems[index]; }
00139 inline Mission *getCurrentMission() { return currentMission; }
00140 inline void setCurrentMission(Mission *mission) { currentMission = mission; }
00141 inline void playSound(const char *sound) { getGameAdapter()->playSound(sound); }
00142
00143 virtual Creature *getClosestVisibleMonster(int x, int y, int w, int h, int radius);
00144 virtual void creatureDeath(Creature *creature);
00145
00146 protected:
00147 virtual void initData();
00148 };
00149
00150 #endif
00151