Fixes an issue where JSON_ArrayIterate
would skip index 0 and potentially cause out of bounds errors too.
This change requires the index
variable be assigned -1
before using JSON_ArrayIterate
.
Example:
LoadMotelHubs()
{
new Node:node, Node:motels;
JSON_ParseFile(MOTEL_DATA_FILE, node);
JSON_GetArray(node, "motels", motels);
new Node:motel, index = -1, data[MOTEL_DATA], motelid;
while(!JSON_ArrayIterate(motels, index, motel))
{
JSON_GetInt(motel, "motelid", motelid);
JSON_GetString(motel, "name", data[MotelName]);
JSON_GetFloat(motel, "x", data[MotelX]);
JSON_GetFloat(motel, "y", data[MotelY]);
JSON_GetFloat(motel, "z", data[MotelZ]);
JSON_GetInt(motel, "interior", data[MotelInterior]);
JSON_GetInt(motel, "world", data[MotelVirtualWorld]);
JSON_GetInt(motel, "fee", data[MotelFee]);
map_add_arr(MotelHubs, motelid, data);
}
}