Example #1
0
        /// <summary>
        ///     Gets the remaining guard time.
        /// </summary>
        public int GetGuardRemainingSeconds()
        {
            int startTime = this._startGuardTime - this._level.GetLogicTime();

            if (startTime <= 0)
            {
                startTime = 0;
            }

            return(LogicMath.Max(LogicTime.GetTicksInSeconds(this._guardTime + startTime), 0));
        }
Example #2
0
 /// <summary>
 ///     Gets the remaining guard time.
 /// </summary>
 public int GetMaintenanceRemainingSeconds()
 {
     return(LogicMath.Max(LogicTime.GetTicksInSeconds(this._maintenanceTime - this._level.GetLogicTime()), 0));
 }
Example #3
0
        public void OnClientTurnReceived(int subTick, int checksum, LogicArrayList <LogicCommand> commands)
        {
            if (this.m_destructed || this.m_logicGameMode.GetState() == 4 || this.m_logicGameMode.GetState() == 5)
            {
                return;
            }

            int currentTimestamp = TimeUtil.GetTimestamp();
            int logicTimestamp   = this.m_logicGameMode.GetStartTime() + LogicTime.GetTicksInSeconds(subTick);

            if (currentTimestamp + 1 >= logicTimestamp)
            {
                if (commands != null)
                {
                    this.m_serverCommandStorage.CheckExecutableServerCommands(subTick, commands);

                    for (int i = 0; i < commands.Size(); i++)
                    {
                        this.m_logicGameMode.GetCommandManager().AddCommand(commands[i]);
                    }
                }

                int previousSubTick = this.m_logicGameMode.GetLevel().GetLogicTime().GetTick();

                try
                {
                    this.m_logicWatch.Start();

                    for (int i = 0, count = subTick - previousSubTick; i < count; i++)
                    {
                        this.m_logicGameMode.UpdateOneSubTick();

                        if (this.m_logicWatch.ElapsedMilliseconds >= GameMode.MAX_LOGIC_LOOP_TIME)
                        {
                            Logging.Error(string.Format("GameMode.onClientTurnReceived: logic update stopped because it took too long. ({0}ms for {1} updates)",
                                                        this.m_logicWatch.ElapsedMilliseconds, i));
                            break;
                        }
                    }

                    GameModeClusterManager.ReportLogicUpdateSpeed(this.m_logicWatch.ElapsedMilliseconds);
                    this.m_logicWatch.Reset();
                }
                catch (LogicException exception)
                {
                    Logging.Error("GameMode.onClientTurnReceived: logic exception thrown: " + exception + " (acc id: " + (long)this.m_session.AccountId + ")");
                    ServerErrorMessage serverErrorMessage = new ServerErrorMessage();
                    serverErrorMessage.SetErrorMessage(exception.Message);
                    this.m_session.SendPiranhaMessage(serverErrorMessage, 1);
                    this.m_session.SendMessage(new StopSessionMessage(), 1);
                }
                catch (Exception exception)
                {
                    Logging.Error("GameMode.onClientTurnReceived: exception thrown: " + exception + " (acc id: " + (long)this.m_session.AccountId + ")");
                    this.m_session.SendMessage(new StopSessionMessage(), 1);
                }

                this.CheckChecksum(checksum);

                if (this.m_avatarChangeListener != null)
                {
                    this.SaveState();
                }
                if (this.m_liveReplayId != null)
                {
                    this.UpdateLiveReplay(subTick, commands);
                }
                if (this.m_logicGameMode.IsBattleOver())
                {
                    this.m_shouldDestruct = true;
                }
                if (this.m_shouldDestruct)
                {
                    this.m_session.DestructGameMode();
                }
            }
            else
            {
                this.m_session.SendMessage(new StopSessionMessage(), 1);
            }
        }
Example #4
0
 /// <summary>
 ///     Gets the remaining shield time.
 /// </summary>
 public int GetShieldRemainingSeconds()
 {
     return(LogicMath.Max(LogicTime.GetTicksInSeconds(this._shieldTime - this._level.GetLogicTime()), 0));
 }
Example #5
0
 public int GetPersonalBreakCooldownSeconds()
 {
     return(LogicMath.Max(LogicTime.GetTicksInSeconds(this.m_personalBreakTime - this.m_level.GetLogicTime().GetTick()), 0));
 }