--- a/hedgewars/PascalExports.pas Thu Aug 26 23:59:18 2010 +0200
+++ b/hedgewars/PascalExports.pas Wed Oct 27 14:02:20 2010 +0200
@@ -1,25 +1,35 @@
(*
- * PascalExports.pas
- * hwengine
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
*
- * Created by Vittorio on 09/01/10.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*)
-
{$INCLUDE "options.inc"}
unit PascalExports;
interface
-uses uKeys, GLunit, uWorld, uMisc, uConsole, uTeams, uConsts, uChat, uGears, uSound, hwengine;
+uses uKeys, GLunit, uWorld, uMisc, uConsole, uTeams, uConsts, uChat,
+ uGears, uSound, hwengine, uAmmos, uLocale; // don't change the order!
{$INCLUDE "config.inc"}
+type PPByte = ^PByte;
implementation
-
{$IFDEF HWLIBRARY}
+var cZoomVal: GLfloat;
// retrieve protocol information
procedure HW_versionInfo(netProto: PShortInt; versionStr: PPChar); cdecl; export;
@@ -34,6 +44,17 @@
leftClick:= true;
end;
+procedure HW_ammoMenu; cdecl; export;
+begin
+ rightClick:= true;
+end;
+
+procedure HW_zoomSet(value: GLfloat); cdecl; export;
+begin
+ cZoomVal:= value;
+ ZoomValue:= value;
+end;
+
procedure HW_zoomIn; cdecl; export;
begin
if wheelDown = false then
@@ -48,15 +69,21 @@
procedure HW_zoomReset; cdecl; export;
begin
- middleClick:= true;
+ ZoomValue:= cZoomVal;
+ //middleClick:= true;
// center the camera at current hog
if CurrentHedgehog <> nil then
followGear:= CurrentHedgehog^.Gear;
end;
-procedure HW_ammoMenu; cdecl; export;
+function HW_zoomFactor: GLfloat; cdecl; export;
begin
- rightClick:= true;
+ exit( ZoomValue / cDefaultZoomLevel );
+end;
+
+function HW_zoomLevel: LongInt; cdecl; export;
+begin
+ exit( trunc((ZoomValue - cDefaultZoomLevel) / cZoomDelta) );
end;
procedure HW_walkingKeysUp; cdecl; export;
@@ -148,18 +175,6 @@
if closeFrontend then alsoShutdownFrontend:= true;
end;
-procedure HW_setLandscape(landscape: boolean); cdecl; export;
-begin
- if landscape then
- begin
- cOffsetY:= 0;
- end
- else
- begin
- cOffsetY:= 120;
- end;
-end;
-
procedure HW_setCursor(x,y: LongInt); cdecl; export;
begin
CursorPoint.X:= x;
@@ -172,14 +187,69 @@
y^:= CursorPoint.Y;
end;
-procedure HW_setPianoSound(snd: LongInt); cdecl; export;
-var CurSlot, CurAmmo: LongWord;
+function HW_isAmmoMenuOpen: boolean; cdecl; export;
+begin
+ exit(bShowAmmoMenu);
+end;
+
+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)) );
+end;
+
+function HW_isPaused: boolean; cdecl; export;
+begin
+ exit( isPaused );
+end;
+
+function HW_isWaiting: boolean; cdecl; export;
+begin
+ exit( ReadyTimeLeft > 0 );
+end;
+
+function HW_isWeaponRequiringClick: boolean; cdecl; export;
+begin
+ if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.BotLevel = 0) then
+ exit( (CurrentHedgehog^.Gear^.State and gstHHChooseTarget) <> 0 )
+ else
+ exit(false);
+end;
+
+function HW_isWeaponTimerable: boolean; cdecl; export;
begin
- CurSlot:= CurrentHedgehog^.CurSlot;
- CurAmmo:= CurrentHedgehog^.CurAmmo;
+ if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then
+ exit( (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable) <> 0)
+ else
+ exit(false);
+end;
+
+function HW_isWeaponSwitch: boolean cdecl; export;
+begin
+ if (CurAmmoGear <> nil) and (CurrentHedgehog^.BotLevel = 0) then
+ exit(CurAmmoGear^.AmmoType = amSwitch)
+ else
+ exit(false)
+end;
+
+function HW_isWeaponRope: boolean cdecl; export;
+begin
+ if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then
+ exit (CurrentHedgehog^.CurAmmoType = amRope)
+ else
+ exit(false);
+end;
+
+procedure HW_setGrenadeTime(time: LongInt); cdecl; export;
+begin
+ ParseCommand('/timer ' + inttostr(time), true);
+end;
+
+procedure HW_setPianoSound(snd: LongInt); cdecl; export;
+begin
// this most likely won't work in network game
- if (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].AmmoType = amPiano) then
- case snd of
+ if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0)
+ and (CurrentHedgehog^.CurAmmoType = amPiano) then
+ case snd of
0: PlaySound(sndPiano0);
1: PlaySound(sndPiano1);
2: PlaySound(sndPiano2);
@@ -192,46 +262,76 @@
end;
end;
-function HW_isAmmoOpen: boolean; cdecl; export;
+function HW_getWeaponNameByIndex(whichone: LongInt): PChar; cdecl; export;
+begin
+ exit (str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId]));
+end;
+
+function HW_getWeaponCaptionByIndex(whichone: LongInt): PChar; cdecl; export;
begin
- exit(bShowAmmoMenu);
+ 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]));
end;
-function HW_isWeaponRequiringClick: boolean; cdecl; export;
+function HW_getNumberOfWeapons:LongInt; cdecl; export;
+begin
+ exit(ord(high(TAmmoType)));
+end;
+
+procedure HW_setWeapon(whichone: LongInt); cdecl; export;
begin
- if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then
- exit( (CurrentHedgehog^.Gear^.State and gstHHChooseTarget) <> 0 )
- else
- exit(false);
+ if (not CurrentTeam^.ExtDriven) and (CurrentTeam^.Hedgehogs[0].BotLevel = 0) then
+ SetWeapon(TAmmoType(whichone+1));
+end;
+
+function HW_isWeaponAnEffect(whichone: LongInt): boolean; cdecl; export;
+begin
+ exit(Ammoz[TAmmoType(whichone+1)].Ammo.Propz and ammoprop_Effect <> 0)
end;
-function HW_isWeaponTimerable: boolean; cdecl; export;
-var CurSlot, CurAmmo: LongWord;
+function HW_getAmmoCounts(counts: PLongInt): LongInt; cdecl; export;
+var a : PHHAmmo;
+ slot, index: LongInt;
begin
- CurSlot:= CurrentHedgehog^.CurSlot;
- CurAmmo:= CurrentHedgehog^.CurAmmo;
- exit( (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0)
+ if (CurrentTeam = nil) or
+ (CurrentHedgehog = nil) or
+ (CurrentTeam^.ExtDriven) or
+ (CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then
+ exit(-1);
+
+ a:= CurrentHedgehog^.Ammo;
+ for slot:= 0 to cMaxSlotIndex do
+ for index:= 0 to cMaxSlotAmmoIndex do
+ if a^[slot,index].Count <> 0 then // yes, ammomenu is hell
+ counts[ord(a^[slot,index].AmmoType)-1]:= a^[slot,index].Count;
+ exit(0);
end;
-function HW_isWeaponSwitch: boolean cdecl; export;
+procedure HW_getAmmoDelays (skipTurns: PByte); cdecl; export;
+var a : TAmmoType;
begin
- if CurAmmoGear <> nil then
- exit(CurAmmoGear^.AmmoType = amSwitch)
- else
- exit(false)
+ for a:= Low(TAmmoType) to High(TAmmoType) do
+ skipTurns[ord(a)-1]:= byte(Ammoz[a].SkipTurns);
end;
-function HW_isPaused: boolean; cdecl; export;
+function HW_getTurnsForCurrentTeam: LongInt; cdecl; export;
begin
- exit( isPaused );
+ exit(CurrentTeam^.Clan^.TurnNumber);
end;
-procedure HW_setGrenadeTime(time: LongInt); cdecl; export;
+function HW_getMaxNumberOfHogs: LongInt; cdecl; export;
begin
- ParseCommand('/timer ' + inttostr(time), true);
+ exit(cMaxHHIndex+1);
end;
-//amSwitch
+function HW_getMaxNumberOfTeams: LongInt; cdecl; export;
+begin
+ exit(cMaxTeams);
+end;
{$ENDIF}
end.