diff --git a/src/lib/subs/mission.c b/src/lib/subs/mission.c index bd7af9f7..8b8b3c11 100644 --- a/src/lib/subs/mission.c +++ b/src/lib/subs/mission.c @@ -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); diff --git a/src/lib/subs/nreport.c b/src/lib/subs/nreport.c index 28eb0129..cc71b22a 100644 --- a/src/lib/subs/nreport.c +++ b/src/lib/subs/nreport.c @@ -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;