From: Joshua Grams Date: Thu, 7 Jul 2005 13:49:09 +0000 (+0000) Subject: Moved macros and such from config.h to common.h X-Git-Tag: 0.4~52 X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=commitdiff_plain;h=e0fab1bd78914a12ee88f2a9fcfca9f28a1df0f2 Moved macros and such from config.h to common.h Now using ~/.vor-scores as our only choice for score file. (it can get deleted if you put it in with data) (and locking issues if multiple users on one machine, etc.) Now passing DATA_PREFIX from Makefile as INSTALL suggests. --- diff --git a/Makefile b/Makefile index d68150b..943059a 100644 --- a/Makefile +++ b/Makefile @@ -15,10 +15,16 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -ldflags := $(shell sdl-config --libs) -lSDL_image -lSDL_mixer -cflags := $(shell sdl-config --cflags) -Wall -DDEBUG=$(if $(DEBUG),1,0) -cflags := $(strip $(cflags)) -cflags += $(CFLAGS) +DATA_PREFIX := /usr/share/vor +PROGRAM_PREFIX := /usr/games/bin + +debug := $(if $(DEBUG),-DDEBUG=1) +paths := -DDATA_PREFIX=\"$(DATA_PREFIX)\" +sdl-cflags := $(shell sdl-config --cflags) +sdl-ldflags := $(shell sdl-config --libs) + +ldflags := $(sdl-ldflags) -lSDL_image -lSDL_mixer +cflags := $(sdl-cflags) $(debug) $(paths) $(CFLAGS) my_objects := args.o file.o rocks.o score.o shape.o sound.o my_objects += $(if $(DEBUG),debug.o) main.o @@ -30,15 +36,12 @@ rocks += 10 11 12 13 14 15 16 17 18 19 rocks += 20 21 22 23 24 25 26 27 28 29 rocks += 30 31 32 33 34 35 36 37 38 39 rocks += 40 41 42 43 44 45 46 47 48 49 +rocks := $(rocks:%=data/sprites/rock%.png) +graphics := data/sprites/ship.png data/indicators/life.png $(rocks) -graphics := data/sprites/ship.png data/indicators/life.png $(rocks:%=data/sprites/rock%.png) - -INSTALL = install -INSTALL_PROGRAM = $(INSTALL) -o games -g games -INSTALL_DATA = $(INSTALL) -m 644 - -DATA_PREFIX = /usr/share/vor -PROGRAM_PREFIX = /usr/games/bin +INSTALL := install +INSTALL_PROGRAM := $(INSTALL) -o games -g games +INSTALL_DATA := $(INSTALL) -m 644 .PHONY: all clean maintainer-clean install uninstall @@ -53,14 +56,16 @@ data: $(graphics) program: vor %.o: %.c - $(CC) $(cflags) -c -o $@ $< + @echo compiling $@ from $< + @$(CC) $(cflags) -c -o $@ $< $(my_objects): config.h main.o file.o: file.h vor: $(objects) - $(CC) $(ldflags) -o $@ $^ $(LIBRARIES) + @echo linking $@ from $^ + @$(CC) $(ldflags) -o $@ $^ $(LIBRARIES) include gfx.mk diff --git a/common.h b/common.h index ac9d87e..be0910e 100644 --- a/common.h +++ b/common.h @@ -25,4 +25,13 @@ #define abs(a) ((a)<=0 ? -(a) : (a)) #endif +#define CONDERROR(a) if((a)) {initerror = strdup(SDL_GetError());return 1;} +#define NULLERROR(a) CONDERROR((a) == NULL) + +#ifndef DEBUG +#define DEBUG 0 +#endif + +#define debug(x) if(DEBUG) { x; } + #endif // VOR_COMMON_H diff --git a/config.h b/config.h index 2eaf0ab..99bed8f 100644 --- a/config.h +++ b/config.h @@ -1,50 +1,42 @@ #ifndef VOR_CONFIG_H #define VOR_CONFIG_H -#define debug(x) if(DEBUG) { x; } - #define VERSION "0.4pre" -#define DATA_PREFIX "/usr/share/vor" // screen size #define XSIZE 640 #define YSIZE 480 -// number of rock image files. -#define NROCKS 50 +#define SCREENDXMIN 7.5 + // image file containing font for score stuff. #define BIG_FONT_FILE "fonts/score.png" -#define I_ROCKS 25 // initial/final counts for rocks-on-screen. + + +// ----------------------------------------------------------------------- +// Rocks + +// number of rock images +#define NROCKS 50 + +// initial/final counts for rocks-on-screen +#define I_ROCKS 25 #define F_ROCKS 45 -#define SCREENDXMIN 7.5 +// number of rock structs to allocate +#define MAXROCKS 120 -#define MAXROCKS 120 // MAX Rocks -#define ROCKRATE 2 #define MAXENGINEDOTS 5000 #define MAXBANGDOTS 50000 #define MAXSPACEDOTS 2000 #define MAXDUSTDEPTH 2 #define W 100 #define M 255 -#define BLAST_RADIUS 300 // radius^2 (pixels) which will be cleared of rocks when you die + +// radius^2 (pixels) which will be cleared of rocks when you die +#define BLAST_RADIUS 300 #define DEAD_PAUSE_LENGTH 40.0 #define MAX_PATH_LEN 1024 -#ifndef true -#define true 1 -#endif - -#ifndef false -#define false 0 -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#define CONDERROR(a) if((a)) {initerror = strdup(SDL_GetError());return 1;} -#define NULLERROR(a) CONDERROR((a) == NULL) - #endif // VOR_CONFIG_H diff --git a/file.c b/file.c index 18193b2..9461616 100644 --- a/file.c +++ b/file.c @@ -16,9 +16,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "config.h" -#include "file.h" - #include #include #include @@ -26,6 +23,10 @@ #include #include +#include "common.h" +#include "config.h" +#include "file.h" + char *g_data_dir; char *g_score_file; mode_t g_score_mode; @@ -80,16 +81,9 @@ find_data_dir(void) int find_score_file(void) { - g_score_file = add_path("scores"); - g_score_mode = 0111; - if(is_file(g_score_file)) { - g_score_file = strdup(g_score_file); - return true; - } - g_score_file = malloc(MAX_PATH_LEN); snprintf(g_score_file, MAX_PATH_LEN, - "%s/.vor-high", getenv("HOME")); + "%s/.vor-scores", getenv("HOME")); g_score_mode = 0177; if(is_file(g_score_file)) return true; diff --git a/rocks.c b/rocks.c index 9c2728c..03f8671 100644 --- a/rocks.c +++ b/rocks.c @@ -3,6 +3,7 @@ #include #include +#include "common.h" #include "config.h" #include "file.h" #include "globals.h" diff --git a/score.c b/score.c index f37fc66..31025a9 100644 --- a/score.c +++ b/score.c @@ -16,12 +16,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "config.h" - -#include "SFont.h" -#include "file.h" -#include "score.h" - #include #include #include @@ -29,6 +23,13 @@ #include #include +#include "SFont.h" + +#include "common.h" +#include "config.h" +#include "file.h" +#include "score.h" + // High score table struct highscore g_scores[N_SCORES] = { {1*60*1000,"-"}, diff --git a/sound.c b/sound.c index 88d8d4c..480690d 100644 --- a/sound.c +++ b/sound.c @@ -1,6 +1,13 @@ +#include +#include +#include +#include +#include + #include "args.h" -#include "sound.h" +#include "common.h" #include "config.h" +#include "sound.h" #define TUNE_TITLE_PAGE 0 #define TUNE_GAMEPLAY 1 diff --git a/sound.h b/sound.h index fda2611..5f5a586 100644 --- a/sound.h +++ b/sound.h @@ -19,12 +19,6 @@ #ifndef VOR_SOUND_H #define VOR_SOUND_H -#include -#include -#include -#include -#include - int init_sound(void); void play_sound(int i); void play_tune(int i);