summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-08 11:35:20 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-08 11:35:20 +0000
commit973509a558e93af8c9ba7ea70a860f5f51d3c718 (patch)
tree4a9a11f288b47f261cce2b65199142b9ba3f2658
parent9e2952d470e02deab56ae8e2ea8773a8ab1662b7 (diff)
downloadcrawl-ref-973509a558e93af8c9ba7ea70a860f5f51d3c718.tar.gz
crawl-ref-973509a558e93af8c9ba7ea70a860f5f51d3c718.zip
Note improvements (1749776). Double notes are possible if regexps
are careless. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1797 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/debug.cc17
-rw-r--r--crawl-ref/source/enum.h3
-rw-r--r--crawl-ref/source/item_use.cc3
-rw-r--r--crawl-ref/source/itemprop.cc5
-rw-r--r--crawl-ref/source/items.cc34
-rw-r--r--crawl-ref/source/notes.cc9
6 files changed, 30 insertions, 41 deletions
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 82b6741d6a..903180a9c0 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -1024,9 +1024,8 @@ void debug_item_scan( void )
int i;
char name[256];
- // unset marks
- for (i = 0; i < MAX_ITEMS; i++)
- mitm[i].flags &= (~ISFLAG_DEBUG_MARK);
+ FixedVector<bool, MAX_ITEMS> visited;
+ visited.init(false);
// First we're going to check all the stacks on the level:
for (int x = 0; x < GXM; x++)
@@ -1059,14 +1058,13 @@ void debug_item_scan( void )
// If we run into a premarked item we're in real trouble,
// this will also keep this from being an infinite loop.
- if (mitm[obj].flags & ISFLAG_DEBUG_MARK)
+ if (visited[obj])
{
mprf(MSGCH_WARN,
"Potential INFINITE STACK at (%d, %d)", x, y);
break;
}
-
- mitm[obj].flags |= ISFLAG_DEBUG_MARK;
+ visited[obj] = true;
}
}
}
@@ -1080,8 +1078,7 @@ void debug_item_scan( void )
strcpy(name, mitm[i].name(DESC_PLAIN).c_str());
// Don't check (-1,-1) player items or (0,0) monster items
- if ((mitm[i].x > 0 || mitm[i].y > 0)
- && !(mitm[i].flags & ISFLAG_DEBUG_MARK))
+ if ((mitm[i].x > 0 || mitm[i].y > 0) && !visited[i])
{
mpr( "Unlinked item:", MSGCH_WARN );
dump_item( name, i, mitm[i] );
@@ -1147,10 +1144,6 @@ void debug_item_scan( void )
}
}
- // Don't want debugging marks interfering with anything else.
- for (i = 0; i < MAX_ITEMS; i++)
- mitm[i].flags &= (~ISFLAG_DEBUG_MARK);
-
// Quickly scan monsters for "program bug"s.
for (i = 0; i < MAX_MONSTERS; i++)
{
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 7797a83c4c..9e7de149b2 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -1520,7 +1520,8 @@ enum item_status_flag_type // per item flags: ie. ident status, cursed status
ISFLAG_ELVEN = 0x04000000, // light and accurate items
ISFLAG_RACIAL_MASK = 0x07000000, // mask of racial equipment types
- ISFLAG_DEBUG_MARK = 0x80000000 // used for testing item structure
+ ISFLAG_NOTED_ID = 0x08000000,
+ ISFLAG_NOTED_GET = 0x10000000
};
enum item_description_type
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 6c803040e6..19a2d3b747 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -3643,6 +3643,9 @@ void read_scroll(void)
// scrolls of immolation were already destroyed earlier
if (scroll_type != SCR_PAPER && scroll_type != SCR_IMMOLATION)
{
+ if ( id_the_scroll )
+ set_ident_flags( scroll, ISFLAG_KNOW_TYPE ); // for notes
+
dec_inv_item_quantity( item_slot, 1 );
}
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index 69709474bb..1e8d20ae10 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -462,12 +462,13 @@ void set_ident_flags( item_def &item, unsigned long flags )
{
const bool known_before = fully_identified(item);
item.flags |= flags;
- if ( notes_are_active() &&
- !known_before && fully_identified(item) && is_interesting_item(item))
+ if (notes_are_active() && !(item.flags & ISFLAG_NOTED_ID) &&
+ !known_before && fully_identified(item) && is_interesting_item(item))
{
/* make a note of it */
take_note(Note(NOTE_ID_ITEM, 0, 0, item.name(DESC_NOCAP_A).c_str(),
origin_desc(item).c_str()));
+ item.flags |= ISFLAG_NOTED_ID;
}
}
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index edabb39e9d..5a6ffb831d 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -845,11 +845,14 @@ static void milestone_check(const item_def &item)
}
#endif // DGL_MILESTONES
-static void check_note_item(const item_def &item)
+static void check_note_item(item_def &item)
{
- if (is_interesting_item(item))
+ if (!(item.flags & ISFLAG_NOTED_GET) && is_interesting_item(item))
+ {
take_note(Note(NOTE_GET_ITEM, 0, 0, item.name(DESC_NOCAP_A).c_str(),
origin_desc(item).c_str()));
+ item.flags |= ISFLAG_NOTED_GET;
+ }
}
void origin_set(int x, int y)
@@ -865,7 +868,6 @@ void origin_set(int x, int y)
if (!item.orig_monnum)
item.orig_monnum = static_cast<short>( monnum );
item.orig_place = pplace;
- check_note_item(item);
#ifdef DGL_MILESTONES
milestone_check(item);
#endif
@@ -1291,13 +1293,7 @@ int find_free_slot(const item_def &i)
// the player's inventory is full.
int move_item_to_player( int obj, int quant_got, bool quiet )
{
- int imass = 0;
- int unit_mass = 0;
int retval = quant_got;
- char brek = 0;
- bool partialPickup = false;
-
- int m = 0;
// Gold has no mass, so we handle it first.
if (mitm[obj].base_type == OBJ_GOLD)
@@ -1316,15 +1312,13 @@ int move_item_to_player( int obj, int quant_got, bool quiet )
return (retval);
}
- unit_mass = item_mass( mitm[obj] );
+ const int unit_mass = item_mass( mitm[obj] );
if (quant_got > mitm[obj].quantity || quant_got <= 0)
quant_got = mitm[obj].quantity;
- imass = unit_mass * quant_got;
-
- brek = 0;
+ const int imass = unit_mass * quant_got;
- // multiply both constants * 10
+ bool partial_pickup = false;
if (you.burden + imass > carrying_capacity())
{
@@ -1336,20 +1330,22 @@ int move_item_to_player( int obj, int quant_got, bool quiet )
// only pickup 'part' items
quant_got = part;
- partialPickup = true;
+ partial_pickup = true;
retval = part;
}
if (is_stackable_item( mitm[obj] ))
{
- for (m = 0; m < ENDOFPACK; m++)
+ for (int m = 0; m < ENDOFPACK; m++)
{
if (items_stack( you.inv[m], mitm[obj] ))
{
- if (!quiet && partialPickup)
+ if (!quiet && partial_pickup)
mpr("You can only carry some of what is here.");
+ check_note_item(mitm[obj]);
+
inc_inv_item_quantity( m, quant_got );
dec_mitm_item_quantity( obj, quant_got );
burden_change();
@@ -1361,14 +1357,14 @@ int move_item_to_player( int obj, int quant_got, bool quiet )
return (retval);
}
- } // end of for m loop.
+ }
}
// can't combine, check for slot space
if (inv_count() >= ENDOFPACK)
return (-1);
- if (!quiet && partialPickup)
+ if (!quiet && partial_pickup)
mpr("You can only carry some of what is here.");
int freeslot = find_free_slot(mitm[obj]);
diff --git a/crawl-ref/source/notes.cc b/crawl-ref/source/notes.cc
index 3f3e1124ed..1d913205ab 100644
--- a/crawl-ref/source/notes.cc
+++ b/crawl-ref/source/notes.cc
@@ -102,6 +102,8 @@ static bool is_noteworthy( const Note& note )
note.type == NOTE_GOD_GIFT ||
note.type == NOTE_GET_MUTATION ||
note.type == NOTE_LOSE_MUTATION ||
+ note.type == NOTE_GET_ITEM ||
+ note.type == NOTE_ID_ITEM ||
note.type == NOTE_SEEN_MONSTER ||
note.type == NOTE_KILL_MONSTER ||
note.type == NOTE_POLY_MONSTER ||
@@ -174,13 +176,6 @@ static bool is_noteworthy( const Note& note )
if ( rnote.first == note.first && rnote.second == note.second )
return false;
break;
- case NOTE_ID_ITEM:
- case NOTE_GET_ITEM:
- /* re-id'ing an item, e.g. second copy of book, isn't
- noteworthy */
- if ( rnote.name == note.name )
- return false;
- break;
case NOTE_HP_CHANGE:
/* not if we have a recent warning */
if ( (note.turn - rnote.turn < 5) &&