 |
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:32
|
|
ShowOnMap is my next endeavor but if this code is simlar to my Good and CanSettle On code I may knock this out.
The concept is to add a flag CivOnly and a separate flag CultureOnly for use by modders to make units, advances, buildings, tileimps, and wonders only availble to certain civs. this would reduce the burden of making unique civ advance trees or grantadvance slic. Slic is great but time should be devoted to bigger things I think and this could make it easy for some sceanrios like WW2.
If your wonder CultureOnly will be like CivOnly except it will check for CityStyle instead of civ name.
I think the Civ only might use this code:
code:
sint32 name;
sint32 n;
if (g_theCivilisationDB->GetCivilisation(name)){
for(n = 0; n < rec->GetCivOnly(); i++) {
if(rec->GetGetCivOnly(n) == name) {
return true;
}
}
}
cultureroup
code:
sint32 style;
sint32 s;
if (g_theCivilisationDB->GetCityStyle(style)){
for(n = 0; n < rec->GetCultureOnly(); i++) {
if(rec->GetCultureOnly(c) == name) {
return true;
}
}
}
Last edited by E on 03-03-2005 at 09:35
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:32
|
|
For units I believe I'll add it in
BOOL Player::CanBuildUnit(const sint32 type) const
Last edited by E on 12-03-2005 at 04:29
|
|
|  |
 |
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:32
|
|
first shot...
code:
BOOL Player::CanBuildUnit(const sint32 type) const
{
const UnitRecord *rec = g_theUnitDB->Get(type);
if (!HasAdvance(rec->GetEnableAdvanceIndex()))
return FALSE;
sint32 o;
for(o = rec->GetNumObsoleteAdvance() - 1; o >= 0; o--) {
if(HasAdvance(rec->GetObsoleteAdvanceIndex(o)))
return FALSE;
}
if(g_exclusions->IsUnitExcluded(type))
return FALSE;
if(rec->GetCantBuild()) {
return FALSE;
}
if(rec->GetNumGovernmentType() > 0) {
sint32 i;
bool found = false;
for(i = 0; i < rec->GetNumGovernmentType(); i++) {
if(rec->GetGovernmentTypeIndex(i) == m_government_type) {
found = true;
break;
}
}
if(!found)
return FALSE;
}
if(rec->GetNumCultureOnly() > 0)
sint32 s;
for(s = 0; s < rec->GetCultureOnly(); s++) {
if(rec->GetNumCultureOnly(s) == g_player->GetCivilisation()->GetCityStyle()) {
return TRUE;
}
}return FALSE;
}
if(rec->GetNuclearAttack() &&
wonderutil_GetNukesEliminated(g_theWonderTracker->GetBuiltWonders())) {
return FALSE;
}
if(rec->GetSlaveRaids() || rec->GetSettlerSlaveRaids() ||
rec->GetSlaveUprising()) {
if(wonderutil_GetFreeSlaves(g_theWonderTracker->GetBuiltWonders())) {
return FALSE;
}
}
if(rec->GetSlaveRaids() || rec->GetSettlerSlaveRaids()) {
sint32 i, n = m_all_units->Num();
for(i = 0; i < n; i++) {
if(m_all_units->Access(i).GetDBRec()->GetNoSlaves())
return FALSE;
}
}
if(rec->GetNoSlaves()) {
sint32 i, n = m_all_cities->Num();
for(i = 0; i < n; i++) {
if(m_all_cities->Access(i).CountSlaves() > 0)
return FALSE;
}
n = g_player[m_owner]->m_all_units->Num();
for(i = 0; i < n; i++) {
if(m_all_units->Access(i).GetDBRec()->GetSlaveRaids())
return FALSE;
}
}
if(rec->GetCreateParks() &&
!wonderutil_GetParkRangersEnabled(g_theWonderTrack
er->GetBuiltWonders())) {
return FALSE;
}
return TRUE;
}
Last edited by E on 12-03-2005 at 04:05
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:32
|
|
I just figured out that you put it into the wrong function. In this function the Player::CanBuildUnit method belongs the part about the civilisation.
And into the following function the culture part goes:
code:
//----------------------------------------------------------------------------
//
// Name : CityData::CanBuildUnit
//
// Description: Checks whether the city can build the unit specified by type.
//
// Parameters : type: The unit type for that is checked whether the city can
// build it.
//
// Globals : g_player: The list of players
// g_theUnitDB: The unit database
// g_slicEngine: The slic engine
// g_theWorld: The world prperties
//
// Returns : Whether the city can build the unit specified by type.
//
// Remark(s) : -
//
//----------------------------------------------------------------------------
BOOL CityData::CanBuildUnit(sint32 type) const
{
#if defined(ACTCIVSION_ORIGINAL)
// Removed by Martin Gühmann same code in Player::CanBuildUnit
const UnitRecord *rec = g_theUnitDB->Get(type);
if(!rec)
return FALSE;
MapPoint pos;
m_home_city.GetPos(pos);
if (!g_player[m_owner]->HasAdvance(rec->GetEnableAdvanceIndex()))
return FALSE;
sint32 o;
for(o = rec->GetNumObsoleteAdvance() - 1; o >= 0; o--) {
if(g_player[m_owner]->HasAdvance(rec->GetObsoleteAdvanceIndex(o)))
return FALSE;
}
if(g_exclusions->IsUnitExcluded(type))
return FALSE;
if(rec->GetCantBuild()) {
return FALSE;
}
if(rec->GetNumGovernmentType() > 0) {
sint32 i;
bool found = false;
for(i = 0; i < rec->GetNumGovernmentType(); i++) {
if(rec->GetGovernmentTypeIndex(i) == g_player[m_owner]->m_government_type) {
found = true;
break;
}
}
if(!found)
return FALSE;
}
if(rec->GetNuclearAttack() &&
wonderutil_GetNukesEliminated(g_theWonderTracker->GetBuiltWonders())) {
return FALSE;
}
if(rec->GetSlaveRaids() || rec->GetSettlerSlaveRaids() ||
rec->GetSlaveUprising()) {
if(wonderutil_GetFreeSlaves(g_theWonderTracker->GetBuiltWonders())) {
return FALSE;
}
}
if(rec->GetSlaveRaids() || rec->GetSettlerSlaveRaids()) {
sint32 i, n = g_player[m_owner]->m_all_units->Num();
for(i = 0; i < n; i++) {
if(g_player[m_owner]->m_all_units->Access(i).GetDBRec()->GetNoSlaves())
return FALSE;
}
}
if(rec->GetNoSlaves()) {
sint32 i, n = g_player[m_owner]->m_all_cities->Num();
for(i = 0; i < n; i++) {
if(g_player[m_owner]->m_all_cities->Access(i).CD()->SlaveCount() > 0)
return FALSE;
}
n = g_player[m_owner]->m_all_units->Num();
for(i = 0; i < n; i++) {
if(g_player[m_owner]->m_all_units->Access(i).GetDBRec()->GetSlaveRaids())
return FALSE;
}
}
if(rec->GetCreateParks() &&
!wonderutil_GetParkRangersEnabled(g_theWonderTrack
er->GetBuiltWonders())) {
return FALSE;
}
#else
// Added by Martin Gühmann
if(!g_player[m_owner]->CanBuildUnit(type))
return FALSE;
const UnitRecord *rec = g_theUnitDB->Get(type);
if(!rec)
return FALSE;
MapPoint pos;
m_home_city.GetPos(pos);
#endif
if(!g_slicEngine->CallMod(mod_CanCityBuildUnit, TRUE, m_home_city.m_id, rec->GetIndex()))
return FALSE;
if(!rec->GetMovementTypeLand() && !rec->GetMovementTypeTrade() && !rec->GetIsTrader()) {
if(g_theWorld->IsWater(pos.x, pos.y) && rec->GetSeaCityCanBuild()) {
return TRUE;
}
if((g_theWorld->IsLand(pos.x, pos.y) ||
g_theWorld->IsMountain(pos.x, pos.y)) &&
rec->GetLandCityCanBuild()) {
return TRUE;
}
if(rec->GetMovementTypeSea() || rec->GetMovementTypeShallowWater()) {
if(g_theWorld->IsNextToWater(pos.x, pos.y)) {
return TRUE;
}
return FALSE;
} else if(rec->GetMovementTypeAir()) {
return TRUE;
}
return FALSE;
}
return TRUE;
}
If it is CityStyle dependent then I expect that cities with different styles behave different, irrespecteive of the current owner, otherwise you would just need the civ only flag.
However the culture stuff should be checked first so at the end of my added-block. It should return FALSE if there was no culture match and it should execute the rest of the code if there was a culture match. And of course you check it against the sytle of the city and not against the style of the owner.
-Martin
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:32
|
|
I keep seeing the code this stuff to ID the civilization, I'm unclear why these won't work...
(g_theCivilisationDB->GetCivilisation())
(g_theStringDB->GetNameStr(str_id),
Also I really like the CityData CityStyle Idea, but I think I'll make that into CityStyleOnly and keep CultureOnly for units that match the player's citystyle to allow for culture group units (native American, european, etc) its easier than listing all the civs out, and we haven't figured out CivOnly yet...
I'll finish the other stuff this weekend...
Last edited by E on 13-03-2005 at 06:06
|
|
|  |
 |
|
tombom
|
|
Pining for the fjords
Oct 2004 time: 05:32
|
|
quote: Originally posted by E
I put the else because i "think" thats whats need to continue with the code. I also added the != because that sounds like what you said I should do to make it return false
|
Else is not needed unless you want to make something happen if the condition in the if is false. So something like this:
code:
if(a == 1) {
a = a +1;
}
else {
a = a + 2
}
So the else there is not needed.
The != part I *think* is right, I don't really know though.
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:32
|
|
quote: Originally posted by E
Also the CityData.cpp I have is dated 12/6/2004, the last time I saw it was in the all pack you released in december, is there a later one (this one doesn't have your changes). |
Yes, on my hard drive , or why should I provide you with a modified version of CityData::CanBuildUnit method?
For the discription: The best is you look at the discription I made for CityData::CanBuildUnit and copy the relevant parts and modify it so that it fits. Then you see that the name of the function is Player::CanBuildUnit and not just CanBuildUnit. This name is ambigious, we see here at least two functions with this name. Then the parameter of this function isn't called s, and it is not for city styles. The return discription is wrong. And the remark doesn't tell me that you added this specific feature we are discussing here.
Well for brevity and to avoid duplicated work, here is the discription of the function Player::CanBuildUnit:
code:
//----------------------------------------------------------------------------
//
// Name : Player::CanBuildUnit
//
// Description: Checks whether the city can build the unit specified by type.
//
// Parameters : type: The unit type for that is checked whether the player can
// build it.
//
// Globals : g_player: The list of players
// g_theUnitDB: The unit database
// g_theWonderTracker: The wonder tracker
// g_exclusions: The exclusions data
//
// Returns : Whether the city can build the unit specified by type.
//
// Remark(s) : -
//
//----------------------------------------------------------------------------
All you have to do now is to write something that makes sense into the Remark(s).
Now let's come to the code:
code:
#if defined(ACTIVISION_ORIGINAL)
if(rec->GetCreateParks() &&
!wonderutil_GetParkRangersEnabled(g_theWonderTrack
er->GetBuiltWonders())) {
return FALSE;
}
#else
if(rec->GetCreateParks() &&
!wonderutil_GetParkRangersEnabled(g_theWonderTrack
er->GetBuiltWonders())) {
return FALSE;
}
if(rec->GetNumCultureOnly() > 0) {
sint32 s;
for(s = 0; s < rec->GetCultureOnly(); s++) {
if(rec->GetNumCultureOnly(s) == g_player->GetCivilisation()->GetCityStyle()) {
return TRUE;
}
}return FALSE;
}
#endif
Why do you copy the code about the EcoRangers? First you have it in the #if defined(ACTIVISION_ORIGINAL) block and then you have it in the #else without any changes. That's superflous. defined(ACTIVISION_ORIGINAL) is a boolean expression and if you want to negate it then you use in c++ the exclamation mark operator, that holds for preprocessor derectives as well. And please give the return FALSE; inside your code its own line.
Then you exchanged GetCultureOnly and GetNumCultureOnly and actual it should be GetCultureOnlyIndex instead of GetCultureOnly. That is is also true for the CityStyleOnly code and was also the case in the code fragment you posted last time.
Otherwise it looks ok.
quote: Originally posted by E
I put the else because i "think" thats whats need to continue with the code. |
Tombom is right about this, it doesn't belong to that place.
quote: Originally posted by E
I also added the != because that sounds like what you said I should do to make it return false |
And that's wrong either. This returns FALSE in most cases, even if it shouldn't.
quote: Originally posted by E
the italics stuff is stuff after the array. My gut tells me to take it out since the m_citystyle I think is an array for a city's citystyle and it will just check that... |
m_citystyle is a member of CityData and that is not an array that is a long, so a simple number. The best is you take a close look on the GovernmentType code and do some copy and paste actions.
-Martin
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:32
|
|
For Culture Only...
As a warning I'm looking to add my code to the advances, buildings, tileimprovements, and wonders as well (and I don't think it will require a change in my coding).
code:
//----------------------------------------------------------------------------
//
// Name : Player::CanBuildUnit
//
// Description: Checks whether the city can build the unit specified by type.
//
// Parameters : type: The unit type for that is checked whether the player can
// build it.
//
// Globals : g_player: The list of players
// g_theUnitDB: The unit database
// g_theWonderTracker: The wonder tracker
// g_exclusions: The exclusions data
//
// Returns : Whether the city can build the unit specified by type.
//
// Remark(s) : CultureOnly flag added by E. It allows only civilizations with
// the same CityStyle as CultureOnly's style to build that unit
//
//----------------------------------------------------------------------------
BOOL Player::CanBuildUnit(const sint32 type) const
{
#if defined(ACTIVISION_ORIGINAL)
const UnitRecord *rec = g_theUnitDB->Get(type);
if (!HasAdvance(rec->GetEnableAdvanceIndex()))
return FALSE;
sint32 o;
for(o = rec->GetNumObsoleteAdvance() - 1; o >= 0; o--) {
if(HasAdvance(rec->GetObsoleteAdvanceIndex(o)))
return FALSE;
}
if(g_exclusions->IsUnitExcluded(type))
return FALSE;
if(rec->GetCantBuild()) {
return FALSE;
}
if(rec->GetNumGovernmentType() > 0) {
sint32 i;
bool found = false;
for(i = 0; i < rec->GetNumGovernmentType(); i++) {
if(rec->GetGovernmentTypeIndex(i) == m_government_type) {
found = true;
break;
}
}
if(!found)
return FALSE;
}
if(rec->GetNuclearAttack() &&
wonderutil_GetNukesEliminated(g_theWonderTracker->GetBuiltWonders())) {
return FALSE;
}
if(rec->GetSlaveRaids() || rec->GetSettlerSlaveRaids() ||
rec->GetSlaveUprising()) {
if(wonderutil_GetFreeSlaves(g_theWonderTracker->GetBuiltWonders())) {
return FALSE;
}
}
if(rec->GetSlaveRaids() || rec->GetSettlerSlaveRaids()) {
sint32 i, n = m_all_units->Num();
for(i = 0; i < n; i++) {
if(m_all_units->Access(i).GetDBRec()->GetNoSlaves())
return FALSE;
}
}
if(rec->GetNoSlaves()) {
sint32 i, n = m_all_cities->Num();
for(i = 0; i < n; i++) {
if(m_all_cities->Access(i).CountSlaves() > 0)
return FALSE;
}
n = g_player[m_owner]->m_all_units->Num();
for(i = 0; i < n; i++) {
if(m_all_units->Access(i).GetDBRec()->GetSlaveRaids())
return FALSE;
}
}
if(rec->GetCreateParks() &&
!wonderutil_GetParkRangersEnabled(g_theWonderTrack
er->GetBuiltWonders())) {
return FALSE;
}
#else
if(rec->GetNumCultureOnly() > 0) {
sint32 s;
for(s = 0; s < rec->GetNumCultureOnly(); s++) {
if(rec->GetCultureOnlyIndex(s) == GetCivilisation()->GetCityStyle()) {
return TRUE;
}
}
return FALSE;
}
#endif
return TRUE;
}
Last edited by E on 14-03-2005 at 21:57
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:32
|
|
For CityStyleOnly...
I added it to the code you posted and since its only on your hard I figured I'd add it into the standard too (to prevent you from adding back your changes)...
Also I used m_founder instead of m_owner that I found in your code to remember a city's citystyle (a nice add on by the way). I hoping this is the right way to check the city's style as opposed to the current owner's style.
code:
//----------------------------------------------------------------------------
//
// Name : CityData::CanBuildUnit
//
// Description: Checks whether the city can build the unit specified by type.
//
// Parameters : type: The unit type for that is checked whether the city can
// build it.
//
// Globals : g_player: The list of players
// g_theUnitDB: The unit database
// g_slicEngine: The slic engine
// g_theWorld: The world prperties
//
// Returns : Whether the city can build the unit specified by type.
//
// Remark(s) : CityStyleOnly added by E. Limits certain units to be built only
// at certain cities of certain styles.
//
//----------------------------------------------------------------------------
BOOL CityData::CanBuildUnit(sint32 type) const
{
#if defined(ACTCIVSION_ORIGINAL)
// Removed by Martin Gühmann same code in Player::CanBuildUnit
const UnitRecord *rec = g_theUnitDB->Get(type);
if(!rec)
return FALSE;
MapPoint pos;
m_home_city.GetPos(pos);
if (!g_player[m_owner]->HasAdvance(rec->GetEnableAdvanceIndex()))
return FALSE;
sint32 o;
for(o = rec->GetNumObsoleteAdvance() - 1; o >= 0; o--) {
if(g_player[m_owner]->HasAdvance(rec->GetObsoleteAdvanceIndex(o)))
return FALSE;
}
if(g_exclusions->IsUnitExcluded(type))
return FALSE;
if(rec->GetCantBuild()) {
return FALSE;
}
if(rec->GetNumGovernmentType() > 0) {
sint32 i;
bool found = false;
for(i = 0; i < rec->GetNumGovernmentType(); i++) {
if(rec->GetGovernmentTypeIndex(i) == g_player[m_owner]->m_government_type) {
found = true;
break;
}
}
if(!found)
return FALSE;
}
if(rec->GetNuclearAttack() &&
wonderutil_GetNukesEliminated(g_theWonderTracker->GetBuiltWonders())) {
return FALSE;
}
if(rec->GetSlaveRaids() || rec->GetSettlerSlaveRaids() ||
rec->GetSlaveUprising()) {
if(wonderutil_GetFreeSlaves(g_theWonderTracker->GetBuiltWonders())) {
return FALSE;
}
}
if(rec->GetSlaveRaids() || rec->GetSettlerSlaveRaids()) {
sint32 i, n = g_player[m_owner]->m_all_units->Num();
for(i = 0; i < n; i++) {
if(g_player[m_owner]->m_all_units->Access(i).GetDBRec()->GetNoSlaves())
return FALSE;
}
}
if(rec->GetNoSlaves()) {
sint32 i, n = g_player[m_owner]->m_all_cities->Num();
for(i = 0; i < n; i++) {
if(g_player[m_owner]->m_all_cities->Access(i).CD()->SlaveCount() > 0)
return FALSE;
}
n = g_player[m_owner]->m_all_units->Num();
for(i = 0; i < n; i++) {
if(g_player[m_owner]->m_all_units->Access(i).GetDBRec()->GetSlaveRaids())
return FALSE;
}
}
if(rec->GetCreateParks() &&
!wonderutil_GetParkRangersEnabled(g_theWonderTrack
er->GetBuiltWonders())) {
return FALSE;
}
#else
// Added by Martin Gühmann
if(!g_player[m_owner]->CanBuildUnit(type))
return FALSE;
const UnitRecord *rec = g_theUnitDB->Get(type);
if(!rec)
return FALSE;
MapPoint pos;
m_home_city.GetPos(pos);
// Added by E
if(rec->GetNumCityStyleOnly() > 0) {
sint32 s;
for(s = 0; s < rec->GetNumCityStyleOnly(); s++) {
if(rec->GetCityStyleOnlyIndex(s) == g_player[m_founder]->m_citystyle) {
return TRUE;
}
}
return FALSE
}
#endif
if(!g_slicEngine->CallMod(mod_CanCityBuildUnit, TRUE, m_home_city.m_id, rec->GetIndex()))
return FALSE;
if(!rec->GetMovementTypeLand() && !rec->GetMovementTypeTrade() && !rec->GetIsTrader()) {
if(g_theWorld->IsWater(pos.x, pos.y) && rec->GetSeaCityCanBuild()) {
return TRUE;
}
if((g_theWorld->IsLand(pos.x, pos.y) ||
g_theWorld->IsMountain(pos.x, pos.y)) &&
rec->GetLandCityCanBuild()) {
return TRUE;
}
if(rec->GetMovementTypeSea() || rec->GetMovementTypeShallowWater()) {
if(g_theWorld->IsNextToWater(pos.x, pos.y)) {
return TRUE;
}
return FALSE;
} else if(rec->GetMovementTypeAir()) {
return TRUE;
}
return FALSE;
}
return TRUE;
}
Last edited by E on 14-03-2005 at 01:29
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:32
|
|
Player::CanBuildUnit
What does do the #if defined(ACTIVISION_ORIGINAL) at the start of the function, you was was supposed to replace the #else by #if !defined(ACTIVISION_ORIGINAL). This mistake shows me that so far you haven't done the preprocessor exercise. Do it now. In the description block you used tabs instead of spaces. While spending the return FALSE; its own line you deleted a closing brace, that you have to reinsert.
The retriving the city style, first g_player is an array, so it should be g_player[m_owner], second g_player[m_owner] is here identical with the this pointer, so it doesn't need to be written here.
Otherwise it seems to be fine.
CityData::CanBuildUnit
If now CityStyleOnly is defined then the according unit can be build if the according city style match, even if it is a boat and the city is not a costoal city. Actual I told you look at the GovernmentType code, as it does excactly we want just for Govenments enistead of city styles: And this thread is now full of this piece of code.
code:
if(rec->GetNumGovernmentType() > 0) {
sint32 i;
bool found = false;
for(i = 0; i < rec->GetNumGovernmentType(); i++) {
if(rec->GetGovernmentTypeIndex(i) == g_player[m_owner]->m_government_type) {
found = true;
break;
}
}
if(!found)
return FALSE;
}
What does this fragment of code it returns FALSE if there is at least one government defined and there wasn't a matching government, otherwise it let the function contine the execution.
Then also retriving the city style doesn't work like this. There is no Player::m_citystyle, there is only a CityData::m_citystyle, so just write m_citystyle into the code.
-Martin
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:32
|
|
For CitystyleOnly...I just redid governmenttype...
code:
//----------------------------------------------------------------------------
//
// Name : CityData::CanBuildUnit
//
// Description: Checks whether the city can build the unit specified by type.
//
// Parameters : type: The unit type for that is checked whether the city can
// build it.
//
// Globals : g_player: The list of players
// g_theUnitDB: The unit database
// g_slicEngine: The slic engine
// g_theWorld: The world prperties
//
// Returns : Whether the city can build the unit specified by type.
//
// Remark(s) : CityStyleOnly added by E. Limits certain units to be built only
// at certain cities of certain styles.
//
//----------------------------------------------------------------------------
BOOL CityData::CanBuildUnit(sint32 type) const
{
#if defined(ACTCIVSION_ORIGINAL)
// Removed by Martin Gühmann same code in Player::CanBuildUnit
const UnitRecord *rec = g_theUnitDB->Get(type);
if(!rec)
return FALSE;
MapPoint pos;
m_home_city.GetPos(pos);
if (!g_player[m_owner]->HasAdvance(rec->GetEnableAdvanceIndex()))
return FALSE;
sint32 o;
for(o = rec->GetNumObsoleteAdvance() - 1; o >= 0; o--) {
if(g_player[m_owner]->HasAdvance(rec->GetObsoleteAdvanceIndex(o)))
return FALSE;
}
if(g_exclusions->IsUnitExcluded(type))
return FALSE;
if(rec->GetCantBuild()) {
return FALSE;
}
if(rec->GetNumGovernmentType() > 0) {
sint32 i;
bool found = false;
for(i = 0; i < rec->GetNumGovernmentType(); i++) {
if(rec->GetGovernmentTypeIndex(i) == g_player[m_owner]->m_government_type) {
found = true;
break;
}
}
if(!found)
return FALSE;
}
if(rec->GetNuclearAttack() &&
wonderutil_GetNukesEliminated(g_theWonderTracker->GetBuiltWonders())) {
return FALSE;
}
if(rec->GetSlaveRaids() || rec->GetSettlerSlaveRaids() ||
rec->GetSlaveUprising()) {
if(wonderutil_GetFreeSlaves(g_theWonderTracker->GetBuiltWonders())) {
return FALSE;
}
}
if(rec->GetSlaveRaids() || rec->GetSettlerSlaveRaids()) {
sint32 i, n = g_player[m_owner]->m_all_units->Num();
for(i = 0; i < n; i++) {
if(g_player[m_owner]->m_all_units->Access(i).GetDBRec()->GetNoSlaves())
return FALSE;
}
}
if(rec->GetNoSlaves()) {
sint32 i, n = g_player[m_owner]->m_all_cities->Num();
for(i = 0; i < n; i++) {
if(g_player[m_owner]->m_all_cities->Access(i).CD()->SlaveCount() > 0)
return FALSE;
}
n = g_player[m_owner]->m_all_units->Num();
for(i = 0; i < n; i++) {
if(g_player[m_owner]->m_all_units->Access(i).GetDBRec()->GetSlaveRaids())
return FALSE;
}
}
if(rec->GetCreateParks() &&
!wonderutil_GetParkRangersEnabled(g_theWonderTrack
er->GetBuiltWonders())) {
return FALSE;
}
#else
// Added by Martin Gühmann
if(!g_player[m_owner]->CanBuildUnit(type))
return FALSE;
const UnitRecord *rec = g_theUnitDB->Get(type);
if(!rec)
return FALSE;
MapPoint pos;
m_home_city.GetPos(pos);
// Added by E
if(rec->GetNumCityStyleOnly() > 0) {
sint32 s;
bool found = false;
for(s = 0; s < rec->GetNumCityStyleOnly(); s++) {
if(rec->GetCityStyleOnlyIndex(s) == m_citystyle) {
found = true;
break;
}
}
if(!found)
return FALSE;
}
#endif
if(!g_slicEngine->CallMod(mod_CanCityBuildUnit, TRUE, m_home_city.m_id, rec->GetIndex()))
return FALSE;
if(!rec->GetMovementTypeLand() && !rec->GetMovementTypeTrade() && !rec->GetIsTrader()) {
if(g_theWorld->IsWater(pos.x, pos.y) && rec->GetSeaCityCanBuild()) {
return TRUE;
}
if((g_theWorld->IsLand(pos.x, pos.y) ||
g_theWorld->IsMountain(pos.x, pos.y)) &&
rec->GetLandCityCanBuild()) {
return TRUE;
}
if(rec->GetMovementTypeSea() || rec->GetMovementTypeShallowWater()) {
if(g_theWorld->IsNextToWater(pos.x, pos.y)) {
return TRUE;
}
return FALSE;
} else if(rec->GetMovementTypeAir()) {
return TRUE;
}
return FALSE;
}
return TRUE;
}
|
|
|  |
 |
|  |
All times are GMT. The time now is 05:32. Apolyton Time is 00:32. |
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
|
|
|
|
|
|