No more crashes when running quick game flibqtfrontend
authorunc0rr
Tue, 27 Nov 2012 00:29:41 +0400
branchflibqtfrontend
changeset 8130 4cab13c82b4e
parent 8128 ebef2de30c18
child 8132 f68b43cf510f
child 8133 2d0f56423eb3
No more crashes when running quick game
QTfrontend/game.cpp
QTfrontend/team.cpp
QTfrontend/ui/widget/mapContainer.cpp
--- a/QTfrontend/game.cpp	Mon Nov 26 00:28:47 2012 +0400
+++ b/QTfrontend/game.cpp	Tue Nov 27 00:29:41 2012 +0400
@@ -345,7 +345,7 @@
     gameSetup.map = flib_map_create_regular(
                 QUuid::createUuid().toByteArray().constData()
                 , themeModel->rowCount() > 0 ? themeModel->index(rand() % themeModel->rowCount()).data().toString().toUtf8().constData() : "Sheep"
-                , 3);
+                , 2);
     gameSetup.teamlist = flib_teamlist_create();
 
     // add teams
@@ -368,21 +368,20 @@
 
     for(int i = 0; i < 2; ++i)
     {
-        flib_weaponset *set = flib_weaponset_create("Default");
         flib_team *team = teams[i];
         team->hogsInGame = 4;
         team->remoteDriven = false;
         for(int h = 0; h < HEDGEHOGS_PER_TEAM; ++h)
-            team->hogs[h].weaponset = set;
+        {
+            team->hogs[h].weaponset = flib_weaponset_create("Default");
+            team->hogs[h].initialHealth = 100;
+        }
         flib_teamlist_insert(gameSetup.teamlist, team, 0);
     }
 
 
     m_conn = flib_gameconn_create(config->netNick().toUtf8().constData(), &gameSetup, false);
 
-    for(int i = 0; i < 2; ++i)
-        flib_weaponset_destroy(teams[i]->hogs[0].weaponset);
-
     flib_teamlist_destroy(gameSetup.teamlist);
     flib_map_destroy(gameSetup.map);
     flib_scheme_destroy(gameSetup.gamescheme);
--- a/QTfrontend/team.cpp	Mon Nov 26 00:28:47 2012 +0400
+++ b/QTfrontend/team.cpp	Tue Nov 27 00:29:41 2012 +0400
@@ -221,7 +221,7 @@
 {
     free(m_team->name);
 
-    m_team->name = qstrdup(name.toUtf8().constData());
+    m_team->name = strdup(name.toUtf8().constData());
 }
 
 QString HWTeam::hedgehogName(int index) const
@@ -238,14 +238,14 @@
 {
     free(m_team->hogs[index].name);
 
-    m_team->hogs[index].name = qstrdup(name.toUtf8().constData());
+    m_team->hogs[index].name = strdup(name.toUtf8().constData());
 }
 
 void HWTeam::setHedgehogHat(int index, const QString & hat)
 {
     free(m_team->hogs[index].hat);
 
-    m_team->hogs[index].hat = qstrdup(hat.toUtf8().constData());
+    m_team->hogs[index].hat = strdup(hat.toUtf8().constData());
 }
 
 
@@ -296,7 +296,7 @@
 {
     free(m_team->bindings[idx].binding);
 
-    m_team->bindings[idx].binding = qstrdup(key.toUtf8().constData());
+    m_team->bindings[idx].binding = strdup(key.toUtf8().constData());
 }
 
 // flag
@@ -381,5 +381,5 @@
 
 flib_team * HWTeam::toFlibTeam()
 {
-    return m_team;
+    return flib_team_copy(m_team);
 }
--- a/QTfrontend/ui/widget/mapContainer.cpp	Mon Nov 26 00:28:47 2012 +0400
+++ b/QTfrontend/ui/widget/mapContainer.cpp	Tue Nov 27 00:29:41 2012 +0400
@@ -44,6 +44,7 @@
     mapgen(MAPGEN_REGULAR),
     m_previewSize(256, 128)
 {
+    m_mapInfo.type = MapModel::GeneratedMap;
     hhSmall.load(":/res/hh_small.png");
     hhLimit = 18;
     templateFilter = 0;