Follow-up Comment #4, bug #13587 (project freeciv):

Alright, I was not sufficiently clear in my
last comments, so I will explain what I meant.

I wanted you to change unit_upkeep_text() to
take an astring parameter:

void unit_upkeep_text(const struct unit *punit, struct astring *astr);

and have the function append its text to the end
of 'astr', if it should add any text at all (i.e.
if the client's player is not the unit owner, it
would not add anything).

The point is to avoid static variables, because
they make the code non re-entrant. This means
that it would not be safe to use this code with
threads, or even to call this function twice in
the same expression (e.g. in the arguments of a
printf style function). While freeciv does not
use threads, making code re-entrant generally
results in a cleaner and more modular design,
as well as leaving the possibility of thread use
open for the future.

Also, do not include headers in other headers
(as I have told you in another ticket, sorry if
I repeat myself :)). When you have a pointer to
some undefined struct, you can just use a forward
declaration:

struct astring;
void unit_upkeep_text(const struct unit *punit, struct astring *astr);

then include the real header in the c file where
the function is implemented.


----------------------------------------------------------------
というわけです。

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?13587>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to