void ScheduledScriptsTable::reload() { #ifdef DataConnect_DEBUG std::cout << "ScheduledScriptsTable: reload" << std::endl; #endif try { Database::SelectQuery query; query.addColumn("scheduledscripts", "sc_scriptname"); query.addColumn("scheduledscripts", "sc_mincycletime"); query.addColumn("scheduledscripts", "sc_maxcycletime"); query.addColumn("scheduledscripts", "sc_functionname"); query.addServerTable("scheduledscripts"); Database::Result results = query.execute(); if (!results.empty()) { clearOldTable(); ScriptData tmpRecord; for (Database::ResultConstIterator itr = results.begin(); itr != results.end(); ++itr) { tmpRecord.minCycleTime = (uint32_t)((*itr)["sc_mincycletime"].as<uint32_t>()); tmpRecord.maxCycleTime = (uint32_t)((*itr)["sc_maxcycletime"].as<uint32_t>()); tmpRecord.nextCycleTime = 0; if (!((*itr)["sc_scriptname"].is_null()) && !((*itr)["sc_functionname"].is_null())) { tmpRecord.functionName = ((*itr)["sc_functionname"].as<std::string>()); tmpRecord.scriptName = ((*itr)["sc_scriptname"].as<std::string>()); try { boost::shared_ptr<LuaScheduledScript> tmpScript(new LuaScheduledScript(tmpRecord.scriptName)); tmpRecord.scriptptr = tmpScript; addData(tmpRecord); } catch (ScriptException &e) { Logger::writeError("scripts", "Error while loading scheduled script: " + tmpRecord.scriptName + ":\n" + e.what() + "\n"); } } } } m_dataOk = true; } catch (std::exception &e) { std::cerr << "exception: " << e.what() << std::endl; m_dataOk = false; } }
void ScheduledScriptsTable::reload() { try { Database::SelectQuery query; query.addColumn("scheduledscripts", "sc_scriptname"); query.addColumn("scheduledscripts", "sc_mincycletime"); query.addColumn("scheduledscripts", "sc_maxcycletime"); query.addColumn("scheduledscripts", "sc_functionname"); query.addServerTable("scheduledscripts"); Database::Result results = query.execute(); if (!results.empty()) { clearOldTable(); ScriptData tmpRecord; for (const auto &row : results) { tmpRecord.minCycleTime = row["sc_mincycletime"].as<uint32_t>(); tmpRecord.maxCycleTime = row["sc_maxcycletime"].as<uint32_t>(); tmpRecord.nextCycleTime = 0; if (!row["sc_scriptname"].is_null() && !row["sc_functionname"].is_null()) { tmpRecord.functionName = row["sc_functionname"].as<std::string>(); tmpRecord.scriptName = row["sc_scriptname"].as<std::string>(); try { std::shared_ptr<LuaScheduledScript> tmpScript = std::make_shared<LuaScheduledScript>(tmpRecord.scriptName); tmpRecord.scriptptr = tmpScript; addData(tmpRecord); } catch (const ScriptException &e) { Logger::error(LogFacility::Script) << "Error while loading scheduled script: " << tmpRecord.scriptName << ": " << e.what() << Log::end; } } } } m_dataOk = true; } catch (std::exception &e) { Logger::error(LogFacility::Other) << "Exception in ScheduledScriptsTable::reload: " << e.what() << Log::end; m_dataOk = false; } }
void NamesObjectTable::reload() { #ifdef DataConnect_DEBUG std::cout << "NamesObjectTable: reload" << std::endl; #endif try { Database::SelectQuery query; query.addColumn("itemname", "itn_itemid"); query.addColumn("itemname", "itn_german"); query.addColumn("itemname", "itn_english"); query.addServerTable("itemname"); Database::Result results = query.execute(); if (!results.empty()) { clearOldTable(); NamesStruct temprecord; for (Database::ResultConstIterator itr = results.begin(); itr != results.end(); ++itr) { temprecord.German = (TYPE_OF_GERMAN)((*itr)["itn_german"].as<std::string>()); temprecord.English = (TYPE_OF_ENGLISH)((*itr)["itn_english"].as<std::string>()); m_table[(TYPE_OF_ITEM_ID)((*itr)["itn_itemid"].as<int32_t>())] = temprecord; } m_dataOK = true; } else { m_dataOK = false; } #ifdef DataConnect_DEBUG std::cout << "loaded " << rows << " rows into NamesObjectTable" << std::endl; #endif } catch (...) { m_dataOK = false; } }
void ContainerObjectTable::reload() { #ifdef DataConnect_DEBUG std::cout << "ContainerObjectTable: reload" << std::endl; #endif try { Database::SelectQuery query; query.addColumn("container", "con_itemid"); query.addColumn("container", "con_volume"); query.addServerTable("container"); Database::Result results = query.execute(); if (!results.empty()) { clearOldTable(); ContainerStruct temprecord; for (Database::ResultConstIterator itr = results.begin(); itr != results.end(); ++itr) { temprecord.ContainerVolume = (TYPE_OF_VOLUME)((*itr)["con_volume"].as<int32_t>()); m_table[(TYPE_OF_ITEM_ID)((*itr)["con_itemid"].as<TYPE_OF_ITEM_ID>())] = temprecord; } m_dataOK = true; } else { m_dataOK = false; } #ifdef DataConnect_DEBUG std::cout << "loaded " << rows << " rows into ContainerObjectTable" << std::endl; #endif } catch (...) { m_dataOK = false; } }
ContainerObjectTable::~ContainerObjectTable() { clearOldTable(); }
void WeaponObjectTable::reload() { #ifdef DataConnect_DEBUG std::cout << "WeaponObjectTable: reload" << std::endl; #endif try { Database::SelectQuery query; query.addColumn("weapon", "wp_itemid"); query.addColumn("weapon", "wp_attack"); query.addColumn("weapon", "wp_defence"); query.addColumn("weapon", "wp_accuracy"); query.addColumn("weapon", "wp_range"); query.addColumn("weapon", "wp_weapontype"); query.addColumn("weapon", "wp_ammunitiontype"); query.addColumn("weapon", "wp_actionpoints"); query.addColumn("weapon", "wp_magicdisturbance"); query.addColumn("weapon", "wp_poison"); query.addColumn("weapon", "wp_fightingscript"); query.addServerTable("weapon"); Database::Result results = query.execute(); if (!results.empty()) { clearOldTable(); WeaponStruct temprecord; std::string scriptname; TYPE_OF_ITEM_ID weaponId; for (Database::ResultConstIterator itr = results.begin(); itr != results.end(); ++itr) { weaponId = (*itr)["wp_itemid"].as<TYPE_OF_ITEM_ID>(); temprecord.Attack = (TYPE_OF_ATTACK)((*itr)["wp_attack"].as<uint16_t>()); temprecord.Defence = (TYPE_OF_DEFENCE)((*itr)["wp_defence"].as<uint16_t>()); temprecord.Accuracy = (TYPE_OF_ACCURACY)((*itr)["wp_accuracy"].as<uint16_t>()); temprecord.Range = (TYPE_OF_RANGE)((*itr)["wp_range"].as<uint16_t>()); temprecord.WeaponType = (TYPE_OF_WEAPONTYPE)((*itr)["wp_weapontype"].as<uint16_t>()); temprecord.AmmunitionType = (TYPE_OF_AMMUNITIONTYPE)((*itr)["wp_ammunitiontype"].as<uint16_t>()); temprecord.ActionPoints = (TYPE_OF_ACTIONPOINTS)((*itr)["wp_actionpoints"].as<uint16_t>()); temprecord.MagicDisturbance = (TYPE_OF_MAGICDISTURBANCE)((*itr)["wp_magicdisturbance"].as<uint16_t>()); temprecord.PoisonStrength = (TYPE_OF_POISONSTRENGTH)((*itr)["wp_poison"].as<uint16_t>()); if (!(*itr)["wp_fightingscript"].is_null()) { scriptname = (*itr)["wp_fightingscript"].as<std::string>(); if (!scriptname.empty()) { try { boost::shared_ptr<LuaWeaponScript> tmpScript(new LuaWeaponScript(scriptname)); temprecord.script = tmpScript; } catch (ScriptException &e) { Logger::writeError("scripts", "Error while loading weapon script: " + scriptname + ":\n" + e.what() + "\n"); } } } m_table[weaponId] = temprecord; } m_dataOK = true; } else { m_dataOK = false; } #ifdef DataConnect_DEBUG std::cout << "loaded " << rows << " rows into WeaponObjectTable" << std::endl; #endif } catch (...) { m_dataOK = false; } }
WeaponObjectTable::~WeaponObjectTable() { clearOldTable(); }
NamesObjectTable::~NamesObjectTable() { clearOldTable(); }