Changeset - r2180:a46dc84e7817
[Not reviewed]
master
0 2 0
tron - 19 years ago 2005-07-23 18:46:17
tron@openttd.org
(svn r2694) Various smaller changes: eol-style, static, code simplification
2 files changed with 61 insertions and 86 deletions:
0 comments (0 inline, 0 general)
os2.c
Show inline comments
 
@@ -620,22 +620,6 @@ void DeterminePaths(void)
 
	mkdir(_path.scenario_dir);
 
}
 

	
 
// FUNCTION: OS2_SwitchToConsoleMode
 
//
 
// Switches OpenTTD to a console app at run-time, instead of a PM app
 
// Necessary to see stdout, etc
 

	
 
void OS2_SwitchToConsoleMode(void)
 
{
 
	PPIB pib;
 
	PTIB tib;
 

	
 
	DosGetInfoBlocks(&tib, &pib);
 

	
 
	// Change flag from PM to VIO
 
	pib->pib_ultype = 3;
 
}
 

	
 
/**
 
 * Insert a chunk of text from the clipboard onto the textbuffer. Get TEXT clipboard
 
 * and append this up to the maximum length (either absolute or screenlength). If maxlength
video/dedicated_v.c
Show inline comments
 
@@ -3,6 +3,7 @@
 
#include "debug.h"
 
#include "functions.h"
 
#include "network.h"
 
#include "video/dedicated_v.h"
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
@@ -11,12 +12,6 @@
 
#include "command.h"
 
#include "console.h"
 
#include "variables.h"
 
#include "video/dedicated_v.h"
 

	
 
#ifdef WIN32
 
#	include <windows.h> /* GetTickCount */
 
#	include <conio.h>
 
#endif
 

	
 
#ifdef __OS2__
 
#	include <sys/time.h> /* gettimeofday */
 
@@ -25,7 +20,19 @@
 
#	include <conio.h>
 
#	define STDIN 0  /* file descriptor for standard input */
 

	
 
	extern void OS2_SwitchToConsoleMode();
 
/** 
 
 * Switches OpenTTD to a console app at run-time, instead of a PM app
 
 * Necessary to see stdout, etc. */
 
static void OS2_SwitchToConsoleMode(void)
 
{
 
	PPIB pib;
 
	PTIB tib;
 

	
 
	DosGetInfoBlocks(&tib, &pib);
 

	
 
	// Change flag from PM to VIO
 
	pib->pib_ultype = 3;
 
}
 
#endif
 

	
 
#ifdef UNIX
 
@@ -34,14 +41,7 @@
 
#	include <unistd.h>
 
#	include <signal.h>
 
#	define STDIN 0  /* file descriptor for standard input */
 
#endif
 

	
 
static void *_dedicated_video_mem;
 

	
 
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm);
 
extern void SwitchMode(int new_mode);
 

	
 
#ifdef UNIX
 
/* Signal handlers */
 
static void DedicatedSignalHandler(int sig)
 
