|
@@ -444,8 +444,15 @@ int handler_player_move(int cliId, JsonParser* json) {
|
|
|
if (mine) {
|
|
|
JsonEncoder notif;
|
|
|
ini_encoder(¬if);
|
|
|
- if(!bomb_explode(&game[index], -1, x, y, ¬if)){
|
|
|
- adderror("Erreur explosion mine");
|
|
|
+ if (bomb_explode(&game[index], playerIndex, x, y, ¬if)) {
|
|
|
+ //Notification joueurs
|
|
|
+ if (!notify_player(&game[index], "POST", "attack/explose", ¬if, -1)) {
|
|
|
+ adderror("Impossible de notifier les joueurs");
|
|
|
+ clean_json_encoder(¬if);
|
|
|
+ clean_json_encoder(&reponse);
|
|
|
+ free(move);
|
|
|
+ return FAIL;
|
|
|
+ }
|
|
|
}
|
|
|
clean_json_encoder(¬if);
|
|
|
}
|
|
@@ -635,7 +642,7 @@ int handler_attack_bomb(int cliId, JsonParser* json) {
|
|
|
p->classicBomb--;
|
|
|
game[index].map[x][y] = '1';
|
|
|
//Lance timer
|
|
|
- int* tab = malloc(sizeof(int) * 2);
|
|
|
+ int* tab = malloc(sizeof (int) * 2);
|
|
|
tab[0] = x;
|
|
|
tab[1] = y;
|
|
|
//Ajout bombe
|
|
@@ -719,7 +726,7 @@ int handler_attack_bomb(int cliId, JsonParser* json) {
|
|
|
return SUCCESS;
|
|
|
}
|
|
|
|
|
|
-int handler_attack_remote_go(int cliId, JsonParser* json){
|
|
|
+int handler_attack_remote_go(int cliId, JsonParser* json) {
|
|
|
int index, playerIndex;
|
|
|
JsonEncoder notif;
|
|
|
Player* p = NULL;
|
|
@@ -747,15 +754,15 @@ int handler_attack_remote_go(int cliId, JsonParser* json){
|
|
|
}
|
|
|
//Explose toutes les remotes du joueur
|
|
|
objn = p->bomb->first;
|
|
|
- while(objn != NULL){
|
|
|
+ while (objn != NULL) {
|
|
|
tmp = objn->next;
|
|
|
- if(objn->type == OBJ_BREMOTE){
|
|
|
+ if (objn->type == OBJ_BREMOTE) {
|
|
|
//Retire mutex gérés dans fonctions
|
|
|
pthread_mutex_unlock(&playerMutex[(index * MAXPLAYER) + playerIndex]);
|
|
|
pthread_mutex_unlock(&gameMutex[index]);
|
|
|
- if(bomb_explode(&game[index], playerIndex, objn->x, objn->y, ¬if)){
|
|
|
+ if (bomb_explode(&game[index], playerIndex, objn->x, objn->y, ¬if)) {
|
|
|
//Notification joueurs
|
|
|
- if(!notify_player(&game[index], "POST", "attack/explose", ¬if, -1)){
|
|
|
+ if (!notify_player(&game[index], "POST", "attack/explose", ¬if, -1)) {
|
|
|
adderror("Impossible de notifier le joueur de l'explosion");
|
|
|
}
|
|
|
clean_json_encoder(¬if);
|