Game Development Community

Corrupted data in saved file - looks like @{8>8 - help please

by Conor O Kane · in Torque Game Builder · 05/31/2008 (9:46 am) · 3 replies

I've created an online scoreboard for my new game, and I've found that some people's names are getting corrupted, so they are listed as this...

@{8>8

The problem seems to be happening when I save their name to a file. Unfortunately I can't reproduce this on my computer so I'm not sure exactly what's happening. It only seems to happen on about 10% of people's computers.

I have a name entry screen where the player types in their name. The I grab the text like this:

$playerName = textPlayerName.text;

where textPlayerName is a text object in the level that gets updated as they type, and then I save it to a file called player.txt

Since other file saves are not getting corrupted, I'm starting to suspect that there's something wrong with the text object returning its text field.

Has anyone encountered something like this before? Does anyone recognise this corrputed data - @{8>8 ?
This is proving to be a real pain to fix as I can't reproduce it on my computers.

#1
05/31/2008 (10:02 am)
I've received a response from someone who's name was corrupted. Their name.txt file contained what looks like random garbage converted to ASCII.
#2
06/01/2008 (5:15 am)
I really don't have an idea on why that should be happening.

To help resolve whether it's a corrupt string coming from the text GUI element or from the file-write operation you could could also write some "sanity" string(s) to the file. In that way you can see if it's pure file-write corruption or not so writing "DEADBEEF" or something else to the file. If that's corrupted then there's something funky going on in the file-write.

You could, after reading the text from the text-object and before you write it to file perhaps confirm or just display on screen the value being written to the file. Not sure if that's possible but it should immediately show if it's corrupt before it goes to file.

You're probably doing it but make sure you're closing/deleting the fileobject after use.

Not sure what else to suggest.

Melv.
#3
06/01/2008 (6:44 am)
Thanks for the tips Melv. I'm pretty sure the file I/O part is ok - it's basically copied and pasted from the file I/O example that comes with TGB 1.7.2

I've switched over from reading the player's name from the text object, to storing it in a string and updating the text object based on that. No new corrupted names have showed up on the scoreboard since this change, but there haven't been that many new players yet so I can't be sure if it's really fixed.