log EntityMessageResponse error instead of throwing

This commit is contained in:
Kae 2024-04-24 16:28:09 +10:00
parent d0f8aec244
commit f58702683f
2 changed files with 26 additions and 25 deletions

View File

@ -994,14 +994,14 @@ void WorldClient::handleIncomingPackets(List<PacketPtr> const& packets) {
} else if (auto entityMessageResponsePacket = as<EntityMessageResponsePacket>(packet)) { } else if (auto entityMessageResponsePacket = as<EntityMessageResponsePacket>(packet)) {
if (!m_entityMessageResponses.contains(entityMessageResponsePacket->uuid)) if (!m_entityMessageResponses.contains(entityMessageResponsePacket->uuid))
throw WorldClientException("EntityMessageResponse received for unknown context!"); Logger::warn("EntityMessageResponse received for unknown context [{}]!", entityMessageResponsePacket->uuid.hex());
else {
auto response = m_entityMessageResponses.take(entityMessageResponsePacket->uuid); auto response = m_entityMessageResponses.take(entityMessageResponsePacket->uuid);
if (entityMessageResponsePacket->response.isRight()) if (entityMessageResponsePacket->response.isRight())
response.fulfill(entityMessageResponsePacket->response.right()); response.fulfill(entityMessageResponsePacket->response.right());
else else
response.fail(entityMessageResponsePacket->response.left()); response.fail(entityMessageResponsePacket->response.left());
}
} else if (auto updateWorldProperties = as<UpdateWorldPropertiesPacket>(packet)) { } else if (auto updateWorldProperties = as<UpdateWorldPropertiesPacket>(packet)) {
// Kae: Properties set to null (nil from Lua) should be erased instead of lingering around // Kae: Properties set to null (nil from Lua) should be erased instead of lingering around
for (auto& pair : updateWorldProperties->updatedProperties) { for (auto& pair : updateWorldProperties->updatedProperties) {
@ -1031,12 +1031,12 @@ void WorldClient::handleIncomingPackets(List<PacketPtr> const& packets) {
m_outgoingPackets.append(make_shared<EntityInteractResultPacket>(interactResult.take(), entityInteract->requestId, entityInteract->interactRequest.sourceId)); m_outgoingPackets.append(make_shared<EntityInteractResultPacket>(interactResult.take(), entityInteract->requestId, entityInteract->interactRequest.sourceId));
} else if (auto interactResult = as<EntityInteractResultPacket>(packet)) { } else if (auto interactResult = as<EntityInteractResultPacket>(packet)) {
auto response = m_entityInteractionResponses.take(interactResult->requestId); if (auto response = m_entityInteractionResponses.maybeTake(interactResult->requestId)) {
if (interactResult->action) if (interactResult->action)
response.fulfill(interactResult->action); response->fulfill(interactResult->action);
else else
response.fail("no interaction result"); response->fail("no interaction result");
}
} else if (auto setPlayerStart = as<SetPlayerStartPacket>(packet)) { } else if (auto setPlayerStart = as<SetPlayerStartPacket>(packet)) {
m_playerStart = setPlayerStart->playerStart; m_playerStart = setPlayerStart->playerStart;
m_respawnInWorld = setPlayerStart->respawnInWorld; m_respawnInWorld = setPlayerStart->respawnInWorld;

View File

@ -507,17 +507,18 @@ void WorldServer::handleIncomingPackets(ConnectionId clientId, List<PacketPtr> c
} else if (auto entityMessageResponsePacket = as<EntityMessageResponsePacket>(packet)) { } else if (auto entityMessageResponsePacket = as<EntityMessageResponsePacket>(packet)) {
if (!m_entityMessageResponses.contains(entityMessageResponsePacket->uuid)) if (!m_entityMessageResponses.contains(entityMessageResponsePacket->uuid))
throw WorldServerException("ScriptedEntityResponse received for unknown context!"); Logger::warn("EntityMessageResponse received for unknown context [{}]!", entityMessageResponsePacket->uuid.hex());
else {
auto response = m_entityMessageResponses.take(entityMessageResponsePacket->uuid).second; auto response = m_entityMessageResponses.take(entityMessageResponsePacket->uuid).second;
if (response.is<ConnectionId>()) { if (response.is<ConnectionId>()) {
if (auto clientInfo = m_clientInfo.value(response.get<ConnectionId>())) if (auto clientInfo = m_clientInfo.value(response.get<ConnectionId>()))
clientInfo->outgoingPackets.append(std::move(entityMessageResponsePacket)); clientInfo->outgoingPackets.append(std::move(entityMessageResponsePacket));
} else { } else {
if (entityMessageResponsePacket->response.isRight()) if (entityMessageResponsePacket->response.isRight())
response.get<RpcPromiseKeeper<Json>>().fulfill(entityMessageResponsePacket->response.right()); response.get<RpcPromiseKeeper<Json>>().fulfill(entityMessageResponsePacket->response.right());
else else
response.get<RpcPromiseKeeper<Json>>().fail(entityMessageResponsePacket->response.left()); response.get<RpcPromiseKeeper<Json>>().fail(entityMessageResponsePacket->response.left());
}
} }
} else if (auto pingPacket = as<PingPacket>(packet)) { } else if (auto pingPacket = as<PingPacket>(packet)) {
clientInfo->outgoingPackets.append(make_shared<PongPacket>(pingPacket->time)); clientInfo->outgoingPackets.append(make_shared<PongPacket>(pingPacket->time));