src/tron/gGame.h

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
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 //extern gGameType sg_gameType;      // the current game type
00048 extern bool      sg_TalkToMaster;  // should this server be known on the internet?
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 //extern gFinishType sg_finishType;
00060 
00061 class gGame:public nNetObject{
00062     unsigned short state;      // the gamestate we are currently in
00063     unsigned short stateNext; // if a state change has been requested
00064 
00065 #ifdef ENABLE_ZONESV2
00066     tJUST_CONTROLLED_PTR< zZone > winDeathZone_; // the win zone
00067 #else
00068     tJUST_CONTROLLED_PTR< gZone > winDeathZone_; // the win zone
00069 #endif
00070 
00071     bool goon;
00072 
00073     int rounds; // the number of rounds played
00074 
00075     double startTime; // time of the match start
00076 
00077     int warning; // timeout warnings
00078 
00079     tCONTROLLED_PTR(eGrid) grid;  // the grid the game takes place
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(); // do all the network syncronisation.
00096     static void NetSyncIdle(); // do all the network syncronisation and wait a bit.
00097 
00098     virtual void Verify(); // verifies settings are OK, throws an exception if not.
00099 
00100     virtual void StateUpdate(); // switch to new gamestate (does all
00101 
00102     // the real work around here).
00103     virtual void  SetState(unsigned short act,unsigned short next);
00104     virtual short GetState(){return state;}
00105 
00106     // make sure the clients are catching up
00107     void SyncState(unsigned short state);
00108 
00109     virtual void Timestep(REAL time,bool cam=false); // do all the world simulation
00110     virtual void Analysis(REAL time); // do we have a winner?
00111 
00112     virtual bool GameLoop(bool input=true); // return values: exit the game loop?
00113 
00114     bool GridIsReady(int c); // can we transfer gameObjects that need the grid to exist?
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 // HACK
00148 gArena * sg_GetArena();
00149 // END OF HACK
00150 
00151 void init_second_pass_zones(eGrid *grid, gParser *parser);
00152 
00153 class gGameSettings
00154 {
00155 public:
00156     int scoreWin;    // score you get when you win a round
00157 
00158     int limitTime;   // match time limit
00159     int limitRounds; // match round limit
00160     int limitScore;  // match score limit
00161 
00162     int numAIs;      // number of AI players
00163     int minPlayers;  // minimum number of players
00164     int AI_IQ;       // preferred IQ of AI players
00165 
00166     bool autoNum;    // automatically adjust number of AIs
00167     bool autoIQ;     // automatically adjust IQ of AIs
00168 
00169     int  speedFactor; // logarithm of cycle speed multiplier
00170     int  sizeFactor;  // logarithm of arena size multiplier
00171 
00172     int  autoAIFraction; // helper variable for the autoAI functions
00173 
00174     int  winZoneMinRoundTime;   // minimum number of seconds a round must be going before the win zone is activated
00175     int  winZoneMinLastDeath;   // minimum number of seconds the last death happended before the win zone is activated
00176 
00177     gGameType   gameType;      // what type of game is played?
00178     gFinishType finishType;    // what happens when all humans are dead?
00179 
00180     // team settings
00181     int                 minTeams, maxTeams;
00182     int                 minPlayersPerTeam, maxPlayersPerTeam;
00183     int                 maxTeamImbalance;
00184     bool                balanceTeamsWithAIs, enforceTeamRulesOnQuit;
00185 
00186     // game mechanics settings
00187     REAL                wallsStayUpDelay;       // the time the cycle walls stay up ( negative values: they stay up forever )
00188     REAL                wallsLength;            // the maximum total length of the walls
00189     REAL                explosionRadius;        // the radius of the holes blewn in by an explosion
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 

Generated on Sat Mar 15 22:56:08 2008 for Armagetron Advanced by  doxygen 1.5.4