History of BF2Hub
Dear fans of Battlefield2.
As you might probably know EA had announced the end online functionality on 30th June 2014 for EA games that use GameSpy.
Community projects like BF2Hub emerged to give Battlefield2 fans a chance to play their game after the shutdown day as if there never was any shutdown. The community has put a lot of effort in bringing complex software and hardware systems to life which mimic the operational behavior of the affected GameSpy online services.
The Goal
With EA's statement around mid of May 2014 the BF2Hub project was started by 2F4Y.com to keep Battlefield2 alive after the GameSpy shutdown. The ambitious goal was to replace GameSpy for Battlefield2 with little to no effort for the players, server admins and server providers and to retain the integrity of existing/established systems (same names, same profile IDs, same CD-Key hashes, same Punkbuster GUIDs). The transition was aimed to be completely transparent upon the shutdown of the GameSpy online services.
Since the deadline was not too far in the future, we decided to only focus on solely replacing GameSpy for Battlefield2. Later we included BF2 Special Forces as the community requested it and it did not severly impact the development.
Design Choices
The first thought was about information and software distribution management. The decision was to give the community a program that would announce and provide software updates as well as important information messages. Once GameSpy shuts down it should release an update which gives you the ability to switch to the BF2Hub network. The result is the BF2Hub Client which did a decent job spreading news and updates to the community.
We also established a Twitter feed - not to be fancy or trendy but to have another information source for players if things go wrong (e.g. large maintenance windows in the data center) or just to spread news to a larger number of people.
A part of the project is the delivery and processing of player statistics, ranks and unlocks. First of all, those stats had to be gathered. Since BF2Hub emerged from 2F4Y.com we already had a quite large number of players ready for querying (see section "BF2Hub in numbers"). We knew which player name had which profile id so we could start rather early with the backup of that data domain. Since we did not want to stress the GameSpy servers too much, we set up a system of distributed nodes gathering the stats with a large-enough back-off time between the requests. Source for the nodes was a prioritized-queue of players with people registered at BF2Hub having higher priorities than other profile ids. Once an iteration was complete, a new one was initiated since stats progress over time as long as GameSpy is still up, ranked servers are still reporting to GameSpy and players are still playing.
Since the goal was to replace GameSpy without the players having to change their logins it was clear that BF2Hub did not only have to mimic the online services with the according protocols but also the user database (accounts with passwords as well as CD-Keys). Due to data privacy policies GameSpy would never publish or distribute that data so BF2Hub had to "mirror" it with the help of the community and its players. Accounts and CD-Keys must have been transferred to the BF2Hub Network both fully retrieve the corresponding data from GameSpy and to verify it (e.g. for spoofing prevention). The creation of a backup-system for Battlefield2 accounts and CD-Keys became the top priority after releasing the BF2Hub Client. The BF2Hub Account Backup tool and the BF2Hub Webclient were developed and published - some of you might know and have used them already.
The server software components on the other hands had to be designed for high-availability (HA) thus being highly robust against many types of error. Most of the server components were either UDP-based (keymaster, hbmaster3) or TCP-based with connect-request-response-close behavior (searchmanager, gmaster3). Those components could be easily designed, implemented, tested and maintained.
But especially the loginserver (gpmanager) has to keep all established connections to the players alive. If the connection gets closed, players would be kicked from the game with the message "The server has closed the connection". BF2Hub therefore has chosen to keep the endpoint for the player connections extremely lightweight and abstract and outsourced the server logic into separate worker processes which are served by the loginserver in a round-robin fashion (load-balancing) and are responding to requests forwarded by the loginserver process. As a result of separating the logic from the connection endpoint we were able to extend and to replace the server logic on the fly without restarting the loginserver thus interfering with connected clients. Other HA considerations included multiple dedicated server machines in combination with DNAT-based server load balancing to distribute maintenance windows across continents and timezones thus affecting the least-possible number of players.
Since the project contributors have longtime experience in the following software systems, C++ was used for the client software and programs with GUI (to achieve the smallest-possible library dependence amongst the playerbase), C++ for the loginserver endpoint (to achieve a lightweight, performant and long-running server component), C for network helper applications (mainly for data verification via GameSpy), PHP for the web-based solutions (Account-Webclient, API-Endpoints, Stats-System, etc.) and Python for the loginserver logic and the other server components (Python gave us a good environment to rapidly build and evaluate prototypes and to quickly develop and establish logic changes and enhancements).
MySQL forms the database backbone and Subversion helped us managing our codebase.
30th June 2014 - Targetted Shutdown-Day
As you might know from the Twitter feed or the news spread by our client, BF2Hub successfully got ready to take over on the targetted shutdown day - 30th June 2014. An update was published that contained the BF2Hub Network Switcher allowing the players to switch to the BF2Hub Network (and back) simply by modifying the hosts files (which take precedence over the DNS resolver).
All server software components were in place and fully operational:
- loginserver (both gpmanager and searchmanager)
- masterserver (reporting endpoint for the servers)
- listserver (endpoint for the ingame server browser)
- keymaster (endpoint for the gameservers checking CD-Key validity)
- availability server (reporting availability status to Battlefield2 clients and servers)
- statsserver (for reporting stats, ranks and unlocks)
BF2Hub in Numbers
Until the shutdown day we had collected and verified ~2,000 logins (including stats, ranks, unlocks) and ~2,000 CD-Keys out of the data submitted by the community.
And since 2F4Y.com is the origin of BF2Hub and tracks player names, ProfileIDs and CD-Key hashes for all of their servers already over a very long time period, we also saved ~800,000 valid player records (stats, ranks and unlocks) from all of the players who have ever played at 2F4Y.com as well as ~600,000 CD-Key hashes which could have been verified even after the GameSpy shutdown.
~11,000 effective lines of code (libraries not included) were solely written in C, C++ and Python (~2,500 in Python). The main effort went into developing the GUI, network code, data validation and error checking.
Why has this Exhaustive Information not been Posted Before?
BF2Hub is a project created and mainly maintained by only two developers. We have been very busy to get all necessary components to a mature state so that we can meet the deadline set by EA's announcements. Getting in touch with the community to this extent would have cost us precious time that could have been better spent on the development of the systems.