For Orion method, I frankly speaking don't understand the purpose of it.
What is the purpose of looping through every loop to check if each tech == iTechCheck?
That's actually a good question. While it does the job, it appears to do lots of stuff it will not have to do, which makes it slow. A quick (untested) edit to improve it:
Code:
def hasTechCheck(iPlayer, iTechType):
# Orion's Standard Functions
# Returns True if the player has the specified tech type.
# Returns False if the player does not have the specified tech type.
pPlayer = gc.getPlayer(iPlayer)
[S]bTechCheck = False[/S]
[S]for iTech in range(gc.getNumTechInfos()):[/S]
[B]if iTechType < gc.getNumTechInfos():[/B]
[S]if (iTech != TechTypes.NO_TECH):[/S]
[B]if iTechType != TechTypes.NO_TECH:[/B]
# Does the player have this tech?
if gc.getTeam(pPlayer.getTeam()).isHasTech(iTech[B]Type[/B]):
[B]return True[/B]
[S]if iTech == iTechType:[/S]
[S]bTechCheck = True[/S]
[S]break[/S]
[S]return bTechCheck[/S]
[B]return False[/B]
That should do the very same thing and should be way faster. Checking for valid pPlayer would make it even safer and should make it impossible to crash the game regardless of arguments. On the other hand, if we skip checking anything and just assume the caller to use correct arguments (could be dangerous), it could be reduced to:
Code:
def hasTechCheck(iPlayer, iTechType):
# Orion's Standard Functions
# Returns True if the player has the specified tech type.
# Returns False if the player does not have the specified tech type.
pPlayer = gc.getPlayer(iPlayer)
return gc.getTeam(pPlayer.getTeam()).isHasTech(iTechType)
This is so simple that I would argue that it might not deserve a function.
My own take on this would likely be to make a function, which takes iTechType as argument and then loops all teams, check if they are alive and if so, return true when one is found, which has the tech in question. That shouldn't require lots of lines. Also the only thing, which could go wrong (if coded correctly) would be an out of range tech ID in arguments. This mean it should start by checking if it's >0 && < numTechs and return false if it is.
However isn't there already code for this. I mean isn't there techs, which goes "provides XX to the first civ to discover"? If so, at least the DLL would know the answer. Granted, it's not the same as it would be reachable from python, but it would make sense to check before coding the very same thing again.