Prosedür ⭐ YENİ GENİE FULL NOTİCE EKLENDİ | GÖRSEL | KOD %100 | 27.04.25 ⭐

Warlord

Administrator
ACS Firma
Katılım
9 Temmuz 2025
Mesajlar
98
Reaksiyon puanı
0
Puanları
6
C++:

#include "stdafx.h"

#include "DBAgent.h"



using std::string;

using std::unique_ptr;

extern CDBAgent g_DBAgent;



#pragma region CUser::HandleGenie(Packet & pkt)

void CUser::HandleGenie(Packet & pkt)

{

uint8 command = pkt.read<uint8>();



switch (command)

{

case GenieInfoRequest:

GenieNonAttackProgress(pkt);

break;

case GenieUpdateRequest:

GenieAttackProgress(pkt);

break;

case 25:

GenieNotice(pkt);

break;

default:

//printf("Genie OpCode %u \n", command); // Hata ! Burası sürekli uyarı veriyor. Opcode 3 veriyor sürekli.

TRACE("Genie OpCode %u \n", command);

break;

}

}

#pragma endregion



void CUser::GenieNotice(Packet& pkt)

{

bool status = pkt.read<bool>();

std::string notice = "Karakteriniz Genie ile hiç bir şekilde yürüme fonksiyonu gerçekleştirmez.";

if (status) notice = "Yürüme fonksiyonu aktif edilmiştir.";

g_pMain->SendGameNotice(ChatType::GENERAL_CHAT, notice, "", false, this, false);

}



#pragma region CUser::GenieNonAttackProgress(Packet & pkt)

void CUser::GenieNonAttackProgress(Packet & pkt)

{

uint8 command = pkt.read<uint8>();



switch (command)

{

case GenieUseSpiringPotion:

GenieUseGenieSpirint(pkt);

break;

case GenieLoadOptions:

HandleGenieLoadOptions();

break;

case GenielSaveOptions:

HandleGenieSaveOptions(pkt);

break;

case GenieStartHandle:

GenieStart();

break;

case GenieStopHandle:

GenieStop();

break;

default:

TRACE("GenieNonAttackProgress Unknow Attack Handle %d\n", command);

//printf("GenieNonAttackProgress Unknow Attack Handle %d\n", command); // Hata ! Burası sürekli uyarı veriyor. - Handle 155 & 22 & 130 & 90 & 87 Uyarısı

break;

}



}

#pragma endregion



#pragma region CUser::HandleGenieLoadOptions()

void CUser::HandleGenieLoadOptions()

{

// DeaFSoft Genie seçeneklerinin yüklenmeye başlandığını bildirelim

//g_pMain->SendHelpDescription(this, "Genie Seçenekleri Yükleniyor...");



Packet result(WIZ_GENIE, uint8(GenieInfoRequest));

result << uint8(GenieLoadOptions);



for (int i = 0; i < sizeof(m_GenieOptions); i++) {

result << uint8(*(uint8*)(m_GenieOptions + i));

}



// DeaFSoft Seçenekler başarıyla gönderildi

Send(&result);



// DeaFSoft Kullanıcıya başarı mesajı gönder

//g_pMain->SendHelpDescription(this, "Genie Seçenekleri Başarıyla Yüklendi.");

}

#pragma endregion



#pragma region CUser::HandleGenieSaveOptions(Packet & pkt)

void CUser::HandleGenieSaveOptions(Packet& pkt)

{

// DeaFSoft Gelen paket uzunluğunu kontrol edelim

if (pkt.size() < sizeof(m_GenieOptions))

{

//g_pMain->SendHelpDescription(this, "Genie Seçenekleri Kaydedilemedi : Eksik Veri.");

return;

}



// DeaFSoft Genie seçeneklerini paket içeriğinden oku

for (int i = 0; i < sizeof(m_GenieOptions); i++)

{

m_GenieOptions = pkt.read<uint8>();

}



// DeaFSoft Kaydedildiğini kullanıcıya bildir

//g_pMain->SendHelpDescription(this, "Genie Seçenekleri Başarıyla Kaydedildi.");

}

#pragma endregion



