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

Method receiveMessage

source/game/StarVehicle.cpp:373–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371}
372
373Maybe<Json> Vehicle::receiveMessage(ConnectionId connectionId, String const& message, JsonArray const& args) {
374 m_aliveMasterConnections[connectionId] = GameTimer(m_slaveControlTimeout);
375 if (message.equalsIgnoreCase("control_on")) {
376 auto& loungePosition = m_loungePositions.valueAt(args.at(0).toUInt());
377 loungePosition.masterControlState[LoungeControlNames.getLeft(args.at(1).toString())].slavesHeld.add(connectionId);
378 return Json();
379 } else if (message.equalsIgnoreCase("control_off")) {
380 auto& loungePosition = m_loungePositions.valueAt(args.at(0).toUInt());
381 loungePosition.masterControlState[LoungeControlNames.getLeft(args.at(1).toString())].slavesHeld.remove(connectionId);
382 return Json();
383 } else if (message.equalsIgnoreCase("control_all")) {
384 auto& loungePosition = m_loungePositions.valueAt(args.at(0).toUInt());
385 Set<LoungeControl> allControlsHeld;
386 for (auto const& s : args.at(1).iterateArray())
387 allControlsHeld.add(LoungeControlNames.getLeft(s.toString()));
388 for (auto& p : loungePosition.masterControlState) {
389 if (allControlsHeld.contains(p.first))
390 p.second.slavesHeld.add(connectionId);
391 else
392 p.second.slavesHeld.remove(connectionId);
393 }
394 return Json();
395 } else if (message.equalsIgnoreCase("aim")) {
396 auto& loungePosition = m_loungePositions.valueAt(args.at(0).toUInt());
397 loungePosition.masterAimPosition = {args.at(1).toFloat(), args.at(2).toFloat()};
398 return Json();
399 } else {
400 return m_scriptComponent.handleMessage(message, connectionId == world()->connection(), args);
401 }
402}
403
404RectF Vehicle::interactiveBoundBox() const {
405 return collisionArea();

Callers

nothing calls this directly

Calls 14

GameTimerClass · 0.85
JsonClass · 0.85
valueAtMethod · 0.80
toUIntMethod · 0.80
iterateArrayMethod · 0.80
toFloatMethod · 0.80
handleMessageMethod · 0.80
equalsIgnoreCaseMethod · 0.45
atMethod · 0.45
addMethod · 0.45
toStringMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected