Good morning for this side of the world... My patch compiles against the latest trunk, and as far as can see, it works, and even as expected. I only have to make the GTK GUI show some relevant information, because currently it always shows that the chance for a city to catch a plague is 0. It seems that, as I have planned, my patch effectively keeps cities from growing to large without certain improvements, while not setting a fixed size. A city without an aqueduct is unlikely to grow above size 8 for long. Haven't got to larger cities yet. I'll send a newer patch in a couple of days or so, with a ruleset that uses the new feature.
On 12/18/08, Madeline Book <madeline.b...@gmail.com> wrote: > On 12/17/08, Yoav Luft <yoav.l...@gmail.com> wrote: >> Hi, >> I've written a little patch to the stable tree, as a way to acquaint >> myself with the code of freeciv. >> The patch adds the new functionality of plagues to game, which are >> determined randomly based on the size, pollution, improvements and >> trade routes of a city. >> The patch segfaults on me. I get that massage: >> Program received signal SIGSEGV, Segmentation fault. >> 0x000000000041bd7d in pay_for_units (pplayer=0x861e18, pcity=0x1890fc0) >> at ../utility/speclist.h:110 >> 110 return genlist_size(tthis->list); >> >> it only happens when the game.info.plague_on is true, but I do not >> understand what genlist_size() does, or where and why it is called. It >> is my first attempt at adding code to freeciv, and I've spent some >> nights trying to understand what went wrong, but I'm kinda clueless. >> I guess it's not a bug, but rather a I didn't do something they it >> should be done, but I could find what that is. >> >> Attached is the patch. >> I will appreciate any help, even in explaining me what genlist_size does. > > The function genlist_size returns the size of a "genlist" which is a > linked list of pointers. Genlists are used to implement speclists, > which are just macro-generated interfaces to the genlist functions > for specific data types (to avoid the type unsafe void pointers used > by genlists). These data structures are defined in utility/genlist.h > and utility/speclist.h. > > The particular segfault you have there is in all likelyhood caused > by an operation on a NULL list somewhere; it would help if you > looked at the entire backtrace to see the history of function calls. > Then when you have a rough idea of where the NULL list might > be, you can use gdb to step through the code or just insert some > printfs (:D) to have the program tell you how far it gets before > crashing. Once you pin point the location of the NULL access you > can trace back the code path and find what caused the list to > be NULL in the first place (you would check all the changes you > made that get activated by your new setting). > > There is some information about using gdb for debugging here: > http://freeciv.wikia.com/wiki/Bug_Reporting > > Also, I looked at your patch and it is actually not that bad at first > glance. Granted you need to setup diff to ignore all those useless > files that change every configure/make cycle, and setup your > editor to follow the freeciv coding style more closely. Of course > this is only if you intend to submit your patch for inclusion later. > > Here are some more helpful pages: > http://freeciv.wikia.com/wiki/How_to_Contribute > http://freeciv.wikia.com/wiki/Coding_Style > > Oh and by the way, you should implement new features on the > trunk branch; the "stable" 2.1.x series is only getting bugfixes > now. > > ----------------------------------------------------------------------- > 黒死病で死にたくない。 > _______________________________________________ Freeciv-dev mailing list Freecivfirstname.lastname@example.org https://mail.gna.org/listinfo/freeciv-dev