{
 
@@ -51,13 +51,15 @@ static void DedicatedSignalHandler(int s
 
#endif
 

	
 
#ifdef WIN32
 
#include <windows.h> /* GetTickCount */
 
#include <conio.h>
 
#include <time.h>
 
HANDLE hEvent;
 
static HANDLE hEvent;
 
static HANDLE hThread; // Thread to close
 
static char _win_console_thread_buffer[200];
 

	
 
/* Windows Console thread. Just loop and signal when input has been received */
 
void WINAPI CheckForConsoleInput(void)
 
static void WINAPI CheckForConsoleInput(void)
 
{
 
	while (true) {
 
		fgets(_win_console_thread_buffer, lengthof(_win_console_thread_buffer), stdin);
 
@@ -65,7 +67,7 @@ void WINAPI CheckForConsoleInput(void)
 
	}
 
}
 

	
 
void CreateWindowsConsoleThread(void)
 
static void CreateWindowsConsoleThread(void)
 
{
 
	static char tbuffer[9];
 
	DWORD dwThreadId;
 
@@ -81,7 +83,7 @@ void CreateWindowsConsoleThread(void)
 
	DEBUG(misc, 0) ("Windows console thread started...");
 
}
 

	
 
void CloseWindowsConsoleThread(void)
 
static void CloseWindowsConsoleThread(void)
 
{
 
	CloseHandle(hThread);
 
	CloseHandle(hEvent);
 
@@ -90,6 +92,13 @@ void CloseWindowsConsoleThread(void)
 

	
 
#endif
 

	
 

	
 
static void *_dedicated_video_mem;
 

	
 
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm);
 
extern void SwitchMode(int new_mode);
 

	
 

	
 
static const char *DedicatedVideoStart(const char * const *parm)
 
{
 
	_screen.width = _screen.pitch = _cur_resolution[0];
 
@@ -132,7 +141,6 @@ static bool InputWaiting(void)
 
{
 
	struct timeval tv;
 
	fd_set readfds;
 
	byte ret;
 

	
 
	tv.tv_sec = 0;
 
	tv.tv_usec = 1;
 
@@ -141,21 +149,29 @@ static bool InputWaiting(void)
 
	FD_SET(STDIN, &readfds);
 

	
 
	/* don't care about writefds and exceptfds: */
 
	ret = select(STDIN + 1, &readfds, NULL, NULL, &tv);
 
	return select(STDIN + 1, &readfds, NULL, NULL, &tv) > 0;
 
}
 

	
 
static uint32 GetTime(void)
 
{
 
	struct timeval tim;
 

	
 
	if (ret > 0)
 
		return true;
 
	gettimeofday(&tim, NULL);
 
	return tim.tv_usec / 1000 + tim.tv_sec * 1000;
 
}
 

	
 
	return false;
 
}
 
#else
 

	
 
static bool InputWaiting(void)
 
{
 
	if (WaitForSingleObject(hEvent, 1) == WAIT_OBJECT_0)
 
		return true;
 
	return WaitForSingleObject(hEvent, 1) == WAIT_OBJECT_0;
 
}
 

	
 
	return false;
 
static uint32 GetTime(void)
 
{
 
	return GetTickCount();
 
}
 

	
 
#endif
 

	
 
static void DedicatedHandleKeyInput(void)
 
@@ -195,18 +211,10 @@ static void DedicatedHandleKeyInput(void
 

	
 
static int DedicatedVideoMainLoop(void)
 
{
 
#ifndef WIN32
 
	struct timeval tim;
 
#endif
 
	uint32 next_tick;
 
	uint32 cur_ticks;
 

	
 
#ifdef WIN32
 
	next_tick = GetTickCount() + 30;
 
#else
 
	gettimeofday(&tim, NULL);
 
	next_tick = (tim.tv_usec / 1000) + 30 + (tim.tv_sec * 1000);
 
#endif
 
	next_tick = GetTime() + 30;
 

	
 
	/* Signal handlers */
 
#ifdef UNIX
 
@@ -254,12 +262,7 @@ static int DedicatedVideoMainLoop(void)
 
		if (!_dedicated_forks)
 
			DedicatedHandleKeyInput();
 

	
 
#ifdef WIN32
 
		cur_ticks = GetTickCount();
 
#else
 
		gettimeofday(&tim, NULL);
 
		cur_ticks = (tim.tv_usec / 1000) + (tim.tv_sec * 1000);
 
#endif
 
		cur_ticks = GetTime();
 

	
 
		if (cur_ticks >= next_tick) {
 
			next_tick += 30;
 
@@ -272,6 +275,22 @@ static int DedicatedVideoMainLoop(void)
 
	}
 
}
 

	
 
#else
 

	
 
static const char *DedicatedVideoStart(const char * const *parm)
 
{
 
	DEBUG(misc, 0) ("OpenTTD compiled without network support, exiting.");
 

	
 
	return NULL;
 
}
 

	
 
static void DedicatedVideoStop(void) {}
 
static void DedicatedVideoMakeDirty(int left, int top, int width, int height) {}
 
static bool DedicatedVideoChangeRes(int w, int h) { return false; }
 
static void DedicatedVideoFullScreen(bool fs) {}
 
static int DedicatedVideoMainLoop(void) { return ML_QUIT; }
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
const HalVideoDriver _dedicated_video_driver = {
 
	DedicatedVideoStart,
 
@@ -281,31 +300,3 @@ const HalVideoDriver _dedicated_video_dr
 
	DedicatedVideoChangeRes,
 
	DedicatedVideoFullScreen,
 
};
 

	
 
#else
 

	
 
static void *_dedicated_video_mem;
 

	
 
static const char *DedicatedVideoStart(const char * const *parm)
 
{
 
	DEBUG(misc, 0) ("OpenTTD compiled without network support, exiting.");
 

	
 
	return NULL;
 
}
 

	
 
static void DedicatedVideoStop(void) { free(_dedicated_video_mem); }
 
static void DedicatedVideoMakeDirty(int left, int top, int width, int height) {}
 
static bool DedicatedVideoChangeRes(int w, int h) { return false; }
 
static void DedicatedVideoFullScreen(bool fs) {}
 
static int DedicatedVideoMainLoop(void) { return ML_QUIT; }
 

	
 
const HalVideoDriver _dedicated_video_driver = {
 
	DedicatedVideoStart,
 
	DedicatedVideoStop,
 
	DedicatedVideoMakeDirty,
 
	DedicatedVideoMainLoop,
 
	DedicatedVideoChangeRes,
 
	DedicatedVideoFullScreen,
 
};
 

	
 
#endif /* ENABLE_NETWORK */
0 comments (0 inline, 0 general)