当前位置: 首页>>代码示例>>C++>>正文


C++ safe_delete函数代码示例

本文整理汇总了C++中safe_delete函数的典型用法代码示例。如果您正苦于以下问题:C++ safe_delete函数的具体用法?C++ safe_delete怎么用?C++ safe_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了safe_delete函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: safe_delete

// deleting the auto pointer deletes what the internal pointer points to...
CMclKernelAutoPtr::~CMclKernelAutoPtr() {
    // no check needed since deleting a NULL
    // pointer is okay in C++...
    safe_delete( m_pObjectPtr ); 
}
开发者ID:KerwinMa,项目名称:AerothFlyffSource,代码行数:6,代码来源:CMclAutoPtr.cpp

示例2: GetName


//.........这里部分代码省略.........
			memset(newid, 0, sizeof(newid));
			for(int i=0;i<7;i++){
				if (!isalpha(item2->IDFile[i])){
					strn0cpy(newid, &item2->IDFile[i],6);
					i=8;
				}
			}

			emat = atoi(newid);
		} else {
			emat = item2->Material;
		}

		if (foundslot == EQEmu::legacy::SlotPrimary) {
			if (item2->Proc.Effect != 0)
				CastToMob()->AddProcToWeapon(item2->Proc.Effect, true);

			eslot = EQEmu::textures::TexturePrimary;
			if (item2->Damage > 0)
				SendAddPlayerState(PlayerState::PrimaryWeaponEquipped);
			if (item2->IsType2HWeapon())
				SetTwoHanderEquipped(true);
		}
		else if (foundslot == EQEmu::legacy::SlotSecondary
			&& (GetOwner() != nullptr || (CanThisClassDualWield() && zone->random.Roll(NPC_DW_CHANCE)) || (item2->Damage==0)) &&
			(item2->IsType1HWeapon() || item2->ItemType == EQEmu::item::ItemTypeShield))
		{
			if (item2->Proc.Effect!=0)
				CastToMob()->AddProcToWeapon(item2->Proc.Effect, true);

			eslot = EQEmu::textures::TextureSecondary;
			if (item2->Damage > 0)
				SendAddPlayerState(PlayerState::SecondaryWeaponEquipped);
		}
		else if (foundslot == EQEmu::legacy::SlotHead) {
			eslot = EQEmu::textures::TextureHead;
		}
		else if (foundslot == EQEmu::legacy::SlotChest) {
			eslot = EQEmu::textures::TextureChest;
		}
		else if (foundslot == EQEmu::legacy::SlotArms) {
			eslot = EQEmu::textures::TextureArms;
		}
		else if (foundslot == EQEmu::legacy::SlotWrist1 || foundslot == EQEmu::legacy::SlotWrist2) {
			eslot = EQEmu::textures::TextureWrist;
		}
		else if (foundslot == EQEmu::legacy::SlotHands) {
			eslot = EQEmu::textures::TextureHands;
		}
		else if (foundslot == EQEmu::legacy::SlotLegs) {
			eslot = EQEmu::textures::TextureLegs;
		}
		else if (foundslot == EQEmu::legacy::SlotFeet) {
			eslot = EQEmu::textures::TextureFeet;
		}

		/*
		what was this about???

		if (((npc->GetRace()==127) && (npc->CastToMob()->GetOwnerID()!=0)) && (item2->Slots==24576) || (item2->Slots==8192) || (item2->Slots==16384)){
			npc->d_melee_texture2=atoi(newid);
			wc->wear_slot_id=8;
			if (item2->Material >0)
				wc->material=item2->Material;
			else
				wc->material=atoi(newid);
			npc->AC+=item2->AC;
			npc->STR+=item2->STR;
			npc->INT+=item2->INT;
		}
		*/

		//if we found an open slot it goes in...
		if(eslot != 0xFF) {
			if(wearchange) {
				wc->wear_slot_id = eslot;
				wc->material = emat;
			}

		}
		if (found) {
			CalcBonuses(); // This is less than ideal for bulk adding of items
		}
		item->equip_slot = item2->Slots;
	}

	if(itemlist != nullptr)
		itemlist->push_back(item);
	else
		safe_delete(item);

	if(wearchange && outapp) {
		entity_list.QueueClients(this, outapp);
		safe_delete(outapp);
	}

	UpdateEquipmentLight();
	if (UpdateActiveLight())
		SendAppearancePacket(AT_Light, GetActiveLightType());
}
开发者ID:Exovane,项目名称:Server,代码行数:101,代码来源:loottables.cpp

示例3: safe_delete

void HGTController::fillDownloadList(bool &usingDiffs)
{
	usingDiffs = false;
	safe_delete(m_vSuperBlockList);
	MCFCore::MCF *webMcf = new MCFCore::MCF();

	try
	{
		webMcf->dlHeaderFromHttp(m_szUrl.c_str());
	}
	catch (gcException &e)
	{
		onErrorEvent(e);
		safe_delete(webMcf);
		return;
	}

	webMcf->sortFileList();

	uint64 mcfOffset = m_pHeader->getSize();
	size_t fsSize = m_rvFileList.size();

	//find the last files offset
	for (size_t x=0; x< fsSize; x++)
	{
		if (!m_rvFileList[x]->isSaved())
			continue;

		if ((m_rvFileList[x]->isComplete() || m_rvFileList[x]->hasStartedDL()) && m_rvFileList[x]->getOffSet() > mcfOffset)
		{
			mcfOffset = m_rvFileList[x]->getOffSet() + m_rvFileList[x]->getCurSize();
		}
	}

	std::deque<Misc::WGTBlock*> vBlockList;
	std::sort(m_rvFileList.begin(), m_rvFileList.end(), SortByOffset);

	for (size_t x=0; x<fsSize; x++)
	{
		//dont download all ready downloaded items
		if (m_rvFileList[x]->isComplete())
			continue;

		//skip files that arnt "saved" in the MCF
		if (!m_rvFileList[x]->isSaved())
			continue;	

		uint32 index = webMcf->findFileIndexByHash(m_rvFileList[x]->getHash());
		auto webFile = webMcf->getFile(index);

		uint64 size = m_rvFileList[x]->getCurSize();
		bool started = m_rvFileList[x]->hasStartedDL();

		if (index == UNKNOWN_ITEM || !webFile || !webFile->isSaved())
		{
			Warning(gcString("File {0} is not in web MCF. Skipping download.\n", m_rvFileList[x]->getName()));

			if (!started)
				m_rvFileList[x]->delFlag(MCFCore::MCFFileI::FLAG_SAVE);

			continue;
		}	


		if (!started)
			m_rvFileList[x]->setOffSet(mcfOffset);


		Misc::WGTBlock* temp = new Misc::WGTBlock;

		temp->fileOffset = m_rvFileList[x]->getOffSet();
		temp->file = m_rvFileList[x];

		if (webFile->hasDiff() && HasAllFlags(m_rvFileList[x]->getFlags(), MCFFileI::FLAG_CANUSEDIFF))
		{
			temp->webOffset = webFile->getDiffOffSet();
			temp->size = webFile->getDiffSize();

			if (!started)
				mcfOffset += webFile->getSize();

			usingDiffs = true;
		}
		else
		{
			m_rvFileList[x]->delFlag(MCFFileI::FLAG_CANUSEDIFF);
			temp->webOffset = webFile->getOffSet();
			temp->size = size;

			if (!started)
				mcfOffset += size;
		}

		vBlockList.push_back(temp);
		m_uiTotal += temp->size;
	}


	std::sort(vBlockList.begin(), vBlockList.end(), &WGTBlockSort);

//.........这里部分代码省略.........
开发者ID:CSRedRat,项目名称:desura-app,代码行数:101,代码来源:HGTController.cpp

示例4: memset

bool Group::DelMember(Mob* oldmember,bool ignoresender)
{
	if (oldmember == nullptr)
	{
		return false;
	}

	for (uint32 i = 0; i < MAX_GROUP_MEMBERS; i++)
	{
		if (members[i] == oldmember)
		{
			members[i] = nullptr;
			membername[i][0] = '\0';
			memset(membername[i],0,64);
			MemberRoles[i] = 0;
			Log.Out(Logs::Detail, Logs::Group, "DelMember: Removed Member: %s", oldmember->GetCleanName());
			break;
		}
	}

	if(GroupCount() < 2)
	{
		DisbandGroup();
		return true;
	}

	// If the leader has quit and we have 2 or more players left in group, we want to first check the zone the old leader was in for a new leader. 
	// If a suitable replacement cannot be found, we need to go out of zone. If checkleader remains true after this method completes, another
	// loop will be run in DelMemberOOZ.
	bool checkleader = true;
	if (strcmp(GetOldLeaderName(),oldmember->GetCleanName()) == 0 && GroupCount() >= 2)
	{
		for(uint32 nl = 0; nl < MAX_GROUP_MEMBERS; nl++)
		{
			if(members[nl]) 
			{
				if (members[nl]->IsClient())
				{
					ChangeLeader(members[nl]);
					checkleader = false;
					break;
				}
			}
		}
	}
			
	ServerPacket* pack = new ServerPacket(ServerOP_GroupLeave, sizeof(ServerGroupLeave_Struct));
	ServerGroupLeave_Struct* gl = (ServerGroupLeave_Struct*)pack->pBuffer;
	gl->gid = GetID();
	gl->zoneid = zone->GetZoneID();
	gl->instance_id = zone->GetInstanceID();
	strcpy(gl->member_name, oldmember->GetName());
	gl->checkleader = checkleader;
	worldserver.SendPacket(pack);
	safe_delete(pack);

	EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupJoin_Struct));
	GroupJoin_Struct* gu = (GroupJoin_Struct*)outapp->pBuffer;
	gu->action = groupActLeave;
	strcpy(gu->membername, oldmember->GetCleanName());
	strcpy(gu->yourname, oldmember->GetCleanName());

	for (uint32 i = 0; i < MAX_GROUP_MEMBERS; i++) {
		if (members[i] == nullptr) {
			//if (DEBUG>=5) Log.Out(Logs::Detail, Logs::Group, "Group::DelMember() null member at slot %i", i);
			continue;
		}
		if (members[i] != oldmember) {
			strcpy(gu->yourname, members[i]->GetCleanName());
			if(members[i]->IsClient())
				members[i]->CastToClient()->QueuePacket(outapp);
		}
	}

	if (!ignoresender)
	{
		strcpy(gu->yourname,oldmember->GetCleanName());
		strcpy(gu->membername,oldmember->GetCleanName());
		gu->action = groupActLeave;

		if(oldmember->IsClient())
			oldmember->CastToClient()->QueuePacket(outapp);
	}

	if(oldmember->IsClient())
	{
		database.SetGroupID(oldmember->GetCleanName(), 0, oldmember->CastToClient()->CharacterID());
	}
	
	oldmember->SetGrouped(false);
	disbandcheck = true;

	safe_delete(outapp);

	return true;
}
开发者ID:jcon321,项目名称:Server,代码行数:96,代码来源:groups.cpp

