Multiple Database Files

EQ2Emulator Development forum.

Moderator: Team Members

Post Reply
User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Multiple Database Files

Post by Scatman » Tue Aug 02, 2011 1:32 am

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?

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: Multiple Database Files

Post by John Adams » Tue Aug 02, 2011 10:56 am

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.

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Re: Multiple Database Files

Post by Scatman » Tue Aug 02, 2011 4:17 pm

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);

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Re: Multiple Database Files

Post by Scatman » Tue Aug 02, 2011 4:24 pm

Crap. Wrong thread :P

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Re: Multiple Database Files

Post by Scatman » Tue Aug 02, 2011 4:30 pm

Done and committed.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: Multiple Database Files

Post by John Adams » Wed Aug 03, 2011 10:39 am

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 :)

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Re: Multiple Database Files

Post by Scatman » Wed Aug 03, 2011 10:25 pm

shoot for the stars!

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: Multiple Database Files

Post by John Adams » Thu Aug 04, 2011 6:34 am

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.

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Re: Multiple Database Files

Post by Scatman » Thu Aug 04, 2011 5:51 pm

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".

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: Multiple Database Files

Post by John Adams » Fri Aug 05, 2011 6:57 am

Right, very good call, Scatto. And I still get my anal-retentive-control-freakish-separation-of-files I want so obsessively.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests