Code: Show/Hide font.open("bin\\font.bat");
if (!font) { ... } font.close(); |
Code: Show/Hide pok.open("bin\\pokemon.a3"); |
Code: Show/Hide return main(); |
Code: Show/Hide if (!font)
{ ... } font.close(); |
Code: Show/Hide int newpokchoice;
cout<<"\n\nCongratulations!! "<<mpn<<" has beat "<<p3<<"!\n"; system("pause"); cout<<"\n\nWould you like to make get a new pokemon,\n"; cout<<"or just level up "<<mpn<<"? (1 = new pokemon, 0 = lvl up)\n\n"; cout<<"Enter your choice: "; cin>>newpokchoice; if (newpokchoice == 1) { cout<<"\n\n\n\nYou decided to get a new pokemon, and you got a \n"; cout<<"lvl "<<dmg4<<" "<<p4<<" who has "<<hp4<<"!\n"; cout<<"And will evolve into "<<evol4<<"!\n\n"; system("pause"); cout<<"\n\nWhat nickname would you like to give your "<<p4<<"?"; cin>>mpn; cout<<"\n\nYou nicknamed your "<<p4<<" "<<mpn<<"!\n"; system("pause"); ofstream sgame; sgame.open("bin\\savedgame.a3"); sgame<<p4<<endl; sgame<<hp4<<endl; sgame<<dmg4<<endl; sgame<<evol4<<endl; sgame<<mpn<<endl; sgame<<trainername<<endl; sgame.close(); cout<<"\n\nGame was saved with your new pokemon..."; system("pause"); } else if (newpokchoice == 0) { cout<<"\n\n\n\nYou decided to lvl up your "<<mpn<<".\n"; system("pause"); dmgmp = dmgmp + 1; hpmp = hpmp + 5; cout<<"\n\n Your "<<mpn<<"("<<mp<<") leved up to lvl"<<dmgmp<<"!"; cout<<"\n\nWholy Shit! Your "<<mp<<" evolved into "<<evolmp<<"!\n"; mp[80] = evolmp[80]; cout<<"\n\nWhat nickname would you like to give your "<<mp<<"?"; cout<<"\nAnswer: "; cin>>mpn; cout<<"\n\nYou nicknamed your "<<mp<<" "<<mpn<<"!\n\n"; system("pause"); ofstream sgame2; sgame2.open("bin\\savedgame.a3"); sgame2<<mp<<endl; sgame2<<hpmp<<endl; sgame2<<dmgmp<<endl; sgame2<<"(OOPS CANNOT EVOLVE ANYMORE, WILL JUST LVL UP)"<<endl; sgame2<<mpn<<endl; sgame2<<trainername<<endl; sgame2.close(); cout<<"\n\nGame Saved..."; system("pause"); } else { cout<<"\n\n\a\aPokeshit: You must enter only 2, 1 or 0 as your choice!!"; cout<<"\n\tSorry but in A3 Custom Pokemon if you enter wrong value game exits...\n\t"; cout<<"Hopefully in the next version this will be fixed..."; system("pause"); return 0; } |
Code: Show/Hide return newpokchoice; |
Code: Show/Hide return newpockchoice(); |
Quote: | |
Also in some places you don't test if a file opened correctly (customize.cpp)
|
Code: Show/Hide int choice;
do { cout << "1 = bla" << endl; cout << "9 = exit" << endl; cout << "your choice: "; cin >> choice; /* more stuff here */ } while (choice != 9); |
Quote: |
In pok.open("bin\\pokemon.a3") it doesn't read from pokemon.a3, it creates pokemon.a3, so if i would do the (!pok){} then it would show up with errors since the file wasn't created yet |
Code: Show/Hide int choice;
do { cout << "1 = bla" << endl; cout << "9 = exit" << endl; cout << "your choice: "; cin >> choice; /* more stuff here */ } while (choice != 9); |
Quote: |
It knows it's not trying to read from pokemon.a3 since pok is of type ofstream (output file stream). You still need to check if it opened the file correctly for writing. Reasons it might fail include being out of disk space or not having permission to write in that location. More commonly though, if the file already exists and is open in another program you won't be able to overwrite it. |