コード例 #1
0
        public void AddServerCommand(LogicServerCommand serverCommand)
        {
            int id = -1;

            for (int i = 0; i < this.ServerCommands.Size(); i++)
            {
                if (this.ServerCommands[i].GetId() > id)
                {
                    id = this.ServerCommands[i].GetId();
                }
            }

            serverCommand.SetId(id + 1);
            this.ServerCommands.Add(serverCommand);

            if (this.CurrentSession != null && this.CurrentSession.GameState != null)
            {
                this.CurrentSession.SendMessage(new HomeServerCommandAllowedMessage
                {
                    ServerCommand = serverCommand
                }, 10);
            }
            else
            {
                GameAvatarManager.ExecuteServerCommandsInOfflineMode(this);
                GameAvatarManager.Save(this);
            }
        }
コード例 #2
0
        public static void ExecuteServerCommandsInOfflineMode(GameAvatar document)
        {
            if (document.ServerCommands.Size() != 0)
            {
                LogicGameMode logicGameMode = new LogicGameMode();
                LogicLevel    logicLevel    = logicGameMode.GetLevel();

                logicLevel.SetVisitorAvatar(document.LogicClientAvatar);

                try
                {
                    for (int i = 0; i < document.ServerCommands.Size(); i++)
                    {
                        int result = document.ServerCommands[i].Execute(logicLevel);

                        if (result == 0)
                        {
                            document.ServerCommands.Remove(i--);
                        }
                    }

                    GameAvatarManager.Save(document);
                }
                catch (Exception exception)
                {
                    Logging.Error("GameAvatarManager.executeServerCommandsInOfflineMode: server command execution in offline mode failed: " + exception);
                }
            }
        }