Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new shop data not initialized for non-updated games #151

Closed
ohrrpgce-bugbot opened this issue Feb 23, 2006 · 2 comments
Closed

new shop data not initialized for non-updated games #151

ohrrpgce-bugbot opened this issue Feb 23, 2006 · 2 comments
Labels
bug Yeah... that's broken rel: serendipity Present in serendipity 2006-02-15 / S+ 2006-02-16 shops

Comments

@ohrrpgce-bugbot
Copy link

[bz#151]

Taken from CP board:

[quote="FireEmblemPride"]And another thing... I was recently playing Ends of the
Earth 2 when I got to the town that you would get Reyna in. After doing all of
the events available, I decided that the best course of action was to buy some
equipment.

Well...

500-something gold, 72 Legendary Axes, and 115 S-Water Elements. That was the
cost for a new weapon.

Now, I know I have not played that game in a while, seeing as my fix of Sword of
Jade was temporarily halted at that moment I played it... but I am preeeettty
sure that I didn't need all of that stuff beforehand...

Any comments?[/quote]

This means that loading any version 5 RPG in the serendipity version of game.exe
will result in broken shops.

Not only do we need to fix this, we need to remember this for the future. When
expanding the record size for an existing data file it is very important to make
sure that the new data is correctly initialized for games that use the old
record size.

From: @bob-the-hamster
Reported version: 20060216 Serendipity+

@ohrrpgce-bugbot
Copy link
Author

Comment author: @rversteegen

(Noooo!!! I was scared this would happen somehow)

"This means that loading any version 5 RPG in the serendipity version of game.exe
will result in broken shops."

--------
DIM b(curbinsize(1) * 25)
recordsize = getbinsize(1) / 2
...
setpicstuf b(), recordsize * 100, -1
loadset game$ + ".stf" + CHR$(0), id, 0
--------
where b() is called like "b(o * recordsize + i)"

This code looked right at the time, but now that I look at it, read data with an
i larger than recordsize would read into the next shop item's data, and all the
real uninitialised data is at the end of b(). I suppose the shop stuff then
needs to be spread out over b() and recordsize set to curbinsize(1)/2

What I don't understand is why I didn't run into this when testing unupgraded
copies of TEST and WANDER. And also, why it took over a week for anybody to
notice this when it should break every shop in every game not released after S.
or edited by the person playing them.

EOTE2 is such an old game, and probably hasn't been updated since the author
disappeared many years ago, so it's very likely version 4 or less.

@ohrrpgce-bugbot
Copy link
Author

Comment author: @bob-the-hamster

Yay! I solved this one. Because each .STF record contains multiple sub-records
for each item in the shop, resizing this lump requires some extra code. The meat
of the fix is wrapped in this new loadshopstuf SUB

SUB loadshopstuf (array(), id)

ol = getbinsize(1) / 2 'old size on disk

nw = curbinsize(1) / 2 'new size in memory

flusharray array(), nw, 0

'load shop data from STF lump

setpicstuf buffer(), ol * 2 * 50, -1

loadset game$ + ".stf" + CHR$(0), id, 0

'in case shop data has been resized, scale records to new size

FOR i = 0 TO ol - 1

FOR o = 0 to 49

array(o * nw + i) = buffer(o * ol + i)

NEXT o

NEXT i

END SUB

check subversion for the full fix.

@ohrrpgce-bugbot ohrrpgce-bugbot added shops bug Yeah... that's broken rel: serendipity Present in serendipity 2006-02-15 / S+ 2006-02-16 labels Mar 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Yeah... that's broken rel: serendipity Present in serendipity 2006-02-15 / S+ 2006-02-16 shops
Projects
None yet
Development

No branches or pull requests

1 participant