MCPcopy Create free account
hub / github.com/ddnet/ddnet / AddCommandUnsafe

Method AddCommandUnsafe

src/engine/client/graphics_threaded.h:601–622  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

599
600 template<class T>
601 bool AddCommandUnsafe(const T &Command)
602 {
603 // make sure that we don't do something stupid like ->AddCommand(&Cmd);
604 (void)static_cast<const SCommand *>(&Command);
605
606 // allocate and copy the command into the buffer
607 T *pCmd = (T *)m_CmdBuffer.Alloc(sizeof(*pCmd), alignof(T));
608 if(!pCmd)
609 return false;
610 *pCmd = Command;
611 pCmd->m_pNext = nullptr;
612
613 if(m_pCmdBufferTail)
614 m_pCmdBufferTail->m_pNext = pCmd;
615 if(!m_pCmdBufferHead)
616 m_pCmdBufferHead = pCmd;
617 m_pCmdBufferTail = pCmd;
618
619 ++m_CommandCount;
620
621 return true;
622 }
623
624 const SCommand *Head() const { return m_pCmdBufferHead; }
625 SCommand *Head() { return m_pCmdBufferHead; }

Callers 3

InitMethod · 0.80
ShutdownMethod · 0.80
AddCmdMethod · 0.80

Calls 1

AllocMethod · 0.80

Tested by

no test coverage detected