Allocating Zero or Less Memory in CvXMLLoadUtility...

Ah, they are not actually arrays but STL vectors. This means they are not pointers, and you don't have to check them for NULL (they can't be). You can check to make sure they're not empty, though.

Code:
if ([B][COLOR="Red"]!m_aszPrereqOrCivicsforPass3.empty()[/COLOR][/B])

If "empty" doesn't compile, check that "size() != 0" instead.

Code:
if ([B][COLOR="Red"]m_aszPrereqOrCivicsforPass3.size() != 0[/COLOR][/B])
 
Hmm, !__.empty() compiled fine, but I still CTD when Init XML.
 
Debug it or add logging statements. Having us continue guessing is getting you nowhere. Your DLL is based on BULL, right? If so, add

Code:
#include "CvBugOptions.h"

at the top and then use logMsg() to write to "bull.log" in the Logs folder:

Code:
logMsg("I got here yay!");
...
logMsg("Found %d civics", m_aszPrereqOrCivicsforPass3.size());

Debugging while attached to the process is more immediate and allows you to better see what's happening. Log messages are repeatable in that you can add a bunch and keep mucking with your code until you get it fixed, then remove the calls to logMsg().
 
I just ran a debug DLL, it's still breaking at exactly the same spot as in the first page.

As for BULL logs, I added some in the readpass3 statement, and none of them appeared.
 
That means it's crashing before then. I would put a breakpoint at the spot where the civic XML keys are read in for the prereqs--long before readpass3 is called--to see that htey are being read correctly.
 
That means it's crashing before then. I would put a breakpoint at the spot where the civic XML keys are read in for the prereqs--long before readpass3 is called--to see that htey are being read correctly.

I added a bunch of breakpoints, all over the code in CvInfos, and NONE of them tripped. The game just CTD again... (Before you ask, I launched BTS from Vs 2008, so it was attached to the code already.) I wonder if the error has something to do with CvXMLLoadUtilitySet.cpp and how I changed that, and not CvInfos...
 
Yeah perhaps you added something else early on that it doesn't like. Add a break point to the beginning of the XML loading.
 
Eureka!

I think I fixed it, Now I need to check if the logic works, and if it is really working, but the game loads and does not CTD.

I had forgot to set this line back to false:

Code:
LoadGlobalClassInfo(GC.getBuildingInfo(), "CIV4BuildingInfos", "Buildings", "Civ4BuildingInfos/BuildingInfos/BuildingInfo", [COLOR="Red"]false, [/COLOR]&CvDLLUtilityIFaceBase::createBuildingInfoCacheObject);
 
Well, I guess I spoke too soon. My code doesn't seem to be having the desired effect, or doing anything at.

I don't think it's a problem with logic, since my CvGameTextMgr code doesn't show any Civic Prereqs for the buildings I set in the XML, and I'm fairly confident that code works.

Breakpoint time, I suppose.
 
At some point, you may find this avenue too painful to continue. Swapping the xml definition so a list of buildings is on the civic may be easier. It avoids any readpass2,3 complexities, and the code can be basically cut and pasted from related, well-known vanilla routines.
 
At some point, you may find this avenue too painful to continue. Swapping the xml definition so a list of buildings is on the civic may be easier. It avoids any readpass2,3 complexities, and the code can be basically cut and pasted from related, well-known vanilla routines.

Never give up, Never surrender...

Actually, I think putting the code in CvCivicInfo would force me to add a bunch of extra code in CvPlayer for Civics, and when they change. Plus, I did some testing with breakpoints. My code seems to be working, but the game isn't reading the XML. No idea why.

Can anyone see anything wrong with my Schema or XML?

Code:
    <ElementType name="bPrereqCivic" content="textOnly" dt:type="boolean"/>
    <ElementType name="PrereqCivic" content="eltOnly">
        <element type="CivicOption"/>
        <element type="bPrereqCivic"/>
    </ElementType>
    <ElementType name="PrereqOrCivics" content="eltOnly">
        <element type="PrereqCivic" minOccurs="0" maxOccurs="*"/>
    </ElementType>
    <ElementType name="PrereqAndCivics" content="eltOnly">
        <element type="PrereqCivic" minOccurs="0" maxOccurs="*"/>
    </ElementType>

