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: The neutral tile improvement pillage bug
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:31
Post  Old Post 03-11-2003 22:33 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
The neutral tile improvement pillage bug Support Apolyton, buy Civilization III: Complete

I located the neutral tile pillage bug in gaiacontroller.cpp or at least I can fix it there:

code:
STDEHANDLER(GaiaController_CutImprovements) { sint32 owner; sint32 type; MapPoint pos; if(!args->GetPos(0, pos)) return GEV_HD_Continue; TerrainImprovement ti; Cell *cell = g_theWorld->GetCell(pos); owner = cell->GetOwner(); //Added by Martin Gühmann to make shure that //g_player[-1] does not happen. //Not a problem for the array but for the //GetGaiaController() if (owner < 0) return GEV_HD_Continue; Player *owner_player = g_player[owner]; if (owner_player == NULL || owner_player->GetGaiaController() == NULL) return GEV_HD_Continue; sint32 num = cell->GetNumDBImprovements(); for (sint16 i = 0; i < num; i++) { type = cell->GetDBImprovement(i); if (GaiaController::sm_endgameImprovements & ((uint64)0x1 << (uint64)type)) { owner_player->GetGaiaController()-> HandleTerrImprovementChange(type,pos, -1); } } return GEV_HD_Continue; }


The problem is the GetGaiaController() function. If it is used on a player with index -1 the game crashs. I guess is that there is no player with index -1 and therefore this function tries to access an object that doesn't exist.

In player.cpp I tried this:

code:
GaiaController *Player::GetGaiaController() { if(this->m_owner < 0) return NULL; //Added return m_gaiaController; }


But without any success maybe the game crashs when the function is called and not when its code is executed. So what do you think about it? I will add it to the altered source files thread once I got your comments or some time passed.

-Martin

MrBaggins is offline MrBaggins
King

May 1999
time: 05:31
  Old Post 03-11-2003 22:40
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Full PM-box? Change here!

Just curious, but is gaiacontroller the place to handle this? how did you come by that information.

I just assumed it would be void World::CutImprovements(const MapPoint &point) in WrlEnv.cpp or something.

Solver is offline Solver
Apolyton Duke Of Something
Latvia, Riga
Sep 2000
time: 07:31
  Old Post 03-11-2003 22:45 Visit Solver<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Browse Apolyton AD-FREE

Forgive my ignorance, what is the meaning of this bug?

MrBaggins is offline MrBaggins
King

May 1999
time: 05:31
  Old Post 03-11-2003 22:50
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Put an end to popups!

Game crashes if a unit pillages a tile which doesn't have an owner.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:31
Post  Old Post 03-11-2003 23:38 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Remove this text

quote:
Originally posted by MrBaggins
Just curious, but is gaiacontroller the place to handle this? how did you come by that information.


I used the debugger of VC++. It directed me to the function in player.cpp I posted above. On the first glance this function looked OK and therefore I decided to find the places where it is called and it is called in the gaiacontroller.cpp in the according handler section. So I added the two lines and it does work now. And I think it shouldn't be a problem as player -1 is non existent and therefore doesn't have a Gaia Controller to check for.

At first I thought there might be a more elegant way to do it but I didn't feel like to bother with it for hours just to come to the same sollution in the end.

-Martin

Gilgamensch is offline Gilgamensch
King
France
Jun 2002
time: 06:31
  Old Post 04-11-2003 14:39
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations: Deluxe Edition

Martin,

might sound stupid,

but why not making it slightly different:

If the owner is < 0, change owner to 0 (babarian, or?)

might be easier, or?

The Big Mc is offline The Big Mc
King
Of the universe / England
Oct 2001
time: 05:31
  Old Post 04-11-2003 15:19 Visit The Big Mc's homepage!
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Got spare money?

there’s no difference in game play or the amount of code you have to Wright

Gilgamensch is offline Gilgamensch
King
France
Jun 2002
time: 06:31
  Old Post 04-11-2003 15:37
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Support Apolyton buy from Amazon

But keeping it in the same area, makes other problem resolution easier

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:31
Post  Old Post 04-11-2003 19:54 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Get a bigger avatar today!

quote:
Originally posted by Gilgamensch
But keeping it in the same area, makes other problem resolution easier


I don't know what you mean Gilgamensch, the problems lies here or more precise GetGaiaController function, but I wasn't able to fix it in the GetGaiaController, although I prefer a fix there.

-Martin

Gilgamensch is offline Gilgamensch
King
France
Jun 2002
time: 06:31
  Old Post 04-11-2003 19:57
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Help yourself to an AD-FREE life

That was also my point, trying to fix in the procedure where it is broken and not somewhere else.

But did you read my other suggestion?

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:31
Post  Old Post 04-11-2003 20:03 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#11 Report this post to a moderator
Put an end to popups!

I think your other sollution is more complicated, and needs also be done at the place where I did the fix. The version of the GetGaiaController function I posted above should do something along this but it crashes. Possibly the index in that function is nor not -1 but NULL. Maybe I should do anther trial or someone else.

-Martin

Gilgamensch is offline Gilgamensch
King
France
Jun 2002
time: 06:31
  Old Post 04-11-2003 20:12
Edit/Delete Message Reply w/Quote
#12 Report this post to a moderator
Lose 30 kilos (of popups)

I haven't got any compiler, so sorry if I can't assist you with this.

But if I see it right,

you just return to GEV_HD_continue, but you don't 'change' the owner.

My idea was more to change the owner to like babarian and get away with it, this way.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:31
Post  Old Post 04-11-2003 20:44 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#13 Report this post to a moderator
Support Apolyton, buy Call to Power 2

The HandleTerrImprovementChange is used to determine whether a player can lunch the Gaia Controller, player -1 doesn't exists and therefore it can't lunch the GaiaController and therefore it is just some waste of time to execute the code further. The player is invalid and if the player is invalid then the code should stop here.

-Martin

J Bytheway is offline J Bytheway
Emperor
England
Jul 2001
time: 05:31
  Old Post 04-11-2003 20:47 Visit J Bytheway's homepage!
Edit/Delete Message Reply w/Quote
#14 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations

Will this cause any problems if a player has gaia controller tile imps which enter or leave his borders after being constructed?

Gilgamensch is offline Gilgamensch
King
France
Jun 2002
time: 06:31
  Old Post 04-11-2003 20:48
Edit/Delete Message Reply w/Quote
#15 Report this post to a moderator
Browse Apolyton AD-FREE

*beating the table with my head*

yep, that would be right.

BUT only as a thought, maybe there is some other check afterwards, while it was run through there. So maybe you still might want to try to change the owner there before returning........(hard to tell without having checked everything........)

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:31
Post  Old Post 04-11-2003 21:04 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#16 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations: Deluxe Edition

quote:
Originally posted by J Bytheway
Will this cause any problems if a player has gaia controller tile imps which enter or leave his borders after being constructed?


Difficuilt question we need to check where the HandleTerrImprovementChange is used and then we can tell.

Gilgamensch changing the owner is I feel something that shouldn't be done the belongs noone thefore the tile improvement shouldn't belong to anybody either, well this I think another bug.

-Martin

Gilgamensch is offline Gilgamensch
King
France
Jun 2002
time: 06:31
  Old Post 04-11-2003 21:07
Edit/Delete Message Reply w/Quote
#17 Report this post to a moderator
Browse Apolyton AD-FREE

OK, then I see two ways:

If you don't like to change it to babarian (which IIRC is player 0)

then

we would need to remove all TI's if the border changes......


But, I don't see where your problem would be, to change it to babarian? (espacially for pillaging?)

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:31
Post  Old Post 06-11-2003 23:17 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#18 Report this post to a moderator
Support Apolyton, pre-order Civilization IV

Well I tried to move the bugfix into the Player::GetGaiaController but as I disabled all the code I added here, nothing happened no crash.
I just added the fix for the buildingutil.cpp by NelsonAndBronte. So I have no idea why it doesn't crash now.

-Martin

Gilgamensch is offline Gilgamensch
King
France
Jun 2002
time: 06:31
  Old Post 07-11-2003 13:22
Edit/Delete Message Reply w/Quote
#19 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations

sounds a little bit like a reversed Murphy's Law.............

But if it doesn't chrash anymore, would be good (just had one of those games.............)

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