|
|
/* $Id$ */
|
|
|
|
|
|
#include "../stdafx.h"
|
|
|
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
|
|
#include "../openttd.h"
|
|
|
#include "../debug.h"
|
|
|
#include "../functions.h"
|
|
|
#include "../gfx.h"
|
|
|
#include "../network/network.h"
|
|
|
#include "../window.h"
|
|
|
#include "../console.h"
|
|
|
#include "../variables.h"
|
|
|
#include "../genworld.h"
|
|
|
#include "../fileio.h"
|
|
|
#include "../blitter/blitter.hpp"
|
|
|
#include "../blitter/factory.hpp"
|
|
|
#include "dedicated_v.h"
|
|
|
|
|
|
#ifdef BEOS_NET_SERVER
|
|
|
#include <net/socket.h>
|
|
|
#endif
|
|
|
|
|
|
#ifdef __OS2__
|
|
|
# include <sys/time.h> /* gettimeofday */
|
|
|
# include <sys/types.h>
|
|
|
# include <unistd.h>
|
|
|
# include <conio.h>
|
|
|
|
|
|
# define INCL_DOS
|
|
|
# include <os2.h>
|
|
|
|
|
|
# define STDIN 0 /* file descriptor for standard input */
|
|
|
|
|
|
/**
|
|
|
* Switches OpenTTD to a console app at run-time, instead of a PM app
|
|
|
* Necessary to see stdout, etc. */
|
|
|
static void OS2_SwitchToConsoleMode()
|
|
|
{
|
|
|
PPIB pib;
|
|
|
PTIB tib;
|
|
@@ -107,50 +107,48 @@ static void CloseWindowsConsoleThread()
|
|
|
{
|
|
|
CloseHandle(_hThread);
|
|
|
CloseHandle(_hInputReady);
|
|
|
CloseHandle(_hWaitForInputHandling);
|
|
|
DEBUG(driver, 2, "Windows console thread shut down");
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
static void *_dedicated_video_mem;
|
|
|
|
|
|
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir);
|
|
|
extern void SwitchMode(int new_mode);
|
|
|
|
|
|
|
|
|
static const char *DedicatedVideoStart(const char * const *parm)
|
|
|
{
|
|
|
int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
|
|
|
if (bpp == 0) _dedicated_video_mem = NULL;
|
|
|
else _dedicated_video_mem = malloc(_cur_resolution[0] * _cur_resolution[1] * (bpp / 8));
|
|
|
|
|
|
_screen.width = _screen.pitch = _cur_resolution[0];
|
|
|
_screen.height = _cur_resolution[1];
|
|
|
_screen.renderer = RendererFactoryBase::SelectRenderer(BlitterFactoryBase::GetCurrentBlitter()->GetRenderer());
|
|
|
if (_screen.renderer == NULL) error("Couldn't load the renderer '%s' the selected blitter depends on", BlitterFactoryBase::GetCurrentBlitter()->GetRenderer());
|
|
|
|
|
|
SetDebugString("net=6");
|
|
|
|
|
|
#ifdef WIN32
|
|
|
// For win32 we need to allocate a console (debug mode does the same)
|
|
|
CreateConsole();
|
|
|
CreateWindowsConsoleThread();
|
|
|
SetConsoleTitle(_T("OpenTTD Dedicated Server"));
|
|
|
#endif
|
|
|
|
|
|
#ifdef __OS2__
|
|
|
// For OS/2 we also need to switch to console mode instead of PM mode
|
|
|
OS2_SwitchToConsoleMode();
|
|
|
#endif
|
|
|
|
|
|
DEBUG(driver, 1, "Loading dedicated server");
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
static void DedicatedVideoStop()
|
|
|
{
|
|
|
#ifdef WIN32
|
|
|
CloseWindowsConsoleThread();
|
|
|
#endif
|