1
0
Fork 0
forked from fte/fteqw

fix ogg audio truncation.

add trace_surfacename qc global string.
concession for nolegacy and viewheights. remember kids, be sure to use VF_ORIGIN.
qcc: optimisation for [0,foo,0] vectors.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4980 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2015-09-02 03:12:25 +00:00
parent c15ce364be
commit a6c66182ba
13 changed files with 92 additions and 53 deletions

View file

@ -153,6 +153,7 @@ extern sfx_t *cl_sfx_r_exp3;
globalfloat(trace_plane_dist, "trace_plane_dist"); /*float written by traceline*/ \
globalentity(trace_ent, "trace_ent"); /*entity written by traceline*/ \
globalfloat(trace_surfaceflags, "trace_surfaceflags"); /*float written by traceline*/ \
globalstring(trace_surfacename, "trace_surfacename"); /*string written by traceline*/ \
globalfloat(trace_endcontents, "trace_endcontents"); /*float written by traceline EXT_CSQC_1*/ \
globalint(trace_brush_id, "trace_brush_id"); /*int written by traceline*/ \
globalint(trace_brush_faceid, "trace_brush_faceid"); /*int written by traceline*/ \
@ -2036,25 +2037,6 @@ static void QCBUILTIN PF_cs_SetSize (pubprogfuncs_t *prinst, struct globalvars_s
static void cs_settracevars(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals, trace_t *tr)
{
/*
world_t *w = prinst->parms->user;
*w->g.trace_allsolid = tr->allsolid;
*w->g.trace_startsolid = tr->startsolid;
*w->g.trace_fraction = tr->fraction;
*w->g.trace_inwater = tr->inwater;
*w->g.trace_inopen = tr->inopen;
VectorCopy (tr->endpos, w->g.trace_endpos);
VectorCopy (tr->plane.normal, w->g.trace_plane_normal);
*w->g.trace_plane_dist = tr->plane.dist;
if (w->g.trace_surfaceflags)
*w->g.trace_surfaceflags = tr->surface?tr->surface->flags:0;
if (w->g.trace_endcontents)
*w->g.trace_endcontents = tr->contents;
if (tr->ent)
*w->g.trace_ent = EDICT_TO_PROG(prinst, (void*)tr->ent);
else
*w->g.trace_ent = EDICT_TO_PROG(prinst, (void*)w->edicts);
*/
*csqcg.trace_allsolid = tr->allsolid;
*csqcg.trace_startsolid = tr->startsolid;
*csqcg.trace_fraction = tr->fraction;
@ -2065,6 +2047,8 @@ static void cs_settracevars(pubprogfuncs_t *prinst, struct globalvars_s *pr_glob
*csqcg.trace_plane_dist = tr->plane.dist;
if (csqcg.trace_surfaceflags)
*csqcg.trace_surfaceflags = tr->surface?tr->surface->flags:0;
if (csqcg.trace_surfacename)
prinst->SetStringField(prinst, NULL, csqcg.trace_surfacename, tr->surface?tr->surface->name:NULL, true);
if (csqcg.trace_endcontents)
*csqcg.trace_endcontents = tr->contents;
if (csqcg.trace_brush_id)

View file

@ -151,6 +151,8 @@ static sfxcache_t *OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, ssam
int outspeed = snd_speed;
int errorcode = 1;
// Con_Printf("Minlength = %03i ", minlength);
start *= 2*dec->srcchannels;
@ -158,6 +160,9 @@ static sfxcache_t *OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, ssam
if (start < dec->decodedbytestart)
{
Con_Printf("Rewound to %i\n", start);
dec->failed = false;
/*something rewound, purge clear the buffer*/
dec->decodedbytecount = 0;
dec->decodedbytestart = start;
@ -184,14 +189,17 @@ static sfxcache_t *OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, ssam
{
dec->decodedbytecount = 0;
dec->decodedbytestart = start;
Con_Printf("trim < 0\n");
}
else if (trim > dec->decodedbytecount)
{
dec->decodedbytecount = 0;
dec->decodedbytestart = start;
Con_Printf("trim > count\n");
}
else
{
Con_Printf("trim retain\n");
//FIXME: retain an extra half-second for dual+ sound devices running slightly out of sync
memmove(dec->decodedbuffer, dec->decodedbuffer + trim, dec->decodedbytecount - trim);
dec->decodedbytecount -= trim;
@ -201,7 +209,7 @@ static sfxcache_t *OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, ssam
for (;;)
{
if (start+length <= dec->decodedbytestart + dec->decodedbytecount)
if (dec->failed || start+length <= dec->decodedbytestart + dec->decodedbytecount)
break;
if (dec->decodedbufferbytes < start+length - dec->decodedbytestart + 128) //expand if needed.
@ -218,8 +226,9 @@ static sfxcache_t *OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, ssam
{
if (bytesread != 0) //0==eof
{
dec->failed = true;
Con_Printf("ogg decoding failed\n");
return NULL;
break;
}
break;
}
@ -242,10 +251,11 @@ static sfxcache_t *OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, ssam
{
if (bytesread != 0) //0==eof
{
dec->failed = true;
Con_Printf("ogg decoding failed\n");
return NULL;
}
return NULL;
break;
}
SND_ResampleStream(dec->tempbuffer,
@ -429,7 +439,7 @@ static qboolean OV_StartDecode(unsigned char *start, unsigned long length, ovdec
buffer->pos = 0;
if (p_ov_open_callbacks(buffer, &buffer->vf, NULL, 0, callbacks))
{
Con_Printf("Input does not appear to be an Ogg Vorbis bitstream.\n");
Con_Printf("Input %s does not appear to be an Ogg Vorbis bitstream.\n", buffer->s->name);
return false;
}
@ -442,6 +452,7 @@ static qboolean OV_StartDecode(unsigned char *start, unsigned long length, ovdec
if (vi->channels < 1 || vi->channels > 2)
{
p_ov_clear (&buffer->vf);
Con_Printf("Input %s has %i channels.\n", buffer->s->name, vi->channels);
return false;
}

View file

@ -1350,8 +1350,7 @@ void V_CalcRefdef (playerview_t *pv)
V_AddIdle (pv);
viewheight = pv->viewheight;
#ifdef QUAKESTATS
if (viewheight == DEFAULT_VIEWHEIGHT)
if (viewheight == DEFAULT_VIEWHEIGHT && cls.protocol == CP_QUAKEWORLD && !(cls.z_ext & Z_EXT_VIEWHEIGHT))
{
if (view_message && view_message->flags & PF_GIB)
viewheight = 8; // gib view height
@ -1359,6 +1358,7 @@ void V_CalcRefdef (playerview_t *pv)
viewheight = 16; // corpse view height
}
#ifdef QUAKESTATS
if (pv->stats[STAT_HEALTH] < 0 && (!cl.spectator || pv->cam_state == CAM_EYECAM) && v_deathtilt.value) // PF_GIB will also set PF_DEAD
{
if (!cl.spectator || cl_chasecam.ival)

View file

@ -829,11 +829,7 @@ enum clcq2_ops_e
#define FITZ_B_ALPHA (1<<2)
#define RMQFITZ_B_SCALE (1<<3)
#ifdef QUAKESTATS
#define DEFAULT_VIEWHEIGHT 22
#else
#define DEFAULT_VIEWHEIGHT 0 //so csqc can position the camera without any worries.
#endif
// svc_print messages have an id, so messages can be filtered

View file

@ -66,7 +66,7 @@ pbool PreCompile(void)
if (sizeof(void*) > 4)
qcchunk = malloc(qcchunksize=512*1024*1024);
else
qcchunk = malloc(qcchunksize=128*1024*1024);
qcchunk = malloc(qcchunksize=256*1024*1024);
while(!qcchunk && qcchunksize > 8*1024*1024)
{
qcchunksize /= 2;

View file

@ -867,13 +867,18 @@ string_t PDECL PR_StringToProgs (pubprogfuncs_t *ppf, const char *str)
//if ed is null, fld points to a global. if str_is_static, then s doesn't need its own memory allocated.
void PDECL PR_SetStringField(pubprogfuncs_t *progfuncs, struct edict_s *ed, string_t *fld, const char *str, pbool str_is_static)
{
if (!str)
*fld = 0;
else
{
#ifdef QCGC
*fld = PR_AllocTempString(progfuncs, str);
*fld = PR_AllocTempString(progfuncs, str);
#else
if (!str_is_static)
str = PR_AddString(progfuncs, str, 0, false);
*fld = PR_StringToProgs(progfuncs, str);
if (!str_is_static)
str = PR_AddString(progfuncs, str, 0, false);
*fld = PR_StringToProgs(progfuncs, str);
#endif
}
}
char *PDECL PR_RemoveProgsString (pubprogfuncs_t *ppf, string_t str)

View file

@ -3323,14 +3323,14 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_
break;
case OP_BITCLR_I:
tmp = var_b;
var_b = var_a;
var_a = tmp;
if (QCC_OPCodeValid(&pr_opcodes[OP_BITCLRSTORE_I]))
{
op = &pr_opcodes[OP_BITCLRSTORE_I];
break;
}
tmp = var_b;
var_b = var_a;
var_a = tmp;
//fallthrough
case OP_BITCLRSTORE_I:
//b = var, a = bit field.
@ -3342,14 +3342,14 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_
var_c = ((op - pr_opcodes)==OP_BITCLRSTORE_I)?var_a:nullsref;
break;
case OP_BITCLR_F:
var_c = var_b;
var_b = var_a;
var_a = var_c;
if (QCC_OPCodeValid(&pr_opcodes[OP_BITCLRSTORE_F]))
{
op = &pr_opcodes[OP_BITCLRSTORE_F];
break;
}
var_c = var_b;
var_b = var_a;
var_a = var_c;
//fallthrough
case OP_BITCLRSTORE_F:
//b = var, a = bit field.
@ -6496,6 +6496,24 @@ QCC_ref_t *QCC_PR_ParseRefValue (QCC_ref_t *refbuf, QCC_type_t *assumeclass, pbo
QCC_FreeTemp(z);
return QCC_DefToRef(refbuf, d);
}
if (QCC_SRef_IsNull(y) && QCC_SRef_IsNull(z))
{
QCC_FreeTemp(y);
QCC_FreeTemp(z);
return QCC_DefToRef(refbuf, QCC_PR_StatementFlags(pr_opcodes + OP_MUL_VF, QCC_MakeVectorConst(1, 0, 0), QCC_SupplyConversion(x, ev_float, true), NULL, 0));
}
if (QCC_SRef_IsNull(x) && QCC_SRef_IsNull(z))
{
QCC_FreeTemp(x);
QCC_FreeTemp(z);
return QCC_DefToRef(refbuf, QCC_PR_StatementFlags(pr_opcodes + OP_MUL_VF, QCC_MakeVectorConst(0, 1, 0), QCC_SupplyConversion(y, ev_float, true), NULL, 0));
}
if (QCC_SRef_IsNull(x) && QCC_SRef_IsNull(y))
{
QCC_FreeTemp(x);
QCC_FreeTemp(y);
return QCC_DefToRef(refbuf, QCC_PR_StatementFlags(pr_opcodes + OP_MUL_VF, QCC_MakeVectorConst(0, 0, 1), QCC_SupplyConversion(z, ev_float, true), NULL, 0));
}
//pack the variables into a vector
d = QCC_GetTemp(type_vector);
@ -8175,14 +8193,14 @@ QCC_ref_t *QCC_PR_RefExpression (QCC_ref_t *retbuf, int priority, int exprflags)
//if we have no int types, force all ints to floats here, just to ensure that we don't end up with non-constant ints that we then can't cope with.
QCC_sref_t val, r;
QCC_statement_t *fromj, *elsej;
QCC_statement_t *fromj, *elsej, *truthstore;
if (QCC_PR_CheckToken(":"))
{
//r=a?:b -> if (a) r=a else r=b;
val = QCC_RefToDef(lhsr, true);
fromj = QCC_Generate_OP_IFNOT(val, true);
r = QCC_GetTemp(val.cast);
QCC_FreeTemp(QCC_PR_StatementFlags(&pr_opcodes[(r.cast->size>=3)?OP_STORE_V:OP_STORE_F], val, r, NULL, STFL_PRESERVEB));
QCC_FreeTemp(QCC_PR_StatementFlags(&pr_opcodes[(r.cast->size>=3)?OP_STORE_V:OP_STORE_F], val, r, &truthstore, STFL_PRESERVEB));
}
else
{
@ -8192,7 +8210,7 @@ QCC_ref_t *QCC_PR_RefExpression (QCC_ref_t *retbuf, int priority, int exprflags)
if (val.cast->type == ev_integer && !QCC_OPCodeValid(&pr_opcodes[OP_STORE_I]))
val = QCC_SupplyConversion(val, ev_float, true);
r = QCC_GetTemp(val.cast);
QCC_FreeTemp(QCC_PR_StatementFlags(&pr_opcodes[(r.cast->size>=3)?OP_STORE_V:OP_STORE_F], val, r, NULL, STFL_PRESERVEB));
QCC_FreeTemp(QCC_PR_StatementFlags(&pr_opcodes[(r.cast->size>=3)?OP_STORE_V:OP_STORE_F], val, r, &truthstore, STFL_PRESERVEB));
//r can be stomped upon until its reused anyway
QCC_PR_Expect(":");
@ -8203,15 +8221,17 @@ QCC_ref_t *QCC_PR_RefExpression (QCC_ref_t *retbuf, int priority, int exprflags)
if (val.cast->type == ev_integer && !QCC_OPCodeValid(&pr_opcodes[OP_STORE_I]))
val = QCC_SupplyConversion(val, ev_float, true);
/* //cond?5:5.1 should be accepted
if ((val->type->type != val->type->type) &&
(val->type->type == ev_float || val->type->type == ev_integer) &&
(r->type->type == ev_float || r->type->type == ev_integer))
{
val = QCC_SupplyConversion(val, ev_float, true);
r = QCC_SupplyConversion(r, ev_float, true);
if (r.cast->type == ev_integer && val.cast->type == ev_float)
{ //cond?5i:5.1 should be accepted. change the initial store_f to a store_if.
truthstore->op = OP_STORE_IF;
r.cast = type_float;
}
*/
else if (r.cast->type == ev_float && val.cast->type == ev_integer)
{
//cond?5.1:5i should be accepted. change the just-parsed value to a float, as needed.
val = QCC_SupplyConversion(val, ev_float, true);
}
if (typecmp(val.cast, r.cast) != 0)
{
//if they're mixed int/float, cast to floats.

View file

@ -3172,7 +3172,7 @@ void QCC_PR_Lex (void)
// if the first character is a valid identifier, parse until a non-id
// character is reached
if ((c == '%') && pr_file_p[1] >= '0' && pr_file_p[1] <= '9') //let's see which one we make into an operator first... possibly both...
if ((c == '%') && pr_file_p[1] >= '0' && pr_file_p[1] <= '9')
{
QCC_PR_ParseWarning(0, "%% prefixes to denote integers are deprecated. Please use a postfix of 'i'");
pr_file_p++;

View file

@ -3768,6 +3768,7 @@ pbool QCC_main (int argc, char **argv) //as part of the quake engine
tempsused = 0;
s_file = 0;
QCC_PurgeTemps();

View file

@ -673,6 +673,7 @@ void PR_LoadGlabalStruct(qboolean muted)
{
static float svphysicsmode = 2;
static float writeonly;
static int writeonly_int;
static float dimension_send_default;
static float dimension_default = 255;
static float zero_default;
@ -720,6 +721,9 @@ void PR_LoadGlabalStruct(qboolean muted)
globalfloat (false, trace_inwater);
globalfloat (false, trace_endcontents);
globalfloat (false, trace_surfaceflags);
globalstring (false, trace_surfacename);
globalint (false, trace_brush_id);
globalint (false, trace_brush_faceid);
globalfloat (false, cycle_wrapped);
globalint (false, msg_entity);
globalfunc (false, main);
@ -760,6 +764,8 @@ void PR_LoadGlabalStruct(qboolean muted)
ensureglobal(dimension_default, dimension_default);
ensureglobal(trace_endcontents, writeonly);
ensureglobal(trace_surfaceflags, writeonly);
ensureglobal(trace_brush_id, writeonly_int);
ensureglobal(trace_brush_faceid, writeonly_int);
ensureglobal(input_timelength, input_timelength_default);
ensureglobal(input_impulse, input_impulse_default);
@ -3117,7 +3123,11 @@ static void set_trace_globals(pubprogfuncs_t *prinst, struct globalvars_s *pr_gl
pr_global_struct->trace_inwater = trace->inwater;
pr_global_struct->trace_inopen = trace->inopen;
pr_global_struct->trace_surfaceflags = trace->surface?trace->surface->flags:0;
if (pr_global_struct->trace_surfacename)
prinst->SetStringField(prinst, NULL, &pr_global_struct->trace_surfacename, trace->surface?trace->surface->name:NULL, true);
pr_global_struct->trace_endcontents = trace->contents;
pr_global_struct->trace_brush_id = trace->brush_id;
pr_global_struct->trace_brush_faceid = trace->brush_face;
// if (trace.fraction != 1)
// VectorMA (trace->endpos, 4, trace->plane.normal, P_VEC(trace_endpos));
// else

View file

@ -945,6 +945,8 @@ static void set_trace_globals(trace_t *trace)
pr_global_struct->trace_inwater = trace->inwater;
pr_global_struct->trace_inopen = trace->inopen;
pr_global_struct->trace_surfaceflags = trace->surface?trace->surface->flags:0;
if (pr_global_struct->trace_surfacename)
prinst->SetStringField(prinst, NULL, &pr_global_struct->trace_surfacename, tr->surface?tr->surface->name:"", true);
pr_global_struct->trace_endcontents = trace->contents;
// if (trace.fraction != 1)
// VectorMA (trace->endpos, 4, trace->plane.normal, P_VEC(trace_endpos));

View file

@ -61,7 +61,10 @@ typedef struct nqglobalvars_s
float *trace_startsolid;
float *trace_fraction;
float *trace_surfaceflags;
string_t*trace_surfacename;
float *trace_endcontents;
int *trace_brush_id;
int *trace_brush_faceid;
vec3_t *trace_endpos;
vec3_t *trace_plane_normal;
float *trace_plane_dist;

View file

@ -6144,11 +6144,18 @@ int SV_PMTypeForClient (client_t *cl, edict_t *ent)
case MOVETYPE_NONE:
return PM_NONE;
#ifdef NOLEGACY
case MOVETYPE_TOSS:
case MOVETYPE_BOUNCE:
return PM_DEAD;
#endif
case MOVETYPE_WALK:
default:
#ifndef NOLEGACY
if (ent->v->health <= 0)
return PM_DEAD;
#endif
return PM_NORMAL;
}
}