X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=svvm_cmds.c;h=c5db79beb498c8c9ef98a4c9446965b6ded87f99;hb=4d1fd3c5300f6db48293cb15df23bf4d2590eed9;hp=e62b2511b1d300b7b8ef518a35255af70892fef1;hpb=d1c3192285c25bf7b4a00fc70986df1ce514ee2b;p=xonotic%2Fdarkplaces.git diff --git a/svvm_cmds.c b/svvm_cmds.c index e62b2511..c5db79be 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -4,7 +4,7 @@ // Server #define PF_WARNING(s) do{Con_Printf(s);PRVM_PrintState();return;}while(0) -cvar_t sv_aim = {CVAR_SAVE, "sv_aim", "2"}; //"0.93"}; // LordHavoc: disabled autoaim by default +cvar_t sv_aim = {CVAR_SAVE, "sv_aim", "2", "maximum cosine angle for quake's vertical autoaim, a value above 1 completely disables the autoaim, quake used 0.93"}; //"0.93"}; // LordHavoc: disabled autoaim by default char *vm_sv_extensions = @@ -111,6 +111,7 @@ char *vm_sv_extensions = "DP_TE_SMALLFLASH " "DP_TE_SPARK " "DP_TE_STANDARDEFFECTBUILTINS " +"DP_TRACE_HITCONTENTSMASK_SURFACEINFO " "DP_VIEWZOOM " "EXT_BITSHIFT " //"EXT_CSQC " // not ready yet @@ -265,9 +266,12 @@ void PF_sprint (void) } client = svs.clients + entnum-1; + if (!client->netconnection) + return; + VM_VarString(1, string, sizeof(string)); - MSG_WriteChar(&client->message,svc_print); - MSG_WriteString(&client->message, string); + MSG_WriteChar(&client->netconnection->message,svc_print); + MSG_WriteString(&client->netconnection->message, string); } @@ -295,9 +299,12 @@ void PF_centerprint (void) } client = svs.clients + entnum-1; + if (!client->netconnection) + return; + VM_VarString(1, string, sizeof(string)); - MSG_WriteChar(&client->message,svc_centerprint); - MSG_WriteString(&client->message, string); + MSG_WriteChar(&client->netconnection->message,svc_centerprint); + MSG_WriteString(&client->netconnection->message, string); } /* @@ -425,6 +432,7 @@ void PF_traceline (void) trace_t trace; int move; prvm_edict_t *ent; + prvm_eval_t *val; prog->xfunction->builtinsprofile += 30; @@ -433,6 +441,9 @@ void PF_traceline (void) move = PRVM_G_FLOAT(OFS_PARM2); ent = PRVM_G_EDICT(OFS_PARM3); + if (IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || IS_NAN(v2[0]) || IS_NAN(v1[2]) || IS_NAN(v2[2])) + PRVM_ERROR("%s: NAN errors detected in traceline('%f %f %f', '%f %f %f', %i, entity %i)\n", PRVM_NAME, v1[0], v1[1], v1[2], v2[0], v2[1], v2[2], move, PRVM_EDICT_TO_PROG(ent)); + trace = SV_Move (v1, vec3_origin, vec3_origin, v2, move, ent); prog->globals.server->trace_allsolid = trace.allsolid; @@ -447,7 +458,23 @@ void PF_traceline (void) prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(trace.ent); else prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(prog->edicts); - // FIXME: add trace_endcontents + if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dpstartcontents))) + val->_float = trace.startsupercontents; + if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitcontents))) + val->_float = trace.hitsupercontents; + if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitq3surfaceflags))) + val->_float = trace.hitq3surfaceflags; + if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphittexturename))) + { + if (trace.hittexture) + { + char *s = VM_GetTempString(); + strlcpy(s, trace.hittexture->name, VM_STRINGTEMP_LENGTH); + val->string = PRVM_SetEngineString(s); + } + else + val->string = 0; + } } @@ -469,6 +496,7 @@ void PF_tracebox (void) trace_t trace; int move; prvm_edict_t *ent; + prvm_eval_t *val; prog->xfunction->builtinsprofile += 30; @@ -479,6 +507,9 @@ void PF_tracebox (void) move = PRVM_G_FLOAT(OFS_PARM4); ent = PRVM_G_EDICT(OFS_PARM5); + if (IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || IS_NAN(v2[0]) || IS_NAN(v1[2]) || IS_NAN(v2[2])) + PRVM_ERROR("%s: NAN errors detected in tracebox('%f %f %f', '%f %f %f', '%f %f %f', '%f %f %f', %i, entity %i)\n", PRVM_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 = SV_Move (v1, m1, m2, v2, move, ent); prog->globals.server->trace_allsolid = trace.allsolid; @@ -493,6 +524,23 @@ void PF_tracebox (void) prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(trace.ent); else prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(prog->edicts); + if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dpstartcontents))) + val->_float = trace.startsupercontents; + if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitcontents))) + val->_float = trace.hitsupercontents; + if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitq3surfaceflags))) + val->_float = trace.hitq3surfaceflags; + if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphittexturename))) + { + if (trace.hittexture) + { + char *s = VM_GetTempString(); + strlcpy(s, trace.hittexture->name, VM_STRINGTEMP_LENGTH); + val->string = PRVM_SetEngineString(s); + } + else + val->string = 0; + } } extern trace_t SV_Trace_Toss (prvm_edict_t *ent, prvm_edict_t *ignore); @@ -501,6 +549,7 @@ void PF_tracetoss (void) trace_t trace; prvm_edict_t *ent; prvm_edict_t *ignore; + prvm_eval_t *val; prog->xfunction->builtinsprofile += 600; @@ -523,6 +572,23 @@ void PF_tracetoss (void) prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(trace.ent); else prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(prog->edicts); + if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dpstartcontents))) + val->_float = trace.startsupercontents; + if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitcontents))) + val->_float = trace.hitsupercontents; + if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitq3surfaceflags))) + val->_float = trace.hitq3surfaceflags; + if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphittexturename))) + { + if (trace.hittexture) + { + char *s = VM_GetTempString(); + strlcpy(s, trace.hittexture->name, VM_STRINGTEMP_LENGTH); + val->string = PRVM_SetEngineString(s); + } + else + val->string = 0; + } } @@ -869,11 +935,11 @@ void PF_lightstyle (void) for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++) { - if (client->active) + if (client->active && client->netconnection) { - MSG_WriteChar (&client->message, svc_lightstyle); - MSG_WriteChar (&client->message,style); - MSG_WriteString (&client->message, val); + MSG_WriteChar (&client->netconnection->message, svc_lightstyle); + MSG_WriteChar (&client->netconnection->message,style); + MSG_WriteString (&client->netconnection->message, val); } } } @@ -1126,13 +1192,13 @@ sizebuf_t *WriteDest (void) case MSG_ONE: ent = PRVM_PROG_TO_EDICT(prog->globals.server->msg_entity); entnum = PRVM_NUM_FOR_EDICT(ent); - if (entnum < 1 || entnum > svs.maxclients || !svs.clients[entnum-1].active) + if (entnum < 1 || entnum > svs.maxclients || !svs.clients[entnum-1].active || !svs.clients[entnum-1].netconnection) { Con_Printf ("WriteDest: tried to write to non-client\n"); return &sv.reliable_datagram; } else - return &svs.clients[entnum-1].message; + return &svs.clients[entnum-1].netconnection->message; default: Con_Printf ("WriteDest: bad destination\n"); @@ -2246,7 +2312,7 @@ int SV_GetEntityLocalTagMatrix(prvm_edict_t *ent, int tagindex, matrix4x4_t *out frame = 0; return Mod_Alias_GetTagMatrix(model, model->animscenes[frame].firstframe, tagindex, out); } - Matrix4x4_CreateIdentity(out); + *out = identitymatrix; return 0; } @@ -2268,7 +2334,7 @@ int SV_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex) matrix4x4_t entitymatrix, tagmatrix, attachmatrix; model_t *model; - Matrix4x4_CreateIdentity(out); // warnings and errors return identical matrix + *out = identitymatrix; // warnings and errors return identical matrix if (ent == prog->edicts) return 1; @@ -2281,7 +2347,7 @@ int SV_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex) model = sv.models[modelindex]; - Matrix4x4_CreateIdentity(&tagmatrix); + tagmatrix = identitymatrix; // DP_GFX_QUAKE3MODELTAGS, scan all chain and stop on unattached entity attachloop = 0; for (;;) @@ -2428,6 +2494,9 @@ void PF_spawnclient (void) { prog->xfunction->builtinsprofile += 100; SV_ConnectClient (i, NULL); + // this has to be set or else ClientDisconnect won't be called + // we assume the qc will call ClientConnect... + svs.clients[i].clientconnectcalled = true; ed = PRVM_EDICT_NUM(i + 1); break; } @@ -2687,7 +2756,7 @@ NULL, // #476 NULL, // #477 NULL, // #478 NULL, // #479 -e10, e10 // #471-499 (LordHavoc) +e10, e10 // #480-499 (LordHavoc) }; const int vm_sv_numbuiltins = sizeof(vm_sv_builtins) / sizeof(prvm_builtin_t);