BF2 Internals
The BF2 engine has been written in C++ and also make heavy use of STL.
Reference Counting
A lot of the internal components of the game use intrusive reference counting through inheritance. The base class would look something like this:
class RefCounted {
public:
RefCounted() : m_refCount(1) {}
virtual int addRef() {
return ++m_refCount;
}
virtual int getRefCount() {
return m_refCount;
}
virtual int release() {
if (--m_refCount == 0) {
delete (RefCounted*)this;
}
return m_refCount;
}
private:
int m_refCount;
}
ClassManager
The program contains a single ClassManager instance which is used to dynamically access different subsystems within the game. These subsystems are registered via a string identifier, the instance pointer and two unknown integers, they can then later be accessed by the string identifier. The following subsystems / identifiers are registered in BF2.exe:
- GameServerSettings
- HudInformationLayer
- DistributedLightRenderer
- LocalProfileManager
- ProfileManager
- RankManager
- ClanManager
- NewsManager
- AutoPatch
- Persistence
- MenuTeamManager
- GlobalSettings
- VideoSettings
- AudioSettings
- ControlSettings
- GeneralSettings
- HapticSettings
- ServerBrowserManager
- SwiffHost
- DemoLibrary
- ServerLogoManager
- ModInfo