Skip to content

Commit

Permalink
Fix save data soft-locks
Browse files Browse the repository at this point in the history
  • Loading branch information
Extremelyd1 committed Sep 7, 2024
1 parent 33579f1 commit 31442cf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions HKMP/Game/Client/Save/SaveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ private void UpdateSaveWithData(ushort index, byte[] encodedValue) {

var value = encodedValue[0] == 1;

_lastPlayerData?.SetBoolInternal(name, value);
pd.SetBoolInternal(name, value);
} else if (type == typeof(float)) {
if (valueLength != 4) {
Expand All @@ -775,6 +776,7 @@ private void UpdateSaveWithData(ushort index, byte[] encodedValue) {

var value = BitConverter.ToSingle(encodedValue, 0);

_lastPlayerData?.SetFloatInternal(name, value);
pd.SetFloatInternal(name, value);
} else if (type == typeof(int)) {
if (valueLength != 4) {
Expand All @@ -783,10 +785,12 @@ private void UpdateSaveWithData(ushort index, byte[] encodedValue) {

var value = BitConverter.ToInt32(encodedValue, 0);

_lastPlayerData?.SetIntInternal(name, value);
pd.SetIntInternal(name, value);
} else if (type == typeof(string)) {
var value = DecodeString(encodedValue, 0);

_lastPlayerData?.SetStringInternal(name, value);
pd.SetStringInternal(name, value);
} else if (type == typeof(Vector3)) {
if (valueLength != 12) {
Expand All @@ -799,6 +803,7 @@ private void UpdateSaveWithData(ushort index, byte[] encodedValue) {
BitConverter.ToSingle(encodedValue, 8)
);

_lastPlayerData?.SetVector3Internal(name, value);
pd.SetVector3Internal(name, value);
} else if (type == typeof(List<string>)) {
var length = BitConverter.ToUInt16(encodedValue, 0);
Expand Down Expand Up @@ -884,6 +889,7 @@ private void UpdateSaveWithData(ushort index, byte[] encodedValue) {
Logger.Warn($"Received save update with incorrect value length for MapZone: {valueLength}");
}

_lastPlayerData?.SetVariableInternal(name, (MapZone) encodedValue[0]);
pd.SetVariableInternal(name, (MapZone) encodedValue[0]);
} else {
throw new ArgumentException($"Could not decode type: {type}");
Expand Down

0 comments on commit 31442cf

Please sign in to comment.