core/smn_bitbuffer.cpp
changeset 1872 c53001c1df36
parent 1764 e4f24e9789fd
child 1947 e73a1e51833b
     1.1 --- a/core/smn_bitbuffer.cpp	Wed Feb 20 07:56:33 2008 +0000
     1.2 +++ b/core/smn_bitbuffer.cpp	Thu Feb 21 01:03:35 2008 +0000
     1.3 @@ -651,6 +651,25 @@
     1.4  	return 1;
     1.5  }
     1.6  
     1.7 +static cell_t smn_BfGetNumBytesLeft(IPluginContext *pCtx, const cell_t *params)
     1.8 +{
     1.9 +	Handle_t hndl = static_cast<Handle_t>(params[1]);
    1.10 +	HandleError herr;
    1.11 +	HandleSecurity sec;
    1.12 +	bf_read *pBitBuf;
    1.13 +
    1.14 +	sec.pOwner = NULL;
    1.15 +	sec.pIdentity = g_pCoreIdent;
    1.16 +
    1.17 +	if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
    1.18 +		!= HandleError_None)
    1.19 +	{
    1.20 +		return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
    1.21 +	}
    1.22 +
    1.23 +	return pBitBuf->GetNumBitsLeft() >> 3;
    1.24 +}
    1.25 +
    1.26  REGISTER_NATIVES(bitbufnatives)
    1.27  {
    1.28  	{"BfWriteBool",				smn_BfWriteBool},
    1.29 @@ -681,5 +700,6 @@
    1.30  	{"BfReadVecCoord",			smn_BfReadVecCoord},
    1.31  	{"BfReadVecNormal",			smn_BfReadVecNormal},
    1.32  	{"BfReadAngles",			smn_BfReadAngles},
    1.33 +	{"BfGetNumBytesLeft",		smn_BfGetNumBytesLeft},
    1.34  	{NULL,						NULL}
    1.35  };