Lesson 19 - save file not being created

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
Bumble
Posts: 3
Joined: March 30th, 2015, 9:22 am

Lesson 19 - save file not being created

Post by Bumble » March 30th, 2015, 9:48 am

firstly thanks so much to Chilli for creating a programming tutorial in plain english and for not going the "hello world!" approach too. it's nice to jump straight into putpixel calls. appreciated :)
--------------------------------------------------------------------------------------------------------

RE: PooFace Ex Alpha - file not being created

Using Visual Studio 2013 ( i think ) whatever the latest version is at this time

assuming this forum is still active, hopefully i can get some much needed advice

checked code many times. the game works and builds fine. no errors other than the warnings for using printf etc and not the safe versions.

can someone please help. i can't move on till i get this sorted and i really want to move on to the last few lessons and then the intermediate tutorials.

i had the same issue with the earlier part of the lesson using the console to create a file. i managed to resolve that finally by using "#pragma warning ( disable : 4996 )" but that doesn't help with this at all.

code included so if someone (anyone) has the patience to check it i would appreciate it.
Attachments
PooFace EA.zip
(187.73 KiB) Downloaded 177 times

nackles
Posts: 22
Joined: February 13th, 2015, 2:36 am

Re: Lesson 19 - save file not being created

Post by nackles » March 30th, 2015, 4:41 pm

the names of these games are killing me lol

Guilherme
Posts: 47
Joined: April 20th, 2014, 1:53 pm

Re: Lesson 19 - save file not being created

Post by Guilherme » March 30th, 2015, 6:41 pm

In my computer it compile, runs and creates a file in the \Pooface EX+alpha\Chili DirectX Framework folder named hiscore.txt. The problem that I see is that you are not opening your old score so it gets reseted everytime you play the game.

Bumble
Posts: 3
Joined: March 30th, 2015, 9:22 am

Re: Lesson 19 - save file not being created

Post by Bumble » April 5th, 2015, 10:55 am

hey there thanks for relying

do you know where the code is wrong? would you mind being specific? or mind posting your own code so i can compare?

i really want to get this sorted so i can move on.

all and any help appreciated

Bumble :)

cameron
Posts: 794
Joined: June 26th, 2012, 5:38 pm
Location: USA

Re: Lesson 19 - save file not being created

Post by cameron » April 5th, 2015, 3:07 pm

First off you aren't loading the scores anywhere. Second off you cant save your scores in the destructor. Game is closed before it saves; destructor is for releasing memory only.
Computer too slow? Consider running a VM on your toaster.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Lesson 19 - save file not being created

Post by albinopapa » April 5th, 2015, 7:12 pm

cameron wrote:First off you aren't loading the scores anywhere. Second off you cant save your scores in the destructor. Game is closed before it saves; destructor is for releasing memory only.

The code works the way it's suppose to. Having SaveScoreboard in the destructor is perfectly legal and makes sense. Game hasn't been fully released until the destructor has completed, same goes for the constructor, the object isn't fully instantiated until the constructor has completed, not just the initializer list, but the function body as well. Creating new variables in the destructor would be a bit rediculous, but cleaning up by saving mem to disk makes sense to me.

Anyway, these are your Scoreboard functions
void ClearScoreboard();
void InsertScore( HighScore score );
void SaveScoreboard();
HighScore GetScore();

You don't have a function for reading the file and loading the previously saved scoreboard. I haven't done these tutorials in a couple years, and not even sure I did them, may have just watched and moved on. Either way, go back and watch the video skip around to see if you missed something that mentions loading / reading a data back into memory, or just move ahead.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

cameron
Posts: 794
Joined: June 26th, 2012, 5:38 pm
Location: USA

Re: Lesson 19 - save file not being created

Post by cameron » April 5th, 2015, 7:58 pm

Hmm strange, I remember having issues with saving files within the dtor of classes. Maybe I had it saving the file in child dtor, when variable was declared as pointer to parent class, without destructor being virtual or something. Then again I had this issue several years ago.
Computer too slow? Consider running a VM on your toaster.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Lesson 19 - save file not being created

Post by albinopapa » April 5th, 2015, 9:27 pm

Yeah, I still don't clearly understand the virtual destructor. I'm assuming since the members of parent classes are initialized as child class members, you would destroy them in the child destructor. From what I have found though is as far as using delete or delete[] on anything created with new or new[], you can delete them anywhere as long as you only delete them once, have had issues with copies of classes deleting my heap variables of same names causing crashes when the original class gets destroyed.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Lesson 19 - save file not being created

Post by chili » April 12th, 2015, 11:55 am

If you don't have a virtual destructor, a parent pointer to a child class will use the parent destructor to deallocate, which will create a memory leak if the child has additional data members (and could cause other problems as well).
Chili

Bumble
Posts: 3
Joined: March 30th, 2015, 9:22 am

Re: Lesson 19 - save file not being created

Post by Bumble » January 20th, 2016, 4:39 pm

hey thanks for the help but i managed to fix the issue. it was partly the _CRT_SECURE_NO_WARNINGS thing that was preventing VS from using the non safe versions of scanf printf etc. and partly because i had the filename wrong and didn't spot it, D'oH! thanks all. now i can finally finish the beginner lessons i started more than a year ago. :)

Post Reply