diff --git a/src/Makefile.include b/src/Makefile.include index cc54c0d6b..bc651e3e7 100644 --- a/src/Makefile.include +++ b/src/Makefile.include @@ -19,7 +19,7 @@ ARFLAGS = cr CTAGSFLAGS = --langmap=c:.c.h --c-types=-m CFLAGS = -I$(ERESSEA) -Wall -Wwrite-strings -Wstrict-prototypes \ -Wpointer-arith -Werror-implicit-function-declaration \ - -Wno-char-subscripts -Wshadow \ + -Wno-char-subscripts \ -march=pentiumpro -fPIC $(INCLUDES) LDFLAGS = $(LIBS) @@ -78,6 +78,13 @@ ifeq ($(CONFIG), profile) LDFLAGS += -g -pg endif +ifeq ($(CONFIG), dmalloc) + BUILD_DIR = Dmalloc-$(ARCHITECTURE) + CFLAGS += -g -DDMALLOC + LDFLAGS += -g + LIBS += -ldmalloc +endif + # ## Dependencies @@ -106,7 +113,7 @@ PUBLISH_DIR = $(ERESSEA)/$(BUILD_DIR) env: @$(MAKEENV) -debug release profile:: env $(PUBLISH_DIR) $(PUBLISH_DIR) +debug release profile dmalloc:: env $(PUBLISH_DIR) $(PUBLISH_DIR) $(MAKE) CONFIG=$@ recurse-subdirs-$@ ## @@ -115,11 +122,12 @@ debug release profile:: env $(PUBLISH_DIR) $(PUBLISH_DIR) recurse-subdirs-debug:: subdirs-debug publish-debug recurse-subdirs-release:: subdirs-release publish-release recurse-subdirs-profile:: subdirs-profile publish-profile +recurse-subdirs-dmalloc:: subdirs-dmalloc publish-dmalloc recurse-clean:: clean recurse-depend:: depend -subdirs-debug subdirs-release subdirs-profile clean depend:: +subdirs-debug subdirs-release subdirs-profile subdirs-dmalloc clean depend:: @mkdir -p $(PUBLISH_DIR) @if [ -n "$(SUBDIRS)" ]; then \ for subdir in x-placeholder-dir $(SUBDIRS); do \ @@ -134,11 +142,12 @@ subdirs-debug subdirs-release subdirs-profile clean depend:: publish-debug:: subdirs-debug publish-release:: subdirs-release publish-profile:: subdirs-profile +publish-dmalloc:: subdirs-dmalloc -publish-debug publish-release publish-profile:: $(PUBLISH_DIR)/$(LIBRARY) $(PUBLISH_DIR)/$(BINARY) +publish-debug publish-release publish-profile publish-dmalloc:: $(PUBLISH_DIR)/$(LIBRARY) $(PUBLISH_DIR)/$(BINARY) clean:: $(BUILD_DIR) $(PUBLISH_DIR) - rm -fr Release-$(ARCHITECTURE)/* Debug-$(ARCHITECTURE)/* Profile-$(ARCHITECTURE)/* + rm -fr Release-$(ARCHITECTURE)/* Debug-$(ARCHITECTURE)/* Profile-$(ARCHITECTURE)/* Dmalloc-$(ARCHITECTURE)/* $(BUILD_DIR) $(PUBLISH_DIR): @mkdir $@ diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index c1c5615fc..e61c96d33 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: laws.c,v 1.7 2001/02/03 13:45:29 enno Exp $ + * $Id: laws.c,v 1.8 2001/02/09 15:17:30 corwin Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -2828,31 +2828,13 @@ processorders (void) if (turn == 0) srand(time((time_t *) NULL)); else srand(turn); new_units(); -#if MALLOCDBG - assert(_CrtCheckMemory()); -#endif puts(" - Monster KI..."); plan_monsters(); -#if MALLOCDBG - assert(_CrtCheckMemory()); -#endif set_passw(); /* und pruefe auf illegale Befehle */ -#if MALLOCDBG - assert(_CrtCheckMemory()); -#endif puts(" - Defaults und Instant-Befehle..."); setdefaults(); -#if MALLOCDBG - assert(_CrtCheckMemory()); -#endif instant_orders(); -#if MALLOCDBG - assert(_CrtCheckMemory()); -#endif mail(); -#if MALLOCDBG - assert(_CrtCheckMemory()); -#endif puts(" - Altern"); for (f = factions; f; f = f->next) { @@ -2884,9 +2866,6 @@ processorders (void) puts(" - Kontaktieren, Betreten von Schiffen und Gebäuden (1.Versuch)"); do_misc(0); -#if MALLOCDBG - assert(_CrtCheckMemory()); -#endif puts(" - Verlassen"); do_leave(); @@ -2897,13 +2876,7 @@ processorders (void) jihad_attacks(); puts(" - Attackieren"); -#if MALLOCDBG - assert(_CrtCheckMemory()); -#endif if(nobattle == false) do_battle(); -#if MALLOCDBG - assert(_CrtCheckMemory()); -#endif if (turn == 0) srand(time((time_t *) NULL)); else srand(turn); @@ -2931,9 +2904,6 @@ processorders (void) puts(" - Gebäudeunterhalt (1. Versuch)"); maintain_buildings(false); -#if MALLOCDBG - assert(_CrtCheckMemory()); -#endif puts(" - Sterben"); quit(); diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index c7ddddf08..de0be2ecd 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: battle.c,v 1.7 2001/02/09 13:53:51 corwin Exp $ + * $Id: battle.c,v 1.8 2001/02/09 15:17:31 corwin Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -3499,9 +3499,11 @@ do_battle(void) /* Auswirkungen berechnen: */ aftermath(b); + /* #if MALLOCDBG assert(_CrtCheckMemory()); #endif + */ /* Hier ist das Gefecht beendet, und wir können die * Hilfsstrukturen * wieder löschen: */ diff --git a/src/corwin.mk b/src/corwin.mk index cc7fc52c4..c3448132e 100644 --- a/src/corwin.mk +++ b/src/corwin.mk @@ -11,3 +11,10 @@ CC = gcc LD = gcc INSTALL = cp +CFLAGS += -DHAVE_GETCURX + +# ifdef DMALLOC +# LIBS += -ldmalloc +# CFLAGS += -DDMALLOC +# endif + diff --git a/src/mapper/map_tools.c b/src/mapper/map_tools.c index 46afc1022..2a8bb4a36 100644 --- a/src/mapper/map_tools.c +++ b/src/mapper/map_tools.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: map_tools.c,v 1.4 2001/02/09 13:53:53 corwin Exp $ + * $Id: map_tools.c,v 1.5 2001/02/09 15:17:31 corwin Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -94,7 +94,7 @@ BuildingName(building * b) int map_input(WINDOW * win, int x, int y, const char *text, int mn, int mx, int pre) { - char buf[10]; + char lbuf[10]; int val, ch, cx, nw = 0; if (!win) { win = openwin(50, 3, 0); @@ -103,13 +103,13 @@ map_input(WINDOW * win, int x, int y, const char *text, int mn, int mx, int pre) } else wrefresh(win); do { - sprintf(buf, "%d", pre); + sprintf(lbuf, "%d", pre); wmove(win, y, x); curs_set(1); wprintw(win, (NCURSES_CONST char*)"%s (%d..%d): %d", text, mn, mx, pre); wrefresh(win); #ifdef HAVE_GETCURX - cx = getcurx(win) - strlen(buf); + cx = getcurx(win) - strlen(lbuf); #else cx = (int)(x + strlen(text) + 7 + log10(abs(mn)) + log10(abs(mx))); if (mx < 0) @@ -117,7 +117,7 @@ map_input(WINDOW * win, int x, int y, const char *text, int mn, int mx, int pre) if (mn < 0) cx++; #endif - val = strlen(buf); + val = strlen(lbuf); do { ch = getch(); if (ch==8 || ch == KEY_BACKSPACE || ch == KEY_LEFT) { @@ -134,14 +134,14 @@ map_input(WINDOW * win, int x, int y, const char *text, int mn, int mx, int pre) curs_set(0); } else if ((ch == '-' && val == 0) || (ch >= '0' && ch <= '9' && val < 10)) { waddch(win, ch); - buf[val] = (char) ch; + lbuf[val] = (char) ch; val++; } else beep(); wrefresh(win); } while (!(ch == 10 || ch == 13)); - buf[val] = 0; - val = atoi(buf); + lbuf[val] = 0; + val = atoi(lbuf); if (val < mn || val > mx) beep(); } while (val < mn || val > mx); diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index 9a1195c7c..c0ac30d58 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: mapper.c,v 1.7 2001/02/09 13:53:53 corwin Exp $ + * $Id: mapper.c,v 1.8 2001/02/09 15:17:31 corwin Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -715,10 +715,16 @@ movearound(int rx, int ry) { } break; case 0x14: - while (Tagged) - removelist(&Tagged, Tagged); - ch=-9; - break; + { + tagregion *tag_next; + tag = Tagged; + while (tag) { + tag_next = tag->next; + removelist(&Tagged, tag); + tag = tag_next; + } + ch=-9; + } break; case 'G': rx=tx; ry=ty; recalc_everything(&x, &y, &rx, &ry);