Python Help

Onionsoilder

Reaver
Joined
Mar 19, 2007
Messages
3,173
Alright, so I'm working on merging the Mastery Victory Condition into another mod. I got all of the SDK and XML files done, but the Python is giving me some trouble. Everything seems to work okay, except for in-game the victory screen never shows up. I think this is the error it gives when it fails to load:

Code:
Traceback (most recent call last):

  File "CvScreensInterface", line 231, in showVictoryScreen

  File "CvVictoryScreen", line 118, in interfaceScreen

  File "CvVictoryScreen", line 516, in showVictoryConditionScreen

AttributeError: 'CyTeam' object has no attribute 'getTotalVictoryScore'
ERR: Python function showVictoryScreen failed, module CvScreensInterface

However, I've looked in all of the files listed and I can't find anything that looks wrong. Can anyone who is more versed in python tell me exactly what it is complaining about/how I can fix it?
 
The problem is on line 516 of the file CvVictoryScreen.py; based on the error message that line contains something like this:
Code:
 iFoo = pTeam.getTotalVictoryScore()
but there is no getTotalVictoryScore() method defined for the CyTeam class. Make sure that the method name is spelled correctly, including capitalization.

If it is spelled correctly then it was probably something that was added by the Mastery Victory Condition SDK changes so make sure it is properly exposed to Python via CyTeam.* (and possibly CyTeamInterface.*)
 
Hmm... that's weird. This is line 516 of CvVictoryScreen.py:

Code:
iTVScore = gc.getTeam(gc.getPlayer(iLoopPlayer).getTeam()).getTotalVictoryScore()

And here is a section from CyTeam.cpp, defining getTotalVictoryScore():
Code:
int CyTeam::getTotalVictoryScore()
{
	return m_pTeam ? m_pTeam->getTotalVictoryScore() : -1;
}
 
OMG... No... no I didn't...

How exactly do I do that? Opening it up in Notepad++ gives me a bunch of gibberish.

Both the existing mod and the new mod have a .dll with the same name in themso I can't just move it over...
 
Could you explain how to do that? Or is there a guide somewhere about compiling a new .dll? I've never done anything like this before so I'm very confused... I looked at the SDK sticky but it didn't help at all...
 
The 2 most widely-used choices of what environment to use to compile the DLL are CodeBlocks (completely free) or Visual Studio (has a free "Express" edition). If you want to use CodeBlocks, see Kael's tutorial. If you want to use Visual Studio, see Chazcon's Tutorial or Refar's PDF. I personally use Visual Studio 2005 which I setup using Refar's instructions.

It may seem daunting, but you've already done the hardest part which is merging the source code changes.
 
Okay... I was going through Refar's PDF, following all the steps of the tutorial, and I got maybe 3/5ths of the way through... Then when I tried to build my solution, I got this fatal error:

Code:
1>NMAKE : fatal error U1052: file 'Final_Release' not found

This happens with both the Final_Release and Debug configurations. What did I do wrong?

EDIT: NVM, I found the problem... I had the makefile in the wrong folder. Building it now...
 
Okay, after building the solution I got 4 errors. From the output I got it seems that the compiler can't access one of the references in the makefile needed to build the solution, though I'm not sure why. Could the fact that I'm using Microsoft Visual Express C++ 2008 instead of 2005 have something to do with it?

