Is pretty much a disaster zone at the moment and its not really code issues im having problems with its more Concept issues.
This post could really fit into Network Board, Game Board and Linux Board so if the moderators feel it should be moved then by all means please do.
Im posting because im hoping there someone out there who has wrote a little mud and could help me out. Ive looked everywhere for basic MUD Tutorials but it seems like majority of people use existing codebases and I cant learn too much from them as they are way more advanced than my simple mud and it would destroy the point of trying to write my own.
Ok well it all started out good, I wrote the server based on the "select" C function and was allowing characters who connected to move around from room to room using a MySQL backend database. They could talk to each other, etc etc.
Then I decided I would try and add some combat routines to give the characters something to do, this is where my probs have started.
I was storing the incoming data in a struct and passing a pointer of it into a function to process and perform various tasks. Anyway once someone started a combat scenario the loop would freeze everyone else up until the combat was over, I posted a question on this in the windows section and was told by a guy called Adrian about threads etc. anyway i got that to work in a little test on a windows machine and figured the same logic would apply to linux and I discovered pthread_create. Thinking this would fix my problem i changed the code to start a new thread on a combat request, and great it worked people could talk and see the combat at the same time.. until i had someone else started a combat loop they "stole" the other persons thread and got their data returned to them aswell, all started getting really messy.
Ok so i checked out some mud codebases and they looked uber complex to me but they all didnt seem to use pthread and instead used "forks" and had the MUD update every 1 second which would send out all the data it needed to every second, im not sure if this is a bad way to write a mud or exactly how a fork is different to a thread.
I realise i need to implement some kind of timer system so that monsters dissapear for a while and then respawn after x amount of time so i dont think my current structure will work here.
Seems to me i just need something like
.. some kind of timer loop
.. process mud every second
.. check for respawns, send out data to clients.
gah ive just re-read this and I know its a real ramble but im in desperate need of some structure ideas and perhaps some pointers as to what the basic concept of how a mud loops is.
im not asking for code as im more than happy to try and learn myself but even if you know of any tutorials that would help as all I can find after hours of google searching is just code bases.
thanks in advance and sorry for the rambling
edit: i realise i have bitten off more than i can chew here but im determined to carry on and try and accomplish something