#pragma region CUser::GenieAttackProgress(Packet & pkt)

void CUser::GenieAttackProgress(Packet& pkt)

{

uint8 command = pkt.read<uint8>();



// DeaFSoft Süre dolmuşsa Genie'yi durdur ve kullanıcıya haber ver

if (UNIXTIME > m_1098GenieTime)

{

g_pMain->SendHelpDescription(this, "Genie Süresi Doldu, Saldırı Durduruluyor.");

return SendGenieStop(true);

}



switch (command)

{

case GenieMove:

MoveProcess(pkt);

break;



case GenieRotate:

Rotate(pkt);

break;



case GenieMainAttack:

Attack(pkt);

break;



case GenieMagic:

CMagicProcess::MagicPacket(pkt, this);

break;



default:

// DeaFSoft Bilinmeyen komut tespit edildiğinde oyuncuya Notice gönder

TRACE("Genie Unknown Attack Handle %d\n", command);

break;

}

}

#pragma endregion



#pragma region CUser::GenieStart()

void CUser::GenieStart()

{

// DeaFSoft Premium kontrolü veya Genie süresi dolmuşsa izin verme. 27.04.2025

if ((g_pMain->pServerSetting.LootandGeniePremium && GetPremium() == 0) || UNIXTIME > m_1098GenieTime)

{

// DeaFSoft Hile koruması : Premium yoksa ya da süresi bitmişse ve Genie açmaya çalışıyorsa.

TRACE("[GENİE HACK] = Oyuncu : [ %s ] Genie Başlatmaya Çalısıyor Dc Edildi! ****** Git.\n", GetName().c_str());

g_pMain->SendHelpDescription(this, string_format("[GENİE HACK] = Oyuncu : [ %s ] İzinsiz Genie Açmaya Çalısıyor Dc Edildi! ****** Git.", GetName().c_str()));

Disconnect();

return;

}



// DeaFSoft Normal doğru Genie açılışı

Packet result(WIZ_GENIE, uint8(GenieStatusActive));

result << uint8(4) << uint16(1) << GetGenieTime();

m_bGenieStatus = true;

Send(&result);

SendGenieStart(true);



bool NoticeGenie = true;



// DeaFSoft Genie Başlıklı ve Renkli Notice Ekliyoruz. 27.04.2025

if (NoticeGenie)

{

uint32 genieTime = GetGenieTime(); // DeaFSoft Genie süresini alıyoruz.

g_pMain->SendHelpDescription(this, string_format("[GENİE AKTİF] = Genie Kalan Süresi : [ -%d ] Kaldı. Başarıyla Aktif Edildi.", genieTime));

}

}

#pragma endregion



#pragma region CUser::SendGenieStart(bool isToRegion /* = false */)

void CUser::SendGenieStart(bool isToRegion /* = false */)

{

Packet result(WIZ_GENIE, uint8(GenieInfoRequest));

result << uint8(GenieStartHandle) << uint16(1) << GetGenieTime();

Send(&result);

Packet newpkt(XSafe, uint8(0xDB));

newpkt << uint8(1);

Send(&newpkt);

Packet result2(WIZ_GENIE, uint8(GenieInfoRequest));

result2 << uint8(GenieActivated) << uint16(GetID()) << uint8(1);



if (isToRegion) SendToRegion(&result2, nullptr, GetEventRoom());

else Send(&result2);



if (m_bGenieStatus == GenieStatusInactive) GenieStop();

//SetOffCha(_choffstatus::ACTIVE, offcharactertype::genie);

}

#pragma endregion



#pragma region CUser::GenieStop()

void CUser::GenieStop()

