Replace all instances of Town Bytes

Attempt to resolve Issue #7
This commit is contained in:
Kurt
2015-09-19 20:36:45 -07:00
parent 66a0a0d522
commit 9a7ea098ee
2 changed files with 34 additions and 3 deletions

View File

@@ -192,12 +192,18 @@ public GardenData(byte[] data)
}
public byte[] Write()
{
// Replace all instances of Town Data with Updated Data
byte[] oldTownIDData = Data.Skip(0x5C7B8).Take(0x14).ToArray();
byte[] newTownIDData = new[]
{
(byte) ((Data[0x5C7B8] & 0xFC) | TownHallColor),
(byte) ((Data[0x5C7B9] & 0xFC) | TrainStationColor)
}.Concat(Encoding.Unicode.GetBytes(TownName.PadRight(9, '\0'))).ToArray();
Util.ReplaceAllBytes(Data, oldTownIDData, newTownIDData);
Data[0x4DA81] = (byte)GrassType;
Data[0x5C7B8] = (byte)((Data[0x5C7B8] & 0xFC) | TownHallColor);
Data[0x5C7B9] = (byte)((Data[0x5C7B9] & 0xFC) | TrainStationColor);
Data[0x5C836] = (byte)NativeFruit;
Array.Copy(Encoding.Unicode.GetBytes(TownName.PadRight(9, '\0')), 0, Data, 0x5C7BA, 0x12);
Array.Copy(BitConverter.GetBytes(SecondsPlayed), 0, Data, 0x5C7B0, 4);
Array.Copy(BitConverter.GetBytes(PlayDays), 0, Data, 0x5C83A, 2);
return Data;