void CDirectInputDetail::Dump(void) { CChars sz; sz.Init(); sz.Append("Joystick "); sz.Append(": "); sz.Append(szID); sz.AppendNewLine(); sz.Dump(); sz.Kill(); }
BOOL PrivateAssertNumber(char* szExpected, CNumber* pcActual, int iLine, char* szFile) { CNumber* pcExpected; CChars szExpectedAsChars; CChars szActual; CChars szFake; int iIndex; int iDecimals; BOOL bResult; szFake.Fake(szExpected); iIndex = szFake.Find(0, '.'); if (iIndex != -1) { iDecimals = szFake.Length() - iIndex; } else { iDecimals = 0; } pcExpected = gcNumberControl.Add(pcActual->mcMaxWholeNumbers, iDecimals); pcExpected->Init(szExpected, pcActual->mcMaxWholeNumbers, iDecimals); if (!pcExpected->Equals(pcActual)) { pcExpected->ToString(&szExpectedAsChars); pcActual->ToString(&szActual); bResult = Fail(szExpectedAsChars.Text(), szActual.Text(), iLine, szFile); szExpectedAsChars.Kill(); szActual.Kill(); } else { bResult = Pass(); } gcNumberControl.Remove(); return bResult; }
CInputVirtualDeviceDesc* CInputDeviceDesc::CreateDefaultVirtualDesc(void) { CInputVirtualDeviceDesc* pcVirtualDesc; SSetIterator sIter; CInputSourceDesc* pcSourceDesc; CInputDevices* pcInputDevices; CChars szTemp; pcInputDevices = GetInputDevices(); szTemp.Init(mszFriendlyName.Text()); szTemp.Append(" Default"); pcVirtualDesc = pcInputDevices->CreateVirtualDeviceDescription(szTemp.Text(), TRUE); szTemp.Kill(); pcSourceDesc = mlcInputs.StartIteration(&sIter); while (pcSourceDesc) { pcVirtualDesc->AddSource(pcSourceDesc, -1); pcSourceDesc = mlcInputs.Iterate(&sIter); } return pcVirtualDesc; }
void CChars::Fake(char* sz, int iStartInclusive, int iEndExclusive) { char* pcPosition; if (iEndExclusive - iStartInclusive > 0) { pcPosition = (char*)RemapSinglePointer(sz, iStartInclusive); mcText.Fake(pcPosition, iEndExclusive - iStartInclusive + 1); } else { mcText.Fake(gszEmptyString.Text(), 1); } }
void CLogger::Error2(char* szText, ...) { va_list vaMarker; char* sz; CChars szError; if (szText) { szError.Init(szText); va_start(vaMarker, szText); sz = va_arg(vaMarker, char*); while (sz != NULL) { szError.Append(sz); sz = va_arg(vaMarker, char*); } va_end(vaMarker); Error(szError.Text()); szError.Kill(); } else {
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// void CCBlockSet::DumpRawTokens(void) { CChars sz; int iLast; iLast = 0; sz.Init(); if (mbTextBlocks) { sz.Append("/* ------- text "); sz.Append(miLine); sz.Append(" ------- */\n"); } else { sz.Append("/* ---- #directive "); sz.Append(miLine); sz.Append(" ---- */\n"); } mcRawTokens.Append(&sz); sz.Dump(); sz.Kill(); }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// BOOL CPreprocessor::ProcessHashInclude(CPreprocessorTokenParser* pcParser) { BOOL bResult; CHeaderFile* pcIncludeFile; CExternalString cExternalString; CChars sz; CHeaderNameMap* pcHeaderNameMap; CHeaderNameMapDirectory* pcNewDirectory; CHeaderNameMapDirectory* pcCurrentDirectory; CChars szPath; pcParser->SkipWhiteSpace(); bResult = pcParser->GetStringDoubleQuoted(&cExternalString); if (!bResult) { bResult = pcParser->GetQuotedCharacterSequence('<', '>', &cExternalString); if (!bResult) { gcUserError.Set("Error in #include"); return FALSE; } } FindBestInclude(&cExternalString, FALSE, &pcIncludeFile, &pcHeaderNameMap); if (pcIncludeFile) { pcNewDirectory = mcHeadersStack.Add(); pcCurrentDirectory = mcHeadersStack.Get(mcHeadersStack.NumElements()-2); pcIncludeFile->Path(&szPath); pcNewDirectory->Init(pcHeaderNameMap, szPath.Text()); szPath.Kill(); bResult = PreprocessBlockSets(pcIncludeFile, mpcCurrentFile); pcNewDirectory = mcHeadersStack.Tail(); pcNewDirectory->Kill(); mcHeadersStack.Pop(); return bResult; } sz.Init("Could not include file "); sz.AppendSubString(cExternalString.msz, cExternalString.EndInclusive()+1); gcUserError.Set(sz.Text()); sz.Kill(); return FALSE; }
void TestFileUtilMisc(void) { CFileUtil cFileUtil; BOOL bResult; CChars szPath; szPath.Init("TestFileUtil"); bResult = cFileUtil.MakeDir(szPath.Text()); AssertTrue(bResult); cFileUtil.AppendToPath(&szPath, "FileOfDoom.Indiana"); bResult = cFileUtil.Touch(szPath.Text()); AssertTrue(bResult); bResult = cFileUtil.Exists(szPath.Text()); AssertTrue(bResult); cFileUtil.RemoveLastFromPath(&szPath); cFileUtil.AppendToPath(&szPath, "AnotherDir"); bResult = cFileUtil.MakeDir(szPath.Text()); AssertTrue(bResult); cFileUtil.RemoveLastFromPath(&szPath); cFileUtil.AppendToPath(&szPath, "Master.Chief"); bResult = cFileUtil.Touch(szPath.Text()); AssertTrue(bResult); bResult = cFileUtil.Delete(szPath.Text()); AssertTrue(bResult); bResult = cFileUtil.Exists(szPath.Text()); AssertFalse(bResult); cFileUtil.RemoveLastFromPath(&szPath); cFileUtil.RemoveDir(szPath.Text()); }
void ToPointerString(void* pv, char* sz) { CChars c; IToA((int)(ENGINE_SIZE_T)pv, sz, 16); c.Init(sz); c.RightAlign('0', 8); c.Insert(0, "0x"); strcpy(sz, c.Text()); c.Kill(); }
void CNamedIndexesBlock::Dump(void) { CArrayBlock avFakeBlock; CChars szText; if (IsCached()) { avFakeBlock.Fake(miBlockWidth, mpvCachePos, (int)miUsedBlocks, (int)miBlockChunkSize); Dump(&avFakeBlock); } else { szText.Init("--- Block(Not Cached) ---\n"); szText.Append("("); szText.Append(mszFirst.Text()); szText.Append(") -> ("); szText.Append(mszLast.Text()); szText.Append(")\n\n"); szText.Dump(); szText.Kill(); } }
void PrivateBeginTests(char* szFile) { CChars sz; giTestsRun = 0; giTestsPassed = 0; giTestsFailed = 0; sz.Init(); sz.Append("--------------- "); sz.Append(szFile); sz.Append(" ---------------\n"); gcLogger.Add(sz.Text()); sz.Kill(); }
BOOL CMeshConverter::CreateLinkNodes(void) { int i; CConnection* pcConnection; SFloat4x4* psWorldMatrix; SFloat4x4* psMatrix; float fDeterminant; CMeshObjectNode* pcLinkNode; int iConnectionIndex; //Link nodes are created here so that the reference meshes matricies can be whatevered. mpcConnectionsAndIndices->Get(0, (void**)&pcConnection, &iConnectionIndex); if (pcConnection) { psWorldMatrix = (SFloat4x4*)&pcConnection->msWorldMatrix; for (i = 1; i < mpcConnectionsAndIndices->NumElements(); i++) { mpcConnectionsAndIndices->Get(i, (void**)&pcConnection, &iConnectionIndex); psMatrix = (SFloat4x4*)&pcConnection->msWorldMatrix; if (i == 1) { pcLinkNode = mpcMeshObject->GetNodes()->InsertBeforeHead(); } else { pcLinkNode = mpcMeshObject->GetNodes()->InsertAfterNode(pcLinkNode); } pcLinkNode->psToSubObjectSpaceFromZeroSpace = mpcSceneConverter->GetWorld()->CreateMatrix(); pcLinkNode->psToZeroSpaceFromSubObjectSpace = mpcSceneConverter->GetWorld()->CreateMatrix(); if (Float4x4Inverse(&pcLinkNode->psToSubObjectSpaceFromZeroSpace->sD3DMatrix, &fDeterminant, psMatrix) == NULL) { gcUserError.Set("Matrix has no inverse"); return FALSE; } } return TRUE; } else { CChars sz; sz.Init("The Mesh ["); sz.Append(mpcMesh->GetName()); sz.Append("] has no Connection (root node matrix)."); gcUserError.Set(sz.Text()); sz.Kill(); return FALSE; } }
BOOL CImageCelsSourceXML::ImportCelSource(CMarkupTag* pcBrushSourceTag, char* szTexturePath) { CMarkupTag* pcFileName; CChars szFileName; CChars szShortFileName; BOOL bResult; CMarkupTag* pcCels; CFileUtil cFileUtil; pcFileName = CMarkupTextParser::GetTag(pcBrushSourceTag, "FileName"); if (!pcFileName) { return FALSE; } szShortFileName.Init(); pcFileName->GetText(&szShortFileName); if (szFileName.Empty()) { szShortFileName.Kill(); CMarkupTextParser::LogErrorTagWasEmpty(pcBrushSourceTag); return FALSE; } pcCels = CMarkupTextParser::GetTag(pcBrushSourceTag, "Cels"); if (!pcCels) { szShortFileName.Kill(); return FALSE; } szFileName.Init(szTexturePath); cFileUtil.AppendToPath(&szFileName, szShortFileName.Text()); bResult = ImportCels(pcCels, szFileName.Text()); return bResult; }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// void CPreprocessor::LogIncludes(CCFile* pcFile) { CChars sz; if (mbLogInlucdes) { sz.Init(); sz.Append(' ', miIncludeDepth*4); sz.Append(" "); sz.Append(pcFile->ShortName()); sz.Append("\n"); if (mbDumpLogs) { sz.Dump(); } mpszIncludesLog->Append(sz); sz.Kill(); } }
void CWindow::EndingWinloop(char* szReason) { CChars szShutdown; mcLoopTimer.Update(); szShutdown.Init("Shutdown winloop ["); szShutdown.Append(szReason); szShutdown.Append("] - "); mcLoopTimer.HumanReadable(&szShutdown); mcLoopTimer.Kill(); szShutdown.AppendNewLine(); gcLogger.Add(szShutdown.Text()); }
void CEmbeddedObject::ValidatePointerTo(CEmbeddedObject* pcPointedTo) { CChars szObject; CChars szToObject; BOOL bToPointsToFrom; bToPointsToFrom = pcPointedTo->ContainsFrom(this); if (!bToPointsToFrom) { szObject.Init(); PrintObject(&szObject, IsEmbedded()); szToObject.Init(); pcPointedTo->PrintObject(&szToObject, pcPointedTo->IsEmbedded()); gcLogger.Error2(__METHOD__, " Object {", szObject.Text(), "} pointing to object {", szToObject.Text(), "} does not have a from pointing to.", NULL); szToObject.Kill(); szObject.Kill(); } }
void CObjects::ValidateEmpty(void) { OIndex iNumIndexed; iNumIndexed = mcMemory.NumIndexed(); if (iNumIndexed != 0) { CChars sz; sz.Init("\n"); sz.Append("Memory not empty. "); sz.Append(iNumIndexed); sz.Append(" objects are still indexed.\n"); PrintMemory(&sz); gcLogger.Error(sz.Text()); sz.Kill(); } }
void CInputDeviceDesc::Dump(void) { CTextFile cFile; CChars szName; cFile.Init(); ToString(&cFile.mcText); szName.Init("../"); szName.Append(mszFriendlyName.Text()); szName.Append(".txt"); cFile.Write(szName.Text()); szName.Kill(); cFile.Kill(); }
void CBaseObject::ValidateInitCalled(void) { CChars szObject; if (miPreInits != miPostInits) { szObject.Init(); PrintObject(&szObject, IsEmbedded()); gcLogger.Error2(__METHOD__, " Object {", szObject.Text(), "} has pre-inits [", IntToString(miPreInits), "] not equal to post inits [", IntToString(miPostInits), "].", NULL); szObject.Kill(); } else if (miPreInits == 0) { szObject.Init(); PrintObject(&szObject, IsEmbedded()); gcLogger.Error2(__METHOD__, " Object {", szObject.Text(), "} has a pre-init of zero.", NULL); szObject.Kill(); } }
BOOL PrivateAssertFileMemory(char* szExpectedFileName, void* pcMemory, int iLength, int iLine, char* szFile) { CFileCompare cCompare; BOOL bResult; CChars szExpected; CChars szActual; szExpected.Init(); szActual.Init(); bResult = cCompare.Compare(szExpectedFileName, pcMemory, iLength, &szExpected, &szActual); if (!bResult) { bResult = Fail(szExpected.Text(), szActual.Text(), iLine, szFile); szActual.Kill(); szExpected.Kill(); return bResult; } else { return Pass(); } }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// void CArrayString::Dump(void) { int i; CChars* psz; CChars sz; sz.Init(1024); for (i = 0; i < mcArray.NumElements(); i++) { psz = mcArray.Get(i); sz.Append(psz); sz.AppendNewLine(); } sz.Dump(); sz.Kill(); }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// void CPreprocessor::ProcessHashError(CPreprocessorTokenParser* pcParser) { CChars szError; CPPToken* pcToken; pcParser->SkipWhiteSpace(); szError.Init("Error ("); szError.Append(mpcCurrentFile->ShortName()); szError.Append("):"); while (pcParser->HasToken()) { pcToken = pcParser->GetToken(); pcToken->Append(&szError); pcParser->NextToken(); } szError.AppendNewLine(); szError.Dump(); szError.Kill(); }
CTranslationUnit* CTranslationUnitFileArray::AddFile(char* szRelativeFileName, BOOL bLogIncludes, BOOL bLogBlocks) { CChars szTemp; CTranslationUnit* pcTranslationUnit; CTranslationUnit cTranslationUnit; szTemp.Init(mpcLibrary->mszBaseDir); szTemp.Append(FILE_SEPARATOR); szTemp.Append(szRelativeFileName); cTranslationUnit.Init(8, szTemp.Text(), mpcLibrary, bLogIncludes, bLogBlocks); szTemp.Kill(); pcTranslationUnit = mcFiles.InsertAfterTail(); memcpy(pcTranslationUnit, &cTranslationUnit, sizeof(CTranslationUnit)); pcTranslationUnit->macBlockSets.mpcFile = pcTranslationUnit; return pcTranslationUnit; }
void CConfig::AddDefines(char* szDefines) { CChars szTemp; CArrayString aszTemp; int i; CChars* pszDefine; szTemp.Init(szDefines); aszTemp.Init(16); szTemp.Split(&aszTemp, ';'); for (i = 0; i < aszTemp.NumElements(); i++) { pszDefine = aszTemp.Get(i); pszDefine->StripWhiteSpace(); AddDefine(pszDefine->Text()); } szTemp.Kill(); aszTemp.Kill(); }
void TestFileSystemIteration(void) { CFileSystem cFileSystem; CFileSystemIterator cIter; CSystemFileNode* pcSystemFile; CChars szName; int i; CArrayChars aszExpected; CChars* pszExpected; aszExpected.Init(); aszExpected.AddList("Models/Super/Barbie.txt", "Models/Super/Ken.txt", "Models/Cars.txt", "Sounds/Santa/Seattle.txt", "Sounds/Ambient.txt", "Sounds/Cheese.PAK", "Sounds/Santa.PAK", "Videos/Intro.txt", "Videos/Outro.txt", "Models.PAK", "Sounds.PAK", "Textures.PAK", "Videos.PAK", NULL); cFileSystem.Init("Game"); i = 0; pcSystemFile = cFileSystem.StartIteration(&cIter); while (pcSystemFile) { szName.Init(); pcSystemFile->GetFullName(&szName); pszExpected = aszExpected.Get(i); AssertString(pszExpected->Text(), szName.Text()); szName.Kill(); i++; pcSystemFile = cFileSystem.Iterate(&cIter); } aszExpected.Kill(); }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// CPPToken* CPreprocessor::ConcaternateTokens(CPPTokenHolder* pcDest, CPPToken* pcLeft, CPPToken* pcRight) { CPPText* pcLeftText; CPPText* pcRightText; CChars szConcaternated; char* szInStrings; if (pcLeft->IsText() && pcRight->IsText()) { pcLeftText = (CPPText*)pcLeft; pcRightText = (CPPText*)pcRight; if (((pcLeftText->meType == PPT_Identifier) && (pcRightText->meType == PPT_Identifier)) || ((pcLeftText->meType == PPT_Number) && (pcRightText->meType == PPT_Number))) { szConcaternated.Init(100); pcLeftText->Append(&szConcaternated); pcRightText->Append(&szConcaternated); szInStrings = (char*)gcTokenStrings.Add(szConcaternated.Length()+1); memcpy(szInStrings, szConcaternated.Text(), szConcaternated.Length()+1); pcLeftText->mcText.msz = szInStrings; pcLeftText->mcText.miLen = szConcaternated.Length(); szConcaternated.Kill(); return pcLeft; } else { pcDest->Add(&pcRight); return pcRight; } } return pcLeft; }
BOOL CChars::AppendData2(const char* szData, int iDataLength) { int i; int iPrintable; unsigned char c; float fPrintable; CChars sz; iPrintable = StrPrintable(szData, iDataLength); fPrintable = (float)iPrintable / (float)iDataLength; if (fPrintable >= 0.9f) { Append(szData, iDataLength); return FALSE; } else { Append("0x"); sz.Init(); for (i = 0; i < iDataLength; i++) { c = szData[i]; sz.Clear(); sz.Append((int)c, 16); sz.RightAlign('0', 2); Append(sz); if (i != iDataLength - 1) { Append(' '); } } sz.Kill(); } return TRUE; }
void CChars::Dump(void) { CChars sz; int i; if (Length() <= 10000) { if (Length() > 0) { EngineOutput(Text()); } return; } for (i = 0; i < Length()-10000; i+=10000) { sz.Init(Text(), i, i+10000); EngineOutput(sz.Text()); sz.Kill(); } sz.Init(Text(), i, Length()); EngineOutput(sz.Text()); sz.Kill(); }
int CCSVHelper::GetColumnIndex(char* szName) { SCSVRowImmutable* pcRow; int i; char* szHeader; CChars sz; pcRow = mcFile.Get(0); for (i = 0; i < pcRow->iNumFields; i++) { szHeader = pcRow->Get(i); sz.Init(szHeader); sz.StripWhiteSpace(); if (sz.EqualsIgnoreCase(szName)) { sz.Kill(); return i; } sz.Kill(); } return -1; }
void* CMemory::Add(unsigned int uiSize, int iAlignment, int iOffset) { CFreeList* pcFreeList; void* pv; if ((mbBreakOnAlloc) && (muiAllocCount == muiBreakAlloc)) { CChars sz; sz.Init("CMemory::Add: muiAllocCount == "); sz.Append(muiBreakAlloc); sz.AppendNewLine(); sz.Dump(); sz.Kill(); Break(); } if (uiSize == 0) { muiAllocCount++; return NULL; } if (uiSize <= (muiFreeListSizeLimit - sizeof(SMemoryAllocation))) { pcFreeList = GetOrAddFreeList(uiSize, iAlignment, iOffset); pv = AllocateInFreeList(pcFreeList, uiSize); muiAllocCount++; return pv; } else { pv = AllocateInLargeList(uiSize, iAlignment, iOffset); muiAllocCount++; return pv; } }