Looking for a basic C++ bareboned mud server

Posted by Daniel Spain on Mon 31 Oct 2011 08:05 AM — 5 posts, 22,281 views.

#0
hello all, i for the past few years have been writing addon modules for the MajorBBS/Worldgroup platform, i have slowly been getting out of the bbs dependency and trying to do my own standalone in C.
Since i have been writing addons all the networking code is done already so doing a standalone is killing me is there anywhere available for C a simple mud code base that accepts a connection, displays a welcome screen and asks for logon, then asks for password, and once connected enteres the "game" where it accepts commands, like say "quit"? i looked at socketmud but it was for linux, i just want something simple to use as a learning tool to see how sockets are initialized, assigned, etc, then the game loop is processed.

any help is appreciated.

Thank you.
Australia Forum Administrator #1
Template:post=2209
Please see the forum thread: http://gammon.com.au/forum/?id=2209.
#2
oh yeah that was a great starter, i took it and compiled it in bcc 5.5 and it worked liek a champ, made some modifications so the user accounting was read from a sqlite database and polished up the server and now i got a server that does what i want, much thanks.

was wondering if you could help with an issue?

i want to parse the commands so they are executed like so:

if(argc == 2 && input == "attack)
{
DoAttack(argv[1]);
}

i got the argc to work by simply counting spaces in input,
but am struggling parsing the input text into multiple words.

here is how i do it:

char input[256];
strncpy(input,str(sLine),256);

string command = GetWord (sLine);

int argc = get_args(input);
	
if (argc == 1 && (command == "exit" || command == "x")) {DoQuit(c);return;}


that works fine, typing "exit now" does nothing where typing "exit" executes the quit command, so if i wanted to attack a target how would i parse it into multiple words?


if (argc == 2 && (command == "attack" || command == "a")) {DoAttack(c,argv[1]);return;} //argv[1] is what i need to build


thanks.

Australia Forum Administrator #3
The tinymudserver source had provision for breaking input into words, for example:


/* tell <someone> <something> */

void DoTell (tPlayer * p, istream & sArgs)
{
  p->NeedNoFlag ("gagged"); // can't if gagged
  tPlayer * ptarget = p->GetPlayer (sArgs, "Tell whom?", true);  // who
  string what = GetMessage (sArgs, "Tell " + p->playername + " what?");  // what  
  *p << "You tell " << p->playername << ", \"" << what << "\"\n";     // confirm
  *ptarget << p->playername << " tells you, \"" << what << "\"\n";    // tell them
} // end of DoTell



(Although that looks slightly wrong to me, it should be using ptarget rather than p in a few places. But the parsing part should be right).
#4
yeah i'll get around to cleaning it up.

before i read this i just went generic:


static void ProcessGameCommand (string & sLine, Character * c)
{
  char input[256];
  strncpy(input,str(sLine),256);

  string command = GetWord (sLine);

  int argc = get_args(input);

  if (argc == 1 && (command == "exit" || command == "x"))
  {
    DoQuit(c);
    return;
  }

  if (argc == 2 && (command == "look" || command = "l"))
  {
    inspect(c,&input[strlen(str(command))+1]);
    return;
  }   

}


as nasty as it looks it does work, but i will definately clean her up once im done polishing up the server options.

this is an old bsb game from the 90's that was written for the majorbbs / worldgroup bbs platform in turbo c 3.1, i ported the codebase to bcc 4.5 in 2000 and rewrote it in 2008 for worldgroup win32 using bcc 5.01 and most recently ported that to bcc 5.5 when i removed flatfile databasing and added sqlite.

problem is im wasting so much time on a bsb game i need to be making it standalone cause im 36 and i was like 19 when it came out, so it needs to be made independant and elimnate
all the bbs api.

my problem is i been workign with this code for so many years thats all i know, doing it standalone i dont get the luxury of all the bbs api that did all the parsing for me i am basically learning it from scratch.

so much thanks for the help.