prg's maze generator
authornemo
Sun, 28 Mar 2010 02:49:39 +0000
changeset 3133 1ab5f18f4df8
parent 3132 72ad441d4c2f
child 3134 430c1e96c80f
prg's maze generator
QTfrontend/gamecfgwidget.cpp
QTfrontend/gamecfgwidget.h
QTfrontend/hwmap.cpp
QTfrontend/hwmap.h
QTfrontend/mapContainer.cpp
QTfrontend/mapContainer.h
hedgewars/uConsole.pas
hedgewars/uLand.pas
hedgewars/uMisc.pas
share/hedgewars/Data/Locale/fr.txt
--- a/QTfrontend/gamecfgwidget.cpp	Sun Mar 28 00:46:34 2010 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Sun Mar 28 02:49:39 2010 +0000
@@ -80,6 +80,8 @@
 
     connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &)));
     connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &)));
+    connect(pMapContainer, SIGNAL(mapgenChanged(MapGenerator)), this, SLOT(mapgenChanged(MapGenerator)));
+    connect(pMapContainer, SIGNAL(maze_sizeChanged(int)), this, SLOT(maze_sizeChanged(int)));
     connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &)));
     connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int)));
 }
@@ -153,6 +155,8 @@
     sl.append(QString("e$minedudpct %1").arg(schemeData(24).toInt()));
     sl.append(QString("e$explosives %1").arg(schemeData(25).toInt()));
     sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()));
+    sl.append(QString("e$mapgen %1").arg(pMapContainer->get_mapgen()));
+    sl.append(QString("e$maze_size %1").arg(pMapContainer->get_maze_size()));
 
     QString currentMap = pMapContainer->getCurrentMap();
     if (currentMap.size() > 0)
@@ -193,6 +197,9 @@
 
     schemeChanged(GameSchemes->currentIndex());
 
+    mapgenChanged(pMapContainer->get_mapgen());
+    maze_sizeChanged(pMapContainer->get_maze_size());
+
     // map must be the last
     QString map = pMapContainer->getCurrentMap();
     if (map.size())
@@ -220,6 +227,14 @@
             pMapContainer->setTemplateFilter(value.toUInt());
             return;
         }
+        if (param == "MAPGEN") {
+            pMapContainer->setMapgen((MapGenerator)value.toUInt());
+            return;
+        }
+        if (param == "MAZE_SIZE") {
+            pMapContainer->setMaze_size(value.toUInt());
+            return;
+        }
     }
 
     if (slValue.size() == 2)
@@ -285,6 +300,16 @@
     emit paramChanged("SCHEME", sl);
 }
 
