[Freeciv-Dev] (PR#11058) pubserver diplomat crash in vnotify_conn_ex
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=11058 >
Got it too, traced to the following mistake in diplomat_sabotage():
improvement can be B_LAST, then the target is randomly selected and put
into "target"; still some code uses improvement as if it is a valid impr_id
Attached fix also fixes a maths mistake: to sabotage a specific impr,
the probability is halved (according to the rules) but the code squared
it instead.
Gr
? civ.serv
? core.18404
? ttt
Index: server/diplomats.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplomats.c,v
retrieving revision 1.62
diff -u -r1.62 diplomats.c
--- server/diplomats.c 11 Oct 2004 01:42:33 -0000 1.62
+++ server/diplomats.c 18 Nov 2004 05:16:09 -0000
@@ -869,6 +869,9 @@
struct player *cplayer;
int count, which, target;
const char *prod;
+ /* Twice as difficult if target is specified. */
+ int success_prob = (improvement >= B_LAST ? game.diplchance
+ : game.diplchance / 2);
/* Fetch target city's player. Sanity checks. */
if (!pcity)
@@ -892,9 +895,7 @@
freelog (LOG_DEBUG, "sabotage: infiltrated");
/* Check if the Diplomat/Spy succeeds with his/her task. */
- /* (Twice as difficult if target is specified.) */
- if ((myrand (100) >= game.diplchance) ||
- ((improvement != B_LAST) && (myrand (100) >= game.diplchance))) {
+ if (myrand (100) >= success_prob) {
notify_player_ex(pplayer, pcity->tile, E_MY_DIPLOMAT_FAILED,
_("Game: Your %s was caught in the attempt"
" of industrial sabotage!"),
@@ -1029,7 +1030,7 @@
* If target was specified, and it is in the capital or are
* City Walls, then there is a 50% chance of getting caught.
*/
- vulnerability = get_improvement_type(improvement)->sabotage;
+ vulnerability = get_improvement_type(target)->sabotage;
vulnerability -= (vulnerability
* get_city_bonus(pcity, EFT_SPY_RESISTANT) / 100);
@@ -1044,7 +1045,7 @@
" to sabotage the %s in %s!"),
get_nation_name(pplayer->nation),
unit_name(pdiplomat->type),
- get_improvement_name(improvement), pcity->name);
+ get_improvement_name(target), pcity->name);
wipe_unit(pdiplomat);
freelog (LOG_DEBUG, "sabotage: caught in capital or on city walls");
return;
|
|