diff options
Diffstat (limited to 'src/base')
| -rw-r--r-- | src/base/myTimer.c | 38 | ||||
| -rw-r--r-- | src/base/net_multiplayer.c | 10 |
2 files changed, 41 insertions, 7 deletions
diff --git a/src/base/myTimer.c b/src/base/myTimer.c index 7bfb91a..114f9d7 100644 --- a/src/base/myTimer.c +++ b/src/base/myTimer.c @@ -14,6 +14,44 @@ #include "interface.h" #endif +#ifdef __WIN32__ +#include <windows.h> +#include <time.h> +#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL +struct timezone +{ + int tz_minuteswest; + int tz_dsttime; +}; + +int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + FILETIME ft; + unsigned __int64 tmpres = 0; + static int tzflag; + if (NULL != tv) { + GetSystemTimeAsFileTime(&ft); + tmpres |= ft.dwHighDateTime; + tmpres <<= 32; + tmpres |= ft.dwLowDateTime; + /*converting file time to unix epoch*/ + tmpres /= 10; /*convert into microseconds*/ + tmpres -= DELTA_EPOCH_IN_MICROSECS; + tv->tv_sec = (long)(tmpres / 1000000UL); + tv->tv_usec = (long)(tmpres % 1000000UL); + } + if (NULL != tz) { + if (!tzflag) { + _tzset(); + tzflag++; + } + tz->tz_minuteswest = _timezone / 60; + tz->tz_dsttime = _daylight; + } + return 0; +} +#endif + static struct timeval start = { .tv_sec = 0, .tv_usec = 0 }; list_t* newTimer() diff --git a/src/base/net_multiplayer.c b/src/base/net_multiplayer.c index 43a9508..3404581 100644 --- a/src/base/net_multiplayer.c +++ b/src/base/net_multiplayer.c @@ -16,10 +16,6 @@ #include "udp.h" #endif -#ifdef SUPPORT_NET_SDL_UDP -#include "sdl_udp.h" -#endif - #ifndef PUBLIC_SERVER #include "screen_setting.h" #include "screen_choiceArena.h" @@ -56,8 +52,8 @@ int initNetMuliplayer(int type, char *ip, int port, int proto) case NET_GAME_TYPE_SERVER : if( initUdpServer(ip, port, proto) != 0 ) { - fprintf(stderr, "Neomzem inicalizovat sietovu hru pre server !\n"); - netGameType = NET_GAME_TYPE_NONE; + fprintf(stderr, "Unable to inicialize network game as server!\n"); + netGameType = NET_GAME_TYPE_NONE; return -1; } break; @@ -66,7 +62,7 @@ int initNetMuliplayer(int type, char *ip, int port, int proto) case NET_GAME_TYPE_CLIENT : if( initUdpClient(ip, port, proto) != 0 ) { - fprintf(stderr, "Neomzem inicalizovat sietovu hru pre clienta !\n"); + fprintf(stderr, "Unable to inicialize network game as client!\n"); netGameType = NET_GAME_TYPE_NONE; return -1; } |