diff --git a/Source/Client/ClientNetworking.cs b/Source/Client/ClientNetworking.cs index c2447d5..9345bf9 100644 --- a/Source/Client/ClientNetworking.cs +++ b/Source/Client/ClientNetworking.cs @@ -35,7 +35,7 @@ public static void TryConnect(IPAddress address, int port) conn.State = ConnectionStateEnum.ClientJoining; Multiplayer.session.client = conn; - MpLog.Log("Client connected"); + MpLog.Log("Net client connected"); }; listener.PeerDisconnectedEvent += (peer, info) => @@ -58,7 +58,7 @@ public static void TryConnect(IPAddress address, int port) ConnectionStatusListeners.TryNotifyAll_Disconnected(); OnMainThread.StopMultiplayer(); - MpLog.Log("Client disconnected"); + MpLog.Log("Net client disconnected"); }; listener.NetworkReceiveEvent += (peer, reader, method) => diff --git a/Source/Client/ConnectingWindow.cs b/Source/Client/ConnectingWindow.cs index 2f406c9..f87cd87 100644 --- a/Source/Client/ConnectingWindow.cs +++ b/Source/Client/ConnectingWindow.cs @@ -49,7 +49,7 @@ public override void DoWindowContents(Rect inRect) public override void PostClose() { - Multiplayer.Client?.Close(); + OnMainThread.StopMultiplayer(); if (returnToServerBrowser) Find.WindowStack.Add(new ServerBrowser()); diff --git a/Source/Client/ServerBrowser.cs b/Source/Client/ServerBrowser.cs index 80e6103..b7ec396 100644 --- a/Source/Client/ServerBrowser.cs +++ b/Source/Client/ServerBrowser.cs @@ -400,6 +400,8 @@ private void DrawSteam(Rect inRect) { Close(false); + Log.Message("Connecting to steam friend"); + Find.WindowStack.Add(new SteamConnectingWindow(friend.serverHost) { returnToServerBrowser = true }); SteamConnection conn = new SteamConnection(friend.serverHost); @@ -445,6 +447,8 @@ private void DrawDirect(Rect inRect) } else { + Log.Message("Connecting directly"); + Find.WindowStack.Add(new ConnectingWindow(address, port) { returnToServerBrowser = true }); Close(false); } @@ -483,6 +487,7 @@ private void DrawLan(Rect inRect) if (Widgets.ButtonText(playButton, ">>")) { Close(false); + Log.Message("Connecting to lan server"); Find.WindowStack.Add(new ConnectingWindow(server.endpoint.Address, server.endpoint.Port) { returnToServerBrowser = true }); } diff --git a/Source/Client/Trading.cs b/Source/Client/Trading.cs index f820103..09f27b9 100644 --- a/Source/Client/Trading.cs +++ b/Source/Client/Trading.cs @@ -85,13 +85,9 @@ public static void TryCreate(ITrader trader, Pawn playerNegotiator, bool giftMod } } + // todo come back to it when the map doesn't get paused during trading private void StartWaitingJobs() { - if (playerNegotiator.Spawned && trader is Pawn traderPawn && traderPawn.Spawned) - { - playerNegotiator.jobs.StartJob(new Job(JobDefOf.Wait, 10, true) { count = 1234, targetA = traderPawn }, JobCondition.InterruptForced); - traderPawn.jobs.StartJob(new Job(JobDefOf.Wait, 10, true) { count = 1234, targetA = playerNegotiator }, JobCondition.InterruptForced); - } } public bool ShouldCancel() @@ -392,38 +388,13 @@ static bool Prefix(Pawn playerNegotiator, ITrader trader, bool giftsOnly) } } - [HarmonyPatch(typeof(JobDriver_Wait), nameof(JobDriver_Wait.DecorateWaitToil))] - static class TradingWaitJobToil - { - static void Postfix(Toil wait) - { - wait.AddPreTickAction(() => - { - Job job = wait.actor.CurJob; - if (job.count == 1234 && Multiplayer.WorldComp.trading.Any(s => s.playerNegotiator == wait.actor || s.trader == wait.actor)) - { - job.startTick = Find.TickManager.TicksGame + 1; // Don't expire while trading - } - }); - } - } - - [HarmonyPatch(typeof(JobDriver_Wait), nameof(JobDriver_Wait.GetReport))] - static class TradingWaitJobReport - { - static void Postfix(JobDriver_Wait __instance, ref string __result) - { - if (__instance.job.count == 1234) - __result = "Negotiating trade"; - } - } - [HarmonyPatch(typeof(IncidentWorker_TraderCaravanArrival), nameof(IncidentWorker_TraderCaravanArrival.TryExecuteWorker))] static class ArriveAtCenter { static void Prefix(IncidentParms parms) { - parms.spawnCenter = (parms.target as Map).Center; + if (MpVersion.IsDebug && Prefs.DevMode) + parms.spawnCenter = (parms.target as Map).Center; } } diff --git a/Source/Client/Windows.cs b/Source/Client/Windows.cs index e5177e3..725d83c 100644 --- a/Source/Client/Windows.cs +++ b/Source/Client/Windows.cs @@ -1,22 +1,11 @@ -using LiteNetLib; -using Multiplayer.Common; +using Multiplayer.Common; using RimWorld; -using RimWorld.Planet; -using Steamworks; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Net; -using System.Net.Sockets; -using System.Reflection; -using System.Text; -using System.Threading; using UnityEngine; using Verse; -using Verse.AI; -using Verse.Profile; -using Verse.Steam; namespace Multiplayer.Client { diff --git a/Source/Common/Version.cs b/Source/Common/Version.cs index 2eb4d86..4d6914b 100644 --- a/Source/Common/Version.cs +++ b/Source/Common/Version.cs @@ -2,7 +2,7 @@ { public static class MpVersion { - public const string Version = "0.1.2"; + public const string Version = "0.1.3"; public const int Protocol = 2; #if DEBUG