1 /* 2 3 ************************************************************************* 4 5 ArmageTron -- Just another Tron Lightcycle Game in 3D. 6 Copyright (C) 2000 Manuel Moos (manuel@moosnet.de) 7 8 ************************************************************************** 9 10 This program is free software; you can redistribute it and/or 11 modify it under the terms of the GNU General Public License 12 as published by the Free Software Foundation; either version 2 13 of the License, or (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 23 24 *************************************************************************** 25 26 */ 27 28 #ifndef ArmageTron_GAME_H 29 #define ArmageTron_GAME_H 30 31 #include "rSDL.h" 32 33 #include "nNetObject.h" 34 35 class eGrid; 36 class nServerInfo; 37 class nServerInfoBase; 38 class eTeam; 39 class gParser; 40 41 typedef enum{gFREESTYLE,gDUEL,gHUMAN_VS_AI} 42 gGameType; 43 44 //extern gGameType sg_gameType; // the current game type 45 extern bool sg_TalkToMaster; // should this server be known on the internet? 46 47 typedef enum{gFINISH_EXPRESS,gFINISH_IMMEDIATELY,gFINISH_SPEEDUP,gFINISH_NORMAL} 48 gFinishType; 49 50 class gZone; 51 52 //extern gFinishType sg_finishType; 53 54 class gGame:public nNetObject{ 55 unsigned short state; // the gamestate we are currently in 56 unsigned short stateNext; // if a state change has been requested 57 58 tJUST_CONTROLLED_PTR< gZone > winDeathZone_; // the win zone 59 60 bool goon; 61 62 int rounds; // the number of rounds played 63 64 double startTime; // time of the match start 65 66 int warning; // timeout warnings 67 68 tCONTROLLED_PTR(eGrid) grid; // the grid the game takes place 69 70 bool synced_; //!< flag indicating whether the game is considered synced 71 72 void Init(); 73 74 gParser *aParser; 75 76 public: 77 gGame(); 78 gGame(nMessage &m); 79 virtual ~gGame(); 80 virtual void WriteSync(nMessage &m); 81 virtual void ReadSync(nMessage &m); 82 virtual nDescriptor &CreatorDescriptor() const; 83 84 static void NetSync(); // do all the network syncronisation. 85 static void NetSyncIdle(); // do all the network syncronisation and wait a bit. 86 87 virtual void Verify(); // verifies settings are OK, throws an exception if not. 88 89 virtual void StateUpdate(); // switch to new gamestate (does all 90 // the real work around here). 91 virtual void SetState(unsigned short act,unsigned short next); GetState()92 virtual short GetState(){return state;} 93 94 // make sure the clients are catching up 95 void SyncState(unsigned short state); 96 97 virtual void Timestep(REAL time,bool cam=false); // do all the world simulation 98 virtual void Analysis(REAL time); // do we have a winner? 99 100 virtual bool GameLoop(bool input=true); // return values: exit the game loop? 101 102 bool GridIsReady(int c); // can we transfer gameObjects that need the grid to exist? Grid()103 eGrid * Grid() const { return grid; } 104 105 void NoLongerGoOn(); 106 107 void StartNewMatch(); 108 109 void StartNewMatchNow(); 110 }; 111 112 void update_settings( bool const * goon = 0 ); 113 114 void ConnectToServer(nServerInfoBase *server); 115 116 void sg_EnterGame( nNetState enter_state ); 117 void sg_HostGame(); 118 void sg_HostGameMenu(); 119 120 void MainMenu(bool ingame=false); 121 122 bool GridIsReady(int c); 123 124 void Activate(bool act); 125 126 void sg_DeclareWinner( eTeam* team, char const * message ); 127 128 void sg_FullscreenMessage(tOutput const & title, tOutput const & message,REAL timeout = 60, int client = 0); //!< Displays a message on a specific client or all clients that gets displayed on the whole screen, blocking view to the game 129 void sg_ClientFullscreenMessage( tOutput const & title, tOutput const & message, REAL timeout = 60 ); //!< Displays a message locally that gets displayed on the whole screen, blocking view to the game 130 131 class gGameSettings 132 { 133 public: 134 int scoreWin; // score you get when you win a round 135 136 int limitTime; // match time limit 137 int limitRounds; // match round limit 138 int limitScore; // match score limit 139 140 int numAIs; // number of AI players 141 int minPlayers; // minimum number of players 142 int AI_IQ; // preferred IQ of AI players 143 144 bool autoNum; // automatically adjust number of AIs 145 bool autoIQ; // automatically adjust IQ of AIs 146 147 int speedFactor; // logarithm of cycle speed multiplier 148 int sizeFactor; // logarithm of arena size multiplier 149 150 int autoAIFraction; // helper variable for the autoAI functions 151 152 REAL winZoneMinRoundTime; // minimum number of seconds a round must be going before the win zone is activated 153 REAL winZoneMinLastDeath; // minimum number of seconds the last death happended before the win zone is activated 154 155 gGameType gameType; // what type of game is played? 156 gFinishType finishType; // what happens when all humans are dead? 157 158 // team settings 159 int minTeams, maxTeams; 160 int minPlayersPerTeam, maxPlayersPerTeam; 161 int maxTeamImbalance; 162 bool balanceTeamsWithAIs, enforceTeamRulesOnQuit; 163 164 // game mechanics settings 165 REAL wallsStayUpDelay; // the time the cycle walls stay up ( negative values: they stay up forever ) 166 REAL wallsLength; // the maximum total length of the walls 167 REAL explosionRadius; // the radius of the holes blewn in by an explosion 168 169 gGameSettings(int a_scoreWin, 170 int a_limitTime, int a_limitRounds, int a_limitScore, 171 int a_numAIs, int a_minPlayers, int a_AI_IQ, 172 bool a_autoNum, bool a_autoIQ, 173 int a_speedFactor, int a_sizeFactor, 174 gGameType a_gameType, gFinishType a_finishType, 175 int a_minTeams, 176 REAL a_winZoneMinRoundTime, REAL a_winZoneMinLastDeath 177 ); 178 179 void AutoAI(bool success); 180 void Menu(); 181 }; 182 183 extern gGameSettings* sg_currentSettings; 184 185 #endif 186 187