fix: update logic show pet.

This commit is contained in:
Tungdv
2026-01-30 19:35:19 +07:00
parent b5d5ae1982
commit 8b4fb251de
2 changed files with 16 additions and 10 deletions
@@ -6,6 +6,7 @@ using CSNetwork.GPDataType;
using ModelRenderer.Scripts.GameData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using UnityEngine;
@@ -253,8 +254,8 @@ namespace BrewMonster.Scripts.Pet
// Update pets data in corral
public void UpdatePets(cmd_pet_room cmd, byte[] data)
{
byte[] pData = new byte[data.Length - Marshal.SizeOf(cmd)];
Buffer.BlockCopy(data, (Marshal.SizeOf(cmd)), pData, 0, pData.Length);
//byte[] pData = new byte[data.Length - Marshal.SizeOf(cmd)];
//Buffer.BlockCopy(data, (Marshal.SizeOf(cmd)), pData, 0, pData.Length);
int idx = Marshal.SizeOf(cmd);
int iSlot = 0;
byte[] tempBuffer = null;
@@ -262,13 +263,13 @@ namespace BrewMonster.Scripts.Pet
for (int i = 0; i < cmd.count; i++)
{
tempBuffer = new byte[Marshal.SizeOf<int>()];
Buffer.BlockCopy(pData, idx, tempBuffer, 0, Marshal.SizeOf<int>());
Buffer.BlockCopy(data, idx, tempBuffer, 0, Marshal.SizeOf<int>());
iSlot = BitConverter.ToInt32(tempBuffer);
//pData += sizeof(int);
idx += Marshal.SizeOf<int>();
tempBuffer = new byte[Marshal.SizeOf<info_pet>()];
Buffer.BlockCopy(pData, idx, tempBuffer, 0, Marshal.SizeOf<info_pet>());
Buffer.BlockCopy(data, idx, tempBuffer, 0, Marshal.SizeOf<info_pet>());
//const info_pet* pInfo = (const info_pet*)pData;
pInfo = GPDataTypeHelper.FromBytes<info_pet>(tempBuffer);
//pData += sizeof(info_pet);
@@ -565,7 +566,7 @@ namespace BrewMonster.Scripts.Pet
List<int> m_vecDynSkillIndex = new List<int>();
int m_iSpecialSkillIndex; // 保存专属技能在m_aSkills里的序号,只有进化宠有一个此技能
CECCounter m_cntAutoSkill;
CECCounter m_cntAutoSkill = new CECCounter();
List<int> m_aAutoSkills = new List<int>();
ROLEEXTPROP m_ExtProps;
@@ -640,7 +641,10 @@ namespace BrewMonster.Scripts.Pet
if (pe != null)
{
PET_ESSENCE petEs = (PET_ESSENCE)pe;
m_strName = new string((char[])(Array)petEs.name);
m_strName = new string(petEs.name
.TakeWhile(c => c != 0)
.Select(c => (char)c)
.ToArray());
EC_Game.GetGameRun().GetUIManager().FilterBadWords(ref m_strName);
}
}
@@ -921,7 +925,7 @@ namespace BrewMonster.Scripts.Pet
{
return false;
}
return m_pDBEssence?.id_type == 8783;
return m_pDBEssence.Value.id_type == 8783;
}
public bool IsMountPet()
{
@@ -929,7 +933,7 @@ namespace BrewMonster.Scripts.Pet
{
return false;
}
return m_pDBEssence?.id_type == 8781;
return m_pDBEssence.Value.id_type == 8781;
}
public bool IsCombatPet()
{
@@ -4,6 +4,7 @@ using BrewMonster.Scripts.Pet;
using BrewMonster.UI;
using CSNetwork;
using CSNetwork.GPDataType;
using System;
using System.Runtime.InteropServices;
using UnityEngine;
using static BrewMonster.Scripts.Pet.CECPetData;
@@ -80,8 +81,9 @@ namespace BrewMonster
{
CECGameRun pGameRun = EC_Game.GetGameRun();
switch (Msg.dwParam2)
int header = Convert.ToInt32(Msg.dwParam2);
Debug.LogError("OnMsgHstPetOpt header = " + header);
switch (header)
{
case CommandID.GAIN_PET:
{