Commit 31208da
authored
Fixing the issue of multiple actions calling the same method was (partially) fixed by syncing both the hashed method's description and the hashed original target's type description.
This only fixes the issue partially, as it will only work if the type we're syncing is a generic type and each possible action uses a different generic arguments. However, it should be enough to handle everything in the game, as well as most (if not all) mods.
As for fixing the issue where an action we sync is opening a confirmation dialog - the fix is a bit more complex.
I've added a new delegate that will work as a wrapper around the original action. It may return either null or the synced method as-is, in which case nothing will happen. However, the wrapper may return a different action that will be called instead of immediately syncing the method.
The wrapper is passed the current instance of the object, its arguments, the original `Action` that was going to be called, as well as the `Action` that, when invoked, will sync the data. The arguments are (currently) unused, but I've decided to include them for the case of future-proofing this code.
As for the wrappers I've included:
The wrapper for Caravan actions will return null (no wrapper) unless the method's declaring type is `CaravanArrivalActionUtility.<>c__DisplayClass0_1<T>`.
If the type matches then we will replace the original action with our own which will access the `action` field from the target type, and:
- If we're in a synced call, it'll execute that action.
- If not in a synced call it'll replace the action with our syncing action and call the original method, displaying the confirmation dialog (which, if accepted, will sync the call).
As for the wrapper for Transport Pods, it will return null (no wrapper) unless the method's declaring type is `TransportPodsArrivalActionUtility.<>c__DisplayClass0_0<T>`.
If the type matches then we will replace the original action with our own which will access the `uiConfirmationCallback` field.
- If executing commands, we set the confirmation to null and call the original method
- This is done so the original method calls the actual action without the confirmation dialog
- If not executing commands and the field is null, just sync the call
- If not executing commands and the field is not null, call the confirmation callback with our syncing action as the action we pass to it
As an additional note, we access the inner compiler-generated types directly. This is due to `MpMethodUtil` not supporting generic types and methods. If we decide to make it support those, we'll need to change how we access those types.
1 parent d64091d commit 31208da
File tree
2 files changed
+116
-14
lines changed- Source/Client/Syncing
- Game
- Handler
2 files changed
+116
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
18 | 35 | | |
19 | 36 | | |
20 | | - | |
| 37 | + | |
21 | 38 | | |
22 | 39 | | |
23 | 40 | | |
24 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
25 | 99 | | |
26 | | - | |
| 100 | + | |
27 | 101 | | |
28 | 102 | | |
29 | | - | |
| 103 | + | |
30 | 104 | | |
31 | | - | |
| 105 | + | |
32 | 106 | | |
33 | 107 | | |
34 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | | - | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
43 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| |||
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
71 | | - | |
72 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
73 | 84 | | |
74 | 85 | | |
75 | 86 | | |
76 | | - | |
| 87 | + | |
77 | 88 | | |
78 | 89 | | |
79 | 90 | | |
| |||
85 | 96 | | |
86 | 97 | | |
87 | 98 | | |
88 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
89 | 118 | | |
90 | | - | |
91 | 119 | | |
92 | 120 | | |
93 | 121 | | |
| |||
0 commit comments