Both SDL and curses clients work on WIN32/64. The SDL client is fully working, as is expected, but the gameLoop timer/signal system does not work. The code is in place via preprocessor conditions but it would require a fake window to be created so the messaging system can be used.
							parent
							
								
									8fc710f3a2
								
							
						
					
					
						commit
						df73d846d8
					
				| 
						 | 
					@ -4,9 +4,9 @@
 | 
				
			||||||
CPP      = g++.exe
 | 
					CPP      = g++.exe
 | 
				
			||||||
CC       = gcc.exe
 | 
					CC       = gcc.exe
 | 
				
			||||||
WINDRES  = windres.exe
 | 
					WINDRES  = windres.exe
 | 
				
			||||||
OBJ      = ../main.o ../interface/curses.o ../net/sockets.o ../game.o ../player.o ../wall.o ../console.o ../context.o ../helper.o ../map.o ../npc.o ../tile.o ../tiles/curses_tiles.o
 | 
					OBJ      = ../main.o ../interface/curses.o ../net/sockets.o ../game.o ../player.o ../wall.o ../console.o ../context.o ../helper.o ../map.o ../npc.o ../tile.o ../tiles/curses_tiles.o ../message.o
 | 
				
			||||||
LINKOBJ  = ../main.o ../interface/curses.o ../net/sockets.o ../game.o ../player.o ../wall.o ../console.o ../context.o ../helper.o ../map.o ../npc.o ../tile.o ../tiles/curses_tiles.o
 | 
					LINKOBJ  = ../main.o ../interface/curses.o ../net/sockets.o ../game.o ../player.o ../wall.o ../console.o ../context.o ../helper.o ../map.o ../npc.o ../tile.o ../tiles/curses_tiles.o ../message.o
 | 
				
			||||||
LIBS     = -L"C:/Program Files (x86)/Dev-Cpp/MinGW32/lib" -static-libstdc++ -static-libgcc ../../PDCurses/pdcurses.lib  -g3
 | 
					LIBS     = -L"C:/Program Files (x86)/Dev-Cpp/MinGW32/lib" -static-libstdc++ -static-libgcc ../../PDCurses/pdcurses.lib ../../../Windows/System32/ws2_32.dll  -g3
 | 
				
			||||||
INCS     = -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/include" -I"../../PDCurses"
 | 
					INCS     = -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/include" -I"../../PDCurses"
 | 
				
			||||||
CXXINCS  = -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/include" -I"../../PDCurses"
 | 
					CXXINCS  = -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/include" -I"../../PDCurses"
 | 
				
			||||||
BIN      = timesynk-pdcurses.exe
 | 
					BIN      = timesynk-pdcurses.exe
 | 
				
			||||||
| 
						 | 
					@ -63,3 +63,6 @@ $(BIN): $(OBJ)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
