X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=clvm_cmds.c;h=29ade032f819644c920cbe4c736279a43859af09;hb=df973c344562c8cadc2413d36dcaa03f8e9040c2;hp=1be822db3ae115043aff8ab8fedb35791c27a83d;hpb=775c0f6d056c37d2e23f9a96ec827023fe5e3404;p=xonotic%2Fdarkplaces.git diff --git a/clvm_cmds.c b/clvm_cmds.c index 1be822db..29ade032 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -50,7 +50,7 @@ static void VM_CL_setorigin (prvm_prog_t *prog) VM_Warning(prog, "setorigin: can not modify world entity\n"); return; } - if (e->priv.required->free) + if (e->free) { VM_Warning(prog, "setorigin: can not modify free entity\n"); return; @@ -151,7 +151,7 @@ static void VM_CL_setsize (prvm_prog_t *prog) VM_Warning(prog, "setsize: can not modify world entity\n"); return; } - if (e->priv.server->free) + if (e->free) { VM_Warning(prog, "setsize: can not modify free entity\n"); return; @@ -296,7 +296,7 @@ static void VM_CL_traceline (prvm_prog_t *prog) move = (int)PRVM_G_FLOAT(OFS_PARM2); ent = PRVM_G_EDICT(OFS_PARM3); - if (VEC_IS_NAN(v1[0]) || VEC_IS_NAN(v1[1]) || VEC_IS_NAN(v1[2]) || VEC_IS_NAN(v2[0]) || VEC_IS_NAN(v2[1]) || VEC_IS_NAN(v2[2])) + if (isnan(v1[0]) || isnan(v1[1]) || isnan(v1[2]) || isnan(v2[0]) || isnan(v2[1]) || isnan(v2[2])) prog->error_cmd("%s: NAN errors detected in traceline('%f %f %f', '%f %f %f', %i, entity %i)\n", prog->name, v1[0], v1[1], v1[2], v2[0], v2[1], v2[2], move, PRVM_EDICT_TO_PROG(ent)); trace = CL_TraceLine(v1, v2, move, ent, CL_GenericHitSuperContentsMask(ent), 0, 0, collision_extendtracelinelength.value, CL_HitNetworkBrushModels(move), CL_HitNetworkPlayers(move), &svent, true, false); @@ -336,7 +336,7 @@ static void VM_CL_tracebox (prvm_prog_t *prog) move = (int)PRVM_G_FLOAT(OFS_PARM4); ent = PRVM_G_EDICT(OFS_PARM5); - if (VEC_IS_NAN(v1[0]) || VEC_IS_NAN(v1[1]) || VEC_IS_NAN(v1[2]) || VEC_IS_NAN(v2[0]) || VEC_IS_NAN(v2[1]) || VEC_IS_NAN(v2[2])) + if (isnan(v1[0]) || isnan(v1[1]) || isnan(v1[2]) || isnan(v2[0]) || isnan(v2[1]) || isnan(v2[2])) prog->error_cmd("%s: NAN errors detected in tracebox('%f %f %f', '%f %f %f', '%f %f %f', '%f %f %f', %i, entity %i)\n", prog->name, v1[0], v1[1], v1[2], m1[0], m1[1], m1[2], m2[0], m2[1], m2[2], v2[0], v2[1], v2[2], move, PRVM_EDICT_TO_PROG(ent)); trace = CL_TraceBox(v1, m1, m2, v2, move, ent, CL_GenericHitSuperContentsMask(ent), 0, 0, collision_extendtraceboxlength.value, CL_HitNetworkBrushModels(move), CL_HitNetworkPlayers(move), &svent, true); @@ -469,7 +469,7 @@ static void VM_CL_findradius (prvm_prog_t *prog) else chainfield = prog->fieldoffsets.chain; if(chainfield < 0) - prog->error_cmd("VM_findchain: %s doesnt have the specified chain field !", prog->name); + prog->error_cmd("VM_CL_findradius: %s doesnt have the specified chain field !", prog->name); chain = (prvm_edict_t *)prog->edicts; @@ -519,6 +519,42 @@ static void VM_CL_findradius (prvm_prog_t *prog) VM_RETURN_EDICT(chain); } +// #566 entity(vector mins, vector maxs) findbox +// #566 entity(vector mins, vector maxs, .entity tofield) findbox_tofield +static void VM_CL_findbox (prvm_prog_t *prog) +{ + prvm_edict_t *chain; + int i, numtouchedicts; + static prvm_edict_t *touchedicts[MAX_EDICTS]; + int chainfield; + + VM_SAFEPARMCOUNTRANGE(2, 3, VM_CL_findbox); + + if(prog->argc == 3) + chainfield = PRVM_G_INT(OFS_PARM2); + else + chainfield = prog->fieldoffsets.chain; + if(chainfield < 0) + prog->error_cmd("VM_CL_findbox: %s doesnt have the specified chain field !", prog->name); + + chain = (prvm_edict_t *)prog->edicts; + + numtouchedicts = World_EntitiesInBox(&cl.world, PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), MAX_EDICTS, touchedicts); + if (numtouchedicts > MAX_EDICTS) + { + // this never happens //[515]: for what then ? + Con_Printf("World_EntitiesInBox returned %i edicts, max was %i\n", numtouchedicts, MAX_EDICTS); + numtouchedicts = MAX_EDICTS; + } + for (i = 0; i < numtouchedicts; ++i) + { + PRVM_EDICTFIELDEDICT(touchedicts[i], chainfield) = PRVM_EDICT_TO_PROG(chain); + chain = touchedicts[i]; + } + + VM_RETURN_EDICT(chain); +} + // #34 float() droptofloor static void VM_CL_droptofloor (prvm_prog_t *prog) { @@ -537,7 +573,7 @@ static void VM_CL_droptofloor (prvm_prog_t *prog) VM_Warning(prog, "droptofloor: can not modify world entity\n"); return; } - if (ent->priv.server->free) + if (ent->free) { VM_Warning(prog, "droptofloor: can not modify free entity\n"); return; @@ -547,7 +583,12 @@ static void VM_CL_droptofloor (prvm_prog_t *prog) VectorCopy(PRVM_clientedictvector(ent, mins), mins); VectorCopy(PRVM_clientedictvector(ent, maxs), maxs); VectorCopy(PRVM_clientedictvector(ent, origin), end); - end[2] -= 256; + if (cl.worldmodel->brush.isq3bsp) + end[2] -= 4096; + else if (cl.worldmodel->brush.isq2bsp) + end[2] -= 128; + else + end[2] -= 256; // Quake, QuakeWorld trace = CL_TraceBox(start, mins, maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), 0, 0, collision_extendmovelength.value, true, true, NULL, true); @@ -761,14 +802,14 @@ static void VM_CL_R_AddEntities (prvm_prog_t *prog) // so we can easily check if CSQC entity #edictnum is currently drawn cl.csqcrenderentities[i].entitynumber = 0; ed = &prog->edicts[i]; - if(ed->priv.required->free) + if(ed->free) continue; CSQC_Think(ed); - if(ed->priv.required->free) + if(ed->free) continue; // note that for RF_USEAXIS entities, Predraw sets v_forward/v_right/v_up globals that are read by CSQC_AddRenderEdict CSQC_Predraw(ed); - if(ed->priv.required->free) + if(ed->free) continue; if(!((int)PRVM_clientedictfloat(ed, drawmask) & drawmask)) continue; @@ -1215,7 +1256,7 @@ void VM_drawline (prvm_prog_t *prog) rgb = PRVM_G_VECTOR(OFS_PARM3); alpha = PRVM_G_FLOAT(OFS_PARM4); flags = (int)PRVM_G_FLOAT(OFS_PARM5); - DrawQ_Line(width, c1[0], c1[1], c2[0], c2[1], rgb[0], rgb[1], rgb[2], alpha, flags, false); + DrawQ_Line(width, c1[0], c1[1], c2[0], c2[1], rgb[0], rgb[1], rgb[2], alpha, flags); } /* @@ -1622,7 +1663,7 @@ void VM_loadfont(prvm_prog_t *prog) f->req_face = 0; c = cm; } - if(!c || (c - filelist) > MAX_QPATH) + if(!c || (c - filelist) >= MAX_QPATH) strlcpy(mainfont, filelist, sizeof(mainfont)); else { @@ -1648,7 +1689,7 @@ void VM_loadfont(prvm_prog_t *prog) f->fallback_faces[i] = 0; // f->req_face; could make it stick to the default-font's face index c = cm; } - if(!c || (c-filelist) > MAX_QPATH) + if(!c || (c-filelist) >= MAX_QPATH) { strlcpy(f->fallbacks[i], filelist, sizeof(mainfont)); } @@ -2402,8 +2443,7 @@ static void VM_CL_setlistener (prvm_prog_t *prog) static void VM_CL_registercmd (prvm_prog_t *prog) { VM_SAFEPARMCOUNT(1, VM_CL_registercmd); - if(!Cmd_Exists(cmd_local, PRVM_G_STRING(OFS_PARM0))) - Cmd_AddCommand(CF_CLIENT, PRVM_G_STRING(OFS_PARM0), NULL, "console command created by QuakeC"); + Cmd_AddCommand(CF_CLIENT, PRVM_G_STRING(OFS_PARM0), NULL, "console command created by QuakeC"); } //#360 float() readbyte (EXT_CSQC) @@ -2523,7 +2563,7 @@ static void VM_CL_makestatic (prvm_prog_t *prog) VM_Warning(prog, "makestatic: can not modify world entity\n"); return; } - if (ent->priv.server->free) + if (ent->free) { VM_Warning(prog, "makestatic: can not modify free entity\n"); return; @@ -2619,7 +2659,7 @@ static void VM_CL_copyentity (prvm_prog_t *prog) VM_Warning(prog, "copyentity: can not read world entity\n"); return; } - if (in->priv.server->free) + if (in->free) { VM_Warning(prog, "copyentity: can not read free entity\n"); return; @@ -2630,15 +2670,13 @@ static void VM_CL_copyentity (prvm_prog_t *prog) VM_Warning(prog, "copyentity: can not modify world entity\n"); return; } - if (out->priv.server->free) + if (out->free) { VM_Warning(prog, "copyentity: can not modify free entity\n"); return; } memcpy(out->fields.fp, in->fields.fp, prog->entityfields * sizeof(prvm_vec_t)); - if (VectorCompare(PRVM_clientedictvector(out, absmin), PRVM_clientedictvector(out, absmax))) - return; CL_LinkEdict(out); } @@ -3089,7 +3127,7 @@ static void VM_CL_setattachment (prvm_prog_t *prog) VM_Warning(prog, "setattachment: can not modify world entity\n"); return; } - if (e->priv.server->free) + if (e->free) { VM_Warning(prog, "setattachment: can not modify free entity\n"); return; @@ -3229,7 +3267,7 @@ int CL_GetTagMatrix (prvm_prog_t *prog, matrix4x4_t *out, prvm_edict_t *ent, int if (ent == prog->edicts) return 1; - if (ent->priv.server->free) + if (ent->free) return 2; model = CL_GetModelFromEdict(ent); @@ -3321,7 +3359,7 @@ static void VM_CL_gettagindex (prvm_prog_t *prog) VM_Warning(prog, "VM_CL_gettagindex(entity #%i): can't affect world entity\n", PRVM_NUM_FOR_EDICT(ent)); return; } - if (ent->priv.server->free) + if (ent->free) { VM_Warning(prog, "VM_CL_gettagindex(entity #%i): can't affect free entity\n", PRVM_NUM_FOR_EDICT(ent)); return; @@ -4416,7 +4454,7 @@ static void VM_CL_walkmove (prvm_prog_t *prog) VM_Warning(prog, "walkmove: can not modify world entity\n"); return; } - if (ent->priv.server->free) + if (ent->free) { VM_Warning(prog, "walkmove: can not modify free entity\n"); return; @@ -4487,7 +4525,7 @@ static void VM_CL_checkpvs (prvm_prog_t *prog) VectorCopy(PRVM_G_VECTOR(OFS_PARM0), viewpos); viewee = PRVM_G_EDICT(OFS_PARM1); - if(viewee->priv.required->free) + if(viewee->free) { VM_Warning(prog, "checkpvs: can not check free entity\n"); PRVM_G_FLOAT(OFS_RETURN) = 4; @@ -5052,7 +5090,7 @@ VM_fclose, // #111 void(float fhandle) fclose (FRIK_FILE) VM_fgets, // #112 string(float fhandle) fgets (FRIK_FILE) VM_fputs, // #113 void(float fhandle, string s) fputs (FRIK_FILE) VM_strlen, // #114 float(string s) strlen (FRIK_FILE) -VM_strcat, // #115 string(string s1, string s2, ...) strcat (FRIK_FILE) +VM_strcat, // #115 string(string s, string...) strcat (FRIK_FILE) VM_substring, // #116 string(string s, float start, float length) substring (FRIK_FILE) VM_stov, // #117 vector(string) stov (FRIK_FILE) VM_strzone, // #118 string(string s) strzone (FRIK_FILE) @@ -5114,7 +5152,7 @@ NULL, // #173 NULL, // #174 NULL, // #175 NULL, // #176 -NULL, // #177 +VM_localsound, // #177 NULL, // #178 NULL, // #179 NULL, // #180 @@ -5506,8 +5544,8 @@ NULL, // #562 NULL, // #563 NULL, // #564 NULL, // #565 -NULL, // #566 -NULL, // #567 +VM_CL_findbox, // #566 entity(vector mins, vector maxs) findbox = #566; (DP_QC_FINDBOX) +VM_nudgeoutofsolid, // #567 float(entity ent) nudgeoutofsolid = #567; (DP_QC_NUDGEOUTOFSOLID) NULL, // #568 NULL, // #569 NULL, // #570