示例5: strcpy

bool Database::DBLoadDoors(uint32 iDoorCount, uint32 iMaxDoorID) {
    cout << "Loading Doors from database..." << endl;
    char errbuf[MYSQL_ERRMSG_SIZE];
    char *query = 0;
    MYSQL_RES *result;
    MYSQL_ROW row;
    query = new char[256];
    strcpy(query, "SELECT MAX(id), Count(*) FROM doors");
    if (RunQuery(query, strlen(query), errbuf, &result))
    {
        safe_delete(query);
        row = mysql_fetch_row(result);
        if (row && row[0]) {
            if (atoi(row[0]) > iMaxDoorID) {
                cout << "Error: Insufficient shared memory to load doors." << endl;
                cout << "Max(id): " << atoi(row[0]) << ", iMaxDoorID: " << iMaxDoorID << endl;
                cout << "Fix this by increasing the MMF_MAX_Door_ID define statement" << endl;
                return false;
            }
            if (atoi(row[1]) != iDoorCount) {
                cout << "Error: Insufficient shared memory to load doors." << endl;
                cout << "Count(*): " << atoi(row[1]) << ", iDoorCount: " << iDoorCount << endl;
                return false;
            }
            max_door_type = atoi(row[0]);
            mysql_free_result(result);
            Door tmpDoor;
            MakeAnyLenString(&query, "SELECT id,doorid,zone,name,pos_x,pos_y,pos_z,heading,opentype,guild,lockpick,keyitem,triggerdoor,triggertype from doors");//WHERE zone='%s'", zone_name
            if (RunQuery(query, strlen(query), errbuf, &result))
            {
                safe_delete(query);
                while((row = mysql_fetch_row(result))) {
                    memset(&tmpDoor, 0, sizeof(Door));
                    tmpDoor.db_id = atoi(row[0]);
                    tmpDoor.door_id = atoi(row[1]);
                    strn0cpy(tmpDoor.zone_name,row[2],32);
                    strn0cpy(tmpDoor.door_name,row[3],32);
                    tmpDoor.pos_x = (float)atof(row[4]);
                    tmpDoor.pos_y = (float)atof(row[5]);
                    tmpDoor.pos_z = (float)atof(row[6]);
                    tmpDoor.heading = atoi(row[7]);
                    tmpDoor.opentype = atoi(row[8]);
                    tmpDoor.guild_id = atoi(row[9]);
                    tmpDoor.lockpick = atoi(row[10]);
                    tmpDoor.keyitem = atoi(row[11]);
                    tmpDoor.trigger_door = atoi(row[12]);
                    tmpDoor.trigger_type = atoi(row[13]);
                    EMuShareMemDLL.Doors.cbAddDoor(tmpDoor.db_id, &tmpDoor);
                    Sleep(0);
                }
                mysql_free_result(result);
            }
            else
            {
                cerr << "Error in DBLoadDoors query '" << query << "' " << errbuf << endl;
                delete[] query;
                return false;
            }
        }
    }
    return true;
}
开发者ID:regneq,项目名称:projecteqemu,代码行数:62,代码来源:dbmemshare.cpp