../tiles/curses_tiles.o: ../tiles/curses_tiles.c
 | 
					../tiles/curses_tiles.o: ../tiles/curses_tiles.c
 | 
				
			||||||
	$(CC) -c ../tiles/curses_tiles.c -o ../tiles/curses_tiles.o $(CFLAGS)
 | 
						$(CC) -c ../tiles/curses_tiles.c -o ../tiles/curses_tiles.o $(CFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					../message.o: ../message.c
 | 
				
			||||||
 | 
						$(CC) -c ../message.c -o ../message.o $(CFLAGS)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ ResourceIncludes=
 | 
				
			||||||
MakeIncludes=
 | 
					MakeIncludes=
 | 
				
			||||||
Compiler=
 | 
					Compiler=
 | 
				
			||||||
CppCompiler=
 | 
					CppCompiler=
 | 
				
			||||||
Linker=../../PDCurses/pdcurses.lib_@@_
 | 
					Linker=../../PDCurses/pdcurses.lib_@@_../../../Windows/System32/ws2_32.dll_@@_
 | 
				
			||||||
IsCpp=0
 | 
					IsCpp=0
 | 
				
			||||||
Icon=
 | 
					Icon=
 | 
				
			||||||
ExeOutput=
 | 
					ExeOutput=
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,7 @@ IncludeVersionInfo=0
 | 
				
			||||||
SupportXPThemes=0
 | 
					SupportXPThemes=0
 | 
				
			||||||
CompilerSet=0
 | 
					CompilerSet=0
 | 
				
			||||||
CompilerSettings=0000000000000000001000000
 | 
					CompilerSettings=0000000000000000001000000
 | 
				
			||||||
UnitCount=28
 | 
					UnitCount=30
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[VersionInfo]
 | 
					[VersionInfo]
 | 
				
			||||||
Major=1
 | 
					Major=1
 | 
				
			||||||
| 
						 | 
					@ -330,3 +330,23 @@ Priority=1000
 | 
				
			||||||
OverrideBuildCmd=0
 | 
					OverrideBuildCmd=0
 | 
				
			||||||
BuildCmd=
 | 
					BuildCmd=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Unit29]
 | 
				
			||||||
 | 
					FileName=..\message.c
 | 
				
			||||||
 | 
					CompileCpp=0
 | 
				
			||||||
 | 
					Folder=timesynk-pdcurses
 | 
				
			||||||
 | 
					Compile=1
 | 
				
			||||||
 | 
					Link=1
 | 
				
			||||||
 | 
					Priority=1000
 | 
				
			||||||
 | 
					OverrideBuildCmd=0
 | 
				
			||||||
 | 
					BuildCmd=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Unit30]
 | 
				
			||||||
 | 
					FileName=..\message.h
 | 
				
			||||||
 | 
					CompileCpp=0
 | 
				
			||||||
 | 
					Folder=timesynk-pdcurses
 | 
				
			||||||
 | 
					Compile=1
 | 
				
			||||||
 | 
					Link=1
 | 
				
			||||||
 | 
					Priority=1000
 | 
				
			||||||
 | 
					OverrideBuildCmd=0
 | 
				
			||||||
 | 
					BuildCmd=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,12 +1,12 @@
 | 
				
			||||||
[Editor_0]
 | 
					[Editor_0]
 | 
				
			||||||
CursorCol=1
 | 
					CursorCol=1
 | 
				
			||||||
CursorRow=1
 | 
					CursorRow=10
 | 
				
			||||||
TopLine=1
 | 
					TopLine=1
 | 
				
			||||||
LeftChar=1
 | 
					LeftChar=1
 | 
				
			||||||
Open=0
 | 
					Open=1
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
[Editors]
 | 
					[Editors]
 | 
				
			||||||
Order=
 | 
					Order=-1
 | 
				
			||||||
Focused=-1
 | 
					Focused=-1
 | 
				
			||||||
[Editor_1]
 | 
					[Editor_1]
 | 
				
			||||||
Open=0
 | 
					Open=0
 | 
				
			||||||
| 
						 | 
					@ -30,17 +30,17 @@ CursorRow=1
 | 
				
			||||||
TopLine=1
 | 
					TopLine=1
 | 
				
			||||||
LeftChar=1
 | 
					LeftChar=1
 | 
				
			||||||
[Editor_4]
 | 
					[Editor_4]
 | 
				
			||||||
Open=0
 | 
					Open=1
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
CursorCol=1
 | 
					CursorCol=24
 | 
				
			||||||
CursorRow=61
 | 
					CursorRow=31
 | 
				
			||||||
TopLine=46
 | 
					TopLine=1
 | 
				
			||||||
LeftChar=1
 | 
					LeftChar=1
 | 
				
			||||||
[Editor_5]
 | 
					[Editor_5]
 | 
				
			||||||
Open=0
 | 
					Open=1
 | 
				
			||||||
Top=0
 | 
					Top=1
 | 
				
			||||||
CursorCol=1
 | 
					CursorCol=115
 | 
				
			||||||
CursorRow=1
 | 
					CursorRow=22
 | 
				
			||||||
TopLine=1
 | 
					TopLine=1
 | 
				
			||||||
LeftChar=1
 | 
					LeftChar=1
 | 
				
			||||||
