Skip to content

Commit

Permalink
Boat pkt encoding len (#405)
Browse files Browse the repository at this point in the history
* guessing game, does encoding can take more space?

* corrected comment to explain fix

* fixed compiler warning

* added corechanges
  • Loading branch information
turleypol committed Jul 22, 2021
1 parent 808bb07 commit 0fab3e1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 6 additions & 1 deletion docs/docs.polserver.com/pol100/corechanges.xml
Expand Up @@ -2,9 +2,14 @@
<ESCRIPT>
<header>
<topic>Latest Core Changes</topic>
<datemodified>07-21-2021</datemodified>
<datemodified>07-22-2021</datemodified>
</header>
<version name="POL100.1.0">
<entry>
<date>07-22-2021</date>
<author>Turley:</author>
<change type="Fixed">Fixed crash when too many items exists an a boat.</change>
</entry>
<entry>
<date>07-21-2021</date>
<author>Kevin:</author>
Expand Down
2 changes: 2 additions & 0 deletions pol-core/doc/core-changes.txt
@@ -1,4 +1,6 @@
-- POL100.1.0 --
07-22-2021 Turley:
Fixed: Fixed crash when too many items exists an a boat.
07-21-2021 Kevin:
Fixed: Fixed bug where a target couldn't be cancelled in some clients.
06-21-2021 Turley:
Expand Down
10 changes: 6 additions & 4 deletions pol-core/pol/multi/boat.cpp
Expand Up @@ -303,9 +303,10 @@ void UBoat::send_smooth_move( Network::Client* client, Plib::UFACING move_dir, u
msg->WriteFlipped<u16>( newy );
msg->WriteFlipped<u16>( ( z < 0 ) ? static_cast<u16>( 0x10000 + z ) : static_cast<u16>( z ) );

const u16 max_count = ( 0xffff - 18 ) / 10;
// 0xf000 encoding room, huffman can take more space then the maximum of 0xffff
const u16 max_count = ( 0xf000 - 18 ) / 10;
u16 object_count = 0;
size_t len_offset = msg->offset;
u16 len_offset = msg->offset;
msg->offset += 2; // Length
for ( auto& component : Components )
{
Expand Down Expand Up @@ -389,9 +390,10 @@ void UBoat::send_display_boat( Network::Client* client )
msg->offset += 2; // Length

// Send_display_boat is only called for CLIENTTYPE_7090, so each 0xF3 is 26 bytes here
const u16 max_count = ( 0xffff - 5 ) / 26;
// 0xf000 encoding room, huffman can take more space then the maximum of 0xffff
const u16 max_count = ( 0xf000 - 5 ) / 26;
u16 object_count = 1; // Add 1 for the boat aswell
size_t len_offset = msg->offset;
u16 len_offset = msg->offset;
msg->offset += 2; // Length

// Build boat part
Expand Down

0 comments on commit 0fab3e1

Please sign in to comment.