void Channel::Join(uint64 p, const char *pass) { WorldPacket data; std::string worldChatChannelName = sWorld->GetWorldChatChannelName(); uint64 worldChatOwnerGuid = sWorld->GetWorldChatOwnerGuid(); uint64 worldChatIdleGuid = sWorld->GetWorldChatIdleGuid(); if (IsOn(p)) { if ( m_name != worldChatChannelName ) { if (!IsConstant()) { MakePlayerAlreadyMember(&data, p); SendToOne(&data, p); } return; } } if (IsBanned(p)) { MakeBanned(&data); SendToOne(&data, p); return; } if (m_password.length() > 0 && strcmp(pass, m_password.c_str())) { MakeWrongPassword(&data); SendToOne(&data, p); return; } Player* player = ObjectAccessor::FindPlayer(p); if (player) { if (HasFlag(CHANNEL_FLAG_LFG) && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && player->GetGroup()) { MakeNotInLfg(&data); SendToOne(&data, p); return; } player->JoinedChannel(this); } if (m_announce && (!player || !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { MakeJoined(&data, p); SendToAll(&data); } data.clear(); PlayerInfo pinfo; pinfo.player = p; pinfo.flags = MEMBER_FLAG_NONE; players[p] = pinfo; MakeYouJoined(&data); SendToOne(&data, p); JoinNotify(p); if ( m_name != worldChatChannelName ) { if (!IsConstant() && !m_ownerGUID) { SetOwner(p, (players.size() > 1 ? true : false)); players[p].SetModerator(true); } } else { if ( p == worldChatOwnerGuid ) { SetOwner(worldChatOwnerGuid, true); players[worldChatOwnerGuid].SetModerator(true); } else { SetOwner(worldChatIdleGuid, true); players[worldChatIdleGuid].SetModerator(true); } } }
void Channel::Leave(uint64 p, bool send) { std::string worldChatChannelName = sWorld->GetWorldChatChannelName(); uint64 worldChatOwnerGuid = sWorld->GetWorldChatOwnerGuid(); uint64 worldChatIdleGuid = sWorld->GetWorldChatIdleGuid(); if (!IsOn(p)) { if (send) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); } } else { Player* player = ObjectAccessor::FindPlayer(p); if (send) { WorldPacket data; MakeYouLeft(&data); SendToOne(&data, p); if (player) player->LeftChannel(this); data.clear(); } bool changeowner = players[p].IsOwner(); players.erase(p); if (m_announce && (!player || !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { WorldPacket data; MakeLeft(&data, p); SendToAll(&data); } LeaveNotify(p); if (!IsConstant()) { // Update last_used timestamp in db UpdateChannelUseageInDB(); // If the channel owner left and there are still players inside, pick a new owner if (changeowner && m_ownership && !players.empty()) { if ( m_name != worldChatChannelName ) { uint64 newowner = !players.empty() ? players.begin()->second.player : 0; players[newowner].SetModerator(true); SetOwner(newowner); } else { if ( IsOn(worldChatOwnerGuid) ) { uint64 newowner = worldChatOwnerGuid; players[newowner].SetModerator(true); SetOwner(newowner); } else { uint64 newowner = worldChatIdleGuid; players[newowner].SetModerator(true); SetOwner(newowner); } } } } } }
void Channel::LeaveChannel(Player* player, bool send) { uint64 guid = player->GetGUID(); if (!IsOn(guid)) { if (send) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, guid); } return; } if (send) { WorldPacket data; MakeYouLeft(&data); SendToOne(&data, guid); player->LeftChannel(this); data.clear(); } bool changeowner = playersStore[guid].IsOwner(); playersStore.erase(guid); if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { WorldPacket data; MakeLeft(&data, guid); SendToAll(&data); } RemoveWatching(player); LeaveNotify(player); if (!IsConstant()) { // Update last_used timestamp in db UpdateChannelUseageInDB(); // If the channel owner left and there are still playersStore inside, pick a new owner if (changeowner && _ownership) { if (!playersStore.empty()) { uint64 newowner = 0; for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr) { newowner = itr->second.player; if (!itr->second.plrPtr->GetSession()->GetSecurity()) break; } SetOwner(newowner); } else SetOwner(0); } } }
JSBool XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface, JSObject *parent, jsval *vp) { if(IsConstant()) { const nsXPTConstant* constant; if(NS_FAILED(iface->GetInterfaceInfo()->GetConstant(mIndex, &constant))) return JS_FALSE; const nsXPTCMiniVariant& mv = *constant->GetValue(); // XXX Big Hack! nsXPTCVariant v; v.flags = 0; v.type = constant->GetType(); memcpy(&v.val, &mv.val, sizeof(mv.val)); jsval resultVal; if(!XPCConvert::NativeData2JS(ccx, &resultVal, &v.val, v.type, nsnull, nsnull)) return JS_FALSE; *vp = resultVal; return JS_TRUE; } // else... // This is a method or attribute - we'll be needing a function object intN argc; JSNative callback; if(IsMethod()) { const nsXPTMethodInfo* info; if(NS_FAILED(iface->GetInterfaceInfo()->GetMethodInfo(mIndex, &info))) return JS_FALSE; // Note: ASSUMES that retval is last arg. argc = (intN) info->GetParamCount(); if(argc && info->GetParam((uint8)(argc-1)).IsRetval()) argc-- ; callback = XPC_WN_CallMethod; } else { argc = 0; callback = XPC_WN_GetterSetter; } JSFunction *fun = JS_NewFunctionById(ccx, callback, argc, 0, parent, GetName()); if(!fun) return JS_FALSE; JSObject* funobj = JS_GetFunctionObject(fun); if(!funobj) return JS_FALSE; if(!JS_SetReservedSlot(ccx, funobj, 0, PRIVATE_TO_JSVAL(iface))|| !JS_SetReservedSlot(ccx, funobj, 1, PRIVATE_TO_JSVAL(this))) return JS_FALSE; *vp = OBJECT_TO_JSVAL(funobj); return JS_TRUE; }
void Channel::Join(ObjectGuid p, const char *pass) { WorldPacket data; if (IsOn(p)) { if(!IsConstant()) // non send error message for built-in channels { MakePlayerAlreadyMember(&data, p); SendToOne(&data, p); } return; } if (IsBanned(p)) { MakeBanned(&data); SendToOne(&data, p); return; } if(m_password.length() > 0 && strcmp(pass, m_password.c_str())) { MakeWrongPassword(&data); SendToOne(&data, p); return; } Player *plr = sObjectMgr.GetPlayer(p); if(plr) { if(HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() <= SEC_CURATOR ) { MakeNotInLfg(&data); SendToOne(&data, p); return; } if(plr->GetGuildId() && (GetFlags() == 0x38)) return; plr->JoinedChannel(this); } if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL) )) { MakeJoined(&data, p); SendToAll(&data); } data.clear(); PlayerInfo& pinfo = m_players[p]; pinfo.player = p; pinfo.flags = 0; MakeYouJoined(&data); SendToOne(&data, p); JoinNotify(p); // if no owner first logged will become if(!IsConstant() && !m_ownerGuid) { SetOwner(p, (m_players.size() > 1 ? true : false)); m_players[p].SetModerator(true); } }
void Channel::JoinChannel(Player* player, std::string const& pass) { ObjectGuid const& guid = player->GetGUID(); if (IsOn(guid)) { // Do not send error message for built-in channels if (!IsConstant()) { WorldPackets::Channel::ChannelNotify notify; MakePlayerAlreadyMember(notify, guid); player->SendDirectMessage(notify.Write()); } return; } if (IsBanned(guid)) { WorldPackets::Channel::ChannelNotify notify; MakeBanned(notify); player->SendDirectMessage(notify.Write()); return; } if (!_password.empty() && pass != _password) { WorldPackets::Channel::ChannelNotify notify; MakeWrongPassword(notify); player->SendDirectMessage(notify.Write()); return; } if (HasFlag(CHANNEL_FLAG_LFG) && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && //FIXME: Move to RBAC player->GetGroup()) { WorldPackets::Channel::ChannelNotify notify; MakeNotInLfg(notify); player->SendDirectMessage(notify.Write()); return; } player->JoinedChannel(this); if (_announce && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { WorldPackets::Channel::ChannelNotify notify; MakeJoined(notify, guid); SendToAll(notify.Write()); } PlayerInfo playerInfo; playerInfo.PlayerGuid = guid; _playersStore[guid] = playerInfo; /* WorldPackets::Channel::ChannelNotify notify; MakeYouJoined(notify); player->SendDirectMessage(notify.Write()); */ WorldPackets::Channel::ChannelNotifyJoined notify; //notify.ChannelWelcomeMsg = ""; notify.ChatChannelID = _channelId; //notify.InstanceID = 0; notify._ChannelFlags = _flags; notify._Channel = _name; player->SendDirectMessage(notify.Write()); JoinNotify(player); // Custom channel handling if (!IsConstant()) { // Update last_used timestamp in db if (!_playersStore.empty()) UpdateChannelUseageInDB(); // If the channel has no owner yet and ownership is allowed, set the new owner. if (_ownerGUID.IsEmpty() && _ownership) { SetOwner(guid, _playersStore.size() > 1); _playersStore[guid].SetModerator(true); } } }
void CTWScriptEdit::FormatTextRange(int nStart, int nEnd) { if (nStart >= nEnd) return; m_bInForcedChange = TRUE; CHARRANGE crOldSel; GetSel(crOldSel); LockWindowUpdate(); HideSelection(TRUE, FALSE); WCHAR *pBuffer = NULL; try { SetSel(nStart, nEnd); //pBuffer = new WCHAR[nEnd - nStart + 1]; CHAR* pBuffer2 = new CHAR[nEnd - nStart + 1]; long nLen = GetSelText(pBuffer2); pBuffer = GetUnicode(pBuffer2); ASSERT(nLen <= nEnd - nStart); pBuffer[nLen] = 0; WCHAR *pStart, *pPtr; pStart = pPtr = pBuffer; WCHAR* pSymbolStart = NULL; SymbolColor ic; while (*pPtr != 0) { WCHAR ch = *pPtr; if (ch == m_chComment && (m_chComment2 == 0 || pPtr[1] == m_chComment2)) { pSymbolStart = pPtr; do { ch = *(++pPtr); } while (ch != 0 && ch != '\r'); ic = m_icComment; } else if (IsStringQuote(ch)) { // Process strings pSymbolStart = pPtr; WCHAR ch1 = ch; do { ch = *(++pPtr); } while (ch != 0 && ch != ch1 && ch != '\r'); if (ch == ch1) pPtr++; ic = m_icString; } else if (_istdigit(ch)) { // Process numbers pSymbolStart = pPtr; wcstod(pSymbolStart, &pPtr); ic = m_icNumber; } else if (_istalpha(ch) || ch == '_') { // Process keywords pSymbolStart = pPtr; do { ch = *(++pPtr); } while (_istalnum(ch) || ch == '_'); *pPtr = 0; int nPos = IsKeyword(pSymbolStart); if (nPos >= 0) { ChangeCase(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, m_strKeywords.Mid(nPos+1, pPtr - pSymbolStart)); if (wcsicmp(m_strComment, pSymbolStart) == 0) { *pPtr = ch; *pSymbolStart = m_chComment; if (pSymbolStart[1] != 0 && m_chComment2 != 0) pSymbolStart[1] = m_chComment2; pPtr = pSymbolStart; pSymbolStart = NULL; continue; } ic = m_icKeyword; } else { nPos = IsConstant(pSymbolStart); if (nPos >= 0) { ChangeCase(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, m_strConstants.Mid(nPos+1, pPtr - pSymbolStart)); ic = m_icConstant; } else { pSymbolStart = NULL; } } *pPtr = ch; } else { pPtr++; } if (pSymbolStart != NULL) { ASSERT(pSymbolStart < pPtr); SetFormatRange(nStart + pStart - pBuffer, nStart + pSymbolStart - pBuffer, FALSE, RGB(0,0,0)); SetFormatRange(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, ic.bBold, ic.clrColor); pStart = pPtr; pSymbolStart = 0; } else if (*pPtr == 0) SetFormatRange(nStart + pStart - pBuffer, nStart + pPtr - pBuffer, FALSE, RGB(0,0,0)); } } catch(...){} //delete [] pBuffer; SetSel(crOldSel); HideSelection(FALSE, FALSE); UnlockWindowUpdate(); m_bInForcedChange = FALSE; }
void Channel::JoinChannel(Player* player, std::string const& pass) { uint64 guid = player->GetGUID(); if (IsOn(guid)) { // Do not send error message for built-in channels if (!IsConstant()) { WorldPacket data; MakePlayerAlreadyMember(&data, guid); SendToOne(&data, guid); } return; } if (IsBanned(guid)) { WorldPacket data; MakeBanned(&data); SendToOne(&data, guid); return; } if (!_password.empty() && pass != _password) { WorldPacket data; MakeWrongPassword(&data); SendToOne(&data, guid); return; } if (HasFlag(CHANNEL_FLAG_LFG) && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && //FIXME: Move to RBAC player->GetGroup()) { WorldPacket data; MakeNotInLfg(&data); SendToOne(&data, guid); return; } player->JoinedChannel(this); if (_announce && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { WorldPacket data; MakeJoined(&data, guid); SendToAll(&data); } PlayerInfo pinfo; pinfo.player = guid; pinfo.flags = MEMBER_FLAG_NONE; playersStore[guid] = pinfo; WorldPacket data; MakeYouJoined(&data); SendToOne(&data, guid); JoinNotify(guid); // Custom channel handling if (!IsConstant()) { // Update last_used timestamp in db if (!playersStore.empty()) UpdateChannelUseageInDB(); // If the channel has no owner yet and ownership is allowed, set the new owner. if (!_ownerGUID && _ownership) { SetOwner(guid, playersStore.size() > 1); playersStore[guid].SetModerator(true); } } }
bool UNiagaraNodeInput::IsExposedConstant()const { return bExposeWhenConstant && IsConstant(); }
void Channel::Join(Player* player, const char* password) { ObjectGuid guid = player->GetObjectGuid(); WorldPacket data; if (IsOn(guid)) { if (!IsConstant()) // non send error message for built-in channels { MakePlayerAlreadyMember(&data, guid); SendToOne(&data, guid); } return; } if (IsBanned(guid)) { MakeBanned(&data); SendToOne(&data, guid); return; } if (m_password.length() > 0 && strcmp(password, m_password.c_str())) { MakeWrongPassword(&data); SendToOne(&data, guid); return; } if (HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL) && player->GetSession()->GetSecurity() == SEC_PLAYER && (player->GetGroup() || player->m_lookingForGroup.Empty())) { MakeNotInLfg(&data); SendToOne(&data, guid); return; } if (player->GetGuildId() && (GetFlags() == 0x38)) return; // join channel player->JoinedChannel(this); if (m_announce && (player->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL))) { MakeJoined(&data, guid); SendToAll(&data); } data.clear(); PlayerInfo& pinfo = m_players[guid]; pinfo.player = guid; pinfo.flags = MEMBER_FLAG_NONE; MakeYouJoined(&data); SendToOne(&data, guid); JoinNotify(guid); // if no owner first logged will become if (!IsConstant() && !m_ownerGuid) { SetOwner(guid, (m_players.size() > 1 ? true : false)); m_players[guid].SetModerator(true); } }
/** Saves the first derivative of the sequence starting at Iter in the back *this * \param Iter: Iterator to function to differentiate. * \param Var: Variable to differentiate with respect to. * \param Trigonemetry: Differentiate trigonometric functions as radians og degrees. * \param Level: Indicates the number os times the function has been called recursive. To prevent infinite loops. * \throw EFuncError: Thrown if differentiation fails. */ void TFuncData::AddDif(TConstIterator Iter, const TElem &Var, TTrigonometry Trigonometry, unsigned Level) { if(*Iter == Var) Data.push_back(TElem(CodeNumber, 1)); else if(Iter->Ident == CodeRand) throw EFuncError(ecNotDifAble, L"rand"); else if(IsConstant(*Iter)) Data.push_back(TElem(CodeNumber, 0.0)); else { if(!ContainsElem(Iter, Var)) { Data.push_back(TElem(CodeNumber, 0.0)); return; } switch(Iter->Ident) { case CodeIf: case CodeIfSeq: { //f(x)=if(a1,b1,a2,b2, ... , an,bn [,c]) //f'(x)=if(a1,b1',a2,b2', ... , an, bn' [,c']) Data.push_back(*Iter); //CodeIf with same number of arguments unsigned Arguments = FunctionArguments(*Iter); ++Iter; for(unsigned I = 0; I < Arguments-1; I++) { TConstIterator End = FindEnd(Iter); if(I % 2) AddDif(Iter, Var, Trigonometry, Level); else Data.insert(Data.end(), Iter, End); Iter = End; } AddDif(Iter, Var, Trigonometry, Level); break; } case CodeMin: case CodeMax: { //f(x)=min(a1,a2,a3, ... , an) f'(x)=if(a1<a2 and a1<a3 ...,a1', a2<a1 and a2<a3 ...,a2', unsigned Arguments = Iter->Arguments; Data.push_back(TElem(CodeIf, 2*Arguments-1, 0)); TConstIterator Param = Iter + 1; for(unsigned I = 0; I < Arguments-1; I++) { TConstIterator End = FindEnd(Param); for(unsigned J = 0; J < Arguments-2; J++) Data.push_back(CodeAnd); TConstIterator Param2 = Iter+1; for(unsigned J = 0; J < Arguments; J++) { if(J != I) { Data.push_back(TElem(Iter->Ident == CodeMin ? cmLess : cmGreater)); Data.insert(Data.end(), Param, End); Data.insert(Data.end(), Param2, FindEnd(Param2)); } Param2 = FindEnd(Param2); } AddDif(Param, Var, Trigonometry, Level); Param = End; } AddDif(Param, Var, Trigonometry, Level); break; } case CodeCustom: { if(Level > MaxDifLevel) throw EFuncError(ecRecursiveDif); boost::shared_ptr<TBaseCustomFunc> Func = boost::any_cast<boost::shared_ptr<TBaseCustomFunc> >(Iter->Value); if(Func) AddDif(Func->GetFuncData()->Data.begin(), Var, Trigonometry, Level + 1); else throw EFuncError(ecSymbolNotFound, Iter->Text); break; } case CodeDNorm: { std::vector<std::wstring> ArgNames; ArgNames.push_back(L"x"); ArgNames.push_back(L"x2"); ArgNames.push_back(L"x3"); TFuncData Temp(FunctionDefinition(CodeDNorm), ArgNames); TFuncData Temp2; std::vector<std::vector<TElem> > Args(3); CopyReplaceArgs(Args.front(), Iter + 1, std::vector<std::vector<TElem> >()); if(Iter->Arguments > 2) { TConstIterator Iter2 = FindEnd(Iter + 1); CopyReplaceArgs(Args[1], Iter2, std::vector<std::vector<TElem> >()); CopyReplaceArgs(Args[2], FindEnd(Iter2), std::vector<std::vector<TElem> >()); } else { Args[1].push_back(TElem(CodeNumber, 0.0)); Args[2].push_back(TElem(CodeNumber, 1.0)); } CopyReplaceArgs(Temp2.Data, Temp.Data.begin(), Args); AddDif(Temp2.Data.begin(), Var, Trigonometry, Level + 1); break; } case CodeMod: if(ContainsElem(FindEnd(Iter+1), Var)) throw EFuncError(ecNotDifAble, FunctionName(CodeMod)); AddDif(Iter+1, Var, Trigonometry, Level + 1); break; default: { if(Trigonometry == Degree) { //Sin, Cos, Tan, Csc, Sec, Cot must be multiplied with PI/180 when differentiated using degrees if((Iter->Ident >= CodeSin && Iter->Ident <= CodeTan) || (Iter->Ident >= CodeCsc && Iter->Ident <= CodeCot)) { Data.push_back(CodeMul); Data.push_back(CodeDiv); Data.push_back(CodePi); Data.push_back(180); } //ASin, ACos, ATan, ACsc, ASec, ACot must be multiplied with 180/PI when differentiated using degrees else if((Iter->Ident >= CodeASin && Iter->Ident <= CodeATan) || (Iter->Ident >= CodeACsc && Iter->Ident <= CodeACot)) { Data.push_back(CodeMul); Data.push_back(CodeDiv); Data.push_back(180); Data.push_back(CodePi); } } const TFuncData &DifData = GetDif(Iter->Ident); if(Iter->Ident == CodeIntegrate) { //f(x)=integrate(g(x,s), s, a(x), b(x)) //f'(x)=g(x,b(x))*db(x)/dx - g(x,a(x))*da(x)/dx + integrate(dg(x,s)/dx, s, a(x), b(x)) TConstIterator From = FindEnd(Iter + 1); TConstIterator To = FindEnd(From); TConstIterator End = FindEnd(To); TElem Elem = *Iter; Elem.Ident = CodeConst; if(!Iter->Text.empty()) Data.push_back(CodeAdd); Data.push_back(CodeSub); Data.push_back(CodeMul); CopyReplace(Data, Iter + 1, Elem, To, End); AddDif(To, Var, Trigonometry, Level); Data.push_back(CodeMul); CopyReplace(Data, Iter + 1, Elem, From, To); AddDif(From, Var, Trigonometry, Level); if(!Iter->Text.empty()) { //Backward compatibility: //f(x)=integrate(g(x), a(x), b(x)) //f'(x)=g(x,b(x))*db(x)/dx - g(x,a(x))*da(x)/dx Data.push_back(*Iter); AddDif(Iter + 1, Var, Trigonometry, Level); Data.insert(Data.end(), From, End); } } else if(DifData.IsEmpty()) throw EFuncError(ecNotDifAble, FunctionName(*Iter)); TConstIterator End = DifData.Data.end(); TConstIterator FirstPar = Iter; //Start of first parenthesis ++FirstPar; TConstIterator SecondPar = FindEnd(FirstPar); //Start of second parenthesis TConstIterator ThirdPar; if(FunctionArguments(*Iter) >= 2) ThirdPar = FindEnd(SecondPar); //Start of third parenthesis TConstIterator Begin = DifData.Data.begin(); if(Iter->Ident == CodeSum) //Use the original CodeSum instead of the one from DifData { Data.push_back(*Iter); Begin++; } for(TConstIterator Elem = Begin; Elem != End; ++Elem) if(Elem->Ident == CodeArgument) Data.insert(Data.end(), FirstPar, SecondPar); else if(*Elem == TElem(CodeCustom, L"dx")) AddDif(FirstPar, Var, Trigonometry, Level); else if(*Elem == TElem(CodeCustom, L"x2")) Data.insert(Data.end(), SecondPar, ThirdPar); else if(*Elem == TElem(CodeCustom, L"dx2")) AddDif(SecondPar, Var, Trigonometry, Level); else if(*Elem == TElem(CodeCustom, L"x3")) Data.insert(Data.end(), ThirdPar, FindEnd(ThirdPar)); else if(*Elem == TElem(CodeCustom, L"dx3")) AddDif(ThirdPar, Var, Trigonometry, Level); else Data.push_back(*Elem); } } } }
void Channel::LeaveChannel(Player* player, bool send) { ObjectGuid const& guid = player->GetGUID(); if (!IsOn(guid)) { if (send) { NotMemberAppend appender; ChannelNameBuilder<NotMemberAppend> builder(this, appender); SendToOne(builder, guid); } return; } player->LeftChannel(this); if (send) { /* YouLeftAppend appender; ChannelNameBuilder<YouLeftAppend> builder(this, appender); SendToOne(builder, guid); */ auto builder = [&](LocaleConstant locale) { LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale); WorldPackets::Channel::ChannelNotifyLeft* notify = new WorldPackets::Channel::ChannelNotifyLeft(); notify->Channel = GetName(localeIdx); notify->ChatChannelID = 0; //notify->Suspended = false; return notify; }; SendToOne(builder, guid); } PlayerInfo& info = _playersStore.at(guid); bool changeowner = info.IsOwner(); _playersStore.erase(guid); if (_announceEnabled && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { LeftAppend appender(guid); ChannelNameBuilder<LeftAppend> builder(this, appender); SendToAll(builder); } LeaveNotify(player); if (!IsConstant()) { // Update last_used timestamp in db UpdateChannelUseageInDB(); // If the channel owner left and there are still playersStore inside, pick a new owner // do not pick invisible gm owner unless there are only invisible gms in that channel (rare) if (changeowner && _ownershipEnabled && !_playersStore.empty()) { PlayerContainer::iterator itr; for (itr = _playersStore.begin(); itr != _playersStore.end(); ++itr) { if (!itr->second.IsInvisible()) break; } if (itr == _playersStore.end()) itr = _playersStore.begin(); ObjectGuid const& newowner = itr->first; itr->second.SetModerator(true); SetOwner(newowner); // if the new owner is invisible gm, set flag to automatically choose a new owner if (itr->second.IsInvisible()) _isOwnerInvisible = true; } } }
void Channel::JoinChannel(Player* player, std::string const& pass) { ObjectGuid const& guid = player->GetGUID(); if (IsOn(guid)) { // Do not send error message for built-in channels if (!IsConstant()) { PlayerAlreadyMemberAppend appender(guid); ChannelNameBuilder<PlayerAlreadyMemberAppend> builder(this, appender); SendToOne(builder, guid); } return; } if (IsBanned(guid)) { BannedAppend appender; ChannelNameBuilder<BannedAppend> builder(this, appender); SendToOne(builder, guid); return; } if (!_channelPassword.empty() && pass != _channelPassword) { WrongPasswordAppend appender; ChannelNameBuilder<WrongPasswordAppend> builder(this, appender); SendToOne(builder, guid); return; } if (HasFlag(CHANNEL_FLAG_LFG) && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && //FIXME: Move to RBAC player->GetGroup()) { NotInLFGAppend appender; ChannelNameBuilder<NotInLFGAppend> builder(this, appender); SendToOne(builder, guid); return; } player->JoinedChannel(this); if (_announceEnabled && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL)) { JoinedAppend appender(guid); ChannelNameBuilder<JoinedAppend> builder(this, appender); SendToAll(builder); } bool newChannel = _playersStore.empty(); PlayerInfo& playerInfo = _playersStore[guid]; playerInfo.SetInvisible(!player->isGMVisible()); /* YouJoinedAppend appender; ChannelNameBuilder<YouJoinedAppend> builder(this, appender); SendToOne(builder, guid); */ auto builder = [&](LocaleConstant /*locale*/) { WorldPackets::Channel::ChannelNotifyJoined* notify = new WorldPackets::Channel::ChannelNotifyJoined(); //notify->ChannelWelcomeMsg = ""; notify->ChatChannelID = _channelId; //notify->InstanceID = 0; notify->_ChannelFlags = _channelFlags; notify->_Channel = _channelName; return notify; }; SendToOne(builder, guid); JoinNotify(player); // Custom channel handling if (!IsConstant()) { // Update last_used timestamp in db if (!_playersStore.empty()) UpdateChannelUseageInDB(); // If the channel has no owner yet and ownership is allowed, set the new owner. // or if the owner was a GM with .gm visible off // don't do this if the new player is, too, an invis GM, unless the channel was empty if (_ownershipEnabled && (newChannel || !playerInfo.IsInvisible()) && (_ownerGuid.IsEmpty() || _isOwnerInvisible)) { _isOwnerInvisible = playerInfo.IsInvisible(); SetOwner(guid, !newChannel && !_isOwnerInvisible); playerInfo.SetModerator(true); } } }
void Channel::Join(uint64 p, const char *pass) { WorldPacket data; if(IsOn(p)) { if(!IsConstant()) // non send error message for built-in channels { MakePlayerAlreadyMember(&data, p); SendToOne(&data, p); } return; } if(IsBanned(p)) { MakeBanned(&data); SendToOne(&data, p); return; } if(m_password.length() > 0 && strcmp(pass, m_password.c_str())) { MakeWrongPassword(&data); SendToOne(&data, p); return; } Player *plr = objmgr.GetPlayer(p); if(plr) { if(HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER && (plr->GetGroup() || plr->m_lookingForGroup.Empty()) ) { MakeNotInLfg(&data); SendToOne(&data, p); return; } if(plr->GetGuildId() && (GetFlags() == 0x38)) return; plr->JoinedChannel(this); } if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) )) { MakeJoined(&data, p); SendToAll(&data); } data.clear(); PlayerInfo pinfo; pinfo.player = p; pinfo.flags = MEMBER_FLAG_NONE; players[p] = pinfo; MakeYouJoined(&data); SendToOne(&data, p); JoinNotify(p); // if no owner first logged will become if(!IsConstant() && !m_ownerGUID) { SetOwner(p, (players.size() > 1 ? true : false)); players[p].SetModerator(true); } /* else if(!IsConstant() && m_ownerGUID && plr && m_ownerGUID == plr->GetGUID() )) { SetOwner(p, (players.size() > 1 ? true : false)); players[p].SetModerator(true); }*/ }
void Channel::Join(uint64 p, const char *pass) { WorldPacket data; if (IsOn(p)) { if (!IsConstant()) // non send error message for built-in channels { MakePlayerAlreadyMember(&data, p); SendToOne(&data, p); } return; } Player *plr = sObjectMgr.GetPlayer(p); if ((!plr || !plr->isGameMaster()) && !IsConstant() && m_name != "world" && m_name != "engworld" && m_name != "handel") { uint32 limitCount = sWorld.getConfig(CONFIG_PRIVATE_CHANNEL_LIMIT); if (limitCount && players.size() > limitCount) { MakeInvalidName(&data); SendToOne(&data, p); return; } } if (!m_ownerGUID && (!plr || !plr->CanSpeak())) // muted players can't create new channels { MakeBanned(&data);//no idea what to send SendToOne(&data, p); return; } if (IsBanned(p) && (!plr || !plr->isGameMaster())) { MakeBanned(&data); SendToOne(&data, p); return; } if (m_password.length() > 0 && strcmp(pass, m_password.c_str()) && (!plr || !plr->isGameMaster())) { MakeWrongPassword(&data); SendToOne(&data, p); return; } if (plr) { if (IsLFG() && sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && !plr->GetSession()->HasPermissions(PERM_GMT) && plr->m_lookingForGroup.Empty()) { MakeNotInLfg(&data); SendToOne(&data, p); return; } if (plr->GetGuildId() && (GetFlags() == 0x38)) return; plr->JoinedChannel(this); } if (m_announce && (!plr || !plr->GetSession()->HasPermissions(PERM_GMT) || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { //MakeJoined(&data, p); //SendToAll(&data); } data.clear(); PlayerInfo pinfo; pinfo.player = p; pinfo.flags = 0; players[p] = pinfo; MakeYouJoined(&data); SendToOne(&data, p); JoinNotify(p); // if no owner first logged will become if (!IsConstant() && !m_ownerGUID) { SetOwner(p, (players.size() > 1 ? true : false)); players[p].SetModerator(true); } }
JSBool XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface) { if(IsConstant()) { const nsXPTConstant* constant; if(NS_FAILED(iface->GetInterfaceInfo()->GetConstant(mIndex, &constant))) return JS_FALSE; const nsXPTCMiniVariant& mv = *constant->GetValue(); // XXX Big Hack! nsXPTCVariant v; v.flags = 0; v.type = constant->GetType(); memcpy(&v.val, &mv.val, sizeof(mv.val)); jsval resultVal; if(!XPCConvert::NativeData2JS(ccx, &resultVal, &v.val, v.type, nsnull, nsnull, nsnull)) return JS_FALSE; { // scoped lock XPCAutoLock lock(ccx.GetRuntime()->GetMapLock()); mVal = resultVal; mFlags |= RESOLVED; } return JS_TRUE; } // else... // This is a method or attribute - we'll be needing a function object intN argc; intN flags; JSNative callback; if(IsMethod()) { const nsXPTMethodInfo* info; if(NS_FAILED(iface->GetInterfaceInfo()->GetMethodInfo(mIndex, &info))) return JS_FALSE; // Note: ASSUMES that retval is last arg. argc = (intN) info->GetParamCount(); if(argc && info->GetParam((uint8)(argc-1)).IsRetval()) argc-- ; flags = 0; callback = XPC_WN_CallMethod; } else { if(IsWritableAttribute()) flags = JSFUN_GETTER | JSFUN_SETTER; else flags = JSFUN_GETTER; argc = 0; callback = XPC_WN_GetterSetter; } // We need to use the safe context for this thread because we don't want // to parent the new (and cached forever!) function object to the current // JSContext's global object. That would be bad! JSContext* cx = ccx.GetSafeJSContext(); if(!cx) return JS_FALSE; const char *memberName = iface->GetMemberName(ccx, this); jsrefcount suspendDepth = 0; if(cx != ccx) { // Switching contexts, suspend the old and enter the new request. suspendDepth = JS_SuspendRequest(ccx); JS_BeginRequest(cx); } JSFunction *fun = JS_NewFunction(cx, callback, argc, flags, nsnull, memberName); if(suspendDepth) { JS_EndRequest(cx); JS_ResumeRequest(ccx, suspendDepth); } if(!fun) return JS_FALSE; JSObject* funobj = JS_GetFunctionObject(fun); if(!funobj) return JS_FALSE; AUTO_MARK_JSVAL(ccx, OBJECT_TO_JSVAL(funobj)); STOBJ_CLEAR_PARENT(funobj); STOBJ_CLEAR_PROTO(funobj); if(!JS_SetReservedSlot(ccx, funobj, 0, PRIVATE_TO_JSVAL(iface))|| !JS_SetReservedSlot(ccx, funobj, 1, PRIVATE_TO_JSVAL(this))) return JS_FALSE; { // scoped lock XPCAutoLock lock(ccx.GetRuntime()->GetMapLock()); mVal = OBJECT_TO_JSVAL(funobj); mFlags |= RESOLVED; } return JS_TRUE; }
/** Optimizes the data elements starting from Iter, which points into list. * \param List: Elements to optimize. * \param Iter: Element to start optimization at. If Iter is erased, Iter is updated to point to the element that is replacing it. * \return An iterator to the element following Iter, jumping over parameters. */ std::list<TElem>::iterator SimplifyData(std::list<TElem> &List, std::list<TElem>::iterator &Iter) { std::list<TElem>::iterator Begin1 = Iter; ++Begin1; if(IsConstant(*Iter)) return Begin1; std::list<TElem>::iterator End; std::list<TElem>::iterator Begin2 = SimplifyData(List, Begin1); if(IsFunction1P(*Iter)) End = Begin2; else if(IsFunction2P(*Iter)) End = SimplifyData(List, Begin2); else if(IsFunction3P(*Iter)) { std::list<TElem>::iterator Begin3 = SimplifyData(List, Begin2); End = SimplifyData(List, Begin3); } else if(IsFunctionVariableP(*Iter)) { End = Begin1; for(unsigned I = 0; I < Iter->Arguments; I++) End = SimplifyData(List, End); //Simplify each argument return End; } else throw EFuncError(ecInternalError); for(unsigned I = 0; I < TableSize; I++) { const TSimplify &Entry = SimplifyTable(I); if(*Iter == Entry.Function && (Entry.Par1 == CodeIgnore || *Begin1 == Entry.Par1) && (Entry.Par2 == CodeIgnore || *Begin2 == Entry.Par2 || (Entry.Par2 == CodePar1 && IsEqual(Begin1, Begin2)))) { bool RemovePar1 = true; bool RemovePar2 = true; std::list<TElem>::iterator Pos = Begin1; for(int N = 0; N < 4; N++) switch(Entry.Result[N].Ident) { case CodePar1: RemovePar1 = false; Pos = Begin2; break; case CodePar2: RemovePar2 = false; break; case CodePar1Par: List.erase(Begin1++); RemovePar1 = false; Pos = Begin2; break; case CodePar2Par: List.erase(Begin2++); RemovePar2 = false; break; case CodeNull: break; default: List.insert(Pos, Entry.Result[N]); } if(RemovePar1) List.erase(Begin1, Begin2); if(RemovePar2) List.erase(Begin2, End); List.erase(Iter++); return End; } } if(Iter->Ident == CodeSub && Begin1->Ident == CodeNumber && Begin2->Ident == CodeNumber) { *Iter = TElem(CodeNumber, boost::any_cast<long double>(Begin1->Value) - boost::any_cast<long double>(Begin2->Value)); List.erase(Begin1, End); } else if(Iter->Ident == CodeAdd && Begin1->Ident == CodeNumber && Begin2->Ident == CodeNumber) { *Iter = TElem(CodeNumber, boost::any_cast<long double>(Begin1->Value) + boost::any_cast<long double>(Begin2->Value)); List.erase(Begin1, End); } else if(Iter->Ident == CodeMul) { //5*2 = 10 if(Begin1->Ident == CodeNumber && Begin2->Ident == CodeNumber) { Begin1->Value = boost::any_cast<long double>(Begin1->Value) * boost::any_cast<long double>(Begin2->Value); List.erase(Iter); List.erase(Begin2); Iter = Begin1; } else { std::list<TElem>::iterator Par1 = Begin1; std::list<TElem>::iterator Par2 = Begin2; ++Par1; ++Par2; // (5*A)*(2*B) = 10*(A*B) if(Begin1->Ident == CodeMul && Par1->Ident == CodeNumber && Begin2->Ident == CodeMul && Par2->Ident == CodeNumber) { List.insert(Begin1, TElem(CodeNumber, boost::any_cast<long double>(Par1->Value) * boost::any_cast<long double>(Par2->Value))); List.erase(Par1); List.erase(Begin2); List.erase(Par2); } // 5*(2*A) = 10*A else if(Begin1->Ident == CodeNumber && Begin2->Ident == CodeMul && Par2->Ident == CodeNumber) { Begin1->Value = boost::any_cast<long double>(Begin1->Value) * boost::any_cast<long double>(Par2->Value); List.erase(Begin2); List.erase(Par2); } //(5*A)*2 = 10*A else if(Begin1->Ident == CodeMul && Par1->Ident == CodeNumber && Begin2->Ident == CodeNumber) { Par1->Value = boost::any_cast<long double>(Par1->Value) * boost::any_cast<long double>(Begin2->Value); List.erase(Begin1); List.erase(Begin2); } //A*(5*B) = 5*(A*B) else if(Begin2->Ident == CodeMul && Par2->Ident == CodeNumber) { List.insert(Begin1, *Par2); List.insert(Begin1, CodeMul); List.erase(Par2); List.erase(Begin2); } //A*5 = 5*A else if(Begin2->Ident == CodeNumber) { List.insert(Begin1, *Begin2); List.erase(Begin2); } //(5*A)*B = 5*(A*B) else if(Begin1->Ident == CodeMul && Par1->Ident == CodeNumber) std::swap(*Begin1, *Par1); } } return End; }
// done 0x03 void Channel::MakeYouLeft(WorldPacket *data) { MakeNotifyPacket(data, CHAT_YOU_LEFT_NOTICE); *data << uint32(GetChannelId()); *data << uint8(IsConstant()); }
void Channel::JoinChannel(Player* player, std::string const& pass) { uint64 guid = player->GetGUID(); if (IsOn(guid)) { // Do not send error message for built-in channels if (!IsConstant()) { WorldPacket data; MakePlayerAlreadyMember(&data, guid); SendToOne(&data, guid); } return; } if (IsBanned(guid)) { WorldPacket data; MakeBanned(&data); SendToOne(&data, guid); return; } if (!_password.empty() && pass != _password) { WorldPacket data; MakeWrongPassword(&data); SendToOne(&data, guid); return; } if (HasFlag(CHANNEL_FLAG_LFG) && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && player->GetGroup()) { WorldPacket data; MakeNotInLfg(&data); SendToOne(&data, guid); return; } player->JoinedChannel(this); if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { WorldPacket data; MakeJoined(&data, guid); SendToAll(&data); } PlayerInfo pinfo; pinfo.player = guid; pinfo.flags = MEMBER_FLAG_NONE; pinfo.lastSpeakTime = 0; pinfo.plrPtr = player; playersStore[guid] = pinfo; if (_channelRights.joinMessage.length()) ChatHandler(player->GetSession()).PSendSysMessage("%s", _channelRights.joinMessage.c_str()); WorldPacket data; MakeYouJoined(&data); SendToOne(&data, guid); JoinNotify(player); // Custom channel handling if (!IsConstant()) { // Update last_used timestamp in db if (!playersStore.empty()) UpdateChannelUseageInDB(); if (_channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end()) { playersStore[guid].SetModerator(true); FlagsNotify(player); } // If the channel has no owner yet and ownership is allowed, set the new owner. if (!_ownerGUID && _ownership) SetOwner(guid, false); if (_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK) playersStore[guid].SetMuted(true); } }
void Channel::Join(uint64 p, const char *pass) { WorldPacket data; if (IsOn(p)) { if (!IsConstant()) // non send error message for built-in channels { MakePlayerAlreadyMember(&data, p); SendToOne(&data, p); } return; } if (IsBanned(p)) { MakeBanned(&data); SendToOne(&data, p); return; } if (m_password.length() > 0 && strcmp(pass, m_password.c_str())) { MakeWrongPassword(&data); SendToOne(&data, p); return; } Player *plr = sObjectMgr->GetPlayer(p); if (plr) { if (HasFlag(CHANNEL_FLAG_LFG) && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER && plr->GetGroup()) { MakeNotInLfg(&data); SendToOne(&data, p); return; } plr->JoinedChannel(this); } if (m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { MakeJoined(&data, p); SendToAll(&data); } data.clear(); PlayerInfo pinfo; pinfo.player = p; pinfo.flags = MEMBER_FLAG_NONE; players[p] = pinfo; MakeYouJoined(&data); SendToOne(&data, p); JoinNotify(p); // Custom channel handling if (!IsConstant()) { // Update last_used timestamp in db if(!players.empty()) UpdateChannelUseageInDB(); // If the channel has no owner yet and ownership is allowed, set the new owner. if ( !m_ownerGUID && m_ownership) { SetOwner(p, (players.size() > 1 ? true : false)); players[p].SetModerator(true); } } }
void Channel::Join(uint64 p, const char *pass) { WorldPacket data; if(IsOn(p)) { if(!IsConstant()) // non send error message for built-in channels { MakePlayerAlreadyMember(&data, p); SendToOne(&data, p); } return; } if(IsBanned(p)) { MakeBanned(&data); SendToOne(&data, p); return; } if(m_password.length() > 0 && strcmp(pass, m_password.c_str())) { MakeWrongPassword(&data); SendToOne(&data, p); return; } Player *plr = objmgr.GetPlayer(p); if(plr) { if(HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER && (plr->GetGroup() || plr->m_lookingForGroup.Empty()) ) { MakeNotInLfg(&data); SendToOne(&data, p); return; } if(plr->GetGuildId() && (GetFlags() == 0x38)) return; plr->JoinedChannel(this); } if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) )) { MakeJoined(&data, p); SendToAll(&data); } data.clear(); PlayerInfo pinfo; pinfo.player = p; pinfo.flags = 0; players[p] = pinfo; MakeYouJoined(&data); SendToOne(&data, p); sIRC.Handle_WoW_Channel(m_name, objmgr.GetPlayer(p), CHANNEL_JOIN); JoinNotify(p); }