[Editor_6]
 | 
					[Editor_6]
 | 
				
			||||||
| 
						 | 
					@ -141,3 +141,9 @@ Top=0
 | 
				
			||||||
[Editor_27]
 | 
					[Editor_27]
 | 
				
			||||||
Open=0
 | 
					Open=0
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
 | 
					[Editor_28]
 | 
				
			||||||
 | 
					Open=0
 | 
				
			||||||
 | 
					Top=0
 | 
				
			||||||
 | 
					[Editor_29]
 | 
				
			||||||
 | 
					Open=0
 | 
				
			||||||
 | 
					Top=0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,7 @@ IncludeVersionInfo=0
 | 
				
			||||||
SupportXPThemes=0
 | 
					SupportXPThemes=0
 | 
				
			||||||
CompilerSet=0
 | 
					CompilerSet=0
 | 
				
			||||||
CompilerSettings=0000000000000000001000000
 | 
					CompilerSettings=0000000000000000001000000
 | 
				
			||||||
UnitCount=28
 | 
					UnitCount=30
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[VersionInfo]
 | 
					[VersionInfo]
 | 
				
			||||||
Major=1
 | 
					Major=1
 | 
				
			||||||
| 
						 | 
					@ -330,3 +330,23 @@ Priority=1000
 | 
				
			||||||
OverrideBuildCmd=0
 | 
					OverrideBuildCmd=0
 | 
				
			||||||
BuildCmd=
 | 
					BuildCmd=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Unit29]
 | 
				
			||||||
 | 
					FileName=..\message.c
 | 
				
			||||||
 | 
					CompileCpp=0
 | 
				
			||||||
 | 
					Folder=timesynk-sdl
 | 
				
			||||||
 | 
					Compile=1
 | 
				
			||||||
 | 
					Link=1
 | 
				
			||||||
 | 
					Priority=1000
 | 
				
			||||||
 | 
					OverrideBuildCmd=0
 | 
				
			||||||
 | 
					BuildCmd=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Unit30]
 | 
				
			||||||
 | 
					FileName=..\message.h
 | 
				
			||||||
 | 
					CompileCpp=0
 | 
				
			||||||
 | 
					Folder=timesynk-sdl
 | 
				
			||||||
 | 
					Compile=1
 | 
				
			||||||
 | 
					Link=1
 | 
				
			||||||
 | 
					Priority=1000
 | 
				
			||||||
 | 
					OverrideBuildCmd=0
 | 
				
			||||||
 | 
					BuildCmd=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,10 +3,10 @@ CursorCol=7
 | 
				
			||||||
CursorRow=13
 | 
					CursorRow=13
 | 
				
			||||||
TopLine=1
 | 
					TopLine=1
 | 
				
			||||||
LeftChar=1
 | 
					LeftChar=1
 | 
				
			||||||
Open=1
 | 
					Open=0
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
[Editors]
 | 
					[Editors]
 | 
				
			||||||
Order=-1
 | 
					Order=
 | 
				
			||||||
Focused=-1
 | 
					Focused=-1
 | 
				
			||||||
[Editor_1]
 | 
					[Editor_1]
 | 
				
			||||||
Open=0
 | 
					Open=0
 | 
				
			||||||
| 
						 | 
					@ -30,14 +30,14 @@ CursorRow=1
 | 
				
			||||||
TopLine=1
 | 
					TopLine=1
 | 
				
			||||||
LeftChar=1
 | 
					LeftChar=1
 | 
				
			||||||
[Editor_4]
 | 
					[Editor_4]
 | 
				
			||||||
Open=1
 | 
					Open=0
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
CursorCol=24
 | 
					CursorCol=22
 | 
				
			||||||
CursorRow=48
 | 
					CursorRow=97
 | 
				
			||||||
TopLine=16
 | 
					TopLine=58
 | 
				
			||||||
LeftChar=1
 | 
					LeftChar=1
 | 
				
			||||||
[Editor_5]
 | 
					[Editor_5]
 | 
				
			||||||
Open=1
 | 
					Open=0
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
CursorCol=1
 | 
					CursorCol=1
 | 
				
			||||||
