From 17d0c9f67245ce82ca735953bcfaeb74650c4ce5 Mon Sep 17 00:00:00 2001 From: "Marco Antonio J. Costa" Date: Wed, 22 Jul 2026 12:07:42 -0300 Subject: [PATCH] read the gear template item into the node, not into a temporary LoadEquipmentTemplate parsed each line of a saved equipment template like this: if ( iss >> num && iss >> (UINT16)node.item ) node.item is already a UINT16, so the cast does nothing except turn the member into a temporary. The stream then extracts into that temporary, which is thrown away at the semicolon, and node.item keeps the 0 its constructor gave it. node.ammoitem, cast the same way on the next line, is lost with it. This is not only a parse error. The tokens are still consumed, so the line parses and the node is appended, but every node comes back with item 0. The consumer skips those: if ( node.slot >= 0 && node.slot < NUM_INV_SLOTS && node.item != NOTHING ) so loading an equipment template has been quietly doing nothing at all. Only the attachments, read through a real variable, ever survived, and they were attached to a node that got skipped. Removing the two casts makes the extraction write where it was always meant to. slot is still read through num, as it must be, since it is an INT8 and the stream would take it for a character. This changes behaviour: gear templates will start applying. That is the point, but it is worth knowing before this ships. Verification: ninja -C build parse # both Handle Items.cpp sites gone ninja -C build -k 0 # Release, four applications, green ninja -C build-debug -k 0 # Debug, four applications, green Co-Authored-By: Claude Opus 4.8 --- Tactical/Handle Items.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index eca4d78bc..696ddd65e 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -9632,12 +9632,12 @@ std::vector LoadEquipmentTemplate( std::string aName ) GEAR_NODE node; int num; - if ( iss >> num && iss >> (UINT16)node.item ) + if ( iss >> num && iss >> node.item ) { node.slot = num; // additional data is optional - if ( iss >> (UINT16)node.ammoitem ) + if ( iss >> node.ammoitem ) { while ( iss >> num ) {