TDP :: Code Architecture

Version 1.0 - Jean-René Bédard - 17/12/2004 - Initial







We build our multiplayer mod from scratch on top of the source engine instead of just modding HL2. Here are the differences between the two options:
Differences between 'from scratch' (MP SDK) and 'modify HL2' (SP SDK)

If you are using Visual C++ 7.0, you can convert the SDK's 7.1 .sln and .vcproj to the 7.0 version using vsconvert.
You can use this convert list to convert all .sln and .vcproj : Convertlist.vsc

DOxygen of the SDK code

Visual Assist X is recommanded to program on our project.

Since we'll often have to merge code and text files, I recommand : WinMerge

Forums:
Official SDK ChatBear forum
The Wavelength

Here is the root of the Source code located in “C:\Troy Divine Playground\src”


cl_dll Client code ("cl_dll\tdp" TDP client code to be developed)
dlls Server code (TDP server code to be developed)
game_shared Shared code (TDP shared code to be developed)


 

 

TDP Architecture :
"C:\Troy Divine Playground\src\cl_dll"



Features on the client side.

"cl_dll\" Generic client code.
(Derivate from here to build a specific game)
"cl_dll\Debug_TDP" Debug output directory for the TDP client. Produces client.dll
"cl_dll\Release_TDP" Release output directory for the TDP client. Produces client.dll
"cl_dll\hl2_hud" Client code specific to Half-life 2.
(HL2 Derivates, SP inspiration)
"cl_dll\sdk" Client code specific to the SDK.
(SDK Derivates, MP inspiration)
"cl_dll\tdp" Client code specific to TDP.
(TDP Derivates)

For a MP game like TDP, we should at least derivate these :
tdp_clientmode class CTDPModeManager : public IVModeManager.
class CTDPClientModeNormal : public ClientModeShared.

Mode manager for the TDP client (SwitchMode, LevelInit, LevelShutdown)
tdp_prediction class CTDPPrediction : public CPrediction

TDP specific prediction (SetupMove, FinishMove)
tdp_in_main class CTDPInput : public CInput

TDP specific input handling.
c_tdp_player class C_TDPPlayer : public C_BasePlayer, public ITDPPlayerAnimStateHelpers

Methods for a TDP client player (UpdateClientSideAnimation, PostDataUpdate)
c_tdp_team class C_TDPTeam : public C_Team

Client side TDP team.

Specifics classes for TDP :
tdp_hud_(hudElementName) class CHud(Name) : (base classes vary)

HUD element for TDP.
c_npc_(npcName) class C_NPC(Name) : public C_AI_BaseNPC

client side NPC code.
c_vehicle_(vehicleName) class C_Vehicle(Name) : public C_BaseAnimating, public IClientVehicle

client side vehicle code.
c_weapon_(weaponName) class C_Weapon(Name) : public C_BaseCombatWeapon

client side weapon code.


"C:\Troy Divine Playground\src\dlls"

Features on the server side.

"dlls\" Generic server code.
(Derivate from here to build a specific game)
"dlls\Debug_TDP" Debug output directory for the TDP server. Produces server.dll
"dlls\Release_TDP" Release output directory for the TDP server. Produces server.dll
"dlls\hl2_dll" Server code specific to Half-life 2.
(HL2 Derivates, SP inspiration)
"dlls\sdk" Server code specific to the SDK.
(SDK Derivates, MP inspiration)
"dlls\tdp" Server code specific to TDP.
(TDP Derivates)

For a MP game like TDP, we should at least derivate these in Server :
tdp_client C-style client methods...
tdp_env_message class CGameMessageEntity : public CLogicalEntity

Entity to transmit message to the client.
tdp_eventlog class CTDPEventLog : public CEventLog

Log of the events in TDP.
tdp_gameinterface CServerGameClients and CServerGameDLL implementations
tdp_(entityName) Brush, Model or Logical entity classes created for TDP.
.
tdp_player class CTDPPlayer : public CBasePlayer, public ITDPPlayerAnimStateHelpers

Methods for a TDP server player (Spawn, PreThink, Event_Killed)
tdp_playermove class CTDPPlayerMove : public CPlayerMove

Methods for TDP player movement (SetupMove, FinishMove)
tdp_team class CTDPTeam : public CTeam

Server side TDP team.

Specifics classes for TDP :
ai_behavior_(behaviorName) Class for each TDP server ai behavior entities.
item_(itemName) Class for each TDP server item entities.
npc_(npcName) Class for each TDP server npc entities.
vehicle_(vehicleName) Class for each TDP server vehicles entities.
weapon_(weaponName) class CWeapon(Name) : public CBaseCombatWeapon

Class for each TDP server weapons entities.
Also, a corresponding weapon_(weaponName).txt must be in ("troydp/scripts")


"C:\Troy Divine Playground\src\game_shared"

Shared code between the client and the server.

"game_shared\" Generic shared code between the client and the server.
(Derivate from here to build a specific game)
"game_shared\hl2" Shared code between the client and the server specific to Half-life 2.
(HL2 Derivates, SP inspiration)
"game_shared\sdk" Shared code between the client and the server specific to the SDK.
(SDK Derivates, MP inspiration)
"game_shared\tdp" Shared code between the client and the server specific to TDP.
(TDP Derivates)

For a MP game like TDP, we should at least derivate these :
tdp_fx_shared Shared effects structs between the client and the server.
tdp_gamemovement class CTDPGameMovement : public CGameMovement

Specials movements for TDP (ladder, etc)
tdp_gamerules class CTDPGameRules : public CTeamplayRules

TDP game rule object (PlayerRelationship, ShouldCollide)
tdp_player_shared Implements CTDPPlayer.
(FireBullet, TDPAnim_GetActiveWeapon)
tdp_playeranimstate class ITDPPlayerAnimState : virtual public IPlayerAnimState

Triggers events for player animations (DoAnimationEvent)
tdp_shareddefs Shared definitions.
tdp_usermessages Register user messages for TDP.
tdp_weapon_parse class CTDPWeaponInfo : public FileWeaponInfo_t

Parsing theWeaponData file loacated in : weapon_(weaponName).txt in ("troydp/scripts")
tdp_weapon_base class CTDPWeaponBase : public CBaseCombatWeapon

Base class for TDP weapons.

Specifics classes for TDP :
weapon_(weaponName) class CWeapon(Name) : public CTDPWeaponBase
tdp_base_weapon(kind) Bases classes for kinds of weapons for further subdivision (projectile, blundgeon)





Entities to be developed :
TDP_Entities Entities to be created for TDP (base for weapons, players, physics, gameplay logic)
TDP_Weapons Weapons entities to be created for TDP.
TDP_Physics Physics entities to be created for TDP.
TDP_Logic Game logic entities to be created for TDP.
TDP_Players Players entities to be created for TDP.
TDP_Effects Visual effects to be created for TDP.



Notes:

Client:
On the client-side, the rendering function OnRenderStart() is in cdll_client_int.cpp.
- HUD
- client-side physic
- animations
- bone slerping (vertex skinning)
- visual FX
- particles system simulation
- prediction
- rendering
- ragdoll

Server
On the server-side, the game loop function CServerGameDLL::GameFrame() is in GameInterface.cpp
- Gameloop
- Edicts dispatching : input, output
- User commands dispatching. Command DP, functors
- Lag compensating
- AI, SP only
- Multiplayer physic