示例6: switch


//.........这里部分代码省略.........
				entity_list.MessageClose(trigger,false,100,CC_Default,"The air shimmers...");
			}
			else
			{
				entity_list.MessageClose(trigger,false,100,CC_Default,"%s",message.c_str());
			}

			for (i = 0; i < effectvalue2; i++)
			{
				if ((tmp = database.GetNPCType(effectvalue)))
				{
					auto randomOffset = glm::vec4(zone->random.Int(-5, 5),zone->random.Int(-5, 5),zone->random.Int(-5, 5), zone->random.Int(0, 249));
					auto spawnPosition = randomOffset + glm::vec4(m_Position, 0.0f);
					NPC* new_npc = new NPC(tmp, nullptr, spawnPosition, FlyMode3);
					new_npc->AddLootTable();
					entity_list.AddNPC(new_npc);
					new_npc->AddToHateList(trigger,1);
				}
			}
			break;
		case trapTypeBanditSpawn:
			if (message.empty())
			{
				entity_list.MessageClose(trigger,false,100,CC_Default,"A bandit leaps out from behind a tree!");
			}
			else
			{
				entity_list.MessageClose(trigger,false,100,CC_Default,"%s",message.c_str());
			}

			for (i = 0; i < effectvalue2; i++)
			{
				if ((tmp = database.GetNPCType(effectvalue)))
				{
					auto randomOffset = glm::vec4(zone->random.Int(-2, 2), zone->random.Int(-2, 2), zone->random.Int(-2, 2), zone->random.Int(0, 249));
					auto spawnPosition = randomOffset + glm::vec4(m_Position, 0.0f);
					NPC* new_npc = new NPC(tmp, nullptr, spawnPosition, FlyMode3);
					new_npc->AddLootTable();
					entity_list.AddNPC(new_npc);
					new_npc->AddToHateList(trigger,1);
				}
			}
			break;
		case trapTypeDamage:
			if (message.empty())
			{
				entity_list.MessageClose(trigger,false,100,CC_Default,"%s triggers a trap!",trigger->GetName());
			}
			else
			{
				entity_list.MessageClose(trigger,false,100,CC_Default,"%s",message.c_str());
			}
			if(trigger->IsClient())
			{
				EQApplicationPacket* outapp = new EQApplicationPacket(OP_Damage, sizeof(CombatDamage_Struct));
				CombatDamage_Struct* a = (CombatDamage_Struct*)outapp->pBuffer;
				int dmg = zone->random.Int(effectvalue, effectvalue2);
				trigger->SetHP(trigger->GetHP() - dmg);
				a->damage = dmg;
				a->sequence = (float)zone->random.Int(0, 511);
				a->source = GetHiddenTrigger()!=nullptr ? GetHiddenTrigger()->GetID() : trigger->GetID();
				a->spellid = 0;
				a->target = trigger->GetID();
				a->type = 253;
				trigger->CastToClient()->QueuePacket(outapp);
				safe_delete(outapp);
			}
	}

	if(trigger && trigger->IsClient())
	{
		trigger->CastToClient()->trapid = trap_id;
		charid = trigger->CastToClient()->CharacterID();
	}

	bool update = false;
	if(despawn_when_triggered)
	{
		Log.Out(Logs::General, Logs::Traps, "Trap %d is despawning after being triggered.", trap_id);
		update = true;
	}
	else
	{
		reset_timer.Start(5000);
	}

	if(triggered_number > 0)
		++times_triggered;

	if(triggered_number > 0 && triggered_number <= times_triggered)
	{
		Log.Out(Logs::General, Logs::Traps, "Triggered number for trap %d reached. %d/%d", trap_id, times_triggered, triggered_number);
		update = true;
	}

	if(update)
	{
		UpdateTrap();
	}
}
开发者ID:jcon321,项目名称:Server,代码行数:101,代码来源:trap.cpp

