diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 637af42..6845635 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index 78213e9..e57dbd3 100644 --- a/main.cpp +++ b/main.cpp @@ -1474,6 +1474,9 @@ void SeasonI::keyUpdates() { if (GetKey(F6).bPressed) { SaveGameSaveData(0); } + if (GetKey(F7).bPressed) { + LoadGameSaveData(0); + } if (GetKey(O).bPressed) { StartEffect(FOUNTAIN_EFFECT); @@ -5229,65 +5232,73 @@ void SeasonI::SaveGameSaveData(int saveSlot) { int SeasonI::ReadIntFromStream(std::ifstream&f) { int temp; f>>temp; + printf("READ %d\n",temp); return temp; }; float SeasonI::ReadFloatFromStream(std::ifstream&f) { float temp; f>>temp; + printf("READ %f\n",temp); return temp; }; double SeasonI::ReadDoubleFromStream(std::ifstream&f) { double temp; f>>temp; + printf("READ %lf\n",temp); return temp; }; std::string SeasonI::ReadStringFromStream(std::ifstream&f) { std::string temp; f>>temp; + printf("READ %s\n",temp.c_str()); return temp; }; void SeasonI::LoadGameSaveData(int saveSlot) { std::ifstream file("save"+std::to_string(saveSlot)); + std::array positions={vd2d{0,0}}; + int playerCount=0; for (int i=PLAYER;i<7;i++) { PARTY_MEMBER_STATS[i]->_SetDirectHP(ReadIntFromStream(file)); PARTY_MEMBER_STATS[i]->stats.maxHP=ReadIntFromStream(file); + std::string memberName=ReadStringFromStream(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}); + PARTY_MEMBER_STATS[i]->obj->name=memberName; + } + 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 j=0;jstats.resistances[j]=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 j=0;jmoveSet.push_back(MOVELIST[(BattleMoveName)ReadIntFromStream(file)]); + } + int statusEffectsSize=ReadIntFromStream(file); + PARTY_MEMBER_STATS[i]->statusEffects.clear(); + for (int j=0;jstatusEffects[(Property)ReadIntFromStream(file)]=ReadIntFromStream(file); + } + int equipmentSize=ReadIntFromStream(file); + for (int j=0;jequipment[j]=ITEMLIST[(ItemName)equipID]; } } + double xPos=ReadDoubleFromStream(file); + double yPos=ReadDoubleFromStream(file); + if (PARTY_MEMBER_STATS[i]->obj!=nullptr) { + PARTY_MEMBER_STATS[i]->obj->SetPos({xPos,yPos}); + positions[playerCount++]={xPos,yPos}; + } } int inventorySize=ReadIntFromStream(file); PARTY_INVENTORY.clear(); @@ -5300,6 +5311,9 @@ void SeasonI::LoadGameSaveData(int saveSlot) { } CURRENT_MAP=MAPS[(MapName::Map)ReadIntFromStream(file)]; LoadMap(CURRENT_MAP); + for (int i=0;iSetPos(positions[i]); + } } #ifndef TEST_SUITE diff --git a/object.cpp b/object.cpp index de65900..f439e7d 100644 --- a/object.cpp +++ b/object.cpp @@ -2,6 +2,7 @@ extern std::vector OBJECTS; +//Moves an object relative to its current position. void Object::Move(vd2d move) { if (move.y==0) { pos+=move; diff --git a/save0 b/save0 index 9c4376d..ce7b5de 100644 --- a/save0 +++ b/save0 @@ -1 +1 @@ -120 120 PLAYER 30 30 8 8 4 0 0 0 0 0 0 0 11 9 10 13 14 15 16 17 33 29 21 25 1 6 4 3 -1 -1 -1 343 200 120 120 NESS 30 30 8 8 4 0 0 0 0 0 0 0 6 33 34 29 30 31 32 0 3 -1 -1 -1 343 200 120 120 PAULA 30 30 8 8 4 0 0 0 0 0 0 0 6 21 22 23 24 37 38 0 3 -1 -1 -1 343 200 120 120 JEFF 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 120 120 ANNA 30 30 8 8 4 0 0 0 0 0 0 0 4 21 25 26 29 0 3 -1 -1 -1 343 200 120 120 KING 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 120 120 POO 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 67 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ No newline at end of file +120 120 PLAYER 30 30 8 8 4 0 0 0 0 0 0 0 11 9 10 13 14 15 16 17 33 29 21 25 1 6 4 3 -1 -1 -1 147 231 120 120 NESS 30 30 8 8 4 0 0 0 0 0 0 0 6 33 34 29 30 31 32 0 3 -1 -1 -1 150 259 120 120 PAULA 30 30 8 8 4 0 0 0 0 0 0 0 6 21 22 23 24 37 38 0 3 -1 -1 -1 138 261 120 120 JEFF 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 48 0 ANNA 30 0 0 0 4 0 0 0 0 0 0 0 0 0 3 -1 -1 -1 126 273 0 0 KING 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 0 0 POO 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 0 512 1 0 0 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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