int CItemMemory::FixWeirdness() { ADDTOCALLSTACK("CItemMemory::FixWeirdness"); int iResultCode = CItem::FixWeirdness(); if ( iResultCode ) return iResultCode; if ( !IsItemEquipped() || (GetEquipLayer() != LAYER_SPECIAL) || !GetMemoryTypes() ) // has to be a memory of some sort. return 0x4222; // get rid of it. CChar *pChar = dynamic_cast<CChar *>(GetParent()); if ( !pChar ) return 0x4223; // get rid of it. // Make sure guild/town memories are linked correctly if ( IsMemoryTypes(MEMORY_GUILD|MEMORY_TOWN) ) { const CItemStone *pStone = pChar->Guild_Find(static_cast<MEMORY_TYPE>(GetMemoryTypes())); if ( !pStone || pStone->GetUID() != m_uidLink ) return 0x4224; // get rid of it. if ( !pStone->GetMember(pChar) ) return 0x4225; // get rid of it. } // Make sure guard memories are linked correctly (this is not an ERROR, just make the item decay on next tick) if ( IsMemoryTypes(MEMORY_GUARD) && !m_uidLink.ObjFind() ) { SetAttr(ATTR_DECAY); SetTimeout(0); } return 0; }
bool CItemStone::CheckValidMember( CStoneMember * pMember ) { ADDTOCALLSTACK("CItemStone::CheckValidMember"); ASSERT(pMember); ASSERT( pMember->GetParent() == this ); if ( GetAmount()==0 || g_Serv.m_iExitFlag ) // no reason to elect new if the stone is dead. return( true ); // we are deleting anyhow. switch ( pMember->GetPriv()) { case STONEPRIV_MASTER: case STONEPRIV_MEMBER: case STONEPRIV_CANDIDATE: case STONEPRIV_ACCEPTED: if ( GetMemoryType()) { // Make sure the member has a memory that links them back here. CChar * pChar = pMember->GetLinkUID().CharFind(); if ( pChar == NULL ) break; if ( pChar->Guild_Find( GetMemoryType()) != this ) break; } return( true ); case STONEPRIV_ENEMY: { CItemStone * pEnemyStone = dynamic_cast <CItemStone *>( pMember->GetLinkUID().ItemFind()); if ( pEnemyStone == NULL ) break; CStoneMember * pEnemyMember = pEnemyStone->GetMember(this); if ( pEnemyMember == NULL ) break; if ( pMember->GetWeDeclared() && ! pEnemyMember->GetTheyDeclared()) break; if ( pMember->GetTheyDeclared() && ! pEnemyMember->GetWeDeclared()) break; } return( true ); default: break; } // just delete this member. (it is mislinked) DEBUG_ERR(( "Stone UID=0%lx has mislinked member uid=0%lx\n", (DWORD) GetUID(), (DWORD) pMember->GetLinkUID())); return( false ); }
int CItemMemory::FixWeirdness() { int iResultCode = CItem::FixWeirdness(); if ( iResultCode ) { bailout: return( iResultCode ); } if ( ! IsItemEquipped() || GetEquipLayer() != LAYER_SPECIAL || ! GetMemoryTypes()) // has to be a memory of some sort. { iResultCode = 0x4222; goto bailout; // get rid of it. } CChar * pChar = dynamic_cast <CChar*>( GetParent()); if ( pChar == NULL ) { iResultCode = 0x4223; goto bailout; // get rid of it. } // If it is my guild make sure i am linked to it correctly ! if ( IsMemoryTypes(MEMORY_GUILD|MEMORY_TOWN)) { CItemStone * pStone = pChar->Guild_Find((MEMORY_TYPE) GetMemoryTypes()); if ( pStone == NULL || pStone->GetUID() != m_uidLink ) { iResultCode = 0x4224; goto bailout; // get rid of it. } if ( ! pStone->GetMember( pChar )) { iResultCode = 0x4225; goto bailout; // get rid of it. } } return( 0 ); }
int CItemMemory::FixWeirdness() { ADDTOCALLSTACK("CItemMemory::FixWeirdness"); int iResultCode = CItem::FixWeirdness(); if ( iResultCode ) return iResultCode; if ( !IsItemEquipped() || GetEquipLayer() != LAYER_SPECIAL || !GetMemoryTypes() ) // has to be a memory of some sort. { iResultCode = 0x4222; return iResultCode; // get rid of it. } CChar *pChar = dynamic_cast<CChar*>(GetParent()); if ( !pChar ) { iResultCode = 0x4223; return iResultCode; // get rid of it. } // If it is my guild make sure I am linked to it correctly ! if ( IsMemoryTypes(MEMORY_GUILD|MEMORY_TOWN) ) { const CItemStone *pStone = pChar->Guild_Find(static_cast<MEMORY_TYPE>(GetMemoryTypes())); if ( !pStone || pStone->GetUID() != m_uidLink ) { iResultCode = 0x4224; return iResultCode; // get rid of it. } if ( !pStone->GetMember(pChar) ) { iResultCode = 0x4225; return iResultCode; // get rid of it. } } return 0; }