Permalink
Browse files

Windows Zeugs

git-svn-id: http://infon.googlecode.com/svn/trunk@131 8171fb75-e542-0410-96e4-03d5dd800671
  • Loading branch information...
1 parent 27129e8 commit 2480f16f2d5f115ac3eec1f69cab168edbda0320 @dividuum committed Dec 13, 2006
Showing with 25 additions and 10 deletions.
  1. +1 −0 Makefile
  2. +3 −3 client.c
  3. +2 −2 infon.rc
  4. +10 −0 misc.c
  5. +3 −0 misc.h
  6. +1 −1 renderer.c
  7. +5 −4 sdl_video.c
View
@@ -76,6 +76,7 @@ $(SDL_RENDERER) : CFLAGS += -I$(SDLDIR)/include/SDL
$(SDL_RENDERER) : LDFLAGS += $(MINGW)/lib/libSGE.a $(MINGW)/lib/libevent.a $(MINGW)/lib/libSDL_image.a \
$(MINGW)/lib/libpng.a $(MINGW)/lib/libz.a $(MINGW)/lib/libSDL_gfx.a $(MINGW)/lib/libSDL.a \
-lmingw32 -lstdc++ -lwsock32 -lwinmm -mwindows -Wl,-s
+$(SDL_RENDERER) : infon.res
else
$(INFON_EXECUTABLE) : LDFLAGS += -levent -lz -lm
View
@@ -347,7 +347,7 @@ int client_open_socket(char *addr) {
host = gethostbyname(addr);
if (!host)
#ifdef WIN32
- die("gethostbyname failed: %d", WSAGetLastError());
+ die("gethostbyname failed: %s", ErrorString(WSAGetLastError()));
#else
die("gethostbyname failed: %s", hstrerror(h_errno));
#endif
@@ -365,15 +365,15 @@ int client_open_socket(char *addr) {
/* Fehler beim Socket erzeugen? */
#ifdef WIN32
if (fd == INVALID_SOCKET)
- die("cannot open socket: Error %d", WSAGetLastError());
+ die("cannot open socket: %s", ErrorString(WSAGetLastError()));
#else
if (fd == -1)
die("cannot open socket: %s", strerror(errno));
#endif
#ifdef WIN32
if (connect(fd, (struct sockaddr *)&serveraddr, sizeof(serveraddr)) == SOCKET_ERROR)
- die("cannot connect socket: Error %d", WSAGetLastError());
+ die("cannot connect socket: %s", ErrorString(WSAGetLastError()));
#else
if (connect(fd, (struct sockaddr *)&serveraddr, sizeof(serveraddr)) < 0)
die("cannot connect socket: %s", strerror(errno));
View
@@ -1,8 +1,8 @@
#include <windows.h>
-A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "infon.ico"
+icon ICON MOVEABLE PURE LOADONCALL DISCARDABLE "infon.ico"
-1 VERSIONINFO
+1 VERSIONINFO
FILETYPE VFT_APP
{
BLOCK "StringFileInfo"
View
10 misc.c
@@ -62,3 +62,13 @@ int yesno(const char *fmt, ...) {
#endif
}
+#ifdef WIN32
+const char *ErrorString(int error) {
+ static char buf[4096];
+ if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, error, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) buf, sizeof (buf), NULL))
+ snprintf(buf, sizeof(buf), "errorcode %d", error);
+ return buf;
+}
+#endif
View
3 misc.h
@@ -23,6 +23,9 @@
void die(const char *fmt, ...);
int yesno(const char *fmt, ...);
+#ifdef WIN32
+const char *ErrorString(int error);
+#endif
#ifndef abs
#define abs(a) ((a)<0?-(a):(a))
View
@@ -108,7 +108,7 @@ int renderer_open_file(const char *shared) {
dlhandle = LoadLibrary(shared);
if (!dlhandle) {
- fprintf(stderr, "LoadLibrary failed: %d\n", GetLastError());
+ fprintf(stderr, "LoadLibrary failed: %s\n", ErrorString(GetLastError()));
goto failed;
}
View
@@ -20,6 +20,7 @@
#include <SDL.h>
#include <SDL_gfxPrimitives.h>
+#include <SDL_syswm.h>
#include <sge.h>
#include <stdio.h>
#include <string.h>
@@ -60,13 +61,13 @@ void video_init(int w, int h, int fs) {
video_set_title(GAME_NAME);
SDL_ShowCursor(1);
-#if 0
+#if 1
SDL_SysWMinfo wminfo;
if (SDL_GetWMInfo(&wminfo) == 1) {
HWND hwnd = wminfo.window;
- HINSTANCE handle = ::GetModuleHandle(NULL);
- HICON icon = ::LoadIcon(handle, "icon");
- ::SetClassLong(hwnd, GCL_HICON, (LONG) icon);
+ HINSTANCE handle = GetModuleHandle(NULL);
+ HICON icon = LoadIcon(handle, "icon");
+ SetClassLong(hwnd, GCL_HICON, (LONG) icon);
}
#endif
//SDL_EnableUNICODE(1);

0 comments on commit 2480f16

Please sign in to comment.