1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Access violation error

Discussion in 'Civ4 - SDK/Python' started by Opera, Jan 23, 2010.

  1. Opera

    Opera Chieftain

    Joined:
    Sep 21, 2008
    Messages:
    4,641
    I was skimming through the pedia after some modding and I got a RuntimeError: unidentified C++ exception in CvPediaMain; in placeCorporations, line:
    Code:
    			screen.setTableText(tableName, iColumn, iRow, u"<font=3>" + item[0] + u"</font>", gc.getCorporationInfo(item[1]).getButton(), WidgetTypes.WIDGET_PEDIA_JUMP_TO_CORPORATION, item[1], 1, CvUtil.FONT_LEFT_JUSTIFY)
    Using a debug dll, I got that:
    Then I figured it was because of a check involving CvCorporation::getCrime(), so I commented out the check... And then the error was back at the below check. Using breakpoints, I managed to find that it breaks right when the function returns, in this case, m_iDefenseModifier.

    What could that error be?
     
  2. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    That error means you tried to use a getSomething(int i) call and it was out of bounds. So you tried to look up what corporation was at -1, or something like that. I can't tell until I see the code, but run a debug build, it will give you an assert right before usually.
     
  3. Opera

    Opera Chieftain

    Joined:
    Sep 21, 2008
    Messages:
    4,641
    I did run one, no assert, which surprised me... It really comes from WIDGET_PEDIA_JUMP_TO_CORPORATION, which calls ParseCorporationHelp (or something) which then calls to CvGameTextMgr::setCorporationHelp which then calls to CvCorporation::getCrime() which bugs.

    As a note, I have added a new class in CvInfos, as well as a new pedia page, hence a new widget... Everything is working; at least everything I have added, since the corp page doesn't work anymore...

    Edit: Oh, and every WIDGET_CLOSE_SCREEN are broken too... I'm willing to bet both bugs share some origin :p

    Edit 2: With some more tests, it appears the defense modifier works like a charm, since it gets added to my city if I put the corporation in it... while the game can't use the exact same function to build the help string...?
     
  4. Opera

    Opera Chieftain

    Joined:
    Sep 21, 2008
    Messages:
    4,641
    Ok, so, now it shows up to 4 corporations and CtD's when I click on one of them :confused:

    Edit: and now it doesn't show any corp anymore... wtf?
     
  5. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    29,860
    Location:
    Germany / Netherlands
    Your HDD and RAM are okay?

    Did you maybe add all the things to a part of the code, which is already memory intensive?
     
  6. xienwolf

    xienwolf Chieftain

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    Typical error when you didn't add the widget to the end of the list. If you added it in the middle or start, then you bumped things down and now something isn't aligned properly. Either a hardcode in the exe (as I suspect is the case with close screen, comes up a lot) or a failure to do a full rebuild after changing CvEnums.h (which always makes things weird).
     
  7. Opera

    Opera Chieftain

    Joined:
    Sep 21, 2008
    Messages:
    4,641
    So you think the error is in CvEnums.h? But you didn't add CIVILOPEDIA_PAGE_TRAIT to the end, iirc. But you did add WIDGET_PEDIA_JUMP_TO_TRAIT to the end... Ah, I'll test that then.
     
  8. Opera

    Opera Chieftain

    Joined:
    Sep 21, 2008
    Messages:
    4,641
    Bug fixed! Thank you so much xienwolf :D
    At least, when I'd want to add new widgets, I'll know I'd have to put them at the end :p
     
  9. xienwolf

    xienwolf Chieftain

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    It is best to get in the habit of always working at the end of everything so that you can avoid such issues as this one. Just not a habit I forced on myself in my earlier days of coding. But I do intend to be more diligent in my rebuild. It really isn't an issue till you run into something which is hardcoded in the EXE or another DLL.
     
  10. Opera

    Opera Chieftain

    Joined:
    Sep 21, 2008
    Messages:
    4,641
    For some reason, I thought I had to put my new widget in the same order as the pedia. I guess there's really few cases in which order do matter :)
     
  11. xienwolf

    xienwolf Chieftain

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    Order is only really important for the hardcode/xml hybrid systems, like GameOptions. Things that are listed completely in the SDK, but also exist in the XML. Since the XML is loaded in order, that is how it tries to match up.
     

Share This Page