]> git.pond.sub.org Git - empserver/commitdiff
(perform_mission): Do not pass the sub-owner to nreport(). News
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 3 Nov 2005 17:40:16 +0000 (17:40 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 3 Nov 2005 17:40:16 +0000 (17:40 +0000)
doesn't show it, but selectors do.  Reported by Doug Wescott.

(nreport, ncache): Catch errors like the above.  Catch bad event
argument while we're at it.

src/lib/subs/mission.c
src/lib/subs/nreport.c

index bd7af9f7bd20c84a25bab39dfcda72204ec82b67..8b8b3c11fda33779fb713420f4e6403e533285a9 100644 (file)
@@ -600,7 +600,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
                dam2 = TORP_DAMAGE();
 
                dam += dam2;
-               nreport(victim, N_TORP_SHIP, sp->shp_own, 1);
+               nreport(victim, N_TORP_SHIP, 0, 1);
                wu(0, sp->shp_own,
                   "\tTorpedo hit %s %s for %d damage\n",
                   cname(victim), s, dam2);
index 28eb0129283cfdcdd340300509859c8ecb7bb211..cc71b22a3f7bcdb115f05c398c1f64866e6b9c52 100644 (file)
@@ -57,6 +57,10 @@ nreport(natid actor, int event, natid victim, int times)
     struct natstr *natp;
     struct newscache *ncp;
 
+    if (CANT_HAPPEN((unsigned)event > N_MAX_VERB
+                   || rpt[event].r_newstory[0] == rpt[0].r_newstory[0]))
+       return;
+
     ncp = ncache(actor, event, victim, times);
     putnews(ncp->id, &ncp->news);
 
@@ -171,10 +175,10 @@ ncache(int actor, int event, int victim, int times)
            return np;
        }
     }
-    if (oldslot < 0) {
-       logerror("internal error; ncache oldslot < 0");
-       return &cache[actor][0];
-    }
+    if (CANT_HAPPEN(oldslot < 0))
+       oldslot = 0;
+    if (CANT_HAPPEN(!strstr(rpt[event].r_newstory[0], "%s") && victim != 0))
+       victim = 0;
     np = &cache[actor][oldslot];
     np->news.nws_ano = actor;
     np->news.nws_vno = victim;