Skip to content

Commit

Permalink
Updated deprecated network methods to newer ones
Browse files Browse the repository at this point in the history
  • Loading branch information
8vogt committed Nov 25, 2020
1 parent 6656f4d commit 64992ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions SEWorldGenPlugin/GUI/PluginMainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,19 @@ private void DrawPluginLoaded()
StringBuilder pluginWithVersion = new StringBuilder();
pluginWithVersion.AppendFormat(PLUGIN_LOADED.ToString(), VersionCheck.Static.GetVersion());

MyGuiManager.DrawString(MyFontEnum.BuildInfo, pluginWithVersion, textLeftBottomPosition, 1, new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha, 1), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
MyGuiManager.DrawString(MyFontEnum.BuildInfo, pluginWithVersion.ToString(), textLeftBottomPosition, 1, new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha, 1), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);

size = MyGuiManager.MeasureString(MyFontEnum.BuildInfo, pluginWithVersion, 1);

textLeftBottomPosition.X += size.X;

if (MySettings.Static.Settings.Enable)
{
MyGuiManager.DrawString(MyFontEnum.BuildInfoHighlight, PLUGIN_ENABLED, textLeftBottomPosition, 1, new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha, 1), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
MyGuiManager.DrawString(MyFontEnum.BuildInfoHighlight, PLUGIN_ENABLED.ToString(), textLeftBottomPosition, 1, new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha, 1), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
}
else
{
MyGuiManager.DrawString(MyFontEnum.BuildInfoHighlight, PLUGIN_DISABLED, textLeftBottomPosition, 1, new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha, 1), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
MyGuiManager.DrawString(MyFontEnum.BuildInfoHighlight, PLUGIN_DISABLED.ToString(), textLeftBottomPosition, 1, new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha, 1), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions SEWorldGenPlugin/Utilities/NetUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@ static NetUtil()
/// a string message and a sender id, then calls the registered handler.
public static void RegisterMessageHandler(ushort id, Action<ulong, string> handler)
{
Action<byte[]> newHandler = delegate (byte[] data)
Action<ushort, byte[], ulong, bool> newHandler = delegate (ushort s, byte[] data, ulong i, bool b)
{
ulong sender = NetDataToMsg(data, out string msg);
handler(sender, msg);
};
MyAPIGateway.Multiplayer.RegisterMessageHandler(id, newHandler);
MyAPIGateway.Multiplayer.RegisterSecureMessageHandler(id, newHandler);
if (unregActions.TryGetValue(id, out Action value))
{
unregActions[id] += delegate
{
MyAPIGateway.Multiplayer.UnregisterMessageHandler(id, newHandler);
MyAPIGateway.Multiplayer.UnregisterSecureMessageHandler(id, newHandler);
};
}
else
{
unregActions[id] = delegate
{
MyAPIGateway.Multiplayer.UnregisterMessageHandler(id, newHandler);
MyAPIGateway.Multiplayer.UnregisterSecureMessageHandler(id, newHandler);
};
}
}
Expand All @@ -78,24 +78,24 @@ public static void RegisterMessageHandler(ushort id, Action<ulong, string> handl
/// a byte[] data message and a sender id, then calls the registered handler.
public static void RegisterMessageHandler(ushort id, Action<ulong, byte[]> handler)
{
Action<byte[]> newHandler = delegate (byte[] data)
Action<ushort, byte[], ulong, bool> newHandler = delegate (ushort s, byte[] data, ulong i, bool b)
{
ulong sender = ReadSenderId(data, out byte[] rawData);
handler(sender, rawData);
};
MyAPIGateway.Multiplayer.RegisterMessageHandler(id, newHandler);
MyAPIGateway.Multiplayer.RegisterSecureMessageHandler(id, newHandler);
if (unregActions.TryGetValue(id, out Action value))
{
unregActions[id] += delegate
{
MyAPIGateway.Multiplayer.UnregisterMessageHandler(id, newHandler);
MyAPIGateway.Multiplayer.UnregisterSecureMessageHandler(id, newHandler);
};
}
else
{
unregActions[id] = delegate
{
MyAPIGateway.Multiplayer.UnregisterMessageHandler(id, newHandler);
MyAPIGateway.Multiplayer.UnregisterSecureMessageHandler(id, newHandler);
};
}
}
Expand Down

0 comments on commit 64992ab

Please sign in to comment.