ioquake / ioq3

The ioquake3 community effort to continue supporting/developing id's Quake III Arena
https://ioquake3.org/
GNU General Public License v2.0
2.42k stars 529 forks source link

FS_Seek return value #690

Open smallmodel opened 2 months ago

smallmodel commented 2 months ago

Hello,

https://github.com/ioquake/ioq3/blob/main/code/qcommon/files.c#L1694

When the file is inside a zip file, FS_Seek returns the requested offset. But when it's on the file system, FS_Seek returns the result of fseek, which is 0 on success. Is this correct? This looks like a mistake to me, it should always return 0 on success, and nonzero on failure.

zturtleman commented 2 months ago

Yeah, it seems incorrect. Though it's the original Quake 3 behavior and changing it could potentially affect mod compatibility. Code can reliably check if FS_Seek() return value is more or equal to 0 for success and less than 0 for failure.

smallmodel commented 1 month ago

Code similar to #691 was the reason why I was asking (from another engine based on quake3), but now it's clear that result < 0 = error. I think a small note above the FS_Seek function telling On success, it returns 0 or a positive value indicating the offset. On failure it returns a negative value indicating the error code could help, up to you.