hedgewars/PascalExports.pas
changeset 6990 40e5af28d026
parent 6954 a61458a81480
child 6997 2356bf174df8
equal deleted inserted replaced
6989:4c35e9cf6057 6990:40e5af28d026
    89         followGear:= CurrentHedgehog^.Gear;
    89         followGear:= CurrentHedgehog^.Gear;
    90 end;
    90 end;
    91 
    91 
    92 function HW_zoomFactor: GLfloat; cdecl; export;
    92 function HW_zoomFactor: GLfloat; cdecl; export;
    93 begin
    93 begin
    94     exit( ZoomValue / cDefaultZoomLevel );
    94     HW_zoomFactor:= ZoomValue / cDefaultZoomLevel;
    95 end;
    95 end;
    96 
    96 
    97 function HW_zoomLevel: LongInt; cdecl; export;
    97 function HW_zoomLevel: LongInt; cdecl; export;
    98 begin
    98 begin
    99     exit( trunc((ZoomValue - cDefaultZoomLevel) / cZoomDelta) );
    99     HW_zoomLevel:= trunc((ZoomValue - cDefaultZoomLevel) / cZoomDelta);
   100 end;
   100 end;
   101 
   101 
   102 procedure HW_walkingKeysUp; cdecl; export;
   102 procedure HW_walkingKeysUp; cdecl; export;
   103 begin
   103 begin
   104     leftKey:= false;
   104     leftKey:= false;
   187     pauseAction:= true;
   187     pauseAction:= true;
   188 end;
   188 end;
   189 
   189 
   190 function HW_isPaused: boolean; cdecl; export;
   190 function HW_isPaused: boolean; cdecl; export;
   191 begin
   191 begin
   192     exit( isPaused );
   192     HW_isPaused:= isPaused;
   193 end;
   193 end;
   194 
   194 
   195 // equivalent to esc+y; when closeFrontend = true the game exits after memory cleanup
   195 // equivalent to esc+y; when closeFrontend = true the game exits after memory cleanup
   196 procedure HW_terminate(closeFrontend: boolean); cdecl; export;
   196 procedure HW_terminate(closeFrontend: boolean); cdecl; export;
   197 begin
   197 begin
   199     ParseCommand('forcequit', true);
   199     ParseCommand('forcequit', true);
   200 end;
   200 end;
   201 
   201 
   202 function HW_getSDLWindow: pointer; cdecl; export;
   202 function HW_getSDLWindow: pointer; cdecl; export;
   203 begin
   203 begin
       
   204     HW_getSDLWindow:= nil;
   204 {$IFDEF SDL13}
   205 {$IFDEF SDL13}
   205     exit( SDLwindow );
   206     HW_getSDLWindow:= SDLwindow;
   206 {$ELSE}
       
   207     exit( nil );
       
   208 {$ENDIF}
   207 {$ENDIF}
   209 end;
   208 end;
   210 
   209 
   211 // cursor handling
   210 // cursor handling
   212 procedure HW_setCursor(x,y: LongInt); cdecl; export;
   211 procedure HW_setCursor(x,y: LongInt); cdecl; export;
   222 end;
   221 end;
   223 
   222 
   224 // ammo menu related functions
   223 // ammo menu related functions
   225 function HW_isAmmoMenuOpen: boolean; cdecl; export;
   224 function HW_isAmmoMenuOpen: boolean; cdecl; export;
   226 begin
   225 begin
   227     exit( bShowAmmoMenu );
   226     HW_isAmmoMenuOpen:= bShowAmmoMenu;
   228 end;
   227 end;
   229 
   228 
   230 function HW_isAmmoMenuNotAllowed: boolean; cdecl; export;
   229 function HW_isAmmoMenuNotAllowed: boolean; cdecl; export;
   231 begin;
   230 begin;
   232     exit( (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil)
   231     HW_isAmmoMenuNotAllowed:= ( (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or
   233     or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) );
   232                                 ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) );
   234 end;
   233 end;
   235 
   234 
   236 function HW_isWeaponRequiringClick: boolean; cdecl; export;
   235 function HW_isWeaponRequiringClick: boolean; cdecl; export;
   237 begin
   236 begin
       
   237     HW_isWeaponRequiringClick:= false;
   238     if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.BotLevel = 0) then
   238     if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.BotLevel = 0) then
   239         exit( (CurrentHedgehog^.Gear^.State and gstHHChooseTarget) <> 0 )
   239         HW_isWeaponRequiringClick:= (CurrentHedgehog^.Gear^.State and gstHHChooseTarget) <> 0;
   240     else
       
   241         exit(false);
       
   242 end;
   240 end;
   243 
   241 
   244 function HW_isWeaponTimerable: boolean; cdecl; export;
   242 function HW_isWeaponTimerable: boolean; cdecl; export;
   245 begin
   243 begin
       
   244     HW_isWeaponTimerable:= false;
   246     if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then
   245     if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then
   247         exit( (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable) <> 0)
   246         HW_isWeaponTimerable:= (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable) <> 0;
   248     else
       
   249         exit(false);
       
   250 end;
   247 end;
   251 
   248 
   252 function HW_isWeaponSwitch: boolean cdecl; export;
   249 function HW_isWeaponSwitch: boolean cdecl; export;
   253 begin
   250 begin
       
   251     HW_isWeaponSwitch:= false;
   254     if (CurAmmoGear <> nil) and (CurrentHedgehog^.BotLevel = 0) then
   252     if (CurAmmoGear <> nil) and (CurrentHedgehog^.BotLevel = 0) then
   255         exit(CurAmmoGear^.AmmoType = amSwitch)
   253         HW_isWeaponSwitch:= (CurAmmoGear^.AmmoType = amSwitch);
   256     else
       
   257         exit(false)
       
   258 end;
   254 end;
   259 
   255 
   260 function HW_isWeaponRope: boolean cdecl; export;
   256 function HW_isWeaponRope: boolean cdecl; export;
   261 begin
   257 begin
       
   258     HW_isWeaponRope:= false
   262     if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then
   259     if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then
   263         exit(CurrentHedgehog^.CurAmmoType = amRope)
   260         HW_isWeaponRope:= (CurrentHedgehog^.CurAmmoType = amRope);
   264     else
       
   265         exit(false);
       
   266 end;
   261 end;
   267 
   262 
   268 procedure HW_setGrenadeTime(time: LongInt); cdecl; export;
   263 procedure HW_setGrenadeTime(time: LongInt); cdecl; export;
   269 begin
   264 begin
   270     ParseCommand('/timer ' + inttostr(time), true);
   265     ParseCommand('/timer ' + inttostr(time), true);
   271 end;
   266 end;
   272 
   267 
   273 function HW_getGrenadeTime: LongInt; cdecl; export;
   268 function HW_getGrenadeTime: LongInt; cdecl; export;
   274 var CurWeapon: PAmmo;
   269 var CurWeapon: PAmmo;
   275     res: LongInt = 3;
   270 begin
   276 begin
   271     HW_getGrenadeTime:= 3;
   277     if HW_isWeaponTimerable then
   272     if HW_isWeaponTimerable then
   278     begin
   273     begin
   279         CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^);
   274         CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^);
   280         res:= CurWeapon^.Timer div 1000;
   275         HW_getGrenadeTime:= CurWeapon^.Timer div 1000;
   281     end;
   276     end;
   282     exit(res);
       
   283 end;
   277 end;
   284 
   278 
   285 procedure HW_setPianoSound(snd: LongInt); cdecl; export;
   279 procedure HW_setPianoSound(snd: LongInt); cdecl; export;
   286 begin
   280 begin
   287     // this most likely won't work in network game
   281     // this most likely won't work in network game
   300         end;
   294         end;
   301 end;
   295 end;
   302 
   296 
   303 function HW_getWeaponNameByIndex(whichone: LongInt): PChar; cdecl; export;
   297 function HW_getWeaponNameByIndex(whichone: LongInt): PChar; cdecl; export;
   304 begin
   298 begin
   305     exit(str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId]));
   299     HW_getWeaponNameByIndex:= (str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId]));
   306 end;
   300 end;
   307 
   301 
   308 function HW_getWeaponCaptionByIndex(whichone: LongInt): PChar; cdecl; export;
   302 function HW_getWeaponCaptionByIndex(whichone: LongInt): PChar; cdecl; export;
   309 begin
   303 begin
   310     exit(str2pchar(trammoc[Ammoz[TAmmoType(whichone+1)].NameId]));
   304     HW_getWeaponCaptionByIndex:= (str2pchar(trammoc[Ammoz[TAmmoType(whichone+1)].NameId]));
   311 end;
   305 end;
   312 
   306 
   313 function HW_getWeaponDescriptionByIndex(whichone: LongInt): PChar; cdecl; export;
   307 function HW_getWeaponDescriptionByIndex(whichone: LongInt): PChar; cdecl; export;
   314 begin
   308 begin
   315     exit(str2pchar(trammod[Ammoz[TAmmoType(whichone+1)].NameId]));
   309     HW_getWeaponDescriptionByIndex:= (str2pchar(trammod[Ammoz[TAmmoType(whichone+1)].NameId]));
   316 end;
   310 end;
   317 
   311 
   318 function HW_getNumberOfWeapons:LongInt; cdecl; export;
   312 function HW_getNumberOfWeapons: LongInt; cdecl; export;
   319 begin
   313 begin
   320     exit(ord(high(TAmmoType)));
   314     HW_getNumberOfWeapons:= ord(high(TAmmoType));
   321 end;
   315 end;
   322 
   316 
   323 procedure HW_setWeapon(whichone: LongInt); cdecl; export;
   317 procedure HW_setWeapon(whichone: LongInt); cdecl; export;
   324 begin
   318 begin
   325     if (CurrentTeam = nil) then exit;
   319     if (CurrentTeam = nil) then exit;
   327         SetWeapon(TAmmoType(whichone+1));
   321         SetWeapon(TAmmoType(whichone+1));
   328 end;
   322 end;
   329 
   323 
   330 function HW_isWeaponAnEffect(whichone: LongInt): boolean; cdecl; export;
   324 function HW_isWeaponAnEffect(whichone: LongInt): boolean; cdecl; export;
   331 begin
   325 begin
   332     exit(Ammoz[TAmmoType(whichone+1)].Ammo.Propz and ammoprop_Effect <> 0)
   326     HW_isWeaponAnEffect:= Ammoz[TAmmoType(whichone+1)].Ammo.Propz and ammoprop_Effect <> 0;
   333 end;
   327 end;
   334 
   328 
   335 function HW_getAmmoCounts(counts: PLongInt): LongInt; cdecl; export;
   329 function HW_getAmmoCounts(counts: PLongInt): LongInt; cdecl; export;
   336 var a : PHHAmmo;
   330 var a : PHHAmmo;
   337     slot, index: LongInt;
   331     slot, index, res: LongInt;
   338 begin
   332 begin
       
   333     HW_getAmmoCounts:= -1;
   339     // nil check
   334     // nil check
   340     if (CurrentHedgehog = nil) or (CurrentHedgehog^.Ammo = nil) or (CurrentTeam = nil) then
   335     if (CurrentHedgehog = nil) or (CurrentHedgehog^.Ammo = nil) or (CurrentTeam = nil) then
   341         exit(-1);
   336         exit;
   342     // hog controlled by opponent (net or ai)
   337     // hog controlled by opponent (net or ai)
   343     if (CurrentTeam^.ExtDriven) or (CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then
   338     if (CurrentTeam^.ExtDriven) or (CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then
   344         exit(1);
   339         exit;
   345 
   340 
   346     a:= CurrentHedgehog^.Ammo;
   341     a:= CurrentHedgehog^.Ammo;
   347     for slot:= 0 to cMaxSlotIndex do
   342     for slot:= 0 to cMaxSlotIndex do
   348         for index:= 0 to cMaxSlotAmmoIndex do
   343         for index:= 0 to cMaxSlotAmmoIndex do
   349             if a^[slot,index].Count <> 0 then // yes, ammomenu is hell
   344             if a^[slot,index].Count <> 0 then // yes, ammomenu is hell
   350                 counts[ord(a^[slot,index].AmmoType)-1]:= a^[slot,index].Count;
   345                 counts[ord(a^[slot,index].AmmoType)-1]:= a^[slot,index].Count;
   351     exit(0);
   346     HW_getAmmoCounts:= 0;
   352 end;
   347 end;
   353 
   348 
   354 procedure HW_getAmmoDelays (skipTurns: PByte); cdecl; export;
   349 procedure HW_getAmmoDelays (skipTurns: PByte); cdecl; export;
   355 var a : TAmmoType;
   350 var a : TAmmoType;
   356 begin
   351 begin
   358         skipTurns[ord(a)-1]:= byte(Ammoz[a].SkipTurns);
   353         skipTurns[ord(a)-1]:= byte(Ammoz[a].SkipTurns);
   359 end;
   354 end;
   360 
   355 
   361 function HW_getTurnsForCurrentTeam: LongInt; cdecl; export;
   356 function HW_getTurnsForCurrentTeam: LongInt; cdecl; export;
   362 begin
   357 begin
       
   358     HW_getTurnsForCurrentTeam:= 0;
   363     if (CurrentTeam <> nil) and (CurrentTeam^.Clan <> nil) then
   359     if (CurrentTeam <> nil) and (CurrentTeam^.Clan <> nil) then
   364         exit(CurrentTeam^.Clan^.TurnNumber)
   360         HW_getTurnsForCurrentTeam:= CurrentTeam^.Clan^.TurnNumber;
   365     else
       
   366         exit(0);
       
   367 end;
   361 end;
   368 
   362 
   369 function HW_getMaxNumberOfHogs: LongInt; cdecl; export;
   363 function HW_getMaxNumberOfHogs: LongInt; cdecl; export;
   370 begin
   364 begin
   371     exit(cMaxHHIndex+1);
   365     HW_getMaxNumberOfHogs:= cMaxHHIndex + 1;
   372 end;
   366 end;
   373 
   367 
   374 function HW_getMaxNumberOfTeams: LongInt; cdecl; export;
   368 function HW_getMaxNumberOfTeams: LongInt; cdecl; export;
   375 begin
   369 begin
   376     exit(cMaxTeams);
   370     HW_getMaxNumberOfTeams:= cMaxTeams;
   377 end;
   371 end;
   378 
   372 
   379 procedure HW_memoryWarningCallback; cdecl; export;
   373 procedure HW_memoryWarningCallback; cdecl; export;
   380 begin
   374 begin
   381     ReleaseSound(false);
   375     ReleaseSound(false);