From 8f5ee89e810581e5b23bef42a65012fb4ec1c11b Mon Sep 17 00:00:00 2001 From: kts Date: Thu, 20 Nov 2014 16:21:43 -0800 Subject: [PATCH] main, tobmp, and sdl compile on Windows now. Added if check for windows to use old random functions. Need to debug some Windows bugs (probably stemming from bad memory access). --- Makefile | 5 ++++- README.txt | 2 ++ src/ktkStructure.c | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d660657..426cda2 100644 --- a/Makefile +++ b/Makefile @@ -6,10 +6,13 @@ VPATH = src CFLAGS = -Wall -Isrc/ -g -c LFLAGS = -Wall +SDL_INCLUDE = -I/usr/include SDL_OBJS = sdl_main.o ktkMap.o ktkStructure.o ktkProgram.o ktk_parse.o SYS := $(shell uname) ifeq ($(OS),Windows_NT) + CFLAGS += $(SDL_INCLUDE) + SDL_LFLAGS += -lmingw32 -lSDLmain SDL_LFLAGS += -lSDL else ifeq ($(SYS),Darwin) SDL_OBJS += SDLMain.o @@ -24,7 +27,7 @@ $(BINARY): $(patsubst %,$(OBJ_DIR)/%,$(OBJS)) $(CC) $(LFLAGS) $^ -o $@ sdl: $(patsubst %,$(OBJ_DIR)/%,$(SDL_OBJS)) - $(CC) $(LFLAGS) $(SDL_LFLAGS) $^ -o $@ + $(CC) -o $@ $^ $(LFLAGS) $(SDL_LFLAGS) tools: tools/tobmp $(MAKE) -C tools diff --git a/README.txt b/README.txt index 079f721..59f8ca8 100644 --- a/README.txt +++ b/README.txt @@ -19,6 +19,8 @@ At the moment, not much is the haps. X - link structures Q - quit + NOTE: for building on win32, you will need to copy SDL.dll (1.2) to the same directory as the Makefile before compiling. + Current structures: castle.txt diff --git a/src/ktkStructure.c b/src/ktkStructure.c index 9e158b1..8287631 100644 --- a/src/ktkStructure.c +++ b/src/ktkStructure.c @@ -8,7 +8,11 @@ unsigned long ktk_RANDOM_SEED = 1; unsigned long ktk_randomizeSeed() { ktk_RANDOM_SEED = (unsigned long)time(0); + #if _WIN32 | _WIN64 + srand(ktk_RANDOM_SEED); + #else srandom(ktk_RANDOM_SEED); + #endif return ktk_RANDOM_SEED; } @@ -26,7 +30,11 @@ int ktk_getRandom(int min, int max) { } int buckets = RAND_MAX / range; int limit = buckets * range; + #if _WIN32 | _WIN64 + for (num = rand(); num >= limit; num = rand()); + #else for (num = random(); num >= limit; num = random()); + #endif return min + (num / buckets); }