Parcourir la source

Meilleur gestion de la map

Arthur Brandao il y a 6 ans
Parent
commit
8592e28cda
1 fichiers modifiés avec 3 ajouts et 4 suppressions
  1. 3 4
      Serveur/game.c

+ 3 - 4
Serveur/game.c

@@ -356,7 +356,6 @@ boolean bomb_explode(Game* g, int playerIndex, int x, int y, JsonEncoder* json)
     JsonEncoder object, notif;
     JsonArray bomb, bonus, chain;
     int res, index, cBomb = 0, cBonus = 0, cChain = 0;
-    char* map;
     //Inie json
     ini_encoder(&object);
     ini_encoder(&notif);
@@ -613,8 +612,9 @@ boolean bomb_explode(Game* g, int playerIndex, int x, int y, JsonEncoder* json)
         }
     }
     //Affichage de la map
-    map = unparse_map(g->map, g->width, g->height);
-    add_string(json, "map", map);
+    free(g->mapContent);
+    g->mapContent = unparse_map(g->map, g->width, g->height);
+    add_string(json, "map", g->mapContent);
     //Ajout des json
     add_array(json, "bomb", &bomb);
     add_array(json, "bonusMalus", &bonus);
@@ -622,7 +622,6 @@ boolean bomb_explode(Game* g, int playerIndex, int x, int y, JsonEncoder* json)
     //Nettoyage
     if(playerIndex >= 0) pthread_mutex_unlock(&playerMutex[(g->index * MAXPLAYER) + playerIndex]);
     pthread_mutex_unlock(&gameMutex[g->index]);
-    free(map);
     return true;
 }