示例#1
0
MANGOS_DLL_EXPORT
void InitScriptLibrary()
{
    // ScriptDev2 startup
    outstring_log("");
    outstring_log(" MMM  MMM    MM");
    outstring_log("M  MM M  M  M  M");
    outstring_log("MM    M   M   M");
    outstring_log(" MMM  M   M  M");
    outstring_log("   MM M   M MMMM");
    outstring_log("MM  M M  M ");
    outstring_log(" MMM  MMM  http://www.scriptdev2.com");
    outstring_log("");

    // Get configuration file
    if (!SD2Config.SetSource(_SCRIPTDEV2_CONFIG))
        error_log("SD2: Unable to open configuration file. Database will be unaccessible. Configuration values will use default.");
    else
        outstring_log("SD2: Using configuration file %s",_SCRIPTDEV2_CONFIG);

    // Check config file version
    if (SD2Config.GetIntDefault("ConfVersion", 0) != SD2_CONF_VERSION)
        error_log("SD2: Configuration file version doesn't match expected version. Some config variables may be wrong or missing.");

    outstring_log("");

    // Load database (must be called after SD2Config.SetSource).
    LoadDatabase();

    outstring_log("SD2: Loading C++ scripts");
    barGoLink bar(1);
    bar.step();
    outstring_log("");

    // Resize script ids to needed ammount of assigned ScriptNames (from core)
    m_scripts.resize(GetScriptIdsCount(), NULL);

    m_scriptStorage.clear();

    FillSpellSummary();

    AddScripts();

    // Check existance scripts for all registered by core script names
    for (uint32 i = 1; i < GetScriptIdsCount(); ++i)
    {
        if (!m_scripts[i])
            error_log("SD2: No script found for ScriptName '%s'.", GetScriptName(i));
    }

    outstring_log(">> Loaded %i C++ Scripts.", num_sc_scripts);
}
示例#2
0
void SystemMgr::LoadScriptWaypoints()
{
    // Drop Existing Waypoint list
    m_mPointMoveMap.clear();

    uint64 uiCreatureCount = 0;

    // Load Waypoints
    QueryResult_AutoPtr Result = WorldDatabase.PQuery("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry");
    if (Result)
        uiCreatureCount = Result->GetRowCount();

    outstring_log("DSCR: Loading Script Waypoints for %u creature(s)...", uiCreatureCount);

    Result = WorldDatabase.PQuery("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid");

    if (Result)
    {
        //barGoLink bar(Result->GetRowCount());
        uint32 uiNodeCount = 0;

        do
        {
             
            Field* pFields = Result->Fetch();
            ScriptPointMove pTemp;

            pTemp.uiCreatureEntry   = pFields[0].GetUInt32();
            uint32 uiEntry          = pTemp.uiCreatureEntry;
            pTemp.uiPointId         = pFields[1].GetUInt32();
            pTemp.fX                = pFields[2].GetFloat();
            pTemp.fY                = pFields[3].GetFloat();
            pTemp.fZ                = pFields[4].GetFloat();
            pTemp.uiWaitTime        = pFields[5].GetUInt32();

            CreatureInfo const* pCInfo = GetCreatureTemplateStore(pTemp.uiCreatureEntry);

            if (!pCInfo)
            {
                error_db_log("DSCR: DB table script_waypoint has waypoint for non-existant creature entry %u", pTemp.uiCreatureEntry);
                continue;
            }

            if (!pCInfo->ScriptID)
                error_db_log("DSCR: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", pTemp.uiCreatureEntry);

            m_mPointMoveMap[uiEntry].push_back(pTemp);
            ++uiNodeCount;
        } while (Result->NextRow());

        outstring_log("");
        outstring_log(">> Loaded %u Script Waypoint nodes.", uiNodeCount);
    }
    else
    {
        
         
        outstring_log("");
        outstring_log(">> Loaded 0 Script Waypoints. DB table `script_waypoint` is empty.");
    }
}
示例#3
0
void SystemMgr::LoadScriptTexts()
{
    outstring_log("DSCR: Loading Script Texts...");
    LoadDiamondStrings(WorldDatabase,"script_texts",TEXT_SOURCE_RANGE,1+(TEXT_SOURCE_RANGE*2));

    QueryResult_AutoPtr Result = WorldDatabase.PQuery("SELECT entry, sound, type, language, emote FROM script_texts");

    outstring_log("DSCR: Loading Script Texts additional data...");

    if (Result)
    {
        //barGoLink bar(Result->GetRowCount());
        uint32 uiCount = 0;

        do
        {
             
            Field* pFields = Result->Fetch();
            StringTextData pTemp;

            int32 iId           = pFields[0].GetInt32();
            pTemp.uiSoundId     = pFields[1].GetUInt32();
            pTemp.uiType        = pFields[2].GetUInt32();
            pTemp.uiLanguage    = pFields[3].GetUInt32();
            pTemp.uiEmote       = pFields[4].GetUInt32();

            if (iId >= 0)
            {
                error_db_log("DSCR: Entry %i in table `script_texts` is not a negative value.", iId);
                continue;
            }

            if (iId > TEXT_SOURCE_RANGE || iId <= TEXT_SOURCE_RANGE*2)
            {
                error_db_log("DSCR: Entry %i in table `script_texts` is out of accepted entry range for table.", iId);
                continue;
            }

            if (pTemp.uiSoundId)
            {
                if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId))
                    error_db_log("DSCR: Entry %i in table `script_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId);
            }

            if (!GetLanguageDescByID(pTemp.uiLanguage))
                error_db_log("DSCR: Entry %i in table `script_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage);

            if (pTemp.uiType > CHAT_TYPE_ZONE_YELL)
                error_db_log("DSCR: Entry %i in table `script_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType);

            m_mTextDataMap[iId] = pTemp;
            ++uiCount;
        } while (Result->NextRow());

        outstring_log("");
        outstring_log(">> Loaded %u additional Script Texts data.", uiCount);
    }
    else
    {
        
         
        outstring_log("");
        outstring_log(">> Loaded 0 additional Script Texts data. DB table `script_texts` is empty.");
    }
}
示例#4
0
void LoadNpcTele(void)
{
    const char *Table[] =
    {
        "custom_npc_tele_category",
        "custom_npc_tele_destination",
        "custom_npc_tele_association",
    };


    QueryResult_AutoPtr result = WorldDatabase.PQuery(
        "SELECT `flag`, `data0`, `data1`, `cat_id`, C.`name` `namecat`, D.`name` `namedest`, "
        //      0        1        2        3                  4                   5
               "`pos_X`, `pos_Y`, `pos_Z`, `orientation`, `map`, `level`, `cost` "
        //      6        7        8        9              10     11       12
        "FROM `%s` C, `%s` D, `%s` A "
        "WHERE C.`id` = `cat_id` AND D.`id` = `dest_id` "
        "ORDER BY `namecat`, `cat_id`, `namedest`", Table[0], Table[1], Table[2]);

    nsNpcTel::TabCatDest.clear();

    if (result)
    {
        outstring_log("TSCR: Loading %s, %s and %s...", Table[0], Table[1], Table[2]);
        barGoLink bar(result->GetRowCount());

        uint32 catid = 0;
        uint32 nbDest = 0;
        bool IsValidCat = true;
        bool FirstTime = true;

        do
        {
            bar.step();
            Field *fields = result->Fetch();

            if (!IsValidCat && catid == fields[3].GetUInt32() && !FirstTime)
                continue;

            IsValidCat = true;
            FirstTime = false;

            if (!nsNpcTel::IsValidData(fields[3].GetUInt32(), (nsNpcTel::Flag)fields[0].GetUInt8(),
                                       fields[1].GetUInt64(), fields[2].GetUInt32()))
            {
                IsValidCat = false;
                catid = fields[3].GetUInt32();
                continue;
            }

            if (catid != fields[3].GetUInt32())
            {
                catid = fields[3].GetUInt32();
                nsNpcTel::CatDest categorie (catid, fields[4].GetCppString(), (nsNpcTel::Flag)fields[0].GetUInt8(),
                                             fields[1].GetUInt64(), fields[2].GetUInt32());
                nsNpcTel::TabCatDest.push_back(categorie);
            }

            nsNpcTel::Dest item =
            {
                fields[5].GetCppString(),   // Name
                fields[6].GetFloat(),       // X
                fields[7].GetFloat(),       // Y
                fields[8].GetFloat(),       // Z
                fields[9].GetFloat(),       // Orientation
                fields[10].GetUInt16(),     // Map
                fields[11].GetUInt8(),      // Level
                fields[12].GetUInt32(),     // Cost
            };

            nsNpcTel::TabCatDest.back().AddDest(item);
            ++nbDest;
        } while (result->NextRow());

        outstring_log("");
        outstring_log("TSCR: >> Loaded %u npc_teleport.", nbDest);
    } else outstring_log("TSCR: WARNING >> Loaded 0 npc_teleport.");
}
示例#5
0
void LoadDatabase(void)
{
    // Verification integrite des donnees de la DB
    QueryResult * pResult = SD2Database.PQuery(
    "  SELECT 0 NumRel, T.Entry Entry"
    "  FROM sd2p_object_tele_relation0 T, sd2p_object_tele_definition D "
    "  WHERE T.Entry = D.Entry "
    "    AND relation_id <> 0 "
    "UNION "
    "  SELECT 1 NumRel, T.Entry Entry"
    "  FROM sd2p_object_tele_relation1 T, sd2p_object_tele_definition D "
    "  WHERE T.Entry = D.Entry "
    "    AND relation_id <> 1 "
    "ORDER BY NumRel, Entry");

    if (pResult)
    {
        outstring_log("½Å±¾¿â£º ERREUR >> %u objects incorrectement configures...", pResult->GetRowCount());
        do
        {
            Field * pFields = pResult->Fetch();
            outstring_log("\tIdObject : %u (Relation invalide : %u)",
                          pFields[0].GetUInt32(), pFields[1].GetUInt8());
        } while (pResult->NextRow());

        delete pResult;
    }

    // Recuperation des donnees de la DB
    pResult = SD2Database.PQuery(
    "  SELECT relation_id, flag, Data0, Data1, T.Entry Entry, DestId "
    "  FROM sd2p_object_tele_definition D, sd2p_object_tele_relation0 T "
    "  WHERE D.Entry = T.Entry "
    "    AND relation_id = 0 "
    "UNION "
    "  SELECT relation_id, flag, Data0, Data1, T.Entry Entry, DestId "
    "  FROM sd2p_object_tele_definition D, sd2p_object_tele_relation1 T "
    "  WHERE D.Entry = T.Entry "
    "    AND relation_id = 1 "
    "ORDER BY relation_id, Entry, flag, Data0 DESC ");
    MDefObject.clear();

    if (pResult)
    {
        outstring_log( "SD2P: Chargement \"sd2p_object_tele_definition\" et \"sd2p_object_tele_relation0\"...");
        barGoLink Bar(pResult->GetRowCount());

        uint32 IdObject = 0;
        uint32 NbDest = 0;
        DefinitionObject * pLastDefIt;

        do
        {
            Bar.step();
            Field * pFields = pResult->Fetch();

            if (!GetDestination(pFields[5].GetUInt32()))
            {
                outstring_log("SD2P >> Destination introuvable (DestID: %u).", pFields[0].GetUInt32());
                continue;
            }

            if (!IsValidData(pFields[4].GetUInt32(), (Relation)pFields[0].GetUInt8(),
                             pFields[1].GetUInt32(), pFields[2].GetUInt64(), pFields[3].GetUInt32()))
                continue;

            if (IdObject != pFields[4].GetUInt32())
            {
                IdObject = pFields[4].GetUInt32();
                DefinitionObject DefIt(IdObject, (Relation)pFields[0].GetUInt8(), pFields[1].GetUInt8());
                pLastDefIt = &MDefObject.insert(MDefObject_t::value_type(IdObject, DefIt)).first->second;
            }

            DestObjectTele Dest =
            {
                pFields[5].GetUInt32(),      // DestId
                pFields[2].GetUInt64(),      // Data0
                pFields[3].GetUInt32(),      // Data1
            };

            pLastDefIt->AddDest(Dest);
            ++NbDest;
        } while (pResult->NextRow());

        delete pResult;
        outstring_log("");
        outstring_log(">> %u object_teleport charge(s).", NbDest);
    } else outstring_log("ATTENTION >> 0 object_teleport charge.");
}
示例#6
0
文件: ScriptMgr.cpp 项目: cbcs/ChgSD2
MANGOS_DLL_EXPORT
void InitScriptLibrary()
{
    //ScriptDev2 startup
    outstring_log("");
    outstring_log("===========================================================================");
    outstring_log("          P   R   O   J   E   C   T - The ChgMangos Project by Chglove     ");
    outstring_log("                     Wish everyone can enjoy my work!                      ");
	outstring_log("ChgMangos v1.3.0 beta                                                      ");
	outstring_log("Mangos 11304,SD2 2016, ChgMangosDB v1.3.0 with ACID 3.0.8 full             ");
	outstring_log("===========================================================================");

    //Get configuration file
    if (!SD2Config.SetSource(_SCRIPTDEV2_CONFIG))
        error_log("脚本库: 打开配置文件失败,系统将使用默认配置! ");
    else
        outstring_log("脚本库: 使用配置文件 %s",_SCRIPTDEV2_CONFIG);

    //Check config file version
    if (SD2Config.GetIntDefault("ConfVersion", 0) != SD2_CONF_VERSION)
        error_log("脚本库: 配置文件版本不正确,可能过期了?一些功能将无法使用或不正常。 ");

    outstring_log("");

    //Load database (must be called after SD2Config.SetSource).
    LoadDatabase();

    outstring_log("脚本库: 加载C++脚本数据 ");
    barGoLink bar(1);
    bar.step();
    outstring_log("");

    for(int i=0; i<MAX_SCRIPTS; ++i)
        m_scripts[i]=NULL;

    m_scriptStorage.clear();

    FillSpellSummary();

    AddScripts();
	SD2P_NAMESPACE::LoadScripts();

    outstring_log(">> 加载了 %i 个脚本数据", num_sc_scripts);
}
示例#7
0
void SendDefaultMenu_Pnj_depart(Player* player, Creature* pCreature, uint32 uiAction)
{
	if (player->isInCombat())
    {
        player->CLOSE_GOSSIP_MENU();
        pCreature->MonsterSay(IN_COMBAT, LANG_UNIVERSAL, NULL);
	    return;
    }  

	Config SD2Config;
    if (!SD2Config.SetSource(_SCRIPTDEV2_CONFIG))
        error_log("SD2: Unable to open configuration file. Database will be unaccessible. Configuration values will use default.");
    else
        outstring_log("SD2: Using configuration file %s",_SCRIPTDEV2_CONFIG);
    if (SD2Config.GetIntDefault("ConfVersion", 0) != SD2_CONF_VERSION)
        error_log("SD2: Configuration file version doesn't match expected version. Some config variables may be wrong or missing.");
    
    switch(uiAction)
    { 
		    case 1003:
            player->CLOSE_GOSSIP_MENU();
			pCreature->MonsterWhisper(GOODBYE_PLAYER, player);
		    break;

	        case 1005:
            player->SetLevel(70);
            player->resetTalents(true);
            player->InitStatsForLevel(true);
            player->SaveToDB();

            wait(1);

			for (uint32 i = 0; i <LIMITE_COMP_ARME; i++)
            player->learnSpell(comp_arme[i],false);

			player->UpdateSkillsToMaxSkillsForLevel(); 
			player->SetTaxiCheater(true);

            wait(1);

			if(player->getClass() == 4)
			{			
			   for (uint32 i = 0; i <LIMITE_ROGUE; i++)
               player->learnSpell(rogue_sort[i],false);
			}

            if(player->getClass() == 1)
			{ 
			   for (uint32 i = 0; i <LIMITE_WARRIOR; i++)
               player->learnSpell(warrior_sort[i],false);
			}
            
            if(player->getClass() == 2)
			{ 
			   for (uint32 i = 0; i <LIMITE_PALADIN; i++)
               player->learnSpell(paladin_sort[i],false);
			}

			if(player->getClass() == 3)
			{ 
			   for (uint32 i = 0; i <LIMITE_HUNTER; i++)
               player->learnSpell(hunter_sort[i],false);
			}

            if(player->getClass() == 5)
			{ 
			   for (uint32 i = 0; i <LIMITE_PRIEST; i++)
               player->learnSpell(priest_sort[i],false);
			}

			if(player->getClass() == 7)
			{ 
			   for (uint32 i = 0; i <LIMITE_SHAMAN; i++)
               player->learnSpell(shaman_sort[i],false);
			}
            
			if(player->getClass() == 8)
			{ 
			   for (uint32 i = 0; i <LIMITE_MAGE; i++)
               player->learnSpell(mage_sort[i],false);
			}

			if(player->getClass() == 9)
			{ 
			   for (uint32 i = 0; i <LIMITE_WARLOCK; i++)
               player->learnSpell(warlock_sort[i],false);
			}

            if(player->getClass() == 11)
			{ 
			   for (uint32 i = 0; i <LIMITE_DRUID; i++)
               player->learnSpell(druid_sort[i],false);
			}

			wait(1);

			if (player->GetTeam() == ALLIANCE )
			{
			   player->TeleportTo(0, -8960.14f, 516.266f, 96.3568f, 0.0f);
			}
			else
			{
			   player->TeleportTo(1, 1552.5f, -4420.66f, 8.94802f, 0.0f);
			}
			player->RemoveAurasDueToSpell(38505);
            CharacterDatabase.PExecute(REQUETE_CHOICE_2, player->GetGUIDLow());
			player->CLOSE_GOSSIP_MENU();
			break;

			case 1001:
			player->ADD_GOSSIP_ITEM( GOSSIP_ICON_CHAT, CONFIRME_CHOICE  ,GOSSIP_SENDER_MAIN, 1005);
	        player->ADD_GOSSIP_ITEM( GOSSIP_ICON_CHAT, REWARD_PAGE            ,GOSSIP_SENDER_MAIN, 1070);
            player->SEND_GOSSIP_MENU(4, pCreature->GetObjectGuid());
			break;
 
			case 1000:
            player->ADD_GOSSIP_ITEM( GOSSIP_ICON_CHAT, CONFIRME_CHOICE  ,GOSSIP_SENDER_MAIN, 1004);
			player->ADD_GOSSIP_ITEM( GOSSIP_ICON_CHAT, REWARD_PAGE            ,GOSSIP_SENDER_MAIN, 1070);
            player->SEND_GOSSIP_MENU(3, pCreature->GetObjectGuid());
            break;
            
			case 1004:
			player->learnSpell((SD2Config.GetFloatDefault("pnj_Bienvenue.SpellMount",0)), true); // mount 6653
			player->learnSpell((SD2Config.GetFloatDefault("pnj_Bienvenue.SpellMiniPet",0)), true); // mini-pet 51716
			player->learnSpell(33388, false); // apprenti mount 
			player->RemoveAurasDueToSpell(38505);
			CharacterDatabase.PExecute(REQUETE_CHOICE_1, player->GetGUIDLow());			
			player->DestroyItemCount(6948, 1, true);
     		player->CLOSE_GOSSIP_MENU();
			break;

			case 1070:
			player->ADD_GOSSIP_ITEM( 0, START_ADVENTURE  ,GOSSIP_SENDER_MAIN, 1000);
	        player->ADD_GOSSIP_ITEM( 0, START_LEVEL_UP   ,GOSSIP_SENDER_MAIN, 1001);
			player->ADD_GOSSIP_ITEM( 0, GOODBYE          ,GOSSIP_SENDER_MAIN, 1003);
            player->SEND_GOSSIP_MENU(5, pCreature->GetObjectGuid());
			break;
	}
}
示例#8
0
void SystemMgr::LoadScriptTextsCustom()
{
    outstring_log("SD2: Loading Custom Texts...");
    LoadMangosStrings(SD2Database, "custom_texts", TEXT_SOURCE_CUSTOM_START, TEXT_SOURCE_CUSTOM_END, true);
}
示例#9
0
void ScriptMgr::ScriptsInit()
{
    //Trinity Script startup
    outstring_log(" _____     _       _ _         ____            _       _");
    outstring_log("|_   _| __(_)_ __ (_) |_ _   _/ ___|  ___ _ __(_)_ __ | |_ ");
    outstring_log("  | || '__| | '_ \\| | __| | | \\___ \\ / __| \'__| | \'_ \\| __|");
    outstring_log("  | || |  | | | | | | |_| |_| |___) | (__| |  | | |_) | |_ ");
    outstring_log("  |_||_|  |_|_| |_|_|\\__|\\__, |____/ \\___|_|  |_| .__/ \\__|");
    outstring_log("                         |___/                  |_|        ");
    outstring_log("");
    outstring_log("");

    //Load database (must be called after SD2Config.SetSource).
    LoadDatabase();

    outstring_log("TSCR: Loading C++ scripts");
    barGoLink bar(1);
    bar.step();
    outstring_log("");

    for (uint16 i =0; i<MAX_SCRIPTS; ++i)
        m_scripts[i]=NULL;

    FillSpellSummary();

    AddScripts();

    outstring_log(">> Loaded %i C++ Scripts.", num_sc_scripts);

    outstring_log(">> Load Overriden SQL Data.");
    LoadOverridenSQLData();
}
示例#10
0
MANGOS_DLL_EXPORT
void InitScriptLibrary()
{
    // ScriptDev2 startup
    outstring_log("");
    outstring_log(" MMM  MMM    MM");
    outstring_log("M  MM M  M  M  M");
    outstring_log("MM    M   M   M");
    outstring_log(" MMM  M   M  M");
    outstring_log("   MM M   M MMMM");
    outstring_log("MM  M M  M ");
    outstring_log(" MMM  MMM  http://www.scriptdev2.com");
    outstring_log("");

   // Get configuration file
   bool configFailure = false;
   if (!SD2Config.SetSource(_MANGOSD_CONFIG))
       configFailure = true;
   else
       outstring_log("SD2: Using configuration file %s", _MANGOSD_CONFIG);

   // Set SD2 Error Log File
   std::string sd2LogFile = SD2Config.GetStringDefault("SD2ErrorLogFile", "SD2Errors.log");
   setScriptLibraryErrorFile(sd2LogFile.c_str(), "SD2");

   if (configFailure)
       script_error_log("Unable to open configuration file. Database will be unaccessible. Configuration values will use default.");

   // Check config file version
   if (SD2Config.GetIntDefault("ConfVersion", 0) != _MANGOSDCONFVERSION)
       script_error_log("Configuration file version doesn't match expected version. Some config variables may be wrong or missing.");

   outstring_log("");

   // Load database (must be called after SD2Config.SetSource).
    LoadDatabase();

    outstring_log("SD2: Loading C++ scripts");
    BarGoLink bar(1);
    bar.step();
    outstring_log("");

    // Resize script ids to needed ammount of assigned ScriptNames (from core)
    m_scripts.resize(GetScriptIdsCount(), nullptr);

    FillSpellSummary();

    AddScripts();

    // Check existance scripts for all registered by core script names
    for (uint32 i = 1; i < GetScriptIdsCount(); ++i)
    {
        if (!m_scripts[i])
            script_error_log("No script found for ScriptName '%s'.", GetScriptName(i));
    }

    outstring_log(">> Loaded %i C++ Scripts.", num_sc_scripts);
}
示例#11
0
void SystemMgr::LoadScriptTexts()
{
    outstring_log("SD2: Loading Script Texts...");
    LoadMangosStrings(SD2Database, "script_texts", TEXT_SOURCE_TEXT_START, TEXT_SOURCE_TEXT_END, true);
}
示例#12
0
文件: system.cpp 项目: Bootz/TC-One
void SystemMgr::LoadScriptTextsCustom()
{
    outstring_log("TSCR: Loading Custom Texts...");
    LoadTrinityStrings(TScriptDB,"custom_texts",TEXT_SOURCE_RANGE*2,1+(TEXT_SOURCE_RANGE*3));

    QueryResult* pResult = TScriptDB.PQuery("SELECT entry, sound, type, language, emote FROM custom_texts");

    outstring_log("TSCR: Loading Custom Texts additional data...");

    if (pResult)
    {
        barGoLink bar(pResult->GetRowCount());
        uint32 uiCount = 0;

        do
        {
            bar.step();
            Field* pFields = pResult->Fetch();
            StringTextData pTemp;

            int32 iId              = pFields[0].GetInt32();
            pTemp.uiSoundId        = pFields[1].GetUInt32();
            pTemp.uiType           = pFields[2].GetUInt32();
            pTemp.uiLanguage       = pFields[3].GetUInt32();
            pTemp.uiEmote          = pFields[4].GetUInt32();

            if (iId >= 0)
            {
                error_db_log("TSCR: Entry %i in table `custom_texts` is not a negative value.", iId);
                continue;
            }

            if (iId > TEXT_SOURCE_RANGE*2 || iId <= TEXT_SOURCE_RANGE*3)
            {
                error_db_log("TSCR: Entry %i in table `custom_texts` is out of accepted entry range for table.", iId);
                continue;
            }

            if (pTemp.uiSoundId)
            {
                if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId))
                    error_db_log("TSCR: Entry %i in table `custom_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId);
            }

            if (!GetLanguageDescByID(pTemp.uiLanguage))
                error_db_log("TSCR: Entry %i in table `custom_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage);

            if (pTemp.uiType > CHAT_TYPE_ZONE_YELL)
                error_db_log("TSCR: Entry %i in table `custom_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType);

            m_mTextDataMap[iId] = pTemp;
            ++uiCount;
        } while (pResult->NextRow());

        outstring_log("");
        outstring_log(">> Loaded %u additional Custom Texts data.", uiCount);
    }
    else
    {
        barGoLink bar(1);
        bar.step();
        outstring_log("");
        outstring_log(">> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty.");
    }
}
示例#13
0
void SystemMgr::LoadScriptWaypoints()
{
    // Drop Existing Waypoint list
    m_mPointMoveMap.clear();

    uint64 uiCreatureCount = 0;

    // Load Waypoints
    QueryResult* pResult = WorldDatabase.PQuery("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry");
    if (pResult)
    {
        uiCreatureCount = pResult->GetRowCount();
        delete pResult;
    }

    outstring_log("[SD3]: Loading Script Waypoints for " UI64FMTD " creature(s)...", uiCreatureCount);

    pResult = WorldDatabase.PQuery("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid");

    if (pResult)
    {
        BarGoLink bar(pResult->GetRowCount());
        uint32 uiNodeCount = 0;

        do
        {
            bar.step();
            Field* pFields = pResult->Fetch();
            ScriptPointMove pTemp;

            pTemp.uiCreatureEntry   = pFields[0].GetUInt32();
            uint32 uiEntry          = pTemp.uiCreatureEntry;
            pTemp.uiPointId         = pFields[1].GetUInt32();
            pTemp.fX                = pFields[2].GetFloat();
            pTemp.fY                = pFields[3].GetFloat();
            pTemp.fZ                = pFields[4].GetFloat();
            pTemp.uiWaitTime        = pFields[5].GetUInt32();

            CreatureInfo const* pCInfo = GetCreatureTemplateStore(pTemp.uiCreatureEntry);

            if (!pCInfo)
            {
                error_db_log("[SD3]: DB table script_waypoint has waypoint for nonexistent creature entry %u", pTemp.uiCreatureEntry);
                continue;
            }

            if (!sScriptMgr.GetBoundScriptId(SCRIPTED_UNIT, pCInfo->Entry))
            {
                error_db_log("[SD3]: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", pTemp.uiCreatureEntry);
            }

            m_mPointMoveMap[uiEntry].push_back(pTemp);
            ++uiNodeCount;
        }
        while (pResult->NextRow());

        delete pResult;

        outstring_log(">> Loaded %u Script Waypoint nodes.", uiNodeCount);
    }
    else
    {
        BarGoLink bar(1);
        bar.step();
        outstring_log(">> Loaded 0 Script Waypoints.");
    }
}
示例#14
0
void SystemMgr::LoadScriptWaypoints()
{
    uint64 creatureCount = 0;

    // Load Waypoints
    QueryResult* result = WorldDatabase.PQuery("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry");
    if (result)
    {
        creatureCount = result->GetRowCount();
        delete result;
    }

    outstring_log("SD2: Loading Script Waypoints for " UI64FMTD " creature(s)...", creatureCount);

    result = WorldDatabase.PQuery("SELECT entry, pathId, pointid, position_x, position_y, position_z, orientation, waittime, script_id FROM script_waypoint ORDER BY entry, pathId, pointid");

    if (result)
    {
        BarGoLink bar(result->GetRowCount());
        uint32 nodeCount = 0;

        do
        {
            bar.step();
            Field* fields = result->Fetch();

            uint32 entry  = fields[0].GetUInt32();

            CreatureInfo const* info = GetCreatureTemplateStore(entry);
            if (!info)
            {
                error_db_log("SD2: DB table script_waypoint has waypoint for nonexistent creature entry %u", entry);
                continue;
            }

            uint32 pathId       = fields[1].GetUInt32();
            uint32 pointId      = fields[2].GetUInt32();
            float position_x    = fields[3].GetFloat();
            float position_y    = fields[4].GetFloat();
            float position_z    = fields[5].GetFloat();
            float orientation   = fields[6].GetFloat();
            uint32 waitTime     = fields[7].GetUInt32();
            uint32 scriptId     = fields[8].GetUInt32();

            sWaypointMgr.AddExternalNode(entry, pathId, pointId, position_x, position_y, position_z, orientation, waitTime, scriptId);

            ++nodeCount;
        }
        while (result->NextRow());

        delete result;

        outstring_log("\n>> Loaded %u Script Waypoint nodes.", nodeCount);
    }
    else
    {
        BarGoLink bar(1);
        bar.step();
        outstring_log("\n>> Loaded 0 Script Waypoints. DB table `script_waypoint` is empty.");
    }
}
示例#15
0
MANGOS_DLL_EXPORT
void ScriptsInit()
{
    //ScriptDev2 startup
    outstring_log("");
    outstring_log(" MMM  MMM    MM");
    outstring_log("M  MM M  M  M  M");
    outstring_log("MM    M   M   M");
    outstring_log(" MMM  M   M  M");
    outstring_log("   MM M   M MMMM");
    outstring_log("MM  M M  M ");
    outstring_log(" MMM  MMM  http://www.scriptdev2.com");
    outstring_log("");

    //Get configuration file
    if (!SD2Config.SetSource(_SCRIPTDEV2_CONFIG))
        error_log("SD2: Unable to open configuration file. Database will be unaccessible. Configuration values will use default.");
    else
        outstring_log("SD2: Using configuration file %s",_SCRIPTDEV2_CONFIG);

    //Check config file version
    if (SD2Config.GetIntDefault("ConfVersion", 0) != SD2_CONF_VERSION)
        error_log("SD2: Configuration file version doesn't match expected version. Some config variables may be wrong or missing.");

    outstring_log("");

    //Load database (must be called after SD2Config.SetSource).
    LoadDatabase();

    outstring_log("SD2: Loading C++ scripts");
    barGoLink bar(1);
    bar.step();
    outstring_log("");

    for(int i=0; i<MAX_SCRIPTS; ++i)
        m_scripts[i]=NULL;

    FillSpellSummary();

    AddScripts();

    outstring_log(">> Loaded %i C++ Scripts.", num_sc_scripts);
}
示例#16
0
void SystemMgr::LoadScriptGossipTexts()
{
    outstring_log("SD0: Loading Gossip Texts...");
    LoadMangosStrings(SD0Database, "gossip_texts", TEXT_SOURCE_GOSSIP_START, TEXT_SOURCE_GOSSIP_END);
}
示例#17
0
void SystemMgr::LoadScriptTextsCustom()
{
    outstring_log("SD2: Loading Custom Texts...");
    LoadMangosStrings(SD2Database, "custom_texts", TEXT_SOURCE_CUSTOM_START, TEXT_SOURCE_CUSTOM_END);

    QueryResult* pResult = SD2Database.PQuery("SELECT entry, sound, type, language, emote FROM custom_texts WHERE entry BETWEEN %i AND %i", TEXT_SOURCE_CUSTOM_END, TEXT_SOURCE_CUSTOM_START);

    outstring_log("SD2: Loading Custom Texts additional data...");

    if (pResult)
    {
        BarGoLink bar(pResult->GetRowCount());
        uint32 uiCount = 0;

        do
        {
            bar.step();
            Field* pFields = pResult->Fetch();
            StringTextData pTemp;

            int32 iId              = pFields[0].GetInt32();
            pTemp.uiSoundId        = pFields[1].GetUInt32();
            pTemp.uiType           = pFields[2].GetUInt32();
            pTemp.uiLanguage       = pFields[3].GetUInt32();
            pTemp.uiEmote          = pFields[4].GetUInt32();

            if (iId >= 0)
            {
                error_db_log("SD2: Entry %i in table `custom_texts` is not a negative value.", iId);
                continue;
            }

            if (pTemp.uiSoundId)
            {
                if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId))
                    error_db_log("SD2: Entry %i in table `custom_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId);
            }

            if (!GetLanguageDescByID(pTemp.uiLanguage))
                error_db_log("SD2: Entry %i in table `custom_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage);

            if (pTemp.uiType > CHAT_TYPE_ZONE_YELL)
                error_db_log("SD2: Entry %i in table `custom_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType);

            m_mTextDataMap[iId] = pTemp;
            ++uiCount;
        }
        while (pResult->NextRow());

        delete pResult;

        // outstring_log("");
        outstring_log(">> Loaded %u additional Custom Texts data.", uiCount);
    }
    else
    {
        BarGoLink bar(1);
        bar.step();
        // outstring_log("");
        outstring_log(">> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty.");
    }
}
示例#18
0
void SD3::InitScriptLibrary()
{
    // ScriptDev3 startup
    outstring_log("   ___         _      _   ___            ____");
    outstring_log("  / __| __ _ _(_)_ __| |_|   \\ _____ __ |__ /");
    outstring_log("  \\__ \\/ _| '_| | '_ \\  _| |) / -_) V /  |_ \\");
    outstring_log("  |___/\\__|_| |_| .__/\\__|___/\\___|\\_/  |___/");
    outstring_log("                |_|                          ");
    outstring_log("                     https://getmangos.eu/\n");

    // Get configuration file
    bool configFailure = false;
    if (!SD3Config.SetSource(MANGOSD_CONFIG_LOCATION))
    {
        configFailure = true;
    }
    else
    {
        outstring_log("sd3: Using configuration file %s", MANGOSD_CONFIG_LOCATION);
    }

    // Set SD3 Error Log File
    std::string SD3LogFile = SD3Config.GetStringDefault("SD3ErrorLogFile", "scriptdev3-errors.log");
    setScriptLibraryErrorFile(SD3LogFile.c_str(), "SD3");

    if (configFailure)
    {
        script_error_log("Unable to open configuration file. Database will be unaccessible. Configuration values will use default.");
    }

    // Check config file version
    if (SD3Config.GetIntDefault("ConfVersion", 0) != MANGOSD_CONFIG_VERSION)
    {
        script_error_log("Configuration file version doesn't match expected version. Some config variables may be wrong or missing.");
    }

    outstring_log("\n");

    // Load database (must be called after SD3Config.SetSource).
    LoadDatabase();

    outstring_log("sd3: Loading C++ scripts");
    BarGoLink bar(1);
    bar.step();

    // Resize script ids to needed ammount of assigned ScriptNames (from core)
    m_scripts.resize(GetScriptIdsCount(), NULL);

    FillSpellSummary();

    AddScripts();

    // Check existance scripts for all registered by core script names
    for (uint32 i = 1; i < GetScriptIdsCount(); ++i)
    {
        if (!m_scripts[i])
        {
            script_error_log("No script found for ScriptName '%s'.", GetScriptName(i));
        }
    }

    outstring_log(">> Loaded %i C++ Scripts.", num_sc_scripts);
}