| 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; } |