From 06a73cd2685aa04766345822fde8cd8de32d458b Mon Sep 17 00:00:00 2001 From: screamingchicken <71244336+screamingchicken@users.noreply.github.com> Date: Fri, 30 Jul 2021 10:19:20 +0800 Subject: [PATCH] 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. --- CnCTDRAMapEditor/TiberianDawn/GamePlugin.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CnCTDRAMapEditor/TiberianDawn/GamePlugin.cs b/CnCTDRAMapEditor/TiberianDawn/GamePlugin.cs index 5daec87..32e211e 100644 --- a/CnCTDRAMapEditor/TiberianDawn/GamePlugin.cs +++ b/CnCTDRAMapEditor/TiberianDawn/GamePlugin.cs @@ -699,7 +699,9 @@ private IEnumerable LoadINI(INI ini) if (buildingType != null) { var coord = int.Parse(tokens[1]); - var location = new Point((coord >> 8) & 0x3F, (coord >> 24) & 0x3F); +// Megamap support - bitwise AND needs to be larger +// var location = new Point((coord >> 8) & 0x3F, (coord >> 24) & 0x3F); + var location = new Point((coord >> 8) & 0x7F, (coord >> 24) & 0x7F); if (Map.Buildings.OfType().Where(x => x.Location == location).FirstOrDefault().Occupier is Building building) { building.BasePriority = priority; @@ -842,7 +844,7 @@ private void LoadBinary(BinaryReader reader) { /* ** Format for this is e.g. 0F 00 - ** Cell number = every cell gets 2 bytes in the bin file + ** Cell number = not required as every cell gets 2 bytes in the bin file ** Template = 0x0F ** Icon = 0x00 */ @@ -1086,7 +1088,9 @@ private void SaveINI(INI ini, FileType fileType) baseSection[key] = string.Format("{0},{1}", building.Type.Name.ToUpper(), - ((location.Y & 0x3F) << 24) | ((location.X & 0x3F) << 8) +// Megamap support - bitwise AND needs to be larger +// ((location.Y & 0x3F) << 24) | ((location.X & 0x3F) << 8) + ((location.Y & 0x7F) << 24) | ((location.X & 0x7F) << 8) ); } baseSection["Count"] = baseBuildings.Length.ToString();