Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 744 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Prevent Game Crash #397024
03/13/12 18:02
03/13/12 18:02
Joined: Dec 2009
Posts: 256
USA , NY
msmith2468 Offline OP
Member
msmith2468  Offline OP
Member

Joined: Dec 2009
Posts: 256
USA , NY
I am finishing up my game team effort. The problem I have is when a player exports a level. Exporting a level creates a file and writes to it. It works great as long as the player is running the game as an administrator however if they are not then the game crashes. I have placed warnings in the game that inform the player that they need to run the game as an administrator in order to export a level.

If there is a way I would like to prevent the crash. Is there a way that I can check to see if the user is running the game as the administrator or not? That way I could check before creating the new file and prevent the crash.

Or perhaps there is another fail safe method I could use. I am open to suggestions Thanks.


Mikes Wicked Games

www.mikeswickedgames.com
Re: Prevent Game Crash [Re: msmith2468] #397028
03/13/12 18:34
03/13/12 18:34
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Where do you write the file?

Re: Prevent Game Crash [Re: Ch40zzC0d3r] #397031
03/13/12 19:00
03/13/12 19:00
Joined: Dec 2010
Posts: 66
München (Germany)
dice Offline
Junior Member
dice  Offline
Junior Member

Joined: Dec 2010
Posts: 66
München (Germany)
I have the same problem with saving my game. I could'nt find a solution till now.

But I don't think that you can check the administrator mode from inside the game. More or less you have to assure the game is installed to start with admin rights. But I also dont know how to do this wink

Re: Prevent Game Crash [Re: dice] #397032
03/13/12 19:14
03/13/12 19:14
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Are you saving to %appdata% or something (or directly in ProgramData)?

Re: Prevent Game Crash [Re: Rei_Ayanami] #397034
03/13/12 19:35
03/13/12 19:35
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
Topic: Can 3dgs read from and write to %appdata%?
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=334501&an=

Go for it wink


no science involved
Re: Prevent Game Crash [Re: Rei_Ayanami] #397035
03/13/12 19:37
03/13/12 19:37
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Hows about this? It is just an idea, so you will need to test yourself.

Once you are about to do the save, try opening and closing a dummy file with
the EXACT same path and filename, but use the function FILE_OPEN_WRITE().
If it SUCESSFULLY opens (ie returns NOT zero), then you have the rights.
If it FAILS (ie returns a zero), then you are unable to save here(not admin?).

Im just not sure if this will trigger a windows error/warning if you are not admin.

Also beware, you may need to delete the dummy file(file_delete) before you actually save.
And when doing this make DOUBLY sure you give file_open_write the COMPLETE file-path.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Prevent Game Crash [Re: dice] #397037
03/13/12 19:47
03/13/12 19:47
Joined: Dec 2009
Posts: 256
USA , NY
msmith2468 Offline OP
Member
msmith2468  Offline OP
Member

Joined: Dec 2009
Posts: 256
USA , NY
Thanks for the reply's

I create and write the files into the same folder that the game is in. If the player downloaded the zipped folder then they can place it anywhere they want. If the player downloaded the installer and had the game installed to their computer under the default settings then a folder is created in program files and that is where the exported level files would be saved to.

You got me thinking and I ran some tests. I found that the error only occurs in the installed version of the game and not the zipped folder. So I took the zipped folder and moved it to the same location as the installed version in program files. Just creating the new folder I had to give permission. And sure enough the error occurred.

So clearly the problem is with the location of the folder. That still leaves me with a problem. I could simply warn the user with a message and save the game before I even attempt to export the files.

Something like this maybe "If Exporting a level crashes the game then run the game as an administrator."
If anyone knows a way to fix this or to at least prevent the crash please let me know. Thanks again.

@dice
My problem is that my game exports a game level so that the user can send it to friends or save it. This requires me to create a new file with a unique name based on the level. This is where the error occurs when I create a new file. I have no problem writing or reading a file.

My point is that your game (I assume) creates a file based on the players name to store the save data. If you create one save file then store all of the data in that save file then you could avoid the error. I hope this helps.


Mikes Wicked Games

www.mikeswickedgames.com
Re: Prevent Game Crash [Re: msmith2468] #397039
03/13/12 20:08
03/13/12 20:08
Joined: Dec 2009
Posts: 256
USA , NY
msmith2468 Offline OP
Member
msmith2468  Offline OP
Member

Joined: Dec 2009
Posts: 256
USA , NY
@dice
Sorry I assumed wrong. The crash happens anytime a file is written to not just file creation. I can read from a file without a problem.

@EvilSOB
I tested your suggestion and it worked. That's exactly what I was looking for. I am going to implement it so that when the game first starts up it checks if it can write to a file. If it can not then I will display a message that tells the user they must restart the game with administrator rights.

Thanks a lot everyone I appreciate it.


Mikes Wicked Games

www.mikeswickedgames.com
Re: Prevent Game Crash [Re: msmith2468] #397072
03/14/12 07:31
03/14/12 07:31
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
i think you can also use reis method: store your files into the appdata folder. every user can read/write into it without any problems
this should solve the problem in a nicer way...


Visit my site: www.masterq32.de
Re: Prevent Game Crash [Re: MasterQ32] #397074
03/14/12 08:14
03/14/12 08:14
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
Manual says:
Quote:

Saving files into the program folder requires administrator rights under Windows Vista and above, and is thus not recommended. Use this string to set a different folder, f.i. in the ProgramData directory.


http://www.conitec.net/beta/asave_dir.htm


no science involved

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1