Author Topic: Account System - corrupted files  (Read 2135 times)

0 Members and 1 Guest are viewing this topic.

Offline ShadowDancer

  • Major(1)
  • Posts: 22
Account System - corrupted files
« on: April 05, 2010, 04:52:01 am »
Hello, I'm working on my server script and I find one hard problem. I'm saving player account in .ini file, but when i'm trying to read it sometimes fail. What can be reasion of this?

I'm doing it like this:
Code: [Select]
procedure Save(ID)
begin
     WriteLnFile(Name+'.ini', data);
end

OnLeaveGame(id, kicked)
begin
     Save(ID);
end

OnPlayerCommand(ID, Text)
begin
    if GetPiece(Text, ' ', 1) = '/logout' then Save(ID);
end
Sorry, I'm not native English speaker...

Offline Stuffy

  • Soldier
  • **
  • Posts: 182
  • Very stuffy.
    • Climb-Zone Forum
Re: Account System - corrupted files
« Reply #1 on: April 05, 2010, 06:43:55 am »
is that your whole script?

or just an example?

The truth is out there? Does anyone know the URL?
The URL is here

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Account System - corrupted files
« Reply #2 on: April 05, 2010, 06:48:34 am »
Example XD
« Last Edit: April 05, 2010, 07:08:11 am by mich1103 »

Offline ShadowDancer

  • Major(1)
  • Posts: 22
Re: Account System - corrupted files
« Reply #3 on: April 05, 2010, 07:05:32 am »
is that your whole script?

lol :) Pseudocode. I'm calling function save in onplayerleave event. Function save contains WriteFIle, that creates file, and next filling it with WriteFileLn

Here is part of whole script: http://nopaste.gamedev.pl/?id=6723
« Last Edit: April 05, 2010, 07:10:32 am by ShadowDancer »
Sorry, I'm not native English speaker...

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Account System - corrupted files
« Reply #4 on: April 05, 2010, 07:42:51 am »
@ShadowDancer: A person's name can contain stuff that a filename cannot (a '?' for example, I think...).
You must change the person's name into something that can be guaranteed the ability to save it.

Maybe a function EncodeString(const Str: string): string; which converts each character into a 2-character hex value (exactly double in length; but you must prefix with 0 for numbers between 0 and F (00, 01, 02, ...0E, 0F, 1A, ..., FF)

I created a thing for it (don't have access to it right now) but still, if you try to figure it out, the more experience for you :P; just say if you want me to post it.

EDIT: Oh.. i took a look at the pseudocode and realized you already have a ProcessName thing going on... but im not sure why you do map.ProcessName(name) :/ (just know that if you try to crossfunc 'foo.bar', it'll try to call 'bar' inside of the script named 'foo')

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Account System - corrupted files
« Reply #5 on: April 05, 2010, 08:05:58 am »
I think that the problem we have is due onplayerleave because when i go modify
the lvl of skills and i save it (in the folder of the Acc)! I go ingame i have the skills ive modified but when i leave my skills recome with -1 ... so i think is due to the INI writting :P

Offline ShadowDancer

  • Major(1)
  • Posts: 22
Re: Account System - corrupted files
« Reply #6 on: April 05, 2010, 09:21:30 am »
@ShadowDancer: A person's name can contain stuff that a filename cannot (a '?' for example, I think...).
You must change the person's name into something that can be guaranteed the ability to save it.

Maybe a function EncodeString(const Str: string): string; which converts each character into a 2-character hex value (exactly double in length; but you must prefix with 0 for numbers between 0 and F (00, 01, 02, ...0E, 0F, 1A, ..., FF)

Function ProcessName converts all '<', '?' , '|' etc. in char (250), char (251) etc.
File exists, everything works in most cases, but sometimes just there's reading file error, and ReadIni pleaces invalid value.
Sorry, I'm not native English speaker...

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Account System - corrupted files
« Reply #7 on: April 05, 2010, 09:25:02 am »
Do you use built-in ReadINI() ?

Offline ShadowDancer

  • Major(1)
  • Posts: 22
Re: Account System - corrupted files
« Reply #8 on: April 05, 2010, 09:42:05 am »
yes

Here is nearby full code: http://nopaste.gamedev.pl/?id=6723
It works, but sometimes crashes. Maybe it's due to server restarting with ctrl+c?
« Last Edit: April 05, 2010, 11:23:10 am by ShadowDancer »
Sorry, I'm not native English speaker...

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Account System - corrupted files
« Reply #9 on: April 05, 2010, 12:37:07 pm »
Hmmmm the server has crashed again for another reason !!!

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Account System - corrupted files
« Reply #10 on: April 05, 2010, 12:42:58 pm »
It's a pretty old script by Gizd, the script can crash easily when you declared alot of special bots aswell having alot of bots in the server. Make such a script yourself is way better. (It has lots of loops /:)

Offline ShadowDancer

  • Major(1)
  • Posts: 22
Re: Account System - corrupted files
« Reply #11 on: April 05, 2010, 01:31:09 pm »
I found in another topic something about ini files, maybe it can be because of storing data inside ini files?
Sorry, I'm not native English speaker...

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Account System - corrupted files
« Reply #12 on: April 05, 2010, 03:20:23 pm »
I found in another topic something about ini files, maybe it can be because of storing data inside ini files?
i've used them alot before, and haven't had too many problems. How often does it break?

Offline ShadowDancer

  • Major(1)
  • Posts: 22
Re: Account System - corrupted files
« Reply #13 on: April 05, 2010, 05:24:01 pm »
I dont know, i'm just playing and sometimes when checking stats i see -1 ;/ I will check it.
Sorry, I'm not native English speaker...

Offline Stuffy

  • Soldier
  • **
  • Posts: 182
  • Very stuffy.
    • Climb-Zone Forum
Re: Account System - corrupted files
« Reply #14 on: April 05, 2010, 05:31:01 pm »
Quote
lol :) Pseudocode. I'm calling function save in onplayerleave event. Function save contains WriteFIle, that creates file, and next filling it with WriteFileLn

Better save than sorry
The truth is out there? Does anyone know the URL?
The URL is here

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Account System - corrupted files
« Reply #15 on: April 06, 2010, 01:22:36 am »
welll... Looks like you do a lot of readinis when you can do one readfile and then parse it. Could anyone who used crossfunc a lot comment on its reliability?

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Account System - corrupted files
« Reply #16 on: April 06, 2010, 02:50:40 am »
Just make your own INI-reading procedure \o/

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Account System - corrupted files
« Reply #17 on: April 06, 2010, 04:26:24 am »
Or simply don't use it and make your own saving system and seperate data with a space or another symbols.. Most people use that since own INI-Reading/Writing w/e functions aren't the best for your server due to much loops D: