BF2 Internals

From BF2 Technical Information Wiki
Revision as of 20:08, 17 June 2018 by Pireax (talk | contribs) (Created page with "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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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