src/tron/gGame.h File Reference

#include "rSDL.h"
#include "nNetObject.h"

Include dependency graph for gGame.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  gGame
class  gGameSettings

Enumerations

enum  gGameType { gFREESTYLE, gDUEL, gHUMAN_VS_AI }
enum  gFinishType { gFINISH_EXPRESS, gFINISH_IMMEDIATELY, gFINISH_SPEEDUP, gFINISH_NORMAL }

Functions

void update_settings ()
void ConnectToServer (nServerInfoBase *server)
void sg_EnterGame (nNetState enter_state)
void sg_HostGame ()
void sg_HostGameMenu ()
void MainMenu (bool ingame=false)
bool GridIsReady (int c)
void Activate (bool act)
void sg_DeclareWinner (eTeam *team, char const *message)
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.
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.
void sg_RespawnPlayer (eGrid *grid, gArena *arena, ePlayerNetID *p)
gArenasg_GetArena ()
void init_second_pass_zones (eGrid *grid, gParser *parser)
void rotate ()

Variables

bool sg_TalkToMaster
gGameSettingssg_currentSettings


Enumeration Type Documentation

enum gFinishType

Enumerator:
gFINISH_EXPRESS 
gFINISH_IMMEDIATELY 
gFINISH_SPEEDUP 
gFINISH_NORMAL 

Definition at line 50 of file gGame.h.

enum gGameType

Enumerator:
gFREESTYLE 
gDUEL 
gHUMAN_VS_AI 

Definition at line 44 of file gGame.h.


Function Documentation

void Activate ( bool  act  ) 

Definition at line 4142 of file gGame.cpp.

References ePlayerNetID::ChatFlags_Away, currentScreensetting, rScreenSettings::fullscreen, tRecorderBase::IsRunning(), nSTANDALONE, se_ChatState(), se_PauseGameTimer(), sn_GetNetState(), and sr_Activate().

Referenced by filter().

