Hello fellow Rom enthusiasts,
Messed up on 'word' a bit. Modified that and ran it, but now I got seg fault
crashes on this
line:
sprintf(buf, "Name: %s Address of function: %p ",
ch->pcdata->menu->name, ch->pcdata->menu->do_fun);
I decided to load up GDB and poke around:
Program received signal SIGINT, Interrupt.
0x400f78b2 in select () from /lib/libc.so.6
(gdb) print menu_list
$1 = (MENU_DATA *) 0x402d61c0
(gdb) print menu_list->do_fun
$2 = (DO_FUN *) 0x8060763 <do_buy>
(gdb) print char_list->pcdata->menu->do_fun
$6 = (DO_FUN *) 0x8060763 <do_buy>
(gdb)
(gdb) print cmd_table[9].do_fun
$11 = (DO_FUN *) 0x8060763 <do_buy>
(gdb) print &do_buy
$13 = (void (*)(CHAR_DATA *, char *)) 0x8060763 <do_buy>
===
Myself at this point: *boggle*
This made me start thinking, and I realized I was an idiot upon analyzing the
debugging code
that followed the above (ha, debugging code that crashes):
for (cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++)
{
sprintf(dbg, "Address of cmd #%d: %p\n\r", cmd,
&cmd_table[cmd].do_fun);
send_to_char(dbg, ch);
}
Problem: &cmd_table[cmd].do_fun.
Fix: cmd_table[cmd].do_fun. Duh :)
I am dumb, consider this case closed. :)
-- Jeremy