I can now say, I do know if UOX compiles under mingw from cvs. The answer is no, it doesn't.
A lot of the issue is the use of a platform to determine things versus basing it off the compilier.
The other major culprit is pasing defined classes (like a ustring) to a va_arg versus having it resolve to a native type first.
Yes, but getting it to compile and do something on cygwin and gcc 3.4.1 was not that difficult. (cygwin is easier than mingw, because platform.h assumes gcc -> unix, which obviously works better with unix like headers and libc

)
After adding configure.in and the mozilla directory from the uox3 CVS to the openuo CVS and updating automake.am with the current source list it only needed some slight tweaking to allow startup with an empty world, logging in and walking around, and clean shutdown. Probably not much else will work, but it should be a starting point.
Following are the (pretty minor) diffs to satisfy the compiler (without fixing the va_arg issue yet, which fortunately is just a warning and not necessary for logging in

):
Code: Select all
Index: Platform.h
===================================================================
RCS file: /cvsroot/openuo/projects/uox3/source/Platform.h,v
retrieving revision 1.2
diff -b -B -d -u -I\$$ -r1.2 Platform.h
--- Platform.h 19 Feb 2005 02:38:32 -0000 1.2
+++ Platform.h 7 Mar 2005 13:05:52 -0000
@@ -33,6 +33,8 @@
#elif defined( __GNUC__ )
# define UOX_COMPILER COMPILER_GNUC
# define UOX_COMP_VER __VERSION__
+#define FALSE 0L
+#define TRUE 1L
#elif defined( __BORLANDC__ )
# define UOX_COMPILER COMPILER_BORL
Index: boats.cpp
===================================================================
RCS file: /cvsroot/openuo/projects/uox3/source/boats.cpp,v
retrieving revision 1.8
diff -b -B -d -u -I\$$ -r1.8 boats.cpp
--- boats.cpp 30 Dec 2004 07:02:24 -0000 1.8
+++ boats.cpp 7 Mar 2005 13:05:52 -0000
@@ -582,7 +582,8 @@
CPPauseResume prSend( 1 );
SOCKLIST nearbyChars = FindNearbyPlayers( b, DIST_BUILDRANGE );
- for( SOCKLIST_CITERATOR cIter = nearbyChars.begin(); cIter != nearbyChars.end(); ++cIter )
+ SOCKLIST_CITERATOR cIter;
+ for( cIter = nearbyChars.begin(); cIter != nearbyChars.end(); ++cIter )
{
(*cIter)->Send( &prSend );
}
Index: cAccountClass.h
===================================================================
RCS file: /cvsroot/openuo/projects/uox3/source/cAccountClass.h,v
retrieving revision 1.3
diff -b -B -d -u -I\$$ -r1.3 cAccountClass.h
--- cAccountClass.h 13 Jan 2005 06:49:26 -0000 1.3
+++ cAccountClass.h 7 Mar 2005 13:05:52 -0000
@@ -23,7 +23,7 @@
#if UOX_PLATFORM != PLATFORM_WIN32
#include <dirent.h>
- #define strnicmp(a,b,c) strncasecmp(a,b,c)
+// #define strnicmp(a,b,c) strncasecmp(a,b,c)
#define _stat stat
#define _mkdir mkdir
#define _rmdir rmdir
Index: pcmanage.cpp
===================================================================
RCS file: /cvsroot/openuo/projects/uox3/source/pcmanage.cpp,v
retrieving revision 1.12
diff -b -B -d -u -I\$$ -r1.12 pcmanage.cpp
--- pcmanage.cpp 1 Mar 2005 04:59:21 -0000 1.12
+++ pcmanage.cpp 7 Mar 2005 13:05:52 -0000
@@ -305,7 +305,7 @@
//o--------------------------------------------------------------------------o
void CPICreateCharacter::newbieItems( CChar *mChar )
{
- const enum NewbieItems
+ /*const*/ enum NewbieItems
{
HAIR = 0,
BEARD,
Erros in the console thread caused Shutdown to be called from the console thread which crashes. The fix is:
Code: Select all
Index: uox3.cpp
===================================================================
RCS file: /cvsroot/openuo/projects/uox3/source/uox3.cpp,v
retrieving revision 1.17
diff -b -B -d -u -I\$$ -r1.17 uox3.cpp
--- uox3.cpp 5 Mar 2005 18:40:07 -0000 1.17
+++ uox3.cpp 7 Mar 2005 13:05:53 -0000
@@ -146,7 +146,7 @@
if( s < 0 )
{
Console.Error( 1, "Error scanning key press" );
- Shutdown( 10 );
+ messageLoop << MSG_SHUTDOWN;
}
if( s > 0 )
{
@@ -173,7 +173,7 @@
if( bytes_written != 1 || asw == 0 )
{
Console.Warning( 1, "Using cluox-io" );
- Shutdown( 10 );
+ messageLoop << MSG_SHUTDOWN;
}
c = (UI08)fgetc( stdin );
if( c == 0 )
@@ -258,7 +258,7 @@
#endif
messageLoop << "Thread: CheckConsoleKeyThread Closed";
#if UOX_PLATFORM != PLATFORM_WIN32
- return NULL;
+ pthread_exit( NULL );
#endif
}
// EviLDeD - End
To find all DFNs (if they are read correctly, I don't know) the following fix is necessary:
Code: Select all
Index: cServerDefinitions.cpp
===================================================================
RCS file: /cvsroot/openuo/projects/uox3/source/cServerDefinitions.cpp,v
retrieving revision 1.9
diff -b -B -d -u -I\$$ -r1.9 cServerDefinitions.cpp
--- cServerDefinitions.cpp 19 Feb 2005 02:38:32 -0000 1.9
+++ cServerDefinitions.cpp 7 Mar 2005 13:05:52 -0000
@@ -492,13 +492,12 @@
{
if( strcmp( dirp->d_name, "." ) && strcmp( dirp->d_name, ".." ) )
{
- subdirectories.push_back( cDirectoryListing( currentDir + "/" + dirp->d_name, extension, doRecursion ) );
- Console.Print( "%s/%s/n", currentDir.c_str(), dirp->d_name );
+ subdirectories.push_back( cDirectoryListing( dirp->d_name, extension, doRecursion ) );
continue;
}
}
shortList.push_back( dirp->d_name );
- sprintf( filePath, "%s/%s", currentDir.c_str(), dirp->d_name );
+ sprintf( filePath, "%s/%s", CurrentWorkingDir().c_str(), dirp->d_name );
filenameList.push_back( filePath );
}
The following fix is probably only necessary for cygwin, but it also fixes a potential security problem: the first connection is accepted to file descriptor 81 (using the default DFN/JS files), probably because not all opened files are closed. Since cygwin FD_SETSIZE defaults to 64, the result is that select doesn't work correctly and causes memory corruption (a quick google search indicates that this doesn't seem to be a problem for windows). The fix is setting FD_SETSIZE to something large enough and catching too large fd numbers:
Code: Select all
Index: network.cpp
===================================================================
RCS file: /cvsroot/openuo/projects/uox3/source/network.cpp,v
retrieving revision 1.11
diff -b -B -d -u -I\$$ -r1.11 network.cpp
--- network.cpp 5 Mar 2005 18:40:07 -0000 1.11
+++ network.cpp 7 Mar 2005 13:05:52 -0000
@@ -1,3 +1,5 @@
+#define FD_SETSIZE 256
+
#include "uox3.h"
#include "network.h"
#include "books.h"
@@ -292,6 +294,11 @@
newClient = accept( a_socket, (struct sockaddr *)&client_addr, &len );
#else
newClient = accept( a_socket, (struct sockaddr *)&client_addr, (socklen_t *)&len );
+ if (newClient >= FD_SETSIZE)
+ {
+ Console.Error( 0, "accept() returning unselectable fd!" );
+ return;
+ }
#endif
CSocket *toMake = new CSocket( newClient );
if( newClient < 0 )
I've also done some slight changes to the unix console support:
Code: Select all
Index: uox3.cpp
===================================================================
RCS file: /cvsroot/openuo/projects/uox3/source/uox3.cpp,v
retrieving revision 1.17
diff -b -B -d -u -I\$$ -r1.17 uox3.cpp
--- uox3.cpp 5 Mar 2005 18:40:07 -0000 1.17
+++ uox3.cpp 7 Mar 2005 13:05:53 -0000
@@ -3218,17 +3218,16 @@
#endif
const UI32 currentTime = 0;
-#if UOX_PLATFORM == PLATFORM_WIN32
sprintf( temp, "%s v%s.%s", CVersionClass::GetProductName().c_str(), CVersionClass::GetVersion().c_str(), CVersionClass::GetBuild().c_str() );
Console.Start( temp );
-#else
+
+#if UOX_PLATFORM != PLATFORM_WIN32
signal( SIGPIPE, SIG_IGN ); // This appears when we try to write to a broken network connection
signal( SIGTERM, &endmessage );
signal( SIGQUIT, &endmessage );
signal( SIGINT, &endmessage );
signal( SIGILL, &illinst );
signal( SIGFPE, &aus );
-
#endif
Console.PrintSectionBegin();
Index: cConsole.cpp
===================================================================
RCS file: /cvsroot/openuo/projects/uox3/source/cConsole.cpp,v
retrieving revision 1.5
diff -b -B -d -u -I\$$ -r1.5 cConsole.cpp
--- cConsole.cpp 27 Aug 2004 07:03:10 -0000 1.5
+++ cConsole.cpp 7 Mar 2005 13:05:52 -0000
@@ -15,6 +15,13 @@
#include "uox3.h"
#include "cConsole.h"
+#if UOX_PLATFORM != PLATFORM_WIN32
+#include <stdio.h>
+#include <unistd.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#endif
+
namespace UOX
{
@@ -34,7 +41,7 @@
//| Purpose - Class Constructor and deconstructor
//o---------------------------------------------------------------------------o
CConsole::CConsole() : left( 0 ), top( 0 ), height( 25 ), width( 80 ), filterSettings( 0xFFFF ),
-currentMode( NORMALMODE ),currentLevel( 0 ), previousColour( CNORMAL ), logEcho( false )
+currentMode( NORMALMODE ),currentLevel( 0 ), previousColour( CNORMAL ), logEcho( false ), forceNL (false)
{
}
@@ -397,6 +404,11 @@
curLeft = 0;
curTop = 0;
TurnNormal();
+
+ if (forceNL)
+ {
+ (*this) << myendl;
+ }
}
//o---------------------------------------------------------------------------o
@@ -408,12 +420,42 @@
//o---------------------------------------------------------------------------o
void CConsole::Start( char *temp )
{
-#if !defined(__unix__)
+#if UOX_PLATFORM == PLATFORM_WIN32
hco = GetStdHandle( STD_OUTPUT_HANDLE );
GetConsoleScreenBufferInfo( hco, &csbi );
width = csbi.dwSize.X;
height = csbi.dwSize.Y;
SetConsoleTitle( temp );
+#else
+ // TODO: unix console handling should really be replaced by (n)curses or
+ // something
+
+ if (isatty (0))
+ {
+ struct termios tio;
+ struct winsize winsz;
+
+ // switch to raw mode
+ tcgetattr (0, &tio);
+
+ tio.c_lflag &= ~ICANON & ~ECHO;
+
+ tcsetattr (0, TCSAFLUSH, &tio); //ignore errors
+
+ // get window size
+ ioctl (0, TIOCGWINSZ, &winsz);
+
+ width = winsz.ws_col;
+ height = winsz.ws_row;
+
+ // disable stdout buffering
+ setvbuf (stdout, NULL, _IONBF, 0);
+ }
+ else
+ {
+ // produce readable log
+ forceNL = true;
+ }
#endif
}
Index: cConsole.h
===================================================================
RCS file: /cvsroot/openuo/projects/uox3/source/cConsole.h,v
retrieving revision 1.4
diff -b -B -d -u -I\$$ -r1.4 cConsole.h
--- cConsole.h 25 Nov 2004 04:14:05 -0000 1.4
+++ cConsole.h 7 Mar 2005 13:05:52 -0000
@@ -102,7 +102,7 @@
UI16 filterSettings;
UI08 currentMode, currentLevel;
UI08 previousColour;
- bool logEcho;
+ bool logEcho, forceNL;
#if UOX_PLATFORM == PLATFORM_WIN32
HANDLE hco;
CONSOLE_SCREEN_BUFFER_INFO csbi;