Page 1 of 2 1 2 LastLast
Results 1 to 30 of 40

Thread: DESIGN/PROJECT: GovernmentsModified complete

  1. #1
    MrBaggins
    King MrBaggins's Avatar
    Join Date
    03 May 1999
    Posts
    1,528
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    03:17

    DESIGN/PROJECT: GovernmentsModified complete

    Intro

    The GovernmentsModified concept was an idea to allow for flexibility in the structure of the text file databases (for units, buildings, etc.)

    Specifically it was an idea that the syntax of these be extended to allow for modifications to the individual records, based on government... so for a particular City Improvement, say a Granary, you might have another modified record (of the same improvement) for the Tyranny government... maybe making it cheaper, perhaps.

    Using this system, you could make Factories more productive, but more polluting under Communism, or Tanks more powerful under Fascism, all without any SLIC, additional identifiers, or code.

    I altered the db creation code, lexer definitions, and the base template class to achieve this.

    Caveat... one small issue remains... I was having issues with dynamic resizing (growth) of a pointerlist array, using an optimized algorithm. I used a workaround, since I was so close to completion, but it needs to be sorted to avoid a limited memory leak. Fixed.

    Tracing code also needs to be removed. Fixed.

    ---

    What is the syntax?

    The following would be the standard defintion of the courthouse.

    Code:
    IMPROVE_COURTHOUSE {
       DefaultIcon ICON_IMPROVE_COURTHOUSE
       Description DESCRIPTION_IMPROVE_COURTHOUSE
       EnableAdvance ADVANCE_JURISPRUDENCE
       ProductionCost 330
       Upkeep 1
       LowerCrime -0.1
    }
    If you wished to have a courthouse that operated slightly differently under monarchy you'd do the following:

    Code:
    IMPROVE_COURTHOUSE {
       DefaultIcon ICON_IMPROVE_COURTHOUSE
       Description DESCRIPTION_IMPROVE_COURTHOUSE
       EnableAdvance ADVANCE_JURISPRUDENCE
       ProductionCost 330
       Upkeep 1
       LowerCrime -0.1
    }
    
    IMPROVE_COURTHOUSE > GOVERNMENT_MONARCHY {
       DefaultIcon ICON_IMPROVE_COURTHOUSE
       Description DESCRIPTION_IMPROVE_COURTHOUSE
       EnableAdvance ADVANCE_JURISPRUDENCE
       ProductionCost 330
       Upkeep 3
       LowerCrime -0.3
       HappyInc -1
    }
    You should note that this is a modification to an existing record. There must be an record with the same name to allow for a modified record.

    The syntax using the '>' character allows for multiple government types, separated by commas.

    It also allows for alpha-numeric (no space) descriptions, which are ignored for purposes of parsing... so
    Code:
    IMPROVE_COURTHOUSE > DecreasedCrime_and_Happy_HarshGovs , 
    GOVERNMENT_MONARCHY, GOVERNMENT_THEOCRACY {
    is perfectly valid, and modifies the courthouse record, for the Monarchy and Theocracy govs. Invalid Governments are also ignored, at parsing.

    There is an additional syntax that can be used within the record structure, that can be used instead of, or as well as, the above syntax...
    Code:
    IMPROVE_COURTHOUSE {
       DefaultIcon ICON_IMPROVE_COURTHOUSE
       Description DESCRIPTION_IMPROVE_COURTHOUSE
       EnableAdvance ADVANCE_JURISPRUDENCE
       ProductionCost 330
       Upkeep 1
       LowerCrime -0.1
    }
    
    IMPROVE_COURTHOUSE > Monarchy {
       DefaultIcon ICON_IMPROVE_COURTHOUSE
       Description DESCRIPTION_IMPROVE_COURTHOUSE
       EnableAdvance ADVANCE_JURISPRUDENCE
       GovernmentsModified GOVERNMENT_MONARCHY
       ProductionCost 330
       Upkeep 3
       LowerCrime -0.3
       HappyInc -1
    }
    It has been mentioned that there are only 64 buildings and 64 wonders. This is actually unrelated to the parser, and has to do with their storage and use within the city data.

    The GovernmentsModified system ignores this limitation for the modified records. You can still only have 65 buildings, but each of those buildings can have as many modified governments as you need. Essentially the system increases the number of buildings available.


    There was a suggestion for another syntax suggested a while back, but from my investigations, its impossible given the current lex definitions, would require a pretty thorough rewrite of the parser, plus would be much more costly in terms of access... something I wanted to avoid... however if a bison/flex pro would like to take a shot...

    ---

    Code access

    This whole system is only half the issue. The database records are accessed via 2 member functions... Get and Access. Get returns a const record, Access the record.

    While it would be nice to just rewrite the existing Get and Access functions to access the government subrecords, we don't have the context of what government is applicable to do that.

    I therefore made two overloaded functions...

    Code:
    template  const T *CTPDatabase::Get(sint32 index,sint32 govIndex)
        and
    template  T *CTPDatabase::Access(sint32 index,sint32 govIndex)
    which work alongside the existing

    Code:
    template  const T *CTPDatabase::Get(sint32 index)
        and
    template  T *CTPDatabase::Access(sint32 index)
    Notice the extra govIndex parameter. These are overloaded functions, so the existing functions can still be used.

    Work we (or maybe just I ) need to do

    None of the existing record access in the code (1700 hundred instances of ->Get( and ->Access(, not all of which are applicable,) use the new method... so they need to be changed...

    This, however, isn't complicated... just a lot of repetition.

    Here's an example of a couple of changes, that I used to test that the system was working fine...

    Code:
    Original (from CityData::CanBuildBuilding):
    
    const BuildingRecord* irec = g_theBuildingDB->Get(type);
    
    New:
    
    const BuildingRecord* irec = g_theBuildingDB->Get(type,g_player[m_owner]->GetGovernmentType());
    
    and, from CityData::CanBuildUnit
    
    const UnitRecord *rec = g_theUnitDB->Get(type);
    
    becomes
    
    	const UnitRecord *rec = g_theUnitDB->Get(type,g_player[m_owner]->GetGovernmentType());
    Last edited by MrBaggins; February 6, 2004 at 15:07.

  2. #2
    J Bytheway
    Emperor J Bytheway's Avatar
    Join Date
    02 Jul 2001
    Location
    England
    Posts
    3,826
    Country
    This is J Bytheway's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17
    Good work .

  3. #3
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 22, 2013
    Local Time
    05:17

    Post

    I found a problem with memory leaks with this, for brevity just the SoundRecord but in fact they leak all.

    -Martin

    1089 8 8712 0x00454061 [void * __cdecl DebugMemory_GuardedBlockAlloc(char const *,int,struct MemoryHeapDescriptor *,int,bool,unsigned char,bool)+0x121] / 0x00455954 [DebugMemory_GuardedMalloc+0x34] / 0x00455c92 [void * __cdecl operator new(unsigned int)+0x22] / 0x006ebcfc [public: void __thiscall CTPDatabase::Add(class SoundRecord *)+0x33c] / 0x006eb696 [public: long __thiscall CTPDatabase::Parse(class DBLexer *)+0xa6] / 0x0045f3cc [public: long __thiscall CivApp::InitializeAppDB(class CivArchive &)+0xe6c] / 0x00462bf4 [public: long __thiscall CivApp::InitializeApp(struct HINSTANCE__ *,int)+0x314] / 0x0045c51a [int __stdcall CivWinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)+0x3aa] / 0x0045bb64 [WinMain@16+0x74] / 0x00addf83 [WinMainCRTStartup+0x1b3] / 0xbff8b560 [(kernel)+0x0] / public: void __thiscall CTPDatabase::Add(class SoundRecord *)
    Civ2 military advisor: "No complaints, Sir!"

  4. #4
    MrBaggins
    King MrBaggins's Avatar
    Join Date
    03 May 1999
    Posts
    1,528
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    03:17
    Since I'm destructing every object thats created in the same code, along side the existing destructor code... either theres a problem with the destructor method I used in CTPDatabase, or the code doesn't destruct created DB objects properly to begin with.
    Last edited by MrBaggins; February 21, 2004 at 15:10.

  5. #5
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 22, 2013
    Local Time
    05:17

    Post

    Well I wonder what these lines should do in CTPDatabase.h, I commented them out without any problems.

    Code:
    /*	sint32* m_recordsModifiedLink;
    	sint32 m_numRecordsModifiedLink;
    	sint32 m_allocatedRecordsModifiedLinkSize;
    
    	sint32* m_modList;
    	sint32 m_numModList;
    	sint32 m_allocatedListSize;*/
    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  6. #6
    The Big Mc
    King The Big Mc's Avatar
    Join Date
    15 Oct 2001
    Location
    Of the universe / England
    Posts
    2,061
    Country
    This is The Big Mc's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    03:17
    Can’t wait to get this in a play test.
    "Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
    The BIG MC making ctp2 a much unsafer place.
    Visit the big mc’s website

  7. #7
    Solver
    Deity Solver's Avatar
    Join Date
    24 Sep 2000
    Location
    Latvia, Riga
    Posts
    18,354
    Country
    This is Solver's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    06:17


    A great addition for the playtest builds.
    Solver, WePlayCiv Co-Administrator
    Contact: solver-at-weplayciv-dot-com
    I can kill you whenever I please... but not today. - The Cigarette Smoking Man

  8. #8
    Tamerlin
    King Tamerlin's Avatar
    Join Date
    26 Apr 2002
    Location
    Toulouse (South-western France)
    Posts
    2,058
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    05:17
    That offers many new possibilities... changing your government will not become a simple decision, though it will be difficult to predict the effects if there are too many changes under each government type.

    Anyway...
    "Democracy is the worst form of government there is, except for all the others that have been tried." Sir Winston Churchill

  9. #9
    J Bytheway
    Emperor J Bytheway's Avatar
    Join Date
    02 Jul 2001
    Location
    England
    Posts
    3,826
    Country
    This is J Bytheway's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17
    Originally posted by Martin Gühmann
    Well I wonder what these lines should do in CTPDatabase.h, I commented them out without any problems.
    [snip]
    A leftover from CTP1, perhaps? They changed most of the database access code between CTP1 and 2, so I guess there's lots of useless old stuff lying around...

  10. #10
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 22, 2013
    Local Time
    05:17

    Post

    Originally posted by J Bytheway
    A leftover from CTP1, perhaps? They changed most of the database access code between CTP1 and 2, so I guess there's lots of useless old stuff lying around...
    Maybe I should have said that this piece of code was part of MrBaggins' GovernmentsModified modification, he added that part of code but didn't use it.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  11. #11
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    19:17
    I ran across the link to this in the code. Has anyone tried this? Have they made govt specific buildings and improvements? (I guess you could do it by making available for the normal building with subneural adds and then make it available at other techs for different governments)...
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  12. #12
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 22, 2013
    Local Time
    05:17

    Post

    Originally posted by E
    I ran across the link to this in the code. Has anyone tried this? Have they made govt specific buildings and improvements?
    As far as I know noone has tried.

    Originally posted by E
    (I guess you could do it by making available for the normal building with subneural adds and then make it available at other techs for different governments)...
    No, it doesn't work like this. MrBaggins posted the syntax here, nothing with different techs and so on, just a different government.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  13. #13
    Maquiladora
    Emperor
    Join Date
    17 Jun 2001
    Posts
    7,714
    Country
    This is Maquiladora's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17

    Post

    Originally posted by Martin Gühmann

    As far as I know noone has tried.
    I just tried it and it doesn't work. It doesn't crash the game or give anything invalid, but it's not finished. Just like it (seems) MrBaggins says in the opening post.
    Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
    CtP2 AE Wiki & Modding Reference
    One way to compile the CtP2 Source Code.

  14. #14
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 22, 2013
    Local Time
    05:17

    Post

    Originally posted by Maquiladora
    I just tried it and it doesn't work. It doesn't crash the game or give anything invalid, but it's not finished. Just like it (seems) MrBaggins says in the opening post.
    Well, that's what MrBaggins says about.

    Originally posted by Maquiladora
    None of the existing record access in the code (1700 hundred instances of ->Get( and ->Access(, not all of which are applicable,) use the new method... so they need to be changed...
    So here you have the problem, so far I made it working or it least it should work with the UnitDB. Maybe there are also other databases but there is no guaranty.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  15. #15
    Maquiladora
    Emperor
    Join Date
    17 Jun 2001
    Posts
    7,714
    Country
    This is Maquiladora's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17

    Post

    Originally posted by Martin Gühmann

    So here you have the problem, so far I made it working or it least it should work with the UnitDB.
    Thanks

    Maybe there are also other databases but there is no guaranty.
    MrBaggins mentions some repetitious work, if I can help with that, to get it working for all databases, then tell me how.
    Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
    CtP2 AE Wiki & Modding Reference
    One way to compile the CtP2 Source Code.

  16. #16
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 22, 2013
    Local Time
    05:17

    Post

    Originally posted by Maquiladora
    MrBaggins mentions some repetitious work, if I can help with that, to get it working for all databases, then tell me how.
    So you wanna become a coder? For that you need and account at our repository, you need TortoiseSVN or another SVN tool. A compiler like the Introductory Edition of VC6 or the Express Edition of VC2008, then the source code a version of Direct X maybe also the Windows SDK, depending on your Direct X version, and you have to find all those instances of DB->Get( in the code, for that the windows search is your friend or also the internal search of Visual Studio.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  17. #17
    Maquiladora
    Emperor
    Join Date
    17 Jun 2001
    Posts
    7,714
    Country
    This is Maquiladora's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17

    Question

    Originally posted by Martin Gühmann

    So you wanna become a coder?
    Yes, but I doubt I can do more than copy and paste at the moment. But I'm good at repetitious tasks, so thought I could be useful.

    For that you need and account at our repository, you need TortoiseSVN or another SVN tool. A compiler like the Introductory Edition of VC6 or the Express Edition of VC2008, then the source code a version of Direct X maybe also the Windows SDK, depending on your Direct X version, and you have to find all those instances of DB->Get( in the code, for that the windows search is your friend or also the internal search of Visual Studio.
    Thanks Martin, I'll look into it.

    BTW which is the best (least problems) VC6 or VC2008?
    Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
    CtP2 AE Wiki & Modding Reference
    One way to compile the CtP2 Source Code.

  18. #18
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 22, 2013
    Local Time
    05:17

    Post

    Originally posted by Maquiladora
    BTW which is the best (least problems) VC6 or VC2008?
    Let's say if you want to release a playtest version then you have to use VC6, since VC2008 eats the army to goal assignment, so that the AI won't move any units. If you just want to do some coding and testing then you can use VC2008. One advantage of VC2008 or more precise of its integrated development environment Visual Studio 2008 is that it has a more user friendly interface and fewer bugs, so I really prefer VS2008 over VS6. Another advantage is that you should be able to download VS2008 Express Edition from Microsoft, directly. Whereas, I have no idea for VS6, but we can upgrade VS6 Introductory version to a full version with Microsoft's latest service pack, very easily.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  19. #19
    Maquiladora
    Emperor
    Join Date
    17 Jun 2001
    Posts
    7,714
    Country
    This is Maquiladora's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17
    I'll try VS2008 and see how I go. Expect a few questions coming though.

    I think I had an account for the old repository but I've forgotten it. I assume I have to contact Darkdust eventually for the new one.
    Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
    CtP2 AE Wiki & Modding Reference
    One way to compile the CtP2 Source Code.

  20. #20
    Maquiladora
    Emperor
    Join Date
    17 Jun 2001
    Posts
    7,714
    Country
    This is Maquiladora's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17

    Post

    Originally posted by Martin Gühmann

    So here you have the problem, so far I made it working or it least it should work with the UnitDB. Maybe there are also other databases but there is no guaranty.
    I just tested a warrior that cost 500 in Tyranny instead of 150 normally and I found some bugs.

    For example the build time doesn't show correctly in the build manager before you add it to the build queue, it just shows the time expected for the original warrior. So I guess I'll start by trying to fix that.

    I also got another freeze and crash when trying to move a tyranny warrior out of the city:

    Code:
    Version 2008-06-18
      0x004e0782  [?UDUnitTypeCanSettle@@YA_NHHABVMapPoint@@_N@Z + 0x32]
      0x004e08b7  [?CanSettle@UnitData@@QBE_NABVMapPoint@@_N@Z + 0x27]
      0x004d94ed  [?CanSettle@Unit@@QBE_NABVMapPoint@@_N@Z + 0x2d]
      0x0043dab7  [?RepaintLayerSprites@TiledMap@@QAEHPAUtagRECT@@H@Z + 0x417]
      0x0043e3c5  [?RepaintSprites@TiledMap@@QAEHPAVaui_Surface@@PAUtagRECT@@_N@Z + 0x95]
      0x006e58bf  [?background_draw_handler@@YA?AW4AUI_ERRCODE@@PAX@Z + 0xaf]
      0x00687a9d  [?DrawThis@Background@@UAE?AW4AUI_ERRCODE@@PAVaui_Surface@@HH@Z + 0xd]
      0x00678c9b  [?Draw@aui_Window@@UAE?AW4AUI_ERRCODE@@PAVaui_Surface@@HH@Z + 0x2b]
      0x0040be13  [?ProcessUI@CivApp@@AAEHIAAI@Z + 0x183]
      0x0040c1cb  [?Process@CivApp@@QAEHXZ + 0x11b]
      0x00406f84  [?CivMain@@YGHPAUHINSTANCE__@@0PADH@Z + 0x394]
      0x004069e5  [WinMain@16 + 0x65]
      0x007ff0fc  [WinMainCRTStartup + 0x134]
      0x7c816fd7  [__onexitbegin + 0x7be50cdf]
    I can imagine what is wrong here but I'll see how the debugger works.
    Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
    CtP2 AE Wiki & Modding Reference
    One way to compile the CtP2 Source Code.

  21. #21
    Maquiladora
    Emperor
    Join Date
    17 Jun 2001
    Posts
    7,714
    Country
    This is Maquiladora's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17

    Question

    I ran the debugger and repeated the bug and got an assertion failure at this line from CTPDatabase.cpp in ...ctp2_code\gs\newdb:

    Code:
    template  T *CTPDatabase::Access(sint32 index)
    {
    	Assert(index >= 0);
    	Assert(index < m_numRecords);
    	if((index < 0) || (index >= m_numRecords))
    	{
    		DPRINTF(k_DBG_GAMESTATE, ("CTPDatabase::Access: index: %i, numRecords: %i\n", index, m_numRecords));
    		return NULL;
    	}
    
    	return m_records[index];
    }
    so the modified tyranny warrior index is not less than m_numRecords, but what do I do about it?
    Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
    CtP2 AE Wiki & Modding Reference
    One way to compile the CtP2 Source Code.

  22. #22
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 22, 2013
    Local Time
    05:17

    Post

    Originally posted by Maquiladora
    For example the build time doesn't show correctly in the build manager before you add it to the build queue, it just shows the time expected for the original warrior. So I guess I'll start by trying to fix that.
    Looks like I only modified the game object files themselves and forgot the UI. The file you are looking for is called editqueue.cpp.

    Originally posted by Maquiladora
    so the modified tyranny warrior index is not less than m_numRecords, but what do I do about it?
    It looks rather like that that isn't even a valid index for without government modified stuff. So what was its value? And what was the function call stack. Both can be figured out with the debugger. But you can find the stuff also in the log files you find in log directory.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  23. #23
    Maquiladora
    Emperor
    Join Date
    17 Jun 2001
    Posts
    7,714
    Country
    This is Maquiladora's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17

    Post

    Originally posted by Martin Gühmann

    Looks like I only modified the game object files themselves and forgot the UI. :D The file you are looking for is called editqueue.cpp.
    There are many instances of ->Get( in that file, but I have no idea which to change or what to change it to, because I can't read the code yet.

    It looks rather like that that isn't even a valid index for without government modified stuff. So what was its value? And what was the function call stack. Both can be figured out with the debugger. But you can find the stuff also in the log files you find in log directory.
    I guess this is the important part from the debugger log:

    Code:
       armydata.cpp@6228: Army 0xd0000005 Executing order ORDER_MOVE_TO @ (1,8), turn=6
        wrlunit.cpp@93  : World::RemoveUnitReference: id: 0x10000007
       armydata.cpp@6228: Army 0xd0000005 Executing order ORDER_MOVE_TO @ (0,10), turn=6
        c3debug.cpp@315 : Assertion (index < m_numRecords) Failed in File:c:\ctp2\ctp2_code\gs\newdb\ctpdatabase.cpp, Line:356
        c3debug.cpp@316 : Stack Trace: '  0x008c460a  [char * __cdecl c3debug_StackTrace(void) + 0x2a]
      0x008beeed  [void __cdecl c3debug_Assert(char const *,char const *,int) + 0x5d]
      0x00bb5618  [public: class UnitRecord * __thiscall CTPDatabase::Access(int) + 0x48]
      0x00bb5538  [public: class UnitRecord * __thiscall CTPDatabase::Access(int,int) + 0x18]
      0x00bb550c  [public: class UnitRecord const * __thiscall CTPDatabase::Get(int,int) + 0x1c]
      0x00a3fcaa  [bool __cdecl UDUnitTypeCanSettle(int,int,class MapPoint const &,bool) + 0x4a]
      0x00a3ff06  [public: bool __thiscall UnitData::CanSettle(class MapPoint const &,bool)const  + 0x36]
      0x00a35c44  [public: bool __thiscall Unit::CanSettle(class MapPoint const &,bool)const  + 0x24]
      0x0091ec47  [public: int __thiscall TiledMap::RepaintLayerSprites(struct tagRECT *,int) + 0x477]
      0x0091fb4f  [public: int __thiscall TiledMap::RepaintSprites(class aui_Surface *,struct tagRECT *,bool) + 0x8f]
      0x00e9a698  [enum AUI_ERRCODE __cdecl background_draw_handler(void *) + 0xf8]
      0x00dfbe17  [public: virtual enum AUI_ERRCODE __thiscall Background::DrawThis(class aui_Surface *,int,int) + 0x27]
      0x00da7058  [public: virtual enum AUI_ERRCODE __thiscall aui_Region::Draw(class aui_Surface *,int,int) + 0x38]
      0x00dcdb58  [public: virtual enum AUI_ERRCODE __thiscall aui_Window::Draw(class aui_Surface *,int,int) + 0x28]
      0x008a38c3  [private: int __thiscall CivApp::ProcessUI(unsigned int,unsigned int &) + 0x1f3]
      0x008a3e9a  [public: int __thiscall CivApp::Process(void) + 0xca]
      0x0089959d  [int __stdcall CivMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int) + 0x3ad]
      0x00898bf7  [WinMain@16 + 0x87]
      0x010d7968  [WinMainCRTStartup + 0x2a8]
      0x010d76cf  [WinMainCRTStartup + 0xf]
      0x7c816fd7  [\177zlib1_NULL_THUNK_DATA + 0x7b41952f]
    but I don't know which is the value of the warrior. There is mention of a "stack trace", but I would have no idea what to do with that either.
    Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
    CtP2 AE Wiki & Modding Reference
    One way to compile the CtP2 Source Code.

  24. #24
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 22, 2013
    Local Time
    05:17

    Post

    Originally posted by Maquiladora
    There are many instances of ->Get( in that file, but I have no idea which to change or what to change it to, because I can't read the code yet.
    Probably you have to change all of them in that file. :D

    Originally posted by Maquiladora
    I guess this is the important part from the debugger log:

    Code:
       armydata.cpp@6228: Army 0xd0000005 Executing order ORDER_MOVE_TO @ (1,8), turn=6
        wrlunit.cpp@93  : World::RemoveUnitReference: id: 0x10000007
       armydata.cpp@6228: Army 0xd0000005 Executing order ORDER_MOVE_TO @ (0,10), turn=6
        c3debug.cpp@315 : Assertion (index < m_numRecords) Failed in File:c:\ctp2\ctp2_code\gs\newdb\ctpdatabase.cpp, Line:356
        c3debug.cpp@316 : Stack Trace: '  0x008c460a  [char * __cdecl c3debug_StackTrace(void) + 0x2a]
      0x008beeed  [void __cdecl c3debug_Assert(char const *,char const *,int) + 0x5d]
      0x00bb5618  [public: class UnitRecord * __thiscall CTPDatabase::Access(int) + 0x48]
      0x00bb5538  [public: class UnitRecord * __thiscall CTPDatabase::Access(int,int) + 0x18]
      0x00bb550c  [public: class UnitRecord const * __thiscall CTPDatabase::Get(int,int) + 0x1c]
      0x00a3fcaa  [bool __cdecl UDUnitTypeCanSettle(int,int,class MapPoint const &,bool) + 0x4a]
      0x00a3ff06  [public: bool __thiscall UnitData::CanSettle(class MapPoint const &,bool)const  + 0x36]
      0x00a35c44  [public: bool __thiscall Unit::CanSettle(class MapPoint const &,bool)const  + 0x24]
      0x0091ec47  [public: int __thiscall TiledMap::RepaintLayerSprites(struct tagRECT *,int) + 0x477]
      0x0091fb4f  [public: int __thiscall TiledMap::RepaintSprites(class aui_Surface *,struct tagRECT *,bool) + 0x8f]
      0x00e9a698  [enum AUI_ERRCODE __cdecl background_draw_handler(void *) + 0xf8]
      0x00dfbe17  [public: virtual enum AUI_ERRCODE __thiscall Background::DrawThis(class aui_Surface *,int,int) + 0x27]
      0x00da7058  [public: virtual enum AUI_ERRCODE __thiscall aui_Region::Draw(class aui_Surface *,int,int) + 0x38]
      0x00dcdb58  [public: virtual enum AUI_ERRCODE __thiscall aui_Window::Draw(class aui_Surface *,int,int) + 0x28]
      0x008a38c3  [private: int __thiscall CivApp::ProcessUI(unsigned int,unsigned int &) + 0x1f3]
      0x008a3e9a  [public: int __thiscall CivApp::Process(void) + 0xca]
      0x0089959d  [int __stdcall CivMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int) + 0x3ad]
      0x00898bf7  [WinMain@16 + 0x87]
      0x010d7968  [WinMainCRTStartup + 0x2a8]
      0x010d76cf  [WinMainCRTStartup + 0xf]
      0x7c816fd7  [\177zlib1_NULL_THUNK_DATA + 0x7b41952f]
    Not quite, one important thing is missing, namely the line that was generated by this piece of code:

    Code:
    DPRINTF(k_DBG_GAMESTATE, ("CTPDatabase::Access: index: %i, numRecords: %i\n", index, m_numRecords));
    When the assertion failure message pops up you can press retry, if the debugger is running, it will place you at c3debug_Assert. You can leave this function by single step execution. You just need to press F10 and the debugger executes one line. Just press F10 until you have left c3debug_Assert. Then execute the program until it prints the actual index into the log file. Alternatively you can hover the mouse over index, then you will see its actual value.

    You can also look into the debugging menu there you will also find some helpful command beside F10.

    Originally posted by Maquiladora
    but I don't know which is the value of the warrior.
    So far I only see in the log an army and a unit. The unit belongs to that army and the army is moving along a line. Both units and armies have identifiers. Those are displayed as hexadecimal number. The first digit for armies is d and the first digit for units is 1.

    Originally posted by Maquiladora
    There is mention of a "stack trace", but I would have no idea what to do with that either.
    With the call stack you can see what functions did call the function that caused the assertion failure. The problem may lie in the function argument. In that case the code you posted is ok, but the value of index is wrong, and that comes certainly from some of the functions deeper in the stack, like UDUnitTypeCanSettle or Unit::CanSettle. Since I know some of E's mistakes, I can speculate that the index parameter passed to the function is not really a unit type but a unit identifier.

    Let's see what you find. :D;)

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  25. #25
    Maquiladora
    Emperor
    Join Date
    17 Jun 2001
    Posts
    7,714
    Country
    This is Maquiladora's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17

    Post

    Originally posted by Martin Gühmann

    Not quite, one important thing is missing, namely the line that was generated by this piece of code:

    Code:
    DPRINTF(k_DBG_GAMESTATE, ("CTPDatabase::Access: index: %i, numRecords: %i\n", index, m_numRecords));
    When the assertion failure message pops up you can press retry, if the debugger is running, it will place you at c3debug_Assert. You can leave this function by single step execution. You just need to press F10 and the debugger executes one line. Just press F10 until you have left c3debug_Assert. Then execute the program until it prints the actual index into the log file. Alternatively you can hover the mouse over index, then you will see its actual value.

    You can also look into the debugging menu there you will also find some helpful command beside F10.
    I have a problem then. When CivCTP_dbg.exe minimizes and I get the assertion pop-up, I choose retry but then I can't see anything, the screen is black and all I can see is the windows taskbar. I tried alt-tabbing, show desktop but nothing allows me to see VC or in-game again unless I close ctp with task manager.

    Debugging is obviously working though because I can check task manager and see nothing is happening, except when I press F10 to move on a line. Everything is responsive, I just can't see anything unless I close ctp. I am doing something wrong?
    Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
    CtP2 AE Wiki & Modding Reference
    One way to compile the CtP2 Source Code.

  26. #26
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 22, 2013
    Local Time
    05:17

    Post

    Looks like you forgot to do the following:

    Originally posted by Martin Gühmann
    Looks like you stumbled across the first thing you have to debug. For that you have to build a debug version. To do this go the menu bar -> Build -> Configuration Manager, there set the active configuration to Debug. Then go to the menu bar -> Project -> ctp2 properties. There go to configuration properties and then Debugging. Add to the program options or program arguments or however it is called nonexclusive. This is needed so that the debugger has any use to you.
    For some reason I posted that in the other thread.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  27. #27
    Maquiladora
    Emperor
    Join Date
    17 Jun 2001
    Posts
    7,714
    Country
    This is Maquiladora's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17

    Question

    Originally posted by Martin Gühmann
    Looks like you forgot to do the following:

    For some reason I posted that in the other thread.
    I added it like the picture attached. I also added it like "NONEXCLUSIVE" and "-NONEXCLUSIVE" but they all do the same. So what is still wrong?
    Attached Images Attached Images
    Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
    CtP2 AE Wiki & Modding Reference
    One way to compile the CtP2 Source Code.

  28. #28
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 22, 2013
    Local Time
    05:17

    Post

    Originally posted by Maquiladora
    I added it like the picture attached. I also added it like "NONEXCLUSIVE" and "-NONEXCLUSIVE" but they all do the same. So what is still wrong?
    The image looks right, so you should be able to alt tab to the debugger window. Otherwise I don't see that there is anything wrong.

    Anyway, what was the unit type?

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  29. #29
    Maquiladora
    Emperor
    Join Date
    17 Jun 2001
    Posts
    7,714
    Country
    This is Maquiladora's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17

    Post

    Originally posted by Martin Gühmann

    The image looks right, so you should be able to alt tab to the debugger window. Otherwise I don't see that there is anything wrong.
    I can alt-tab between the game and the debugger, but the screen stays black, except for the windows taskbar, really annoying.

    Anyway, what was the unit type?
    A warrior, that is modified like this, in bold lines that are different to the normal warrior:

    Code:
    ## UNIT 70
    UNIT_WARRIOR > GOVERNMENT_TYRANNY {
       Description DESCRIPTION_UNIT_WARRIOR
       DefaultIcon ICON_UNIT_WARRIOR
       DefaultSprite SPRITE_WARRIOR
       Category UNIT_CATEGORY_ATTACK
       Attack 20
       Defense 10
       ZBRangeAttack 0
    ...
    the rest of the warrior is the same.
    Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
    CtP2 AE Wiki & Modding Reference
    One way to compile the CtP2 Source Code.

  30. #30
    Maquiladora
    Emperor
    Join Date
    17 Jun 2001
    Posts
    7,714
    Country
    This is Maquiladora's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 22, 2013
    Local Time
    04:17
    BTW when I terminate the game I can see the call stack information in the debugger, but then I have to press "continue" or "break" in the debugger, then the call stack window disappears.
    Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
    CtP2 AE Wiki & Modding Reference
    One way to compile the CtP2 Source Code.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. need opinions on design for a game project.
    By self biased in forum Off Topic
    Replies: 18
    Last Post: April 24, 2009, 07:43
  2. Aceituna Project - Design Document
    By Frodoqui in forum Alternative Civs
    Replies: 1
    Last Post: June 24, 2008, 13:27
  3. PROJECT/DESIGN: Altered Tilesets
    By The Big Mc in forum CtP2 Source Code Project
    Replies: 139
    Last Post: February 19, 2005, 13:26
  4. Source Code Project Design Index
    By Locutus in forum CtP2 Source Code Project
    Replies: 7
    Last Post: February 4, 2005, 11:07

Visitors found this page by searching for:

0x00455c92

Bookmarks

Posting Permissions