fsxNet Wiki

BBS Development & Resources

User Tools

Site Tools


doors:programming:interbbsgd

InterBBS ideas used in Galactic Dynasty

Under Construction

I've been asked a couple of times how to add InterBBS capabilities into a door game, and how I did it in Galactic Dynasty.

Packets

In GD, packets are data files containing information that needs to be sent to other games, the data is prefixed by some information about the packet, such as the packet version, who the packet is for, what league the packet is for, the size of the data etc.

Packets are named in a way to avoid collisions, the first four characters are hexidecimal representation of the minute in the month, the next 2 is the hexidecimal node number of the sending node, and the final 2 the hexidecimal packet number.

The packet number is stored on the disk in a file, and is reset to 0 everytime a minute passes. This means Galactic Dynasty can send up to 256 packets a minute each month.

The extension is .GAL which is to signify it as a Galactic Dynasty Packet, so other games can use the same method but use a different extension.

Sending Packets

Packets are sent out by placing them in directories or outboxes for other nodes. The transport is left up to the sysop, in FSXnet we use fileboxes, but could just as easily use FTP or some other file transfer system.

When a packet is received, and maintenance is run, the game first checks if the packet is for the right league and then whether the version is correct. If these are incorrect it logs it and continues ignoring the packet. Next it checks the memory size of the data vs the size of the packet to see if it's corrupt, and finally if the packet is actually meant for this system.

If a game receives a packet not meant for it, it will forward it on to the outbox of the system it's meant for, this means you can route packets by using outboxes for the uplink system instead of the destination system, and the uplink will forward to it's uplink and so on until it finally gets to the destination.

Processing Packets

Incoming packets are processed when calling maintenance, outgoing packets are created at any time. So if someone sends an InterBBS battle whilst playing, the packet is created immediately. The packet is sent, and the receiving end processes the packet when running maintenance, calculates the result of the battle and sends the resulting packet back.

The data segment of the packet can be any size and any information the game needs to send. In galactic dynasty, a single structure is used for packet data, and contains an integer field specifying what the data is for and the fields are used in a way that represents that type of packet.

Technical Details

A packet looks like this:

  [ Version String ] (fixed length)
  [   League No    ] (fixed length)
  [Destination Node] (fixed length)
  [    Data Size   ] (fixed length)
  [      Data      ] (Variable length)

In galactic dynasty the data segment looks like this:

  int32_t type;
  uint32_t from;
  char player_name[17];
  char victim_name[17];
  uint32_t score;
  uint32_t troops;
  uint32_t generals;
  uint32_t fighters;
  uint32_t plunder_credits;
  uint32_t plunder_food;
  uint32_t plunder_people;
  char message[256];
  uint32_t created;
  uint32_t turns_per_day;
  uint32_t turns_in_protection;
  uint32_t game_id;

(So while the data field can be variable, in galactic dynasty it is not, and each packet contains fields for all types of packets)

All packet structures must be both packed and converted to network endian. This ensures compatability over various OSes and CPUs.

doors/programming/interbbsgd.txt · Last modified: 2017/09/19 07:50 by apam