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).

master
kts 2014-11-20 16:21:43 -08:00
parent df41a1d911
commit 8f5ee89e81
3 changed files with 14 additions and 1 deletions

View File

@ -6,10 +6,13 @@ VPATH = src
CFLAGS = -Wall -Isrc/ -g -c CFLAGS = -Wall -Isrc/ -g -c
LFLAGS = -Wall LFLAGS = -Wall
SDL_INCLUDE = -I/usr/include
SDL_OBJS = sdl_main.o ktkMap.o ktkStructure.o ktkProgram.o ktk_parse.o SDL_OBJS = sdl_main.o ktkMap.o ktkStructure.o ktkProgram.o ktk_parse.o
SYS := $(shell uname) SYS := $(shell uname)
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
CFLAGS += $(SDL_INCLUDE)
SDL_LFLAGS += -lmingw32 -lSDLmain
SDL_LFLAGS += -lSDL SDL_LFLAGS += -lSDL
else ifeq ($(SYS),Darwin) else ifeq ($(SYS),Darwin)
SDL_OBJS += SDLMain.o SDL_OBJS += SDLMain.o
@ -24,7 +27,7 @@ $(BINARY): $(patsubst %,$(OBJ_DIR)/%,$(OBJS))
$(CC) $(LFLAGS) $^ -o $@ $(CC) $(LFLAGS) $^ -o $@
sdl: $(patsubst %,$(OBJ_DIR)/%,$(SDL_OBJS)) sdl: $(patsubst %,$(OBJ_DIR)/%,$(SDL_OBJS))
$(CC) $(LFLAGS) $(SDL_LFLAGS) $^ -o $@ $(CC) -o $@ $^ $(LFLAGS) $(SDL_LFLAGS)
tools: tools/tobmp tools: tools/tobmp
$(MAKE) -C tools $(MAKE) -C tools

View File

@ -19,6 +19,8 @@ At the moment, not much is the haps.
X - link structures X - link structures
Q - quit 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: Current structures:
castle.txt castle.txt

View File

@ -8,7 +8,11 @@ unsigned long ktk_RANDOM_SEED = 1;
unsigned long ktk_randomizeSeed() { unsigned long ktk_randomizeSeed() {
ktk_RANDOM_SEED = (unsigned long)time(0); ktk_RANDOM_SEED = (unsigned long)time(0);
#if _WIN32 | _WIN64
srand(ktk_RANDOM_SEED);
#else
srandom(ktk_RANDOM_SEED); srandom(ktk_RANDOM_SEED);
#endif
return ktk_RANDOM_SEED; return ktk_RANDOM_SEED;
} }
@ -26,7 +30,11 @@ int ktk_getRandom(int min, int max) {
} }
int buckets = RAND_MAX / range; int buckets = RAND_MAX / range;
int limit = buckets * range; int limit = buckets * range;
#if _WIN32 | _WIN64
for (num = rand(); num >= limit; num = rand());
#else
for (num = random(); num >= limit; num = random()); for (num = random(); num >= limit; num = random());
#endif
return min + (num / buckets); return min + (num / buckets);
} }