Merge branch 'windows' into cleanup

Conflicts:
	src/common/filesystem.c
	src/sdl/input.c
	src/sdl/refresh.c
	src/unix/system.c
This commit is contained in:
Yamagi Burmeister 2012-06-11 11:21:16 +02:00
commit 060235e7dd
16 changed files with 126 additions and 68 deletions

View file

@ -185,11 +185,27 @@ endif
# ----------
# Phony targets
.PHONY : all client game icon refresher server
# ----------
# Builds everything
all: client server refresher game
# ----------
# Special target to compile
# the icon on Windows
ifeq ($(OSTYPE), Windows)
icon:
@echo "===> WR build/icon/icon.res"
${Q}stuff/misc/mkdir -p build/icon
${Q}windres stuff\icon\icon.rc -O COFF -o build\icon\icon.res
endif
# ----------
# Cleanup
ifeq ($(OSTYPE), Windows)
clean:
@ -627,9 +643,9 @@ GAME_DEPS= $(GAME_OBJS:.o=.d)
# release/quake2
ifeq ($(OSTYPE), Windows)
release/quake2.exe : $(CLIENT_OBJS)
release/quake2.exe : $(CLIENT_OBJS) icon
@echo "===> LD $@"
${Q}$(CC) $(CLIENT_OBJS) $(LDFLAGS) $(SDLLDFLAGS) -o $@
${Q}$(CC) build/icon/icon.res $(CLIENT_OBJS) $(LDFLAGS) $(SDLLDFLAGS) -o $@
else
release/quake2 : $(CLIENT_OBJS)
@echo "===> LD $@"
@ -638,9 +654,9 @@ endif
# release/q2ded
ifeq ($(OSTYPE), Windows)
release/q2ded.exe : $(SERVER_OBJS)
release/q2ded.exe : $(SERVER_OBJS) icon
@echo "===> LD $@.exe"
${Q}$(CC) $(SERVER_OBJS) $(LDFLAGS) -o $@
${Q}$(CC) build/icon/icon.res $(SERVER_OBJS) $(LDFLAGS) -o $@
else
release/q2ded : $(SERVER_OBJS)
@echo "===> LD $@"

View file

