/* * =================== * SV_ClientThink * * the move fields specify an intended velocity in pix/sec * the angle fields specify an exact angular motion in degrees * =================== */ static void SV_ClientThink() { double[] v_angle = new double[3]; if (sv_player.v.movetype == MOVETYPE_NONE) { return; } onground = ((int)sv_player.v.flags & FL_ONGROUND) != 0; origin = sv_player.v.origin; velocity = sv_player.v.velocity; DropPunchAngle(); // // if dead, behave differently // if (sv_player.v.health <= 0) { return; } // // angles // show 1/3 the pitch angle and all the roll angle cmd = host.host_client.cmd; angles = sv_player.v.angles; mathlib.VectorAdd(sv_player.v.v_angle, sv_player.v.punchangle, ref v_angle); angles[quakedef.ROLL] = view.V_CalcRoll(sv_player.v.angles, sv_player.v.velocity) * 4; if (sv_player.v.fixangle == 0) { angles[quakedef.PITCH] = -v_angle[quakedef.PITCH] / 3; angles[quakedef.YAW] = v_angle[quakedef.YAW]; } if (((int)sv_player.v.flags & FL_WATERJUMP) != 0) { SV_WaterJump(); return; } // // walk // if ((sv_player.v.waterlevel >= 2) && (sv_player.v.movetype != MOVETYPE_NOCLIP)) { SV_WaterMove(); return; } SV_AirMove(); }
/* * =================== * SV_ReadClientMove * =================== */ static void SV_ReadClientMove(client.usercmd_t move) { int i; double[] angle = new double[3]; int bits; // read ping time host.host_client.ping_times[host.host_client.num_pings % NUM_PING_TIMES] = sv.time - common.MSG_ReadFloat(); host.host_client.num_pings++; // read current angles for (i = 0; i < 3; i++) { angle[i] = common.MSG_ReadAngle(); } mathlib.VectorCopy(angle, ref host.host_client.edict.v.v_angle); // read movement move.forwardmove = common.MSG_ReadShort(); move.sidemove = common.MSG_ReadShort(); move.upmove = common.MSG_ReadShort(); // read buttons bits = common.MSG_ReadByte(); host.host_client.edict.v.button0 = bits & 1; host.host_client.edict.v.button2 = (bits & 2) >> 1; i = common.MSG_ReadByte(); if (i != 0) { host.host_client.edict.v.impulse = i; } }
/* * =================== * SV_ReadClientMessage * * Returns false if the client should be killed * =================== */ static bool SV_ReadClientMessage() { int ret; int cmd; string s; do { nextmsg: ret = net.NET_GetMessage(host.host_client.netconnection); if (ret == -1) { sys_linux.Sys_Printf("SV_ReadClientMessage: NET_GetMessage failed\n"); return(false); } if (ret == 0) { return(true); } common.MSG_BeginReading(); while (true) { if (!host.host_client.active) { return(false); // a command caused an error } if (common.msg_badread) { sys_linux.Sys_Printf("SV_ReadClientMessage: badread\n"); return(false); } cmd = common.MSG_ReadChar(); switch (cmd) { case -1: goto nextmsg; // end of message default: sys_linux.Sys_Printf("SV_ReadClientMessage: unknown command char\n"); return(false); case net.clc_nop: // Sys_Printf ("clc_nop\n"); break; case net.clc_stringcmd: s = common.MSG_ReadString(); if (host.host_client.privileged) { ret = 2; } else { ret = 0; } if (s.StartsWith("status")) { ret = 1; } else if (s.StartsWith("god")) { ret = 1; } else if (s.StartsWith("notarget")) { ret = 1; } else if (s.StartsWith("fly")) { ret = 1; } else if (s.StartsWith("name")) { ret = 1; } else if (s.StartsWith("noclip")) { ret = 1; } else if (s.StartsWith("say")) { ret = 1; } else if (s.StartsWith("say_team")) { ret = 1; } else if (s.StartsWith("tell")) { ret = 1; } else if (s.StartsWith("color")) { ret = 1; } else if (s.StartsWith("kill")) { ret = 1; } else if (s.StartsWith("pause")) { ret = 1; } else if (s.StartsWith("spawn")) { ret = 1; } else if (s.StartsWith("begin")) { ret = 1; } else if (s.StartsWith("prespawn")) { ret = 1; } else if (s.StartsWith("kick")) { ret = 1; } else if (s.StartsWith("ping")) { ret = 1; } else if (s.StartsWith("give")) { ret = 1; } else if (s.StartsWith("ban")) { ret = 1; } if (ret == 2) { quake.cmd.Cbuf_InsertText(s); } else if (ret == 1) { quake.cmd.Cmd_ExecuteString((s + "\0").ToCharArray(), quake.cmd.cmd_source_t.src_client); } else { console.Con_DPrintf(host.host_client.name + " tried to " + s + "\n"); } break; case net.clc_disconnect: // Sys_Printf ("SV_ReadClientMessage: client disconnected\n"); return(false); case net.clc_move: SV_ReadClientMove(host.host_client.cmd); break; } } } while (ret == 1); return(true); }
/* =================== SV_ReadClientMessage Returns false if the client should be killed =================== */ static bool SV_ReadClientMessage() { int ret; int cmd; string s; do { nextmsg: ret = net.NET_GetMessage (host.host_client.netconnection); if (ret == -1) { sys_linux.Sys_Printf("SV_ReadClientMessage: NET_GetMessage failed\n"); return false; } if (ret == 0) return true; common.MSG_BeginReading (); while (true) { if (!host.host_client.active) return false; // a command caused an error if (common.msg_badread) { sys_linux.Sys_Printf ("SV_ReadClientMessage: badread\n"); return false; } cmd = common.MSG_ReadChar (); switch (cmd) { case -1: goto nextmsg; // end of message default: sys_linux.Sys_Printf ("SV_ReadClientMessage: unknown command char\n"); return false; case net.clc_nop: // Sys_Printf ("clc_nop\n"); break; case net.clc_stringcmd: s = common.MSG_ReadString (); if (host.host_client.privileged) ret = 2; else ret = 0; if (s.StartsWith("status")) ret = 1; else if (s.StartsWith("god")) ret = 1; else if (s.StartsWith("notarget")) ret = 1; else if (s.StartsWith("fly")) ret = 1; else if (s.StartsWith("name")) ret = 1; else if (s.StartsWith("noclip")) ret = 1; else if (s.StartsWith("say")) ret = 1; else if (s.StartsWith("say_team")) ret = 1; else if (s.StartsWith("tell")) ret = 1; else if (s.StartsWith("color")) ret = 1; else if (s.StartsWith("kill")) ret = 1; else if (s.StartsWith("pause")) ret = 1; else if (s.StartsWith("spawn")) ret = 1; else if (s.StartsWith("begin")) ret = 1; else if (s.StartsWith("prespawn")) ret = 1; else if (s.StartsWith("kick")) ret = 1; else if (s.StartsWith("ping")) ret = 1; else if (s.StartsWith("give")) ret = 1; else if (s.StartsWith("ban")) ret = 1; if (ret == 2) quake.cmd.Cbuf_InsertText(s); else if (ret == 1) quake.cmd.Cmd_ExecuteString ((s + "\0").ToCharArray(), quake.cmd.cmd_source_t.src_client); else console.Con_DPrintf(host.host_client.name + " tried to " + s + "\n"); break; case net.clc_disconnect: // Sys_Printf ("SV_ReadClientMessage: client disconnected\n"); return false; case net.clc_move: SV_ReadClientMove(host.host_client.cmd); break; } } } while (ret == 1); return true; }
/* =================== SV_ClientThink the move fields specify an intended velocity in pix/sec the angle fields specify an exact angular motion in degrees =================== */ static void SV_ClientThink() { double[] v_angle = new double[3]; if (sv_player.v.movetype == MOVETYPE_NONE) return; onground = ((int)sv_player.v.flags & FL_ONGROUND) != 0; origin = sv_player.v.origin; velocity = sv_player.v.velocity; DropPunchAngle(); // // if dead, behave differently // if (sv_player.v.health <= 0) return; // // angles // show 1/3 the pitch angle and all the roll angle cmd = host.host_client.cmd; angles = sv_player.v.angles; mathlib.VectorAdd(sv_player.v.v_angle, sv_player.v.punchangle, ref v_angle); angles[quakedef.ROLL] = view.V_CalcRoll(sv_player.v.angles, sv_player.v.velocity) * 4; if (sv_player.v.fixangle == 0) { angles[quakedef.PITCH] = -v_angle[quakedef.PITCH] / 3; angles[quakedef.YAW] = v_angle[quakedef.YAW]; } if (((int)sv_player.v.flags & FL_WATERJUMP) != 0) { SV_WaterJump(); return; } // // walk // if ((sv_player.v.waterlevel >= 2) && (sv_player.v.movetype != MOVETYPE_NOCLIP)) { SV_WaterMove(); return; } SV_AirMove(); }