View Single Post
  #2  
Old 10-19-2014, 11:54 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,603
Default

I believe the code in the source just grabs one of them, here's the code for it:
Code:
void Zone::LoadTempMerchantData() {
    LogFile->write(EQEMuLog::Status, "Loading Temporary Merchant Lists...");
    std::string query = StringFormat(
        "SELECT                                   "
        "ml.npcid,                               "
        "ml.slot,                               "
        "ml.charges,                           "
        "ml.itemid                               "
        "FROM                                   "
        "merchantlist_temp ml,                   "
        "spawnentry se,                           "
        "spawn2 s2                               "
        "WHERE                                   "
        "ml.npcid = se.npcid                   "
        "AND se.spawngroupid = s2.spawngroupid "
        "AND s2.zone = '%s' AND s2.version = %i "
        "ORDER BY ml.slot                       ", GetShortName(), GetInstanceVersion());
    auto results = database.QueryDatabase(query);
    if (!results.Success()) {
        LogFile->write(EQEMuLog::Error, "Error in LoadTempMerchantData query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
        return;
    }
    std::map<uint32, std::list<TempMerchantList> >::iterator cur;
    uint32 npcid = 0;
    for (auto row = results.begin(); row != results.end(); ++row) {
        TempMerchantList ml;
        ml.npcid = atoul(row[0]);
        if (npcid != ml.npcid){
            cur = tmpmerchanttable.find(ml.npcid);
            if (cur == tmpmerchanttable.end()) {
                std::list<TempMerchantList> empty;
                tmpmerchanttable[ml.npcid] = empty;
                cur = tmpmerchanttable.find(ml.npcid);
            }
            npcid = ml.npcid;
        }
        ml.slot = atoul(row[1]);
        ml.charges = atoul(row[2]);
        ml.item = atoul(row[3]);
        ml.origslot = ml.slot;
        cur->second.push_back(ml);
    }
    pQueuedMerchantsWorkID = 0;
}
Reply With Quote