本文整理汇总了C++中safe_delete函数的典型用法代码示例。如果您正苦于以下问题:C++ safe_delete函数的具体用法?C++ safe_delete怎么用?C++ safe_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safe_delete函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: SendLootReqErrorPacket
void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* app) {
// Added 12/08. Started compressing loot struct on live.
char tmp[10];
if(player_corpse_depop) {
SendLootReqErrorPacket(client, 0);
return;
}
if(IsPlayerCorpse() && corpse_db_id == 0) {
// SendLootReqErrorPacket(client, 0);
client->Message(13, "Warning: Corpse's dbid = 0! Corpse will not survive zone shutdown!");
std::cout << "Error: PlayerCorpse::MakeLootRequestPackets: dbid = 0!" << std::endl;
// return;
}
if(is_locked && client->Admin() < 100) {
SendLootReqErrorPacket(client, 0);
client->Message(13, "Error: Corpse locked by GM.");
return;
}
if(being_looted_by == 0)
being_looted_by = 0xFFFFFFFF;
if(this->being_looted_by != 0xFFFFFFFF) {
// lets double check....
Entity* looter = entity_list.GetID(this->being_looted_by);
if(looter == 0)
this->being_looted_by = 0xFFFFFFFF;
}
uint8 Loot_Request_Type = 1;
bool loot_coin = false;
if(database.GetVariable("LootCoin", tmp, 9))
loot_coin = (atoi(tmp) == 1);
if (this->being_looted_by != 0xFFFFFFFF && this->being_looted_by != client->GetID()) {
SendLootReqErrorPacket(client, 0);
Loot_Request_Type = 0;
}
else if (IsPlayerCorpse() && char_id == client->CharacterID()) {
Loot_Request_Type = 2;
}
else if ((IsNPCCorpse() || become_npc) && CanPlayerLoot(client->CharacterID())) {
Loot_Request_Type = 2;
}
else if (GetPlayerKillItem() == -1 && CanPlayerLoot(client->CharacterID())) { /* PVP loot all items, variable cash */
Loot_Request_Type = 3;
}
else if (GetPlayerKillItem() == 1 && CanPlayerLoot(client->CharacterID())) { /* PVP loot 1 item, variable cash */
Loot_Request_Type = 4;
}
else if (GetPlayerKillItem() > 1 && CanPlayerLoot(client->CharacterID())) { /* PVP loot 1 set item, variable cash */
Loot_Request_Type = 5;
}
if (Loot_Request_Type == 1) {
if (client->Admin() < 100 || !client->GetGM()) {
SendLootReqErrorPacket(client, 2);
}
}
if(Loot_Request_Type >= 2 || (Loot_Request_Type == 1 && client->Admin() >= 100 && client->GetGM())) {
this->being_looted_by = client->GetID();
EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoneyOnCorpse, sizeof(moneyOnCorpseStruct));
moneyOnCorpseStruct* d = (moneyOnCorpseStruct*) outapp->pBuffer;
d->response = 1;
d->unknown1 = 0x42;
d->unknown2 = 0xef;
/* Dont take the coin off if it's a gm peeking at the corpse */
if(Loot_Request_Type == 2 || (Loot_Request_Type >= 3 && loot_coin)) {
if(!IsPlayerCorpse() && client->IsGrouped() && client->AutoSplitEnabled() && client->GetGroup()) {
d->copper = 0;
d->silver = 0;
d->gold = 0;
d->platinum = 0;
Group *cgroup = client->GetGroup();
cgroup->SplitMoney(GetCopper(), GetSilver(), GetGold(), GetPlatinum(), client);
}
else {
d->copper = this->GetCopper();
d->silver = this->GetSilver();
d->gold = this->GetGold();
d->platinum = this->GetPlatinum();
client->AddMoneyToPP(GetCopper(), GetSilver(), GetGold(), GetPlatinum(), false);
}
RemoveCash();
Save();
}
auto timestamps = database.GetItemRecastTimestamps(client->CharacterID());
outapp->priority = 6;
client->QueuePacket(outapp);
safe_delete(outapp);
if(Loot_Request_Type == 5) {
int pkitem = GetPlayerKillItem();
const Item_Struct* item = database.GetItem(pkitem);
//.........这里部分代码省略.........
开发者ID:UnityEQ,项目名称:UnityEQServer,代码行数:101,代码来源:corpse.cpp
示例17: safe_delete
SMTWorker::~SMTWorker()
{
safe_delete(m_phFhSink);
safe_delete(m_BZ2Worker);
}
开发者ID:CSRedRat,项目名称:desura-app,代码行数:5,代码来源:SMTWorker.cpp
示例18: gcException
void MCF::dlHeaderFromWeb()
{
if (m_bStopped)
return;
if (m_vProviderList.size() == 0)
throw gcException(ERR_ZEROFILE);
gcException lastE;
bool successful = false;
OutBuffer out(MCF_HEADERSIZE_V2);
MCFCore::Misc::MCFServerCon msc;
for (size_t x=0; x<m_vProviderList.size(); x++)
{
try
{
msc.disconnect();
msc.connect(m_vProviderList[x]->getUrl(), m_pFileAuth);
msc.downloadRange(0, 5, &out); //4 id bytes and 1 version byte
if (out.m_uiTotalSize != 5)
throw gcException(ERR_BADHEADER, "Did not get any data from mcf server.");
const char* data = out.m_szBuffer;
if ( !(data[0] == 'L' && data[1] == 'M' && data[2] == 'C' && data[3] == 'F') )
throw gcException(ERR_BADHEADER, "Failed magic check.");
size_t headerSize = MCF_HEADERSIZE_V1;
if (data[4] == 0x01)
headerSize = MCF_HEADERSIZE_V1;
else if (data[4] == 0x02)
headerSize = MCF_HEADERSIZE_V2;
else
throw gcException(ERR_BADHEADER, "Bad version number");
out.reset();
msc.downloadRange(0, headerSize, &out);
if (out.m_uiTotalSize != headerSize)
throw gcException(ERR_BADHEADER, "Did not get correct ammount of data from server.");
MCFCore::MCFHeader webHeader((uint8*)out.m_szBuffer);
if (!webHeader.isValid())
throw gcException(ERR_BADHEADER, "Mcf header was not valid.");
uint32 ths = webHeader.getXmlSize();
out = ths;
msc.downloadRange(webHeader.getXmlStart(), webHeader.getXmlSize(), &out);
if (out.m_uiTotalSize == 0 || out.m_uiTotalSize != webHeader.getXmlSize())
throw gcException(ERR_WEBDL_FAILED, "Failed to download MCF xml from web (size is ether zero or didnt match header size)");
data = out.m_szBuffer;
if (data[0] == 'L' && data[1] == 'M' && data[2] == 'C' && data[3] == 'F')
throw gcException(ERR_WEBDL_FAILED, "Server failed 4gb seek.");
setHeader(&webHeader);
successful = true;
break;
}
catch (gcException &e)
{
lastE = e;
Warning(gcString("Failed to download MCF Header from {1}: {0}\n", e, m_vProviderList[x]->getUrl()));
}
}
if (!successful)
throw lastE;
uint32 bz2BuffLen = getHeader()->getXmlSize()*25;
char* bz2Buff = NULL;
if ( isCompressed() )
{
bz2Buff = new char[bz2BuffLen];
UTIL::STRING::zeroBuffer(bz2Buff, bz2BuffLen);
try
{
UTIL::BZIP::BZ2DBuff((char*)bz2Buff, &bz2BuffLen, out.m_szBuffer, out.m_uiTotalSize);
parseXml(bz2Buff, bz2BuffLen);
safe_delete(bz2Buff);
}
catch (gcException &)
{
safe_delete(bz2Buff);
throw;
}
}
else
//.........这里部分代码省略.........
开发者ID:Alasaad,项目名称:Desurium,代码行数:101,代码来源:MCF_Save.cpp
示例19: CastToClient
//.........这里部分代码省略.........
npc_type->race = WOLF;
npc_type->texture = 2;
break;
case IKSAR:
npc_type->race = WOLF;
npc_type->texture = 0;
npc_type->gender = 1;
npc_type->size *= 2.0f;
npc_type->luclinface = 0;
break;
default:
npc_type->race = WOLF;
npc_type->texture = 0;
}
}
// handle monster summoning pet appearance
if(record.monsterflag) {
uint32 monsterid = 0;
// get a random npc id from the spawngroups assigned to this zone
auto query = StringFormat("SELECT npcID "
"FROM (spawnentry INNER JOIN spawn2 ON spawn2.spawngroupID = spawnentry.spawngroupID) "
"INNER JOIN npc_types ON npc_types.id = spawnentry.npcID "
"WHERE spawn2.zone = '%s' AND npc_types.bodytype NOT IN (11, 33, 66, 67) "
"AND npc_types.race NOT IN (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 44, "
"55, 67, 71, 72, 73, 77, 78, 81, 90, 92, 93, 94, 106, 112, 114, 127, 128, "
"130, 139, 141, 183, 236, 237, 238, 239, 254, 266, 329, 330, 378, 379, "
"380, 381, 382, 383, 404, 522) "
"ORDER BY RAND() LIMIT 1", zone->GetShortName());
auto results = database.QueryDatabase(query);
if (!results.Success()) {
safe_delete(npc_type);
return;
}
if (results.RowCount() != 0) {
auto row = results.begin();
monsterid = atoi(row[0]);
}
// since we don't have any monsters, just make it look like an earth pet for now
if (monsterid == 0)
monsterid = 567;
// give the summoned pet the attributes of the monster we found
const NPCType* monster = database.LoadNPCTypesData(monsterid);
if(monster) {
npc_type->race = monster->race;
npc_type->size = monster->size;
npc_type->texture = monster->texture;
npc_type->gender = monster->gender;
npc_type->luclinface = monster->luclinface;
npc_type->helmtexture = monster->helmtexture;
npc_type->herosforgemodel = monster->herosforgemodel;
} else
Log.Out(Logs::General, Logs::Error, "Error loading NPC data for monster summoning pet (NPC ID %d)", monsterid);
}
//this takes ownership of the npc_type data
auto npc = new Pet(npc_type, this, (PetType)record.petcontrol, spell_id, record.petpower);
// Now that we have an actual object to interact with, load
// the base items for the pet. These are always loaded
开发者ID:Exovane,项目名称:Server,代码行数:67,代码来源:pets.cpp
示例20: safe_delete
~OutBuffer()
{
safe_delete(m_szBuffer);
}
开发者ID:Alasaad,项目名称:Desurium,代码行数:4,代码来源:MCF_Save.cpp
注:本文中的safe_delete函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论