Hello,
I've put together an complete introduction system. It works pretty well,
but I've noticed a minor bug, in my add_know() function. It works, but
usually only after the function is called several times. Here is the code:
-- snip --
void add_know(struct char_data *ch, struct char_data *victim)
{
int i, found = 0;
if (knows_char(ch,victim))
return;
/* simple case first */
if (!ch->player_specials->memory) {
CREATE(ch->player_specials->memory, long, 2);
ch->player_specials->memory[0] = 1;
ch->player_specials->memory[1] = GET_IDNUM(victim);
return;
}
ch->player_specials->memory[0]++;
/* number of remembered + index -> +1*/
RECREATE(ch->player_specials->memory, long, ch->player_specials->memory[0]
+1);
for (i = ch->player_specials->memory[0]+1;i > 1; i--) {
if (ch->player_specials->memory[i-1] < GET_IDNUM(victim)) {
ch->player_specials->memory[i] = GET_IDNUM(victim);
found = i;
} else
ch->player_specials->memory[i] = ch->player_specials->memory[i-1];
}
if (!found)
ch->player_specials->memory[1] = GET_IDNUM(victim);
}
-- end of snip --
Please ask if any more information is required.
--
+---------------------------------------------------------------+
| FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
| Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
| Newbie List: http://groups.yahoo.com/group/circle-newbies/ |
+---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/26/03 PDT