Am Friday 02 July 2010 19:18:27 schrieb Matthias Pfafferodt: > > Thanks for the interesting info, Matthias. Could you please elaborate a > > little? Why are these changes necessary to increase the number of > > possible players? > > First of, I'm *not* an expert! That I'm telling you could be wrong. It > includes the knowledge I got from looking at the code and some testing!
[... a lot of text ...] You got me to really try it. It is possible - not nice, but possible. The attached patch increases the player number to 128. If MAX_NUM_PLAYER is changed even higher numbers are possible. But at the moment you cant save the game as the savegame format is not prepared for such a number of players ... Patched servers/clients are *INCOMPATIBLE* to all other versions of freeciv! Matthias -- Matthias Pfafferodt - http://www.mapfa.de Matthias.Pfafferodt <at> mapfa.de
From b16e1dbc3c0f6831942c1dbbdf41d16bacc25372 Mon Sep 17 00:00:00 2001 From: syntron <[email protected]> Date: Fri, 2 Jul 2010 23:07:28 +0200 Subject: [PATCH] increase number of players - dirty hack(s) - *incompatible* network protocol - memory requirements? --- client/tilespec.c | 30 +++++++++++++++++++++++++++--- common/fc_types.h | 2 +- server/ruleset.c | 10 ++++++++++ server/sanitycheck.c | 4 +++- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/client/tilespec.c b/client/tilespec.c index c6b3c2e..8e068bb 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -2447,9 +2447,33 @@ static void tileset_lookup_sprite_tags(struct tileset *t) SET_SPRITE(tx.fog, "tx.fog"); /* Load color sprites. */ - for (i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) { - fc_snprintf(buffer, sizeof(buffer), "colors.player%d", i); - SET_SPRITE(colors.player[i], buffer); + { + /* Loop over all players and load the corresponding colors. If there + * are no more colors start again with color 0. */ + int last = -1; /* the last valid player color */ + for (i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) { + if (last == -1) { + j = i; + } else { + j = i % last; + } + + fc_snprintf(buffer, sizeof(buffer), "colors.player%d", j); + t->sprites.colors.player[i] = load_sprite(t, buffer); + + if (last == -1 && NULL == t->sprites.colors.player[i]) { + last = i; + /* repeat this loop */ + i--; + } + + if (i == 0 && last == 0) { + /* no color defined */ + fc_assert_exit_msg(NULL != t->sprites.colors.player[i], + "No player colors defined (sprite tag '%s' " + "missing).", buffer); + } + } } SET_SPRITE(colors.background, "colors.background"); sprite_vector_init(&t->sprites.colors.overlays); diff --git a/common/fc_types.h b/common/fc_types.h index 996ee23..2883001 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -24,7 +24,7 @@ * directory! */ /* MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS <= 32 !!!! */ -#define MAX_NUM_PLAYERS 30 +#define MAX_NUM_PLAYERS 126 #define MAX_NUM_BARBARIANS 2 #define MAX_NUM_CONNECTIONS (2 * (MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS)) #define MAX_NUM_ITEMS 200 /* eg, unit_types */ diff --git a/server/ruleset.c b/server/ruleset.c index c1d5bc3..5da2def 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -3437,6 +3437,16 @@ static void load_ruleset_game(void) sz_strlcpy(game.info.team_names_orig[i], svec[i]); } free(svec); + if (game.info.num_teams < MAX_NUM_TEAMS) { + log_error("Not enough team names defined (have: %d; need: %d). " + "Creating missing names ...", game.info.num_teams, + MAX_NUM_TEAMS); + for (; game.info.num_teams < MAX_NUM_TEAMS; game.info.num_teams++) { + fc_snprintf(game.info.team_names_orig[game.info.num_teams], + sizeof(game.info.team_names_orig[game.info.num_teams]), + "Team %d", game.info.num_teams); + } + } settings_ruleset(file, "settings"); diff --git a/server/sanitycheck.c b/server/sanitycheck.c index d900102..288b3f0 100644 --- a/server/sanitycheck.c +++ b/server/sanitycheck.c @@ -525,7 +525,9 @@ static void check_teams(const char *file, const char *function, int line) } players_iterate_end; for (i = 0; i < MAX_NUM_TEAMS; i++) { - SANITY_CHECK(team_by_number(i)->players == count[i]); + struct team *t = team_by_number(i); + fc_assert_exit(t); + SANITY_CHECK(t->players == count[i]); } } -- 1.6.0.2
_______________________________________________ Freeciv-dev mailing list [email protected] https://mail.gna.org/listinfo/freeciv-dev
