Archived

This topic is now archived and is closed to further replies.

GAME: Where to put registry stuff

This topic is 5815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I''m not a big registry fan, and i like to keep stuff, like settings, in a file the user can save, if he uninstall the game, but i reckon registry will be necessary somewhere... So, where should we put our gamestuff in the registry? under which levels?

[Hugo Ferreira][Positronic Dreams][]
"Research is what I''m doing when I don''t know what I''m doing."
- Wernher Von Braun (1912-1977)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
OK, I''m comming from the Unix world, so please forgive this stupid question, but...

Why do Windows games always need to put their config stuff into the registry ? Why can''t they just create a little ini or cfg (or .config ) file in their current directory, and load that one at startup ? This way, games would be 100% relocable. I hate this: Try to copy a game that you installed on D:\blah to E:\blah because you need the space on D for something else. Game doesn''t run anymore. WHY do Windows games need to store direct references on drive letters ? Some even store drive-bound paths into registry entries !! WHY ?

Don''t get it...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I have to agree, stop playing with the registry! Mine is already over 32MB big(!!)

Give me a .ini (or whatever file) in the GAME DIRECTORY anytime over the stupid use of the registry.

And if you must use the registry, then don''t put directory paths, or anything else that can mess up a game just by moving the folder from one drive to another.


Share this post


Link to post
Share on other sites
Using the registry is an easy way to allow per-user settings. You can also store binary data directly.

I still prefer config files for games and stuff though.

----------------
Blaster
Computer game programmer and part time human being
Strategy First - http://www.strategyfirst.com
BlasterSoft - http://www.blastersoft.com

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Why do Windows games always need to put their config stuff into the registry ? Why can''t they just create a little ini or cfg (or .config ) file in their current directory, and load that one at startup ?

What about allowing settings for different users? Under UNIX you get a different home directory for each person so this is trivial, Windows doesn''t do that.

quote:
This way, games would be 100% relocable. I hate this: Try to copy a game that you installed on D:\blah to E:\blah because you need the space on D for something else.

If you could move games around that easily, how would Windows how to uninstall it?

(Of course, this can be answered with: "why not teach the users how to delete a directory for themselves, instead of using a convoluted Add/Remove mechanism".)

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:

What about allowing settings for different users? Under UNIX you get a different home directory for each person so this is trivial, Windows doesn''t do that.



Hmm, yes. Good point.

But, although I don''t know the Win-API very well, I''m sure that there is a function to query the username of the currently logged in user. So you could just create a CFG for each user: user1.config, user2.config, etc.. Perhaps encrypted with a user defined password.

That way, each user could just do what he wants with his config file, copy it onto his notebook (to keep playing at work ), backup it, or even access his personal configs (or savegames) over a network, or... Oops, probably I''m thinking too much Unix here...

Share this post


Link to post
Share on other sites
Since nobody mentioned it, you can still create .ini files. In fact, you can give the user the choice of using the registry or an .ini file (so the power user has more control), but default to one for the type of user who always clicks "Default Installation."

Happy Hacking!

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
The registry is cool, because it begins to provide type-safe storage.. it''s certainly not perfect though. Personally I find text parsing a pain, and a waste of time that could be spent doing something else, so I tend to use the registry early on in development because it''s a little quicker to use.

As for username''s, etc.. Win9x doesn''t really have that concept. NT/2000/XP does though. NT also has the concept of a ''home'' directory which you can get the path for, using Win32 APIs. Max Payne (for PC) will query for your user folder and store your save games there (and maybe other user specific stuff). I think there was an article on MSDN that describes this as "the right way to store savegames/etc under Windows"..


-Brannon

Share this post


Link to post
Share on other sites
quote:
Original post by Brannon
Personally I find text parsing a pain, and a waste of time that could be spent doing something else, so I tend to use the registry early on in development because it''s a little quicker to use.


Well, there''s a host of functions for parsing .ini files. You could switch at compile time with one #define, or at run time with one boolean test.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
I hugely prefer saving profiles in files, not
using the registry. You can allways start the game
by saying "Who are you", leting the user identify himself,
then selecting/creating his file...

I just started this post because i''m pretty sure
the registry stuff will creep up son enough, and i haven''t
looked into it yet...

[Hugo Ferreira][Positronic Dreams][]
"Research is what I''m doing when I don''t know what I''m doing."
- Wernher Von Braun (1912-1977)

Share this post


Link to post
Share on other sites
Or why couldn''t Microsoft in their infinate wisdom build a registry snooper into the OS. They can certainly give you a message that says if you move those files, you will affect the registry settings. WHy couldn''t they take it one step further and just reposition the pointers to point to the new directory.

---
Make it work.
Make it fast.

