Project

General

Profile

Actions

Bug #1710

closed

disaster frequency value > 255 cause network problem

Added by Dean Brown 15 days ago. Updated 9 days ago.

Status:
Closed
Priority:
Normal
Category:
General
Target version:
Start date:
10/19/2025
Due date:
% Done:

0%

Estimated time:

Description

In packets.def the disaster frequency is UINT8, needs to be UINT32. The ruleset value could in theory be as high as 1000000 if you wanted the disaster to always happen. Currently values > 255 get truncated.

If game.ruleset has -

[disaster_5]
...
frequency=50000

get message -
"Trying to put 50000 into 8 bits; it will result 80 at receiving side."

Pretty rare, so I suggest targeting 3.3.0


Files

1710.patch (742 Bytes) 1710.patch Dean Brown, 10/22/2025 04:28 AM

Related issues 1 (1 open0 closed)

Blocks Tasks #1712: S3_3 network protocol freeze (npf)New10/22/2025

Actions
Actions #1

Updated by Dean Brown 15 days ago

  • File 1710.patch added

Patch for S3_3 and Main

Actions #2

Updated by Marko Lindqvist 14 days ago

Dean Brown wrote:

In packets.def the disaster frequency is UINT8, needs to be UINT32. The ruleset value could in theory be as high as 1000000 if you wanted the disaster to always happen. Currently values > 255 get truncated.

The max should be 1000, I think, as it gets multiplied by the server setting that has max of 1000 (1000*1000=1000000). The server setting values that user may set should be meaningful, or the ruleset should lock the setting (to 1000).

Actions #3

Updated by Marko Lindqvist 12 days ago

Marko Lindqvist wrote in #note-2:

Dean Brown wrote:

In packets.def the disaster frequency is UINT8, needs to be UINT32. The ruleset value could in theory be as high as 1000000 if you wanted the disaster to always happen. Currently values > 255 get truncated.

The max should be 1000, I think

So correct type would be uint16. It's not that using the two extra bytes would be any way significant, but in the name of self-documenting code uint16 would show the intendet usage better.

Actions #4

Updated by Marko Lindqvist 12 days ago

  • Target version set to 3.3.0
Actions #5

Updated by Marko Lindqvist 12 days ago

  • Target version changed from 3.3.0 to 3.3.0-npf
Actions #6

Updated by Marko Lindqvist 12 days ago

  • Blocks Tasks #1712: S3_3 network protocol freeze (npf) added
Actions #7

Updated by Dean Brown 12 days ago

My example of frequency=50000 was a mistake on my part, I was wrong about what my server setting was. With server setting "disasters", 1000 I can change the usual disaster's frequency to 1 without changing their actual result chance of .001, and then frequency=255 for my added disaster gets me to .255, much closer to what I want. So 1000 as a max value seems right, and UINT16 is OK. Updated the patch.

There is no bounds checking in the ruleset load code, except implicit "read an int" must limit value to 2**31.

Actions #8

Updated by Dean Brown 12 days ago

  • File deleted (1710.patch)
Actions #9

Updated by Marko Lindqvist 12 days ago

  • Status changed from New to In Review
  • Assignee set to Marko Lindqvist
Actions #10

Updated by Marko Lindqvist 9 days ago

  • Status changed from In Review to Closed
Actions

Also available in: Atom PDF