if (IS_NPC(ch)) /* NPCs do not have skills */ return;
sn = skill_lookup(name);
if (sn != -1) { /**/ if (ch->pcdata->learned[sn] == 0) /* i.e. not known */ { ch->pcdata->learned[sn] = 1; if (deduct) ch->pcdata->points += skill_table[sn].rating[ch->class]; } return; }
/* now check groups */
gn = group_lookup(name);
if (gn != -1) { if (ch->pcdata->group_known[gn] == FALSE) { ch->pcdata->group_known[gn] = TRUE; if (deduct) ch->pcdata->points += group_table[gn].rating[ch->class]; } gn_add(ch,gn); /* make sure all skills in the group are known */ } }
It error is when it checks to see if it's learned, it finds the sn properly but cannot access ch->pcdata->learned. It can access ch->pcdata, but when I try to print ch->pcdata->learned, it says cannot access memory
Just cause you can access ch->pcdata and just because it's not set to 0 does not mean it's valid memory it's pointing to.
This is likely a case of what the old timers called a 'rogue pointer'. But I guess since we're using the same language we're free to use the term too. ;)
There's a variety of ways to get a rogue pointer. A common way is freeing the memory and then using it later. Use a memory profiling tool like valgrind. It'll save you a lot of footwork. But honestly, these types of errors are always a lot of fun to track down. :)
From nanny before the call for group_add, ch->pcdata->learned has a value of "{0 <repeats 150 times>}", but then when I step and it goes to group_add, it is no longer accessible
It error is when it checks to see if it's learned, it finds the sn properly but cannot access ch->pcdata->learned. It can access ch->pcdata, but when I try to print ch->pcdata->learned, it says cannot access memory