 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:29
|
|
Ok, I think I got all of your editing...
code:
sint32 good;
if (g_theWorld->GetGood(pos, good)){
for(i = 0; i < rec->GetNumIsRestrictedToGood(); i++) {
if(rec->GetIsRestrictedToGood(i) == good) {
return false;
}
}
}
for(i = 0; i < rec->GetNumCantBuildOn(); i++) {
if(rec->GetCantBuildOnIndex(i) == cell->GetTerrain()) {
return false;
}
}
}
return true;
}
Last edited by E on 01-03-2005 at 04:07
|
|
|  |
 |
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:29
|
|
Ok, I'll give it a shot...
code:
//----------------------------------------------------------------------------
//
// Name : CanPlayerBuildAt
//
// Description: Checks terrain improvement properties to see if it can build on a tile only if it has a good
//
// Parameters : sint32 pl : Variable for player
// const MapPoint &pos : Variable for tile on map
// const TerrainImprovementRecord *rec :Varriable for improvement flag
// sint32 good : Variable for good
//
// Globals : g_theWorld : The game world properties
// g_player : Player properties
//
// Returns : BOOL : Returns TRUE if an improvement can be built on a tile
// FALSE if the improvement cannot
//
// Remark(s) : a new improvement attribute IsRestrictedToGood was added by E.
// Modders will define this in tileimp.txt as IsRestrictedToGood: X.
// The flag adds an additional option in order to restrict ceratin improvements to goods, adding new options and bonuses.
//
//
//----------------------------------------------------------------------------
bool terrainutil_CanPlayerBuildAt(const TerrainImprovementRecord *rec, sint32 pl, const MapPoint &pos)
{
sint32 i;
Assert(rec != NULL);
if(rec == NULL)
return false;
Assert(pl >= 0);
Assert(pl < k_MAX_PLAYERS);
if(pl < 0 || pl >= k_MAX_PLAYERS)
return false;
Assert(g_player[pl]);
if(!g_player[pl])
return false;
Cell *cell = g_theWorld->GetCell(pos);
Assert(cell);
if(!cell)
return false;
if(cell->GetOwner() == -1) {
if(rec->GetIntBorderRadius()) {
if(!g_player[pl]->IsVisible(pos)) {
return false;
}
} else {
return false;
}
}
if(cell->GetOwner() >= 0 && cell->GetOwner() != pl)
{
#if defined(ACTIVISION_ORIGINAL) // Non-standard syntax
bool haveAlliance = AgreementMatrix.s_agreements.HasAgreement(pl, cell->GetOwner(), PROPOSAL_TREATY_ALLIANCE);
#else
bool const haveAlliance =
AgreementMatrix::s_agreements.HasAgreement(pl, cell->GetOwner(), PROPOSAL_TREATY_ALLIANCE);
#endif
if(cell->GetOwner() > 0 && haveAlliance) {
if(rec->GetClassRoad() ||
(g_player[pl]->GetGaiaController() && g_player[pl]->GetGaiaController()->GaiaControllerTileImp(rec->GetIndex()))) {
} else {
return false;
}
} else {
return false;
}
}
if(g_theWorld->GetCity(pos).IsValid())
return false;
if(rec->GetClassTerraform()) {
sint32 terr;
if(!rec->GetTerraformTerrainIndex(terr))
return false;
if(cell->GetTerrain() == terr)
return false;
const TerrainRecord *tfrom = g_theTerrainDB->Get(cell->GetTerrain());
const TerrainRecord *tto = g_theTerrainDB->Get(terr);
if(tfrom->GetRemoveAdvanceIndex() < 0 || tto->GetAddAdvanceIndex() < 0)
return false;
if(!g_player[pl]->HasAdvance(tfrom->GetRemoveAdvanceIndex()) ||
!g_player[pl]->HasAdvance(tto->GetAddAdvanceIndex())) {
return false;
}
} else {
const TerrainImprovementRecord::Effect *eff;
eff = terrainutil_GetTerrainEffect(rec, cell->GetTerrain());
if(!eff)
return false;
if(!g_player[pl]->HasAdvance(eff->GetEnableAdvanceIndex()))
return false;
sint32 a;
for(a = 0; a < eff->GetNumObsoleteAdvance(); a++) {
if(g_player[pl]->HasAdvance(eff->GetObsoleteAdvanceIndex(a))) {
return false;
}
}
#if defined(ACTIVISION_ORIGINAL) // Non-standard syntax
for(i = 0; i < rec->GetNumCantBuildOn(); i++) {
if(rec->GetCantBuildOnIndex(i) == cell->GetTerrain()) {
return FALSE;
}
}
}
#else // Is restricted to code added by E 2-Mar-2005
for(i = 0; i < rec->GetNumCantBuildOn(); i++) {
if(rec->GetCantBuildOnIndex(i) == cell->GetTerrain()) {
return false;
}
}
}
sint32 good;
if (g_theWorld->GetGood(pos, good)){
for(i > 0; i < rec->GetNumIsRestrictedToGood(); i++) {
if(rec->GetIsRestrictedToGood(i) == good) {
return true;
} return false;
}
}
#endif
return true;
}
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:29
|
|
Ok, I in corporated your changes....
code:
//----------------------------------------------------------------------------
//
// Name : terrainutil_CanPlayerBuildAt
//
// Description: Checks terrain improvement properties to see if it can build on a tile only if it has a good
//
// Parameters : sint32 pl : Variable for player
// const MapPoint &pos : Variable for tile on map
// const TerrainImprovementRecord *rec :Varriable for improvement flag
// Globals : g_theWorld : The game world properties
// g_player : Player properties
//
// Returns : bool : Returns true if an improvement can be built on a tile
// false if the improvement cannot
//
// Remark(s) : A new improvement attribute IsRestrictedToGood was added by E.
// Modders will define this in tileimp.txt as IsRestrictedToGood: X.
// The flag adds an additional option in order to restrict ceratin improvements to goods, adding new options and bonuses.
//
//
//----------------------------------------------------------------------------
bool terrainutil_CanPlayerBuildAt(const TerrainImprovementRecord *rec, sint32 pl, const MapPoint &pos)
{
sint32 i;
Assert(rec != NULL);
if(rec == NULL)
return false;
Assert(pl >= 0);
Assert(pl < k_MAX_PLAYERS);
if(pl < 0 || pl >= k_MAX_PLAYERS)
return false;
Assert(g_player[pl]);
if(!g_player[pl])
return false;
Cell *cell = g_theWorld->GetCell(pos);
Assert(cell);
if(!cell)
return false;
if(cell->GetOwner() == -1) {
if(rec->GetIntBorderRadius()) {
if(!g_player[pl]->IsVisible(pos)) {
return false;
}
} else {
return false;
}
}
if(cell->GetOwner() >= 0 && cell->GetOwner() != pl)
{
#if defined(ACTIVISION_ORIGINAL)
bool haveAlliance = AgreementMatrix.s_agreements.HasAgreement(pl, cell->GetOwner(), PROPOSAL_TREATY_ALLIANCE);
#else
bool const haveAlliance =
AgreementMatrix::s_agreements.HasAgreement(pl, cell->GetOwner(), PROPOSAL_TREATY_ALLIANCE);
#endif
if(cell->GetOwner() > 0 && haveAlliance) {
if(rec->GetClassRoad() ||
(g_player[pl]->GetGaiaController() &&
g_player[pl]->GetGaiaController()->GaiaControllerTileImp(rec->GetIndex()))) {
} else {
return false;
}
} else {
return false;
}
}
if(g_theWorld->GetCity(pos).IsValid())
return false;
if(rec->GetClassTerraform()) {
sint32 terr;
if(!rec->GetTerraformTerrainIndex(terr))
return false;
if(cell->GetTerrain() == terr)
return false;
const TerrainRecord *tfrom = g_theTerrainDB->Get(cell->GetTerrain());
const TerrainRecord *tto = g_theTerrainDB->Get(terr);
if(tfrom->GetRemoveAdvanceIndex() < 0 || tto->GetAddAdvanceIndex() < 0)
return false;
if(!g_player[pl]->HasAdvance(tfrom->GetRemoveAdvanceIndex()) ||
!g_player[pl]->HasAdvance(tto->GetAddAdvanceIndex())) {
return false;
}
} else {
const TerrainImprovementRecord::Effect *eff;
eff = terrainutil_GetTerrainEffect(rec, cell->GetTerrain());
if(!eff)
return false;
if(!g_player[pl]->HasAdvance(eff->GetEnableAdvanceIndex()))
return false;
sint32 a;
for(a = 0; a < eff->GetNumObsoleteAdvance(); a++) {
if(g_player[pl]->HasAdvance(eff->GetObsoleteAdvanceIndex(a))) {
return false;
}
}
#if defined(ACTIVISION_ORIGINAL) // Non-standard syntax
for(i = 0; i < rec->GetNumCantBuildOn(); i++) {
if(rec->GetCantBuildOnIndex(i) == cell->GetTerrain()) {
return FALSE;
}
}
}
#else // Is restricted to code added by E 2-Mar-2005
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;
}
}
}
}
#endif
return true;
}
I think I got the BOLD part right. Not sure I understood the less than your looking for. Also I think I added an else like you said was needed...
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:29
|
|
code:
//----------------------------------------------------------------------------
//
// Name : terrainutil_CanPlayerBuildAt
//
// Description: Checks terrain improvement properties to see if it can build on a tile only if it has a good
//
// Parameters : sint32 pl : Variable for player
// const MapPoint &pos : Variable for tile on map
// const TerrainImprovementRecord *rec :Varriable for improvement flag
// Globals : g_theWorld : The game world properties
// g_player : Player properties
//
// Returns : bool : Returns true if an improvement can be built on a tile
// false if the improvement cannot
//
// Remark(s) : A new improvement attribute IsRestrictedToGood was added by E.
// Modders will define this in tileimp.txt as IsRestrictedToGood: X.
// The flag adds an additional option in order to restrict ceratin improvements to goods, adding new options and bonuses.
//
//
//----------------------------------------------------------------------------
bool terrainutil_CanPlayerBuildAt(const TerrainImprovementRecord *rec, sint32 pl, const MapPoint &pos)
{
sint32 i;
Assert(rec != NULL);
if(rec == NULL)
return false;
Assert(pl >= 0);
Assert(pl < k_MAX_PLAYERS);
if(pl < 0 || pl >= k_MAX_PLAYERS)
return false;
Assert(g_player[pl]);
if(!g_player[pl])
return false;
Cell *cell = g_theWorld->GetCell(pos);
Assert(cell);
if(!cell)
return false;
if(cell->GetOwner() == -1) {
if(rec->GetIntBorderRadius()) {
if(!g_player[pl]->IsVisible(pos)) {
return false;
}
} else {
return false;
}
}
if(cell->GetOwner() >= 0 && cell->GetOwner() != pl)
{
#if defined(ACTIVISION_ORIGINAL)
bool haveAlliance = AgreementMatrix.s_agreements.HasAgreement(pl, cell->GetOwner(), PROPOSAL_TREATY_ALLIANCE);
#else
bool const haveAlliance =
AgreementMatrix::s_agreements.HasAgreement(pl, cell->GetOwner(), PROPOSAL_TREATY_ALLIANCE);
#endif
if(cell->GetOwner() > 0 && haveAlliance) {
if(rec->GetClassRoad() ||
(g_player[pl]->GetGaiaController() &&
g_player[pl]->GetGaiaController()->GaiaControllerTileImp(rec->GetIndex()))) {
} else {
return false;
}
} else {
return false;
}
}
if(g_theWorld->GetCity(pos).IsValid())
return false;
if(rec->GetClassTerraform()) {
sint32 terr;
if(!rec->GetTerraformTerrainIndex(terr))
return false;
if(cell->GetTerrain() == terr)
return false;
const TerrainRecord *tfrom = g_theTerrainDB->Get(cell->GetTerrain());
const TerrainRecord *tto = g_theTerrainDB->Get(terr);
if(tfrom->GetRemoveAdvanceIndex() < 0 || tto->GetAddAdvanceIndex() < 0)
return false;
if(!g_player[pl]->HasAdvance(tfrom->GetRemoveAdvanceIndex()) ||
!g_player[pl]->HasAdvance(tto->GetAddAdvanceIndex())) {
return false;
}
} else {
const TerrainImprovementRecord::Effect *eff;
eff = terrainutil_GetTerrainEffect(rec, cell->GetTerrain());
if(!eff)
return false;
if(!g_player[pl]->HasAdvance(eff->GetEnableAdvanceIndex()))
return false;
sint32 a;
for(a = 0; a < eff->GetNumObsoleteAdvance(); a++) {
if(g_player[pl]->HasAdvance(eff->GetObsoleteAdvanceIndex(a))) {
return false;
}
}
#if defined(ACTIVISION_ORIGINAL)
for(i = 0; i < rec->GetNumCantBuildOn(); i++) {
if(rec->GetCantBuildOnIndex(i) == cell->GetTerrain()) {
return false;
}
}
}
#else // Is restricted to code added by E 2-Mar-2005
if(rec->IsRestrictedToGood){
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 = -1; i > rec->GetNumIsRestrictedToGood(); i++) {
if(rec->GetIsRestrictedToGood(i) == good) {
return true;
} return false;
}
}
}
#endif
return true;
}
I think where I'm confsed on your if-else statement is that I'm not clear if you are asking for a #if and #else or an if and else for the code. It just didn't come across if its a comment thing or a coding thing.
But I'm hoping I got you this time.
Last edited by E on 12-03-2005 at 01:25
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:29
|
|
code:
//----------------------------------------------------------------------------
//
// Name : terrainutil_CanPlayerBuildAt
//
// Description: Checks terrain improvement properties to see if it can build on a tile only if it has a good
//
// Parameters : sint32 pl : Variable for player
// const MapPoint &pos : Variable for tile on map
// const TerrainImprovementRecord *rec :Varriable for improvement flag
// Globals : g_theWorld : The game world properties
// g_player : Player properties
//
// Returns : bool : Returns true if an improvement can be built on a tile
// false if the improvement cannot
//
// Remark(s) : A new improvement attribute IsRestrictedToGood was added by E.
// Modders will define this in tileimp.txt as IsRestrictedToGood: X.
// The flag adds an additional option in order to restrict ceratin improvements to goods, adding new options and bonuses.
//
//
//----------------------------------------------------------------------------
bool terrainutil_CanPlayerBuildAt(const TerrainImprovementRecord *rec, sint32 pl, const MapPoint &pos)
{
sint32 i;
Assert(rec != NULL);
if(rec == NULL)
return false;
Assert(pl >= 0);
Assert(pl < k_MAX_PLAYERS);
if(pl < 0 || pl >= k_MAX_PLAYERS)
return false;
Assert(g_player[pl]);
if(!g_player[pl])
return false;
Cell *cell = g_theWorld->GetCell(pos);
Assert(cell);
if(!cell)
return false;
if(cell->GetOwner() == -1) {
if(rec->GetIntBorderRadius()) {
if(!g_player[pl]->IsVisible(pos)) {
return false;
}
} else {
return false;
}
}
if(cell->GetOwner() >= 0 && cell->GetOwner() != pl)
{
#if defined(ACTIVISION_ORIGINAL)
bool haveAlliance = AgreementMatrix.s_agreements.HasAgreement(pl, cell->GetOwner(), PROPOSAL_TREATY_ALLIANCE);
#else
bool const haveAlliance =
AgreementMatrix::s_agreements.HasAgreement(pl, cell->GetOwner(), PROPOSAL_TREATY_ALLIANCE);
#endif
if(cell->GetOwner() > 0 && haveAlliance) {
if(rec->GetClassRoad() ||
(g_player[pl]->GetGaiaController() &&
g_player[pl]->GetGaiaController()->GaiaControllerTileImp(rec->GetIndex()))) {
} else {
return false;
}
} else {
return false;
}
}
if(g_theWorld->GetCity(pos).IsValid())
return false;
if(rec->GetClassTerraform()) {
sint32 terr;
if(!rec->GetTerraformTerrainIndex(terr))
return false;
if(cell->GetTerrain() == terr)
return false;
const TerrainRecord *tfrom = g_theTerrainDB->Get(cell->GetTerrain());
const TerrainRecord *tto = g_theTerrainDB->Get(terr);
if(tfrom->GetRemoveAdvanceIndex() < 0 || tto->GetAddAdvanceIndex() < 0)
return false;
if(!g_player[pl]->HasAdvance(tfrom->GetRemoveAdvanceIndex()) ||
!g_player[pl]->HasAdvance(tto->GetAddAdvanceIndex())) {
return false;
}
} else {
const TerrainImprovementRecord::Effect *eff;
eff = terrainutil_GetTerrainEffect(rec, cell->GetTerrain());
if(!eff)
return false;
if(!g_player[pl]->HasAdvance(eff->GetEnableAdvanceIndex()))
return false;
sint32 a;
for(a = 0; a < eff->GetNumObsoleteAdvance(); a++) {
if(g_player[pl]->HasAdvance(eff->GetObsoleteAdvanceIndex(a))) {
return false;
}
}
#if defined(ACTIVISION_ORIGINAL)
for(i = 0; i < rec->GetNumCantBuildOn(); i++) {
if(rec->GetCantBuildOnIndex(i) == cell->GetTerrain()) {
return FALSE;
}
}
}
#else // Is restricted to code added by E 2-Mar-2005
if(rec->IsRestrictedToGood){
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 = 1; i > rec->GetNumIsRestrictedToGood(); i++) {
if(rec->GetIsRestrictedToGood(i) == good) {
return true;
} return false;
}
}
}
}
#endif
return true;
}
checking on the preprocesor stuff
Last edited by E on 12-03-2005 at 03:20
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:29
|
|
Taking another crack at this...
code:
//----------------------------------------------------------------------------
//
// Name : terrainutil_CanPlayerBuildAt
//
// Description: Checks terrain improvement properties to see if it can build on a tile only if it has a good
//
// Parameters : sint32 pl : Variable for player
// const MapPoint &pos : Variable for tile on map
// const TerrainImprovementRecord *rec :Varriable for improvement flag
// Globals : g_theWorld : The game world properties
// g_player : Player properties
//
// Returns : bool : Returns true if an improvement can be built on a tile
// false if the improvement cannot
//
// Remark(s) : A new improvement attribute IsRestrictedToGood was added by E.
// Modders will define this in tileimp.txt as IsRestrictedToGood: X.
// The flag adds an additional option in order to restrict ceratin improvements to goods, adding new options and bonuses.
//
//
//----------------------------------------------------------------------------
bool terrainutil_CanPlayerBuildAt(const TerrainImprovementRecord *rec, sint32 pl, const MapPoint &pos)
{
sint32 i;
Assert(rec != NULL);
if(rec == NULL)
return false;
Assert(pl >= 0);
Assert(pl < k_MAX_PLAYERS);
if(pl < 0 || pl >= k_MAX_PLAYERS)
return false;
Assert(g_player[pl]);
if(!g_player[pl])
return false;
Cell *cell = g_theWorld->GetCell(pos);
Assert(cell);
if(!cell)
return false;
if(cell->GetOwner() == -1) {
if(rec->GetIntBorderRadius()) {
if(!g_player[pl]->IsVisible(pos)) {
return false;
}
} else {
return false;
}
}
if(cell->GetOwner() >= 0 && cell->GetOwner() != pl)
{
#if defined(ACTIVISION_ORIGINAL)
bool haveAlliance = AgreementMatrix.s_agreements.HasAgreement(pl, cell->GetOwner(), PROPOSAL_TREATY_ALLIANCE);
#else
bool const haveAlliance =
AgreementMatrix::s_agreements.HasAgreement(pl, cell->GetOwner(), PROPOSAL_TREATY_ALLIANCE);
#endif
if(cell->GetOwner() > 0 && haveAlliance) {
if(rec->GetClassRoad() ||
(g_player[pl]->GetGaiaController() &&
g_player[pl]->GetGaiaController()->GaiaControllerTileImp(rec->GetIndex()))) {
} else {
return false;
}
} else {
return false;
}
}
if(g_theWorld->GetCity(pos).IsValid())
return false;
if(rec->GetClassTerraform()) {
sint32 terr;
if(!rec->GetTerraformTerrainIndex(terr))
return false;
if(cell->GetTerrain() == terr)
return false;
const TerrainRecord *tfrom = g_theTerrainDB->Get(cell->GetTerrain());
const TerrainRecord *tto = g_theTerrainDB->Get(terr);
if(tfrom->GetRemoveAdvanceIndex() < 0 || tto->GetAddAdvanceIndex() < 0)
return false;
if(!g_player[pl]->HasAdvance(tfrom->GetRemoveAdvanceIndex()) ||
!g_player[pl]->HasAdvance(tto->GetAddAdvanceIndex())) {
return false;
}
} else {
const TerrainImprovementRecord::Effect *eff;
eff = terrainutil_GetTerrainEffect(rec, cell->GetTerrain());
if(!eff)
return false;
if(!g_player[pl]->HasAdvance(eff->GetEnableAdvanceIndex()))
return false;
sint32 a;
for(a = 0; a < eff->GetNumObsoleteAdvance(); a++) {
if(g_player[pl]->HasAdvance(eff->GetObsoleteAdvanceIndex(a))) {
return false;
}
}
#if defined (ACTIVISION_ORIGINAL)
for(i = 0; i < rec->GetNumCantBuildOn(); i++) {
if(rec->GetCantBuildOnIndex(i) == cell->GetTerrain()) {
return FALSE;
}
}
#else // Is restricted to code added by E 2-Mar-2005
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;
}
}
}
#endif
return true;
}
I was going to put: if(rec->IsRestrictedToGood > 0) like in the culture code, but I re-read one of your lines that said if IsRestrictedToGood is 0 then it should execute the original. I'm not sure you intended me to put an '=' there to do it, butI put it out there to find out why its '=' or if it should be a '>' like the other code how does it execute the first code only?
Last edited by E on 16-03-2005 at 01:44
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:29
|
|
quote: Originally posted by E
I was going to put: if(rec->IsRestrictedToGood > 0) like in the culture code, but I re-read one of your lines that said if IsRestrictedToGood is 0 then it should execute the original. |
Actual I said something about the number of IsRestrictedToGood that's something else. I thought it is obviously in order to get the number of IsRestrictedToGood, to use the function that has the first syllable of number in its name.
quote: Originally posted by E
I'm not sure you intended me to put an '=' there to do it, butI put it out there to find out why its '=' or if it should be a '>' like the other code how does it execute the first code only? |
Actual I neither intended you to put an '=' nor a '>' but a '=='. First is an assignment the second is a bigger and the third is an equal.
The first operator assignes the value of the right variable to the left variable. Or in other words the value of the left variable becomes the value of the right variable.
Bigger is an operator that checks whether the right variable is bigger than the left variable. If it is the case it returns true otherwise false. And the third the equal checks whether the varaiables on both sides have (or contain) the same value(s).
The last two operators return a boolean value, true or false.
Since we have here an alternative, on the one hand the code that is present in the original and on the other hand the code code you wrote, we have to do a decission, between the codes.
Internally the IsRestrictedToGood items are stored in an array. So what happens if there is not a single IsRestrictedToGood defined. The answer is that array is empty and its size is therefore zero.
Now two the code:
First thing is that you changed the preprocessor derectives, as we want to replace here original code we have to go with the #if-#else-#endif derectives. As it was in the last version. Well you removed the closing brace that was too much inside the preprocessor blocks, but you didn't add it outside just above the final return.
Then the indention is not fixed.
Another thing I just notice is that the return false inside your code is at the wrong place. It is inside the for-loop but, it should be outside, just right below the for-loop. So move it down one line.
And you have to edit the description, especially you have to add some line breaks and replace the tabs by spaces. For the line breaks orientate you on the lines with the: ---- The text should not end to much behind the end of the ------.
-Martin
-Martin
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:29
|
|
OK let's start about the zip file: It contains a folder called Ctp2_code, if you unzip it on a Linux system you have a problem. A Unix file system is case sensitive and the consequence is Ctp2_code != ctp2_code. Well that doesn't matter when you submit it to the repository. Another thing I wonder about is why in the archive are two copies of each *.cdb, same file, same directory, same size.
unit.cdb seems to be ok, but why is SettleImprovement outcommented. However if it wouldn't be outcommented then there would be a problem, a unit could only settle one definite type of improvement, or do you want to add some random effects? Otherwise the is no sense to make it an array. By the EnableAdvance isn't an array, either.
terrimprove.cbd is not OK.
Let's start with the harmless stuff. If you add Wonder and Urban to Class you should also add it to Excludes. You don't know what modders want to do.
What's that:
quote:
Record Resource[0] PlantGood //added by E for future imp that places a good instead
Record Resource[1] PlantGood //added by E for future imp that places a good instead
Record Resource[2] PlantGood //added by E for future imp that places a good instead
Record Resource[3] PlantGood //added by E for future imp that places a good instead
Record Resource[4] PlantGood //added by E for future imp that places a good instead
|
I thought you wanted to use an integer, that can have the values 0-3 indicating the index in the according terrain database array.
That are are Resource database record and this array notation is probably invalid syntax.
Then what do you want to do here? Do you want to allow a maximum of four goods to that a tileimp can be restricted to? Why not all goods in the database?
quote:
Record Resource[0..4] IsRestrictedToGood //added by E -- can only build imps if tile has good
|
wonder.cdb is ok.
advance.cdb seems to be compilable. However CantTrade and CantCapture suggests that normally advances can trade. This is of course wrong they should be CantBeTraded and CantBeCaptured.
And Bridges is at the wrong place it, belongs into the tileimp.txt and should be something like BridgeAdvance, like EnablingAdvance. Probably mot every modder likes it that you need the same advance for building bridges on grassland and for building bridges in the swamp. 
Now to the source files. But only in brief for today.
wonder_util.cpp
Spend the description of wonderutil_IsAvailable a conluding new free line. So that it looks better. The description what you have done at the start of the file is missing.
The code for CityStyleOnly should be modelled like the one above for GovernmentType, otherwise the CityStyleOnly precedes CultureOnly only.
m_government_type is not a member of wonderutil, it isn't possible wonderutil isn't a class. And there aren't global, either. The same holds for m_founder and GetCivilisation.
terrainutil.cpp isn't correct either, check the description at the top of the file, check the description of the function you have modified. Get the indention right, and insert at the right place a closing brace, you have erased in the meantime.
So that must be enough for today. It is late and I should go to bed. 
-Martin
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:29
|
|
OK, let's see and have a look on the *.cdb files:
advace.cdb is OK.
building.cdb is OK.
wonder.cdb is OK.
government.cdb is OK.
Now to the problematic files:
terrimprove.cdb:
code:
Struct Effect {
Record Terrain[] Terrain
Bit(Int) BonusFood
Bit(Int) BonusProduction
Bit(Int) BonusGold
Bit(Int) MoveCost
#Added by Martin Gühmann for Trade redirection
Bit(Int) Freight
Bit Radar
Bit CantPillage //futureUse added by E to prevent pillage of certain imps
Bit NeedsWorker //futureUse - can't build unless IsWorker unit is on square
Bit NeedsWaterSupply //futureUse -- can only build on rivers or adjacent to other IsWaterSupply imps
Bit Airport
Bit ListeningPost
Bit Endgame
Bit(Int) VisionRange
Bit(Int) RadarRange
Bit(Float) DefenseBonus
Record Resource[] PlantGood //added by E for future imp that places a good instead
Record Advance EnableAdvance
Record Advance[] ObsoleteAdvance
Int ProductionCost
Int ProductionTime
Int TilesetIndex
}
Now to the problematic line:
code:
Record Resource[] PlantGood //added by E for future imp
How many goods do you want to plant on a certain spot. 1, 2, 20, all you can find in the database? I guess this is a little bit utopic. A spot can only contain only one good, so it must not be an array.
Second problem, what happens if you specify a good that you can't plant on the spot. Should the game crash? Or should nothing happen, should the resources spent for the tileimp be wasted? Of course neither should the game crash nor should the PW wasted.
So again PlantGood should be an integer and not a database entry in the good database, nor should be an array in of entries in the good database. It should be just a plain integer like ProductionCost, ProductionTime or TilesetIndex. But in comparision to those it should be optional like BonusFood, BonusProduction or BonusGold.
It should now be obvious how this line should look. 
To the next wrong line in this file:
code:
Record Sound Sound
Record Terrain[] CantBuildOn
Record Government[] GovernmentsModified
Record CityStyle[] CultureOnly //added by E -- can only build imps if civ has certain citystyle
Record Government[] GovernmentType //added by E --- a copy of unit Government type code
Record Resource[0..4] IsRestrictedToGood //added by E -- can only build imps if tile has good
Bit(Struct Effect) Effect
Struct Effect[] TerrainEffect
The line in particular:
code:
Record Resource[0..4] IsRestrictedToGood //added by E -- can only build imps if tile has good
Come on you don't want to restrict the maximum number of goods to that a terrain improvement can be restricted to four. It should be a free array like GovernmentType, CultureOnly or CantBuildOn.
Now let's come to unit.cdb:
code:
Record Advance EnableAdvance
Record Advance[0..5] ObsoleteAdvance
Record Government[] GovernmentsModified
Record Unit[] UpgradeTo //FutureUse to create Upgrade Paths, cost based on difference ShieldCost x Gold?
Record Terrain[] CanSettleOn //added by E restricts settling to certain terrains
Record CityStyle[] CultureOnly //added by E -- can only build units if civ has certain citystyle
Record CityStyle[] CityStyleOnly //added by E--can only build units at cities with certain citystyle
Record TerrainImprovement[] SettleImprovement // future use - for units to make specific imps like forts
The first line that is wrong is:
code:
Record Unit[] UpgradeTo //FutureUse to create Upgrade Paths, cost based on difference ShieldCost x Gold?
UpgradeTo is an array, but you cannot upgrade one unit to one unit type on the one hand and to another different unit type at the same time. For instance a unit can't be a settler and a diplomat at the same time. That's impossible. However you rethink it yourself anyways. But again this is a single unit record like EnableAdvance is a single advance record. And therefore it isn't an array, either.
Well wether SettleImprovement should be an array of records or an single record is a design issure.
The following flag name is missleading:
code:
Bit(Int) CostPopToBuild //added for future use
It reminds me of BuildingRemovesAPop, probably a better name would be PopCostsToBuild, maybe PopCosts is enough to make it clear.
That was the *.cdb part.
In Player.cpp, the function Player::CanBuildUnit is not correct, you forgot to remove the first ACTIVISION_ORIGINAL right at the start of the function, it even hasn't a coresponding matching #endif.
CityData.cpp:
code:
//----------------------------------------------------------------------------
//
// Name : CityData::CanBuildBuilding
//
// Description: Checks whether the city can build the building specified by
// type.
//
// Parameters : type: The building type for that is checked whether the city
// can build it.
//
// Globals : g_player: The list of players
// g_theBuildingDB: The building database
// g_slicEngine: The slic engine
// g_theWorld: The world prperties
//
// Returns : Whether the city can build the building specified by type.
//
// Remark(s) : CityStyleOnly added by E. Limits certain buildings to be built
// only at certain cities of certain styles.
// GovernmentType flag for Buidings limits Buildings to govt type.
// CultureOnly flag added by E. It allows only civilizations with
// the same CityStyle as CultureOnly's style to build that building.
//----------------------------------------------------------------------------
BOOL CityData::CanBuildBuilding(sint32 type) const
{
if(g_exclusions->IsBuildingExcluded(type))
return FALSE;
const BuildingRecord* irec = g_theBuildingDB->Get(type);
Assert(irec != NULL);
if (!irec)
return FALSE;
if(!g_player[m_owner]->HasAdvance(irec->GetEnableAdvanceIndex()) && irec->GetEnableAdvanceIndex() >= 0) {
return FALSE;
}
sint32 o;
for(o = 0; o < irec->GetNumObsoleteAdvance(); o++) {
if(g_player[m_owner]->HasAdvance(irec->GetObsoleteAdvanceIndex(o)))
return FALSE;
}
MapPoint pos;
m_home_city.GetPos(pos);
if(g_theWorld->IsWater(pos)) {
if(irec->GetCantBuildInSea())
return FALSE;
} else {
if(irec->GetCantBuildOnLand())
return FALSE;
}
if (irec->GetCoastalBuilding()) {
if(!g_theWorld->IsNextToWater(pos.x, pos.y))
return FALSE;
}
if(m_built_improvements & uint64((uint64)1 << (uint64)type)) {
return FALSE;
}
if((irec->GetNuclearPlant() &&
wonderutil_GetNukesEliminated(g_theWonderTracker->GetBuiltWonders()))) {
return FALSE;
}
if(irec->GetNumPrerequisiteBuilding() > 0) {
for(o = 0; o < irec->GetNumPrerequisiteBuilding(); o++) {
sint32 b = irec->GetPrerequisiteBuildingIndex(o);
if(!(GetEffectiveBuildings() & ((uint64)1 << (uint64)b)))
return FALSE;
}
}
#if !defined(ACTIVISION_ORIGINAL)
if(irec->GetNumGovernmentType() > 0) {
sint32 i;
bool found = false;
for(i = 0; i < irec->GetNumGovernmentType(); i++) {
if(irec->GetGovernmentTypeIndex(i) == m_government_type) {
found = true;
break;
}
}
if(!found)
return FALSE;
}
if(irec->GetNumCityStyleOnly() > 0) {
sint32 s;
for(s = 0; s < irec->GetNumCityStyleOnly(); s++) {
if(irec->GetCityStyleOnlyIndex(s) == g_player[m_founder]->m_citystyle) {
return TRUE;
}
}
return FALSE
}
if(irec->GetNumCultureOnly() > 0) {
sint32 s;
for(s = 0; s < irec->GetNumCultureOnly(); s++) {
if(irec->GetCultureOnlyIndex(s) == GetCivilisation()->GetCityStyle()) {
return TRUE;
}
}
return FALSE;
}
#endif
return g_slicEngine->CallMod(mod_CanCityBuildBuilding, TRUE, m_home_city.m_id, irec->GetIndex());
}
In this function we have a typo in the description of the function. In the line of the g_theWorld. Just because I saw it and "prperties" is also one of my favourites. And so I realize that it is actual my typo. But fix it anyway. Now to the more important stuff.
The code about CityStyleOnly should be modelled like the one for GovernmentType.
Again m_government_type is a member of player. So you need the accoring function of the Player class. The same hold for GetCivilisation. The according player is the owner of the city. And for the CityStyleOnly part you have to compare it against the city style of the city not against the city style of the founder. The city style of the city itsself can be changed by the cheat editor. The same is true for the code in the CanBuildUnit code and there as well the code should be modelled like the code of GovernmentType.
Well that isn't everthing, but for today it is enough. 
-Martin
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:29
|
|
Martin, I checked out the *.h files for citydata and player and found the m_citystyle (in citydata.h) and m_civilization (in player.h). Now that I can find where to get the m_ stuff do you have an example for it so I know what it should look like or is the government type a good enough example?
also would it be something like g_CivilizationData to use these classes in CivilzationData.h:
code:
//----------------------------------------------------------------------------
// Class declarations
//----------------------------------------------------------------------------
#endif // _MSC_VER
class CivilisationData : public GAMEOBJ
{
public:
PLAYER_INDEX m_owner ;
uint8 m_cityname_count[k_MAX_CITY_NAMES] ;
CIV_INDEX m_civ ;
GENDER m_gender;
sint32 m_cityStyle;
MBCHAR m_leader_name[k_MAX_NAME_LEN],
m_personality_description[k_MAX_NAME_LEN],
m_civilisation_name[k_MAX_NAME_LEN],
m_country_name[k_MAX_NAME_LEN],
m_singular_name[k_MAX_NAME_LEN] ;
I'm mainly interested in m_civilisation_name and m_citystyle
Last edited by E on 08-04-2005 at 04:24
|
|
|  |
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
|
|
|
|
|
|