crude map change support; quite a few things aren't right
This commit is contained in:
@@ -301,6 +301,29 @@ namespace OpenRA.Server
|
||||
new ServerOrder(conn.PlayerIndex, "SetPalette", pal.ToString()).Serialize());
|
||||
return true;
|
||||
}},
|
||||
{ "map",
|
||||
s =>
|
||||
{
|
||||
if (conn.PlayerIndex != 0)
|
||||
{
|
||||
DispatchOrdersToClient(conn, 0,
|
||||
new ServerOrder( conn.PlayerIndex, "Chat",
|
||||
"Only the host can change the map" ).Serialize() );
|
||||
return true;
|
||||
}
|
||||
|
||||
if (conn.IsReady)
|
||||
{
|
||||
DispatchOrdersToClient(conn, 0,
|
||||
new ServerOrder( conn.PlayerIndex, "Chat",
|
||||
"You can't change the map after the game has started" ).Serialize() );
|
||||
return true;
|
||||
}
|
||||
|
||||
DispatchOrders( null, 0,
|
||||
new ServerOrder(0, "ChangeMap", s).Serialize());
|
||||
return true;
|
||||
}},
|
||||
};
|
||||
|
||||
var cmdName = cmd.Split(' ').First();
|
||||
|
||||
@@ -48,45 +48,68 @@ namespace OpenRa.Game
|
||||
|
||||
public static bool skipMakeAnims = true;
|
||||
|
||||
public static void Initialize(string mapName, Renderer renderer, int2 clientSize,
|
||||
int localPlayer, bool useAftermath, Controller controller)
|
||||
static Renderer renderer;
|
||||
static bool usingAftermath;
|
||||
static int2 clientSize;
|
||||
|
||||
public static void ChangeMap(string mapName)
|
||||
{
|
||||
Rules.LoadRules(mapName, useAftermath);
|
||||
SheetBuilder.Initialize(renderer);
|
||||
|
||||
Rules.LoadRules(mapName, usingAftermath);
|
||||
world = new World();
|
||||
|
||||
for( int i = 0 ; i < 8 ; i++ )
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
var a = new Actor( null, new int2( int.MaxValue, int.MaxValue ), null );
|
||||
players[ i ] = new Player( a, i, i, "Multi{0}".F( i ), Race.Allies );
|
||||
a.Owner = players[ i ];
|
||||
a.traits.Add( new Traits.ProductionQueue( a ) );
|
||||
Game.world.Add( a );
|
||||
var a = new Actor(null, new int2(int.MaxValue, int.MaxValue), null);
|
||||
players[i] = new Player(a, i, i, "Multi{0}".F(i), Race.Allies);
|
||||
a.Owner = players[i];
|
||||
a.traits.Add(new Traits.ProductionQueue(a));
|
||||
Game.world.Add(a);
|
||||
}
|
||||
|
||||
localPlayerIndex = localPlayer;
|
||||
|
||||
Rules.Map.InitOreDensity();
|
||||
worldRenderer = new WorldRenderer(renderer);
|
||||
|
||||
Game.controller = controller;
|
||||
worldRenderer = new WorldRenderer( renderer );
|
||||
|
||||
SequenceProvider.Initialize(useAftermath);
|
||||
viewport = new Viewport( clientSize, Rules.Map.Offset, Rules.Map.Offset + Rules.Map.Size, renderer );
|
||||
|
||||
Sound.Initialize();
|
||||
SequenceProvider.Initialize(usingAftermath);
|
||||
viewport = new Viewport(clientSize, Rules.Map.Offset, Rules.Map.Offset + Rules.Map.Size, renderer);
|
||||
|
||||
BuildingInfluence = new BuildingInfluenceMap();
|
||||
UnitInfluence = new UnitInfluenceMap();
|
||||
|
||||
skipMakeAnims = true;
|
||||
foreach (var treeReference in Rules.Map.Trees)
|
||||
world.Add(new Actor(Rules.UnitInfo[treeReference.Image],
|
||||
new int2(treeReference.Location),
|
||||
null));
|
||||
|
||||
LoadMapActors(Rules.AllRules);
|
||||
skipMakeAnims = false;
|
||||
|
||||
PathFinder = new PathFinder();
|
||||
|
||||
chrome = new Chrome(renderer);
|
||||
|
||||
oreFrequency = (int)(Rules.General.GrowthRate * 60 * 1000);
|
||||
oreTicks = oreFrequency;
|
||||
}
|
||||
|
||||
public static void Initialize(string mapName, Renderer renderer, int2 clientSize,
|
||||
int localPlayer, bool useAftermath, Controller controller)
|
||||
{
|
||||
localPlayerIndex = localPlayer;
|
||||
usingAftermath = useAftermath;
|
||||
Game.renderer = renderer;
|
||||
Game.clientSize = clientSize;
|
||||
|
||||
// todo
|
||||
Sound.Initialize();
|
||||
PerfHistory.items["render"].hasNormalTick = false;
|
||||
PerfHistory.items["batches"].hasNormalTick = false;
|
||||
Game.controller = controller;
|
||||
|
||||
ChangeMap(mapName);
|
||||
|
||||
if (Replay != "")
|
||||
orderManager = new OrderManager(new IOrderSource[] { new ReplayOrderSource(Replay) });
|
||||
else
|
||||
@@ -96,15 +119,6 @@ namespace OpenRa.Game
|
||||
: new IOrderSource[] { new LocalOrderSource(), new NetworkOrderSource(new TcpClient(NetworkHost, NetworkPort)) };
|
||||
orderManager = new OrderManager(orderSources, "replay.rep");
|
||||
}
|
||||
|
||||
skipMakeAnims = false;
|
||||
PerfHistory.items["render"].hasNormalTick = false;
|
||||
PerfHistory.items["batches"].hasNormalTick = false;
|
||||
|
||||
chrome = new Chrome(renderer);
|
||||
|
||||
oreFrequency = (int)(Rules.General.GrowthRate * 60 * 1000);
|
||||
oreTicks = oreFrequency;
|
||||
}
|
||||
|
||||
static void LoadMapActors(IniFile mapfile)
|
||||
|
||||
@@ -8,13 +8,14 @@ namespace OpenRa.Game.Graphics
|
||||
{
|
||||
static class SequenceProvider
|
||||
{
|
||||
static Dictionary<string, Dictionary<string, Sequence>> units =
|
||||
new Dictionary<string, Dictionary<string, Sequence>>();
|
||||
|
||||
static Dictionary<string, CursorSequence> cursors = new Dictionary<string, CursorSequence>();
|
||||
static Dictionary<string, Dictionary<string, Sequence>> units;
|
||||
static Dictionary<string, CursorSequence> cursors;
|
||||
|
||||
public static void Initialize( bool useAftermath )
|
||||
{
|
||||
units = new Dictionary<string, Dictionary<string, Sequence>>();
|
||||
cursors = new Dictionary<string, CursorSequence>();
|
||||
|
||||
LoadSequenceSource("sequences.xml");
|
||||
if (useAftermath)
|
||||
LoadSequenceSource("sequences-aftermath.xml");
|
||||
|
||||
@@ -7,6 +7,9 @@ namespace OpenRa.Game.Graphics
|
||||
public static void Initialize(Renderer r)
|
||||
{
|
||||
renderer = r;
|
||||
current = null;
|
||||
rowHeight = 0;
|
||||
channel = null;
|
||||
}
|
||||
|
||||
public static Sprite Add(byte[] src, Size size)
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRa.Game.Graphics
|
||||
public readonly SpriteRenderer spriteRenderer;
|
||||
public readonly LineRenderer lineRenderer;
|
||||
public readonly UiOverlay uiOverlay;
|
||||
readonly Renderer renderer;
|
||||
public readonly Renderer renderer;
|
||||
|
||||
public static bool ShowUnitPaths = false;
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ namespace OpenRa.Game
|
||||
|
||||
bool windowed = !settings.GetValue( "fullscreen", false );
|
||||
renderer = new Renderer( this, GetResolution( settings ), windowed );
|
||||
SheetBuilder.Initialize( renderer );
|
||||
|
||||
var controller = new Controller( () => (Modifiers)(int)ModifierKeys ); /* a bit of insane input routing */
|
||||
|
||||
|
||||
@@ -105,6 +105,12 @@ namespace OpenRa.Game
|
||||
Game.orderManager.StartGame();
|
||||
break;
|
||||
}
|
||||
case "ChangeMap":
|
||||
{
|
||||
Game.chat.AddLine(Color.White, "Server", "Changing map to {0}".F(order.TargetString));
|
||||
Game.ChangeMap(order.TargetString);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
|
||||
Reference in New Issue
Block a user