CursorRow=26
 | 
					CursorRow=26
 | 
				
			||||||
| 
						 | 
					@ -93,22 +93,22 @@ Top=0
 | 
				
			||||||
Open=0
 | 
					Open=0
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
[Editor_17]
 | 
					[Editor_17]
 | 
				
			||||||
Open=1
 | 
					Open=0
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
CursorCol=30
 | 
					CursorCol=30
 | 
				
			||||||
CursorRow=58
 | 
					CursorRow=58
 | 
				
			||||||
TopLine=35
 | 
					TopLine=35
 | 
				
			||||||
LeftChar=1
 | 
					LeftChar=1
 | 
				
			||||||
[Editor_18]
 | 
					[Editor_18]
 | 
				
			||||||
Open=1
 | 
					Open=0
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
CursorCol=21
 | 
					CursorCol=21
 | 
				
			||||||
CursorRow=33
 | 
					CursorRow=33
 | 
				
			||||||
TopLine=1
 | 
					TopLine=1
 | 
				
			||||||
LeftChar=1
 | 
					LeftChar=1
 | 
				
			||||||
[Editor_19]
 | 
					[Editor_19]
 | 
				
			||||||
Open=1
 | 
					Open=0
 | 
				
			||||||
Top=1
 | 
					Top=0
 | 
				
			||||||
CursorCol=28
 | 
					CursorCol=28
 | 
				
			||||||
CursorRow=32
 | 
					CursorRow=32
 | 
				
			||||||
TopLine=13
 | 
					TopLine=13
 | 
				
			||||||
| 
						 | 
					@ -117,14 +117,14 @@ LeftChar=1
 | 
				
			||||||
Open=0
 | 
					Open=0
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
[Editor_21]
 | 
					[Editor_21]
 | 
				
			||||||
Open=1
 | 
					Open=0
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
CursorCol=32
 | 
					CursorCol=32
 | 
				
			||||||
CursorRow=31
 | 
					CursorRow=31
 | 
				
			||||||
TopLine=4
 | 
					TopLine=4
 | 
				
			||||||
LeftChar=1
 | 
					LeftChar=1
 | 
				
			||||||
[Editor_22]
 | 
					[Editor_22]
 | 
				
			||||||
Open=1
 | 
					Open=0
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
CursorCol=1
 | 
					CursorCol=1
 | 
				
			||||||
CursorRow=11
 | 
					CursorRow=11
 | 
				
			||||||
| 
						 | 
					@ -149,3 +149,9 @@ LeftChar=1
 | 
				
			||||||
[Editor_27]
 | 
					[Editor_27]
 | 
				
			||||||
Open=0
 | 
					Open=0
 | 
				
			||||||
