Originally posted by Martin Gühmann
Must it really be disband and create? Why not just change the unit owner?
-Martin
Must it really be disband and create? Why not just change the unit owner?
-Martin
// Put this army on sentinal duty. void ArmyData::Sleep() { //ORIGINAL // sint32 i; // for(i = 0; i < m_nElements; i++) { // //EMOD upgrade code 4-25-2006 outcommented sint32 i; sint32 s = 0; Unit city = g_theWorld->GetCity(m_pos); for(i = m_nElements - 1; i >= 0; i--) { // if((city.m_id != (0)) && (m_array[i].GetDBRec()->GetUpgradeToIndex(s))) { // add terrainutil_HasAirfield(m_pos) || terrainutil_HasFort(m_pos) || terrainutil_HasUpgrader(m_pos) // for(s = 0; s < m_array[i].GetDBRec()->GetNumUpgradeTo(); s++) { // sint32 s = m_array[i].GetDBRec()->GetNumUpgradeTo(); // s++) { //m_array[i].GetDBRec()->GetUpgradeToIndex(s) // if(city.AccessData()->GetCityData()->CanBuildUnit(m_array[i].GetDBRec()->GetUpgradeToIndex(s))){ // sint32 newunit = m_array[i].GetDBRec()->GetUpgradeToIndex(s); // sint32 newshields = m_array[i].GetDBRec()->GetShieldCost() * 2; // sint32 oldshields = m_array[i].GetDBRec()->GetShieldCost(); // sint32 rushmod = g_theGovernmentDB->Get(g_player[m_owner]->m_government_type)->GetUnitRushModifier(); // sint32 goldcost = (newshields - oldshields);// * rushmod; // // if((city.AccessData()->GetCityData()->CanBuildUnit(m_array[i].GetDBRec()->GetUpgradeToIndex(s))) ){//&& (g_player[m_owner]->m_gold->GetLevel() > goldcost)) { //&& (g_player[m_owner]->GetPlayerType() != PLAYER_TYPE_ROBOT) // m_array[i].Kill(CAUSE_REMOVE_ARMY_DISBANDED, -1); // g_player[m_owner]->CreateUnit(s, m_pos, Unit(), FALSE, CAUSE_NEW_ARMY_INITIAL); // g_player[m_owner]->m_gold->SubGold(goldcost); // } else { // g_gevManager->AddEvent(GEV_INSERT_AfterCurrent, GEV_SleepUnit, // GEA_Unit, m_array[i], // GEA_End); // } // // } // } else { //end EMOD g_gevManager->AddEvent(GEV_INSERT_AfterCurrent, GEV_SleepUnit, GEA_Unit, m_array[i], GEA_End); // } } }
// Put this army on sentinal duty or upgrade it. void ArmyData::Sleep() { Cell *cell = g_theWorld->GetCell(m_pos); sint32 CellOwner = cell->GetOwner(); sint32 i; sint32 s; //rec = g_theUnitDB->Get(m_array[i].GetType(), g_player[GetOwner()]->GetGovernmentType()); Unit city = g_theWorld->GetCity(m_pos); for(i = m_nElements - 1; i >= 0; i--) { const UnitRecord *rec = m_array[i].GetDBRec(); if((city.m_id != (0)) && (rec->GetNumUpgradeTo() > 0)) { for(s = 0; s < rec->GetNumUpgradeTo(); s++) { sint32 oldshield = rec->GetShieldCost(); sint32 newshield = g_theUnitDB->Get(rec->GetUpgradeToIndex(s))->GetShieldCost(); sint32 rushmod = g_theGovernmentDB->Get(g_player[m_owner]->m_government_type)->GetUnitRushModifier(); sint32 goldcost = (newshield - oldshield) * rushmod; sint32 newunit = rec->GetUpgradeToIndex(s); if(city.AccessData()->GetCityData()->CanBuildUnit(rec->GetUpgradeToIndex(s)) && (g_player[m_owner]->m_gold->GetLevel() > goldcost)){ m_array[i].Kill(CAUSE_REMOVE_ARMY_DISBANDED, -1); g_player[m_owner]->CreateUnit(newunit, m_pos, Unit(), FALSE, CAUSE_NEW_ARMY_INITIAL); g_player[m_owner]->m_gold->SubGold(goldcost); } else { g_gevManager->AddEvent(GEV_INSERT_AfterCurrent, GEV_SleepUnit, GEA_Unit, m_array[i], GEA_End); } } } else { g_gevManager->AddEvent(GEV_INSERT_AfterCurrent, GEV_SleepUnit, GEA_Unit, m_array[i], GEA_End); } } }
void UnitData::SetOwner(PLAYER_INDEX newo) { m_owner = newo; ENQUEUE(); }
PLAYER_INDEX Unit::GetOwner() const { return g_theUnitPool->GetUnit(m_id)->GetOwner(); } sint32 Unit::GetType() const { return g_theUnitPool->GetUnit(m_id)->GetType(); }
for(i = m_nElements - 1; i >= 0; i--) { const UnitRecord *rec = m_array[i].GetDBRec(); if((city.m_id != (0)) && (rec->GetNumUpgradeTo() > 0)) { for(s = 0; s < rec->GetNumUpgradeTo(); s++) { sint32 oldshield = rec->GetShieldCost(); sint32 newshield = g_theUnitDB->Get(rec->GetUpgradeToIndex(s))->GetShieldCost(); sint32 rushmod = g_theGovernmentDB->Get(g_player[m_owner]->m_government_type)->GetUnitRushModifier(); sint32 goldcost = (newshield - oldshield) * rushmod; sint32 newunit = rec->GetUpgradeToIndex(s); if(city.AccessData()->GetCityData()->CanBuildUnit(rec->GetUpgradeToIndex(s)) && (g_player[m_owner]->m_gold->GetLevel() > goldcost)){ m_array[i].SetType(newunit); //m_array[i].Kill(CAUSE_REMOVE_ARMY_DISBANDED, -1); //g_player[m_owner]->CreateUnit(newunit, m_pos, Unit(), FALSE, CAUSE_NEW_ARMY_INITIAL); g_player[m_owner]->m_gold->SubGold(goldcost); } else { g_gevManager->AddEvent(GEV_INSERT_AfterCurrent, GEV_SleepUnit, GEA_Unit, m_array[i], GEA_End); } } } else {
void Unit::SetType(const sint32 type) { AccessData()->SetType(type); } void UnitData::SetType(sint32 type) { m_type = type; //ENQUEUE(); }
Comment