summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSebastian Valle <subv2112@gmail.com>2017-06-21 04:29:00 +0200
committerGitHub <noreply@github.com>2017-06-21 04:29:00 +0200
commit96dcccc80ce16dbf60fc629d7659d6b9d19e27f0 (patch)
tree07b69550230b62fbb6ff1a4955f96caf270b457a /src
parentMerge pull request #2787 from yuriks/hle-ipc-tests (diff)
parentUDS: Added a hook for updating the connection status when a client connects to the network. (diff)
downloadyuzu-96dcccc80ce16dbf60fc629d7659d6b9d19e27f0.tar
yuzu-96dcccc80ce16dbf60fc629d7659d6b9d19e27f0.tar.gz
yuzu-96dcccc80ce16dbf60fc629d7659d6b9d19e27f0.tar.bz2
yuzu-96dcccc80ce16dbf60fc629d7659d6b9d19e27f0.tar.lz
yuzu-96dcccc80ce16dbf60fc629d7659d6b9d19e27f0.tar.xz
yuzu-96dcccc80ce16dbf60fc629d7659d6b9d19e27f0.tar.zst
yuzu-96dcccc80ce16dbf60fc629d7659d6b9d19e27f0.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nwm/nwm_uds.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp
index e92900d48..51786d172 100644
--- a/src/core/hle/service/nwm/nwm_uds.cpp
+++ b/src/core/hle/service/nwm/nwm_uds.cpp
@@ -543,6 +543,42 @@ static void BeaconBroadcastCallback(u64 userdata, int cycles_late) {
beacon_broadcast_event, 0);
}
+/*
+ * Returns an available index in the nodes array for the
+ * currently-hosted UDS network.
+ */
+static u32 GetNextAvailableNodeId() {
+ ASSERT_MSG(connection_status.status == static_cast<u32>(NetworkStatus::ConnectedAsHost),
+ "Can not accept clients if we're not hosting a network");
+
+ for (unsigned index = 0; index < connection_status.max_nodes; ++index) {
+ if ((connection_status.node_bitmask & (1 << index)) == 0)
+ return index;
+ }
+
+ // Any connection attempts to an already full network should have been refused.
+ ASSERT_MSG(false, "No available connection slots in the network");
+}
+
+/*
+ * Called when a client connects to an UDS network we're hosting,
+ * updates the connection status and signals the update event.
+ * @param network_node_id Network Node Id of the connecting client.
+ */
+void OnClientConnected(u16 network_node_id) {
+ ASSERT_MSG(connection_status.status == static_cast<u32>(NetworkStatus::ConnectedAsHost),
+ "Can not accept clients if we're not hosting a network");
+ ASSERT_MSG(connection_status.total_nodes < connection_status.max_nodes,
+ "Can not accept connections on a full network");
+
+ u32 node_id = GetNextAvailableNodeId();
+ connection_status.node_bitmask |= 1 << node_id;
+ connection_status.changed_nodes |= 1 << node_id;
+ connection_status.nodes[node_id] = network_node_id;
+ connection_status.total_nodes++;
+ connection_status_event->Signal();
+}
+
const Interface::FunctionInfo FunctionTable[] = {
{0x00010442, nullptr, "Initialize (deprecated)"},
{0x00020000, nullptr, "Scrap"},