[Freeciv-Dev] (PR#8672) punit->occupy has no value at the server
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8672 >
> [jdorje - Sun May 23 22:46:36 2004]:
>
> > [jdorje - Tue May 04 17:48:11 2004]:
> >
> > Originally punit->client.occupy was created so the client could
track if
> > units were occupied. It was a boolean.
> >
> > It was changed to punit->occupy and turned into an integer. I don't
> > know why. The server still doesn't use this value.
> >
> > However the AI code has started using the value. This won't work since
> > it's always 0 at the server.
> >
> > The quick fix is that the AI should call get_transporter_occupancy()
> > instead. However this function is slow. Better would be to update the
> > punit->occupy value at the server. It should be renamed
> > (punit->occupancy?) and updated in
> > load_unit_onto_transporter/unload_unit_from_transporter.
>
> The fix for this isn't entirely trivial.
>
> Using punit->client.occupy at the client doesn't work well. Because at
> the server get_unit_occupancy() must still count the units in the
> transporter. But at the client you _can't_ count the units in the
> transporter, you can only check the occupy value (at least for some
> units). So the only solution is to do an is_server check, which is just
> ugly.
>
> The alternative is to make punit->occupy work at the server. The
> biggest problem here is when loading savegames this value must be
> assembled, and it's not easy. (It would be pointless to save this
> value, since you'd still have to assemble it for old savegames.)
>
> Therefore this patch does the latter. For good measure I rename
> punit->occupy (a sucky name since this was originally a boolean value)
> as punit->occupancy and remove get_transporter_occupancy. Perhaps this
> is a little overboard but it does make things clearer.
Is this code
======================================
diff -u -r1.210 unit.c
--- common/unit.c 19 May 2004 00:49:31 -0000 1.210
+++ common/unit.c 23 May 2004 22:39:57 -0000
@@ -654,8 +654,7 @@
}
/* Make sure there's room in the transporter. */
- return (get_transporter_occupancy(ptrans)
- < get_transporter_capacity(ptrans));
+ return (ptrans->occupancy < get_transporter_capacity(ptrans));
}
======================================
going to work in the cleint?
What is the value of the occupancy filed in the server and in the
client? Maybe you should write a few words for HACKING.
|
|