project reality header
Go Back   Project Reality Forums > Developer Blogs > Mats391
04 Dec 2022, 00:00:00 (PRT)
Register Developer Blogs Project Reality Members List Search Today's Posts Mark Forums Read

Rate this Entry
Breaking the seat limit
Posted in: Coding
Posted 2020-09-26 at 19:08 by Mats391

The seat limit of 8 players per vehicle was assumed to be hardcoded for a long time. However, it turns out that it just never got really tested properly. After looking at the code and giving it a test, we found out that the real hardcoded limit is 10 players per vehicle. Those who already read the v1.6.3 update highlight will know that we broke that too and this DEV Blog will talk about some of the challenges that we had.

The first big issue and main reason why the seat limit was assumed to be hardcoded, was the control binding. Normal BF2 only has controls for switching to seats 1 to 8, but if those 8 seats were filled, you would enter the normally unreachable seats. While that would work for normal gameplay, it would make testing seats nearly impossible. With v1.6 we added new server side capabilities to hook and interact with the engine through Python code. [R-DEV]AlonTavor used these to change the F8 key binding to cycle you to the next open seat instead of switching to seat 8. This will only work on dedicated servers.

Next up was COOP. The AI module does not like any vehicle with more than 8 seats and crashes instantly on map load. This could have been avoided by creating copies of every vehicle for coop mode. Luckily the crash was fixable through some binary editing, so coop players can enjoy the same amount of seats as everyone else.

With these two issues out of the way, BF2 would support up to 10 seats per vehicle without any further changes. The limit of 10 comes from the client side HUD showing the seat positions and names of players in the vehicle. The code for that has no out of bounds check and would start accessing part of the memory it should not touch which results in a crash. Even if the seats would not show up on the HUD, it would still result in a crash. We fixed this by injecting an overflow protection through the Launcher. However this also means the normal HUD will not work for any seat above 10.

That brings us to the next step: Making a nicer HUD for used seats. While non-essential for this to work, it ties everything together. As the BF2 HUD only supports 10 seats, we started making our own HUD that gets controlled by the Launcher. For that we count the amount of currently occupied seats that do not have a seat dot in the HUD and show this number as the passenger counter in the bottom left. We decided to use this counter even for vehicles that do not go past 10 seats to ensure consistency and easy recognition across all vehicles. As such only the vehicle crew gets position dots for their seats. The crew is roughly defined as pilot/driver, co-pilot/co-driver and any gunner.

At last the only thing left to to do was to go through all our vehicles, figure out how many seats it should have and then add them. Since some vehicle got created with the assumption that there would never be more than 8 seats, we even had to change some vehicle models to add more.

Passenger numbers in v1.6.3(in game values may have changed since list got updated):

Land vehicles:

Air vehicles:

Sea vehicles:
Views: 54769 | Comments: 38

« Previous Entry  |  Main

Total Comments: 38
  1. Old Comment
    This could have been avoided by creating copies of every vehicle for coop mode. Luckily the crash was fixable through some binary editing, so coop players can enjoy the same amount of seats as everyone else. concrete leveling
    Posted 2022-05-23 at 09:31 by neebwhitlinger neebwhitlinger is offline
  2. Old Comment
    Fantastic job! It's great to learn about such accomplishments!
    I'm excited to see how it plays out in the game. pool tile repair oviedo
    Posted 2022-05-27 at 03:30 by jensonjones jensonjones is offline
  3. Old Comment
    Posted 2022-06-04 at 03:16 by Oliver045 Oliver045 is offline
    Updated 2022-09-13 at 13:26 by Oliver045
  4. Old Comment
    This is great work, thanks for sharing this information. Metal Roofing Peterborough Ontario
    Posted 2022-07-05 at 15:54 by abbyrconley abbyrconley is offline
  5. Old Comment
    great information. I'll be back to this site. cleaning service
    Posted 2022-07-12 at 20:42 by abbyrconley abbyrconley is offline
  6. Old Comment


    Very fantastic. It's worked.

    Posted 2022-07-15 at 04:38 by cockysponson cockysponson is offline
  7. Old Comment
    Thank you for the efforts, and took me time to read all the comments, but I really enjoyed the topic of this thread. tax preparation near me
    Posted 2022-07-20 at 04:38 by ampva302 ampva302 is offline
  8. Old Comment
    Fortunately, the problem could be fixed with some binary tweaking, allowing cooperative players to take advantage of the same number of seats as everyone else.

    window cleaner
    Posted 2022-08-04 at 13:26 by falcon66hygienic falcon66hygienic is offline
  9. Old Comment
    I want to thank you this great idea! I love every bit of it. I have a bookmark you look at your new things. mount vernon appliance repair
    Posted 2022-09-01 at 03:31 by anthonyscotte23 anthonyscotte23 is offline
  10. Old Comment
    By making duplicates of every vehicle for cooperative mode, this might have been prevented.
    Posted 2022-09-08 at 11:18 by gakabakma gakabakma is offline

All times are GMT. The time now is 00:57.