JDPElGrillo
Chieftain
- Joined
- Aug 20, 2015
- Messages
- 72
Hello, I have a couple of questions as I'm trying to get my mod to work for simultaneous multiplayer games. I've read through the tutorial here: http://forums.civfanatics.com/showthread.php?p=4609823#post4609823 , and I've looked at the differences in OOSLog.txt.
In my mod, Spiritual leaders discover the cheapest first-row tech unknown to them when they found their first city:
This works just fine in singleplayer (I know it's a bit inelegant to specify which techs are eligible, but I wanted to prevent corner cases where large teams of Spiritual leaders would result in them starting with multiple religions). However, in simultaneous multiplayer, I get this:
These are the only differences between the OOSLog.txt outputs. What's happening is that Player 0, who is Spiritual, discovers Fishing, and the city swaps from a 2/1/0 grassland forest to a 2/0/2 freshwater lake. Player 1 is not getting updated that Player 0 discovered a tech and swapped to a different tile. Now, to my understanding, onCityBuilt is within the global context, and I don't have any conditions based on active players in my code, so it should work just fine.
Two questions: Do I need to use ModNetMessage here, and if so, why?
In my mod, Spiritual leaders discover the cheapest first-row tech unknown to them when they found their first city:
Code:
def onCityBuilt(self, argsList):
'City Built'
city = argsList[0]
pPlayer = gc.getPlayer(city.getOwner())
###########################################
# Spiritual Trait Free Tech Start #
###########################################
if city.isCapital():
if pPlayer.hasTrait(gc.getInfoTypeForString("TRAIT_SPIRITUAL")):
techs = []
team = gc.getTeam(gc.getPlayer(city.getOwner()).getTeam())
for iTech in range(gc.getNumTechInfos()):
if iTech == gc.getInfoTypeForString("TECH_FISHING") or iTech == gc.getInfoTypeForString("TECH_AGRICULTURE") or iTech == gc.getInfoTypeForString("TECH_HUNTING") or iTech == gc.getInfoTypeForString("TECH_THE_WHEEL") or iTech == gc.getInfoTypeForString("TECH_MINING") or iTech == gc.getInfoTypeForString("TECH_MYSTICISM"):
if pPlayer.canResearch(iTech,1):
iCost = team.getResearchLeft(iTech)
if iCost > 0:
techs.append((iCost, iTech))
if techs:
techs.sort()
iTech = techs[0][1]
team.setHasTech(iTech, True, city.getOwner(), False, False)
###########################################
# Spiritual Trait Free Tech End #
###########################################
if (city.getOwner() == gc.getGame().getActivePlayer()):
self.__eventEditCityNameBegin(city, False)
CvUtil.pyPrint('City Built Event: %s' %(city.getName()))
This works just fine in singleplayer (I know it's a bit inelegant to specify which techs are eligible, but I wanted to prevent corner cases where large teams of Spiritual leaders would result in them starting with multiple religions). However, in simultaneous multiplayer, I get this:
These are the only differences between the OOSLog.txt outputs. What's happening is that Player 0, who is Spiritual, discovers Fishing, and the city swaps from a 2/1/0 grassland forest to a 2/0/2 freshwater lake. Player 1 is not getting updated that Player 0 discovered a tech and swapped to a different tile. Now, to my understanding, onCityBuilt is within the global context, and I don't have any conditions based on active players in my code, so it should work just fine.
Two questions: Do I need to use ModNetMessage here, and if so, why?