Skip to content

Commit 06a73cd

Browse files
Fix to reading in larger BASE coordinate values
Have increase the size of the bit mask to 0x7f, this works for 64 and 128 maps.
1 parent 059709c commit 06a73cd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

CnCTDRAMapEditor/TiberianDawn/GamePlugin.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,9 @@ private IEnumerable<string> LoadINI(INI ini)
699699
if (buildingType != null)
700700
{
701701
var coord = int.Parse(tokens[1]);
702-
var location = new Point((coord >> 8) & 0x3F, (coord >> 24) & 0x3F);
702+
// Megamap support - bitwise AND needs to be larger
703+
// var location = new Point((coord >> 8) & 0x3F, (coord >> 24) & 0x3F);
704+
var location = new Point((coord >> 8) & 0x7F, (coord >> 24) & 0x7F);
703705
if (Map.Buildings.OfType<Building>().Where(x => x.Location == location).FirstOrDefault().Occupier is Building building)
704706
{
705707
building.BasePriority = priority;
@@ -842,7 +844,7 @@ private void LoadBinary(BinaryReader reader)
842844
{
843845
/*
844846
** Format for this is e.g. 0F 00
845-
** Cell number = every cell gets 2 bytes in the bin file
847+
** Cell number = not required as every cell gets 2 bytes in the bin file
846848
** Template = 0x0F
847849
** Icon = 0x00
848850
*/
@@ -1086,7 +1088,9 @@ private void SaveINI(INI ini, FileType fileType)
10861088

10871089
baseSection[key] = string.Format("{0},{1}",
10881090
building.Type.Name.ToUpper(),
1089-
((location.Y & 0x3F) << 24) | ((location.X & 0x3F) << 8)
1091+
// Megamap support - bitwise AND needs to be larger
1092+
// ((location.Y & 0x3F) << 24) | ((location.X & 0x3F) << 8)
1093+
((location.Y & 0x7F) << 24) | ((location.X & 0x7F) << 8)
10901094
);
10911095
}
10921096
baseSection["Count"] = baseBuildings.Length.ToString();

0 commit comments

Comments
 (0)