From b0d02f8fd54c06d0706c185ab86250c3a696e5b3 Mon Sep 17 00:00:00 2001 From: black Date: Sat, 4 Mar 2006 14:45:35 +0000 Subject: [PATCH] Fix a bug in the video system. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6066 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_video.c | 29 +++++++++++++++++------------ cl_video.h | 2 +- gl_draw.c | 2 +- prvm_cmds.c | 8 ++++---- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/cl_video.c b/cl_video.c index 038276bb..64e02307 100644 --- a/cl_video.c +++ b/cl_video.c @@ -112,18 +112,9 @@ clvideo_t* CL_OpenVideo( const char *filename, const char *name, int owner ) return video; } -clvideo_t* CL_GetVideo( const char *name ) +static clvideo_t* CL_GetVideoBySlot( int slot ) { - int i; - clvideo_t *video; - - for( i = 0 ; i < cl_activevideos ; i++ ) - if( videoarray[ i ].state != CLVIDEO_UNUSED - && !strcmp( videoarray[ i ].cpif.name , name ) ) - break; - if( i == cl_activevideos ) - return NULL; - video = &videoarray[ i ]; + clvideo_t *video = &videoarray[ slot ]; if( video->suspended ) { @@ -138,6 +129,20 @@ clvideo_t* CL_GetVideo( const char *name ) return video; } +clvideo_t *CL_GetVideoByName( const char *name ) +{ + int i; + + for( i = 0 ; i < cl_activevideos ; i++ ) + if( videoarray[ i ].state != CLVIDEO_UNUSED + && !strcmp( videoarray[ i ].cpif.name , name ) ) + break; + if( i != cl_activevideos ) + return CL_GetVideoBySlot( i ); + else + return NULL; +} + void CL_SetVideoState( clvideo_t *video, clvideostate_t state ) { if( !video ) @@ -251,7 +256,7 @@ int cl_videoplaying = false; // old, but still supported void CL_DrawVideo(void) { if (cl_videoplaying) - DrawQ_Pic(0, 0, &videoarray->cpif, vid_conwidth.integer, vid_conheight.integer, 1, 1, 1, 1, 0); + DrawQ_Pic(0, 0, &CL_GetVideoBySlot( 0 )->cpif, vid_conwidth.integer, vid_conheight.integer, 1, 1, 1, 1, 0); } void CL_VideoStart(char *filename) diff --git a/cl_video.h b/cl_video.h index 8439e92c..878d2494 100644 --- a/cl_video.h +++ b/cl_video.h @@ -46,7 +46,7 @@ typedef struct clvideo_s } clvideo_t; clvideo_t* CL_OpenVideo( const char *filename, const char *name, int owner ); -clvideo_t* CL_GetVideo( const char *name ); +clvideo_t* CL_GetVideoByName( const char *name ); void CL_SetVideoState( clvideo_t *video, clvideostate_t state ); void CL_RestartVideo( clvideo_t *video ); diff --git a/gl_draw.c b/gl_draw.c index b908a242..f6180997 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -310,7 +310,7 @@ cachepic_t *Draw_CachePic (const char *path, qboolean persistent) { clvideo_t *video; - video = CL_GetVideo(path); + video = CL_GetVideoByName(path); if( video ) return &video->cpif; } diff --git a/prvm_cmds.c b/prvm_cmds.c index ee881933..8f0a3fd9 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -2705,7 +2705,7 @@ void VM_cin_close( void ) name = PRVM_G_STRING( OFS_PARM0 ); VM_CheckEmptyString( name ); - CL_CloseVideo( CL_GetVideo( name ) ); + CL_CloseVideo( CL_GetVideoByName( name ) ); } /* @@ -2727,7 +2727,7 @@ void VM_cin_setstate( void ) state = (clvideostate_t)((int)PRVM_G_FLOAT( OFS_PARM1 )); - video = CL_GetVideo( name ); + video = CL_GetVideoByName( name ); if( video && state > CLVIDEO_UNUSED && state < CLVIDEO_STATECOUNT ) CL_SetVideoState( video, state ); } @@ -2749,7 +2749,7 @@ void VM_cin_getstate( void ) name = PRVM_G_STRING( OFS_PARM0 ); VM_CheckEmptyString( name ); - video = CL_GetVideo( name ); + video = CL_GetVideoByName( name ); if( video ) PRVM_G_FLOAT( OFS_RETURN ) = (int)video->state; else @@ -2773,7 +2773,7 @@ void VM_cin_restart( void ) name = PRVM_G_STRING( OFS_PARM0 ); VM_CheckEmptyString( name ); - video = CL_GetVideo( name ); + video = CL_GetVideoByName( name ); if( video ) CL_RestartVideo( video ); } -- 2.39.2