UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
cl_cinematic.cpp
Go to the documentation of this file.
1
4
5
/*
6
Copyright (C) 2002-2025 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
37
void
CIN_InitCinematic
(
cinematic_t
* cin)
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
61
void
CIN_RunCinematic
(
cinematic_t
* cin)
62
{
63
assert(cin->
status
!=
CIN_STATUS_NONE
);
64
65
/* Decode chunks until the desired frame is reached */
66
if
(cin->
cinematicType
==
CINEMATIC_TYPE_ROQ
&&
CIN_ROQ_RunCinematic
(cin))
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
111
void
CIN_CloseCinematic
(
cinematic_t
* cin)
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
)
119
CIN_ROQ_CloseCinematic
(cin);
120
else
if
(cin->
cinematicType
==
CINEMATIC_TYPE_OGM
)
121
CIN_OGM_CloseCinematic
(cin);
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
}
CIN_InitCinematic
void CIN_InitCinematic(cinematic_t *cin)
Definition
cl_cinematic.cpp:37
CIN_RunCinematic
void CIN_RunCinematic(cinematic_t *cin)
Definition
cl_cinematic.cpp:61
CIN_Shutdown
void CIN_Shutdown(void)
Definition
cl_cinematic.cpp:132
CIN_SetParameters
void CIN_SetParameters(cinematic_t *cin, int x, int y, int w, int h, int status, bool noSound)
Definition
cl_cinematic.cpp:47
CIN_OpenCinematic
void CIN_OpenCinematic(cinematic_t *cin, const char *fileName)
Open a cinematic file and store status to a structure.
Definition
cl_cinematic.cpp:86
CIN_Init
void CIN_Init(void)
Definition
cl_cinematic.cpp:126
CIN_CloseCinematic
void CIN_CloseCinematic(cinematic_t *cin)
Close a cinematic, and clean up status and memory.
Definition
cl_cinematic.cpp:111
cl_cinematic.h
Header file for cinematics.
CINEMATIC_TYPE_OGM
@ CINEMATIC_TYPE_OGM
Definition
cl_cinematic.h:34
CINEMATIC_TYPE_ROQ
@ CINEMATIC_TYPE_ROQ
Definition
cl_cinematic.h:33
CIN_STATUS_NONE
@ CIN_STATUS_NONE
Definition
cl_cinematic.h:63
CIN_STATUS_INVALID
@ CIN_STATUS_INVALID
Definition
cl_cinematic.h:64
CIN_OGM_RunCinematic
bool CIN_OGM_RunCinematic(cinematic_t *cin)
Definition
cl_cinematic_ogm.cpp:722
CIN_OGM_Init
void CIN_OGM_Init(void)
Definition
cl_cinematic_ogm.cpp:774
CIN_OGM_CloseCinematic
void CIN_OGM_CloseCinematic(cinematic_t *cin)
Definition
cl_cinematic_ogm.cpp:740
CIN_OGM_OpenCinematic
int CIN_OGM_OpenCinematic(cinematic_t *cin, const char *filename)
Definition
cl_cinematic_ogm.cpp:549
cl_cinematic_ogm.h
Header file for OGM cinematics.
CIN_ROQ_OpenCinematic
int CIN_ROQ_OpenCinematic(cinematic_t *cin, const char *fileName)
Definition
cl_cinematic_roq.cpp:541
CIN_ROQ_CloseCinematic
void CIN_ROQ_CloseCinematic(cinematic_t *cin)
Definition
cl_cinematic_roq.cpp:525
CIN_ROQ_Init
void CIN_ROQ_Init(void)
Definition
cl_cinematic_roq.cpp:604
CIN_ROQ_RunCinematic
bool CIN_ROQ_RunCinematic(cinematic_t *cin)
Definition
cl_cinematic_roq.cpp:517
cl_cinematic_roq.h
Header file for ROQ cinematics.
cl_console.h
Console header file.
viddef
viddef_t viddef
Definition
cl_video.cpp:34
cl_video.h
Video driver defs.
Com_Printf
void Com_Printf(const char *const fmt,...)
Definition
common.cpp:428
FS_CheckFile
int FS_CheckFile(const char *fmt,...)
Just returns the filelength and -1 if the file wasn't found.
Definition
files.cpp:298
MAX_OSPATH
#define MAX_OSPATH
Definition
filesys.h:44
MAX_QPATH
#define MAX_QPATH
Definition
filesys.h:40
name
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition
r_gl.h:110
s_main.h
Specifies sound API?
s_music.h
Specifies music API.
shared.h
OBJZERO
#define OBJZERO(obj)
Definition
shared.h:178
Com_StripExtension
void Com_StripExtension(const char *in, char *out, const size_t size)
Removes the file extension from a filename.
Definition
shared.cpp:259
Q_strncpyz
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
Definition
shared.cpp:457
va
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
cinematic_t
Definition
cl_cinematic.h:37
cinematic_t::replay
bool replay
Definition
cl_cinematic.h:40
cinematic_t::x
int x
Definition
cl_cinematic.h:41
cinematic_t::noSound
bool noSound
Definition
cl_cinematic.h:43
cinematic_t::cinematicType
int cinematicType
Definition
cl_cinematic.h:46
cinematic_t::w
int w
Definition
cl_cinematic.h:41
cinematic_t::name
char name[MAX_QPATH]
Definition
cl_cinematic.h:38
cinematic_t::y
int y
Definition
cl_cinematic.h:41
cinematic_t::h
int h
Definition
cl_cinematic.h:41
cinematic_t::status
int status
Definition
cl_cinematic.h:48
src
client
cinematic
cl_cinematic.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0