04144                        {
04145 #ifdef DEBUG
04146     return;
04147 #endif
04148 
04149 // another fullscreen fix ammendmend: avoid the short screen flicker
04150 // by ignoring deactivation events in fullscreen mode completely.
04151 #ifndef WIN32
04152 #ifndef MACOSX
04153     if ( currentScreensetting.fullscreen && !act )
04154     {
04155         return;
04156     }
04157 #endif
04158 #endif
04159 
04160     sr_Activate( act );
04161 
04162     if (!tRecorder::IsRunning() )
04163     {
04164         if (sn_GetNetState()==nSTANDALONE)
04165         {
04166             se_PauseGameTimer(!act);
04167         }
04168 
04169         se_ChatState( ePlayerNetID::ChatFlags_Away, !act);

Here is the call graph for this function:

Here is the caller graph for this function:

void ConnectToServer ( nServerInfoBase server  ) 

Definition at line 1654 of file gGame.cpp.

References ConnectToServerCore(), and sn_GetRedirectTo().

Referenced by gServerFavorite::Connect(), gCommandLineJumpStartAnalyzer::Connect(), and gServerMenuItem::Enter().

01656 {
01657     bool okToRedirect = ConnectToServerCore( server );
01658 
01659     // REAL redirections = 0;
01660     // double lastTime = tSysTimeFloat();
01661 
01662     // check for redirection
01663     while( okToRedirect )
01664     {
01665         std::auto_ptr< nServerInfoBase > redirectTo( sn_GetRedirectTo() );
01666 
01667         // abort loop
01668         if ( !(&(*redirectTo)) )
01669         {
01670             break;
01671         }
01672 
01673         okToRedirect = ConnectToServerCore( redirectTo.get() );
01674 
01675         /*
01676         // redirection spam chain protection, allow one redirection every 30 seconds. Should
01677         // be short enough to allow hacky applications (server-to-server teleport), but
01678         // long enough to allow players to escape via the menu or at least shift-esc.
01679         static const REAL timeout = 30;
01680         static const REAL maxRedirections = 5;
01681 
01682         redirections = redirections + 1;
01683         if ( redirections > maxRedirections )
01684         {
01685             break;
01686         }
01687 
01688         // decay spam protection
01689         double newTime = tSysTimeFloat();
01690         REAL dt = newTime - lastTime;
01691         lastTime = newTime;
01692         redirections *= 1/(1 + dt * maxRedirections * timeout );
01693         */
01694     }

Here is the call graph for this function:

Here is the caller graph for this function:

bool GridIsReady ( int  c  ) 

Definition at line 4129 of file gGame.cpp.

Referenced by gNetPlayerWall::ClearToTransmit().

04131                        {

Here is the caller graph for this function:

void init_second_pass_zones ( eGrid grid,
gParser parser 
)

Referenced by gGame::StateUpdate().

Here is the caller graph for this function:

void MainMenu ( bool  ingame = false  ) 

Definition at line 1959 of file gGame.cpp.

References uMenu::Enter(), GameSettingsCurrent(), GameSettingsSP(), MainMenu(), MAX_PLAYERS, mp, nCLIENT, net_game(), nSTANDALONE, NULL, PlayerLogIn(), ePlayerNetID::PoliceMenu(), ret_to_MainMenu(), se_SoundMenu(), gLogo::SetDisplayed(), rConsole::SetHeight(), tOutput::SetTemplateParameter(), sg_DisplayVersionInfo(), sg_LanguageMenu(), sg_moviepackUse, sg_PlayerMenu(), sg_screenMenu, singlePlayer_game(), sn_GetNetState(), sn_programVersion, sr_con, sr_textOut, StartNewMatch(), su_InputConfigGlobal(), nVersionFeature::Supported(), gTeam::TeamMenu(), tNEW, rViewport::Update(), eVoter::VotingMenu(), eVoter::VotingPossible(), and uMenu::wrap.

Referenced by main(), and MainMenu().

01960                           {
01961     //  update_settings();
01962 
01963     if (ingame)
01964         sr_con.SetHeight(2);
01965 
01966     //gLogo::SetDisplayed(true);
01967 
01968     tOutput gametitle;
01969     if (!ingame)
01970         gametitle << "$game_menu_text";
01971     else
01972         gametitle << "$game_menu_ingame_text";
01973 
01974     uMenu game_menu(gametitle);
01975 
01976     uMenuItemFunction *reset=NULL;
01977 
01978     if (ingame && sn_GetNetState()!=nCLIENT){
01979         reset=new uMenuItemFunction
01980               (&game_menu,"$game_menu_reset_text",
01981                "$game_menu_reset_help",
01982                &StartNewMatch);
01983     }
01984 
01985     uMenuItemFunction *settings1=NULL;
01986 
01987     if (!ingame)
01988         settings1=tNEW(uMenuItemFunction)
01989                   (&game_menu,
01990                    "$game_settings_menu_text",
01991                    "$game_settings_menu_help",
01992                    &GameSettingsSP);
01993     else
01994         settings1=tNEW(uMenuItemFunction)
01995                   (&game_menu,
01996                    "$game_settings_menu_text",
01997                    "$game_settings_menu_help",
01998                    &GameSettingsCurrent);
01999 
02000     uMenuItemFunction *connect=NULL,*start=NULL,*sound=NULL;
02001 
02002     if (!ingame){
02003         connect=new uMenuItemFunction
02004                 (&game_menu,
02005                  "$network_menu_text",
02006                  "$network_menu_help",
02007                  &net_game);
02008 
02009         start= new uMenuItemFunction(&game_menu,"$game_menu_start_text",
02010                                      "$game_menu_start_help",&singlePlayer_game);
02011     }
02012 
02013     tOutput title;
02014     title.SetTemplateParameter( 1, sn_programVersion );
02015     if (!ingame)
02016         title << "$main_menu_text";
02017     else
02018         title << "$ingame_menu_text";
02019 
02020     uMenu MainMenu(title,false);
02021 
02022     if (ingame)
02023         sg_IngameMenu = &MainMenu;
02024 
02025     char const * extitle,* exhelp;
02026     if (!ingame){
02027         extitle="$main_menu_exit_text";
02028         exhelp="$main_menu_exit_help";
02029     }
02030     else{
02031         extitle="$ingame_menu_exit_text";
02032         exhelp="$ingame_menu_exit_help";
02033     }
02034 
02035     uMenuItemExit exx(&MainMenu,extitle,
02036                       exhelp);
02037 
02038     uMenuItemFunction *return_to_main=NULL;
02039     if (ingame){
02040         if (sn_GetNetState()==nSTANDALONE)
02041             return_to_main=new uMenuItemFunction
02042                            (&MainMenu,"$game_menu_exit_text",
02043                             "$game_menu_exit_help",
02044                             &ret_to_MainMenu);
02045         else if (sn_GetNetState()==nCLIENT)
02046             return_to_main=new uMenuItemFunction
02047                            (&MainMenu,"$game_menu_disconnect_text",
02048                             "$game_menu_disconnect_help",
02049                             &ret_to_MainMenu);
02050         else
02051             return_to_main=new uMenuItemFunction
02052                            (&MainMenu,
02053                             "$game_menu_shutdown_text",
02054                             "game_menu_shutdown_help",
02055                             &ret_to_MainMenu);
02056     }
02057 
02058     uMenuItemFunction * auth = 0;
02059     static nVersionFeature authentication( 15 );
02060     if ( sn_GetNetState() == nCLIENT && ingame && authentication.Supported(0) )
02061     {
02062         auth =tNEW(uMenuItemFunction)(&MainMenu,
02063                                       "$player_authenticate_text",
02064                                       "$player_authenticate_help",
02065                                       &PlayerLogIn );
02066     }
02067 
02068     uMenuItemFunction abb(&MainMenu,
02069                           "$main_menu_about_text",
02070                           "$main_menu_about_help",
02071                           &sg_DisplayVersionInfo);
02072 
02073 
02074     uMenu Settings("$system_settings_menu_text");
02075 
02076     uMenuItemSubmenu subm_settings
02077     (&MainMenu,&Settings,
02078      "$system_settings_menu_help");
02079 
02080 
02081     uMenuItem* team = NULL;
02082     if ( ingame )
02083     {
02084         team = tNEW( uMenuItemFunction) ( &MainMenu,
02085                                           "$team_menu_title",
02086                                           "$team_menu_help",
02087                                           &gTeam::TeamMenu );
02088     }
02089 
02090     uMenuItemFunction *se_PlayerMenu=NULL;
02091 
02092     //   if (!ingame)
02093     se_PlayerMenu= new uMenuItemFunction
02094                    (&MainMenu,"$player_mainmenu_text",
02095                     "$player_mainmenu_help",
02096                     &sg_PlayerMenu);
02097 
02098     uMenuItemFunction *player_police=NULL;
02099     uMenuItemFunction *voting=NULL;
02100     if ( ingame && sn_GetNetState() != nSTANDALONE )
02101     {
02102         player_police = tNEW( uMenuItemFunction )( &MainMenu, "$player_police_text", "$player_police_help", ePlayerNetID::PoliceMenu );
02103 
02104         if ( eVoter::VotingPossible() )
02105             voting = tNEW( uMenuItemFunction )( &MainMenu, "$voting_menu_text", "$voting_menu_help", eVoter::VotingMenu );
02106     }
02107 
02108     uMenu misc("$misc_menu_text");
02109 
02110     //  misc.SetCenter(.25);
02111 
02112     uMenuItemFunction language
02113     (&misc,"$language_menu_title",
02114      "$language_menu_help",
02115      &sg_LanguageMenu);
02116 
02117     uMenuItemFunction global_key
02118     (&misc,"$misc_global_key_text",
02119      "$misc_global_key_help",
02120      &su_InputConfigGlobal);
02121 
02122     uMenuItemToggle wrap
02123     (&misc,"$misc_menuwrap_text",
02124      "$misc_menuwrap_help",
02125      uMenu::wrap);
02126 
02127     uMenuItemToggle to2
02128     (&misc,"$misc_textout_text",
02129      "$misc_textout_help",sr_textOut);
02130 
02131 
02132 
02133     uMenuItemToggle mp
02134     (&misc,"$misc_moviepack_text",
02135      "$misc_moviepack_help",sg_moviepackUse);
02136 
02137 
02138     uMenuItemSubmenu misc_sm
02139     (&Settings,&misc,
02140      "$misc_menu_help");
02141 
02142     sound = new uMenuItemFunction
02143             (&Settings,"$sound_menu_text",
02144              "$sound_menu_help",&se_SoundMenu);
02145 
02146     uMenuItemSubmenu subm
02147     (&Settings,&sg_screenMenu,
02148      "$display_settings_menu_help");
02149 
02150     uMenuItemSubmenu *gamemenuitem = NULL;
02151     if (sn_GetNetState() != nCLIENT)
02152     {
02153         char const * gamehelp;
02154         if (!ingame)
02155             gamehelp="$game_menu_main_help";
02156         else
02157             gamehelp="$game_menu_ingame_help";
02158 
02159         gamemenuitem = tNEW(uMenuItemSubmenu) (&MainMenu,
02160                                                &game_menu,
02161                                                gamehelp
02162                                               );
02163     }
02164 
02165     if (!ingame)
02166     {
02167         rViewport::Update(MAX_PLAYERS);
02168         // ePlayerNetID::Update();
02169     }
02170 
02171     MainMenu.Enter();
02172 
02173     if (settings1)
02174         delete settings1;
02175     if (team)
02176         delete team;
02177     if (gamemenuitem)
02178         delete gamemenuitem;
02179     if (sound)
02180         delete sound;
02181     if (connect)
02182         delete connect;
02183     if (start)
02184         delete start;
02185     if (return_to_main)
02186         delete return_to_main;
02187     if (se_PlayerMenu)
02188         delete se_PlayerMenu;
02189     if (reset)
02190         delete reset;
02191     if ( player_police )
02192         delete player_police;
02193     if ( voting )
02194         delete voting;
02195 
02196     if (ingame)
02197         sg_IngameMenu=NULL;
02198 
02199     if (ingame)
02200     {
02201         gLogo::SetDisplayed(false);
02202         sr_con.SetHeight(7);
02203     }
02204 
02205     if ( auth )
02206     {
02207         delete auth;
02208     }

Here is the call graph for this function:

Here is the caller graph for this function:

void rotate (  ) 

Definition at line 3547 of file gGame.cpp.

03550 {
03551     if ( sg_mapRotation.Size() > 0 )
03552     {
03553         conf_mapfile.Set( sg_mapRotation.Current() );
03554         sg_mapRotation.Rotate();
03555     }
03556 
03557     if ( sg_configRotation.Size() > 0 )
03558     {
03559         st_Include( sg_configRotation.Current() );
03560         sg_configRotation.Rotate();

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.

Definition at line 4186 of file gGame.cpp.

Referenced by sg_FullscreenMessage(), and sg_TodoClientFullscreenMessage().

04188                                                                                                {
04189     // keep syncing the network
04190     rPerFrameTask idle( sg_FullscreenIdle );
04191 
04192     // put players into idle mode
04193     ePlayerNetID::SpectateAll();
04194     se_ChatState( ePlayerNetID::ChatFlags_Menu, true );
04195 
04196     // show message
04197     uMenu::Message( title, message, timeout );
04198 
04199     // and print it to the console
04200 #ifndef DEDICATED
04201     con <<  title << "\n" << message << "\n";
04202 #endif
04203 
04204     // get players out of idle mode again
04205     ePlayerNetID::SpectateAll(false);

Here is the caller graph for this function:

void sg_DeclareWinner ( eTeam team,
char const *  message 
)

Definition at line 746 of file gGame.cpp.

References eTeam::TeamID(), winner, wishWinner, and wishWinnerMessage.

Referenced by zEffectorWin::effect(), gBaseZoneHack::OnConquest(), gWinZoneHack::OnEnter(), and gBaseZoneHack::Timestep().

00747 {
00748     if ( team && !winner )
00749     {
00750         wishWinner = team->TeamID() + 1;
00751         wishWinnerMessage = message;
00752     }
00753 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sg_EnterGame ( nNetState  enter_state  ) 

Definition at line 4094 of file gGame.cpp.

Referenced by ConnectToServerCore(), and own_game().

04097 {
04098     try
04099     {
04100         // enter the game
04101         sg_EnterGameCore( enter_state );
04102     }
04103     catch (tException const & e)
04104     {
04105         // cleanup
04106         sg_EnterGameCleanup();
04107 
04108         // inform user of generic errors
04109         tConsole::Message( e.GetName(), e.GetDescription(), 120000 );
04110     }
04111     // again: VC6 does not catch tGenericException with above statement
04112 #ifdef _MSC_VER
04113 #pragma warning ( disable : 4286 )
04114     catch (tGenericException const & e)
04115     {
04116         // cleanup
04117         sg_EnterGameCleanup();
04118 
04119         // inform user of generic errors
04120         tConsole::Message( e.GetName(), e.GetDescription(), 120000 );
04121     }
04122 #endif
04123 
04124     // bounce teams
04125     for ( int i = eTeam::teams.Len()-1; i>=0; --i )
04126     {
04127         tJUST_CONTROLLED_PTR< eTeam > t = eTeam::teams(i);

Here is the caller graph for this function:

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.

Definition at line 4230 of file gGame.cpp.

References c, gameloop_idle(), ePlayerNetID::IsChatting(), GrowingArrayBase::Len(), MAXCLIENTS, gGame::NetSyncIdle(), REAL, se_GameTime(), se_mainGameTimer, se_PauseGameTimer(), se_PlayerNetIDs, sg_ClientFullscreenMessage(), sg_clientFullscreenMessage, sg_FullscreenIdle(), sg_fullscreenMessages, sg_lastChatBreakTime, sn_Connections, sn_ConsoleOut(), eTimer::speed, nVersionFeature::Supported(), and tSysTimeFloat().

Referenced by sg_DisplayVersionInfo().

04232                                                                                                    {
04233     tJUST_CONTROLLED_PTR< nMessage > m=new nMessage(sg_clientFullscreenMessage);
04234     *m << title;
04235     *m << message;
04236     *m << timeout;
04237 
04238     tString complete( title );
04239     complete << "\n" << message << "\n";
04240 
04241     if (client <= 0){
04242         if ( sg_fullscreenMessages.Supported() )
04243             m->BroadCast();
04244         else
04245         {
04246             for (int c = MAXCLIENTS; c > 0; --c)
04247             {
04248                 if ( sn_Connections[c].socket )
04249                 {
04250                     if ( sg_fullscreenMessages.Supported(c) )
04251                         m->Send(c);
04252                     else
04253                         sn_ConsoleOut(complete, c);
04254                 }
04255             }
04256         }
04257 
04258         // display the message locally, waiting for the clients to have seen it
04259         {
04260             // stop the game
04261             bool paused = se_mainGameTimer && se_mainGameTimer->speed < .0001;
04262             se_PauseGameTimer(true);
04263             gGame::NetSyncIdle();
04264 
04265             REAL waitTo = tSysTimeFloat() + timeout;
04266             REAL waitToMin = tSysTimeFloat() + 1.0;
04267             sg_ClientFullscreenMessage( title, message, timeout );
04268 
04269             // wait for players to see it
04270             bool goon = true;
04271             while ( goon && waitTo > tSysTimeFloat() )
04272             {
04273                 sg_FullscreenIdle();
04274                 gameloop_idle();
04275                 if ( se_GameTime() > sg_lastChatBreakTime )
04276                     se_PauseGameTimer(true);
04277 
04278                 // give the clients a second to enter chat state
04279                 if ( tSysTimeFloat() > waitToMin )
04280                 {
04281                     goon = false;
04282                     for ( int i = se_PlayerNetIDs.Len()-1; i>=0; --i )
04283                     {
04284                         ePlayerNetID* player = se_PlayerNetIDs(i);
04285                         if ( player->IsChatting() )
04286                             goon = true;
04287                     }
04288                 }
04289             }
04290 
04291             // continue the game
04292             se_PauseGameTimer(paused);
04293             gGame::NetSyncIdle();
04294         }
04295     }
04296     else
04297     {
04298         if ( sg_fullscreenMessages.Supported(client) )
04299             m->Send(client);
04300         else
04301             sn_ConsoleOut(complete, client);

Here is the call graph for this function:

Here is the caller graph for this function:

gArena* sg_GetArena (  ) 

Definition at line 2936 of file gGame.cpp.

02937                        {
02938     return &Arena;

void sg_HostGame (  ) 

Definition at line 1387 of file gGame.cpp.

References nBasicNetworkSystem::AccessListener(), ePlayerNetID::CompleteRebuild(), con, gServerBrowser::CurrentMaster(), ded_idle, gStats, nSocketListener::Listen(), gGame::NetSyncIdle(), nSERVER, nSTANDALONE, own_game(), uMenu::quickexit, nBasicNetworkSystem::Select(), sg_NumUsers(), sg_TalkToMaster, sg_Timestamp(), sn_BasicNetworkSystem, sn_SetNetState(), sr_Read_stdin(), st_DoToDo(), tAdvanceFrame(), nServerInfo::TellMasterAboutMe(), tNEW, tSysTimeFloat(), and update_settings().

Referenced by main(), and sg_HostGameMenu().

01388                   {
01389     //we'll want to collect stats
01390     gStats = new gStatistics();
01391 
01392     {
01393         // create a game to check map once
01394         tJUST_CONTROLLED_PTR< gGame > game = tNEW(gGame);
01395         game->Verify();
01396     }
01397 
01398     if (sg_TalkToMaster)
01399     {
01400         nServerInfo::TellMasterAboutMe( gServerBrowser::CurrentMaster() );
01401     }
01402 
01403     sn_SetNetState(nSERVER);
01404 
01405     update_settings();
01406     ePlayerNetID::CompleteRebuild();
01407 
01408     tAdvanceFrame();
01409 
01410     //#ifndef DEBUG
01411 #ifdef DEDICATED
01412     static double startTime=tSysTimeFloat();
01413 
01414     if ( sg_NumUsers() == 0)
01415     {
01416         cp();
01417         con << tOutput("$online_activity_napping") << "\n";
01418         sg_Timestamp();
01419 
01420         int counter = -1;
01421 
01422         int numPlayers = 0;
01423 
01424         while (numPlayers == 0 &&
01425                 (ded_idle<.0001 || tSysTimeFloat()<startTime + ded_idle * 3600 ) && !uMenu::quickexit ){
01426             sr_Read_stdin();
01427             st_DoToDo();
01428             gGame::NetSyncIdle();
01429 
01430             sn_BasicNetworkSystem.Select( 1.0f );
01431 
01432             // std::cout the players who are logged in:
01433             numPlayers = sg_NumUsers();
01434             /*
01435                                 for (int i = se_PlayerNetIDs.Len()-1; i>=0; i--)
01436                                         if (se_PlayerNetIDs(i)->IsAuth())
01437                                                 numPlayers++;
01438             */
01439 
01440             if (counter <= 0)
01441             {
01442                 // restart network, just in case we lost the input socket
01443                 sn_BasicNetworkSystem.AccessListener().Listen(false);
01444                 sn_BasicNetworkSystem.AccessListener().Listen(true);
01445                 counter = 50;
01446             }
01447         }
01448 
01449         if (sg_NumUsers() <= 0 && ded_idle>0.0001 &&
01450                 tSysTimeFloat()>= startTime + ded_idle * 3600 )
01451         {
01452             sg_Timestamp();
01453             con << "Server exiting due to DEDICATED_IDLE after " << (tSysTimeFloat() - startTime)/3600 << " hours.\n";
01454             uMenu::quickexit = true;
01455         }
01456     }
01457     cp();
01458 
01459     if (!uMenu::quickexit)
01460 #endif
01461         //#endif
01462         own_game( nSERVER );
01463 
01464     sn_SetNetState(nSTANDALONE);
01465 
01466     // close listening sockets
01467     sn_BasicNetworkSystem.AccessListener().Listen(false);
01468 
01469     //wrap up the stats
01470     delete gStats;

Here is the call graph for this function:

Here is the caller graph for this function:

void sg_HostGameMenu (  ) 

Definition at line 1809 of file gGame.cpp.

References uMenu::Enter(), GameSettingsMP(), gServerBrowser::highPort, gServerBrowser::lowPort, NULL, uMenu::ReverseItems(), uMenu::SetSelected(), sg_HostGame(), sn_serverName, and sn_serverPort.

Referenced by gServerStartMenuItem::Enter().

01810                       {
01811     uMenu net_menu("$network_host_text");
01812 
01813     sg_HostMenu = &net_menu;
01814 
01815     uMenuItemInt port(&net_menu, "$network_host_port_text",
01816                       "$network_host_port_help"
01817                       ,reinterpret_cast<int &>(sn_serverPort), gServerBrowser::lowPort, gServerBrowser::highPort);
01818 
01819     uMenuItemString serverName
01820     (&net_menu,"$network_host_name_text",
01821      "$network_host_name_help",
01822      sn_serverName);
01823 
01824     uMenuItemFunction settings1
01825     (&net_menu,
01826      "$game_settings_menu_text",
01827      "$game_settings_menu_help",
01828      &GameSettingsMP);
01829 
01830     uMenuItemFunction serv
01831     (&net_menu,"$network_host_host_text",
01832      "$network_host_host_help",&sg_HostGame);
01833 
01834     net_menu.ReverseItems();
01835     net_menu.SetSelected(0);
01836     net_menu.Enter();
01837 
01838     sg_HostMenu = NULL;

Here is the call graph for this function:

Here is the caller graph for this function:

void sg_RespawnPlayer ( eGrid grid,
gArena arena,
ePlayerNetID p 
)

Definition at line 2905 of file gGame.cpp.

References eGameObject::Alive(), eWallRim::Bound(), ePlayerNetID::ControlObject(), eGameObject::Direction(), eCoord, gArena::LeastDangerousSpawnPoint(), nCLIENT, ePlayerNetID::Object(), pos, eGameObject::Position(), sg_Timestamp(), sn_GetNetState(), and gSpawnPoint::Spawn().

Referenced by zEffectorSpawnPlayer::effect().

02907 {
02908     eGameObject *e=p->Object();
02909 
02910     if ( ( !e || !e->Alive()) && sn_GetNetState() != nCLIENT )
02911     {
02912         eCoord pos,dir;
02913         if ( e )
02914         {
02915             dir = e->Direction();
02916             pos = e->Position();
02917             eWallRim::Bound( pos, 1 );
02918             eCoord displacement = pos - e->Position();
02919             if ( displacement.NormSquared() > .01 )
02920             {
02921                 dir = displacement;
02922                 dir.Normalize();
02923             }
02924         }
02925         else
02926             arena->LeastDangerousSpawnPoint()->Spawn( pos, dir );
02927 #ifdef DEBUG
02928         //                std::cout << "spawning player " << pni->name << '\n';
02929 #endif
02930         gCycle * cycle = new gCycle(grid, pos, dir, p);
02931         p->ControlObject(cycle);
02932 
02933         sg_Timestamp();
02934     }

Here is the call graph for this function:

Here is the caller graph for this function:

void update_settings (  ) 

Definition at line 903 of file gGame.cpp.

References nMachine::KickSpectators(), multiPlayer, nCLIENT, gGame::NetSyncIdle(), gGame::NoLongerGoOn(), nSTANDALONE, nAuthentication::OnBreak(), REAL, ePlayerNetID::RemoveChatbots(), nBasicNetworkSystem::Select(), sg_copySettings(), sg_NumHumans(), sg_NumUsers(), sg_singlePlayer, singlePlayer, sn_BasicNetworkSystem, sn_CenterMessage(), sn_ConsoleOut(), sn_GetNetState(), sr_Read_stdin(), st_DoToDo(), gGame::StartNewMatch(), eTeam::teams, and tSysTimeFloat().

Referenced by gParser::parseSettings(), sg_HostGame(), singlePlayer_game(), and gGame::StateUpdate().

00904 {
00905     if (sn_GetNetState()!=nCLIENT)
00906     {
00907 #ifdef DEDICATED
00908         // wait for players to join
00909         {
00910             bool restarted = false;
00911 
00912             REAL timeout = tSysTimeFloat() + 3.0f;
00913             while ( sg_NumHumans() <= 0 && sg_NumUsers() > 0 )
00914             {
00915                 if ( !restarted && bool(sg_currentGame) )
00916                 {
00917                     sg_currentGame->StartNewMatch();
00918                     restarted = true;
00919                 }
00920 
00921                 if ( tSysTimeFloat() > timeout )
00922                 {
00923                     tOutput o("$gamestate_wait_players");
00924                     sn_CenterMessage(o);
00925 
00926                     tOutput o2("$gamestate_wait_players_con");
00927                     sn_ConsoleOut(o2);
00928 
00929                     timeout = tSysTimeFloat() + 10.0f;
00930 
00931                     // do tasks
00932                     st_DoToDo();
00933                     nAuthentication::OnBreak();
00934                 }
00935 
00936                 // kick spectators and chatbots
00937                 nMachine::KickSpectators();
00938                 ePlayerNetID::RemoveChatbots();
00939 
00940                 // wait for network messages
00941                 sn_BasicNetworkSystem.Select( 0.1f );
00942                 gGame::NetSyncIdle();
00943 
00944                 // handle console input
00945                 sr_Read_stdin();
00946             }
00947         }
00948 
00949         if ( sg_NumUsers() <= 0 && bool( sg_currentGame ) )
00950         {
00951             sg_currentGame->NoLongerGoOn();
00952         }
00953 
00954         // count the active players
00955         int humans = sg_NumHumans();
00956 
00957         bool newsg_singlePlayer = (humans<=1);
00958 #else
00959         bool newsg_singlePlayer = (sn_GetNetState() == nSTANDALONE);
00960 #endif
00961         if (sg_singlePlayer != newsg_singlePlayer && bool( sg_currentGame ) )
00962         {
00963             sg_currentGame->StartNewMatch();
00964         }
00965         sg_singlePlayer=newsg_singlePlayer;
00966 
00967         if (sg_singlePlayer)
00968             sg_currentSettings = &singlePlayer;
00969         else
00970             sg_currentSettings = &multiPlayer;
00971 
00972         sg_copySettings();
00973     }
00974 
00975     // update team properties
00976     for (int i = eTeam::teams.Len() - 1; i>=0; --i)
00977         eTeam::teams(i)->UpdateProperties();
00978 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

gGameSettings* sg_currentSettings

Definition at line 645 of file gGame.cpp.

Referenced by gCamera::MyInit().

bool sg_TalkToMaster

Definition at line 730 of file gGame.cpp.

Referenced by gServerBrowser::BrowseLAN(), gServerBrowser::BrowseSpecialMaster(), and sg_HostGame().


Generated on Sat Mar 15 23:17:07 2008 for Armagetron Advanced by  doxygen 1.5.4