Results 1 to 4 of 4
  1. #1
    toby2449's Avatar
    Join Date
    Jan 2015
    Gender
    male
    Location
    The Ocean
    Posts
    281
    Reputation
    10
    Thanks
    21
    My Mood
    Inspired

    [SD] Why isnt there a realm portal showing up?

    Why isnt there a realm portal showing up? The code is right and a realm portal should spawn. But it doesn't?

    RealmManager:
    Code:
    using System;
    using System.Collections.Concurrent;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.Threading;
    using db;
    using log4net;
    using wServer.logic;
    using wServer.networking;
    using wServer.realm.commands;
    using wServer.realm.entities;
    using wServer.realm.worlds;
    
    namespace wServer.realm
    {
        public struct RealmTime
        {
            public int thisTickCounts;
            public int thisTickTimes;
            public long tickCount;
            public long tickTimes;
        }
    
        public class TimeEventArgs : EventArgs
        {
            public TimeEventArgs(RealmTime time)
            {
                Time = time;
            }
    
            public RealmTime Time { get; private set; }
        }
    
        public enum PendingPriority
        {
            Emergent,
            Destruction,
            Networking,
            Normal,
            Creation,
        }
    
        public class RealmManager
        {
            public const int MAX_CLIENT = 200;
            public const int MAX_INREALM = 85;
            private static readonly ILog log = LogManager.GetLogger(typeof (RealmManager));
    
            public static List<string> realmNames = new List<string>
            {
                "Medusa",
                "Beholder",
                "Flayer",
                "Ogre",
                "Cyclops",
                "Sprite",
                "Djinn",
                "Slime",
                "Blob",
                "Demon",
                "Spider",
                "Scorpion",
                "Ghost"
            };
    
            public static List<string> CurrentRealmNames = new List<string>();
    
            public readonly ConcurrentDictionary<int, Client> Clients = new ConcurrentDictionary<int, Client>();
    
            public readonly ConcurrentDictionary<string, GuildHall> GuildHalls =
                new ConcurrentDictionary<string, GuildHall>();
    
            public readonly ConcurrentDictionary<int, World> Worlds = new ConcurrentDictionary<int, World>();
            public ConcurrentDictionary<int, World> PlayerWorldMapping = new ConcurrentDictionary<int, World>();
            private Thread logic;
            private Thread network;
            private Thread database;
            private Thread save;
            private int nextWorldId;
    
            public RealmManager(int maxClient, int tps, Database db)
            {
                MaxClient = maxClient;
                TPS = tps;
                Database = db;
            }
    
            public int MaxClient { get; private set; }
            public int TPS { get; private set; }
            public Database Database { get; private set; }
    
            public RealmPortalMonitor Monitor { get; private set; }
            public NetworkTicker Network { get; private set; }
            public LogicTicker Logic { get; private set; }
            public DatabaseTicker Data { get; private set; }
            public AutoSave Save { get; private set; }
    
            public XmlData GameData { get; private set; }
            public BehaviorDb Behaviors { get; private set; }
    
            public ChatManager Chat { get; private set; }
            public CommandManager Commands { get; private set; }
            public bool Terminating { get; private set; }
    
            public int TimeOut = 60;
            public int conTimes = 1;
    
            public bool TryConnect(Client client)
            {
                if (Clients.Count >= MaxClient)
                    return false;
                return Clients.TryAdd(client.Account.AccountId, client);
            }
    
            public bool IsUserOnline(Client client, Account account)
            {
                if (TimeOut > 0)
                {
                    this.TimeOut -= conTimes;
                    if (conTimes < 5)
                    {
                        conTimes++;
                    }
                }
                else
                {
                    this.TimeOut = 60;
                    foreach (Client i in Clients.Values.Where(i => i.Account.Name.EqualsIgnoreCase(account.Name)))
                    {
                        i.Disconnect();
                        i.Save();
                    }
                    return false;
                }
    
                return Clients.ContainsKey(account.AccountId);
            }
    
            public void Disconnect(Client client)
            {
                Clients.TryRemove(client.Account.AccountId, out client);
            }
    
            public World GuildHallWorld(string g)
            {
                if (!GuildHalls.ContainsKey(g))
                {
                    var gh = (GuildHall) AddWorld(new GuildHall(g));
                    return GuildHalls.GetOrAdd(g, gh);
                }
                return GuildHalls[g];
            }
    
            public World AddWorld(int id, World world)
            {
                if (world.Manager != null)
                    throw new InvalidOperationException("World already added.");
                world.Id = id;
                Worlds[id] = world;
                OnWorldAdded(world);
                return world;
            }
    
            public World AddWorld(World world)
            {
                if (world.Manager != null)
                    throw new InvalidOperationException("World already added.");
                world.Id = Interlocked.Increment(ref nextWorldId);
                Worlds[world.Id] = world;
                OnWorldAdded(world);
                return world;
            }
    
            public bool RemoveWorld(World world)
            {
                if (world.Manager == null)
                    throw new InvalidOperationException("World is not added.");
                World dummy;
                if (Worlds.TryRemove(world.Id, out dummy))
                {
                    try
                    {
                        OnWorldRemoved(world);
                        world.Dispose();
                        GC.Collect();
                    }
                    catch (Exception e)
                    { log.Fatal(e); }
                    return true;
                }
                return false;
            }
    
            public World GetWorld(int id)
            {
                World ret;
                if (!Worlds.TryGetValue(id, out ret)) return null;
                if (ret.Id == 0) return null;
                return ret;
            }
    
            public List<Player> GuildMembersOf(string guild)
            {
                return (from i in Worlds
                    where i.Key != 0
                    from e in i.Value.Players
                    where String.Equals(e.Value.Guild, guild, StringComparison.CurrentCultureIgnoreCase)
                    select e.Value).ToList();
            }
    
            public Player FindPlayer(string name)
            {
                if (name.Split(' ').Length > 1)
                    name = name.Split(' ')[1];
                return (from i in Worlds
                    where i.Key != 0
                    from e in i.Value.Players
                    where String.Equals(e.Value.Client.Account.Name, name, StringComparison.CurrentCultureIgnoreCase)
                    select e.Value).FirstOrDefault();
            }
    
            public Player FindPlayerRough(string name)
            {
                Player dummy;
                foreach (var i in Worlds)
                    if (i.Key != 0)
                        if ((dummy = i.Value.GetUniqueNamedPlayerRough(name)) != null)
                            return dummy;
                return null;
            }
    
            private void OnWorldAdded(World world)
            {
                world.Manager = this;
                if (world is GameWorld)
                    Monitor.WorldAdded(world);
                log.InfoFormat("World {0}({1}) added.", world.Id, world.Name);
            }
    
            private void OnWorldRemoved(World world)
            {
                world.Manager = null;
                if (world is GameWorld)
                    Monitor.WorldRemoved(world);
                log.InfoFormat("World {0}({1}) removed.", world.Id, world.Name);
            }
    
    
            public void Initialize()
            {
                log.Info("Initializing Realm Manager...");
    
                GameData = new XmlData();
                Behaviors = new BehaviorDb(this);
    
                AddWorld(World.NEXUS_ID, Worlds[0] = new Nexus());
                Monitor = new RealmPortalMonitor(this);
    
                AddWorld(World.TUT_ID, new Tutorial(true));
                AddWorld(World.NEXUS_LIMBO, new NexusLimbo());
                AddWorld(World.VAULT_ID, new Vault(true));
                AddWorld(World.TEST_ID, new Test());
                AddWorld(World.RAND_REALM, new RandomRealm());
                AddWorld(World.PVP, new PVPArena());
                AddWorld(World.SHOP_ID, new Shop());
    
                if (Program.Settings.GetValue<bool>("hasRealm"))
                    AddWorld(GameWorld.AutoName(1, true));
    
                Chat = new ChatManager(this);
                Commands = new CommandManager(this);
    
                UnusualEffects.Init();
    
                log.Info("Realm Manager initialized.");
            }
    
            public void Run()
            {
                log.Info("Starting Realm Manager...");
    
                Network = new NetworkTicker(this);
                Logic = new LogicTicker(this);
                Data = new DatabaseTicker(this);
                Save = new AutoSave(this);
                network = new Thread(Network.TickLoop)
                {
                    Name = "Network",
                    CurrentCulture = CultureInfo.InvariantCulture
                };
                logic = new Thread(Logic.TickLoop)
                {
                    Name = "Logic",
                    CurrentCulture = CultureInfo.InvariantCulture
                };
                database = new Thread(Data.TickLoop)
                {
                    Name = "Database",
                    CurrentCulture = CultureInfo.InvariantCulture
                };
                save = new Thread(Save.TickLoop)
                {
                    Name = "Save",
                    CurrentCulture = CultureInfo.InvariantCulture
                };
                //Start logic loop first
                logic.Start();
                network.Start();
                database.Start();
                save.Start();
    
                log.Info("Realm Manager started.");
            }
    
            public void Stop()
            {
                log.Info("Stopping Realm Manager...");
    
                Terminating = true;
                GameData.Dispose();
                logic.Join();
                network.Join();
                save.Join();
                database.Join();
    
                log.Info("Realm Manager stopped.");
            }
        }
    }

    RealmPortalMonitor:
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using log4net;
    using wServer.realm.entities;
    using wServer.realm.terrain;
    using wServer.realm.worlds;
    
    namespace wServer.realm
    {
        public class RealmPortalMonitor
        {
            private static readonly ILog log = LogManager.GetLogger(typeof (RealmPortalMonitor));
    
            private readonly RealmManager manager;
            private readonly Nexus nexus;
            private readonly Random rand = new Random();
            private readonly object worldLock = new object();
            public Dictionary<World, Portal> portals = new Dictionary<World, Portal>();
    
            public RealmPortalMonitor(RealmManager manager)
            {
                log.Info("Initalizing Portal Monitor...");
                this.manager = manager;
                nexus = manager.Worlds[World.NEXUS_ID] as Nexus;
                lock (worldLock)
                    foreach (var i in manager.Worlds)
                    {
                        if (i.Value is GameWorld)
                            WorldAdded(i.Value);
                    }
                log.Info("Portal Monitor initialized.");
            }
    
            private Position GetRandPosition()
            {
                int x, y;
                do
                {
                    x = rand.Next(0, nexus.Map.Width);
                    y = rand.Next(0, nexus.Map.Height);
                } while (
                    portals.Values.Any(_ => _.X == x && _.Y == y) ||
                    nexus.Map[x, y].Region != TileRegion.Realm_Portals);
                return new Position {X = x, Y = y};
            }
    
            public void WorldAdded(World world)
            {
                lock (worldLock)
                {
                    Position pos = GetRandPosition();
                    var portal = new Portal(manager, 0x0712, null)
                    {
                        Size = 80,
                        WorldInstance = world,
                        Name = world.Name
                    };
                    portal.Move(pos.X + 0.5f, pos.Y + 0.5f);
                    nexus.EnterWorld(portal);
                    portals.Add(world, portal);
                    log.InfoFormat("World {0}({1}) added.", world.Id, world.Name);
                }
            }
    
            public void WorldRemoved(World world)
            {
                lock (worldLock)
                {
                    Portal portal = portals[world];
                    nexus.LeaveWorld(portal);
                    portals.Remove(world);
                    log.InfoFormat("World {0}({1}) removed.", world.Id, world.Name);
                }
            }
    
            public void WorldClosed(World world)
            {
                lock (worldLock)
                {
                    Portal portal = portals[world];
                    nexus.LeaveWorld(portal);
                    portals.Remove(world);
                    log.InfoFormat("World {0}({1}) closed.", world.Id, world.Name);
                }
            }
    
            public void WorldOpened(World world)
            {
                lock (worldLock)
                {
                    Position pos = GetRandPosition();
                    var portal = new Portal(manager, 0x71c, null)
                    {
                        Size = 150,
                        WorldInstance = world,
                        Name = world.Name
                    };
                    portal.Move(pos.X, pos.Y);
                    nexus.EnterWorld(portal);
                    portals.Add(world, portal);
                    log.InfoFormat("World {0}({1}) opened.", world.Id, world.Name);
                }
            }
    
            public World GetRandomRealm()
            {
                lock (worldLock)
                {
                    World[] worlds = portals.Keys.ToArray();
                    if (worlds.Length == 0)
                        return manager.Worlds[World.NEXUS_ID];
                    return worlds[Environment.TickCount%worlds.Length];
                }
            }
        }
    }
     
    ded lol


     
     
    I don't have skype xd. Well, I used to before it got hacked. Go hack it some more - toby2449

  2. #2
    Travoos's Avatar
    Join Date
    Jul 2012
    Gender
    female
    Posts
    282
    Reputation
    23
    Thanks
    649
    My Mood
    Tired
    The code is right, but is your wServer.cfg right?

    Code:
    port:2050
    conn:Server=localhost;Database=rotmg;uid=root;password=
    tps:10
    hasRealm:false

  3. The Following User Says Thank You to Travoos For This Useful Post:

    toby2449 (03-03-2015)

  4. #3
    toby2449's Avatar
    Join Date
    Jan 2015
    Gender
    male
    Location
    The Ocean
    Posts
    281
    Reputation
    10
    Thanks
    21
    My Mood
    Inspired
    im a idiot xd thanks for the help though
    @Color or @Raple close thread please
    Last edited by toby2449; 03-03-2015 at 08:35 PM.
     
    ded lol


     
     
    I don't have skype xd. Well, I used to before it got hacked. Go hack it some more - toby2449

  5. #4
    Color's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Posts
    19,896
    Reputation
    2588
    Thanks
    7,864
    My Mood
    Lurking
    //Solved

    Member Since 8/05/2012
    Editor 4/04/13 - 4/21/13
    Middleman 7/14/13 - 11/4/13

    Battlefield Minion 6/13/14-3/20/15
    Steam Minion 7/16/14-3/20/15

    Minion+ 10/1/14-3/20/15
    M.A.T. Minion 10/19/14-3/20/15
    ROTMG Minion 1/14/15-3/20/15

    Donator Since 2/26/15 (Thanks @Cursed!)
    Steam Minion 5/9/15 - 11/5/15
    OSFPS Minion 9/15/15 - 11/5/15


Similar Threads

  1. [Discussion] Why isnt there any more hacks?
    By CheapMCAccounts in forum CrossFire Discussions
    Replies: 2
    Last Post: 02-28-2015, 01:24 AM
  2. [Help] WHY isnt there a SELLIG/TRADING/BUYING section for CF EU ?
    By Scapa in forum CrossFire Europe Discussions
    Replies: 1
    Last Post: 05-09-2012, 01:20 PM
  3. man why isnt there private servers
    By arturspider2 in forum Combat Arms EU Discussions
    Replies: 12
    Last Post: 03-27-2010, 02:07 PM
  4. Why isnt there an olimpic sport lik this??
    By Zhellbound in forum General
    Replies: 2
    Last Post: 10-17-2008, 04:01 PM
  5. Why isint there no inf ammo on forums?
    By Ardefoc in forum WarRock - International Hacks
    Replies: 19
    Last Post: 06-10-2007, 05:04 AM