DWORD CMySql::StopExe() { DWORD dwRetour = ERROR_SUCCESS; HANDLE hEventShutdown = NULL; char szShutdownEvent[31] = {0}; _snprintf(szShutdownEvent, sizeof(szShutdownEvent)-1, "MySQLShutdown%u", GetProcID()); CUtils::Log("MySqlSutdown event = %s", szShutdownEvent); if ((hEventShutdown=OpenEvent(EVENT_MODIFY_STATE, 0, szShutdownEvent)) != NULL) { SetEvent(hEventShutdown); CloseHandle(hEventShutdown); } else { dwRetour = GetLastError(); CUtils::Log("MySqlSutdown event open fail = %d", dwRetour); // if (dwRetour==ERROR_FILE_NOT_FOUND || ) { char szToExecute[MAX_PATH+50] = {0}; _snprintf(szToExecute, sizeof(szToExecute)-1, "%sbin\\mysqladmin.exe -u root shutdown", (LPCTSTR) m_sMySqlPath); dwRetour = WinExec(szToExecute, SW_HIDE); if (dwRetour > 31) dwRetour = ERROR_SUCCESS; } } return dwRetour; }
void NPC::SetPetState(SpellBuff_Struct *pet_buffs, int32 *items) { //restore their buffs... int i; for (i = 0; i < BUFF_COUNT; i++) { for(int z = 0; z < BUFF_COUNT; z++) { // check for duplicates if(buffs[z].spellid != SPELL_UNKNOWN && buffs[z].spellid == pet_buffs[i].spellid) { buffs[z].spellid = SPELL_UNKNOWN; pet_buffs[i].spellid = 0xFFFFFFFF; } } if (pet_buffs[i].spellid <= (int32)SPDAT_RECORDS && pet_buffs[i].spellid != 0 && pet_buffs[i].duration > 0) { if(pet_buffs[i].level == 0 || pet_buffs[i].level > 100) pet_buffs[i].level = 1; buffs[i].spellid = pet_buffs[i].spellid; buffs[i].ticsremaining = pet_buffs[i].duration; buffs[i].casterlevel = pet_buffs[i].level; buffs[i].casterid = 0; buffs[i].counters = pet_buffs[i].counters; buffs[i].numhits = spells[pet_buffs[i].spellid].numhits; } else { buffs[i].spellid = SPELL_UNKNOWN; pet_buffs[i].spellid = 0xFFFFFFFF; pet_buffs[i].slotid = 0; pet_buffs[i].level = 0; pet_buffs[i].duration = 0; pet_buffs[i].effect = 0; } } for (int j1=0; j1 < BUFF_COUNT; j1++) { if (buffs[j1].spellid <= (int32)SPDAT_RECORDS) { for (int x1=0; x1 < EFFECT_COUNT; x1++) { switch (spells[buffs[j1].spellid].effectid[x1]) { case SE_WeaponProc: // We need to reapply buff based procs // We need to do this here so suspended pets also regain their procs. if (spells[buffs[j1].spellid].base2[x1] == 0) { AddProcToWeapon(GetProcID(buffs[j1].spellid,x1), false, 100); } else { AddProcToWeapon(GetProcID(buffs[j1].spellid,x1), false, 100+spells[buffs[j1].spellid].base2[x1]); } break; case SE_Charm: case SE_Rune: case SE_NegateAttacks: case SE_Illusion: buffs[j1].spellid = SPELL_UNKNOWN; pet_buffs[j1].spellid = SPELLBOOK_UNKNOWN; pet_buffs[j1].slotid = 0; pet_buffs[j1].level = 0; pet_buffs[j1].duration = 0; pet_buffs[j1].effect = 0; x1 = EFFECT_COUNT; break; // We can't send appearance packets yet, put down at CompleteConnect } } } } UpdateRuneFlags(); //restore their equipment... for(i = 0; i < MAX_WORN_INVENTORY; i++) { if(items[i] == 0) continue; const Item_Struct* item2 = database.GetItem(items[i]); if (item2 && item2->NoDrop != 0) { //dont bother saving item charges for now, NPCs never use them //and nobody should be able to get them off the corpse..? AddLootDrop(item2, &itemlist, 0, true, true); } } }