本文整理汇总了C++中CGrayUID::ItemFind方法的典型用法代码示例。如果您正苦于以下问题:C++ CGrayUID::ItemFind方法的具体用法?C++ CGrayUID::ItemFind怎么用?C++ CGrayUID::ItemFind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGrayUID
的用法示例。
在下文中一共展示了CGrayUID::ItemFind方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DelObj
void CItemSpawn::DelObj( CGrayUID uid )
{
ADDTOCALLSTACK("CitemSpawn:DelObj");
if ( !uid.IsValidUID() )
return;
for ( unsigned char i = 0; i < GetCount(); i++ )
{
if ( m_obj[i].IsValidUID() && m_obj[i] == uid ) // found this uid, proceeding to clear it
{
if (GetType() == IT_SPAWN_CHAR) // IT_SPAWN_ITEM uses 'more2' to store how much items to spawn at once, so we must not touch it.
m_itSpawnChar.m_current--; // found this UID in the spawn's list, decreasing CChar's count only in this case
while ( m_obj[i + 1].IsValidUID() ) // searching for any entry higher than this one...
{
m_obj[i] = m_obj[i + 1]; // and moving it 1 position to keep values 'together'.
i++;
}
m_obj[i].InitUID(); // Finished moving higher entries (if any) so we free the last entry.
break;
}
}
if (uid.ItemFind())
uid.ItemFind()->m_uidSpawnItem.InitUID();
else if (uid.CharFind())
{
uid.CharFind()->m_uidSpawnItem.InitUID();
uid.CharFind()->StatFlag_Clear(STATF_Spawned);
}
}
示例2: AddObj
void CItemSpawn::AddObj( CGrayUID uid )
{
ADDTOCALLSTACK("CitemSpawn:AddObj");
unsigned char iMax = GetAmount() > 0 ? static_cast<unsigned char>(GetAmount()) : 1;
bool bIsSpawnChar = GetType() == IT_SPAWN_CHAR;
if (!uid)
return;
if ( bIsSpawnChar )
{
if ( !uid.CharFind()->m_pNPC) // Only adding NPCs to IT_SPAWN_CHAR..
return;
if ( uid.CharFind()->m_uidSpawnItem.ItemFind() ) //... if they doesn't have a SpawnItem already.
return;
} else if( !uid.ItemFind() ) // Only adding Items to IT_SPAWN_ITEM
return;
for ( unsigned char i = 0; i < iMax; i++ )
{
if ( m_obj[i] == uid ) // Not adding me again
return;
if ( !m_obj[i].ObjFind() )
{
m_obj[i] = uid;
if (bIsSpawnChar)
{
m_itSpawnChar.m_current++;
uid.CharFind()->StatFlag_Set(STATF_Spawned);
}
uid.ObjFind()->m_uidSpawnItem = GetUID();
break;
}
}
}
示例3: AddObj
void CItemSpawn::AddObj(CGrayUID uid)
{
ADDTOCALLSTACK("CitemSpawn:AddObj");
// NOTE: This function is also called when loading spawn items
// on server startup. In this case, some objs UID still invalid
// (not loaded yet) so just proceed without any checks.
bool bIsSpawnChar = IsType(IT_SPAWN_CHAR);
if ( !g_Serv.IsLoading() )
{
if ( !uid.IsValidUID() )
return;
if ( bIsSpawnChar ) // IT_SPAWN_CHAR can only spawn NPCs
{
CChar *pChar = uid.CharFind();
if ( !pChar || !pChar->m_pNPC )
return;
}
else if ( !uid.ItemFind() ) // IT_SPAWN_ITEM can only spawn items
return;
CItemSpawn *pPrevSpawn = static_cast<CItemSpawn*>(uid.ObjFind()->m_uidSpawnItem.ItemFind());
if ( pPrevSpawn )
{
if ( pPrevSpawn == this ) // obj already linked to this spawn
return;
pPrevSpawn->DelObj(uid); // obj linked to other spawn, remove the link before proceed
}
}
BYTE iMax = maximum(GetAmount(), 1);
for (BYTE i = 0; i < iMax; i++ )
{
if ( !m_obj[i].IsValidUID() )
{
m_obj[i] = uid;
m_currentSpawned++;
// objects are linked to the spawn at each server start
if ( !g_Serv.IsLoading() )
{
uid.ObjFind()->m_uidSpawnItem = GetUID();
if ( bIsSpawnChar )
{
CChar *pChar = uid.CharFind();
ASSERT(pChar->m_pNPC);
pChar->StatFlag_Set(STATF_Spawned);
pChar->m_ptHome = GetTopPoint();
pChar->m_pNPC->m_Home_Dist_Wander = static_cast<WORD>(m_itSpawnChar.m_DistMax);
}
}
break;
}
}
if ( !g_Serv.IsLoading() )
ResendTooltip();
}
示例4: WeDeclarePeace
void CItemStone::WeDeclarePeace(CGrayUID uid, bool fForcePeace)
{
ADDTOCALLSTACK("CItemStone::WeDeclarePeace");
CItemStone * pEnemyStone = dynamic_cast <CItemStone*>( uid.ItemFind());
if (!pEnemyStone)
return;
CStoneMember * pMember = GetMember(pEnemyStone);
if ( ! pMember ) // No such member
return;
// Set my flags on the subject.
if (!pMember->GetTheyDeclared() || fForcePeace) // If they're not at war with us, delete this record
delete pMember;
else
pMember->SetWeDeclared(false);
pEnemyStone->TheyDeclarePeace( this, fForcePeace );
}
示例5: Use_Train_ArcheryButte
bool CChar::Use_Train_ArcheryButte( CItem * pButte, bool fSetup )
{
ADDTOCALLSTACK("CChar::Use_Train_ArcheryButte");
// IT_ARCHERY_BUTTE
ASSERT(pButte);
ITEMID_TYPE AmmoID;
if ( GetDist(pButte) < 2 ) // if we are standing right next to the butte, retrieve the arrows/bolts
{
if ( pButte->m_itArcheryButte.m_AmmoCount == 0 )
{
SysMessageDefault(DEFMSG_ITEMUSE_ARCHB_EMPTY);
return true;
}
AmmoID = pButte->m_itArcheryButte.m_AmmoType;
CItemBase *pAmmoDef = CItemBase::FindItemBase(AmmoID);
if ( pAmmoDef )
{
TCHAR *pszMsg = Str_GetTemp();
sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_REM), pAmmoDef->GetName(), (pButte->m_itArcheryButte.m_AmmoCount == 1) ? "" : g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_REMS));
Emote(pszMsg);
CItem *pRemovedAmmo = CItem::CreateBase(AmmoID);
ASSERT(pRemovedAmmo);
pRemovedAmmo->SetAmount(pButte->m_itArcheryButte.m_AmmoCount);
ItemBounce(pRemovedAmmo);
}
// Clear the target
pButte->m_itArcheryButte.m_AmmoType = ITEMID_NOTHING;
pButte->m_itArcheryButte.m_AmmoCount = 0;
return true;
}
SKILL_TYPE skill = Fight_GetWeaponSkill();
if ( !g_Cfg.IsSkillFlag(skill, SKF_RANGED) )
{
SysMessageDefault(DEFMSG_ITEMUSE_ARCHB_WS);
return true;
}
if ( Skill_GetBase(skill) > g_Cfg.m_iSkillPracticeMax )
{
SysMessageDefault(DEFMSG_ITEMUSE_ARCHB_SKILL);
return true;
}
// Make sure we have some ammo
CItem *pWeapon = m_uidWeapon.ItemFind();
ASSERT(pWeapon);
const CItemBase *pWeaponDef = pWeapon->Item_GetDef();
// Determine ammo type
CVarDefCont *pVarAmmoType = pWeapon->GetDefKey("AMMOTYPE", true);
RESOURCE_ID_BASE rid;
LPCTSTR t_Str;
if ( pVarAmmoType )
{
t_Str = pVarAmmoType->GetValStr();
rid = static_cast<RESOURCE_ID_BASE>(g_Cfg.ResourceGetID(RES_ITEMDEF, t_Str));
}
else
{
rid = pWeaponDef->m_ttWeaponBow.m_idAmmo;
}
AmmoID = static_cast<ITEMID_TYPE>(rid.GetResIndex());
// If there is a different ammo type on the butte currently, tell us to remove the current type first
if ( (pButte->m_itArcheryButte.m_AmmoType != ITEMID_NOTHING) && (pButte->m_itArcheryButte.m_AmmoType != AmmoID) )
{
SysMessageDefault(DEFMSG_ITEMUSE_ARCHB_X);
return true;
}
// We need to be correctly aligned with the target before we can use it
// For the south facing butte, we need to have the same X value and a Y > 2
// For the east facing butte, we need to have the same Y value and an X > 2
if ( !pButte->IsTopLevel() )
{
badalign:
SysMessageDefault(DEFMSG_ITEMUSE_ARCHB_P);
return true;
}
int targDistX = GetTopPoint().m_x - pButte->GetTopPoint().m_x;
int targDistY = GetTopPoint().m_y - pButte->GetTopPoint().m_y;
if ( (pButte->GetID() == ITEMID_ARCHERYBUTTE_S) || (pButte->GetID() == ITEMID_MONGBATTARGET_S) )
{
if ( !(targDistX == 0 && targDistY > 2) )
goto badalign;
}
else
{
if ( !(targDistY == 0 && targDistX > 2) )
goto badalign;
}
if ( !CanSeeLOS(pButte, LOS_NB_WINDOWS) ) //we should be able to shoot through a window
//.........这里部分代码省略.........
示例6: r_WriteVal
//.........这里部分代码省略.........
CStoneMember * pMember = STATIC_CAST <CStoneMember *>(GetHead());
sVal.FormatVal(0);
for ( int i = 0 ; pMember != NULL; pMember = pMember->GetNext() )
{
if (pMember->GetLinkUID().IsChar())
continue;
if ( nNumber == i )
{
if (!pszCmd[0])
return true;
return pMember->r_WriteVal(pszCmd, sVal, pSrc);
}
i++;
}
return true;
}
else if ( !strnicmp("guildfromuid.", pszKey, 13) )
{
LPCTSTR pszCmd = pszKey + 13;
sVal.FormatVal(0);
if ( !pszCmd[0] )
return true;
CGrayUID pGuildUid = static_cast<DWORD>(Exp_GetVal(pszCmd));
SKIP_SEPARATORS(pszCmd);
CItem * pMemberGuild = pGuildUid.ItemFind();
if ( pMemberGuild )
{
CStoneMember * pGuild = GetMember( pMemberGuild );
if ( pGuild )
{
return pGuild->r_WriteVal(pszCmd, sVal, pSrc);
}
}
return true;
}
else if ( !strnicmp(sm_szLoadKeys[STC_CHARTER], pszKey, 7) )
{
LPCTSTR pszCmd = pszKey + 7;
unsigned int i = ATOI(pszCmd);
if ( i >= COUNTOF(m_sCharter))
sVal = "";
else
sVal = m_sCharter[i];
return( true );
}
STC_TYPE iIndex = (STC_TYPE) FindTableSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 );
switch ( iIndex )
{
case STC_ABBREV: // "ABBREV"
sVal = m_sAbbrev;
return true;
case STC_ALIGN:
示例7: r_GetRef
bool CItemStone::r_GetRef( LPCTSTR & pszKey, CScriptObj * & pRef )
{
ADDTOCALLSTACK("CItemStone::r_GetRef");
if ( !strnicmp("member.", pszKey, 7) )
{
pszKey = pszKey + 7;
if ( !pszKey[0] )
return false;
int nNumber = Exp_GetVal(pszKey);
SKIP_SEPARATORS(pszKey);
CStoneMember * pMember = STATIC_CAST <CStoneMember *>(GetHead());
for ( int i = 0; pMember != NULL; pMember = pMember->GetNext() )
{
if ( !pMember->GetLinkUID().IsChar() )
continue;
if ( nNumber == i )
{
pRef = pMember;
return true;
}
i++;
}
}
else if ( !strnicmp("memberfromuid.", pszKey, 14) )
{
pszKey = pszKey + 14;
if ( !pszKey[0] )
return false;
CGrayUID pMemberUid = static_cast<DWORD>(Exp_GetVal(pszKey));
SKIP_SEPARATORS(pszKey);
CChar * pMemberChar = pMemberUid.CharFind();
if ( pMemberChar )
{
CStoneMember * pMemberGuild = GetMember( pMemberChar );
if ( pMemberGuild )
{
pRef = pMemberGuild;
return true;
}
}
}
else if ( !strnicmp("guild.", pszKey, 6) )
{
pszKey = pszKey + 6;
if ( !pszKey[0] )
return false;
int nNumber = Exp_GetVal(pszKey);
SKIP_SEPARATORS(pszKey);
CStoneMember * pMember = STATIC_CAST <CStoneMember *>(GetHead());
for ( int i = 0; pMember != NULL; pMember = pMember->GetNext() )
{
if ( pMember->GetLinkUID().IsChar() )
continue;
if ( nNumber == i )
{
pRef = pMember;
return true;
}
i++;
}
}
else if ( !strnicmp("guildfromuid.", pszKey, 13) )
{
pszKey = pszKey + 13;
if ( !pszKey[0] )
return false;
CGrayUID pGuildUid = static_cast<DWORD>(Exp_GetVal(pszKey));
SKIP_SEPARATORS(pszKey);
CItem * pMemberGuild = pGuildUid.ItemFind();
if ( pMemberGuild )
{
CStoneMember * pGuild = GetMember( pMemberGuild );
if ( pGuild )
{
pRef = pGuild;
return true;
}
}
}
return CItem::r_GetRef( pszKey, pRef );
}
示例8: r_Verb
//.........这里部分代码省略.........
}
break;
case ISV_APPLYTOJOIN:
if ( s.HasArgs())
{
CGrayUID pMemberUid = s.GetArgVal();
CChar * pMemberChar = pMemberUid.CharFind();
if ( pMemberChar )
{
AddRecruit( pMemberChar, STONEPRIV_CANDIDATE );
}
}
break;
case ISV_CHANGEALIGN:
if ( s.HasArgs())
{
SetAlignType(static_cast<STONEALIGN_TYPE>(s.GetArgVal()));
TCHAR *pszMsg = Str_GetTemp();
sprintf(pszMsg, "%s is now a %s %s\n", static_cast<LPCTSTR>(GetName()), static_cast<LPCTSTR>(GetAlignName()), static_cast<LPCTSTR>(GetTypeName()));
Speak(pszMsg);
}
break;
case ISV_DECLAREPEACE:
if ( s.HasArgs())
{
CGrayUID pMemberUid = s.GetArgVal();
WeDeclarePeace(pMemberUid);
}
break;
case ISV_DECLAREWAR:
if ( s.HasArgs())
{
CGrayUID pMemberUid = s.GetArgVal();
CItem * pEnemyItem = pMemberUid.ItemFind();
if ( pEnemyItem )
{
CItemStone * pNewEnemy = dynamic_cast<CItemStone*>(pEnemyItem);
if ( pNewEnemy )
{
WeDeclareWar(pNewEnemy);
}
}
}
break;
case ISV_ELECTMASTER:
ElectMaster();
break;
// Need to change FixWeirdness or rewrite how cstonemember guilds are handled.
case ISV_INVITEWAR:
{
if ( s.HasArgs() )
{
INT64 piCmd[2];
size_t iArgQty = Str_ParseCmds( s.GetArgStr(), piCmd, COUNTOF(piCmd));
if ( iArgQty == 2 )
{
CGrayUID pGuildUid = static_cast<unsigned long>(piCmd[0]);
bool bWeDeclared = (piCmd[1] != 0);
CItem * pEnemyItem = pGuildUid.ItemFind();
if ( pEnemyItem && (pEnemyItem->IsType(IT_STONE_GUILD) || pEnemyItem->IsType(IT_STONE_TOWN)) )
{
CStoneMember * pMemberGuild = GetMember( pEnemyItem );
if ( !pMemberGuild )
pMemberGuild = new CStoneMember(this, pGuildUid, STONEPRIV_ENEMY);
if ( bWeDeclared )
示例9: r_Verb
//.........这里部分代码省略.........
m_Targ_Text = s.GetArgRaw();
m_tmTile.m_ptFirst.InitPoint(); // clear this first
m_tmTile.m_Code = CV_NUKECHAR; // set nuke code
addTarget(CLIMODE_TARG_TILE, g_Cfg.GetDefaultMsg(DEFMSG_SELECT_NUKE_CHAR_AREA), true);
break;
}
case CV_OPENPAPERDOLL:
{
CChar *pChar = m_pChar;
if ( s.HasArgs() )
{
CGrayUID uid = static_cast<CGrayUID>(s.GetArgVal());
pChar = uid.CharFind();
}
if ( pChar )
addCharPaperdoll(pChar);
break;
}
case CV_OPENTRADEWINDOW:
{
TCHAR *ppArgs[2];
Str_ParseCmds(s.GetArgStr(), ppArgs, COUNTOF(ppArgs));
CChar *pChar = NULL;
CItem *pItem = NULL;
if ( ppArgs[0] )
{
CGrayUID uidChar = static_cast<CGrayUID>(Exp_GetVal(ppArgs[0]));
pChar = uidChar.CharFind();
}
if ( ppArgs[1] )
{
CGrayUID uidItem = static_cast<CGrayUID>(Exp_GetVal(ppArgs[1]));
pItem = uidItem.ItemFind();
}
if ( pChar )
Cmd_SecureTrade(pChar, pItem);
break;
}
case CV_PAGE:
Cmd_GM_PageCmd(s.GetArgStr());
break;
case CV_REPAIR:
addTarget(CLIMODE_TARG_REPAIR, g_Cfg.GetDefaultMsg(DEFMSG_SELECT_ITEM_REPAIR));
break;
case CV_FLUSH:
#ifndef _MTNETWORK
g_NetworkOut.flush(this);
#else
g_NetworkManager.flush(m_NetState);
#endif
break;
case CV_RESEND:
addReSync();
break;
case CV_SAVE:
g_World.Save(s.GetArgVal() != 0);
break;
case CV_SCROLL:
// put a scroll up.
addScrollResource(s.GetArgStr(), SCROLL_TYPE_UPDATES);
break;
case CV_SENDPACKET:
SendPacket(s.GetArgStr());
break;
case CV_SELF: // fake self target