salaminizer
Colorado Internacional
Hello,
First of all (as usual), I don't know if what I'm doing is correct, but I couldn't find another way to do it, I'm following what's in the game.
What I want is another event such as onUnitKilled, etc. I want onUnitUnload.
so I have copied CvEventManager.py to my mod's directory and added:
in the end of self.EventHandlerMap.
I also added the onUnitUnload function in this same file:
(it's commented because I thought this is what was wrong)
In the SDK, I have added:
in CvUnit::unload()
and in CvDLLEventReporterIFaceBase.h:
I compile it successfully, but the game crashes when unloading a unit. I don't know what I else I need to set but the logs in My Games don't show anything. I have init,mplog,pythonerr2,resmgr and xml logs but none of them have anything useful at all. in my mod's ini I have:
; Enable the logging system
LoggingEnabled = 1
; Enable synchronization logging
SynchLog = 0
; Overwrite old network and message logs
OverwriteLogs = 1
; Enable rand event logging
RandLog = 0
; Enable message logging
MessageLog = 1
GenerateCrashDumps = 1
and chipotle.
that's one problem, the other is the crash. by using the debug DLL I have found out that it crashes right after the call to gDLL:
and that's all I know about the crash. solving both would be great
in the end what I want is doing something cool after an unit is unloaded, such checking for the plot and spawning a unit, stuff like that.
thanks.
First of all (as usual), I don't know if what I'm doing is correct, but I couldn't find another way to do it, I'm following what's in the game.
What I want is another event such as onUnitKilled, etc. I want onUnitUnload.
so I have copied CvEventManager.py to my mod's directory and added:
Code:
'unitUnload' : self.onUnitUnload
in the end of self.EventHandlerMap.
I also added the onUnitUnload function in this same file:
Code:
# onUnload
def onUnitUnload(self, argsList):
pUnit = argsList[0]
# player = PyPlayer(pUnit.getOwner())
# iX = pUnit.getX()
# iY = pUnit.getY()
# pPlot = CyMap().plot(iX, iY)
# pCity = pPlot.getPlotCity()
# if unit.getUnitType() == gc.getInfoTypeForString('UNIT_CRATE'):
# CvUtil.pyPrint("Player %d's %s unloaded at city %s at plot (%d, %d)"
# %(player, PyInfo.UnitInfo(pUnit.getUnitType()).getDescription(), pCity.getName(), iX, iY))
(it's commented because I thought this is what was wrong)
In the SDK, I have added:
Code:
gDLL->getEventReporterIFace()->unitUnload(this);
in CvUnit::unload()
and in CvDLLEventReporterIFaceBase.h:
Code:
virtual void unitUnload(CvUnit *pUnit) = 0;
I compile it successfully, but the game crashes when unloading a unit. I don't know what I else I need to set but the logs in My Games don't show anything. I have init,mplog,pythonerr2,resmgr and xml logs but none of them have anything useful at all. in my mod's ini I have:
Spoiler :
; Enable the logging system
LoggingEnabled = 1
; Enable synchronization logging
SynchLog = 0
; Overwrite old network and message logs
OverwriteLogs = 1
; Enable rand event logging
RandLog = 0
; Enable message logging
MessageLog = 1
GenerateCrashDumps = 1
and chipotle.
that's one problem, the other is the crash. by using the debug DLL I have found out that it crashes right after the call to gDLL:
First-chance exception at 0x00b4a31d in Civ4BeyondSword.exe: 0xC0000005: Access violation reading location 0xd8ea86d8.
Unhandled exception at 0x00b4a31d in Civ4BeyondSword.exe: 0xC0000005: Access violation reading location 0xd8ea86d8.
and that's all I know about the crash. solving both would be great
in the end what I want is doing something cool after an unit is unloaded, such checking for the plot and spawning a unit, stuff like that.
thanks.