/// <summary> /// Host_Spawn_f /// </summary> private static void Spawn_f() { if (Cmd.Source == cmd_source_t.src_command) { Con.Print("spawn is not valid from the console\n"); return; } if (Host.HostClient.spawned) { Con.Print("Spawn not valid -- allready spawned\n"); return; } edict_t ent; // run the entrance script if (Server.sv.loadgame) { // loaded games are fully inited allready // if this is the last client to be connected, unpause Server.sv.paused = false; } else { // set up the edict ent = Host.HostClient.edict; ent.Clear(); //memset(&ent.v, 0, progs.entityfields * 4); ent.v.colormap = Server.NumForEdict(ent); ent.v.team = (Host.HostClient.colors & 15) + 1; ent.v.netname = Progs.NewString(Host.HostClient.name); // copy spawn parms out of the client_t Progs.GlobalStruct.SetParams(Host.HostClient.spawn_parms); // call the spawn function Progs.GlobalStruct.time = (float)Server.sv.time; Progs.GlobalStruct.self = Server.EdictToProg(Server.Player); Progs.Execute(Progs.GlobalStruct.ClientConnect); if ((Sys.GetFloatTime() - Host.HostClient.netconnection.connecttime) <= Server.sv.time) { Con.DPrint("{0} entered the game\n", Host.HostClient.name); } Progs.Execute(Progs.GlobalStruct.PutClientInServer); } // send all current names, colors, and frag counts MsgWriter msg = Host.HostClient.message; msg.Clear(); // send time of update msg.WriteByte(Protocol.svc_time); msg.WriteFloat((float)Server.sv.time); for (int i = 0; i < Server.svs.maxclients; i++) { client_t client = Server.svs.clients[i]; msg.WriteByte(Protocol.svc_updatename); msg.WriteByte(i); msg.WriteString(client.name); msg.WriteByte(Protocol.svc_updatefrags); msg.WriteByte(i); msg.WriteShort(client.old_frags); msg.WriteByte(Protocol.svc_updatecolors); msg.WriteByte(i); msg.WriteByte(client.colors); } // send all current light styles for (int i = 0; i < QDef.MAX_LIGHTSTYLES; i++) { msg.WriteByte(Protocol.svc_lightstyle); msg.WriteByte((char)i); msg.WriteString(Server.sv.lightstyles[i]); } // // send some stats // msg.WriteByte(Protocol.svc_updatestat); msg.WriteByte(QStats.STAT_TOTALSECRETS); msg.WriteLong((int)Progs.GlobalStruct.total_secrets); msg.WriteByte(Protocol.svc_updatestat); msg.WriteByte(QStats.STAT_TOTALMONSTERS); msg.WriteLong((int)Progs.GlobalStruct.total_monsters); msg.WriteByte(Protocol.svc_updatestat); msg.WriteByte(QStats.STAT_SECRETS); msg.WriteLong((int)Progs.GlobalStruct.found_secrets); msg.WriteByte(Protocol.svc_updatestat); msg.WriteByte(QStats.STAT_MONSTERS); msg.WriteLong((int)Progs.GlobalStruct.killed_monsters); // // send a fixangle // Never send a roll angle, because savegames can catch the server // in a state where it is expecting the client to correct the angle // and it won't happen if the game was just loaded, so you wind up // with a permanent head tilt ent = Server.EdictNum(1 + Host.ClientNum); msg.WriteByte(Protocol.svc_setangle); msg.WriteAngle(ent.v.angles.x); msg.WriteAngle(ent.v.angles.y); msg.WriteAngle(0); Server.WriteClientDataToMessage(Server.Player, Host.HostClient.message); msg.WriteByte(Protocol.svc_signonnum); msg.WriteByte(3); Host.HostClient.sendsignon = true; }
public static void Host_Spawn_f() { if (cmd_source == cmd_source_t.src_command) { Con_Printf("spawn is not valid from the console\n"); return; } if (host_client.spawned) { Con_Printf("Spawn not valid -- allready spawned\n"); return; } edict_t ent; // run the entrance script if (sv.loadgame) { // loaded games are fully inited allready // if this is the last client to be connected, unpause sv.paused = false; } else { // set up the edict ent = host_client.edict; ent.Clear(); //memset(&ent.v, 0, progs.entityfields * 4); ent.v.colormap = NUM_FOR_EDICT(ent); ent.v.team = (host_client.colors & 15) + 1; ent.v.netname = ED_NewString(host_client.name); // copy spawn parms out of the client_t pr_global_struct.SetParams(host_client.spawn_parms); // call the spawn function pr_global_struct.time = (float)sv.time; pr_global_struct.self = EDICT_TO_PROG(sv_player); PR_ExecuteProgram(pr_global_struct.ClientConnect); if ((Sys_FloatTime() - host_client.netconnection.connecttime) <= sv.time) { Con_DPrintf("{0} entered the game\n", host_client.name); } PR_ExecuteProgram(pr_global_struct.PutClientInServer); } // send all current names, colors, and frag counts MsgWriter msg = host_client.message; msg.Clear(); // send time of update msg.MSG_WriteByte(q_shared.svc_time); msg.MSG_WriteFloat((float)sv.time); for (int i = 0; i < svs.maxclients; i++) { client_t client = svs.clients[i]; msg.MSG_WriteByte(q_shared.svc_updatename); msg.MSG_WriteByte(i); msg.MSG_WriteString(client.name); msg.MSG_WriteByte(q_shared.svc_updatefrags); msg.MSG_WriteByte(i); msg.MSG_WriteShort(client.old_frags); msg.MSG_WriteByte(q_shared.svc_updatecolors); msg.MSG_WriteByte(i); msg.MSG_WriteByte(client.colors); } // send all current light styles for (int i = 0; i < q_shared.MAX_LIGHTSTYLES; i++) { msg.MSG_WriteByte(q_shared.svc_lightstyle); msg.MSG_WriteByte((char)i); msg.MSG_WriteString(sv.lightstyles[i]); } // // send some stats // msg.MSG_WriteByte(q_shared.svc_updatestat); msg.MSG_WriteByte(q_shared.STAT_TOTALSECRETS); msg.MSG_WriteLong((int)pr_global_struct.total_secrets); msg.MSG_WriteByte(q_shared.svc_updatestat); msg.MSG_WriteByte(q_shared.STAT_TOTALMONSTERS); msg.MSG_WriteLong((int)pr_global_struct.total_monsters); msg.MSG_WriteByte(q_shared.svc_updatestat); msg.MSG_WriteByte(q_shared.STAT_SECRETS); msg.MSG_WriteLong((int)pr_global_struct.found_secrets); msg.MSG_WriteByte(q_shared.svc_updatestat); msg.MSG_WriteByte(q_shared.STAT_MONSTERS); msg.MSG_WriteLong((int)pr_global_struct.killed_monsters); // // send a fixangle // Never send a roll angle, because savegames can catch the server // in a state where it is expecting the client to correct the angle // and it won't happen if the game was just loaded, so you wind up // with a permanent head tilt ent = EDICT_NUM(1 + ClientNum); msg.MSG_WriteByte(q_shared.svc_setangle); msg.MSG_WriteAngle(ent.v.angles.x); msg.MSG_WriteAngle(ent.v.angles.y); msg.MSG_WriteAngle(0); SV_WriteClientdataToMessage(sv_player, host_client.message); msg.MSG_WriteByte(q_shared.svc_signonnum); msg.MSG_WriteByte(3); host_client.sendsignon = true; }