From: Ian Jackson Date: Wed, 25 May 2022 23:46:30 +0000 (+0100) Subject: shapelib: Fix a backward incompatible itemname field X-Git-Tag: otter-1.1.0~5 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3cf691393c3832ae933a2246450544cec7faf54a;p=otter.git shapelib: Fix a backward incompatible itemname field This is a bit of a bodge, but it will work right for existing games. Signed-off-by: Ian Jackson --- diff --git a/src/shapelib.rs b/src/shapelib.rs index 669b393d..10661a46 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -217,7 +217,7 @@ pub struct Item { #[derive(Debug,Serialize,Deserialize)] struct ItemInertForOcculted { - itemname: GoodItemName, + #[serde(default="dummy_item_name")] itemname: GoodItemName, desc: Html, svgd: Html, xform: FaceTransform, @@ -283,6 +283,15 @@ impl InertPieceTrait for ItemInertForOcculted { fn describe_html(&self, _: FaceId) -> Html { self.desc.clone() } } +fn dummy_item_name() -> GoodItemName { + "".to_string().try_into().unwrap() +} + +#[test] +fn test_dummy_item_name() { + let _ = dummy_item_name(); +} + //---------- ItemEnquiryData, LibraryEnquiryData ---------- #[derive(Debug,Clone,Serialize,Deserialize,Eq,PartialEq,Ord,PartialOrd)]