void Spell::AddRaidTargets(uint32 i, uint32 TargetType, float r, uint32 maxtargets, bool partylimit) { Object* u = m_caster->GetMapMgr()->_GetObject(m_targets.m_unitTarget); if(u == NULL) u = m_caster; Player* p = TO< Player* >(u->GetPlayerOwner()); if(p == NULL || u_caster == NULL) return; AddTarget(i, TargetType, p); ObjectSet::iterator itr; for(itr = u->GetInRangeSetBegin(); itr != u->GetInRangeSetEnd(); itr++) { if(!(*itr)->IsUnit() || !TO_UNIT(*itr)->isAlive()) continue; //only affect players and pets if(!(*itr)->IsPlayer() && !(*itr)->IsPet()) continue; if(!p->InRaid(TO_UNIT(*itr))) continue; if(u->CalcDistance(*itr) > r) continue; AddTarget(i, TargetType, (*itr)); } }
void Action::AddTargets(Action *a) {// add copy of a.targets to action.targets for (Target *p = a->target; p != NULL; p = p->next) { Target *t = new Target(p->state); AddTarget(t); } if (a->tc == Node::contextTrans) tc = Node::contextTrans; }
extern an BGStopInline( call_handle handle, type_def *tipe ) { /******************************************************************/ // works if we're in the middle of a conditional??? label_handle lbl; inline_stack *junk; an retv; if( HaveCurrBlock == FALSE ) { EnLink( AskForNewLabel(), TRUE ); HaveCurrBlock = TRUE; } lbl = AskForNewLabel(); GenBlock( JUMP, 1 ); AddTarget( lbl, FALSE ); EnLink( lbl, TRUE ); InlineStack->tipe = tipe; FEGenProc( InlineStack->proc_sym, handle ); retv = InlineStack->addr; junk = InlineStack; InlineStack = InlineStack->next; CGFree( junk ); return( retv ); }
void CSpammer::UpdateLoadIn(float frameTime) { const int currentAmmoCount = GetAmmoCount(); const bool infiniteAmmo = (GetClipSize() < 0); if ((!infiniteAmmo) && (m_numLoadedRockets >= currentAmmoCount)) { GetWeapon()->PlayAction(GetFragmentIds().empty_clip); StopFire(); return; } const SSpammerParams& params = GetShared()->spammerParams; const float loadInTime = 1.0f / (params.loadInRate / 60.0f); m_timer -= frameTime; while (m_timer < 0.0f && m_numLoadedRockets < params.maxNumRockets) { m_timer += loadInTime; AddTarget(); GetWeapon()->PlayAction(GetFragmentIds().c**k); } if (m_numLoadedRockets != m_targetsAssigned.GetNumLockOns()) { EntityId nextTarget = GetNextLockOnTarget(); if (nextTarget != 0) m_targetsAssigned.LockOn(nextTarget); } }
void CReactorTool::OnAddTarget () { if (!GetMine ()) return; int segnum, sidenum; UpdateData (TRUE); sscanf (m_szTarget, "%d,%d", &segnum, &sidenum); if ((segnum < 0) || (segnum >= m_mine->SegCount ()) || (sidenum < 1) || (sidenum > 6)) return; AddTarget (segnum, sidenum); }
WidgetStyle::WidgetStyle(const TiXmlNode* node) { const TiXmlElement* asElement = node->ToElement(); if (asElement) { } std::vector<std::string> statesInXML; const char* widgetName = node->ToElement()->Value(); AddTarget(widgetName); for (const TiXmlNode* stateDefinition = node->FirstChild(); stateDefinition; stateDefinition = stateDefinition->NextSibling()) { if (!stateDefinition->FirstChild()) continue; std::string stateName = stateDefinition->ToElement()->Value(); statesInXML.push_back(stateName); NamedProperties widgetAttributes = ExtractWidgetAttributesFromStateDefinition(stateDefinition); if (stateName != "All") { UIState state = WidgetBase::GetStateForName(stateName); AddProperty(state, widgetAttributes); } else { AddGeneralProperty(widgetAttributes); } } /* if (node) { const char* updateEventToFire = node->ToElement()->Attribute("OnUpdate"); const char* renderEventToFire = node->ToElement()->Attribute("OnRender"); const char* clickEventToFire = node->ToElement()->Attribute("OnClick"); NamedProperties eventNP; if (updateEventToFire) { eventNP.Set("update event", std::string(updateEventToFire)); } if (renderEventToFire) { eventNP.Set("render event", std::string(renderEventToFire)); } if (clickEventToFire) { eventNP.Set("click event", std::string(clickEventToFire)); } if (!eventNP.GetPropertyMap().empty()) AddGeneralProperty(eventNP); } */ }
static an FlowOut( an node, type_def *tipe ) { /**************************************************/ name *temp; label_handle lbl; lbl = AskForNewLabel(); temp = BGGlobalTemp( tipe ); AddIns( MakeMove( AllocIntConst( FETrue() ), temp, temp->n.type_class ) ); *(node->u.b.t) = CurrBlock->label; GenBlock( BLK_JUMP, 1 ); AddTarget( lbl, false ); EnLink( AskForNewLabel(), true ); AddIns( MakeMove( AllocIntConst( 0 ), temp, temp->n.type_class ) ); *(node->u.b.f) = CurrBlock->label; GenBlock( BLK_JUMP, 1 ); AddTarget( lbl, false ); EnLink( lbl, true ); NamesCrossBlocks(); AddrFree( node ); return( AddrName( temp, tipe ) ); }
void Spell::AddAOETargets(uint32 i, uint32 TargetType, float r, uint32 maxtargets) { LocationVector source; //cant do raid/party stuff here, seperate functions for it if(TargetType & (SPELL_TARGET_AREA_PARTY | SPELL_TARGET_AREA_RAID) && !(p_caster == NULL && !m_caster->IsPet() && (!m_caster->IsCreature() || !m_caster->IsTotem()))) return; Object* tarobj = m_caster->GetMapMgr()->_GetObject(m_targets.m_unitTarget); if(TargetType & SPELL_TARGET_AREA_SELF) source = m_caster->GetPosition(); else if(TargetType & SPELL_TARGET_AREA_CURTARGET && tarobj != NULL) source = tarobj->GetPosition(); else { m_targets.m_targetMask |= TARGET_FLAG_DEST_LOCATION; source.x = m_targets.m_destX; source.y = m_targets.m_destY; source.z = m_targets.m_destZ; } //caster might be in the aoe LOL if(m_caster->CalcDistance(source) <= r) AddTarget(i, TargetType, m_caster); TargetsList* t = &m_targetUnits[i]; for(ObjectSet::iterator itr = m_caster->GetInRangeSetBegin(); itr != m_caster->GetInRangeSetEnd(); ++itr) { if(maxtargets != 0 && t->size() >= maxtargets) break; float dist = (*itr)->CalcDistance(source); if(dist <= r) AddTarget(i, TargetType, (*itr)); } }
nsresult nsRelUtils::AddTargetFromContent(PRUint32 aRelationType, nsIAccessibleRelation **aRelation, nsIContent *aContent) { if (!aContent) return NS_OK_NO_RELATION_TARGET; nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aContent)); nsCOMPtr<nsIAccessible> accessible; GetAccService()->GetAccessibleFor(node, getter_AddRefs(accessible)); return AddTarget(aRelationType, aRelation, accessible); }
void ObservableHandler::_handleAddObserver( BMessage* message) { #if DEBUG BLooper* l = Looper(); ASSERT(l); ASSERT(l->IsLocked()); #endif BMessage reply; BMessenger observer; status_t err = message->FindMessenger( "observer", &observer); if(err < B_OK) { PRINT(( "* ObservableHandler::_handleAddObserver(): no observer specified!\n")); // send reply? +++++ return; } if(m_released) { // already quitting reply.what = M_BAD_TARGET; reply.AddMessenger("target", BMessenger(this)); reply.AddMessenger("observer", observer); message->SendReply(&reply); return; } else if(IndexOfTarget(observer.Target(0)) != -1) { // observer already added reply.what = M_BAD_OBSERVER; reply.AddMessenger("target", BMessenger(this)); reply.AddMessenger("observer", observer); message->SendReply(&reply); return; } // valid observer given // add it err = AddTarget(observer.Target(0)); ASSERT(err == B_OK); // call hook observerAdded(observer); }
bool plCubicRenderTargetModifier::MsgReceive( plMessage* msg ) { plEvalMsg* eval = plEvalMsg::ConvertNoRef(msg); if (eval) { const double secs = eval->DSeconds(); const float del = eval->DelSeconds(); IEval(secs, del, 0); return true; } plRefMsg* refMsg = plRefMsg::ConvertNoRef(msg); if (refMsg) { plSceneObject* scene = plSceneObject::ConvertNoRef(refMsg->GetRef()); if (scene) { if (refMsg->GetContext() & (plRefMsg::kOnCreate | plRefMsg::kOnRequest | plRefMsg::kOnReplace)) AddTarget(scene); else RemoveTarget(scene); } plCubicRenderTarget* cubic = plCubicRenderTarget::ConvertNoRef(refMsg->GetRef()); if (cubic) { if (refMsg->GetContext() & (plRefMsg::kOnCreate | plRefMsg::kOnRequest | plRefMsg::kOnReplace)) { fCubic = cubic; for (int i = 0; i < 6; i++) ICreateRenderRequest(i); } else { fCubic = nullptr; for (int i = 0; i < 6; i++) { delete fRequests[i]; fRequests[i] = nullptr; } } } return true; } return plModifier::MsgReceive(msg); }
void Spell::AddConeTargets(uint32 i, uint32 TargetType, float r, uint32 maxtargets) { TargetsList* list = &m_targetUnits[i]; ObjectSet::iterator itr; for(itr = m_caster->GetInRangeSetBegin(); itr != m_caster->GetInRangeSetEnd(); itr++) { if(!((*itr)->IsUnit()) || !TO_UNIT((*itr))->isAlive()) continue; //is Creature in range if(m_caster->isInRange(TO_UNIT(*itr), GetRadius(i))) { if(m_spellInfo->cone_width ? m_caster->isInArc(TO_UNIT(*itr), m_spellInfo->cone_width) : m_caster->isInFront(TO_UNIT(*itr))) // !!! is the target within our cone ? { AddTarget(i, TargetType, (*itr)); } } if(maxtargets != 0 && list->size() >= maxtargets) return; } }
void ObservableLooper::_handleAddObserver( BMessage* message) { BMessage reply; BMessenger observer; status_t err = message->FindMessenger( "observer", &observer); if(err < B_OK) { PRINT(( "* ObservableLooper::_handleAddObserver(): no observer specified!\n")); // send reply? +++++ return; } // at this point, a reply of some sort will be sent reply.AddMessenger("target", BMessenger(this)); reply.AddMessenger("observer", observer); if(m_quitting) { // already quitting reply.what = M_BAD_TARGET; } else if(IndexOfTarget(observer.Target(0)) != -1) { // observer already added reply.what = M_BAD_OBSERVER; } else { // add it err = AddTarget(observer.Target(0)); ASSERT(err == B_OK); reply.what = M_OBSERVER_ADDED; } // send reply message->SendReply(&reply); // call hook observerAdded(observer); }
void AAIAirForceManager::CheckBombTarget(int unit_id, int def_id) { // dont continue if target list already full if(num_of_targets >= cfg->MAX_AIR_TARGETS) return; // do not add own units or units that ar already on target list if(my_team != cb->GetUnitTeam(unit_id) && !IsTarget(unit_id)) { float3 pos = cb->GetUnitPos(unit_id); // calculate in which sector unit is located int x = pos.x/map->xSectorSize; int y = pos.z/map->ySectorSize; // check if unit is within the map if(x >= 0 && x < map->xSectors && y >= 0 && y < map->ySectors) { AddTarget(unit_id, def_id); } } }
void Spell::AddScriptedOrSpellFocusTargets(uint32 i, uint32 TargetType, float r, uint32 maxtargets) { for(ObjectSet::iterator itr = m_caster->GetInRangeSetBegin(); itr != m_caster->GetInRangeSetEnd(); ++itr) { Object* o = *itr; if(!o->IsGameObject()) continue; GameObject* go = TO_GAMEOBJECT(o); if(go->GetInfo()->TypeSpellFocus.FocusId == m_spellInfo->RequiresSpellFocus) { if(!m_caster->isInRange(go, r)) continue; bool success = AddTarget(i, TargetType, go); if(success) return; } } }
void Spell::AddScriptedOrSpellFocusTargets(uint32 i, uint32 TargetType, float r, uint32 maxtargets) { for (std::set< Object* >::iterator itr = m_caster->GetInRangeSetBegin(); itr != m_caster->GetInRangeSetEnd(); ++itr) { Object* o = *itr; if (!o->IsGameObject()) continue; GameObject* go = static_cast<GameObject*>(o); if (go->GetInfo()->parameter_0 == m_spellInfo->RequiresSpellFocus) { if (!m_caster->isInRange(go, r)) continue; bool success = AddTarget(i, TargetType, go); if (success) return; } } }
/// Fill the target map with the targets /// the targets are specified with numbers and handled accordingly void Spell::FillTargetMap(uint32 i) { if(!m_caster->IsInWorld()) return; uint32 TargetType = SPELL_TARGET_NONE; // Get our info from A regardless of nullity TargetType |= GetTargetType(m_spellInfo->EffectImplicitTargetA[i], i); //never get info from B if it is 0 :P if(m_spellInfo->EffectImplicitTargetB[i] != 0) TargetType |= GetTargetType(m_spellInfo->EffectImplicitTargetB[i], i); if(TargetType & SPELL_TARGET_NOT_IMPLEMENTED) return; if(TargetType & SPELL_TARGET_NO_OBJECT) //summon spells that appear infront of caster { HandleTargetNoObject(); return; } //always add this guy :P if(!(TargetType & (SPELL_TARGET_AREA | SPELL_TARGET_AREA_SELF | SPELL_TARGET_AREA_CURTARGET | SPELL_TARGET_AREA_CONE | SPELL_TARGET_OBJECT_SELF | SPELL_TARGET_OBJECT_PETOWNER))) { Object* target = m_caster->GetMapMgr()->_GetObject(m_targets.m_unitTarget); AddTarget(i, TargetType, target); } if(TargetType & SPELL_TARGET_OBJECT_SELF) AddTarget(i, TargetType, m_caster); if(TargetType & (SPELL_TARGET_AREA | SPELL_TARGET_AREA_SELF)) //targetted aoe AddAOETargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); if (TargetType & SPELL_TARGET_OBJECT_CURTOTEMS && u_caster != NULL) { std::vector<Creature*> m_totemList; u_caster->FillSummonList(m_totemList, SUMMON_TYPE_TOTEM); for(std::vector<Creature*>::iterator itr = m_totemList.begin(); itr != m_totemList.end(); itr++) AddTarget(i, TargetType, *itr); } if(TargetType & SPELL_TARGET_OBJECT_CURPET && p_caster != NULL) AddTarget(i, TargetType, p_caster->GetSummon()); if(TargetType & SPELL_TARGET_OBJECT_PETOWNER) { uint64 guid = m_targets.m_unitTarget; if(GUID_HIPART(guid) == HIGHGUID_TYPE_PET) { Pet* p = m_caster->GetMapMgr()->GetPet(GUID_LOPART(guid)); if(p != NULL) AddTarget(i, TargetType, p->GetPetOwner()); } } //targets party, not raid if((TargetType & SPELL_TARGET_AREA_PARTY) && !(TargetType & SPELL_TARGET_AREA_RAID)) { if(p_caster == NULL && !m_caster->IsPet() && (!m_caster->IsCreature() || !m_caster->IsTotem())) AddAOETargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //npcs else AddPartyTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //players/pets/totems } if(TargetType & SPELL_TARGET_AREA_RAID) { if(p_caster == NULL && !m_caster->IsPet() && (!m_caster->IsCreature() || !m_caster->IsTotem())) AddAOETargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //npcs else AddRaidTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets, (TargetType & SPELL_TARGET_AREA_PARTY) ? true : false); //players/pets/totems } if(TargetType & SPELL_TARGET_AREA_CHAIN) AddChainTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //target cone if(TargetType & SPELL_TARGET_AREA_CONE) AddConeTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); if(TargetType & SPELL_TARGET_OBJECT_SCRIPTED) AddScriptedOrSpellFocusTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); }
int main(int argc, char ** argv) { int result = 0; AwaServerSession * session = NULL; AwaServerExecuteOperation * operation = NULL; struct gengetopt_args_info ai; if (cmdline_parser(argc, argv, &ai) != 0) { result = 1; goto cleanup; } g_logLevel = ai.debug_given ? 2 : (ai.verbose_given ? 1 : 0); AwaLog_SetLevel(ai.debug_given ? AwaLogLevel_Debug : (ai.verbose_given ? AwaLogLevel_Verbose : AwaLogLevel_Warning)); if (ai.inputs_num == 0) { Error("Specify one or more resource paths.\n"); result = 1; goto cleanup; } // Create Session session = Server_EstablishSession(ai.ipcAddress_arg, ai.ipcPort_arg); if (session == NULL) { Error("EstablishSession failed\n"); result = 1; goto cleanup; } operation = AwaServerExecuteOperation_New(session); if (operation == NULL) { Error("AwaServerExecuteOperation_New failed\n"); result = 1; goto cleanup; } AwaExecuteArguments arguments = { .Data = NULL, .Size = 0 }; if (ai.stdin_given) { char buf[BUFSIZ]; int numBytes = 0; while (fread(buf+numBytes, 1, 1, stdin) == 1) { numBytes++; } arguments.Data = buf; arguments.Size = numBytes; Verbose("Read payload from stdin: %s [%zu bytes]\n", buf, arguments.Size); } else { Verbose("No payload specified.\n"); } int i = 0; for (i = 0; i < ai.inputs_num; ++i) { Target * target = CreateTarget(ai.inputs[i]); if (target != NULL) { AddTarget(operation, ai.clientID_arg, target, &arguments); FreeTarget(&target); } } result = ProcessExecuteOperation(session, operation, ai.clientID_arg); cleanup: if (session) { Server_ReleaseSession(&session); } if (operation) { AwaServerExecuteOperation_Free(&operation); } cmdline_parser_free(&ai); return result; }
NS_IMETHODIMP nsClipboard::SetData(nsITransferable *aTransferable, nsIClipboardOwner *aOwner, PRInt32 aWhichClipboard) { // See if we can short cut if ((aWhichClipboard == kGlobalClipboard && aTransferable == mGlobalTransferable.get() && aOwner == mGlobalOwner.get()) || (aWhichClipboard == kSelectionClipboard && aTransferable == mSelectionTransferable.get() && aOwner == mSelectionOwner.get())) { return NS_OK; } // Clear out the clipboard in order to set the new data EmptyClipboard(aWhichClipboard); if (aWhichClipboard == kSelectionClipboard) { mSelectionOwner = aOwner; mSelectionTransferable = aTransferable; } else { mGlobalOwner = aOwner; mGlobalTransferable = aTransferable; } // Which selection are we about to claim, CLIPBOARD or PRIMARY? GdkAtom selectionAtom = GetSelectionAtom(aWhichClipboard); // Make ourselves the owner. If we fail to, return. if (!gtk_selection_owner_set(mWidget, selectionAtom, GDK_CURRENT_TIME)) return NS_ERROR_FAILURE; // Clear the old selection target list. gtk_selection_clear_targets(mWidget, selectionAtom); // Get the types of supported flavors nsresult rv; nsCOMPtr<nsISupportsArray> flavors; rv = aTransferable->FlavorsTransferableCanExport(getter_AddRefs(flavors)); if (!flavors || NS_FAILED(rv)) return NS_ERROR_FAILURE; // Add all the flavors to this widget's supported type. PRUint32 count; flavors->Count(&count); for (PRUint32 i=0; i < count; i++) { nsCOMPtr<nsISupports> tastesLike; flavors->GetElementAt(i, getter_AddRefs(tastesLike)); nsCOMPtr<nsISupportsCString> flavor = do_QueryInterface(tastesLike); if (flavor) { nsXPIDLCString flavorStr; flavor->ToString(getter_Copies(flavorStr)); // special case text/unicode since we can handle all of // the string types if (!strcmp(flavorStr, kUnicodeMime)) { AddTarget(gdk_atom_intern("UTF8_STRING", FALSE), selectionAtom); AddTarget(gdk_atom_intern("COMPOUND_TEXT", FALSE), selectionAtom); AddTarget(gdk_atom_intern("TEXT", FALSE), selectionAtom); AddTarget(GDK_SELECTION_TYPE_STRING, selectionAtom); // next loop iteration continue; } // Add this to our list of valid targets GdkAtom atom = gdk_atom_intern(flavorStr, FALSE); AddTarget(atom, selectionAtom); } } return NS_OK; }
void Spell::FillTargetMap(uint32 i) { //Spell::prepare() has already a m_caster->IsInWorld() check so if now the caster is no more in world something bad happened. ARCEMU_ASSERT(m_caster->IsInWorld()); uint32 TargetType = 0; TargetType |= GetTargetType(m_spellInfo->EffectImplicitTargetA[i], i); //never get info from B if it is 0 :P if(m_spellInfo->EffectImplicitTargetB[i] != 0) TargetType |= GetTargetType(m_spellInfo->EffectImplicitTargetB[i], i); if(TargetType & SPELL_TARGET_NOT_IMPLEMENTED) return; if(TargetType & SPELL_TARGET_NO_OBJECT) //summon spells that appear infront of caster { HandleTargetNoObject(); return; } //always add this guy :P if(!(TargetType & (SPELL_TARGET_AREA | SPELL_TARGET_AREA_SELF | SPELL_TARGET_AREA_CURTARGET | SPELL_TARGET_AREA_CONE | SPELL_TARGET_OBJECT_SELF | SPELL_TARGET_OBJECT_PETOWNER))) { Object* target = m_caster->GetMapMgr()->_GetObject(m_targets.m_unitTarget); AddTarget(i, TargetType, target); } if(TargetType & SPELL_TARGET_OBJECT_SELF) AddTarget(i, TargetType, m_caster); if(TargetType & (SPELL_TARGET_AREA | SPELL_TARGET_AREA_SELF)) //targetted aoe AddAOETargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //TODO: arcemu, doesn't support summon slots? /*if (TargetType & SPELL_TARGET_OBJECT_CURTOTEMS && u_caster != NULL) for (uint32 i=1; i<5; ++i) //totem slots are 1, 2, 3, 4 AddTarget(i, TargetType, u_caster->m_summonslot[i]);*/ if(TargetType & SPELL_TARGET_OBJECT_CURPET && p_caster != NULL) AddTarget(i, TargetType, p_caster->GetSummon()); if(TargetType & SPELL_TARGET_OBJECT_PETOWNER) { uint64 guid = m_targets.m_unitTarget; if(GET_TYPE_FROM_GUID(guid) == HIGHGUID_TYPE_PET) { Pet* p = m_caster->GetMapMgr()->GetPet(GET_LOWGUID_PART(guid)); if(p != NULL) AddTarget(i, TargetType, p->GetPetOwner()); } } //targets party, not raid if((TargetType & SPELL_TARGET_AREA_PARTY) && !(TargetType & SPELL_TARGET_AREA_RAID)) { if(p_caster == NULL && !m_caster->IsPet() && (!m_caster->IsCreature() || !m_caster->IsTotem())) AddAOETargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //npcs else AddPartyTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //players/pets/totems } if(TargetType & SPELL_TARGET_AREA_RAID) { if(p_caster == NULL && !m_caster->IsPet() && (!m_caster->IsCreature() || !m_caster->IsTotem())) AddAOETargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //npcs else AddRaidTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets, (TargetType & SPELL_TARGET_AREA_PARTY) ? true : false); //players/pets/totems } if(TargetType & SPELL_TARGET_AREA_CHAIN) AddChainTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //target cone if(TargetType & SPELL_TARGET_AREA_CONE) AddConeTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); if(TargetType & SPELL_TARGET_OBJECT_SCRIPTED) AddScriptedOrSpellFocusTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); }
int main(int argc, char ** argv) { int result = 0; struct gengetopt_args_info ai; AwaClientSession * session = NULL; AwaClientDeleteOperation * operation = NULL; if (cmdline_parser(argc, argv, &ai) != 0) { exit(1); } g_logLevel = ai.debug_given ? 2 : (ai.verbose_given ? 1 : 0); AwaLog_SetLevel(ai.debug_given ? AwaLogLevel_Debug : (ai.verbose_given ? AwaLogLevel_Verbose : AwaLogLevel_Warning)); if (ai.inputs_num == 0) { printf("Specify one or more resource paths.\n"); result = 1; goto cleanup; } session = Client_EstablishSession(ai.ipcAddress_arg, ai.ipcPort_arg); if (session != NULL) { // Create delete operation operation = AwaClientDeleteOperation_New(session); if (operation == NULL) { Error("AwaClientDeleteOperation_New failed\n"); result = 1; goto cleanup; } int i = 0; for (i = 0; i < ai.inputs_num; ++i) { Target * target = CreateTarget(ai.inputs[i]); if (target != NULL) { AddTarget(operation, target); FreeTarget(&target); } } } else { Error("Failed to establish Awa Session\n"); result = 1; goto cleanup; } result = ProcessDeleteOperation(operation); cleanup: if (session != NULL) { Client_ReleaseSession(&session); } cmdline_parser_free(&ai); return result; }
int CCBServer::HandleRegistration(int cmd,Stream *stream) { ReliSock *sock = (ReliSock *)stream; ASSERT( cmd == CCB_REGISTER ); // Avoid lengthy blocking on communication with our peer. // This command-handler should not get called until data // is ready to read. sock->timeout(1); ClassAd msg; sock->decode(); if( !msg.initFromStream( *sock ) || !sock->end_of_message() ) { dprintf(D_ALWAYS, "CCB: failed to receive registration " "from %s.\n", sock->peer_description() ); return FALSE; } SetSmallBuffers(sock); MyString name; if( msg.LookupString(ATTR_NAME,name) ) { // target daemon name is purely for debugging purposes name.formatstr_cat(" on %s",sock->peer_description()); sock->set_peer_description(name.Value()); } CCBTarget *target = new CCBTarget(sock); MyString reconnect_cookie_str,reconnect_ccbid_str; CCBID reconnect_cookie,reconnect_ccbid; bool reconnected = false; if( msg.LookupString(ATTR_CLAIM_ID,reconnect_cookie_str) && CCBIDFromString(reconnect_cookie,reconnect_cookie_str.Value()) && msg.LookupString( ATTR_CCBID,reconnect_ccbid_str) && CCBIDFromContactString(reconnect_ccbid,reconnect_ccbid_str.Value()) ) { target->setCCBID( reconnect_ccbid ); reconnected = ReconnectTarget( target, reconnect_cookie ); } if( !reconnected ) { AddTarget( target ); } CCBReconnectInfo *reconnect_info = GetReconnectInfo( target->getCCBID() ); ASSERT( reconnect_info ); sock->encode(); ClassAd reply_msg; MyString ccb_contact; CCBIDToString( reconnect_info->getReconnectCookie(),reconnect_cookie_str ); // We send our address as part of the CCB contact string, rather // than letting the target daemon fill it in. This is to give us // potential flexibility on the CCB server side to do things like // assign different targets to different CCB server sub-processes, // each with their own command port. CCBIDToContactString( m_address.Value(), target->getCCBID(), ccb_contact ); reply_msg.Assign(ATTR_CCBID,ccb_contact.Value()); reply_msg.Assign(ATTR_COMMAND,CCB_REGISTER); reply_msg.Assign(ATTR_CLAIM_ID,reconnect_cookie_str.Value()); if( !reply_msg.put( *sock ) || !sock->end_of_message() ) { dprintf(D_ALWAYS, "CCB: failed to send registration response " "to %s.\n", sock->peer_description() ); RemoveTarget( target ); return KEEP_STREAM; // we have already closed this socket } return KEEP_STREAM; }
void Spell::AddChainTargets(uint32 i, uint32 TargetType, float r, uint32 maxtargets) { if(!m_caster->IsInWorld()) return; Object* targ = m_caster->GetMapMgr()->_GetObject(m_targets.m_unitTarget); if(targ == NULL) return; TargetsList* list = &m_targetUnits[i]; //if selected target is party member, then jumps on party Unit* firstTarget = NULL; if(targ->IsUnit()) firstTarget = TO_UNIT(targ); else firstTarget = u_caster; bool RaidOnly = false; float range = GetMaxRange(dbcSpellRange.LookupEntry(m_spellInfo->rangeIndex));//this is probably wrong, //this is cast distance, not searching distance range *= range; //is this party only? Player* casterFrom = TO< Player* >(u_caster->GetPlayerOwner()); Player* pfirstTargetFrom = TO< Player* >(firstTarget->GetPlayerOwner()); if(casterFrom != NULL && pfirstTargetFrom != NULL && casterFrom->GetGroup() == pfirstTargetFrom->GetGroup()) RaidOnly = true; uint32 jumps = m_spellInfo->EffectChainTarget[i]; //range range /= jumps; //hacky, needs better implementation! if(m_spellInfo->SpellGroupType && u_caster != NULL) SM_FIValue(u_caster->SM_FAdditionalTargets, (int32*)&jumps, m_spellInfo->SpellGroupType); AddTarget(i, TargetType, firstTarget); if(jumps <= 1 || list->size() == 0) //1 because we've added the first target, 0 size if spell is resisted return; ObjectSet::iterator itr; for(itr = firstTarget->GetInRangeSetBegin(); itr != firstTarget->GetInRangeSetEnd(); itr++) { if(!(*itr)->IsUnit() || !TO_UNIT((*itr))->isAlive()) continue; if(RaidOnly && !pfirstTargetFrom->InRaid(TO_UNIT(*itr))) continue; //healing spell, full health target = NONO if(IsHealingSpell(m_spellInfo) && TO_UNIT(*itr)->GetHealthPct() == 100) continue; size_t oldsize; if(IsInrange(firstTarget->GetPositionX(), firstTarget->GetPositionY(), firstTarget->GetPositionZ(), (*itr), range)) { oldsize = list->size(); AddTarget(i, TargetType, (*itr)); if(list->size() == oldsize || list->size() >= jumps) //either out of jumps or a resist return; } } }
void mhmakefileparser::LoadAutoDepsFile(fileinfo *pDepFile) { if (m_AutoDepFileLoaded && m_AutoDepFileLoaded==pDepFile) return; /* This autodep file is already loaded. */ m_AutoDepFileLoaded=pDepFile; FILE *pIn=fopen(pDepFile->GetFullFileName().c_str(),"rb"); if (!pIn) { cerr << "Error opening autodep file "<<pDepFile->GetQuotedFullFileName()<<endl; return; } if (1!=fread(&m_EnvMd5_32,sizeof(m_EnvMd5_32),1,pIn)) { cerr << "Wrong format of autodep file "<<pDepFile->GetQuotedFullFileName()<<endl; fclose(pIn); return; } #ifdef _DEBUG if (g_PrintAdditionalInfo) cout << "Reading Env Md5 from "<<pDepFile->GetQuotedFullFileName()<<": "<<hex<<m_EnvMd5_32<<endl; #endif char UsedEnvVars[1024]; ReadStr(pIn,UsedEnvVars); SetVariable(USED_ENVVARS,UsedEnvVars); char FileName[MAX_PATH]; ReadStr(pIn,FileName); while (FileName[0]) { fileinfo *pTarget=GetFileInfo(FileName,m_MakeDir); autodeps_entry_t &Autodeps=m_AutoDeps[pTarget]; ReadStr(pIn,FileName); while (FileName[0]) { if (!g_ForceAutoDepRescan) /* If we are forcing the autodepscan we do not have to load the dependencies. */ { fileinfo *pDep=GetFileInfo(FileName,m_MakeDir); Autodeps.second.insert(pDep); pTarget->AddDep(pDep); } ReadStr(pIn,FileName); } ReadStr(pIn,FileName); } uint32 Md5_32; bool MakeNotDirty=true; while (fread(&Md5_32,sizeof(Md5_32),1,pIn)) { ReadStr(pIn,FileName); fileinfo *pTarget=GetAbsFileInfo(FileName); if (!pTarget->CompareMd5_32(0) && !pTarget->CompareMd5_32(Md5_32)) { MakeNotDirty=false; /* BuildTarget had set the dirty flag, but since the md5 did not change it was a false dirty. This is for BuildTargets called before this routine */ #ifdef _DEBUG cout << "Warning: trying to set to different md5's for Target "<<pTarget->GetQuotedFullFileName()<<" Old: "<<hex<<pTarget->GetCommandsMd5_32()<<" New: "<<Md5_32<<endl; #endif } #ifdef _DEBUG if (g_PrintAdditionalInfo) cout << "Setting Md5 for Target "<<pTarget->GetQuotedFullFileName()<<" to "<<hex<<Md5_32<<endl; #endif pTarget->SetCommandsMd5_32(Md5_32); // If it was already there, just update the md5 value AddTarget(pTarget); } if (MakeNotDirty) ClearAutoDepsDirty(); fclose(pIn); }
// MSGRECEIVE // receive trigger messages bool plAGMasterMod::MsgReceive(plMessage* msg) { plSDLNotificationMsg* nMsg = plSDLNotificationMsg::ConvertNoRef(msg); if (nMsg) { // Force a single eval plgDispatch::Dispatch()->RegisterForExactType(plEvalMsg::Index(), GetKey()); return true; } plAnimCmdMsg* cmdMsg = plAnimCmdMsg::ConvertNoRef(msg); if (cmdMsg) { plString targetName = cmdMsg->GetAnimName(); if (targetName.IsNull()) targetName = ENTIRE_ANIMATION_NAME; plAGAnimInstance *inst = FindAnimInstance(targetName); if (inst != nil) { if (cmdMsg->CmdChangesAnimTime()) { for (int i = 0; i < GetNumAnimations(); i++) { plAGAnimInstance *currInst = GetAnimInstance(i); if (currInst != inst && currInst->GetAnimation()->SharesPinsWith(inst->GetAnimation())) currInst->SetBlend(0); } inst->SetBlend(1); } inst->HandleCmd(cmdMsg); } return true; } plAGCmdMsg* agMsg = plAGCmdMsg::ConvertNoRef(msg); if (agMsg) { if (agMsg->Cmd(plAGCmdMsg::kSetAnimTime)) { for (int i = 0; i < fAnimInstances.size(); i++) { plAGAnimInstance *inst = fAnimInstances[i]; inst->SetCurrentTime(agMsg->fAnimTime, true); } return true; } plAGAnimInstance *inst = FindAnimInstance(agMsg->GetAnimName()); if (inst != nil) { if (agMsg->Cmd(plAGCmdMsg::kSetBlend)) inst->Fade(agMsg->fBlend, agMsg->fBlendRate, plAGAnimInstance::kFadeBlend); if (agMsg->Cmd(plAGCmdMsg::kSetAmp)) inst->Fade(agMsg->fAmp, agMsg->fAmpRate, plAGAnimInstance::kFadeAmp); } return true; } plAGInstanceCallbackMsg *agicMsg = plAGInstanceCallbackMsg::ConvertNoRef(msg); if (agicMsg) { if (agicMsg->fEvent == kStart) { IRegForEval(true); } else if (agicMsg->fEvent == kStop) { if (!HasRunningAnims()) IRegForEval(false); } else // Just force a single eval { plgDispatch::Dispatch()->RegisterForExactType(plEvalMsg::Index(), GetKey()); } return true; } plAGDetachCallbackMsg *detachMsg = plAGDetachCallbackMsg::ConvertNoRef(msg); if (detachMsg) { DetachAnimation(detachMsg->GetAnimName()); } plGenRefMsg *genRefMsg = plGenRefMsg::ConvertNoRef(msg); if (genRefMsg) { plAGAnim *anim = plAGAnim::ConvertNoRef(genRefMsg->GetRef()); if (anim) { if (genRefMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest)) { if (genRefMsg->fType == kPrivateAnim) fPrivateAnims.push_back(anim); } else { if (genRefMsg->fType == kPrivateAnim) { plAnimVector::iterator i = fPrivateAnims.begin(); for ( ; i != fPrivateAnims.end(); i++) { plAGAnim *currAnim = *i; if(currAnim == anim) { i = fPrivateAnims.erase(i); break; } } } } return true; } plAGModifier *agmod = plAGModifier::ConvertNoRef(genRefMsg->GetRef()); if (agmod) { if (genRefMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest)) fChannelMods[agmod->GetChannelName()] = agmod; else fChannelMods.erase(agmod->GetChannelName()); return true; } plMsgForwarder *msgfwd = plMsgForwarder::ConvertNoRef(genRefMsg->GetRef()); if (msgfwd) { if (genRefMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest)) fMsgForwarder = msgfwd; else fMsgForwarder = nil; return true; } } plRefMsg* refMsg = plRefMsg::ConvertNoRef(msg); if (refMsg) { if( refMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest|plRefMsg::kOnReplace) ) AddTarget(plSceneObject::ConvertNoRef(refMsg->GetRef())); else RemoveTarget(plSceneObject::ConvertNoRef(refMsg->GetRef())); return true; } return plModifier::MsgReceive(msg); }
GoalMapTarget::GoalMapTarget ( AiMain *ai, const MapPointData &target, const GOAL_TYPE &type ) : ArmyGoal(ai, 1000000, target) { BOOL ASSERT_MAP_TARGET_INVALID = 0; Init(); what_goal = type; switch (what_goal) { case GOAL_TYPE_PILLAGE: case GOAL_TYPE_PIRATE: case GOAL_TYPE_COUNTER_STEALTH: the_class = MILITARY_GOAL_CLASS; break; case GOAL_TYPE_BONUS_FOOD: the_class = BONUS_FOOD_GOAL_CLASS; break; case GOAL_TYPE_CHOKEPOINT: the_class = PROTECT_GOAL_CLASS; break; case GOAL_TYPE_WANDER: the_class = DEFAULT_GOAL_CLASS; break; case GOAL_TYPE_TRANSPORT: the_class = TRANSPORT_HACK_GOAL_CLASS; break; case GOAL_TYPE_PROBE_WORMHOLE: the_class = WORMHOLE_PROBE_GOAL_CLASS; break; case GOAL_TYPE_GOODY_HUT: the_class = EXPLORE_GOAL_CLASS; break; default: Assert(ASSERT_MAP_TARGET_INVALID); } if (what_goal == GOAL_TYPE_WANDER || what_goal == GOAL_TYPE_TRANSPORT) removal_time = REMOVE_WHEN_FULFILLED; else removal_time = REMOVE_WHEN_SORTED; m_ai = ai; AddTarget(target); ai->m_world->GetMoveType((MapPointData*) &target, &m_moveType); ai->m_planner->Add_Goal(this); #ifdef _DEBUG { MapPointData pos = target; sint32 player_id; uint32 a_id; sint32 top_unit_type; sint32 unit_num; uint32 c_id; BOOL unitVis; BOOL cityVis; BOOL mineVis; sint32 GOAL_hey_theres_is_an_army_here=0; BOOL can_be_expelled; ai->m_world->GetCellContents(&pos, &player_id, &a_id, &top_unit_type, &unit_num, &c_id, &unitVis, &cityVis, &mineVis, &can_be_expelled); if ((a_id != 0) && !can_be_expelled) { if (ai->m_my_player_id != player_id) { Assert(GOAL_hey_theres_is_an_army_here); ai->m_world->GetCellContents(&pos, &player_id, &a_id, &top_unit_type, &unit_num, &c_id, &unitVis, &cityVis, &mineVis, &can_be_expelled); } } else if (c_id != 0) { if (ai->m_my_player_id != player_id) { Assert(GOAL_hey_theres_is_an_army_here); ai->m_world->GetCellContents(&pos, &player_id, &a_id, &top_unit_type, &unit_num, &c_id, &unitVis, &cityVis, &mineVis, &can_be_expelled); } } } #endif _DEBUG sint32 id = this->GetID(); Assert(id != UNASSIGNED_ID); if (what_goal != GOAL_TYPE_WANDER) ai->m_planner->the_strategic_map->SetAreaGoal(target,what_goal,this); else ai->m_wanderGoalTargets->InsertFlat(this); }