(perform_mission): Do not pass the sub-owner to nreport(). News
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.
This commit is contained in:
parent
f2eaedfe75
commit
d71ab5a3e5
2 changed files with 9 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue