Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Database Fun

Sign in to follow this  
Evil Steve


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:
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...
  • Sign in to follow this  


    Recommended Comments

    Keep us up to date on the mud, sounds cool, specially when you get somthing on a dedicated server.

    Share this comment

    Link to comment

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Advertisement

    Important Information

    By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

    GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

    Sign me up!