Sys_Get_Empire_Fleet_ID doesn't work as expected |
| Project: | Space Empires V |
| Version: | 1.25-rev2 |
| Component: | Code |
| Category: | bug |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Description
Documentation says that this function should return
fleet id based on index which goes from 1 to obtained
number of fleets. This is not so.
Under the hood there is array which goes from 1 to fleet
count.
If fleet is disbanded element is set to 0.
If fleet is created element is is set to adequate index.
Value 1 for fleet id 1 at position 1. Value 2 for fleet id 2 at index position 2 and so on.
Sys_Get_Empire_Fleet_ID returns for index 1 value 1 if
fleet exists and value 0 if does not exists. This causes
problems with a code as fleet id 0 is returned instead of
2, for example, if fleet count is 1 and fleet at index 2
exists.
Fortunately this can be currently remedied
with following function as Sys_Get_Empire_Fleet_ID
simply returns index into array.
function Get_Empire_Fleet_ID returns long
params
player_id: long
index: long
vars
counter: long := 0
index1: long := 0
begin
loop
set index1 := index1 + 1
if (Sys_Get_Empire_Fleet_ID(player_id, index1) <> 0) then
set counter := counter + 1
endif
exitwhen (counter >= index)
endloop
return Sys_Get_Empire_Fleet_ID(player_id, index1)
end
Branimir Maksimovic



