Page 1 of 1

Multiple Database Files

Posted: Tue Aug 02, 2011 1:32 am
by Scatman
I was thinking today. You know how we have a WorldDatabase.cpp and a RulesDB.cpp? Would you be opposed to moving everything in RulesDB.cpp into WorldDatabase.cpp BUT! keeping the Rules database functions in a separate file (like RulesDB.cpp)? This way, we don't have 20+ different classes handling database functions. We would still only have database.myfunction(), but the actual functions would be spread across different files, in their respectful places.

So if your intentions for splitting it up were to just organize the code better, I think it'd still be best to keep all database functions in one class, across multiple files? Whatcha think?

Re: Multiple Database Files

Posted: Tue Aug 02, 2011 10:56 am
by John Adams
That sounds perfect, Scatto. The only thing I was after with the new *DB file(s) was to stop WorldDatabase.cpp from growing to an unmanageable confusing mess that it is today.

If you can leave the functions in their own files, YET still have them under the WorldDatabase database class, then certainly go for it!

Great idea.

Re: Multiple Database Files

Posted: Tue Aug 02, 2011 4:17 pm
by Scatman
Nope no locking needed. The locking is handled by the guild functions. However, I would get rid of the reload all guilds. All you need to do is:

Build a GuildMember* struct using the fields that go into the database table for the new guildmember.
Then call Guild::AddGuildMember(GuildMemeber *gm);

Code: Select all

GuildMember *gm = new GuildMember;
gm->blah = blah;
gm->blah = blah;
Query to insert the guild member
guild->AddGuildMember(gm);

Re: Multiple Database Files

Posted: Tue Aug 02, 2011 4:24 pm
by Scatman
Crap. Wrong thread :P

Re: Multiple Database Files

Posted: Tue Aug 02, 2011 4:30 pm
by Scatman
Done and committed.

Re: Multiple Database Files

Posted: Wed Aug 03, 2011 10:39 am
by John Adams
I would like to go retrofit our other new "DB" files to this new concept. I'll take a crack at it today, and when I fail, pass it off to you, Scatman :)

Re: Multiple Database Files

Posted: Wed Aug 03, 2011 10:25 pm
by Scatman
shoot for the stars!

Re: Multiple Database Files

Posted: Thu Aug 04, 2011 6:34 am
by John Adams
k, as I said in IRC last night, I have a butt-load of changes I've made relating to this.

- I have moved Guilds into their own folder
- Created a GuildDB.cpp, and moved all functions out of WorldDatabase (per above)
- Built DB files for Tradeskills, Collections and Commands and will move what I can there tonight
- Retrofitted RecipesDB
- and a bunch of other stuff, logging (of course) etc.

Once I test the Server Guild stuff tonight, I will commit. Strongly suggest everyone update soon after, so we don't have conflicts.

Re: Multiple Database Files

Posted: Thu Aug 04, 2011 5:51 pm
by Scatman
Sweet! Will do. I like this implementation of the database functions much better. It would've been crazy having so many classes for each "system".

Re: Multiple Database Files

Posted: Fri Aug 05, 2011 6:57 am
by John Adams
Right, very good call, Scatto. And I still get my anal-retentive-control-freakish-separation-of-files I want so obsessively.