Exemple #1
0
        public static void SV_ConSay_f( )
        {
            client_t client;
            Int32    j;
            String   p;
            String   text;

            if (Cmd.Argc() < 2)
            {
                return;
            }
            text = "console: ";
            p    = Cmd.Args();
            if (p[0] == '"')
            {
                p = p.Substring(1, p.Length - 1);
            }

            text += p;
            for (j = 0; j < SV_MAIN.maxclients.value; j++)
            {
                client = SV_INIT.svs.clients[j];
                if (client.state != Defines.cs_spawned)
                {
                    continue;
                }
                SV_SEND.SV_ClientPrintf(client, Defines.PRINT_CHAT, text + "\\n");
            }
        }
Exemple #2
0
        public static void SV_Frame(Int64 msec)
        {
            Globals.time_before_game = Globals.time_after_game = 0;
            if (!SV_INIT.svs.initialized)
            {
                return;
            }
            SV_INIT.svs.realtime += ( Int32 )msec;
            Lib.Rand();
            SV_CheckTimeouts();
            SV_ReadPackets();
            if (0 == SV_MAIN.sv_timedemo.value && SV_INIT.svs.realtime < SV_INIT.sv.time)
            {
                if (SV_INIT.sv.time - SV_INIT.svs.realtime > 100)
                {
                    if (SV_MAIN.sv_showclamp.value != 0)
                    {
                        Com.Printf("sv lowclamp\\n");
                    }
                    SV_INIT.svs.realtime = SV_INIT.sv.time - 100;
                }

                NET.Sleep(SV_INIT.sv.time - SV_INIT.svs.realtime);
                return;
            }

            SV_CalcPings();
            SV_GiveMsec();
            SV_RunGameFrame();
            SV_SEND.SV_SendClientMessages();
            SV_ENTS.SV_RecordDemoMessage();
            Master_Heartbeat();
            SV_PrepWorldFrame();
        }
Exemple #3
0
        public static Int32 SV_FindIndex(String name, Int32 start, Int32 max, Boolean create)
        {
            Int32 i;

            if (name == null || name.Length == 0)
            {
                return(0);
            }
            for (i = 1; i < max && sv.configstrings[start + i] != null; i++)
            {
                if (0 == Lib.Strcmp(sv.configstrings[start + i], name))
                {
                    return(i);
                }
            }
            if (!create)
            {
                return(0);
            }
            if (i == max)
            {
                Com.Error(Defines.ERR_DROP, "*Index: overflow");
            }
            sv.configstrings[start + i] = name;
            if (sv.state != Defines.ss_loading)
            {
                SZ.Clear(sv.multicast);
                MSG.WriteChar(sv.multicast, Defines.svc_configstring);
                MSG.WriteShort(sv.multicast, start + i);
                MSG.WriteString(sv.multicast, name);
                SV_SEND.SV_Multicast(Globals.vec3_origin, Defines.MULTICAST_ALL_R);
            }

            return(i);
        }
Exemple #4
0
        public static void SV_CheckTimeouts( )
        {
            Int32    i;
            client_t cl;
            Int32    droppoint;
            Int32    zombiepoint;

            droppoint   = ( Int32 )(SV_INIT.svs.realtime - 1000 * SV_MAIN.timeout.value);
            zombiepoint = ( Int32 )(SV_INIT.svs.realtime - 1000 * SV_MAIN.zombietime.value);
            for (i = 0; i < SV_MAIN.maxclients.value; i++)
            {
                cl = SV_INIT.svs.clients[i];
                if (cl.lastmessage > SV_INIT.svs.realtime)
                {
                    cl.lastmessage = SV_INIT.svs.realtime;
                }
                if (cl.state == Defines.cs_zombie && cl.lastmessage < zombiepoint)
                {
                    cl.state = Defines.cs_free;
                    continue;
                }

                if ((cl.state == Defines.cs_connected || cl.state == Defines.cs_spawned) && cl.lastmessage < droppoint)
                {
                    SV_SEND.SV_BroadcastPrintf(Defines.PRINT_HIGH, cl.name + " timed out\\n");
                    SV_DropClient(cl);
                    cl.state = Defines.cs_free;
                }
            }
        }
Exemple #5
0
 public static void PF_StartSound(edict_t entity, int channel, int sound_num, float volume, float attenuation, float timeofs)
 {
     if (null == entity)
     {
         return;
     }
     SV_SEND.SV_StartSound(null, entity, channel, sound_num, volume, attenuation, timeofs);
 }