Here is the rebuilt output(eliminated most of the unneeded log)
Code:
1>------ Build started: Project: CvGameCoreDLL, Configuration: Final_Release Win32 ------
1>Performing Makefile project actions
1>Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1> "C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003/bin/link.exe" /dll /nologo  /LIBPATH:Python24/libs /LIBPATH:boost-1.32.0/libs/ /LIBPATH:"C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003/lib" /LIBPATH:"C:\Program Files\Microsoft Platform SDK/Lib" /out:Final_Release\CvGameCoreDLL.dll  boost_python-vc71-mt-1_32.lib winmm.lib user32.lib  Final_Release\CvArea.obj Final_Release\CvArtFileMgr.obj Final_Release\CvCity.obj Final_Release\CvCityAI.obj Final_Release\CvDLLButtonPopup.obj Final_Release\CvDLLEntity.obj Final_Release\CvDLLPython.obj Final_Release\CvDLLWidgetData.obj Final_Release\CvDeal.obj Final_Release\CvDiploParameters.obj Final_Release\CvFractal.obj Final_Release\CvGame.obj Final_Release\CvGameAI.obj Final_Release\CvGameCoreDLL.obj Final_Release\CvGameCoreUtils.obj Final_Release\CvGameInterface.obj Final_Release\CvGameTextMgr.obj Final_Release\CvGlobals.obj Final_Release\CvHallOfFameInfo.obj Final_Release\CvInfoWater.obj Final_Release\CvInfos.obj Final_Release\CvInitCore.obj Final_Release\CvMap.obj Final_Release\CvMapGenerator.obj Final_Release\CvPlayer.obj Final_Release\CvPlayerAI.obj Final_Release\CvPlot.obj Final_Release\CvPlotGroup.obj Final_Release\CvPopupInfo.obj Final_Release\CvPopupReturn.obj Final_Release\CvRandom.obj Final_Release\CvReplayInfo.obj Final_Release\CvReplayMessage.obj Final_Release\CvSelectionGroup.obj Final_Release\CvSelectionGroupAI.obj Final_Release\CvStructs.obj Final_Release\CvTalkingHeadMessage.obj Final_Release\CvTeam.obj Final_Release\CvTeamAI.obj Final_Release\CvUnit.obj Final_Release\CvUnitAI.obj Final_Release\CvXMLLoadUtility.obj Final_Release\CvXMLLoadUtilityGet.obj Final_Release\CvXMLLoadUtilityInit.obj Final_Release\CvXMLLoadUtilitySet.obj Final_Release\CyArea.obj Final_Release\CyAreaInterface.obj Final_Release\CyArgsList.obj Final_Release\CyArtFileMgr.obj Final_Release\CyArtFileMgrInterface.obj Final_Release\CyCity.obj Final_Release\CyCityInterface1.obj Final_Release\CyDeal.obj Final_Release\CyEnumsInterface.obj Final_Release\CyGame.obj Final_Release\CyGameCoreUtils.obj Final_Release\CyGameCoreUtilsInterface.obj Final_Release\CyGameInterface.obj Final_Release\CyGameTextMgr.obj Final_Release\CyGameTextMgrInterface.obj Final_Release\CyGlobalContext.obj Final_Release\CyGlobalContextInterface1.obj Final_Release\CyGlobalContextInterface2.obj Final_Release\CyGlobalContextInterface3.obj Final_Release\CyGlobalContextInterface4.obj Final_Release\CyHallOfFameInfo.obj Final_Release\CyHallOfFameInterface.obj Final_Release\CyInfoInterface1.obj Final_Release\CyInfoInterface2.obj Final_Release\CyInfoInterface3.obj Final_Release\CyMap.obj Final_Release\CyMapGenerator.obj Final_Release\CyMapGeneratorInterface.obj Final_Release\CyMapInterface.obj Final_Release\CyPlayer.obj Final_Release\CyPlayerInterface1.obj Final_Release\CyPlayerInterface2.obj Final_Release\CyPlot.obj Final_Release\CyPlotInterface1.obj Final_Release\CyRandomInterface.obj Final_Release\CyReplayInfo.obj Final_Release\CySelectionGroup.obj Final_Release\CySelectionGroupInterface.obj Final_Release\CyStructsInterface1.obj Final_Release\CyTeam.obj Final_Release\CyTeamInterface.obj Final_Release\CyUnit.obj Final_Release\CyUnitInterface1.obj Final_Release\FAssert.obj Final_Release\FDialogTemplate.obj Final_Release\_precompile.obj    /debug /INCREMENTAL:NO /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF 
1>   Creating library Final_Release\CvGameCoreDLL.lib and object Final_Release\CvGameCoreDLL.exp
1>CvDLLPython.obj : error LNK2019: unresolved external symbol "void __cdecl CyCityPythonInterface2(class boost::python::class_<class CyCity,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified> &)" (?CyCityPythonInterface2@@YAXAAV?$class_@VCyCity@@Unot_specified@detail@python@boost@@U2345@U2345@@python@boost@@@Z) referenced in function "void __cdecl DLLPublishToPython(void)" (?DLLPublishToPython@@YAXXZ)
1>Final_Release\CvGameCoreDLL.dll : fatal error LNK1120: 1 unresolved externals
1>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003/bin/link.exe"' : return code '0x460'
1>Stop.
1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
1>Build log was saved at "file://C:\Users\Sean\Desktop\BTS SDK\CvGameCoreDLL\Final_Release\BuildLog.htm"
1>CvGameCoreDLL - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
That's what I was missing... The mod I'm using adds another Cy file...

EDIT: WOHOOO! IT WORKS! I have everything all working now! Yeah!

Thanks so much Dresden!
 
Top Bottom