mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-28 00:17:08 +01:00
45 files changed
+2979
-26
No files matched your search
@@ -402,6 +402,9 @@ std::vector<std::uint8_t> encode(const Packet &p, bool compact_pose, std::uint32
|
||||
throw std::invalid_argument("Invalid voice packet");
|
||||
if (p.kind == PacketKind::effects && (!p.map || !p.source || !valid_impacts(p.impacts)))
|
||||
throw std::invalid_argument("Invalid effects packet");
|
||||
if (p.kind == PacketKind::drone && (!p.map || !p.source || !valid_drone_position(p.drone_position) ||
|
||||
!valid_drone_rotation(p.drone_rotation)))
|
||||
throw std::invalid_argument("Invalid drone packet");
|
||||
if (p.kind == PacketKind::chat && (!p.source || !valid_chat_text(p.text)))
|
||||
throw std::invalid_argument("Invalid chat message");
|
||||
if (p.kind == PacketKind::typing && !p.source)
|
||||
@@ -477,7 +480,8 @@ std::vector<std::uint8_t> encode(const Packet &p, bool compact_pose, std::uint32
|
||||
p.kind != PacketKind::throwdown && p.kind != PacketKind::teleport && p.kind != PacketKind::physics_tuning &&
|
||||
p.kind != PacketKind::party && p.kind != PacketKind::scoring && p.kind != PacketKind::physics_extras &&
|
||||
p.kind != PacketKind::effects && p.kind != PacketKind::permissions && p.kind != PacketKind::words &&
|
||||
p.kind != PacketKind::next_maps && p.kind != PacketKind::typing)
|
||||
p.kind != PacketKind::next_maps && p.kind != PacketKind::typing &&
|
||||
p.kind != PacketKind::drone)
|
||||
throw std::invalid_argument("Unknown packet kind");
|
||||
const auto payload = greeting ? 72
|
||||
: p.kind == PacketKind::away
|
||||
@@ -618,6 +622,11 @@ std::vector<std::uint8_t> encode(const Packet &p, bool compact_pose, std::uint32
|
||||
w.integer(impact.material, 2);
|
||||
}
|
||||
}
|
||||
if (p.kind == PacketKind::drone) {
|
||||
w.integer(p.drone_active ? 1 : 0, 1);
|
||||
for (const auto v : p.drone_position) w.integer(std::bit_cast<std::uint32_t>(v), 4);
|
||||
for (const auto v : p.drone_rotation) w.integer(std::bit_cast<std::uint32_t>(v), 4);
|
||||
}
|
||||
if (p.kind == PacketKind::physics_extras) {
|
||||
w.integer(p.extras.size(), 2);
|
||||
w.bytes.insert(w.bytes.end(), p.extras.begin(), p.extras.end());
|
||||
@@ -729,6 +738,7 @@ std::vector<std::uint8_t> encode(const Packet &p, bool compact_pose, std::uint32
|
||||
w.integer(p.object_limit, 2);
|
||||
w.integer(p.object_scaling ? 1 : 0, 1);
|
||||
w.integer(p.sync_effects ? 1 : 0, 1);
|
||||
w.integer(p.sync_drones ? 1 : 0, 1);
|
||||
w.integer(p.force_world_layers, 1);
|
||||
// One mode per world-layer catalog row; both peers read the same catalog
|
||||
// from the same game build.
|
||||
@@ -991,6 +1001,14 @@ std::optional<Packet> decode(std::span<const std::uint8_t> bytes) noexcept {
|
||||
impact.material = static_cast<std::uint16_t>(r.integer(2));
|
||||
}
|
||||
if (!valid_impacts(p.impacts)) return {};
|
||||
} else if (p.kind == PacketKind::drone) {
|
||||
if (!p.map || !p.source || bytes.size() - r.at != drone_wire_size) return {};
|
||||
const auto flag = r.integer(1);
|
||||
if (flag > 1) return {};
|
||||
p.drone_active = flag != 0;
|
||||
for (auto &v : p.drone_position) v = r.number();
|
||||
for (auto &v : p.drone_rotation) v = r.number();
|
||||
if (!valid_drone_position(p.drone_position) || !valid_drone_rotation(p.drone_rotation)) return {};
|
||||
} else if (p.kind == PacketKind::physics_extras) {
|
||||
const auto length = r.integer(2);
|
||||
if (!p.source || length > max_physics_extras || length != bytes.size() - r.at)
|
||||
@@ -1177,6 +1195,9 @@ std::optional<Packet> decode(std::span<const std::uint8_t> bytes) noexcept {
|
||||
const auto shared_effects = r.integer(1);
|
||||
if (shared_effects > 1) return {};
|
||||
p.sync_effects = shared_effects != 0;
|
||||
const auto shared_drones = r.integer(1);
|
||||
if (shared_drones > 1) return {};
|
||||
p.sync_drones = shared_drones != 0;
|
||||
const auto forced = r.integer(1);
|
||||
if (forced > 1) return {};
|
||||
p.force_world_layers = forced != 0;
|
||||
|
||||
Reference in new issue
Block a user