"Commmmpuuuuterrrr.." --Scotty Star Trek IV:The Voyage Home

Share this post


Link to post
Share on other sites
Don''t forget about how many times you need to patch an installed game. With the registry you can just run the patch, it can look in the registry to see where the game is installed, and go patch it. It is not really feesable to search the entire computer to find where the game was installed, and many users don''t remember where they installed the game (or how to find out).

jakar

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Most of the time the registry is used for the speed improvement it provides over parsing text files. its that simple.

Share this post


Link to post
Share on other sites
I believe it is better to put configurations into the registry, because its better then having a bunch of .ini or .cfg files littered around the system. Also, it prevents the **average** user from tinkering with the config files in a text editor.

Basically, for games I write, in the "HKEY_CURRENT_USER\Software\Company Name\Game Title\" I store things like user defined controls, player names or handles, the sound level and other things that will differ from player to player.

In "HKEY_LOCAL_MACHINE\Software\Company Name\Game Title\" I store things like the video resolution, the sound quality and other hardware configurations. I also tend to store the high scores list there as well.

Also, Microsoft prefer''s that you use the system registry, becuase .ini files are a thing of the past

Share this post


Link to post
Share on other sites
quote:
Original post by skreuzer
I believe it is better to put configurations into the registry, because its better then having a bunch of .ini or .cfg files littered around the system.

So that one bad sector appearing on your hard disk destroys your whole operating system instead of just one program.

quote:
Also, it prevents the **average** user from tinkering with the config files in a text editor.

Why would you want to? The ''average'' user tends not to be wandering around in subdirectories anyway.

quote:
Basically, for games I write, in the "HKEY_CURRENT_USER\Software\Company Name\Game Title\" I store things like user defined controls, player names or handles, the sound level and other things that will differ from player to player.

In "HKEY_LOCAL_MACHINE\Software\Company Name\Game Title\" I store things like the video resolution, the sound quality and other hardware configurations. I also tend to store the high scores list there as well.

These are good reasons to use the registry: just a shame that it is necessary to do this.

quote:
Also, Microsoft prefer''s that you use the system registry, becuase .ini files are a thing of the past

Circular definition: They are only a thing of the past because Microsoft wanted you to stop using them. Probably because it created an operating system where it was beneficial for every program you installed to add its own section to win.ini. (Oh, those glorious days.)

I don''t like the idea of hiding things from users, or storing them in proprietary binary formats (see No Proprietary Binary Data Formats), and especially not in 2 monolithic files that are open to corruption. (How many ''average users'' know how to restore a damaged registry?)


[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:

I believe it is better to put configurations into the registry, because its better then having a bunch of .ini or .cfg files littered around the system.



They are not littered around your system. They are in the directory of the game / app they belong to.

I don''t see, why I should have a huge registry with thousands of little information pieces belonging to different software packages, than having well ordered ini files in the same directory than their app.

Ini files actually make your system cleaner and better to maintain. And as Kylotan mentioned: if you kill a cfg file for a certain game, then this specific game won''t run anymore. But if you have a problem with your registry, well, then you are pretty much f*cked.

The idea of a registry is around centralization of vital information. This concept has been proved wrong and dangerous, it corrupts stability and is error prone. Decentralization is the way to go. INI files do exactly that. They are a thing of the future...

Share this post


Link to post
Share on other sites
I Hate the registry more than anything else in all of that poorly implemented operating system that we call windows. But actually the windows API has a great system for creating Per-User configurations and the like. My Documents! Games like Max Payne use the My Documents folder for storing per-user save games, so why can''t you use it for storing per-user configuration files? There is an excellent tutorial (unfortunatly, in power point format) for obtaining the proper folder paths as well as playing nice with WindowsXP and it''s fast user switching here:

http://www.microsoft.com/mscorp/corpevents/meltdown2001/presentations.asp

as well as a direct link to the power point presentation:
http://www.microsoft.com/mscorp/corpevents/meltdown2001/ppt/GamingWinXP.ppt

Share this post


Link to post
Share on other sites
There are a lot of good motivations for the registry: trivial per-user settings, random access, remote configuration, etc. People using ini files in the bad-old 16-bit days needed to be broken of bad habits also - they either put app configuration data in win.ini (the windows ini file) or they put a private ini file in the windows directory itself. The latter is a problem for admins who want to lock down their systems and write-protect windows directory from every random joe that comes along.

The registry is easy to abuse however. It''s not meant for storing large amounts of data (use a pointer to a file instead). A lot of apps put stuff all over the place instead of keeping things tidy. A lot of apps require stuff to be initialized in the registry to even run instead of using it for non-default settings only.

It''s just a tool and has its upsides and downsides like any other. Use it or not as you please.

-Mike

Share this post


Link to post
Share on other sites