00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ArmageTron_GAME_H
00029 #define ArmageTron_GAME_H
00030
00031 #include "rSDL.h"
00032
00033 #include "nNetObject.h"
00034
00035 class eSoundMixer;
00036 class eGrid;
00037 class nServerInfo;
00038 class nServerInfoBase;
00039 class eTeam;
00040 class gParser;
00041 class gArena;
00042 class ePlayerNetID;
00043
00044 typedef enum{gFREESTYLE,gDUEL,gHUMAN_VS_AI}
00045 gGameType;
00046
00047
00048 extern bool sg_TalkToMaster;
00049
00050 typedef enum{gFINISH_EXPRESS,gFINISH_IMMEDIATELY,gFINISH_SPEEDUP,gFINISH_NORMAL}
00051 gFinishType;
00052
00053 #ifdef ENABLE_ZONESV2
00054 class zZone;
00055 #else
00056 class gZone;
00057 #endif
00058
00059
00060
00061 class gGame:public nNetObject{
00062 unsigned short state;
00063 unsigned short stateNext;
00064
00065 #ifdef ENABLE_ZONESV2
00066 tJUST_CONTROLLED_PTR< zZone > winDeathZone_;
00067 #else
00068 tJUST_CONTROLLED_PTR< gZone > winDeathZone_;
00069 #endif
00070
00071 bool goon;
00072
00073 int rounds;
00074
00075 double startTime;
00076
00077 int warning;
00078
00079 tCONTROLLED_PTR(eGrid) grid;
00080
00081 bool synced_;
00082
00083 void Init();
00084
00085 gParser *aParser;
00086
00087 public:
00088 gGame();
00089 gGame(nMessage &m);
00090 virtual ~gGame();
00091 virtual void WriteSync(nMessage &m);
00092 virtual void ReadSync(nMessage &m);
00093 virtual nDescriptor &CreatorDescriptor() const;
00094
00095 static void NetSync();
00096 static void NetSyncIdle();
00097
00098 virtual void Verify();
00099
00100 virtual void StateUpdate();
00101
00102
00103 virtual void SetState(unsigned short act,unsigned short next);
00104 virtual short GetState(){return state;}
00105
00106
00107 void SyncState(unsigned short state);
00108
00109 virtual void Timestep(REAL time,bool cam=false);
00110 virtual void Analysis(REAL time);
00111
00112 virtual bool GameLoop(bool input=true);
00113
00114 bool GridIsReady(int c);
00115 eGrid * Grid() const { return grid; }
00116
00117 void NoLongerGoOn();
00118
00119 void StartNewMatch();
00120
00121 void StartNewMatchNow();
00122
00123 eSoundMixer* m_Mixer;
00124 };
00125
00126 void update_settings();
00127
00128 void ConnectToServer(nServerInfoBase *server);
00129
00130 void sg_EnterGame( nNetState enter_state );
00131 void sg_HostGame();
00132 void sg_HostGameMenu();
00133
00134 void MainMenu(bool ingame=false);
00135
00136 bool GridIsReady(int c);
00137
00138 void Activate(bool act);
00139
00140 void sg_DeclareWinner( eTeam* team, char const * message );
00141
00142 void sg_FullscreenMessage(tOutput const & title, tOutput const & message,REAL timeout = 60, int client = 0);
00143 void sg_ClientFullscreenMessage( tOutput const & title, tOutput const & message, REAL timeout = 60 );
00144
00145 void sg_RespawnPlayer(eGrid *grid, gArena *arena, ePlayerNetID *p);
00146
00147
00148 gArena * sg_GetArena();
00149
00150
00151 void init_second_pass_zones(eGrid *grid, gParser *parser);
00152
00153 class gGameSettings
00154 {
00155 public:
00156 int scoreWin;
00157
00158 int limitTime;
00159 int limitRounds;
00160 int limitScore;
00161
00162 int numAIs;
00163 int minPlayers;
00164 int AI_IQ;
00165
00166 bool autoNum;
00167 bool autoIQ;
00168
00169 int speedFactor;
00170 int sizeFactor;
00171
00172 int autoAIFraction;
00173
00174 int winZoneMinRoundTime;
00175 int winZoneMinLastDeath;
00176
00177 gGameType gameType;
00178 gFinishType finishType;
00179
00180
00181 int minTeams, maxTeams;
00182 int minPlayersPerTeam, maxPlayersPerTeam;
00183 int maxTeamImbalance;
00184 bool balanceTeamsWithAIs, enforceTeamRulesOnQuit;
00185
00186
00187 REAL wallsStayUpDelay;
00188 REAL wallsLength;
00189 REAL explosionRadius;
00190
00191 gGameSettings(int a_scoreWin,
00192 int a_limitTime, int a_limitRounds, int a_limitScore,
00193 int a_numAIs, int a_minPlayers, int a_AI_IQ,
00194 bool a_autoNum, bool a_autoIQ,
00195 int a_speedFactor, int a_sizeFactor,
00196 gGameType a_gameType, gFinishType a_finishType,
00197 int a_minTeams,
00198 int a_winZoneMinRoundTime, int a_winZoneMinLastDeath
00199 );
00200
00201 void AutoAI(bool success);
00202 void Menu();
00203 };
00204
00205 extern gGameSettings* sg_currentSettings;
00206
00207 void rotate();
00208
00209
00210 #endif
00211