author | tron |
Sat, 23 Jul 2005 17:22:39 +0000 | |
changeset 2177 | 73d67828ea5e |
parent 2163 | dedicated.c@637ec3c361f5 |
child 2180 | efe39e3d3fb4 |
permissions | -rw-r--r-- |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
1 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1829
diff
changeset
|
2 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1290
diff
changeset
|
3 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
4 |
#include "functions.h" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
5 |
#include "network.h" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
6 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
7 |
#ifdef ENABLE_NETWORK |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
8 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
9 |
#include "gfx.h" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
10 |
#include "window.h" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
11 |
#include "command.h" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
12 |
#include "console.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1959
diff
changeset
|
13 |
#include "variables.h" |
2177
73d67828ea5e
(svn r2691) Separate dedicated video driver and fix bemidi declarations
tron
parents:
2163
diff
changeset
|
14 |
#include "video/dedicated_v.h" |
73d67828ea5e
(svn r2691) Separate dedicated video driver and fix bemidi declarations
tron
parents:
2163
diff
changeset
|
15 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
16 |
#ifdef WIN32 |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
17 |
# include <windows.h> /* GetTickCount */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
18 |
# include <conio.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
19 |
#endif |
781
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
20 |
|
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
21 |
#ifdef __OS2__ |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
22 |
# include <sys/time.h> /* gettimeofday */ |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
23 |
# include <sys/types.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
24 |
# include <unistd.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
25 |
# include <conio.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
26 |
# define STDIN 0 /* file descriptor for standard input */ |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
796
diff
changeset
|
27 |
|
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
796
diff
changeset
|
28 |
extern void OS2_SwitchToConsoleMode(); |
781
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
29 |
#endif |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
30 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
31 |
#ifdef UNIX |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
32 |
# include <sys/time.h> /* gettimeofday */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
33 |
# include <sys/types.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
34 |
# include <unistd.h> |
702
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
35 |
# include <signal.h> |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
36 |
# define STDIN 0 /* file descriptor for standard input */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
37 |
#endif |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
38 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
39 |
static void *_dedicated_video_mem; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
40 |
|
1414
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
41 |
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm); |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
42 |
extern void SwitchMode(int new_mode); |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
43 |
|
702
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
44 |
#ifdef UNIX |
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
45 |
/* Signal handlers */ |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
702
diff
changeset
|
46 |
static void DedicatedSignalHandler(int sig) |
702
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
47 |
{ |
736
53618d1ade61
(svn r1188) -Fix: [Network] Fixed that CTRL+<key> could sometimes hang a dedicated
truelight
parents:
721
diff
changeset
|
48 |
_exit_game = true; |
53618d1ade61
(svn r1188) -Fix: [Network] Fixed that CTRL+<key> could sometimes hang a dedicated
truelight
parents:
721
diff
changeset
|
49 |
signal(sig, DedicatedSignalHandler); |
702
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
50 |
} |
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
51 |
#endif |
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
52 |
|
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
53 |
#ifdef WIN32 |
1114
5433cbd50835
(svn r1615) -Fix: [1107350] console ignoring return character occasionally. For everyone that is running 2 dedicated servers on 1 windows machine, console input is now correct (event was the same so it was random which console received the input)
darkvater
parents:
1109
diff
changeset
|
54 |
#include <time.h> |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
55 |
HANDLE hEvent; |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
56 |
static HANDLE hThread; // Thread to close |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
57 |
static char _win_console_thread_buffer[200]; |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
58 |
|
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
59 |
/* Windows Console thread. Just loop and signal when input has been received */ |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
60 |
void WINAPI CheckForConsoleInput(void) |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
61 |
{ |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
62 |
while (true) { |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
63 |
fgets(_win_console_thread_buffer, lengthof(_win_console_thread_buffer), stdin); |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
64 |
SetEvent(hEvent); // signal input waiting that the line is ready |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
65 |
} |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
66 |
} |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
67 |
|
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
68 |
void CreateWindowsConsoleThread(void) |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
69 |
{ |
1114
5433cbd50835
(svn r1615) -Fix: [1107350] console ignoring return character occasionally. For everyone that is running 2 dedicated servers on 1 windows machine, console input is now correct (event was the same so it was random which console received the input)
darkvater
parents:
1109
diff
changeset
|
70 |
static char tbuffer[9]; |
1762
01d1e351aafe
(svn r2266) - Feature: it is now possible to start a dedicated server on Win98/95, for the few sadistic geeks that really want to do this (thanks for testing Hackykid). Also fix up another glitch in console output
Darkvater
parents:
1626
diff
changeset
|
71 |
DWORD dwThreadId; |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
72 |
/* Create event to signal when console input is ready */ |
1114
5433cbd50835
(svn r1615) -Fix: [1107350] console ignoring return character occasionally. For everyone that is running 2 dedicated servers on 1 windows machine, console input is now correct (event was the same so it was random which console received the input)
darkvater
parents:
1109
diff
changeset
|
73 |
hEvent = CreateEvent(NULL, false, false, _strtime(tbuffer)); |
5433cbd50835
(svn r1615) -Fix: [1107350] console ignoring return character occasionally. For everyone that is running 2 dedicated servers on 1 windows machine, console input is now correct (event was the same so it was random which console received the input)
darkvater
parents:
1109
diff
changeset
|
74 |
if (hEvent == NULL) |
5433cbd50835
(svn r1615) -Fix: [1107350] console ignoring return character occasionally. For everyone that is running 2 dedicated servers on 1 windows machine, console input is now correct (event was the same so it was random which console received the input)
darkvater
parents:
1109
diff
changeset
|
75 |
error("Cannot create console event!"); |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
76 |
|
1762
01d1e351aafe
(svn r2266) - Feature: it is now possible to start a dedicated server on Win98/95, for the few sadistic geeks that really want to do this (thanks for testing Hackykid). Also fix up another glitch in console output
Darkvater
parents:
1626
diff
changeset
|
77 |
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CheckForConsoleInput, NULL, 0, &dwThreadId); |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
78 |
if (hThread == NULL) |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
79 |
error("Cannot create console thread!"); |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
80 |
|
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
81 |
DEBUG(misc, 0) ("Windows console thread started..."); |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
82 |
} |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
83 |
|
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
84 |
void CloseWindowsConsoleThread(void) |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
85 |
{ |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
86 |
CloseHandle(hThread); |
1114
5433cbd50835
(svn r1615) -Fix: [1107350] console ignoring return character occasionally. For everyone that is running 2 dedicated servers on 1 windows machine, console input is now correct (event was the same so it was random which console received the input)
darkvater
parents:
1109
diff
changeset
|
87 |
CloseHandle(hEvent); |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
88 |
DEBUG(misc, 0) ("Windows console thread shut down..."); |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
89 |
} |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
90 |
|
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
91 |
#endif |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
92 |
|
1301
313804601383
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
93 |
static const char *DedicatedVideoStart(const char * const *parm) |
313804601383
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
94 |
{ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
95 |
_screen.width = _screen.pitch = _cur_resolution[0]; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
96 |
_screen.height = _cur_resolution[1]; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
97 |
_dedicated_video_mem = malloc(_cur_resolution[0]*_cur_resolution[1]); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
98 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
99 |
_debug_net_level = 6; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
100 |
_debug_misc_level = 0; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
101 |
|
626
78c7e1c9f7c5
(svn r1056) -Fix: [Network] Give the dedicated-server always a console in windows (sign_de)
truelight
parents:
543
diff
changeset
|
102 |
#ifdef WIN32 |
78c7e1c9f7c5
(svn r1056) -Fix: [Network] Give the dedicated-server always a console in windows (sign_de)
truelight
parents:
543
diff
changeset
|
103 |
// For win32 we need to allocate an console (debug mode does the same) |
78c7e1c9f7c5
(svn r1056) -Fix: [Network] Give the dedicated-server always a console in windows (sign_de)
truelight
parents:
543
diff
changeset
|
104 |
CreateConsole(); |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
105 |
CreateWindowsConsoleThread(); |
626
78c7e1c9f7c5
(svn r1056) -Fix: [Network] Give the dedicated-server always a console in windows (sign_de)
truelight
parents:
543
diff
changeset
|
106 |
SetConsoleTitle("OpenTTD Dedicated Server"); |
78c7e1c9f7c5
(svn r1056) -Fix: [Network] Give the dedicated-server always a console in windows (sign_de)
truelight
parents:
543
diff
changeset
|
107 |
#endif |
78c7e1c9f7c5
(svn r1056) -Fix: [Network] Give the dedicated-server always a console in windows (sign_de)
truelight
parents:
543
diff
changeset
|
108 |
|
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
796
diff
changeset
|
109 |
#ifdef __OS2__ |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
796
diff
changeset
|
110 |
// For OS/2 we also need to switch to console mode instead of PM mode |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
796
diff
changeset
|
111 |
OS2_SwitchToConsoleMode(); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
796
diff
changeset
|
112 |
#endif |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
796
diff
changeset
|
113 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
114 |
DEBUG(misc,0)("Loading dedicated server..."); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
115 |
return NULL; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
116 |
} |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
117 |
|
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
118 |
static void DedicatedVideoStop(void) |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
119 |
{ |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
120 |
#ifdef WIN32 |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
121 |
CloseWindowsConsoleThread(); |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
122 |
#endif |
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1090
diff
changeset
|
123 |
free(_dedicated_video_mem); |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
124 |
} |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
125 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
126 |
static void DedicatedVideoMakeDirty(int left, int top, int width, int height) {} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
127 |
static bool DedicatedVideoChangeRes(int w, int h) { return false; } |
1829
0b6de3b4458a
(svn r2334) - Fix (regression): moved togglefullscreen into the video-driver, now windows works, dedicated works and sdl works. Also reverted the change to the makefile.
Darkvater
parents:
1794
diff
changeset
|
128 |
static void DedicatedVideoFullScreen(bool fs) {} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
129 |
|
1090
7a367d006de9
(svn r1591) Make dedicated servers on OS/2 check for input the UNIX way
tron
parents:
1046
diff
changeset
|
130 |
#if defined(UNIX) || defined(__OS2__) |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
131 |
static bool InputWaiting(void) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
132 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
133 |
struct timeval tv; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
134 |
fd_set readfds; |
736
53618d1ade61
(svn r1188) -Fix: [Network] Fixed that CTRL+<key> could sometimes hang a dedicated
truelight
parents:
721
diff
changeset
|
135 |
byte ret; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
136 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
137 |
tv.tv_sec = 0; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
138 |
tv.tv_usec = 1; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
139 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
140 |
FD_ZERO(&readfds); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
141 |
FD_SET(STDIN, &readfds); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
142 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
143 |
/* don't care about writefds and exceptfds: */ |
736
53618d1ade61
(svn r1188) -Fix: [Network] Fixed that CTRL+<key> could sometimes hang a dedicated
truelight
parents:
721
diff
changeset
|
144 |
ret = select(STDIN + 1, &readfds, NULL, NULL, &tv); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
145 |
|
736
53618d1ade61
(svn r1188) -Fix: [Network] Fixed that CTRL+<key> could sometimes hang a dedicated
truelight
parents:
721
diff
changeset
|
146 |
if (ret > 0) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
147 |
return true; |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
148 |
|
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
149 |
return false; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
150 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
151 |
#else |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
152 |
static bool InputWaiting(void) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
153 |
{ |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
154 |
if (WaitForSingleObject(hEvent, 1) == WAIT_OBJECT_0) |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
155 |
return true; |
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1090
diff
changeset
|
156 |
|
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
157 |
return false; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
158 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
159 |
#endif |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
160 |
|
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
161 |
static void DedicatedHandleKeyInput(void) |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
702
diff
changeset
|
162 |
{ |
721
20591395836b
(svn r1173) -Fix: [Network] Console input in dedicated server for windows was not
truelight
parents:
720
diff
changeset
|
163 |
static char input_line[200] = ""; |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
702
diff
changeset
|
164 |
|
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
165 |
if (!InputWaiting()) |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
166 |
return; |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
167 |
|
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
168 |
if (_exit_game) |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
169 |
return; |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
170 |
|
781
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
171 |
#if defined(UNIX) || defined(__OS2__) |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
172 |
fgets(input_line, lengthof(input_line), stdin); |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
173 |
#else |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
174 |
strncpy(input_line, _win_console_thread_buffer, lengthof(input_line)); |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
175 |
#endif |
736
53618d1ade61
(svn r1188) -Fix: [Network] Fixed that CTRL+<key> could sometimes hang a dedicated
truelight
parents:
721
diff
changeset
|
176 |
|
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
177 |
/* XXX - strtok() does not 'forget' \n\r if it is the first character! */ |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
178 |
strtok(input_line, "\r\n"); // Forget about the final \n (or \r) |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
179 |
{ /* Remove any special control characters */ |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
180 |
uint i; |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
181 |
for (i = 0; i < lengthof(input_line); i++) { |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
182 |
if (input_line[i] == '\n' || input_line[i] == '\r') // cut missed beginning '\0' |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
183 |
input_line[i] = '\0'; |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
184 |
|
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
185 |
if (input_line[i] == '\0') |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
186 |
break; |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
187 |
|
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
188 |
if (!IS_INT_INSIDE(input_line[i], ' ', 256)) |
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
189 |
input_line[i] = ' '; |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
702
diff
changeset
|
190 |
} |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
702
diff
changeset
|
191 |
} |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
192 |
|
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
193 |
IConsoleCmdExec(input_line); // execute command |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
702
diff
changeset
|
194 |
} |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
702
diff
changeset
|
195 |
|
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
196 |
static int DedicatedVideoMainLoop(void) |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
702
diff
changeset
|
197 |
{ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
198 |
#ifndef WIN32 |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
199 |
struct timeval tim; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
200 |
#endif |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
201 |
uint32 next_tick; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
202 |
uint32 cur_ticks; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
203 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
204 |
#ifdef WIN32 |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
205 |
next_tick = GetTickCount() + 30; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
206 |
#else |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
207 |
gettimeofday(&tim, NULL); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
208 |
next_tick = (tim.tv_usec / 1000) + 30 + (tim.tv_sec * 1000); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
209 |
#endif |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
210 |
|
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
736
diff
changeset
|
211 |
/* Signal handlers */ |
702
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
212 |
#ifdef UNIX |
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
213 |
signal(SIGTERM, DedicatedSignalHandler); |
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
214 |
signal(SIGINT, DedicatedSignalHandler); |
736
53618d1ade61
(svn r1188) -Fix: [Network] Fixed that CTRL+<key> could sometimes hang a dedicated
truelight
parents:
721
diff
changeset
|
215 |
signal(SIGQUIT, DedicatedSignalHandler); |
702
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
216 |
#endif |
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
217 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
218 |
// Load the dedicated server stuff |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
219 |
_is_network_server = true; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
220 |
_network_dedicated = true; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
221 |
_network_playas = OWNER_SPECTATOR; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
222 |
_local_player = OWNER_SPECTATOR; |
1414
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
223 |
|
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
224 |
/* If SwitchMode is SM_LOAD, it means that the user used the '-g' options */ |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
225 |
if (_switch_mode != SM_LOAD) { |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
226 |
_switch_mode = SM_NONE; |
1794
44f9deff97ed
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1762
diff
changeset
|
227 |
GenRandomNewGame(Random(), InteractiveRandom()); |
1414
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
228 |
} else { |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
229 |
_switch_mode = SM_NONE; |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
230 |
/* First we need to test if the savegame can be loaded, else we will end up playing the |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
231 |
* intro game... */ |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
232 |
if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL)) { |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
233 |
/* Loading failed, pop out.. */ |
1626 | 234 |
DEBUG(net, 0)("Loading requested map failed. Aborting."); |
1414
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
235 |
_networking = false; |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
236 |
} else { |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
237 |
/* We can load this game, so go ahead */ |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
238 |
SwitchMode(SM_LOAD); |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
239 |
} |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
240 |
} |
d7fa2709bf86
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
truelight
parents:
1406
diff
changeset
|
241 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
242 |
// Done loading, start game! |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
243 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
244 |
if (!_networking) { |
1626 | 245 |
DEBUG(net, 1)("Dedicated server could not be launched. Aborting."); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
246 |
return ML_QUIT; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
247 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
248 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
249 |
while (true) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
250 |
InteractiveRandom(); // randomness |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
251 |
|
702
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
252 |
if (_exit_game) return ML_QUIT; |
e8f37893243e
(svn r1152) -Add: [Network] Added signal handling (GeniusDex)
truelight
parents:
626
diff
changeset
|
253 |
|
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
702
diff
changeset
|
254 |
if (!_dedicated_forks) |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
702
diff
changeset
|
255 |
DedicatedHandleKeyInput(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
256 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
257 |
#ifdef WIN32 |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
258 |
cur_ticks = GetTickCount(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
259 |
#else |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
260 |
gettimeofday(&tim, NULL); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
261 |
cur_ticks = (tim.tv_usec / 1000) + (tim.tv_sec * 1000); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
262 |
#endif |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
263 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
264 |
if (cur_ticks >= next_tick) { |
1543
d502c1c2ea80
(svn r2047) -Fix: never commit your own personal changes... :(
truelight
parents:
1542
diff
changeset
|
265 |
next_tick += 30; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
266 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
267 |
GameLoop(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
268 |
_screen.dst_ptr = _dedicated_video_mem; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
269 |
UpdateWindows(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
270 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
271 |
CSleep(1); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
272 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
273 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
274 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
275 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
276 |
const HalVideoDriver _dedicated_video_driver = { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
277 |
DedicatedVideoStart, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
278 |
DedicatedVideoStop, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
279 |
DedicatedVideoMakeDirty, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
280 |
DedicatedVideoMainLoop, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
281 |
DedicatedVideoChangeRes, |
1829
0b6de3b4458a
(svn r2334) - Fix (regression): moved togglefullscreen into the video-driver, now windows works, dedicated works and sdl works. Also reverted the change to the makefile.
Darkvater
parents:
1794
diff
changeset
|
282 |
DedicatedVideoFullScreen, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
283 |
}; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
284 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
285 |
#else |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
286 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
287 |
static void *_dedicated_video_mem; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
288 |
|
1614
4ee38e74afd1
(svn r2118) - Fix: Fix compilation with network disabled, and comment out some of the warnings (unused function)
Darkvater
parents:
1543
diff
changeset
|
289 |
static const char *DedicatedVideoStart(const char * const *parm) |
1301
313804601383
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
290 |
{ |
1626 | 291 |
DEBUG(misc, 0) ("OpenTTD compiled without network support, exiting."); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
292 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
293 |
return NULL; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
294 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
295 |
|
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
296 |
static void DedicatedVideoStop(void) { free(_dedicated_video_mem); } |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
297 |
static void DedicatedVideoMakeDirty(int left, int top, int width, int height) {} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
298 |
static bool DedicatedVideoChangeRes(int w, int h) { return false; } |
1829
0b6de3b4458a
(svn r2334) - Fix (regression): moved togglefullscreen into the video-driver, now windows works, dedicated works and sdl works. Also reverted the change to the makefile.
Darkvater
parents:
1794
diff
changeset
|
299 |
static void DedicatedVideoFullScreen(bool fs) {} |
1046
d46ccd96c40f
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
915
diff
changeset
|
300 |
static int DedicatedVideoMainLoop(void) { return ML_QUIT; } |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
301 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
302 |
const HalVideoDriver _dedicated_video_driver = { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
303 |
DedicatedVideoStart, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
304 |
DedicatedVideoStop, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
305 |
DedicatedVideoMakeDirty, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
306 |
DedicatedVideoMainLoop, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
307 |
DedicatedVideoChangeRes, |
1829
0b6de3b4458a
(svn r2334) - Fix (regression): moved togglefullscreen into the video-driver, now windows works, dedicated works and sdl works. Also reverted the change to the makefile.
Darkvater
parents:
1794
diff
changeset
|
308 |
DedicatedVideoFullScreen, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
309 |
}; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
310 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
311 |
#endif /* ENABLE_NETWORK */ |