diff --git a/game/Actor.cpp b/game/Actor.cpp index 4f1ca0a..045973c 100644 --- a/game/Actor.cpp +++ b/game/Actor.cpp @@ -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 ); diff --git a/game/Player.cpp b/game/Player.cpp index 69ca215..79bef03 100644 --- a/game/Player.cpp +++ b/game/Player.cpp @@ -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::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(); diff --git a/game/Weapon.cpp b/game/Weapon.cpp index 84cfa0f..98ff2e5 100644 --- a/game/Weapon.cpp +++ b/game/Weapon.cpp @@ -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 diff --git a/idlib/geometry/Winding2D.cpp b/idlib/geometry/Winding2D.cpp index 3106d10..7119548 100644 --- a/idlib/geometry/Winding2D.cpp +++ b/idlib/geometry/Winding2D.cpp @@ -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; }