From: H.G. Muller Date: Fri, 12 Mar 2010 08:07:46 +0000 (+0100) Subject: Fix crash on rated Gothic games X-Git-Url: http://winboard.nl/cgi-bin?p=capablanca.git;a=commitdiff_plain;h=e0c6e5ba79b1df3450fda89f9e7beacdc62103d1;hp=707e46a1e2dba3ef53b97c63520d50f4ecc3996b Fix crash on rated Gothic games The new game types were not everywere mapped on rating types, leading to a crash. Types KNIGHTMATE, CAPABLANCA and GOTHIC are for the time being now all treated as WILD, in rating calculations. Eventually these should all have their own rating type, but this requires an extension of the rating database format. --- diff --git a/lasker-2.2.3/src/gamedb.c b/lasker-2.2.3/src/gamedb.c index 666b5ed..0d1223f 100644 --- a/lasker-2.2.3/src/gamedb.c +++ b/lasker-2.2.3/src/gamedb.c @@ -1216,6 +1216,7 @@ static void write_g_out(int g, char *file, int maxlines, int isDraw, type[1] = 'b'; } 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) { wr = player_globals.parray[wp].w_stats.rating; br = player_globals.parray[bp].w_stats.rating; diff --git a/lasker-2.2.3/src/ratings.c b/lasker-2.2.3/src/ratings.c index 55eaa74..6a6f629 100644 --- a/lasker-2.2.3/src/ratings.c +++ b/lasker-2.2.3/src/ratings.c @@ -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; }