From 3cf691393c3832ae933a2246450544cec7faf54a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 26 May 2022 00:46:30 +0100 Subject: [PATCH] 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 --- src/shapelib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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)] -- 2.30.2