{

if (m_bGenieStatus == GenieStatusInactive) return;



Packet newpkt(XSafe, uint8(0xDB));

newpkt << uint8(0);

Send(&newpkt);



Packet result(WIZ_GENIE, uint8(1));

result << uint8(5) << uint16(1) << GetGenieTime();

m_bGenieStatus = false;

SendGenieStop(true);

Send(&result);



{

Packet newpkt(XSafe, uint8(0xDB));

newpkt << uint8(0);

Send(&newpkt);

}



bool NoticeGenie = true;



// DeaFSoft Genie Başlıklı Notice Ekliyoruz. 27.04.2025

if (NoticeGenie)

{

// DeaFSoft Genie işlemi Durdurulurken, işlemin süresiyle ilgili bilgiyi içeren Notice ekliyoruz.

uint32 genieTime = GetGenieTime(); // DeaFSoft Genie süresini alıyoruz.

g_pMain->SendHelpDescription(this, string_format("[GENİE DURDUR] = Genie Durduruluyor. Kalan Süresi : [ -%d ] Kaldı.", genieTime)); // DeaFSoft Genie süresi, saniye cinsinden gösteriliyor.

}

}

#pragma endregion



#pragma region CUser::SendGenieStop()

void CUser::SendGenieStop(bool isToRegion /* = false */)

{

Packet result(WIZ_GENIE, uint8(GenieInfoRequest));

if (GetGenieTime() > 0)

result << uint8(GenieStopHandle) << uint16(1) << GetGenieTime();

Send(&result);

Packet newpkt(XSafe, uint8(0xDB));

newpkt << uint8(0);

Send(&newpkt);

Packet result2(WIZ_GENIE, uint8(GenieInfoRequest));

result2 << uint8(GenieActivated) << uint16(GetID()) << uint8(0);

if (isToRegion) SendToRegion(&result2, nullptr, GetEventRoom());

else Send(&result2);

//SetOffCha(_choffstatus::DEACTIVE, offcharactertype::genie);

}

#pragma endregion



#pragma region CUser::UpdateGenieTime(uint16 m_sTime)

void CUser::UpdateGenieTime(uint16 m_sTime)

{

Packet result(WIZ_GENIE, uint8(GenieInfoRequest));

result << uint8(GenieRemainingTime) << m_sTime;

Send(&result);



bool NoticeGenie = true;



// DeaFSoft Genie Süre Bittiğinde Notice Ekliyoruz. 27.04.2025

if (m_sTime == GenieStatusInactive)

{

g_pMain->SendHelpDescription(this, string_format("[GENİE SÜRE BİTTİ] = Genie Süreniz Doldu : [ -%d ], Sona Erdi.", m_sTime)); // Genie bittiğinde mesaj Eklendi.

GenieStop();

}

else

{

g_pMain->SendHelpDescription(this, string_format("[GENİE KALAN] = Kullanıcı : %s Genie Kalan Süresi : [ -%d ] Kaç Kaldı.", GetName().c_str(), m_sTime));

}

}

#pragma endregion



#pragma region CUser::GenieUseGenieSpirint()

void CUser::GenieUseGenieSpirint(Packet & pkt)

{



#if 0

if (isTrading() || isMerchanting() || isMining() || isFishing()) return;



uint32 nItemID; uint16 GenieItem;

pkt >> nItemID;



_ITEM_TABLE* ItemTable = g_pMain->GetItemPtr(nItemID);

if (ItemTable == nullptr)

return;



GenieItem = GetItemCount(nItemID);



if (!CheckExistItem(nItemID))

return;



if (nItemID != 810305000 && nItemID != 810378000 && nItemID != 900772000)

return;



if (RobItem(nItemID))

m_GenieTime = 120;



if (m_sFirstUsingGenie <= 0)

m_sFirstUsingGenie = 1;



Packet result(WIZ_GENIE, uint8(GenieUseSpiringPotion));

result << uint8(GenieUseSpiringPotion) << GetGenieTime();

Send(&result);

#endif // 0

}

#pragma endregion



#pragma region CDBAgent::UpdateGenieData(string& strCharID, CUser* pUser)

bool CDBAgent::UpdateGenieData(string& strCharID, CUser* pUser)