Exemple #6
0
 public static void PF_Configstring(int index, string val)
 {
     if (index < 0 || index >= Defines.MAX_CONFIGSTRINGS)
     {
         Com.Error(Defines.ERR_DROP, "configstring: bad index " + index + "\\n");
     }
     if (val == null)
     {
         val = "";
     }
     SV_INIT.sv.configstrings[index] = val;
     if (SV_INIT.sv.state != Defines.ss_loading)
     {
         SZ.Clear(SV_INIT.sv.multicast);
         MSG.WriteChar(SV_INIT.sv.multicast, Defines.svc_configstring);
         MSG.WriteShort(SV_INIT.sv.multicast, index);
         MSG.WriteString(SV_INIT.sv.multicast, val);
         SV_SEND.SV_Multicast(Globals.vec3_origin, Defines.MULTICAST_ALL_R);
     }
 }
Exemple #7
0
        public static void PF_cprintf(edict_t ent, int level, string fmt)
        {
            int n = 0;

            if (ent != null)
            {
                n = ent.index;
                if (n < 1 || n > SV_MAIN.maxclients.value)
                {
                    Com.Error(Defines.ERR_DROP, "cprintf to a non-client");
                }
            }

            if (ent != null)
            {
                SV_SEND.SV_ClientPrintf(SV_INIT.svs.clients[n - 1], level, fmt);
            }
            else
            {
                Com.Printf(fmt);
            }
        }
Exemple #8
0
        public static void SV_Kick_f( )
        {
            if (!SV_INIT.svs.initialized)
            {
                Com.Printf("No server running.\\n");
                return;
            }

            if (Cmd.Argc() != 2)
            {
                Com.Printf("Usage: kick <userid>\\n");
                return;
            }

            if (!SV_SetPlayer())
            {
                return;
            }
            SV_SEND.SV_BroadcastPrintf(Defines.PRINT_HIGH, SV_MAIN.sv_client.name + " was kicked\\n");
            SV_SEND.SV_ClientPrintf(SV_MAIN.sv_client, Defines.PRINT_HIGH, "You were kicked from the game\\n");
            SV_MAIN.SV_DropClient(SV_MAIN.sv_client);
            SV_MAIN.sv_client.lastmessage = SV_INIT.svs.realtime;
        }
Exemple #9
0
 public override void Rd_flush(Int32 target, StringBuffer buffer)
 {
     SV_SEND.SV_FlushRedirect(target, Lib.StringToBytes(buffer.ToString()));
 }
Exemple #10
0
        public static void SV_Map(Boolean attractloop, String levelstring, Boolean loadgame)
        {
            Int32  l;
            String level, ch, spawnpoint;
            var    pos = 0;

            sv.loadgame    = loadgame;
            sv.attractloop = attractloop;
            if (sv.state == Defines.ss_dead && !sv.loadgame)
            {
                SV_InitGame();
            }
            level = levelstring;
            var c = level.IndexOf('+');

            if (c != -1)
            {
                Cvar.Set("nextserver", "gamemap \\\"" + level.Substring(c + 1) + "\\\"");
                level = level.Substring(0, c);
            }
            else
            {
                Cvar.Set("nextserver", "");
            }

            if (firstmap.Length == 0)
            {
                if (!levelstring.EndsWith(".cin") && !levelstring.EndsWith(".pcx") && !levelstring.EndsWith(".dm2"))
                {
                    pos      = levelstring.IndexOf('+');
                    firstmap = levelstring.Substring(pos + 1);
                }
            }

            if (Cvar.VariableValue("coop") != 0 && level.Equals("victory.pcx"))
            {
                Cvar.Set("nextserver", "gamemap \\\"*" + firstmap + "\\\"");
            }
            pos = level.IndexOf('$');
            if (pos != -1)
            {
                spawnpoint = level.Substring(pos + 1);
                level      = level.Substring(0, pos);
            }
            else
            {
                spawnpoint = "";
            }
            if (level[0] == '*')
            {
                level = level.Substring(1);
            }
            l = level.Length;
            if (l > 4 && level.EndsWith(".cin"))
            {
                SCR.BeginLoadingPlaque();
                SV_SEND.SV_BroadcastCommand("changing\\n");
                SV_SpawnServer(level, spawnpoint, Defines.ss_cinematic, attractloop, loadgame);
            }
            else if (l > 4 && level.EndsWith(".dm2"))
            {
                SCR.BeginLoadingPlaque();
                SV_SEND.SV_BroadcastCommand("changing\\n");
                SV_SpawnServer(level, spawnpoint, Defines.ss_demo, attractloop, loadgame);
            }
            else if (l > 4 && level.EndsWith(".pcx"))
            {
                SCR.BeginLoadingPlaque();
                SV_SEND.SV_BroadcastCommand("changing\\n");
                SV_SpawnServer(level, spawnpoint, Defines.ss_pic, attractloop, loadgame);
            }
            else
            {
                SCR.BeginLoadingPlaque();
                SV_SEND.SV_BroadcastCommand("changing\\n");
                SV_SEND.SV_SendClientMessages();
                SV_SpawnServer(level, spawnpoint, Defines.ss_game, attractloop, loadgame);
                Cbuf.CopyToDefer();
            }

            SV_SEND.SV_BroadcastCommand("reconnect\\n");
        }