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 BuildingSettingsDlg::updateMemberVariables() { long forest = -1; bool bForests = true; EditorObject* pEditorObject = units.GetHead(); m_Alignment = pEditorObject->getAlignment(); if (m_Alignment == -1) m_Alignment = 8; //Move it to the neutral select button for ( EDITOROBJECT_LIST::EIterator iter = units.Begin(); !iter.IsDone(); iter++ ) { if ( ((*iter)->getAlignment() != m_Alignment) && ((*iter)->getAlignment() != -1)) { m_Alignment = -1; break; } if ( (*iter)->getForestID() != -1 ) { if ( forest == -1 ) forest = (*iter)->getForestID(); else if ( forest != (*iter)->getForestID() ) bForests = false; } } if ( forest != -1 ) { const Forest* pForest = EditorObjectMgr::instance()->getForest( forest ); if ( pForest ) { m_forestName = pForest->getFileName(); } } EditorObjectMgr* pMgr = EditorObjectMgr::instance(); int groupCount = pMgr->getBuildingGroupCount(); const char** pGroups = new const char*[groupCount]; m_Group.ResetContent(); pMgr->getBuildingGroupNames(pGroups, groupCount); int count = 0; for ( int i = 0; i < groupCount; ++i ) { if ((4/*mech group*/ == i) || (6/*vehicle group*/ == i)) { continue; } m_Group.AddString( pGroups[i] ); m_Group.SetItemData( count, (DWORD)i ); count += 1; } delete [] pGroups; // make sure all the units we are editing are in the same group int group = units.GetHead()->getGroup(); for ( iter = units.Begin(); !iter.IsDone(); iter++ ) { if ( (*iter)->getGroup() != group ) { group = -1; break; } } if ( group != -1 ) // we found a valid group { const char* pGroupName = pMgr->getGroupName( group ); int index = m_Group.FindString( -1, pGroupName ); m_Group.SetCurSel( index ); // OK, now fill in the index.... const char* MechNames[256]; int count = 256; m_Mech.ResetContent(); pMgr->getBuildingNamesInGroup( group, MechNames, count ); for ( int i = 0; i < count; ++i ) { m_Mech.AddString( MechNames[i] ); } // ok, now determine if all of the mechs are the same. int indexInGroup = units.GetHead()->getIndexInGroup(); for ( iter = units.Begin(); !iter.IsDone(); iter++ ) { if ( (*iter)->getIndexInGroup() != indexInGroup ) { indexInGroup = -1; break; } } if ( indexInGroup != -1 ) { const char* pName = units.GetHead()->getDisplayName(); index = m_Mech.FindString( -1, pName ); if ( index != -1 ) { m_Mech.SetCurSel( index ); } } } m_x = pEditorObject->getPosition().x; m_y = pEditorObject->getPosition().y; long row, column; pEditorObject->getCells(row, column); m_partID = MIN_TERRAIN_PART_ID + row * MAX_MAP_CELL_WIDTH + column; UpdateData( false ); }