Database Fun

posted in DruinkJournal
Published March 12, 2005
Advertisement
I've been working on my database class(es) for my new MUD. I've reused a lot of the code from the old one, but I've changed it to make it threaded. I seem to be getting a bit carried away with threads at the moment. When the database class starts up, it connects to my MySQL database, loads all the users and IP bans, and starts the worker thread. Every game loop, I cycle through the connected users, and process them. If something happens that causes an update (e.g. picking something up, taking damage), then the user is marked as dirty. Once the user's processing is complete, if they're marked as dirty, they get sent off to the Database class, which adds them to a queue of updates, which the thread processes.
This way I don't need to have the main thred interrupted by lots of database access, since my version of MySQL doesn't allow prepared statements, which isn't going to do a lot for performance.

I've already got the front end up and running, I decided to go for a GUI instead of a console. It's pretty simple, just a log window with a edit box for me to enter commands. Here's a screenshot anyway, just for the sake of it:
DruinkMUD
The text that you probably can't read is:
Database conneted, loading data
Listening for connections
Nothing much. It also goes to the system tray if you click the close button, since me (or one of my friends if they're using my server to play a network game) is bound to accidently close it. It restores itself when you double-click the icon in the system tray.

At the moment the database loads the users and IP bans from the worker thread (hence why it says "loading data" not "loaded data"). But that means I don't know when the loading is complete, which will cause issues when a user logs in. So I'm about to change that.
It'll also log things like how many users and IP bans were loaded, what scripts, items, rooms, NPCs, etc were loaded, and a lot of other junk. When the server is running, it'll show real buffers (I'll filter out the .password command, since my server is publicly viewable by VNC).
I intend to do something similar to [A place that does not exist], in so far as there'll be a bot which I can access through the server console. In fact, that's what typing something in the edit box does, just dispatches what I typed as an input for the bot user, which will get processed by the server.

So, my current todo list, just for the next day or two:
  • Fix the databse class
  • Implement the room manager, and implement one room
  • Handle connections, and create CClient and CBot classes
  • Create a CBot and bind it to the server console
  • Correctly handle the bot [dis]connecting, in case someone thinks it'll be funny to kick the bot
  • Simple text input and relay (no commands) from the bot and other users
    Then I'll move onto stuff like scripting, more rooms, spells, items, etc etc.

    Well, I think that's enough for now...
  • Previous Entry Druink Bomber is done!
    Next Entry Yay productivity
    0 likes 2 comments

    Comments

    H_o_p_s
    I like that you added the simple GUI around the console program.
    March 12, 2005 01:57 PM
    Asheh
    Keep us up to date on the mud, sounds cool, specially when you get somthing on a dedicated server.
    March 12, 2005 04:04 PM
    You must log in to join the conversation.
    Don't have a GameDev.net account? Sign up!
    Advertisement
    Advertisement