 |
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:29
|
|
Martin,
I made the changes. One thing I want to double check though:
code:
Terrailutil.cpp
if(rec->IsRestrictedToGood == 0) {
for(i = 0; i < rec->GetNumCantBuildOn(); i++) {
if(rec->GetCantBuildOnIndex(i) == cell->GetTerrain()) {
return false;
}
}
}
else {
sint32 good;
if (g_theWorld->GetGood(pos, good)) {
for(i = 0; i < rec->GetNumIsRestrictedToGood(); i++) {
if(rec->GetIsRestrictedToGood(i) == good) {
return true;
}
}
return false;
}
}
}
When we went through this code awhile ago so it should be good, but I don't understand why the first line is:
if(rec->IsRestrictedToGood
and not CantBuildOn like the code was originally. Will the game still check the CantBuildOn in this case?
attached are all the files cdb and cpp.
{removed}
Last edited by E on 02-05-2005 at 02:24
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:29
|
|
Well I know I have to GetNum so I think the code should be:
code:
if(rec->GetNumIsRestrictedToGood () == 0) {
for(i = 0; i < rec->GetNumCantBuildOn(); i++) {
if(rec->GetCantBuildOnIndex(i) == cell->GetTerrain()) {
return false;
}
}
}
else {
if(irec->GetNumIsRestrictedToGood() > 0) {
sint32 good;
if (g_theWorld->GetGood(pos, good)) {
for(i = 0; i < rec->GetNumIsRestrictedToGood(); i++) {
if(rec->GetIsRestrictedToGood(i) == good) {
return true;
}
}
return false;
}
}
}
BUT I added that extra line for the check but if thats wrong then the code should be:
code:
if(rec->GetNumIsRestrictedToGood () == 0) {
for(i = 0; i < rec->GetNumCantBuildOn(); i++) {
if(rec->GetCantBuildOnIndex(i) == cell->GetTerrain()) {
return false;
}
}
}
else {
sint32 good;
if (g_theWorld->GetGood(pos, good)) {
for(i = 0; i < rec->GetNumIsRestrictedToGood(); i++) {
if(rec->GetIsRestrictedToGood(i) == good) {
return true;
}
}
return false;
}
}
Where there any other code problems with the CultureOnly, etc?
{removed}
Last edited by E on 02-05-2005 at 02:24
|
|
|  |
 |
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:29
|
|
Thanks for going easy on me. I updated all the stuff and attached here ( i did my wonder rec from what I saw in another file).
Everything else seemed straight forward.
Also I did install the C++for dummies CD and using its cpp program. It has a compiler too so as a warning I may be compiling soon.
{removed}
Last edited by E on 02-05-2005 at 02:25
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:29
|
|
quote: Originally posted by E
Thanks for going easy on me. I updated all the stuff and attached here ( i did my wonder rec from what I saw in another file). |
So far we aren't finished.
code:
// - Added a check in terrainutil_CanPlayerBuild for the GovernmentOnly flag
// to see if a tile improvement is limited to certain player
// governments - added by E March 12th 2005
Actual this should be something along whether the player has the right government or his government is matching to the record you find in tileimp.txt. And check the description of the terrainuti.cpp again there are two added with two following spaces.
code:
// Added GovernmentType flag from Units to use for Improvements
if(rec->GetNumGovernmentType() > 0) {
sint32 i;
bool found = false;
for(i = 0; i < rec->GetNumGovernmentType(); i++) {
if(rec->GetGovernmentTypeIndex(i) == g_player[pl]->m_government_type->GetGovernmentType()) {
found = true;
break;
}
}
if(!found)
return false;
}
m_government_type is a member of Player like GetGovernmentType(), so this doesn't compile. Actual you was supposed to replace all instances of m_government_type by GetGovernmentType() you have added in all the three files. This has the advantange that you cannot modify this variable by acciendent. And I can make all these members in the long run private.
The rest of terrainutil.cpp seems to be ok. So let's go to Player.cpp:
code:
// - CultureOnly code added to CanBuildUnit; checks the CultureOnly flag to a
// player's citystyle by E April 20th 2005
Nice that it checks it but what for?
code:
// Remark(s) : CultureOnly added by E; checks if player an unit have the
// same CityStyle in order to build
Is this English? And by the way remove the last four trailing tabs.
OK let's go to CityData.cpp
code:
// : Added PrerequisiteBuilding check to see if a cit has a building
// needed to build a unit.
A city without y.
code:
// Added by E - checks if a city has a building required to build the unit
if(rec->GetNumPrerequisiteBuilding() > 0) {
sint32 o;
for(o = 0; o < rec->GetNumPrerequisiteBuilding(); o++) {
sint32 b = rec->GetPrerequisiteBuildingIndex(o);
if(!(GetEffectiveBuildings() & ((uint64)1 << (uint64)b)))
return FALSE;
}
}
And some additional code fortunatly for you it compiles and it is correct, but please stop now adding anything else, before the rest is correct. Therefore I had again to check the *.cdb files, fortunately there where correct as well.
Well, the only thing you can do is to check the white space, there are two tabs replaced by spaces in.
And there again is a m_government_type instead of a GetGovernmentType()
code:
// Returns : Whether the city can build the building specified by type.
This line is wrong at least if your method is called CityData::CanBuildWonder
code:
// : GovernmentType flag for wonderss limits wonders to govt type.
wonders with an s too much. And the rest of the CityData::CanBuildWonder looks ok, except that there are again some spaces where tabs should be. And I rather tought of a more generic name than wrec, so that you can paste the piece of code more easily into other locations. But well there is no real need to change it now.
quote: Originally posted by E
Also I did install the C++for dummies CD and using its cpp program. It has a compiler too so as a warning I may be compiling soon. |
Maybe you should finish this project first and then commit it to the respiratory. So that you have a good code base. I hope you have a Microsoft compiler, as noone as far as I know has compiled it on anything else.
-Martin
|
|
|  |
 |
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:29
|
|
Thanks Martin,
Will do the stuff tonight (after I get the most recent update etc)
My compiler came with my C++ for dumies I think its Visual Basic 6.0 or something to that affect.
I'll also refresh the CanSettleOn issue but HasResource keeps bugging me that it has something to do with checking or assigning a resource(good) to a city and that it could be used to do a needsCityGood function...
code:
IN CITYDATA.CPP
BOOL CityData::HasResource(sint32 resource) const
{
return m_collectingResources[resource] > m_sellingResources[resource];
}
BOOL CityData::IsLocalResource(sint32 resource) const
{
return m_collectingResources[resource] > 0;
}
bool CityData::GetResourceTradeRoute(sint32 resource, TradeRoute & route) const
{
sint32 i;
for(i = 0; i < m_tradeSourceList.Num(); i++) {
ROUTE_TYPE type;
sint32 rr;
m_tradeSourceList[i].GetSourceResource(type, rr);
if(type != ROUTE_TYPE_RESOURCE) continue;
if(rr != resource) continue;
route = m_tradeSourceList[i];
return true;
}
return false;
}
bool CityData::IsSellingResourceTo(sint32 resource, Unit & destination) const
{
sint32 i;
for(i = 0; i < m_tradeSourceList.Num(); i++) {
ROUTE_TYPE type;
sint32 rr;
m_tradeSourceList[i].GetSourceResource(type, rr);
if(type != ROUTE_TYPE_RESOURCE) continue;
if(rr != resource) continue;
destination.m_id = m_tradeSourceList[i].GetDestination().m_id;
return true;
}
destination.m_id = 0;
return false;
}
and
code:
GOVERNOR.CPP
void Governor::ManageGoodsTradeRoutes()
{
Assert(g_player[m_playerId] != NULL);
Player *player_ptr = g_player[m_playerId];
sint32 cur_round = player_ptr->GetCurRound();
Unit city;
sint16 i,g,d;;
UnitDynamicArray *city_list = player_ptr->GetAllCitiesList();
double unused_freight = player_ptr->GetUnusedFreight();
double total_freight = player_ptr->GetTotalFreight();
GoodsRoute new_route;
GoodsRouteList new_routes;
m_neededFreight = 0.0;
for (i = 0; i < city_list->Num(); i++) {
city = city_list->Access(i);
for(g = 0; g < g_theResourceDB->NumRecords(); g++) {
if(city.CD()->IsLocalResource(g)) {
sint32 op;
Unit maxCity;
sint32 maxPrice = 0;
sint32 bestPrice = 0;
double maxCost = 0.0;
double maxNeededFreight = 0.0;
sint32 sellingPrice = -1;
TradeRoute curDestRoute;
if( city.CD()->HasResource(g) == FALSE &&
city.CD()->GetResourceTradeRoute(g, curDestRoute))
{
sellingPrice =
tradeutil_GetTradeValue(m_playerId, curDestRoute->GetDestination(), g);
}
else
{
curDestRoute.m_id = 0;
sellingPrice = -1;
}
for(op = 1; op < k_MAX_PLAYERS; op++) {
Last edited by E on 07-05-2005 at 03:29
|
|
|  |
 |
|  |
All times are GMT. The time now is 05:29. Apolyton Time is 00:29. |
top of page
|
|
|
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
|
|
|
|
|
|