collision: add additional checks

This commit is contained in:
Denis Pauk 2023-12-30 16:31:47 +02:00
parent 59d6766e90
commit 6701ad8cc5

View file

@ -2231,6 +2231,11 @@ CM_LeafContents(int leafnum)
int int
CM_LeafCluster(int leafnum) CM_LeafCluster(int leafnum)
{ {
if (!cmod->map_leafs)
{
return 0;
}
if ((leafnum < 0) || (leafnum >= (cmod->numleafs + EXTRA_LUMP_LEAFS))) if ((leafnum < 0) || (leafnum >= (cmod->numleafs + EXTRA_LUMP_LEAFS)))
{ {
Com_Error(ERR_DROP, "%s: bad number", __func__); Com_Error(ERR_DROP, "%s: bad number", __func__);
@ -2242,6 +2247,11 @@ CM_LeafCluster(int leafnum)
int int
CM_LeafArea(int leafnum) CM_LeafArea(int leafnum)
{ {
if (!cmod->map_leafs)
{
return 0;
}
if ((leafnum < 0) || (leafnum >= (cmod->numleafs + EXTRA_LUMP_LEAFS))) if ((leafnum < 0) || (leafnum >= (cmod->numleafs + EXTRA_LUMP_LEAFS)))
{ {
Com_Error(ERR_DROP, "%s: bad number", __func__); Com_Error(ERR_DROP, "%s: bad number", __func__);
@ -2333,7 +2343,7 @@ CM_ClusterPVS(int cluster)
byte * byte *
CM_ClusterPHS(int cluster) CM_ClusterPHS(int cluster)
{ {
if (cluster == -1) if (cluster == -1 || !cmod->map_vis)
{ {
memset(phsrow, 0, (cmod->numclusters + 7) >> 3); memset(phsrow, 0, (cmod->numclusters + 7) >> 3);
} }