Skip to content

Commit

Permalink
Windows Zeugs
Browse files Browse the repository at this point in the history
git-svn-id: http://infon.googlecode.com/svn/trunk@131 8171fb75-e542-0410-96e4-03d5dd800671
  • Loading branch information
dividuum committed Dec 13, 2006
1 parent 27129e8 commit 2480f16
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions infon.rc
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
10 changes: 10 additions & 0 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
9 changes: 5 additions & 4 deletions sdl_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <SDL.h>
#include <SDL_gfxPrimitives.h>
#include <SDL_syswm.h>
#include <sge.h>
#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2480f16

Please sign in to comment.