ID:157461
 
People on my game have been getting corrupted files were they go to a black screen and lose their pokemon.. What causes a corrupted file, may I ask? I have a regular save system and they can't save with a pokemon sent out, but I have gotten reports of a corrupted file. What causes these?! Please tell me so I can search my scripts.
Maybe those players tried to edit their own saves, are your savefiles encrypted?
In response to SteelPole (#1)
I've been able to pinpoint the error, when the Pokemon are caught, they aren't deleted or anything, but they are corrupted after you save and bring it back up. This can ultimately lead to a corrupted file.
mob
proc
AI()
while(src.owner=="None")
if(src.Attacker:Rank2=="Pokemon")
..()
else
spawn(100)
if(src.owner=="None")
src.Attacker<<"[src] fleed."
del(src)
step_towards(src,src.Attacker)
for(var/mob/M in get_step(src,src.dir))
if(M==src.Attacker)
if(M.Rank2=="Pokemon")
if(src.First==1)
src.MHP=M.MHP
src.HP=M.MHP
src.First=0
var/damage = round(src.Attacker:Attack*2/8)
src.Attacker<<"The Pokemon has done [damage] damage."
src.Attacker:HP -= damage
if(src.Attacker:HP<=0)
src.Attacker:HP=0
if(Attacker:Faint==1)
src.Attacker<< output("The enemy Pokemon has fleed.","default.BattleInfo")
del(src)
return
else
src.Attacker<< output("Your Pokemon fainted. Please return it now.","default.BattleInfo")
src.Attacker:overlays+='pokeball2.dmi'
src.Attacker:Faint=1
src.Attacker:Faint2=1
src.Attacker<< output("The enemy Pokemon has fleed.","default.BattleInfo")
del(src)
sleep(10)
src.AI()
else
..()
else
..()
sleep(5)
is my AI script, I seem to get an error, can not read Null.Rank2, and the pokemon disappears from my inventory. Could you explain why this may be?

EDIT: This doesn't seem to happen with Pokemon I create using the the Create verb. But, when I create it I get a can't read Null. Rank2 error, but it saves properly. NOTE: Pokemon I create don't HAVE an Attacker.
In response to Xyphon101 (#2)
The null.Rank2 error would be the result of src.Attacker not having a value.

As for the broader question... a large number of things could corrupt a savefile like you describe. To actually give an answer you'd have to post how you save/load, in addition to all of the variables and possible values of everything that is saved.

Perhaps an easier first step is to grab one of those corrupted savefiles and use ExportText() and post that.
In response to Garthor (#3)
How do I use ExportText() o_O
In response to Xyphon101 (#4)
In response to Garthor (#5)
Unfortunately, var/txtfile = file("players/[ckey].txt") is not in my script, and unless I get them on to save again after updating, it won't be.

I have a new problem, anyway, I fixed the black screen bugs.. but now they are losing verbs from a different bug.. How could you lose verbs from a bug?
In response to Xyphon101 (#6)
1. Please delete my other post.. It's misleading and I'd like to reevaluate everything.

1. Even though I fixed a black screen glitch, people are still getting it? Although I think it'a just players who haven't come on sense.. So I don't think this is a problem any more.

2. THIS is the big problem. For got knows why, people are losing, yes, LOSING, verbs and tabs. This is not a save error I don't think so, because I'm using the same save I was before (So please, spare me of the save lectures, people I could mention who ramble on about how everything I do is wrong, and that their way is right)

I just want a simple explanation of HOW you could lose verbs and tabs that you once had.
In response to Xyphon101 (#7)
What does this have to do with "Developer How-To"?

You're ranting about a malfunction in your game, not asking for help with something you don't understand how to do.
In response to Proteen (#8)
I'm wondering what could create a loss of verbs and tabs, there's no better place to put it, it's not a code problem because I can't provide any code to work with, it's not a bug report because it's not a byond bug.
In response to Xyphon101 (#9)
If its not a problem with the programming, or a problem with BYOND, I have no idea where it could be coming from.

How do you know its not the code if you don't have any code to show?
In response to Xyphon101 (#7)
Until you supply code snippits, people will be utterly unable to help you... probably.
In response to Mr.Tophat (#11)
I'm not saying it's not my code.. I'm saying it's most likely not my SAVE code, and I don't want to see garthor lecturing me on saving because it's not how he does it.
mob
proc
SaveFile()
var/savefile/F = new("players/[src.key].sav")
src.xco=src.x
src.yco=src.y
src.zco=src.z
Write(F)
src << "<font color=red><b>Your game has been saved!"

is the code..

I don't know what other code you need.
In response to Proteen (#10)
You aren't saving them . ......
In response to Gigimoi (#13)
This is the least using resource way to save some coordinates. This is explained in the DM guide about how they are not "cluttering up the object definition", whatever that means....

mob/Write(savefile/F)
F << x
F << y
F << z
..()
mob/Read(savefile/F)
var {saved_x; saved_y; saved_z}
F >> saved_x
F >> saved_y
F >> saved_z
..()
Move(locate(saved_x,saved_y,saved_z))

PS: Lol did you know the game your making, Pokemon Trainers Challenge, stands for PTC, which means Pay To Click. XD.
In response to Gigimoi (#13)
Gigimoi wrote:
You aren't saving them . ......
Oh, but I am, because every time I log on, my verbs are still there.
@Last person: Please read my first post, I don't want a lecture telling me what I'm doing is wrong.
In response to Xyphon101 (#15)
Xyphon101 wrote:
Gigimoi wrote:
You aren't saving them . ......
Oh, but I am, because every time I log on, my verbs are still there.
@Last person: Please read my first post, I don't want a lecture telling me what I'm doing is wrong.

I actually did read it. The thing is your code doesn't work at all. So I gave you a basis. Looks like you didnt read your posts because it took you more than 1 post for people to explain to actually post your code.
In response to Darkjohn66 (#14)
Note that you need a fallback if Move() fails. In this case, it's probably better just to fake it entirely:

var/turf/T = locate(x,y,z)
if(T)
loc = T
T.Entered(src)
T.loc.Entered(src)


(and then something else to deal with when you can't find a turf at those coordinates)
In response to Xyphon101 (#12)
Calling Write(F) directly can be the source of many, many, many errors, especially in combination with various other mistakes (like abusing mob/Login()).

People telling you that you're doing things wrong is not because they are looking to stroke their... egos. It's because you are doing things wrong and it leads to problems such as this. The more arbitrary the mistakes seem, the more likely it is that the reason they're so wrong is because they lead to errors that are incredibly difficult to track down, like usr abuse, and calling Write() directly.

Again, the most helpful thing is going to be for you to post the ExportText() of a savefile. Again, I'll point you to the Reference, but in the interest of avoiding more of your whining, I'll just post a simple verb for this:

mob/verb/test(var/f as file)
var/savefile/F = new(f)
usr << F.ExportText("/")


Also, for future reference: creating new threads for the same exact issue is incredibly annoying. Don't do it.
In response to Garthor (#18)
OK, not to be rude or anything, but how does doing << and >> for the x y and z have anything to do with the verbs? I'll be honest, no, I'm not good at DM I'm average at best. But I am very good at PHP, however, and if there's anything I've learned from PHP, it's that, although one way may appear to be more efficient, both ways are very usable. The x y and z are teleporting perfectly, so it has nothing to do with that. It is the tabs disappearing, and only that, that is the problem.
Page: 1 2