Closed michael-torkaman closed 8 months ago
This is what my user database file looks like when I create a new user profile. It appears to be making a new line each time it writes to the file.
yeah im investigating it. currently. Thank you for the output. for me it was writing it to the same line and creating a a new line underneath it which i dont know how that is possible but will fix it in a moment!
that's very strange. I can look into it. maybe I added something into the last code I pushed up
Im pretty sure a big part of it is the changes i added to the file paths. because i tried to touch as little code that you wrote as possible. there is probably some logic somewhere that breaks when i changed the file path scheme. If the filepaths are changed to the windows ones the problem will go away.
I want to say my code has a good amount of bugs so wouldn't blame you for running into issues lol. Change whatever you think would be for the best.
this is my user_database file after creating one user. it adds it to the end of the last user created and then adds a new line at the end of the file which is beyond me. And no the code is pretty solid. Its just multi threading is confusing and multi threading on a collaborative project where we are all experimenting is even more confusing. When it works it works. just need the game logic. and ironing out the bugs and we are out of the woods.
I'll look into this more. will try to reproduce this bug but yes I agree its really hard with multi-threading. I don't know how to use my debugger with threads
simple fix. issue closed. needed to remove a "\n" from the end of the saveUserCredentials() in ClientHandler.java fixed it. added a line to throw an exception when loading the database in server.java just in case. but should be removed later on.
not appending to user_database.txt properly. need to write to new line. on next run of server. server crashes. removing the empty lines at end of file fixes problem. Need to either correct how server reads from file. or correct how server writes to file. correcting both would be the best case. read correctly and write correctly.