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 > PROJECT: ShowOnMap
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   
Pages (2): [ 1   2   ]
< Last Thread     Next Thread > Post New Thread     Post A Reply
E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 15-02-2005 06:13 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
PROJECT: ShowOnMap Support Apolyton, buy Call to Power 2

Ok, my other project I want to do is add a flag for wonders (later buildings too) that will tell the program to create a wonderimprovement once a wonder is built. Yes, it is based on the visible wonders mod, but wouldn't it be nice to just add a flag ShowOnMap () and put the index number and the game will place it. I think so. So I'm looking at where to put the code first, and I think I'll relook the slic and then try to code it from there. I'm thinking the code might have to go in some of the code found in WonderTracker.cpp


code:
BOOL WonderTracker::HasWonderBeenBuilt(sint32 which) { return (m_builtWonders & ((uint64)1 << (uint64)which)) != 0; } void WonderTracker::AddBuilt(sint32 which) { m_builtWonders |= (uint64)1 << (uint64)which; if(g_network.IsHost()) { g_network.Enqueue(new NetInfo(NET_INFO_CODE_BUILT_WONDERS, (uint32)(m_builtWonders & 0xffffffff), (uint32)(m_builtWonders >> (uint64)32))); } } BOOL WonderTracker::GetCityWithWonder(sint32 which, Unit &city) { sint32 p; for(p = 0; p < k_MAX_PLAYERS; p++) { if(!g_player[p]) continue; sint32 c; for(c = g_player[p]->m_all_cities->Num() - 1; c >= 0; c--) { if(g_player[p]->m_all_cities->Access(c).GetData()->GetCityData()->GetBuiltWonders() & ((uint64)1 << which)) { city = g_player[p]->m_all_cities->Access(c); return TRUE; } } } return FALSE;



OR in CityEvent.cpp


code:
STDEHANDLER(CityBuildWonderEvent) { Unit city; sint32 type; if(!args->GetCity(0, city)) return GEV_HD_Continue; if(!args->GetInt(0, type)) return GEV_HD_Continue; city.BuildWonder(type); return GEV_HD_Continue; }

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 21-02-2005 09:10 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Increase the size of your Attachments

Martin,
I saw that Actor uses the draw forcefield and drawWalls funcion to place it on the map when built. Would you recommend using the Draw features but have it search for tiles or to create it as an event?

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:24
Post  Old Post 21-02-2005 20:19 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Support Apolyton buy from Amazon

Well the little problem is that you have to store the location of the wonder tile somewhere. One possible way would be to use the tile object list. However I would put or call the placement from the City::BuildWonder function. But maybe you should take a close lock on your good improvements first.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 21-02-2005 21:42 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Support Apolyton, pre-order Civilization IV

I'll stick to finishing my goods first, but I was thinking of making it a flag in the wonder/building.txt something like ShowOnMap 42, using the integer as the index number. I saw that the forcefield code had a default value that you ended up putting in your citystyle.txt IIRC.

So I'm thinking I'd have to do something similar but copy the searching tile code IW did in the SLIC and then having the DrawActor trigger it in the CityEvent code...

the follow on to this might also be to add a flag in the advances.txt that is EnableCitySprawl 44, and if a player has the advance and the city grows than it does city sprawl. Having it as flags in the txt also allows it to be a modder option and not change the original game.

Of course adding Unit updater and the kill city options are also on my list but I will stay focused on my good improvements first.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:24
Post  Old Post 21-02-2005 23:42 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Inflate your Upload Space

It is not so easy:

1. You have to figure out where you put the graphic on the map.
2. That must be stored, so that you don't put it at another place each time you call the draw function.
3. What about the Great Wall, in Ben's version it is a set of tile improvements, in which order in how must they arranged on the map.
4. How do you store this bit of information in the save game file so that it is compatible with old savegames.

And I think that are just some questions you have to answer and implement finally.

-Martin

Immortal Wombat is offline Immortal Wombat
Prince
in perpetuity
Dec 2000
time: 05:24
  Old Post 22-02-2005 05:14 Visit Immortal Wombat's homepage!
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Enter the AD-FREE zone

If it's done, then limiting it to one-tile wonders would be far easier than kludging the Great Wall in.

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 22-02-2005 08:37 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Support Apolyton, buy Call to Power 2

quote:
Originally posted by Martin Gühmann
It is not so easy:

1. You have to figure out where you put the graphic on the map.


I can't just use a search tile function like in IW's slic? I'm thinking I may to make it an event where a tileimp is built as opposed to "draw" which I think just places a graphic.

quote:
2. That must be stored, so that you don't put it at another place each time you call the draw function.


Will making it a tileimp thats placed at an event solve this?

quote:
3. What about the Great Wall, in Ben's version it is a set of tile improvements, in which order in how must they arranged on the map.


Ben said it can be just one tile, and I think that is best.

quote:
4. How do you store this bit of information in the save game file so that it is compatible with old savegames.


You got me on that one. Does forcefield have a problem with that/ Or citywalls? Would making it an event solve it?



PS Immortal Wombat, you've done great stuff with SLIC have you ever tried helping with the source code? We could use the help here.

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 22-02-2005 09:01 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Tired of ads?

CityEvent.cpp

code:
STDEHANDLER(CreateWonderEvent) { Unit c; sint32 wonder; if(!args->GetCity(0, c)) return GEV_HD_Continue; if(!args->GetInt(0, wonder)) return GEV_HD_Continue; c.CD()->SetWonders(c.CD()->GetBuiltWonders() | ((uint64)1 << (uint64)wonder)); wonderutil_AddBuilt(wonder); g_player[c->GetOwner()]->AddWonder(wonder, c); g_player[c->GetOwner()]->RegisterCreateWonder(c, wonder); if (c->GetOwner() == g_selected_item->GetVisiblePlayer() && !Player::IsThisPlayerARobot(c->GetOwner())) { if ( g_theProfileDB->IsWonderMovies() ) { if (g_director) { g_director->AddPlayWonderMovie(c.CD()->GetBuildQueue()->GetHead()->m_type); } } } if(g_network.IsHost()) { g_network.Block(c.GetOwner()); g_network.Enqueue(new NetInfo(NET_INFO_CODE_WONDER_BUILT, c.CD()->GetBuildQueue()->GetHead()->m_type, (uint32)c.m_id)); g_network.Unblock(c.GetOwner()); } Unit u; c.CD()->GetBuildQueue()->FinishBuildFront(u); SlicObject *so; if(wonder == wonderutil_GetFobCityIndex()) { so = new SlicObject("911ForbiddenCityPeace"); so->AddRecipient(c.GetOwner()); so->AddCity(c); g_slicEngine->Execute(so); } if(wonder == wonderutil_GetGaiaIndex()) { #if defined(ACTIVISION_ORIGINAL) // have to make a new object for each player so = new SlicObject("GCMustDiscoverGaiaController"); for(sint32 i = 1; i < g_theProfileDB->GetMaxPlayers(); i++) { if(g_player[i] && i != c->GetOwner()) { #else // Notify the other players that they have to hurry to win. // Starting at 1: the Barbarians do not have to be notified. for (sint32 i = 1; i < k_MAX_PLAYERS; ++i) { if (g_player[i] && !g_player[i]->IsDead() && (i != c.GetOwner())) { SlicObject * so = new SlicObject("GCMustDiscoverGaiaController"); #endif so->AddRecipient(i); so->AddPlayer(i); so->AddPlayer(c.GetOwner()); g_slicEngine->Execute(so); // will delete so after handling } } } return GEV_HD_Continue; }

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:24
Post  Old Post 22-02-2005 20:31 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Support Apolyton buy from Amazon

quote:
Originally posted by E
You got me on that one. Does forcefield have a problem with that/ Or citywalls? Would making it an event solve it?


No forcefoelds and citywalls are place on the same tile as the city itsself, but visible wonders are placed outside of the city. But if you turn them into a tileimprovements than you shouldn't have a problem, but then I suggest to use real tileimprovements stored in tileimp.txt.

To place them you have to use the create wonder event posted above. Another thing is that you should add then a CantPillaged flag to tileimp.txt.

And finally you have to consider a way to remove them from the map if the wonder is destroyed.

For placing them you should find in the source code a search function.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 23-02-2005 06:07 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Support Apolyton, buy Civilization 2

I'll go with the tileimp and use IW's as a default to add to the code.

I'll look for the searc function in a bit, but cant I use something similar to IW's Slic? just get city pos check for an imp and if they are all imps then cut one. I think I may also have to add a check in can build if its an island etc...


for CantPillage I think I need to add the check here in OA_Pillage.cpp

code:
if (ai->m_world->GetNumImprovements(pos) > 0) { start_owner = ai->m_world->GetCellOwner(&pos); if ((0 <= start_owner) && (start_owner <= k_MAX_PLAYERS)) { if (ai->m_foreigner[start_owner]) { if (start_owner != ai->m_my_player_id) { if (ai->m_foreigner[start_owner]->IsAtHotWar()) { if (ai->m_player->CanPillage(nth_army->m_id.GetVal(), &is_unknown_id, &pos)) { ai->m_player->Pillage(nth_army->m_id.GetVal(), &is_unknown_id, &pos); } } } } } } } }

Immortal Wombat is offline Immortal Wombat
Prince
in perpetuity
Dec 2000
time: 05:24
  Old Post 23-02-2005 21:28 Visit Immortal Wombat's homepage!
Edit/Delete Message Reply w/Quote
#11 Report this post to a moderator
Help yourself to an AD-FREE life

quote:
Originally posted by E
PS Immortal Wombat, you've done great stuff with SLIC have you ever tried helping with the source code? We could use the help here.

I plan to get involved at some point, but that point is not here yet

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

quote:
Originally posted by E
I'll look for the searc function in a bit, but cant I use something similar to IW's Slic?


Of course you can reprogram it, but first that is an unnecessary code duplication. Second if you duplicate code you can do errors. Third why writing code again if someone else already has written it. And fourth that isn't a very good style of programming.

quote:
Originally posted by E
just get city pos check for an imp and if they are all imps then cut one. I think I may also have to add a check in can build if its an island etc...


Why cutting one? The tileimp records have already an exclusion flag that does this automaticly for you, you may just need to add some new.

quote:
Originally posted by E
for CantPillage I think I need to add the check here in OA_Pillage.cpp


From a glipse at it, it seems that it is just related to the AI, however it must know which it can pillage and which not, but it would prevent a human player from pillaging the tileimps.

By the way I think we should make it so that if a location contains an unpillagable tileimp that the rest of the tileimps at that location can be pillaged, if they are pillagble.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 26-02-2005 01:58 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#13 Report this post to a moderator
Got spare money?

Martin,

I've been hunting for a search function and found something in governor.cpp but I don't think the AI is the way to go. I didn't see much in gs. Could you point in the right direction or may be point out what I miss?

I searched on SEARCH...and Search tile, etc.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:24
Post  Old Post 26-02-2005 02:38 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#14 Report this post to a moderator
Support Apolyton buy from Amazon

You are looking for a function that scans through all tiles under the city influence. For instance an iterator does something like this. And in fact you find something like this in the governor.cpp.

-Martin

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

great. so I was close, and in the right place, but couldnt find what I was looking for

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

Martin this code kept popping up in governor.cpp

code:
MapAnalysis & the_map = MapAnalysis::GetMapAnalysis();


not sure if this what you were talking about, but I also found this..

code:
Governor::PlaceTileImprovements() { for(it.Start(); !it.End(); it.Next()) { if (unit.RetPos() == it.Pos()) continue; cell = g_theWorld->GetCell(it.Pos()); if (!(cell->GetCityOwner() == unit)) continue; if (cell->GetNumImprovements() > 0) continue;

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:24
Post  Old Post 01-03-2005 21:47 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#17 Report this post to a moderator
Get a bigger avatar today!

It is the second one, that's an iterator. This iterator contains all the locations within a certain radius. Therefore they check whether the current locations isn't the center or doesn't even belong to the city influence area, and finally they check whether the locations has a tile improvement.

-Martin

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

Great! I thought I'd have to look more. But the problem is that the iterator is part of a code. Should I make a free standing search function (for later coders too?)

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:24
Post  Old Post 01-03-2005 22:15 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#19 Report this post to a moderator
Enter the AD-FREE zone

quote:
Originally posted by E
Great! I thought I'd have to look more. But the problem is that the iterator is part of a code. Should I make a free standing search function (for later coders too?)


No it is an iterator, a pointer on the first element, a pointer on the last element and a way to get from one element to the next element. And actual this is all you need. You have to get the iterator, well you omitted that piece of code and the for loop, that goes through all the elements, and that is your search function, you wouldn't do much different stuff with your search function.

And of course everyone may have to do something else in that for-loop. But I think that you need the three checks you posted here as well.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 03-03-2005 10:14 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#20 Report this post to a moderator
Increase Your PM Length

Okay this isnt a real attempt at the code (yet) but I'm trying to gather exactly what I'll need to do.
1) it has to go in the citywonderevent, no prob.
2) first it has to check the radius for terrain andimprovements
3) then it has to get the wonder imp properties Cantbuildon and excludes
4) it has to check if the wonder can be built on terrain or the improvements
5) then it has to build the wonder

