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 > DEBUG: Slic Dtabase Access
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
Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:32
Post  Old Post 25-12-2003 23:23 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
DEBUG: Slic Database Access Full PM-box? Change here!

I am trying to figure out where the problem of the slic database access lies. So far I know this:

code:
int1 = GovernmentDB(GOVERNMENT_CORPORATE_REPUBLIC).CrimeOffset;


This does work the argument of GovernmentDB is a string variable of the government name or something like this. This doesn't work and make the game crash:

code:
int1 = GovernmentDB(3).CrimeOffset;


I also know that the code somewhere converts the GOVERNMENT_CORPORATE_REPUBLIC into a number. Unfortunatly I don't know where it is determined that GovernmentDB accepts just an advance name/type or whatever but not a number, maybe it is somewhere in these *.y or *.l files determined, but so far I wasn't able to find it.

I only found the place where you can have a GovernmentDB, unfortunatly it is a template and the parser is so far a miracle to me.

So does anyone has some knowledge about Bison?

-Martin

Last edited by Martin Gühmann on 16-01-2004 at 04:04

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:32
Post  Old Post 27-12-2003 23:38 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Support Apolyton

Well I found the place where it is defined and it is actual much easier to make it work for array like database refferences and add a way to get the number of entries in the database then to make it work at all.

So far I have working these syntaces:

code:
GovernmentDB(6); GovernmentDB(6).CrimeOffset; GovernmentDB(i); GovernmentDB(i).CrimeOffset;


But this doen't work:

code:
GovernmentDB(GovernmentDB(i)); GovernmentDB(government[0]).CrimeOffset; GovernmentDB(i + 1); GovernmentDB(IsHumanPlayer(g.player)); GovernmentDB(i + i).CrimeOffset;


And here a small piece of the code from slic.y:

code:
| DBREF '(' expression ')' REF NAME { slicif_add_op(SOP_PUSHI, slicif_find_db_value_by_index($1.dbptr, $3.val, $6.name)); }


DBREF is something like OrderDB or anyother of the valids DB function and this is the first argument of the syntax definition. The '(' is the second part of the syntax definition, expression the thirsd ')' the forth, REF the fifth and NAME the sixth. Here we use the slicif_find_db_value_by_index to access the database. $1.dbptr comes from DBREF from the first part of the syntax definition. And $3.val comes from expression and is supposed to contain an integervalue, well it does contain something, something that can be interpreted as integer but that is not the value that the expression should contain. It looks for me that this value is never initialized.

-Martin

Peter Triggs is offline Peter Triggs
Prince
Gone Fishin, Canada
Jan 2000
time: 05:32
  Old Post 27-12-2003 23:38
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Inflate your Upload Space

quote:

I am trying to figure out where the problem of the slic database access lies.


Are you trying to find a function that returns the GovernmentDB index rather than the string?

quote:

I only found the place where you can have a GovernmentDB, unfortunatly it is a template and the parser is so far a miracle to me.


Me too.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:32
Post  Old Post 28-12-2003 03:00 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

OK, in the meantime I figured out that the slic.y and slic.l files contain the diffinition for syntax and such stuff, but it does not the code that does the computation at run time. So I have a valid syntax but the game still does not understand it.

-Martin

J Bytheway is offline J Bytheway
Emperor
England
Jul 2001
time: 05:32
  Old Post 04-01-2004 02:13 Visit J Bytheway's homepage!
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Support Apolyton, buy Call to Power 2

I've used a parser generator before, but never Bison. I don't like the way it does things compared to the other one I've used, and I can't quite figure out what's really going on...

I guess the problem here is that when you call .val on the expression it is returning the wrong thing - because the expression cannot be evaluated at compile time, so you need to shift the evaluation to be performed at run time.

Quite how to do this I am not sure...

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:32
Post  Old Post 04-01-2004 03:12 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Support Apolyton, pre-order Civilization IV

I already found out where the stuff is calculated at run time, but unfortunatly I have to do some stuff for uni so that I can't look into it for the next one or two weeks.

-Martin

MrBaggins is offline MrBaggins
King

