fix: fix crash on mobile when enter world.

This commit is contained in:
Tungdv
2026-04-18 17:40:33 +07:00
parent fd08797f4a
commit 12ecb7dcb4
3 changed files with 21 additions and 17 deletions
@@ -683,7 +683,7 @@ namespace BrewMonster.Scripts
if (numHole > 0)
{
Holes.Clear();
Holes.Capacity = numHole;
//Holes.Capacity = numHole;
for (int i = 0; i < numHole; i++)
{
Holes.Add(dr.ReadInt());
@@ -701,7 +701,7 @@ namespace BrewMonster.Scripts
if (numProp > 0)
{
Props.Clear();
Props.Capacity = numProp;
//Props.Capacity = numProp;
for (int i = 0; i < numProp; i++)
{
int type = dr.ReadInt();
@@ -147,7 +147,7 @@ namespace BrewMonster.Scripts
};
#endregion
List<GOBLINSKILL> m_aSkills;
List<uint> m_aEquipID;
uint[] m_aEquipID;
IVTR_ESSENCE_GOBLIN m_Essence; // Goblin essence data
// Data in database
@@ -188,8 +188,8 @@ namespace BrewMonster.Scripts
m_aSkills[i] = other.m_aSkills[i];
// Copy equipments
int iNumEquip = other.m_aEquipID.Count;
m_aEquipID = new List<uint>(iNumEquip);
int iNumEquip = other.m_aEquipID.Length;
m_aEquipID = new uint[iNumEquip];
for(i=0; i< iNumEquip; i++)
m_aEquipID[i] = other.m_aEquipID[i];
@@ -310,10 +310,12 @@ namespace BrewMonster.Scripts
int i, iEquipCnt = dr.ReadInt();
m_Essence.equip_cnt = iEquipCnt;
m_aEquipID = new List<uint>(iEquipCnt);
for(i=0; i< iEquipCnt; i++)
// TODO: need optimize m_aEquipID, becasue iEquipCnt is big
m_aEquipID = new uint[iEquipCnt];
for (i=0; i< iEquipCnt; i++)
{
m_aEquipID[i] = (uint)dr.ReadInt();
m_aEquipID[i] = ((uint)dr.ReadInt());
}
// Set skill info
@@ -330,7 +332,7 @@ namespace BrewMonster.Scripts
}
catch (Exception e)
{
Debug.LogError("CECIvtrGoblin::SetItemInfo, data read error (" + e.GetType() + ")");
Debug.LogError("CECIvtrGoblin::SetItemInfo, data read error (" + e.GetType() + ")" + e.StackTrace);
return false;
}
@@ -393,7 +395,7 @@ namespace BrewMonster.Scripts
DATA_TYPE DataType = DATA_TYPE.DT_INVALID;
GOBLIN_EQUIP_ESSENCE pDBEssence;
for(i=0; i< m_aEquipID.Count; i++)
for(i=0; i< m_aEquipID.Length; i++)
{
pDBEssence = (GOBLIN_EQUIP_ESSENCE)pDB.get_data_ptr(m_aEquipID[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
iEquipStrength += pDBEssence.strength;
@@ -475,9 +477,9 @@ namespace BrewMonster.Scripts
AddPriceDesc(white, bRepair);
// Equipment info
if(m_aEquipID.Count != 0)
if(m_aEquipID.Length != 0)
m_strDesc += "\\r";
for(i=0; i< m_aEquipID.Count; i++)
for(i=0; i< m_aEquipID.Length; i++)
{
pDBEssence = (GOBLIN_EQUIP_ESSENCE)pDB.get_data_ptr(m_aEquipID[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLINEQUIP_POS_1 + pDBEssence.equip_type));
@@ -485,7 +487,7 @@ namespace BrewMonster.Scripts
}
// Skill list
if(m_aSkills.Count != 0 && m_aEquipID.Count == 0)
if(m_aSkills.Count != 0 && m_aEquipID.Length == 0)
m_strDesc += "\\r";
for (i=0; i < m_aSkills.Count; i++)
{
@@ -554,7 +556,7 @@ namespace BrewMonster.Scripts
DATA_TYPE DataType = DATA_TYPE.DT_INVALID;
GOBLIN_EQUIP_ESSENCE pDBEssence;
for(i=0; i< m_aEquipID.Count; i++)
for(i=0; i< m_aEquipID.Length; i++)
{
pDBEssence = (GOBLIN_EQUIP_ESSENCE)pDB.get_data_ptr(m_aEquipID[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
iEquipStrength += pDBEssence.strength;
@@ -679,7 +681,7 @@ namespace BrewMonster.Scripts
DATA_TYPE DataType = DATA_TYPE.DT_INVALID;
GOBLIN_EQUIP_ESSENCE pDBEssence;
for(i=0; i< m_aEquipID.Count; i++)
for(i=0; i< m_aEquipID.Length; i++)
{
pDBEssence = (GOBLIN_EQUIP_ESSENCE)pDB.get_data_ptr(m_aEquipID[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
iRet += pDBEssence.magic[iIndex];
@@ -1,8 +1,9 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace BrewMonster
{
@@ -150,8 +151,9 @@ namespace BrewMonster
}
void BoundCheck(int dwSize)
{
if (m_pCur + dwSize < m_pStart || m_pCur + dwSize > m_pEnd)
if (m_pCur < m_pStart || m_pCur + dwSize > m_pEnd)
{
//Debug.LogError("TYPE_OVERBOUND " + m_pCur + " || " + m_pStart + " || " + (m_pCur + dwSize) + " || " + m_pEnd);
throw new System.InvalidOperationException("Out of bounds");
}
}