I know I'm going to need help on the iterator, havent done anything like that before, but I think I found something similar in the jumble of code I pasted there. Questions though:
1) do I have to copy the checks that createtile (like Cantbuildon etc) or is there some whay I can just do Get terrainutil_CanPlayerBuildAt?

2)How do I tell it to create the tile?

3) should I make it do a check n the build ques to see if the wonder can be shown on the map so it doesn't cause a problem afterwards?

thanks




code:
//// sint32 w; const WonderRecord *rec = g_theWonderDB->Get(wonder_type); sint32 t = rec->GetTerrutilIndex(); sint32 wonderimp = rec->GetShowOnMapIndex(); if (t < 0) { return FALSE; for(i = 0; i < rec->GetNumCanSettleOn(); i++) { if(rec->GetCanSettleOnIndex(i) == cell->GetTerrain()) { return TRUE; } } if(cell->GetOwner() == -1) { if(rec->GetIntBorderRadius()) { if(!g_player[pl]->IsVisible(pos)) { return false; } } else { return false; } } for(i = 0; i < rec->GetNumCantBuildOn(); i++) { if(rec->GetCantBuildOnIndex(i) == cell->GetTerrain()) { return FALSE; } } } g_gevManager->AddEvent(GEV_INSERT_Tail, GEV_CreateImprovement, GEA_Player, m_playerId, GEA_MapPoint, iter->pos, GEA_Int, iter->type, GEA_Int, 0, GEA_End);

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 09-03-2005 10:29 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#21 Report this post to a moderator
Full PM-box? Change here!

