torpedo: New variable sub_mcp to make code more concise

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2015-02-15 08:47:43 +01:00
parent 695352d9d3
commit 76214dbfbd

View file

@ -58,6 +58,7 @@ torp(void)
double hitchance; double hitchance;
struct shpstr vship; struct shpstr vship;
struct shpstr sub; struct shpstr sub;
struct mchrstr *sub_mcp;
char *ptr; char *ptr;
struct nstr_item nbst; struct nstr_item nbst;
char buf[1024]; char buf[1024];
@ -90,9 +91,10 @@ torp(void)
if (sub.shp_own != player->cnum) { if (sub.shp_own != player->cnum) {
continue; continue;
} }
if ((mchr[(int)sub.shp_type].m_flags & M_TORP) == 0) { sub_mcp = &mchr[sub.shp_type];
if (!(sub_mcp->m_flags & M_TORP)) {
pr("Ship # %d: A %s can't fire torpedoes!\n", pr("Ship # %d: A %s can't fire torpedoes!\n",
sub.shp_uid, mchr[(int)sub.shp_type].m_name); sub.shp_uid, sub_mcp->m_name);
continue; continue;
} }
if (sub.shp_item[I_GUN] == 0 if (sub.shp_item[I_GUN] == 0
@ -130,7 +132,7 @@ torp(void)
continue; continue;
} }
if (mchr[(int)vship.shp_type].m_flags & M_SUB) { if (mchr[(int)vship.shp_type].m_flags & M_SUB) {
if (!(mchr[(int)sub.shp_type].m_flags & M_SUBT)) { if (!(sub_mcp->m_flags & M_SUBT)) {
pr("You can't torpedo a submarine!\n"); pr("You can't torpedo a submarine!\n");
continue; continue;
} }
@ -143,7 +145,7 @@ torp(void)
continue; continue;
} }
if ((mchr[(int)sub.shp_type].m_flags & M_SUB) == 0) if (!(sub_mcp->m_flags & M_SUB))
anti_torp(sub.shp_uid, ntorping, vshipown); anti_torp(sub.shp_uid, ntorping, vshipown);
getship(sub.shp_uid, &sub); getship(sub.shp_uid, &sub);
if (sub.shp_own == 0) if (sub.shp_own == 0)
@ -198,7 +200,7 @@ torp(void)
xyas(sub.shp_x, sub.shp_y, vshipown), prship(&vship)); xyas(sub.shp_x, sub.shp_y, vshipown), prship(&vship));
} }
if (mchr[(int)sub.shp_type].m_flags & M_SUB) if (sub_mcp->m_flags & M_SUB)
anti_torp(sub.shp_uid, ntorping, vshipown); anti_torp(sub.shp_uid, ntorping, vshipown);
} }
return RET_OK; return RET_OK;