+void GameCFGWidget::mapgenChanged(MapGenerator m)
+{
+    emit paramChanged("MAPGEN", QStringList(QString::number(m)));
+}
+
+void GameCFGWidget::maze_sizeChanged(int s)
+{
+    emit paramChanged("MAZE_SIZE", QStringList(QString::number(s)));
+}
+
 void GameCFGWidget::resendSchemeData()
 {
     schemeChanged(GameSchemes->currentIndex());
--- a/QTfrontend/gamecfgwidget.h	Sun Mar 28 00:46:34 2010 +0000
+++ b/QTfrontend/gamecfgwidget.h	Sun Mar 28 02:49:39 2010 +0000
@@ -63,6 +63,8 @@
     void themeChanged(const QString &);
     void schemeChanged(int);
     void jumpToWeapons();
+    void mapgenChanged(MapGenerator m);
+    void maze_sizeChanged(int s);
 
 private:
     QGridLayout mainLayout;
--- a/QTfrontend/hwmap.cpp	Sun Mar 28 00:46:34 2010 +0000
+++ b/QTfrontend/hwmap.cpp	Sun Mar 28 02:49:39 2010 +0000
@@ -27,10 +27,12 @@
 {
 }
 
-void HWMap::getImage(std::string seed, int filter)
+void HWMap::getImage(std::string seed, int filter, MapGenerator mapgen, int maze_size)
 {
     m_seed = seed;
     templateFilter = filter;
+    m_mapgen = mapgen;
+    m_maze_size = maze_size;
     Start();
 }
 
@@ -59,5 +61,7 @@
 {
     SendIPC(QString("eseed %1").arg(m_seed.c_str()).toLatin1());
     SendIPC(QString("e$template_filter %1").arg(templateFilter).toLatin1());
+    SendIPC(QString("e$mapgen %1").arg(m_mapgen).toLatin1());
+    SendIPC(QString("e$maze_size %1").arg(m_maze_size).toLatin1());
     SendIPC("!");
 }
--- a/QTfrontend/hwmap.h	Sun Mar 28 00:46:34 2010 +0000
+++ b/QTfrontend/hwmap.h	Sun Mar 28 02:49:39 2010 +0000
@@ -27,6 +27,12 @@
 
 #include <string>
 
+enum MapGenerator
+{
+    MAPGEN_REGULAR,
+    MAPGEN_MAZE,
+};
+
 class HWMap : public TCPBase
 {
   Q_OBJECT
@@ -34,7 +40,7 @@
  public:
   HWMap();
   virtual ~HWMap();
-  void getImage(std::string seed, int templateFilter);
+  void getImage(std::string seed, int templateFilter, MapGenerator mapgen, int maze_size);
 
  protected:
   virtual QStringList setArguments();
@@ -48,6 +54,8 @@
  private:
   std::string m_seed;
   int templateFilter;
+  MapGenerator m_mapgen;
+  int m_maze_size;
 
  private slots:
 };
--- a/QTfrontend/mapContainer.cpp	Sun Mar 28 00:46:34 2010 +0000
+++ b/QTfrontend/mapContainer.cpp	Sun Mar 28 02:49:39 2010 +0000
@@ -37,7 +37,9 @@
 HWMapContainer::HWMapContainer(QWidget * parent) :
     QWidget(parent),
     mainLayout(this),
-    pMap(0)
+    pMap(0),
+    mapgen(MAPGEN_REGULAR),
+    maze_size(0)
 {
     hhSmall.load(":/res/hh_small.png");
     hhLimit = 18;
@@ -60,6 +62,7 @@
     chooseMap = new QComboBox(this);
     chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
     chooseMap->addItem(QComboBox::tr("generated map..."));
+    chooseMap->addItem(QComboBox::tr("generated maze..."));
     for (int i = 0; i < mapList->size(); ++i) {
         QString map = (*mapList)[i];
         QFile mapCfgFile(
@@ -110,6 +113,17 @@
 
     connect(CB_TemplateFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(templateFilterChanged(int)));
 
+    maze_size_label = new QLabel("Size", this);
+    mainLayout.addWidget(maze_size_label, 2, 0);
+    maze_size_label->hide();
+    maze_size_selection = new QComboBox(this);
+    maze_size_selection->addItem(tr("Small"), 0);
+    maze_size_selection->addItem(tr("Medium"), 1);
+    maze_size_selection->addItem(tr("Large"), 2);
+    mainLayout.addWidget(maze_size_selection, 2, 1);
+    maze_size_selection->hide();
+    connect(maze_size_selection, SIGNAL(currentIndexChanged(int)), this, SLOT(setMaze_size(int)));
+
     gbThemes = new IconedGroupBox(this);
     gbThemes->setTitleTextPadding(60);
     gbThemes->setContentTopPadding(6);
@@ -172,7 +186,7 @@
     p.drawPixmap(QPoint(0, 0), px);
 
     addInfoToPreview(pxres);
-    chooseMap->setCurrentIndex(0);
+    chooseMap->setCurrentIndex(mapgen);
     pMap = 0;
 }
 
@@ -183,19 +197,38 @@
 
 void HWMapContainer::mapChanged(int index)
 {
-    if(!index) {
+    switch(index) {
+    case MAPGEN_REGULAR:
+        mapgen = MAPGEN_REGULAR;
         changeImage();
         gbThemes->show();
         lblFilter->show();
         CB_TemplateFilter->show();
+        maze_size_label->hide();
+        maze_size_selection->hide();
         emit mapChanged("+rnd+");
-        emit themeChanged(chooseMap->itemData(0).toList()[1].toString());
-    } else
-    {
+        emit mapgenChanged(mapgen);
+        emit themeChanged(chooseMap->itemData(index).toList()[1].toString());
+        break;
+    case MAPGEN_MAZE:
+        mapgen = MAPGEN_MAZE;
+        changeImage();
+        gbThemes->show();
+        lblFilter->hide();
+        CB_TemplateFilter->hide();
+        maze_size_label->show();
+        maze_size_selection->show();
+        emit mapChanged("+rnd+");
+        emit mapgenChanged(mapgen);
+        emit themeChanged(chooseMap->itemData(index).toList()[1].toString());
+        break;
+    default:
         loadMap(index);
         gbThemes->hide();
         lblFilter->hide();
         CB_TemplateFilter->hide();
+        maze_size_label->hide();
+        maze_size_selection->hide();
         emit mapChanged(chooseMap->itemData(index).toList()[0].toString());
     }
 }
@@ -245,7 +278,7 @@
     pMap = new HWMap();
     connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage)));
     connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int)));
