Fix crash on rated Gothic games
[capablanca.git] / lasker-2.2.3 / src / ratings.c
index 55eaa74..6a6f629 100644 (file)
@@ -102,7 +102,7 @@ static void rating_add(int rating, int type)
     }
     Ratings_B_StdDev = sqrt(Rb_S / Rb_count);
     Ratings_B_Average = Rb_total / (double) Rb_count;
-  } else if (type == TYPE_WILD) {      /* TYPE_WILD */
+  } else if (type == TYPE_WILD || type == TYPE_KNIGHTMATE || type == TYPE_GOTHIC || type == TYPE_CAPABLANCA) { /* TYPE_WILD */
     wHist[which] += 1;
     Rw_count++;
     Rw_total += rating;
@@ -186,7 +186,7 @@ static void rating_remove(int rating, int type)
       Ratings_B_StdDev = 0;
       Ratings_B_Average = 0;
     }
-  } else if (type == TYPE_WILD) {      /* TYPE_WILD */
+  } else if (type == TYPE_WILD || type == TYPE_KNIGHTMATE || type == TYPE_GOTHIC || type == TYPE_CAPABLANCA) { /* TYPE_WILD */
     wHist[which] = wHist[which] - 1;
     if (wHist[which] < 0)
       wHist[which] = 0;
@@ -466,6 +466,9 @@ static void GetCurrentStats (int p, int *r, double *s, int *new,
       p_stats = &pp->s_stats;
       break;
     case TYPE_WILD:
+    case TYPE_KNIGHTMATE:
+    case TYPE_CAPABLANCA:
+    case TYPE_GOTHIC:
       p_stats = &pp->w_stats;
       break;
     case TYPE_LIGHT:
@@ -549,7 +552,10 @@ int rating_update(int g, int link_game)
   } else if (game_globals.garray[g].type == TYPE_STAND) {
     w_stats = &player_globals.parray[game_globals.garray[g].white].s_stats;
     b_stats = &player_globals.parray[game_globals.garray[g].black].s_stats;
-  } else if (game_globals.garray[g].type == TYPE_WILD) {
+  } else if (game_globals.garray[g].type == TYPE_WILD
+          || game_globals.garray[g].type == TYPE_KNIGHTMATE
+          || game_globals.garray[g].type == TYPE_GOTHIC
+          || game_globals.garray[g].type == TYPE_CAPABLANCA) {
     w_stats = &player_globals.parray[game_globals.garray[g].white].w_stats;
     b_stats = &player_globals.parray[game_globals.garray[g].black].w_stats;
   } else if (game_globals.garray[g].type == TYPE_LIGHT) {
@@ -692,7 +698,10 @@ int rating_update(int g, int link_game)
   } else if (game_globals.garray[g].type == TYPE_BUGHOUSE) {
     Rbug_count++;
     Rbug_total += (w_stats->rating + b_stats->rating) / 2.0;
-  } else if (game_globals.garray[g].type == TYPE_WILD) {
+  } else if (game_globals.garray[g].type == TYPE_WILD
+          || game_globals.garray[g].type == TYPE_KNIGHTMATE
+          || game_globals.garray[g].type == TYPE_CAPABLANCA
+          || game_globals.garray[g].type == TYPE_GOTHIC) {
     Rw_count++;
     Rw_total += (w_stats->rating + b_stats->rating) / 2.0;
   }