MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / doorLock

Method doorLock

source/gamemap/GameMap.cpp:3059–3158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3057}
3058
3059void GameMap::doorLock(Tile* tileDoor, Seat* seat, bool locked)
3060{
3061 if(!locked)
3062 {
3063 // When a door is unlocked, we check all its neighboors to find a floodfill value for each possible
3064 // tile type and set the same for all neighboor tiles
3065 std::vector<uint32_t> colors(static_cast<uint32_t>(FloodFillType::nbValues), Tile::NO_FLOODFILL);
3066
3067 for(uint32_t i = 0; i < colors.size(); ++i)
3068 {
3069 FloodFillType type = static_cast<FloodFillType>(i);
3070 colors[i] = tileDoor->getFloodFillValue(seat, type);
3071 }
3072
3073 // Now, we check all neighboors and replace floodfill values if different
3074 for(uint32_t i = 0; i < colors.size(); ++i)
3075 {
3076 if(colors[i] == Tile::NO_FLOODFILL)
3077 continue;
3078
3079 FloodFillType type = static_cast<FloodFillType>(i);
3080 for(Tile* neigh : tileDoor->getAllNeighbors())
3081 {
3082 uint32_t neighColor = neigh->getFloodFillValue(seat, type);
3083 if(neighColor == Tile::NO_FLOODFILL)
3084 continue;
3085
3086 if(neighColor == colors[i])
3087 continue;
3088
3089 replaceFloodFill(seat, type, neighColor, colors[i]);
3090 }
3091 }
3092
3093 return;
3094 }
3095
3096 // We save the list of the creatures that are on the same floodfill as the door tile. Then, we will check if the path
3097 // is still valid
3098 std::vector<Creature*> creatures;
3099 for(Seat* alliedSeat : getSeats())
3100 {
3101 if((alliedSeat != seat) &&
3102 (!alliedSeat->isAlliedSeat(seat)))
3103 {
3104 continue;
3105 }
3106
3107 std::vector<Creature*> alliedCreatures = getCreaturesBySeat(seat);
3108 for(Creature* creature : alliedCreatures)
3109 {
3110 if(!pathExists(creature, tileDoor, creature->getPositionTile()))
3111 continue;
3112
3113 creatures.push_back(creature);
3114 }
3115 }
3116

Callers 2

doUpkeepMethod · 0.80
changeDoorStateMethod · 0.80

Calls 5

getFloodFillValueMethod · 0.80
isAlliedSeatMethod · 0.80
getPositionTileMethod · 0.80
isFullTileMethod · 0.80
checkWalkPathValidMethod · 0.80

Tested by

no test coverage detected