Fix duplicate import of multi-cell overlays.
This commit is contained in:
@@ -121,6 +121,42 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
{ 0xBC, "crate" }
|
{ 0xBC, "crate" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static readonly Dictionary<byte, Size> OverlayShapes = new Dictionary<byte, Size>()
|
||||||
|
{
|
||||||
|
{ 0x4A, new Size(1, 3) },
|
||||||
|
{ 0x4B, new Size(1, 3) },
|
||||||
|
{ 0x4C, new Size(1, 3) },
|
||||||
|
{ 0x4D, new Size(1, 3) },
|
||||||
|
{ 0x4E, new Size(1, 3) },
|
||||||
|
{ 0x4F, new Size(1, 3) },
|
||||||
|
{ 0x50, new Size(1, 3) },
|
||||||
|
{ 0x51, new Size(1, 3) },
|
||||||
|
{ 0x52, new Size(1, 3) },
|
||||||
|
{ 0x53, new Size(3, 1) },
|
||||||
|
{ 0x54, new Size(3, 1) },
|
||||||
|
{ 0x55, new Size(3, 1) },
|
||||||
|
{ 0x56, new Size(3, 1) },
|
||||||
|
{ 0x57, new Size(3, 1) },
|
||||||
|
{ 0x58, new Size(3, 1) },
|
||||||
|
{ 0x59, new Size(3, 1) },
|
||||||
|
{ 0x5A, new Size(3, 1) },
|
||||||
|
{ 0x5B, new Size(3, 1) },
|
||||||
|
{ 0x5C, new Size(1, 3) },
|
||||||
|
{ 0x5D, new Size(1, 3) },
|
||||||
|
{ 0x5E, new Size(1, 3) },
|
||||||
|
{ 0x5F, new Size(1, 3) },
|
||||||
|
{ 0x60, new Size(3, 1) },
|
||||||
|
{ 0x61, new Size(3, 1) },
|
||||||
|
{ 0x62, new Size(3, 1) },
|
||||||
|
{ 0x63, new Size(3, 1) },
|
||||||
|
{ 0x64, new Size(1, 3) },
|
||||||
|
{ 0x65, new Size(3, 1) },
|
||||||
|
{ 0x7A, new Size(1, 3) },
|
||||||
|
{ 0x7B, new Size(1, 3) },
|
||||||
|
{ 0x7C, new Size(3, 1) },
|
||||||
|
{ 0x7D, new Size(3, 1) },
|
||||||
|
};
|
||||||
|
|
||||||
static readonly Dictionary<byte, byte[]> ResourceFromOverlay = new Dictionary<byte, byte[]>()
|
static readonly Dictionary<byte, byte[]> ResourceFromOverlay = new Dictionary<byte, byte[]>()
|
||||||
{
|
{
|
||||||
// "tib" - Regular Tiberium
|
// "tib" - Regular Tiberium
|
||||||
@@ -274,6 +310,9 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
var overlayDataPack = new byte[1 << 18];
|
var overlayDataPack = new byte[1 << 18];
|
||||||
UnpackLCW(overlayDataCompressed, overlayDataPack, temp);
|
UnpackLCW(overlayDataCompressed, overlayDataPack, temp);
|
||||||
|
|
||||||
|
var overlayIndex = new CellLayer<int>(map);
|
||||||
|
overlayIndex.Clear(0xFF);
|
||||||
|
|
||||||
for (var y = 0; y < fullSize.Y; y++)
|
for (var y = 0; y < fullSize.Y; y++)
|
||||||
{
|
{
|
||||||
for (var x = fullSize.X * 2 - 2; x >= 0; x--)
|
for (var x = fullSize.X * 2 - 2; x >= 0; x--)
|
||||||
@@ -288,21 +327,48 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
if (!map.Resources.Contains(uv))
|
if (!map.Resources.Contains(uv))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var idx = rx + 512 * ry;
|
overlayIndex[uv] = rx + 512 * ry;
|
||||||
var overlayType = overlayPack[idx];
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var cell in map.AllCells)
|
||||||
|
{
|
||||||
|
var overlayType = overlayPack[overlayIndex[cell]];
|
||||||
if (overlayType == 0xFF)
|
if (overlayType == 0xFF)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string actorType;
|
string actorType;
|
||||||
if (OverlayToActor.TryGetValue(overlayType, out actorType))
|
if (OverlayToActor.TryGetValue(overlayType, out actorType))
|
||||||
{
|
{
|
||||||
|
var shape = new Size(1, 1);
|
||||||
|
if (OverlayShapes.TryGetValue(overlayType, out shape))
|
||||||
|
{
|
||||||
|
// Only import the top-left cell of multi-celled overlays
|
||||||
|
var aboveType = overlayPack[overlayIndex[cell - new CVec(1, 0)]];
|
||||||
|
if (shape.Width > 1 && aboveType != 0xFF)
|
||||||
|
{
|
||||||
|
string a;
|
||||||
|
if (OverlayToActor.TryGetValue(aboveType, out a) && a == actorType)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var leftType = overlayPack[overlayIndex[cell - new CVec(0, 1)]];
|
||||||
|
if (shape.Height > 1 && leftType != 0xFF)
|
||||||
|
{
|
||||||
|
string a;
|
||||||
|
if (OverlayToActor.TryGetValue(leftType, out a) && a == actorType)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var ar = new ActorReference(actorType)
|
var ar = new ActorReference(actorType)
|
||||||
{
|
{
|
||||||
new LocationInit(uv.ToCPos(map)),
|
new LocationInit(cell),
|
||||||
new OwnerInit("Neutral")
|
new OwnerInit("Neutral")
|
||||||
};
|
};
|
||||||
|
|
||||||
map.ActorDefinitions.Add(new MiniYamlNode("Actor" + map.ActorDefinitions.Count, ar.Save()));
|
map.ActorDefinitions.Add(new MiniYamlNode("Actor" + map.ActorDefinitions.Count, ar.Save()));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,12 +379,11 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
|
|
||||||
if (resourceType != 0)
|
if (resourceType != 0)
|
||||||
{
|
{
|
||||||
map.Resources[uv] = new ResourceTile(resourceType, overlayDataPack[idx]);
|
map.Resources[cell] = new ResourceTile(resourceType, overlayDataPack[overlayIndex[cell]]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("{0} unknown overlay {1}", uv, overlayType);
|
Console.WriteLine("{0} unknown overlay {1}", cell, overlayType);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user