コード例 #1
0
    private void Awake()
    {
        Instance = this;

        regions     = GameObject.FindObjectsOfType <RegionQuad>();
        regionCount = regions.Length;
    }
コード例 #2
0
        public string StartTransfer(string targetRegion, bool notify, bool backupmail)
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
            if (!EnableMigration)
            {
                return(null);
            }

            if (CurrentRegion.Equals(targetRegion, StringComparison.OrdinalIgnoreCase))
            {
                return(ToJsonError(Resources.Resource.ErrorTransferPortalInRegion));
            }

            try
            {
                using (var backupClient = new BackupServiceClient())
                {
                    var transferRequest = new TransferRequest
                    {
                        TenantId     = TenantProvider.CurrentTenantID,
                        TargetRegion = targetRegion,
                        NotifyUsers  = notify,
                        BackupMail   = backupmail
                    };

                    return(ToJsonSuccess(backupClient.TransferPortal(transferRequest)));
                }
            }
            catch (Exception error)
            {
                return(ToJsonError(error.Message));
            }
        }
コード例 #3
0
 public void MoveSouth()
 {
     if (HasLocationToSouth)
     {
         CurrentLocation = CurrentRegion.LocationAt(CurrentLocation.XCoordinate, CurrentLocation.YCoordinate - 1);
     }
 }
コード例 #4
0
 public void MoveNorth()
 {
     if (HasLocationToNorth)
     {
         CurrentLocation = CurrentRegion.LocationAt(CurrentLocation.XCoordinate, CurrentLocation.YCoordinate + 1);
     }
 }
コード例 #5
0
 public void MoveWest()
 {
     if (HasLocationToWest)
     {
         CurrentLocation = CurrentRegion.LocationAt(CurrentLocation.XCoordinate - 1, CurrentLocation.YCoordinate);
     }
 }
コード例 #6
0
ファイル: GameRelicPad.cs プロジェクト: JVirant/DOLSharp
        /// <summary>
        /// removes the relicpad from the world
        /// </summary>
        /// <returns></returns>
        public override bool RemoveFromWorld()
        {
            if (m_area != null)
            {
                CurrentRegion.RemoveArea(m_area);
            }

            return(base.RemoveFromWorld());
        }
コード例 #7
0
        public GameSession()
        {
            CurrentWorld  = new World();
            CurrentPlayer = new Player();

            World.Regions region;
            foreach (string regString in Enum.GetNames(typeof(World.Regions)))
            {
                Enum.TryParse(regString, out region);
                CurrentWorld.AddRegion(region, RegionFactory.CreateRegion(region));
            }
            CurrentRegion   = CurrentWorld.GetRegion(World.Regions.HollowMouth);
            CurrentLocation = CurrentRegion.LocationAt(0, 0);
        }
コード例 #8
0
        /// <summary>
        /// Remove a keep from the database
        /// </summary>
        /// <param name="area"></param>
        public virtual void Remove(KeepArea area)
        {
            Dictionary <string, GameKeepGuard> guards = new Dictionary <string, GameKeepGuard>(Guards);           // Use a shallow copy

            foreach (GameKeepGuard guard in guards.Values)
            {
                guard.Delete();
                guard.DeleteFromDatabase();
            }

            Dictionary <string, GameKeepBanner> banners = new Dictionary <string, GameKeepBanner>(Banners);           // Use a shallow copy

            foreach (GameKeepBanner banner in banners.Values)
            {
                banner.Delete();
                banner.DeleteFromDatabase();
            }

            Dictionary <string, GameKeepDoor> doors = new Dictionary <string, GameKeepDoor>(Doors);           // Use a shallow copy

            foreach (GameKeepDoor door in doors.Values)
            {
                door.Delete();
                GameDoor d = new GameDoor();
                d.CurrentRegionID = door.CurrentRegionID;
                d.DoorID          = door.DoorID;
                d.Heading         = door.Heading;
                d.Level           = door.Level;
                d.Model           = door.Model;
                d.Name            = "door";
                d.Realm           = door.Realm;
                d.State           = eDoorState.Closed;
                d.X = door.X;
                d.Y = door.Y;
                d.Z = door.Z;
                DoorMgr.RegisterDoor(door);
                d.AddToWorld();
            }

            UnloadTimers();
            GameEventMgr.RemoveHandler(CurrentRegion, RegionEvent.PlayerEnter, new DOLEventHandler(SendKeepInit));
            if (area != null)
            {
                CurrentRegion.RemoveArea(area);
            }

            RemoveFromDatabase();
            GameServer.KeepManager.Keeps[KeepID] = null;
        }
