View Single Post
EfeDursun125
Senior Member
Join Date: Feb 2019
Location: Turkey
Old 04-11-2022 , 06:22   Re: File cannot be read correctly (only reads 1 character)
Reply With Quote #9

Quote:
Originally Posted by Bacardi View Post
...I think you gonna get more trouble by handling file on later.
I would suggest you to use KeyValues (and/or SMC parse to read).

But let's continue with this File structure. With BINARY mode (rb)

I encounter first problem with ReadString
Code:
    // read about the file and author // Note! (char author[32])
    WaypointHeader header;
    fp.ReadString(header.author, sizeof(header.author), sizeof(header.author));
...this start read all data as STRING from first line until it hits string limit (32) or NULL terminate, which is end of file.
Means, it read even new lines.
example
map.ewp
Code:
author is me
9
2
5
end
fp.ReadString(header.author, sizeof(header.author), sizeof(header.author)); output
Code:
author is me
9
2
5
end
... if AUTHOR name is less than 32 bytes you can't get correct version numbers.





Using ReadLine you can get one line at time.
Code:
author is me

But you need tell us in this point:
Are you gonna use waypoint files as normal TEXT file (so you can read with notepad)
Or are you gonna handle as binary file (this turn data to bytes so it is unreadable in notepad).

- How your waypoint file suppose to look at the end ?



*edit
Next you need replace Read -> https://sm.alliedmods.net/new-api/files/File/ReadInt8 or else
int origin[3];
error 035: argument type mismatch (argument 1)
fp.ReadInt8(m_paths[i].origin);

fp.ReadInt8(m_paths[i].origin[3]); is not working

i will use them as binary data
__________________
CS 1.6 E-BOT (Best Bot For Zombie Plague): https://github.com/EfeDursun125/CS-EBOT

Last edited by EfeDursun125; 04-11-2022 at 06:27.
EfeDursun125 is offline