Changeset 379

Show
Ignore:
Timestamp:
09/13/11 23:20:25 (8 months ago)
Author:
Carsten
Message:

Updates to game code and game implementation documentation.

Location:
cafu/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • cafu/trunk/Games/DeathMatch/Code/DeathMatch.cpp

    r285 r379  
    7373 
    7474 
    75 // This is the first function that is called by both the client and the server after they have loaded this DLL. 
    76 // Its purpose is to point us to the shared implementation of the relevant interfaces (the MatSys etc.), 
    77 // so that we can access the same implementation of the interfaces as the engine. 
    78 // 
    79 // The fact that DLLs that are loaded multiple times cause only a reference counter to be increased rather than separate copies 
    80 // of the DLL to be created (the global state exists only once), and the way how clients and servers change worlds (client deletes 
    81 // the old world first, then loads the new, server loads new world first and only then deletes the old one), and the fact that in 
    82 // a single Cafu.exe instance, the client only, the server only, or both can be running, means that a *single* instance of this 
    83 // DLL may live over several world changes of a client and server, because at least one of them keeps referring to it at all times. 
    84 // 
    85 // Therefore, it may happen that GetGame() is called *many* times, namely on each world change once by the server and once 
    86 // by the client. The parameters to this function however are always non-volatile, they don't change over multiple calls. 
    87 // In future implementations I'll possibly change this and load and init the DLL only once, even before the client or server gets instantiated. 
    88  
    8975#ifdef _WIN32 
     76// Provide definitions for the globally declared pointers to these interfaces (see e.g. see GuiMan.hpp for more details). 
    9077// Under Linux (where DLLs are shared objects), these all resolve to their counterparts in the main executable. 
    91 cf::GuiSys::GuiManI*   cf::GuiSys::GuiMan=NULL;     // Define the global GuiMan pointer instance -- see GuiMan.hpp for more details. 
    92 MaterialManagerI*      MaterialManager   =NULL; 
    93 cf::ConsoleI*          Console=NULL; 
    94 ConsoleInterpreterI*   ConsoleInterpreter=NULL; 
    95 cf::FileSys::FileManI* cf::FileSys::FileMan=NULL; 
     78cf::GuiSys::GuiManI*        cf::GuiSys::GuiMan       =NULL; 
     79MaterialManagerI*           MaterialManager          =NULL; 
     80cf::ConsoleI*               Console                  =NULL; 
     81ConsoleInterpreterI*        ConsoleInterpreter       =NULL; 
     82cf::FileSys::FileManI*      cf::FileSys::FileMan     =NULL; 
    9683cf::ClipSys::CollModelManI* cf::ClipSys::CollModelMan=NULL; 
    97 SoundSysI*             SoundSystem=NULL; 
    98 SoundShaderManagerI*   SoundShaderManager=NULL; 
     84SoundSysI*                  SoundSystem              =NULL; 
     85SoundShaderManagerI*        SoundShaderManager       =NULL; 
    9986#endif 
    10087 
    10188 
    102 // WARNING: When the signature of GetGame() is changed here (e.g. by adding more interface pointer parameters), 
    103 // grep all C++ source code files for "GetGame@", because the number of parameter bytes must be updated there! 
    104 DLL_EXPORT cf::GameSys::GameI* __stdcall GetGame(MatSys::RendererI* Renderer, MatSys::TextureMapManagerI* TexMapMan, MaterialManagerI* MatMan, cf::GuiSys::GuiManI* GuiMan_, cf::ConsoleI* Console_, ConsoleInterpreterI* ConInterpreter_, cf::ClipSys::CollModelManI* CollModelMan_, SoundSysI* SoundSystem_, SoundShaderManagerI* SoundShaderManager_) 
     89/// This is the first function that is called by the core engine (both the client and the server) 
     90/// after it has loaded this game DLL. 
     91/// 
     92/// Its purpose is to exchange pointers to various interfaces: 
     93///   - The engine points us to all the relevant interfaces (the MatSys, SoundSys, etc.) 
     94///     that are implemented in the core engine and can be used by our code in the game DLL. 
     95///   - In return we provide the core engine with our implementation of the cf::GameSys::GameI interface, 
     96///     that the client and/or the server will in turn use as the sole means to communicate with and run the game. 
     97/// 
     98/// The fact that DLLs that are loaded multiple times cause only a reference counter to be increased rather than separate copies 
     99/// of the DLL to be created (the global state exists only once), and the way how clients and servers change worlds (client deletes 
     100/// the old world first, then loads the new, server loads new world first and only then deletes the old one), and the fact that in 
     101/// a single Cafu.exe instance, the client only, the server only, or both can be running, means that a *single* instance of this 
     102/// DLL may live over several world changes of a client and server, because at least one of them keeps referring to it at all times. 
     103/// 
     104/// Therefore, it may happen that GetGame() is called *many* times, namely on each world change once by the server and once 
     105/// by the client. The parameters to this function however are always non-volatile, they don't change over multiple calls. 
     106/// In future implementations we'll possibly change this and load and init the DLL only once, even before the client or server gets instantiated. 
     107/// 
     108/// WARNING: When the signature of GetGame() is changed here (e.g. by adding more interface pointer parameters), 
     109/// grep all C++ source code files for "GetGame@", because the number of parameter bytes must be updated there! 
     110DLL_EXPORT cf::GameSys::GameI* __stdcall GetGame( 
     111    MatSys::RendererI* Renderer, 
     112    MatSys::TextureMapManagerI* TexMapMan, 
     113    MaterialManagerI* MatMan, 
     114    cf::GuiSys::GuiManI* GuiMan_, 
     115    cf::ConsoleI* Console_, 
     116    ConsoleInterpreterI* ConInterpreter_, 
     117    cf::ClipSys::CollModelManI* CollModelMan_, 
     118    SoundSysI* SoundSystem_, 
     119    SoundShaderManagerI* SoundShaderManager_) 
    105120{ 
    106121#ifdef _WIN32 
  • cafu/trunk/Games/Game.hpp

    r316 r379  
    4040    { 
    4141        /// The game interface, specified as an ABC so that is can be used without linked (module-local) implementation. 
    42         /// This interfce is implemented by the game DLL, and thus defines the essence of a game/MOD. 
     42        /// This interface is implemented by the game DLL, and thus defines the essence of a game/MOD. 
    4343        /// It is used (only) by the engine to run the game. 
    4444        class GameI