Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Call To Power II > CtP2-Source Code Project > DESIGN/PROJECT: GovernmentsModified complete
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!
CivGroups
CTP2 Source Code Project (59): Not a Member - Join

bottom of page
  
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
MrBaggins is offline MrBaggins
King

May 1999
time: 05:33
  Old Post 05-02-2004 00:50
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
DESIGN/PROJECT: GovernmentsModified complete Support Apolyton, buy Call to Power 2

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 on 07-02-2004 at 01:07

J Bytheway is offline J Bytheway
Emperor
England
Jul 2001
time: 05:33
  Old Post 08-02-2004 03:28 Visit J Bytheway's homepage!
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations

Good work .

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:33
Post  Old Post 21-02-2004 22:49 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Tired of ads?

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

-Martin

quote:

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 *)

MrBaggins is offline MrBaggins
King

May 1999
time: 05:33
  Old Post 22-02-2004 00:55
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Support Apolyton

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 on 22-02-2004 at 01:10

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:33
Post  Old Post 01-05-2004 03:30 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Browse Apolyton AD-FREE

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

The Big Mc is offline The Big Mc
King
Of the universe / England
Oct 2001
time: 05:33
  Old Post 01-05-2004 13:12 Visit The Big Mc's homepage!
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Support Apolyton, pre-order Civilization IV

Can’t wait to get this in a play test.

Solver is offline Solver
Apolyton Duke Of Something
Latvia, Riga
Sep 2000
time: 07:33
  Old Post 01-05-2004 16:01 Visit Solver<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Avatar Enlargement: We've got the solution



A great addition for the playtest builds.

Tamerlin is offline Tamerlin
King
Toulouse (South-western France)
Apr 2002
time: 06:33
  Old Post 01-05-2004 17:26
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Lose 30 kilos (of popups)

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...

J Bytheway is offline J Bytheway
Emperor
England
Jul 2001
time: 05:33
  Old Post 01-05-2004 17:58 Visit J Bytheway's homepage!
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Support Apolyton, buy Civilization 2

quote:
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...

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:33
Post  Old Post 01-05-2004 20:23 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations: Deluxe Edition

quote:
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

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:33
  Old Post 03-03-2005 02:52 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#11 Report this post to a moderator
Avatar Enlargement: We've got the solution

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)...

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:33
Post  Old Post 03-03-2005 21:05 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#12 Report this post to a moderator
Support Apolyton or Terrorists Win

quote:
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.

quote:
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

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:33.
Apolyton Time is 00:33.
    top of page
Rate This Thread:
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0549 seconds (91.42% PHP - 8.58% MySQL) with 36 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net