@ -578,7 +578,7 @@ void CL_InitLocal (void)
void CL_WriteConfiguration (void)
{
FILE *f;
char path[MAX_QPATH];
char path[MAX_OSPATH];
if (cls.state == ca_uninitialized)
return;

View file

@ -31,10 +31,15 @@
#ifdef USE_OPENAL
#include "../header/client.h"
#include "../../unix/header/qal.h"
#include "header/local.h"
#include "header/vorbis.h"
#ifdef _WIN32
#include "../../windows/header/qal.h"
#else
#include "../../unix/header/qal.h"
#endif
/* translates from AL coordinate system to quake */
#define AL_UnpackVector(v) - v[1], v[2], -v[0]
#define AL_CopyVector(a, b) ((b)[0] = -(a)[1], (b)[1] = (a)[2], (b)[2] = \

View file

@ -27,10 +27,15 @@
*/
#include "../header/client.h"
#include "../../unix/header/qal.h"
#include "header/local.h"
#include "header/vorbis.h"
#ifdef _WIN32
#include "../../windows/header/qal.h"
#else
#include "../../unix/header/qal.h"
#endif
void S_Play(void);
void S_SoundList(void);
void S_StopAllSounds(void);

View file

@ -1357,49 +1357,18 @@ FS_AddGameDirectory(const char *dir)
void
FS_AddHomeAsGameDirectory(char *dir)
{
char *home;
char gdir[MAX_OSPATH];
int len;
size_t len;
#ifdef _WIN32
char *cur;
char *old;
char *profile = getenv("USERPROFILE");
home = Sys_GetHomeDir();
if (!profile)
if (home == NULL)
{
return;
}
cur = old = profile;
/* Replace backslashes with slashes */
if (strstr(cur, "\\") != NULL)
{
while (cur != NULL)
{
if ((cur - old) > 1)
{
*cur = '/';
}
old = cur;
cur = strchr(old + 1, '\\');
}
}
len = snprintf(gdir, sizeof(gdir), "%s%s%s/", profile,
"/Documents/YamagiQ2/", dir);
#else
char *homedir = getenv("HOME");
if (!homedir)
{
return;
}
len = snprintf(gdir, sizeof(gdir), "%s/.yq2/%s/", homedir, dir);
#endif
len = snprintf(gdir, sizeof(gdir), "%s%s/", home, dir);
FS_CreatePath(gdir);
if ((len > 0) && (len < sizeof(gdir)) && (gdir[len - 1] == '/'))

View file

@ -55,6 +55,12 @@
#define CPUSTRING "Unknown"
#endif
#ifdef _WIN32
#define CFGDIR "YamagiQ2"
#else
#define CFGDIR ".yq2"
#endif
/* ================================================================== */
typedef struct sizebuf_s
@ -741,6 +747,7 @@ void Sys_ConsoleOutput (char *string);
void Sys_SendKeyEvents (void);
void Sys_Error (char *error, ...);
void Sys_Quit (void);
char *Sys_GetHomeDir(void);
/* CLIENT / SERVER SYSTEMS */

View file

@ -53,7 +53,12 @@ typedef enum {false, true} qboolean;
#define MAX_TOKEN_CHARS 128 /* max length of an individual token */
#define MAX_QPATH 64 /* max length of a quake game pathname */
#ifdef _WIN32
#define MAX_OSPATH 256 /* max length of a filesystem pathname */
#else
#define MAX_OSPATH 128 /* max length of a filesystem pathname */
#endif
/* */
/* per-level limits */

View file

@ -24,16 +24,17 @@
*
* =======================================================================
*/
#ifdef _WIN32
#include <SDL/SDL.h>
#else
#include <SDL.h>
#endif
#include "../refresh/header/local.h"
#include "../client/header/keyboard.h"
#ifdef _WIN32
#include <SDL/SDL.h>
#include "../windows/header/winquake.h"
#else
#include <SDL.h>
#include "../unix/header/unix.h"
#endif
#define MOUSE_MAX 3000
#define MOUSE_MIN 40

View file

@ -25,16 +25,16 @@
* =======================================================================
*/
#ifdef _WIN32
#include <SDL/SDL.h>
#else
#include <SDL.h>
#endif
#include "../refresh/header/local.h"
#include <GL/gl.h>
#include "../refresh/header/local.h"
#ifdef _WIN32
#include <SDL/SDL.h>
#include "../windows/header/glwindow.h"
#else
#include <SDL.h>
#include "../unix/header/glwindow.h"
#endif
/* The window icon */
#include "icon/q2icon.xbm"

View file

@ -500,3 +500,21 @@ Sys_SendKeyEvents(void)
sys_frame_time = Sys_Milliseconds();
}
char *
Sys_GetHomeDir(void)
{
static char gdir[MAX_OSPATH];
char *home;
home = getenv("HOME");
if (!home)
{
return NULL;
}
snprintf(gdir, sizeof(gdir), "%s/%s/", home, CFGDIR);
return gdir;
}

View file

@ -27,6 +27,8 @@
#ifndef WIN_GLW_WIN_H__
#define WIN_GLW_WIN_H__
#include <windows.h>
typedef struct
{
HINSTANCE hInstance;

View file

@ -935,13 +935,8 @@ logBindTexture(GLenum target, GLuint texture)
}
static void APIENTRY
logBitmap(GLsizei width,
GLsizei height,
GLfloat xorig,
GLfloat yorig,
GLfloat xmove,
GLfloat ymove,
const GLubyte *bitmap)
logBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig,
GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)
{
fprintf(glw_state.log_fp, "glBitmap\n");
dllBitmap(width, height, xorig, yorig, xmove, ymove, bitmap);
@ -3673,8 +3668,8 @@ QGL_Shutdown(void)
/*
* This is responsible for binding our qgl function pointers to
* the appropriate GL stuff. In Windows this means doing a
* LoadLibrary and a bunch of calls to GetProcAddress. On other
* the appropriate GL stuff. In Windows this means doing a
* LoadLibrary and a bunch of calls to GetProcAddress. On other
* operating systems we need to do the right thing, whatever that
* might be.
*/

View file

@ -32,6 +32,7 @@
#include <direct.h>
#include <io.h>
#include <conio.h>
#include <shlobj.h>
#include "../common/header/common.h"
#include "header/conproc.h"
@ -204,9 +205,9 @@ Sys_Init(void)
limit Yamagi Quake II to Windows XP and
above. Testing older version would be a
PITA. */
if (!(vinfo.dwMajorVersion > 5) ||
if (!((vinfo.dwMajorVersion > 5) ||
((vinfo.dwMajorVersion == 5) &&
(vinfo.dwMinorVersion >= 1)))
(vinfo.dwMinorVersion >= 1))))
{
Sys_Error("Yamagi Quake II needs Windows XP or higher!\n");
}
@ -606,6 +607,39 @@ Sys_GetCurrentDirectory(void)
return dir;
}
char *
Sys_GetHomeDir(void)
{
char *old;
char *cur;
static char gdir[MAX_OSPATH];
TCHAR profile[MAX_OSPATH];
SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, profile);
/* Replace backslashes by slashes */
cur = old = profile;
if (strstr(cur, "\\") != NULL)
{
while (cur != NULL)
{
if ((cur - old) > 1)
{
*cur = '/';
}
old = cur;
cur = strchr(old + 1, '\\');
}
}
snprintf(gdir, sizeof(gdir), "%s/%s/", profile, CFGDIR);
return gdir;
}
/* ======================================================================= */
/*

BIN
stuff/icon/Quake2.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View file

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

1
stuff/icon/icon.rc Normal file
View file

@ -0,0 +1 @@
id ICON "stuff/icon/Quake2.ico"