mirror of
https://github.com/dhewm/dhewm3-sdk.git
synced 2025-02-22 03:31:45 +00:00
Fix some (mostly Savegame-related) Crashes
Somehow I must have added that savefile->WriteFloat( spreadCrouchFactor ); twice when merging the Ruiner/Rivensin changes into the SDK.. damn. (As it's only read once, all data read from the savegame after it will be garbage) I had a crash when creating a Savegame in idAnimState::Save(), because animator was NULL - so I added a check for that. The rest has been found with GCC address sanitizer (ASan)
This commit is contained in:
parent
cf83d7a579
commit
53ab8e1031
4 changed files with 12 additions and 6 deletions
|
@ -81,7 +81,10 @@ void idAnimState::Save( idSaveGame *savefile ) const {
|
|||
savefile->WriteObject( self );
|
||||
|
||||
// Save the entity owner of the animator
|
||||
savefile->WriteObject( animator->GetEntity() );
|
||||
if(animator != NULL) // DG: don't crash if it's NULL
|
||||
savefile->WriteObject( animator->GetEntity() );
|
||||
else
|
||||
savefile->WriteInt(0);
|
||||
|
||||
savefile->WriteObject( thread );
|
||||
|
||||
|
|
|
@ -4934,11 +4934,15 @@ bool idPlayer::DropWeapon( bool died, bool selectNext ) { //ivan - bool selectNe
|
|||
}
|
||||
// set the appropriate ammo in the dropped object
|
||||
const idKeyValue * keyval = item->spawnArgs.MatchPrefix( "inv_ammo_" );
|
||||
idStr inclipOrigKey;
|
||||
if ( keyval ) {
|
||||
//item->spawnArgs.SetInt( keyval->GetKey(), ammoavailable ); //ivan - commented out
|
||||
idStr inclipKey = keyval->GetKey();
|
||||
inclipOrigKey = inclipKey;
|
||||
inclipKey.Insert( "inclip_", 4 );
|
||||
inclipKey.Insert( va("%.2d", currentWeapon), 11);//new
|
||||
// DG: the following line seems to cause keyval to be deleted (via idList<idKeyValue>::Resize())
|
||||
// that's why I copied the old key to inclipOrigKey and use that below in ivans code
|
||||
item->spawnArgs.SetInt( inclipKey, inclip );
|
||||
}
|
||||
|
||||
|
@ -4946,13 +4950,13 @@ bool idPlayer::DropWeapon( bool died, bool selectNext ) { //ivan - bool selectNe
|
|||
//was: if ( !died ) {
|
||||
if ( died ) {
|
||||
//don't call WeaponStolen on weapon in this case bacause OwnerDied will be called instead (so it will be in scripts too).
|
||||
if ( keyval ) item->spawnArgs.SetInt( keyval->GetKey(), ammoavailable );
|
||||
if ( !inclipOrigKey.IsEmpty() ) item->spawnArgs.SetInt( inclipOrigKey, ammoavailable );
|
||||
}else{
|
||||
//ivan end
|
||||
// remove from our local inventory completely
|
||||
inventory.Drop( spawnArgs, item->spawnArgs.GetString( "inv_weapon" ), -1 , &dropAmmoInItem ); //ivan - dropAmmoInItem added
|
||||
|
||||
if ( keyval ) item->spawnArgs.SetInt( keyval->GetKey(), dropAmmoInItem ? ammoavailable : 0 ); //ivan
|
||||
if ( !inclipOrigKey.IsEmpty() ) item->spawnArgs.SetInt( inclipOrigKey, dropAmmoInItem ? ammoavailable : 0 ); //ivan
|
||||
|
||||
weapon.GetEntity()->ResetAmmoClip();
|
||||
|
||||
|
|
|
@ -476,8 +476,7 @@ void idWeapon::Save( idSaveGame *savefile ) const {
|
|||
savefile->WriteFloat( dynamicSpreadValue );
|
||||
savefile->WriteFloat( spreadBaseValue );
|
||||
savefile->WriteFloat( spreadVelocityFactor );
|
||||
savefile->WriteFloat( spreadCrouchFactor );
|
||||
savefile->WriteFloat( spreadCrouchFactor );
|
||||
savefile->WriteFloat( spreadCrouchFactor );
|
||||
//ivan end
|
||||
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ void idWinding2D::ExpandForAxialBox( const idVec2 bounds[2] ) {
|
|||
continue;
|
||||
}
|
||||
plane = Plane2DFromPoints( p[i], p[j], true );
|
||||
if ( i ) {
|
||||
if ( numPlanes ) { // DG: was if(i), but if we continued above at i=0, numPlanes is still 0 and numPlanes-1 is invalid...
|
||||
if ( GetAxialBevel( planes[numPlanes-1], plane, p[i], bevel ) ) {
|
||||
planes[numPlanes++] = bevel;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue