Esempio n. 1
0
        private static void GenerateEntities(DirectoryInfo directory)
        {
            var crumbEntities = directory.FullName
                                .Split('\\')
                                .Skip(ScarredWorldDirectoryIndex)
                                .Select(s => EntityDictionary[s])
                                .ToArray();

            foreach (var file in directory.GetFiles("*.md"))
            {
                var entity = EntityDictionary.FirstOrDefault(kv => kv.Key == file.Name.Split('.').First()).Value;
                int take   = crumbEntities.Length;
                if (entity.Key == crumbEntities.Last().Key)
                {
                    --take;
                }
                var crumbs = crumbEntities.Take(take)
                             .Select(e => e.NameLink)
                             .ToList();
                crumbs.Add(entity.FullName);
                WriteMarkdown(entity, crumbs, file);
            }

            foreach (var childDirectory in directory.GetDirectories())
            {
                GenerateEntities(childDirectory);
            }
        }
        private EntityDictionary <ServerInfo> GetServerInfoListFromDataTable(DataTable dt)
        {
            var result = new EntityDictionary <ServerInfo>();

            if (dt == null || dt.Rows.Count == 0)
            {
                return(result);
            }

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                result.Add(new ServerInfo
                {
                    Id            = GetInt(dt.Rows[i]["id"]),
                    Address       = GetString(dt.Rows[i]["address"]),
                    Name          = GetString(dt.Rows[i]["name"]),
                    Ports         = GetString(dt.Rows[i]["ports"]),
                    Region        = GetString(dt.Rows[i]["region"]),
                    ActualizedOn  = GetNullableDateTime(dt.Rows[i]["actualized_on"]),
                    ClientVersion = GetString(dt.Rows[i]["client_version"]),
                    PeerCount     = GetInt(dt.Rows[i]["peers_count"]),
                    IsApproved    = GetBoolean(dt.Rows[i]["is_approved"]),
                    ServerRole    = (ServerRole)GetByte(dt.Rows[i]["server_role"]),
                    HttpPort      = GetUshort(dt.Rows[i]["http_port"]),
                    HttpsPort     = GetUshort(dt.Rows[i]["https_port"]),
                });
            }

            return(result);
        }
        public static EntityDictionary <T> ReadEntityDictionary <T>(this ITypeReader typeReader)
            where T : EntityBase, new()
        {
            var result = new EntityDictionary <T>();

            try
            {
                var length = typeReader.ReadInt();

                if (length != 0)
                {
                    for (int i = 0; i < length; i++)
                    {
                        var item = new T();
                        item.Deserialize(typeReader);
                        result.Add(item);
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception($"Error deserializing EntityDictionary<{typeof(T)}>: {e}");
            }


            return(result);
        }
Esempio n. 4
0
        internal unsafe Wrapper(EngineFuncs engineFuncs, GlobalVars.Internal *pGlobals)
            : base(new EngineShared(engineFuncs))
        {
            Log.Message("Initializing wrapper");

            EntityDictionary = new EntityDictionary(engineFuncs);

            //Make sure this knows how to convert edicts
            EntVars.EntityDictionary = EntityDictionary;

            EngineFuncs = engineFuncs;

            Globals = new GlobalVars(pGlobals, EntityDictionary);

            EntityDictionary.SetGlobals(Globals);

            StringPool = new StringPool(Globals);

            EngineString.StringPool = StringPool;

            //Create interface implementations
            EngineServer = new EngineServer(EngineFuncs, StringPool, EntityDictionary, Globals, FileSystem);

            CVar = new CVar.CVar(EngineFuncs);
        }
Esempio n. 5
0
        internal void KeyValue(Edict.Native *pentKeyvalue, KeyValueData.Native *pkvd)
        {
            try
            {
                if (FirstKeyValueCall)
                {
                    FirstKeyValueCall = false;

                    var pEdictList = EngineFuncs.pfnPEntityOfEntOffset(0);

                    Log.Message($"Initializing entity dictionary with 0x{(uint)pEdictList:X} as edict list address");

                    EntityDictionary.Initialize(pEdictList, Globals.MaxEntities);

                    Log.Message("Finished initializing entity dictionary");
                }

                Entities.KeyValue(EntityDictionary.EdictFromNative(pentKeyvalue), new KeyValueData(pkvd));
            }
            catch (Exception e)
            {
                Log.Exception(e);
                throw;
            }
        }
Esempio n. 6
0
        public BaseEntity CreateInstance(EntityInfo info, Edict edict)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            try
            {
                var entity = (BaseEntity)Activator.CreateInstance(info.EntityClass);

                edict.PrivateData = entity;

                entity.pev = edict.Vars;

                entity.ClassName = info.PreferredName;

                //Inform of creation
                entity.OnCreate();

                return(entity);
            }
            catch (Exception e)
            {
                Log.Message($"Couldn't create entity \"{info.PreferredName}\":");
                Log.Exception(e);

                //On failure always free the edict
                //This will also free the entity instance if it has been assigned
                EntityDictionary.Free(edict);

                return(null);
            }
        }
        public void LoadingTest()
        {
            context.AccessLevel = EntityAccessLevel.Administrator;
            context.Execute("DELETE FROM pubserver;");
            context.Execute("DELETE FROM usr WHERE username IN ('user1', 'user2');");

            User user1 = new User(context);

            user1.Username = "******";
            user1.Store();

            User user2 = new User(context);

            user2.Username = "******";
            user2.Store();

            context.StartImpersonation(user1.Id);
            PublishServer p1 = new PublishServer(context);

            p1.Name     = "p1";
            p1.Protocol = "ftp";
            p1.Hostname = "test.org";
            p1.Store();
            PublishServer p2 = new PublishServer(context);

            p2.Name     = "p2";
            p2.Protocol = "ftp";
            p2.Hostname = "test.org";
            p2.Store();
            context.EndImpersonation();

            context.StartImpersonation(user2.Id);
            PublishServer p3 = new PublishServer(context);

            p3.Name     = "p3";
            p3.Protocol = "ftp";
            p3.Hostname = "test.org";
            p3.Store();
            context.EndImpersonation();

            context.StartImpersonation(user1.Id);
            EntityDictionary <PublishServer> pd1 = new EntityDictionary <PublishServer>(context);

            pd1.ItemVisibility = EntityItemVisibility.OwnedOnly;
            pd1.Load();
            Assert.AreEqual(2, pd1.Count);
            context.EndImpersonation();

            context.StartImpersonation(user2.Id);
            EntityDictionary <PublishServer> pd2 = new EntityDictionary <PublishServer>(context);

            Assert.Throws <EntityNotFoundException>(delegate {
                pd2.LoadFromSource(pd1, false);
            });

            pd2.LoadFromSource(pd1, true);
            Assert.AreEqual(2, pd2.Count);

            context.EndImpersonation();
        }
Esempio n. 8
0
 public NewDLLFunctions(EntityDictionary entityDictionary, Wrapper wrapper, IServerInterface serverInterface, IEntities serverEntities)
 {
     EntityDictionary = entityDictionary ?? throw new ArgumentNullException(nameof(entityDictionary));
     Wrapper          = wrapper ?? throw new ArgumentNullException(nameof(wrapper));
     ServerInterface  = serverInterface ?? throw new ArgumentNullException(nameof(serverInterface));
     ServerEntities   = serverEntities ?? throw new ArgumentNullException(nameof(serverEntities));
 }
Esempio n. 9
0
        public static BaseEntity FindEntityByString(BaseEntity entStartAfter, string key, string value)
        {
            for (var index = entStartAfter != null ? EntityDictionary.EntityIndex(entStartAfter.Edict()) + 1 : 0; index < EntityDictionary.Max;)
            {
                var entity = FirstEntityAtIndex(index);

                if (entity == null)
                {
                    return(null);
                }

                if (EntityProperties.TryGetValue(key, out var prop))
                {
                    var propValue = prop.GetValue(entity);

                    if (value == (string)propValue)
                    {
                        return(entity);
                    }
                }

                index = EntityDictionary.EntityIndex(entity.Edict()) + 1;
            }

            return(null);
        }
Esempio n. 10
0
        internal void LoadEntities(string data)
        {
            try
            {
                //Refresh the cache
                EngineServer.MapStartedLoading();

                var pEdictList = EngineFuncs.pfnPEntityOfEntOffset(0);

                Log.Message($"Initializing entity dictionary with 0x{(uint)pEdictList:X} as edict list address");

                EntityDictionary.Initialize(pEdictList, Globals.MaxEntities);

                Log.Message("Finished initializing entity dictionary");

                Entities.LoadEntities(data);
            }
            catch (Exception e)
            {
                Log.Exception(e);
                throw;
            }
            finally
            {
                EngineServer.MapFinishedLoading();
            }
        }
Esempio n. 11
0
        protected IEntity GetEntity(string ID)
        {
            IEntity result = null;

            EntityDictionary.TryGetValue(ID, out result);
            return(result);
        }
Esempio n. 12
0
 public TestEntity(int id, int intField, string stringField)
 {
     Id              = id;
     IntField        = intField;
     StringField     = stringField;
     ChildList       = new List <TestChildEntity>();
     ChildDictionary = new EntityDictionary <TestChildEntity>();
 }
Esempio n. 13
0
        public SpyManager(NktSpyMgr aSpyMgr)
        {
            _manager = aSpyMgr;
            InitializeHooksByProcesses();
            _cachedDbModulesByPlatformBits = new EntityDictionary <int, int, Module[]>(platformBits => platformBits, RetrieveModulesFromDB);

            InitializeSpyManager();
            StartDeviareWorker();
        }
Esempio n. 14
0
        public SpyManager(NktSpyMgr aSpyMgr)
        {
            _manager = aSpyMgr;
            InitializeHooksByProcesses();
            _cachedDbModulesByPlatformBits = new EntityDictionary<int, int, Module[]>(platformBits => platformBits, RetrieveModulesFromDB);

            InitializeSpyManager();
            StartDeviareWorker();
        }
Esempio n. 15
0
        public unsafe IInfoBuffer GetClientPhysicsInfoBuffer(Edict pClient)
        {
            if (!ServerAPIUtils.IsClient(pClient, EntityDictionary, Globals))
            {
                throw new ArgumentException("Edict must be a client", nameof(pClient));
            }

            return(new ClientPhysicsInfoBuffer(EngineFuncs, pClient.Data, EntityDictionary.EntityIndex(pClient)));
        }
 public ServerEntityList(
     EntityDictionary entityDictionary,
     int maxClients,
     INetworkObjectList entitiesNetworkList,
     ServerEntities entities)
     : base(entityDictionary, maxClients)
 {
     _entitiesNetworkList = entitiesNetworkList ?? throw new ArgumentNullException(nameof(entitiesNetworkList));
     _entities            = entities ?? throw new ArgumentNullException(nameof(entities));
 }
Esempio n. 17
0
        public Trace(EngineFuncs engineFuncs, EntityDictionary entityDictionary)
        {
            EngineFuncs      = engineFuncs ?? throw new ArgumentNullException(nameof(engineFuncs));
            EntityDictionary = entityDictionary ?? throw new ArgumentNullException(nameof(entityDictionary));

            //Set default trace group
            GroupTraces.Push(new GroupTrace {
                Mask = 0, Op = GroupOp.And
            });
        }
Esempio n. 18
0
 public Blog()
 {
     _attributes = new EntityDictionary<string, string>();
     posts = new PostsSet(
         delegate(Post p) { p.Blog = this; },
         delegate(Post p) { p.Blog = null; }
         );
     _users = new EntitySet<User>(
         delegate(User u) { u.Blogs.Add(this);},
         delegate(User u) { u.Blogs.Add(this);});
 }
Esempio n. 19
0
 internal void CvarValue(Edict.Native *pEnt, string value)
 {
     try
     {
         ServerInterface.CvarValue(EntityDictionary.EdictFromNative(pEnt), value);
     }
     catch (Exception e)
     {
         Log.Exception(e);
         throw;
     }
 }
Esempio n. 20
0
 internal int ShouldCollide(Edict.Native *pentTouched, Edict.Native *pentOther)
 {
     try
     {
         return(ServerEntities.ShouldCollide(EntityDictionary.EdictFromNative(pentTouched), EntityDictionary.EdictFromNative(pentOther)) ? 1 : 0);
     }
     catch (Exception e)
     {
         Log.Exception(e);
         throw;
     }
 }
Esempio n. 21
0
 internal void OnFreeEntPrivateData(Edict.Native *pEnt)
 {
     try
     {
         ServerEntities.OnFreeEntPrivateData(EntityDictionary.EdictFromNative(pEnt));
     }
     catch (Exception e)
     {
         Log.Exception(e);
         throw;
     }
 }
Esempio n. 22
0
        public ProcessNode(IProcess aProcess)
        {
            Text = aProcess.Name;
            IsRunning = true;
            Icon = aProcess.Icon;
            Process = aProcess;
            Pid = string.Empty;
            aProcess.IfRunning(p => Pid = p.Id.ToString());


            _moduleNodes = new EntityDictionary<Module, string, ModuleNode>(module => module.Path.ToLower(), ModuleNode.From);
        }
Esempio n. 23
0
 internal void PlayerPostThink(Edict.Native *pEntity)
 {
     try
     {
         GameClients.PostThink(EntityDictionary.EdictFromNative(pEntity));
     }
     catch (Exception e)
     {
         Log.Exception(e);
         throw;
     }
 }
Esempio n. 24
0
        public ProcessNode(IProcess aProcess)
        {
            Text      = aProcess.Name;
            IsRunning = true;
            Icon      = aProcess.Icon;
            Process   = aProcess;
            Pid       = string.Empty;
            aProcess.IfRunning(p => Pid = p.Id.ToString());


            _moduleNodes = new EntityDictionary <Module, string, ModuleNode>(module => module.Path.ToLower(), ModuleNode.From);
        }
Esempio n. 25
0
 internal void UpdateClientData(Edict.Native *ent, QBoolean sendweapons, ClientData.Native *cd)
 {
     try
     {
         Networking.UpdateClientData(EntityDictionary.EdictFromNative(ent), sendweapons != QBoolean.False, new ClientData(cd));
     }
     catch (Exception e)
     {
         Log.Exception(e);
         throw;
     }
 }
Esempio n. 26
0
 internal void SetAbsBox(Edict.Native *pent)
 {
     try
     {
         Entities.SetAbsBox(EntityDictionary.EdictFromNative(pent));
     }
     catch (Exception e)
     {
         Log.Exception(e);
         throw;
     }
 }
Esempio n. 27
0
 internal void ClientDisconnect(Edict.Native *pEntity)
 {
     try
     {
         GameClients.Disconnect(EntityDictionary.EdictFromNative(pEntity));
     }
     catch (Exception e)
     {
         Log.Exception(e);
         throw;
     }
 }
Esempio n. 28
0
 internal void ClientPutInServer(Edict.Native *pEntity)
 {
     try
     {
         GameClients.PutInServer(EntityDictionary.EdictFromNative(pEntity));
     }
     catch (Exception e)
     {
         Log.Exception(e);
         throw;
     }
 }
Esempio n. 29
0
 internal void ClientCommand(Edict.Native *pEntity)
 {
     try
     {
         GameClients.Command(EntityDictionary.EdictFromNative(pEntity), new Command(ServerAPIUtils.ArgsAsList(EngineFuncs)));
     }
     catch (Exception e)
     {
         Log.Exception(e);
         throw;
     }
 }
Esempio n. 30
0
 internal void CvarValue2(Edict.Native *pEnt, int requestID, string cvarName, string value)
 {
     try
     {
         ServerInterface.CvarValue2(EntityDictionary.EdictFromNative(pEnt), requestID, cvarName, value);
     }
     catch (Exception e)
     {
         Log.Exception(e);
         throw;
     }
 }
Esempio n. 31
0
 internal void SetupVisibility(Edict.Native *pViewEntity, Edict.Native *pClient, out IntPtr pvs, out IntPtr pas)
 {
     try
     {
         Networking.SetupVisibility(pViewEntity != null ? EntityDictionary.EdictFromNative(pViewEntity) : null, EntityDictionary.EdictFromNative(pClient), out pvs, out pas);
     }
     catch (Exception e)
     {
         Log.Exception(e);
         throw;
     }
 }
Esempio n. 32
0
 internal void PlayerCustomization(Edict.Native *pEntity, Customization.Native *pCustom)
 {
     try
     {
         GameClients.Customization(EntityDictionary.EdictFromNative(pEntity), new Customization(pCustom));
     }
     catch (Exception e)
     {
         Log.Exception(e);
         throw;
     }
 }
Esempio n. 33
0
        public static BaseEntity EntityByIndex(int index)
        {
            //TODO: could throw here
            if (index < 0 || index >= EntityDictionary.Max)
            {
                return(null);
            }

            var edict = EntityDictionary.EdictByIndex(index);

            return(edict.TryGetEntity());
        }
Esempio n. 34
0
 public ModulesTreeView()
 {
     _moduleNodesCache = new EntityDictionary<Module, string, ModuleNode>(module => module.Path, ModuleNode.From);
     FullRowSelect = true;
 }
Esempio n. 35
0
 public HooksTreeView()
 {
     _nodes = new EntityDictionary<IRunningProcess, int, ProcessNode>(process => process.Id, ProcessNode.From);
     FullRowSelect = true;
 }