Page 1 of 1

Structure of the new DoCommands Array -> CommandPacket

Posted: 30 Aug 2023 10:37
by XfrankX
Hello everyone :-)

Recently I decided to dive back into patch development for some server side patches we have running on the BTPro Servers.
These patches were gathered in the past all over the place (mostly CB patches from Novapolis and some small town patches from zuu) and made "fit for purpose" on the BTPro Servers.

Now I'm trying to make these patches fit for the new CommandPacket structure of cp->data, but I'm a bit puzzled on how the new structure can be used.
Formally we had cp->p1 and cp->p2 in which we could find all the data we needed, but now they are gathered in the cp->data. I'm just trying to find out what the structure is there:

When I'm trying to see what is in the cp->data array, I just get a bunch of numbers on different indexes, so I guess there is a different way on how to get the data structured out of this cp->data structure.

I'm currently checking what is in the cp->data structure with the following code:

Code: Select all

Debug(net, 3, "Command: {}", GetCommandName(cp->cmd));

for (size_t i = 0; i < cp->data.size(); ++i) {
 	Debug(net, 3, "index: {}, Data: {}\n", i, cp->data[i]);
}
Which gives the following as output:

Code: Select all

dbg: [net] Command: CmdBuildObject, CompanyID:
dbg: [net] index: 0, Data: 46

dbg: [net] index: 1, Data: 13

dbg: [net] index: 2, Data: 0

dbg: [net] index: 3, Data: 0

dbg: [net] index: 4, Data: 4

dbg: [net] index: 5, Data: 0

dbg: [net] index: 6, Data: 0

dbg: [net] Command: CmdGoalQuestionAnswer, CompanyID:
dbg: [net] index: 0, Data: 83

dbg: [net] index: 1, Data: 31

dbg: [net] index: 2, Data: 1

dbg: [net] Command: CmdBuildRailroadTrack, CompanyID:
dbg: [net] index: 0, Data: 222

dbg: [net] index: 1, Data: 12

dbg: [net] index: 2, Data: 0

dbg: [net] index: 3, Data: 0

dbg: [net] index: 4, Data: 224

dbg: [net] index: 5, Data: 12

dbg: [net] index: 6, Data: 0

dbg: [net] index: 7, Data: 0

dbg: [net] index: 8, Data: 0

dbg: [net] index: 9, Data: 0

dbg: [net] index: 10, Data: 0

dbg: [net] index: 11, Data: 0
Below is a link to the DIFF which we used for version 12.2. I was hoping someone could point me in the right direction on how to read that cp->data in a proper and maybe structured way.
My guess is that all the cp->p1 and cp->p2 commands and the GB() commands in the network_checks.cpp file need to get replaced. I was hoping someone could guide me a bit.

Link:
https://openttd.btpro.nl/diff/serverdiff12.2.diff

Thank you in advance.

Best regards,

Frank
BTPro Server Admin