Sync from GitHub main #1
+18
-13
@@ -6,7 +6,7 @@ import time
|
||||
import unittest
|
||||
|
||||
from client_session import ClientSession
|
||||
from server_core import FalloutTogetherServer
|
||||
from server_core import FalloutTogetherServer, MAX_NPCS_PER_PACKET
|
||||
|
||||
|
||||
class NpcProtocolTests(unittest.TestCase):
|
||||
@@ -16,6 +16,10 @@ class NpcProtocolTests(unittest.TestCase):
|
||||
self.server = FalloutTogetherServer()
|
||||
self.host = ClientSession(self.host_server, ("local", 1), 1, time.time())
|
||||
self.client = ClientSession(self.client_server, ("local", 2), 2, time.time())
|
||||
self.host.mark_gameplay_active(1)
|
||||
self.client.mark_gameplay_active(1)
|
||||
self.server._init_rate_state(self.host, time.monotonic())
|
||||
self.server._init_rate_state(self.client, time.monotonic())
|
||||
self.server._clients = {
|
||||
self.host_server: self.host,
|
||||
self.client_server: self.client,
|
||||
@@ -31,6 +35,17 @@ class NpcProtocolTests(unittest.TestCase):
|
||||
):
|
||||
connection.close()
|
||||
|
||||
def _npc(self, index: int) -> dict:
|
||||
return {
|
||||
"npcId": index,
|
||||
"sourceFormId": "0001A4D7",
|
||||
"x": float(index),
|
||||
"y": 2.0,
|
||||
"z": 3.0,
|
||||
"angleZ": 0.5,
|
||||
"cellId": "0000003C",
|
||||
}
|
||||
|
||||
def test_host_npc_state_is_authoritative_and_broadcast(self) -> None:
|
||||
self.server._handle_line(
|
||||
self.host,
|
||||
@@ -38,17 +53,7 @@ class NpcProtocolTests(unittest.TestCase):
|
||||
{
|
||||
"type": "npcState",
|
||||
"playerId": 999,
|
||||
"npcs": [
|
||||
{
|
||||
"npcId": 1,
|
||||
"baseFormId": "0001A4D7",
|
||||
"x": 1.0,
|
||||
"y": 2.0,
|
||||
"z": 3.0,
|
||||
"angleZ": 0.5,
|
||||
"cellId": "0000003C",
|
||||
}
|
||||
],
|
||||
"npcs": [self._npc(1)],
|
||||
}
|
||||
),
|
||||
)
|
||||
@@ -104,7 +109,7 @@ class NpcProtocolTests(unittest.TestCase):
|
||||
json.dumps(
|
||||
{
|
||||
"type": "npcState",
|
||||
"npcs": [{"npcId": index + 1} for index in range(17)],
|
||||
"npcs": [self._npc(index + 1) for index in range(MAX_NPCS_PER_PACKET + 1)],
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user