terraria_protocol/lib.rs
1//! This library contains all the packet definitions needed to work with
2//! Terraria's multiplayer network protocol, and it can be used to build
3//! a client, a robot, or even a custom Terraria server.
4//!
5//! Note that the library itself only contains the packets and mechanisms
6//! to serialize and deserialize them, along with basic protocol management.
7//! If you want it to do anything interesting, you should build that yourself.
8pub mod net;
9pub mod packets;
10pub mod structures;
11
12pub(crate) use structures::{Deserializable, Serializable, SliceCursor};
13
14#[cfg(test)]
15mod tests {
16 use super::*;
17
18 #[test]
19 fn check_remote_deserialization() {
20 let mut data = include_bytes!("../test-data/remote.bin").to_vec();
21
22 let mut index = 0;
23 while index < data.len() {
24 // TODO don't reimplement this here
25 let packet_len = u16::from_le_bytes([data[index], data[index + 1]]) as usize;
26 packets::Packet::from_slice(&mut data[index + 2..index + packet_len]);
27 index += packet_len;
28 }
29
30 todo!("make sure we found a certain number of present tiles")
31 }
32}