Only reload sprites on theatre change; kill cruft

This commit is contained in:
Paul Chote
2010-08-21 20:34:59 +12:00
parent 9db92ed8ba
commit 49f2bfb460
2 changed files with 13 additions and 23 deletions

View File

@@ -46,9 +46,7 @@ namespace OpenRA
public static Renderer Renderer; public static Renderer Renderer;
static int2 clientSize; static int2 clientSize;
static string mapName;
public static Session LobbyInfo = new Session(); public static Session LobbyInfo = new Session();
static bool mapChangePending;
static void LoadMap(string uid) static void LoadMap(string uid)
{ {
@@ -59,9 +57,6 @@ namespace OpenRA
Timer.Time("viewport: {0}"); Timer.Time("viewport: {0}");
world = new World(modData.Manifest, map); world = new World(modData.Manifest, map);
Timer.Time("world: {0}"); Timer.Time("world: {0}");
Timer.Time("----end LoadMap");
Debug("Map change {0} -> {1}".F(Game.mapName, mapName));
} }
public static void MoveViewport(int2 loc) public static void MoveViewport(int2 loc)
@@ -116,13 +111,6 @@ namespace OpenRA
static void Tick() static void Tick()
{ {
if (mapChangePending)
{
mapName = LobbyInfo.GlobalSettings.Map;
mapChangePending = false;
return;
}
if (orderManager.Connection.ConnectionState != lastConnectionState) if (orderManager.Connection.ConnectionState != lastConnectionState)
{ {
lastConnectionState = orderManager.Connection.ConnectionState; lastConnectionState = orderManager.Connection.ConnectionState;
@@ -215,9 +203,6 @@ namespace OpenRA
Debug("Order lag is now {0} frames.".F(LobbyInfo.GlobalSettings.OrderLatency)); Debug("Order lag is now {0} frames.".F(LobbyInfo.GlobalSettings.OrderLatency));
} }
if (mapName != LobbyInfo.GlobalSettings.Map)
mapChangePending = true;
LobbyInfoChanged(); LobbyInfoChanged();
} }

View File

@@ -40,22 +40,27 @@ namespace OpenRA
return paths.Select(p => new MapStub(new Folder(p))).ToDictionary(m => m.Uid); return paths.Select(p => new MapStub(new Folder(p))).ToDictionary(m => m.Uid);
} }
string cachedTheatre = null;
public Map PrepareMap(string uid) public Map PrepareMap(string uid)
{ {
if (!AvailableMaps.ContainsKey(uid))
throw new InvalidDataException("Invalid map uid: {0}".F(uid));
Timer.Time("----PrepareMap"); Timer.Time("----PrepareMap");
var map = new Map(AvailableMaps[uid].Package); var map = new Map(AvailableMaps[uid].Package);
Timer.Time( "Map: {0}" ); Timer.Time( "Map: {0}" );
if (!AvailableMaps.ContainsKey(uid))
throw new InvalidDataException("Invalid map uid: {0}".F(uid));
Rules.LoadRules(Manifest, map); Rules.LoadRules(Manifest, map);
Timer.Time( "Rules: {0}" ); Timer.Time( "Rules: {0}" );
if (map.Theater != cachedTheatre)
{
SpriteSheetBuilder.Initialize( Rules.TileSets[map.Tileset] ); SpriteSheetBuilder.Initialize( Rules.TileSets[map.Tileset] );
SequenceProvider.Initialize(Manifest.Sequences); SequenceProvider.Initialize(Manifest.Sequences);
Timer.Time("SSB, SeqProv: {0}"); Timer.Time("SSB, SeqProv: {0}");
cachedTheatre = map.Theater;
}
Timer.Time("----end PrepareMap");
return map; return map;
} }
} }