doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Session_local.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
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.
13 
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.
18 
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/>.
21 
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.
23 
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.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __SESSIONLOCAL_H__
30 #define __SESSIONLOCAL_H__
31 
32 /*
33 
34 IsConnectedToServer();
35 IsGameLoaded();
36 IsGuiActive();
37 IsPlayingRenderDemo();
38 
39 if connected to a server
40  if handshaking
41  if map loading
42  if in game
43 else if a game loaded
44  if in load game menu
45  if main menu up
46 else if playing render demo
47 else
48  if error dialog
49  full console
50 
51 */
52 
53 typedef struct {
56 } logCmd_t;
57 
58 struct fileTIME_T {
59  int index;
60  ID_TIME_T timeStamp;
61 
62  operator int() const { return timeStamp; }
63 };
64 
65 typedef struct {
69  idDict persistentPlayerInfo[MAX_ASYNC_CLIENTS];
70  usercmd_t mapSpawnUsercmd[MAX_ASYNC_CLIENTS]; // needed for tracking delta angles
72 
73 typedef enum {
77 } timeDemo_t;
78 
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
82 
83 class idSessionLocal : public idSession {
84 public:
85 
87  virtual ~idSessionLocal();
88 
89  virtual void Init();
90 
91  virtual void Shutdown();
92 
93  virtual void Stop();
94 
95  virtual void UpdateScreen( bool outOfSequence = true );
96 
97  virtual void PacifierUpdate();
98 
99  virtual void Frame();
100 
101  virtual bool IsMultiplayer();
102 
103  virtual bool ProcessEvent( const sysEvent_t *event );
104 
105  virtual void StartMenu( bool playIntro = false );
106  virtual void ExitMenu();
107  virtual void GuiFrameEvents();
108  virtual void SetGUI( idUserInterface *gui, HandleGuiCommand_t handle );
109 
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();
114 
115  virtual void TimeHitch( int msec );
116 
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 );
126 
127  virtual int GetSaveGameVersion( void );
128 
129  virtual const char *GetCurrentMapName();
130 
131  //=====================================
132 
133  int GetLocalClientNum();
134 
135  void MoveToNewMap( const char *mapName );
136 
137  // loads a map and starts a new game on it
138  void StartNewGame( const char *mapName, bool devmap = false );
139  void PlayIntroGui();
140 
141  void LoadSession( const char *name );
142  void SaveSession( const char *name );
143 
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);
147  void CompleteWipe();
148  void ClearWipe();
149 
150  void ShowLoadingGui();
151 
152  void ScrubSaveGameFileName( idStr &saveFileName ) const;
153  idStr GetAutoSaveName( const char *mapName ) const;
154 
155  bool LoadGame(const char *saveName);
156  bool SaveGame(const char *saveName, bool autosave = false);
157 
158  const char *GetAuthMsg( void );
159 
160  //=====================================
161 
173  static idCVar com_guid;
174 
176 
178 
180  idSoundWorld * menuSoundWorld; // so the game soundWorld can be muted
181 
182  bool insideExecuteMapChange; // draw loading screen and update
183  // screen on prints
185 
186  // we don't want to redraw the loading screen for every single
187  // console print that happens
189 
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
193  idStr currentMapName; // for checking reload on same level
194  bool mapSpawned; // cleared on Stop()
195 
196  int numClients; // from serverInfo
197 
198  int logIndex;
201  logStats_t loggedStats[MAX_LOGGED_STATS];
203  // each game tic, numClients usercmds will be added, until full
204 
205  bool insideUpdateScreen; // true while inside ::UpdateScreen()
206 
207  bool loadingSaveGame; // currently loading map from a SaveGame
208  idFile * savegameFile; // this is the savegame file to load from
210 
211  idFile * cmdDemoFile; // if non-zero, we are reading commands from a file
212 
213  int latchedTicNumber; // set to com_ticNumber each frame
214  int lastGameTic; // while latchedTicNumber > lastGameTic, run game frames
217 
218 
219  bool aviCaptureMode; // if true, screenshots will be taken and sound captured
223 
226  int numDemoFrames; // for timeDemo and demoShot
229  // the next one will be read when
230  // com_frameTime + demoTimeOffset > currentDemoRenderView.
231 
232  // TODO: make this private (after sync networking removal and idnet tweaks)
235 
238  idListGUI * guiMainMenu_MapList; // easy map list handling
245 
247  idUserInterface * guiMsgRestore; // store the calling GUI for restore
252 
254 
256 
260  bool wipeHold;
261 
262 #if ID_CONSOLE_LOCK
263  int emptyDrawCount; // watchdog to force the main menu to restart
264 #endif
265 
266  //=====================================
267  void Clear();
268 
269  void DrawCmdGraph();
270  void Draw();
271 
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 );
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();
288 
289  void AdvanceRenderDemo( bool singleFrameOnly );
290  void RunGameTic();
291 
292  void FinishCmdLoad();
293  void LoadLoadingGui(const char *mapName);
294 
295  void DemoShot( const char *name );
296 
297  void TestGUI( const char *name );
298 
299  int GetBytesNeededForMapLoad( const char *mapName );
300  void SetBytesNeededForMapLoad( const char *mapName, int bytesNeeded );
301 
302  void ExecuteMapChange( bool noFadeWipe = false );
303  void UnloadMap();
304 
305  // return true if we actually waiting on an auth reply
306  bool MaybeWaitOnCDKey( void );
307 
308  //------------------
309  // Session_menu.cpp
310 
313 
315 
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 );
329 
330  void SetSaveGameGuiVars( void );
331  void SetMainMenuGuiVars( void );
332  void SetModsMenuGuiVars( void );
333  void SetMainMenuSkin( void );
334  void SetPbMenuGuiVars( void );
335 
336 private:
337  bool BoxDialogSanityCheck( void );
338  void EmitGameAuth( void );
339 
340  typedef enum {
341  CDKEY_UNKNOWN, // need to perform checks on the key
342  CDKEY_INVALID, // that key is wrong
343  CDKEY_OK, // valid
344  CDKEY_CHECKING, // sent a check request ( gameAuth only )
345  CDKEY_NA // does not apply, xp key when xp is not present
346  } cdKeyState_t;
347 
348  static const int CDKEY_BUF_LEN = 17;
349  static const int CDKEY_AUTH_TIMEOUT = 5000;
350 
357 
359 };
360 
362 
363 #endif /* !__SESSIONLOCAL_H__ */
void DrawCmdGraph()
Definition: Session.cpp:2311
float aviDemoFrameCount
void StartRecordingRenderDemo(const char *name)
Definition: Session.cpp:786
const int MAX_ASYNC_CLIENTS
Definition: AsyncNetwork.h:44
char xpkey[CDKEY_BUF_LEN]
void HandleRestartMenuCommands(const char *menuCommand)
void SetBytesNeededForMapLoad(const char *mapName, int bytesNeeded)
Definition: Session.cpp:1481
void StartPlayingRenderDemo(idStr name)
Definition: Session.cpp:903
idStr GetAutoSaveName(const char *mapName) const
Definition: Session.cpp:1208
void FinishCmdLoad()
Definition: Session.cpp:1329
void AdvanceRenderDemo(bool singleFrameOnly)
Definition: Session.cpp:2241
void GetSaveGameList(idStrList &fileList, idList< fileTIME_T > &fileTimes)
renderView_t currentDemoRenderView
static idCVar com_aviDemoTics
idFile * cmdDemoFile
virtual bool CDKeysAreValid(bool strict)
Definition: Session.cpp:3205
void AVICmdDemo(const char *name)
Definition: Session.cpp:1058
virtual const char * GetCurrentMapName()
Definition: Session.cpp:3304
const int USERCMD_PER_DEMO_FRAME
Definition: Session_local.h:79
void ScrubSaveGameFileName(idStr &saveFileName) const
Definition: Session.cpp:1863
void ShowLoadingGui()
Definition: Session.cpp:506
void DrawWipeModel()
Definition: Session.cpp:2220
void TakeNotes(const char *p, bool extended=false)
Definition: Session.cpp:1790
void WriteCmdDemo(const char *name, bool save=false)
Definition: Session.cpp:1284
static idCVar com_showDemo
idUserInterface * guiMsg
void TestGUI(const char *name)
Definition: Session.cpp:559
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)
virtual void WriteCDKey(void)
Definition: Session.cpp:3024
void StartWipe(const char *materialName, bool hold=false)
Definition: Session.cpp:463
static const int CDKEY_AUTH_TIMEOUT
void MenuEvent(const sysEvent_t *event)
case const int
Definition: Callbacks.cpp:52
void TimeCmdDemo(const char *demoName)
Definition: Session.cpp:1373
static idCVar com_guid
virtual void Frame()
Definition: Session.cpp:2514
virtual void ClearCDKey(bool valid[2])
Definition: Session.cpp:3057
virtual ~idSessionLocal()
Definition: Session.cpp:369
timeDemo_t
Definition: Session_local.h:73
const idMaterial * wipeMaterial
virtual void PacifierUpdate()
Definition: Session.cpp:2332
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
static idCVar com_showTics
virtual void ExitMenu()
idSessionLocal sessLocal
Definition: Session.cpp:47
void BeginAVICapture(const char *name)
Definition: Session.cpp:996
idStrList loadGameList
void UpdateMPLevelShot(void)
HandleGuiCommand_t guiHandle
const idMaterial * whiteMaterial
const char * GetAuthMsg(void)
Definition: Session.cpp:3322
cdKeyState_t xpkey_state
idSoundWorld * menuSoundWorld
void MoveToNewMap(const char *mapName)
Definition: Session.cpp:1225
static idCVar com_wipeSeconds
idUserInterface * guiTest
Definition: File.h:50
bool insideExecuteMapChange
void StartPlayingCmdDemo(const char *demoName)
Definition: Session.cpp:1337
void LoadCmdDemoFromFile(idFile *file)
Definition: Session.cpp:1265
bool MaybeWaitOnCDKey(void)
Definition: Session.cpp:209
const int CONNECT_TRANSMIT_TIME
Definition: Session_local.h:80
bool BoxDialogSanityCheck(void)
void EndAVICapture()
Definition: Session.cpp:1010
void CompressDemoFile(const char *scheme, const char *name)
Definition: Session.cpp:1097
idListGUI * guiMainMenu_MapList
void LoadSession(const char *name)
idStrList modsList
idStr msgFireBack[2]
void SetMainMenuGuiVars(void)
virtual const char * GetCDKey(bool xp)
Definition: Session.cpp:3079
void DispatchCommand(idUserInterface *gui, const char *menuCommand, bool doIngame=true)
void SetSaveGameGuiVars(void)
virtual void ReadCDKey(void)
Definition: Session.cpp:2985
virtual void Stop()
Definition: Session.cpp:379
idFile * savegameFile
idUserInterface * guiActive
idUserInterface * guiTakeNotes
void StartNewGame(const char *mapName, bool devmap=false)
Definition: Session.cpp:1150
Definition: Dict.h:65
#define NULL
Definition: Lib.h:88
void HandleMsgCommands(const char *menuCommand)
int consistencyHash
Definition: Session_local.h:55
void StopRecordingRenderDemo()
Definition: Session.cpp:823
void EmitGameAuth(void)
Definition: Session.cpp:3098
static const int CDKEY_BUF_LEN
void DemoShot(const char *name)
Definition: Session.cpp:889
virtual bool ProcessEvent(const sysEvent_t *event)
Definition: Session.cpp:2152
void HandleChatMenuCommands(const char *menuCommand)
timeDemo_t timeDemo
virtual void DownloadProgressBox(backgroundDownload_t *bgl, const char *title, int progress_start=0, int progress_end=100)
void HandleInGameCommands(const char *menuCommand)
static idCVar com_aviDemoSamples
idStr aviDemoShortName
void StopPlayingRenderDemo()
Definition: Session.cpp:844
static idCVar com_showAngles
virtual void SetPlayingSoundWorld()
Definition: Session.cpp:2960
void SetMainMenuSkin(void)
void ExecuteMapChange(bool noFadeWipe=false)
Definition: Session.cpp:1515
void SaveCmdDemoToFile(idFile *file)
Definition: Session.cpp:1243
usercmd_t cmd
Definition: Session_local.h:54
virtual void StartMenu(bool playIntro=false)
virtual void Init()
Definition: Session.cpp:2847
msgBoxType_t
Definition: Session.h:50
mapSpawnData_t mapSpawnData
idUserInterface * guiIntro
void TimeRenderDemo(const char *name, bool twice=false)
Definition: Session.cpp:960
idUserInterface * GetActiveMenu()
static idCVar gui_configServerRate
void LoadLoadingGui(const char *mapName)
Definition: Session.cpp:1438
virtual void Shutdown()
Definition: Session.cpp:407
void Clear()
Definition: Session.cpp:297
virtual void StopBox(void)
idDict syncedCVars
Definition: Session_local.h:67
virtual void GuiFrameEvents()
void ClearWipe()
Definition: Session.cpp:539
idUserInterface * guiMainMenu
logStats_t loggedStats[MAX_LOGGED_STATS]
virtual void UpdateScreen(bool outOfSequence=true)
Definition: Session.cpp:2471
const char *(* HandleGuiCommand_t)(const char *)
Definition: Session.h:61
virtual void SetGUI(idUserInterface *gui, HandleGuiCommand_t handle)
static idCVar com_aviDemoHeight
idUserInterface * guiGameOver
bool LoadGame(const char *saveName)
Definition: Session.cpp:2040
void AVIRenderDemo(const char *name)
Definition: Session.cpp:1038
const GLcharARB * name
Definition: glext.h:3629
void SaveSession(const char *name)
const int MAX_LOGGED_USERCMDS
Definition: Session_local.h:81
Definition: Str.h:116
void HandleIntroMenuCommands(const char *menuCommand)
static idCVar com_fixedTic
virtual void SetCDKeyGuiVars(void)
void CompleteWipe()
Definition: Session.cpp:486
bool HandleSaveGameMenuCommand(idCmdArgs &args, int &icmd)
void AVIGame(const char *name)
Definition: Session.cpp:1071
char cdkey[CDKEY_BUF_LEN]
idUserInterface * guiInGame
idUserInterface * guiLoading
void SetModsMenuGuiVars(void)
virtual bool IsMultiplayer()
Definition: Session.cpp:452
virtual bool CheckKey(const char *key, bool netConnect, bool offline_valid[2])
Definition: Session.cpp:3123
virtual bool WaitingForGameAuth(void)
Definition: Session.cpp:3261
virtual int GetSaveGameVersion(void)
Definition: Session.cpp:3313
int GetBytesNeededForMapLoad(const char *mapName)
Definition: Session.cpp:1462
void PlayIntroGui()
ID_TIME_T timeStamp
Definition: Session_local.h:60
logCmd_t loggedUsercmds[MAX_LOGGED_USERCMDS]
static idCVar com_skipGameDraw
GLfloat GLfloat p
Definition: glext.h:4674
static idCVar com_minTics
cdKeyState_t cdkey_state
virtual void CDKeysAuthReply(bool valid, const char *auth_msg)
Definition: Session.cpp:3270
idUserInterface * guiMsgRestore
idUserInterface * guiRestartMenu
void UnloadMap()
Definition: Session.cpp:1413
virtual void TimeHitch(int msec)
Definition: Session.cpp:2976
void HandleMainMenuCommands(const char *menuCommand)
bool SaveGame(const char *saveName, bool autosave=false)
Definition: Session.cpp:1894
int GetLocalClientNum()
Definition: Session.cpp:2939
void RunGameTic()
Definition: Session.cpp:2740
void SetPbMenuGuiVars(void)
static idCVar com_aviDemoWidth
void HandleNoteCommands(const char *menuCommand)