Add handle storage task data method

This commit is contained in:
HungDK
2025-12-16 10:41:31 +07:00
parent a3f22af550
commit 6141971ddf
@@ -754,7 +754,25 @@ namespace BrewMonster.Scripts.Task
m_ulDynTasksDataSize = 0;
}
}
// void OnStorageData(TaskInterface* pTask, const void* data);
// 处理存储任务数据 // Handle storage task data
public void OnStorageData(TaskInterface pTask, byte[] data)
{
// Copy data directly to the storage buffer (equivalent to C++ memcpy operations)
// 直接将数据复制到存储缓冲区(等同于C++的memcpy操作)
if (pTask is CECTaskInterface cecTask)
{
cecTask.SetStorageTaskListBuffer(data);
}
else
{
// Fallback: read into struct (but won't persist without writing back)
// 后备方案:读取到结构体(但不写回则不会持久化)
StorageTaskList pLst = pTask.GetStorageTaskList();
pLst.ReadByte(data);
}
}
// void OnSpecialAward(const special_award* p,TaskInterface* pTask);
// void VerifyDynTasksPack(const char* szPath);
// const special_award* GetSpecialAward() const { return &m_SpecialAward; }
@@ -902,7 +920,9 @@ namespace BrewMonster.Scripts.Task
return false;
}
if (header.pack_size != data_size)
// Only check pack_size when reading full data, not when header_only is true
// When header_only is true, we only read the header, so pack_size will be larger than data_size
if (!header_only && header.pack_size != data_size)
{
// TaskInterface::WriteLog(0, 0, 0, "UnmarshalDynTasks, wrong header");
BMLogger.LogError($" [ATaskTemplMan] UnmarshalDynTasks, wrong header: pack_size {header.pack_size} != data_size {data_size}");