示例7: to_string

void Doors::HandleClick(Client* sender, uint8 trigger)
{
    //door debugging info dump
    Log.Out(Logs::Detail, Logs::Doors, "%s clicked door %s (dbid %d, eqid %d) at %s", sender->GetName(), door_name, db_id, door_id, to_string(m_Position).c_str());
    Log.Out(Logs::Detail, Logs::Doors, "  incline %d, opentype %d, lockpick %d, key %d, nokeyring %d, trigger %d type %d, param %d", incline, opentype, lockpick, keyitem, nokeyring, trigger_door, trigger_type, door_param);
    Log.Out(Logs::Detail, Logs::Doors, "  size %d, invert %d, dest: %s %s", size, invert_state, dest_zone, to_string(m_Destination).c_str());

    EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
    MoveDoor_Struct* md = (MoveDoor_Struct*)outapp->pBuffer;
    md->doorid = door_id;
    /////////////////////////////////////////////////////////////////
    //used_pawn: Locked doors! Rogue friendly too =)
    //TODO: add check for other lockpick items
    //////////////////////////////////////////////////////////////////

    //TODO: ADVENTURE DOOR
    if(IsLDoNDoor())
    {
        if(sender)
        {
            if(RuleI(Adventure, ItemIDToEnablePorts) != 0)
            {
                if(!sender->KeyRingCheck(RuleI(Adventure, ItemIDToEnablePorts)))
                {
                    if (sender->GetInv().HasItem(RuleI(Adventure, ItemIDToEnablePorts)) == INVALID_INDEX)
                    {
                        sender->Message_StringID(13, DUNGEON_SEALED);
                        safe_delete(outapp);
                        return;
                    }
                    else
                    {
                        sender->KeyRingAdd(RuleI(Adventure, ItemIDToEnablePorts));
                    }
                }
            }

            if(!sender->GetPendingAdventureDoorClick())
            {
                sender->PendingAdventureDoorClick();
                ServerPacket *pack = new ServerPacket(ServerOP_AdventureClickDoor, sizeof(ServerPlayerClickedAdventureDoor_Struct));
                ServerPlayerClickedAdventureDoor_Struct *ads = (ServerPlayerClickedAdventureDoor_Struct*)pack->pBuffer;
                strcpy(ads->player, sender->GetName());
                ads->zone_id = zone->GetZoneID();
                ads->id = GetDoorDBID();
                worldserver.SendPacket(pack);
                safe_delete(pack);
                safe_delete(outapp);
            }
            return;
        }
    }

    uint32 keyneeded = GetKeyItem();
    uint8 keepoffkeyring = GetNoKeyring();
    uint32 haskey = 0;
    uint32 playerkey = 0;
    const ItemInst *lockpicks = sender->GetInv().GetItem(SlotCursor);

    haskey = sender->GetInv().HasItem(keyneeded, 1);

    if (haskey != INVALID_INDEX)
    {
        playerkey = keyneeded;
    }

    if(GetTriggerType() == 255)
    {   // this object isnt triggered
        if(trigger == 1)
        {   // this door is only triggered by an object
            if(!IsDoorOpen() || (opentype == 58))
            {
                md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
            }
            else
            {
                md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
            }
        }
        else
        {
            safe_delete(outapp);
            return;
        }
    }

    // guild doors
    if(((keyneeded == 0) && (GetLockpick() == 0) && (guild_id == 0)) ||
            (IsDoorOpen() && (opentype == 58)) ||
            ((guild_id > 0) && (guild_id == sender->GuildID())))
    {   //door not locked
        if(!IsDoorOpen() || (opentype == 58))
        {
            md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
        }
        else
        {
            md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
        }
    }
//.........这里部分代码省略.........
开发者ID:ngdeao,项目名称:Server-1,代码行数:101,代码来源:doors.cpp

示例8: EQApplicationPacket

void Corpse::SendEndLootErrorPacket(Client* client) {
	EQApplicationPacket* outapp = new EQApplicationPacket(OP_LootComplete, 0);
	client->QueuePacket(outapp);
	safe_delete(outapp);
}
开发者ID:UnityEQ,项目名称:UnityEQServer,代码行数:5,代码来源:corpse.cpp

示例9: Save

bool Corpse::Process() {
	if (player_corpse_depop)
		return false;

	if (corpse_delay_timer.Check()) {
		for (int i = 0; i < MAX_LOOTERS; i++)
			allowed_looters[i] = 0;
		corpse_delay_timer.Disable();
		return true;
	}

	if (corpse_graveyard_timer.Check()) {
		if (zone->HasGraveyard()) {
			Save();
			player_corpse_depop = true;
			database.SendCharacterCorpseToGraveyard(corpse_db_id, zone->graveyard_zoneid(),
				(zone->GetZoneID() == zone->graveyard_zoneid()) ? zone->GetInstanceID() : 0, zone->GetGraveyardPoint());
			corpse_graveyard_timer.Disable();
			ServerPacket* pack = new ServerPacket(ServerOP_SpawnPlayerCorpse, sizeof(SpawnPlayerCorpse_Struct));
			SpawnPlayerCorpse_Struct* spc = (SpawnPlayerCorpse_Struct*)pack->pBuffer;
			spc->player_corpse_id = corpse_db_id;
			spc->zone_id = zone->graveyard_zoneid();
			worldserver.SendPacket(pack);
			safe_delete(pack);
			Log.Out(Logs::General, Logs::None, "Moved %s player corpse to the designated graveyard in zone %s.", this->GetName(), database.GetZoneName(zone->graveyard_zoneid()));
			corpse_db_id = 0;
		}

		corpse_graveyard_timer.Disable();
		return false;
	}
	/*
	if(corpse_res_timer.Check()) {
		can_rez = false;
		corpse_res_timer.Disable();
	}
	*/

	/* This is when a corpse hits decay timer and does checks*/
	if (corpse_decay_timer.Check()) {
		/* NPC */
		if (IsNPCCorpse()){
			corpse_decay_timer.Disable();
			return false;
		}
		/* Client */
		if (!RuleB(Zone, EnableShadowrest)){
			Delete();
		}
		else {
			if (database.BuryCharacterCorpse(corpse_db_id)) {
				Save();
				player_corpse_depop = true;
				corpse_db_id = 0;
				Log.Out(Logs::General, Logs::None, "Tagged %s player corpse has buried.", this->GetName());
			}
			else {
				Log.Out(Logs::General, Logs::Error, "Unable to bury %s player corpse.", this->GetName());
				return true;
			}
		}
		corpse_decay_timer.Disable();
		return false;
	}

	return true;
}
开发者ID:UnityEQ,项目名称:UnityEQServer,代码行数:67,代码来源:corpse.cpp

示例10: SendEndLootErrorPacket


//.........这里部分代码省略.........

		char buf[88];
		char corpse_name[64];
		strcpy(corpse_name, corpse_name);
		snprintf(buf, 87, "%d %d %s", inst->GetItem()->ID, inst->GetCharges(), EntityList::RemoveNumbers(corpse_name));
		buf[87] = '\0';
		std::vector<EQEmu::Any> args;
		args.push_back(inst);
		args.push_back(this);
		parse->EventPlayer(EVENT_LOOT, client, buf, 0, &args);
		parse->EventItem(EVENT_LOOT, client, inst, this, buf, 0);

		if (!IsPlayerCorpse() && RuleB(Character, EnableDiscoveredItems)) {
			if (client && !client->GetGM() && !client->IsDiscovered(inst->GetItem()->ID))
				client->DiscoverItem(inst->GetItem()->ID);
		}

		if (zone->adv_data) {
			ServerZoneAdventureDataReply_Struct *ad = (ServerZoneAdventureDataReply_Struct*)zone->adv_data;
			if (ad->type == Adventure_Collect && !IsPlayerCorpse()) {
				if (ad->data_id == inst->GetItem()->ID) {
					zone->DoAdventureCountIncrease();
				}
			}
		}

		/* First add it to the looter - this will do the bag contents too */
		if (lootitem->auto_loot) {
			if (!client->AutoPutLootInInventory(*inst, true, true, bag_item_data))
				client->PutLootInInventory(MainCursor, *inst, bag_item_data);
		}
		else {
			client->PutLootInInventory(MainCursor, *inst, bag_item_data);
		}

		/* Update any tasks that have an activity to loot this item */
		if (RuleB(TaskSystem, EnableTaskSystem))
			client->UpdateTasksForItem(ActivityLoot, item->ID);

		/* Remove it from Corpse */
		if (item_data){
			/* Delete needs to be before RemoveItem because its deletes the pointer for item_data/bag_item_data */
			database.DeleteItemOffCharacterCorpse(this->corpse_db_id, item_data->equip_slot, item_data->item_id);
			/* Delete Item Instance */
			RemoveItem(item_data->lootslot);
		}

		/* Remove Bag Contents */
		if (item->ItemClass == ItemClassContainer && (GetPlayerKillItem() != -1 || GetPlayerKillItem() != 1)) {
			for (int i = SUB_BEGIN; i < EmuConstants::ITEM_CONTAINER_SIZE; i++) {
				if (bag_item_data[i]) {
					/* Delete needs to be before RemoveItem because its deletes the pointer for item_data/bag_item_data */
					database.DeleteItemOffCharacterCorpse(this->corpse_db_id, bag_item_data[i]->equip_slot, bag_item_data[i]->item_id);
					/* Delete Item Instance */
					RemoveItem(bag_item_data[i]);
				}
			}
		}

		if (GetPlayerKillItem() != -1) {
			SetPlayerKillItemID(0);
		}

	/* Send message with item link to groups and such */
	Client::TextLink linker;
	linker.SetLinkType(linker.linkItemInst);
	linker.SetItemInst(inst);

	auto item_link = linker.GenerateLink();

	client->Message_StringID(MT_LootMessages, LOOTED_MESSAGE, item_link.c_str());

	if (!IsPlayerCorpse()) {
			Group *g = client->GetGroup();
			if(g != nullptr) {
				g->GroupMessage_StringID(client, MT_LootMessages, OTHER_LOOTED_MESSAGE, client->GetName(), item_link.c_str());
			}
			else {
				Raid *r = client->GetRaid();
				if(r != nullptr) {
					r->RaidMessage_StringID(client, MT_LootMessages, OTHER_LOOTED_MESSAGE, client->GetName(), item_link.c_str());
				}
			}
		}
	}
	else {
		SendEndLootErrorPacket(client);
		safe_delete(inst);
		return;
	}

	if (IsPlayerCorpse()){
		client->SendItemLink(inst);
	}
	else{
		client->SendItemLink(inst, true);
	}

	safe_delete(inst);
}
开发者ID:UnityEQ,项目名称:UnityEQServer,代码行数:101,代码来源:corpse.cpp