I realize its going to be a multi change process. Mainly since I don't want the program to run the iterator ONCE the wonder has already been built, first I have to do the radius search to the ShowOn Map here first:

code:
BOOL CityData::CanBuildWonder(sint32 type) const { if(g_exclusions->IsWonderExcluded(type)) return FALSE; if(!wonderutil_IsAvailable(type, m_owner)) return FALSE; return g_slicEngine->CallMod(mod_CanCityBuildWonder, TRUE, m_home_city.m_id, type); }


then once they build it then the build event will just run the iterator (again?) to find the best spot and then place the improvement. Still working....

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:24
Post  Old Post 09-03-2005 22:15 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#22 Report this post to a moderator
Remove this text

quote:
Originally posted by E
I realize its going to be a multi change process.


Nice that you have got this in the mean time.

quote:
Originally posted by E
Mainly since I don't want the program to run the iterator ONCE the wonder has already been built, first I have to do the radius search to the ShowOn Map here first:


Why that? That's the time when it should be done and the slic file does it like that.

quote:
Originally posted by E
code:
BOOL CityData::CanBuildWonder(sint32 type) const { if(g_exclusions->IsWonderExcluded(type)) return FALSE; if(!wonderutil_IsAvailable(type, m_owner)) return FALSE; return g_slicEngine->CallMod(mod_CanCityBuildWonder, TRUE, m_home_city.m_id, type); }