Top=0
 | 
					Top=0
 | 
				
			||||||
 | 
					[Editor_28]
 | 
				
			||||||
 | 
					Open=0
 | 
				
			||||||
 | 
					Top=0
 | 
				
			||||||
 | 
					[Editor_29]
 | 
				
			||||||
 | 
					Open=0
 | 
				
			||||||
 | 
					Top=0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,10 +28,15 @@ void tickSignal() {
 | 
				
			||||||
void interfaceSetInterval(const char *input_string) {
 | 
					void interfaceSetInterval(const char *input_string) {
 | 
				
			||||||
  if (input_string) {
 | 
					  if (input_string) {
 | 
				
			||||||
    int tickrate = atoi(input_string);
 | 
					    int tickrate = atoi(input_string);
 | 
				
			||||||
 | 
					    #if _WIN32 | _WIN64
 | 
				
			||||||
 | 
					    KillTimer(NULL, win_timer); 
 | 
				
			||||||
 | 
					    win_timer = SetTimer(NULL, 1, tickrate, (TIMERPROC) tickSignal);
 | 
				
			||||||
 | 
					    #else
 | 
				
			||||||
    getitimer(ITIMER_REAL, &interval);
 | 
					    getitimer(ITIMER_REAL, &interval);
 | 
				
			||||||
    interval.it_interval.tv_sec = tickrate / 1000;
 | 
					    interval.it_interval.tv_sec = tickrate / 1000;
 | 
				
			||||||
    interval.it_interval.tv_usec = (tickrate*1000) % 1000000;
 | 
					    interval.it_interval.tv_usec = (tickrate*1000) % 1000000;
 | 
				
			||||||
    setitimer(ITIMER_REAL, &interval, NULL);
 | 
					    setitimer(ITIMER_REAL, &interval, NULL);
 | 
				
			||||||
 | 
					    #endif
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -66,6 +71,10 @@ int interfaceInit() {
 | 
				
			||||||
  FD_SET(interface_fd, &master_fds);
 | 
					  FD_SET(interface_fd, &master_fds);
 | 
				
			||||||
  max_fd = interface_fd;
 | 
					  max_fd = interface_fd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  #if _WIN32 | _WIN64
 | 
				
			||||||
 | 
					  win_timer = SetTimer(NULL, 1, 500, tickSignal);
 | 
				
			||||||
 | 
					  consoleLog("augh");
 | 
				
			||||||
 | 
					  #else
 | 
				
			||||||
  /* basically instead of using linux-only timer fds, we use SIGALRM for updating the game world instead. I don't know if I agree with it. */
 | 
					  /* basically instead of using linux-only timer fds, we use SIGALRM for updating the game world instead. I don't know if I agree with it. */
 | 
				
			||||||
  if (signal(SIGALRM, (void (*)(int)) tickSignal) == SIG_ERR) {
 | 
					  if (signal(SIGALRM, (void (*)(int)) tickSignal) == SIG_ERR) {
 | 
				
			||||||
    consoleLog("Unable to catch SIGALARM for gameLoop, game is broken.");
 | 
					    consoleLog("Unable to catch SIGALARM for gameLoop, game is broken.");
 | 
				
			||||||
| 
						 | 
					@ -76,6 +85,7 @@ int interfaceInit() {
 | 
				
			||||||
  if (setitimer(ITIMER_REAL, &interval, NULL) == -1) {
 | 
					  if (setitimer(ITIMER_REAL, &interval, NULL) == -1) {
 | 
				
			||||||
    consoleLog("error calling setitmer(), game is broken");
 | 
					    consoleLog("error calling setitmer(), game is broken");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* add our commands */
 | 
					  /* add our commands */
 | 
				
			||||||
  consoleAddCommand("tickrate", interfaceSetInterval);
 | 
					  consoleAddCommand("tickrate", interfaceSetInterval);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,11 @@
 | 
				
			||||||
#ifndef NCURSES_H
 | 
					#ifndef NCURSES_H
 | 
				
			||||||
#define NCURSES_H
 | 
					#define NCURSES_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _WIN32 | _WIN64
 | 
				
			||||||
 | 
					#include <Winsock2.h>
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
#include <sys/select.h> // fd_set, etc.
 | 
					#include <sys/select.h> // fd_set, etc.
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WINDOW * screen;
 | 
					WINDOW * screen;
 | 
				
			||||||
int cols;
 | 
					int cols;
 | 
				
			||||||
| 
						 | 
					@ -15,9 +19,13 @@ fd_set master_fds;
 | 
				
			||||||
fd_set read_fds;
 | 
					fd_set read_fds;
 | 
				
			||||||
int max_fd;
 | 
					int max_fd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TODO: gameLoop timer does not work on win32. Code is there, but needs a fake window for handling message events
 | 
				
			||||||
// called on SIGALRM, calls gameLoop();
 | 
					// called on SIGALRM, calls gameLoop();
 | 
				
			||||||
void tickSignal();
 | 
					void tickSignal();
 | 
				
			||||||
 | 
					#if _WIN32 | _WIN64
 | 
				
			||||||
 | 
					HWND win_timer;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
// our so-called timer for ticking the world. aka a sigalrm
 | 
					// our so-called timer for ticking the world. aka a sigalrm
 | 
				
			||||||
struct itimerval interval;
 | 
					struct itimerval interval;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue