diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 752389a..637af42 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/SeasonI.h b/SeasonI.h index 0ed12d9..a0c4703 100644 --- a/SeasonI.h +++ b/SeasonI.h @@ -132,6 +132,10 @@ class SeasonI:public PixelGameEngine{ void DrawTriggers(); void SaveGameSaveData(int saveSlot); void LoadGameSaveData(int saveSlot); + int ReadIntFromStream(std::ifstream&f); + float ReadFloatFromStream(std::ifstream&f); + double ReadDoubleFromStream(std::ifstream&f); + std::string ReadStringFromStream(std::ifstream&f); }; extern SeasonI*GAME; #endif \ No newline at end of file diff --git a/main.cpp b/main.cpp index 8593f5b..78213e9 100644 --- a/main.cpp +++ b/main.cpp @@ -5226,8 +5226,80 @@ void SeasonI::SaveGameSaveData(int saveSlot) { file.close(); } +int SeasonI::ReadIntFromStream(std::ifstream&f) { + int temp; + f>>temp; + return temp; +}; +float SeasonI::ReadFloatFromStream(std::ifstream&f) { + float temp; + f>>temp; + return temp; +}; +double SeasonI::ReadDoubleFromStream(std::ifstream&f) { + double temp; + f>>temp; + return temp; +}; +std::string SeasonI::ReadStringFromStream(std::ifstream&f) { + std::string temp; + f>>temp; + return temp; +}; + void SeasonI::LoadGameSaveData(int saveSlot) { - + std::ifstream file("save"+std::to_string(saveSlot)); + for (int i=PLAYER;i<7;i++) { + PARTY_MEMBER_STATS[i]->_SetDirectHP(ReadIntFromStream(file)); + PARTY_MEMBER_STATS[i]->stats.maxHP=ReadIntFromStream(file); + if (PARTY_MEMBER_STATS[i]->obj!=nullptr) { + PARTY_MEMBER_STATS[i]->obj->name=ReadStringFromStream(file); + PARTY_MEMBER_STATS[i]->_SetDirectPP(ReadIntFromStream(file)); + PARTY_MEMBER_STATS[i]->stats.maxPP=ReadIntFromStream(file); + PARTY_MEMBER_STATS[i]->stats.baseAtk=ReadIntFromStream(file); + PARTY_MEMBER_STATS[i]->stats.speed=ReadIntFromStream(file); + int resistanceSize = ReadIntFromStream(file); + for (int i=0;istats.resistances[i]=ReadIntFromStream(file); + } + PARTY_MEMBER_STATS[i]->stats.damageReduction=ReadIntFromStream(file); + PARTY_MEMBER_STATS[i]->stats.smart=ReadIntFromStream(file)?true:false; + PARTY_MEMBER_STATS[i]->stats.dumb=ReadIntFromStream(file)?true:false; + int movesetSize=ReadIntFromStream(file); + PARTY_MEMBER_STATS[i]->moveSet.clear(); + for (int i=0;imoveSet.push_back(MOVELIST[(BattleMoveName)ReadIntFromStream(file)]); + } + int statusEffectsSize=ReadIntFromStream(file); + PARTY_MEMBER_STATS[i]->statusEffects.clear(); + for (int i=0;istatusEffects[(Property)ReadIntFromStream(file)]=ReadIntFromStream(file); + } + int equipmentSize=ReadIntFromStream(file); + for (int i=0;iequipment[i]=ITEMLIST[(ItemName)equipID]; + } + } + double xPos=ReadDoubleFromStream(file); + double yPos=ReadDoubleFromStream(file); + if (PARTY_MEMBER_STATS[i]->obj!=nullptr) { + PARTY_MEMBER_STATS[i]->obj->Move({xPos,yPos}); + } + } + } + int inventorySize=ReadIntFromStream(file); + PARTY_INVENTORY.clear(); + for (int i=0;i