コード例 #9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            CurrentRegion = GetRegionConfigString(Configuration["Api:CurrentRegion"] ?? "EU");

            services.AddServerSideBlazor();
            services.AddRazorPages();
            services.AddHttpContextAccessor();

            services.AddProgressiveWebApp(new PwaOptions
            {
                RegisterServiceWorker = true,
                RegisterWebmanifest   = true,
                AllowHttp             = false
            });

            services.AddDistributedMemoryCache();

            services.AddHttpClient(
                Options.DefaultName,
                config =>
            {
                config.BaseAddress = new(Configuration[$"Api:{CurrentRegion.ToRegionString()}:Host"]);
            }
                )
            .ConfigurePrimaryHttpMessageHandler(
                () => new HttpClientHandler
            {
                AutomaticDecompression = DecompressionMethods.All
            }
                );


            services.AddApplicationInsightsTelemetry(options =>
            {
#if DEBUG
                options.DeveloperMode = true;
#endif
            });
#if RELEASE
            services.AddHsts(options =>
            {
                options.Preload = true;
            });
#endif

            //TODO : Add custom Auth Handler
            services.AddAuthentication(ApiTokenAuthenticationHandler.AuthenticationScheme)
            .AddScheme <AuthenticationSchemeOptions, ApiTokenAuthenticationHandler>(ApiTokenAuthenticationHandler.AuthenticationScheme, "API Token", _ => { });

            services.AddAuthorizationCore();

            services.AddResponseCompression(opts =>
            {
                opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
                    new[] { "application/octet-stream" });
            });

            services.AddHostedService <AuthCacheService>();
            services.AddSingleton <AuthCacheService>();
            services.AddSingleton <JwtSecurityTokenHandler>();
            services.AddSingleton <FileContentLoader>();

            services.AddScoped <PlayerClient>();
            services.AddScoped <UserClient>();
            services.AddScoped <PostClient>();
            services.AddScoped <ModClient>();
            services.AddScoped <ReplayClient>();
            services.AddScoped <ClanService>();

#if DEBUG
            services.AddSassCompiler();
#endif
        }
