User Tag List

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 22

Thread: NPCs fail to appear after writing new values to the packfile.

  1. #11
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,815
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,933
    Level
    33
    vBActivity - Bars
    Lv. Percent
    23.44%
    Quote Originally Posted by ZoriaRPG View Post
    Where do I change the defs for guyversion, and add the new version; or did you mean that 23 is current? I'd still need to know where to set that.
    V_GUYS in zdefs.h.
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  2. #12
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,760
    Level
    21
    vBActivity - Bars
    Lv. Percent
    68.7%
    Quote Originally Posted by Gleeok View Post
    V_GUYS in zdefs.h.

    Oh, must have glossed over it. probably because I didn't know the current version, and it didn't match the known ID.

    Anyhow, still massive data corruption:


    The default bubble enemy, upon loading the base quest template with this patch.

    qst.cpp

    Spoiler: show
    Code:
    int readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
    {
        dword dummy;
        word dummy2;
        word guyversion=0;
        
        if(Header->zelda_version >= 0x193)
        {
            //section version info
            if(!p_igetw(&guyversion,f,true))
            {
                return qe_invalid;
            }
            
            //al_trace("Guys version %d\n", guyversion);
            if(!p_igetw(&dummy2,f,true))
            {
                return qe_invalid;
            }
            
            //section size
            if(!p_igetl(&dummy,f,true))
            {
                return qe_invalid;
            }
        }
        
        if(guyversion > 3)
        {
            for(int i=0; i<MAXGUYS; i++)
            {
                char tempname[64];
                
                // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
                // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
                if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
                {
                    memset(tempname, 0, sizeof(char)*64);
                    sprintf(tempname, "e%03d", i);
                    strcpy(guy_string[i], tempname);
                    
                    continue;
                }
                
                if(!pfread(tempname, 64, f, keepdata))
                {
                    return qe_invalid;
                }
                
                // Don't retain names of uneditable enemy entries!
                if(keepdata)
                {
                    // for version upgrade to 2.5
                    if(guyversion < 23 && i >= 177)
                    {
                        // some of the older builds have names such as 'zz123',
                        // (this order gets messed up with some eXXX and some zzXXX)
                        // so let's update to the newer naming convection. -Gleeok
                        char tmpbuf[64];
                        memset(tmpbuf, 0, sizeof(char)*64);
                        sprintf(tmpbuf, "zz%03d", i);
                        
                        if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
                        {
                            memset(tempname, 0, sizeof(char)*64);
                            sprintf(tempname, "e%03d", i);
                        }
                    }
                    
                    if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
                    {
                        strcpy(guy_string[i], tempname);
                    }
                    else
                    {
                        strcpy(guy_string[i],old_guy_string[i]);
                    }
                }
            }
        }
        else
        {
            if(keepdata)
            {
                for(int i=0; i<eMAXGUYS; i++)
                {
                    sprintf(guy_string[i],"zz%03d",i);
                }
                
                for(int i=0; i<OLDMAXGUYS; i++)
                {
                    strcpy(guy_string[i],old_guy_string[i]);
                }
            }
        }
        
        
        //finally...  section data
        if(keepdata)
        {
            init_guys(guyversion);                            //using default data for now...
            
            // Goriya guy fix
            if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
            {
                if(get_bit(quest_rules,qr_NEWENEMYTILES))
                {
                    guysbuf[gGORIYA].tile=130;
                    guysbuf[gGORIYA].e_tile=130;
                }
            }
        }
        
        if(Header->zelda_version < 0x193)
        {
            if(get_bit(deprecated_rules,46))
            {
                guysbuf[eDODONGO].cset=14;
                guysbuf[eDODONGO].bosspal=spDIG;
            }
        }
        
        // Not sure when this first changed, but it's necessary for 2.10, at least
        if(Header->zelda_version <= 0x210)
        {
            guysbuf[eGLEEOK1F].misc6 = 16;
            guysbuf[eGLEEOK2F].misc6 = 16;
            guysbuf[eGLEEOK3F].misc6 = 16;
            guysbuf[eGLEEOK4F].misc6 = 16;
            
            guysbuf[eWIZ1].misc4 = 1;
            guysbuf[eBATROBE].misc4 = 1;
            guysbuf[eSUMMONER].misc4 = 1;
            guysbuf[eWWIZ].misc4 = 1;
        }
        
        // The versions here may not be correct
        // zelda_version>=0x211 handled at guyversion<24
        if(Header->zelda_version <= 0x190)
        {
            guysbuf[eCENT1].misc3 = 0;
            guysbuf[eCENT2].misc3 = 0;
            guysbuf[eMOLDORM].misc2 = 0;
        }
        else if(Header->zelda_version <= 0x210)
        {
            guysbuf[eCENT1].misc3 = 1;
            guysbuf[eCENT2].misc3 = 1;
            guysbuf[eMOLDORM].misc2 = 0;
        }
        
        if(guyversion<=2)
        {
            return readlinksprites2(f, guyversion==2?0:-1, 0, keepdata);
        }
        
        if(guyversion > 3)
        {
            guydata tempguy;
            
            for(int i=0; i<MAXGUYS; i++)
            {
                if(guyversion < 23 && keepdata)   // May 2012 : 512 max enemies
                {
                    if(i >= OLDBETAMAXGUYS)
                    {
                        memset(&guysbuf[i], 0, sizeof(guydata));
                        continue;
                    }
                }
                
                memset(&tempguy, 0, sizeof(guydata));
                
                if(!p_igetl(&(tempguy.flags),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetl(&(tempguy.flags2),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.tile),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_getc(&(tempguy.width),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_getc(&(tempguy.height),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.s_tile),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_getc(&(tempguy.s_width),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_getc(&(tempguy.s_height),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.e_tile),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_getc(&(tempguy.e_width),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_getc(&(tempguy.e_height),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.hp),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.family),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
                {
                    if(get_bit(quest_rules,qr_NEWENEMYTILES))
                    {
                        tempguy.s_tile=tempguy.e_tile+120;
                        tempguy.s_width=tempguy.e_width;
                        tempguy.s_height=tempguy.e_height;
                    }
                    else tempguy.s_tile=860;
                }
                
                if(!p_igetw(&(tempguy.cset),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.anim),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.e_anim),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.frate),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.e_frate),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(guyversion < 13)  // April 2009
                {
                    if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
                    {
                        tempguy.frate *= 2;
                        tempguy.e_frate *= 2;
                    }
                }
                
                if(guyversion < 14)  // May 1 2009
                {
                    if(tempguy.anim==a2FRMSLOW)
                    {
                        tempguy.anim=a2FRM;
                        tempguy.frate *= 2;
                    }
                    
                    if(tempguy.e_anim==a2FRMSLOW)
                    {
                        tempguy.e_anim=a2FRM;
                        tempguy.e_frate *= 2;
                    }
                    
                    if(tempguy.anim==aFLIPSLOW)
                    {
                        tempguy.anim=aFLIP;
                        tempguy.frate *= 2;
                    }
                    
                    if(tempguy.e_anim==aFLIPSLOW)
                    {
                        tempguy.e_anim=aFLIP;
                        tempguy.e_frate *= 2;
                    }
                    
                    if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
                    
                    if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
                    
                    if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
                    {
                        tempguy.anim=a4FRM4DIR;
                        tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
                    }
                    
                    if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
                    {
                        tempguy.e_anim=a4FRM4DIR;
                        tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
                    }
                }
                
                if(!p_igetw(&(tempguy.dp),f,keepdata))
                {
                    return qe_invalid;
                }
                
                //correction for guy fire
                if(guyversion < 6)
                {
                    if(i == gFIRE)
                        tempguy.dp = 2;
                }
                
                if(!p_igetw(&(tempguy.wdp),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.weapon),f,keepdata))
                {
                    return qe_invalid;
                }
                
                //correction for bosses using triple, "rising" fireballs
                if(guyversion < 5)
                {
                    if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
                            i == eGOHMA3 || i == eGOHMA4)
                    {
                        if(tempguy.weapon == ewFireball)
                            tempguy.weapon = ewFireball2;
                    }
                }
                
                if(!p_igetw(&(tempguy.rate),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.hrate),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.step),f,keepdata))
                {
                    return qe_invalid;
                }
                
                // HIGHLY UNORTHODOX UPDATING THING, part 2
                if(fixpolsvoice && tempguy.family==eePOLSV)
                {
                    tempguy.step /= 2;
                }
                
                if(!p_igetw(&(tempguy.homing),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.grumble),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.item_set),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
                {
                    if(!p_igetl(&(tempguy.misc1),f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    if(!p_igetl(&(tempguy.misc2),f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    if(!p_igetl(&(tempguy.misc3),f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    if(!p_igetl(&(tempguy.misc4),f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    if(!p_igetl(&(tempguy.misc5),f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    if(!p_igetl(&(tempguy.misc6),f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    if(!p_igetl(&(tempguy.misc7),f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    if(!p_igetl(&(tempguy.misc8),f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    if(!p_igetl(&(tempguy.misc9),f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    if(!p_igetl(&(tempguy.misc10),f,keepdata))
                    {
                        return qe_invalid;
                    }
                }
                else
                {
                    short tempMisc;
                    
                    if(!p_igetw(&tempMisc,f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    tempguy.misc1=tempMisc;
                    
                    if(!p_igetw(&tempMisc,f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    tempguy.misc2=tempMisc;
                    
                    if(!p_igetw(&tempMisc,f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    tempguy.misc3=tempMisc;
                    
                    if(!p_igetw(&tempMisc,f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    tempguy.misc4=tempMisc;
                    
                    if(!p_igetw(&tempMisc,f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    tempguy.misc5=tempMisc;
                    
                    if(guyversion < 13)  // April 2009 - a tiny Wizzrobe update
                    {
                        if(tempguy.family == eeWIZZ && !(tempguy.misc1))
                            tempguy.misc5 = 74;
                    }
                    
                    if(!p_igetw(&tempMisc,f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    tempguy.misc6=tempMisc;
                    
                    if(!p_igetw(&tempMisc,f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    tempguy.misc7=tempMisc;
                    
                    if(!p_igetw(&tempMisc,f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    tempguy.misc8=tempMisc;
                    
                    if(!p_igetw(&tempMisc,f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    tempguy.misc9=tempMisc;
                    
                    if(!p_igetw(&tempMisc,f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    tempguy.misc10=tempMisc;
                }
                
                if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.bosspal),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(!p_igetw(&(tempguy.extend),f,keepdata))
                {
                    return qe_invalid;
                }
                
                if(guyversion >= 16)  // November 2009 - Super Enemy Editor
                {
                    for(int j=0; j<edefLAST; j++)
                    {
                        if(!p_getc(&(tempguy.defense[j]),f,keepdata))
                        {
                            return qe_invalid;
                        }
                    }
                }
                
                if(guyversion >= 18)
                {
                    if(!p_getc(&(tempguy.hitsfx),f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    if(!p_getc(&(tempguy.deadsfx),f,keepdata))
                    {
                        return qe_invalid;
                    }
                }
                
                if(guyversion >= 22)
                {
                    if(!p_igetl(&(tempguy.misc11),f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    if(!p_igetl(&(tempguy.misc12),f,keepdata))
                    {
                        return qe_invalid;
                    }
    		
                }
    	    if(guyversion >= 23) // Add new guyversion conditional statement 
                {
    		for(int j=0; j<scriptDEFLAST; j++)
                    {
                        if(!p_getc(&(tempguy.scriptdefense[j]),f,keepdata))
                        {
                            return qe_invalid;
                        }
                    }
                }
                else if(guyversion >= 19)
                {
                    short tempMisc;
                    
                    if(!p_igetw(&tempMisc,f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    tempguy.misc11=tempMisc;
                    
                    if(!p_igetw(&tempMisc,f,keepdata))
                    {
                        return qe_invalid;
                    }
                    
                    tempguy.misc12=tempMisc;
                }
                
                //miscellaneous other corrections
                //fix the mirror wizzrobe -DD
                if(guyversion < 7)
                {
                    if(i == eMWIZ)
                    {
                        tempguy.misc2 = 0;
                        tempguy.misc4 = 1;
                    }
                }
                
                if(guyversion < 8)
                {
                    if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
                    {
                        // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
                        tempguy.misc5 = 4; //neck length in segments
                        tempguy.misc6 = 8; //neck offset from first body tile
                        tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
                        tempguy.misc8 = 168; //head offset from first body tile
                        tempguy.misc9 = 228; //flying head offset from first body tile
                        
                        if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
                        {
                            tempguy.misc6 += 10; //neck offset from first body tile
                            tempguy.misc8 -= 12; //head offset from first body tile
                        }
                    }
                }
                
                if(guyversion < 10) // December 2007 - Dodongo CSet fix
                {
                    if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
                        tempguy.bosspal = spDIG;
                }
                
                if(guyversion < 11) // December 2007 - Spinning Tile fix
                {
                    if(tempguy.family==eeSPINTILE)
                    {
                        tempguy.flags |= guy_superman;
                        tempguy.item_set = 0; // Don't drop items
                        tempguy.step = 300;
                    }
                }
                
                if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
                {
                    if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
                    {
                        if(tempguy.family==eeROPE)
                        {
                            tempguy.flags2 &= ~guy_flashing;
                        }
                    }
                    
                    if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
                    {
                        if(tempguy.family==eeBUBBLE)
                        {
                            tempguy.flags2 &= ~guy_flashing;
                        }
                    }
                    
                    if((tempguy.family==eeGHINI)&&(tempguy.misc1))
                    {
                        if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
                        {
                            tempguy.flags2 |= guy_blinking;
                        }
                        
                        if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
                        {
                            tempguy.flags2 |= guy_transparent;
                        }
                    }
                }
                
                if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
                {
                    if(i==gFIRE)
                    {
                        tempguy.e_anim = aFLIP;
                        tempguy.e_frate = 24;
                    }
                    
                    if(i==gFAIRY)
                    {
                        tempguy.e_anim = a2FRM;
                        tempguy.e_frate = 16;
                    }
                }
                
                if(guyversion < 16)  // November 2009 - Super Enemy Editor part 1
                {
                    if(i==0) Z_message("Updating guys to version 16...\n");
                    
                    update_guy_1(&tempguy);
                    
                    if(i==eMPOLSV)
                    {
                        tempguy.defense[edefARROW] = edCHINK;
                        tempguy.defense[edefMAGIC] = ed1HKO;
                        tempguy.defense[edefREFMAGIC] = ed1HKO;
                    }
                }
                
                if(guyversion < 17)  // December 2009
                {
                    if(tempguy.family==eePROJECTILE)
                    {
                        tempguy.misc1 = 0;
                    }
                }
                
                if(guyversion < 18)  // January 2010
                {
                    bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
                                 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
                                 
                    tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
                    tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
                    
                    if(tempguy.family == eeAQUA)
                        for(int j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
                    else if(tempguy.family == eeMANHAN)
                        for(int j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
                    else if(tempguy.family==eePATRA)
                        for(int j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
                    else if(tempguy.family==eeGHOMA)
                    {
                        for(int j=0; j<edefLAST; j++)
                            tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
                            
                        tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
                        
                        if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
                        
                        tempguy.misc1--;
                    }
                    else if(tempguy.family == eeGLEEOK)
                    {
                        for(int j=0; j<edefLAST; j++)
                            tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
                            
                        if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
                    }
                    else if(tempguy.family == eeARMOS)
                    {
                        tempguy.family=eeWALK;
                        tempguy.hrate = 0;
                        tempguy.misc10 = tempguy.misc1;
                        tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
                        tempguy.misc9 = e9tARMOS;
                    }
                    else if(tempguy.family == eeGHINI && !tempguy.misc1)
                    {
                        tempguy.family=eeWALK;
                        tempguy.hrate = 0;
                        tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
                                                            tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
                    }
                    
                    // Spawn animation flags
                    if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
                        tempguy.flags |= guy_fadeflicker;
                    else
                        tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
                }
                
                if(guyversion < 20)  // April 2010
                {
                    if(tempguy.family == eeTRAP)
                    {
                        tempguy.misc2 = tempguy.misc10;
                        
                        if(tempguy.misc10>=1)
                        {
                            tempguy.misc1++;
                        }
                        
                        tempguy.misc10 = 0;
                    }
                    
                    // Bomb Blast fix
                    if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
                        tempguy.weapon = ewLitBomb;
                    else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
                        tempguy.weapon = ewLitSBomb;
                }
                
                if(guyversion < 21)  // September 2011
                {
                    if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
                    {
                        if(tempguy.family == eeKEESETRIB)
                        {
                            tempguy.family = eeKEESE;
                            tempguy.misc2 = e2tKEESETRIB;
                            tempguy.misc1 = 0;
                        }
                        
                        tempguy.rate = 2;
                        tempguy.hrate = 8;
                        tempguy.homing = 0;
                        tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
                    }
                    else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
                    {
                        if(tempguy.family == eePEAHAT)
                        {
                            tempguy.rate = 4;
                            tempguy.step = 62;
                        }
                        else
                            tempguy.step = 25;
                            
                        tempguy.hrate = 8;
                        tempguy.homing = 0;
                    }
                    else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
                    {
                        if(tempguy.family == eeMANHAN)
                            tempguy.step=50;
                            
                        tempguy.hrate = 16;
                        tempguy.homing = 0;
                    }
                    else if(tempguy.family == eeGLEEOK)
                    {
                        tempguy.rate = 2;
                        tempguy.homing = 0;
                        tempguy.hrate = 9;
                        tempguy.step=89;
                    }
                    else if(tempguy.family == eeGHINI)
                    {
                        tempguy.rate = 4;
                        tempguy.hrate = 12;
                        tempguy.step=62;
                        tempguy.homing = 0;
                    }
                    
                    // Bigdig random rate fix
                    if(tempguy.family==eeDIG && tempguy.misc10==1)
                    {
                        tempguy.rate = 2;
                    }
                }
                
                if(guyversion < 24) // November 2012
                {
                    if(tempguy.family==eeLANM)
                        tempguy.misc3 = 1;
                    else if(tempguy.family==eeMOLD)
                        tempguy.misc2 = 0;
                }
                
                if(keepdata)
                {
                    guysbuf[i] = tempguy;
                }
            }
        }
        
        return 0;
    }


    zq_class.cpp

    Spoiler: show
    Code:
    int writeguys(PACKFILE *f, zquestheader *Header)
    {
        //these are here to bypass compiler warnings about unused arguments
        Header=Header;
        
        dword section_id=ID_GUYS;
        dword section_version=V_GUYS;
        dword section_cversion=CV_GUYS;
        dword section_size=0;
        
        //section id
        if(!p_mputl(section_id,f))
        {
            new_return(1);
        }
        
        //section version info
        if(!p_iputw(section_version,f))
        {
            new_return(2);
        }
        
        if(!p_iputw(section_cversion,f))
        {
            new_return(3);
        }
        
        for(int writecycle=0; writecycle<2; ++writecycle)
        {
            fake_pack_writing=(writecycle==0);
            
            //section size
            if(!p_iputl(section_size,f))
            {
                new_return(4);
            }
            
            writesize=0;
            
            //finally...  section data
            for(int i=0; i<MAXGUYS; i++)
            {
                if(!pfwrite((char *)guy_string[i], 64, f))
                {
                    new_return(5);
                }
            }
            
            for(int i=0; i<MAXGUYS; i++)
            {
                if(!p_iputl(guysbuf[i].flags,f))
                {
                    new_return(6);
                }
                
                if(!p_iputl(guysbuf[i].flags2,f))
                {
                    new_return(7);
                }
                
                if(!p_iputw(guysbuf[i].tile,f))
                {
                    new_return(8);
                }
                
                if(!p_putc(guysbuf[i].width,f))
                {
                    new_return(9);
                }
                
                if(!p_putc(guysbuf[i].height,f))
                {
                    new_return(10);
                }
                
                if(!p_iputw(guysbuf[i].s_tile,f))
                {
                    new_return(11);
                }
                
                if(!p_putc(guysbuf[i].s_width,f))
                {
                    new_return(12);
                }
                
                if(!p_putc(guysbuf[i].s_height,f))
                {
                    new_return(13);
                }
                
                if(!p_iputw(guysbuf[i].e_tile,f))
                {
                    new_return(14);
                }
                
                if(!p_putc(guysbuf[i].e_width,f))
                {
                    new_return(15);
                }
                
                if(!p_putc(guysbuf[i].e_height,f))
                {
                    new_return(16);
                }
                
                if(!p_iputw(guysbuf[i].hp,f))
                {
                    new_return(17);
                }
                
                if(!p_iputw(guysbuf[i].family,f))
                {
                    new_return(18);
                }
                
                if(!p_iputw(guysbuf[i].cset,f))
                {
                    new_return(19);
                }
                
                if(!p_iputw(guysbuf[i].anim,f))
                {
                    new_return(20);
                }
                
                if(!p_iputw(guysbuf[i].e_anim,f))
                {
                    new_return(21);
                }
                
                if(!p_iputw(guysbuf[i].frate,f))
                {
                    new_return(22);
                }
                
                if(!p_iputw(guysbuf[i].e_frate,f))
                {
                    new_return(23);
                }
                
                if(!p_iputw(guysbuf[i].dp,f))
                {
                    new_return(24);
                }
                
                if(!p_iputw(guysbuf[i].wdp,f))
                {
                    new_return(25);
                }
                
                if(!p_iputw(guysbuf[i].weapon,f))
                {
                    new_return(26);
                }
                
                if(!p_iputw(guysbuf[i].rate,f))
                {
                    new_return(27);
                }
                
                if(!p_iputw(guysbuf[i].hrate,f))
                {
                    new_return(28);
                }
                
                if(!p_iputw(guysbuf[i].step,f))
                {
                    new_return(29);
                }
                
                if(!p_iputw(guysbuf[i].homing,f))
                {
                    new_return(30);
                }
                
                if(!p_iputw(guysbuf[i].grumble,f))
                {
                    new_return(31);
                }
                
                if(!p_iputw(guysbuf[i].item_set,f))
                {
                    new_return(32);
                }
                
                if(!p_iputl(guysbuf[i].misc1,f))
                {
                    new_return(33);
                }
                
                if(!p_iputl(guysbuf[i].misc2,f))
                {
                    new_return(34);
                }
                
                if(!p_iputl(guysbuf[i].misc3,f))
                {
                    new_return(35);
                }
                
                if(!p_iputl(guysbuf[i].misc4,f))
                {
                    new_return(36);
                }
                
                if(!p_iputl(guysbuf[i].misc5,f))
                {
                    new_return(37);
                }
                
                if(!p_iputl(guysbuf[i].misc6,f))
                {
                    new_return(38);
                }
                
                if(!p_iputl(guysbuf[i].misc7,f))
                {
                    new_return(39);
                }
                
                if(!p_iputl(guysbuf[i].misc8,f))
                {
                    new_return(40);
                }
                
                if(!p_iputl(guysbuf[i].misc9,f))
                {
                    new_return(41);
                }
                
                if(!p_iputl(guysbuf[i].misc10,f))
                {
                    new_return(42);
                }
                
                if(!p_iputw(guysbuf[i].bgsfx,f))
                {
                    new_return(43);
                }
                
                if(!p_iputw(guysbuf[i].bosspal,f))
                {
                    new_return(44);
                }
                
                if(!p_iputw(guysbuf[i].extend,f))
                {
                    new_return(45);
                }
               
                if(!p_putc(guysbuf[i].hitsfx,f))
                {
                    new_return(47);
                }
                
                if(!p_putc(guysbuf[i].deadsfx,f))
                {
                    new_return(48);
                }
                
                if(!p_iputl(guysbuf[i].misc11,f))
                {
                    new_return(49);
                }
    		
                if(!p_iputl(guysbuf[i].misc12,f))
                {
                    new_return(50);
                }
    	    
    	    
    	    //This stopped npcs from spawning!?
    	    
    	    for(int j=0; j < scriptDEFLAST; j++)
                {
                    if(!p_putc(guysbuf[i].scriptdefense[j],f))
                    {
                        new_return(51);
                    }
                }
    	    
            }
            
            if(writecycle==0)
            {
                section_size=writesize;
            }
        }
        
        if(writesize!=int(section_size) && save_warn)
        {
            char ebuf[80];
            sprintf(ebuf, "%d != %d", writesize, int(section_size));
            jwin_alert("Error:  writeguys()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,lfont);
        }
        
        new_return(0);
    }


    IDK if you want to try to debug a binary, or do a build.

  3. #13
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,760
    Level
    21
    vBActivity - Bars
    Lv. Percent
    68.7%
    Something that I did made it worse... Looks as if there is now corruption even with those two disabled.

    The odd thing, is that I didn't touch anything related to those, but I made a slight modification of the item editor. Saving the quest, and reopening it somehow scrambled the data. I'm not sure how, at this point. As soon as the quest is saved, the data is corrupted, so I'm, rolling back again to beta 30.

    (The beta 30 sources are stable.)

    ---------------

    I rolled it back to 30, which still compiled and ran with no issues (packfile saving of the new array is disabled).

    I tried reintroducing your changes, this time moving the loading sequence a bit farther down the line. No difference.

    You should probably see the result for yourself.

    Here's Beta 33, which has your suggested changes implemented:

    http://timelord.insomnia247.nl/zc/zc...ile_Issues.zip

  4. #14
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,815
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,933
    Level
    33
    vBActivity - Bars
    Lv. Percent
    23.44%
    Can you take a fresh working version and add in a single simple write and read to get the hang of binary file IO?

    For example: Write out an array of 10000 values "[] = { 0,1,2,3,4,5,6,7,8,9, ... }" , then read it back in and print it out. If you don't feel like using a debugger properly then you simply /have/ to generate some output that can help you find out what you are doing wrong.
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  5. #15
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,760
    Level
    21
    vBActivity - Bars
    Lv. Percent
    68.7%
    Quote Originally Posted by Gleeok View Post
    Can you take a fresh working version and add in a single simple write and read to get the hang of binary file IO?

    For example: Write out an array of 10000 values "[] = { 0,1,2,3,4,5,6,7,8,9, ... }" , then read it back in and print it out. If you don't feel like using a debugger properly then you simply /have/ to generate some output that can help you find out what you are doing wrong.
    I may have found my answer without changing to VS... I'm not sync'd with the tables n defdata.cpp. It felt as if there was a third element to this, and there surely is. Thus might account for values shifting like this; eh? From what I can tell, the new data insertion is offsetting te vales by 10, resulting in reading the defaults from the wrong locations.

    What would be the right way to insert the new array into this table?
    I suppose I could just revert to a larger size for Defense instead now, though.

    Code:
        
    // flags         flags2         tile   width,  height  s_tile s_width s_height etile e_width e_height  hp family         cset    anim         e_anim,            frate e_frate    dp      wdp    weapon         rate  hrate   step  homing  grumble  item_set         misc1          misc2                misc3          misc4          m5    m6    m7      m8    m9    m10   m11   m12   m13   m14   m15     bgsfx        bosspal          extend
    { 0x00000001,    0x00000000,      85,     1,    0,      0,    0,    0,       85,     1,     1,      2,    eeGUY,            8,    aNONE,         aNONE,             0,      0,     1,     1,    wNone,           0,     0,      0,      0,    0,    isNONE,             0,              0,                0,               0,           0,    0,    0,      0,    0,    0,    0,    0,    0,    0,    0,      -1,                -1,            0,    { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, 0, WAV_EDEAD, },
    Didn't change much. Until I set up the other laptop, this may need to wait, unless someone else on the team wants to muck with it.

    Is there any other file in which this type of thing is set? Perhaps somewhere in the quest header definitions?

  6. #16
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,815
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,933
    Level
    33
    vBActivity - Bars
    Lv. Percent
    23.44%
    The tables have nothing to do with corrupted data though.

    Have a look at some specs for the c language aggregate initialization rules: https://msdn.microsoft.com/en-us/library/81k8cwsz.aspx

    The scriptdefense array at the end will be zero initialized.


    [edit] Also, I have to ask it, (sorry if it seems obvious to you, just trying to help) not trying to sound like a ass or anything: Without properly reading the version correctly you'll never be able to read/write a quest file without it becoming corrupted. This is because without it you introduce a "chicken and egg" logic bug regardless. The only way around this is to compile two versions, one for saving and one for loading.
    Last edited by Gleeok; 12-19-2016 at 01:48 AM.
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  7. #17
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,760
    Level
    21
    vBActivity - Bars
    Lv. Percent
    68.7%
    Quote Originally Posted by Gleeok View Post
    The tables have nothing to do with corrupted data though.

    Have a look at some specs for the c language aggregate initialization rules: https://msdn.microsoft.com/en-us/library/81k8cwsz.aspx

    The scriptdefense array at the end will be zero initialized.

    I was lookin at comments like this, and I wasn't sure if that dat table needed me to reserve the space; as this is the case for many entries, even with zero'd fields.

    Code:
    bool reset_guys()
    {
        // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
        init_guys(V_GUYS);
        return true;
    }
    Things like this tend to make me consider that proper synchronisation is mandatory at all times, and that the fields are explicitly prepared.

    [edit] Also, I have to ask it, (sorry if it seems obvious to you, just trying to help) not trying to sound like a ass or anything: Without properly reading the version correctly you'll never be able to read/write a quest file without it becoming corrupted. This is because without it you introduce a "chicken and egg" logic bug regardless. The only way around this is to compile two versions, one for saving and one for loading.
    No, that's something that I need to know. Could you expand on that, and specify: By version, do you mean the defined ZC version, V_GUYS, or something else? Have I done this somewhere, that you have observed?

    Tell me this though: Why is expanding the enum with defLAST alone enough to corrupt this, when everything that thie packfile and editor generation code does relies on s size read fro this entry's placement?

    If I add defs to the enum before edefLAST, and compile, with no other changes, the corruption still occurs. Is there anything with an explicit size that I missed? i simply fail to believe that the code can't resize itself around this, unless it's because it is shifting the values and the code isn't adaptive enough to comply. Even so, if it shifts the values, I'd expect it to mismatch when reading another quest, not the quest in memory, which is what led me to believe that the default values from defdata were involved.

    Also, you said that the latest guyversion is 24, but in zdefs, it was 24 without my intervention.

  8. #18
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,815
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,933
    Level
    33
    vBActivity - Bars
    Lv. Percent
    23.44%
    Sure. You add an extra 10 byte array and read an older quest-> guy 0 gets loaded fine, guy 1 gets offset 10 bytes and is garbage, guy 2 gets offset 20 bytes and is garbage, guy 3 gets offset 30 bytes and is garbage. The old quest file here is the chicken, and the new format is the egg. You have to be able to load the chicken into the egg here. Without knowing that the quest file is a chicken you're just shoving an egg up the chicken's ass and turning a chicken into an egg by unnatural means, and then hilarity ensues as you have a messed up looking chicken that's bleeding all over your couch screaming in pain. You then beat it to death with a bat and try to figure out what's wrong with the chicken, but you can't. Make sense? :)



    Moral of the story: Don't @#$% your chickens before they hatch.
    Last edited by Gleeok; 12-19-2016 at 03:42 AM.
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  9. #19
    Administrator War Lord's Avatar
    Join Date
    Feb 2000
    Age
    40
    Posts
    6,028
    Mentioned
    54 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,448
    Level
    12
    vBActivity - Bars
    Lv. Percent
    89.14%
    Quote Originally Posted by Gleeok View Post
    Sure. You add an extra 10 byte array and read an older quest-> guy 0 gets loaded fine, guy 1 gets offset 10 bytes and is garbage, guy 2 gets offset 20 bytes and is garbage, guy 3 gets offset 30 bytes and is garbage. The old quest file here is the chicken, and the new format is the egg. You have to be able to load the chicken into the egg here. Without knowing that the quest file is a chicken you're just shoving an egg up the chicken's ass and turning a chicken into an egg by unnatural means, and then hilarity ensues as you have a messed up looking chicken that's bleeding all over your couch screaming in pain. You then beat it to death with a bat and try to figure out what's wrong with the chicken, but you can't. Make sense? :)



    Moral of the story: Don't @#$% your chickens before they hatch.

    Fantastic Analogy
    Well played

  10. #20
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,760
    Level
    21
    vBActivity - Bars
    Lv. Percent
    68.7%
    Quote Originally Posted by Gleeok View Post
    Sure. You add an extra 10 byte array and read an older quest-> guy 0 gets loaded fine, guy 1 gets offset 10 bytes and is garbage, guy 2 gets offset 20 bytes and is garbage, guy 3 gets offset 30 bytes and is garbage. The old quest file here is the chicken, and the new format is the egg. You have to be able to load the chicken into the egg here. Without knowing that the quest file is a chicken you're just shoving an egg up the chicken's ass and turning a chicken into an egg by unnatural means, and then hilarity ensues as you have a messed up looking chicken that's bleeding all over your couch screaming in pain. You then beat it to death with a bat and try to figure out what's wrong with the chicken, but you can't. Make sense? :)

    Oh, I know what's causing the offset. That's obvious. What I don't comprehend, is why when the loader reads the size of the defense array from the same place as the saver, why this occurs. Do I need to define a new guysversion for both sides, and load the new stuff only if guysversion is > N; because the editor panel doesn't do that at all for anything.

    If I can't sort this, is it something you'd be willing to fix so that I have a basis of comparison on what you did?



    Moral of the story: Don't @#$% your chickens before they hatch.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social