<commit_before>/*
 * MinefieldAttackTask.h
 *
 *  Created on: 20/12/2012
 *      Author: victor
 */

#ifndef MINEFIELDATTACKTASK_H_
#define MINEFIELDATTACKTASK_H_

#include "engine/engine.h"
#include "server/zone/objects/creature/CreatureObject.h"
#include "server/zone/packets/tangible/UpdatePVPStatusMessage.h"
class MinefieldAttackTask : public Task {
	ManagedReference<SceneObject*> sceneObject;
	ManagedReference<CreatureObject*> player;
	//ManagedReference<WeaponObject*> mine;

public:
	MinefieldAttackTask(SceneObject* scene, CreatureObject* player) {
		sceneObject = scene;
		this->player = player;
	}

	void run() {
		Locker locker(sceneObject);

		if(sceneObject->getContainerObjectsSize() <= 0)
			return;

		DataObjectComponentReference* ref = sceneObject->getDataObjectComponent();
		if(ref == NULL){
			return;
		}

		MinefieldDataComponent* mineData = cast<MinefieldDataComponent*>(ref->get());

		if(mineData == NULL || !mineData->canExplode()){
			return;
		}

		Locker clocker(player, sceneObject);

		ManagedReference<WeaponObject*> weapon = cast<WeaponObject*>(sceneObject->getContainerObject(0));;

		if (weapon == NULL)
			return;

		PlayClientEffectLoc* explodeLoc = new PlayClientEffectLoc("clienteffect/lair_damage_heavy.cef", sceneObject->getZone()->getZoneName(), sceneObject->getPositionX(), sceneObject->getPositionZ(), sceneObject->getPositionY());
		sceneObject->broadcastMessage(explodeLoc, false);

		sceneObject->removeObject(weapon,NULL,true);

		locker.release();

		Locker clockerm(weapon, player);

		if(sceneObject->getZoneServer() != NULL){
			ManagedReference<ObjectController*> objectController = sceneObject->getZoneServer()->getObjectController();
			QueueCommand* command = objectController->getQueueCommand(String("minefieldattack").hashCode());

			if(command != NULL){
				CombatQueueCommand* combatCommand = cast<CombatQueueCommand*>(command);
				if(combatCommand != NULL){
					CombatManager::instance()->doCombatAction(sceneObject.castTo<TangibleObject*>(), weapon, player, combatCommand);
				}
			}

		}

		mineData->updateCooldown(weapon->getAttackSpeed());
		mineData->setMaxRange(weapon->getMaxRange());

		weapon->destroyObjectFromWorld(true);
		weapon->destroyObjectFromDatabase(true);


		if(sceneObject->getContainerObjectsSize() <= 0){
			TangibleObject* tano = sceneObject.castTo<TangibleObject*>();
			if(tano == NULL)
				return;

			tano->setPvpStatusBitmask(tano->getPvpStatusBitmask() | CreatureFlag::ATTACKABLE);
			UpdatePVPStatusMessage* upvpsm = new UpdatePVPStatusMessage(tano,tano->getPvpStatusBitmask());
			sceneObject->broadcastMessage(upvpsm, true, true);
		}
	}

};


#endif /* MINEFIELDATTACKTASK_H_ */<commit_msg>(unstable) [fixed] deadlock<commit_after>/*
 * MinefieldAttackTask.h
 *
 *  Created on: 20/12/2012
 *      Author: victor
 */

#ifndef MINEFIELDATTACKTASK_H_
#define MINEFIELDATTACKTASK_H_

#include "engine/engine.h"
#include "server/zone/objects/creature/CreatureObject.h"
#include "server/zone/packets/tangible/UpdatePVPStatusMessage.h"
class MinefieldAttackTask : public Task {
	ManagedReference<SceneObject*> sceneObject;
	ManagedReference<CreatureObject*> player;
	//ManagedReference<WeaponObject*> mine;

public:
	MinefieldAttackTask(SceneObject* scene, CreatureObject* player) {
		sceneObject = scene;
		this->player = player;
	}

	void run() {
		Locker locker(sceneObject);

		if(sceneObject->getContainerObjectsSize() <= 0)
			return;

		DataObjectComponentReference* ref = sceneObject->getDataObjectComponent();
		if(ref == NULL){
			return;
		}

		MinefieldDataComponent* mineData = cast<MinefieldDataComponent*>(ref->get());

		if(mineData == NULL || !mineData->canExplode()){
			return;
		}

		Locker clocker(player, sceneObject);

		ManagedReference<WeaponObject*> weapon = cast<WeaponObject*>(sceneObject->getContainerObject(0));;

		if (weapon == NULL)
			return;

		PlayClientEffectLoc* explodeLoc = new PlayClientEffectLoc("clienteffect/lair_damage_heavy.cef", sceneObject->getZone()->getZoneName(), sceneObject->getPositionX(), sceneObject->getPositionZ(), sceneObject->getPositionY());
		sceneObject->broadcastMessage(explodeLoc, false);

		sceneObject->removeObject(weapon,NULL,true);

		if(sceneObject->getZoneServer() != NULL){
			ManagedReference<ObjectController*> objectController = sceneObject->getZoneServer()->getObjectController();
			QueueCommand* command = objectController->getQueueCommand(String("minefieldattack").hashCode());

			if(command != NULL){
				CombatQueueCommand* combatCommand = cast<CombatQueueCommand*>(command);
				if(combatCommand != NULL){
					CombatManager::instance()->doCombatAction(sceneObject.castTo<TangibleObject*>(), weapon, player, combatCommand);
				}
			}

		}

		mineData->updateCooldown(weapon->getAttackSpeed());
		mineData->setMaxRange(weapon->getMaxRange());

		if(sceneObject->getContainerObjectsSize() <= 0){
			TangibleObject* tano = sceneObject.castTo<TangibleObject*>();
			if(tano == NULL)
				return;

			tano->setPvpStatusBitmask(tano->getPvpStatusBitmask() | CreatureFlag::ATTACKABLE);
			UpdatePVPStatusMessage* upvpsm = new UpdatePVPStatusMessage(tano,tano->getPvpStatusBitmask());
			sceneObject->broadcastMessage(upvpsm, true, true);
		}

		clocker.release();
		locker.release();

		Locker locker(weapon);

		weapon->destroyObjectFromWorld(true);
		weapon->destroyObjectFromDatabase(true);

	}

};


#endif /* MINEFIELDATTACKTASK_H_ */
{'fraction_non_alphanumeric': 0.13647276084949214, 'fraction_numerical': 0.004062788550323176, 'mean_word_length': 6.145118733509235, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3319414', 'n_tokens_mistral': 1886, 'n_tokens_neox': 1683, 'n_words': 248}