|
.dat loaders in v2k+j? Displaying 1-6 of 6 total.
1
el_desconocido
|
Am I the only one having trouble getting previously working .dat loading fontions working in v2k+j? I've been helping someone port his project, and it always loads the first character's .dat twice, then proceeds like normal. The exact same code works in v2, v2k, and v2k beta 6.1. (albeit with extra blank lines at top for all but v2)
The code goes a little like this: (edited so the board won't eat it)
For(lin=1; lin is_less_than 11; lin++)
{
partydat = f open ("party.dat");
f seekline (lin,partydat); f getline (strin,partydat); party.chr[lin-1] = left(strin,12);
chrdat = mid (strin,26,12);
f close (partydat);
datfil = f open (chrdat);
f seekline (1,datfil); f getline (strin,datfil); party.name[lin-1] = strin; ptmp=0; While(!ptmp) { If(!strcmp (right(party.name[lin-1],1)," ")) party.name[lin-1] = left (party.name[lin-1],strlen (party.name[lin-1])-1); Else { ptmp++; } }
f seekline (2,datfil); f getline (strin,datfil);
party.exp[lin-1] = val (left(strin,1));
party.maxhp[lin-1] = val (mid(strin,7,5));
party.maxmp[lin-1] = val (mid(strin,15,4));
party.curhp[lin-1] = party.maxhp[lin-1]; party.curmp[lin-1] = party.maxmp[lin-1]; party.tmaxhp[lin-1] = party.maxhp[lin-1];
party.lvl[lin-1] = 1;
party.str[lin-1] = val(mid(strin,23,4));
(more of same)
f close (datfil);
}
For some reason when it grabs the party member from party.dat, the first two times through the loop, it grabs the first member both times. Still, it loads 10 members, just #1 twice, then 2-9.
Mind boggles...
-Pontifex
(aka: ¶, the coder formerly known as Prince Paul)
Posted on 2000-11-14 19:56:58
|
andy
|
I thought I had fixed that fseekline bug. (the one that shows up in all the other v2k's) Maybe I just made it worse. @_@;
(but Sully Pi's dat loaders work great under it)
Does it work when you remove the extra blank lines? (a la plain-vanilla v2)
'What you get by achieving your goals is not as important as what you become by achieving your goals.' -Zig Ziglar
Posted on 2000-11-14 22:02:13
|
el_desconocido
|
Yep, tried 0, 1, and 2 blank lines. Also, fseekline seems to work fine in other (later) loads within the same function, and in fact loads the member's .dats perfectly. It seems the bug is much more subtle, like it screws up only on first call within a loop, or only with files named 'party.dat' (ya, unlikely), or some such.
I can send the offending code and .dats, if you think it may help pinpoint the bug.
FYI this is actually code from LF's LotBSO, which William Wong is using for his own game (looking good, too), and I'm helping him to port to the latest-greatest version. I had similar problems porting rev:tmp, but I've been revamping the whole system (went back to v2k, for now) and don't recall the exact problem at the moment. I'll try and reproduce the bug in my own code, as soon as I get it back up and running full force.
And I'm curious... why did you need donothing()?
-Pontifex
(aka: ¶, the coder formerly known as Prince Paul)
Posted on 2000-11-14 23:39:52
|
Ear
|
fgetline skips to the next line for you. Also, instead of using fgetline and then splitting a giant string, wouldn't using fgettoken be easier? If you do need to skip a line that only contains comments, you can use fgetline into a dummy sting and simply not use it. ;)
- Ear
Posted on 2000-11-15 16:06:12
|
Ear
|
Just use < for < and > for <!
- Ear
Posted on 2000-11-15 16:11:59
|
el_desconocido
|
Well, I normally use nothing but fgettoken()s, as it makes it easy to add things in later, but that is code from someone else's project, and I didn't want to rewrite all thier functions. Also, I avoided < & > to be safe, since the board kept throwing up errors, and refusing to post my message.
The unneeded fseekline() may be the cause, though, so I'll look into that.
Thanks, :-)
-Pontifex
(aka: ¶, the coder formerly known as Prince Paul)
Posted on 2000-11-15 19:31:47
|
Displaying 1-6 of 6 total.
1
|
|