Minor fixes for bugs which can cause segfaults.
parent
151a6a5084
commit
9a2563de97
|
@ -176,6 +176,7 @@ IMAGEFILE *iV_LoadImageFile(const char *fileName)
|
|||
if (retval != 3)
|
||||
{
|
||||
debug(LOG_ERROR, "Bad line in \"%s\".", fileName);
|
||||
delete imageFile;
|
||||
return NULL;
|
||||
}
|
||||
imageFile->imageNames[numImages].first = tmpName;
|
||||
|
|
|
@ -302,7 +302,7 @@ void counterBatteryFire(BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget)
|
|||
// Also ignore cases where there are already 1000 missiles heading towards the attacker.
|
||||
if (psTarget == NULL
|
||||
|| (psAttacker != NULL && psAttacker->player == psTarget->player)
|
||||
|| aiObjectIsProbablyDoomed(psAttacker))
|
||||
|| (psAttacker != NULL && aiObjectIsProbablyDoomed(psAttacker)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1410,7 +1410,7 @@ void finishDeliveryPosition()
|
|||
setAssemblyPoint(psStruct->pFunctionality->factory.psAssemblyPoint,
|
||||
flagPos.coords.x, flagPos.coords.y, selectedPlayer, true);
|
||||
}
|
||||
else if (psStruct->pStructureType->type == REF_REPAIR_FACILITY)
|
||||
else if (psStruct->pStructureType->type == REF_REPAIR_FACILITY && psStruct->pFunctionality != NULL)
|
||||
{
|
||||
setAssemblyPoint(psStruct->pFunctionality->repairFacility.psDeliveryPoint,
|
||||
flagPos.coords.x, flagPos.coords.y, selectedPlayer, true);
|
||||
|
@ -2614,8 +2614,8 @@ static SELECTION_TYPE establishSelection(UDWORD selectedPlayer)
|
|||
ASSERT( psDroid->droidType < NUM_DROID_WEIGHTS,
|
||||
"establishSelection : droidType exceeds NUM_DROID_WEIGHTS" );
|
||||
|
||||
atLeastOne = true;
|
||||
if(DroidSelectionWeights[psDroid->droidType] < CurrWeight) {
|
||||
atLeastOne = true;
|
||||
CurrWeight = DroidSelectionWeights[psDroid->droidType];
|
||||
psDominant = psDroid;
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ bool recvLasSat(NETQUEUE queue)
|
|||
if (psStruct && !canGiveOrdersFor(queue.index, psStruct->player))
|
||||
{
|
||||
syncDebug("Wrong player.");
|
||||
return !"Meow"; // Return value meaningless and ignored.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (psStruct && psObj && psStruct->pStructureType->psWeapStat[0]->weaponSubClass == WSC_LAS_SAT)
|
||||
|
|
|
@ -119,8 +119,8 @@ static bool objmemDestroy(BASE_OBJECT *psObj)
|
|||
default:
|
||||
ASSERT(!"unknown object type", "objmemDestroy: unknown object type in destroyed list at 0x%p", psObj);
|
||||
}
|
||||
delete psObj;
|
||||
debug(LOG_MEMORY, "BASE_OBJECT* 0x%p is freed.", psObj);
|
||||
delete psObj;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ std::vector<Vector2i> derricks;
|
|||
bool scriptOperatorEquals(INTERP_VAL const &v1, INTERP_VAL const &v2)
|
||||
{
|
||||
ASSERT_OR_RETURN(false, scriptTypeIsPointer(v1.type) && scriptTypeIsPointer(v2.type), "Bad types.");
|
||||
if (v1.type == (INTERP_TYPE)ST_RESEARCH && v1.type == (INTERP_TYPE)ST_RESEARCH)
|
||||
if (v1.type == (INTERP_TYPE)ST_RESEARCH && v2.type == (INTERP_TYPE)ST_RESEARCH)
|
||||
{
|
||||
return ((RESEARCH *)v1.v.oval)->ref == ((RESEARCH *)v2.v.oval)->ref;
|
||||
}
|
||||
|
@ -9138,6 +9138,7 @@ VIEWDATA *CreateBeaconViewData(SDWORD sender, UDWORD LocX, UDWORD LocY)
|
|||
if (psViewData->pData == NULL)
|
||||
{
|
||||
ASSERT(false, "prepairHelpViewData() - Unable to allocate memory");
|
||||
delete psViewData;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -10245,6 +10246,7 @@ bool scrAssembleWeaponTemplate(void)
|
|||
// finalize template and set its name
|
||||
if (!intValidTemplate(pNewTemplate, GetDefaultTemplateName(pNewTemplate), false, player))
|
||||
{
|
||||
delete pNewTemplate;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1698,16 +1698,15 @@ int bodyArmour(const BODY_STATS *psStats, int player, WEAPON_CLASS weaponClass)
|
|||
int weaponROF(const WEAPON_STATS *psStat, int player)
|
||||
{
|
||||
int rof = 0;
|
||||
// if there are salvos
|
||||
if (player >= 0
|
||||
&& psStat->upgrade[player].numRounds
|
||||
&& psStat->upgrade[player].reloadTime != 0)
|
||||
{
|
||||
// Rounds per salvo multiplied with the number of salvos per minute
|
||||
rof = psStat->upgrade[player].numRounds * 60 * GAME_TICKS_PER_SEC / weaponReloadTime(psStat, player);
|
||||
}
|
||||
|
||||
if (psStat->upgrade[player].numRounds) // if there are salvos
|
||||
{
|
||||
if (psStat->upgrade[player].reloadTime != 0)
|
||||
{
|
||||
// Rounds per salvo multiplied with the number of salvos per minute
|
||||
rof = psStat->upgrade[player].numRounds * 60 * GAME_TICKS_PER_SEC /
|
||||
(player >= 0 ? weaponReloadTime(psStat, player) : psStat->upgrade[player].reloadTime);
|
||||
}
|
||||
}
|
||||
if (rof == 0)
|
||||
{
|
||||
rof = weaponFirePause(psStat, selectedPlayer);
|
||||
|
|
Loading…
Reference in New Issue