bool TMap::setExit( int from, int to, int dir ) { TRoom * pR = mpRoomDB->getRoom( from ); TRoom * pR_to = mpRoomDB->getRoom( to ); if( !pR ) return false; if( !pR_to && to > 0 ) return false; if( to < 1 ) to = -1; mPlausaOptOut = 0; bool ret = true; switch( dir ) { case DIR_NORTH: pR->setNorth(to); break; case DIR_NORTHEAST: pR->setNortheast(to); break; case DIR_NORTHWEST: pR->setNorthwest(to); break; case DIR_EAST: pR->setEast(to); break; case DIR_WEST: pR->setWest(to); break; case DIR_SOUTH: pR->setSouth(to); break; case DIR_SOUTHEAST: pR->setSoutheast(to); break; case DIR_SOUTHWEST: pR->setSouthwest(to); break; case DIR_UP: pR->setUp(to); break; case DIR_DOWN: pR->setDown(to); break; case DIR_IN: pR->setIn(to); break; case DIR_OUT: pR->setOut(to); break; default: ret = false; } pR->setExitStub(dir, 0); mMapGraphNeedsUpdate = true; TArea * pA = mpRoomDB->getArea( pR->getAreaId() ); pA->fast_ausgaengeBestimmen(pR->getId()); return ret; }
// this is call by TRoom destructor only bool TRoomDB::__removeRoom( int id ) { if( rooms.contains(id ) && id > 0 ) { TRoom * pR = getRoom( id ); if( !pR ) return false; QMapIterator<int, TRoom *> it( rooms ); while( it.hasNext() ) { it.next(); TRoom * r = it.value(); if( r->getNorth() == id ) r->setNorth(-1); if( r->getNortheast() == id ) r->setNortheast(-1); if( r->getNorthwest() == id ) r->setNorthwest(-1); if( r->getEast() == id ) r->setEast(-1); if( r->getWest() == id ) r->setWest(-1); if( r->getSouth() == id ) r->setSouth(-1); if( r->getSoutheast() == id ) r->setSoutheast(-1); if( r->getSouthwest() == id ) r->setSouthwest(-1); if( r->getUp() == id ) r->setUp(-1); if( r->getDown() == id ) r->setDown(-1); if( r->getIn() == id ) r->setIn(-1); if( r->getOut() == id ) r->setOut(-1); r->removeAllSpecialExitsToRoom( id ); } int _areaId = pR->getAreaId(); TArea * pA = getArea( _areaId ); if( !pA ) return false; pA->rooms.removeAll( id ); pA->exits.remove( id ); //note: this removes *all* keys=id mpMap->mMapGraphNeedsUpdate = true; } QList<QString> keyList = hashTable.keys(); QList<int> valueList = hashTable.values(); for( int i=0; i<valueList.size(); i++ ) { if( valueList[i] == id ) { hashTable.remove( keyList[i] ); } } return true; }