-    pMap->getImage(m_seed.toStdString(), getTemplateFilter());
+    pMap->getImage(m_seed.toStdString(), getTemplateFilter(), mapgen, maze_size);
 }
 
 void HWMapContainer::themeSelected(int currentRow)
@@ -257,6 +290,7 @@
     mapInfo.push_back(18);
     mapInfo.push_back(false);
     chooseMap->setItemData(0, mapInfo);
+    chooseMap->setItemData(1, mapInfo);
     gbThemes->setIcon(QIcon(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(theme)));
     emit themeChanged(theme);
 }
@@ -268,7 +302,7 @@
 
 QString HWMapContainer::getCurrentMap() const
 {
-    if(!chooseMap->currentIndex()) return QString();
+    if(chooseMap->currentIndex() <= 1) return QString();
     return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString();
 }
 
@@ -364,3 +398,28 @@
     changeImage();
 }
 
+MapGenerator HWMapContainer::get_mapgen(void) const
+{
+    return mapgen;
+}
+
+int HWMapContainer::get_maze_size(void) const
+{
+    return maze_size;
+}
+
+void HWMapContainer::setMaze_size(int size)
+{
+    maze_size = size;
+    emit maze_sizeChanged(size);
+//    emit mapChanged("+rnd+");
+    changeImage();
+}
+
+void HWMapContainer::setMapgen(MapGenerator m)
+{
+    mapgen = m;
+    emit mapgenChanged(m);
+//    emit mapChanged("+rnd+");
+    changeImage();
+}
--- a/QTfrontend/mapContainer.h	Sun Mar 28 00:46:34 2010 +0000
+++ b/QTfrontend/mapContainer.h	Sun Mar 28 02:49:39 2010 +0000
@@ -45,6 +45,8 @@
   QString getCurrentTheme() const;
   int     getCurrentHHLimit() const;
   quint32 getTemplateFilter() const;
+  MapGenerator get_mapgen(void) const;
+  int get_maze_size(void) const;
   bool getCurrentIsMission() const;
 
  public slots:
@@ -53,13 +55,16 @@
   void setMap(const QString & map);
   void setTheme(const QString & theme);
   void setTemplateFilter(int);
+  void setMapgen(MapGenerator m);
+  void setMaze_size(int size);
 
  signals:
   void seedChanged(const QString & seed);
   void mapChanged(const QString & map);
   void themeChanged(const QString & theme);
   void newTemplateFilter(int filter);
-
+  void mapgenChanged(MapGenerator m);
+  void maze_sizeChanged(int s);
 
  private slots:
   void setImage(const QImage newImage);
@@ -87,6 +92,10 @@
   QPixmap hhSmall;
   QLabel* lblFilter;
   QComboBox* CB_TemplateFilter;
