Fix loading x-light missiles on ships without capability plane
These ships could only use their x-light slots for x-light planes, not
their plane slots. For instance, agc (30 x-light slots, 32 plane
slots) could load only 30 sams, and mb (0 x-light slots, 10 plane
slots) could not load any sams.
Culprit is could_be_on_ship(). Broken in commit 3e370da5
, v4.3.17.
This commit is contained in:
parent
265bd0c56b
commit
162158fd4a
1 changed files with 8 additions and 4 deletions
|
@ -827,6 +827,7 @@ could_be_on_ship(struct plnstr *pp, struct shpstr *sp,
|
||||||
{
|
{
|
||||||
struct plchrstr *pcp = &plchr[pp->pln_type];
|
struct plchrstr *pcp = &plchr[pp->pln_type];
|
||||||
struct mchrstr *mcp = &mchr[sp->shp_type];
|
struct mchrstr *mcp = &mchr[sp->shp_type];
|
||||||
|
int nfw;
|
||||||
|
|
||||||
if (pcp->pl_flags & P_K)
|
if (pcp->pl_flags & P_K)
|
||||||
nch++;
|
nch++;
|
||||||
|
@ -837,14 +838,17 @@ could_be_on_ship(struct plnstr *pp, struct shpstr *sp,
|
||||||
else if (pcp->pl_flags & P_M)
|
else if (pcp->pl_flags & P_M)
|
||||||
nmsl++;
|
nmsl++;
|
||||||
n++;
|
n++;
|
||||||
|
nfw = n - nch - nxl - nmsl;
|
||||||
|
|
||||||
n -= MIN(nch, mcp->m_nchoppers);
|
if (nch > mcp->m_nchoppers) /* overflow into fixed-wing slots */
|
||||||
n -= MIN(nxl, mcp->m_nxlight);
|
nfw += nch - mcp->m_nchoppers;
|
||||||
|
if (nxl > mcp->m_nxlight) /* overflow into missile slots */
|
||||||
|
nmsl += nxl - mcp->m_nxlight;
|
||||||
if (nmsl && !(mcp->m_flags & (M_MSL | M_FLY)))
|
if (nmsl && !(mcp->m_flags & (M_MSL | M_FLY)))
|
||||||
return 0; /* missile slots wanted */
|
return 0; /* missile slots wanted */
|
||||||
if (nmsl < n && !(mcp->m_flags & M_FLY))
|
if (nfw && !(mcp->m_flags & M_FLY))
|
||||||
return 0; /* fixed-wing slots wanted */
|
return 0; /* fixed-wing slots wanted */
|
||||||
return n <= mcp->m_nplanes;
|
return nfw + nmsl <= mcp->m_nplanes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue