fix minor shroud bug [where we have no units]; spawn point choosing
This commit is contained in:
@@ -400,9 +400,41 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
public static void StartGame()
|
public static void StartGame()
|
||||||
{
|
{
|
||||||
// todo: spawn starting units for everyone
|
var available = SpawnPoints.ToList();
|
||||||
|
var taken = new List<int2>();
|
||||||
|
|
||||||
|
foreach (var client in LobbyInfo.Clients)
|
||||||
|
{
|
||||||
|
// todo: allow players to choose their own spawn points.
|
||||||
|
// only select a point for them if they didn't.
|
||||||
|
|
||||||
|
// todo: spawn more than one unit, in most cases!
|
||||||
|
|
||||||
|
var sp = ChooseSpawnPoint(available, taken);
|
||||||
|
world.Add(new Actor("mcv", sp, players[client.Index]));
|
||||||
|
}
|
||||||
|
|
||||||
|
Game.viewport.GoToStartLocation();
|
||||||
orderManager.StartGame();
|
orderManager.StartGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int2 ChooseSpawnPoint(List<int2> available, List<int2> taken)
|
||||||
|
{
|
||||||
|
if (available.Count == 0)
|
||||||
|
throw new InvalidOperationException("No free spawnpoint.");
|
||||||
|
|
||||||
|
var n = taken.Count == 0
|
||||||
|
? Game.SharedRandom.Next(available.Count)
|
||||||
|
: available // pick the most distant spawnpoint from everyone else
|
||||||
|
.Select((k,i) => Pair.New(k,i))
|
||||||
|
.OrderByDescending(a => taken.Sum(t => (t - a.First).LengthSquared))
|
||||||
|
.Select(a => a.Second)
|
||||||
|
.First();
|
||||||
|
|
||||||
|
var sp = available[n];
|
||||||
|
available.RemoveAt(n);
|
||||||
|
taken.Add(sp);
|
||||||
|
return sp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
if( useAftermath )
|
if( useAftermath )
|
||||||
AllRules = new IniFile(
|
AllRules = new IniFile(
|
||||||
FileSystem.Open( "session.ini" ),
|
|
||||||
FileSystem.Open( mapFileName ),
|
FileSystem.Open( mapFileName ),
|
||||||
FileSystem.Open("aftermathUnits.ini"),
|
FileSystem.Open("aftermathUnits.ini"),
|
||||||
FileSystem.Open("units.ini"),
|
FileSystem.Open("units.ini"),
|
||||||
@@ -38,7 +37,6 @@ namespace OpenRa.Game
|
|||||||
FileSystem.Open("trees.ini"));
|
FileSystem.Open("trees.ini"));
|
||||||
else
|
else
|
||||||
AllRules = new IniFile(
|
AllRules = new IniFile(
|
||||||
FileSystem.Open("session.ini"),
|
|
||||||
FileSystem.Open(mapFileName),
|
FileSystem.Open(mapFileName),
|
||||||
FileSystem.Open("units.ini"),
|
FileSystem.Open("units.ini"),
|
||||||
FileSystem.Open("rules.ini"),
|
FileSystem.Open("rules.ini"),
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace OpenRa.Game
|
|||||||
bool[,] explored = new bool[128, 128];
|
bool[,] explored = new bool[128, 128];
|
||||||
Sprite[] shadowBits = SpriteSheetBuilder.LoadAllSprites("shadow");
|
Sprite[] shadowBits = SpriteSheetBuilder.LoadAllSprites("shadow");
|
||||||
Sprite[,] sprites = new Sprite[128, 128];
|
Sprite[,] sprites = new Sprite[128, 128];
|
||||||
bool dirty;
|
bool dirty = true;
|
||||||
bool hasGPS = false;
|
bool hasGPS = false;
|
||||||
|
|
||||||
float gapOpaqueTicks = (int)(Rules.General.GapRegenInterval * 25 * 60);
|
float gapOpaqueTicks = (int)(Rules.General.GapRegenInterval * 25 * 60);
|
||||||
|
|||||||
Reference in New Issue
Block a user