Code:
            <PrereqOrCivics>
                <PrereqCivic>
                    <CivicOption>CIVIC_DESPOTISM</CivicOption>
                    <bPrereqCivic>1</bPrereqCivic>
                </PrereqCivic>
                <PrereqCivic>
                    <CivicOption>CIVIC_SLAVERY</CivicOption>
                    <bPrereqCivic>1</bPrereqCivic>
                </PrereqCivic>
            </PrereqOrCivics>

Otherwise, there is an error in CvInfos, and I posted all of that already. I haven't changed that one bit.
 
Never give up, Never surrender...

Charge that machine gun nest, instead of throwing in a grenade.

Actually, I think putting the code in CvCivicInfo would force me to add a bunch of extra code in CvPlayer for Civics

I do not follow. My suggestion only changes where the data is stored. Instead of defining CvBuilding::getPrereqOrCivic, you define CvCivic::getPrereqOrBuilding. As you are finding, dealing with unknown size arrays is much trickier than the vanilla arrays, which have known size.
 
Instead of defining CvBuilding::getPrereqOrCivic, you define CvCivic::getPrereqOrBuilding.

I'm not sure how to deal with the arrays in CvCivicInfo...

First off,does it even make sense to have an OR and an AND array in CvCivicInfos? I could just make one array, and have two civics require the same building with the array.

I just think the code would be pretty tricky to do that way to. However, if you can think of a simple way to do this in CvCivicInfo, I'm all ears.
 
Swapping to Civics instead of buildings makes it far harder to handle the AND case. If we were only considering an OR prereq, it would be easy. But how would you specify the AND requirements from Civics?


Afforess, along with your XML/Schema, I will need your CvInfos ::read(pXML) line(s) to ensure that you are loading THESE tags, and holding on to them. (and any supporting XMLLoadUtility work you may have done)
 
Swapping to Civics instead of buildings makes it far harder to handle the AND case. If we were only considering an OR prereq, it would be easy. But how would you specify the AND requirements from Civics?

That's what I thought. Despite the troubles involved with readpass3, I think it will be worth it.


Afforess, along with your XML/Schema, I will need your CvInfos ::read(pXML) line(s) to ensure that you are loading THESE tags, and holding on to them. (and any supporting XMLLoadUtility work you may have done)

If you need my full sources, or XML, I can give it too.
View attachment Sources & XML.rar
 
Swapping to Civics instead of buildings makes it far harder to handle the AND case. If we were only considering an OR prereq, it would be easy. But how would you specify the AND requirements from Civics?

Each of them is a list. Why is OR different from AND?
 
  • Building1
    • Requires Civic1 OR Civic2
  • Building2
    • Requires Civic1 AND Civic3
  • Building3
    • Requires Civic2 AND (Civic3 OR Civic4)


Easy enough to list, even if we get slightly complicated like with building 3. I can easily adjust the requirements at will.

  • Civic1
    • Allows Building 1
    • Allows Building2 WITH Civic3
  • Civic2
    • Allows Building 1
    • Allows Building3 WITH (Civic3 OR Civic4)
  • Civic3
    • Allows Building 2 WITH Civic 1
    • Allows Building3 WITH Civic2
  • Civic4
    • Allows Building3 WITH Civic2

Now, not only do I need a readpass2 since civics refer to each other, but I also have to make any change to the more complicated building 3 in multiple locations, even the relatively simply building 2 needs updated in multiple locations. Or I could choose to only list all requirements on one civic, but then WHICH one? How does the other display any information at all?
 
Yeah, I had the same thoughts Xienwolf. It gets very complex, very fast. Better to leave it in CvBuildingInfos, and do a readpass3.

Did you take a look at the code I posted? Does it look correct?
 
Back
Top Bottom