- Katılım
- 8 Haz 2024
- Konular
- 85
- Mesajlar
- 526
- Online süresi
- 2ay 12g
- Reaksiyon Skoru
- 405
- Altın Konu
- 0
- Başarım Puanı
- 121
- TM Yaşı
- 1 Yıl 10 Ay 15 Gün
- MmoLira
- 3,272
- DevLira
- 189
Metin2 EP, Valorant VP dahil tüm oyun ürünlerini en uygun fiyatlarla bulabilir, Item ve Karakterlerinizi hızlıca satabilirsiniz. HEMEN TIKLA!
arat
değiştir
arat
değiştir
arat
ve for döngüsünün içine ekle
arat
değiştir
arat
değiştir
arat
değiştir
arat
değiştir
bool CShopManager::Initialize(TShopTable * table, int size)
kısmı böyle görünecek
void CShopManager:estroy()
{
TShopMap::iterator it = m_map_pkShop.begin();
while (it != m_map_pkShop.end())
{
M2_DELETE(it->second);
++it;
}
m_map_pkShop.clear();
}
değiştir
void CShopManager:estroy()
{
for (TShopMap::iterator it = m_map_pkShop.begin(); it != m_map_pkShop.end(); ++it)
{
M2_DELETE(it->second);
}
m_map_pkShop.clear();
m_map_pkShopByNPCVnum.clear(); // Ek haritaları da temizle
m_map_pkShopByPC.clear();
}
arat
LPSHOP CShopManager::Get(DWORD dwVnum)
{
TShopMap::const_iterator it = m_map_pkShop.find(dwVnum);
if (it == m_map_pkShop.end())
return NULL;
return (it->second);
}
LPSHOP CShopManager::GetByNPCVnum(DWORD dwVnum)
{
TShopMap::const_iterator it = m_map_pkShopByNPCVnum.find(dwVnum);
if (it == m_map_pkShopByNPCVnum.end())
return NULL;
return (it->second);
}
değiştir
LPSHOP CShopManager::Get(DWORD dwVnum)
{
TShopMap::const_iterator it = m_map_pkShop.find(dwVnum);
return (it != m_map_pkShop.end()) ? it->second : NULL;
}
LPSHOP CShopManager::GetByNPCVnum(DWORD dwVnum)
{
TShopMap::const_iterator it = m_map_pkShopByNPCVnum.find(dwVnum);
return (it != m_map_pkShopByNPCVnum.end()) ? it->second : NULL;
}
arat
bool CShopManager::Initialize(TShopTable * table, int size)
ve for döngüsünün içine ekle
// dup fix
if (m_map_pkShop.find(table->dwVnum) != m_map_pkShop.end())
{
sys_err("Duplicate shop Vnum %u", table->dwVnum);
M2_DELETE(shop);
continue;
}
arat
bool CompareShopItemName(const SShopItemTable& lhs, const SShopItemTable& rhs)
{
TItemTable* lItem = ITEM_MANAGER::instance().GetTable(lhs.vnum);
TItemTable* rItem = ITEM_MANAGER::instance().GetTable(rhs.vnum);
if (lItem && rItem)
return strcmp(lItem->szLocaleName, rItem->szLocaleName) < 0;
else
return true;
}
değiştir
bool CompareShopItemName(const SShopItemTable& lhs, const SShopItemTable& rhs)
{
TItemTable* lItem = ITEM_MANAGER::instance().GetTable(lhs.vnum);
TItemTable* rItem = ITEM_MANAGER::instance().GetTable(rhs.vnum);
// Eğer ikisi de null ise, eşit kabul et
if (!lItem && !rItem)
return false;
// Eğer sadece lhs null ise, rhs önce gelir
if (!lItem)
return false;
// Eğer sadece rhs null ise, lhs önce gelir
if (!rItem)
return true;
// Her ikisi de geçerliyse, isim karşılaştırması yap
return strcmp(lItem->szLocaleName, rItem->szLocaleName) < 0;
}
arat
if (pkShopEx->GetTabCount() >= SHOP_TAB_COUNT_MAX)
{
sys_err("ShopEx cannot have tab more than %d", SHOP_TAB_COUNT_MAX);
return false;
}
if (pkShopEx->GetVnum() != 0 && m_map_pkShop.find(pkShopEx->GetVnum()) != m_map_pkShop.end())
{
sys_err("Shop vnum(%d) already exist.", pkShopEx->GetVnum());
return false;
}
değiştir
if (pkShopEx->GetTabCount() >= SHOP_TAB_COUNT_MAX)
{
sys_err("ShopEx cannot have tab more than %d", SHOP_TAB_COUNT_MAX);
if (shop_it == m_map_pkShopByNPCVnum.end()) // Yeni oluşturulmuşsa
M2_DELETE(pkShopEx);
return false;
}
if (pkShopEx->GetVnum() != 0 && m_map_pkShop.find(pkShopEx->GetVnum()) != m_map_pkShop.end())
{
sys_err("Shop vnum(%d) already exist.", pkShopEx->GetVnum());
if (shop_it == m_map_pkShopByNPCVnum.end()) // Yeni oluşturulmuşsa
M2_DELETE(pkShopEx);
return false;
}
arat
FILE* fp = fopen(stFileName, "rb");
if (NULL == fp)
return true;
fclose(fp);
değiştir
FILE* fp = fopen(stFileName, "rb");
if (!fp)
return true; // Dosya yoksa hata değil
fclose(fp);
arat
std::transform(shopName.begin(), shopName.end(), shopName.begin(), (int(*)(int))std::tolower);
değiştir
std::transform(shopName.begin(), shopName.end(), shopName.begin(), ::tolower); // Daha güvenli tolower
bool CShopManager::Initialize(TShopTable * table, int size)
kısmı böyle görünecek
bool CShopManager::Initialize(TShopTable * table, int size)
{
if (!m_map_pkShop.empty())
return false;
if (!m_map_pkShopByNPCVnum.empty())
return false;
for (int i = 0; i < size; ++i, ++table)
{
LPSHOP shop = M2_NEW CShop;
if (!shop->Create(table->dwVnum, table->dwNPCVnum, table->items))
{
M2_DELETE(shop);
continue;
}
// dup fix
if (m_map_pkShop.find(table->dwVnum) != m_map_pkShop.end())
{
sys_err("Duplicate shop Vnum %u", table->dwVnum);
M2_DELETE(shop);
continue;
}
if (m_map_pkShopByNPCVnum.find(table->dwNPCVnum) != m_map_pkShopByNPCVnum.end())
{
sys_err("Duplicate NPC Vnum %u in shop table", table->dwNPCVnum);
M2_DELETE(shop);
continue;
}
m_map_pkShop.insert(TShopMap::value_type(table->dwVnum, shop));
m_map_pkShopByNPCVnum.insert(TShopMap::value_type(table->dwNPCVnum, shop));
}
char szShopTableExFileName[256];
snprintf(szShopTableExFileName, sizeof(szShopTableExFileName),
"%s/shop_table_ex.txt", LocaleService_GetBasePath().c_str());
return ReadShopTableEx(szShopTableExFileName);
}


