/* * SCR_PlayCinematic */ static void SCR_PlayCinematic( const char *arg, int flags ) { struct cinematics_s *cin; CL_SoundModule_Clear(); cin = CIN_Open( arg, 0, qfalse, qtrue ); if( !cin ) { Com_Printf( "SCR_PlayCinematic: couldn't find %s\n", arg ); return; } CL_Disconnect( NULL ); cl.cin.h = cin; cl.cin.keepRatio = (flags & 1) ? qfalse : qtrue; cl.cin.allowConsole = (flags & 2) ? qfalse : qtrue; cl.cin.paused = qfalse; cl.cin.absStartTime = cl.cin.absCurrentTime = cl.cin.absPrevTime = SCR_CinematicTime(); cl.cin.currentTime = 0; CL_SetClientState( CA_CINEMATIC ); CL_SoundModule_StopAllSounds(); SCR_EndLoadingPlaque(); SCR_ReadNextCinematicFrame(); }
/* ================ SCR_BeginLoadingPlaque ================ */ void SCR_BeginLoadingPlaque( void ) { CL_SoundModule_StopAllSounds(); memset( cl.configstrings, 0, sizeof( cl.configstrings ) ); scr_conlines = 0; // none visible scr_draw_loading = 2; // clear to black first SCR_UpdateScreen(); CL_ShutdownMedia( qfalse ); #if 0 if( cls.disable_screen ) return; if( developer->integer ) return; if( cls.state == ca_disconnected ) return; // if at console, don't bring up the plaque if( cls.key_dest == key_console ) return; if( cl.cin.time > 0 ) scr_draw_loading = 2; // clear to black first else scr_draw_loading = 1; SCR_UpdateScreen(); cls.disable_screen = Sys_Milliseconds(); cls.disable_servercount = cl.servercount; #endif }
/* * SCR_PlayCinematic */ static void SCR_PlayCinematic( const char *arg, int flags ) { struct cinematics_s *cin; bool has_ogg; bool yuv; float framerate; size_t name_size = strlen( "video/" ) + strlen( arg ) + 1; char *name = alloca( name_size ); if( strstr( arg, "/" ) == NULL && strstr( arg, "\\" ) == NULL ) { Q_snprintfz( name, name_size, "video/%s", arg ); } else { Q_snprintfz( name, name_size, "%s", arg ); } cin = CIN_Open( name, 0, 0, &yuv, &framerate ); if( !cin ) { Com_Printf( "SCR_PlayCinematic: couldn't find %s\n", name ); return; } has_ogg = CIN_HasOggAudio( cin ); CIN_Close( cin ); SCR_FinishCinematic(); CL_SoundModule_StopAllSounds( true, true ); cin = CIN_Open( name, 0, has_ogg ? CIN_NOAUDIO : 0, &yuv, &framerate ); if( !cin ) { Com_Printf( "SCR_PlayCinematic: (FIXME) couldn't find %s\n", name ); return; } if( has_ogg ) { CL_SoundModule_StartBackgroundTrack( CIN_FileName( cin ), NULL, 4 ); } cl.cin.h = cin; cl.cin.keepRatio = (flags & 1) ? false : true; cl.cin.allowConsole = (flags & 2) ? false : true; cl.cin.startTime = SCR_CinematicTime(); cl.cin.paused = false; cl.cin.pause_cnt = 0; cl.cin.yuv = yuv; cl.cin.framerate = framerate; CL_SetClientState( CA_CINEMATIC ); SCR_EndLoadingPlaque(); SCR_RunCinematic(); }
/* * SCR_BeginLoadingPlaque */ void SCR_BeginLoadingPlaque( void ) { CL_SoundModule_StopAllSounds( true, true ); memset( cl.configstrings, 0, sizeof( cl.configstrings ) ); scr_conlines = 0; // none visible scr_draw_loading = 2; // clear to black first SCR_UpdateScreen(); }
/* * SCR_PlayCinematic */ static void SCR_PlayCinematic( char *arg ) { int len; size_t name_size; static cinematics_t clientCin; cinematics_t *cin = cl.cin = &clientCin; roq_chunk_t *chunk = &cin->chunk; name_size = strlen( "video/" ) + strlen( arg ) + strlen( ".roq" ) + 1; cin->name = Mem_ZoneMalloc( name_size ); Q_snprintfz( cin->name, name_size, "video/%s", arg ); COM_DefaultExtension( cin->name, ".roq", name_size ); // nasty hack cin->s_rate = 22050; cin->s_width = 2; cin->width = cin->height = 0; cin->frame = 0; len = FS_FOpenFile( cin->name, &cin->file, FS_READ ); if( !cin->file || len < 1 ) { Com_Printf( "Couldn't find %s\n", cin->name ); SCR_StopCinematic(); return; } // read header RoQ_ReadChunk( cin ); if( chunk->id != RoQ_HEADER1 || chunk->size != RoQ_HEADER2 || chunk->argument != RoQ_HEADER3 ) { Com_Printf( "Invalid video file %s\n", cin->name ); SCR_StopCinematic(); return; } SCR_EndLoadingPlaque(); cin->headerlen = FS_Tell( cin->file ); cin->frame = 0; cin->pic = cin->pic_pending = SCR_ReadNextCinematicFrame(); cin->time = cls.realtime + 1; // add 1 msec so SCR_GetCinematicTime is also valid for early commands CL_SetClientState( CA_ACTIVE ); CL_SoundModule_StopAllSounds(); }
/* * CL_GameModule_Init */ void CL_GameModule_Init( void ) { int apiversion; unsigned int start; cgame_import_t import; void *( *builtinAPIfunc )(void *) = NULL; #ifdef CGAME_HARD_LINKED builtinAPIfunc = GetCGameAPI; #endif // stop all playing sounds CL_SoundModule_StopAllSounds( true, true ); CL_GameModule_Shutdown(); // disable reading of client game module chat cvars Cvar_ForceSet( "con_chatCGame", "0" ); cl_gamemodulepool = _Mem_AllocPool( NULL, "Client Game Progs", MEMPOOL_CLIENTGAME, __FILE__, __LINE__ ); import.Error = CL_GameModule_Error; import.Print = CL_GameModule_Print; import.PrintToLog = CL_GameModule_PrintToLog; import.Dynvar_Create = Dynvar_Create; import.Dynvar_Destroy = Dynvar_Destroy; import.Dynvar_Lookup = Dynvar_Lookup; import.Dynvar_GetName = Dynvar_GetName; import.Dynvar_GetValue = Dynvar_GetValue; import.Dynvar_SetValue = Dynvar_SetValue; import.Dynvar_AddListener = Dynvar_AddListener; import.Dynvar_RemoveListener = Dynvar_RemoveListener; import.Cvar_Get = Cvar_Get; import.Cvar_Set = Cvar_Set; import.Cvar_SetValue = Cvar_SetValue; import.Cvar_ForceSet = Cvar_ForceSet; import.Cvar_String = Cvar_String; import.Cvar_Value = Cvar_Value; import.Cmd_TokenizeString = Cmd_TokenizeString; import.Cmd_Argc = Cmd_Argc; import.Cmd_Argv = Cmd_Argv; import.Cmd_Args = Cmd_Args; import.Cmd_AddCommand = Cmd_AddCommand; import.Cmd_RemoveCommand = Cmd_RemoveCommand; import.Cmd_ExecuteText = Cbuf_ExecuteText; import.Cmd_Execute = Cbuf_Execute; import.Cmd_SetCompletionFunc = Cmd_SetCompletionFunc; import.FS_FOpenFile = FS_FOpenFile; import.FS_Read = FS_Read; import.FS_Write = FS_Write; import.FS_Print = FS_Print; import.FS_Tell = FS_Tell; import.FS_Seek = FS_Seek; import.FS_Eof = FS_Eof; import.FS_Flush = FS_Flush; import.FS_FCloseFile = FS_FCloseFile; import.FS_RemoveFile = FS_RemoveFile; import.FS_GetFileList = FS_GetFileList; import.FS_FirstExtension = FS_FirstExtension; import.FS_IsPureFile = FS_IsPureFile; import.FS_MoveFile = FS_MoveFile; import.FS_IsUrl = FS_IsUrl; import.FS_FileMTime = FS_BaseFileMTime; import.FS_RemoveDirectory = FS_RemoveDirectory; import.Key_GetBindingBuf = Key_GetBindingBuf; import.Key_KeynumToString = Key_KeynumToString; import.GetConfigString = CL_GameModule_GetConfigString; import.Milliseconds = Sys_Milliseconds; import.DownloadRequest = CL_DownloadRequest; import.NET_GetUserCmd = CL_GameModule_NET_GetUserCmd; import.NET_GetCurrentUserCmdNum = CL_GameModule_NET_GetCurrentUserCmdNum; import.NET_GetCurrentState = CL_GameModule_NET_GetCurrentState; import.RefreshMouseAngles = CL_GameModule_RefreshMouseAngles; import.R_UpdateScreen = SCR_UpdateScreen; import.R_GetClippedFragments = re.GetClippedFragments; import.R_ClearScene = re.ClearScene; import.R_AddEntityToScene = re.AddEntityToScene; import.R_AddLightToScene = re.AddLightToScene; import.R_AddPolyToScene = re.AddPolyToScene; import.R_AddLightStyleToScene = re.AddLightStyleToScene; import.R_RenderScene = re.RenderScene; import.R_SpeedsMessage = re.SpeedsMessage; import.R_RegisterWorldModel = CL_GameModule_R_RegisterWorldModel; import.R_ModelBounds = re.ModelBounds; import.R_ModelFrameBounds = re.ModelFrameBounds; import.R_RegisterModel = re.RegisterModel; import.R_RegisterPic = re.RegisterPic; import.R_RegisterRawPic = re.RegisterRawPic; import.R_RegisterLevelshot = re.RegisterLevelshot; import.R_RegisterSkin = re.RegisterSkin; import.R_RegisterSkinFile = re.RegisterSkinFile; import.R_LerpTag = re.LerpTag; import.R_LightForOrigin = re.LightForOrigin; import.R_SetCustomColor = re.SetCustomColor; import.R_DrawStretchPic = re.DrawStretchPic; import.R_DrawStretchPoly = re.DrawStretchPoly; import.R_DrawRotatedStretchPic = re.DrawRotatedStretchPic; import.R_Scissor = re.Scissor; import.R_GetScissor = re.GetScissor; import.R_ResetScissor = re.ResetScissor; import.R_GetShaderDimensions = re.GetShaderDimensions; import.R_TransformVectorToScreen = re.TransformVectorToScreen; import.R_SkeletalGetNumBones = re.SkeletalGetNumBones; import.R_SkeletalGetBoneInfo = re.SkeletalGetBoneInfo; import.R_SkeletalGetBonePose = re.SkeletalGetBonePose; import.R_GetShaderForOrigin = re.GetShaderForOrigin; import.R_GetShaderCinematic = re.GetShaderCinematic; import.VID_FlashWindow = VID_FlashWindow; import.CM_NumInlineModels = CL_GameModule_CM_NumInlineModels; import.CM_InlineModel = CL_GameModule_CM_InlineModel; import.CM_TransformedBoxTrace = CL_GameModule_CM_TransformedBoxTrace; import.CM_RoundUpToHullSize = CL_GameModule_CM_RoundUpToHullSize; import.CM_TransformedPointContents = CL_GameModule_CM_TransformedPointContents; import.CM_ModelForBBox = CL_GameModule_CM_ModelForBBox; import.CM_OctagonModelForBBox = CL_GameModule_CM_OctagonModelForBBox; import.CM_InlineModelBounds = CL_GameModule_CM_InlineModelBounds; import.CM_InPVS = CL_GameModule_CM_InPVS; import.S_RegisterSound = CL_SoundModule_RegisterSound; import.S_StartFixedSound = CL_SoundModule_StartFixedSound; import.S_StartRelativeSound = CL_SoundModule_StartRelativeSound; import.S_StartGlobalSound = CL_SoundModule_StartGlobalSound; import.S_Update = CL_GameModule_SoundUpdate; import.S_AddLoopSound = CL_SoundModule_AddLoopSound; import.S_StartBackgroundTrack = CL_SoundModule_StartBackgroundTrack; import.S_StopBackgroundTrack = CL_SoundModule_StopBackgroundTrack; import.S_RawSamples = CL_GameModule_S_RawSamples; import.S_PositionedRawSamples = CL_SoundModule_PositionedRawSamples; import.S_GetRawSamplesLength = CL_SoundModule_GetRawSamplesLength; import.S_GetPositionedRawSamplesLength = CL_SoundModule_GetPositionedRawSamplesLength; import.S_SetEntitySpatilization = CL_SoundModule_SetEntitySpatilization; import.SCR_RegisterFont = SCR_RegisterFont; import.SCR_RegisterSpecialFont = SCR_RegisterSpecialFont; import.SCR_DrawString = SCR_DrawString; import.SCR_DrawStringWidth = SCR_DrawStringWidth; import.SCR_DrawClampString = SCR_DrawClampString; import.SCR_DrawMultilineString = SCR_DrawMultilineString; import.SCR_DrawRawChar = SCR_DrawRawChar; import.SCR_DrawClampChar = SCR_DrawClampChar; import.SCR_FontSize = SCR_FontSize; import.SCR_FontHeight = SCR_FontHeight; import.SCR_FontUnderline = SCR_FontUnderline; import.SCR_FontAdvance = SCR_FontAdvance; import.SCR_FontXHeight = SCR_FontXHeight; import.SCR_SetDrawCharIntercept = SCR_SetDrawCharIntercept; import.SCR_strWidth = SCR_strWidth; import.SCR_StrlenForWidth = SCR_StrlenForWidth; import.AsyncStream_UrlEncode = AsyncStream_UrlEncode; import.AsyncStream_UrlDecode = AsyncStream_UrlDecode; import.AsyncStream_PerformRequest = CL_GameModule_AsyncStream_PerformRequest; import.GetBaseServerURL = CL_GetBaseServerURL; import.Mem_Alloc = CL_GameModule_MemAlloc; import.Mem_Free = CL_GameModule_MemFree; import.L10n_LoadLangPOFile = &CL_GameModule_L10n_LoadLangPOFile; import.L10n_TranslateString = &CL_GameModule_L10n_TranslateString; import.L10n_ClearDomain = &CL_GameModule_L10n_ClearDomain; import.CIN_AddRawSamplesListener = &CL_GameModule_AddRawSamplesListener; import.IN_GetThumbsticks = IN_GetThumbsticks; import.IN_IME_GetCandidates = IN_IME_GetCandidates; import.IN_SupportedDevices = IN_SupportedDevices; if( builtinAPIfunc ) { cge = builtinAPIfunc( &import ); } else { cge = (cgame_export_t *)Com_LoadGameLibrary( "cgame", "GetCGameAPI", &module_handle, &import, cls.sv_pure, NULL ); } if( !cge ) Com_Error( ERR_DROP, "Failed to load client game DLL" ); AC_LoadLibrary( (void *) &import, (void *) cge, ANTICHEAT_CLIENT ); // impulZ: Refire AC Init apiversion = cge->API(); if( apiversion != CGAME_API_VERSION ) { Com_UnloadGameLibrary( &module_handle ); Mem_FreePool( &cl_gamemodulepool ); cge = NULL; Com_Error( ERR_DROP, "Client game is version %i, not %i", apiversion, CGAME_API_VERSION ); } CL_GameModule_AsyncStream_Init(); start = Sys_Milliseconds(); cge->Init( cls.servername, cl.playernum, viddef.width, viddef.height, VID_GetPixelRatio(), cls.demo.playing, cls.demo.playing ? cls.demo.filename : "", cls.sv_pure, cl.snapFrameTime, APP_PROTOCOL_VERSION, APP_DEMO_EXTENSION_STR, cls.mediaRandomSeed, cl.gamestart ); Com_DPrintf( "CL_GameModule_Init: %.2f seconds\n", (float)( Sys_Milliseconds() - start ) * 0.001f ); cl.gamestart = false; cls.cgameActive = true; }
/* * CL_GameModule_Init */ void CL_GameModule_Init( void ) { int apiversion, oldState; unsigned int start; cgame_import_t import; void *( *builtinAPIfunc )(void *) = NULL; #ifdef CGAME_HARD_LINKED builtinAPIfunc = GetCGameAPI; #endif // stop all playing sounds CL_SoundModule_StopAllSounds(); CL_GameModule_Shutdown(); // disable reading of client game module chat cvars Cvar_ForceSet( "con_chatCGame", "0" ); cl_gamemodulepool = _Mem_AllocPool( NULL, "Client Game Progs", MEMPOOL_CLIENTGAME, __FILE__, __LINE__ ); import.Error = CL_GameModule_Error; import.Print = CL_GameModule_Print; import.PrintToLog = CL_GameModule_PrintToLog; import.Dynvar_Create = Dynvar_Create; import.Dynvar_Destroy = Dynvar_Destroy; import.Dynvar_Lookup = Dynvar_Lookup; import.Dynvar_GetName = Dynvar_GetName; import.Dynvar_GetValue = Dynvar_GetValue; import.Dynvar_SetValue = Dynvar_SetValue; import.Dynvar_AddListener = Dynvar_AddListener; import.Dynvar_RemoveListener = Dynvar_RemoveListener; import.Cvar_Get = Cvar_Get; import.Cvar_Set = Cvar_Set; import.Cvar_SetValue = Cvar_SetValue; import.Cvar_ForceSet = Cvar_ForceSet; import.Cvar_String = Cvar_String; import.Cvar_Value = Cvar_Value; import.Cmd_TokenizeString = Cmd_TokenizeString; import.Cmd_Argc = Cmd_Argc; import.Cmd_Argv = Cmd_Argv; import.Cmd_Args = Cmd_Args; import.Cmd_AddCommand = Cmd_AddCommand; import.Cmd_RemoveCommand = Cmd_RemoveCommand; import.Cmd_ExecuteText = Cbuf_ExecuteText; import.Cmd_Execute = Cbuf_Execute; import.Cmd_SetCompletionFunc = Cmd_SetCompletionFunc; import.FS_FOpenFile = FS_FOpenFile; import.FS_Read = FS_Read; import.FS_Write = FS_Write; import.FS_Print = FS_Print; import.FS_Tell = FS_Tell; import.FS_Seek = FS_Seek; import.FS_Eof = FS_Eof; import.FS_Flush = FS_Flush; import.FS_FCloseFile = FS_FCloseFile; import.FS_RemoveFile = FS_RemoveFile; import.FS_GetFileList = FS_GetFileList; import.FS_FirstExtension = FS_FirstExtension; import.FS_IsPureFile = FS_IsPureFile; import.FS_MoveFile = FS_MoveFile; import.FS_IsUrl = FS_IsUrl; import.FS_FileMTime = FS_BaseFileMTime; import.FS_RemoveDirectory = FS_RemoveDirectory; import.Key_GetBindingBuf = Key_GetBindingBuf; import.Key_KeynumToString = Key_KeynumToString; import.GetConfigString = CL_GameModule_GetConfigString; import.Milliseconds = Sys_Milliseconds; import.DownloadRequest = CL_DownloadRequest; import.Hash_BlockChecksum = Com_MD5Digest32; import.Hash_SuperFastHash = Com_SuperFastHash; import.NET_GetUserCmd = CL_GameModule_NET_GetUserCmd; import.NET_GetCurrentUserCmdNum = CL_GameModule_NET_GetCurrentUserCmdNum; import.NET_GetCurrentState = CL_GameModule_NET_GetCurrentState; import.RefreshMouseAngles = CL_GameModule_RefreshMouseAngles; import.R_UpdateScreen = SCR_UpdateScreen; import.R_GetClippedFragments = R_GetClippedFragments; import.R_ClearScene = R_ClearScene; import.R_AddEntityToScene = R_AddEntityToScene; import.R_AddLightToScene = R_AddLightToScene; import.R_AddPolyToScene = R_AddPolyToScene; import.R_AddLightStyleToScene = R_AddLightStyleToScene; import.R_RenderScene = R_RenderScene; import.R_SpeedsMessage = R_SpeedsMessage; import.R_RegisterWorldModel = CL_GameModule_R_RegisterWorldModel; import.R_ModelBounds = R_ModelBounds; import.R_ModelFrameBounds = R_ModelFrameBounds; import.R_RegisterModel = R_RegisterModel; import.R_RegisterPic = R_RegisterPic; import.R_RegisterRawPic = R_RegisterRawPic; import.R_RegisterLevelshot = R_RegisterLevelshot; import.R_RegisterSkin = R_RegisterSkin; import.R_RegisterSkinFile = R_RegisterSkinFile; import.R_LerpTag = R_LerpTag; import.R_LightForOrigin = R_LightForOrigin; import.R_SetCustomColor = R_SetCustomColor; import.R_DrawStretchPic = R_DrawStretchPic; import.R_DrawStretchPoly = R_DrawStretchPoly; import.R_DrawRotatedStretchPic = R_DrawRotatedStretchPic; import.R_SetScissorRegion = R_SetScissorRegion; import.R_GetShaderDimensions = R_GetShaderDimensions; import.R_TransformVectorToScreen = R_TransformVectorToScreen; import.R_SkeletalGetNumBones = R_SkeletalGetNumBones; import.R_SkeletalGetBoneInfo = R_SkeletalGetBoneInfo; import.R_SkeletalGetBonePose = R_SkeletalGetBonePose; import.VID_FlashWindow = VID_FlashWindow; import.CM_NumInlineModels = CL_GameModule_CM_NumInlineModels; import.CM_InlineModel = CL_GameModule_CM_InlineModel; import.CM_TransformedBoxTrace = CL_GameModule_CM_TransformedBoxTrace; import.CM_RoundUpToHullSize = CL_GameModule_CM_RoundUpToHullSize; import.CM_TransformedPointContents = CL_GameModule_CM_TransformedPointContents; import.CM_ModelForBBox = CL_GameModule_CM_ModelForBBox; import.CM_OctagonModelForBBox = CL_GameModule_CM_OctagonModelForBBox; import.CM_InlineModelBounds = CL_GameModule_CM_InlineModelBounds; import.S_RegisterSound = CL_SoundModule_RegisterSound; import.S_StartFixedSound = CL_SoundModule_StartFixedSound; import.S_StartRelativeSound = CL_SoundModule_StartRelativeSound; import.S_StartGlobalSound = CL_SoundModule_StartGlobalSound; import.S_Update = CL_GameModule_SoundUpdate; import.S_AddLoopSound = CL_SoundModule_AddLoopSound; import.S_StartBackgroundTrack = CL_SoundModule_StartBackgroundTrack; import.S_StopBackgroundTrack = CL_SoundModule_StopBackgroundTrack; import.SCR_RegisterFont = SCR_RegisterFont; import.SCR_DrawString = SCR_DrawString; import.SCR_DrawStringWidth = SCR_DrawStringWidth; import.SCR_DrawClampString = SCR_DrawClampString; import.SCR_strHeight = SCR_strHeight; import.SCR_strWidth = SCR_strWidth; import.SCR_StrlenForWidth = SCR_StrlenForWidth; import.Mem_Alloc = CL_GameModule_MemAlloc; import.Mem_Free = CL_GameModule_MemFree; cge = (cgame_export_t *)Com_LoadGameLibrary( "cgame", "GetCGameAPI", &module_handle, &import, builtinAPIfunc, cls.sv_pure, NULL ); if( !cge ) Com_Error( ERR_DROP, "Failed to load client game DLL" ); AC_LoadLibrary( (void *) &import, (void *) cge, ANTICHEAT_CLIENT ); // impulZ: Refire AC Init apiversion = cge->API(); if( apiversion != CGAME_API_VERSION ) { Com_UnloadGameLibrary( &module_handle ); Mem_FreePool( &cl_gamemodulepool ); cge = NULL; Com_Error( ERR_DROP, "Client game is version %i, not %i", apiversion, CGAME_API_VERSION ); } oldState = cls.state; cls.state = CA_LOADING; start = Sys_Milliseconds(); cge->Init( cl.playernum, viddef.width, viddef.height, cls.demo.playing, cls.sv_pure, cl.snapFrameTime, APP_PROTOCOL_VERSION, cls.mediaRandomSeed ); Com_DPrintf( "CL_GameModule_Init: %.2f seconds\n", (float)( Sys_Milliseconds() - start ) * 0.001f ); cls.state = oldState; cls.cgameActive = qtrue; // check memory integrity Mem_CheckSentinelsGlobal(); Sys_SendKeyEvents(); // pump message loop }