Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am8
-rw-r--r--src/client/client.cc2
-rw-r--r--src/client/client.h2
-rw-r--r--src/client/video.cc3
-rw-r--r--src/core/application.cc5
-rw-r--r--src/core/netclient.h4
-rw-r--r--src/core/netconnection.cc6
-rw-r--r--src/core/netconnection.h4
-rw-r--r--src/core/netserver.cc19
-rw-r--r--src/core/netserver.h4
-rw-r--r--src/filesystem/filesystem.cc6
-rw-r--r--src/osirion.cc2
-rw-r--r--src/render/gl.h4
-rw-r--r--src/sys/sys.cc18
14 files changed, 66 insertions, 21 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 90ddbed..bdb46ee 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,11 +8,13 @@ bin_PROGRAMS = osiriond osirion
# dedicated server
osiriond_SOURCES = osiriond.cc
osiriond_LDADD = $(top_builddir)/src/game/libgame.la \
- $(top_builddir)/src/core/libcore.la $(top_builddir)/src/server/libserver.la
+ $(top_builddir)/src/core/libcore.la $(top_builddir)/src/server/libserver.la \
+ $(HOST_LIBS)
# client
osirion_SOURCES = osirion.cc
osirion_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS) $(GLUT_CFLAGS)
osirion_LDADD = $(top_builddir)/src/game/libgame.la \
- $(top_builddir)/src/core/libcore.la $(top_builddir)/src/client/libclient.la
-osirion_LDFLAGS = $(GL_LIBS) $(LIBSDL_LIBS)
+ $(top_builddir)/src/core/libcore.la $(top_builddir)/src/client/libclient.la \
+ $(HOST_LIBS) $(GL_LIBS)
+osirion_LDFLAGS = $(LIBSDL_LIBS)
diff --git a/src/client/client.cc b/src/client/client.cc
index 99bd41f..b09618e 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -60,7 +60,7 @@ void func_r_restart(std::stringstream &args)
//--- public ------------------------------------------------------
-void main(int count, char **arguments)
+void client_main(int count, char **arguments)
{
std::cout << core::name() << " " << core::version() << std::endl;
diff --git a/src/client/client.h b/src/client/client.h
index 2113202..b1a50df 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -11,7 +11,7 @@
namespace client {
/// the client main loop
-void main(int count, char **arguments);
+void client_main(int count, char **arguments);
}
diff --git a/src/client/video.cc b/src/client/video.cc
index a7a74d5..e41f774 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -215,7 +215,7 @@ void screenshot()
unsigned char *rgb_data = (unsigned char *) malloc(video::width * video::height * 3);
// read OpenGL pixels into the buffer
- //glReadBuffer(GL_FRONT);
+ //glReadBuffer(GL_BACK);
glReadPixels(0, 0, (GLsizei) video::width, (GLsizei) video::height, GL_RGB, GL_UNSIGNED_BYTE, (void *) rgb_data);
// either OpenGL actually returns BGR, or TGA wants BGR
@@ -233,7 +233,6 @@ void screenshot()
// close file
ofs.close();
-
con_print << "Wrote " << shortname << std::endl;
}
diff --git a/src/core/application.cc b/src/core/application.cc
index d1dbcc0..485bac2 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -98,6 +98,7 @@ void func_name(std::string const &args) {
extern "C" void signal_handler(int signum)
{
+#ifndef _WIN32
switch (signum) {
case SIGHUP:
case SIGINT:
@@ -117,6 +118,7 @@ extern "C" void signal_handler(int signum)
application()->quit(1);
break;
}
+#endif
}
// --------------- Application -----------------------------
@@ -134,10 +136,13 @@ Application::Application()
application_time = 0;
application_game = 0;
+#ifndef _WIN32
sys::signal(SIGHUP, signal_handler);
sys::signal(SIGINT, signal_handler);
sys::signal(SIGQUIT, signal_handler);
sys::signal(SIGTERM, signal_handler);
+#endif
+
}
Application::~Application()
diff --git a/src/core/netclient.h b/src/core/netclient.h
index 49f509c..7176260 100644
--- a/src/core/netclient.h
+++ b/src/core/netclient.h
@@ -10,12 +10,16 @@
#include <unistd.h>
#include <errno.h>
+#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#else
+#include <windows.h>
+#endif
#include <string>
#include <deque>
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index b640595..18ae3bc 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -74,8 +74,12 @@ void NetConnection::connect(std::string const &to_host, int to_port)
connection_error = false;
FD_ZERO(&clientset);
+#ifdef _WIN32
+ FD_SET((unsigned int) fd(), &clientset);
+#else
FD_SET(fd(), &clientset);
-
+#endif
+
connection_timeout = application()->time();
connection_keepalive = application()->time();
diff --git a/src/core/netconnection.h b/src/core/netconnection.h
index 08536de..3cc28db 100644
--- a/src/core/netconnection.h
+++ b/src/core/netconnection.h
@@ -10,6 +10,7 @@
#include <unistd.h>
#include <errno.h>
+#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
@@ -19,6 +20,9 @@
#include <sys/select.h>
#include <netdb.h>
+#else
+#include <windows.h>
+#endif
#include <string>
#include <deque>
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 3b17a65..e3e01a3 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -7,12 +7,16 @@
#include <unistd.h>
#include <errno.h>
+#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#else
+#include <windows.h>
+#endif
#include <iostream>
#include <sstream>
@@ -25,6 +29,10 @@
#include "core/func.h"
#include "core/core.h"
+#ifdef _WIN32
+ typedef int socklen_t;
+#endif
+
namespace core
{
@@ -43,7 +51,8 @@ NetServer::NetServer(std::string const host, unsigned int const port)
//perror("socket");
return;
}
-
+
+ /*
// set socket options
socklen_t yes = 1;
if (::setsockopt(netserver_fd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(socklen_t)) == -1) {
@@ -51,6 +60,7 @@ NetServer::NetServer(std::string const host, unsigned int const port)
//perror("setsockopt");
return;
}
+ */
// Get the local adress to bind to
netserver_addr.sin_family = AF_INET;
@@ -77,8 +87,11 @@ NetServer::NetServer(std::string const host, unsigned int const port)
// add the listening socket to the file descriptor set
FD_ZERO(&serverset);
+#ifdef _WIN32
+ FD_SET((unsigned int) netserver_fd, &serverset);
+#else
FD_SET(netserver_fd, &serverset);
-
+#endif
netserver_error = false;
}
@@ -173,7 +186,7 @@ void NetServer::receive()
while (nb && FD_ISSET(fd(), &readset)) {
// receive incoming data
- struct sockaddr_in client_addr;
+ struct sockaddr_in client_addr;
socklen_t client_addr_len = sizeof(client_addr);
memset(recbuf, '\0', sizeof(recbuf));
ssize_t bytes_received = ::recvfrom(fd(), recbuf, FRAMESIZE-1, 0, (struct sockaddr *)&client_addr, &client_addr_len);
diff --git a/src/core/netserver.h b/src/core/netserver.h
index de923b9..5850b29 100644
--- a/src/core/netserver.h
+++ b/src/core/netserver.h
@@ -7,7 +7,11 @@
#ifndef __INCLUDED_CORE_NETSERVER_H__
#define __INCLUDED_CORE_NETSERVER_H__
+#ifndef _WIN32
#include <sys/select.h>
+#else
+#include <windows.h>
+#endif
#include <list>
#include <string>
diff --git a/src/filesystem/filesystem.cc b/src/filesystem/filesystem.cc
index f34ac42..130aeb7 100644
--- a/src/filesystem/filesystem.cc
+++ b/src/filesystem/filesystem.cc
@@ -32,9 +32,13 @@ void init()
moddir = "";
// FIXME win32
+#ifndef _WIN32
homedir = getenv("HOME");
homedir = homedir + "/.osirion/";
-
+#else
+ homedir = "./home/";
+#endif
+
sys::mkdir(homedir);
sys::mkdir(homedir+basedir);
diff --git a/src/osirion.cc b/src/osirion.cc
index 6fa2eb3..2f0a5eb 100644
--- a/src/osirion.cc
+++ b/src/osirion.cc
@@ -12,7 +12,7 @@ int main(int count, char **arguments)
// preload the game module
core::Module::load(new game::Game());
- client::main(count, arguments);
+ client::client_main(count, arguments);
// unload the game module
core::Module::unload();
diff --git a/src/render/gl.h b/src/render/gl.h
index d5d6418..9153435 100644
--- a/src/render/gl.h
+++ b/src/render/gl.h
@@ -12,6 +12,10 @@
#include "math/vector3f.h"
#include "math/color.h"
+#ifdef _WIN32
+#define GL_RESCALE_NORMAL 0x803A
+#endif
+
namespace render {
/// wrapper namespace for OpenGL operations
diff --git a/src/sys/sys.cc b/src/sys/sys.cc
index a9958f4..4c3f38f 100644
--- a/src/sys/sys.cc
+++ b/src/sys/sys.cc
@@ -4,13 +4,10 @@
the terms of the GNU General Public License version 2
*/
-// project headers
-#include "sys/sys.h"
-// system headers
#ifdef _WIN32
-#include <dlfcn.h>
+#include <windows.h>
#else
@@ -21,15 +18,17 @@
#include <sys/types.h>
#endif
+
#include <stdlib.h>
+#include "sys/sys.h"
+
namespace sys {
void mkdir(const char *path)
{
#ifdef _WIN32
- ::mkdir(path);
- return true;
+ mkdir(path);
#else
::mkdir(path, 0777);
#endif
@@ -60,14 +59,16 @@ unsigned long time()
::localtime_r(&epochtime, &localtime);
return ((unsigned long) (localtime.tm_sec + localtime.tm_min*60 + localtime.tm_hour*3600));
#else
- retrun 0;
+ return 0;
#endif
}
void sleep(float seconds)
{
#ifndef _WIN32
- ::usleep((useconds_t) (seconds * 1000000.0) );
+ ::usleep((useconds_t) (seconds * 1000000.0f) );
+#else
+ Sleep((DWORD) (seconds*1000.0f));
#endif
}
@@ -76,3 +77,4 @@ void quit(int status) {
}
}
+