2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #ifndef __SESSIONLOCAL_H__
30 #define __SESSIONLOCAL_H__
34 IsConnectedToServer();
37 IsPlayingRenderDemo();
39 if connected to a server
46 else if playing render demo
62 operator int() const { return timeStamp; }
68 idDict userInfo[MAX_ASYNC_CLIENTS];
69 idDict persistentPlayerInfo[MAX_ASYNC_CLIENTS];
70 usercmd_t mapSpawnUsercmd[MAX_ASYNC_CLIENTS]; // needed for tracking delta angles
79 const int USERCMD_PER_DEMO_FRAME = 2;
80 const int CONNECT_TRANSMIT_TIME = 1000;
81 const int MAX_LOGGED_USERCMDS = 60*60*60; // one hour of single player, 15 minutes of four player
83 class idSessionLocal : public idSession {
87 virtual ~idSessionLocal();
91 virtual void Shutdown();
95 virtual void UpdateScreen( bool outOfSequence = true );
97 virtual void PacifierUpdate();
101 virtual bool IsMultiplayer();
103 virtual bool ProcessEvent( const sysEvent_t *event );
105 virtual void StartMenu( bool playIntro = false );
106 virtual void ExitMenu();
107 virtual void GuiFrameEvents();
108 virtual void SetGUI( idUserInterface *gui, HandleGuiCommand_t handle );
110 virtual const char *MessageBox( msgBoxType_t type, const char *message, const char *title = NULL, bool wait = false, const char *fire_yes = NULL, const char *fire_no = NULL, bool network = false );
111 virtual void StopBox( void );
112 virtual void DownloadProgressBox( backgroundDownload_t *bgl, const char *title, int progress_start = 0, int progress_end = 100 );
113 virtual void SetPlayingSoundWorld();
115 virtual void TimeHitch( int msec );
117 virtual void ReadCDKey( void );
118 virtual void WriteCDKey( void );
119 virtual const char *GetCDKey( bool xp );
120 virtual bool CheckKey( const char *key, bool netConnect, bool offline_valid[ 2 ] );
121 virtual bool CDKeysAreValid( bool strict );
122 virtual void ClearCDKey( bool valid[ 2 ] );
123 virtual void SetCDKeyGuiVars( void );
124 virtual bool WaitingForGameAuth( void );
125 virtual void CDKeysAuthReply( bool valid, const char *auth_msg );
127 virtual int GetSaveGameVersion( void );
129 virtual const char *GetCurrentMapName();
131 //=====================================
133 int GetLocalClientNum();
135 void MoveToNewMap( const char *mapName );
137 // loads a map and starts a new game on it
138 void StartNewGame( const char *mapName, bool devmap = false );
141 void LoadSession( const char *name );
142 void SaveSession( const char *name );
144 // called by Draw when the scene to scene wipe is still running
145 void DrawWipeModel();
146 void StartWipe( const char *materialName, bool hold = false);
150 void ShowLoadingGui();
152 void ScrubSaveGameFileName( idStr &saveFileName ) const;
153 idStr GetAutoSaveName( const char *mapName ) const;
155 bool LoadGame(const char *saveName);
156 bool SaveGame(const char *saveName, bool autosave = false);
158 const char *GetAuthMsg( void );
160 //=====================================
162 static idCVar com_showAngles;
163 static idCVar com_showTics;
164 static idCVar com_minTics;
165 static idCVar com_fixedTic;
166 static idCVar com_showDemo;
167 static idCVar com_skipGameDraw;
168 static idCVar com_aviDemoWidth;
169 static idCVar com_aviDemoHeight;
170 static idCVar com_aviDemoSamples;
171 static idCVar com_aviDemoTics;
172 static idCVar com_wipeSeconds;
173 static idCVar com_guid;
175 static idCVar gui_configServerRate;
180 idSoundWorld * menuSoundWorld; // so the game soundWorld can be muted
182 bool insideExecuteMapChange; // draw loading screen and update
184 int bytesNeededForMapLoad; //
186 // we don't want to redraw the loading screen for every single
187 // console print that happens
188 int lastPacifierTime;
190 // this is the information required to be set before ExecuteMapChange() is called,
191 // which can be saved off at any time with the following commands so it can all be played back
192 mapSpawnData_t mapSpawnData;
193 idStr currentMapName; // for checking reload on same level
194 bool mapSpawned; // cleared on Stop()
196 int numClients; // from serverInfo
199 logCmd_t loggedUsercmds[MAX_LOGGED_USERCMDS];
201 logStats_t loggedStats[MAX_LOGGED_STATS];
203 // each game tic, numClients usercmds will be added, until full
205 bool insideUpdateScreen; // true while inside ::UpdateScreen()
207 bool loadingSaveGame; // currently loading map from a SaveGame
208 idFile * savegameFile; // this is the savegame file to load from
211 idFile * cmdDemoFile; // if non-zero, we are reading commands from a file
213 int latchedTicNumber; // set to com_ticNumber each frame
214 int lastGameTic; // while latchedTicNumber > lastGameTic, run game frames
216 bool syncNextGameFrame;
219 bool aviCaptureMode; // if true, screenshots will be taken and sound captured
220 idStr aviDemoShortName; //
221 float aviDemoFrameCount;
225 int timeDemoStartTime;
226 int numDemoFrames; // for timeDemo and demoShot
228 renderView_t currentDemoRenderView;
229 // the next one will be read when
230 // com_frameTime + demoTimeOffset > currentDemoRenderView.
232 // TODO: make this private (after sync networking removal and idnet tweaks)
233 idUserInterface * guiActive;
234 HandleGuiCommand_t guiHandle;
236 idUserInterface * guiInGame;
237 idUserInterface * guiMainMenu;
238 idListGUI * guiMainMenu_MapList; // easy map list handling
239 idUserInterface * guiRestartMenu;
240 idUserInterface * guiLoading;
241 idUserInterface * guiIntro;
242 idUserInterface * guiGameOver;
243 idUserInterface * guiTest;
244 idUserInterface * guiTakeNotes;
246 idUserInterface * guiMsg;
247 idUserInterface * guiMsgRestore; // store the calling GUI for restore
248 idStr msgFireBack[ 2 ];
251 bool msgIgnoreButtons;
255 const idMaterial * whiteMaterial;
257 const idMaterial * wipeMaterial;
263 int emptyDrawCount; // watchdog to force the main menu to restart
266 //=====================================
272 void WriteCmdDemo( const char *name, bool save = false);
273 void StartPlayingCmdDemo( const char *demoName);
274 void TimeCmdDemo( const char *demoName);
275 void SaveCmdDemoToFile(idFile *file);
276 void LoadCmdDemoFromFile(idFile *file);
277 void StartRecordingRenderDemo( const char *name );
278 void StopRecordingRenderDemo();
279 void StartPlayingRenderDemo( idStr name );
280 void StopPlayingRenderDemo();
281 void CompressDemoFile( const char *scheme, const char *name );
282 void TimeRenderDemo( const char *name, bool twice = false );
283 void AVIRenderDemo( const char *name );
284 void AVICmdDemo( const char *name );
285 void AVIGame( const char *name );
286 void BeginAVICapture( const char *name );
287 void EndAVICapture();
289 void AdvanceRenderDemo( bool singleFrameOnly );
292 void FinishCmdLoad();
293 void LoadLoadingGui(const char *mapName);
295 void DemoShot( const char *name );
297 void TestGUI( const char *name );
299 int GetBytesNeededForMapLoad( const char *mapName );
300 void SetBytesNeededForMapLoad( const char *mapName, int bytesNeeded );
302 void ExecuteMapChange( bool noFadeWipe = false );
305 // return true if we actually waiting on an auth reply
306 bool MaybeWaitOnCDKey( void );
311 idStrList loadGameList;
314 idUserInterface * GetActiveMenu();
316 void DispatchCommand( idUserInterface *gui, const char *menuCommand, bool doIngame = true );
317 void MenuEvent( const sysEvent_t *event );
318 bool HandleSaveGameMenuCommand( idCmdArgs &args, int &icmd );
319 void HandleInGameCommands( const char *menuCommand );
320 void HandleMainMenuCommands( const char *menuCommand );
321 void HandleChatMenuCommands( const char *menuCommand );
322 void HandleIntroMenuCommands( const char *menuCommand );
323 void HandleRestartMenuCommands( const char *menuCommand );
324 void HandleMsgCommands( const char *menuCommand );
325 void HandleNoteCommands( const char *menuCommand );
326 void GetSaveGameList( idStrList &fileList, idList<fileTIME_T> &fileTimes );
327 void TakeNotes( const char * p, bool extended = false );
328 void UpdateMPLevelShot( void );
330 void SetSaveGameGuiVars( void );
331 void SetMainMenuGuiVars( void );
332 void SetModsMenuGuiVars( void );
333 void SetMainMenuSkin( void );
334 void SetPbMenuGuiVars( void );
337 bool BoxDialogSanityCheck( void );
338 void EmitGameAuth( void );
341 CDKEY_UNKNOWN, // need to perform checks on the key
342 CDKEY_INVALID, // that key is wrong
344 CDKEY_CHECKING, // sent a check request ( gameAuth only )
345 CDKEY_NA // does not apply, xp key when xp is not present
348 static const int CDKEY_BUF_LEN = 17;
349 static const int CDKEY_AUTH_TIMEOUT = 5000;
351 char cdkey[ CDKEY_BUF_LEN ];
352 cdKeyState_t cdkey_state;
353 char xpkey[ CDKEY_BUF_LEN ];
354 cdKeyState_t xpkey_state;
361 extern idSessionLocal sessLocal;
363 #endif /* !__SESSIONLOCAL_H__ */