Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

Commit

Permalink
Fix interactions with zones
Browse files Browse the repository at this point in the history
  • Loading branch information
Zetrith committed Dec 17, 2018
1 parent a476158 commit 49035b3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
3 changes: 3 additions & 0 deletions Languages/English/Keyed/Multiplayer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@

<MpArbiterDesc>A game instance which runs in the background and helps with desync solving.</MpArbiterDesc>

<MpReplayOutdated>(Outdated)</MpReplayOutdated>
<MpReplayOutdatedDesc>This replay was made for protocol version {0}, but you are running version {1}.\n\nThe replay might not play correctly.</MpReplayOutdatedDesc>

</LanguageData>
6 changes: 3 additions & 3 deletions Source/Client/ServerBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,13 @@ private void DrawSaveList(List<SaveFile> saves, float width, ref float y)

if (saveFile.replay && saveFile.protocol != MpVersion.Protocol)
{
GUI.color = new Color(0.8f, 0, 0);
GUI.color = new Color(0.8f, 0.8f, 0);
var outdated = new Rect(infoText.x - 70, infoText.y + 8f, 70, 24f);
Widgets.Label(outdated, "(Outdated)");
Widgets.Label(outdated, "MpReplayOutdated".Translate());

TooltipHandler.TipRegion(
outdated,
$"This replay was made for protocol version {saveFile.protocol}, but you are running version {MpVersion.Protocol}."
"MpReplayOutdatedDesc".Translate(saveFile.protocol, MpVersion.Protocol)
);
}

Expand Down
25 changes: 17 additions & 8 deletions Source/Client/SyncSerialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,16 @@ public static partial class Sync
}
};

private static Type[] storageParents = GenTypes.AllTypes.Where(t => typeof(IStoreSettingsParent).IsAssignableFrom(t)).ToArray();
private static Type[] plantToGrowSettables = GenTypes.AllTypes.Where(t => typeof(IPlantToGrowSettable).IsAssignableFrom(t)).ToArray();
public static Type[] storageParents = AllImplementations(typeof(IStoreSettingsParent));
public static Type[] plantToGrowSettables = AllImplementations(typeof(IPlantToGrowSettable));

private static Type[] AllImplementations(Type type)
{
return GenTypes.AllTypes
.Where(t => t != type && type.IsAssignableFrom(t))
.OrderBy(t => t.IsInterface)
.ToArray();
}

public static MultiTarget thingFilterTarget = new MultiTarget()
{
Expand Down Expand Up @@ -535,9 +543,9 @@ public static object ReadSyncObject(ByteReader data, Type type)

throw new SerializationException("No reader for type " + type);
}
catch
catch (Exception e)
{
MpLog.Error($"Error reading type: {type}");
MpLog.Error($"Error reading type: {type}, {e}");
throw;
}
}
Expand Down Expand Up @@ -937,9 +945,9 @@ public static void WriteSyncObject(ByteWriter data, object obj, Type type)
throw new SerializationException("No writer for type " + type);
}
}
catch
catch (Exception e)
{
MpLog.Error($"Error writing type: {type}, obj: {obj}");
MpLog.Error($"Error writing type: {type}, obj: {obj}, {e}");
throw;
}
finally
Expand Down Expand Up @@ -985,6 +993,7 @@ private static void GetImpl(object obj, IList<Type> impls, out Type type, out in
{
type = impls[i];
index = i;
break;
}
}
}
Expand All @@ -995,7 +1004,7 @@ private static T GetAnyParent<T>(Thing thing) where T : class
if (t != null)
return t;

for (IThingHolder parentHolder = thing.ParentHolder; parentHolder != null; parentHolder = parentHolder.ParentHolder)
for (var parentHolder = thing.ParentHolder; parentHolder != null; parentHolder = parentHolder.ParentHolder)
if (parentHolder is T t2)
return t2;

Expand All @@ -1006,7 +1015,7 @@ private static string ThingHolderString(Thing thing)
{
StringBuilder builder = new StringBuilder(thing.ToString());

for (IThingHolder parentHolder = thing.ParentHolder; parentHolder != null; parentHolder = parentHolder.ParentHolder)
for (var parentHolder = thing.ParentHolder; parentHolder != null; parentHolder = parentHolder.ParentHolder)
{
builder.Insert(0, "=>");
builder.Insert(0, parentHolder.ToString());
Expand Down
4 changes: 2 additions & 2 deletions Source/Common/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
public static class MpVersion
{
public const string Version = "0.1.4";
public const int Protocol = 3;
public const string Version = "0.1.5";
public const int Protocol = 4;

#if DEBUG
public const bool IsDebug = true;
Expand Down

0 comments on commit 49035b3

Please sign in to comment.