Code problem

  • Dragonfree97
    24th Oct 2010 Member 0 Permalink
    if(t==PT_JKSN){
    if((r&0xFF)!=PT_BHOL&&(r&0xFF)!=PT_WHOL&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_IMTL&&(r&0xF F)!=PT_IBTR&&(r&0xFF)!=PT_MOVS&&(r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_VOID&&(r&0xFF)!=PT_CS TF&&(r&0xFF)!=PT_HETR&&(r&0xFF)!=PT_INSL&&(r&0xFF)!=PT_NONE&&(r&0xFF)!=PT_JKSN){
    parts[r>>8].type = PT_FIRE;
    }
    }

    just crashes the game when JKSN is placed, says that variable 'r' needs to be initialised, and adding r = pmap[y+ny][x+nx]; above
    if(r&0xFF)... gives me error:

    Unhandled exception at 0x003c4787 in thepowdertoy.exe: 0xC0000005: Access violation writing location 0x0dee0c50.

    What do I do?
  • Felix
    24th Oct 2010 Member 0 Permalink
    first of all, pastebin all your code. Secondly, generate a proper debug output. Use a debugger, eg. GDB.
  • Xenocide
    24th Oct 2010 Former Staff 0 Permalink
    Taking a guess, your not putting it in the right place.

    Felix:
    pastebin all your code

  • Dragonfree97
    24th Oct 2010 Member 0 Permalink
    antb:
    Taking a guess, your not putting it in the right place.

    It's in the right place, I assure you.
  • Xenocide
    24th Oct 2010 Former Staff 0 Permalink
    If you would like to upload your modified file with highlighting to www.pastebin.com we can tell you.
  • Dragonfree97
    24th Oct 2010 Member 0 Permalink
    right here

    line 2183 to about 2189

    the highlighting thing didn't work for me
  • MiXih
    24th Oct 2010 Member 0 Permalink
    <offtopic>
    JKSN is michael jackson and burns everything? lol
    </offtopic>
  • Dragonfree97
    24th Oct 2010 Member 0 Permalink
    <offtopic>no it was named for a guy at my school called jack so we called it jacksonium</offtopic>

    but yeah, that's what it's supposed to do...
  • Xenocide
    24th Oct 2010 Former Staff 0 Permalink
    replaces lines 2183 to 2189 with:


    if(t==PT_JKSN)
    for(nx=-2; nx<3; nx++)
    for(ny=-2; ny<3; ny++)
    if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
    {
    r = pmap[y+ny][x+nx];
    if((r>>8)>=NPART || !r)
    continue;
    if((r&0xFF)!=PT_BHOL&&(r&0xFF)!=PT_WHOL&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_IMTL&&(r&0xF F)!=PT_IBTR&&(r&0xFF)!=PT_MOVS&&(r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_VOID&&(r&0xFF)!=PT_CS TF&&(r&0xFF)!=PT_HETR&&(r&0xFF)!=PT_INSL&&(r&0xFF)!=PT_NONE&&(r&0xFF)!=PT_JKSN)
    parts[r>>8].type = PT_FIRE;
    }
  • Dragonfree97
    24th Oct 2010 Member 0 Permalink
    Thanks!