So I have this code to load in a file. But it seems to keep going even after the file has ended...
Is there a known problem with File End(f), or can you see any mistakes in my code?
I have tried using WHILE FILE END(f) <> 1, and have also tried using a REPEAT - UNTIL FILE END(f) loop instead.
Nothing seems to work... As far as I can tell from debugging it just keeps going...
Any help is greatly appreciated...
// (NO RETURN VALUE) ENT_LoadEntities("FileName")
// Loads an Entity file.
//
function ENT_LoadEntities(FileName as string)
name as string
FileName = FileName + ".ent"
if file exist(FileName) = 0 then exitfunction
f = RES_grab(res_File)
open to read f, FileName
while file end(f) = 0
read string f, name
read word f, etype
i = ENT_AddEntity(name, etype)
info = ENT_Entity(i).info
if etype = ENT_TYPE_OBJECT then ENT_LoadObjectInfo(f, info)
// Add loading of other Entity types here...
// ...
endwhile
RES_free(f, res_File) // Close File and free resource number.
endfunction
// (NO RETURN VALUE) ENT_LoadObjectInfo(FileNumber, ObjectIndex)
// Loads Object specific attributes.
//
// DEVNOTE: Does not allocate resource numbers for the object at this time.
//
function ENT_LoadObjectInfo(f as integer, info as integer)
fname as string
read string f, fname
ENT_Object(info).fname = fname
x as float
y as float
z as float
b as boolean
read float f, x
read float f, y
read float f, z
set vector3 ENT_Object(info).pos, x, y, z
read float f, x
read float f, y
read float f, z
set vector3 ENT_Object(info).rot, x, y, z
read byte f, b
ENT_Object(info).dynamic = b
read byte f, b
ENT_Object(info).physics = b
endfunction