Ok, I maybe it's the sleep deprivation in my effort to dive into
circlemud code (started this saturday, have gone a LONG way since).
I understood the original code for displaying objects, but I wanted the
object stacking code ... I'm a nut about being able to understand my code,
however ... and I just need someone to explain the areas marked by
***(?)*** to me. My confusion stems mainly from the (item_number==NOTHING)
Sections
---------------------------- code ----------------------------
void list_obj_to_char(struct obj_data * list, struct char_data * ch, int mode,
bool show)
{
struct obj_data *i, *j; // adden j for another file pointer
char buf[10]; // Added buffer of size ten
bool found = FALSE;
int num;
//'i' = list of obj in room ;while i exists do ... ; go to next item
for (i = list; i; i = i->next_content) {
num = 0; // reset number of said item found
for (j = list; j != i; j = j->next_content)
if (j->item_number==NOTHING) { // ***(?)*** I think if there is
nothing in room
if(strcmp(j->short_description,i->short_description)==0) // ***(?)***
break;
}
else if (j->item_number==i->item_number) // if we've reached same
item
break;
if (j!=i) // if j != i keep going
continue;
for (j = i; j; j = j->next_content) // ***(?)***
if (j->item_number==NOTHING) { // ***(?)***
if(strcmp(j->short_description,i->short_description)==0) num++;
} // ***(?)***
else if (j->item_number==i->item_number) num++; // if object
numbers are
// the same
if (CAN_SEE_OBJ(ch, i)) {
if (num!=1) {
sprintf(buf,"[%2i] ",num);
send_to_char(buf,ch);
}
show_obj_to_char(i, ch, mode);
found = TRUE;
}
}
if (!found && show)
send_to_char(" Nothing.\r\n", ch);
}
----------------------- end code ----------------------------
I put the "unnecessary" comments in b/c my brain was so fried
from looking through code last night that I might not have
understood what a simple for loop did :) Please feel free to
correct my comments if in fact I didn't understand them. I
wouldn't be surprised if I totally didn't understand what I
was doing.
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST