30 #include "../client.h"
31 #include "../battlescape/cl_localentity.h"
32 #include "../battlescape/cl_view.h"
33 #include "../renderer/r_main.h"
34 #include "../renderer/r_draw.h"
35 #include "../renderer/r_misc.h"
36 #include "../renderer/r_mesh_anim.h"
37 #include "../cl_language.h"
38 #include "../../shared/parse.h"
39 #include "../ui/ui_render.h"
41 #define MAX_DATA_LENGTH 512
117 #define MAX_SEQCMDS 768
118 #define MAX_SEQUENCES 32
119 #define MAX_SEQENTS 128
120 #define MAX_SEQ2DS 128
221 if (!context->
size[0] || !context->
size[1])
253 for (i = 0, se = context->
ents; i < context->numEnts; i++, se++)
256 if (i < context->numEnts)
271 for (i = 0, s2d = context->
obj2Ds; i < context->numObj2Ds; i++, s2d++)
274 if (i < context->numObj2Ds)
310 ent.model = se->
model;
311 ent.skinnum = se->
skin;
313 ent.alpha = se->
alpha;
322 ent.tagent = parent->
ep;
323 ent.tagname = se->
tag;
369 s2d->
pos[1] += height;
373 for (
int j = 0; j < 4; j++) {
375 if (s2d->
color[j] < 0.0)
377 else if (s2d->
color[j] > 1.0)
380 for (
int j = 0; j < 2; j++) {
394 if (s2d->
image[0] !=
'\0') {
412 int maxWidth = (
int) s2d->
size[0];
439 context->
pos[0] = pos[0];
440 context->
pos[1] = pos[1];
441 context->
size[0] = size[0];
442 context->
size[1] = size[1];
457 for (i = 0, sp = sequences; i <
numSequences; i++, sp++)
460 if (i >= numSequences) {
461 Com_Printf(
"Couldn't find sequence '%s'\n", name);
520 if (!context->
size[0] || !context->
size[1])
575 context->
time += 1000;
586 context->
time += 1000 * atof(name);
612 data += strlen(data) + 1;
614 }
else if (
Q_streq(name,
"pics")) {
618 data += strlen(data) + 1;
621 Com_Printf(
"SEQ_ExecutePrecache: unknown format '%s'\n", name);
633 for (vp = seqCamera_vals; vp->
string; vp++)
635 data += strlen(data) + 1;
640 Com_Printf(
"SEQ_ExecuteCamera: unknown token '%s'\n", data);
642 data += strlen(data) + 1;
660 for (i = 0, se = context->
ents; i < context->numEnts; i++, se++)
678 for (vp = seqEnt_vals; vp->
string; vp++)
680 data += strlen(data) + 1;
686 data += strlen(data) + 1;
689 if (se->
model ==
nullptr)
691 }
else if (
Q_streq(data,
"anim")) {
692 if (se->
model ==
nullptr)
694 data += strlen(data) + 1;
698 Com_Printf(
"SEQ_ExecuteModel: unknown token '%s'\n", data);
701 data += strlen(data) + 1;
740 for (i = 0, s2d = context->
obj2Ds; i < context->numObj2Ds; i++, s2d++)
750 for (i = 0; i < 4; i++)
751 s2d->
color[i] = 1.0f;
760 for (vp = seq2D_vals; vp->
string; vp++)
762 data += strlen(data) + 1;
776 Com_Printf(
"SEQ_ExecuteObj2D: unknown token '%s'\n", data);
778 data += strlen(data) + 1;
804 Com_Printf(
"SEQ_ExecuteDelete: couldn't find '%s'\n", name);
838 #define SEQ_NUMCMDS lengthof(seqCmdName)
880 const char* errhead =
"CL_ParseSequence: unexpected end of file (sequence ";
885 if (
Q_streq(name, sequences[i].name))
888 if (i < numSequences) {
889 Com_Printf(
"CL_ParseSequence: sequence def \"%s\" with same name found, second ignored\n", name);
905 if (!*text || *token !=
'{') {
906 Com_Printf(
"CL_ParseSequence: sequence def \"%s\" without body ignored\n", name);
933 if (seqCmds ==
nullptr)
952 if (maxLength <= 0) {
962 else if (*token ==
'}')
966 data += strlen(token) + 1;
967 maxLength -= (strlen(token) + 1);
970 }
else if (*token ==
'(') {
974 Com_Error(
ERR_DROP,
"CL_ParseSequence: error while reading list (sequence \"%s\")", name);
977 for (
linkedList_t* element = list; element !=
nullptr; element = element->
next) {
978 if (maxLength <= 0) {
982 const char*
v = (
char*)element->data;
984 data += strlen(v) + 1;
985 maxLength -= (strlen(v) + 1);
992 Com_Printf(
"CL_ParseSequence: unknown command \"%s\" ignored (sequence %s)\n", token, name);
struct sequence_s sequence_t
CASSERT(lengthof(seqCmdFunc)==lengthof(seqCmdName))
#define VectorCopy(src, dest)
int(* sequenceHandler_t)(struct sequenceContext_s *context, const char *name, const char *data)
execution function of a command
struct sequenceContext_s sequenceContext_t
seq2D_t obj2Ds[MAX_SEQ2DS]
static int SEQ_ExecuteModel(sequenceContext_t *context, const char *name, const char *data)
Parse values for a sequence model.
#define VectorSet(v, x, y, z)
struct seqCamera_s seqCamera_t
void R_DrawImage(float x, float y, const image_t *image)
Draws an image or parts of it.
static const value_t seq2D_vals[]
valid id names for 2d entity
void VectorMA(const vec3_t veca, const float scale, const vec3_t vecb, vec3_t outVector)
Sets vector_out (vc) to vevtor1 (va) + scale * vector2 (vb)
static seqEnt_t * SEQ_FindEnt(sequenceContext_t *context, const char *name)
Finds a given entity in all sequence entities.
static int SEQ_ExecuteWait(sequenceContext_t *context, const char *name, const char *data)
Increase the sequence time.
static bool SEQ_Execute(sequenceContext_t *context)
Move the sequence to the right position according to the current time.
char data[MAX_DATA_LENGTH]
static int SEQ_ExecuteClick(sequenceContext_t *context, const char *name, const char *data)
Wait until someone clicks with the mouse.
void Cbuf_AddText(const char *format,...)
Adds command text at the end of the buffer.
const image_t * R_FindPics(const char *name)
Searches for an image in the image array.
bool SEQ_InitContext(sequenceContext_t *context, const char *name)
Initialize a sequence context from data of a named script sequence.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
void Com_Printf(const char *const fmt,...)
void SEQ_SendClickEvent(sequenceContext_t *context)
Unlock a click event for the current sequence or ends the current sequence if not locked...
void LIST_Delete(linkedList_t **list)
void SEQ_FreeContext(sequenceContext_t *context)
Free a sequence context.
memPool_t * cl_genericPool
#define Mem_PoolStrDupTo(in, out, pool, tagNum)
void R_AnimChange(animState_t *as, const model_t *mod, const char *name)
Changes the animation for md2 models.
void R_Color(const vec4_t rgba)
Change the color to given value.
void Com_Error(int code, const char *fmt,...)
static sequenceHandler_t seqCmdFunc[]
Function to exeute all available commands.
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
void AngleVectors(const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Create the rotation matrix in order to rotate something.
align_t
We need this here for checking the boundaries from script values.
static int SEQ_ExecuteSound(sequenceContext_t *context, const char *name, const char *data)
Plays a sound in a sequence.
void CL_ParseSequence(const char *name, const char **text)
Reads the sequence values from given text-pointer.
entity_t * R_GetFreeEntity(void)
Get the next free entry in the entity list (the last one)
static seq2D_t * SEQ_Find2D(sequenceContext_t *context, const char *name)
Finds a given 2d object in the current sequence data.
static const value_t seqCamera_vals[]
valid id names for camera
const char * Com_EParse(const char **text, const char *errhead, const char *errinfo, char *target, size_t size)
Parsing function that prints an error message when there is no text in the buffer.
sequenceHandler_t handler
static int SEQ_ExecuteDelete(sequenceContext_t *context, const char *name, const char *data)
Removed a sequence entity from the current sequence.
void CL_ViewCalcFieldOfViewX(void)
Calculates refdef's FOV_X. Should generally be called after any changes are made to the zoom level (v...
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
model_t * R_FindModel(const char *name)
Tries to load a model.
void R_AnimRun(animState_t *as, const model_t *mod, int msec)
Run the animation of the given model.
void UI_Transform(const vec3_t transform, const vec3_t rotate, const vec3_t scale)
Pushes a new matrix, normalize to current resolution and move, rotate and scale the matrix to the giv...
static char const *const seqCmdName[]
void S_StartLocalSample(const char *s, float volume)
Plays a sample without spatialization.
#define Mem_PoolAllocTypeN(type, n, pool)
int Com_EParseValue(void *base, const char *token, valueTypes_t type, int ofs, size_t size)
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
static int SEQ_ExecutePrecache(sequenceContext_t *context, const char *name, const char *data)
Precaches the models and images for a sequence.
bool Com_ParseList(const char **text, linkedList_t **list)
const char * CL_Translate(const char *t)
void R_PopMatrix(void)
Removes the current matrix from the stack.
static seqCmd_t * seqCmds
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
void CL_ViewUpdateRenderData(void)
Updates the refdef.
bool SEQ_Render(sequenceContext_t *context)
Execute and render a sequence.
#define MEMBER_SIZEOF(TYPE, MEMBER)
void R_EntitySetOrigin(entity_t *ent, const vec3_t origin)
setter for entity origin
int R_AddEntity(const entity_t *ent)
Adds a copy of the specified entity to the list of all known render entities.
static int SEQ_ExecuteCamera(sequenceContext_t *context, const char *name, const char *data)
Parse the values for the camera like given in seqCamera.
static sequence_t sequences[MAX_SEQUENCES]
static int SEQ_ExecuteObj2D(sequenceContext_t *context, const char *name, const char *data)
Parse 2D objects like text and images.
void R_DrawRect(int x, int y, int w, int h, const vec4_t color, float lineWidth, int pattern)
Draws a rect to the screen. Also has support for stippled rendering of the rect.
int UI_DrawString(const char *fontID, align_t align, int x, int y, int absX, int maxWidth, int lineHeight, const char *c, int boxHeight, int scrollPos, int *curLine, bool increaseLine, longlines_t method)
sequenceContext_t * SEQ_AllocContext(void)
Allocate a sequence context.
static int SEQ_ExecuteAnimSpeed(sequenceContext_t *context, const char *name, const char *data)
Set the animation speed, default value is 1000.
struct seq2D_s seq2D_t
Represents a text object or image object.
#define Mem_AllocType(type)
void Com_UnParseLastToken(void)
Put back the last token into the parser The next call of Com_Parse will return the same token again...
static void SEQ_SetCamera(sequenceContext_t *context)
Set the camera values for a sequence.
GLsizei const GLvoid * data
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
void R_DrawFill(int x, int y, int w, int h, const vec4_t color)
Fills a box of pixels with a single color.
void R_PushMatrix(void)
Push a new matrix to the stack.
seqEnt_t ents[MAX_SEQENTS]
static int CL_FindSequenceCommand(const char *commandName)
void SEQ_SetView(sequenceContext_t *context, vec2_t pos, vec2_t size)
Define the position of the viewport on the screen.
QGL_EXTERN int GLboolean GLfloat * v
static int SEQ_ExecuteCommand(sequenceContext_t *context, const char *name, const char *data)
Executes a sequence command.
static const value_t seqEnt_vals[]
valid entity names for a sequence
static void SEQ_Render2D(sequenceContext_t *context, bool backgroundObjects)
Renders text and images.
static int SEQ_ExecuteMusic(sequenceContext_t *context, const char *name, const char *data)
Changes the music in the sequence.
static void SEQ_Render3D(sequenceContext_t *context)
#define SND_VOLUME_DEFAULT
static void SEQ_StopSequence(sequenceContext_t *context)
Represents a text object or image object.