MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / sendEntityMessage

Method sendEntityMessage

source/game/StarWorldServer.cpp:2344–2366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2342}
2343
2344RpcPromise<Json> WorldServer::sendEntityMessage(Variant<EntityId, String> const& entityId, String const& message, JsonArray const& args) {
2345 EntityPtr entity;
2346 if (entityId.is<EntityId>())
2347 entity = m_entityMap->entity(entityId.get<EntityId>());
2348 else
2349 entity = m_entityMap->entity(loadUniqueEntity(entityId.get<String>()));
2350
2351 if (!entity) {
2352 return RpcPromise<Json>::createFailed("Unknown entity");
2353 } else if (entity->isMaster()) {
2354 if (auto resp = entity->receiveMessage(ServerConnectionId, message, args))
2355 return RpcPromise<Json>::createFulfilled(resp.take());
2356 else
2357 return RpcPromise<Json>::createFailed("Message not handled by entity");
2358 } else {
2359 auto pair = RpcPromise<Json>::createPair();
2360 auto clientInfo = m_clientInfo.get(connectionForEntity(entity->entityId()));
2361 Uuid uuid;
2362 m_entityMessageResponses[uuid] = {clientInfo->clientId, pair.second};
2363 clientInfo->outgoingPackets.append(make_shared<EntityMessagePacket>(entity->entityId(), message, args, uuid));
2364 return pair.first;
2365 }
2366}
2367
2368void WorldServer::setPlayerStart(Vec2F const& startPosition, bool respawnInWorld) {
2369 m_playerStart = startPosition;

Callers

nothing calls this directly

Calls 8

connectionForEntityFunction · 0.85
isMasterMethod · 0.80
entityIdMethod · 0.80
entityMethod · 0.45
receiveMessageMethod · 0.45
takeMethod · 0.45
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected