BF2 Internals: Difference between revisions

From BF2 Technical Information Wiki
Jump to navigation Jump to search
(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...")
 
Line 29: Line 29:
== ClassManager ==
== ClassManager ==
The program contains a single ClassManager instance which is used to dynamically access different subsystems within the game.
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.
These subsystems are registered via a string identifier(class name), an instance pointer, the class id and another unknown integer, they can then later be accessed using the class name.
The following subsystems / identifiers are registered in BF2.exe:
The following classes are registered in BF2.exe:
; GameServerSettings
; GameServerSettings
; HudInformationLayer
; HudInformationLayer

Revision as of 20:13, 17 June 2018

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(class name), an instance pointer, the class id and another unknown integer, they can then later be accessed using the class name. The following classes 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