/*! * AbStatusIO * * * Saves and loads the game status * * Copyright (c) 2007 by OneManBand Software */ #include "StdAfx.h" #include "tuonolib.h" #include "AbStatusIO.h" extern TuCoreServer* tu; AbStatusIO::AbStatusIO(void) { } AbStatusIO::~AbStatusIO(void) { } void AbStatusIO::DataWrite_Start(AbIODevice* i) { i->SaveString("Default Tuono Status I/O file. Version 1"); } void AbStatusIO::DataRead_Start(AbIODevice* i) { i->LoadString(); //skip header } void AbStatusIO::WriteData(AbIODevice* i,TuSaveEnabledObject* obj) { i->SaveString(""); i->SaveString(obj->GetObjectID()->GetStringID() ); // now save obj->Save(i); i->SaveString(""); } AbstractedObject* AbStatusIO::ReadData(AbIODevice* i) { std::string check = i->LoadString(); if ( check=="" || i->EndOfFile()) { return NULL; } // get the game to read meta data and create the appropriate object TuSaveEnabledObject* b = NULL; check = i->LoadString(); /// we're safe to dodgy casts here, since the object couldn't of // saved if it wasn't TuSaveEnabledObject* b = (TuSaveEnabledObject*) tu->GetObjectFactory()->CreateObject(check); if (b!=NULL) { // now load b->Load(i); } i->LoadString(); AbstractedObject* a = (AbstractedObject*)b; return a; } void AbStatusIO::DataWrite_Terminate(AbIODevice* i) { i->SaveString(""); } void AbStatusIO::DataRead_Terminate(AbIODevice* i) { // nothing }