MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / HandlePlayerSpring

Method HandlePlayerSpring

Sources/Jazz2/Multiplayer/MpLevelHandler.cpp:1273–1301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1271 }
1272
1273 bool MpLevelHandler::HandlePlayerSpring(Actors::Player* player, Vector2f pos, Vector2f force, bool keepSpeedX, bool keepSpeedY)
1274 {
1275 // TODO: Only called by RemotePlayerOnServer
1276 if (_isServer) {
1277 auto* mpPlayer = static_cast<MpPlayer*>(player);
1278 auto peerDesc = mpPlayer->GetPeerDescriptor();
1279
1280 if (peerDesc->RemotePeer) {
1281 std::uint8_t flags = 0;
1282 if (keepSpeedX) {
1283 flags |= 0x01;
1284 }
1285 if (keepSpeedY) {
1286 flags |= 0x02;
1287 }
1288
1289 MemoryStream packet(17);
1290 packet.WriteVariableUint32(mpPlayer->_playerIndex);
1291 packet.WriteValue<std::int32_t>((std::int32_t)(pos.X * 512.0f));
1292 packet.WriteValue<std::int32_t>((std::int32_t)(pos.Y * 512.0f));
1293 packet.WriteValue<std::int16_t>((std::int16_t)(force.X * 512.0f));
1294 packet.WriteValue<std::int16_t>((std::int16_t)(force.Y * 512.0f));
1295 packet.WriteValue<std::uint8_t>(flags);
1296 _networkManager->SendTo(peerDesc->RemotePeer, NetworkChannel::Main, (std::uint8_t)ServerPacketType::PlayerActivateSpring, packet);
1297 }
1298 }
1299
1300 return true;
1301 }
1302
1303 void MpLevelHandler::HandlePlayerBeforeWarp(Actors::Player* player, Vector2f pos, WarpFlags flags)
1304 {

Callers 1

OnHitSpringMethod · 0.80

Calls 3

WriteVariableUint32Method · 0.80
SendToMethod · 0.80
GetPeerDescriptorMethod · 0.45

Tested by

no test coverage detected