示例11: safe_delete

void Corpse::Spawn() {
	EQApplicationPacket* app = new EQApplicationPacket;
	this->CreateSpawnPacket(app, this);
	entity_list.QueueClients(this, app);
	safe_delete(app);
}
开发者ID:UnityEQ,项目名称:UnityEQServer,代码行数:6,代码来源:corpse.cpp

示例12: safe_delete

BaseMCFThread::~BaseMCFThread()
{
	safe_delete(m_pUPThread);
}
开发者ID:anchowee,项目名称:desura-app,代码行数:4,代码来源:BaseMCFThread.cpp

示例13: OnUnload

	void Window::OnResourceUnload()
	{
		OnUnload();

		safe_delete(mLayout);
	}
开发者ID:MSoft1115,项目名称:Rad3D,代码行数:6,代码来源:MGUI_Window.cpp

示例14: OnShutdown

	virtual void OnShutdown()
	{
		safe_delete(mVideoPlayer);
	}
开发者ID:MSoft1115,项目名称:Rad3D,代码行数:4,代码来源:Demo13_Video.cpp

示例15: thread_proc

static void thread_proc(NodeFunction* pFunc, ParseInfo* pinfo, std::vector<Symbol*>* pvecSyms)
{
	// ignore return value
	Symbol *pRet = task_proc(pFunc, pinfo, pvecSyms);
	safe_delete(pRet, 0, pinfo);
}
开发者ID:t-weber,项目名称:tlibs,代码行数:6,代码来源:calls_thread.cpp


注:本文中的safe_delete函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。