Added amb1460 - BfGetNumBytesLeft

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401878
This commit is contained in:
Matt Woodrow 2008-02-21 01:03:35 +00:00
parent 9a49bf2f08
commit 7a5b8caa16
2 changed files with 29 additions and 0 deletions

View File

@ -651,6 +651,25 @@ static cell_t smn_BfReadAngles(IPluginContext *pCtx, const cell_t *params)
return 1; return 1;
} }
static cell_t smn_BfGetNumBytesLeft(IPluginContext *pCtx, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError herr;
HandleSecurity sec;
bf_read *pBitBuf;
sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None)
{
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
}
return pBitBuf->GetNumBitsLeft() >> 3;
}
REGISTER_NATIVES(bitbufnatives) REGISTER_NATIVES(bitbufnatives)
{ {
{"BfWriteBool", smn_BfWriteBool}, {"BfWriteBool", smn_BfWriteBool},
@ -681,5 +700,6 @@ REGISTER_NATIVES(bitbufnatives)
{"BfReadVecCoord", smn_BfReadVecCoord}, {"BfReadVecCoord", smn_BfReadVecCoord},
{"BfReadVecNormal", smn_BfReadVecNormal}, {"BfReadVecNormal", smn_BfReadVecNormal},
{"BfReadAngles", smn_BfReadAngles}, {"BfReadAngles", smn_BfReadAngles},
{"BfGetNumBytesLeft", smn_BfGetNumBytesLeft},
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -314,3 +314,12 @@ native BfReadVecNormal(Handle:bf, Float:vec[3]);
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfReadAngles(Handle:bf, Float:angles[3]); native BfReadAngles(Handle:bf, Float:angles[3]);
/**
* Returns the number of bytes left in a readable bitbuffer (bf_read).
*
* @param bf bf_read handle to read from.
* @return Number of bytes left unread.
* @error Invalid or incorrect Handle.
*/
native BfGetNumBytesLeft(Handle:bf);