{

// DeaFSoft Karakter ID uyuşmazlığı

if (strCharID != pUser->GetName())

{

if (pUser != nullptr) g_pMain->SendHelpDescription(pUser, ("Genie Verisi Güncellemesi Başarısız : Yetkisiz Karakter (%s).", strCharID.c_str()));

else

printf("Genie Verisi Güncellemesi Başarısız: Yetkisiz Karakter (%s).\n", strCharID.c_str());

}



unique_ptr<OdbcCommand> dbCommand(m_GameDB->CreateCommand());

if (dbCommand.get() == nullptr)

{

if (pUser != nullptr) g_pMain->SendHelpDescription(pUser, "Genie Verisi Güncellemesi Başarısız : Veritabanı Komutu Oluşturulamadı.");

else

printf("Genie Verisi Güncellemesi Başarısız : Veritabanı Komutu Oluşturulamadı.\n");

return false;

}



// DeaFSoft Parametreleri ekle

dbCommand->AddParameter(SQL_PARAM_INPUT, strCharID.c_str(), strCharID.length());

dbCommand->AddParameter(SQL_PARAM_INPUT, pUser->GetAccountName().c_str(), pUser->GetAccountName().length());

dbCommand->AddParameter(SQL_PARAM_INPUT, (char*)pUser->m_GenieOptions, sizeof(pUser->m_GenieOptions), SQL_BINARY);



// DeaFSoft Stored procedure çağrısı

string proc = string_format(_T("{CALL UPDATE_GENIE_DATA(?,?, ?, %d,%d)}"), (uint32)pUser->m_1098GenieTime, pUser->m_sFirstUsingGenie);



if (!dbCommand->Execute(proc))

{

// DeaFSoft Hata raporu

ReportSQLError(m_GameDB->GetError());

// DeaFSoft Oyuncuya notice

if (pUser != nullptr) g_pMain->SendHelpDescription(pUser, "Genie Verisi Güncellemesi Başarısız : Sunucu Hatası.");

else

printf("Genie Verisi Güncellemesi Başarısız : Sunucu Hatası.\n");

return false;

}



return true;

}

#pragma endregion



#pragma region CDBAgent::LoadGenieData(string& strCharID, CUser* pUser)

bool CDBAgent::LoadGenieData(string& strCharID, CUser* pUser)

{

if (pUser == nullptr || strCharID != pUser->GetName())

{

// DeaFSoft Kullanıcı geçerli değil veya karakter adı uyuşmuyor

if (pUser != nullptr) g_pMain->SendHelpDescription(pUser, "Genie Verisi Yüklenemedi : Geçersiz Kullanıcı.");

else

printf("Genie Verisi Yüklenemedi : Geçersiz Kullanıcı.\n");

return false;

}



unique_ptr<OdbcCommand> dbCommand(m_GameDB->CreateCommand());

if (dbCommand.get() == nullptr)

{

// DeaFSoft Veritabanı komutu oluşturulamadı

if (pUser != nullptr) g_pMain->SendHelpDescription(pUser, "Genie Verisi Yüklenemedi : Veritabanı Bağlantı Hatası.");

else

printf("Genie Verisi Yüklenemedi : Geçersiz Kullanıcı.\n");

return false;

}



dbCommand->AddParameter(SQL_PARAM_INPUT, strCharID.c_str(), strCharID.length());

dbCommand->AddParameter(SQL_PARAM_INPUT, pUser->GetAccountName().c_str(), pUser->GetAccountName().length());



// DeaFSoft Veritabanında veriyi yüklemeye çalış

if (!dbCommand->Execute(_T("{CALL LOAD_GENIE_DATA(?,?)}")))

{

ReportSQLError(m_GameDB->GetError());

if (pUser != nullptr) g_pMain->SendHelpDescription(pUser, "Genie Verisi Yüklenemedi : Sunucu Hatası.");

else

printf("Genie Verisi Yüklenemedi : Sunucu Hatası.\n");

return false;

}



// DeaFSoft Veritabanından veri yoksa

if (!dbCommand->hasData())

{

if (pUser != nullptr) g_pMain->SendHelpDescription(pUser, "Genie Verisi Bulunamadı.");

else

printf("Genie Verisi Bulunamadı.\n");

return false;

}



// DeaFSoft Veri başarılı şekilde yüklendi

int field = 1;

uint32 genietime = 0;

dbCommand->FetchUInt32(field++, genietime);

dbCommand->FetchBinary(field++, (char*)pUser->m_GenieOptions, sizeof(pUser->m_GenieOptions));

dbCommand->FetchByte(field++, pUser->m_sFirstUsingGenie);



pUser->m_1098GenieTime = genietime;



return true;

}

