Coding problem regarding Goodies

Mercury314

Chieftain
Joined
Sep 6, 2007
Messages
43
Hey all,

I am writing some code in the SDK to disallow a certain Goody if a certain tech has been discovered (effectively disabling or enabling a Goody after a certain time).

To do this, I am using the following code in the

bool CvPlayer::canReceiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) const

function, in the CvPlayer.cpp file. This is where a goody is checked for legallity (no experience for settlers, that sort of thing), so it seems the proper place.

Code:
	if(eGoody == (GoodyTypes)GC.getInfoTypeForString("GOODY_HUNTER"))
	{
	    if(GET_TEAM(getTeam()).isHasTech((TechTypes)GC.getInfoTypeForString("TECH_BLADE")))
	    {
            return false;
	    }
    }

Unfortunately this code always returns false instead of only when the team has the technology TECH_BLADE.

Does anyone know where the error lies?
 
So far the problem appears to lie within this line:

GET_TEAM(getTeam()).isHasTech((TechTypes)GC.getInfoTypeForString("TECH_BLADE"))

Perhaps this is the wrong way of going about it?
 
I have further narrowed it down.

(TechTypes)GC.getInfoTypeForString("TECH_BLADE")

does not produce the desired result. Instead it returns a NO_TECH to which the isHasTech function always returns true, hence my problem.

What would be the proper method of getting a TechTypes from a String?
 
That looks like it should work. Perhaps recheck the spelling of TECH_BLADE in the xml?
 
The spelling is correct. In fact it appears as if none of the techs, original or new, work using getInfoTypeForString. Very strange. I am trying to work around it atm...
 
I haven't heard of any glitches with getInfoTypeForString. I seem to remember it working to call tech types from python and if the sdk didn't work the python wouldn't work. Maybe try calling some other object type, like getInfoTypeForString("UNIT_WARRIOR"), and see if that works. If it works for the other things it is most likely somthing in your techinfos xml.
 
Back
Top Bottom