summaryrefslogtreecommitdiffstats
path: root/pacman-c++/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pacman-c++/util.cpp')
-rw-r--r--pacman-c++/util.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/pacman-c++/util.cpp b/pacman-c++/util.cpp
index 31d2e79..b1848e1 100644
--- a/pacman-c++/util.cpp
+++ b/pacman-c++/util.cpp
@@ -81,8 +81,14 @@ namespace Util
81 /* this outer loop is used if there are no more valid places left 81 /* this outer loop is used if there are no more valid places left
82 * so we can change mindistance 82 * so we can change mindistance
83 */ 83 */
84 QList<QPoint> actors;
84 for(unsigned int i = 0; i < players; ++i) 85 for(unsigned int i = 0; i < players; ++i)
85 { 86 {
87 /* first remove formally placed actors from map */
88 foreach(QPoint pos, actors)
89 map[pos.x()][pos.y()] = Transmission::none;
90 actors.clear();
91
86 /* get list of valid positions */ 92 /* get list of valid positions */
87 QList<QPoint> validpos; 93 QList<QPoint> validpos;
88 for (unsigned int x = 0; x < Constants::map_size.width; ++x) 94 for (unsigned int x = 0; x < Constants::map_size.width; ++x)
@@ -101,7 +107,9 @@ namespace Util
101 int rand = (int) (validpos.size() * (qrand() / (RAND_MAX + 1.0))); 107 int rand = (int) (validpos.size() * (qrand() / (RAND_MAX + 1.0)));
102 QPoint newpos = validpos.at(rand); 108 QPoint newpos = validpos.at(rand);
103 map[newpos.x()][newpos.y()] = colors[i] | Transmission::pacman | Transmission::direction_none; 109 map[newpos.x()][newpos.y()] = colors[i] | Transmission::pacman | Transmission::direction_none;
110 actors.append(newpos);
104 validpos.removeAt(rand); 111 validpos.removeAt(rand);
112 qDebug() << "actor" << colors[i] << "at" << newpos;
105 113
106 QMutableListIterator<QPoint> j(validpos); 114 QMutableListIterator<QPoint> j(validpos);
107 while(j.hasNext()) 115 while(j.hasNext())