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

Commit

Permalink
Fix Linux/Mac bug, more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Zetrith committed Dec 16, 2018
1 parent 0e890e9 commit ca9cf91
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 48 deletions.
4 changes: 2 additions & 2 deletions Source/Client/ClientNetworking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand All @@ -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) =>
Expand Down
2 changes: 1 addition & 1 deletion Source/Client/ConnectingWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
5 changes: 5 additions & 0 deletions Source/Client/ServerBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 });
}

Expand Down
35 changes: 3 additions & 32 deletions Source/Client/Trading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
}
}

Expand Down
13 changes: 1 addition & 12 deletions Source/Client/Windows.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Common/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca9cf91

Please sign in to comment.