Skip to content

Commit

Permalink
mod: Subclass CCharacter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaffeine committed Dec 20, 2023
1 parent df6898d commit 184300b
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/game/server/gamemodes/mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,37 @@
#define GAME_TYPE_NAME "Mod"
#define TEST_TYPE_NAME "TestMod"

#include <game/server/entities/character.h>
#include <game/server/player.h>

class CCharacterMod : public CCharacter
{
MACRO_ALLOC_POOL_ID()
public:
CCharacterMod(CGameControllerMod *pGameController, CNetObj_PlayerInput LastInput);

protected:
CGameControllerMod *m_pGameController = nullptr;
};

CCharacterMod::CCharacterMod(CGameControllerMod *pGameController, CNetObj_PlayerInput LastInput) :
CCharacter(&pGameController->GameServer()->m_World, LastInput),
m_pGameController(pGameController)

{
}

MACRO_ALLOC_POOL_ID_IMPL(CCharacterMod, MAX_CLIENTS)

class CPlayerMod : public CPlayer
{
MACRO_ALLOC_POOL_ID()
public:
CPlayerMod(CGameControllerMod *pGameController, uint32_t UniqueClientID, int ClientID, int Team);

private:
protected:
CCharacter *CreateCharacter() override;

CGameControllerMod *m_pGameController = nullptr;
};

Expand All @@ -26,6 +48,11 @@ CPlayerMod::CPlayerMod(CGameControllerMod *pGameController, uint32_t UniqueClien
{
}

CCharacter *CPlayerMod::CreateCharacter()
{
return new(m_ClientID) CCharacterMod(m_pGameController, GameServer()->GetLastPlayerInput(m_ClientID));
}

CGameControllerMod::CGameControllerMod(class CGameContext *pGameServer) :
IGameController(pGameServer)
{
Expand Down

0 comments on commit 184300b

Please sign in to comment.