Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session rework #401

Closed
wants to merge 33 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
65c163f
Initial version of the sessions rework. Won't compile, as some things…
SokyranTheDragon Sep 30, 2023
7ac64b3
Merge branch 'master' of github.com:SokyranTheDragon/Multiplayer into…
SokyranTheDragon Oct 31, 2023
2bfbf44
First compiling version. Still WIP and needs cleaning.
SokyranTheDragon Nov 2, 2023
2598273
Turn pause locks into a session
SokyranTheDragon Nov 3, 2023
cd03e8c
Some minor cleanup related to trade sessions
SokyranTheDragon Nov 3, 2023
9561360
MpTradeSession.TryCreate now uses session manager
SokyranTheDragon Nov 4, 2023
9814dd0
Use `WorldComp.trading` instead of `WorldComp.sessionManager`
SokyranTheDragon Nov 4, 2023
23b6a96
Minor cleanup and error logging
SokyranTheDragon Nov 4, 2023
d4f363c
Fixed reading world data in `SemiPersistent:ReadSemiPersistent`
SokyranTheDragon Nov 4, 2023
8800453
TickMapTrading -> TickMapSessions
SokyranTheDragon Nov 4, 2023
54d201f
Remove the unnecessary "cleanup" of trading sessions
SokyranTheDragon Nov 5, 2023
e22f085
Fix ritual session not opening the dialog when started
SokyranTheDragon Nov 5, 2023
31750e0
Fix trading session transferables, put all drawn session changes into…
SokyranTheDragon Nov 5, 2023
21cc449
Rename `DrawnThingFilter` to `DrawnSessionWithTransferables`
SokyranTheDragon Nov 5, 2023
5acf4fe
Remove unnecessary commented-out code
SokyranTheDragon Nov 5, 2023
6b660ab
Call `ISession:PostRemoveSession` from `SessionManager:ExposeSessions…
SokyranTheDragon Nov 5, 2023
c2c11d9
Rename WindowSession back to Session
SokyranTheDragon Nov 5, 2023
237678d
Make session manager sync semi persistent session ID
SokyranTheDragon Nov 6, 2023
4f7f2ad
Stop sessions from self-assigning IDs, let session manager handle it
SokyranTheDragon Nov 6, 2023
5320d3f
Added XML documentation to most session interfaces
SokyranTheDragon Nov 6, 2023
a3438f8
ISemiPersistentSession Write/Read -> Sync, make rituals use it
SokyranTheDragon Nov 6, 2023
d1d5810
Slightly change how pause lock session works
SokyranTheDragon Nov 6, 2023
ceb1a83
Added ISessionManagerAPI
SokyranTheDragon Nov 6, 2023
d12a6cf
Expose `MultiplayerGameComp.nextSessionId`
SokyranTheDragon Nov 6, 2023
bc5d2e2
Rename `ISessionManagerAPI` to `ISessionManager`
SokyranTheDragon Nov 10, 2023
78bee79
Rename ISessionManager file
SokyranTheDragon Nov 10, 2023
e238082
Remove 3 session interfaces in favor of abstract classes
SokyranTheDragon Nov 10, 2023
f85c6b4
Added methods to `MultiplayerAPIBridge` that will (likely) end up in …
SokyranTheDragon Nov 11, 2023
ccf0b22
Fix session map syncing
SokyranTheDragon Nov 14, 2023
2a5ffe6
Merge branch 'master' of github.com:rwmt/Multiplayer into session-rework
SokyranTheDragon Nov 14, 2023
ba19d25
Added a sync dict entry for `ISessionWithTransferables`
SokyranTheDragon Nov 15, 2023
08600e8
Merge branch 'master' of github.com:SokyranTheDragon/Multiplayer into…
SokyranTheDragon Nov 20, 2023
2523da6
Merge branch 'master' of github.com:SokyranTheDragon/Multiplayer into…
SokyranTheDragon Dec 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use WorldComp.trading instead of WorldComp.sessionManager
SokyranTheDragon committed Nov 4, 2023
commit 9814dd03db2b1136ce0210323253c6f074800ba3
9 changes: 3 additions & 6 deletions Source/Client/Comp/Map/MultiplayerMapComp.cs
Original file line number Diff line number Diff line change
@@ -224,12 +224,9 @@ static void Prefix()
if (Multiplayer.Client == null) return;

// Trading window on resume save
if (!Multiplayer.WorldComp.sessionManager.AnySessionActive) return;
if (!Multiplayer.WorldComp.trading.NullOrEmpty()) return;
// playerNegotiator == null can only happen during loading? Is this a resuming check?
Multiplayer.WorldComp.sessionManager.AllSessions
.OfType<MpTradeSession>()
.FirstOrDefault(t => t.playerNegotiator == null)
?.OpenWindow();
Multiplayer.WorldComp.trading.FirstOrDefault(t => t.playerNegotiator == null)?.OpenWindow();
}
}

@@ -243,7 +240,7 @@ static void Prefix(WorldInterface __instance)
if (Find.World.renderer.wantedMode == WorldRenderMode.Planet)
{
// Hide trading window for map trades
if (Multiplayer.WorldComp.sessionManager.AllSessions.OfType<MpTradeSession>().All(t => t.playerNegotiator?.Map != null))
if (Multiplayer.WorldComp.trading.All(t => t.playerNegotiator?.Map != null))
{
if (Find.WindowStack.IsOpen(typeof(TradingWindow)))
Find.WindowStack.TryRemove(typeof(TradingWindow), doCloseSound: false);
8 changes: 4 additions & 4 deletions Source/Client/Comp/World/MultiplayerWorldComp.cs
Original file line number Diff line number Diff line change
@@ -154,30 +154,30 @@ public void SetFaction(Faction faction)
public void DirtyColonyTradeForMap(Map map)
{
if (map == null) return;
foreach (MpTradeSession session in sessionManager.AllSessions.OfType<MpTradeSession>())
foreach (MpTradeSession session in trading)
if (session.playerNegotiator.Map == map)
session.deal.recacheColony = true;
}

public void DirtyTraderTradeForTrader(ITrader trader)
{
if (trader == null) return;
foreach (MpTradeSession session in sessionManager.AllSessions.OfType<MpTradeSession>())
foreach (MpTradeSession session in trading)
if (session.trader == trader)
session.deal.recacheTrader = true;
}

public void DirtyTradeForSpawnedThing(Thing t)
{
if (t is not { Spawned: true }) return;
foreach (MpTradeSession session in sessionManager.AllSessions.OfType<MpTradeSession>())
foreach (MpTradeSession session in trading)
if (session.playerNegotiator.Map == t.Map)
session.deal.recacheThings.Add(t);
}

public bool AnyTradeSessionsOnMap(Map map)
{
foreach (MpTradeSession session in trading.OfType<MpTradeSession>())
foreach (MpTradeSession session in trading)
if (session.playerNegotiator.Map == map)
return true;
return false;
2 changes: 1 addition & 1 deletion Source/Client/Patches/Patches.cs
Original file line number Diff line number Diff line change
@@ -488,7 +488,7 @@ internal static void SyncDialogOptionByIndex(int position)
if (!option.resolveTree) SyncUtil.isDialogNodeTreeOpen = true; // In case dialog is still open, we mark it as such

// Try opening the trading menu if the picked option was supposed to do so (caravan meeting, trading option)
if (Multiplayer.Client != null && Multiplayer.WorldComp.sessionManager.AllSessions.OfType<MpTradeSession>().Any(t => t.trader is Caravan))
if (Multiplayer.Client != null && Multiplayer.WorldComp.trading.Any(t => t.trader is Caravan))
Find.WindowStack.Add(new TradingWindow());
}
else SyncUtil.isDialogNodeTreeOpen = false;