+  QLabel *maze_size_label;
+  QComboBox *maze_size_selection;
+  MapGenerator mapgen;
+  int maze_size;
 
   void loadMap(int index);
 };
--- a/hedgewars/uConsole.pas	Sun Mar 28 00:46:34 2010 +0000
+++ b/hedgewars/uConsole.pas	Sun Mar 28 02:49:39 2010 +0000
@@ -235,6 +235,8 @@
     RegisterVariable('theme'   , vtCommand, @chSetTheme     , false);
     RegisterVariable('seed'    , vtCommand, @chSetSeed      , false);
     RegisterVariable('template_filter', vtLongInt, @cTemplateFilter, false);
+    RegisterVariable('mapgen'  , vtLongInt, @cMapGen        , false);
+    RegisterVariable('maze_size',vtLongInt, @cMazeSize      , false);
     RegisterVariable('delay'   , vtLongInt, @cInactDelay    , false);
     RegisterVariable('casefreq', vtLongInt, @cCaseFactor    , false);
     RegisterVariable('sd_turns', vtLongInt, @cSuddenDTurns  , false);
--- a/hedgewars/uLand.pas	Sun Mar 28 00:46:34 2010 +0000
+++ b/hedgewars/uLand.pas	Sun Mar 28 02:49:39 2010 +0000
@@ -41,6 +41,13 @@
     playHeight, playWidth, leftX, rightX, topY, MaxHedgehogs: Longword;  // idea is that a template can specify height/width.  Or, a map, a height/width by the dimensions of the image.  If the map has pixels near top of image, it triggers border.
     LandBackSurface: PSDL_Surface;
 
+type direction = record x, y: integer; end;
+var DIR_N: direction = (x: 0; y: -1);
+var DIR_E: direction = (x: 1; y: 0);
+var DIR_S: direction = (x: 0; y: 1);
+var DIR_W: direction = (x: -1; y: 0);
+var DIR_NONE: direction = (x: 0; y: 0);
+
 procedure initModule;
 procedure freeModule;
 procedure GenMap;
@@ -51,6 +58,11 @@
 implementation
 uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, uSHA, uIO, uAmmos, uLandTexture;
 
+operator=(const a, b: direction) c: Boolean;
+begin
+    c := (a.x = b.x) and (a.y = b.y);
+end;
+
 type TPixAr = record
               Count: Longword;
               ar: array[0..Pred(cMaxEdgePoints)] of TPoint;
@@ -637,11 +649,344 @@
     SDL_UnlockSurface(Surface);
 end;
 
