Python Performance and Interface Overhaul (PPIO)

@Toffer90 alright I started to see if I could get that to run. I corrected a few minor things so that c++ is able to read the code but I'm getting issues with defining 'duration' and 'format'. Here's the error log (9 errrors):
Code:
Severity    Code    Description    Project    File    Line    Suppression State
Error    C2734    'duration' : const object must be initialized if not extern    C2C    D:\C2C\Caveman2Cosmos\Sources\CvPlayer.cpp    6593  
Error    C2373    'duration' : redefinition; different type modifiers    C2C    D:\C2C\Caveman2Cosmos\Sources\CvPlayer.cpp    6593  
Error    C3861    'duration': identifier not found, even with argument-dependent lookup    C2C    D:\C2C\Caveman2Cosmos\Sources\CvPlayer.cpp    6612  
Error    C2374    'format' : redefinition; multiple initialization    C2C    D:\C2C\Caveman2Cosmos\Sources\CvPlayer.cpp    6616  
Error    C2734    'duration' : const object must be initialized if not extern    C2C    D:\C2C\Caveman2Cosmos\Sources\CvPlayer.cpp    6616  
Error    C2373    'duration' : redefinition; different type modifiers    C2C    D:\C2C\Caveman2Cosmos\Sources\CvPlayer.cpp    6616  
Error    C2086    'char buf[2048]' : redefinition    C2C    D:\C2C\Caveman2Cosmos\Sources\CvPlayer.cpp    6617  
Error    C3861    'format': identifier not found, even with argument-dependent lookup    C2C    D:\C2C\Caveman2Cosmos\Sources\CvPlayer.cpp    6618  
Error    C3861    'format': identifier not found, even with argument-dependent lookup    C2C    D:\C2C\Caveman2Cosmos\Sources\CvPlayer.cpp    6618

I might ask in the CIV4 modding forum about this...
 
@Toffer90 alright I started to see if I could get that to run. I corrected a few minor things so that c++ is able to read the code but I'm getting issues with defining 'duration' and 'format'. Here's the error log (9 errrors):
I might ask in the CIV4 modding forum about this...
@Thunderbrd : probably have some insight in what causes such errors.
I believe it has something to do with proper initialization/declaration of new variables within the scope you are working within.

From the first errors it looks like you declared 'duration' as a const (constant)... C2734
const unsigned long duration;

Did you have this twice in the code? C2374
const char* format =​
The second time you should just have:
format =​
I provided that mistake in my code example...

I think the way the format variable is set is all wrong.
Maybe it should be more like this:
TCHAR szOut[2048];
sprintf(szOut, "Dll duration: %d ms.", duration);
gDLL->logMsg("Test.log", szOut);
I edited the code example post I made with adjustments based on your errors.
 
Last edited:
Are those errors you're getting on compile? The do sound like familiar issues that are all probably fairly easily solved syntax oopses. Show me the code and what the errors are referring to. (double click on the error line to get it to go to the line it's saying is in error)
 
@Toffer90 that worked. Managed to compile :) Got this while processing a turn with Vanilla:
Code:
[795724.500] Python duration: 0 ms.
[795724.500] Dll duration: 0 ms.
[795729.250] Python duration: 0 ms.
[795729.250] Dll duration: 0 ms.

EDIT: On another run I managed to get something:
Code:
[796480.875] Dll duration: 0 ms.
[796480.875] Python duration: 1 ms.
 
Last edited:
Having a hard time making them appear in the logs. :\ I know the code runs as I see the score being updated but on the logs it's like nothing is happening.
Code:
[800277.000] Python duration: 0.000000 ms.
[800277.000] Dll duration: 0.000000 ms.

Tried to output %d and a (%f) in the logs.
Code:
[809831.125] Dll duration: 0 (0.000000) ms.
[809831.125] Python duration: 1 (0.000000) ms.

So the float isn't being written. :undecide:
 
Last edited:
Having a hard time making them appear in the logs. :\ I know the code runs as I see the score being updated but on the logs it's like nothing is happening.
Code:
[800277.000] Python duration: 0.000000 ms.
[800277.000] Dll duration: 0.000000 ms.

Tried to output %d and a (%f) in the logs.
Code:
[809831.125] Dll duration: 0 (0.000000) ms.
[809831.125] Python duration: 1 (0.000000) ms.

So the float isn't being written. :undecide:
Hmm, let's do a last try where we use:

/* clock_t, clock, CLOCKS_PER_SEC comes from this include*/
#include <time.h> \\ This needs to be somewhere in the file, probably at the top of the file.

clock_t clocks = clock();
... ... ... // code
clocks = clock() - clocks;
TCHAR szOut[2048];
sprintf(szOut, "Python took %d clicks (%f seconds).\n", clocks, ((float) clocks) / CLOCKS_PER_SEC);​

CLOCKS_PER_SEC should be a built in MACRO from the time.h standard library.

Remove all the XMLPlatformUtils stuff; I guess it isn't valid code.
The only place I saw XMLPlatformUtils used for timing was in:
Caveman2Cosmos\Sources\xerces-c-3.1.1-x86-windows-vc-7.1\samples\src​
Which isn't code that is processed when playing the game as far as I understand, probably not included in the dll at all.
 
Last edited:
Alright, I got this. Can confirm equal results with VS profiler:
Code:
   Vanilla    |     PPIO
C++  | Python | C++  | Python
4 ms |  0 ms  | 3 ms |  3 ms

The 0 ms is because the code isn't being processed.
 
PPIO v0.6
SVN rev.10384
  • Overhauled\revised the barbarian civ module.
    • That is the module/"game option" that make minor civs emerge from barbarian cities, and when they may become major cities, where new world landmasses have its own rules.
    • 2000 lines of spaghetti code got reduced to 700 lines of optimized and orderly code.
    • Should result in a noticeable improvement in turn times.
    • The rules and technical mechanics of it have changed quite a bit, will probably need later adjustments to get it tuned perfectly in.
  • Optimized some misc code here and there too.
  • The start as minor civs option will now function a bit differently if barbarian civ option is active.
    • The barbarian civ feature code does no longer discriminate between difference minor civs when deciding when they deserve to become major civs, which is based on accomplishments and a random roll every turn.
    • A civ that have been a minor civ since turn 0 can become a major civ before discovering writing, through the barbarian civ code.
    • Discovering writing will still make you a major civ right away if the "start as minor" option is active.
Note: It is recommended to delete the whole UserSetting folder for this update, but you might get away by just deleting the revolution.ini file within it.
P.S. This update has not been tested much, so I hope you all will keep an eye on how the barbarian civ feature is operating. Please report any oddities about it if you see one.
I hope I managed to include all the modified files in this update.
Alright, I got this. Can confirm equal results with VS profiler:
Code:
   Vanilla    |     PPIO
C++  | Python | C++  | Python
4 ms |  0 ms  | 3 ms |  3 ms

The 0 ms is because the code isn't being processed.
Awesome that you figured it out, would have been nice with an float result instead of a rounded integer though. It should be possible if the "sprintf(" formatting is done correctly.

Since it's close to equal at the ms scale, I would suggest that we let python handle the score calculation as it makes it easier to adjust/mod later if needed.
 
Last edited:
@Toffer90 compatibility with last SVN was bit short, as I updated Python file, that you touched :p

What happened to python files, as they are 0 sized? Where code was moved?
 
Here's the compiled .dll if you want to test with that.
That could help.
When you did the test without PPIO, were you on SVN rev. 10379 or newer?
The strange thing is that the SVN code for it is identical to the PPIO code... so I'll have to look at the framework around the code.
 
Last edited:
Back
Top Bottom