From: Martin Read Date: Sat, 8 Feb 2014 17:14:41 +0000 (+0000) Subject: Ball-of-mud change for various things. X-Git-Tag: printmsg-purged~11 X-Git-Url: http://git.blackswordsonics.com/?a=commitdiff_plain;h=98829a7f4da029870e5d7f90594c9f89eef11655;p=victrix-abyssi Ball-of-mud change for various things. --- diff --git a/MANIFEST b/MANIFEST index 75fc27a..a6227d6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,11 +1,15 @@ +COPYING MANIFEST Makefile +configure +Doxyfile +victrix-abyssi.6 combat.cc combat.hh coord.hh +default.permobjs display.hh display-nc.cc -Doxyfile fov.cc fov.hh main.cc @@ -26,8 +30,8 @@ pmon2.cc pobj_comp pobj_id.hh rng.cc +rng.hh sorcery.cc sorcery.hh u.cc -vector.cc victrix-abyssi.hh diff --git a/Makefile b/Makefile index 692bad6..312f918 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1,42 @@ # Makefile for Victrix Abyssi -OBJS=combat.o display-nc.o fov.o main.o map.o misc.o monsters.o mon2.o notify-local-tty.o objects.o permobj.o permons.o pmon2.o rng.o sorcery.o u.o - include dirs.mk include features.mk +GENERATED_OBJS:=permobj.o +GENERATED_SOURCE:=permobj.cc pobj_id.hh dirs.mk features.mk +HANDWRITTEN_OBJS:=combat.o display-nc.o fov.o main.o map.o misc.o monsters.o mon2.o notify-local-tty.o objects.o permons.o pmon2.o rng.o sorcery.o u.o +OBJS:=$(GENERATED_OBJS) $(HANDWRITTEN_OBJS) GAME:=victrix-abyssi MAJVERS:=1 MINVERS:=0 -PRODUCTION_CXXFLAGS:=-c -Wall -Wwrite-strings -Wno-unused-but-set-variable -Wredundant-decls -Wunreachable-code -DMAJVERS=$(MAJVERS) -DMINVERS=$(MINVERS) -std=gnu++11 -DEVELOPMENT_CXXFLAGS:=-c -g -Wall -Wwrite-strings -Wno-unused-but-set-variable -Wredundant-decls -Wunreachable-code -Werror -DMAJVERS=$(MAJVERS) -DMINVERS=$(MINVERS) -std=gnu++11 -LINKFLAGS=-lm -lpanelw -lncursesw -g -ARCHIVEDIR:=victrix-abyssi_$(MAJVERS).$(MINVERS) +COMMON_CXXFLAGS:=-c -Wall -Wwrite-strings -Wno-unused-but-set-variable -Wredundant-decls -Wunreachable-code -Wformat -Werror=format-security -fstack-protector --param=ssp-buffer-size=4 -DMAJVERS=$(MAJVERS) -DMINVERS=$(MINVERS) -std=gnu++11 -D_FORTIFY_SOURCE=2 +PRODUCTION_CXXFLAGS:=$(COMMON_CXXFLAGS) +DEVELOPMENT_CXXFLAGS:=$(COMMON_CXXFLAGS) -g -Werror +LIBS=-lm -lpanelw -lncursesw +ARCHIVEDIR:=victrix-abyssi-$(MAJVERS).$(MINVERS) +ARCHIVENAME:=victrix-abyssi_$(MAJVERS).$(MINVERS) .cc.o: - $(CXX) $(DEVELOPMENT_CXXFLAGS) $(CXXFLAGS) $< -o $@ + $(CXX) $(DEVELOPMENT_CXXFLAGS) $(CPPFLAGS) $(CXXFLAGS) $< -o $@ all: $(GAME) $(GAME): $(OBJS) - $(CXX) $(OBJS) $(LINKFLAGS) -o $(GAME) + $(CXX) $(LDFLAGS) $(OBJS) $(LIBS) -o $(GAME) -archive: clean headergen +archive: clean permobj.cc pobj_id.hh mkdir $(ARCHIVEDIR) cp `cat MANIFEST` $(ARCHIVEDIR) - tar czf $(ARCHIVEDIR).tgz $(ARCHIVEDIR) + tar czf $(ARCHIVENAME).tar.gz $(ARCHIVEDIR) rm -r $(ARCHIVEDIR) +debianize-archive: archive + mv $(ARCHIVENAME).tar.gz $(ARCHIVENAME).orig.tar.gz + clean: - -rm -f *.o $(GAME) victrix-abyssi.log victrix-abyssi.sav.gz *.tgz + -rm -rf $(ARCHIVEDIR) + -rm -f *.o $(GAME) *.tar.gz code-docs: doxygen Doxyfile @@ -37,28 +45,48 @@ headergen: ./pobj_comp default.permobjs #./pmon_comp default.permons -display-nc.o: display-nc.cc victrix-abyssi.hh display.hh - -main.o: main.cc combat.hh victrix-abyssi.hh monsters.hh +install: all + echo "man6dir is $(man6dir)" + install -D $(GAME) $(DESTDIR)$(gamesdir)/$(GAME) + install -D $(GAME).6 $(DESTDIR)$(man6dir)/$(GAME).6 -combat.o: combat.cc combat.hh victrix-abyssi.hh monsters.hh objects.hh +spotless: clean + -rm -f $(GENERATED_SOURCE) -u.o: u.cc combat.hh victrix-abyssi.hh monsters.hh objects.hh - -permobj.o: permobj.cc victrix-abyssi.hh objects.hh +## Dependencies for autogeneration +permobj.cc pobj_id.hh: pobj_comp default.permobjs + ./pobj_comp default.permobjs -map.o: map.cc victrix-abyssi.hh +## Dependencies for the build +combat.o: combat.cc combat.hh victrix-abyssi.hh monsters.hh objects.hh pobj_id.hh -permons.o: permons.cc victrix-abyssi.hh monsters.hh +display-nc.o: display-nc.cc victrix-abyssi.hh display.hh pobj_id.hh -pmon2.o: pmon2.cc victrix-abyssi.hh monsters.hh +main.o: main.cc combat.hh victrix-abyssi.hh monsters.hh pobj_id.hh -objects.o: objects.cc victrix-abyssi.hh objects.hh monsters.hh +map.o: map.cc victrix-abyssi.hh objects.hh monsters.o: monsters.cc victrix-abyssi.hh monsters.hh objects.hh mon2.o: mon2.cc victrix-abyssi.hh sorcery.hh monsters.hh objects.hh +notify-local-tty.o: notify-local-tty.cc victrix-abyssi.hh combat.hh monsters.hh notify.hh objects.hh sorcery.hh pobj_id.hh + +# NOTICE: permobj.cc does not depend on pobj_id.hh because they are both +# generated from the same input file and should not be hand-edited. If you +# file a bug report over this, I will close it NOTABUG; if you submit a +# patch to add such a dependency, I will reject it out of hand. + +permobj.o: permobj.cc victrix-abyssi.hh objects.hh + +permons.o: permons.cc victrix-abyssi.hh monsters.hh + +pmon2.o: pmon2.cc victrix-abyssi.hh monsters.hh + +objects.o: objects.cc victrix-abyssi.hh objects.hh monsters.hh pobj_id.hh + sorcery.o: sorcery.cc victrix-abyssi.hh sorcery.hh objects.hh monsters.hh +u.o: u.cc combat.hh victrix-abyssi.hh monsters.hh objects.hh pobj_id.hh + # vim:ts=8:sts=8:sw=8:noexpandtab diff --git a/configure b/configure index 3cbb65e..26e3313 100755 --- a/configure +++ b/configure @@ -12,6 +12,7 @@ my $bindir='$(exec_prefix)/bin'; my $sbindir='$(exec_prefix)/sbin'; my $libdir='$(exec_prefix)/lib'; my $libexecdir='$(exec_prefix)/libexec'; +my $gamesdir='$(prefix)/games'; my $datarootdir='$(prefix)/share'; my $datadir='$(datarootdir)/victrix-abyssi'; @@ -51,6 +52,7 @@ my $verbose=1; GetOptions( 'prefix=s' => \$prefix, 'exec_prefix=s' => \$exec_prefix, 'bindir=s' => \$bindir, 'libdir=s' => \$libdir, +'libexecdir=s' => \$libexecdir, 'gamesdir=s' => \$gamesdir, 'includedir=s' => \$includedir, 'oldincludedir=s' => \$oldincludedir, 'datarootdir=s' => \$datarootdir, 'datadir=s' => \$datadir, 'sysconfdir=s' => \$sysconfdir, 'sharedstatedir=s' => \$sharedstatedir, @@ -95,6 +97,7 @@ print DIRS_MK "bindir=${bindir}\n"; print DIRS_MK "sbindir=${sbindir}\n"; print DIRS_MK "libdir=${libdir}\n"; print DIRS_MK "libexecdir=${libexecdir}\n"; +print DIRS_MK "gamesdir=${gamesdir}\n"; print DIRS_MK "datarootdir=${datarootdir}\n"; print DIRS_MK "datadir=${datadir}\n"; print DIRS_MK "sysconfdir=${sysconfdir}\n"; diff --git a/map.cc b/map.cc index b32fcbd..4c2a5f0 100644 --- a/map.cc +++ b/map.cc @@ -218,7 +218,7 @@ void build_level(void) int theme_roll; /* Snapshot the running RNG state, so that we can rebuild the map from * the saved RNG state at game reload. */ - memcpy(saved_state, rng_state, sizeof saved_state); + rng.extract_serialization(saved_state_buffer, saved_state_size); theme_roll = zero_die(depth + 50); if (!zero_die(4)) { @@ -768,27 +768,23 @@ void deserialize_level(FILE *fp, Level *l) uint32_t tmp_pair[2]; uint32_t i; uint32_t j; - fread(tmp_pair, sizeof tmp_pair[0], 2, fp); + wrapped_fread(tmp_pair, sizeof tmp_pair[0], 2, fp); l->origin_off.y = (int) ntohl(tmp_pair[0]); l->origin_off.x = (int) ntohl(tmp_pair[1]); - fread(&tmp, sizeof tmp, 1, fp); + wrapped_fread(&tmp, sizeof tmp, 1, fp); l->dead_space = Terrain(ntohl(tmp)); - fread(&tmp, sizeof tmp, 1, fp); + wrapped_fread(&tmp, sizeof tmp, 1, fp); l->theme = level_theme(ntohl(tmp)); - fread(&tmp, sizeof tmp, 1, fp); + wrapped_fread(&tmp, sizeof tmp, 1, fp); l->layout = level_layout(ntohl(tmp)); - fread(&tmp, sizeof tmp, 1, fp); + wrapped_fread(&tmp, sizeof tmp, 1, fp); l->chunks_high = ntohl(tmp); - fread(&tmp, sizeof tmp, 1, fp); + wrapped_fread(&tmp, sizeof tmp, 1, fp); l->chunks_wide = ntohl(tmp); initialize_chunks(l, l->chunks_high, l->chunks_wide, false); do { - i = fread(&tmp_pair, sizeof tmp_pair[0], 2, fp); - if (i != 2) - { - print_msg("blech\n"); - } + wrapped_fread(&tmp_pair, sizeof tmp_pair[0], 2, fp); i = ntohl(tmp_pair[0]); j = ntohl(tmp_pair[1]); if (i == ~0u) diff --git a/notify-local-tty.cc b/notify-local-tty.cc index 9211f32..c14f3da 100644 --- a/notify-local-tty.cc +++ b/notify-local-tty.cc @@ -322,6 +322,44 @@ void notify_no_flask_target(void) print_msg("That would be a waste; there's nobody to throw it at.\n"); } +void notify_magic_no_ring(void) +{ + print_msg("You are not wearing a ring.\n"); +} + +void notify_emanate_no_armour(void) +{ + print_msg("You are not wearing any armour.\n"); +} + +void notify_zap_no_weapon(void) +{ + print_msg("You have no weapon in hand.\n"); +} + +void notify_armour_equip(void) +{ + Permobj *pobj = permobjs + objects[u.armour].obj_id; + if (pobj->flags[0] & POF_NOTIFY_EQUIP) + { + switch (objects[u.armour].obj_id) + { + case PO_SET_OF_RIBBONS: + print_msg("You grit your teeth, trying to get used to the tingle of the ribbons' magic against your skin.\n"); + break; + default: + print_msg("BUG: object '%s' has POF_NOTIFY_EQUIP defined but no special message written.\n", pobj->name); + break; + } + } + else + { + print_msg("Wearing "); + print_obj_name(u.armour); + print_msg(".\n"); + } +} + /* Debugging notifications */ void debug_bad_monspell(int spell) @@ -359,5 +397,30 @@ void debug_unimplemented(void) print_msg("NOTICE: Attempt to activate unimplemented feature\n"); } +void debug_wear_while_wearing(void) +{ + print_msg("BUG: Got to wear_armour while wearing armour\n"); +} + +void debug_wear_uncarried_armour(void) +{ + print_msg("NOTICE: Attempt to wear uncarried armour\n"); +} + +void debug_remove_no_ring(void) +{ + print_msg("BUG: calling remove_ring with no ring equipped.\n"); +} + +void debug_put_on_second_ring(void) +{ + print_msg("BUG: calling put_on_ring with ring already equipped.\n"); +} + +void debug_put_on_uncarried_ring(void) +{ + print_msg("BUG: attempting to put on uncarried ring.\n"); +} + /* display-nc.cc */ // vim:cindent diff --git a/notify.hh b/notify.hh index c413614..5139973 100644 --- a/notify.hh +++ b/notify.hh @@ -29,7 +29,7 @@ #ifndef NOTIFY_HH #define NOTIFY_HH -/* Notification functions */ +// Player status changes void notify_level_gain(void); void notify_agility_gain(int amount); void notify_body_gain(int amount); @@ -42,15 +42,25 @@ void notify_leadfoot_recovered(void); void notify_armourmelt_recovered(void); void notify_wither_recovered(void); void notify_protection_lost(void); +void notify_wasted_gain(void); + +// Player movement notifications void notify_start_lavawalk(void); void notify_blocked_lava(void); void notify_start_waterwalk(void); void notify_blocked_water(void); -void notify_obj_at(Coord c); void notify_cant_go(void); -void notify_wasted_gain(void); -/* combat notifications */ +// Unsorted notifications +void notify_obj_at(Coord c); + +// Item manipulation notifications +void notify_magic_no_ring(void); +void notify_emanate_no_armour(void); +void notify_zap_no_weapon(void); +void notify_armour_equip(void); + +// combat notifications void notify_swing_bow(void); void notify_no_attackee(void); void notify_no_flask_target(void); @@ -65,7 +75,7 @@ void notify_mon_hit_armour(int mon); void notify_mon_missed_player(int mon); void notify_mon_hit_player(int mon); -/* Sorcery notifications */ +// Sorcery notifications void notify_summon_help(int mon, bool success); void notify_monster_cursing(int mon); void notify_mon_disappear(int mon); @@ -77,7 +87,7 @@ void notify_necrosmite_fail(void); void notify_necrosmite_hit(void); void notify_hellfire_hit(bool resisted); -/* Debugging notifications */ +// Debugging notifications void debug_move_oob(Coord c); void debug_body_gain(int amount); void debug_agility_gain(int amount); @@ -86,6 +96,11 @@ void debug_player_resists_phys(void); void debug_bad_damage_type(int dt); void debug_throw_non_flask(void); void debug_unimplemented(void); +void debug_wear_while_wearing(void); +void debug_wear_uncarried_armour(void); +void debug_remove_no_ring(void); +void debug_put_on_second_ring(void); +void debug_put_on_uncarried_ring(void); #endif diff --git a/objects.cc b/objects.cc index 2e522bf..d2ea374 100644 --- a/objects.cc +++ b/objects.cc @@ -842,16 +842,36 @@ Action_cost player_wield(int slot, Noisiness noisy) return Cost_std; } +Action_cost wear_armour(int slot) +{ + int obj; + if (u.armour != NO_OBJ) + { + debug_wear_while_wearing(); + return Cost_none; + } + obj = u.inventory[slot]; + if (!objects[obj].with_you) + { + debug_wear_uncarried_armour(); + return Cost_none; + } + u.armour = obj; + recalc_defence(); + notify_armour_equip(); + return Cost_std; +} + Action_cost put_on_ring(int obj) { if (u.ring != NO_OBJ) { - print_msg("BUG: calling put_on_ring with ring already equipped.\n"); + debug_put_on_second_ring(); return Cost_none; } if (!objects[obj].with_you) { - print_msg("BUG: attempting to put on uncarried ring.\n"); + debug_put_on_uncarried_ring(); return Cost_none; } u.ring = obj; @@ -863,7 +883,7 @@ Action_cost remove_ring(void) { if (u.ring == NO_OBJ) { - print_msg("BUG: calling remove_ring with no ring equipped.\n"); + debug_remove_no_ring(); return Cost_none; } u.ring = NO_OBJ; diff --git a/u.cc b/u.cc index e9ff10b..931bdf6 100644 --- a/u.cc +++ b/u.cc @@ -315,7 +315,10 @@ void heal_u(int amount, int boost, int loud) int do_death(Death d, char const *what) { - FILE *fp; + // GRATIUTOUS INITIALIZATION: The idiot bastard compiler's inadequate + // control flow analysis shits itself when using debuild/dh's default + // CXXFLAGS settings. + FILE *fp = 0; int really = 0; if (wizard_mode) diff --git a/victrix-abyssi.hh b/victrix-abyssi.hh index fff4e00..ce8c7de 100644 --- a/victrix-abyssi.hh +++ b/victrix-abyssi.hh @@ -43,6 +43,10 @@ #include "coord.hh" #endif +#ifndef RNG_HH +#include "rng.hh" +#endif + enum Comparison { Lesser = -1, @@ -192,18 +196,13 @@ struct Action #endif /* XXX main.c data and funcs */ -extern int zero_die(int sides); /* 0..n-1 */ -extern int one_die(int sides); /* 1..n */ -extern int dice(int count, int sides); -extern int exclusive_flat(int lower, int upper); /* l+1 ... u-1 */ -extern int inclusive_flat(int lower, int upper); /* l ... u */ extern Offset random_step(void); -extern Coord inclusive_boxed(Coord topleft, Coord botright); -extern Coord exclusive_boxed(Coord topleft, Coord botright); extern Action_cost do_player_action(Action *act); extern bool game_finished; extern int game_tick; extern bool wizard_mode; +extern void wrapped_system(char const *cmd); +extern void wrapped_fread(void *buf, size_t size, size_t nmemb, FILE *stream); /* XXX misc.c data and funcs */ extern char const *damtype_names[DT_COUNT]; @@ -213,13 +212,6 @@ extern bool po_is_stackable(int po); extern void damage_obj(int obj); extern int evasion_penalty(int obj); -/* XXX rng.c data and funcs */ -#define RNG_MAX 0xFFFFFFFFu -extern uint32_t rng_state[5]; -extern uint32_t saved_state[5]; -extern uint32_t rng(void); -extern void rng_init(void); - /* XXX u.c data and funcs */ extern void u_init(void); extern void write_char_dump(void);