Jump to content

Edison Problem


Elodran

Recommended Posts

So I think I've tracked down the issue with the Edison achievement. I'm still learning how to pack the UPKs to get things working properly for me, but here's the issue for those that might want to go ahead and create the mod for it.

 

If you look in the XComStrategyGame.XGFacilityLabs.CheckForEdison function, you'll see what essentially boils down to this code:

    function bool CheckForEdison()
    {
        local int iTech;
        for (iTech = 0; iTech < eTech_MAX /* 61 */; iTech++)
        {
            if (iTech == XComeGame.XGGameData.ETechType.eTech_None             /*  0 */ ||
                iTech == XComeGame.XGGameData.ETechType.eTech_PsiLabs          /*  4 */ ||
                iTech == XComeGame.XGGameData.ETechType.eTech_AutopsyZombie    /* 49 */ ||
                iTech == XComeGame.XGGameData.ETechType.eTech_PlaceHolder      /* 60 */ ||
                TECH(iTech).iTechReq == 60)
            {
                continue;
            }
            else if (!IsResearched(iTech))
            {
                return false;
            }
        }
        
        return true;
    }

The problem is, if you look at the table of research items, there is also this one: XComeGame.XGGameData.ETechType.eTech_Autopsy_END (= 59).

 

However, when a research is completed (as seen in OnResearchCompleted()) or when setting up the game (as seen in Init() and InitNewGame()), that m_arrResearched index is never set to 1, which means we need to skip this as well.

 

So we can either update InitNewGame() or, and my preference, is to update CheckForEdison() to also add the check for XComeGame.XGGameData.ETechType.eTech_Autopsy_END in the list of ones to skip.

 

The updated code would look like this:

    function bool CheckForEdison()
    {
        local int iTech;
        for (iTech = 0; iTech < eTech_MAX /* 61 */; iTech++)
        {
            if (iTech == XComeGame.XGGameData.ETechType.eTech_None             /*  0 */ ||
                iTech == XComeGame.XGGameData.ETechType.eTech_PsiLabs          /*  4 */ ||
                iTech == XComeGame.XGGameData.ETechType.eTech_AutopsyZombie    /* 49 */ ||
                iTech == XComeGame.XGGameData.ETechType.eTech_AutopsyEnd       /* 59 */ ||
                iTech == XComeGame.XGGameData.ETechType.eTech_PlaceHolder      /* 60 */ ||
                TECH(iTech).iTechReq == 60)
            {
                continue;
            }
            else if (!IsResearched(iTech))
            {
                return false;
            }
        }
        
        return true;
    }

Again, I'm still trying to figure out how to patch these things (especially since I play on the Mac), but if someone wants to do it, the source of the problem has been found! =)

Link to comment
Share on other sites

Good to know. When we get to adding techs, Edison achievement should be taken care of as well.

 

Are you using integers instead of XComGame.XGGameData.ETechType.eTech_Name?

 

Edit: XCome - XCom

Edited by Drakous79
Link to comment
Share on other sites

In the UE Explorer the actual code I see in the decompiled version is this:

function bool CheckForEdison()
{
    local int iTech;

    iTech = 0;
    J0x0B:
    // End:0xBC [Loop If]
    if(iTech < 61)
    {
        // End:0x3F
        if((iTech == 0) || iTech == 60)
        {
        }
        // End:0xAE
        else
        {
            // End:0x6F
            if(TECH(iTech).iTechReq == 60)
            {
            }
            // End:0xAE
            else
            {
                // End:0x94
                if((iTech == 4) || iTech == 49)
                {
                }
                // End:0xAE
                else
                {
                    // End:0xAE
                    if(!IsResearched(iTech))
                    {
                        return false;
                    }
                }
            }
        }
        ++ iTech;
        // [Loop Continue]
        goto J0x0B;
    }
    return true;
    //return ReturnValue;    
}

If there is a way to make it use the symbols instead of the numbers there, that would be fantastic to know!

Link to comment
Share on other sites

I think 59 and 60

// 59    (3b)    eTech_Autopsy_END
// 60    (3c)    eTech_Placeholder
// 61    (3d)    eTech_MAX

can be skipped by shortening the loop by two, that'd be one byte edit:

// End:0xBC [Loop If]
if(iTech < 59)

------

Or rewrite the function including Autopsy_END and excluding TECH(iTech).iTechReq == 60 (if I understand it correctly, it's a tech with Placeholder tech requirement):

function bool CheckForEdison()
{
    local int iTech;

    iTech = 0;
    // [Loop If]
    if(iTech < 61)
    {
        // None or PsiLabs or AutopsyZombie or Autopsy_END or Placeholder or MAX
        if((iTech == 0) || (iTech == 4) || (iTech == 49) || (iTech == 59) || (iTech == 60))
        {
        }
        else
        {
            if(!IsResearched(iTech))
            {
               return false;
            }
        }
        ++ iTech;
        // [Loop Continue]
    }
    return true;
}
Edited by Drakous79
Link to comment
Share on other sites

In the UE Explorer the actual code I see in the decompiled version is this:

function bool CheckForEdison()
{
    local int iTech;

    iTech = 0;
    J0x0B:
    // End:0xBC [Loop If]
    if(iTech < 61)
    {
        // End:0x3F
        if((iTech == 0) || iTech == 60)
        {
        }
        // End:0xAE
        else
        {
            // End:0x6F
            if(TECH(iTech).iTechReq == 60)
            {
            }
            // End:0xAE
            else
            {
                // End:0x94
                if((iTech == 4) || iTech == 49)
                {
                }
                // End:0xAE
                else
                {
                    // End:0xAE
                    if(!IsResearched(iTech))
                    {
                        return false;
                    }
                }
            }
        }
        ++ iTech;
        // [Loop Continue]
        goto J0x0B;
    }
    return true;
    //return ReturnValue;    
}

If there is a way to make it use the symbols instead of the numbers there, that would be fantastic to know!

 

Unfortunately inverting from numbers to enum names is a non-trivial inversion, so UE Explorer (nor any decompression tool that I know of) can do it. I use Bertilsson's tool here : http://hem.bredband.net/bertrich/XCOM/ReverseLookup.htm to help me figure out what in-code numbers could refer to based on contextual clues.

 

 

Good to know. When we get to adding techs, Edison achievement should be taken care of as well.

 

 

johnnylump and I have already started to dig into the various things needed to be able to add new techs, foundry techs, etc.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...