优化【自定义AI_生物】功能中一些提示,以免因数据库填写错误造成不必要麻烦
This commit is contained in:
parent
47ed48ae81
commit
2baafba765
@ -99,8 +99,6 @@ private:
|
||||
uint32 _value;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void CustomScript::LoadCreautreScripts()
|
||||
{
|
||||
uint32 CreatureScriptVec_OldMSTime = getMSTime();
|
||||
@ -170,6 +168,35 @@ void CustomScript::LoadCreautreScripts()
|
||||
Temp.actionType = ACTION_TYPE_NONE;
|
||||
}
|
||||
|
||||
// 在动作类型解析后添加验证
|
||||
if (Temp.actionType == ACTION_TYPE_SUMMON)
|
||||
{
|
||||
int32 summonEntry = atoi(Temp.actionParam1.c_str());
|
||||
if (summonEntry == 0)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "[自定义AI_生物]: 生物 {} 具有(召唤动作类型),但条目0无效,已跳过。", Temp.entry);
|
||||
continue; // 跳过这条无效记录
|
||||
}
|
||||
|
||||
// 可选:验证正数entry是否存在于creature_template,负数entry是否存在于gameobject_template
|
||||
if (summonEntry > 0)
|
||||
{
|
||||
if (!sObjectMgr->GetCreatureTemplate(summonEntry))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "[自定义AI_生物]: 引用了不存在的生物条目 {},已跳过。", Temp.entry, summonEntry);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sObjectMgr->GetGameObjectTemplate(abs(summonEntry)))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "[自定义AI_生物]: 引用了不存在的游戏对象条目 {},已跳过。", Temp.entry, abs(summonEntry));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Temp.actionParam1 = fields[6].Get<std::string>();
|
||||
Temp.actionParam2 = fields[7].Get<int32>();
|
||||
Temp.actionFlags = 0;//fields[8].Get<uint32>();
|
||||
@ -565,6 +592,13 @@ public:
|
||||
{
|
||||
int32 entry = atoi(actionParam1.c_str());
|
||||
|
||||
// 验证entry不能为0
|
||||
if (entry == 0)
|
||||
{
|
||||
LOG_ERROR("scripts", "[自定义AI_生物]: entry 0的ACTION_TYPE_SUMMON对生物{}无效 {}", me->GetEntry());
|
||||
break;
|
||||
}
|
||||
|
||||
uint32 map = me->GetMapId();
|
||||
float x = me->GetPositionX();
|
||||
float y = me->GetPositionY();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user