Improved visible monster list. Still has some c++ style commented out debugging statements. Worked great if I recall correctly. Seperated monsters based on ego type and status (partial,friendly,pet,etc) as well as race. Also showed the ASCII symbol.
diff -udprBb --exclude='*.o' --exclude='*.raw' tome-225-src/src/xtra1.c floor_patch/src/xtra1.c
--- tome-225-src/src/xtra1.c 2003-12-11 13:32:41.000000000 -0700
+++ floor_patch/src/xtra1.c 2004-01-30 13:54:52.000000000 -0700
@@ -1419,6 +1454,73 @@ static void fix_object(void)
}
/* Show the monster list in a window */
+struct ml_list_list{
+ int r_idx, re_idx, mstat, count, level;
+};
+
+/* Add to the monster list list, in sorted order. Or just increment a count */
+void fix_ml_list_aux(
+ struct ml_list_list *ml_list,
+ int *count,
+ int max_count,
+ monster_type *m_ptr)
+{
+ int i,j;
+
+ /* Find the proper position in the list */
+ for( i = 0 ; i < *count ; i++ )
+ {
+ /* sort by: level, r_idx, re_idx, status */
+ if( m_ptr->level > ml_list[i].level)
+ break;
+ if( m_ptr->level == ml_list[i].level &&
+ m_ptr->r_idx > ml_list[i].r_idx)
+ break;
+ if( m_ptr->level == ml_list[i].level &&
+ m_ptr->r_idx == ml_list[i].r_idx &&
+ m_ptr->ego > ml_list[i].re_idx)
+ break;
+ if( m_ptr->level == ml_list[i].level &&
+ m_ptr->r_idx == ml_list[i].r_idx &&
+ m_ptr->ego == ml_list[i].re_idx &&
+ m_ptr->status >= ml_list[i].mstat )
+ break;
+ }
+// get_check(format("testing final i=%d,r=%s",i,r_name+r_info[m_ptr->r_idx].name));
+
+ /* We need to add a new record, shove everything else in the list up by one */
+ if( m_ptr->level != ml_list[i].level ||
+ m_ptr->r_idx != ml_list[i].r_idx ||
+ m_ptr->ego != ml_list[i].re_idx ||
+ m_ptr->status != ml_list[i].mstat || i >= *count)
+ {
+ /* Check for list overflow */
+ if(*count >= (max_count -1) )
+ return;
+
+ /* Shove things up */
+ for( j = *count ; j > i ; j--){
+// get_check(format("moving %s up to slot %d over %s",r_name+r_info[ml_list[j-1].r_idx].name,j,r_name + r_info[ml_list[j].r_idx].name));
+ ml_list[j].level = ml_list[j-1].level;
+ ml_list[j].r_idx = ml_list[j-1].r_idx;
+ ml_list[j].re_idx = ml_list[j-1].re_idx;
+ ml_list[j].mstat = ml_list[j-1].mstat;
+ ml_list[j].count = ml_list[j-1].count;
+ }
+
+ /* Track the count */
+ *count = *count +1;
+
+ /* Add the new record */
+ ml_list[i].level = m_ptr->level;
+ ml_list[i].r_idx = m_ptr->r_idx;
+ ml_list[i].re_idx = m_ptr->ego;
+ ml_list[i].mstat = m_ptr->status;
+ ml_list[i].count = 0;
+ }
+ /* increase the count by one */
+ ml_list[i].count++;
+}
static void fix_m_list(void)
{
@@ -1429,8 +1531,6 @@ static void fix_m_list(void)
{
term *old = Term;
- int c = 0;
-
/* No window */
if (!angband_term[j]) continue;
@@ -1456,6 +1556,137 @@ static void fix_m_list(void)
return;
}
+ {
+ struct ml_list_list ml_list[40];
+ int count=0;
+ monster_race *r_ptr;
+// while(!get_check(format("testing count=%d",count)));
+ for( i = 1 ; i < m_max ; i++)
+ {
+ monster_type *m_ptr=&m_list[i];
+
+ /* Skip dead monsters */
+ if( !m_ptr->r_idx )
+ continue;
+
+ r_ptr = &r_info[m_ptr->r_idx];
+
+ /* Skip unknown mimics and non-visible monsters */
+ if ( ((r_ptr->flags9 & RF9_MIMIC) && m_ptr->csleep) || (!m_ptr->ml))
+ continue;
+
+ /* add to list in sorted order... */
+ fix_ml_list_aux(ml_list,&count,40,m_ptr);
+ }
+// while(!get_check(format("final count=%d",count)));
+ /* Note that no monsters are visible */
+ if(!count)
+ {
+ c_prt(TERM_WHITE, "You see no monsters.", 0, 0);
+ }
+ else
+ /* print visible monsters */
+ {
+ int w, h, num=0,attr;
+ (void)Term_get_size(&w, &h);
+ for( i = 0 ; i < count ; i ++ )
+ {
+ monster_race *r_ptr = &r_info[ml_list[i].r_idx];
+ char m_name[80];
+ char character[2];
+ int row=(i%(h-1))+1;
+ int col=(i/(h-1))*32;
+
+ /* We've reached the maximum number displayable in the window */
+ /* Here 32 is the column width - note that it's not a multiple of 80.
+ There IS a point in doing it this way, as platforms (i.e. X11) can have
+ odd-sized windows. */
+ if(col > ( w - 32))
+ break;
+
+ /* Is this monster OOD? */
+ if (r_ptr->level > dun_level)
+ {
+ attr = TERM_L_RED;
+
+ if (r_ptr->flags1 & RF1_UNIQUE)
+ {
+ attr = TERM_YELLOW;
+ }
+ }
+ else
+ {
+ /* Uniques */
+ if (r_ptr->flags1 & RF1_UNIQUE)
+ attr = TERM_L_BLUE;
+ else
+ attr = TERM_GREEN;
+ }
+
+ /* Grab the racial name */
+ strcpy(m_name,r_name+r_ptr->name);
+
+ /* Add the ego name, if any */
+ if(ml_list[i].re_idx)
+ {
+ monster_ego *re_ptr = &re_info[ml_list[i].re_idx];
+ /* copy in the ego name*/
+ if(re_ptr->before)
+ sprintf(m_name,"%s %s",re_name+re_ptr->name,r_name+r_ptr->name);
+ else
+ sprintf(m_name,"%s %s",r_name+r_ptr->name,re_name+re_ptr->name);
+ }
+ /* OK - the display format:
+ 127wP Green worm mass(k12)
+ w - racial char and attribute
+ 127 - visible count, always white
+ P - status - companion, coaligned, etc.
+ k12 - Kill counter.
+ desc - Color indicates OOD/Unique/etc. */
+ /* Red-OOD, yellow-OOD+Unique, blue-Unique, Green(normal)*/
+ prt(format(" %3d",ml_list[i].count),row,col);
+ col+=4;
+ character[0]=r_ptr->d_char;
+ character[1]='\0';
+ c_prt(r_ptr->d_attr,character,row,col);
+ col+=1;
+
+ /* Print a 'friendly' indicator, if needed */
+ switch (ml_list[i].mstat)
+ {
+ case MSTATUS_NEUTRAL_P: c_prt(TERM_WHITE,"N",row,col);col+=1;break;
+ case MSTATUS_FRIEND: c_prt(TERM_GREEN,"F",row,col);col+=1;break;
+ case MSTATUS_PET: c_prt(TERM_GREEN,"P",row,col);col+=1;break;
+ case MSTATUS_COMPANION: c_prt(TERM_L_GREEN,"C",row,col);col += 1; break;
+ case MSTATUS_NEUTRAL_M: c_prt(TERM_RED,"N",row,col);col += 1; break;
+ case MSTATUS_ENEMY: break;
+ case MSTATUS_NEUTRAL: c_prt(TERM_WHITE,"N",row,col);col+=1; break;
+ }
+ col++;
+
+ /* Dump the monster name */
+ if (r_ptr->r_tkills == 0)
+ {
+ /* Enfore maximum length */
+ m_name[25]='\0';
+ c_prt(attr, (r_name + r_ptr->name), row, col);
+ }
+ else
+ {
+ /* Enfore maximum length */
+ m_name[19]='\0';
+ c_prt(attr, format("%s (%dk)", m_name, r_ptr->r_tkills) , row, col);
+ }
+
+ num++;
+ }
+ }
+ }
+#if 0
+This code is replaced so that I can show:
+friendly/enemy status
+race ego
+kills, etc.
/* reset visible count */
for (i = 1; i < max_r_idx; i++)
@@ -1560,6 +1791,7 @@ static void fix_m_list(void)
{
c_prt(TERM_WHITE, "You see no monsters.", 0, 0);
}
+#endif
/* Fresh */
Term_fresh();
ToME Wiki