Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUDs ➜ General ➜ Tiny MUD Server - version 2

Tiny MUD Server - version 2

Posting of new messages is disabled at present.

Refresh page


Pages: 1  2  3  4 5  6  7  8  

Posted by Enderandrew   USA  (37 posts)  Bio
Date Reply #45 on Mon 27 Feb 2006 02:54 AM (UTC)
Message
Where is the Wiki?

"Nihilism makes me smile."
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #46 on Tue 28 Feb 2006 07:04 PM (UTC)
Message
At the moment it's also private, but we're talking about whether or not to make it public. It'll be either that or the forum, in any case. :)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #47 on Wed 03 May 2006 10:34 PM (UTC)
Message
Any news on what/when anything will be made public in the ways of BabbleMUD?

~Nick Cash
http://www.nick-cash.com
Top

Posted by Miller0521   (3 posts)  Bio
Date Reply #48 on Sat 14 Oct 2006 05:40 PM (UTC)
Message
I'm trying to go from using the tinymudserver and write my own server based on that.

I am not sure how much trouble it will be, but I thought I'd give it a shot. I know C code pretty well, but for some reason I ran into a hard time when reading from the player file, I am simply trying to add three lines that read in strings for example

this is a detailed description.

However it doesn't read it in properly, here is my load function, any ideas?

void tPlayer::Load ()
{
ifstream f ((PLAYER_DIR + playername + PLAYER_EXT).c_str (), ios::in);
if (!f)
throw runtime_error ("That player does not exist, type 'new' to create a new one.");

// read player details
f >> password;
f >> room;
getline(f, shortDescr);
getline(f,longDescr);
getline(f,detailedDescr);
f >> level;
for( int i = 0; i < NUM_STATS; i++)
{
f >> stats[i];
}
} /* end of tPlayer::Load */
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #49 on Sat 14 Oct 2006 10:45 PM (UTC)
Message
Can you post the error messages please?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Miller0521   (3 posts)  Bio
Date Reply #50 on Tue 17 Oct 2006 01:42 PM (UTC)
Message
There is no error message. Its simply not writing or reading from the player file correctly. After you log into the game, if you type save, and I look at the pfile, it has everything stored correctly up to the detailed description, then it just starts writting numbers. I'm not sure why, if it sucessfully stores the short and long descriptions, I would think detailed would work the same.
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #51 on Tue 17 Oct 2006 09:41 PM (UTC)
Message
In that case you need to post your "save" function, as you say it hasn't saved correctly.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Miller0521   (3 posts)  Bio
Date Reply #52 on Wed 18 Oct 2006 01:39 AM (UTC)
Message
void tPlayer::Save ()
{
ofstream f ((PLAYER_DIR + playername + PLAYER_EXT).c_str (), ios::out);
if (!f)
{
cerr << "Could not write to file for player " << playername << endl;
return;
}
// write player details
f << password << endl;
f << room;
f << shortDescr << endl;
f << longDescr << endl;
f << detailedDescr << endl;
f << level << endl;
for( int i = 0; i < NUM_STATS; i++)
{
f << stats[i] << endl;
}

f << endl;

} /* end of tPlayer::Save */
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #53 on Wed 18 Oct 2006 04:15 AM (UTC)
Message
You need to write a newline after 'room'. Do that by adding "<< endl" after "<< room".

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Arew264   (8 posts)  Bio
Date Reply #54 on Sun 29 Oct 2006 03:04 AM (UTC)
Message
I am getting the following error compiling the split version under the latest stable g++ (4.1.1)

utils.h: In function âvoid LoadSet(std::ifstream&, T&)â:
utils.h:26: error: cannot convert âstd::basic_ifstream<char, std::char_traits<char> >â to âchar**â for argument â1â to â__ssize_t getline(char**, size_t*, FILE*)â

Managed to get through several other errors, but I am stumped here (new to C++ but have programmed C and PHP)
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #55 on Sun 29 Oct 2006 03:53 AM (UTC)
Message
What is the line in question?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Arew264   (8 posts)  Bio
Date Reply #56 on Sun 29 Oct 2006 05:53 PM (UTC)

Amended on Sun 29 Oct 2006 11:47 PM (UTC) by Arew264

Message
As it says, the line in question is line 26 of utils.h (in the version where Nick separated everything out).

The surrounding area is:

