From 963e6bffaaf6a62a1f764c6633cf6accbb1608c9 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 17 六月 2025 08:54:35 +0800
Subject: [PATCH] 1.两片玻璃贴合后一起搬运的逻辑问题再优化,同时修改Slot信息,贴合后的玻璃应该放置在同一Slot.

---
 SourceCode/Bond/Servo/CEquipment.cpp |   43 ++++++++++++++++++++++++++-----------------
 1 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index db4ab5a..cdc0d73 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -255,13 +255,21 @@
 			if (!m_slot[i].isEnable()) continue;
 
 			CGlass* pGlass = (CGlass*)m_slot[i].getContext();
+			CGlass* pBuddy = nullptr;
 			if (pGlass == nullptr) {
 				attrubutes.addAttribute(new CAttribute(m_slot[i].getName().c_str(),
 					"", "", weight++));
 			}
 			else {
-				attrubutes.addAttribute(new CAttribute(m_slot[i].getName().c_str(),
-					pGlass->getID().c_str(), "", weight++));
+				pBuddy = pGlass->getBuddy();
+				if (pBuddy == nullptr) {
+					attrubutes.addAttribute(new CAttribute(m_slot[i].getName().c_str(),
+						pGlass->getID().c_str(), "", weight++));
+				}
+				else {
+					attrubutes.addAttribute(new CAttribute(m_slot[i].getName().c_str(),
+						(pGlass->getID() + " -> " + pBuddy->getID()).c_str(), "", weight++));
+				}
 			}
 
 		}
@@ -317,8 +325,13 @@
 			Lock();
 			for (int i = 0; i < SLOT_MAX; i++) {
 				m_slot[i].serialize(ar);
-				if (m_slot[i].getContext() != nullptr) {
-					((CGlass*)m_slot[i].getContext())->serialize(ar);
+				CGlass* pGlass = (CGlass *)m_slot[i].getContext();
+				if (pGlass != nullptr) {					
+					pGlass->serialize(ar);
+					CGlass* pBuddy = pGlass->getBuddy();
+					if (pBuddy != nullptr) {
+						pBuddy->serialize(ar);
+					}
 				}
 			}
 			Unlock();
@@ -330,10 +343,16 @@
 					CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
 					pGlass->serialize(ar);
 					m_slot[i].setContext(pGlass);
+					if (pGlass->getBuddy() != nullptr) {
+						CGlass* pBuddy = theApp.m_model.m_glassPool.allocaGlass();
+						pBuddy->serialize(ar);
+						pGlass->forceSetBuddy(pBuddy);
+					}
 				}
 			}
 			
 			// 梳理各玻璃之间的绑定关系
+			/*
 			Lock();
 			for (int i = 0; i < SLOT_MAX; i++) {
 				CGlass* pGlass = (CGlass*)m_slot[i].getContext();
@@ -351,6 +370,7 @@
 				}
 			}
 			Unlock();
+			*/
 		}
 	}
 
@@ -766,18 +786,6 @@
 			return -3;
 		}
 
-		// 如果此玻璃已经贴合,贴合的玻璃也要从列表中移除
-		CGlass* pBuddy = pContext->getBuddy();
-		if (pBuddy != nullptr) {
-			for (int i = 0; i < SLOT_MAX; i++) {
-				CGlass* pGlass = (CGlass*)m_slot[i].getContext();
-				if (pGlass != nullptr && compareJobDataB(pBuddy->getJobDataB(), pGlass->getJobDataB())) {
-					m_slot[i].setContext(nullptr);
-					break;
-				}
-			}
-		}
-
 
 		((CArm*)m_pArm)->tempStore(pContext);
 		pContext->release();
@@ -811,6 +819,7 @@
 
 
 		// 如果此玻璃已经贴合,贴合的玻璃也要从加入到列表中
+		/*
 		CGlass* pBuddy = pGlass->getBuddy();
 		if (pBuddy != nullptr) {
 			Lock();
@@ -823,7 +832,7 @@
 			}
 			Unlock();
 		}
-
+		*/
 
 		if (m_listener.onDataChanged != nullptr) {
 			m_listener.onDataChanged(this, EDCC_STORED_JOB);

--
Gitblit v1.9.3