+procedure GenMaze;
+const small_cell_size = 128;
+    medium_cell_size = 192;
+    large_cell_size = 256;
+    braidness = 25;
+    maze_inverted = false; //false makes more sense for now
+
+var x, y: Longint;
+    bg_color, fg_color: Longint;
+    cellsize: LongInt; //selected by the user in the gui
+    seen_cells_x, seen_cells_y: Longint; //number of cells that can be visited by the generator, that is every second cell in x and y direction. the cells between there are walls that will be removed when we move from one cell to another
+    start_x, start_y: Longint; //first visited cell, must be between 0 and seen_cells_x/y - 1 inclusive
+    num_edges_x, num_edges_y: Longint; //number of resulting edges that need to be vertexificated
+    num_cells_x, num_cells_y: Longint; //actual number of cells, depending on cell size
+    seen_list: array of array of Boolean;
+    xwalls: array of array of Boolean;
+    ywalls: array of array of Boolean;
+    x_edge_list: array of array of Boolean;
+    y_edge_list: array of array of Boolean;
+    maze: array of array of Boolean;
+    pa: TPixAr;
+    num_vertices: Longint;
+    off_y: LongInt;
+
+function is_cell_seen(x: Longint; y: Longint): Boolean;
+begin
+if (x < 0) or (x >= seen_cells_x) or (y < 0) or (y >= seen_cells_y) then
+    is_cell_seen := true
+else
+    is_cell_seen := seen_list[x, y];
+end;
+
+function is_x_edge(x, y: Longint): Boolean;
+begin
+if (x < 0) or (x > num_edges_x) or (y < 0) or (y > num_cells_y) then
+    is_x_edge := false
+else
+    is_x_edge := x_edge_list[x, y];
+end;
+
+function is_y_edge(x, y: Longint): Boolean;
+begin
+if (x < 0) or (x > num_cells_x) or (y < 0) or (y > num_edges_y) then
+    is_y_edge := false
+else
+    is_y_edge := y_edge_list[x, y];
+end;
+
+procedure see_cell(x: Longint; y: Longint);
+var dir: direction;
+    tries: Longint;
+begin
+seen_list[x, y] := true;
+case GetRandom(4) of
+    0: dir := DIR_N;
+    1: dir := DIR_E;
+    2: dir := DIR_S;
+    3: dir := DIR_W;
+end;
+tries := 0;
+while (tries < 5) do
+begin
+    if is_cell_seen(x + dir.x, y + dir.y) then
+    begin
+        //we have already seen the target cell, decide if we should remove the wall anyway
+        //(or put a wall there if maze_inverted, but we're not doing that right now)
+        if not maze_inverted and (GetRandom(braidness) = 0) then
+        //or just warn that inverted+braid+indestructable terrain != good idea
+        begin
+            case dir.x of
+                -1: if x > 0 then ywalls[x-1, y] := false;
+                1: if x < seen_cells_x - 1 then ywalls[x, y] := false;
+            end;
+            case dir.y of
+                -1: if y > 0 then xwalls[x, y-1] := false;
+                1: if y < seen_cells_y - 1 then xwalls[x, y] := false;
+            end;
+        end;
+        if dir = DIR_N then //TODO might want to randomize that
+            dir := DIR_E
+        else if dir = DIR_E then
+            dir := DIR_S
+        else if dir = DIR_S then
+            dir := DIR_W
+        else
+            dir := DIR_N;
+    end
+    else //cell wasn't seen yet, go there
+    begin
+        case dir.y of
+            -1: xwalls[x, y-1] := false;
+            1: xwalls[x, y] := false;
+        end;
+        case dir.x of
+            -1: ywalls[x-1, y] := false;
+            1: ywalls[x, y] := false;
+        end;
+        see_cell(x + dir.x, y + dir.y);
+    end;
+
+    tries := tries + 1;
+end;
+
+end;
+procedure add_vertex(x, y: Longint);
+begin
+writelntoconsole('add_vertex('+inttostr(x)+', '+inttostr(y)+')');
+if x = NTPX then
+begin
+    pa.ar[num_vertices].x := NTPX;
+    pa.ar[num_vertices].y := 0;
+end
+else
+begin
+    pa.ar[num_vertices].x := x*cellsize;
+    pa.ar[num_vertices].y := y*cellsize + off_y;
+end;
+num_vertices := num_vertices + 1;
+end;
+
+procedure add_edge(x, y: Longint; dir: direction);
+var i: integer;
+begin
+if dir = DIR_N then
+begin
+    dir := DIR_W
+end
+else if dir = DIR_E then
+begin
+    dir := DIR_N
+end
+else if dir = DIR_S then
+begin
+    dir := DIR_E
+end
+else
+begin
+    dir := DIR_S;
+end;
+
+for i := 0 to 3 do
+begin
+        if dir = DIR_N then
+            dir := DIR_E
+        else if dir = DIR_E then
+            dir := DIR_S
+        else if dir = DIR_S then
+            dir := DIR_W
+        else
+            dir := DIR_N;
+
+    if (dir = DIR_N) and is_x_edge(x, y) then
+        begin
+            x_edge_list[x, y] := false;
+            add_vertex(x+1, y);
+            add_edge(x, y-1, DIR_N);
+            break;
+        end;
+
+    if (dir = DIR_E) and is_y_edge(x+1, y) then
+        begin
+            y_edge_list[x+1, y] := false;
+            add_vertex(x+2, y+1);
+            add_edge(x+1, y, DIR_E);
+            break;
+        end;
+
+    if (dir = DIR_S) and is_x_edge(x, y+1) then
+        begin
+            x_edge_list[x, y+1] := false;
+            add_vertex(x+1, y+2);
+            add_edge(x, y+1, DIR_S);
+            break;
+        end;
+
+    if (dir = DIR_W) and is_y_edge(x, y) then
+        begin
+            y_edge_list[x, y] := false;
+            add_vertex(x, y+1);
+            add_edge(x-1, y, DIR_W);
+            break;
+        end;
+end;
+
+end;
+
+begin
+case cMazeSize of
+    0: cellsize := small_cell_size;
+    1: cellsize := medium_cell_size;
+    2: cellsize := large_cell_size;
+end;
+
+num_cells_x := LAND_WIDTH div cellsize;
+if num_cells_x mod 2 = 0 then num_cells_x := num_cells_x - 1; //needs to be odd
+num_cells_y := LAND_HEIGHT div cellsize;
+if num_cells_y mod 2 = 0 then num_cells_y := num_cells_y - 1;
+num_edges_x := num_cells_x - 1;
+num_edges_y := num_cells_y - 1;
+seen_cells_x := num_cells_x div 2;
+seen_cells_y := num_cells_y div 2;
+
+SetLength(seen_list, seen_cells_x, seen_cells_y);
+SetLength(xwalls, seen_cells_x, seen_cells_y - 1);
+SetLength(ywalls, seen_cells_x - 1, seen_cells_y);
+SetLength(x_edge_list, num_edges_x, num_cells_y);
+SetLength(y_edge_list, num_cells_x, num_edges_y);
+SetLength(maze, num_cells_x, num_cells_y);
+
+num_vertices := 0;
+
+(*
+TODO - Inverted maze
+if maze_inverted then
+begin
+    bg_color := 0;
+    fg_color := COLOR_LAND;
+end
+else
+begin*)
+    bg_color := COLOR_LAND;
+    fg_color := 0;
+//end;
+
+playHeight := num_cells_y * cellsize;
+playWidth := num_cells_x * cellsize;
+off_y := LAND_HEIGHT - playHeight;
+
+for x := 0 to playWidth do
+    for y := 0 to off_y - 1 do
+        Land[y, x] := fg_color;
+
+for x := 0 to playWidth do
+    for y := off_y to LAND_HEIGHT - 1 do
+        Land[y, x] := bg_color;
+
+for y := 0 to num_cells_y - 1 do
+    for x := 0 to num_cells_x - 1 do
+        maze[x, y] := false;
+
+start_x := GetRandom(seen_cells_x);
+start_y := GetRandom(seen_cells_y);
+
+for x := 0 to seen_cells_x - 1 do
+    for y := 0 to seen_cells_y - 2 do
+        xwalls[x, y] := true;
+
+for x := 0 to seen_cells_x - 2 do
+    for y := 0 to seen_cells_y - 1 do
+        ywalls[x, y] := true;
+
+for x := 0 to seen_cells_x - 1 do
+    for y := 0 to seen_cells_y - 1 do
+        seen_list[x, y] := false;
+
+for x := 0 to num_edges_x - 1 do
+    for y := 0 to num_cells_y - 1 do
+        x_edge_list[x, y] := false;
+
+for x := 0 to num_cells_x - 1 do
+    for y := 0 to num_edges_y - 1 do
+        y_edge_list[x, y] := false;
+
+see_cell(start_x, start_y);
+
+for x := 0 to seen_cells_x - 1 do
+    for y := 0 to seen_cells_y - 1 do
+        if seen_list[x, y] then
+            maze[(x+1)*2-1, (y+1)*2-1] := true;
+
+for x := 0 to seen_cells_x - 1 do
+    for y := 0 to seen_cells_y - 2 do
+        if not xwalls[x, y] then
+            maze[x*2 + 1, y*2 + 2] := true;
+
+
+for x := 0 to seen_cells_x - 2 do
+     for y := 0 to seen_cells_y - 1 do
+        if not ywalls[x, y] then
+            maze[x*2 + 2, y*2 + 1] := true;
+
+for x := 0 to num_edges_x - 1 do
+    for y := 0 to num_cells_y - 1 do
+        if maze[x, y] xor maze[x+1, y] then
+            x_edge_list[x, y] := true
+        else
+            x_edge_list[x, y] := false;
+
+for x := 0 to num_cells_x - 1 do
+    for y := 0 to num_edges_y - 1 do
+        if maze[x, y] xor maze[x, y+1] then
+            y_edge_list[x, y] := true
+        else
+            y_edge_list[x, y] := false;
+
+for x := 0 to num_edges_x - 1 do
+    for y := 0 to num_cells_y - 1 do
+        if x_edge_list[x, y] then
+        begin
+            x_edge_list[x, y] := false;
+            add_vertex(x+1, y+1);
+            add_vertex(x+1, y);
+            add_edge(x, y-1, DIR_N);
+            add_vertex(NTPX, 0);
+        end;
+
+pa.count := num_vertices;
+
+RandomizePoints(pa);
+BezierizeEdge(pa, _0_25);
+RandomizePoints(pa);
+BezierizeEdge(pa, _0_5);
+
+DrawEdge(pa, 0);
+
+for x := 0 to num_cells_x - 1 do
+    for y := 0 to num_cells_y - 1 do
+        if maze[x, y] then begin
+            FillLand(cellsize div 2 + cellsize * x, cellsize div 2 + cellsize * y + off_y);
+            break;
+        end;
+
+MaxHedgehogs:= 32;
+hasGirders:= false;
+leftX:= 0;
+rightX:= playWidth;
+topY:= off_y;
+hasBorder := true;
+end;
+
 procedure GenLandSurface;
 var tmpsurf: PSDL_Surface;
 begin
     WriteLnToConsole('Generating land...');
