-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Migrate convertible to foldable #59572
Merged
Fris0uman
merged 8 commits into
CleverRaven:master
from
irwiss:migrate-convertible-to-foldable
Aug 17, 2022
Merged
Migrate convertible to foldable #59572
Fris0uman
merged 8 commits into
CleverRaven:master
from
irwiss:migrate-convertible-to-foldable
Aug 17, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
[C++]
Changes (can be) made in C++. Previously named `Code`
[JSON]
Changes (can be) made in JSON
Code: Tests
Measurement, self-control, statistics, balancing.
Vehicles
Vehicles, parts, mechanics & interactions
<Bugfix>
This is a fix for a bug (or closes open issue)
json-styled
JSON lint passed, label assigned by github actions
astyled
astyled PR, label is assigned by github actions
Mutations / Traits / Professions/ Hobbies
Mutations / Traits / Professions/ Hobbies
NPC / Factions
NPCs, AI, Speech, Factions, Ownership
Spawn
Creatures, items, vehicles, locations appearing on map
and removed
json-styled
JSON lint passed, label assigned by github actions
labels
Jul 24, 2022
irwiss
force-pushed
the
migrate-convertible-to-foldable
branch
from
July 24, 2022 23:23
b6fe0b1
to
5712a69
Compare
github-actions
bot
added
json-styled
JSON lint passed, label assigned by github actions
BasicBuildPassed
This PR builds correctly, label assigned by github actions
labels
Jul 24, 2022
irwiss
force-pushed
the
migrate-convertible-to-foldable
branch
4 times, most recently
from
July 26, 2022 06:41
edcff4c
to
151721c
Compare
github-actions
bot
added
BasicBuildPassed
This PR builds correctly, label assigned by github actions
json-styled
JSON lint passed, label assigned by github actions
and removed
json-styled
JSON lint passed, label assigned by github actions
BasicBuildPassed
This PR builds correctly, label assigned by github actions
labels
Jul 26, 2022
irwiss
force-pushed
the
migrate-convertible-to-foldable
branch
from
July 30, 2022 16:14
151721c
to
369276c
Compare
github-actions
bot
added
<Documentation>
Design documents, internal info, guides and help.
[Markdown]
Markdown issues and PRs
BasicBuildPassed
This PR builds correctly, label assigned by github actions
labels
Jul 30, 2022
irwiss
force-pushed
the
migrate-convertible-to-foldable
branch
from
August 12, 2022 11:15
369276c
to
5341c34
Compare
irwiss
force-pushed
the
migrate-convertible-to-foldable
branch
from
August 13, 2022 20:30
5341c34
to
4229494
Compare
Hirmuolio
pushed a commit
to Hirmuolio/Cataclysm-DDA
that referenced
this pull request
Aug 27, 2022
* Allow itype definitions assign item's item_vars * Add docs on item properties, variables, itype's variables * Allow migrations to reset item's variables, document it * Migrate saved vehicles to generic foldables * Migrate folding bicycle, wheelchair, inflatable boat items * Remove "convertible" and unfold iuse from C++ side * Cosmetic changes * Adjust item groups, professions to new folded items
chaosvolt
added a commit
to chaosvolt/MST_Extra_Mod
that referenced
this pull request
Sep 18, 2022
So it turns out a long-forgotten side effect of CleverRaven/Cataclysm-DDA#21545 was breaking the janky hardcoded injection of certain flags and ammo effects into cataclysmbnteam/Cataclysm-BN#1857 makes this more important in BN but implemented same general changes to both versions in case DDA ever notices that function (and it's been about 5 years so literally everyone evidently never noticed any changes to crossbow behavior). Also updated the deployable vehicles in DDA version, as CleverRaven/Cataclysm-DDA#59572 updated folding vehicles. While a great idea on paper, in practice they somehow managed to invent a form of JSON that's even MORE of an unreadable mess than vehicle JSON is, with making folded_parts something you have to work with to implement deployable vehicles now.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
astyled
astyled PR, label is assigned by github actions
BasicBuildPassed
This PR builds correctly, label assigned by github actions
<Bugfix>
This is a fix for a bug (or closes open issue)
[C++]
Changes (can be) made in C++. Previously named `Code`
Code: Tests
Measurement, self-control, statistics, balancing.
<Documentation>
Design documents, internal info, guides and help.
[JSON]
Changes (can be) made in JSON
json-styled
JSON lint passed, label assigned by github actions
[Markdown]
Markdown issues and PRs
Mutations / Traits / Professions/ Hobbies
Mutations / Traits / Professions/ Hobbies
NPC / Factions
NPCs, AI, Speech, Factions, Ownership
Spawn
Creatures, items, vehicles, locations appearing on map
Vehicles
Vehicles, parts, mechanics & interactions
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Bugfixes "Migrate convertible stuff to foldable"
Purpose of change
Fixes #48113
Fixes #46752
Fixes #28976
Fixes #39399
Fixes #51005
Describe the solution
Patch converts all "convertible" items and vehicles to their to "generic" foldable equivalents.
This gets rid of all convertible-related code, including vehicle install/remove blocking on any vehicle with convertible flag, with minimal losses (some things like #28976 are a write off in existing saves)
There was an earlier attempt in #46805 but I don't believe you can do this migration mostly lossless with json alone.
Had to add some code to support 2 things:
Add "item_variables" to
itype
, they are then copied over to instance ofitem
's item_vars when one is created - this is so itypes are able to store variables as "presets", once anitem
is spawed it gets a copy and is then taking over and using their normal item::get_var/set_var to manipulate them. This allows having a preset of "folding_parts" the generic unfolding can use to produce a vehicle out of that parts list.Add support for
reset_item_vars
in Item_factory::migrate_item , this allows to reset thefolding_parts
(or any other) variable to the item prototype value, this allows to migrate the old parts to new and add the correspondingfolding_parts
so they can unfold.Stuff changed
The
folding_bicycle
vehicle used light frames (so: not "generically" foldable), and "convertible" tag + iuse action that used convertible tag to spawn a fresh bicycle on activation, this caused a bunch of issues from the flag not persisting through racking on bike rack to repairing demolished tiles on unfolding.folding_bicycle
is migrated tofolded_bicycle
- this one will use "generic" folding code paths.folded_bicycle
and loseconvertible*
flags.wheelchair
the vehicle already uses folding parts therefore mostly cosmetic adjustments were done to it.folded_wheelchair
which used convertible code is migrated tofolded_wheelchair_generic
which is the generic one.folded_wheelchair_generic
item that can be placed and unfolds into thewheelchair
vehicle.wheelchair
vehicles are untouched, they should fold into item closely matchingfolded_wheelchair
(sans vehicle name).Inflatable boat is probably weirdest of them all, it also had the same issues but also didn't sink if you destroyed one of the parts (sinking is out of scope of this patch)
inflatable_boat
is migrated tofolded_inflatable_boat
, to use "generic" folding code, also weight/volume adjusted to match the folded/unfolded versions for Inflatable boat volume and weight change when unused vs folded #48113 and "folded inflatable boat" very different from inflatable boat #51005inflatable_boat
remains exactly the sameinflatable_section
andinflatable_airbag
(parts the inflatable boat is made of) now have 2 new flags each:NO_INSTALL_PLAYER
,NO_UNINSTALL
- to match behaviour of vehicles flagged convertible - vehicle ui code did not allow modifications (and unbolting quarter of an inflatable boat makes no sense anyway)The bad parts
The "generic" folding code is saving json string as one of the item's variables, and that causes the prototypes for having an unfoldable item be super ugly since it's escaped json string as seen for example here can't think of a better solution right now that doesn't involve changing more code than necessary.
Inflatable boat required a pump before - it was handled in the iuse handler, for now the "generic" folding vehicles have nowhere to put it into and I wanted to keep this already awkward patch relatively light - I cheated a bit by adding pump into the description. Folding/unfolding has to become an activity either way, as current time of 500 moves to un/fold is unreasonable, that's the opportunity to let specific parts (inflatable bags for example) require pumps to unfold, or other tools depending on the parts involved.
Any folding bicycle that already passed a bike racking activity "lost" it's convertible flag and can no longer be differentiated from any other bicycle, so I decided to write them off and leave them as non-foldable.
Describe alternatives you've considered
Leaving convertible code to rot more
Testing
Before applying patch prepare map or load the one I prepared:
for each of (folding bicycle, wheelchair, inflatable boat):
spawn two and drop them nearby
spawn one and inflate/unfold it nearby
spawn one + any vehicle with rack and rack it on the vehicle
Save, apply patch and reload that save, check that:
a
ctivate itUnit test is removed for 3 reasons:
Additional context
Regenerating parts of a vehicle on fold/unfold cycle (in old convertible code)
https://user-images.githubusercontent.com/6560075/180669156-1164c82e-72c8-4ecd-8400-d362010e0fb1.mp4
"New" folding vehicles keep their damage and degradation on fold/unfold cycle
https://user-images.githubusercontent.com/6560075/180669217-cc95cd99-9959-40e9-96e9-6998e6c3343c.mp4