Skip to content

Commit

Permalink
Rename ToLayer to WithLayer. Fix missing brace.
Browse files Browse the repository at this point in the history
  • Loading branch information
anvilvapre committed Apr 8, 2021
1 parent a2c9125 commit e70198a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion OpenRA.Game/CPos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public MPos ToMPos(MapGridType gridType)
return new MPos(u, v);
}

public CPos ToLayer(byte layer)
public CPos WithLayer(byte layer)
{
return new CPos((Bits & 0xff) | layer);
}
Expand Down
16 changes: 10 additions & 6 deletions OpenRA.Game/Primitives/PriorityQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ public void Add(T item)
{
var addLevel = level;
var addIndex = index;
var above = Above(addLevel, addIndex);

while (addLevel >= 1 && comparer.Compare(above), item) > 0)
while (addLevel >= 1)
{
items[addLevel][addIndex] = above;
--addLevel;
addIndex >>= 1;
above = Above(addLevel, addIndex);
var above = Above(addLevel, addIndex);
if (comparer.Compare(above, item) > 0)
{
items[addLevel][addIndex] = above;
--addLevel;
addIndex >>= 1;
}
else
break;
}

items[addLevel][addIndex] = item;
Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Mods.Common/Pathfinder/PathGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ public List<GraphConnection> GetConnections(CPos position)
{
foreach (var layer in customMovementLayers)
{
var layerPosition = position.ToLayer(layer.Index);
var layerPosition = position.WithLayer(layer.Index);
var entryCost = layer.EntryMovementCost(actorInfo, locomotorInfo, layerPosition);
if (entryCost != CostForInvalidCell)
validNeighbors.Add(new GraphConnection(layerPosition, entryCost));
}
}
else
{
var layerPosition = position.ToLayer(0);
var layerPosition = position.WithLayer(0);
var exitCost = customLayerInfo[positionLayer].Layer.ExitMovementCost(actorInfo, locomotorInfo, layerPosition);
if (exitCost != CostForInvalidCell)
validNeighbors.Add(new GraphConnection(layerPosition, exitCost));
Expand Down

0 comments on commit e70198a

Please sign in to comment.