diff --git a/MapChooserSharp/Modules/MapCycle/McsMapCycleController.cs b/MapChooserSharp/Modules/MapCycle/McsMapCycleController.cs index 31c9d98..47b2f26 100644 --- a/MapChooserSharp/Modules/MapCycle/McsMapCycleController.cs +++ b/MapChooserSharp/Modules/MapCycle/McsMapCycleController.cs @@ -270,6 +270,7 @@ private void OnMapStart(string mapName) CurrentMap = NextMap; NextMap = null; + Server.NextFrame(ExecuteMapLimitConfig); // Wait for first people joined // TODO() Maybe we can use Server.NextWorldUpdate() to execute things? @@ -468,6 +469,42 @@ private Func GetCorrespondTimelimitCheck() throw new InvalidOperationException($"This extend type {_timeLeftUtil.ExtendType} is not supported"); } } + + // Timelimit, Round time limit, Round Limit + private void ExecuteMapLimitConfig() + { + if (CurrentMap == null) + { + Logger.LogError("Failed to find current map config, we cannot execute map time/round limit config."); + return; + } + + var cvarName = _timeLeftUtil.ExtendType switch + { + McsMapExtendType.TimeLimit => "mp_timelimit", + McsMapExtendType.RoundTime => "mp_roundtime", + McsMapExtendType.Rounds => "mp_maxrounds", + _ => throw new InvalidOperationException($"This extend type {_timeLeftUtil.ExtendType} is not supported") + }; + + var cvar = ConVar.Find(cvarName); + if (cvar == null) + { + Logger.LogError($"Failed to find ConVar: {cvarName}"); + return; + } + + switch (_timeLeftUtil.ExtendType) + { + case McsMapExtendType.TimeLimit: + case McsMapExtendType.RoundTime: + cvar.SetValue((float)CurrentMap.MapTime); + break; + case McsMapExtendType.Rounds: + cvar.SetValue(CurrentMap.MapRounds); + break; + } + } // tuna: I know same method exists in vote controller, but I don't have mutch time to refactor so I simply copy paste it. // TODO() Needs refactor diff --git a/docs/en/configuration/MAP_CONFIG.md b/docs/en/configuration/MAP_CONFIG.md index d200125..088d120 100644 --- a/docs/en/configuration/MAP_CONFIG.md +++ b/docs/en/configuration/MAP_CONFIG.md @@ -314,8 +314,6 @@ For time-based maps, specifies how many minutes to extend each time an extension ### MapTime -Currently not in use. - For time-based maps, specifies the duration of the map. ### ExtendRoundsPerExtends @@ -324,8 +322,6 @@ For round-based maps, specifies how many rounds to extend each time an extension ### MapRounds -Currently not in use. - For round-based maps, specifies the number of rounds for the map. ## Nomination Settings diff --git a/docs/ja/configuration/MAP_CONFIG.md b/docs/ja/configuration/MAP_CONFIG.md index 8cb72bc..a22c359 100644 --- a/docs/ja/configuration/MAP_CONFIG.md +++ b/docs/ja/configuration/MAP_CONFIG.md @@ -313,8 +313,6 @@ cost = 100 ### MapTime -現在は使用していません。 - マップが時間ベースの場合に、マップの時間を指定します。 ### ExtendRoundsPerExtends @@ -323,8 +321,6 @@ cost = 100 ### MapRounds -現在は使用していません。 - マップがラウンドベースの場合に、マップのラウンド数を指定します。 ## ノミネート関連