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

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  Programming
. -> [Folder]  General
. . -> [Subject]  Looking for a basic C++ bareboned mud server
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Looking for a basic C++ bareboned mud server

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Daniel Spain   (15 posts)  [Biography] bio
Date Mon 31 Oct 2011 08:05 AM (UTC)  quote  ]
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  (19,168 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 01 Nov 2011 12:25 AM (UTC)  quote  ]
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)  quote  ]
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  (19,168 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sun 13 Nov 2011 12:40 AM (UTC)  quote  ]
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)  quote  ]
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.


1,522 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]