then once they build it then the build event will just run the iterator (again?) to find the best spot and then place the improvement. Still working....


Why do you want to modify this? It just determines whether your city can build the according wonder.

quote:
Originally posted by E
I realize its going to be a multi change process.


Back to this. You have to modify tileimp.txt. You have to extend the Excludes set, so that we don't have to worry about removing the other tileimp from the given tile, but of course it would be nice to find a free tile.

Then tileimp.txt needs an unpillageble flag. Maybe also a flag that doesn't allow to build other tileimps on it.

You have to change the AI so that it doesn't go for goals that pillages this tile if it only contains the wonder improvement. You have to modify wonders.txt, for the flag that specifies the tileimprovement.

And of course you have to find a good spot to place the tileimp.

And maybe some other things I have forgotten.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 09-03-2005 22:22 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#23 Report this post to a moderator
Support Apolyton, buy Civilization: The Boardgame

The tile imp stuff I havent gotten to yet and I'll probably take the stuff from IW's visible wonders mod (graphics and tileimp.txt info).

I'll have to see how the slic handles the building after the city has already built it, mainly because I'm thinking about what happens if the wonder has a CantBuildOn flag and the city is on a single square island. Does the slic just place it in the water? I was thinking of doing the iteration (like building sea units only in coast cities) so that land wonders can only be built in cities that have a land tile adjacent to it.

