# HG changeset patch # User unc0rr # Date 1309429561 -14400 # Node ID a4409b50bdc2d6d375a162743c1b1c381bdad88b # Parent 0bc81de36e083d7ec2aea3ac172053cdf11a2e79 Convert huge switch into an array diff -r 0bc81de36e08 -r a4409b50bdc2 hedgewars/uGears.pas --- a/hedgewars/uGears.pas Thu Jun 30 13:59:57 2011 +0400 +++ b/hedgewars/uGears.pas Thu Jun 30 14:26:01 2011 +0400 @@ -222,65 +222,15 @@ gear^.SoundChannel:= -1; gear^.ImpactSound:= sndNone; gear^.nImpactSounds:= 0; -gear^.AmmoType:= amNothing; +// Define ammo association, if any. +gear^.AmmoType:= GearKindAmmoTypeMap[Kind]; if CurrentHedgehog <> nil then begin gear^.Hedgehog:= CurrentHedgehog; gear^.IntersectGear:= CurrentHedgehog^.Gear end; -// Define ammo association, if any. -case Kind of - gtGrenade: gear^.AmmoType:= amGrenade; - gtShell: gear^.AmmoType:= amBazooka; - gtBee: gear^.AmmoType:= amBee; - gtShotgunShot: gear^.AmmoType:= amShotgun; - gtPickHammer: gear^.AmmoType:= amPickHammer; - gtRope: gear^.AmmoType:= amRope; - gtDEagleShot: gear^.AmmoType:= amDEagle; - gtDynamite: gear^.AmmoType:= amDynamite; - gtClusterBomb, - gtCluster: gear^.AmmoType:= amClusterBomb; - gtShover: gear^.AmmoType:= amBaseballBat; // Shover is only used for baseball bat right now - gtFirePunch: gear^.AmmoType:= amFirePunch; - gtParachute: gear^.AmmoType:= amParachute; - gtAirBomb: gear^.AmmoType:= amAirAttack; - gtBlowTorch: gear^.AmmoType:= amBlowTorch; - gtGirder: gear^.AmmoType:= amGirder; - gtTeleport: gear^.AmmoType:= amTeleport; - gtSwitcher: gear^.AmmoType:= amSwitch; - gtMortar: gear^.AmmoType:= amMortar; - gtWhip: gear^.AmmoType:= amWhip; - gtKamikaze: gear^.AmmoType:= amKamikaze; - gtCake: gear^.AmmoType:= amCake; - gtSeduction: gear^.AmmoType:= amSeduction; - gtWatermelon, - gtMelonPiece: gear^.AmmoType:= amWatermelon; - gtHellishBomb: gear^.AmmoType:= amHellishBomb; - gtDrill: gear^.AmmoType:= amDrill; - gtBallGun, - gtBall: gear^.AmmoType:= amBallgun; - gtRCPlane: gear^.AmmoType:= amRCPlane; -gtSniperRifleShot: gear^.AmmoType:= amSniperRifle; - gtJetpack: gear^.AmmoType:= amJetpack; - gtMolotov: gear^.AmmoType:= amMolotov; - gtBirdy, - gtEgg: gear^.AmmoType:= amBirdy; - gtPortal: gear^.AmmoType:= amPortalGun; - gtPiano: gear^.AmmoType:= amPiano; - gtGasBomb: gear^.AmmoType:= amGasBomb; - gtSineGunShot: gear^.AmmoType:= amSineGun; - gtFlamethrower: gear^.AmmoType:= amFlamethrower; - gtSMine: gear^.AmmoType:= amSMine; - gtHammer, - gtHammerHit: gear^.AmmoType:= amHammer; - gtResurrector: gear^.AmmoType:= amResurrector; - gtSnowball: gear^.AmmoType:= amSnowball; - gtStructure: gear^.AmmoType:= amStructure; // TODO - This will undoubtedly change once there is more than one structure - gtLandGun: gear^.AmmoType:= amLandGun; - gtTardis: gear^.AmmoType:= amTardis; -end; - + case Kind of gtGrenade, gtClusterBomb, diff -r 0bc81de36e08 -r a4409b50bdc2 hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Thu Jun 30 13:59:57 2011 +0400 +++ b/hedgewars/uVariables.pas Thu Jun 30 14:26:01 2011 +0400 @@ -2170,6 +2170,72 @@ ejectY: -3) ); + GearKindAmmoTypeMap : array [TGearType] of TAmmoType = ( +(* gtGrenade *) amGrenade +(* gtHedgehog *) , amNothing +(* gtShell *) , amBazooka +(* gtGrave *) , amNothing +(* gtBee *) , amBee +(* gtShotgunShot *) , amShotgun +(* gtPickHammer *) , amPickHammer +(* gtRope *) , amRope +(* gtMine *) , amNothing +(* gtCase *) , amNothing +(* gtDEagleShot *) , amDEagle +(* gtDynamite *) , amDynamite +(* gtClusterBomb *) , amClusterBomb +(* gtCluster *) , amClusterBomb +(* gtShover *) , amBaseballBat // Shover is only used for baseball bat right now +(* gtFlame *) , amNothing +(* gtFirePunch *) , amFirePunch +(* gtATStartGame *) , amNothing +(* gtATSmoothWindCh *) , amNothing +(* gtATFinishGame *) , amNothing +(* gtParachute *) , amParachute +(* gtAirAttack *) , amAirAttack +(* gtAirBomb *) , amAirAttack +(* gtBlowTorch *) , amBlowTorch +(* gtGirder *) , amGirder +(* gtTeleport *) , amTeleport +(* gtSwitcher *) , amSwitch +(* gtTarget *) , amNothing +(* gtMortar *) , amMortar +(* gtWhip *) , amWhip +(* gtKamikaze *) , amKamikaze +(* gtCake *) , amCake +(* gtSeduction *) , amSeduction +(* gtWatermelon *) , amWatermelon +(* gtMelonPiece *) , amWatermelon +(* gtHellishBomb *) , amHellishBomb +(* gtWaterUp *) , amNothing +(* gtDrill *) , amDrill +(* gtBallGun *) , amBallgun +(* gtBall *) , amBallgun +(* gtRCPlane *) , amRCPlane +(*gtSniperRifleShot *) , amSniperRifle +(* gtJetpack *) , amJetpack +(* gtMolotov *) , amMolotov +(* gtExplosives *) , amNothing +(* gtBirdy *) , amBirdy +(* gtEgg *) , amBirdy +(* gtPortal *) , amPortalGun +(* gtPiano *) , amPiano +(* gtGasBomb *) , amGasBomb +(* gtSineGunShot *) , amSineGun +(* gtFlamethrower *) , amFlamethrower +(* gtSMine *) , amSMine +(* gtPoisonCloud *) , amNothing +(* gtHammer *) , amHammer +(* gtHammerHit *) , amHammer +(* gtResurrector *) , amResurrector +(* gtPoisonCloud *) , amNothing +(* gtSnowball *) , amSnowball +(* gtFlake *) , amNothing +(* gtStructure *) , amStructure // TODO - This will undoubtedly change once there is more than one structure +(* gtLandGun *) , amLandGun +(* gtTardis *) , amTardis + ); + var Land: TCollisionArray; LandPixels: TLandArray;