[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  Programming
. -> [Folder]  General
. . -> [Subject]  Looking for a basic C++ bareboned mud server

Looking for a basic C++ bareboned mud server

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Daniel Spain   (15 posts)  [Biography] bio
Date Mon 31 Oct 2011 08:05 AM (UTC)
Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 01 Nov 2011 12:25 AM (UTC)
Message
Template:post=2209 Please see the forum thread: http://gammon.com.au/forum/?id=2209.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Daniel Spain   (15 posts)  [Biography] bio
Date Reply #2 on Sun 13 Nov 2011 12:15 AM (UTC)
Message
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.

[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sun 13 Nov 2011 12:40 AM (UTC)
Message
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).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Daniel Spain   (15 posts)  [Biography] bio
Date Reply #4 on Sun 13 Nov 2011 04:19 AM (UTC)
Message
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.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,662 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]