]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_video.c
no longer sends moves if time is not moving forward, except when paused (this fixes...
[xonotic/darkplaces.git] / cl_video.c
index 5f56b889014c50308f5b9d4701c466be6144fb56..42c0496d679026ff9e5229329b32cd27bd6321cc 100644 (file)
@@ -62,7 +62,7 @@ static qboolean WakeVideo( clvideo_t * video )
 
        video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
        video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
-               video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
+               video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, TEXF_ALWAYSPRECACHE, NULL );
 
        // update starttime
        video->starttime += realtime - video->lasttime;
@@ -72,11 +72,11 @@ static qboolean WakeVideo( clvideo_t * video )
 
 static clvideo_t* OpenVideo( clvideo_t *video, const char *filename, const char *name, int owner )
 {
-       strncpy( video->filename, filename, MAX_QPATH );
+       strlcpy( video->filename, filename, sizeof(video->filename) );
        video->ownertag = owner;
        if( strncmp( name, CLVIDEOPREFIX, sizeof( CLVIDEOPREFIX ) - 1 ) )
                return NULL;
-       strncpy( video->cpif.name, name, MAX_QPATH );
+       strlcpy( video->cpif.name, name, sizeof(video->cpif.name) );
 
        if( !OpenStream( video ) )
                return NULL;
@@ -89,7 +89,7 @@ static clvideo_t* OpenVideo( clvideo_t *video, const char *filename, const char
        video->cpif.width = dpvsimpledecode_getwidth( video->stream );
        video->cpif.height = dpvsimpledecode_getheight( video->stream );
        video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
-               video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
+               video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, TEXF_ALWAYSPRECACHE, NULL );
 
     video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
 
@@ -189,7 +189,7 @@ static void VideoFrame( clvideo_t *video )
        if( video->state == CLVIDEO_FIRSTFRAME )
                destframe = 0;
        else
-               destframe = (realtime - video->starttime) * video->framerate;
+               destframe = (int)((realtime - video->starttime) * video->framerate);
        if( destframe < 0 )
                destframe = 0;
        if( video->framenum < destframe ) {
@@ -276,6 +276,16 @@ void CL_VideoStart(char *filename)
        CL_RestartVideo( cl_videos );
 }
 
+void CL_Video_KeyEvent( int key, int ascii, qboolean down ) 
+{
+       // only react to up events, to allow the user to delay the abortion point if it suddenly becomes interesting..
+       if( !down ) {
+               if( key == K_ESCAPE || key == K_ENTER || key == K_SPACE ) {
+                       CL_VideoStop();
+               }
+       }
+}
+
 void CL_VideoStop(void)
 {
        cl_videoplaying = false;
@@ -314,7 +324,7 @@ static void cl_video_start( void )
        for( video = cl_videos, i = 0 ; i < cl_num_videos ; i++, video++ )
                if( video->state != CLVIDEO_UNUSED && !video->suspended )
                        video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
-                               video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
+                               video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, TEXF_ALWAYSPRECACHE, NULL );
 }
 
 static void cl_video_shutdown( void )