| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Message
| You are right, the .exe was already there.
Well I have spent a considerable time trying to get the program to compile under gcc, let alone run.
I found, after compiling it, the exact same results you did, that it would just "hang" if you connected to it. However if you aborted the server the client would say "lost connection" so clearly something was happening.
I suspected it hadn't recognised the new connection, which turned out to be the case. It's funny the author never noticed it.
Anyway, the offending line is in SocketLib/SocketSet.h (line 43 in my version):
Change:
return select( *(m_socketdescs.rbegin()), &m_activityset, 0, 0, &t );
To:
return select( *(m_socketdescs.rbegin()) + 1, &m_activityset, 0, 0, &t );
It took me a while to work out what he was doing there. The critical line is from the help for "select" which reads:
n is the highest-numbered descriptor in any of the three sets, plus 1.
socketdescs is declared as a set of sockets, like this:
std::set<sock> m_socketdescs;
*(m_socketdescs.rbegin()) is going to return the highest socket in the set. However it needs to be that number, plus one. Thus, I have put the "+ 1" into that line.
Also, to get rid of the compiler warnings, I made these changes:
diff -c ../SimpleMUD 1.0.1/SimpleMUD/EntityDatabase.h SimpleMUD/EntityDatabase.h
*** ../SimpleMUD 1.0.1/SimpleMUD/EntityDatabase.h 2005-12-07 13:33:34.000000000 +1100
--- SimpleMUD/EntityDatabase.h 2005-12-07 12:04:15.000000000 +1100
***************
*** 50,58 ****
// Have I mentioned that VC6 sucks yet?
// --------------------------------------------------------------------
iterator() {}; // default constructor
! iterator( typename const container::iterator& p_itr ) // copy constructor
{
! container::iterator& itr = *this; // also needed because VC6 sucks
itr = p_itr;
}
--- 50,58 ----
// Have I mentioned that VC6 sucks yet?
// --------------------------------------------------------------------
iterator() {}; // default constructor
! iterator( const typename container::iterator& p_itr ) // copy constructor
{
! typename container::iterator& itr = *this; // also needed because VC6 sucks
itr = p_itr;
}
***************
*** 62,68 ****
// --------------------------------------------------------------------
inline datatype& operator*()
{
! container::iterator& itr = *this; // also needed because VC6 sucks
return itr->second;
}
--- 62,68 ----
// --------------------------------------------------------------------
inline datatype& operator*()
{
! typename container::iterator& itr = *this; // also needed because VC6 sucks
return itr->second;
}
***************
*** 72,78 ****
// --------------------------------------------------------------------
inline datatype* operator->()
{
! container::iterator& itr = *this; // also needed because VC6 sucks
return &(itr->second);
}
}; // end iterator inner class
--- 72,78 ----
// --------------------------------------------------------------------
inline datatype* operator->()
{
! typename container::iterator& itr = *this; // also needed because VC6 sucks
return &(itr->second);
}
}; // end iterator inner class
***************
*** 162,168 ****
entityid openid = 0;
entityid previous = 0;
! std::map<entityid,datatype>::iterator itr = m_map.begin();
while( !openid )
{
--- 162,168 ----
entityid openid = 0;
entityid previous = 0;
! typename std::map<entityid,datatype>::iterator itr = m_map.begin();
while( !openid )
{
***************
*** 189,195 ****
public:
// internal iterator
! typename typedef std::vector<datatype>::iterator iterator;
inline static iterator begin() { return m_vector.begin() + 1; }
inline static iterator end() { return m_vector.end(); }
--- 189,195 ----
public:
// internal iterator
! typedef typename std::vector<datatype>::iterator iterator;
inline static iterator begin() { return m_vector.begin() + 1; }
inline static iterator end() { return m_vector.end(); }
He doesn't seem to have a high opinion of VC6 :).
I compiled this under:
gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
I suspect you may have problems with other versions of gcc, however I have had enough of this program for today. :)
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|