Re: [Freeciv-Dev] Fwd: Longturn Freeciv
This is great news, Matthias. What do you think about setting the maximum number of players to 1024? Also, how should Freeciv assign nations and flags to all these players? -Andreas At the moment freeciv (trunk) has 205 nations. Thus, I think that 128 player are more than enough. Furthermore, a balance between the memory requirement and the normally used number of players has to be found. If you need more player you can create your own server by increasing MAX_NUM_PLAYERS (this will be incompatible!). Nations and flags are automatically (randomly) assigned to the players if they do not select one. The patch as well as additional cleanups can be found in https://gna.org/patch/index.php?1732. Especially the information about the vision need changes. Matthias -- Matthias Pfafferodt - http://www.mapfa.de Matthias.Pfafferodt at mapfa.de ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] Fwd: Longturn Freeciv
Am Friday 02 July 2010 23:18:05 schrieb Matthias Pfafferodt: 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 ... in a second try even saving seems to work ... but I do not know if there is not a big bug waiting somethere ... Patched servers/clients are *INCOMPATIBLE* to all other versions of freeciv! This is great news, Matthias. What do you think about setting the maximum number of players to 1024? Also, how should Freeciv assign nations and flags to all these players? -Andreas ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] Fwd: Longturn Freeciv
On Thu, 1 Jul 2010, Matthias Pfafferodt wrote: Do not expect the patches to apply cleanly or even to work. They are based on the svn from 2010-04-21 patch 'Add utilities to make safe operations on UTF-8 strings.'. I do not have the svn ID as I import the svn into a git repo. Some additional ideas how to do this (I pondered this a long time) : - if the number of player is increased, the player struct should be defined as pointer - some data in the struct is saved for each player (diplstat), thus old player *must not* be removed; else one cannot access this data using the player id (= index of the player in the corresponding list) - as result, the player struct should be divided into two parts; one with the basic data (name) and one with all the data only needed if the player is alive - speclist.h should be used for the list of players and also the additional data per player (player-diplstat) - there should be functions to add a player (to the list of players and also to the diplstat of *each* player) and to kill a player (remove the variable data part and set the diplstat to a defined state) - the network protocol and the client have to be checked (can they handle the changes?) Thanks for the interesting info, Matthias. Could you please elaborate a little? Why are these changes necessary to increase the number of possible players? - Andreas ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] Fwd: Longturn Freeciv
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! Theoretically, you could increase the number of players by increasing MAX_NUM_PLAYERS in common/fc_types.h. But if you try this you will get a segmentation fault quickly. This is due to the fact that the code often assumes that there are no more than 32 players. You have to find and fix all these code blocks. If you are doing this, you will have to change or even rewrite some code. The above list proposes a new structure of the player code which is (I hope) robust for a high number of players. It especially can handle the addition of players while keeping the basic data of the old players using only a small amount of memory. You could also try to use the current structure which allocates the player as a static variable at the start of the server (as done by only increasing MAX_NUM_PLAYERS). It's the easy way out. But even doing this, you will have to solve a lot of segmentation faults. If I try the above and define a game with 32 players, I hit an assert in the team code after executing the start command: Core was generated by `./server/freeciv-server'. Program terminated with signal 11, Segmentation fault. #0 0x00480ee7 in real_sanity_check (file=0x5a0918 srv_main.c, function=0x5a162c begin_turn, line=752) at sanitycheck.c:528 528 SANITY_CHECK(team_by_number(i)-players == count[i]); (gdb) bt full #0 0x00480ee7 in real_sanity_check (file=0x5a0918 srv_main.c, function=0x5a162c begin_turn, line=752) at sanitycheck.c:528 No locals. #1 0x0040c0b9 in srv_main () at srv_main.c:752 __FUNCTION__ = srv_main #2 0x00404099 in main (argc=1, argv=0x7fff669f38a8) at civserver.c:376 inx = 1 showhelp = false showvers = false option = value optimized out __FUNCTION__ = main I think there are a lot such small things to solve before it is working ... (I did not further investigate this one). Matthias - Andreas ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev -- Matthias Pfafferodt - http://www.mapfa.de Matthias.Pfafferodt at mapfa.de ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] Fwd: Longturn Freeciv
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 free...@mapfa.de 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 Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] Fwd: Longturn Freeciv
Am Friday 02 July 2010 23:18:05 schrieb Matthias Pfafferodt: 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 ... in a second try even saving seems to work ... but I do not know if there is not a big bug waiting somethere ... Patched servers/clients are *INCOMPATIBLE* to all other versions of freeciv! Matthias -- Matthias Pfafferodt - http://www.mapfa.de Matthias.Pfafferodt at mapfa.de ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] Fwd: Longturn Freeciv
Great. Would you be interested in sharing how the code needs to be cleaned up? Perhaps I can help with making the changed necessary to making this work. - Andreas Have a look at the source code and the attached patches. At the moment all player slots are statically allocated. I did try to change this to a player list. Therefore I first renamed some functions (to player_id() and player_by_name()). After that I wanted to do all at once, but this did not work. At that time I also got the feeling that small steps are needed. But as the player definition and also the map definition are one of the basic data of freeciv it is interconnected with all the code. At the end I through about this roadmap: 1) implement players as pointer 2) add player_list 3) make the required changes to the player struct (step by step) 4) increase the number of players Do not expect the patches to apply cleanly or even to work. They are based on the svn from 2010-04-21 patch 'Add utilities to make safe operations on UTF-8 strings.'. I do not have the svn ID as I import the svn into a git repo. Some additional ideas how to do this (I pondered this a long time) : - if the number of player is increased, the player struct should be defined as pointer - some data in the struct is saved for each player (diplstat), thus old player *must not* be removed; else one cannot access this data using the player id (= index of the player in the corresponding list) - as result, the player struct should be divided into two parts; one with the basic data (name) and one with all the data only needed if the player is alive - speclist.h should be used for the list of players and also the additional data per player (player-diplstat) - there should be functions to add a player (to the list of players and also to the diplstat of *each* player) and to kill a player (remove the variable data part and set the diplstat to a defined state) - the network protocol and the client have to be checked (can they handle the changes?) My TODO list is at the moment as follows (no guarantee and no deadline; I could even stop ...): short time: - bug fixes and small changes (gtk client) long time: - merge longturn - check enums / code cleanup far away: - save ruleset in one file and use it to send the ruleset to the clients - savegame cleanup (and save ruleset in savegame) far far away: - mapimg (save an image of the map for each turn; this is at the moment at the end of the list, but a nice project; once upon a time parts of it were working ...) dreaming: - loyal citizens - more players - larger maps - ... Matthias I have to do other things at the moment and freeciv is only a tool to distract me ... (but the original task has to be done!) Matthias -- Matthias Pfafferodt - http://www.mapfa.de Matthias.Pfafferodt at mapfa.de ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] Fwd: Longturn Freeciv
Am Wednesday 30 June 2010 19:34:48 schrieb John Wilson: * Very large maps: For Longturn games, I think it should be possible to have much larger maps. This would allow many more players to play simulaneously. There seems to be a limit of 256x256 tiles at the moment. I have done some experiments with maps of 1024x1024 tiles, but I get mostly segmentation faults. A while ago I requested the max map size to be raised from 29 to 30 in bug #14661 and pepeto said this: As far as I know, the maximum number of tiles is (2^15 - 1) because on some places, the code assume the tile index is an signed short integer (e.g. path finding code). The size is automatically adjusted on the generator, and usually you don't get exactly the number of tiles you requested. So, a margin must be hold. Maybe that gives a little more insight. Yes, I did checked the code. If one wants to change the maximal number of tiles (= map size) a lot of code has to be rewritten. If you take the numbers it would be possible to go up to (2^15 - 1) = 32767 tiles. If I remember correctly, one could replace the signed short integer by a signed integer. This would increase the possible map size to 2^31 - 1 but would also increase the calculation time for the path finding code as well as the memory requirement. Matthias -- Matthias Pfafferodt - http://www.mapfa.de Matthias.Pfafferodt at mapfa.de ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] Fwd: Longturn Freeciv
On Wed, 30 Jun 2010, Matthias Pfafferodt wrote: Am Wednesday 30 June 2010 19:34:48 schrieb John Wilson: * Very large maps: For Longturn games, I think it should be possible to have much larger maps. This would allow many more players to play simulaneously. There seems to be a limit of 256x256 tiles at the moment. I have done some experiments with maps of 1024x1024 tiles, but I get mostly segmentation faults. A while ago I requested the max map size to be raised from 29 to 30 in bug #14661 and pepeto said this: As far as I know, the maximum number of tiles is (2^15 - 1) because on some places, the code assume the tile index is an signed short integer (e.g. path finding code). The size is automatically adjusted on the generator, and usually you don't get exactly the number of tiles you requested. So, a margin must be hold. Maybe that gives a little more insight. Yes, I did checked the code. If one wants to change the maximal number of tiles (= map size) a lot of code has to be rewritten. If you take the numbers it would be possible to go up to (2^15 - 1) = 32767 tiles. If I remember correctly, one could replace the signed short integer by a signed integer. This would increase the possible map size to 2^31 - 1 but would also increase the calculation time for the path finding code as well as the memory requirement. I'm very positive to increasing the maximum map size, and also maximum number of players. Would anyone be interested in creating a patch to increase the maximum map size and player limit? It could be a compile-time configuration-option if necessary. As Matthias said, it would require changes to the path-finding code. I think it would also require changes to the map generators, and rendering of the overview map in the clients. Regards, Andreas R. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] Fwd: Longturn Freeciv
On Wed, 30 Jun 2010, Matthias Pfafferodt wrote: Am Wednesday 30 June 2010 20:16:07 schrieb Andreas Røsdal: I'm very positive to increasing the maximum map size, and also maximum number of players. Would anyone be interested in creating a patch to increase the maximum map size and player limit? It could be a compile-time configuration-option if necessary. As Matthias said, it would require changes to the path-finding code. I think it would also require changes to the map generators, and rendering of the overview map in the clients. Some time ago I did check how hard this would be - and stopped. Before this can be done some cleanup of the code is needed. Both features touch a lot of code which is quite old and has to be checked before. Matthias Great. Would you be interested in sharing how the code needs to be cleaned up? Perhaps I can help with making the changed necessary to making this work. - Andreas___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev