UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cl_cinematic.cpp
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2020 UFO: Alien Invasion.
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17 See the GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23 */
24 
25 
26 #include "cl_cinematic.h"
27 #include "cl_cinematic_ogm.h"
28 #include "cl_cinematic_roq.h"
29 #include "../cl_console.h"
30 #include "../sound/s_main.h"
31 #include "../sound/s_music.h"
32 /* trying to get rid of client.h ... */
33 #include <assert.h>
34 #include "../cl_video.h" /* viddef */
35 #include "../../shared/shared.h" /* Q_strncpyz */
36 
38 {
39  OBJZERO(*cin);
40 }
41 
47 void CIN_SetParameters (cinematic_t* cin, int x, int y, int w, int h, int status, bool noSound)
48 {
49  cin->x = x * viddef.rx;
50  cin->y = y * viddef.ry;
51  cin->w = w * viddef.rx;
52  cin->h = h * viddef.ry;
53  if (status > CIN_STATUS_NONE)
54  cin->status = status;
55  cin->noSound = noSound;
56 }
57 
62 {
63  assert(cin->status != CIN_STATUS_NONE);
64 
65  /* Decode chunks until the desired frame is reached */
67  return;
68  else if (cin->cinematicType == CINEMATIC_TYPE_OGM && CIN_OGM_RunCinematic(cin))
69  return;
70 
71  /* If we get here, the cinematic has either finished or failed */
72  if (cin->replay) {
73  char name[MAX_QPATH];
74  Q_strncpyz(name, cin->name, sizeof(name));
75  CIN_OpenCinematic(cin, name);
76  cin->replay = true;
77  } else {
78  CIN_CloseCinematic(cin);
79  }
80 }
81 
86 void CIN_OpenCinematic (cinematic_t* cin, const char* fileName)
87 {
88  char name[MAX_OSPATH];
89  int status = 1;
90 
91  Com_StripExtension(fileName, name, sizeof(name));
92 
93  /* If already playing a cinematic, stop it */
94  CIN_CloseCinematic(cin);
95 
96  if (FS_CheckFile("%s.roq", name) >= 0)
97  status = CIN_ROQ_OpenCinematic(cin, va("%s.roq", name));
98  else if (FS_CheckFile("%s.ogm", name) >= 0)
99  status = CIN_OGM_OpenCinematic(cin, va("%s.ogm", name));
100 
101  if (status != 0) {
102  Com_Printf("Could not load cinematic '%s'\n", name);
103  cin->status = CIN_STATUS_INVALID;
104  }
105 }
106 
112 {
113  if (cin->status == CIN_STATUS_NONE)
114  return; /* Not playing */
115 
116  cin->status = CIN_STATUS_NONE;
117 
118  if (cin->cinematicType == CINEMATIC_TYPE_ROQ)
120  else if (cin->cinematicType == CINEMATIC_TYPE_OGM)
122 
123  CIN_InitCinematic(cin);
124 }
125 
126 void CIN_Init (void)
127 {
128  CIN_ROQ_Init();
129  CIN_OGM_Init();
130 }
131 
132 void CIN_Shutdown (void)
133 {
134 }
void CIN_Shutdown(void)
int FS_CheckFile(const char *fmt,...)
Just returns the filelength and -1 if the file wasn't found.
Definition: files.cpp:298
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
Definition: shared.cpp:410
void CIN_RunCinematic(cinematic_t *cin)
void CIN_OpenCinematic(cinematic_t *cin, const char *fileName)
Open a cinematic file and store status to a structure.
void Com_StripExtension(const char *in, char *out, const size_t size)
Removes the file extension from a filename.
Definition: shared.cpp:259
void CIN_CloseCinematic(cinematic_t *cin)
Close a cinematic, and clean up status and memory.
void CIN_ROQ_Init(void)
float rx
Definition: cl_video.h:71
float float float float h
Definition: cgame.h:130
viddef_t viddef
Definition: cl_video.cpp:34
#define MAX_OSPATH
Definition: filesys.h:44
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
Definition: shared.cpp:457
#define OBJZERO(obj)
Definition: shared.h:178
void CIN_ROQ_CloseCinematic(cinematic_t *cin)
bool CIN_ROQ_RunCinematic(cinematic_t *cin)
Header file for OGM cinematics.
int CIN_OGM_OpenCinematic(cinematic_t *cin, const char *filename)
align_t int x
Definition: cgame.h:128
int CIN_ROQ_OpenCinematic(cinematic_t *cin, const char *fileName)
Header file for ROQ cinematics.
#define MAX_QPATH
Definition: filesys.h:40
void CIN_OGM_Init(void)
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
void CIN_SetParameters(cinematic_t *cin, int x, int y, int w, int h, int status, bool noSound)
void CIN_InitCinematic(cinematic_t *cin)
bool CIN_OGM_RunCinematic(cinematic_t *cin)
char name[MAX_QPATH]
Definition: cl_cinematic.h:38
void CIN_Init(void)
float ry
Definition: cl_video.h:72
align_t int int y
Definition: cgame.h:128
Header file for cinematics.
int cinematicType
Definition: cl_cinematic.h:46
void CIN_OGM_CloseCinematic(cinematic_t *cin)
float float float w
Definition: cgame.h:130