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

Supreme: HamSandwich format doesn't handle changed items #22

Open
MirrorAzure opened this issue Sep 15, 2024 · 0 comments
Open

Supreme: HamSandwich format doesn't handle changed items #22

MirrorAzure opened this issue Sep 15, 2024 · 0 comments
Labels
bug Something isn't working p-supreme Related to Supreme

Comments

@MirrorAzure
Copy link

Description

When saving world in hamsandwich format, all changes made in base items don't save.

Expected behavior

Hamsandwich format should save changed base items as well as it does with new items.

Actual behavior

Only new items are saved, but all changes made in base items are withdrawn.
However, world files saved in legacy supreme format stage those changes.

Steps to reproduce

  1. Create new world;
  2. Change base item;
  3. Save world in Hamsandwich format;
  4. Load saved world.

There is item_definitions section in new format, and it doesn't contain changed items data.

test_world.dlw
image

test_world.dlw_old
image

Possible reasons

The problem is probably in world2.cpp:

	for (int i = NUM_ORIGINAL_ITEMS; i < NumItems(); ++i)
	{
		item_definitions.write_string("");  // savename not yet implemented
		SaveItem(&item_definitions, GetItem(i));
	}

ref:
https://github.com/SpaceManiac/HamSandwich/blob/84f4b945165f134a7686f595be57fd096c2891ac/source/supreme/world2.cpp#L370C1-L374C3

We're only iterating through items which ids are between NUM_ORIGINAL_ITEMS and NumItems(), which are new added items.

Legacy saving method is using SaveItems function which handles cases when items were changed by player.

	changedItems=numItems-NUM_ORIGINAL_ITEMS;
	for(i=0;i<NUM_ORIGINAL_ITEMS;i++)
	{
		// has this item been modified in some way?
		if(memcmp(&items[i],&baseItems[i],sizeof(item_t)))
			changedItems++;
	}

ref:
https://github.com/SpaceManiac/HamSandwich/blob/84f4b945165f134a7686f595be57fd096c2891ac/source/supreme/items.cpp#L1075C1-L1081C3

@SpaceManiac SpaceManiac added p-supreme Related to Supreme bug Something isn't working labels Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p-supreme Related to Supreme
Projects
None yet
Development

No branches or pull requests

2 participants