// load a set of flags from a single line in the input stream "f"
template <class T>
void LoadSet (ifstream & f, T & s)
{
s.clear ();
string sLine;
getline (f, sLine); // get one line (THIS THROWS THE ERROR)
istringstream is (sLine); // convert back to stream
string flag; // each flag name
while (!is.eof ()) // read that stream
{
is >> flag; // read flag
s.insert (flag); // and insert it
} // end of getting each item
} // end of LoadSet
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #57 on Sun 29 Oct 2006 05:56 PM (UTC)
Message
I thought the syntax for getline was...
f.getline(string,SIZE);

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #58 on Sun 29 Oct 2006 08:21 PM (UTC)
Message
Change the line:


void LoadSet (ifstream & f, T & s)


to:


void LoadSet (istream & f, T & s)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #59 on Sun 29 Oct 2006 08:35 PM (UTC)

Amended on Sun 29 Oct 2006 08:40 PM (UTC) by Nick Gammon

Message
These are the changes I had to make to get it to compile under the more recent gcc compiler:


diff -c tinymudserver/player.cpp tinymudserver.fixed/player.cpp
*** tinymudserver/player.cpp	Tue Jul 27 15:53:07 2004
--- tinymudserver.fixed/player.cpp	Mon Oct 30 08:03:13 2006
***************
*** 20,25 ****
--- 20,27 ----
  #include <fstream>
  #include <iterator>
  
+ #include <errno.h>
+ 
  using namespace std; 
  
  #include "utils.h"
diff -c tinymudserver/player.h tinymudserver.fixed/player.h
*** tinymudserver/player.h	Tue Jul 27 15:53:07 2004
--- tinymudserver.fixed/player.h	Mon Oct 30 08:02:17 2006
***************
*** 81,87 ****
      {     
      outbuf += MAKE_STRING (i); 
      return *this; 
!     };  
    
    void ClosePlayer () { closing = true; }    // close this player's connection
    
--- 81,87 ----
      {     
      outbuf += MAKE_STRING (i); 
      return *this; 
!     }
    
    void ClosePlayer () { closing = true; }    // close this player's connection
    
diff -c tinymudserver/strings.cpp tinymudserver.fixed/strings.cpp
*** tinymudserver/strings.cpp	Tue Jul 27 15:53:07 2004
--- tinymudserver.fixed/strings.cpp	Mon Oct 30 08:02:39 2006
***************
*** 31,37 ****
        pos = found + replacement.size ();
        }
    return str;
!   };   // end of FindAndReplace
  
  // get rid of leading and trailing spaces from a string
  string Trim (const string & s, const string & t)
--- 31,37 ----
        pos = found + replacement.size ();
        }
    return str;
!   }   // end of FindAndReplace
  
  // get rid of leading and trailing spaces from a string
  string Trim (const string & s, const string & t)
diff -c tinymudserver/utils.h tinymudserver.fixed/utils.h
*** tinymudserver/utils.h	Tue Jul 27 15:25:10 2004
--- tinymudserver.fixed/utils.h	Mon Oct 30 08:12:52 2006
***************
*** 8,25 ****
  struct DeleteObject
    {
    template <typename T>
!   void operator() (const T* ptr) const { delete ptr; };
    };
  // similar concept for maps
  struct DeleteMapObject
    {
    template <typename T>
!   void operator() (const T item) const { delete item.second; };
    };
  
  // load a set of flags from a single line in the input stream "f"
! template <class T>
! void LoadSet (ifstream & f, T & s)
  {
    s.clear ();
    string sLine;
--- 8,25 ----
  struct DeleteObject
    {
    template <typename T>
!   void operator() (const T* ptr) const { delete ptr; }
    };
  // similar concept for maps
  struct DeleteMapObject
    {
    template <typename T>
!   void operator() (const T item) const { delete item.second; }
    };
  
  // load a set of flags from a single line in the input stream "f"
! template <typename T>
! void LoadSet (istream & f, T & s)
  {
    s.clear ();
    string sLine;



You can send the above through the patch program to apply them automatically, or just visually do it. The lines I changed are in bold above. The file names and line numbers are part of the "diff" text. Basically I had to remove a few semicolons, add a couple, add an include file, and change "ifstream" to "istream".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


344,726 views.

This is page 4, subject is 8 pages long:  [Previous page]  1  2  3  4 5  6  7  8  [Next page]

Posting of new messages is disabled at present.

Refresh page

Go to topic:           Search the forum


[Go to top] top

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