Skip to content

Commit

Permalink
always use +map for zdoom based ports/helion
Browse files Browse the repository at this point in the history
  • Loading branch information
nstlaurent committed Jul 15, 2023
1 parent 6a42a90 commit 43c2a1a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
15 changes: 8 additions & 7 deletions DoomLauncher/SourcePort/GenericSourcePort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public bool CheckFileNameContains(string name)

public virtual string IwadParameter(SpData data)
{
return string.Format(" -iwad \"{0}\"", data.Value);
return $" -iwad \"{data.Value}\"";
}

public virtual string FileParameter(SpData data)
Expand All @@ -48,17 +48,17 @@ public virtual string WarpParameter(SpData data)

public virtual string SkillParameter(SpData data)
{
return string.Format(" -skill {0}", data.Value);
return $" -skill {data.Value}";
}

public virtual string RecordParameter(SpData data)
{
return string.Format(" -record \"{0}\"", data.Value);
return $" -record \"{data.Value}\"";
}

public virtual string PlayDemoParameter(SpData data)
{
return string.Format(" -playdemo \"{0}\"", data.Value);
return $" -playdemo \"{data.Value}\"";
}

public virtual string LoadSaveParameter(SpData data)
Expand All @@ -78,9 +78,11 @@ public static string BuildWarpParameter(string map)
if (Regex.IsMatch(map, @"^E\dM\d$") || Regex.IsMatch(map, @"^MAP\d\d$"))
return BuildWarpLegacy(map);

return string.Format(" +map {0}", map);
return GetMapParameter(map);
}

public static string GetMapParameter(string map) => $" +map {map}";

public virtual bool Supported() => true;

public virtual bool StatisticsSupported() => false;
Expand Down Expand Up @@ -126,7 +128,6 @@ private static string BuildWarpLegacy(string map)
numbers.Add(num.ToString());

StringBuilder sb = new StringBuilder();

foreach (string number in numbers)
{
sb.Append(Convert.ToInt32(number));
Expand All @@ -136,7 +137,7 @@ private static string BuildWarpLegacy(string map)
if (numbers.Any())
sb.Remove(sb.Length - 1, 1);

return string.Format(" -warp {0}", sb.ToString());
return $" -warp {sb.ToString()}";
}
}
}
2 changes: 2 additions & 0 deletions DoomLauncher/SourcePort/HelionSourcePort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ public override IStatisticsReader CreateStatisticsReader(IGameFile gameFile, IEn
{
return new BoomStatsReader(gameFile, Path.Combine(m_sourcePortData.Directory.GetFullPath(), "levelstat.txt"));
}

public override string WarpParameter(SpData data) => GetMapParameter(data.Value);
}
}
2 changes: 2 additions & 0 deletions DoomLauncher/SourcePort/ZDoomSourcePort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ public override string LoadSaveParameter(SpData data) =>

public override IStatisticsReader CreateStatisticsReader(IGameFile gameFile, IEnumerable<IStatsData> existingStats) =>
new ZDoomStatsReader(gameFile, m_sourcePortData.Directory.GetFullPath(), existingStats);

public override string WarpParameter(SpData data) => GetMapParameter(data.Value);
}
}
26 changes: 23 additions & 3 deletions UnitTest/Tests/TestPlayAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,43 @@ public void TestParametersSourcePortExtraParams()
}

[TestMethod]
public void TestSkill()
public void TestSkillAndMap()
{
LauncherPath gameFilePath = new LauncherPath("GameFiles");
LauncherPath tempPath = new LauncherPath("Temp");
GameFilePlayAdapter adapter = new GameFilePlayAdapter();
adapter.ExtractFiles = false;
adapter.Skill = "3";
string launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), GetTestPort(".wad,.deh"), false);
var port = GetPrBoomTestPort(".wad,.deh");
string launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), port, false);
//only add skill with map
Assert.IsFalse(launch.Contains("-skill 3"));

adapter.Map = "MAP01";
launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), GetTestPort(".wad,.deh"), false);
launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), port, false);
Assert.IsTrue(launch.Contains("-skill 3"));
Assert.IsTrue(launch.Contains("-warp 1"));
}

[TestMethod]
public void TestSkillAndMapZdoom()
{
LauncherPath gameFilePath = new LauncherPath("GameFiles");
LauncherPath tempPath = new LauncherPath("Temp");
GameFilePlayAdapter adapter = new GameFilePlayAdapter();
adapter.ExtractFiles = false;
adapter.Skill = "3";
var port = GetTestPort(".wad,.deh");
string launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), port, false);
//only add skill with map
Assert.IsFalse(launch.Contains("-skill 3"));

adapter.Map = "MAP01";
launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), port, false);
Assert.IsTrue(launch.Contains("-skill 3"));
Assert.IsTrue(launch.Contains("+map MAP01"));
}

[TestMethod]
public void TestRecord()
{
Expand Down

0 comments on commit 43c2a1a

Please sign in to comment.