// --------------------------------------------------------- bool CPartyDef::DeclineEvent( CChar * pCharDecline, CGrayUID uidInviter ) // static { ADDTOCALLSTACK("CPartyDef::DeclineEvent"); // This should happen after a timeout as well. // " You notify %s that you do not wish to join the party" CChar * pCharInviter = uidInviter.CharFind(); if ( !pCharInviter || !pCharDecline ) return( false ); if ( uidInviter == pCharDecline->GetUID() ) return( false ); CVarDefCont * sTempVal = pCharInviter->GetTagDefs()->GetKey("PARTY_LASTINVITE"); if ( !sTempVal ) return( false ); if ((DWORD)sTempVal->GetValNum() != (DWORD)pCharDecline->GetUID()) return( false ); // Remove the key pCharInviter->DeleteKey("PARTY_LASTINVITE"); TCHAR * sTemp = Str_GetTemp(); sprintf(sTemp, g_Cfg.GetDefaultMsg(DEFMSG_PARTY_DECLINE_2), static_cast<LPCTSTR>(pCharInviter->GetName())); pCharDecline->SysMessage( sTemp ); sTemp = Str_GetTemp(); sprintf(sTemp, g_Cfg.GetDefaultMsg(DEFMSG_PARTY_DECLINE_1), static_cast<LPCTSTR>(pCharDecline->GetName())); pCharInviter->SysMessage( sTemp ); return( true ); }
bool CPartyDef::AcceptEvent( CChar *pCharAccept, CGrayUID uidInviter, bool bForced ) // static { ADDTOCALLSTACK("CPartyDef::AcceptEvent"); // We are accepting the invite to join a party // No security checks if bForced -> true !!! // Party master is only one that can add ! GetChar(0) CChar *pCharInviter = uidInviter.CharFind(); if ( !pCharInviter || !pCharInviter->m_pClient || !pCharAccept || !pCharAccept->m_pClient || (pCharInviter == pCharAccept) ) return false; CPartyDef *pParty = pCharInviter->m_pParty; if ( !bForced ) { CVarDefCont *sTempVal = pCharInviter->GetTagDefs()->GetKey("PARTY_LASTINVITE"); if ( !sTempVal || (static_cast<CGrayUID>(sTempVal->GetValNum()) != pCharAccept->GetUID()) ) return false; pCharInviter->DeleteKey("PARTY_LASTINVITE"); if ( !pCharInviter->CanSee(pCharAccept) ) return false; } if ( pCharAccept->m_pParty ) // already in a party { if ( pParty == pCharAccept->m_pParty ) // already in this party return true; if ( bForced ) { pCharAccept->m_pParty->RemoveMember(pCharAccept->GetUID(), pCharAccept->GetUID()); pCharAccept->m_pParty = NULL; } else return false; } TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_PARTY_JOINED), pCharAccept->GetName()); if ( !pParty ) { // Create the party now. pParty = new CPartyDef(pCharInviter, pCharAccept); ASSERT(pParty); g_World.m_Parties.InsertHead(pParty); pCharInviter->SysMessage(pszMsg); } else { // Add to existing party if ( pParty->IsPartyFull() || (!bForced && !pParty->IsPartyMaster(pCharInviter)) ) return false; pParty->SysMessageAll(pszMsg); // tell everyone already in the party about this pParty->AcceptMember(pCharAccept); } pCharAccept->SysMessageDefault(DEFMSG_PARTY_ADDED); return true; }