Skip to content

Commit

Permalink
Fix FUNC template when create via ingame command
Browse files Browse the repository at this point in the history
  • Loading branch information
raydienull committed Dec 11, 2023
1 parent 56f6e6c commit 81b8d3b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/game/items/CItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,18 @@ CItem * CItem::ReadTemplate( CResourceLock & s, CObjBase * pCont ) // static
pScriptArgs = std::make_unique<CScriptTriggerArgs>(ptcArgs);
}

CObjBaseTemplate* pContObjBaseT = pCont->GetTopLevelObj();
ASSERT(pContObjBaseT);
pItem->r_Call(ptcFunctionName, dynamic_cast<CTextConsole*>(pContObjBaseT), pScriptArgs.get());
// use pCont is exist, if not use g_Serv
if (pCont)
{
CObjBaseTemplate* pContObjBaseT = pCont->GetTopLevelObj();
ASSERT(pContObjBaseT);
pItem->r_Call(ptcFunctionName, dynamic_cast<CTextConsole*>(pContObjBaseT), pScriptArgs.get());
}
else
{
pItem->r_Call(ptcFunctionName, &g_Serv, pScriptArgs.get());
}

if (pItem->IsDeleted())
{
pItem = nullptr;
Expand Down

0 comments on commit 81b8d3b

Please sign in to comment.