rewrote IRC cache parser to be (hopefully) more stable
[NeonServV5.git] / src / modules / NeonFun.mod / game_4wins.c
index 88503a184cec1bfcc15869a88eb10c66d075db3a..3b55d146ae024704461bc9d1e16af960ae5ef6d0 100644 (file)
@@ -78,7 +78,7 @@ int fourwins_check_win(struct fourwins_game *game, int x, int y) {
             else
                 break;
         }
-        for(ix = x, iy = y; ix >= 0 && iy >= 0; ix--, iy--) {
+        for(ix = x-1, iy = y-1; ix >= 0 && iy >= 0; ix--, iy--) {
             if(game->matrix[ix][iy].field == field)
                 fc++;
             else
@@ -96,7 +96,7 @@ int fourwins_check_win(struct fourwins_game *game, int x, int y) {
             else
                 break;
         }
-        for(ix = x, iy = y; ix >= 0 && iy < FOURWINS_MATRIX_HEIGHT; ix--, iy++) {
+        for(ix = x-1, iy = y+1; ix >= 0 && iy < FOURWINS_MATRIX_HEIGHT; ix--, iy++) {
             if(game->matrix[ix][iy].field == field)
                 fc++;
             else
@@ -148,7 +148,8 @@ void fourwins_free_game(struct fourwins_game *game) {
             if(prev)
                 prev->next = game->next;
             else
-                fourwins_active_games->next = game->next;
+                fourwins_active_games = game->next;
+            break;
         } else
             prev = cgame;
     }
@@ -178,29 +179,6 @@ void fourwins_event_part(struct ChanUser *chanuser) {
     }
 }
 
-void fourwins_event_quit(struct UserNode *user) {
-    struct fourwins_game *game;
-    for(game = fourwins_active_games; game; game = game->next) {
-        if(game->player[0]->user == user || game->player[1]->user == user) {
-            fourwins_reply(game, "NF_4WINS_GAME_CLOSED");
-            fourwins_free_game(game);
-            return;
-        }
-        struct fourwins_guest *guest, *prev_guest = NULL;
-        for(guest = game->guests; guest; guest = guest->next) {
-            if(guest->chanuser->user == user) {
-                if(prev_guest)
-                    prev_guest->next = guest->next;
-                else
-                    game->guests = guest->next;
-                free(guest);
-                break;
-            } else
-                prev_guest = guest;
-        }
-    }
-}
-
 void fourwins_event_freechan(struct ChanNode *chan) {
     struct fourwins_game *game;
     for(game = fourwins_active_games; game; game = game->next) {