May 1999
time: 05:32
  Old Post 04-01-2004 03:18
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Avatar Enlargement: We've got the solution

I'm looking into this for the other issue. I'll probably bump into at least some info for this when I'm doing the alterations to the parser.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:32
Post  Old Post 04-01-2004 03:22 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Suffering from ads?

This is actual slic not the database, the database parser generates actual some C++ code that is finally used in the program, but I think I don't need go into the details here.

-Martin

MrBaggins is offline MrBaggins
King

May 1999
time: 05:32
  Old Post 04-01-2004 03:27
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Support Apolyton, buy Civilization 2

right... I understand...

Bison and flex parse the db structure datafiles, used by ctpdb to create the actual database parser and db classes in ctp2.exe

The issue is that the accessor used by the slic function accessing the data object takes a constant identifier.. rather than an index.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:32
Post  Old Post 04-01-2004 03:32 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Avatar Enlargement: We've got the solution

quote:
Originally posted by MrBaggins
right... I understand...

Bison and flex parse the db structure datafiles, used by ctpdb to create the actual database parser and db classes in ctp2.exe


Well that's right for Slic and the user interface but not for the database. The database files themselves are generated by dbgen and it looks like dbgen was writen by the CTP2 programmers.

quote:
Originally posted by MrBaggins
The issue is that the accessor used by the slic function accessing the data object takes a constant identifier.. rather than an index.


That's the problem for the Slic database function.

-Martin

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:32
Post  Old Post 16-01-2004 01:36 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#11 Report this post to a moderator
Avatar Enlargement: We've got the solution

So far I got this working:

code:
int_t i; i = 1; int8 = GovernmentDB(army[0].size + i + GovernmentDB(GOVERNMENT_CORPORATE_REPUBLIC) + IsHumanPlayer(g.player));


Well this is stupid but it should be possible according the slic documentation. The return value is the value of the argument, given there is a database entry with such an index, otherwise it returns -1 one, in the debug version you get an assert, but that shouldn't be a problem in the release version, well I think I leave the assert in maybe it is usefull at other places.

Unfortunatly this doesn't work as expected:

code:
government[0] = 3; int8 = GovernmentDB(government[0]);


-1 is returned.

Also this works:

code:
government[0] = 3; int8 = government[0];


-Martin

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:32
Post  Old Post 16-01-2004 04:04 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#12 Report this post to a moderator
Support Apolyton, buy Civilization 2

Now I have something like this working:

code:
unitrecord[0] = MGUnit.type; int7 = UnitDB(unitrecord[0]).ShieldCost; int6 = UnitDB(unitrecord[0]).MaxMovePoints; int9 = UnitDB(UNIT_SETTLER).MaxMovePoints;


As it is from the standart game known you get array index of bounce errors if you put between the assignment of the build in arry and it call some code. Does anybody know how the MaxMovePoints flag behaves in the official game, I tried it on the settler and I got 10000 MaxMovePoints instead of 100 as you find it in the unit.txt. Well at least with unit name and with a number you get the same value for MaxMovePoints. Well also in the Great Libary this is taken in consideration. So we shouldn't change it.

Another point I have now is when I use the /slicreload either from the Cheat Editor or from the Chat Window the CTP_LEAKS_99998.TXT gets filled with a lot of leaks.

So I fast does CTP2 quit afterwards you reloaded slic heavily.

-Martin

Peter Triggs is offline Peter Triggs
Prince
Gone Fishin, Canada
Jan 2000
time: 05:32
  Old Post 16-01-2004 05:52
Edit/Delete Message Reply w/Quote
#13 Report this post to a moderator
Browse Apolyton AD-FREE

Nice work, Martin.

quote:

I tried it on the settler and I got 10000 MaxMovePoints instead of 100 as you find it in the unit.txt.


Some of the members of UnitRecord are doubles (m_MaxMovePoints is one of them) and Mr Ogre wrote:

quote:

Floating point values are multiplied by 100 and converted to ints, since SLIC does not otherwise support floating point variables.


