From 8760e97a9f5e6dd1dec38117dfcbfd3717be0bdb Mon Sep 17 00:00:00 2001 From: Fabian Wunsch Date: Sat, 30 Dec 2023 12:56:18 +0100 Subject: [PATCH] fix offset parsing --- src/network.rs | 4 ++++ src/parser.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/network.rs b/src/network.rs index e299931..705a441 100644 --- a/src/network.rs +++ b/src/network.rs @@ -269,6 +269,10 @@ mod test { "PX 0 0 ffffff\nPX 42 42 000000\n" )] // The get pixel result is also offseted #[case("OFFSET 0 0\nPX 0 42 abcdef\nPX 0 42\n", "PX 0 42 abcdef\n")] + #[case( + "OFFSET 10 10\nPX 0 0 ffffff\nOFFSET 0 0\nPX 0 0\nPX 10 10\n", + "PX 0 0 000000\nPX 10 10 ffffff\n" + )] #[tokio::test] async fn test_setting_pixel( #[case] input: &str, diff --git a/src/parser.rs b/src/parser.rs index 31b502a..740c1dc 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -175,7 +175,7 @@ pub async fn parse_pixelflut_commands( continue; } } - } else if current_command & 0x0000_ffff_ffff_ffff == string_to_number(b"OFFSET \0\0") { + } else if current_command & 0x00ff_ffff_ffff_ffff == string_to_number(b"OFFSET \0\0") { i += 7; let (x, y, present) = parse_pixel_coordinates(buffer.as_ptr(), &mut i);