The cant pillage I'll look into once I get the iterator and stuff down.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:24
Post  Old Post 09-03-2005 22:27 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#24 Report this post to a moderator
Support Apolyton buy from Amazon

quote:
Originally posted by E
I'll have to see how the slic handles the building after the city has already built it, mainly because I'm thinking about what happens if the wonder has a CantBuildOn flag and the city is on a single square island. Does the slic just place it in the water? I was thinking of doing the iteration (like building sea units only in coast cities) so that land wonders can only be built in cities that have a land tile adjacent to it.


In that case the solution is no visible wonder, but just the wonder inside the city. At least that would be the first step.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 11-03-2005 01:11 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#25 Report this post to a moderator
Support Apolyton, pre-order Civilization IV

no wonder at all... i was taking the more difficult route and insisting that it must show. Ok I'll pursue that....

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 15-03-2005 10:19 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#26 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations: Deluxe Edition

Martin (or someone) could you walk me through how the iterator falls into the code, I'm getting use to if and == stuff but not sure how the iterator would kick in mainly since I only see it like this:

code:
sint16 num_cities = player_ptr->m_all_cities->Num(); for (sint16 city_index = 0; city_index < num_cities; city_index++) { unit = player_ptr->m_all_cities->Get(city_index); Assert(unit->GetCityData()); city = unit->GetCityData(); if (city->GetUseGovernor() == false) continue; CityInfluenceIterator it(unit.RetPos(), city->GetSizeIndex()); bonusFood = 0; bonusProduction = 0; bonusCommerce = 0; for(it.Start(); !it.End(); it.Next()) { if (unit.RetPos() == it.Pos()) continue; cell = g_theWorld->GetCell(it.Pos()); if (!(cell->GetCityOwner() == unit)) continue; if (cell->GetNumImprovements() > 0) continue; if ( FindBestTileImprovement(it.Pos(), ti_goal) )


I see Start and End of course but how do I limit to only the city radius or just a radius of one? And do I make it equal to the CantBuild for the result. Just need a little direction here. I think Can't Pillage is easy (except the AI part) but the iterator and "finding" the best spot is a little confusing.

J Bytheway is offline J Bytheway
Emperor
England
Jul 2001
time: 05:24
  Old Post 16-03-2005 19:07 Visit J Bytheway's homepage!
Edit/Delete Message Reply w/Quote
#27 Report this post to a moderator
Support Apolyton buy from Amazon

quote:
Originally posted by E
Martin (or someone) could you walk me through how the iterator falls into the code


I'll try. The important part is where the iterator is created, which I think is here:

code:
CityInfluenceIterator it(unit.RetPos(), city->GetSizeIndex());


This part says that you want an iterator which is centred on the unit (the city), and of radius the city SizeIndex, which I presume means the city radius. Once the iterator is so initialized, the loop goes over all the squares specified.

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

John is right. One thing to add is that as far as I could figure it out the city iterator only visit tiles that are inside the city's influence radius. This means that actual this part of code is superflous:

code:
if (!(cell->GetCityOwner() == unit)) continue;


-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 18-03-2005 09:10 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#29 Report this post to a moderator
Got spare money?

Thanks guys,
I found in the CityInfluenceIterator.cpp that there is also a Get CityRadius, might be a duplicate form of code. But I would like to limit it to the city radius (no sense having the wondering pop up four tiles away for an ancient wonder if it goes by influence).

I think I might know enough to be dangerous so I'll take a crack at the code soon...

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:24
  Old Post 13-08-2005 00:05 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#30 Report this post to a moderator
Support Apolyton, buy Civilization 2

Just some left over notes and stuff to clean up after I finish NeedsCityGood. the stuff in bold I'll need to walk through though...

code:
STDEHANDLER(CreateWonderEvent) { Unit c; sint32 wonder; if(!args->GetCity(0, c)) return GEV_HD_Continue; if(!args->GetInt(0, wonder)) return GEV_HD_Continue; c.CD()->SetWonders(c.CD()->GetBuiltWonders() | ((uint64)1 << (uint64)wonder)); wonderutil_AddBuilt(wonder); g_player[c->GetOwner()]->AddWonder(wonder, c); g_player[c->GetOwner()]->RegisterCreateWonder(c, wonder); if (c->GetOwner() == g_selected_item->GetVisiblePlayer() && !Player::IsThisPlayerARobot(c->GetOwner())) { if ( g_theProfileDB->IsWonderMovies() ) { if (g_director) { g_director->AddPlayWonderMovie(c.CD()->GetBuildQueue()->GetHead()->m_type); } } } if(g_network.IsHost()) { g_network.Block(c.GetOwner()); g_network.Enqueue(new NetInfo(NET_INFO_CODE_WONDER_BUILT, c.CD()->GetBuildQueue()->GetHead()->m_type, (uint32)c.m_id)); g_network.Unblock(c.GetOwner()); } Unit u; c.CD()->GetBuildQueue()->FinishBuildFront(u); SlicObject *so; if(wonder == wonderutil_GetFobCityIndex()) { so = new SlicObject("911ForbiddenCityPeace"); so->AddRecipient(c.GetOwner()); so->AddCity(c); g_slicEngine->Execute(so); } //begin E code from Governor.cpp PlaceTileImprovements Player *player_ptr; CityData *city; Unit unit; Cell *cell; TiGoal ti_goal; MapPoint pos; CityInfluenceIterator it(unit.RetPos(), city->GetSizeIndex()); for(it.Start(); !it.End(); it.Next()) { if (unit.RetPos() == it.Pos()) continue; cell = g_theWorld->GetCell(it.Pos()); if (!(cell->GetCityOwner() == unit)) continue; if (cell->GetNumImprovements() > 0) continue; if ( terrutil_PlayerCanBuildAt(it.Pos(), imp) ) g_gevManager->AddEvent(GEV_INSERT_Tail, GEV_CreateImprovement, GEA_Player, m_playerId, GEA_MapPoint, iter->pos, GEA_Int, iter->type, GEA_Int, 0, //end E code if(wonder == wonderutil_GetGaiaIndex()) { // Notify the other players that they have to hurry to win. // Starting at 1: the Barbarians do not have to be notified. for (sint32 i = 1; i < k_MAX_PLAYERS; ++i) { if (g_player[i] && !g_player[i]->IsDead() && (i != c.GetOwner())) { SlicObject * so = new SlicObject("GCMustDiscoverGaiaController"); so->AddRecipient(i); so->AddPlayer(i); so->AddPlayer(c.GetOwner()); g_slicEngine->Execute(so); // will delete so after handling } } } return GEV_HD_Continue; }

 
Pages (2): [ 1   2   ]
< Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:24.
Apolyton Time is 00:24.
    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.0725 seconds (92.06% PHP - 7.94% 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