I guess this is what you're seeing and you'll have to counter it.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:32
Post  Old Post 17-01-2004 05:01 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#14 Report this post to a moderator
Lose 30 kilos (of popups)

quote:
Originally posted by Peter Triggs
Some of the members of UnitRecord are doubles (m_MaxMovePoints is one of them) and Mr Ogre wrote:


Indeed this flag is a float.

I also figuered out why there is now such a long delay until the program shuts down, in earlier versions of CTP2 I got some thousand asserts on close, and of course I had to click on the quit button. So I just notice now how long it need to write the CTP_LEAKS_99999.TXT and that was also the reason why it was so empty.

By the way now also this does something:

code:
int2 = UnitDB();


This returns the number of entries in the according database. And it is computed during run time so that you can detect via slic when someone added something to the database during a game, so that you can warn him via slic.

The only problem I have is that this doesn't work:

code:
int3 = GovernmentDB(i).TooManyCitiesThreshold; int4 = GovernmentDB(i);


But this is only a problem that can be easily solved during compiling time.

Then some further cleaning and I can release this.

-Martin

Peter Triggs is offline Peter Triggs
Prince
Gone Fishin, Canada
Jan 2000
time: 05:32
  Old Post 11-02-2004 20:37
Edit/Delete Message Reply w/Quote
#15 Report this post to a moderator
Enter the AD-FREE zone

I'm not having any luck with this Slic Database code. I put the following simple Slic script into the Activision World Map scenario and can't get it parsed. Am I missing something?

code:
HandleEvent(BeginTurn) 'Test' post { int_t i; int_t numunits; unit_t tmpUnit; int_t unit2; int_t unit3; int_t unit4; if (g.year>0){ numUnits=player[0].units; if (numUnits){ for (i=0; i < numUnits; i=i+1){ GetUnitByIndex(player[0],i,tmpUnit); if (tmpUnit.valid){ unit[0]=tmpUnit; unit2=unitDB(UNIT_TANK); unit3=unitDB(tmpUnit.type); unit4=unitDB(unit[0].type); } } } } }

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:32
Post  Old Post 11-02-2004 21:05 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#16 Report this post to a moderator
Help yourself to an AD-FREE life

quote:
Originally posted by Peter Triggs
I'm not having any luck with this Slic Database code. I put the following simple Slic script into the Activision World Map scenario and can't get it parsed. Am I missing something?


Obviously I plugged it into the main scenario.slc started the latest playtest version of the game and the code ran fine. To verify this I added a message box, nothing unexpected happend.

So did you installe the latestest source code pack Peter?

The files that should be modified are these ones:

..\ctp2_code\gs\slic\slic.y
..\ctp2_code\gs\slic\y.tab.c
..\ctp2_code\gs\slic\y.tab.h
..\ctp2_code\gs\slic\slicif.h
..\ctp2_code\gs\slic\slicif.cpp
..\ctp2_code\gs\slic\SlicFrame.cpp
..\ctp2_code\gs\slic\SlicDBConduit.h

If these files should be at the place then you could compile the whole project again or just delete the according *obj files in the debug/release folder, to force the compiler to build these files again. I had strange effect by just letting it recompile the files, especeally files that were not altered by myself.

-Martin

Peter Triggs is offline Peter Triggs
Prince
Gone Fishin, Canada
Jan 2000
time: 05:32
  Old Post 11-02-2004 23:14
Edit/Delete Message Reply w/Quote
#17 Report this post to a moderator
Full PM-box? Change here!

I re-installed all those files, compiled the ones I could, and now it works. I'll keep testing as I work on patching SLIC.

MrBaggins is offline MrBaggins
King

May 1999
time: 05:32
  Old Post 11-02-2004 23:18
Edit/Delete Message Reply w/Quote
#18 Report this post to a moderator
Enter the AD-FREE zone

What are you working on currently, Peter? The SLIC files for AI functionality?

Peter Triggs is offline Peter Triggs
Prince
Gone Fishin, Canada
Jan 2000
time: 05:32
  Old Post 12-02-2004 00:51
