Skip to content

Commit

Permalink
Fixed other issues causing rooms to fail to save
Browse files Browse the repository at this point in the history
  • Loading branch information
SolventMercury committed Nov 14, 2021
1 parent cbb780d commit 2634e18
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions Scripts/HgPatcher.csx
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,25 @@ void ReadRoom(string filePath) {

ReadRoomMainVals(ref reader, newRoom);

ClearRoomData(newRoom);

ReadBackgrounds(ref reader, newRoom);
ReadViews(ref reader, newRoom);
ReadGameObjects(ref reader, newRoom);
ReadTiles(ref reader, newRoom);
ReadLayers(ref reader, newRoom);

ReadAnticipateEndObj(ref reader);

}

void ClearRoomData(UndertaleRoom newRoom) {
newRoom.Backgrounds.Clear();
newRoom.Views.Clear();
newRoom.GameObjects.Clear();
newRoom.Tiles.Clear();
newRoom.Layers.Clear();
newRoom.Sequences.Clear();
}

void ReadRoomMainVals(ref Utf8JsonReader reader, UndertaleRoom newRoom) {
Expand All @@ -294,16 +306,14 @@ void ReadRoomMainVals(ref Utf8JsonReader reader, UndertaleRoom newRoom) {
newRoom.GravityY = ReadFloat(ref reader);
newRoom.MetersPerPixel = ReadFloat(ref reader);

if (caption == null) {
newRoom.Caption = null;
} else {
if (caption != null) {
newRoom.Caption = new UndertaleString(caption);
ScriptMessage(String.Format("caption is {0}", caption));
}

if (ccIdName == null) {
newRoom.CreationCodeId = null;
} else {
if (ccIdName != null) {
newRoom.CreationCodeId = Data.Code.ByName(ccIdName);
ScriptMessage(String.Format("Creation Code is {0}", ccIdName));
}
}

Expand Down Expand Up @@ -943,7 +953,12 @@ string ReadString(ref Utf8JsonReader reader) {
continue;
}
if (reader.TokenType == JsonTokenType.String) {
return reader.GetString();
string result = reader.GetString();
if (result.Equals("null") || result.Length < 1) {
return null;
} else {
return result;
}
} else if (reader.TokenType == JsonTokenType.Null) {
return null;
} else {
Expand Down

0 comments on commit 2634e18

Please sign in to comment.