From 06e26d380869092af87f9281826037d5ac4afff2 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sat, 20 Jun 2015 14:22:06 +0000 Subject: [PATCH] tweaks for ktx/nq clients. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4913 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cd_win.c | 4 ++-- engine/server/pr_cmds.c | 7 +++---- engine/server/pr_q1qvm.c | 25 +++++++++++++++++------ engine/server/progs.h | 3 +-- engine/server/sv_main.c | 19 +++++++++-------- engine/server/sv_mvd.c | 4 ++-- engine/server/sv_user.c | 34 ++++++++++++++++++++++--------- engine/shaders/glsl/lpp_wall.glsl | 2 +- 8 files changed, 63 insertions(+), 35 deletions(-) diff --git a/engine/client/cd_win.c b/engine/client/cd_win.c index f3e49d9c7..7e633df29 100644 --- a/engine/client/cd_win.c +++ b/engine/client/cd_win.c @@ -264,7 +264,7 @@ void CDAudio_Stop(void) dwReturn = mciSendCommand(wDeviceID, MCI_STOP, 0, (DWORD_PTR)NULL); if (dwReturn) - Con_DPrintf("MCI_STOP failed (%i)", (int)dwReturn); + Con_DPrintf("MCI_STOP failed (%i)\n", (int)dwReturn); } @@ -279,7 +279,7 @@ void CDAudio_Pause(void) mciGenericParms.dwCallback = (DWORD_PTR)mainwindow; dwReturn = mciSendCommand(wDeviceID, MCI_PAUSE, 0, (DWORD_PTR)(LPVOID) &mciGenericParms); if (dwReturn) - Con_DPrintf("MCI_PAUSE failed (%i)", (int)dwReturn); + Con_DPrintf("MCI_PAUSE failed (%i)\n", (int)dwReturn); pollneeded = false; } diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index c854ac0dd..70a0364fb 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -1879,8 +1879,7 @@ qboolean PR_UserCmd(char *s) { pr_global_struct->time = sv.world.physicstime; pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player); - Q1QVM_ClientCommand(); - return true; //qvm can print something if it wants + return Q1QVM_ClientCommand(); } #endif @@ -9973,8 +9972,8 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs // {"log", PF_Fixme, 0, 0, 0, 532, "float(string mname)", true}, {"getsoundtime", PF_Ignore, 0, 0, 0, 533, "float(entity e, float channel)"}, {"soundlength", PF_Ignore, 0, 0, 0, 534, "float(string sample)"}, - {"buf_loadfile", PF_buf_loadfile, 0, 0, 0, 535, "float(string filename, strbuf bufhandle)"}, - {"buf_writefile", PF_buf_writefile, 0, 0, 0, 536, "float(filestream filehandle, strbuf bufhandle, optional float startpos, optional float numstrings)"}, + {"buf_loadfile", PF_buf_loadfile, 0, 0, 0, 535, D("float(string filename, strbuf bufhandle)", "Appends the named file into a string buffer (which must have been created in advance). The return value merely says whether the file was readable.")}, + {"buf_writefile", PF_buf_writefile, 0, 0, 0, 536, D("float(filestream filehandle, strbuf bufhandle, optional float startpos, optional float numstrings)", "Writes the contents of a string buffer onto the end of the supplied filehandle (you must have already used fopen). Additional optional arguments permit you to constrain the writes to a subsection of the stringbuffer.")}, // {"bufstr_find", PF_Fixme, 0, 0, 0, 537, "float(float bufhandle, string match, float matchrule, float startpos)"}, // {"matchpattern", PF_Fixme, 0, 0, 0, 538, "float(string s, string pattern, float matchrule)"}, // {"undefined", PF_Fixme, 0, 0, 0, 539, ""}, diff --git a/engine/server/pr_q1qvm.c b/engine/server/pr_q1qvm.c index 2caa3cc1a..03cfccd82 100755 --- a/engine/server/pr_q1qvm.c +++ b/engine/server/pr_q1qvm.c @@ -395,7 +395,7 @@ static edict_t *QDECL Q1QVMPF_ProgsToEdict(pubprogfuncs_t *pf, int num) return Q1QVMPF_EdictNum(pf, num); } -void Q1QVMED_ClearEdict (edict_t *e, qboolean wipe) +static void Q1QVMED_ClearEdict (edict_t *e, qboolean wipe) { int num = e->entnum; if (wipe) @@ -403,6 +403,10 @@ void Q1QVMED_ClearEdict (edict_t *e, qboolean wipe) e->isfree = false; e->entnum = num; } +static void Q1QVMPF_ClearEdict(pubprogfuncs_t *pf, edict_t *e) +{ + Q1QVMED_ClearEdict(e, true); +} static void QDECL Q1QVMPF_EntRemove(pubprogfuncs_t *pf, edict_t *e) { @@ -1211,10 +1215,18 @@ Con_DPrintf("PF_readcmd: %s\n%s", s, output); { char *dst = VM_POINTER(arg[0]); char *src = VM_POINTER(arg[1]); - if (VM_OOB(arg[0], arg[2])) + if (VM_OOB(arg[0], arg[2]) || VM_LONG(arg[2]) < 1) return -1; - Q_strncpyz(dst, src, VM_LONG(arg[2])); - //WARNING: no return value + else if (!src) + { + *dst = 0; + return 0; + } + else + { + Q_strncpyz(dst, src, VM_LONG(arg[2])); + return strlen(src); + } } break; case G_strlcat: @@ -1404,6 +1416,7 @@ qboolean PR_LoadQ1QVM(void) q1qvmprogfuncs.StringToProgs = Q1QVMPF_StringToProgs; q1qvmprogfuncs.StringToNative = Q1QVMPF_StringToNative; q1qvmprogfuncs.SetStringField = Q1QVMPF_SetStringField; + q1qvmprogfuncs.EntClear = Q1QVMPF_ClearEdict; sv.world.Event_Touch = Q1QVM_Event_Touch; sv.world.Event_Think = Q1QVM_Event_Think; @@ -1653,9 +1666,9 @@ void Q1QVM_SetChangeParms(void) VM_Call(q1qvm, GAME_SETCHANGEPARMS, 0, 0, 0); } -void Q1QVM_ClientCommand(void) +qboolean Q1QVM_ClientCommand(void) { - VM_Call(q1qvm, GAME_CLIENT_COMMAND, 0, 0, 0); + return VM_Call(q1qvm, GAME_CLIENT_COMMAND, 0, 0, 0); } void Q1QVM_GameCodePausedTic(float pausedduration) diff --git a/engine/server/progs.h b/engine/server/progs.h index b44b8a947..4bcec0203 100644 --- a/engine/server/progs.h +++ b/engine/server/progs.h @@ -141,11 +141,10 @@ void Q1QVM_StartFrame(void); void Q1QVM_Blocked(void); void Q1QVM_SetNewParms(void); void Q1QVM_SetChangeParms(void); -void Q1QVM_ClientCommand(void); +qboolean Q1QVM_ClientCommand(void); void Q1QVM_GameCodePausedTic(float pausedduration); void Q1QVM_DropClient(struct client_s *cl); void Q1QVM_ChainMoved(void); void Q1QVM_EndFrame(void); -void Q1QVMED_ClearEdict (edict_t *e, qboolean wipe); #endif diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 9e4d78231..1bde94a6d 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -3349,10 +3349,13 @@ qboolean SVNQ_ConnectionlessPacket(void) sb.data = buffer; /*ack it, so dumb proquake clones can actually send the proper packet*/ - SZ_Clear(&sb); - MSG_WriteLong(&sb, BigLong(NETFLAG_ACK | 8)); - MSG_WriteLong(&sb, sequence); - NET_SendPacket(NS_SERVER, sb.cursize, sb.data, &net_from); + if (!sequence) + { + SZ_Clear(&sb); + MSG_WriteLong(&sb, BigLong(NETFLAG_ACK | 8)); + MSG_WriteLong(&sb, sequence); + NET_SendPacket(NS_SERVER, sb.cursize, sb.data, &net_from); + } /*resend the cmd request, cos if they didn't send it then it must have gotten dropped. @@ -3360,8 +3363,8 @@ qboolean SVNQ_ConnectionlessPacket(void) a vanilla client will not start spamming nops until it has received the server info, so its only the proquake clients+clones that will send a nop before a challengeconnect unfortunatly we don't know the modver+flags+password any more. I hope its not needed. if it does, server admins will be forced to use sv_listen_nq 1 instead of 2*/ SZ_Clear(&sb); - MSG_WriteLong(&sb, 0); - MSG_WriteLong(&sb, 0); + MSG_WriteLong(&sb, BigLong(0)); + MSG_WriteLong(&sb, BigLong(1)); //sequence 1, because 0 matches the old sequence, and thus might get dropped. hopefully the client will cope with dupes properly and ignore any regular (but unreliable) stuff. MSG_WriteByte(&sb, svc_stufftext); MSG_WriteString(&sb, va("cmd challengeconnect %i %i\n", SV_NewChallenge(), 1/*MOD_PROQUAKE*/)); @@ -3445,8 +3448,8 @@ qboolean SVNQ_ConnectionlessPacket(void) SZ_Clear(&sb); - MSG_WriteLong(&sb, 0); - MSG_WriteLong(&sb, 0); + MSG_WriteLong(&sb, BigLong(0)); + MSG_WriteLong(&sb, BigLong(1)); //sequence 1, because 0 matches the old sequence, and thus might get dropped. hopefully the client will cope with dupes properly and ignore any regular (but unreliable) stuff. MSG_WriteByte(&sb, svc_stufftext); MSG_WriteString(&sb, va("cmd challengeconnect %i %i %i %i %i\n", SV_NewChallenge(), mod, modver, flags, passwd)); diff --git a/engine/server/sv_mvd.c b/engine/server/sv_mvd.c index bb0418492..09ce39613 100644 --- a/engine/server/sv_mvd.c +++ b/engine/server/sv_mvd.c @@ -1777,8 +1777,8 @@ void SV_MVD_SendInitialGamestate(mvddest_t *dest) demo.recorder.prespawn_stage++;//client won't reply, so don't wait. demo.recorder.prespawn_idx = 0; } - if (demo.recorder.prespawn_stage == PRESPAWN_SOUNDLIST || demo.recorder.prespawn_stage == PRESPAWN_MODELLIST) - demo.recorder.prespawn_idx &= ~0x80000000; //normally set for the server to wait for ack. we don't want to wait. + demo.recorder.prespawn_allow_soundlist = true; //normally set for the server to wait for ack. we don't want to wait. + demo.recorder.prespawn_allow_modellist = true; //normally set for the server to wait for ack. we don't want to wait. SV_SendClientPrespawnInfo(&demo.recorder); SV_WriteRecordMVDMessage (&demo.recorder.netchan.message); diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index 76f6472be..bd3efcfaf 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -4457,7 +4457,8 @@ void SV_SetUpClientEdict (client_t *cl, edict_t *ent) { string_t preserve; preserve = ent->v->netname; - Q1QVMED_ClearEdict(ent, true); + if (progstype != PROG_NQ) //allow frikbots to work in NQ mods (but not qw!) + ED_Clear(svprogfuncs, ent); ent->v->netname = preserve; } else @@ -5002,17 +5003,24 @@ void SVNQ_Begin_f (void) *pr_global_ptrs->spawnparamglobals[i] = host_client->spawn_parms[i]; } - // call the spawn function sv.skipbprintclient = host_client; - pr_global_struct->time = sv.world.physicstime; - pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player); - PR_ExecuteProgram (svprogfuncs, pr_global_struct->ClientConnect); - sv.skipbprintclient = NULL; +#ifdef VM_Q1 + if (svs.gametype == GT_Q1QVM) + Q1QVM_ClientConnect(host_client); + else +#endif + { + // call the spawn function + pr_global_struct->time = sv.world.physicstime; + pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player); + PR_ExecuteProgram (svprogfuncs, pr_global_struct->ClientConnect); + sv.skipbprintclient = NULL; - // actually spawn the player - pr_global_struct->time = sv.world.physicstime; - pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player); - PR_ExecuteProgram (svprogfuncs, pr_global_struct->PutClientInServer); + // actually spawn the player + pr_global_struct->time = sv.world.physicstime; + pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player); + PR_ExecuteProgram (svprogfuncs, pr_global_struct->PutClientInServer); + } } } @@ -5066,6 +5074,12 @@ void SVNQ_Begin_f (void) host_client->send_message = true; + + + SV_PreRunCmd(); + host_client->lastcmd.msec = 0; + SV_RunCmd (&host_client->lastcmd, false); + SV_PostRunCmd(); } void SVNQ_PreSpawn_f (void) { diff --git a/engine/shaders/glsl/lpp_wall.glsl b/engine/shaders/glsl/lpp_wall.glsl index d77547c83..7a715671d 100644 --- a/engine/shaders/glsl/lpp_wall.glsl +++ b/engine/shaders/glsl/lpp_wall.glsl @@ -25,7 +25,7 @@ void main () nst = (1.0 + nst) / 2.0; vec4 l = texture2D(s_t0, nst)*5.0; vec4 c = texture2D(s_t1, tc); - vec3 lmsamp = texture2D(s_t2, lm).rgb*e_lmscale; + vec3 lmsamp = texture2D(s_t2, lm).rgb*e_lmscale.rgb; vec3 diff = l.rgb; vec3 chrom = diff / (0.001 + dot(diff, vec3(0.3, 0.59, 0.11))); vec3 spec = chrom * l.a;