Beispiel #1
0
        public static void ReadPackets()
        {
            while (NET.GetPacket(NetSrc.NS_SERVER))
            {
                if (SV.FilterPacket())
                {
                    SV.SendBan();
                }
                else
                {
                    //       if PInt32(NetMessage.Data) ^ = OUTOFBAND_TAG then
                    //          SV.ConnectionlessPacket()
                    //      else
                    for (int i = 0; i < Global.SVS.MaxClients; i++)
                    {
                        Client C = null;
                        //C := @SVS.Clients[I];
                        if ((C.Active || C.Spawned || C.Connected) && NET.CompareAdr(Global.NetFrom, C.netchan.Addr))
                        {
                            if (Netchan.Process(ref C.netchan))
                            {
                                if ((Global.SVS.MaxClients == 1) || !C.Active || !C.Spawned || !C.SendInfo)
                                {
                                    C.NeedUpdate = true;
                                }

                                SV.ExecuteClientMessage(ref C);
                                Global.GlobalVars.FrameTime = (float)Global.HostFrameTime;
                            }

                            if (Netchan.IncomingReady(C.netchan))
                            {
                                if (Netchan.CopyNormalFragments(ref C.netchan))
                                {
                                    MSG.BeginReading();
                                    SV.ExecuteClientMessage(ref C);
                                }

                                if (Netchan.CopyFileFragments(ref C.netchan))
                                {
                                    //  Global.HostClient = C;
                                    SV.ProcessFile(ref C, C.netchan.FileName);
                                }
                            }

                            break;
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public static void Shutdown()
        {
            if (Global.InHostShutdown)
            {
                Sys.DebugOutStraight("Host_Shutdown: Recursive shutdown.");
            }
            else
            {
                Global.InHostShutdown = true;
                Global.HostInit       = false;

                SV.ServerDeactivate();

                Mod.ClearAll();
                SV.ClearAllEntities();
                CM.FreePAS();
                SV.FreePMSimulator();

                SV.Shutdown();
                ReleaseEntityDLLs();
                Delta.Shutdown();
                NET.Shutdown();

                // if WADPath != nil then
                //  Mem.FreeAndNil(WADPath);

                Draw.DecalShutdown();
                W.Shutdown();
                HPAK.FlushHostQueue();
                Con.Shutdown();
                Cmd.RemoveGameCmds();
                Cmd.Shutdown();
                CVar.Shutdown();

                LPrint("Server shutdown\n");
                Log.Close();
                Global.RealTime = 0.0;
                SV.Time         = 0.0;
            }
        }
Beispiel #3
0
        public static void Init()
        {
            Global.RealTime = 0.0;

            Trash.Rand_Init();
            CBuf.Init();
            Cmd.Init();
            CVar.Init();
            InitLocal();
            ClearSaveDirectory();
            Con.Init();
            HPAK.Init();

            SV.SetMaxClients();
            W.LoadWADFile();
            Decal.Init();
            Mod.Init();
            R.Init();
            NET.Init();
            Netchan.Init();
            Delta.Init();
            SV.Init();

            string buf = "asdasd"; // TODO

            CVar.DirectSet(ref Global.sv_version, buf);

            HPAK.CheckIntegrity("custom.hpk");
            CBuf.InsertText("exec valve.rc\n");
            Hunk.AllocName(0, "-HOST_HUNKLEVEL-");
            Global.HostHunkLevel = Hunk.LowMark;

            Global.HostActive    = 1;
            Global.HostNumFrames = 0;

            Global.HostTimes.Prev = Sys.FloatTime();
            Global.HostInit       = true;
        }
Beispiel #4
0
        public static void _Frame(double time)
        {
            if (Host.FilterTime(time))
            {
                Host.ComputeFPS(Global.HostFrameTime);
                CBuf.Execute();
                if (Global.HostTimes.CollectData)
                {
                    Global.HostTimes.Host = Sys.FloatTime();
                }

                SV.Frame();
                if (Global.HostTimes.CollectData)
                {
                    Global.HostTimes.SV = Sys.FloatTime();
                }

                SV.CheckForRcon();
                if (Global.HostTimes.CollectData)
                {
                    Global.HostTimes.Rcon = Sys.FloatTime();
                }

                Host.WriteSpeeds();
                Global.HostNumFrames++;
                if (Global.sv_stats.value != 0)
                {
                    Host.UpdateStats();
                }

                if (Global.host_killtime.value != 0 && Global.host_killtime.value < Global.SV.Time)
                {
                    CBuf.AddText("quit\n");
                }

                // UI_Frame(RealTime);
            }
        }