diff --git a/Makefile.mac b/Makefile.mac index 46847ecf..59422f8c 100644 --- a/Makefile.mac +++ b/Makefile.mac @@ -1,4 +1,4 @@ -# This Makefile works for Mac OS X (Yosemite). +# This Makefile works for Mac OS X (El Capitan). # # Run "brew install sdl" to install SDL in /usr/local. # Run "brew install sdl_gfx". @@ -7,15 +7,31 @@ # Run "make -f Makefile.mac" to build HyperRogue as ./hyper. CXXFLAGS += -std=c++11 -march=native -DMAC -# CXXFLAGS += -DCAP_ROGUEVIZ CXXFLAGS += -W -Wall -Wextra -pedantic -CXXFLAGS += -Wno-format-pedantic -Wno-unused-parameter -Wno-char-subscripts -Wno-missing-field-initializers -Wno-vla-extension -CXXFLAGS += ${EXTRA_CXXFLAGS} +CXXFLAGS += -Wno-format-pedantic -Wno-unused-parameter -Wno-missing-field-initializers -Wno-vla-extension CXXFLAGS += -I/usr/local/include +CXXFLAGS += ${EXTRA_CXXFLAGS} + LDFLAGS += -L/usr/local/lib -hyper: hyper.o - $(CXX) $(CXXFLAGS) hyper.o $(LDFLAGS) -lSDL -lSDLMain -lSDL_gfx -lSDL_mixer -lSDL_ttf -framework AppKit -framework OpenGL -o hyper +OBJS = hyper.o + +ifeq (a,b) +# Enable PNG screenshots. Requires "brew install libpng". +CXXFLAGS += -DCAP_PNG +LDFLAGS += -lpng +OBJS += savepng.o +else +CXXFLAGS += -DCAP_PNG=0 +endif + +ifeq (a,b) +# Enable RogueViz. +CXXFLAGS += -DCAP_ROGUEVIZ +endif + +hyper: $(OBJS) + $(CXX) $(CXXFLAGS) $(OBJS) $(LDFLAGS) -lSDL -lSDLMain -lSDL_gfx -lSDL_mixer -lSDL_ttf -framework AppKit -framework OpenGL -o hyper hyper.o: *.cpp language-data.cpp $(CXX) $(CXXFLAGS) -O2 -c hyper.cpp @@ -23,11 +39,13 @@ hyper.o: *.cpp language-data.cpp langen: langen.cpp language-??.cpp language-ptbr.cpp $(CXX) $(CXXFLAGS) -O0 -Wno-embedded-directive langen.cpp -o langen -# Generation of language-data.cpp language-data.cpp: langen ./langen > language-data.cpp +savepng.o: savepng.cpp + $(CXX) $(CXXFLAGS) -O2 -c savepng.cpp + .PHONY: clean clean: - rm -f langen language-data.cpp hyper.o hyper + rm -f hyper hyper.o langen language-data.cpp savepng.o diff --git a/Makefile.mgw b/Makefile.mgw index c1b5f044..f91e1020 100644 --- a/Makefile.mgw +++ b/Makefile.mgw @@ -7,11 +7,26 @@ CXXFLAGS += -std=c++11 -mwindows -DWINDOWS CXXFLAGS += -D_A_VOLID=8 -CXXFLAGS += -DCAP_PNG=0 CXXFLAGS += ${EXTRA_CXXFLAGS} -hyper.exe: hyper.obj hyper.res - $(CXX) $(CXXFLAGS) hyper.obj hyper.res -lSDL -lSDL_mixer -lopengl32 -lSDL_ttf -lSDL_gfx -lglew32 -o hyper.exe +OBJS = hyper.obj + +ifeq (a,b) +# Enable PNG screenshots. Requires libpng. +CXXFLAGS += -DCAP_PNG +LDFLAGS += -lpng +OBJS += savepng.obj +else +CXXFLAGS += -DCAP_PNG=0 +endif + +ifeq (a,b) +# Enable RogueViz. +CXXFLAGS += -DCAP_ROGUEVIZ +endif + +hyper.exe: $(OBJS) hyper.res + $(CXX) $(CXXFLAGS) $(OBJS) hyper.res -lSDL -lSDL_mixer -lopengl32 -lSDL_ttf -lSDL_gfx -lglew32 -o hyper.exe hyper.obj: *.cpp language-data.cpp hyper.res $(CXX) $(CXXFLAGS) -O2 -c hyper.cpp -o hyper.obj @@ -25,7 +40,10 @@ langen.exe: langen.cpp language-??.cpp language-ptbr.cpp language-data.cpp: langen.exe ./langen.exe > language-data.cpp +savepng.obj: savepng.cpp + $(CXX) $(CXXFLAGS) -O2 -c savepng.cpp -o savepng.obj + .PHONY: clean clean: - rm -f langen.exe language-data.cpp hyper.obj hyper.res hyper.exe + rm -f hyper.exe hyper.obj hyper.res langen.exe language-data.cpp savepng.obj diff --git a/fieldpattern.cpp b/fieldpattern.cpp index dd71ba96..7c85080c 100644 --- a/fieldpattern.cpp +++ b/fieldpattern.cpp @@ -754,7 +754,8 @@ void nextPrime(fgeomextra& ex) { fp.Prime = nextprime; if(fp.solve() == 0) { fp.build(); - ex.primes.emplace_back(primeinfo{nextprime, size(fp.matrices) / S7, (bool) fp.wsquare}); + int cells = fp.matrices.size() / S7; + ex.primes.emplace_back(primeinfo{nextprime, cells, (bool) fp.wsquare}); break; } nextprime++; diff --git a/hyper.h b/hyper.h index 6253fa55..e313e831 100644 --- a/hyper.h +++ b/hyper.h @@ -6,6 +6,8 @@ #define VERNUM 10403 #define VERNUM_HEX 0xA0B3 +#include + namespace hr { using namespace std; @@ -368,7 +370,7 @@ string its(int i); int hrand(int i); #ifndef STDSIZE -template int size(const T& x) {return int(x.size()); } +template int size(const T& x) {return x.size(); } #endif // initialize the achievement system. @@ -3433,7 +3435,15 @@ int score_default(int id); void handle_event(SDL_Event& ev); #ifndef XPRINTF -template void Xprintf(const char *fmt, T... t) { printf(fmt, t...); } +#ifdef __GNUC__ +__attribute__((__format__ (__printf__, 1, 2))) +#endif +void Xprintf(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); +} #endif void pop_game(); @@ -3507,4 +3517,4 @@ bool confusingGeometry(); int revhint(cell *c, int hint); -} \ No newline at end of file +} diff --git a/langen.cpp b/langen.cpp index 724c6aa8..1600ae50 100644 --- a/langen.cpp +++ b/langen.cpp @@ -14,7 +14,9 @@ #include using namespace std; -template int size(T x) { return x.size(); } +#ifndef STDSIZE +template int size(const T& x) { return x.size(); } +#endif #define NUMLAN 7 diff --git a/rogueviz-video.cpp b/rogueviz-video.cpp index f3d66066..80eaf4c4 100644 --- a/rogueviz-video.cpp +++ b/rogueviz-video.cpp @@ -23,7 +23,7 @@ void rvvideo(const string &fname) { reached = (2*reached-1) / 3; else reached *= 2; } - printf("reached = %Ld\n", reached); + printf("reached = %lld\n", reached); vector seq; while(reached>1) { seq.push_back(llts(reached)); diff --git a/savepng.c b/savepng.cpp similarity index 98% rename from savepng.c rename to savepng.cpp index 72a05de3..bc74ce50 100644 --- a/savepng.c +++ b/savepng.cpp @@ -35,6 +35,9 @@ static void png_write_SDL(png_structp png_ptr, png_bytep data, png_size_t length SDL_RWwrite(rw, data, sizeof(png_byte), length); } +#ifdef __cplusplus +extern "C" +#endif SDL_Surface *SDL_PNGFormatAlpha(SDL_Surface *src) { SDL_Surface *surf; @@ -56,6 +59,9 @@ SDL_Surface *SDL_PNGFormatAlpha(SDL_Surface *src) return surf; } +#ifdef __cplusplus +extern "C" +#endif int SDL_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst) { png_structp png_ptr; diff --git a/sysconfig.h b/sysconfig.h index 67871b14..be93aeb0 100644 --- a/sysconfig.h +++ b/sysconfig.h @@ -88,7 +88,7 @@ #define CAP_SDL (!ISMOBILE) #endif -#ifdef CAP_COMPASS +#ifndef CAP_COMPASS #define CAP_COMPASS ISMOBILE #endif