Edit/Delete Message Reply w/Quote
#19 Report this post to a moderator
Full PM-box? Change here!

I filled in most of the AI SLIC functions a while back but haven't properly debugged them yet. Now that the database access is going I want to get CTC working as a scenario. It's a first step towards getting the mods converted back to scenarios, which is what they should have been in the first place.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:32
Post  Old Post 12-02-2004 23:12 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#20 Report this post to a moderator
Support Apolyton

Even if the slic functions aren't debug properly you could post them nevertheless so that we have them and no one would be tempted to do the work twice. By the way did you added more databases like AgeDB, CityStyleDB, and other DBs?

-Martin

Peter Triggs is offline Peter Triggs
Prince
Gone Fishin, Canada
Jan 2000
time: 05:32
  Old Post 15-02-2004 20:10
Edit/Delete Message Reply w/Quote
#21 Report this post to a moderator
Browse Apolyton AD-FREE

I put in personalityDB, AgeDB, and SpriteDB. Most of the others have strings, which aren't a lot of use to us yet.

I'm in the process of organizing my stuff so that I can post it, hopefully, later tonight.

Another thing I've done is to add two new buildlists to strategy.ctb so that you get:

code:
// Unit Percents must total to 1 (100%) OffensiveUnitsPercent 0.20 DefensiveUnitsPercent 0.40 RangedUnitsPercent 0.30 BombardUnitsPercent 0.10 FlankerUnitsPercent 0.0 SeaUnitsPercent 0.0 AirUnitsPercent 0.0 ... // Types of standard units that should be built OffensiveUnitList UNIT_BUILD_LIST_OFFENSE DefensiveUnitList UNIT_BUILD_LIST_DEFENSE RangedUnitList UNIT_BUILD_LIST_RANGED BombardUnitList UNIT_BUILD_LIST_BOMBARD FlankerUnitList UNIT_BUILD_LIST_FLANKER SeaUnitList UNIT_BUILD_LIST_SEA AirUnitList UNIT_BUILD_LIST_AIR


I also expanded the garrison count categories:

code:
// minimum number of units to keep in cities as a garrison OffensiveGarrisonCount 0 DefensiveGarrisonCount 1 RangedGarrisonCount 1 BombardGarrisonCount 0 FlankerGarrisonCount 0


One of the first things that WesW wanted when the game was released was a more flexible unit building system. The question is: Should I include this stuff at this point?

MrBaggins is offline MrBaggins
King

May 1999
time: 05:32
  Old Post 15-02-2004 20:16
Edit/Delete Message Reply w/Quote
#22 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

I think we need to have a chat discussion about the AI. I spent spare time on Friday, looking over the AI code.

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

Of course we can add something to the databases, but as MrBaggins noted the question is whether these changes are in the final version, meaning whether we will remove them late because of a redesign of the AI, but for now it doesn't hurt to include them as they can be easily removed, or did you gave these new flags already functionality, Peter?

-Martin

Peter Triggs is offline Peter Triggs
Prince
Gone Fishin, Canada
Jan 2000
time: 05:32
  Old Post 16-02-2004 07:37
Edit/Delete Message Reply w/Quote
#24 Report this post to a moderator
Enter the AD-FREE zone

Yes, so it will mean re-doing all the strategies. I've put some data in for the vanilla game and CTC but haven't done the Activision scenarios.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:32
Post  Old Post 19-02-2004 23:02 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#25 Report this post to a moderator
Support Apolyton, buy Civilization: The Boardgame

quote:
Originally posted by Peter Triggs
I'm in the process of organizing my stuff so that I can post it, hopefully, later tonight.


Obviously you got some problems, Peter.

-Martin

Peter Triggs is offline Peter Triggs
Prince
Gone Fishin, Canada
Jan 2000
time: 05:32
  Old Post 19-02-2004 23:58
Edit/Delete Message Reply w/Quote
#26 Report this post to a moderator
Support Apolyton, buy Civilization III: Complete

Yup, I'm still debugging.

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:32.
Apolyton Time is 00:32.
    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.0616 seconds (91.59% PHP - 8.41% 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