OSDN Git Service

Field::createRectRoom() コンストラクタを追加。 / Add another constructor to Field::createRectRoom().
authorDeskull <desull@users.sourceforge.jp>
Wed, 14 Jan 2015 11:15:20 +0000 (20:15 +0900)
committerDeskull <desull@users.sourceforge.jp>
Wed, 14 Jan 2015 11:15:20 +0000 (20:15 +0900)
Deeangband/Field.cpp
Deeangband/Field.h

index bb3192c..9b348de 100644 (file)
@@ -35,7 +35,7 @@ namespace Deeangband
                        }
                }
 
-               Field::UpdateSight();
+               this->createRectRoom(13, 13, 20, 33);
 
                creatures.resize(0);
                doors.resize(0);
@@ -90,6 +90,11 @@ namespace Deeangband
                return squares[y][x].get();
        }
 
+       Square *Field::GetSquare(Coordinates &coord)
+       {
+               return this->GetSquare(coord.GetX(), coord.GetY());
+       }
+
        bool Field::GenerateTrap(std::map<TAG, boost::shared_ptr<TrapBase>>::iterator trapBaseIt, Coordinates *position)
        {
                traps.emplace(traps.end(), boost::make_shared<Trap>(trapBaseIt, position));
@@ -188,14 +193,13 @@ namespace Deeangband
 
        }
 
-       void Field::createRectRoom(Coordinates& leftTop, Coordinates& rightBottom)
+       void Field::createRectRoom(MAP_LENGTH sx, MAP_LENGTH sy,  MAP_LENGTH ex, MAP_LENGTH ey)
        {
-               MAP_LENGTH x, y;
-               MAP_LENGTH sx = leftTop.GetX();
-               MAP_LENGTH sy = leftTop.GetY();
-               MAP_LENGTH ex = rightBottom.GetX();
-               MAP_LENGTH ey = rightBottom.GetY();
                Square *squarePtr;
+               std::vector<boost::shared_ptr<Coordinates>> wallVec;
+
+               MAP_LENGTH x, y;
+               wallVec.clear();
 
                for(y = sy + 1; y < ey; y++)
                {
@@ -215,15 +219,26 @@ namespace Deeangband
                        squarePtr->SetFloorTag(dungeonPtr->GetInnerWallFloorTag());
                        squarePtr = this->GetSquare(ex, y);
                        squarePtr->SetFloorTag(dungeonPtr->GetInnerWallFloorTag());
+                       wallVec.push_back(boost::make_shared<Coordinates>(sx, y));
+                       wallVec.push_back(boost::make_shared<Coordinates>(ex, y));
                }
 
-               for(x = sx + 1; x < ex; y++)
+               for(x = sx + 1; x < ex; x++)
                {
                        squarePtr = this->GetSquare(x, sy);
                        squarePtr->SetFloorTag(dungeonPtr->GetInnerWallFloorTag());
                        squarePtr = this->GetSquare(x, ey);
                        squarePtr->SetFloorTag(dungeonPtr->GetInnerWallFloorTag());
+                       wallVec.push_back(boost::make_shared<Coordinates>(x, sy));
+                       wallVec.push_back(boost::make_shared<Coordinates>(x, ey));
                }
+
+               this->GetSquare(*wallVec[Dice::Rand0(wallVec.size())].get())->SetFloorTag(dungeonPtr->GetFloorFloorTag());
+       }
+
+       void Field::createRectRoom(Coordinates& leftTop, Coordinates& rightBottom)
+       {
+               this->createRectRoom(leftTop.GetX(), leftTop.GetY(), rightBottom.GetX(), rightBottom.GetY());
        }
 
        void Field::GetSight(std::vector<bool> &coordVec, MAP_LENGTH size, MAP_LENGTH baseX, MAP_LENGTH baseY)
index 83088ef..ec788a8 100644 (file)
@@ -70,6 +70,7 @@ namespace Deeangband
                 * @param rightBottom \89E\89º\8dÀ\95W
                 * @return \82È\82µ
                 */
+               void Field::createRectRoom(MAP_LENGTH sx, MAP_LENGTH sy,  MAP_LENGTH ex, MAP_LENGTH ey);
                void Field::createRectRoom(Coordinates& leftTop, Coordinates& rightBottom);
 
        public:
@@ -134,6 +135,8 @@ namespace Deeangband
                */
                Square *Field::GetSquare(MAP_LENGTH x, MAP_LENGTH y);
 
+               Square *Field::GetSquare(Coordinates &coord);
+
                /*!
                 * @brief \83t\83\8d\83A\82Ì\8aY\93\96\8dÀ\95W\82É\83g\83\89\83b\83v\82ð\90\90¬\82·\82é
                 * @param trapBaseTag \94z\92u\82·\82é\83g\83\89\83b\83v\8eí\95Ê\83^\83O