Skip to content

Commit

Permalink
readme developer
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Oct 25, 2024
1 parent 381fb40 commit e55e436
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ Edit your server's CMakeLists.txt and insert those lines above `add_executable(g
# add_executable(game-server ..
```

Then add a callback context to the gameserver.
```C++
// src/game/server/gamecontext.h

#include <server/ddnet_callback_ctx.h>

class CGameContext
{
// [..]
TWBL::CDDNetCallbackCtx m_TwblCallbackCtx;
};
```

Then add a state buffer to the player class.
```C++
// src/game/server/player.h
Expand Down Expand Up @@ -87,6 +100,7 @@ void CCharacter::Tick()
TWBL::SetState(this, &State);
State.m_pCollision = Collision();
State.m_ppPlayers = GameServer()->m_apPlayers;
State.m_pCallbackCtx = &GameServer()->m_TwblCallbackCtx;
Twbl_SampleTick(&State, &Bot, &GetPlayer()->m_TwblPersistentState, sizeof(GetPlayer()->m_TwblPersistentState));
Expand Down
7 changes: 2 additions & 5 deletions src/server/set_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@

namespace TWBL {

void SetState(CCharacter *pChr, CServerBotStateIn *pState)
void SetState(CCharacter *pChr, CServerBotStateIn *pState, *pCallbackCtx)
{
CDDNetCallbackCtx CallbackCtx;
CallbackCtx.m_pGameServer = pChr->GameServer();

pState->m_GameTick = pChr->GameServer()->Server()->Tick();
pState->m_pCharacter = pChr;
pState->m_ClientId = pChr->GetPlayer()->GetCid();
pState->m_pCallbackCtx = &CallbackCtx;
pState->m_pCallbackCtx = pCallbackCtx;
}

} // namespace TWBL
Expand Down

0 comments on commit e55e436

Please sign in to comment.