ModifyBuildingAction::~ModifyBuildingAction() { for ( OBJ_INFO_PTR_LIST::EIterator iter = buildingCopyPtrs.Begin(); !iter.IsDone(); iter++) { delete (*iter); } }
bool ModifyBuildingAction::doRedo() { bool bRetVal = true; OBJ_INFO_PTR_LIST::EIterator iter2 = buildingPtrs.Begin(); OBJ_APPEAR_LIST::EIterator iter3 = buildingAppearanceCopies.Begin(); OBJ_ID_LIST::EIterator iter4 = buildingIDs.Begin(); for ( OBJ_INFO_PTR_LIST::EIterator iter = buildingCopyPtrs.Begin(); !iter.IsDone(); iter++) { //EditorObject *pBuilding = (*iter2); EditorObject *pBuilding = EditorObjectMgr::instance()->getObjectAtLocation((*iter4).x, (*iter4).y); if (pBuilding) { EditorObject *pBuildingSwap = (*iter)->Clone(); ObjectAppearance AppearanceSwap = (*iter3); (*iter)->CastAndCopy(*pBuilding); (*iter3) = (*(pBuilding->appearance())); (*pBuilding).CastAndCopy(*pBuildingSwap); (*(pBuilding->appearance())) = AppearanceSwap; delete pBuildingSwap; { /*this is just to make sure the visuals are up-to-date*/ bool d = pBuilding->getDamage(); pBuilding->setDamage(!d); pBuilding->setDamage(d); } long row, column; pBuilding->getCells(row, column); EditorObjectMgr::instance()->moveBuilding(pBuilding, row, column); (*iter4).x = pBuilding->getPosition().x; (*iter4).y = pBuilding->getPosition().y; } else { gosASSERT(false); } iter2++; iter3++; iter4++; } return bRetVal; }
void ModifyBuildingAction::updateNotedObjectPositions() { OBJ_ID_LIST::EIterator iter4 = buildingIDs.Begin(); for ( OBJ_INFO_PTR_LIST::EIterator iter = buildingPtrs.Begin(); !iter.IsDone(); iter++) { EditorObject *pBuilding = (*iter); if (pBuilding) { (*iter4).x = pBuilding->getPosition().x; (*iter4).y = pBuilding->getPosition().y; } else { gosASSERT(false); } iter4++; } }
bool BuildingBrush::BuildingAction::redo() { bool bRetVal = true; for (OBJ_INFO_PTR_LIST::EIterator iter = objInfoPtrList.Begin(); !iter.IsDone(); iter++) { ObjectAppearance* pAppearance = (*(*iter)).appearance(); EditorObject* pObj = EditorObjectMgr::instance()->addBuilding(pAppearance->position, EditorObjectMgr::instance()->getGroup((*(*iter)).getID()), EditorObjectMgr::instance()->getIndexInGroup((*(*iter)).getID()), pAppearance->teamId, pAppearance->rotation); if (pObj) { (*pObj).CastAndCopy((*(*iter))); } else { gosASSERT(false); bRetVal = false; } } return bRetVal; }
bool BuildingBrush::BuildingAction::undo() { bool bRetVal = true; /* OBJ_APPEAR_LIST::EIterator iter3 = buildingAppearanceCopies.Begin(); for ( OBJ_INFO_LIST::EIterator iter = positions.Begin(); !iter.IsDone(); iter++ ) { EditorObject* pObj = EditorObjectMgr::instance()->getObjectAtLocation((*iter3).position.x, (*iter3).position.y); if (pObj) { bRetVal = EditorObjectMgr::instance()->deleteBuilding( pObj ) && bRetVal; } else { gosASSERT(false); } iter3++; } */ for (OBJ_INFO_PTR_LIST::EIterator iter = objInfoPtrList.Begin(); !iter.IsDone(); iter++) { ObjectAppearance* pAppearance = (*(*iter)).appearance(); EditorObject* pObj = EditorObjectMgr::instance()->getObjectAtLocation( pAppearance->position.x, pAppearance->position.y); if (pObj) { bRetVal = EditorObjectMgr::instance()->deleteBuilding(pObj) && bRetVal; } else { gosASSERT(false); } } return bRetVal; }