[implemented] Constants or functions to return maximum zoneId and zoneIndex
Could we please get some constants ZONE_MAX_ID and ZONE_MAX_INDEX or functions like GetMaxZoneId() and GetMaxZoneIndex() so we can know how many zoneIds and indices there are to check for?
Currently we can only guess and hardode a loop from 1 to e.g. 2500 (increased each API patch) to check if GetZoneNameById or GetZoneNameByIndex returns a usable string or is empty. This way we "somehow know" it does not exist. |
ad § 1) would be useful indeed
ad § 2) assuming valid zone indices form contiguous sequence, you can quickly find max valid index by binary search without hardcoding some arbitrary limit |
Just for reference:
Someone already asked for the max_zone_id constant before, in this thread (my forum search did not find it though :confused:): https://www.esoui.com/forums/showthread.php?t=8480 Request was: MAX_ZONE_ID |
While Zone Index or Identifier tables may appear to be contiguous, they are not because, while the table index or identifier key (number) for either table is present, it's Zone name is not.
So I agree with everyone else who would like to know that there are 748 valid Zone entries in the Elsweyr release (100027) before one starts searching, because knowing beats the heck out of sequentially searching through a hypothetical table whose size has been hard-coded to 2000 entries. I checked that by building a table via a "for loop" that inserted a "NAME IS MISSING" constant into every table entry whose index or identifier returned a nil value to the game's API function call. There were too many "NAME IS MISSING" entries to count... :p |
Oh okay. I only knew there are missing zonIds. I thought the zoneIndex entries are contiguous. Good to know they aren't.
|
I checked on PTS and GetZoneNameByIndex() returns a non-empty string for all indices 1 through 726, and empty string for 727 and up. Which is in line with how the word "index" is used in other parts of the API: you have a valid thing for thingIndex = 1, GetNumThing()
|
I added in GetNumZones() to the API, which should be on PTS now. This will let you iterate over the zone indices which from there you should already have everything else you need.
|
Thank you, already usign it in my addons/libs now.
Thread can be closed, request is fullfilled! |
All times are GMT -6. The time now is 07:07 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI