void ESMWriter::endRecord (uint32_t name) { std::string type; for (int i=0; i<4; ++i) /// \todo make endianess agnostic type += reinterpret_cast<const char *> (&name)[i]; endRecord (type); }
void ESMWriter::save(std::ostream& file) { mRecordCount = 0; mRecords.clear(); mCounting = true; mStream = &file; startRecord("TES3", 0); mHeader.save (*this); endRecord("TES3"); }
void ESMWriter::writeHNString(const std::string& name, const std::string& data, size_t size) { assert(data.size() <= size); startSubRecord(name); writeHString(data); if (data.size() < size) { for (size_t i = data.size(); i < size; ++i) write("\0",1); } endRecord(name); }
/* UndoManager::beginRecord * Begins 'recording' a new undo level *******************************************************************/ void UndoManager::beginRecord(string name) { // Can't if currently in an undo/redo operation if (undo_running) return; // Set this as the current undo manager current_undo_manager = this; // End current recording if any if (current_level) endRecord(true); // Begin new UndoLevel //wxLogMessage("Recording undo level \"%s\"", name); current_level = new UndoLevel(name); }
void ESMWriter::save(std::ostream& file) { m_recordCount = 0; m_stream = &file; startRecord("TES3", 0); m_header.records = 0; writeHNT("HEDR", m_header, 300); m_headerPos = m_stream->tellp() - (std::streampos)4; for (std::list<MasterData>::iterator it = m_masters.begin(); it != m_masters.end(); ++it) { writeHNCString("MAST", it->name); writeHNT("DATA", it->size); } endRecord("TES3"); }
void ESMWriter::writeHNString(const std::string& name, const std::string& data) { startSubRecord(name); writeHString(data); endRecord(name); }
LocalController::~LocalController() { endRecord(); }
bool LocalController::process() { if(state == StateWeaponSelection) { if(ws->processFrame()) changeState(StateGame); } else if(state == StateGame || state == StateGameEnded) { int realFrameSkip = inverseFrameSkip ? !(cycles % frameSkip) : frameSkip; for(int i = 0; i < realFrameSkip && (state == StateGame || state == StateGameEnded); ++i) { int phase = game.cycles % 2; for (std::size_t i = 0; i < game.worms.size(); ++i) { Worm& worm = *game.worms[(i + phase) % game.worms.size()]; if(worm.ai.get()) { uint64_t time = gvl::get_hires_ticks(); worm.ai->process(game, worm); time = gvl::get_hires_ticks() - time; game.statsRecorder->aiProcessTime(&worm, time); } } if(replay.get()) { try { replay->recordFrame(); } catch(std::runtime_error& e) { Console::writeWarning(std::string("Error recording replay frame: ") + e.what()); Console::writeWarning("Replay recording aborted"); replay.reset(); } } game.processFrame(); if(game.isGameOver()) { changeState(StateGameEnded); } } } //CommonController::process(); if(goingToMenu) { if(fadeValue > 0) fadeValue -= 1; else { if(state == StateGameEnded) { endRecord(); game.statsRecorder->finish(game); // TODO: Get rid of cast. presentStats(static_cast<NormalStatsRecorder&>(*game.statsRecorder), game); } return false; } } else { if(fadeValue < 33) { fadeValue += 1; } } return true; }
void writeHNT(const std::string& name, const T& data, int size) { startSubRecord(name); writeT(data, size); endRecord(name); }
void writeHNCString(const std::string& name, const std::string& data) { startSubRecord(name); writeHCString(data); endRecord(name); }
ReplayWriter::~ReplayWriter() { endRecord(); }