inline bool Groups::IsCaptain(HexPoint point) const { return GetGroup(point).Captain() == point; }
void Client::AddEXP(uint32 in_add_exp, uint8 conlevel, bool resexp) { uint32 add_exp = in_add_exp; if(!resexp && (XPRate != 0)) add_exp = static_cast<uint32>(in_add_exp * (static_cast<float>(XPRate) / 100.0f)); if (m_epp.perAA<0 || m_epp.perAA>100) m_epp.perAA=0; // stop exploit with sanity check uint32 add_aaxp; if(resexp) { add_aaxp = 0; } else { //figure out how much of this goes to AAs add_aaxp = add_exp * m_epp.perAA / 100; //take that ammount away from regular exp add_exp -= add_aaxp; float totalmod = 1.0; float zemmod = 1.0; //get modifiers if(RuleR(Character, ExpMultiplier) >= 0){ totalmod *= RuleR(Character, ExpMultiplier); } if(zone->newzone_data.zone_exp_multiplier >= 0){ zemmod *= zone->newzone_data.zone_exp_multiplier; } if(RuleB(Character,UseRaceClassExpBonuses)) { if(GetBaseRace() == HALFLING){ totalmod *= 1.05; } if(GetClass() == ROGUE || GetClass() == WARRIOR){ totalmod *= 1.05; } } if(zone->IsHotzone()) { totalmod += RuleR(Zone, HotZoneBonus); } add_exp = uint32(float(add_exp) * totalmod * zemmod); if(RuleB(Character,UseXPConScaling)) { if (conlevel != 0xFF && !resexp) { switch (conlevel) { case CON_GREEN: add_exp = 0; add_aaxp = 0; return; case CON_LIGHTBLUE: add_exp = add_exp * RuleI(Character, LightBlueModifier)/100; add_aaxp = add_aaxp * RuleI(Character, LightBlueModifier)/100; break; case CON_BLUE: add_exp = add_exp * RuleI(Character, BlueModifier)/100; add_aaxp = add_aaxp * RuleI(Character, BlueModifier)/100; break; case CON_WHITE: add_exp = add_exp * RuleI(Character, WhiteModifier)/100; add_aaxp = add_aaxp * RuleI(Character, WhiteModifier)/100; break; case CON_YELLOW: add_exp = add_exp * RuleI(Character, YellowModifier)/100; add_aaxp = add_aaxp * RuleI(Character, YellowModifier)/100; break; case CON_RED: add_exp = add_exp * RuleI(Character, RedModifier)/100; add_aaxp = add_aaxp * RuleI(Character, RedModifier)/100; break; } } } if(IsLeadershipEXPOn() && ((conlevel == CON_BLUE) || (conlevel == CON_WHITE) || (conlevel == CON_YELLOW) || (conlevel == CON_RED))) { add_exp = static_cast<uint32>(static_cast<float>(add_exp) * 0.8f); if(GetGroup()) { if((m_pp.group_leadership_points < MaxBankedGroupLeadershipPoints(GetLevel())) && (RuleI(Character, KillsPerGroupLeadershipAA) > 0)) { AddLeadershipEXP(GROUP_EXP_PER_POINT / RuleI(Character, KillsPerGroupLeadershipAA), 0); Message_StringID(MT_Leadership, GAIN_GROUP_LEADERSHIP_EXP); } else Message_StringID(MT_Leadership, MAX_GROUP_LEADERSHIP_POINTS); } else { if((m_pp.raid_leadership_points < MaxBankedRaidLeadershipPoints(GetLevel())) && (RuleI(Character, KillsPerRaidLeadershipAA) > 0)) { AddLeadershipEXP(0, RAID_EXP_PER_POINT / RuleI(Character, KillsPerRaidLeadershipAA)); Message_StringID(MT_Leadership, GAIN_RAID_LEADERSHIP_EXP); } else Message_StringID(MT_Leadership, MAX_RAID_LEADERSHIP_POINTS); } } } //end !resexp float aatotalmod = 1.0; if(zone->newzone_data.zone_exp_multiplier >= 0){ aatotalmod *= zone->newzone_data.zone_exp_multiplier; } if(RuleB(Character,UseRaceClassExpBonuses)) { if(GetBaseRace() == HALFLING){ aatotalmod *= 1.05; } if(GetClass() == ROGUE || GetClass() == WARRIOR){ aatotalmod *= 1.05; } } if(RuleB(Zone, LevelBasedEXPMods)){ if(zone->level_exp_mod[GetLevel()].ExpMod){ add_exp *= zone->level_exp_mod[GetLevel()].ExpMod; add_aaxp *= zone->level_exp_mod[GetLevel()].AAExpMod; } } uint32 exp = GetEXP() + add_exp; uint32 aaexp = (uint32)(RuleR(Character, AAExpMultiplier) * add_aaxp * aatotalmod); uint32 had_aaexp = GetAAXP(); aaexp += had_aaexp; if(aaexp < had_aaexp) aaexp = had_aaexp; //watch for wrap SetEXP(exp, aaexp, resexp); }
void Player::Reputation_OnKilledUnit(Unit* pUnit, bool InnerLoop) { // add rep for on kill if(!pUnit->IsCreature() || pUnit->IsPet()) return; Group* m_Group = GetGroup(); // Why would this be accessed if the group didn't exist? if(!InnerLoop && m_Group != NULL) { /* loop the rep for group members */ m_Group->getLock().Acquire(); GroupMembersSet::iterator it; for(uint32 i = 0; i < m_Group->GetSubGroupCount(); i++) { for(it = m_Group->GetSubGroup(i)->GetGroupMembersBegin(); it != m_Group->GetSubGroup(i)->GetGroupMembersEnd(); ++it) { if((*it)->m_loggedInPlayer && (*it)->m_loggedInPlayer->isInRange(this, 100.0f)) (*it)->m_loggedInPlayer->Reputation_OnKilledUnit(pUnit, true); } } m_Group->getLock().Release(); return; } uint32 team = GetTeam(); ReputationModifier* modifier = objmgr.GetReputationModifier(pUnit->GetEntry(), pUnit->m_factionDBC->ID); if(modifier != 0) { // Apply this data. for(vector<ReputationMod>::iterator itr = modifier->mods.begin(); itr != modifier->mods.end(); ++itr) { if(!(*itr).faction[team]) continue; /* rep limit? */ if(!IS_INSTANCE(GetMapId()) || (IS_INSTANCE(GetMapId()) && this->iInstanceType != MODE_HEROIC)) { if((*itr).replimit) { if(GetStanding((*itr).faction[team]) >= (int32)(*itr).replimit) continue; } } ModStanding(itr->faction[team], float2int32(itr->value * sWorld.getRate(RATE_KILLREPUTATION))); } } else { if(IS_INSTANCE(GetMapId()) && objmgr.HandleInstanceReputationModifiers(this, pUnit)) return; if(pUnit->m_factionDBC->RepListId < 0) return; int32 change = int32(-5.0f * sWorld.getRate(RATE_KILLREPUTATION)); ModStanding(pUnit->m_factionDBC->ID, change); } }
void CSVWholeview::enumSVSE() { if(!m_pContent) return; PAIRLIST selist; string szRootname(""); int nRow = 0; WTable *pTable = m_pContent; if(GetIniFileInt("solover","solover",1,"general.ini") == 1) { sv_pair svpair; svpair.name = "1"; OBJECT objSE = GetSVSE("1");//, m_szIDCUser, m_szIDCPwd); if(objSE != INVALID_VALUE) { svpair.value = GetSVSELabel(objSE); CloseSVSE(objSE); } selist.push_back(svpair); } else { GetAllSVSEInfo(selist); szRootname = GetIniFileString("segroup","name","","general.ini"); if(szRootname.empty()) szRootname = "SiteView ECC 7.0"; nRow = m_pContent->numRows(); //WImage *pShow = new WImage("../Images/foldopen.gif", m_pContent->elementAt(nRow, 0)); //WImage *pHide = new WImage("../Images/foldclose.gif", m_pContent->elementAt(nRow, 0)); WImage *pShow = new WImage("/Images/cb1-unwrap.gif", m_pContent->elementAt(nRow, 0)); WImage *pHide = new WImage("/Images/cb1-fold.gif", m_pContent->elementAt(nRow, 0)); new WText(" ",m_pContent->elementAt(nRow, 0)); //new WImage("../Images/home.gif", m_pContent->elementAt(nRow, 1)); new WImage("/Images/cbb-2main.gif", m_pContent->elementAt(nRow, 1)); new WText(" ",m_pContent->elementAt(nRow, 1)); WText *pName = new WText(szRootname, m_pContent->elementAt(nRow, 2)); if(pName) { sprintf(pName->contextmenu_, "style='color:#669;cursor:pointer;' onmouseover='" \ "this.style.textDecoration=\"underline\"' " \ "onmouseout='this.style.textDecoration=\"none\"'"); } pTable = new WTable(m_pContent->elementAt(nRow + 1, 2)); pTable->setStyleClass("widthauto"); if(!pTable) return; else { if(pShow && pHide) { string szShow = "", szHide = "", szSubTable = ""; szShow = pHide->formName(); szHide = pShow->formName(); szSubTable = pTable->formName(); string szShowText = "onclick='showsubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='display:none;cursor:pointer'"; string szHideText = "onclick='hidesubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='cursor:pointer'"; sprintf(pShow->contextmenu_, szShowText.c_str()); sprintf(pHide->contextmenu_, szHideText.c_str()); } } } PAIRLIST::iterator iSe; bool bHasRight = true; int nChildCount = 0, nIndex = 0; OBJECT objSE = INVALID_VALUE; OBJECT objGroup = INVALID_VALUE; MAPNODE node = INVALID_VALUE; string szSEID(""), szSubGroupID(""), szEntityID(""); string szName(""), szIndex(""); string szContext(""), szShow(""), szHide(""), szSubTable(""); string szShowText(""), szHideText(""); list<string> lsGroupID; list<string> lsDeviceID; list<string>::iterator lstItem; for(iSe= selist.begin(); iSe!=selist.end(); iSe++) { szSEID = (*iSe).name; bHasRight = true; if(m_pSVUser) bHasRight = m_pSVUser->haveGroupRight(szSEID, Tree_SE); if(bHasRight) { nRow = pTable->numRows(); //WImage *pShow = new WImage("../Images/foldopen.gif", pTable->elementAt(nRow, 0)); //WImage *pHide = new WImage("../Images/foldclose.gif", pTable->elementAt(nRow, 0)); WImage *pShow = new WImage("/Images/cb1-unwrap.gif", pTable->elementAt(nRow, 0)); WImage *pHide = new WImage("/Images/cb1-fold.gif", pTable->elementAt(nRow, 0)); new WText(" ",pTable->elementAt(nRow, 0)); new WImage("/Images/cbb-2main.gif", pTable->elementAt(nRow, 1)); new WText(" ",pTable->elementAt(nRow, 1)); WText *pName = new WText((*iSe).value, pTable->elementAt(nRow, 2)); if(pName) { szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?svseid=" + szSEID + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'" + "onmouseout='this.style.textDecoration=\"none\"'"; sprintf(pName->contextmenu_, szContext.c_str()); } WTable *pSubTable = new WTable(pTable->elementAt(nRow + 1, 2)); pSubTable->setStyleClass("widthauto"); if(!pSubTable) return; else { if(pShow && pHide) { szShow = pHide->formName(); szHide = pShow->formName(); szSubTable = pSubTable->formName(); szShowText = "onclick='showsubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='display:none;cursor:pointer'"; szHideText = "onclick='hidesubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='cursor:pointer'"; sprintf(pShow->contextmenu_, szShowText.c_str()); sprintf(pHide->contextmenu_, szHideText.c_str()); } } objSE = GetSVSE(szSEID); if(objSE != INVALID_VALUE) { lsGroupID.clear(); if(GetSubGroupsIDBySE(objSE, lsGroupID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; map<int, base_param, less<int> >::iterator compItem; base_param group; for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++) { szSubGroupID =(*lstItem); bHasRight = true; if(m_pSVUser) bHasRight = m_pSVUser->haveGroupRight(szSubGroupID, Tree_GROUP); if(bHasRight) { objGroup = GetGroup(szSubGroupID, m_szIDCUser, m_szIDCPwd); if(objGroup != INVALID_VALUE) { node = GetGroupMainAttribNode(objGroup); if(node != INVALID_VALUE) { FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) nIndex = FindIndexByID(szSubGroupID); else nIndex = atoi(szIndex.c_str()); group.szIndex = szSubGroupID; group.szName = szName; lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = group; } CloseGroup(objGroup); } } } nChildCount += static_cast<int>(sortList.size()); for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { //PrintDebugString("In first setting ---------" + lsItem->second.szName + "\n"); //bool bbbb = false; nRow = pSubTable->numRows(); WImage *pShow = new WImage("/Images/cb1-unwrap.gif", pSubTable->elementAt(nRow, 0)); WImage *pHide = new WImage("/Images/cb1-fold.gif", pSubTable->elementAt(nRow, 0)); new WText(" ",pSubTable->elementAt(nRow, 0)); new WImage("/Images/cbb-3group.gif", pSubTable->elementAt(nRow, 1)); new WText(" ",pSubTable->elementAt(nRow, 1)); WText *pName = new WText(lsItem->second.szName, pSubTable->elementAt(nRow, 2)); if(pName) { string szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?groupid=" + lsItem->second.szIndex + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'" + "onmouseout='this.style.textDecoration=\"none\"'"; sprintf(pName->contextmenu_, szContext.c_str()); } WTable * pSub = new WTable(pSubTable->elementAt(nRow + 1, 2)); if(pSub) { if(pShow && pHide) { szShow = pHide->formName(); szHide = pShow->formName(); szSubTable = pSub->formName(); string szShowText = "onclick='showsubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='display:none;cursor:pointer'"; string szHideText = "onclick='hidesubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='cursor:pointer'"; sprintf(pShow->contextmenu_, szShowText.c_str()); sprintf(pHide->contextmenu_, szHideText.c_str()); } if(!enumGroups(lsItem->second.szIndex, pSub)) { //bbbb = true; //pSubTable->deleteRow(nRow); pShow->hide(); pHide->hide(); } } } } lsDeviceID.clear(); if(GetSubEntitysIDBySE(objSE, lsDeviceID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; base_param device; for(lstItem = lsDeviceID.begin(); lstItem != lsDeviceID.end(); lstItem ++) { szEntityID =(*lstItem); bHasRight = true; if(m_pSVUser) bHasRight = m_pSVUser->haveGroupRight(szEntityID, Tree_DEVICE); if(bHasRight) { OBJECT objDevice = GetEntity(szEntityID, m_szIDCUser, m_szIDCPwd); if(objDevice != INVALID_VALUE) { MAPNODE node = GetEntityMainAttribNode(objDevice); if(node != INVALID_VALUE) { FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) nIndex = FindIndexByID(szEntityID); else nIndex = atoi(szIndex.c_str()); device.szIndex = szEntityID; device.szName = szName; lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = device; } CloseEntity(objDevice); } } } nChildCount += static_cast<int>(sortList.size()); for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { nRow = pSubTable->numRows(); new WText(" ",pSubTable->elementAt(nRow , 0)); new WImage("/Images/cbb-4server.gif", pSubTable->elementAt(nRow, 1)); new WText(" ",pSubTable->elementAt(nRow , 1)); WText *pName = new WText(lsItem->second.szName, pSubTable->elementAt(nRow, 2)); if(pName) { szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?deviceid=" + lsItem->second.szIndex + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'" + "onmouseout='this.style.textDecoration=\"none\"'"; sprintf(pName->contextmenu_, szContext.c_str()); } if(!enumMonitors(lsItem->second.szIndex, lsItem->second.szName, pSubTable->elementAt(nRow, 2))) { //pSubTable->deleteRow(nRow); } } } CloseSVSE(objSE); if(nChildCount <= 0) { new WText(m_szNoChild, pSubTable->elementAt(nRow, 2)); } } } } }
void CLuaMenu::UpdateSize() { m_pMenu->size(GetGroup()->w(), m_pMenu->h()); }
//---------------------------------------------------------------------------- ObjLoader::ObjLoader (const string& path, const string& filename) : mCode(EC_SUCCESSFUL), mCurrentGroup(-1), mCurrentPos(-1), mCurrentTcd(-1), mCurrentNor(-1), mCurrentMtl(-1), mCurrentMesh(-1) { mLogFile = fopen("ObjLogFile.txt", "wt"); if (!mLogFile) { assert(false); mCode = EC_LOGFILE_OPEN_FAILED; return; } string filePath = path + filename; ifstream inFile(filePath.c_str()); if (!inFile) { assert(false); mCode = EC_FILE_OPEN_FAILED; fprintf(mLogFile, "%s: %s\n", msCodeString[mCode], filePath.c_str()); fclose(mLogFile); return; } string line; vector<string> tokens; while (!inFile.eof()) { getline(inFile, line); // Skip blank lines. if (line == "") { continue; } // Skip comments. if (line[0] == '#') { continue; } GetTokens(line, tokens); if (tokens.size() == 0) { assert(false); mCode = EC_NO_TOKENS; break; } // mtllib if (GetMaterialLibrary(path, tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // g default if (GetDefaultGroup(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // v x y z if (GetPosition(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // vt x y if (GetTCoord(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // vn x y z if (GetNormal(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // Ignore smoothing groups for now (syntax: 's number'). if (tokens[0] == "s") { continue; } // g groupname if (GetGroup(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // usemtl mtlname if (GetMaterialAndMesh(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // f vertexList if (GetFace(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } assert(false); mCode = EC_UNEXPECTED_TOKEN; break; } if (mCode != EC_SUCCESSFUL) { fprintf(mLogFile, "%s: %s\n", msCodeString[mCode], line.c_str()); } else { fprintf(mLogFile, "%s\n", msCodeString[EC_SUCCESSFUL]); } fclose(mLogFile); inFile.close(); }
static void AllocSeg( void *_snode, void *dummy ) /***********************************************/ { segnode *snode = _snode; segdata *sdata; char *clname; char *sname; group_entry *group; bool isdbi; dummy = dummy; sdata = snode->entry; if( sdata == NULL ) return; sname = sdata->u.name; if( CurrMod->modinfo & MOD_IMPORT_LIB ) { if( sdata->isidata || sdata->iscode ) { if( sdata->iscode ) { snode->info |= SEG_CODE; } snode->info |= SEG_DEAD; snode->entry = NULL; FreeSegData( sdata ); return; } } isdbi = false; if( memicmp( CoffDebugPrefix, sdata->u.name, sizeof(CoffDebugPrefix) - 1 ) == 0 ) { if( CurrMod->modinfo & MOD_IMPORT_LIB ) { snode->info |= SEG_DEAD; snode->entry = NULL; FreeSegData( sdata ); return; } isdbi = true; if( stricmp(CoffDebugSymName, sdata->u.name ) == 0 ) { clname = _MSLocalClass; } else if( stricmp(CoffDebugTypeName, sdata->u.name ) == 0 ) { clname = _MSTypeClass; } else { clname = _DwarfClass; } } else if( memicmp( TLSSegPrefix, sdata->u.name, sizeof(TLSSegPrefix) - 1 ) == 0 ) { clname = TLSClassName; } else if( sdata->iscode ) { clname = CodeClassName; } else if( sdata->isuninit ) { clname = BSSClassName; } else { clname = DataClassName; if( memcmp( sname, CoffPDataSegName, sizeof(CoffPDataSegName) ) == 0 ) { sdata->ispdata = true; } else if( memcmp(sname, CoffReldataSegName, sizeof(CoffReldataSegName) ) == 0 ) { sdata->isreldata = true; } } AllocateSegment( snode, clname ); if( clname == TLSClassName ) { group = GetGroup( TLSGrpName ); AddToGroup( group, snode->entry->u.leader ); } else if( !sdata->iscode && !isdbi ) { group = GetGroup( DataGrpName ); AddToGroup( group, snode->entry->u.leader ); } if( sdata->isuninit ) { snode->contents = NULL; } else { snode->entry->u.leader->info |= SEG_LXDATA_SEEN; if( !sdata->isdead ) { ORLSecGetContents( snode->handle, &snode->contents ); if( !sdata->iscdat && ( snode->contents != NULL )) { PutInfo( sdata->u1.vm_ptr, snode->contents, sdata->length ); } } } }
bool AMech_RPGCharacter::CompareGroup(UGroup* inGroup) { return GetGroup() != nullptr ? GetGroup()->Compare(inGroup) : true; }
void Aura::ProcessOnGroupMembersPets(Mob *owner) { auto &mob_list = entity_list.GetMobList(); // read only reference so we can do it all inline std::set<int> delayed_remove; bool is_buff = IsBuffSpell(spell_id); // non-buff spells don't cast on enter // This type can either live on the pet (level 55/70 MAG aura) or on the pet owner (level 85 MAG aura) auto group_member = owner->GetOwnerOrSelf(); if (group_member->IsRaidGrouped() && group_member->IsClient()) { // currently raids are just client, but safety check auto raid = group_member->GetRaid(); if (raid == nullptr) { // well shit owner->RemoveAura(GetID(), false, true); return; } auto group_id = raid->GetGroup(group_member->CastToClient()); // some lambdas so the for loop is less horrible ... auto verify_raid_client_pet = [&raid, &group_id, &group_member, this](Mob *m) { auto idx = raid->GetPlayerIndex(m->GetOwner()->CastToClient()); if (m->GetOwner()->GetID() == group_member->GetID()) { return DistanceSquared(GetPosition(), m->GetPosition()) <= distance; } else if (idx == 0xFFFFFFFF || raid->members[idx].GroupNumber != group_id || raid->members[idx].GroupNumber == 0xFFFFFFFF) { return false; } else if (DistanceSquared(GetPosition(), m->GetPosition()) > distance) { return false; } return true; }; auto verify_raid_client_swarm = [&raid, &group_id, &group_member, this](NPC *n) { auto owner = entity_list.GetMob(n->GetSwarmOwner()); if (owner == nullptr) return false; auto idx = raid->GetPlayerIndex(owner->CastToClient()); if (owner->GetID() == group_member->GetID()) { return DistanceSquared(GetPosition(), n->GetPosition()) <= distance; } else if (idx == 0xFFFFFFFF || raid->members[idx].GroupNumber != group_id || raid->members[idx].GroupNumber == 0xFFFFFFFF) { return false; } else if (DistanceSquared(GetPosition(), n->GetPosition()) > distance) { return false; } return true; }; for (auto &e : mob_list) { auto mob = e.second; // step 1: check if we're already managing this NPC's buff auto it = casted_on.find(mob->GetID()); if (it != casted_on.end()) { // verify still good! if (mob->IsPet() && mob->IsPetOwnerClient() && mob->GetOwner()) { if (!verify_raid_client_pet(mob)) delayed_remove.insert(mob->GetID()); } else if (mob->IsNPC() && mob->IsPetOwnerClient()) { auto npc = mob->CastToNPC(); if (!verify_raid_client_swarm(npc)) delayed_remove.insert(mob->GetID()); } } else { // we're not on it! if (mob->IsClient()) { continue; // never hit client } else if (mob->IsPet() && mob->IsPetOwnerClient() && mob->GetOwner() && verify_raid_client_pet(mob)) { casted_on.insert(mob->GetID()); if (is_buff) SpellFinished(spell_id, mob); } else if (mob->IsNPC() && mob->IsPetOwnerClient()) { auto npc = mob->CastToNPC(); if (verify_raid_client_swarm(npc)) { casted_on.insert(mob->GetID()); if (is_buff) SpellFinished(spell_id, mob); } } } } } else if (group_member->IsGrouped()) { auto group = group_member->GetGroup(); if (group == nullptr) { // uh oh owner->RemoveAura(GetID(), false, true); return; } // lambdas to make for loop less ugly auto verify_group_pet = [&group, this](Mob *m) { auto owner = m->GetOwner(); if (owner != nullptr && group->IsGroupMember(owner) && DistanceSquared(GetPosition(), m->GetPosition()) <= distance) return true; return false; }; auto verify_group_swarm = [&group, this](NPC *n) { auto owner = entity_list.GetMob(n->GetSwarmOwner()); if (owner != nullptr && group->IsGroupMember(owner) && DistanceSquared(GetPosition(), n->GetPosition()) <= distance) return true; return false; }; for (auto &e : mob_list) { auto mob = e.second; auto it = casted_on.find(mob->GetID()); if (it != casted_on.end()) { // make sure we're still valid if (mob->IsPet()) { if (!verify_group_pet(mob)) delayed_remove.insert(mob->GetID()); } else if (mob->IsNPC() && mob->CastToNPC()->GetSwarmInfo()) { if (!verify_group_swarm(mob->CastToNPC())) delayed_remove.insert(mob->GetID()); } } else { // not on, check if we should be! if (mob->IsClient()) { continue; } else if (mob->IsPet() && verify_group_pet(mob)) { casted_on.insert(mob->GetID()); if (is_buff) SpellFinished(spell_id, mob); } else if (mob->IsNPC() && mob->CastToNPC()->GetSwarmInfo() && verify_group_swarm(mob->CastToNPC())) { casted_on.insert(mob->GetID()); if (is_buff) SpellFinished(spell_id, mob); } } } } else { auto verify_solo = [&group_member, this](Mob *m) { if (m->IsPet() && m->GetOwnerID() == group_member->GetID()) return true; else if (m->IsNPC() && m->CastToNPC()->GetSwarmOwner() == group_member->GetID()) return true; else return false; }; for (auto &e : mob_list) { auto mob = e.second; auto it = casted_on.find(mob->GetID()); bool good = verify_solo(mob); if (it != casted_on.end()) { // make sure still valid if (!good || DistanceSquared(GetPosition(), mob->GetPosition()) > distance) { delayed_remove.insert(mob->GetID()); } } else if (good && DistanceSquared(GetPosition(), mob->GetPosition()) <= distance) { casted_on.insert(mob->GetID()); if (is_buff) SpellFinished(spell_id, mob); } } } for (auto &e : delayed_remove) { auto mob = entity_list.GetMob(e); if (mob != nullptr && is_buff) // some auras cast instant spells so no need to remove mob->BuffFadeBySpellIDAndCaster(spell_id, GetID()); casted_on.erase(e); } // so if we have a cast timer and our set isn't empty and timer is disabled we need to enable it if (cast_timer.GetDuration() > 0 && !cast_timer.Enabled() && !casted_on.empty()) cast_timer.Start(); if (!cast_timer.Enabled() || !cast_timer.Check()) return; // some auras have to recast (DRU for example, non-buff too) for (auto &e : casted_on) { auto mob = entity_list.GetMob(e); if (mob != nullptr) SpellFinished(spell_id, mob); } }
bool AMech_RPGCharacter::IsEnemy(AMech_RPGCharacter* other) { return !other->CompareGroup(GetGroup()); }
void AMech_RPGCharacter::EnemyKilled(AMech_RPGCharacter* character) { if (OnEnemyKilled.IsBound()) OnEnemyKilled.Broadcast(character); GetGroup()->GroupEnemyKilled(character); }
cGroupManager::cGroupManager() : m_pState( new sGroupManagerState ) { LOGD("-- Loading Groups --"); cIniFile IniFile; if (!IniFile.ReadFile("groups.ini")) { LOGWARNING("Regenerating groups.ini, all groups will be reset"); IniFile.AddHeaderComment(" This is the MCServer permissions manager groups file"); IniFile.AddHeaderComment(" It stores all defined groups such as Administrators, Players, or Moderators"); IniFile.SetValue("Owner", "Permissions", "*", true); IniFile.SetValue("Owner", "Color", "2", true); IniFile.SetValue("Moderator", "Permissions", "core.time,core.item,core.teleport,core.ban,core.unban,core.save-all,core.toggledownfall"); IniFile.SetValue("Moderator", "Color", "2", true); IniFile.SetValue("Moderator", "Inherits", "Player", true); IniFile.SetValue("Player", "Permissions", "core.build", true); IniFile.SetValue("Player", "Color", "f", true); IniFile.SetValue("Player", "Inherits", "Default", true); IniFile.SetValue("Default", "Permissions", "core.help,core.playerlist,core.pluginlist,core.spawn,core.listworlds,core.back,core.motd,core.gotoworld,core.coords,core.viewdistance", true); IniFile.SetValue("Default", "Color", "f", true); IniFile.WriteFile("groups.ini"); } unsigned int NumKeys = IniFile.GetNumKeys(); for( unsigned int i = 0; i < NumKeys; i++ ) { std::string KeyName = IniFile.GetKeyName( i ); cGroup* Group = GetGroup( KeyName.c_str() ); LOGD("Loading group: %s", KeyName.c_str() ); Group->SetName( KeyName ); char Color = IniFile.GetValue( KeyName, "Color", "-" )[0]; if( Color != '-' ) Group->SetColor( cChatColor::MakeColor(Color) ); else Group->SetColor( cChatColor::White ); std::string Commands = IniFile.GetValue( KeyName, "Commands", "" ); if( Commands.size() > 0 ) { AStringVector Split = StringSplit( Commands, "," ); for( unsigned int i = 0; i < Split.size(); i++) { Group->AddCommand( Split[i] ); } } std::string Permissions = IniFile.GetValue( KeyName, "Permissions", "" ); if( Permissions.size() > 0 ) { AStringVector Split = StringSplit( Permissions, "," ); for( unsigned int i = 0; i < Split.size(); i++) { Group->AddPermission( Split[i] ); } } std::string Groups = IniFile.GetValue( KeyName, "Inherits", "" ); if( Groups.size() > 0 ) { AStringVector Split = StringSplit( Groups, "," ); for( unsigned int i = 0; i < Split.size(); i++) { Group->InheritFrom( GetGroup( Split[i].c_str() ) ); } } } LOGD("-- Groups Successfully Loaded --"); }
bool cGroupManager::LoadGroups() { cIniFile IniFile; if (!IniFile.ReadFile("groups.ini")) { LOGWARNING("Regenerating groups.ini, all groups will be reset"); IniFile.AddHeaderComment(" This is the MCServer permissions manager groups file"); IniFile.AddHeaderComment(" It stores all defined groups such as Administrators, Players, or Moderators"); IniFile.SetValue("Owner", "Permissions", "*", true); IniFile.SetValue("Owner", "Color", "2", true); IniFile.SetValue("Moderator", "Permissions", "core.time,core.item,core.teleport,core.ban,core.unban,core.save-all,core.toggledownfall"); IniFile.SetValue("Moderator", "Color", "2", true); IniFile.SetValue("Moderator", "Inherits", "Player", true); IniFile.SetValue("Player", "Permissions", "core.portal", true); IniFile.SetValue("Player", "Color", "f", true); IniFile.SetValue("Player", "Inherits", "Default", true); IniFile.SetValue("Default", "Permissions", "core.help,core.plugins,core.spawn,core.worlds,core.back,core.motd,core.build,core.locate,core.viewdistance", true); IniFile.SetValue("Default", "Color", "f", true); IniFile.WriteFile("groups.ini"); } int NumKeys = IniFile.GetNumKeys(); for (int i = 0; i < NumKeys; i++) { AString KeyName = IniFile.GetKeyName(i); cGroup * Group = GetGroup(KeyName.c_str()); Group->ClearPermission(); // Needed in case the groups are reloaded. LOGD("Loading group %s", KeyName.c_str()); Group->SetName(KeyName); AString Color = IniFile.GetValue(KeyName, "Color", "-"); if ((Color != "-") && (Color.length() >= 1)) { Group->SetColor(cChatColor::Color + Color[0]); } else { Group->SetColor(cChatColor::White); } AString Commands = IniFile.GetValue(KeyName, "Commands", ""); if (!Commands.empty()) { AStringVector Split = StringSplitAndTrim(Commands, ","); for (size_t i = 0; i < Split.size(); i++) { Group->AddCommand(Split[i]); } } AString Permissions = IniFile.GetValue(KeyName, "Permissions", ""); if (!Permissions.empty()) { AStringVector Split = StringSplitAndTrim(Permissions, ","); for (size_t i = 0; i < Split.size(); i++) { Group->AddPermission(Split[i]); } } AString Groups = IniFile.GetValue(KeyName, "Inherits", ""); if (!Groups.empty()) { AStringVector Split = StringSplitAndTrim(Groups, ","); for (size_t i = 0; i < Split.size(); i++) { Group->InheritFrom(GetGroup(Split[i].c_str())); } } } // Always return true, we can handle writefile fails later. return true; }
void AdminCache::DumpCache(FILE *fp) { int *itable; AdminId aid; GroupId gid; char flagstr[64]; unsigned int num; AdminUser *pAdmin; AdminGroup *pGroup; char name_buffer[512]; fprintf(fp, "\"Groups\"\n{\n"); num = 0; gid = m_FirstGroup; while (gid != INVALID_GROUP_ID && (pGroup = GetGroup(gid)) != NULL) { num++; FillFlagString(pGroup->addflags, flagstr, sizeof(flagstr)); fprintf(fp, "\t/* num = %d, gid = 0x%X */\n", num, gid); fprintf(fp, "\t\"%s\"\n\t{\n", GetString(pGroup->nameidx)); fprintf(fp, "\t\t\"flags\"\t\t\t\"%s\"\n", flagstr); fprintf(fp, "\t\t\"immunity\"\t\t\"%d\"\n", pGroup->immunity_level); if (pGroup->immune_table != -1 && (itable = (int *)m_pMemory->GetAddress(pGroup->immune_table)) != NULL) { AdminGroup *pAltGroup; const char *gname, *mod; for (int i = 1; i <= itable[0]; i++) { if ((pAltGroup = GetGroup(itable[i])) == NULL) { /* Assume the rest of the table is corrupt */ break; } gname = GetString(pAltGroup->nameidx); if (atoi(gname) != 0) { mod = "@"; } else { mod = ""; } fprintf(fp, "\t\t\"immunity\"\t\t\"%s%s\"\n", mod, gname); } } fprintf(fp, "\n\t\t\"Overrides\"\n\t\t{\n"); if (pGroup->pCmdGrpTable != NULL) { sm_trie_bad_iterator(pGroup->pCmdGrpTable, name_buffer, sizeof(name_buffer), iterator_group_grp_override, fp); } if (pGroup->pCmdTable != NULL) { sm_trie_bad_iterator(pGroup->pCmdTable, name_buffer, sizeof(name_buffer), iterator_group_basic_override, fp); } fprintf(fp, "\t\t}\n"); fprintf(fp, "\t}\n"); if ((gid = pGroup->next_grp) != INVALID_GROUP_ID) { fprintf(fp, "\n"); } } fprintf(fp, "}\n\n"); fprintf(fp, "\"Admins\"\n{\n"); num = 0; aid = m_FirstUser; while (aid != INVALID_ADMIN_ID && (pAdmin = GetUser(aid)) != NULL) { num++; FillFlagString(pAdmin->flags, flagstr, sizeof(flagstr)); fprintf(fp, "\t/* num = %d, aid = 0x%X, serialno = 0x%X*/\n", num, aid, pAdmin->serialchange); if (pAdmin->nameidx != -1) { fprintf(fp, "\t\"%s\"\n\t{\n", GetString(pAdmin->nameidx)); } else { fprintf(fp, "\t\"\"\n\t{\n"); } if (pAdmin->auth.identidx != -1) { fprintf(fp, "\t\t\"auth\"\t\t\t\"%s\"\n", GetMethodName(pAdmin->auth.index)); fprintf(fp, "\t\t\"identity\"\t\t\"%s\"\n", GetString(pAdmin->auth.identidx)); } if (pAdmin->password != -1) { fprintf(fp, "\t\t\"password\"\t\t\"%s\"\n", GetString(pAdmin->password)); } fprintf(fp, "\t\t\"flags\"\t\t\t\"%s\"\n", flagstr); fprintf(fp, "\t\t\"immunity\"\t\t\"%d\"\n", pAdmin->immunity_level); if (pAdmin->grp_count != 0 && pAdmin->grp_table != -1 && (itable = (int *)m_pMemory->GetAddress(pAdmin->grp_table)) != NULL) { unsigned int i; for (i = 0; i < pAdmin->grp_count; i++) { if ((pGroup = GetGroup(itable[i])) == NULL) { /* Assume the rest of the table is corrupt */ break; } fprintf(fp, "\t\t\"group\"\t\t\t\"%s\"\n", GetString(pGroup->nameidx)); } } fprintf(fp, "\t}\n"); if ((aid = pAdmin->next_user) != INVALID_ADMIN_ID) { fprintf(fp, "\n"); } } fprintf(fp, "}\n\n"); fprintf(fp, "\"Overrides\"\n{\n"); if (m_pCmdGrpOverrides != NULL) { sm_trie_bad_iterator(m_pCmdGrpOverrides, name_buffer, sizeof(name_buffer), iterator_glob_grp_override, fp); } if (m_pCmdOverrides != NULL) { sm_trie_bad_iterator(m_pCmdOverrides, name_buffer, sizeof(name_buffer), iterator_glob_basic_override, fp); } fprintf(fp, "}\n"); }
bool CCheckBoxTreeView::InitTree(std::string strFirstNode_, bool bDevice_ ,bool bCheck_ ,bool bMain_ ,std::string strUser_, std::string szSEID) { vector<string >::iterator iSelItor; m_pOldSelNode =NULL; if(treeroot) delete treeroot; if (m_menutable) { while ( m_menutable->numRows() > 1) { m_menutable->deleteRow(m_menutable->numRows() - 1); } } strFirstNode=strFirstNode_; bDevice=bDevice_; bCheck=bCheck_; bMain=bMain_; strUser=strUser_; pTreeSelNode =NULL; if (bDevice_) //增加权限table cell { if(pRightTbl==NULL) { InitRightCell(); } Scrolltable->resize(WLength(100,WLength::Percentage), 450); this->setStyleClass("margin_top"); }else { this->setStyleClass("margin_top"); Scrolltable->setStyleClass("widthauto"); } int nAdmin = GetIniFileInt(strUser, "nAdmin", -1, "user.ini"); if(nAdmin==-1) bAdmin = false; else bAdmin= true; if(!bAdmin) { std::string groupright= GetIniFileString(strUser, "groupright", "", "user.ini"); ParserToken(pUserSelGroupList,groupright.c_str(),","); vector<string>::iterator result1; for( result1=pUserSelGroupList.begin();result1!=pUserSelGroupList.end();result1++) PushGroup(result1->c_str(),pUserTreeGroupList); } WTreeNode *FistNode; { OBJECT root = GetSVSE(szSEID); list<string> lsGroupID; list<string>::iterator lstItem; WTreeNode *tmpNode = NULL; if(treeroot!=NULL) { FistNode= makeTreeFile(GetSVSELabel(root), szSEID, Tree_SE, treeroot, false, false, "/Images/cbb-2main.gif", "/Images/cbb-2main.gif"); }else{ FistNode= makeTreeMap(GetSVSELabel(root), szSEID, Tree_SE, m_menutable, false, false, "/Images/cbb-2main.gif", "/Images/cbb-2main.gif"); treeroot= FistNode; } if (root != INVALID_VALUE) { //第一层组 if(GetSubGroupsIDBySE(root, lsGroupID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; base_param group; for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++) { string szSubGroupID = (*lstItem).c_str(); bool bSelTree = true;// 是否增加组或者设备到树上 if(!bAdmin) { iSelItor = find(pUserTreeGroupList.begin(),pUserTreeGroupList.end(),szSubGroupID); if(iSelItor == pUserTreeGroupList.end()) bSelTree= false; } if(bSelTree) { OBJECT objGroup = GetGroup(szSubGroupID); if(objGroup != INVALID_VALUE) { MAPNODE node = GetGroupMainAttribNode(objGroup); if(node != INVALID_VALUE) { string szName = "", szIndex = ""; FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) szIndex = findIndexByRealID(szSubGroupID); group.szIndex = szSubGroupID; group.szName = szName; int nIndex = atoi(szIndex.c_str()); lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = group; } CloseGroup(objGroup); } } } for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { bool bTreehaveCheck=true; if(bCheck_) bTreehaveCheck =true; else { iSelItor =find(pUserSelGroupList.begin(),pUserSelGroupList.end(), lsItem->second.szIndex); if(iSelItor ==pUserSelGroupList.end()) bTreehaveCheck= false; } tmpNode=AddGroupTreeNode(lsItem->second.szIndex, FistNode, bTreehaveCheck); if(tmpNode!=NULL) EnumGroup(lsItem->second.szIndex, tmpNode, bTreehaveCheck); } } if(GetSubEntitysIDBySE(root, lsGroupID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; base_param device; for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++) { string szEntityID = (*lstItem).c_str(); bool bSelTree =true;// 是否增加组或者设备到树上 if(!bAdmin) { iSelItor =find(pUserTreeGroupList.begin(),pUserTreeGroupList.end(),szEntityID); if(iSelItor ==pUserTreeGroupList.end()) bSelTree= false; } if(bSelTree) { OBJECT objDevice = GetEntity(szEntityID); if(objDevice != INVALID_VALUE) { MAPNODE node = GetEntityMainAttribNode(objDevice); if(node != INVALID_VALUE) { string szName = "", szIndex = ""; //FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) szIndex = findIndexByRealID(szEntityID); device.szIndex = szEntityID; device.szName = szName; int nIndex = atoi(szIndex.c_str()); lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { //nMax ++; nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = device; } CloseEntity(objDevice); } //AddDeviceTreeNode(szEntityID, parentNode ); } } for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) AddDeviceTreeNode(lsItem->second.szIndex, FistNode); } CloseSVSE(root); } } makeTreeFile("无依靠", "-2", Tree_MONITOR, FistNode, false, false, "/Images/cbb-6application.gif","/Images/cbb-6application.gif"); return true; }
IResourceManager::GroupWeakPtr IResourceManager::GetGroup(xst_castring& strName) { GroupHandle Handle = XSE_HASH( strName ); m_pStrTmp = strName.c_str(); return GetGroup( Handle ); }
/** * Returns true if the local node is a member of the subgroup */ inline bool IsServer() const { return GetGroup().GetSubgroup().Contains(GetLocalId()); }
ResourceWeakPtr IResourceManager::PrepareResource(xst_castring &strName, xst_castring &strGroupName) { return PrepareResource( strName, GetGroup( strGroupName ) ); }
int Client::GroupLeadershipAAOffenseEnhancement() { if (IsRaidGrouped()) { int bonus = 0; Raid *raid = GetRaid(); if (!raid) return 0; uint32 group_id = raid->GetGroup(this); if (group_id < 12 && raid->GroupCount(group_id) >= 3) { switch (raid->GetLeadershipAA(groupAAOffenseEnhancement, group_id)) { case 1: bonus = 10; break; case 2: bonus = 19; break; case 3: bonus = 28; break; case 4: bonus = 34; break; case 5: bonus = 40; break; } } if (raid->RaidCount() >= 18) { switch (raid->GetLeadershipAA(raidAAOffenseEnhancement)) { case 1: bonus += 10; break; case 2: bonus += 19; break; case 3: bonus += 28; break; case 4: bonus += 34; break; case 5: bonus += 40; break; } } return bonus; } Group *g = GetGroup(); if(!g || (g->GroupCount() < 3)) return 0; switch(g->GetLeadershipAA(groupAAOffenseEnhancement)) { case 0: return 0; case 1: return 10; case 2: return 19; case 3: return 28; case 4: return 34; case 5: return 40; } return 0; }
i32 IResourceManager::AddResource(const ResourceHandle& Handle, ResourceWeakPtr pRes, const GroupHandle& GroupHandle ) { return AddResource( Handle, pRes, GetGroup( GroupHandle ) ); }
void CLayers::Init(class IKernel *pKernel) { // reset pointers to race specific layers m_pTeleLayer = 0; m_pSpeedupLayer = 0; m_pFrontLayer = 0; m_pMap = pKernel->RequestInterface<IMap>(); m_pMap->GetType(MAPITEMTYPE_GROUP, &m_GroupsStart, &m_GroupsNum); m_pMap->GetType(MAPITEMTYPE_LAYER, &m_LayersStart, &m_LayersNum); for(int g = 0; g < NumGroups(); g++) { CMapItemGroup *pGroup = GetGroup(g); for(int l = 0; l < pGroup->m_NumLayers; l++) { CMapItemLayer *pLayer = GetLayer(pGroup->m_StartLayer+l); if(pLayer->m_Type == LAYERTYPE_TILES) { CMapItemLayerTilemap *pTilemap = reinterpret_cast<CMapItemLayerTilemap *>(pLayer); if(pTilemap->m_Flags&TILESLAYERFLAG_GAME) { m_pGameLayer = pTilemap; m_pGameGroup = pGroup; // make sure the game group has standard settings m_pGameGroup->m_OffsetX = 0; m_pGameGroup->m_OffsetY = 0; m_pGameGroup->m_ParallaxX = 100; m_pGameGroup->m_ParallaxY = 100; if(m_pGameGroup->m_Version >= 2) { m_pGameGroup->m_UseClipping = 0; m_pGameGroup->m_ClipX = 0; m_pGameGroup->m_ClipY = 0; m_pGameGroup->m_ClipW = 0; m_pGameGroup->m_ClipH = 0; } //break; } else if(pTilemap->m_Flags&2) { if(pTilemap->m_Version < 3) // get the right values for tele layer { int *pTele = (int*)(pTilemap)+15; pTilemap->m_Tele = *pTele; } m_pTeleLayer = pTilemap; } else if(pTilemap->m_Flags&4) { if(pTilemap->m_Version < 3) // get the right values for speedup layer { int *pSpeedup = (int*)(pTilemap)+16; pTilemap->m_Speedup = *pSpeedup; } m_pSpeedupLayer = pTilemap; } if(pTilemap->m_Flags&8) { if(pTilemap->m_Version < 3) // get the right values for front layer { pTilemap->m_Front = *((int*)(pTilemap)+17); } m_pFrontLayer = pTilemap; } } } } }
OPCITEMSTATE* myOPC::Read (GROUP_ID _id) { if (!Connected) { #ifdef _mDEBUG log+="Возврат ибо нет соединения с сервером\n"; #endif return nullptr; } Item _item=GetGroup(_id); #ifdef _mDEBUG log+="Проверка полученного итератора\n"; #endif if (_item==Groups.end()) { #ifdef _mDEBUG log+="FAIL\n"; #endif return nullptr; } #ifdef _mDEBUG log+="OK\n"; log+="Чтение данных с сервера\n"; #endif GroupPTRs* __item=*_item; OPCHANDLE *phServer=new OPCHANDLE[__item->ItemsCount];;//массив указателией на OPC OPCITEMSTATE *pItemsValues=nullptr; //указатель на состояния итемов в опс LPWSTR ErrorStr=L""; //текст ошибки #ifdef _mDEBUG log+="Получение массива указателей на серверы для чтения из групп (phServer)\n"; #endif for(int i=0;i<__item->ItemsCount;i++) { phServer[i]=__item->pItemResult[i].hServer; } #ifdef _mDEBUG log+="OK\n"; log+="Чтение данных по группам\n"; #endif result=__item->pSyncIO->Read(OPC_DS_CACHE,__item->ItemsCount,phServer,&pItemsValues,&pRErrors); delete [] phServer; //удаление массива с указателя на источники для элементов групп if(result==S_OK) { #ifdef _mDEBUG log+="OK\n"; log+="Возврат OPCITEMSTATE *pItemsValues для наполнения массивов данных программы\n\n"; #endif return pItemsValues; } else { #ifdef _mDEBUG pIOPCServer->GetErrorString(pRErrors[0],LOCALE_ID,&ErrorStr); log+="FAIL - Ошибка получения данных в блоке "+String(_id)+"\n\n"; CoTaskMemFree(ErrorStr); #endif return nullptr; } }
bool CSVWholeview::enumGroups(const string &szGroupID, WTable *pTable) { bool bShowGroup = false; bool gShowGroup = true;//jansion bool mShowGroup = true; //jansion pTable->setStyleClass("widthauto"); if(!szGroupID.empty()) { OBJECT objGroup = GetGroup(szGroupID); if(objGroup != INVALID_VALUE) { //PrintDebugString("In ------------------------------------\n"); string szIndex(""), szName(""), szShowIndex(""), szContext(""); string szShow(""), szHide(""), szSubTable(""); string szShowText(""), szHideText(""); bool bHasRight = true; int nIndex = 0, nRow = 0; MAPNODE node = INVALID_VALUE; list<string> lsGroupID; list<string> lsDeviceID; list<string>::iterator lstItem; //list<string>::iterator bcompItem; if(GetSubGroupsIDByGroup(objGroup, lsGroupID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; map<int, base_param, less<int> >::iterator bcompItem; //bool gShow = false; base_param group; OBJECT objSubGroup = INVALID_VALUE; for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++) { //PrintDebugString("In --------------- for ---------------------\n"); szIndex =(*lstItem); bHasRight = true; if(m_pSVUser) bHasRight = m_pSVUser->haveGroupRight(szIndex, Tree_GROUP); if(bHasRight) { objSubGroup = GetGroup(szIndex, m_szIDCUser, m_szIDCPwd); if(objGroup != INVALID_VALUE) { node = GetGroupMainAttribNode(objSubGroup); if(node != INVALID_VALUE) { FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szShowIndex); if(szShowIndex.empty()) nIndex = FindIndexByID(szIndex); else nIndex = atoi(szShowIndex.c_str()); group.szIndex = szIndex; group.szName = szName; lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = group; } else { gShowGroup = false; } CloseGroup(objSubGroup); } } else { gShowGroup =false; } } //if (lsGroupID.empty()) // PrintDebugString("In group is ====== false\n"); for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { //PrintDebugString("In emnuGroup " + lsItem->second.szName + "\n"); //bool gShow = false; nRow = pTable->numRows(); //WImage *pShow = new WImage("../Images/foldopen.gif", pTable->elementAt(nRow, 0)); //WImage *pHide = new WImage("../Images/foldclose.gif", pTable->elementAt(nRow, 0)); //if(!enumGroups(lsItem->second.szIndex, pSub)) //{ WImage *pShow = new WImage("/Images/cb1-unwrap.gif", pTable->elementAt(nRow, 0)); WImage *pHide = new WImage("/Images/cb1-fold.gif", pTable->elementAt(nRow, 0)); //} new WText(" ",pTable->elementAt(nRow, 0)); //new WImage("../Images/group.gif", pTable->elementAt(nRow, 1)); new WImage("/Images/cbb-3group.gif", pTable->elementAt(nRow, 1)); new WText(" ",pTable->elementAt(nRow, 1)); WText *pName = new WText(lsItem->second.szName, pTable->elementAt(nRow, 2)); if(pName) { szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?groupid=" + lsItem->second.szIndex + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'" + "onmouseout='this.style.textDecoration=\"none\"'"; sprintf(pName->contextmenu_, szContext.c_str()); } WTable * pSub = new WTable(pTable->elementAt(nRow + 1, 2)); if(pSub) { if(pShow && pHide) { szShow = pHide->formName(); szHide = pShow->formName(); szSubTable = pSub->formName(); szShowText = "onclick='showsubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='display:none;cursor:pointer'"; szHideText = "onclick='hidesubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='cursor:pointer'"; sprintf(pShow->contextmenu_, szShowText.c_str()); sprintf(pHide->contextmenu_, szHideText.c_str()); } if(!enumGroups(lsItem->second.szIndex, pSub)) { //gShow = true; //pTable->deleteRow(nRow); pShow->hide(); pHide->hide(); } else { //bShowGroup = true; //pShow->hide(); //pHide->hide(); } } } if (sortList.empty()) gShowGroup = false; } else { gShowGroup = false; } if(GetSubEntitysIDByGroup(objGroup, lsDeviceID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; base_param device; OBJECT objDevice = INVALID_VALUE; for(lstItem = lsDeviceID.begin(); lstItem != lsDeviceID.end(); lstItem ++) { szIndex =(*lstItem); bHasRight = true; if(m_pSVUser) bHasRight = m_pSVUser->haveGroupRight(szIndex, Tree_DEVICE); if(bHasRight) { objDevice = GetEntity(szIndex, m_szIDCUser, m_szIDCPwd); if(objDevice != INVALID_VALUE) { node = GetEntityMainAttribNode(objDevice); if(node != INVALID_VALUE) { FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szShowIndex); if(szShowIndex.empty()) nIndex = FindIndexByID(szIndex); else nIndex = atoi(szShowIndex.c_str()); device.szIndex = szIndex; device.szName = szName; lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = device; } else { mShowGroup = false; } CloseEntity(objDevice); } } } for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { //PrintDebugString("In emnuGroup " + lsItem->second.szName + "------------------------\n"); nRow = pTable->numRows(); //new WImage("../Images/device.gif", pTable->elementAt(nRow, 1)); new WImage("/Images/cbb-4server.gif", pTable->elementAt(nRow, 1)); new WText(" ",pTable->elementAt(nRow, 1)); WText *pName = new WText(lsItem->second.szName, pTable->elementAt(nRow, 2)); if(pName) { szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?deviceid=" + lsItem->second.szIndex + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'" + "onmouseout='this.style.textDecoration=\"none\"'"; sprintf(pName->contextmenu_, szContext.c_str()); } if(!enumMonitors(lsItem->second.szIndex, lsItem->second.szName, pTable->elementAt(nRow, 2))) { bShowGroup = false; //bShowGroup = true; //pTable->deleteRow(nRow); } else bShowGroup = true; } //84200891 if (sortList.empty()) { mShowGroup = false; } } else { mShowGroup = false; } CloseGroup(objGroup); } else { mShowGroup = false; gShowGroup = false; } } else { mShowGroup = false; gShowGroup = false; } bool bbShowGroup; bbShowGroup = gShowGroup || mShowGroup; return bbShowGroup; }
HRESULT myOPC::WriteMass (GROUP_ID _id,size_t pos,size_t mass_len,void *item,types type) { if (!Connected) { #ifdef _mDEBUG log+="Возврат ибо нет соединения с сервером\n"; #endif return E_FAIL; } Item _item=GetGroup(_id); #ifdef _mDEBUG log+="Проверка полученного итератора\n"; #endif if (_item==Groups.end()) { #ifdef _mDEBUG log+="FAIL\n"; #endif return E_FAIL; } #ifdef _mDEBUG log+="OK\n"; log+="Запись данных на сервер\n"; #endif GroupPTRs* __item=*_item; if (__item->ItemsCount<=pos) { #ifdef _mDEBUG log+="FAIL выход за пределы группы\n"; #endif return E_FAIL; } OPCHANDLE *phServer=new OPCHANDLE[mass_len]; VARIANT *values=new VARIANT[mass_len]; HRESULT *pWErrors; LPWSTR ErrorStr; for (size_t i=0; i<mass_len; i++) { *(phServer+i) = __item->pItemResult[pos+i].hServer; #ifdef _mDEBUG log+="Определение типа данных\n"; #endif switch (type) { case tBOOL: { #ifdef _mDEBUG log+="OK - BOOL\n"; #endif (*(values+i)).vt = VT_BOOL; (*(values+i)).boolVal = *(((bool *)item)+i); break; } case tINT: { #ifdef _mDEBUG log+="OK - INT\n"; #endif (*(values+i)).vt = VT_I4; (*(values+i)).lVal = *(((int *)item)+i); break; } case tFLOAT: { #ifdef _mDEBUG log+="OK - FLOAT\n"; #endif (*(values+i)).vt = VT_R4; (*(values+i)).fltVal = *(((float *)item)+i); break; } default: { #ifdef _mDEBUG log+="FAIL - UNCNOWN\n"; #endif return E_FAIL; } } } #ifdef _mDEBUG log+="Запись данных в контроллер\n"; #endif result=__item->pSyncIO->Write(mass_len,phServer,values,&pWErrors); delete [] phServer; delete [] values; if(result == S_OK||result==S_FALSE) { #ifdef _mDEBUG log+="OK\n"; #endif return *pWErrors; } else { #ifdef _mDEBUG pIOPCServer->GetErrorString(pWErrors[0],LOCALE_ID,&ErrorStr); log+="FAIL - Ощибка записи данных группы "+String(_id)+" "+String(ErrorStr)+"\n"; CoTaskMemFree(pWErrors); #endif return *pWErrors; } }
void CLN_Login::Register() { tag1PComuCfg obj1PComuCfg; GetImpCfg( &obj1PComuCfg, sizeof(obj1PComuCfg), offsetof(tagImportantCfg, m_uni1PComuCfg.m_obj1PComuCfg), sizeof(obj1PComuCfg) ); if( 0x20 == obj1PComuCfg.m_szTel[0] || 0x30 == obj1PComuCfg.m_szTel[0] || !strcmp("", obj1PComuCfg.m_szTel) ) { PRTMSG(MSG_NOR, "Get SelfTel, but Incorrect or Empty, Quit Register!\n" ); return; } m_dwRegisterTimers++; // 注册重传了10次未收到应答,请求ComuExe重新拨号 if( m_dwRegisterTimers >= 50 ) { PRTMSG(MSG_NOR, "Send Register to max timers, Ask ComuExe to queck net!\n"); char buf[] = {0x34, 0x01}; DataPush((void*)&buf, 2, DEV_SOCK, DEV_PHONE, LV3); m_dwRegisterTimers = 0; _KillTimer(&g_objTimerMng, REGISTER_TIMER); return; } char szBuf[200] = {0}; DWORD dwLen = 0; char szTempBuf[100] = {0}; DWORD dwTempLen = 0; szBuf[dwLen++] = 0x41; // 命令类型 szBuf[dwLen++] = 0x00; // 动作:注册 szBuf[dwLen++] = 0x00; szBuf[dwLen++] = 0x00; // Attr1 szBuf[dwLen++] = 0x03; // K_len1 szBuf[dwLen++] = 'v'; // Key1: ver 终端版本号:M(3)+R(3)+V(4)+S(1) szBuf[dwLen++] = 'e'; szBuf[dwLen++] = 'r'; szBuf[dwLen++] = 0x00; // V_len1 szBuf[dwLen++] = dwTempLen = GetVer(szTempBuf); memcpy(szBuf+dwLen, szTempBuf, dwTempLen); dwLen += dwTempLen; szBuf[dwLen++] = 0x00; // Attr2 szBuf[dwLen++] = 0x03; // K_len2 szBuf[dwLen++] = 'v'; // Key2: ven 厂商编号 szBuf[dwLen++] = 'e'; szBuf[dwLen++] = 'n'; szBuf[dwLen++] = 0x00; // V_len2 szBuf[dwLen++] = dwTempLen = GetVen(szTempBuf); memcpy(szBuf+dwLen, szTempBuf, dwTempLen); dwLen += dwTempLen; szBuf[dwLen++] = 0x00; // Attr3 szBuf[dwLen++] = 0x05; // K_len3 szBuf[dwLen++] = 'g'; // Key3: group 集团计费号 szBuf[dwLen++] = 'r'; szBuf[dwLen++] = 'o'; szBuf[dwLen++] = 'u'; szBuf[dwLen++] = 'p'; szBuf[dwLen++] = 0x00; // V_len3 szBuf[dwLen++] = dwTempLen = GetGroup(szTempBuf); memcpy(szBuf+dwLen, szTempBuf, dwTempLen); dwLen += dwTempLen; // 发送 g_objApplication.SendAppFrame(MODE_A, 0x80, true, 0, szBuf, dwLen); PRTMSG(MSG_NOR, "Send Register Frame!\n"); _SetTimer(&g_objTimerMng, REGISTER_TIMER, 10000, G_TmRegister); }
//----------------------------------------------------------------------------- // Purpose: Return true if pTestHint passes the criteria specified in hintCriteria //----------------------------------------------------------------------------- bool CAI_Hint::HintMatchesCriteria( CAI_BaseNPC *pNPC, const CHintCriteria &hintCriteria, const Vector &position, float *flNearestDistance, bool bIgnoreLock, bool bIgnoreHintType ) { // Cannot be locked if ( !bIgnoreLock && IsLocked() ) { REPORTFAILURE( "Node is locked." ); return false; } if ( !bIgnoreHintType && !hintCriteria.MatchesHintType( HintType() ) ) { return false; } if ( GetMinState() > NPC_STATE_IDLE || GetMaxState() < NPC_STATE_COMBAT ) { if ( pNPC && ( pNPC->GetState() < GetMinState() || pNPC->GetState() > GetMaxState() ) ) { REPORTFAILURE( "NPC not in correct state." ); return false; } } // See if we're filtering by group name if ( hintCriteria.GetGroup() != NULL_STRING ) { AssertIsValidString( GetGroup() ); AssertIsValidString( hintCriteria.GetGroup() ); if ( GetGroup() == NULL_STRING || GetGroup() != hintCriteria.GetGroup() ) { Assert(GetGroup() == NULL_STRING || strcmp( STRING(GetGroup()), STRING(hintCriteria.GetGroup())) != 0 ); REPORTFAILURE( "Doesn't match NPC hint group." ); return false; } } // If we're watching for include zones, test it if ( ( hintCriteria.HasIncludeZones() ) && ( hintCriteria.InIncludedZone( GetAbsOrigin() ) == false ) ) { REPORTFAILURE( "Not inside include zones." ); return false; } // If we're watching for exclude zones, test it if ( ( hintCriteria.HasExcludeZones() ) && ( hintCriteria.InExcludedZone( GetAbsOrigin() ) ) ) { REPORTFAILURE( "Inside exclude zones." ); return false; } // See if the class handles this hint type if ( ( pNPC != NULL ) && ( pNPC->FValidateHintType( this ) == false ) ) { REPORTFAILURE( "NPC doesn't know how to handle that type." ); return false; } if ( hintCriteria.HasFlag(bits_HINT_NPC_IN_NODE_FOV) ) { if ( pNPC == NULL ) { AssertMsg(0,"Hint node attempted to verify NPC in node FOV without NPC!\n"); } else { if( !IsInNodeFOV(pNPC) ) { REPORTFAILURE( "NPC Not in hint's FOV" ); return false; } } } if ( hintCriteria.HasFlag( bits_HINT_NODE_IN_AIMCONE ) ) { if ( pNPC == NULL ) { AssertMsg( 0, "Hint node attempted to find node in aimcone without specifying NPC!\n" ); } else { if( !pNPC->FInAimCone( GetAbsOrigin() ) ) { REPORTFAILURE( "Hint isn't in NPC's aimcone" ); return false; } } } if ( hintCriteria.HasFlag( bits_HINT_NODE_IN_VIEWCONE ) ) { if ( pNPC == NULL ) { AssertMsg( 0, "Hint node attempted to find node in viewcone without specifying NPC!\n" ); } else { if( !pNPC->FInViewCone( this ) ) { REPORTFAILURE( "Hint isn't in NPC's viewcone" ); return false; } } } { AI_PROFILE_SCOPE( HINT_FVisible ); // See if we're requesting a visible node if ( hintCriteria.HasFlag( bits_HINT_NODE_VISIBLE ) ) { if ( pNPC == NULL ) { //NOTENOTE: If you're hitting this, you've asked for a visible node without specifing an NPC! AssertMsg( 0, "Hint node attempted to find visible node without specifying NPC!\n" ); } else { if( m_NodeData.nNodeID == NO_NODE ) { // This is just an info_hint, not a node. if( !pNPC->FVisible( this ) ) { REPORTFAILURE( "Hint isn't visible to NPC." ); return false; } } else { // This hint associated with a node. trace_t tr; Vector vHintPos; GetPosition(pNPC,&vHintPos); AI_TraceLine ( pNPC->EyePosition(), vHintPos + pNPC->GetViewOffset(), MASK_NPCSOLID_BRUSHONLY, pNPC, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction != 1.0f ) { REPORTFAILURE( "Node isn't visible to NPC." ); return false; } } } } } // Check for clear if requested if ( hintCriteria.HasFlag( bits_HINT_NODE_CLEAR ) ) { if ( pNPC == NULL ) { //NOTENOTE: If you're hitting this, you've asked for a clear node without specifing an NPC! AssertMsg( 0, "Hint node attempted to find clear node without specifying NPC!\n" ); } else { trace_t tr; // Can my bounding box fit there? AI_TraceHull ( GetAbsOrigin(), GetAbsOrigin(), pNPC->WorldAlignMins(), pNPC->WorldAlignMaxs(), MASK_SOLID, pNPC, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction != 1.0 ) { REPORTFAILURE( "Node isn't clear." ); return false; } } } // See if this is our next, closest node if ( hintCriteria.HasFlag( bits_HINT_NODE_NEAREST ) ) { Assert( flNearestDistance ); // Calculate our distance float distance = (GetAbsOrigin() - position).Length(); // Must be closer than the current best if ( distance > *flNearestDistance ) { REPORTFAILURE( "Not the nearest node." ); return false; } // Remember the distance *flNearestDistance = distance; } // Must either be visible or not if requested if ( hintCriteria.HasFlag( bits_HINT_NODE_NOT_VISIBLE_TO_PLAYER|bits_HINT_NODE_VISIBLE_TO_PLAYER ) ) { bool bWasSeen = false; // Test all potential seers for ( int i = 1; i <= gpGlobals->maxClients; i++ ) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); if ( pPlayer ) { // Only spawn if the player's looking away from me Vector vLookDir = pPlayer->EyeDirection3D(); Vector vTargetDir = GetAbsOrigin() - pPlayer->EyePosition(); VectorNormalize(vTargetDir); float fDotPr = DotProduct(vLookDir,vTargetDir); if ( fDotPr > 0 ) { trace_t tr; UTIL_TraceLine( pPlayer->EyePosition(), GetAbsOrigin(), MASK_SOLID_BRUSHONLY, pPlayer, COLLISION_GROUP_NONE, &tr); if ( tr.fraction == 1.0 ) { if ( hintCriteria.HasFlag( bits_HINT_NODE_NOT_VISIBLE_TO_PLAYER ) ) { REPORTFAILURE( "Node is visible to player." ); return false; } bWasSeen = true; } } } } if ( !bWasSeen && hintCriteria.HasFlag( bits_HINT_NODE_VISIBLE_TO_PLAYER ) ) { REPORTFAILURE( "Node isn't visible to player." ); return false; } } return true; }
bool WaitForChildren::IsFinished() { return GetGroup() == nullptr || GetGroup()->GetSize() == 0; }
void CCheckBoxTreeView::EnumGroup(std::string szIndex, WTreeNode* parentNode, bool bhaveCheck ) { list<string> lsGroupID; list<string> lsEntityID; list<string>::iterator lstItem; WTreeNode *tmpNode; vector<string >::iterator iSelItor; if(!szIndex.empty()) { OBJECT group = GetGroup(szIndex); if(group != INVALID_VALUE) { /////////////////////////////////////////////////////////////////////////////////////////////////// // 删除每一个设备 /////////////////////////////////////////////////////////////////////////////////////////////////// // 删除每一个子组 if(GetSubGroupsIDByGroup(group, lsGroupID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; base_param group; for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++) { string szSubGroupID = (*lstItem).c_str(); bool bSelTree =true;// 是否增加组或者设备到树上 if(!bAdmin) { iSelItor =find(pUserTreeGroupList.begin(),pUserTreeGroupList.end(),szSubGroupID); if(iSelItor ==pUserTreeGroupList.end()) bSelTree= false; } if(bSelTree) { OBJECT objGroup = GetGroup(szSubGroupID); if(objGroup != INVALID_VALUE) { MAPNODE node = GetGroupMainAttribNode(objGroup); if(node != INVALID_VALUE) { string szName = "", szIndex = ""; //FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) szIndex = findIndexByRealID(szSubGroupID); group.szIndex = szSubGroupID; group.szName = szName; int nIndex = atoi(szIndex.c_str()); lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = group; } CloseGroup(objGroup); } } } for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { bool bTreehaveCheck=true; if(bhaveCheck) bTreehaveCheck =true; else { iSelItor =find(pUserSelGroupList.begin(),pUserSelGroupList.end(), lsItem->second.szIndex); if(iSelItor ==pUserSelGroupList.end()) bTreehaveCheck= false; } tmpNode=AddGroupTreeNode(lsItem->second.szIndex, parentNode, bTreehaveCheck); if(tmpNode!=NULL) EnumGroup(lsItem->second.szIndex, tmpNode, bTreehaveCheck); } } if(GetSubEntitysIDByGroup(group, lsEntityID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; base_param device; for(lstItem = lsEntityID.begin(); lstItem != lsEntityID.end(); lstItem ++) { string szEntityID = (*lstItem).c_str(); bool bSelTree =true;// 是否增加组或者设备到树上 if(!bAdmin) { iSelItor =find(pUserTreeGroupList.begin(),pUserTreeGroupList.end(),szEntityID); if(iSelItor ==pUserTreeGroupList.end()) bSelTree= false; } if(bSelTree) { OBJECT objDevice = GetEntity(szEntityID); if(objDevice != INVALID_VALUE) { MAPNODE node = GetEntityMainAttribNode(objDevice); if(node != INVALID_VALUE) { string szName = "", szIndex = ""; //FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) szIndex = findIndexByRealID(szEntityID); device.szIndex = szEntityID; device.szName = szName; int nIndex = atoi(szIndex.c_str()); lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { //nMax ++; nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = device; } CloseEntity(objDevice); } //AddDeviceTreeNode(szEntityID, parentNode ); } } for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) AddDeviceTreeNode(lsItem->second.szIndex, parentNode); } CloseGroup(group); } } }
int CAddrInfo::GetTriedBucket(const uint256& nKey) const { uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetKey()).GetHash().GetCheapHash(); uint64_t hash2 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup() << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP)).GetHash().GetCheapHash(); return hash2 % ADDRMAN_TRIED_BUCKET_COUNT; }
inline HexPoint Groups::CaptainOf(HexPoint point) const { return GetGroup(point).Captain(); }