diff -r b9aed3de7c27 -r 272ed78e59a7 hedgewars/PascalExports.pas --- a/hedgewars/PascalExports.pas Thu Aug 04 17:41:07 2011 +0200 +++ b/hedgewars/PascalExports.pas Thu Aug 04 17:44:55 2011 +0200 @@ -80,7 +80,6 @@ procedure HW_zoomReset; cdecl; export; begin ZoomValue:= cZoomVal; - //middleClick:= true; // center the camera at current hog if CurrentHedgehog <> nil then followGear:= CurrentHedgehog^.Gear; @@ -237,8 +236,8 @@ function HW_isAmmoMenuNotAllowed: boolean; cdecl; export; begin; - exit ( (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or - ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) ); + exit( (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or + ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) ); end; function HW_isWeaponRequiringClick: boolean; cdecl; export; @@ -268,7 +267,7 @@ function HW_isWeaponRope: boolean cdecl; export; begin if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then - exit (CurrentHedgehog^.CurAmmoType = amRope) + exit(CurrentHedgehog^.CurAmmoType = amRope) else exit(false); end; @@ -298,17 +297,17 @@ function HW_getWeaponNameByIndex(whichone: LongInt): PChar; cdecl; export; begin - exit (str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId])); + exit(str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId])); end; function HW_getWeaponCaptionByIndex(whichone: LongInt): PChar; cdecl; export; begin - exit (str2pchar(trammoc[Ammoz[TAmmoType(whichone+1)].NameId])); + exit(str2pchar(trammoc[Ammoz[TAmmoType(whichone+1)].NameId])); end; function HW_getWeaponDescriptionByIndex(whichone: LongInt): PChar; cdecl; export; begin - exit (str2pchar(trammod[Ammoz[TAmmoType(whichone+1)].NameId])); + exit(str2pchar(trammod[Ammoz[TAmmoType(whichone+1)].NameId])); end; function HW_getNumberOfWeapons:LongInt; cdecl; export; @@ -318,6 +317,7 @@ procedure HW_setWeapon(whichone: LongInt); cdecl; export; begin + if (CurrentTeam = nil) then exit; if (not CurrentTeam^.ExtDriven) and (CurrentTeam^.Hedgehogs[0].BotLevel = 0) then SetWeapon(TAmmoType(whichone+1)); end; @@ -331,11 +331,12 @@ var a : PHHAmmo; slot, index: LongInt; begin - if (CurrentTeam = nil) or - (CurrentHedgehog = nil) or - (CurrentTeam^.ExtDriven) or - (CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then + // nil check + if (CurrentHedgehog = nil) or (CurrentHedgehog^.Ammo = nil) or (CurrentTeam = nil) then exit(-1); + // hog controlled by opponent (net or ai) + if (CurrentTeam^.ExtDriven) or (CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then + exit(1); a:= CurrentHedgehog^.Ammo; for slot:= 0 to cMaxSlotIndex do @@ -354,7 +355,10 @@ function HW_getTurnsForCurrentTeam: LongInt; cdecl; export; begin - exit(CurrentTeam^.Clan^.TurnNumber); + if (CurrentTeam <> nil) and (CurrentTeam^.Clan <> nil) then + exit(CurrentTeam^.Clan^.TurnNumber) + else + exit(0); end; function HW_getMaxNumberOfHogs: LongInt; cdecl; export;