From 2402f3f2a2402d307e857519aee60f2a96e9bbb2 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 18 Jul 2016 21:14:30 +0200 Subject: [PATCH] lost: Fix to track more than one lost sector per owner makelost() overwrites an existing entry for the same thing, else creates a new one. It calls findlost() to find existing entries. findlost() means to look up by coordinates if it's looking for a sector entry, and by ID if it's looking for a ship, plane, land unit or nuke entry. It actually does both for sectors. Since callers pass zero ID for sectors, sector entries always match, so at most one gets created, and additional ones overwrite it. Broken since the lost table was introduced in 4.0.7. Fix the flawed comparison in findlost(). Signed-off-by: Markus Armbruster --- src/lib/subs/lostsub.c | 2 +- tests/actofgod/final.xdump | 7 +++++++ tests/bridgefall/final.xdump | 13 +++++++++++-- tests/smoke/final.xdump | 1 + tests/smoke/journal.log | 3 ++- tests/update/final.xdump | 3 +++ 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/lib/subs/lostsub.c b/src/lib/subs/lostsub.c index 31b44331..613ce2b1 100644 --- a/src/lib/subs/lostsub.c +++ b/src/lib/subs/lostsub.c @@ -109,7 +109,7 @@ findlost(int type, natid owner, int id, coord x, coord y, int free) if (lost.lost_owner == owner && type == lost.lost_type) { if (type == EF_SECTOR && lost.lost_x == x && lost.lost_y == y) return n; - else if (lost.lost_id == id) + if (type != EF_SECTOR && lost.lost_id == id) return n; } } diff --git a/tests/actofgod/final.xdump b/tests/actofgod/final.xdump index 4a539346..717bf634 100644 --- a/tests/actofgod/final.xdump +++ b/tests/actofgod/final.xdump @@ -252,7 +252,14 @@ uid owner type amount price maxbidder markettime xbuy ybuy xsell ysell /config config lost timestamp owner type id x y +0 1 0 0 1 7 +0 1 0 0 3 7 +0 1 0 0 5 7 +0 1 0 0 7 7 +0 1 0 0 9 7 0 1 0 0 11 7 +0 3 0 0 5 -7 +0 2 0 0 -2 2 0 3 0 0 2 -2 0 3 1 0 1 -1 0 3 1 1 1 -1 diff --git a/tests/bridgefall/final.xdump b/tests/bridgefall/final.xdump index 9c702e18..6ed660db 100644 --- a/tests/bridgefall/final.xdump +++ b/tests/bridgefall/final.xdump @@ -67,7 +67,7 @@ uid owner type amount price maxbidder markettime xbuy ybuy xsell ysell /config config lost timestamp owner type id x y -0 2 0 0 -1 1 +0 2 0 0 -1 -1 0 1 3 0 0 -2 0 1 2 0 0 -2 0 1 3 1 0 -2 @@ -75,7 +75,7 @@ timestamp owner type id x y 0 1 2 2 0 -2 0 1 4 2 0 -2 0 1 4 0 0 -2 -0 1 0 0 3 1 +0 1 0 0 0 -2 0 2 3 10 1 -3 0 2 2 10 1 -3 0 2 3 11 1 -3 @@ -83,6 +83,15 @@ timestamp owner type id x y 0 2 2 12 1 -3 0 2 4 12 1 -3 0 2 4 10 1 -3 +0 2 0 0 3 -3 +0 2 0 0 1 -3 +0 1 0 0 3 1 +0 2 0 0 2 2 +0 2 0 0 1 3 +0 2 0 0 -2 2 +0 2 0 0 -3 1 +0 2 0 0 0 2 +0 2 0 0 -1 1 /config config realm cnum realm xl xh yl yh diff --git a/tests/smoke/final.xdump b/tests/smoke/final.xdump index ff5a30c6..1e956e0c 100644 --- a/tests/smoke/final.xdump +++ b/tests/smoke/final.xdump @@ -1108,6 +1108,7 @@ uid owner type amount price maxbidder markettime xbuy ybuy xsell ysell /config config lost timestamp owner type id x y +0 8 0 0 16 -14 0 0 1 2 11 -13 0 1 3 1 11 -13 0 1 3 2 10 -14 diff --git a/tests/smoke/journal.log b/tests/smoke/journal.log index 809ef497..4013e02d 100644 --- a/tests/smoke/journal.log +++ b/tests/smoke/journal.log @@ -14088,9 +14088,10 @@ Play#0 input xdump lost * Play#0 command xdump Play#0 output Play#0 1 XDUMP lost 0 + Play#0 output Play#0 1 0 8 0 0 16 -14 Play#0 output Play#0 1 0 1 3 1 11 -13 Play#0 output Play#0 1 0 1 3 2 10 -14 - Play#0 output Play#0 1 /2 + Play#0 output Play#0 1 /3 Play#0 output Play#0 6 0 640 Play#0 input xdump realm 0 Play#0 command xdump diff --git a/tests/update/final.xdump b/tests/update/final.xdump index 787f0399..d0816588 100644 --- a/tests/update/final.xdump +++ b/tests/update/final.xdump @@ -427,6 +427,9 @@ uid owner type amount price maxbidder markettime xbuy ybuy xsell ysell /config config lost timestamp owner type id x y +0 4 0 0 -16 -8 +0 4 0 0 -14 -8 +0 4 0 0 -16 -6 0 4 0 0 -8 -6 /config config realm