So how about this patch. Apart from some trivial comment cleanups, it
attempts to restore the 10 fps behaviour.
I've done some testing with a modified Python client that sends eight
CP_TORP packets for every mouse click. On a local server, without this
patch, I got just one torp. On continuum, I got two. On pickled, I got
one. Continuum is on 50 fps. Pickled is on 10 fps.
The patch also changes the static variable to match the same bit length
as the p_updates variable, and notes that it introduces a bug that will
stop a ship firing torps after 497 days alive at 50 fps ... which is
2^31 frames.
--- old-netrek-server/Vanilla/ntserv/torp.c 2008-07-17 14:44:43.000000000 +1000
+++ new-netrek-server/Vanilla/ntserv/torp.c 2008-07-17 14:44:43.000000000 +1000
@@ -51,15 +51,16 @@
*/
void ntorp(u_char course, int attributes)
{
- static LONG last_torp_fired_update = 0;
+ static int last_torp_fired_update = 0;
struct torp *k;
if (status->gameup & GU_CONQUER) return;
/*
* Prevent player from firing more than one torp per update. */
- if (me->p_updates == last_torp_fired_update)
+ if (me->p_updates < (last_torp_fired_update + (fps / 10)))
return;
+ /*! @bug ship may stop firing torps after 497 days alive at 50 fps */
if (me->p_flags & PFWEP) {
new_warning(25, "Torpedo launch tubes have exceeded maximum safe temperature!");
@@ -138,8 +139,7 @@
me->p_fuel -= myship->s_torpcost;
me->p_wtemp += (myship->s_torpcost / 10) - 10; /* Heat weapons */
- /*
- * Initialize torp: */
+ /* initialize torp */
k->t_status = TMOVE;
k->t_type = TPHOTON;
k->t_attribute = attributes;
@@ -164,13 +164,9 @@
#endif
#ifdef LTD_STATS
-
- /* At this point, a torpedo was fired */
if (status->tourn) {
ltd_update_torp_fired(me);
}
-
#endif
-
}
--
James Cameron mailto:quozl at us.netrek.org http://quozl.netrek.org/