TheSuperHackers / GeneralsGamePatch

Community Patch to fix and improve original Generals Zero Hour 1.04
Other
58 stars 19 forks source link

Game will crash if Battle Bus with Rebels destroys Nuke Battle Masters #1922

Open TranzistorP opened 1 year ago

TranzistorP commented 1 year ago

изображение If sitting in Battle Bus or Civilian Building a Ranger, Rebel, Redguard, Colonel Burton or Minigunner destroys a Nuke Power Plant or Nuke Battle Master and because of this the Battle Bus or Neutral Building is dealt a lethal amount of damage, the game will be crashed. But if Building is KindOf GARRISONABLE_UNTIL_DESTROYED it will be OK. Map for test is attached: _Crash.zip

P.S Sorry for my english

xezon commented 1 year ago

Where did you put GARRISONABLE_UNTIL_DESTROYED to avoid crash?

TranzistorP commented 1 year ago

I added GARRISONABLE_UNTIL_DESTROYEDto the KindOf string of all civilian buildings in my mod. But this isn`t very good solution. Maybe it will be better to give detonation delay to Nuke Battle Master and Nuke Power Plant. As far as i understand, the game crash when it happens in the same frame.

TranzistorP commented 1 year ago

For this reason this bug doesn`t occur for Tunnel Defender (and other units have a Projectile Object) and Demo Trup.

Battlefieldkille commented 1 year ago

Wow, thats insane

xezon commented 1 year ago

Callstack

>   thyme.dll!StateMachine::Internal_Get_State(unsigned int id) Line 403    C++
    thyme.dll!StateMachine::Internal_Set_State(unsigned int new_state_id) Line 443  C++
    thyme.dll!State::Friend_Check_For_Transitions(StateReturnType status) Line 168  C++
    thyme.dll!StateMachine::Update_State_Machine() Line 356 C++
    game.dat!0059cf03() Unknown
    game.dat![Frames below may be incorrect and/or missing, no symbols loaded for game.dat] Unknown
    thyme.dll!StateMachine::Update_State_Machine() Line 348 C++
    game.dat!005961df() Unknown
    game.dat!005d1754() Unknown
    game.dat!004a6ddd() Unknown
    game.dat!004a6dee() Unknown
    thyme.dll!GameEngine::Update() Line 188 C++
    thyme.dll!Win32GameEngine::Update() Line 58 C++
    thyme.dll!GameEngine::Execute() Line 556    C++
    thyme.dll!Game_Main(int argc, char * * argv) Line 41    C++
    thyme.dll!main(int argc, char * * argv) Line 700    C++
    thyme.dll!Main_Func(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 728  C++
    game.dat!008e08ac() Unknown
    kernel32.dll!76ad0099() Unknown
    ntdll.dll!77817b6e()    Unknown
    ntdll.dll!77817b3e()    Unknown
    game.dat!006e0069() Unknown
    game.dat!006e0069() Unknown
    game.dat!006e0069() Unknown
    game.dat!006e0069() Unknown
    game.dat!006e0069() Unknown
    game.dat!006e0069() Unknown
    game.dat!006e0069() Unknown
    game.dat!006e0069() Unknown
    game.dat!006e0069() Unknown
    game.dat!006e0069() Unknown

iter is m_stateMap.end()

xezon commented 1 year ago

Need to debug again when we have more code in Thyme. I cannot see which object this state machine belongs to. Is it the bus or the passenger? I suspect state machine was already cleaned up because of death, yet it is being accesses afterwards.

OccultGuy commented 1 month ago

I think I've fixed this. Basically let the fireweaponwhendead behavior fire a dummy weapon, creating a system object that then fires the actual weapon. The "downside" of this, is the origial object does not get exp, but its dead most of the time anyway (though infantry in a battlebus might survive). Genpoints are given as one would expect. I think this is a worthwile tradeoff until it can be fixed in Thyme.

Object
  Behavior = FireWeaponWhenDeadBehavior ModuleTag_04
    DeathWeapon   = NuclearTankDeathWeaponObjectCreation ;NuclearTankDeathWeapon
    StartsActive  = No                        ; turned on by upgrade
    TriggeredBy   = Upgrade_ChinaNuclearTanks
  End

Weapon NuclearTankDeathWeaponObjectCreation
  PrimaryDamage = 0.0
  PrimaryDamageRadius = 1.0      
  AttackRange = 100.0
  DamageType = EXPLOSION 
  DeathType = EXPLODED
  WeaponSpeed = 99999.0
  ProjectileObject = NONE
  ;FireFX = WeaponFX_NapalmMissileDetonation
  FireOCL = OCL_NuclearTankDeathWeaponObjectCreation
  RadiusDamageAffects = ALLIES ENEMIES NEUTRALS
  DelayBetweenShots = 0                   ; time between shots, msec
  ClipSize = 1                            ; how many shots in a Clip (0 == infinite)
  ClipReloadTime = 0                      ; how long to reload a Clip, msec
  AutoReloadsClip = No 
  AntiGround = Yes
  DamageDealtAtSelfPosition = Yes
End

ObjectCreationList OCL_NuclearTankDeathWeaponObjectCreation
 CreateObject
   ObjectNames = NuclearTankDeathWeaponObjectCreationObject
   Disposition = ON_GROUND_ALIGNED
 End
End

System
Object NuclearTankDeathWeaponObjectCreationObject

  ; *** ART Parameters ***
  Draw = W3DModelDraw ModuleTag_01
    DefaultConditionState
      Model = NONE
    End
  End

  ; ***DESIGN parameters ***
  EditorSorting = SYSTEM
  ; srj asks: should this also be STICK_TO_TERRAIN_SLOPE?
  KindOf = IMMOBILE INERT NO_COLLIDE SCORE
  ArmorSet
    Conditions      = None
    Armor           = InvulnerableAllArmor
  End

  ; ***AUDIO parameters ***

  ; *** ENGINEERING Parameters ***
  Body = ActiveBody ModuleTag_02
    MaxHealth        = 99999.0
    InitialHealth    = 99999.0
  End
  Behavior = FireWeaponUpdate ModuleTag_03
    Weapon = NuclearTankDeathWeapon
  End

  Behavior = LifetimeUpdate ModuleTag_04
    MinLifetime = 1000
    MaxLifetime = 1000
  End

  Behavior = DestroyDie ModuleTag_06
  End

  Geometry            = CYLINDER
  GeometryMajorRadius = 1.0
  GeometryHeight      = 1.0
  GeometryIsSmall     = Yes

End

Edit: Needs to fixed for at least the china tanks, power plants and the bomb truck

xezon commented 1 month ago

Thank you and welcome. I have taken the liberty and fixed the code format of your code block.

What do you mean with "the origial object does not get exp"? If a death explosion occurs, then that unit does not need XP anymore anyway, no? Does the death explosion benefit from veterancy however? Aka is a Vet 3 Nuke Battlemaster doing more damage when exploding?

OccultGuy commented 1 month ago

Hi, thanks for fixing the code block.

I wrongfully assumed the unit that destroys the object with the fireweaponwhendead behavior would get exp for a chain reaction. Don't know why I would think that. So there is no gameplay impact with this change, just a few extra objects on the map.

The death explosion does in fact not benefit from veterancy - tested