aboutsummaryrefslogtreecommitdiff
path: root/src/server/auto/cmd/room.rs
blob: 16c27b87f5aa49e529bc3cf499ed760f933beed5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
pub fn create_room_id_redirect_command(room_name: &str, room_id: usize) -> Vec<u8> {
	let mut room_id_redirect = vec![
		0x01, // ?
		0x1A, // Command type
	];

	// room_id_redirect.push(room_id_redirect.len() as u8 + 1); // Data length
	room_id_redirect.push(room_name.len() as u8); // UTF/ room name length
	for i in room_name.bytes() { room_id_redirect.push(i); } // Push `room_name`
	// for i in "<dimension-1>".bytes() { room_id_redirect.push(i); } // Push room number

	// Room number
	room_id_redirect.push(0x00);
	room_id_redirect.push(room_id as u8);

	// IP
	room_id_redirect.push(0x00);
	room_id_redirect.push(0x00);
	room_id_redirect.push(0x00);
	room_id_redirect.push(0x00);

	// Port
	// for byte in convert_u16_to_two_u8s_be(0x1629).iter() {
	// 	room_id_redirect.push(*byte);
	// }
	// Port
	// for byte in convert_u16_to_two_u8s_be(5673_i32 as u16).iter() {
	// 	room_id_redirect.push(*byte);
	// }
	room_id_redirect.push(0x16);
	room_id_redirect.push(0x29);

	room_id_redirect.insert(0, room_id_redirect.len() as u8 + 1); // Data length

	room_id_redirect
}