Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
211 changes: 105 additions & 106 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,114 +1,113 @@
include config.mk

SDL_FLAGS = `sdl-config --cflags` `sdl-config --libs`
LIBTCODDIR=src/libtcod-1.5.2
CFLAGS=-Isrc/brogue -Isrc/platform -Wall -Wno-parentheses ${DEFINES}
RELEASENAME=brogue-1.7.4
LASTTARGET := $(shell ./brogue --target)
CC ?= gcc

ifeq (${LASTTARGET},both)
all : both
else ifeq (${LASTTARGET},curses)
all : curses
else ifeq (${LASTTARGET},tcod)
all : tcod
cflags := -Isrc/brogue -Isrc/platform -std=c99 \
-Wall -Wpedantic -Werror=implicit -Wno-parentheses -Wno-unused-result \
-Wformat -Werror=format-security -Wformat-overflow=0
libs := -lm
cppflags := -DDATADIR=$(DATADIR)

sources := $(wildcard src/brogue/*.c) $(addprefix src/platform/,main.c platformdependent.c)

ifeq ($(RELEASE),YES)
extra_version :=
else
all : both
extra_version := $(shell bash tools/git-extra-version)
endif
cppflags += -DBROGUE_EXTRA_VERSION='"$(extra_version)"'

ifeq ($(TERMINAL),YES)
sources += $(addprefix src/platform/,curses-platform.c term.c)
cppflags += -DBROGUE_CURSES
libs += -lncurses
endif

ifeq ($(GRAPHICS),YES)
sources += $(addprefix src/platform/,sdl2-platform.c tiles.c)
cflags += $(shell $(SDL_CONFIG) --cflags)
cppflags += -DBROGUE_SDL
libs += $(shell $(SDL_CONFIG) --libs) -lSDL2_image
endif

ifeq ($(WEBBROGUE),YES)
sources += $(addprefix src/platform/,web-platform.c)
cppflags += -DBROGUE_WEB
endif

ifeq ($(MAC_APP),YES)
cppflags += -DSDL_PATHS
endif

%.o : %.c Makefile src/brogue/Rogue.h src/brogue/IncludeGlobals.h
$(CC) $(CFLAGS) -g -o $@ -c $<

BROGUEFILES=src/brogue/Architect.o \
src/brogue/Bot.o \
src/brogue/Combat.o \
src/brogue/Dijkstra.o \
src/brogue/Globals.o \
src/brogue/IO.o \
src/brogue/Items.o \
src/brogue/Light.o \
src/brogue/Monsters.o \
src/brogue/Buttons.o \
src/brogue/Movement.o \
src/brogue/Recordings.o \
src/brogue/RogueMain.o \
src/brogue/Random.o \
src/brogue/MainMenu.o \
src/brogue/Grid.o \
src/brogue/Time.o \
src/platform/main.o \
src/platform/platformdependent.o \
src/platform/curses-platform.o \
src/platform/tcod-platform.o \
src/platform/term.o

TCOD_DEF = -DBROGUE_TCOD -I$(LIBTCODDIR)/include
TCOD_DEP = ${LIBTCODDIR}
TCOD_LIB = -L. -L${LIBTCODDIR} ${SDL_FLAGS} -ltcod -Wl,-rpath,.

CURSES_DEF = -DBROGUE_CURSES
CURSES_LIB = -lncurses -lm

LIBRARIES += -llua

tcod : DEPENDENCIES += ${TCOD_DEP}
tcod : DEFINES += ${TCOD_DEF}
tcod : LIBRARIES += ${TCOD_LIB}

curses : DEFINES += ${CURSES_DEF}
curses : LIBRARIES += ${CURSES_LIB}

both : DEPENDENCIES += ${TCOD_DEP}
both : DEFINES += ${TCOD_DEF} ${CURSES_DEF}
both : LIBRARIES += ${TCOD_LIB} ${CURSES_LIB}

ifeq (${LASTTARGET},both)
both : bin/brogue
tcod : clean bin/brogue
curses : clean bin/brogue
else ifeq (${LASTTARGET},curses)
curses : bin/brogue
tcod : clean bin/brogue
both : clean bin/brogue
else ifeq (${LASTTARGET},tcod)
tcod : bin/brogue
curses : clean bin/brogue
both : clean bin/brogue
ifeq ($(DEBUG),YES)
cflags += -g -Og
cppflags += -DENABLE_PLAYBACK_SWITCH
else
both : bin/brogue
curses : bin/brogue
tcod : bin/brogue
cflags += -O2
endif

.PHONY : clean both curses tcod tar

bin/brogue : ${DEPENDENCIES} ${BROGUEFILES}
$(CC) -O2 -march=i586 -o bin/brogue ${BROGUEFILES} ${LIBRARIES} -Wl,-rpath,.

clean :
rm -f src/brogue/*.o src/platform/*.o bin/brogue

${LIBTCODDIR} :
src/get-libtcod.sh

tar : both
rm -f ${RELEASENAME}.tar.gz
tar --transform 's,^,${RELEASENAME}/,' -czf ${RELEASENAME}.tar.gz \
Makefile \
brogue \
$(wildcard *.sh) \
$(wildcard *.rtf) \
readme \
$(wildcard *.txt) \
bin/brogue \
bin/keymap \
bin/icon.bmp \
bin/brogue-icon.png \
$(wildcard bin/fonts/*.png) \
$(wildcard bin/*.so) \
$(wildcard src/*.sh) \
$(wildcard src/brogue/*.c) \
$(wildcard src/brogue/*.h) \
$(wildcard src/platform/*.c) \
$(wildcard src/platform/*.h)
objects := $(sources:.c=.o)

.PHONY: clean

%.o: %.c src/brogue/Rogue.h src/brogue/IncludeGlobals.h
$(CC) $(cppflags) $(CPPFLAGS) $(cflags) $(CFLAGS) -c $< -o $@

bin/brogue: $(objects)
$(CC) $(cflags) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(libs) $(LDLIBS)

windows/icon.o: windows/icon.rc
windres $< $@

bin/brogue.exe: $(objects) windows/icon.o
$(CC) $(cflags) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(libs) $(LDLIBS)
mt -manifest windows/brogue.exe.manifest '-outputresource:bin/brogue.exe;1'

clean:
$(RM) src/brogue/*.o src/platform/*.o windows/icon.o bin/brogue{,.exe}


# Release archives

common_bin := bin/assets bin/keymap.txt

define make_release_base
mkdir $@
cp README.md $@/README.txt
cp CHANGELOG.md $@/CHANGELOG.txt
cp LICENSE.txt $@
endef

# Flatten bin/ in the Windows archive
BrogueCE-windows: bin/brogue.exe
$(make_release_base)
cp -r $(common_bin) bin/{brogue.exe,brogue-cmd.bat} $@

BrogueCE-macos: Brogue.app
$(make_release_base)
cp -r Brogue.app $@/"Brogue CE.app"

BrogueCE-linux: bin/brogue
$(make_release_base)
cp brogue $@
cp -r --parents $(common_bin) bin/brogue $@
cp linux/make-link-for-desktop.sh $@


# macOS app bundle

# $* is the matched %
icon_%.png: bin/assets/icon.png
convert $< -resize $* $@

macos/Brogue.icns: icon_32.png icon_128.png icon_256.png icon_512.png
png2icns $@ $^
$(RM) $^

Brogue.app: bin/brogue
mkdir -p $@/Contents/{MacOS,Resources}
cp macos/Info.plist $@/Contents
cp bin/brogue $@/Contents/MacOS
cp -r macos/Brogue.icns bin/assets $@/Contents/Resources

macos/sdl2.rb:
curl -L 'https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/sdl2.rb' >$@
patch $@ macos/sdl2-deployment-target.patch
61 changes: 37 additions & 24 deletions bin/definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ ITEM_DETECTED = Fl(12) -- magic-detected item on cell
CLAIRVOYANT_VISIBLE = Fl(13)
CLAIRVOYANT_DARKENED = Fl(15) -- magical blindness from a cursed ring of clairvoyance
CAUGHT_FIRE_THIS_TURN = Fl(16) -- so that fire does not spread asymmetrically
KNOWN_TO_BE_TRAP_FREE = Fl(19) -- keep track of where the player has stepped as he knows no traps are there
KNOWN_TO_BE_TRAP_FREE = Fl(19) -- keep track of where the player has stepped or watched monsters step as he knows no traps are there
TELEPATHIC_VISIBLE = Fl(29) -- potions of telepathy let you see through other creatures' eyes

-- ~ PERMANENT_TILE_FLAGS = (DISCOVERED | MAGIC_MAPPED | ITEM_DETECTED | HAS_ITEM | HAS_DORMANT_MONSTER
-- ~ | HAS_UP_STAIRS | HAS_DOWN_STAIRS | PRESSURE_PLATE_DEPRESSED
-- ~ | HAS_MONSTER | HAS_STAIRS | SEARCHED_FROM_HERE | PRESSURE_PLATE_DEPRESSED
-- ~ | STABLE_MEMORY | KNOWN_TO_BE_TRAP_FREE | IN_LOOP
-- ~ | IS_CHOKEPOINT | IS_GATE_SITE | IS_IN_MACHINE | IMPREGNABLE)

Expand Down Expand Up @@ -122,25 +122,28 @@ MONST_NEVER_MUTATED = (MONST_INVISIBLE | MONST_INANIMATE | MONST_IMM
-- monster ability flags
MA_HIT_HALLUCINATE = Fl(0) -- monster can hit to cause hallucinations
MA_HIT_STEAL_FLEE = Fl(1) -- monster can steal an item and then run away
MA_ENTER_SUMMONS = Fl(2) -- monster will "become" its summoned leader, reappearing when that leader is defeated
MA_HIT_DEGRADE_ARMOR = Fl(3) -- monster damages armor
MA_CAST_SUMMON = Fl(4) -- requires that there be one or more summon hordes with this monster type as the leader
MA_SEIZES = Fl(5) -- monster seizes enemies before attacking
MA_POISONS = Fl(6) -- monster's damage is dealt in the form of poison
MA_DF_ON_DEATH = Fl(7) -- monster spawns its DF when it dies
MA_CLONE_SELF_ON_DEFEND = Fl(8) -- monster splits in two when struck
MA_KAMIKAZE = Fl(9) -- monster dies instead of attacking
MA_TRANSFERENCE = Fl(10) -- monster recovers 40 or 90% of the damage that it inflicts as health
MA_CAUSES_WEAKNESS = Fl(11) -- monster attacks cause weakness status in target
MA_ATTACKS_PENETRATE = Fl(12) -- monster attacks all adjacent enemies, like an axe
MA_ATTACKS_ALL_ADJACENT = Fl(13) -- monster attacks penetrate one layer of enemies, like a spear
MA_ATTACKS_EXTEND = Fl(14) -- monster attacks from a distance in a cardinal direction, like a whip
MA_AVOID_CORRIDORS = Fl(15) -- monster will avoid corridors when hunting

SPECIAL_HIT = (MA_HIT_HALLUCINATE | MA_HIT_STEAL_FLEE | MA_HIT_DEGRADE_ARMOR | MA_POISONS | MA_TRANSFERENCE | MA_CAUSES_WEAKNESS)
MA_HIT_BURN = Fl(2) -- monster can hit to set you on fire
MA_ENTER_SUMMONS = Fl(3) -- monster will "become" its summoned leader, reappearing when that leader is defeated
MA_HIT_DEGRADE_ARMOR = Fl(4) -- monster damages armor
MA_CAST_SUMMON = Fl(5) -- requires that there be one or more summon hordes with this monster type as the leader
MA_SEIZES = Fl(6) -- monster seizes enemies before attacking
MA_POISONS = Fl(7) -- monster's damage is dealt in the form of poison
MA_DF_ON_DEATH = Fl(8) -- monster spawns its DF when it dies
MA_CLONE_SELF_ON_DEFEND = Fl(9) -- monster splits in two when struck
MA_KAMIKAZE = Fl(10) -- monster dies instead of attacking
MA_TRANSFERENCE = Fl(11) -- monster recovers 40 or 90% of the damage that it inflicts as health
MA_CAUSES_WEAKNESS = Fl(12) -- monster attacks cause weakness status in target
MA_ATTACKS_PENETRATE = Fl(13) -- monster attacks all adjacent enemies, like an axe
MA_ATTACKS_ALL_ADJACENT = Fl(14) -- monster attacks penetrate one layer of enemies, like a spear
MA_ATTACKS_EXTEND = Fl(15) -- monster attacks from a distance in a cardinal direction, like a whip
MA_ATTACKS_STAGGER = Fl(16) -- monster attacks will push the player backward by one space if there is room
MA_AVOID_CORRIDORS = Fl(17) -- monster will avoid corridors when hunting

SPECIAL_HIT = (MA_HIT_HALLUCINATE | MA_HIT_STEAL_FLEE | MA_HIT_DEGRADE_ARMOR | MA_POISONS
| MA_TRANSFERENCE | MA_CAUSES_WEAKNESS | MA_HIT_BURN | MA_ATTACKS_STAGGER)
LEARNABLE_ABILITIES = (MA_TRANSFERENCE | MA_CAUSES_WEAKNESS)

MA_NON_NEGATABLE_ABILITIES = (MA_ATTACKS_PENETRATE | MA_ATTACKS_ALL_ADJACENT)
MA_NON_NEGATABLE_ABILITIES = (MA_ATTACKS_PENETRATE | MA_ATTACKS_ALL_ADJACENT | MA_ATTACKS_EXTEND | MA_ATTACKS_STAGGER)
MA_NEVER_VORPAL_ENEMY = (MA_KAMIKAZE)
MA_NEVER_MUTATED = (MA_KAMIKAZE)

Expand All @@ -151,9 +154,9 @@ MB_CAPTIVE = Fl(8) -- monster is all tied up
MB_SEIZED = Fl(9) -- monster is being held
MB_SEIZING = Fl(10) -- monster is holding another creature immobile
MB_SUBMERGED = Fl(11) -- monster is currently submerged and hence invisible until it attacks
MB_ABSORBING = Fl(15) -- currently learning a skill by absorbing an enemy corpse
MB_HAS_SOUL = Fl(21) -- slaying the monster will count toward weapon auto-ID
MB_ALREADY_SEEN = Fl(22) -- seeing this monster won't interrupt exploration
MB_ABSORBING = Fl(16) -- currently learning a skill by absorbing an enemy corpse
MB_HAS_SOUL = Fl(22) -- slaying the monster will count toward weapon auto-ID
MB_ALREADY_SEEN = Fl(23) -- seeing this monster won't interrupt exploration


-- monster states
Expand All @@ -167,6 +170,7 @@ MONSTER_ALLY = nexti()

-- creature status effect indices
i = 0 -- start from 1 as these are table indices
STATUS_DONNING = nexti()
STATUS_WEAKENED = nexti()
STATUS_TELEPATHIC = nexti()
STATUS_HALLUCINATING = nexti()
Expand All @@ -184,6 +188,7 @@ STATUS_IMMUNE_TO_FIRE = nexti()
STATUS_EXPLOSION_IMMUNITY = nexti()
STATUS_NUTRITION = nexti()
STATUS_ENTERS_LEVEL_IN = nexti()
STATUS_ENRAGED = nexti() -- temporarily ignores normal MA_AVOID_CORRIDORS behavior
STATUS_MAGICAL_FEAR = nexti()
STATUS_ENTRANCED = nexti()
STATUS_DARKNESS = nexti()
Expand All @@ -204,7 +209,7 @@ ITEM_FLAMMABLE = Fl(10)
ITEM_MAGIC_DETECTED = Fl(11)
ITEM_IS_KEY = Fl(13)

ITEM_ATTACKS_HIT_SLOWLY = Fl(14) -- mace, hammer
ITEM_ATTACKS_STAGGER = Fl(14) -- mace, hammer
ITEM_ATTACKS_EXTEND = Fl(15) -- whip
ITEM_ATTACKS_QUICKLY = Fl(16) -- rapier
ITEM_ATTACKS_PENETRATE = Fl(17) -- spear, pike
Expand Down Expand Up @@ -432,7 +437,6 @@ ACID_JELLY = nexti()
CENTAUR = nexti()
UNDERWORM = nexti()
SENTINEL = nexti()
ACID_TURRET = nexti()
DART_TURRET = nexti()
KRAKEN = nexti()
LICH = nexti()
Expand Down Expand Up @@ -578,6 +582,10 @@ STONE_BRIDGE = nexti()
MACHINE_FLOOD_WATER_DORMANT = nexti()
MACHINE_FLOOD_WATER_SPREADING = nexti()
MACHINE_MUD_DORMANT = nexti()
ICE_DEEP = nexti()
ICE_DEEP_MELT = nexti()
ICE_SHALLOW = nexti()
ICE_SHALLOW_MELT = nexti()
HOLE = nexti()
HOLE_GLOW = nexti()
HOLE_EDGE = nexti()
Expand Down Expand Up @@ -659,6 +667,11 @@ PIPE_INERT = nexti()
RESURRECTION_ALTAR = nexti()
RESURRECTION_ALTAR_INERT = nexti()
MACHINE_TRIGGER_FLOOR_REPEATING = nexti()
SACRIFICE_ALTAR_DORMANT = nexti()
SACRIFICE_ALTAR = nexti()
SACRIFICE_LAVA = nexti()
SACRIFICE_CAGE_DORMANT = nexti()
DEMONIC_STATUE = nexti()
STATUE_INERT_DOORWAY = nexti()
STATUE_DORMANT_DOORWAY = nexti()
CHASM_WITH_HIDDEN_BRIDGE = nexti()
Expand Down
22 changes: 22 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Where to look for game data files (found in 'bin'). Must be without trailing slashes!
DATADIR := .

# Include terminal support. Requires ncurses
TERMINAL := NO

# Include graphical support. Requires SDL2 and SDL2_image
GRAPHICS := YES
# Path to sdl2-config script
SDL_CONFIG := sdl2-config

# Select web brogue mode. Requires POSIX system.
WEBBROGUE := NO

# Enable debugging mode. See top of Rogue.h for features
DEBUG := NO

# Declare this is a release build
RELEASE := NO

# Configure the executable to run from a macOS .app bundle (only works in graphical mode)
MAC_APP := NO
Loading