ALERROR WriteHeader (CTDBCompiler &Ctx, int iGameFile, CDataFile &Out) { ALERROR error; CMemoryWriteStream Stream; if (error = Stream.Create()) { Ctx.ReportError(CONSTLIT("Out of memory")); return error; } // Write it CString sError; if (!Ctx.WriteHeader(Stream, iGameFile, &sError)) { Ctx.ReportError(strPatternSubst(CONSTLIT("Unable to write header: %s"), sError)); return ERR_FAIL; } // Write out the header Stream.Close(); CString sData(Stream.GetPointer(), Stream.GetLength(), TRUE); int iEntry; if (error = Out.AddEntry(sData, &iEntry)) { Ctx.ReportError(CONSTLIT("Unable to write header")); return error; } Out.SetDefaultEntry(iEntry); return NOERROR; }
ALERROR WriteHeader (int iGameFile, CSymbolTable &Resources, CDataFile &Out) { ALERROR error; CMemoryWriteStream Stream; DWORD dwSave; if (error = Stream.Create()) { printf("Out of memory\n"); return error; } // Signature dwSave = TDB_SIGNATURE; Stream.Write((char *)&dwSave, sizeof(dwSave)); // Version dwSave = TDB_VERSION; Stream.Write((char *)&dwSave, sizeof(dwSave)); // Game file entry dwSave = iGameFile; Stream.Write((char *)&dwSave, sizeof(dwSave)); // Game title CString sGameTitle = CONSTLIT("Transcendence: The March of the Heretic"); sGameTitle.WriteToStream(&Stream); // Resource map CString sSave; if (error = CObject::Flatten(&Resources, &sSave)) { printf("Unable to flatten resources map\n"); return error; } sSave.WriteToStream(&Stream); // Write out the header Stream.Close(); CString sData(Stream.GetPointer(), Stream.GetLength(), TRUE); int iEntry; if (error = Out.AddEntry(sData, &iEntry)) { printf("Unable to write out header\n"); return error; } Out.SetDefaultEntry(iEntry); return NOERROR; }
void CopyGameStatsToClipboard (HWND hWnd, const CGameStats &GameStats) // CopyGameStatsToClipboard // // Copy the game stats to the clipboard { CMemoryWriteStream Output; if (Output.Create() != NOERROR) return; GameStats.WriteAsText(&Output); // Terminate Output.Write("\0", 1); // Copy uiCopyTextToClipboard(hWnd, CString(Output.GetPointer(), Output.GetLength(), TRUE)); Output.Close(); }