Esempio n. 1
0
bool CD3D_Device::LoadWorldData(ILTStream *pStream)
{
	if (m_pRenderWorld)
		delete m_pRenderWorld;
	LT_MEM_TRACK_ALLOC(m_pRenderWorld = new CD3D_RenderWorld,LT_MEM_TYPE_RENDERER);
	return m_pRenderWorld->Load(pStream);
}
Esempio n. 2
0
//allocators for a block of memory
void* CLTALoadOnlyAlloc::AllocateBlock(uint32 nSize)
{
	//see if we have enough room left in this block
	if(m_nMemLeft < nSize)
	{
		uint32 nBlockSize = LTMAX(m_nBlockSize, nSize);

		//we need to allocate the memory for a block. If the size is bigger than
		//a block, we need to allocate the block to be that big
		uint8* pMem;
		LT_MEM_TRACK_ALLOC(pMem = new uint8[nBlockSize],LT_MEM_TYPE_MISC);

		//check the allocation
		if(pMem == NULL)
			return NULL;

		//now allocate the block structure that will maintain the mem
		CLoadMemBlock* pNewBlock;
		LT_MEM_TRACK_ALLOC(pNewBlock = new CLoadMemBlock(pMem, m_pHead),LT_MEM_TYPE_MISC);

		//check the allocation
		if(pNewBlock == NULL)
		{
			delete [] pMem;
			return NULL;
		}

		m_pHead = pNewBlock;

		//update the block size
		m_nMemLeft = nBlockSize;
	}

	//ok, now we know that the allocation will fit inside of this block, so lets
	//go ahead and return the pointer and update our counts
	ASSERT(m_nMemLeft >= nSize);
	ASSERT(m_pHead);

	void* pRV = (void*)m_pHead->m_pCurrMemHead;

	//update our counts
	m_pHead->m_pCurrMemHead += nSize;
	m_nMemLeft -= nSize;

	return pRV;
}
Esempio n. 3
0
//  ---------------------------------------------------------------------------
void CUIWidgetManager::Init(uint16 scrWidth, uint16 scrHeight)
{
	CUIRECT rect;

	m_ScreenHeight = scrHeight;
	m_ScreenWidth  = scrWidth;
	
	// create the GUID storage area (RedBlack Tree)
	LT_MEM_TRACK_ALLOC(m_pGUIDTree = new CUIRedBlackTree(),LT_MEM_TYPE_UI);
	m_GUIDCount = 0;
	
	// create the destroylist
	LT_MEM_TRACK_ALLOC(m_pDestroyList = new CUILinkList(),LT_MEM_TYPE_UI);
	
	// create the messagequeue
	LT_MEM_TRACK_ALLOC(m_pMessageQueue = new CUIMessageQueue(),LT_MEM_TYPE_UI);

	// initialize the user-callback
	m_pUserCallback       = NULL;
	m_pUserCallbackObject = NULL;
	m_pUserCallbackData	  = NULL;

	// no default skin
	m_CurrentSkin = NULL;

	// create the desktop widget	
	rect.x = 0;
	rect.y = 0;
	rect.width  = scrWidth;
	rect.height = scrHeight;
	
	// a sneaky little shuffle-- do this here so we can create the root widget.
	m_bInitted = true;

	m_pRootWidget = this->CreateWidget(
		NULL, CUIW_WINDOW, &rect, NULL, CUIS_ENABLED | CUIS_TREE_VISIBLE);
		
	if (!m_pRootWidget) {
		m_bInitted = false;
		return;
	}

	m_pRootWidget->Hide(false);
	
	
}
//  ---------------------------------------------------------------------------
CUIFormattedPolyString::CUIFormattedPolyString(CUIFont* pFont, 
							 const char* pText,
							 float x,
							 float y,
							 CUI_ALIGNMENTTYPE alignment)
{
	LT_MEM_TRACK_ALLOC(m_pImpl = new CUIFormattedPolyString_Impl(pFont, pText, x, y, alignment),LT_MEM_TYPE_UI);
}
Esempio n. 5
0
CPlex* CPlex::Create(CPlex*& pHead, uint32 nMax, uint32 cbElement)
{
	ASSERT(nMax > 0 && cbElement > 0);
	CPlex* p;
	LT_MEM_TRACK_ALLOC(p = (CPlex*) new int8[sizeof(CPlex) + nMax * cbElement],LT_MEM_TYPE_MISC);
			// may throw exception
	p->pNext = pHead;
	pHead = p;  // change head (adds in reverse order for simplicity)
	return p;
}
Esempio n. 6
0
bool CD3DSkelMesh::Load_RD(ILTStream& File)
{
	// What type of Vert do we need?
	switch (m_iMaxBonesPerTri)
	{
	case 1  : m_VertType = eNO_WORLD_BLENDS; break;
	case 2  : m_VertType = eNONINDEXED_B1; break;
	case 3  : m_VertType = eNONINDEXED_B2; break;
	case 4  : m_VertType = eNONINDEXED_B3; break;
	default : assert(0); return false;
	}

	// Read in our Verts...
	for (uint32 i=0;i<4;++i)
	{
		if (!m_VertStreamFlags[i]) continue;

		uint32 iVertexSize	= 0;									// Figure out the vertex size...
		uint32 iVertFlags	= 0;
		uint32 iUVSets		= 0;
		GetVertexFlags_and_Size(m_VertType,m_VertStreamFlags[i],iVertFlags,iVertexSize,iUVSets,m_bNonFixPipeData);

		uint32 iSize = iVertexSize * m_iVertCount;					// Alloc the VertData...
		LT_MEM_TRACK_ALLOC(m_pVertData[i] = new uint8[iSize],LT_MEM_TYPE_RENDERER);
		File.Read(m_pVertData[i],iSize);
	}

	// Read in pIndexList...
	LT_MEM_TRACK_ALLOC(m_pIndexData = new uint8[sizeof(uint16) * m_iPolyCount * 3],LT_MEM_TYPE_RENDERER);
	File.Read(m_pIndexData,sizeof(uint16) * m_iPolyCount * 3);

	// Allocate and read in the BoneSets...
	File.Read(&m_iBoneSetCount,sizeof(m_iBoneSetCount));
	LT_MEM_TRACK_ALLOC(m_pBoneSetArray = new BoneSetListItem[m_iBoneSetCount],LT_MEM_TYPE_RENDERER);
	if (!m_pBoneSetArray)
		return false;
	File.Read(m_pBoneSetArray,sizeof(BoneSetListItem)*m_iBoneSetCount);

	// Create the VBs and stuff...
	ReCreateObject();

	return true;
}
Esempio n. 7
0
//called during the creation to extract all the unique glyphs from a string, allocate the
//glyph list, and set them up with the characters they reference
bool CTextureStringImage::SetupUniqueGlyphList(const wchar_t* pszString)
{
	//determine the length of the string
	uint32 nStrLen = LTStrLen(pszString);

	//the first thing to do is build up the unique character list
	wchar_t* pszUniqueList;
	LT_MEM_TRACK_ALLOC(pszUniqueList = new wchar_t[nStrLen + 1], MEMORY_CATEGORY);
	if(!pszUniqueList)
		return false;

	//get the unique character list
	GetUniqueCharList(pszString, pszUniqueList, nStrLen + 1);

	//determine the number of unique characters
	uint32 nNumGlyphs = LTStrLen(pszUniqueList);

	//now allocate our glyph list
	LT_MEM_TRACK_ALLOC(m_pGlyphList = new CTextureStringGlyph[nNumGlyphs], MEMORY_CATEGORY);

	//check the allocation
	if(!m_pGlyphList)
	{
		delete [] pszUniqueList;
		return false;
	}

	//now copy over the data
	m_nNumGlyphs = nNumGlyphs;

	for(uint32 nCurrGlyph = 0; nCurrGlyph < nNumGlyphs; nCurrGlyph++)
	{
		m_pGlyphList[nCurrGlyph].m_cGlyph = pszUniqueList[nCurrGlyph];
	}
	
	//free up the unique string list
	delete [] pszUniqueList;
	pszUniqueList = NULL;

	//and success
	return true;
}
Esempio n. 8
0
LTRESULT CreateInterLink(LTObject *pOwner, void *pOther, uint32 linkType)
{

	// Don't link them if they already are.
	if( DoesLinkExist( pOwner, pOther, linkType ))
		return LT_OK;

	if (pOwner == pOther)
		return LT_ERROR;
	
	InterLink* pLink;
	LT_MEM_TRACK_ALLOC(pLink = (InterLink*)sb_Allocate(&g_pServerMgr->m_InterLinkBank), LT_MEM_TYPE_MISC);
	pLink->m_Type = linkType;
	pLink->m_pOwner	= pOwner;
	pLink->m_pOther	= pOther;

	LTLink* pOwnerLink;
	LT_MEM_TRACK_ALLOC(pOwnerLink = g_DLinkBank.Allocate(), LT_MEM_TYPE_MISC);
	
	pOwnerLink->m_pData = pLink;
	pLink->m_pOwnerLink = pOwnerLink;
	
	dl_Insert(&pOwner->sd->m_Links, pOwnerLink);

	if (linkType == LINKTYPE_SOUND)
	{
		((CSoundTrack *)pOther)->m_pInterLink = pLink;
	}
	else
	{
		LTLink* pOtherLink;
		LT_MEM_TRACK_ALLOC(pOtherLink = g_DLinkBank.Allocate(), LT_MEM_TYPE_MISC);

		pOtherLink->m_pData = pLink;
		pLink->m_pOtherLink = pOtherLink;

		dl_Insert(&((LTObject *)pOther)->sd->m_Links, pOtherLink);
	}

	return LT_OK;
}
Esempio n. 9
0
//-----------------------------------------------------------------------------
LTRESULT CLTClientContext::Init(IUnknown* /*IN*/ pUnknown, CLTRealVideoPlayer* pPlayer)
{
	LTRConsoleOutput(LTRA_CONOUT_INFO, "CLTClientContext::Init()");

	LT_MEM_TRACK_ALLOC(m_pClientAdviceSink = new CLTClientAdviceSink,LT_MEM_TYPE_MISC);
	ASSERT(m_pClientAdviceSink);
	m_pClientAdviceSink->Init(pUnknown);
	m_pClientAdviceSink->AddRef();

	LT_MEM_TRACK_ALLOC(m_pErrorSink = new CLTErrorSink,LT_MEM_TYPE_MISC);
	ASSERT(m_pErrorSink);
	m_pErrorSink->Init(pUnknown);
	m_pErrorSink->AddRef();

	LT_MEM_TRACK_ALLOC(m_pSiteSupplier = new CLTSiteSupplier,LT_MEM_TYPE_MISC);
	ASSERT(m_pSiteSupplier);
	m_pSiteSupplier->Init(pUnknown, pPlayer);
	m_pSiteSupplier->AddRef();

	return LT_OK;
}
Esempio n. 10
0
// -----------------------------------------------------------------------------------------
CRezFileSingleFile::CRezFileSingleFile(CRezMgr* pRezMgr, const char* sFileName, CRezFileDirectoryEmulation* pDirEmulation) : CBaseRezFile(pRezMgr) {
  ASSERT(sFileName != NULL);
  ASSERT(pDirEmulation != NULL);

  m_pDirEmulation = pDirEmulation;
  m_pFile = NULL;

  LT_MEM_TRACK_ALLOC(m_sFileName = new char[strlen(sFileName)+1],LT_MEM_TYPE_MISC);
  ASSERT(m_sFileName != NULL);
  strcpy(m_sFileName,sFileName);

  m_pDirEmulation->lstClosedFiles.Insert(this);
};
Esempio n. 11
0
CD3DRenderStyle* CD3D_Device::CreateRenderStyle()
{
	CD3DRenderStyle* pRenderStyle;
	LT_MEM_TRACK_ALLOC(pRenderStyle = new CD3DRenderStyle,LT_MEM_TYPE_RENDERER);
	if (!pRenderStyle)
		return NULL;
	pRenderStyle->IncRefCount();

	// Add it to the Render Object List...
	pRenderStyle->SetNext(g_Device.m_pRenderStyleList_Head);
	g_Device.m_pRenderStyleList_Head = pRenderStyle;

	return pRenderStyle;
}
Esempio n. 12
0
//	--------------------------------------------------------------------------
CUIPolyString* CUIFontManager::CreatePolyString(CUIFont* font, 
										  char* buf,
										  float x,
										  float y)
{
	if (!m_bInitted) {
		CUI_ERR("ILTFontManager was never initialized!\n");
		return NULL;
	}

	CUIPolyString* p;
	LT_MEM_TRACK_ALLOC(p = new CUIPolyString(font, buf, x, y),LT_MEM_TYPE_UI);	
	return p;
}
Esempio n. 13
0
// ------------------------------------------------------------------------
// D3D specific object creation routine.
// ------------------------------------------------------------------------
CDIModelDrawable *ModelPiece::CreateModelRenderObject( uint32 type )
{
#if !defined(DE_SERVER_COMPILE) && !defined(DE_HEADLESS_CLIENT)
			// Note : The renderer can create render objects without being initialized
			if (r_GetRenderStruct()->m_bLoaded)
				return (CDIModelDrawable*)r_GetRenderStruct()->CreateRenderObject((enum CRenderObject::RENDER_OBJECT_TYPES)type);

		
#endif
		// default or server option
		CDIModelDrawable* p;
		LT_MEM_TRACK_ALLOC(p = new CDIModelDrawable(),LT_MEM_TYPE_MODEL);
		return p;	// Create a dummy Drawable object (it knows how to load - or, really, skip by a load)...

}
Esempio n. 14
0
//	--------------------------------------------------------------------------
CUIFormattedPolyString*	CUIFontManager::CreateFormattedPolyString(CUIFont* font, 
											     char* buf,
											     float x,
											     float y,
												 CUI_ALIGNMENTTYPE alignment)
{
	if (!m_bInitted) {
		CUI_ERR("ILTFontManager was never initialized!\n");
		return NULL;
	}

	CUIFormattedPolyString*	p;
	LT_MEM_TRACK_ALLOC(p = new CUIFormattedPolyString(font, buf, x, y, alignment),LT_MEM_TYPE_UI);
	return p;
}
Esempio n. 15
0
ILTStream* streamsim_Open(const char *pFilename, const char *pAccess)
{
	FILE *fp;
	SSFile *pFile;

	fp = fopen(pFilename, pAccess);
	if(!fp)
		return 0;

	LT_MEM_TRACK_ALLOC(pFile = new SSFile,LT_MEM_TYPE_FILE);
	if(pFile)
		pFile->m_pFile = fp;
	
	return pFile;
}
Esempio n. 16
0
ILTStream* streamsim_OpenWinFileHandle( const char *pszFilename, uint32 dwDesiredAccess )
{
	HANDLE hFile;
	SSWinFileHandle *pFile;

	hFile = CreateFile( pszFilename, dwDesiredAccess, FILE_SHARE_READ, LTNULL, OPEN_ALWAYS, 0, LTNULL );
	if( hFile == INVALID_HANDLE_VALUE )
		return LTNULL;

	LT_MEM_TRACK_ALLOC(pFile = new SSWinFileHandle ,LT_MEM_TYPE_FILE);
	if(pFile)
		pFile->m_hFile = hFile;
	
	return pFile;
}
Esempio n. 17
0
void CLocalDriver::DoConnection(CLocalDriver *pDriver)
{
	if (m_pConnection)
		return;

	LT_MEM_TRACK_ALLOC(m_pBaseConn = new CBaseConn,LT_MEM_TYPE_NETWORKING);
	m_pBaseConn->m_pDriver = this;

	m_pConnection = pDriver;

	// This makes it wait until it gets update to notify everyone that
	// we made a new connection.  This is because you don't want the
	// connection notification coming in at an inconvenient time.
	m_bPendingConnection = true;
}
Esempio n. 18
0
HLTBUFFER nr_CreateSurface(int width, int height)
{
	NullBuf *pBuf;

	LT_MEM_TRACK_ALLOC(pBuf = (NullBuf*)LTMemAlloc(sizeof(NullBuf) + ((width*height)-1) * sizeof(unsigned short)),LT_MEM_TYPE_RENDERER);
	if(pBuf)
	{
		pBuf->m_Width = width;
		pBuf->m_Height = height;
		return (HLTBUFFER)pBuf;
	}
	else
	{
		return LTNULL;
	}
}
Esempio n. 19
0
void CDIDebugText::Render()
{
	if (!m_pPolyString && m_Font) {
		uint32 i32Color = RGBA_MAKE(m_DPVert.rgba.r,m_DPVert.rgba.g,m_DPVert.rgba.b,m_DPVert.rgba.a);
		//m_Font->SetColor(i32Color);
		LT_MEM_TRACK_ALLOC(m_pPolyString = new CUIPolyString(m_Font, m_Text, m_DPVert.x, m_DPVert.y),LT_MEM_TYPE_MISC);
	}

	if (m_pPolyString) {
		m_pPolyString->Render(); } 

/*LTRect rc; rc.left = m_DPVert.x; rc.top = m_DPVert.y;	
rc.bottom = rc.top + 20; rc.right = min(rc.left + 100,g_ScreenWidth);;
uint32 i32Color = RGBA_MAKE(m_DPVert.rgba.r,m_DPVert.rgba.g,m_DPVert.rgba.b,m_DPVert.rgba.a);
r_GenericTextPrint(m_Text,&rc,i32Color);*/
}
Esempio n. 20
0
void* dalloc(size_t size)
{
	//[DLK] Removed to avoid allocation errors with D3DXEffectCompiler
	/*
	if(size == 0)
	{
		return NULL;
	}
	*/

	size_t fullAllocSize;

	// Add 4 bytes if we're tracking memory usage.
	#ifdef TRACK_MEMORY_USAGE
		MemTrack *pMemTrack;
		fullAllocSize = size + sizeof(MemTrack);
	#else
		fullAllocSize = size;
	#endif

	
	char *ptr;
	// Try to allocate the memory.
	{
		CountAdder cntAdd(&g_PD_Malloc);
		LT_MEM_TRACK_ALLOC(ptr = (char*)LTMemAlloc(fullAllocSize),LT_MEM_TYPE_UNKNOWN);
	}

	if(!ptr)
	{
		dsi_OnMemoryFailure();
	}

	// Store the size in there if we're tracking memory usage.
	#ifdef TRACK_MEMORY_USAGE
		g_MemoryUsage += size;
		pMemTrack = (MemTrack*)ptr;
		pMemTrack->m_AllocSize = size;
		pMemTrack->m_AllocNumber = g_nAllocations;
		ptr += sizeof(MemTrack);
	#endif

	++g_nAllocations;
	++g_nTotalAllocations;

	return ptr;
}
Esempio n. 21
0
// Init -- load the pixel shader byte code from file.
//
bool LTPixelShaderImp::Init(ILTStream *pStream, bool bCompileShader)
{
    Term();

    ZeroMemory(m_Constants, sizeof(m_Constants));

    // The old LithTech pixel shader format is no longer supported.
    uint32 nTag;
    *pStream >> nTag;
    if (nTag == MAKEFOURCC('L', 'T', 'P', 'S'))
    {
        // not supported
        assert(!"LithTech pixel shader files are no longer supported. You must use DX9 pixel shader files!");
        return false;
    }
    else
    {
        //
        // This is a regular microsoft pixel shader.
        //

        pStream->SeekTo(0);

        // Allocate memory to read the pixel shader file.
        m_ByteCodeSize = pStream->GetLen();
        LT_MEM_TRACK_ALLOC(m_pByteCode = new uint8[m_ByteCodeSize + 4], LT_MEM_TYPE_RENDER_SHADER);
        if (m_pByteCode == NULL)
        {
            Term();
            return false;
        }
        ZeroMemory(m_pByteCode, m_ByteCodeSize + 4);

        // Read the pre-compiled pixel shader microcode
        if (pStream->Read(m_pByteCode, m_ByteCodeSize) != LT_OK)
        {
            Term();
            return false;
        }
    }

    // Save this for later.
    m_bCompileShader = bCompileShader;

    // Create the pixel shader handle.
    return Recreate();
}
Esempio n. 22
0
LTExtraCommandStruct* cc_AddCommand(ConsoleState *pState,
	const char *pCmdName, LTCommandFn fn, uint32 flags)
{
	LTExtraCommandStruct *pCommand;

	LT_MEM_TRACK_ALLOC(pCommand = (LTExtraCommandStruct*)pState->Alloc(sizeof(LTExtraCommandStruct)), LT_MEM_TYPE_CONSOLE);
	if(!pCommand)
		return 0;

	pCommand->link.m_pData = pCommand;
	pCommand->fn = fn;
	pCommand->pCmdName = pCmdName;
	pCommand->flags = flags;
	dl_Insert(&pState->m_ExtraCommands, &pCommand->link);

	return pCommand;
}
Esempio n. 23
0
void CClientMgr::AddToObjectMap(uint16 id) {
    LTRecord *newMap;
    uint32 newSize;

    // Make sure the object map is large enough.
    if (m_ObjectMapSize <= id)
    {
        newSize = id + 100;
        LT_MEM_TRACK_ALLOC(newMap = (LTRecord*)dalloc(sizeof(LTRecord) * newSize),LT_MEM_TYPE_OBJECT);
        memset(newMap, 0, sizeof(LTRecord) * newSize);

        memcpy(newMap, m_ObjectMap, sizeof(LTRecord) * m_ObjectMapSize);
        dfree(m_ObjectMap);
        m_ObjectMap = newMap;
        m_ObjectMapSize = newSize;
    }
}
Esempio n. 24
0
//-----------------------------------------------------------------------------
BOOL CopyFileFromRC(const char* sName, const char* sType, const char* sDest)
{
	HMODULE hMod = AfxGetResourceHandle();

	HRSRC hRes = FindResource(AfxGetResourceHandle(), sName, sType);
	if (!hRes)
	{
		DWORD error = GetLastError();
		return(FALSE);
	}

	HGLOBAL hGlob = LoadResource(hMod, hRes);
	if (!hGlob) return(FALSE);

	DWORD dwSize = SizeofResource(hMod, hRes);
	if (dwSize == 0) return(FALSE);
	if (dwSize > 999999) return(FALSE);

	BYTE* pRes = (BYTE*)LockResource(hGlob);
	if (!pRes) return(FALSE);

	BYTE* pData;
	LT_MEM_TRACK_ALLOC(pData = new BYTE [dwSize + 32],LT_MEM_TYPE_MISC);
	if (!pData) return(FALSE);

	memset(pData, 0, dwSize + 16);
	memcpy(pData, pRes, dwSize);

	CFile file;
	if (!file.Open(sDest, CFile::modeCreate | CFile::modeWrite))
	{
		delete pData;
		return(FALSE);
	}

	file.Write(pData, dwSize);
	file.Flush();
	file.Close();

	delete pData;
	pData = NULL;

	return(TRUE);
}
Esempio n. 25
0
void* dalloc(uint32 size)
{

	if(size == 0)
		return NULL;

	unsigned long fullAllocSize;

	// Add 4 bytes if we're tracking memory usage.
	#ifdef TRACK_MEMORY_USAGE
		MemTrack *pMemTrack;
		fullAllocSize = size + sizeof(MemTrack);
	#else
		fullAllocSize = size;
	#endif

	
	char *ptr;
	// Try to allocate the memory.
	{
		CountAdder cntAdd(&g_PD_Malloc);
		LT_MEM_TRACK_ALLOC(ptr = (char*)LTMemAlloc((size_t)fullAllocSize),LT_MEM_TYPE_UNKNOWN);
	}

	if(!ptr)
	{
		dsi_OnMemoryFailure();
	}

	// Store the size in there if we're tracking memory usage.
	#ifdef TRACK_MEMORY_USAGE
		g_MemoryUsage += size;
		pMemTrack = (MemTrack*)ptr;
		pMemTrack->m_AllocSize = size;
		pMemTrack->m_AllocNumber = g_nAllocations;
		ptr += sizeof(MemTrack);
	#endif

	++g_nAllocations;
	++g_nTotalAllocations;

	return ptr;
	
}
Esempio n. 26
0
static void dsi_GetDLLModes(char *pDLLName, RMode **pMyList) {
    RMode *pMyMode;
    RMode *pListHead, *pCur;

    pListHead = rdll_GetSupportedModes();
    
    // Copy the mode list.
    pCur = pListHead;
    while (pCur)
    {
        LT_MEM_TRACK_ALLOC(pMyMode = (RMode*)dalloc(sizeof(RMode)),LT_MEM_TYPE_MISC);
        memcpy(pMyMode, pCur, sizeof(RMode));

        pMyMode->m_pNext = *pMyList;
        *pMyList = pMyMode;
        
        pCur = pCur->m_pNext;
    }                       

    rdll_FreeModeList(pListHead);
}
Esempio n. 27
0
//called to allocate a string. This will allocate the characters, the string, and handle copying
//them over
bool CTextureString::AllocateString(const wchar_t* pszString)
{
	//make sure we don't already have a string allocated
	FreeString();

	if(!pszString)
		return false;

	//we now want to create a string using the other string as a base. This is done by first allocating
	//our characters, matching them to the appropriate glyphs, and then ordering them
	m_nNumCharacters = LTStrLen(pszString);

	//allocate our main memory block
	uint32 nMemBlockSize = 0;
	nMemBlockSize += AlignAllocSize(sizeof(CTextureStringChar) * m_nNumCharacters);
	nMemBlockSize += AlignAllocSize(sizeof(wchar_t) * m_nNumCharacters + 1);
	
	uint8* pMemBlock;
	LT_MEM_TRACK_ALLOC(pMemBlock = new uint8[nMemBlockSize], MEMORY_CATEGORY);
	if(!pMemBlock)
	{
		FreeString();
		return false;
	}

	CMemBlockAllocator Allocator(pMemBlock, nMemBlockSize);

	//allocate the new buffer of characters
	m_pCharacters = Allocator.AllocateObjects<CTextureStringChar>(m_nNumCharacters);
	m_pszString = Allocator.AllocateObjects<wchar_t>(m_nNumCharacters + 1);

	LTStrCpy(m_pszString, pszString, m_nNumCharacters + 1);

	//sanity check on our memory block
	if ( !(Allocator.GetAllocationOffset() == Allocator.GetBlockSize()))
		ASSERT(!"Error: Incorrect usage of texture string memory block");

	//success
	return true;
}
Esempio n. 28
0
LTRESULT CLTCursor::LoadCursorBitmapResource(const char *pName, HLTCURSOR &hCursor)
{
    HINSTANCE hInst;
    LTRESULT dRes;
    HCURSOR hWinCursor;
    HLTCURSOR hNew;

    if ((dRes = ilt_client->GetEngineHook("cres_hinstance",(void **)&hInst)) != LT_OK)
        return dRes;

    hWinCursor = (HCURSOR)(::LoadImage(hInst, pName, IMAGE_CURSOR, 0, 0, LR_DEFAULTCOLOR));

    if (!hWinCursor)
        return LT_MISSINGCURSORRESOURCE;

    LT_MEM_TRACK_ALLOC(hNew = new CLTCursorInst(),LT_MEM_TYPE_MISC);

    hNew->SetData((void *)hWinCursor);
    hCursor = hNew;

    return LT_OK;
}
Esempio n. 29
0
//  ---------------------------------------------------------------------------
CUIList_Impl::CUIList_Impl(CUIBase* abstract, CUIGUID guid) :
	CUIWidget_Impl(abstract, guid)
{
	m_pFont = NULL;
	LT_MEM_TRACK_ALLOC(m_pList = new CUILinkList(),LT_MEM_TYPE_UI);

	m_pTextColors[0] = 
		m_pTextColors[1] = 
			m_pTextColors[2] = 
				m_pTextColors[3] = CUI_DEFAULT_FONT_COLOR | CUI_SYSTEM_OPAQUE;

	m_pSelectedColors[0] = 
		m_pSelectedColors[1] = 
			m_pSelectedColors[2] = 
				m_pSelectedColors[3] = (~CUI_DEFAULT_FONT_COLOR) | CUI_SYSTEM_OPAQUE;

	m_CharHeight	= 0;

	m_ItemCount = 0;
	m_Selection = -1;
	m_WindowStart = 0;
}
Esempio n. 30
0
void CMapWordToPtr::InitHashTable(
	uint16 nHashSize, LTBOOL bAllocNow)
//
// Used to force allocation of a hash table or to override the default
//   hash table size of (which is fairly small)
{
	ASSERT(m_nCount == 0);
	ASSERT(nHashSize > 0);

	if (m_pHashTable != LTNULL)
	{
		// free hash table
		delete[] m_pHashTable;
		m_pHashTable = LTNULL;
	}

	if (bAllocNow)
	{
		LT_MEM_TRACK_ALLOC(m_pHashTable = new CAssoc* [nHashSize],LT_MEM_TYPE_MISC);
		memset(m_pHashTable, 0, sizeof(CAssoc*) * nHashSize);
	}
	m_nHashTableSize = nHashSize;
}