#pragma endregion



#pragma region CUser::GenieExchange(uint32 itemid, uint32 time, bool newChar)

bool CUser::GenieExchange(uint32 itemid, uint32 time, bool newChar)

{

// DeaFSoft Geçersiz süre veya eşya kontrolü

if (!time || (!newChar && !itemid))

{

g_pMain->SendHelpDescription(this, "Genie Değişimi Başarısız : Geçersiz Süre Veya Eşya.");

return false;

}



// DeaFSoft Eşya kullanımı gerekiyor, varsa kontrol et ve sil

if (!newChar)

{

if (!CheckExistItem(itemid))

{

g_pMain->SendHelpDescription(this, string_format("Genie Değişimi Başarısız: Item Bulunamadı (ID: %u).", itemid));

return false;

}

if (!RobItem(itemid))

{

g_pMain->SendHelpDescription(this, string_format("Genie Değişimi Başarısız: Item Silinemedi (ID: %u).", itemid));

return false;

}

g_pMain->SendHelpDescription(this, "Eşya Başarıyla Kullanıldı. Güle Güle");

}



// DeaFSoft İlk kullanım flag'ini ayarla

if (!m_sFirstUsingGenie)

{

m_sFirstUsingGenie = 1;

g_pMain->SendHelpDescription(this, "Genie İlk Kez Kullanıldı, Bonus Süreler Aktif.");

}



// DeaFSoft Kalan sürenin hesaplanması

int remtime = int(m_1098GenieTime > UNIXTIME ? m_1098GenieTime - UNIXTIME : 0);

m_1098GenieTime = UNIXTIME + (time * HOUR) + (remtime > 0 ? remtime : 0);



// DeaFSoft Kullanıcıya yeni süre bilgisini gönder

uint32 newRemaining = GetGenieTime();

g_pMain->SendHelpDescription(this, string_format("Genie Etkinleştirildi! Kalan Süre : [ %d ] Oldunuz Tebrikler!", newRemaining));



// DeaFSoft İstemciye WIZ_GENIE paketi

if (!newChar)

{

Packet result(WIZ_GENIE, uint8(GenieUseSpiringPotion));

result << uint8(GenieUseSpiringPotion) << GetGenieTime();

Send(&result);

}



return true;

}

#pragma endregion



#pragma region CUser::CheckGenieTime()

void CUser::CheckGenieTime()

{

// DeaFSoft Genie'nin süresi dolmuşsa işlemi sonlandır

if (UNIXTIME > m_1098GenieTime)

{

g_pMain->SendHelpDescription(this, "Genie Süresi Dolmuş, Sistem Sonlandırılıyor.");

GenieStop();

}



// DeaFSoft Genie zaman bilgisini istemciye gönder

Packet result(WIZ_GENIE, uint8(GenieInfoRequest));

result << uint8(GenieRemainingTime) << GetGenieTime();

Send(&result);

}

#pragma endregion



bool CDBAgent::LoadPriestBotGenieData(string& strCharID, CUser* pUser)

{

if (pUser == nullptr

|| strCharID != pUser->GetName())

return false;



unique_ptr<OdbcCommand> dbCommand(m_GameDB->CreateCommand());

if (dbCommand.get() == nullptr)

return false;



dbCommand->AddParameter(SQL_PARAM_INPUT, strCharID.c_str(), strCharID.length());



if (!dbCommand->Execute(_T("{CALL LOAD_GENIE_DATA(?)}")))

ReportSQLError(m_GameDB->GetError());



if (!dbCommand->hasData())

return false;



CBot* pPriest = nullptr;

pPriest = g_pMain->m_MapBotList.GetData(pUser->m_bUserPriestBotID);

if (!pPriest)

return false;



int field = 1;

dbCommand->FetchUInt16(field++, pPriest->m_GenieTime);

dbCommand->FetchBinary(field++, (char*)pPriest->m_GenieOptions, sizeof(pPriest->m_GenieOptions));

dbCommand->FetchByte(field++, pPriest->m_sFirstUsingGenie);



return true;

}
 
Geri
Üst