<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40207 >

> By doing a full struct copy you alias pointers in the original
> tile. This is generally a bad idea,

Indeed, it makes me cringe, but...

> though it looks like it
> will not have any unfortunate consequences in this case so long
> as all functions using the dummy tile respect its "constness"
> (and do not modify its member pointers).

It's hard to see how any function that is likely to ever be called by
this function would need to modify the tile it's passed.

I have perpetrated a certain loss of const-ness within the function --
the compiler will no longer warn if &tile is passed to a function
which doesn't promise to treat it as const. It would be possible to
create a "const struct tile *p_dummy_tile = &dummy_tile" and passing
it where possible to restore this property. Is that worth doing?

> While you are modifying references to 'tile' I would change
> the name to 'dummy' or 'dummy_tile' since 'struct tile tile'
> is an eyesore and "dummy" would clearly mark its purpose
> in the code.


It would also be possible to replace the direct contains_special()
calls with calls to the standard tile_has_special() (at the run-time
cost of adding some function calls).

Freeciv-dev mailing list

Reply via email to