コード例 #10
0
        /// <summary>
        /// What the Server sends to the client
        /// </summary>
        protected virtual void FromServerGaming(PacketFromServer packet)
        {
            try
            {
                byte pid = packet.PacketID;

                if (pid == PassThrough.ID)
                {
                    Player.SendToClient(packet);
                    return;
                }

                //Before we rewrite the eid
                //Record all presented mobs, so far we have no method of cleaning this up so hold your thumbs
                if (pid == SpawnMob.ID)
                {
                    World.Main.UpdateEntity((SpawnMob)packet);
                }
                if (pid == EntityMetadata.ID)
                {
                    World.Main.UpdateEntity((EntityMetadata)packet);
                }
                //if (pid == SpawnPlayer.ID)
                //World.Main.UpdateEntity((SpawnPlayer)packet);
                if (pid == SpawnObject.ID)
                {
                    World.Main.UpdateEntity((SpawnObject)packet);
                }
                if (pid == SpawnPainting.ID)
                {
                    World.Main.UpdateEntity((SpawnPainting)packet);
                }

                //Rewrite own EID, Fix eid to client eid player
                if (packet is IEntity)
                {
                    IEntity ie = (IEntity)packet;
                    if (ie.EID == EID)
                    {
                        ie.EID = Player.EntityID;
                        packet.SetPacketBuffer(null);
                    }
                }
                if (pid == SpawnObject.ID)
                {
                    var so = (SpawnObject)packet;
                    if (so.SourceEntity == EID)
                    {
                        so.SourceEntity = Player.EntityID;
                        packet.SetPacketBuffer(null);
                    }
                }

                //Region filters
                if (CurrentRegion != null && CurrentRegion.FilterServer(this, packet))
                {
                    return;
                }

                //Cloak and Nick
                if (Cloak.Filter(this, packet))
                {
                    return;
                }

                switch (pid)
                {
                case SpawnPlayer.ID:
                    //Change reported uuid from offline to the known with names
                    var sp = (SpawnPlayer)packet;
                    var p  = PlayerList.GetPlayerByVanillaUUID(sp.PlayerUUID);
                    if (p != null)
                    {
                        Debug.WriteLine("SpawnPlayer changed from " + sp.PlayerUUID);
                        Debug.WriteLine("SpawnPlayer changed to   " + p.UUID);
                        sp.PlayerUUID = p.UUID;
                        sp.SetPacketBuffer(null);
                    }
                    else
                    {
                        Debug.WriteLine("SpawnPlayer not changed: " + sp.PlayerUUID);
                    }
                    break;

                case ChangeGameState.ID:
                    ChangeGameState ns = packet as ChangeGameState;
                    if (ns.Reason == GameState.BeginRaining || ns.Reason == GameState.EndRaining)
                    {
                        World.Main.Weather = ns;
                    }
                    if (ns.Reason == GameState.ChangeGameMode)
                    {
                        Mode = (GameMode)ns.Value;
                    }
                    break;

                case SpawnObject.ID:
                    var so = (SpawnObject)packet;
                    if (so.Type != Vehicles.Item)
                    {
                        break;
                    }
                    OreTracker.Spawn(so, Position);
                    break;

                case EntityMetadata.ID:
                    OreTracker.Track((EntityMetadata)packet);
                    break;

                case EntityEffect.ID:
                    EntityEffect ee = (EntityEffect)packet;
                    if (ee.Effect == PlayerEffects.MoveSpeed)
                    {
                        EffectSpeed.Active    = true;
                        EffectSpeed.Amplifier = ee.Amplifier;
                    }
                    if (ee.Effect == PlayerEffects.MoveSlowdown)
                    {
                        EffectSlow.Active    = true;
                        EffectSlow.Amplifier = ee.Amplifier;
                    }
                    break;

                case RemoveEntityEffect.ID:
                    RemoveEntityEffect re = (RemoveEntityEffect)packet;
                    if (re.Effect == PlayerEffects.MoveSpeed)
                    {
                        EffectSpeed.Active = false;
                    }
                    if (re.Effect == PlayerEffects.MoveSlowdown)
                    {
                        EffectSlow.Active = false;
                    }
                    break;

                case TimeUpdate.ID:
                    World.Main.Time = packet as TimeUpdate;
                    break;

                case UseBed.ID:
                    UseBed ub = (UseBed)packet;
                    if (ub.EID == Player.EntityID)
                    {
                        Sleeping = true;
                    }
                    break;

                //Waking up, among other things
                case Animation.ID:
                    Animation a = (Animation)packet;
                    if (a.EID == Player.EntityID)
                    {
                        if (a.Animate == Animations.LeaveBed)
                        {
                            Sleeping = false;
                        }
                    }
                    break;

                    #region Position and speed

                //Regions and player position
                case PlayerPositionLookServer.ID:
                    var pp = (PlayerPositionLookServer)packet;
                    if (pp.Position.Y % 1 > 0.95)
                    {
                        //Console.WriteLine(pp.Position.ToString("0.00") + " " + pp.HeadY);
                        pp.Position.Y = Math.Ceiling(Position.Y);
                        //pp.HeadPosition = Position.Y + 1.62;
                        //Console.WriteLine(pp.Position.ToString("0.00") + " " + pp.Stance);
                        packet.SetPacketBuffer(null);
                    }
                    SetPosition(pp.Position, false);
                    break;

                case Respawn.ID:
                    Dimension = ((Respawn)packet).Dimension;
                    SetPosition(Position, false);
                    break;

                //Boats and carts
                case AttachEntity.ID:
                    AttachEntity ae = (AttachEntity)packet;
                    if (ae.EID == Player.EntityID)
                    {
                        AttachedEntity = ae.VehicleID;
                    }
                    break;

                case UpdateBlockEntity.ID:
                    if (Player.Admin(Permissions.AnyAdmin))
                    {
                        var ute = (UpdateBlockEntity)packet;
                        if (ute.Action == UpdateBlockEntity.Actions.MobSpawner)
                        {
                            if (Spawners.Contains(ute.Pos) == false)
                            {
                                Spawners.Add(ute.Pos);
                            }
                        }
                    }
                    break;

                case EntityTeleport.ID:
                    if (AttachedEntity != 0)
                    {
                        EntityTeleport et = (EntityTeleport)packet;
                        if (et.EID == AttachedEntity)
                        {
                            SetPosition(et.Position, false);
                        }
                    }
                    break;

                case EntityRelativeMove.ID:
                    if (AttachedEntity != 0)
                    {
                        EntityRelativeMove er = (EntityRelativeMove)packet;
                        if (er.EID == AttachedEntity)
                        {
                            SetPosition(Position + er.Delta, false);
                        }
                    }
                    break;
                    #endregion

                case ChatMessageServer.ID:
                    if (ServerParser.ParseServer(this.Player, (ChatMessageServer)packet))
                    {
                        return;
                    }
                    break;

                //Inventory
                case WindowItems.ID:
                    var wi = (WindowItems)packet;
                    for (int n = 0; n < wi.Items.Length; n++)
                    {
                        if (wi.Items[n] == null)
                        {
                            continue;
                        }
                        if (wi.Items[n].Count > 64)
                        {
                            wi.Items[n] = null;
                            packet.SetPacketBuffer(null);
                        }
                    }
                    break;

                case SetSlot.ID:
                    //Debug.WriteLine(packet);
                    SetSlot ss = (SetSlot)packet;

                    if (0 <= ss.Slot && ss.Slot < Inventory.Length)
                    {
                        Inventory[ss.Slot] = ss.Item;
                    }
                    break;

                //Tab player list items: Block Player, managed in PlayerList thread
                case PlayerListItem.ID:
                    return;

                case HeldItemServer.ID:
                    //Active item
                    var hc = (HeldItemServer)packet;
                    if (hc.SlotID >= 0 && hc.SlotID <= 8)
                    {
                        ActiveInventoryIndex = hc.SlotID;
                    }
                    else
                    {
                        Log.Write(
                            new InvalidOperationException("Invalid holding slot id: " + hc.SlotID),
                            this.Player
                            );
                    }
                    break;

                //Keep a record of what window is open
                case WindowOpen.ID:
                    WorldRegion r  = LastClickRegion ?? CurrentRegion;
                    var         wo = (WindowOpen)packet;
                    if (OpenWindows.ContainsKey(wo.WindowID))
                    {
                        OpenWindows.Remove(wo.WindowID);
                    }
                    OpenWindows.Add(wo.WindowID, new OpenWindowRegion(wo, r));

                    if (r == null || (Player.Admin(Permissions.AnyAdmin) == false) && (Mode == GameMode.Creative))
                    {
                        //Leave unmodified
                    }
                    else
                    {
                        if (r.Type == Protected.Type &&
                            r.IsResident(Player) == false &&
                            wo.InventoryType != "CraftingTable" &&
                            wo.InventoryType != "Enchant" &&
                            wo.WindowTitle != "container.enderchest")
                        {
                            var cj = new ChatJson();
                            cj.Text        = "Locked: " + r.Name;
                            wo.WindowTitle = cj.Serialize();
                            wo.SetPacketBuffer(null);
                        }
                    }
                    break;

                //Turn off pvp when you die
                case UpdateHealth.ID:
                    UpdateHealth uh = (UpdateHealth)packet;
                    if (Player.PvP && uh.Health <= 0)
                    {
                        Player.PvP = false;
                        Player.TellSystem(Chat.Purple, "PvP off");
                    }
                    break;


                case WindowCloseServer.ID:
                    WindowClose((WindowCloseServer)packet);
                    break;

                //Disconnect while running the game
                //For disconnect at login see the handshake part
                case Disconnect.ID:
                    Disconnect d = (Disconnect)packet;
                    if (d.Reason.Text == "Flying is not enabled on this server")
                    {
                            #if !DEBUG
                        Player.BanByServer(DateTime.Now.AddMinutes(2), d.Reason.Text);
                            #else
                        Chatting.Parser.Say(Chat.Yellow + Player.Name + Chat.Blue, " was kicked for flying");
                            #endif
                        return;
                    }
                    if (d.Reason.Text == "Internal server error")
                    {
                        Log.WritePlayer(
                            this.Player,
                            "Backend: Internal error - Restarting connection"
                            );
                        Player.SetWorld(World.Main);
                        return;
                    }
                    Player.SetWorld(World.Construct);
                    return;
                }
                //////////////Sending packet
                Player.SendToClient(packet);
                //////////////

#if !DEBUG
            } catch (Exception e)
            {
                thread.State = "ServerGamingException: " + e.Message;

                Log.Write(e, this.Player);
                Player.Queue.Queue(packet);
#endif
            }
            finally
            {
            }
        }
コード例 #11
0
 public void EnterDoor()
 {
     CurrentRegion   = CurrentWorld.GetRegion(CurrentLocation.Door.RegionCode);
     CurrentLocation = CurrentRegion.LocationAt(CurrentLocation.Door.X, CurrentLocation.Door.Y);
 }