Make sure getmodelindex/modelnameforindex and sound equivelents are available in both ssqc and csqc.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6265 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2022-06-19 15:17:41 +00:00
parent ce01181d88
commit c39c4d0255
3 changed files with 60 additions and 8 deletions

View File

@ -4434,10 +4434,7 @@ void CL_LinkPacketEntities (void)
ent->shaderRGBAf[1] = (state->colormod[1]*8.0f)/256;
ent->shaderRGBAf[2] = (state->colormod[2]*8.0f)/256;
}
if (state->colormod[0] == 32 && state->colormod[1] == 32 && state->colormod[2] == 32)
VectorSet(ent->glowmod, 1, 1, 1);
else
VectorScale(state->glowmod, 1/255.0, ent->glowmod);
VectorScale(state->glowmod, 8.0/256.0, ent->glowmod);
#ifdef PEXT_FATNESS
//set trans

View File

@ -3270,6 +3270,30 @@ static void QCBUILTIN PF_cs_getmodelindex (pubprogfuncs_t *prinst, struct global
G_FLOAT(OFS_RETURN) = PF_cs_PrecacheModel_Internal(prinst, s, queryonly);
}
static void QCBUILTIN PF_cs_getsoundindex (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
const char *s = PR_GetStringOfs(prinst, OFS_PARM0);
qboolean queryonly = (prinst->callargc >= 2)?G_FLOAT(OFS_PARM1):false;
int i;
G_FLOAT(OFS_RETURN) = 0;
//look for the server's names first...
for (i = 1; i < MAX_PRECACHE_SOUNDS; i++)
{
if (!*cl.sound_name[i])
break;
if (!strcmp(cl.sound_name[i], s))
{
G_FLOAT(OFS_RETURN) = i;
return;
}
}
//FIXME: we don't track clientside sound precaches (the sound system has its own, but can be flushed at any time forgetting/reordering them)
//can still make sure its cached though.
if (!queryonly)
S_PrecacheSound(s);
}
static void QCBUILTIN PF_cs_precachefile(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
const char *filename = PR_GetStringOfs(prinst, OFS_PARM0);
@ -3288,10 +3312,22 @@ static void QCBUILTIN PF_cs_ModelnameForIndex(pubprogfuncs_t *prinst, struct glo
{
int modelindex = G_FLOAT(OFS_PARM0);
if (modelindex < 0)
if (modelindex < 0 && (-modelindex) < MAX_CSMODELS)
G_INT(OFS_RETURN) = (int)PR_SetString(prinst, cl.model_csqcname[-modelindex]);
else
else if (modelindex >= 0 && modelindex < MAX_PRECACHE_MODELS)
G_INT(OFS_RETURN) = (int)PR_SetString(prinst, cl.model_name[modelindex]);
else
G_INT(OFS_RETURN) = 0;
}
static void QCBUILTIN PF_cs_SoundnameForIndex(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int soundindex = G_FLOAT(OFS_PARM0);
//FIXME: no private indexes. still useful for sending sound names from the ssqc via indexes.
if (soundindex >= 0 && soundindex < MAX_PRECACHE_SOUNDS)
G_INT(OFS_RETURN) = (int)PR_SetString(prinst, cl.sound_name[soundindex]);
else
G_INT(OFS_RETURN) = 0;
}
static void QCBUILTIN PF_cs_spriteframe(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
@ -7004,6 +7040,7 @@ static struct {
//200
{"getmodelindex", PF_cs_getmodelindex, 200},
{"getsoundindex", PF_cs_getsoundindex, 0},
{"externcall", PF_externcall, 201},
{"addprogs", PF_cs_addprogs, 202},
{"externvalue", PF_externvalue, 203},
@ -7225,6 +7262,7 @@ static struct {
{"getplayerstat", PF_cs_getplayerstat, 0}, // #0 __variant(float playernum, float statnum, float stattype) getplayerstat
{"setmodelindex", PF_cs_SetModelIndex, 333}, // #333 void(entity e, float mdlindex) setmodelindex (EXT_CSQC)
{"modelnameforindex", PF_cs_ModelnameForIndex, 334}, // #334 string(float mdlindex) modelnameforindex (EXT_CSQC)
{"soundnameforindex", PF_cs_SoundnameForIndex, 0},
{"particleeffectnum", PF_cs_particleeffectnum, 335}, // #335 float(string effectname) particleeffectnum (EXT_CSQC)
{"trailparticles", PF_cs_trailparticles, 336}, // #336 void(float effectnum, entity ent, vector start, vector end) trailparticles (EXT_CSQC),

View File

@ -4503,6 +4503,14 @@ static void QCBUILTIN PF_getsoundindex (pubprogfuncs_t *prinst, struct globalvar
G_FLOAT(OFS_RETURN) = PF_precache_sound_Internal(prinst, s, queryonly);
}
static void QCBUILTIN PF_soundnameforindex (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int idx = G_FLOAT(OFS_PARM0);
if (idx >= 0 && idx < MAX_PRECACHE_SOUNDS && sv.strings.sound_precache)
RETURN_TSTRING(sv.strings.sound_precache[idx]);
else
G_INT(OFS_RETURN) = 0;
}
int PF_precache_model_Internal (pubprogfuncs_t *prinst, const char *s, qboolean queryonly)
{
@ -4594,6 +4602,14 @@ static void QCBUILTIN PF_getmodelindex (pubprogfuncs_t *prinst, struct globalvar
G_FLOAT(OFS_RETURN) = PF_precache_model_Internal(prinst, s, queryonly);
}
static void QCBUILTIN PF_modelnameforindex (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int idx = G_FLOAT(OFS_PARM0);
if (idx >= 0 && idx < MAX_PRECACHE_MODELS && sv.strings.model_precache)
RETURN_TSTRING(sv.strings.model_precache[idx]);
else
G_INT(OFS_RETURN) = 0;
}
#ifdef HAVE_LEGACY
void QCBUILTIN PF_precache_vwep_model (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
@ -11339,8 +11355,8 @@ static BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
// {"findlist_radius", PF_FindListRadius, 0, 0, 0, 0, D("entity*(vector pos, float radius)", "Return a list of entities with the given string field set to the given value.")},
// {"traceboxptr", PF_TraceBox, 0, 0, 0, 0, D("typedef struct {\nfloat allsolid;\nfloat startsolid;\nfloat fraction;\nfloat truefraction;\nentity ent;\nvector endpos;\nvector plane_normal;\nfloat plane_dist;\nint surfaceflags;\nint contents;\n} trace_t;\nvoid(trace_t *trace, vector start, vector mins, vector maxs, vector end, float nomonsters, entity forent)", "Like regular tracebox, except doesn't doesn't use any evil globals.")},
{"getsoundindex", PF_getsoundindex, 0, 0, 0, 0, D("float(string soundname, float queryonly)", "Provides a way to query if a sound is already precached or not. The return value can also be checked for <=255 to see if it'll work over any network protocol. The sound index can also be used for writebyte hacks, but this is discouraged - use SOUNDFLAG_UNICAST instead.")},
{"getmodelindex", PF_getmodelindex, 0, 0, 0, 200, D("float(string modelname, optional float queryonly)", "Acts as an alternative to precache_model(foo);setmodel(bar, foo); return bar.modelindex;\nIf queryonly is set and the model was not previously precached, the builtin will return 0 without needlessly precaching the model.")},
{"getsoundindex", PF_getsoundindex, 0, 0, 0, 0, D("float(string soundname, optional float queryonly)", "Provides a way to query if a sound is already precached or not. The return value can also be checked for <=255 to see if it'll work over any network protocol. The sound index can also be used for writebyte hacks, but this is discouraged - use SOUNDFLAG_UNICAST instead.")},
{"externcall", PF_externcall, 0, 0, 0, 201, D("__variant(float prnum, string funcname, ...)", "Directly call a function in a different/same progs by its name.\nprnum=0 is the 'default' or 'main' progs.\nprnum=-1 means current progs.\nprnum=-2 will scan through the active progs and will use the first it finds.")},
{"addprogs", PF_addprogs, 0, 0, 0, 202, D("float(string progsname)", "Loads an additional .dat file into the current qcvm. The returned handle can be used with any of the externcall/externset/externvalue builtins.\nThere are cvars that allow progs to be loaded automatically.")},
{"externvalue", PF_externvalue, 0, 0, 0, 203, D("__variant(float prnum, string varname)", "Reads a global in the named progs by the name of that global.\nprnum=0 is the 'default' or 'main' progs.\nprnum=-1 means current progs.\nprnum=-2 will scan through the active progs and will use the first it finds.")},
@ -11635,7 +11651,8 @@ static BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
//EXT_CSQC
{"setmodelindex", PF_Fixme, 0, 0, 0, 333, D("void(entity e, float mdlindex)", "Sets a model by precache index instead of by name. Otherwise identical to setmodel.")},//
{"modelnameforindex",PF_Fixme, 0, 0, 0, 334, D("string(float mdlindex)", "Retrieves the name of the model based upon a precache index. This can be used to reduce csqc network traffic by enabling model matching.")},//
{"modelnameforindex",PF_modelnameforindex,0,0, 0, 334, D("string(float mdlindex)", "Retrieves the name of the model based upon a precache index. This can be used to reduce csqc network traffic by enabling model matching (with getmodelindex).")},//
{"soundnameforindex",PF_soundnameforindex,0,0, 0, 0, D("string(float sndindex)", "Retrieves the name of the sound based upon a precache index. This can be used to reduce csqc network traffic by enabling sound matching (with getsoundindex).")},//
{"particleeffectnum",PF_sv_particleeffectnum,0,0,0, 335, D("float(string effectname)", "Precaches the named particle effect. If your effect name is of the form 'foo.bar' then particles/foo.cfg will be loaded by the client if foo.bar was not already defined.\nDifferent engines will have different particle systems, this specifies the QC API only.")},// (EXT_CSQC)
{"trailparticles", PF_sv_trailparticles,0,0, 0, 336, D("void(float effectnum, entity ent, vector start, vector end)", "Draws the given effect between the two named points. If ent is not world, distances will be cached in the entity in order to avoid framerate dependancies. The entity is not otherwise used.")},// (EXT_CSQC),