-    GenBlank(EdgeTemplates[SelectTemplate]);
+    case cMapGen of
+        0: GenBlank(EdgeTemplates[SelectTemplate]);
+        1: GenMaze;
+    end;
     AddProgress();
 
     tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH, LAND_HEIGHT, 32, RMask, GMask, BMask, 0);
@@ -838,7 +1183,10 @@
     Preview: TPreview;
 begin
 WriteLnToConsole('Generating preview...');
-GenBlank(EdgeTemplates[SelectTemplate]);
+case cMapGen of
+    0: GenBlank(EdgeTemplates[SelectTemplate]);
+    1: GenMaze;
+end;
 
 for y:= 0 to 127 do
     for x:= 0 to 31 do
--- a/hedgewars/uMisc.pas	Sun Mar 28 00:46:34 2010 +0000
+++ b/hedgewars/uMisc.pas	Sun Mar 28 02:49:39 2010 +0000
@@ -51,6 +51,8 @@
     cDamagePercent  : LongInt;
     cMineDudPercent : LongWord;
     cTemplateFilter : LongInt;
+    cMapGen         : LongInt;
+    cMazeSize       : LongInt;
 
     cHedgehogTurnTime: Longword;
     cMinesTime       : LongInt;
@@ -685,6 +687,8 @@
     cDamagePercent      := 100;
     cMineDudPercent     := 0;
     cTemplateFilter     := 0;
+    cMapGen             := 0;//MAPGEN_REGULAR
+    cMazeSize           := 0;
 
     cHedgehogTurnTime   := 45000;
     cMinesTime          := 3000;
--- a/share/hedgewars/Data/Locale/fr.txt	Sun Mar 28 00:46:34 2010 +0000
+++ b/share/hedgewars/Data/Locale/fr.txt	Sun Mar 28 02:49:39 2010 +0000
@@ -3,7 +3,7 @@
 00:00=Grenade
 00:01=Grenade à fragments
 00:02=Bazooka
-00:03=O.V.N.I.
+00:03=Abeille Autoguidé
 00:04=Fusil
 00:05=Marteau-piqueur
 00:06=Passer