• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Write in local file: how to append a line ?

Status
Not open for further replies.
Hello,

I know well that you can write text to a local file with the following primitives:

JASS:
        call PreloadGenClear() // Optional, clear all previous entries in PreloadGen buffer
        call PreloadGenStart() // Clears the buffer and starts a timer until PreloadGenEnd, the time value gets appended to the file

        call Preload("<any text to write>") // adds the string to the buffer

        call PreloadGenEnd("<file full-name>") // unloads the buffer in a given path.

I'm using it in a logger in my map to debug all bugs, including desyncs. Currently I only do it in replay, but it's laggy. Because I cannot append a line to the file without rewriting the whole buffer to the file...

Is there a way to append 1 line to a file in a performant way ? Without rewriting all the file ?
 
[vJASS] - FileIO has appendBuffer method implemented. I would probably just use the lib.

Mhh I read the implementation. It's just saving the data in a struct, not writing it to the file. It only write in file on close() call.
In my case, I can't detect player desync event (if it is the local player who desyncs): player leaves or defeat event are not called.
So I need to write in file as soon as the log function is called, what results in tons of write per second, and lagg if I cannot append line by line...
 
There doesn't exist any trigger event to detect when the local player desyncs.

So if I want to see the last executed log before desync happens (in my logfile), I need to write-in-file each time there is a new log. This seems to be the only way to be certain the log is written in the file in case of desync.

But it laggs like hell to rewrite the whole file at each new log^^
 
Weird desync doesn't fire a leave event. Maybe a workaround is needed, like checking each second if player is still in game. And if player is not in game anymore, without an event fired, it's maybe caused by desync.

What's the use ?
Only other players would have this 1s periodic trigger executed just after desync (since I exited the game cause of desync). So my logfile would not display it.

Well back to the main question. There is no way to just happend a line to a local file ?
 
Status
Not open for further replies.
Top