Changeset 28 for trunk

Show
Ignore:
Timestamp:
11/19/08 13:24:39 (17 years ago)
Author:
yumileroy
Message:

[svn] * Updated to 6743 and 685

Moved language id used by Arena to a higher place to solve conflicts
Added the empty script folders

Original author: Neo2003
Date: 2008-10-09 08:42:22-05:00

Location:
trunk
Files:
1 removed
55 modified
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sql/characters.sql

    r10 r28  
    177177  `trans_o` float NOT NULL default '0', 
    178178  `transguid` bigint(20) unsigned NOT NULL default '0', 
    179   `gmstate` tinyint(3) unsigned NOT NULL default '0', 
     179  `gmstate` int(11) unsigned NOT NULL default '0', 
    180180  `stable_slots` tinyint(1) unsigned NOT NULL default '0', 
    181181  `at_login` int(11) unsigned NOT NULL default '0', 
  • trunk/sql/mangos.sql

    r18 r28  
    211211('explorecheat',3,'Syntax: .explorecheat #flag\r\n\r\nReveal  or hide all maps for the selected player. If no player is selected, hide or reveal maps to you.\r\n\r\nUse a #flag of value 1 to reveal, use a #flag value of 0 to hide all maps.'), 
    212212('flusharenapoints',3,'Syntax: .flusharenapoints\r\n\r\nUse it to distribute arena points based on arena team ratings, and start a new week.'), 
    213 ('gm',1,'Syntax: .gm on/off\r\n\r\nEnable or Disable GM MODE'), 
     213('gm',1,'Syntax: .gm [on/off]\r\n\r\nEnable or Disable in game GM MODE or show current state of on/off not provided.'), 
     214('gm chat',1,'Syntax: .gm chat [on/off]\r\n\r\nEnable or disable chat GM MODE (show gm badge in messages) or show current state of on/off not provided.'), 
    214215('gm fly',3,'Syntax: .gm fly on/off\r\nEnable/disable gm fly mode.'), 
    215216('gm list',0,'Syntax: .gm list\r\n\r\nDisplay a list of available Game Masters.'), 
     
    353354('saveall',1,'Syntax: .saveall\r\n\r\nSave all characters in game.'), 
    354355('security',3,'Syntax: .security $name #level\r\n\r\nSet the security level of player $name to a level of #level.\r\n\r\n#level may range from 0 to 5.'), 
    355 ('sendmail',1,'Syntax: .sendmail #playername #subject #text\r\n\r\nSend a mail to a player. Note: subject may not contain spaces.'), 
     356('sendmail',1,'Syntax: .sendmail #playername "#subject" "#text" itemid1[:count1] itemid2[:count2] ... itemidN[:countN]\r\n\r\nSend a mail to a player. Subject and mail text must be in "". If for itemid not provided related count values then expected 1, if count > max items in stack then items will be send in required amount stacks. All stacks amount in mail limited to 12.'), 
    356357('server info',0,'Syntax: .server info\r\n\r\nDisplay server version and the number of connected players.'), 
    357358('server idleshutdown',3,'Syntax: .server idleshutdown #delay|cancel\r\n\r\nShut the server down after #delay seconds if no active connections are present (no players) or cancel the restart/shutdown if cancel value is used.'), 
     
    21382139(50,'You must be at least level %u and have item %s to enter.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    21392140(51,'Hello! Ready for some training?',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2141(52,'Invaid item count (%u) for item %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2142(53,'Mail can\'t have more %u item stacks',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    21402143(100,'Global notify: ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    21412144(101,'Map: %u (%s) Zone: %u (%s) Area: %u (%s)\nX: %f Y: %f Z: %f Orientation: %f\ngrid[%u,%u]cell[%u,%u] InstanceID: %u\n ZoneX: %f ZoneY: %f\nGroundZ: %f FloorZ: %f Have height data (Map: %u VMap: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     
    23402343(330,'No players found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    23412344(331,'Extended item cost %u not exist',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2345(332,'GM mode is ON',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2346(333,'GM mode is OFF',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2347(334,'GM Chat Badge is ON',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2348(335,'GM Chat Badge is OFF',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    23422349(400,'|cffff0000[System Message]:|rScripts reloaded',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    23432350(401,'You change security level of %s to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     
    25792586(711,'Your group is too large for this battleground. Please regroup to join.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    25802587(712,'Your group is too large for this arena. Please regroup to join.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2581 (713,'Your group has members not in your arena team. Please regroup to join.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2582 (714,'Your group does not have enough players to join this match.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2583 (715,'The Gold Team wins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2584 (716,'The Green Team wins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2585 (717, 'There aren\'t enough players in this battleground. It will end soon unless some more players join to balance the fight.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2586 (718, 'Your group has an offline member. Please remove him before joining.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2587 (719, 'Your group has players from the opposing faction. You can\'t join the battleground as a group.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2588 (720, 'Your group has players from different battleground brakets. You can\'t join as group.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2589 (721, 'Someone in your party is already in this battleground queue. (S)he must leave it before joining as group.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2590 (722, 'Someone in your party is Deserter. You can\'t join as group.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2591 (723, 'Someone in your party is already in three battleground queues. You cannot join as group.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2592 (724, 'You cannot teleport to a battleground or arena map.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2593 (725, 'You cannot summon players to a battleground or arena map.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2594 (726, 'You must be in GM mode to teleport to a player in a battleground.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2595 (727, 'You cannot teleport to a battleground from another battleground. Please leave the current battleground first.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
    2596 (728, 'Arena testing turned %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); 
     2588(713,'You must be level %u to join an arena team!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2589(714,'%s is not high enough level to join your team',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2590(715,'You don\'t meet Battleground level requirements',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2591(716,'Your arena team is full, %s cannot join it.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2592(730,'Your group has members not in your arena team. Please regroup to join.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2593(731,'Your group does not have enough players to join this match.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2594(732,'The Gold Team wins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2595(733,'The Green Team wins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2596(734, 'There aren\'t enough players in this battleground. It will end soon unless some more players join to balance the fight.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2597(735, 'Your group has an offline member. Please remove him before joining.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2598(736, 'Your group has players from the opposing faction. You can\'t join the battleground as a group.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2599(737, 'Your group has players from different battleground brakets. You can\'t join as group.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2600(738, 'Someone in your party is already in this battleground queue. (S)he must leave it before joining as group.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2601(739, 'Someone in your party is Deserter. You can\'t join as group.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2602(740, 'Someone in your party is already in three battleground queues. You cannot join as group.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2603(741, 'You cannot teleport to a battleground or arena map.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2604(742, 'You cannot summon players to a battleground or arena map.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2605(743, 'You must be in GM mode to teleport to a player in a battleground.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2606(744, 'You cannot teleport to a battleground from another battleground. Please leave the current battleground first.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2607(745, 'Arena testing turned %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2608(800,'Invalid name',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2609(801,'You do not have enough gold',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2610(802,'You do not have enough free slots',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2611(803,'Your partner does not have enough free bag slots',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2612(804,'You do not have permission to perform that function',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2613(805,'Unknown language',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2614(806,'You don\'t know that language',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2615(807,'Please provide character name',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2616(808,'Player %s not found or offline',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), 
     2617(809,'Account for character %s not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); 
     2618 
    25972619/*!40000 ALTER TABLE `mangos_string` ENABLE KEYS */; 
    25982620UNLOCK TABLES; 
  • trunk/sql/updates/10_instantiated_battlegrounds.sql

    r9 r28  
    1616 
    1717 
    18 DELETE FROM mangos_string WHERE entry BETWEEN 711 AND 728; 
     18DELETE FROM mangos_string WHERE entry IN (711,712); 
     19DELETE FROM mangos_string WHERE entry BETWEEN 730 AND 745; 
    1920INSERT INTO mangos_string (entry, content_default) VALUES 
    2021    (711,'Your group is too large for this battleground. Please regroup to join.'), 
    2122    (712,'Your group is too large for this arena. Please regroup to join.'), 
    22     (713,'Your group has members not in your arena team. Please regroup to join.'), 
    23     (714,'Your group does not have enough players to join this match.'), 
    24     (715,'The Gold Team wins!'), 
    25     (716,'The Green Team wins!'), 
    26     (717, 'There aren\'t enough players in this battleground. It will end soon unless some more players join to balance the fight.'), 
    27     (718, 'Your group has an offline member. Please remove him before joining.'), 
    28     (719, 'Your group has players from the opposing faction. You can\'t join the battleground as a group.'), 
    29     (720, 'Your group has players from different battleground brakets. You can\'t join as group.'), 
    30     (721, 'Someone in your party is already in this battleground queue. (S)he must leave it before joining as group.'), 
    31     (722, 'Someone in your party is Deserter. You can\'t join as group.'), 
    32     (723, 'Someone in your party is already in three battleground queues. You cannot join as group.'), 
    33     (724, 'You cannot teleport to a battleground or arena map.'), 
    34     (725, 'You cannot summon players to a battleground or arena map.'), 
    35     (726, 'You must be in GM mode to teleport to a player in a battleground.'), 
    36     (727, 'You cannot teleport to a battleground from another battleground. Please leave the current battleground first.'), 
    37     (728, 'Arena testing turned %s'); 
     23    (730,'Your group has members not in your arena team. Please regroup to join.'), 
     24    (731,'Your group does not have enough players to join this match.'), 
     25    (732,'The Gold Team wins!'), 
     26    (733,'The Green Team wins!'), 
     27    (734, 'There aren\'t enough players in this battleground. It will end soon unless some more players join to balance the fight.'), 
     28    (735, 'Your group has an offline member. Please remove him before joining.'), 
     29    (736, 'Your group has players from the opposing faction. You can\'t join the battleground as a group.'), 
     30    (737, 'Your group has players from different battleground brakets. You can\'t join as group.'), 
     31    (738, 'Someone in your party is already in this battleground queue. (S)he must leave it before joining as group.'), 
     32    (739, 'Someone in your party is Deserter. You can\'t join as group.'), 
     33    (740, 'Someone in your party is already in three battleground queues. You cannot join as group.'), 
     34    (741, 'You cannot teleport to a battleground or arena map.'), 
     35    (742, 'You cannot summon players to a battleground or arena map.'), 
     36    (743, 'You must be in GM mode to teleport to a player in a battleground.'), 
     37    (744, 'You cannot teleport to a battleground from another battleground. Please leave the current battleground first.'), 
     38    (745, 'Arena testing turned %s'); 
    3839     
  • trunk/src/bindings/scripts/ScriptMgr.cpp

    r12 r28  
    1 /* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> 
     1/* Copyright (C) 2006 - 2008 TrinityScript <https://scriptdev2.svn.sourceforge.net/> 
    22 * This program is free software licensed under GPL version 2 
    33 * Please see the included DOCS/LICENSE.TXT for more information */ 
     
    55#include "precompiled.h" 
    66#include "Config/Config.h" 
     7#include "Database/DatabaseEnv.h" 
     8#include "Database/DBCStores.h" 
     9#include "ObjectMgr.h" 
    710#include "ProgressBar.h" 
    8 #include "Database/DBCStores.h" 
    9 #include "Database/DatabaseMysql.h" 
    10 #include "ObjectMgr.h" 
    1111#include "scripts/creature/mob_event_ai.h" 
    1212 
     
    2525Script *m_scripts[MAX_SCRIPTS]; 
    2626 
    27 // Text Map for Event AI 
    28 HM_NAMESPACE::hash_map<uint32, std::string> EventAI_Text_Map; 
    29  
    30 // Script Text used as says / yells / text emotes / whispers in scripts. 
    31 struct ScriptText 
     27DatabaseType TScriptDB; 
     28Config TScriptConfig; 
     29uint32 Locale; 
     30 
     31// String text additional data, used in TextMap 
     32struct StringTextData 
    3233{ 
    3334    uint32 SoundId; 
    3435    uint8  Type; 
    3536    uint32 Language; 
    36     std::string Text; 
    3737}; 
    3838 
    39 // Enums used by ScriptText::Type 
     39// Enums used by StringTextData::Type 
    4040enum ChatType 
    4141{ 
     
    4848}; 
    4949 
    50 HM_NAMESPACE::hash_map<uint32, ScriptText> Script_TextMap; 
     50#define TEXT_SOURCE_RANGE   -100000                         //the amount of entries each text source has available 
     51 
     52// Text Maps 
     53HM_NAMESPACE::hash_map<uint32, std::string> EventAI_Text_Map; 
     54HM_NAMESPACE::hash_map<int32, StringTextData> TextMap; 
    5155 
    5256// Localized Text structure for storing locales (for EAI and SD2 scripts). 
     
    6266    std::string locale_8; 
    6367}; 
     68//*** End Global data *** 
     69 
     70//*** EventAI data *** 
    6471HM_NAMESPACE::hash_map<uint32, Localized_Text> EventAI_LocalizedTextMap; 
    65 HM_NAMESPACE::hash_map<uint32, Localized_Text> Script_LocalizedTextMap; 
    66  
    67 //*** End Global data *** 
    68  
    69 //*** EventAI data *** 
     72 
    7073//Event AI structure. Used exclusivly by mob_event_ai.cpp (60 bytes each) 
    7174std::list<EventAI_Event> EventAI_Event_List; 
     
    7881 
    7982uint32 EAI_ErrorLevel; 
    80  
    8183//*** End EventAI data *** 
    82  
    83 DatabaseMysql TScriptDB; 
    84 Config TScriptConfig; 
    85 uint32 Locale; 
    8684 
    8785void FillSpellSummary(); 
     
    598596    //Get db string from file 
    599597    char const* dbstring = NULL; 
    600     if(!TScriptConfig.GetString("TScriptDatabaseInfo", &dbstring)) 
    601         error_log("TSCR: Missing Trinity Script Database Info in configuration file"); 
    602  
    603     //Initilize connection to DB 
    604     if(!dbstring || !TScriptDB.Initialize(dbstring)) 
    605         error_db_log("TSCR: Unable to connect to Database"); 
     598 
     599    if( !TScriptConfig.GetString("TScriptDatabaseInfo", &dbstring) ) 
     600    { 
     601        error_log("TSCR: Missing Trinity Script database info from configuration file. Load database aborted."); 
     602        return; 
     603    } 
     604 
     605    //Initialize connection to DB 
     606    if( dbstring && TScriptDB.Initialize(dbstring) ) 
     607        outstring_log("TSCR: TrinityScript database: %s",dbstring); 
    606608    else 
    607609    { 
    608         //***Preform all DB queries here*** 
    609         QueryResult *result; 
    610  
    611         //Get Version information 
    612         result = TScriptDB.PQuery("SELECT `version`" 
    613             "FROM `script_db_version`"); 
    614  
    615         if (result) 
     610        error_log("TSCR: Unable to connect to Database. Load database aborted."); 
     611        return; 
     612    } 
     613 
     614    //***Preform all DB queries here*** 
     615    QueryResult *result; 
     616 
     617    //Get Version information 
     618    result = TScriptDB.PQuery("SELECT version FROM script_db_version"); 
     619 
     620    if (result) 
     621    { 
     622        Field *fields = result->Fetch(); 
     623        outstring_log("TSCR: Database version is: %s", fields[0].GetString()); 
     624        outstring_log(""); 
     625        delete result; 
     626 
     627    }else 
     628    { 
     629        error_log("TSCR: Missing `script_db_version` information."); 
     630        outstring_log(""); 
     631    } 
     632 
     633    // Drop Existing Text Map, only done once and we are ready to add data from multiple sources. 
     634    TextMap.clear(); 
     635 
     636    //TODO: Add load from eventai_texts here 
     637 
     638    // Load Script Text  
     639    outstring_log("TSCR: Loading Script Texts..."); 
     640    LoadMangosStrings(TScriptDB,"script_texts",TEXT_SOURCE_RANGE,(TEXT_SOURCE_RANGE*2)+1); 
     641 
     642    // Gather Additional data from Script Texts 
     643    result = TScriptDB.PQuery("SELECT entry, sound, type, language FROM script_texts"); 
     644 
     645    outstring_log("TSCR: Loading Script Texts additional data..."); 
     646    if (result) 
     647    { 
     648        barGoLink bar(result->GetRowCount()); 
     649        uint32 count = 0; 
     650 
     651        do 
    616652        { 
     653            bar.step(); 
     654            Field* fields = result->Fetch(); 
     655            StringTextData temp; 
     656 
     657            int32 i             = fields[0].GetInt32(); 
     658            temp.SoundId        = fields[1].GetInt32(); 
     659            temp.Type           = fields[2].GetInt32(); 
     660            temp.Language       = fields[3].GetInt32(); 
     661 
     662            if (i >= 0) 
     663            { 
     664                error_db_log("TSCR: Entry %i in table `script_texts` is not a negative value.",i); 
     665                continue; 
     666            } 
     667 
     668            if (i > TEXT_SOURCE_RANGE || i <= TEXT_SOURCE_RANGE*2) 
     669            { 
     670                error_db_log("TSCR: Entry %i in table `script_texts` is out of accepted entry range for table.",i); 
     671                continue; 
     672            } 
     673 
     674            if (temp.SoundId) 
     675            { 
     676                if (!GetSoundEntriesStore()->LookupEntry(temp.SoundId)) 
     677                    error_db_log("TSCR: Entry %i in table `script_texts` has soundId %u but sound does not exist.",i,temp.SoundId); 
     678            } 
     679 
     680            if (!GetLanguageDescByID(temp.Language)) 
     681                error_db_log("TSCR: Entry %i in table `script_texts` using Language %u but Language does not exist.",i,temp.Language); 
     682 
     683            if (temp.Type > CHAT_TYPE_BOSS_WHISPER) 
     684                error_db_log("TSCR: Entry %i in table `script_texts` has Type %u but this Chat Type does not exist.",i,temp.Type); 
     685 
     686            TextMap[i] = temp; 
     687            ++count; 
     688        } while (result->NextRow()); 
     689 
     690        delete result; 
     691 
     692        outstring_log(""); 
     693        outstring_log(">> TSCR: Loaded %u additional Script Texts data.", count); 
     694    }else 
     695    { 
     696        barGoLink bar(1); 
     697        bar.step(); 
     698        outstring_log(""); 
     699        outstring_log(">> Loaded 0 additional Script Texts data. DB table `script_texts` is empty."); 
     700    } 
     701 
     702    // Load Custom Text  
     703    outstring_log("TSCR: Loading Custom Texts..."); 
     704    LoadMangosStrings(TScriptDB,"custom_texts",TEXT_SOURCE_RANGE*2,(TEXT_SOURCE_RANGE*3)+1); 
     705 
     706    // Gather Additional data from Custom Texts 
     707    result = TScriptDB.PQuery("SELECT entry, sound, type, language FROM custom_texts"); 
     708 
     709    outstring_log("TSCR: Loading Custom Texts additional data..."); 
     710    if (result) 
     711    { 
     712        barGoLink bar(result->GetRowCount()); 
     713        uint32 count = 0; 
     714 
     715        do 
     716        { 
     717            bar.step(); 
     718            Field* fields = result->Fetch(); 
     719            StringTextData temp; 
     720 
     721            int32 i             = fields[0].GetInt32(); 
     722            temp.SoundId        = fields[1].GetInt32(); 
     723            temp.Type           = fields[2].GetInt32(); 
     724            temp.Language       = fields[3].GetInt32(); 
     725 
     726            if (i >= 0) 
     727            { 
     728                error_db_log("TSCR: Entry %i in table `custom_texts` is not a negative value.",i); 
     729                continue; 
     730            } 
     731 
     732            if (i > TEXT_SOURCE_RANGE*2 || i <= TEXT_SOURCE_RANGE*3) 
     733            { 
     734                error_db_log("TSCR: Entry %i in table `custom_texts` is out of accepted entry range for table.",i); 
     735                continue; 
     736            } 
     737 
     738            if (temp.SoundId) 
     739            { 
     740                if (!GetSoundEntriesStore()->LookupEntry(temp.SoundId)) 
     741                    error_db_log("TSCR: Entry %i in table `custom_texts` has soundId %u but sound does not exist.",i,temp.SoundId); 
     742            } 
     743 
     744            if (!GetLanguageDescByID(temp.Language)) 
     745                error_db_log("TSCR: Entry %i in table `custom_texts` using Language %u but Language does not exist.",i,temp.Language); 
     746 
     747            if (temp.Type > CHAT_TYPE_BOSS_WHISPER) 
     748                error_db_log("TSCR: Entry %i in table `custom_texts` has Type %u but this Chat Type does not exist.",i,temp.Type); 
     749 
     750            TextMap[i] = temp; 
     751            ++count; 
     752        } while (result->NextRow()); 
     753 
     754        delete result; 
     755 
     756        outstring_log(""); 
     757        outstring_log(">> Loaded %u additional Custom Texts data.", count); 
     758    }else 
     759    { 
     760        barGoLink bar(1); 
     761        bar.step(); 
     762        outstring_log(""); 
     763        outstring_log(">> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty."); 
     764    } 
     765 
     766    // Drop existing Event AI Localized Text hash map 
     767    EventAI_LocalizedTextMap.clear(); 
     768 
     769    // Gather EventAI Localized Texts 
     770    result = TScriptDB.PQuery("SELECT id, locale_1, locale_2, locale_3, locale_4, locale_5, locale_6, locale_7, locale_8 " 
     771        "FROM eventai_localized_texts"); 
     772 
     773    outstring_log("TSCR: Loading EventAI Localized Texts..."); 
     774    if(result) 
     775    { 
     776        barGoLink bar(result->GetRowCount()); 
     777        uint32 count = 0; 
     778 
     779        do 
     780        { 
     781            Localized_Text temp; 
     782            bar.step(); 
     783 
    617784            Field *fields = result->Fetch(); 
    618             outstring_log(" "); 
    619             outstring_log("TSCR: Database version is: %s", fields[0].GetString()); 
    620             outstring_log(" "); 
    621             delete result; 
    622  
    623         }else error_db_log("TSCR: Missing script_db_version information."); 
    624  
    625         // Drop existing Event AI Localized Text hash map 
    626         EventAI_LocalizedTextMap.clear(); 
    627  
    628         // Gather EventAI Localized Texts 
    629         result = TScriptDB.PQuery("SELECT `id`,`locale_1`,`locale_2`,`locale_3`,`locale_4`,`locale_5`,`locale_6`,`locale_7`,`locale_8`" 
    630             "FROM `eventai_localized_texts`"); 
    631  
    632         if(result) 
     785 
     786            uint32 i = fields[0].GetInt32(); 
     787 
     788            temp.locale_1 = fields[1].GetString(); 
     789            temp.locale_2 = fields[2].GetString(); 
     790            temp.locale_3 = fields[3].GetString(); 
     791            temp.locale_4 = fields[4].GetString(); 
     792            temp.locale_5 = fields[5].GetString(); 
     793            temp.locale_6 = fields[6].GetString(); 
     794            temp.locale_7 = fields[7].GetString(); 
     795            temp.locale_8 = fields[8].GetString(); 
     796 
     797            EventAI_LocalizedTextMap[i] = temp; 
     798            ++count; 
     799 
     800        }while(result->NextRow()); 
     801 
     802        delete result; 
     803 
     804        outstring_log(""); 
     805        outstring_log(">> Loaded %u EventAI Localized Texts", count); 
     806    }else 
     807    { 
     808        barGoLink bar(1); 
     809        bar.step(); 
     810        outstring_log(""); 
     811        outstring_log(">> Loaded 0 EventAI Localized Texts. DB table `eventai_localized_texts` is empty"); 
     812    } 
     813 
     814    //Drop existing EventAI Text hash map 
     815    EventAI_Text_Map.clear(); 
     816 
     817    //Gather EventAI Text Entries 
     818    result = TScriptDB.PQuery("SELECT id, text FROM eventai_texts"); 
     819 
     820    outstring_log("TSCR: Loading EventAI_Texts..."); 
     821    if (result) 
     822    { 
     823        barGoLink bar(result->GetRowCount()); 
     824        uint32 Count = 0; 
     825 
     826        do 
    633827        { 
    634             outstring_log("TSCR: Loading EAI Localized Texts...."); 
    635             barGoLink bar(result->GetRowCount()); 
    636             uint32 count = 0; 
    637  
    638             do 
     828            bar.step(); 
     829            Field *fields = result->Fetch(); 
     830 
     831            uint32 i = fields[0].GetInt32(); 
     832 
     833            std::string text = fields[1].GetString(); 
     834 
     835            if (!strlen(text.c_str())) 
     836                error_db_log("TSCR: EventAI text %u is empty", i); 
     837 
     838            EventAI_Text_Map[i] = text; 
     839            ++Count; 
     840 
     841        }while (result->NextRow()); 
     842 
     843        delete result; 
     844 
     845        outstring_log(""); 
     846        outstring_log(">> Loaded %u EventAI texts", Count); 
     847    }else 
     848    { 
     849        barGoLink bar(1); 
     850        bar.step(); 
     851        outstring_log(""); 
     852        outstring_log(">> Loaded 0 EventAI texts. DB table `eventai_texts` is empty."); 
     853    } 
     854 
     855    //Gather event data 
     856    result = TScriptDB.PQuery("SELECT id, position_x, position_y, position_z, orientation, spawntimesecs FROM eventai_summons"); 
     857 
     858    //Drop Existing EventSummon Map 
     859    EventAI_Summon_Map.clear(); 
     860 
     861    outstring_log("TSCR: Loading EventAI_Summons..."); 
     862    if (result) 
     863    { 
     864        barGoLink bar(result->GetRowCount()); 
     865        uint32 Count = 0; 
     866 
     867        do 
     868        { 
     869            bar.step(); 
     870            Field *fields = result->Fetch(); 
     871 
     872            EventAI_Summon temp; 
     873 
     874            uint32 i = fields[0].GetUInt32(); 
     875            temp.position_x = fields[1].GetFloat(); 
     876            temp.position_y = fields[2].GetFloat(); 
     877            temp.position_z = fields[3].GetFloat(); 
     878            temp.orientation = fields[4].GetFloat(); 
     879            temp.SpawnTimeSecs = fields[5].GetUInt32(); 
     880 
     881            //Add to map 
     882            EventAI_Summon_Map[i] = temp; 
     883            ++Count; 
     884        }while (result->NextRow()); 
     885 
     886        delete result; 
     887 
     888        outstring_log(""); 
     889        outstring_log(">> Loaded %u EventAI summon definitions", Count); 
     890    }else 
     891    { 
     892        barGoLink bar(1); 
     893        bar.step(); 
     894        outstring_log(""); 
     895        outstring_log(">> Loaded 0 EventAI Summon definitions. DB table `eventai_summons` is empty."); 
     896    } 
     897 
     898    //Gather event data 
     899    result = TScriptDB.PQuery("SELECT id, creature_id, event_type, event_inverse_phase_mask, event_chance, event_flags, " 
     900        "event_param1, event_param2, event_param3, event_param4, " 
     901        "action1_type, action1_param1, action1_param2, action1_param3, " 
     902        "action2_type, action2_param1, action2_param2, action2_param3, " 
     903        "action3_type, action3_param1, action3_param2, action3_param3 " 
     904        "FROM eventai_scripts"); 
     905 
     906    //Drop Existing EventAI List 
     907    EventAI_Event_List.clear(); 
     908 
     909    outstring_log("TSCR: Loading EventAI_Scripts..."); 
     910    if (result) 
     911    { 
     912        barGoLink bar(result->GetRowCount()); 
     913        uint32 Count = 0; 
     914 
     915        do 
     916        { 
     917            bar.step(); 
     918            Field *fields = result->Fetch(); 
     919 
     920            EventAI_Event temp; 
     921 
     922            temp.event_id = fields[0].GetUInt32(); 
     923            uint32 i = temp.event_id; 
     924            temp.creature_id = fields[1].GetUInt32(); 
     925            temp.event_type = fields[2].GetUInt16(); 
     926            temp.event_inverse_phase_mask = fields[3].GetUInt32(); 
     927            temp.event_chance = fields[4].GetUInt8(); 
     928            temp.event_flags = fields[5].GetUInt8(); 
     929            temp.event_param1 = fields[6].GetUInt32(); 
     930            temp.event_param2 = fields[7].GetUInt32(); 
     931            temp.event_param3 = fields[8].GetUInt32(); 
     932            temp.event_param4 = fields[9].GetUInt32(); 
     933 
     934            //Report any errors in event 
     935            if (temp.event_type >= EVENT_T_END) 
     936                error_db_log("TSCR: Event %u has incorrect event type. Maybe DB requires updated version of SD2.", i); 
     937 
     938            //No chance of this event occuring 
     939            if (temp.event_chance == 0) 
     940                error_db_log("TSCR: Event %u has 0 percent chance. Event will never trigger!", i); 
     941 
     942            //Chance above 100, force it to be 100 
     943            if (temp.event_chance > 100) 
    639944            { 
    640                 Localized_Text temp; 
    641                 bar.step(); 
    642                  
    643                 Field *fields = result->Fetch(); 
    644  
    645                 uint32 i = fields[0].GetInt32(); 
    646  
    647                 temp.locale_1 = fields[1].GetString(); 
    648                 temp.locale_2 = fields[2].GetString(); 
    649                 temp.locale_3 = fields[3].GetString(); 
    650                 temp.locale_4 = fields[4].GetString(); 
    651                 temp.locale_5 = fields[5].GetString(); 
    652                 temp.locale_6 = fields[6].GetString(); 
    653                 temp.locale_7 = fields[7].GetString(); 
    654                 temp.locale_8 = fields[8].GetString(); 
    655  
    656                 EventAI_LocalizedTextMap[i] = temp; 
    657                 ++count; 
    658  
    659             }while(result->NextRow()); 
    660  
    661             delete result; 
    662  
    663             outstring_log(""); 
    664             outstring_log("TSCR: Loaded %u EventAI Localized Texts", count); 
    665         }else outstring_log("TSCR: WARNING >> Loaded 0 EventAI Localized Texts. Database table `eventai_localized_texts` is empty"); 
    666  
    667         // Drop Existing Script Localized Text Hash Map 
    668         Script_LocalizedTextMap.clear(); 
    669  
    670         // Gather Script Localized Texts 
    671         result = TScriptDB.PQuery("SELECT `id`,`locale_1`,`locale_2`,`locale_3`,`locale_4`,`locale_5`,`locale_6`,`locale_7`,`locale_8`" 
    672             "FROM `script_localized_texts`"); 
    673  
    674         if(result) 
    675         { 
    676             outstring_log("TSCR: Loading Script Localized Texts...."); 
    677             barGoLink bar(result->GetRowCount()); 
    678             uint32 count = 0; 
    679  
    680             do 
     945                error_db_log("TSCR: Creature %u are using event %u with more than 100 percent chance. Adjusting to 100 percent.", temp.creature_id, i); 
     946                temp.event_chance = 100; 
     947            } 
     948 
     949            //Individual event checks 
     950            switch (temp.event_type) 
    681951            { 
    682                 Localized_Text temp; 
    683                 bar.step(); 
    684  
    685                 Field *fields = result->Fetch(); 
    686  
    687                 uint32 i = fields[0].GetInt32(); 
    688  
    689                 temp.locale_1 = fields[1].GetString(); 
    690                 temp.locale_2 = fields[2].GetString(); 
    691                 temp.locale_3 = fields[3].GetString(); 
    692                 temp.locale_4 = fields[4].GetString(); 
    693                 temp.locale_5 = fields[5].GetString(); 
    694                 temp.locale_6 = fields[6].GetString(); 
    695                 temp.locale_7 = fields[7].GetString(); 
    696                 temp.locale_8 = fields[8].GetString(); 
    697  
    698                 Script_LocalizedTextMap[i] = temp; 
    699                 ++count; 
    700  
    701             }while(result->NextRow()); 
    702  
    703             delete result; 
    704  
    705             outstring_log(""); 
    706             outstring_log("TSCR: Loaded %u Script Localized Texts", count); 
    707         }else outstring_log("TSCR: WARNING >> Loaded 0 Script Localized Texts. Database table `script_localized_texts` is empty"); 
    708  
    709         //Drop existing EventAI Text hash map 
    710         EventAI_Text_Map.clear(); 
    711  
    712         //Gather EventAI Text Entries 
    713         result = TScriptDB.PQuery("SELECT `id`,`text` FROM `eventai_texts`"); 
    714  
    715         if (result) 
    716         { 
    717             outstring_log( "TSCR: Loading EventAI_Texts..."); 
    718             barGoLink bar(result->GetRowCount()); 
    719             uint32 Count = 0; 
    720  
    721             do 
     952                case EVENT_T_HP: 
     953                case EVENT_T_MANA: 
     954                case EVENT_T_TARGET_HP: 
     955                    { 
     956                        if (temp.event_param2 > 100) 
     957                            error_db_log("TSCR: Creature %u are using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! ", temp.creature_id, i); 
     958 
     959                        if (temp.event_param1 <= temp.event_param2) 
     960                            error_db_log("TSCR: Creature %u are using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! ", temp.creature_id, i); 
     961 
     962                        if (temp.event_flags & EFLAG_REPEATABLE && !temp.event_param3 && !temp.event_param4) 
     963                        { 
     964                            error_db_log("TSCR: Creature %u has param3 and param4=0 (RepeatMin/RepeatMax) but cannot be repeatable without timers. Removing EFLAG_REPEATABLE for event %u.", temp.creature_id, i); 
     965                            temp.event_flags &= ~EFLAG_REPEATABLE; 
     966                        } 
     967                    } 
     968                    break; 
     969 
     970                case EVENT_T_SPELLHIT: 
     971                    { 
     972                        if (temp.event_param1) 
     973                        { 
     974                            SpellEntry const* pSpell = GetSpellStore()->LookupEntry(temp.event_param1); 
     975                            if (!pSpell) 
     976                            { 
     977                                error_db_log("TSCR: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.event_param1, i); 
     978                                continue; 
     979                            } 
     980 
     981                            if (temp.event_param2_s != -1 && temp.event_param2 != pSpell->SchoolMask) 
     982                                error_db_log("TSCR: Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", temp.creature_id, temp.event_param1, i); 
     983                        } 
     984 
     985                        //TODO: fix this system with SPELL_SCHOOL_MASK. Current complicate things, using int32(-1) instead of just 0 
     986                        //SPELL_SCHOOL_MASK_NONE = 0 and does not exist, thus it can not ever trigger or be used in SpellHit() 
     987                        if (temp.event_param2_s != -1 && temp.event_param2_s > SPELL_SCHOOL_MASK_ALL) 
     988                            error_db_log("TSCR: Creature %u is using invalid SpellSchoolMask(%u) defined in event %u.", temp.creature_id, temp.event_param2, i); 
     989 
     990                        if (temp.event_param4 < temp.event_param3) 
     991                            error_db_log("TSCR: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); 
     992                    } 
     993                    break; 
     994 
     995                case EVENT_T_RANGE: 
     996                case EVENT_T_OOC_LOS: 
     997                case EVENT_T_FRIENDLY_HP: 
     998                case EVENT_T_FRIENDLY_IS_CC: 
     999                case EVENT_T_FRIENDLY_MISSING_BUFF: 
     1000                    { 
     1001                        if (temp.event_param4 < temp.event_param3) 
     1002                            error_db_log("TSCR: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); 
     1003                    } 
     1004                    break; 
     1005 
     1006                case EVENT_T_TIMER: 
     1007                case EVENT_T_TIMER_OOC: 
     1008                    { 
     1009                        if (temp.event_param2 < temp.event_param1) 
     1010                            error_db_log("TSCR: Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i); 
     1011 
     1012                        if (temp.event_param4 < temp.event_param3) 
     1013                            error_db_log("TSCR: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); 
     1014                    } 
     1015                    break; 
     1016 
     1017                case EVENT_T_KILL: 
     1018                case EVENT_T_TARGET_CASTING: 
     1019                    { 
     1020                        if (temp.event_param2 < temp.event_param1) 
     1021                            error_db_log("TSCR: Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); 
     1022                    } 
     1023                    break; 
     1024 
     1025                case EVENT_T_AGGRO: 
     1026                case EVENT_T_DEATH: 
     1027                case EVENT_T_EVADE: 
     1028                case EVENT_T_SPAWNED: 
     1029                    { 
     1030                        if (temp.event_flags & EFLAG_REPEATABLE) 
     1031                        { 
     1032                            error_db_log("TSCR: Creature %u has EFLAG_REPEATABLE set. Event can never be repeatable. Removing flag for event %u.", temp.creature_id, i); 
     1033                            temp.event_flags &= ~EFLAG_REPEATABLE; 
     1034                        } 
     1035                    } 
     1036                    break; 
     1037            } 
     1038 
     1039            for (uint32 j = 0; j < MAX_ACTIONS; j++) 
    7221040            { 
    723                 bar.step(); 
    724                 Field *fields = result->Fetch(); 
    725  
    726                 uint32 i = fields[0].GetInt32(); 
    727  
    728                 std::string text = fields[1].GetString(); 
    729  
    730                 if (!strlen(text.c_str())) 
    731                     error_db_log("TSCR: EventAI text %u is empty", i); 
    732  
    733                 EventAI_Text_Map[i] = text; 
    734                 ++Count; 
    735  
    736             }while (result->NextRow()); 
    737  
    738             delete result; 
    739  
    740             outstring_log(""); 
    741             outstring_log("TSCR: >> Loaded %u EventAI_Texts", Count); 
    742  
    743         }else outstring_log("TSCR: WARNING >> Loaded 0 EventAI_Texts. DB table `EventAI_Texts` is empty."); 
    744  
    745         //Gather event data 
    746         result = TScriptDB.PQuery("SELECT `id`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`" 
    747             "FROM `eventai_summons`"); 
    748  
    749         //Drop Existing EventSummon Map 
    750         EventAI_Summon_Map.clear(); 
    751  
    752         if (result) 
    753         { 
    754             outstring_log( "TSCR: Loading EventAI_Summons..."); 
    755             barGoLink bar(result->GetRowCount()); 
    756             uint32 Count = 0; 
    757  
    758             do 
    759             { 
    760                 bar.step(); 
    761                 Field *fields = result->Fetch(); 
    762  
    763                 EventAI_Summon temp; 
    764  
    765                 uint32 i = fields[0].GetUInt32(); 
    766                 temp.position_x = fields[1].GetFloat(); 
    767                 temp.position_y = fields[2].GetFloat(); 
    768                 temp.position_z = fields[3].GetFloat(); 
    769                 temp.orientation = fields[4].GetFloat(); 
    770                 temp.SpawnTimeSecs = fields[5].GetUInt32(); 
    771  
    772                 //Add to map 
    773                 EventAI_Summon_Map[i] = temp; 
    774                 ++Count; 
    775  
    776             }while (result->NextRow()); 
    777  
    778             delete result; 
    779             outstring_log(""); 
    780             outstring_log("TSCR: >> Loaded %u EventAI_Summons", Count); 
    781  
    782         }else outstring_log("TSCR: WARNING >> Loaded 0 EventAI_Summons. DB table `EventAI_Summons` is empty."); 
    783  
    784         //Gather event data 
    785         result = TScriptDB.PQuery("SELECT `id`,`creature_id`,`event_type`,`event_inverse_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action1_type`,`action1_param1`,`action1_param2`,`action1_param3`,`action2_type`,`action2_param1`,`action2_param2`,`action2_param3`,`action3_type`,`action3_param1`,`action3_param2`,`action3_param3`" 
    786             "FROM `eventai_scripts`"); 
    787  
    788         //Drop Existing EventAI List 
    789         EventAI_Event_List.clear(); 
    790  
    791         if (result) 
    792         { 
    793             outstring_log( "TSCR: Loading EventAI_Scripts..."); 
    794             barGoLink bar(result->GetRowCount()); 
    795             uint32 Count = 0; 
    796  
    797             do 
    798             { 
    799                 bar.step(); 
    800                 Field *fields = result->Fetch(); 
    801  
    802                 EventAI_Event temp; 
    803  
    804                 temp.event_id = fields[0].GetUInt32(); 
    805                 uint32 i = temp.event_id; 
    806                 temp.creature_id = fields[1].GetUInt32(); 
    807                 temp.event_type = fields[2].GetUInt16(); 
    808                 temp.event_inverse_phase_mask = fields[3].GetUInt32(); 
    809                 temp.event_chance = fields[4].GetUInt8(); 
    810                 temp.event_flags = fields[5].GetUInt8(); 
    811                 temp.event_param1 = fields[6].GetUInt32(); 
    812                 temp.event_param2 = fields[7].GetUInt32(); 
    813                 temp.event_param3 = fields[8].GetUInt32(); 
    814                 temp.event_param4 = fields[9].GetUInt32(); 
    815  
    816                 //Report any errors in event 
    817                 if (temp.event_type >= EVENT_T_END) 
    818                     error_db_log("TSCR: Event %u has incorrect event type. Maybe DB requires updated version of SD2.", i); 
    819  
    820                 //No chance of this event occuring 
    821                 if (temp.event_chance == 0) 
    822                     error_db_log("TSCR: Event %u has 0 percent chance. Event will never trigger!", i); 
    823                 //Chance above 100, force it to be 100 
    824                 if (temp.event_chance > 100) 
     1041                temp.action[j].type = fields[10+(j*4)].GetUInt16(); 
     1042                temp.action[j].param1 = fields[11+(j*4)].GetUInt32(); 
     1043                temp.action[j].param2 = fields[12+(j*4)].GetUInt32(); 
     1044                temp.action[j].param3 = fields[13+(j*4)].GetUInt32(); 
     1045 
     1046                //Report any errors in actions 
     1047                switch (temp.action[j].type) 
    8251048                { 
    826                     error_db_log("TSCR: Creature %u are using event %u with more than 100 percent chance. Adjusting to 100 percent.", temp.creature_id, i); 
    827                     temp.event_chance = 100; 
    828                 } 
    829  
    830                 //Individual event checks 
    831                 switch (temp.event_type) 
    832                 { 
    833                     case EVENT_T_HP: 
    834                     case EVENT_T_MANA: 
    835                     case EVENT_T_TARGET_HP: 
     1049                    case ACTION_T_SAY: 
     1050                    case ACTION_T_YELL: 
     1051                    case ACTION_T_TEXTEMOTE: 
     1052                        if (GetEventAIText(temp.action[j].param1) == DEFAULT_TEXT) 
     1053                            error_db_log("TSCR: Event %u Action %u refrences missing Localized_Text entry", i, j+1); 
     1054                        break; 
     1055 
     1056                    case ACTION_T_SOUND: 
     1057                        if (!GetSoundEntriesStore()->LookupEntry(temp.action[j].param1)) 
     1058                            error_db_log("TSCR: Event %u Action %u uses non-existant SoundID %u.", i, j+1, temp.action[j].param1); 
     1059                        break; 
     1060 
     1061                    case ACTION_T_RANDOM_SAY: 
     1062                    case ACTION_T_RANDOM_YELL: 
     1063                    case ACTION_T_RANDOM_TEXTEMOTE: 
     1064                        if ((temp.action[j].param1 != 0xffffffff && GetEventAIText(temp.action[j].param1) == DEFAULT_TEXT) || 
     1065                            (temp.action[j].param2 != 0xffffffff && GetEventAIText(temp.action[j].param2) == DEFAULT_TEXT) || 
     1066                            (temp.action[j].param3 != 0xffffffff && GetEventAIText(temp.action[j].param3) == DEFAULT_TEXT)) 
     1067                            error_db_log("TSCR: Event %u Action %u refrences missing Localized_Text entry", i, j+1); 
     1068                        break; 
     1069 
     1070                    case ACTION_T_CAST: 
    8361071                        { 
    837                             if (temp.event_param2 > 100) 
    838                                 error_db_log("TSCR: Creature %u are using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! ", temp.creature_id, i); 
    839  
    840                             if (temp.event_param1 <= temp.event_param2) 
    841                                 error_db_log("TSCR: Creature %u are using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! ", temp.creature_id, i); 
    842  
    843                             if (temp.event_flags & EFLAG_REPEATABLE && !temp.event_param3 && !temp.event_param4) 
    844                             { 
    845                                 error_db_log("TSCR: Creature %u has param3 and param4=0 (RepeatMin/RepeatMax) but cannot be repeatable without timers. Removing EFLAG_REPEATABLE for event %u.", temp.creature_id, i); 
    846                                 temp.event_flags &= ~EFLAG_REPEATABLE; 
    847                             } 
     1072                            if (!GetSpellStore()->LookupEntry(temp.action[j].param1)) 
     1073                                error_db_log("TSCR: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param1); 
     1074 
     1075                            if (temp.action[j].param2 >= TARGET_T_END) 
     1076                                error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); 
    8481077                        } 
    8491078                        break; 
    8501079 
    851                     case EVENT_T_SPELLHIT: 
     1080                    case ACTION_T_REMOVEAURASFROMSPELL: 
    8521081                        { 
    853                             if (temp.event_param1) 
    854                             { 
    855                                 SpellEntry const* pSpell = GetSpellStore()->LookupEntry(temp.event_param1); 
    856                                 if (!pSpell) 
    857                                 { 
    858                                     error_db_log("TSCR: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.event_param1, i); 
    859                                     continue; 
    860                                 } 
    861  
    862                                 if (temp.event_param2_s != -1 && temp.event_param2 != pSpell->SchoolMask) 
    863                                     error_db_log("TSCR: Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", temp.creature_id, temp.event_param1, i); 
    864                             } 
    865  
    866                             //TODO: fix this system with SPELL_SCHOOL_MASK. Current complicate things, using int32(-1) instead of just 0 
    867                             //SPELL_SCHOOL_MASK_NONE = 0 and does not exist, thus it can not ever trigger or be used in SpellHit() 
    868                             if (temp.event_param2_s != -1 && temp.event_param2_s > SPELL_SCHOOL_MASK_ALL) 
    869                                 error_db_log("TSCR: Creature %u is using invalid SpellSchoolMask(%u) defined in event %u.", temp.creature_id, temp.event_param2, i); 
    870  
    871                             if (temp.event_param4 < temp.event_param3) 
    872                                 error_db_log("TSCR: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); 
     1082                            if (!GetSpellStore()->LookupEntry(temp.action[j].param2)) 
     1083                                error_db_log("TSCR: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param2); 
     1084 
     1085                            if (temp.action[j].param1 >= TARGET_T_END) 
     1086                                error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); 
    8731087                        } 
    8741088                        break; 
    8751089 
    876                     case EVENT_T_RANGE: 
    877                     case EVENT_T_OOC_LOS: 
    878                     case EVENT_T_FRIENDLY_HP: 
    879                     case EVENT_T_FRIENDLY_IS_CC: 
    880                     case EVENT_T_FRIENDLY_MISSING_BUFF: 
     1090                    case ACTION_T_CASTCREATUREGO: 
    8811091                        { 
    882                             if (temp.event_param4 < temp.event_param3) 
    883                                 error_db_log("TSCR: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); 
     1092                            if (!GetSpellStore()->LookupEntry(temp.action[j].param2)) 
     1093                                error_db_log("TSCR: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param2); 
     1094 
     1095                            if (temp.action[j].param3 >= TARGET_T_END) 
     1096                                error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); 
    8841097                        } 
    8851098                        break; 
    8861099 
    887                     case EVENT_T_TIMER: 
    888                     case EVENT_T_TIMER_OOC: 
     1100                    //2nd param target 
     1101                    case ACTION_T_SUMMON_ID: 
    8891102                        { 
    890                             if (temp.event_param2 < temp.event_param1) 
    891                                 error_db_log("TSCR: Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i); 
    892  
    893                             if (temp.event_param4 < temp.event_param3) 
    894                                 error_db_log("TSCR: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); 
     1103                            if (EventAI_Summon_Map.find(temp.action[j].param3) == EventAI_Summon_Map.end()) 
     1104                                error_db_log("TSCR: Event %u Action %u summons missing EventAI_Summon %u", i, j+1, temp.action[j].param3); 
     1105 
     1106                            if (temp.action[j].param2 >= TARGET_T_END) 
     1107                                error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); 
    8951108                        } 
    8961109                        break; 
    8971110 
    898                     case EVENT_T_KILL: 
    899                     case EVENT_T_TARGET_CASTING: 
    900                         { 
    901                             if (temp.event_param2 < temp.event_param1) 
    902                                 error_db_log("TSCR: Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); 
    903                         } 
     1111                    case ACTION_T_SUMMON: 
     1112                    case ACTION_T_THREAT_SINGLE_PCT: 
     1113                    case ACTION_T_QUEST_EVENT: 
     1114                    case ACTION_T_SET_UNIT_FLAG: 
     1115                    case ACTION_T_REMOVE_UNIT_FLAG: 
     1116                    case ACTION_T_SET_INST_DATA64: 
     1117                        if (temp.action[j].param2 >= TARGET_T_END) 
     1118                            error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); 
    9041119                        break; 
    9051120 
    906                     case EVENT_T_AGGRO: 
    907                     case EVENT_T_DEATH: 
    908                     case EVENT_T_EVADE: 
    909                     case EVENT_T_SPAWNED: 
    910                         { 
    911                             if (temp.event_flags & EFLAG_REPEATABLE) 
    912                             { 
    913                                 error_db_log("TSCR: Creature %u has EFLAG_REPEATABLE set. Event can never be repeatable. Removing flag for event %u.", temp.creature_id, i); 
    914                                 temp.event_flags &= ~EFLAG_REPEATABLE; 
    915                             } 
    916                         } 
     1121                    //3rd param target 
     1122                    case ACTION_T_SET_UNIT_FIELD: 
     1123                        if (temp.action[j].param3 >= TARGET_T_END) 
     1124                            error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); 
    9171125                        break; 
    918                 }; 
    919  
    920                 for (uint32 j = 0; j < MAX_ACTIONS; j++) 
    921                 { 
    922                     temp.action[j].type = fields[10+(j*4)].GetUInt16(); 
    923                     temp.action[j].param1 = fields[11+(j*4)].GetUInt32(); 
    924                     temp.action[j].param2 = fields[12+(j*4)].GetUInt32(); 
    925                     temp.action[j].param3 = fields[13+(j*4)].GetUInt32(); 
    926  
    927                     //Report any errors in actions 
    928                     switch (temp.action[j].type) 
    929                     { 
    930                         case ACTION_T_SAY: 
    931                         case ACTION_T_YELL: 
    932                         case ACTION_T_TEXTEMOTE: 
    933                             if (GetEventAIText(temp.action[j].param1) == DEFAULT_TEXT) 
    934                                 error_db_log("TSCR: Event %u Action %u refrences missing Localized_Text entry", i, j+1); 
    935                             break; 
    936  
    937                         case ACTION_T_SOUND: 
    938                             if (!GetSoundEntriesStore()->LookupEntry(temp.action[j].param1)) 
    939                                 error_db_log("TSCR: Event %u Action %u uses non-existant SoundID %u.", i, j+1, temp.action[j].param1); 
    940                             break; 
    941  
    942                         case ACTION_T_RANDOM_SAY: 
    943                         case ACTION_T_RANDOM_YELL: 
    944                         case ACTION_T_RANDOM_TEXTEMOTE: 
    945                             if ((temp.action[j].param1 != 0xffffffff && GetEventAIText(temp.action[j].param1) == DEFAULT_TEXT) || 
    946                                 (temp.action[j].param2 != 0xffffffff && GetEventAIText(temp.action[j].param2) == DEFAULT_TEXT) || 
    947                                 (temp.action[j].param3 != 0xffffffff && GetEventAIText(temp.action[j].param3) == DEFAULT_TEXT)) 
    948                                 error_db_log("TSCR: Event %u Action %u refrences missing Localized_Text entry", i, j+1); 
    949                             break; 
    950  
    951                         case ACTION_T_CAST: 
    952                             { 
    953                                 if (!GetSpellStore()->LookupEntry(temp.action[j].param1)) 
    954                                     error_db_log("TSCR: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param1); 
    955  
    956                                 if (temp.action[j].param2 >= TARGET_T_END) 
    957                                     error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); 
    958                             } 
    959                             break; 
    960  
    961                         case ACTION_T_REMOVEAURASFROMSPELL: 
    962                             { 
    963                                 if (!GetSpellStore()->LookupEntry(temp.action[j].param2)) 
    964                                     error_db_log("TSCR: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param2); 
    965  
    966                                 if (temp.action[j].param1 >= TARGET_T_END) 
    967                                     error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); 
    968                             } 
    969                             break; 
    970  
    971                         case ACTION_T_CASTCREATUREGO: 
    972                             { 
    973                                 if (!GetSpellStore()->LookupEntry(temp.action[j].param2)) 
    974                                     error_db_log("TSCR: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param2); 
    975  
    976                                 if (temp.action[j].param3 >= TARGET_T_END) 
    977                                     error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); 
    978                             } 
    979                             break; 
    980  
    981                         //2nd param target 
    982                         case ACTION_T_SUMMON_ID: 
    983                             { 
    984                                 if (EventAI_Summon_Map.find(temp.action[j].param3) == EventAI_Summon_Map.end()) 
    985                                     error_db_log("TSCR: Event %u Action %u summons missing EventAI_Summon %u", i, j+1, temp.action[j].param3); 
    986  
    987                                 if (temp.action[j].param2 >= TARGET_T_END) 
    988                                     error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); 
    989                             } 
    990                             break; 
    991  
    992                         case ACTION_T_SUMMON: 
    993                         case ACTION_T_THREAT_SINGLE_PCT: 
    994                         case ACTION_T_QUEST_EVENT: 
    995                         case ACTION_T_SET_UNIT_FLAG: 
    996                         case ACTION_T_REMOVE_UNIT_FLAG: 
    997                         case ACTION_T_SET_INST_DATA64: 
    998                             if (temp.action[j].param2 >= TARGET_T_END) 
    999                                 error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); 
    1000                             break; 
    1001  
    1002                         //3rd param target 
    1003                         case ACTION_T_SET_UNIT_FIELD: 
    1004                             if (temp.action[j].param3 >= TARGET_T_END) 
    1005                                 error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); 
    1006                             break; 
    1007  
    1008                         case ACTION_T_SET_PHASE: 
    1009                             if (temp.action[j].param1 > 31) 
    1010                                 error_db_log("TSCR: Event %u Action %u attempts to set phase > 31. Phase mask cannot be used past phase 31.", i, j+1); 
    1011                             break; 
    1012  
    1013                         case ACTION_T_INC_PHASE: 
    1014                             if (!temp.action[j].param1) 
    1015                                 error_db_log("TSCR: Event %u Action %u is incrementing phase by 0. Was this intended?", i, j+1); 
    1016                             break; 
    1017  
    1018                         case ACTION_T_KILLED_MONSTER: 
    1019                             if (temp.event_type != EVENT_T_DEATH) 
    1020                                 outstring_log("TSCR WARNING: Event %u Action %u calling ACTION_T_KILLED_MONSTER outside of EVENT_T_DEATH", i, j+1); 
    1021                             break; 
    1022  
    1023                         case ACTION_T_SET_INST_DATA: 
    1024                             if (temp.action[j].param2 > 3) 
    1025                                 error_db_log("TSCR: Event %u Action %u attempts to set instance data above encounter state 3. Custom case?", i, j+1); 
    1026                             break; 
    1027  
    1028                         default: 
    1029                             break; 
    1030                     } 
    1031  
    1032                     if (temp.action[j].type >= ACTION_T_END) 
    1033                         error_db_log("TSCR: Event %u Action %u has incorrect action type. Maybe DB requires updated version of SD2.", i, j+1); 
     1126 
     1127                    case ACTION_T_SET_PHASE: 
     1128                        if (temp.action[j].param1 > 31) 
     1129                            error_db_log("TSCR: Event %u Action %u attempts to set phase > 31. Phase mask cannot be used past phase 31.", i, j+1); 
     1130                        break; 
     1131 
     1132                    case ACTION_T_INC_PHASE: 
     1133                        if (!temp.action[j].param1) 
     1134                            error_db_log("TSCR: Event %u Action %u is incrementing phase by 0. Was this intended?", i, j+1); 
     1135                        break; 
     1136 
     1137                    case ACTION_T_KILLED_MONSTER: 
     1138                        if (temp.event_type != EVENT_T_DEATH) 
     1139                            outstring_log("SD2 WARNING: Event %u Action %u calling ACTION_T_KILLED_MONSTER outside of EVENT_T_DEATH", i, j+1); 
     1140                        break; 
     1141 
     1142                    case ACTION_T_SET_INST_DATA: 
     1143                        if (temp.action[j].param2 > 3) 
     1144                            error_db_log("TSCR: Event %u Action %u attempts to set instance data above encounter state 3. Custom case?", i, j+1); 
     1145                        break; 
     1146 
     1147                    default: 
     1148                        if (temp.action[j].type >= ACTION_T_END) 
     1149                            error_db_log("TSCR: Event %u Action %u has incorrect action type. Maybe DB requires updated version of SD2.", i, j+1); 
     1150                        break; 
    10341151                } 
    1035  
    1036                 //Add to list 
    1037                 EventAI_Event_List.push_back(temp); 
    1038                 ++Count; 
    1039  
    1040             }while (result->NextRow()); 
    1041  
    1042             delete result; 
    1043             outstring_log(""); 
    1044             outstring_log("TSCR: >> Loaded %u EventAI_Events", Count); 
    1045  
    1046         }else outstring_log("TSCR: WARNING >> Loaded 0 EventAI_Scripts. DB table `EventAI_Scripts` is empty."); 
    1047  
    1048         // Gather Script Text  
    1049         result = TScriptDB.PQuery("SELECT `id`, `sound`, `type`, `language`, `text`" 
    1050             "FROM `script_texts`;"); 
    1051  
    1052         // Drop Existing Script Text Map 
    1053         Script_TextMap.clear(); 
    1054  
    1055         if(result) 
    1056         { 
    1057             outstring_log("TSCR: Loading Script Text..."); 
    1058             barGoLink bar(result->GetRowCount()); 
    1059             uint32 count = 0; 
    1060  
    1061             do 
    1062             { 
    1063                 bar.step(); 
    1064                 Field* fields = result->Fetch(); 
    1065                 ScriptText temp; 
    1066  
    1067                 uint32 i            = fields[0].GetInt32(); 
    1068                 temp.SoundId        = fields[1].GetInt32(); 
    1069                 temp.Type           = fields[2].GetInt32(); 
    1070                 temp.Language       = fields[3].GetInt32(); 
    1071                 temp.Text           = fields[4].GetString(); 
    1072  
    1073                 if (temp.SoundId) 
    1074                 { 
    1075                     if (!GetSoundEntriesStore()->LookupEntry(temp.SoundId)) 
    1076                         error_db_log("TSCR: Id %u in table script_texts has soundid %u but sound does not exist.",i,temp.SoundId); 
    1077                 } 
    1078  
    1079                 if(!strlen(temp.Text.c_str())) 
    1080                     error_db_log("TSCR: Id %u in table script_texts has no text.", i); 
    1081  
    1082                 Script_TextMap[i] = temp; 
    1083                 ++count; 
    1084  
    1085             }while(result->NextRow()); 
    1086  
    1087             delete result; 
    1088  
    1089             outstring_log(""); 
    1090             outstring_log("TSCR: Loaded %u Script Texts", count); 
    1091  
    1092         }else outstring_log("TSCR WARNING >> Loaded 0 Script Texts. Database table `script_texts` is empty."); 
    1093  
    1094         //Free database thread and resources 
    1095         TScriptDB.HaltDelayThread(); 
    1096  
    1097         //***End DB queries*** 
     1152            } 
     1153 
     1154            //Add to list 
     1155            EventAI_Event_List.push_back(temp); 
     1156            ++Count; 
     1157        } while (result->NextRow()); 
     1158 
     1159        delete result; 
     1160 
     1161        outstring_log(""); 
     1162        outstring_log(">> Loaded %u EventAI scripts", Count); 
     1163    }else 
     1164    { 
     1165        barGoLink bar(1); 
     1166        bar.step(); 
     1167        outstring_log(""); 
     1168        outstring_log(">> Loaded 0 EventAI scripts. DB table `eventai_scripts` is empty."); 
    10981169    } 
     1170 
     1171    //Free database thread and resources 
     1172    TScriptDB.HaltDelayThread(); 
     1173 
    10991174} 
    11001175 
    11011176struct TSpellSummary { 
    1102     uint8 Targets;    // set of enum SelectTarget 
    1103     uint8 Effects;    // set of enum SelectEffect  
     1177    uint8 Targets;                                          // set of enum SelectTarget 
     1178    uint8 Effects;                                          // set of enum SelectEffect  
    11041179}extern *SpellSummary; 
    11051180 
     
    11201195void ScriptsInit() 
    11211196{ 
     1197    bool CanLoadDB = true; 
     1198 
    11221199    //Trinity Script startup 
    11231200    outstring_log(" _____     _       _ _         ____            _       _"); 
     
    11321209    //Get configuration file 
    11331210    if (!TScriptConfig.SetSource(_TRINITY_SCRIPT_CONFIG)) 
    1134         error_log("TSCR: Unable to open configuration file, Database will be unaccessible"); 
    1135     else outstring_log("TSCR: Using configuration file %s", _TRINITY_SCRIPT_CONFIG); 
    1136  
     1211    { 
     1212        CanLoadDB = false; 
     1213        error_log("TSCR: Unable to open configuration file. Database will be unaccessible. Configuration values will use default."); 
     1214    } 
     1215    else outstring_log("TSCR: Using configuration file %s",_TRINITY_SCRIPT_CONFIG); 
    11371216 
    11381217    //Check config file version 
     
    11501229 
    11511230    outstring_log("TSCR: Using locale %u", Locale); 
     1231 
     1232    EAI_ErrorLevel = TScriptConfig.GetIntDefault("EAIErrorLevel", 1); 
     1233 
     1234    switch (EAI_ErrorLevel) 
     1235    { 
     1236    case 0: 
     1237        outstring_log("TSCR: EventAI Error Reporting level set to 0 (Startup Errors only)"); 
     1238        break; 
     1239    case 1: 
     1240        outstring_log("TSCR: EventAI Error Reporting level set to 1 (Startup errors and Runtime event errors)"); 
     1241        break; 
     1242    case 2: 
     1243        outstring_log("TSCR: EventAI Error Reporting level set to 2 (Startup errors, Runtime event errors, and Creation errors)"); 
     1244        break; 
     1245    default: 
     1246        outstring_log("TSCR: Unknown EventAI Error Reporting level. Defaulting to 1 (Startup errors and Runtime event errors)"); 
     1247        EAI_ErrorLevel = 1; 
     1248        break; 
     1249    } 
     1250 
    11521251    outstring_log(""); 
    11531252 
    1154     EAI_ErrorLevel = TScriptConfig.GetIntDefault("EAIErrorLevel", 1); 
    1155  
    1156     switch (EAI_ErrorLevel) 
    1157     { 
    1158         case 0: 
    1159             outstring_log("TSCR: EventAI Error Reporting level set to 0 (Startup Errors only)"); 
    1160             break; 
    1161  
    1162         case 1: 
    1163             outstring_log("TSCR: EventAI Error Reporting level set to 1 (Startup errors and Runtime event errors)"); 
    1164             break; 
    1165  
    1166         case 2: 
    1167             outstring_log("TSCR: EventAI Error Reporting level set to 2 (Startup errors, Runtime event errors, and Creation errors)"); 
    1168             break; 
    1169  
    1170         default: 
    1171             outstring_log("TSCR: Unknown EventAI Error Reporting level. Defaulting to 1 (Startup errors and Runtime event errors)"); 
    1172             EAI_ErrorLevel = 1; 
    1173             break; 
    1174     } 
     1253    //Load database (must be called after TScriptConfig.SetSource). In case it failed, no need to even try load. 
     1254    if (CanLoadDB) 
     1255        LoadDatabase(); 
     1256 
     1257    outstring_log("TSCR: Loading C++ scripts"); 
     1258    barGoLink bar(1); 
     1259    bar.step(); 
    11751260    outstring_log(""); 
    1176  
    1177     //Load database (must be called after TScriptConfig.SetSource) 
    1178     LoadDatabase(); 
    11791261 
    11801262    nrscripts = 0; 
     
    17561838} 
    17571839 
    1758 const char* GetScriptLocalizedText(uint32 entry) 
    1759 {    
    1760     const char* temp = NULL; 
    1761  
    1762     HM_NAMESPACE::hash_map<uint32, Localized_Text>::iterator i = Script_LocalizedTextMap.find(entry); 
    1763  
    1764     if (i == Script_LocalizedTextMap.end()) 
    1765     { 
    1766         error_log("TSCR: Script Localized Text %u not found", entry); 
    1767         return DEFAULT_TEXT; 
    1768     } 
    1769  
    1770     switch (Locale) 
    1771     { 
    1772         case 1: 
    1773             temp =  (*i).second.locale_1.c_str(); 
    1774             break; 
    1775  
    1776         case 2: 
    1777             temp =  (*i).second.locale_2.c_str(); 
    1778             break; 
    1779  
    1780         case 3: 
    1781             temp =  (*i).second.locale_3.c_str(); 
    1782             break; 
    1783  
    1784         case 4: 
    1785             temp =  (*i).second.locale_4.c_str(); 
    1786             break; 
    1787  
    1788         case 5: 
    1789             temp =  (*i).second.locale_5.c_str(); 
    1790             break; 
    1791  
    1792         case 6: 
    1793             temp =  (*i).second.locale_6.c_str(); 
    1794             break; 
    1795  
    1796         case 7: 
    1797             temp =  (*i).second.locale_7.c_str(); 
    1798             break; 
    1799  
    1800         case 8: 
    1801             temp =  (*i).second.locale_8.c_str(); 
    1802             break; 
    1803     }; 
    1804  
    1805     if (strlen(temp)) 
    1806         return temp; 
    1807  
    1808     return DEFAULT_TEXT; 
    1809 } 
    1810  
    18111840const char* GetEventAIText(uint32 entry) 
    18121841{ 
     
    18341863} 
    18351864 
    1836 void ProcessScriptText(uint32 id, WorldObject* pSource, Unit* target) 
     1865void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target) 
    18371866{ 
    18381867    if (!pSource) 
    18391868    { 
    1840         error_log("TSCR: ProcessScriptText invalid Source pointer."); 
     1869        error_log("TSCR: DoScriptText entry %i, invalid Source pointer.",textEntry); 
    18411870        return; 
    18421871    } 
    18431872 
    1844     HM_NAMESPACE::hash_map<uint32, ScriptText>::iterator i = Script_TextMap.find(id); 
    1845  
    1846     if (i == Script_TextMap.end()) 
    1847     { 
    1848         error_log("TSCR: ProcessScriptText could not find id %u.",id); 
     1873    if (textEntry >= 0) 
     1874    { 
     1875        error_log("TSCR: DoScriptText attempts to process entry %i, but entry must be negative.",textEntry); 
    18491876        return; 
    18501877    } 
    18511878 
     1879    HM_NAMESPACE::hash_map<int32, StringTextData>::iterator i = TextMap.find(textEntry); 
     1880 
     1881    if (i == TextMap.end()) 
     1882    { 
     1883        error_log("TSCR: DoScriptText could not find text entry %i.",textEntry); 
     1884        return; 
     1885    } 
     1886 
    18521887    if((*i).second.SoundId) 
    18531888    { 
    1854         if(GetSoundEntriesStore()->LookupEntry((*i).second.SoundId)) 
     1889        if( GetSoundEntriesStore()->LookupEntry((*i).second.SoundId) ) 
    18551890        { 
    18561891            pSource->SendPlaySound((*i).second.SoundId, false); 
    18571892        } 
    18581893        else 
    1859             error_log("TSCR: ProcessScriptText id %u tried to process invalid soundid %u.",id,(*i).second.SoundId); 
     1894            error_log("TSCR: DoScriptText entry %i tried to process invalid sound id %u.",textEntry,(*i).second.SoundId); 
    18601895    } 
    18611896 
     
    18631898    { 
    18641899        case CHAT_TYPE_SAY: 
    1865             pSource->MonsterSay((*i).second.Text.c_str(), (*i).second.Language, target ? target->GetGUID() : 0); 
     1900            pSource->MonsterSay(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); 
    18661901            break; 
    1867  
    18681902        case CHAT_TYPE_YELL: 
    1869             pSource->MonsterYell((*i).second.Text.c_str(), (*i).second.Language, target ? target->GetGUID() : 0); 
     1903            pSource->MonsterYell(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); 
    18701904            break; 
    1871  
    18721905        case CHAT_TYPE_TEXT_EMOTE: 
    1873             pSource->MonsterTextEmote((*i).second.Text.c_str(), target ? target->GetGUID() : 0); 
     1906            pSource->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0); 
    18741907            break; 
    1875  
    18761908        case CHAT_TYPE_BOSS_EMOTE: 
    1877             pSource->MonsterTextEmote((*i).second.Text.c_str(), target ? target->GetGUID() : 0, true); 
     1909            pSource->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0, true); 
    18781910            break; 
    1879  
    18801911        case CHAT_TYPE_WHISPER: 
    18811912            { 
    18821913                if (target && target->GetTypeId() == TYPEID_PLAYER) 
    1883                     pSource->MonsterWhisper((*i).second.Text.c_str(), target->GetGUID()); 
    1884                 else error_log("TSCR: ProcessScriptText id %u cannot whisper without target unit (TYPEID_PLAYER).", id); 
     1914                    pSource->MonsterWhisper(textEntry, target->GetGUID()); 
     1915                else error_log("TSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry); 
    18851916            }break; 
    1886  
    18871917        case CHAT_TYPE_BOSS_WHISPER: 
    18881918            { 
    18891919                if (target && target->GetTypeId() == TYPEID_PLAYER) 
    1890                     pSource->MonsterWhisper((*i).second.Text.c_str(), target->GetGUID(), true); 
    1891                 else error_log("TSCR: ProcessScriptText id %u cannot whisper without target unit (TYPEID_PLAYER).", id); 
     1920                    pSource->MonsterWhisper(textEntry, target->GetGUID(), true); 
     1921                else error_log("TSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry); 
    18921922            }break; 
    18931923    } 
  • trunk/src/bindings/scripts/ScriptMgr.h

    r5 r28  
    11/* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> 
    2 * This program is free software licensed under GPL version 2 
    3 * Please see the included DOCS/LICENSE.TXT for more information */ 
     2 * This program is free software licensed under GPL version 2 
     3 * Please see the included DOCS/LICENSE.TXT for more information */ 
    44 
    55#ifndef SCRIPTMGR_H 
     
    2222class WorldObject; 
    2323 
    24 #define MAX_SCRIPTS     1000            //72 bytes each (approx 71kb) 
     24#define MAX_SCRIPTS         1000                            //72 bytes each (approx 71kb) 
     25#define VISIBLE_RANGE       (166.0f)                        //MAX visible range (size of grid) 
     26#define DEFAULT_TEXT        "<Trinity Script Text Entry Missing!>" 
    2527 
    26 //MAX visible range (size of grid) 
    27 #define VISIBLE_RANGE   (166.0f) 
    28  
    29 #define DEFAULT_TEXT    "<Trinity Script Text Entry Missing!>" 
    30  
    31 // 
    3228struct Script 
    3329{ 
     
    4137std::string Name; 
    4238 
    43 // -- Quest/gossip Methods to be scripted -- 
     39// Quest/gossip Methods to be scripted 
    4440bool (*pGossipHello         )(Player*, Creature*); 
    4541bool (*pQuestAccept         )(Player*, Creature*, Quest const* ); 
     
    6258CreatureAI* (*GetAI)(Creature*); 
    6359InstanceData* (*GetInstanceData)(Map*); 
    64 // ----------------------------------------- 
    6560}; 
    6661 
     
    7065// Localized Text function 
    7166const char* GetEventAILocalizedText(uint32 entry); 
    72 const char* GetScriptLocalizedText(uint32 entry); 
    7367 
    7468//EventAI text function 
    75 const char* GetEventAIText(uint32 entry); // TODO: Locales 
     69const char* GetEventAIText(uint32 entry);                   // TODO: Locales 
    7670 
    77 // Script Text function 
    78 void ProcessScriptText(uint32 id, WorldObject* pSource, Unit* target = NULL); // TODO: Locales 
     71//Generic scripting text function 
     72void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target = NULL); 
    7973 
    8074#if COMPILER == COMPILER_GNU 
  • trunk/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp

    r18 r28  
    400400        }else EnfeebleResetTimer -= diff; 
    401401 
    402         if(m_creature->hasUnitState(UNIT_STAT_STUNDED))     //While shifting to phase 2 malchezaar stuns himself 
     402        if(m_creature->hasUnitState(UNIT_STAT_STUNNED))     //While shifting to phase 2 malchezaar stuns himself 
    403403            return; 
    404404 
  • trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp

    r6 r28  
    10031003            }else Freezing_Trap_Timer -= diff; 
    10041004 
    1005             if(!m_creature->getVictim()->hasUnitState(UNIT_STAT_STUNDED | UNIT_STAT_ROOT | UNIT_STAT_CONFUSED | UNIT_STAT_DISTRACTED)) 
     1005            if(!m_creature->getVictim()->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_ROOT | UNIT_STAT_CONFUSED | UNIT_STAT_DISTRACTED)) 
    10061006                DoMeleeAttackIfReady(); 
    10071007        }else 
  • trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp

    r6 r28  
    1717/* ScriptData 
    1818SDName: Boss_Selin_Fireheart 
    19 SD%Complete: 99 
     19SD%Complete: 90 
    2020SDComment: Heroic and Normal Support. Needs further testing. 
    2121SDCategory: Magister's Terrace 
     
    7474            { 
    7575                uint64 guid = pInstance->GetData64(DATA_FEL_CRYSTAL); 
    76                 outstring_log("Selin: Adding Fel Crystal %u to list", guid); 
     76                debug_log("SD2: Selin: Adding Fel Crystal %u to list", guid); 
    7777                Crystals.push_back(guid); 
    7878            } 
     
    117117 
    118118            GameObject* Door = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR)); 
    119             if(Door) 
    120                 Door->SetGoState(0);                        // Close the door. Open it only in JustDied. 
    121  
     119            if( Door ) 
     120                Door->SetGoState(0);                        // Open the big encounter door. Close it in Aggro and open it only in JustDied(and here) 
     121                                                            // Small door opened after event are expected to be closed by default 
    122122            // Set Inst data for encounter 
    123123            pInstance->SetData(DATA_SELIN_EVENT, NOT_STARTED); 
     
    161161            } 
    162162        } 
    163         if(CrystalChosen) 
     163        if( CrystalChosen ) 
    164164        { 
    165165            DoYell(SAY_ENERGY, LANG_UNIVERSAL, NULL); 
    166166            DoPlaySoundToSet(m_creature, SOUND_ENERGY); 
     167 
    167168            CrystalChosen->CastSpell(CrystalChosen, SPELL_FEL_CRYSTAL_COSMETIC, true); 
    168169 
     
    186187            //Creature* pCrystal = ((Creature*)Unit::GetUnit(*m_creature, FelCrystals[i])); 
    187188            Creature* pCrystal = ((Creature*)Unit::GetUnit(*m_creature, *itr)); 
    188             if(pCrystal && pCrystal->isAlive()) 
     189            if( pCrystal && pCrystal->isAlive()) 
    189190                pCrystal->DealDamage(pCrystal, pCrystal->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); 
    190191        } 
     
    195196        DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); 
    196197        DoPlaySoundToSet(m_creature, SOUND_AGGRO); 
     198 
     199        if( pInstance ) 
     200        { 
     201            GameObject* EncounterDoor = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR)); 
     202            if( EncounterDoor ) 
     203                EncounterDoor->SetGoState(1);               //Close the encounter door, open it in JustDied/Reset 
     204        } 
    197205    } 
    198206 
     
    246254 
    247255        pInstance->SetData(DATA_SELIN_EVENT, DONE);         // Encounter complete! 
     256 
    248257        GameObject* EncounterDoor = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR)); 
    249         if(EncounterDoor) 
    250             EncounterDoor->SetGoState(1);                   // Open the door 
     258        if( EncounterDoor ) 
     259            EncounterDoor->SetGoState(0);                   // Open the encounter door 
     260 
     261        GameObject* ContinueDoor = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_SELIN_DOOR)); 
     262        if( ContinueDoor ) 
     263            ContinueDoor->SetGoState(0);                    // Open the door leading further in 
    251264 
    252265        ShatterRemainingCrystals(); 
     
    303316        }else 
    304317        { 
    305             if(IsDraining) 
    306                 if(EmpowerTimer < diff) 
    307             { 
    308                 IsDraining = false; 
    309                 DrainingCrystal = false; 
    310                 DoYell(SAY_EMPOWERED, LANG_UNIVERSAL, NULL); 
    311                 DoPlaySoundToSet(m_creature, SOUND_EMPOWERED); 
    312                 Unit* CrystalChosen = Unit::GetUnit(*m_creature, CrystalGUID); 
    313                 if(CrystalChosen && CrystalChosen->isAlive()) 
    314                     // Use Deal Damage to kill it, not setDeathState. 
    315                     CrystalChosen->DealDamage(CrystalChosen, CrystalChosen->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); 
    316  
    317                 CrystalGUID = 0; 
    318  
    319                 m_creature->GetMotionMaster()->Clear(); 
    320                 m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); 
    321             }else EmpowerTimer -= diff; 
     318            if( IsDraining ) 
     319            { 
     320                if( EmpowerTimer < diff ) 
     321                { 
     322                    IsDraining = false; 
     323                    DrainingCrystal = false; 
     324 
     325                    DoYell(SAY_EMPOWERED, LANG_UNIVERSAL, NULL); 
     326                    DoPlaySoundToSet(m_creature, SOUND_EMPOWERED); 
     327 
     328                    Unit* CrystalChosen = Unit::GetUnit(*m_creature, CrystalGUID); 
     329                    if( CrystalChosen && CrystalChosen->isAlive() ) 
     330                        // Use Deal Damage to kill it, not setDeathState. 
     331                        CrystalChosen->DealDamage(CrystalChosen, CrystalChosen->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); 
     332 
     333                    CrystalGUID = 0; 
     334 
     335                    m_creature->GetMotionMaster()->Clear(); 
     336                    m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); 
     337                }else EmpowerTimer -= diff; 
     338            } 
    322339        } 
    323340 
  • trunk/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp

    r6 r28  
    1717/* ScriptData 
    1818SDName: Instance_Magisters_Terrace 
    19 SD%Complete: 100 
     19SD%Complete: 60 
    2020SDComment:  Designed only for Selin Fireheart 
    2121SDCategory: Magister's Terrace 
     
    119119        switch(entry) 
    120120        { 
    121             case 24723: 
    122                 SelinGUID = creature->GetGUID(); 
    123                 break; 
    124             case 24560: 
    125                 DelrissaGUID = creature->GetGUID(); 
    126                 break; 
    127             case 24722: 
    128                 FelCrystals.push_back(creature->GetGUID()); 
    129                 break; 
     121            case 24723: SelinGUID = creature->GetGUID(); break; 
     122            case 24560: DelrissaGUID = creature->GetGUID(); break; 
     123            case 24722: FelCrystals.push_back(creature->GetGUID()); break; 
     124        } 
     125    } 
     126 
     127    void OnObjectCreate(GameObject* go) 
     128    { 
     129        switch(go->GetEntry()) 
     130        { 
     131            case 187896:  VexallusDoorGUID = go->GetGUID();       break; 
     132            //SunwellRaid Gate 02 
     133            case 187979:  SelinDoorGUID = go->GetGUID();          break; 
     134            //Assembly Chamber Door 
     135            case 188065:  SelinEncounterDoorGUID = go->GetGUID(); break; 
     136            case 187770:  DelrissaDoorGUID = go->GetGUID();       break; 
     137            case 188165:  KaelStatue[0] = go->GetGUID();          break; 
     138            case 188166:  KaelStatue[1] = go->GetGUID();          break; 
    130139        } 
    131140    } 
     
    165174        return 0; 
    166175    } 
    167  
    168     void OnObjectCreate(GameObject* go) 
    169     { 
    170         switch(go->GetEntry()) 
    171         { 
    172             case 187896:  VexallusDoorGUID = go->GetGUID();       break; 
    173             case 187979:  SelinDoorGUID = go->GetGUID();          break; 
    174             case 188118:  SelinEncounterDoorGUID = go->GetGUID(); break; 
    175             case 187770:  DelrissaDoorGUID = go->GetGUID();       break; 
    176             case 188165:  KaelStatue[0] = go->GetGUID();          break; 
    177             case 188166:  KaelStatue[1] = go->GetGUID();          break; 
    178         } 
    179     } 
    180176}; 
    181177 
  • trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp

    r18 r28  
    8888        Abuse_Bug_Timer = 10000 + rand()%7000; 
    8989        BugsTimer = 2000; 
    90         m_creature->clearUnitState(UNIT_STAT_STUNDED); 
     90        m_creature->clearUnitState(UNIT_STAT_STUNNED); 
    9191        DontYellWhenDead = false; 
    9292        EnrageTimer = 15*60000; 
     
    291291        DoResetThreat(); 
    292292        DoCast(m_creature, SPELL_TWIN_TELEPORT_VISUAL); 
    293         m_creature->addUnitState(UNIT_STAT_STUNDED); 
     293        m_creature->addUnitState(UNIT_STAT_STUNNED); 
    294294        AfterTeleport = true; 
    295295        AfterTeleportTimer = 2000; 
     
    303303            if (!tspellcasted) 
    304304            { 
    305                 m_creature->clearUnitState(UNIT_STAT_STUNDED); 
     305                m_creature->clearUnitState(UNIT_STAT_STUNNED); 
    306306                DoCast(m_creature, SPELL_TWIN_TELEPORT); 
    307                 m_creature->addUnitState(UNIT_STAT_STUNDED); 
     307                m_creature->addUnitState(UNIT_STAT_STUNNED); 
    308308            } 
    309309 
     
    313313            { 
    314314                AfterTeleport = false; 
    315                 m_creature->clearUnitState(UNIT_STAT_STUNDED); 
     315                m_creature->clearUnitState(UNIT_STAT_STUNNED); 
    316316                Unit *nearu = PickNearestPlayer(); 
    317317                //DoYell(nearu->GetName(), LANG_UNIVERSAL, 0); 
  • trunk/src/bindings/scripts/sql/scriptdev2_structure.sql

    r5 r28  
    7474DROP TABLE IF EXISTS `script_texts`; 
    7575CREATE TABLE `script_texts` ( 
    76 `id` int(11) unsigned NOT NULL auto_increment COMMENT 'Identifier', 
    77 `sound` int(11) unsigned NOT NULL default '0', 
    78 `type` int(11) unsigned NOT NULL default '0', 
    79 `language` int(11) unsigned NOT NULL default '0', 
    80 `text` varchar(255) NOT NULL default '', 
    81 `comment` varchar(255) NOT NULL default '', 
    82 PRIMARY KEY  (`id`) 
     76  `entry` mediumint(8) NOT NULL, 
     77  `content_default` text NOT NULL, 
     78  `content_loc1` text, 
     79  `content_loc2` text, 
     80  `content_loc3` text, 
     81  `content_loc4` text, 
     82  `content_loc5` text, 
     83  `content_loc6` text, 
     84  `content_loc7` text, 
     85  `content_loc8` text, 
     86  `sound` mediumint(8) unsigned NOT NULL default '0', 
     87  `type` tinyint unsigned NOT NULL default '0', 
     88  `language` tinyint unsigned NOT NULL default '0', 
     89  `comment` text, 
     90  PRIMARY KEY  (`entry`) 
    8391) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Script Texts'; 
    8492 
    85  
    86 DROP TABLE IF EXISTS `script_localized_texts`; 
    87 CREATE TABLE `script_localized_texts` ( 
    88 `id` int(11) unsigned NOT NULL auto_increment COMMENT 'Identifier', 
    89 `locale_1` varchar(255) NOT NULL default '', 
    90 `locale_2` varchar(255) NOT NULL default '', 
    91 `locale_3` varchar(255) NOT NULL default '', 
    92 `locale_4` varchar(255) NOT NULL default '', 
    93 `locale_5` varchar(255) NOT NULL default '', 
    94 `locale_6` varchar(255) NOT NULL default '', 
    95 `locale_7` varchar(255) NOT NULL default '', 
    96 `locale_8` varchar(255) NOT NULL default '', 
    97 `comment` varchar(255) NOT NULL default '' COMMENT 'Text Comment', 
    98 PRIMARY KEY  (`id`)             
    99 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Localized Script Text'; 
    100  
     93DROP TABLE IF EXISTS `custom_texts`; 
     94CREATE TABLE `custom_texts` ( 
     95  `entry` mediumint(8) NOT NULL, 
     96  `content_default` text NOT NULL, 
     97  `content_loc1` text, 
     98  `content_loc2` text, 
     99  `content_loc3` text, 
     100  `content_loc4` text, 
     101  `content_loc5` text, 
     102  `content_loc6` text, 
     103  `content_loc7` text, 
     104  `content_loc8` text, 
     105  `sound` mediumint(8) unsigned NOT NULL default '0', 
     106  `type` tinyint unsigned NOT NULL default '0', 
     107  `language` tinyint unsigned NOT NULL default '0', 
     108  `comment` text, 
     109  PRIMARY KEY  (`entry`) 
     110) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Custom Texts'; 
    101111 
    102112DROP TABLE IF EXISTS `script_db_version`; 
  • trunk/src/game/AggressorAI.cpp

    r6 r28  
    4848        return; 
    4949     
    50     if( !i_creature.getVictim() && !i_creature.hasUnitState(UNIT_STAT_STUNDED) && u->isTargetableForAttack() && 
     50    if( !i_creature.getVictim() && !i_creature.hasUnitState(UNIT_STAT_STUNNED) && u->isTargetableForAttack() && 
    5151        ( i_creature.IsHostileTo( u ) /*|| u->getVictim() && i_creature.IsFriendlyTo( u->getVictim() )*/ ) && 
    5252        u->isInAccessablePlaceFor(&i_creature) ) 
  • trunk/src/game/ArenaTeamHandler.cpp

    r2 r28  
    2626#include "World.h" 
    2727#include "SocialMgr.h" 
     28#include "Language.h" 
    2829 
    2930void WorldSession::HandleInspectArenaStatsOpcode(WorldPacket & recv_data) 
     
    118119        //SendArenaTeamCommandResult(ARENA_TEAM_INVITE_SS,"",Invitedname,ARENA_TEAM_PLAYER_NOT_FOUND_S); 
    119120                                                            // can't find related opcode 
    120         SendNotification("%s is not high enough level to join your team", player->GetName()); 
     121        SendNotification(LANG_HIS_ARENA_LEVEL_REQ_ERROR, player->GetName()); 
    121122        return; 
    122123    } 
     
    155156        // should send an "arena team is full" or the likes message, I just don't know the proper values so... ERR_INTERNAL 
    156157//        SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_INTERNAL); 
    157         SendNotification("Your arena team is full, %s cannot join it.", player->GetName()); 
     158        SendNotification(LANG_YOUR_ARENA_TEAM_FULL, player->GetName()); 
    158159        return; 
    159160    } 
  • trunk/src/game/BattleGroundHandler.cpp

    r9 r28  
    5757    { 
    5858                                                            // temp, must be gossip message... 
    59         SendNotification("You don't meet Battleground level requirements"); 
     59        SendNotification(LANG_YOUR_BG_LEVEL_REQ_ERROR); 
    6060        return; 
    6161    } 
  • trunk/src/game/CharacterHandler.cpp

    r6 r28  
    3737#include "SocialMgr.h" 
    3838#include "Util.h" 
     39#include "Language.h" 
    3940 
    4041class LoginQueryHolder : public SqlQueryHolder 
     
    719720    { 
    720721        pCurrChar->resetSpells(); 
    721         SendNotification("Spells has been reset."); 
     722        SendNotification(LANG_RESET_SPELLS); 
    722723    } 
    723724 
     
    725726    { 
    726727        pCurrChar->resetTalents(true); 
    727         SendNotification("Talents has been reset."); 
     728        SendNotification(LANG_RESET_TALENTS); 
    728729    } 
    729730 
     
    733734 
    734735    if(pCurrChar->isGameMaster()) 
    735         SendNotification("GM mode is ON"); 
     736        SendNotification(LANG_GM_ON); 
    736737 
    737738    std::string IP_str = GetRemoteAddress(); 
  • trunk/src/game/Chat.cpp

    r18 r28  
    354354    static ChatCommand gmCommandTable[] = 
    355355    { 
     356        { "chat",           SEC_MODERATOR,      &ChatHandler::HandleGMChatCommand,              "", NULL }, 
    356357        { "list",           SEC_PLAYER,         &ChatHandler::HandleGMListCommand,              "", NULL }, 
    357358        { "visible",        SEC_MODERATOR,      &ChatHandler::HandleVisibleCommand,             "", NULL }, 
     
    508509} 
    509510 
    510 bool ChatHandler::hasStringAbbr(const char* s1, const char* s2) 
    511 { 
    512     for(;;) 
    513     { 
    514         if( !*s2 ) 
    515             return true; 
    516         else if( !*s1 ) 
     511bool ChatHandler::hasStringAbbr(const char* name, const char* part) 
     512{ 
     513    // non "" command 
     514    if( *name ) 
     515    { 
     516        // "" part from non-"" command 
     517        if( !*part ) 
    517518            return false; 
    518         else if( tolower( *s1 ) != tolower( *s2 ) ) 
    519             return false; 
    520         ++s1; ++s2; 
    521     } 
     519 
     520        for(;;) 
     521        { 
     522            if( !*part ) 
     523                return true; 
     524            else if( !*name ) 
     525                return false; 
     526            else if( tolower( *name ) != tolower( *part ) ) 
     527                return false; 
     528            ++name; ++part; 
     529        } 
     530    } 
     531    // allow with any for "" 
     532 
     533    return true; 
    522534} 
    523535 
     
    595607    while (*text == ' ') ++text; 
    596608 
    597     if(!cmd.length()) 
    598         return false; 
    599  
    600609    for(uint32 i = 0; table[i].Name != NULL; i++) 
    601610    { 
    602         // allow pass "" command name in table 
    603         if(strlen(table[i].Name) && !hasStringAbbr(table[i].Name, cmd.c_str())) 
     611        if( !hasStringAbbr(table[i].Name, cmd.c_str()) ) 
    604612            continue; 
    605613 
     
    689697            continue; 
    690698 
    691         if(strlen(table[i].Name) && !hasStringAbbr(table[i].Name, subcmd)) 
    692             continue; 
     699        if( !hasStringAbbr(table[i].Name, subcmd) ) 
    693700 
    694701        (list += "\n    ") += table[i].Name; 
     
    718725                continue; 
    719726 
    720             if(strlen(table[i].Name) && !hasStringAbbr(table[i].Name, cmd)) 
     727            if( !hasStringAbbr(table[i].Name, cmd) ) 
    721728                continue; 
    722729 
  • trunk/src/game/Chat.h

    r18 r28  
    7070 
    7171    protected: 
    72         bool hasStringAbbr(const char* s1, const char* s2); 
     72        bool hasStringAbbr(const char* name, const char* part); 
    7373        void SendGlobalSysMessage(const char *str); 
    7474 
     
    9595        bool HandleNotifyCommand(const char* args); 
    9696        bool HandleGMmodeCommand(const char* args); 
     97        bool HandleGMChatCommand(const char* args); 
    9798        bool HandleVisibleCommand(const char* args); 
    9899        bool HandleGPSCommand(const char* args); 
  • trunk/src/game/ChatHandler.cpp

    r2 r28  
    5959    if(!langDesc) 
    6060    { 
    61         SendNotification("Unknown language"); 
     61        SendNotification(LANG_UNKNOWN_LANGUAGE); 
    6262        return; 
    6363    } 
     
    7777        if(!foundAura) 
    7878        { 
    79             SendNotification("You don't know that language"); 
     79            SendNotification(LANG_NOT_LEARNED_LANGUAGE); 
    8080            return; 
    8181        } 
  • trunk/src/game/ConfusedMovementGenerator.cpp

    r2 r28  
    102102        return true; 
    103103 
    104     if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED | UNIT_STAT_DISTRACTED)) 
     104    if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) 
    105105        return true; 
    106106 
  • trunk/src/game/Creature.cpp

    r18 r28  
    7474    } 
    7575    return false; 
     76} 
     77 
     78size_t VendorItemData::FindItemSlot(uint32 item_id) const 
     79{ 
     80    for(size_t i = 0; i < m_items.size(); ++i ) 
     81        if(m_items[i]->item==item_id) 
     82            return i; 
     83    return m_items.size(); 
    7684} 
    7785 
     
    19111919void Creature::GetRespawnCoord( float &x, float &y, float &z, float* ori, float* dist ) const 
    19121920{ 
    1913     if(CreatureData const* data = objmgr.GetCreatureData(GetDBTableGUIDLow())) 
    1914     { 
    1915         x = data->posX; 
    1916         y = data->posY; 
    1917         z = data->posZ; 
    1918         if(ori) 
    1919             *ori = data->orientation; 
    1920         if(dist) 
    1921             *dist = data->spawndist; 
    1922     } 
    1923     else 
    1924     { 
    1925         x = GetPositionX(); 
    1926         y = GetPositionY(); 
    1927         z = GetPositionZ(); 
    1928         if(ori) 
    1929             *ori = GetOrientation(); 
    1930         if(dist) 
    1931             *dist = 0; 
    1932     } 
     1921    if (m_DBTableGuid) 
     1922    { 
     1923        if (CreatureData const* data = objmgr.GetCreatureData(GetDBTableGUIDLow())) 
     1924        { 
     1925            x = data->posX; 
     1926            y = data->posY; 
     1927            z = data->posZ; 
     1928            if(ori) 
     1929                *ori = data->orientation; 
     1930            if(dist) 
     1931                *dist = data->spawndist; 
     1932 
     1933            return; 
     1934        } 
     1935    } 
     1936 
     1937    x = GetPositionX(); 
     1938    y = GetPositionY(); 
     1939    z = GetPositionZ(); 
     1940    if(ori) 
     1941        *ori = GetOrientation(); 
     1942    if(dist) 
     1943        *dist = 0; 
    19331944} 
    19341945 
  • trunk/src/game/Creature.h

    r18 r28  
    309309    bool RemoveItem( uint32 item_id ); 
    310310    VendorItem const* FindItem(uint32 item_id) const; 
     311    size_t FindItemSlot(uint32 item_id) const; 
    311312 
    312313    void Clear() 
  • trunk/src/game/FleeingMovementGenerator.cpp

    r2 r28  
    3333        return; 
    3434 
    35     if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED) ) 
     35    if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED) ) 
    3636        return; 
    3737 
     
    339339    if( !&owner || !owner.isAlive() ) 
    340340        return false; 
    341     if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED) ) 
     341    if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED) ) 
    342342        return true; 
    343343 
  • trunk/src/game/GridNotifiers.h

    r13 r28  
    853853        { 
    854854            if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && 
    855                 (u->isFeared() || u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_STUNDED) || u->hasUnitState(UNIT_STAT_STUNDED) || u->hasUnitState(UNIT_STAT_CONFUSED))) 
     855                (u->isFeared() || u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_STUNNED) || u->hasUnitState(UNIT_STAT_CONFUSED))) 
    856856            { 
    857857                return true; 
  • trunk/src/game/Group.cpp

    r9 r28  
    624624        case 1:                                             //player choose Need 
    625625        { 
    626             SendLootRoll(0, playerGUID, 1, 1, *roll); 
     626            SendLootRoll(0, playerGUID, 0, 0, *roll); 
    627627            ++roll->totalNeed; 
    628628            itr->second = NEED; 
     
    631631        case 2:                                             //player choose Greed 
    632632        { 
    633             SendLootRoll(0, playerGUID, 2, 2, *roll); 
     633            SendLootRoll(0, playerGUID, 128, 2, *roll); 
    634634            ++roll->totalGreed; 
    635635            itr->second = GREED; 
  • trunk/src/game/HomeMovementGenerator.cpp

    r2 r28  
    4444        return; 
    4545 
    46     if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED | UNIT_STAT_DISTRACTED) ) 
     46    if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED) ) 
    4747        return; 
    4848 
  • trunk/src/game/Language.h

    r18 r28  
    7676    LANG_LEVEL_MINREQUIRED_AND_ITEM     = 50, 
    7777    LANG_NPC_TAINER_HELLO               = 51, 
    78     // Room for more level 0 
     78    LANG_COMMAND_INVALID_ITEM_COUNT     = 52, 
     79    LANG_COMMAND_MAIL_ITEMS_LIMIT       = 53, 
     80    // Room for more level 0              54-99 not used 
    7981 
    8082    // level 1 chat 
     
    160162    LANG_MAIL_SENT                      = 169, 
    161163    LANG_SOUND_NOT_EXIST                = 170, 
    162     // Room for more level 1 
     164    // Room for more level 1              171-199 not used 
    163165 
    164166    // level 2 chat 
     
    305307    LANG_NO_PLAYERS_FOUND               = 330, 
    306308    LANG_EXTENDED_COST_NOT_EXIST        = 331, 
    307  
    308     // Room for more level 2 
     309    LANG_GM_ON                          = 332, 
     310    LANG_GM_OFF                         = 333, 
     311    LANG_GM_CHAT_ON                     = 334, 
     312    LANG_GM_CHAT_OFF                    = 335, 
     313    // Room for more level 2              336-399 not used 
    309314 
    310315    // level 3 chat 
     
    611616    LANG_BG_GROUP_TOO_LARGE             = 711, 
    612617    LANG_ARENA_GROUP_TOO_LARGE          = 712, 
    613     LANG_ARENA_YOUR_TEAM_ONLY           = 713, 
    614     LANG_ARENA_NOT_ENOUGH_PLAYERS       = 714, 
    615     LANG_ARENA_GOLD_WINS                = 715, 
    616     LANG_ARENA_GREEN_WINS               = 716, 
    617     LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING = 717, 
    618     LANG_BG_GROUP_OFFLINE_MEMBER        = 718, 
    619     LANG_BG_GROUP_MIXED_FACTION         = 719, 
    620     LANG_BG_GROUP_MIXED_LEVELS          = 720, 
    621     LANG_BG_GROUP_MEMBER_ALREADY_IN_QUEUE = 721, 
    622     LANG_BG_GROUP_MEMBER_DESERTER       = 722, 
    623     LANG_BG_GROUP_MEMBER_NO_FREE_QUEUE_SLOTS = 723, 
    624  
    625     LANG_CANNOT_TELE_TO_BG              = 724, 
    626     LANG_CANNOT_SUMMON_TO_BG            = 725, 
    627     LANG_CANNOT_GO_TO_BG_GM             = 726, 
    628     LANG_CANNOT_GO_TO_BG_FROM_BG        = 727, 
    629  
    630     LANG_ARENA_TESTING                  = 728 
    631  
     618    LANG_YOUR_ARENA_LEVEL_REQ_ERROR     = 713, 
     619    LANG_HIS_ARENA_LEVEL_REQ_ERROR      = 714, 
     620    LANG_YOUR_BG_LEVEL_REQ_ERROR        = 715, 
     621    LANG_YOUR_ARENA_TEAM_FULL           = 716, 
     622    // Room for BG/ARENA                  717-799 not used 
     623 
     624    LANG_ARENA_YOUR_TEAM_ONLY           = 730, 
     625    LANG_ARENA_NOT_ENOUGH_PLAYERS       = 731, 
     626    LANG_ARENA_GOLD_WINS                = 732, 
     627    LANG_ARENA_GREEN_WINS               = 733, 
     628    LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING = 734, 
     629    LANG_BG_GROUP_OFFLINE_MEMBER        = 735, 
     630    LANG_BG_GROUP_MIXED_FACTION         = 736, 
     631    LANG_BG_GROUP_MIXED_LEVELS          = 737, 
     632    LANG_BG_GROUP_MEMBER_ALREADY_IN_QUEUE = 738, 
     633    LANG_BG_GROUP_MEMBER_DESERTER       = 739, 
     634    LANG_BG_GROUP_MEMBER_NO_FREE_QUEUE_SLOTS = 740, 
     635 
     636    LANG_CANNOT_TELE_TO_BG              = 741, 
     637    LANG_CANNOT_SUMMON_TO_BG            = 742, 
     638    LANG_CANNOT_GO_TO_BG_GM             = 743, 
     639    LANG_CANNOT_GO_TO_BG_FROM_BG        = 744, 
     640 
     641    LANG_ARENA_TESTING                  = 745, 
     642 
     643    // in game strings 
     644    LANG_PET_INVALID_NAME               = 800, 
     645    LANG_NOT_ENOUGH_GOLD                = 801, 
     646    LANG_NOT_FREE_TRADE_SLOTS           = 802, 
     647    LANG_NOT_PARTNER_FREE_TRADE_SLOTS   = 803, 
     648    LANG_YOU_NOT_HAVE_PERMISSION        = 804, 
     649    LANG_UNKNOWN_LANGUAGE               = 805, 
     650    LANG_NOT_LEARNED_LANGUAGE           = 806, 
     651    LANG_NEED_CHARACTER_NAME            = 807, 
     652    LANG_PLAYER_NOT_EXIST_OR_OFFLINE    = 808, 
     653    LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND   = 809, 
     654    // Room for in-game strings           810-999 not used 
     655 
     656    // FREE IDS                           1000-9999 
     657 
     658    // Use for not-in-svn patches         10000-10999 
     659    // Use for custom patches             11000-11999 
     660 
     661    // NOT RESERVED IDS                   12000- 
    632662}; 
    633663#endif 
    634  
    635 /*  NOT USED VALUES 
    636 // alliance ranks 
    637 #define LANG_ALI_PRIVATE                 "Private " 
    638 #define LANG_ALI_CORPORAL                "Corporal " 
    639 #define LANG_ALI_SERGEANT                "Sergeant " 
    640 #define LANG_ALI_MASTER_SERGEANT         "Master Sergeant " 
    641 #define LANG_ALI_SERGEANT_MAJOR          "Sergeant Major " 
    642 #define LANG_ALI_KNIGHT                  "Knight " 
    643 #define LANG_ALI_KNIGHT_LIEUTENANT       "Knight-Lieutenant " 
    644 #define LANG_ALI_KNIGHT_CAPTAIN          "Knight-Captain " 
    645 #define LANG_ALI_KNIGHT_CHAMPION         "Knight-Champion " 
    646 #define LANG_ALI_LIEUTENANT_COMMANDER    "Lieutenant Commander " 
    647 #define LANG_ALI_COMMANDER               "Commander " 
    648 #define LANG_ALI_MARSHAL                 "Marshal " 
    649 #define LANG_ALI_FIELD_MARSHAL           "Field Marshal " 
    650 #define LANG_ALI_GRAND_MARSHAL           "Grand Marshal " 
    651 #define LANG_ALI_GAME_MASTER             "Game Master " 
    652  
    653 // horde ranks 
    654 #define LANG_HRD_SCOUT                   "Scout " 
    655 #define LANG_HRD_GRUNT                   "Grunt " 
    656 #define LANG_HRD_SERGEANT                "Sergeant " 
    657 #define LANG_HRD_SENIOR_SERGEANT         "Senior Sergeant " 
    658 #define LANG_HRD_FIRST_SERGEANT          "First Sergeant " 
    659 #define LANG_HRD_STONE_GUARD             "Stone Guard " 
    660 #define LANG_HRD_BLOOD_GUARD             "Blood Guard " 
    661 #define LANG_HRD_LEGIONNARE              "Legionnaire " 
    662 #define LANG_HRD_CENTURION               "Centurion " 
    663 #define LANG_HRD_CHAMPION                "Champion " 
    664 #define LANG_HRD_LIEUTENANT_GENERAL      "Lieutenant General " 
    665 #define LANG_HRD_GENERAL                 "General " 
    666 #define LANG_HRD_WARLORD                 "Warlord " 
    667 #define LANG_HRD_HIGH_WARLORD            "High Warlord " 
    668 #define LANG_HRD_GAME_MASTER             "Game Master " 
    669  
    670 #define LANG_NO_RANK                     "No rank " 
    671 #define LANG_RANK                        "%s (Rank %u)" 
    672 #define LANG_HONOR_TODAY                 "Today: [Honorable kills: |c0000ff00%u|r] [Dishonorable kills: |c00ff0000%u|r]" 
    673 #define LANG_HONOR_YESTERDAY             "Yesterday: [Kills: |c0000ff00%u|r] [Honor: %u]" 
    674 #define LANG_HONOR_THIS_WEEK             "This week: [Kills: |c0000ff00%u|r] [Honor: %u]" 
    675 #define LANG_HONOR_LAST_WEEK             "Last week: [Kills: |c0000ff00%u|r] [Honor: %u] [Standing: %u]" 
    676 #define LANG_HONOR_LIFE                  "Lifetime: [Honorable kills: |c0000ff00%u|r] [Dishonorable kills: |c00ff0000%u|r] [Highest rank %u: %s]" 
    677  
    678 // level 2 
    679 #define LANG_ADD_OBJ                     "AddObject at Chat.cpp" //log 
    680 #define LANG_DEMORPHED                   "Demorphed %s"     //log 
    681  
    682 // level 3 
    683 #define LANG_SPAWNING_SPIRIT_HEAL        "Spawning spirit healers\n" 
    684 #define LANG_NO_SPIRIT_HEAL_DB           "No spirit healers in database, exiting." 
    685  
    686 #define LANG_ADD_OBJ_LV3                 "AddObject at Level3.cpp line 1176" 
    687  
    688 */ 
  • trunk/src/game/Level1.cpp

    r9 r28  
    148148    if(!*args) 
    149149    { 
    150         SendSysMessage(LANG_USE_BOL); 
    151         SetSentErrorMessage(true); 
    152         return false; 
     150        if(m_session->GetPlayer()->isGameMaster()) 
     151            m_session->SendNotification(LANG_GM_ON); 
     152        else 
     153            m_session->SendNotification(LANG_GM_OFF); 
     154        return true; 
    153155    } 
    154156 
     
    158160    { 
    159161        m_session->GetPlayer()->SetGameMaster(true); 
    160         m_session->SendNotification("GM mode is ON"); 
     162        m_session->SendNotification(LANG_GM_ON); 
    161163        #ifdef _DEBUG_VMAPS 
    162164        VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); 
     
    169171    { 
    170172        m_session->GetPlayer()->SetGameMaster(false); 
    171         m_session->SendNotification("GM mode is OFF"); 
     173        m_session->SendNotification(LANG_GM_OFF); 
    172174        #ifdef _DEBUG_VMAPS 
    173175        VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); 
     
    182184} 
    183185 
     186// Enables or disables hiding of the staff badge 
     187bool ChatHandler::HandleGMChatCommand(const char* args) 
     188{ 
     189    if(!*args) 
     190    { 
     191        if(m_session->GetPlayer()->isGMChat()) 
     192            m_session->SendNotification(LANG_GM_CHAT_ON); 
     193        else 
     194            m_session->SendNotification(LANG_GM_CHAT_OFF); 
     195        return true; 
     196    } 
     197 
     198    std::string argstr = (char*)args; 
     199 
     200    if (argstr == "on") 
     201    { 
     202        m_session->GetPlayer()->SetGMChat(true); 
     203        m_session->SendNotification(LANG_GM_CHAT_ON); 
     204        return true; 
     205    } 
     206 
     207    if (argstr == "off") 
     208    { 
     209        m_session->GetPlayer()->SetGMChat(false); 
     210        m_session->SendNotification(LANG_GM_CHAT_OFF); 
     211        return true; 
     212    } 
     213 
     214    SendSysMessage(LANG_USE_BOL); 
     215    SetSentErrorMessage(true); 
     216    return false; 
     217} 
     218 
     219 
    184220//Enable\Dissable Invisible mode 
    185221bool ChatHandler::HandleVisibleCommand(const char* args) 
     
    196232    { 
    197233        m_session->GetPlayer()->SetGMVisible(true); 
    198         m_session->SendNotification(GetMangosString(LANG_INVISIBLE_VISIBLE)); 
     234        m_session->SendNotification(LANG_INVISIBLE_VISIBLE); 
    199235        return true; 
    200236    } 
     
    202238    if (argstr == "off") 
    203239    { 
    204         m_session->SendNotification(GetMangosString(LANG_INVISIBLE_INVISIBLE)); 
     240        m_session->SendNotification(LANG_INVISIBLE_INVISIBLE); 
    205241        m_session->GetPlayer()->SetGMVisible(false); 
    206242        return true; 
     
    18241860        return false; 
    18251861 
     1862    // format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12] 
     1863 
    18261864    char* pName = strtok((char*)args, " "); 
    1827     char* msgSubject = strtok(NULL, " "); 
    1828     char* msgText = strtok(NULL, ""); 
     1865    if(!pName) 
     1866        return false; 
     1867 
     1868    char* tail1 = strtok(NULL, ""); 
     1869    if(!tail1) 
     1870        return false; 
     1871 
     1872    char* msgSubject; 
     1873    if(*tail1=='"') 
     1874        msgSubject = strtok(tail1+1, "\""); 
     1875    else 
     1876    { 
     1877        char* space = strtok(tail1, "\""); 
     1878        if(!space) 
     1879            return false; 
     1880        msgSubject = strtok(NULL, "\""); 
     1881    } 
     1882 
     1883    if (!msgSubject) 
     1884        return false; 
     1885 
     1886    char* tail2 = strtok(NULL, ""); 
     1887    if(!tail2) 
     1888        return false; 
     1889 
     1890    char* msgText; 
     1891    if(*tail2=='"') 
     1892        msgText = strtok(tail2+1, "\""); 
     1893    else 
     1894    { 
     1895        char* space = strtok(tail2, "\""); 
     1896        if(!space) 
     1897            return false; 
     1898        msgText = strtok(NULL, "\""); 
     1899    } 
    18291900 
    18301901    if (!msgText) 
     
    18321903 
    18331904    // pName, msgSubject, msgText isn't NUL after prev. check 
    1834  
    18351905    std::string name    = pName; 
    18361906    std::string subject = msgSubject; 
    18371907    std::string text    = msgText; 
    18381908 
     1909    // extract items 
     1910    typedef std::pair<uint32,uint32> ItemPair; 
     1911    typedef std::list< ItemPair > ItemPairs; 
     1912    ItemPairs items; 
     1913 
     1914    // get all tail string 
     1915    char* tail = strtok(NULL, ""); 
     1916 
     1917    // get from tail next item str 
     1918    while(char* itemStr = strtok(tail, " ")) 
     1919    { 
     1920        // and get new tail  
     1921        tail = strtok(NULL, ""); 
     1922 
     1923        // parse item str 
     1924        char* itemIdStr = strtok(itemStr, ":"); 
     1925        char* itemCountStr = strtok(NULL, " "); 
     1926         
     1927        uint32 item_id = atoi(itemIdStr); 
     1928        if(!item_id) 
     1929            return false; 
     1930 
     1931        ItemPrototype const* item_proto = objmgr.GetItemPrototype(item_id); 
     1932        if(!item_proto) 
     1933        { 
     1934            PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); 
     1935            SetSentErrorMessage(true); 
     1936            return false; 
     1937        } 
     1938 
     1939        uint32 item_count = itemCountStr ? atoi(itemCountStr) : 1; 
     1940        if(item_count < 1 || item_proto->MaxCount && item_count > item_proto->MaxCount) 
     1941        { 
     1942            PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, item_count,item_id); 
     1943            SetSentErrorMessage(true); 
     1944            return false; 
     1945        } 
     1946 
     1947        while(item_count > item_proto->Stackable) 
     1948        { 
     1949            items.push_back(ItemPair(item_id,item_proto->Stackable)); 
     1950            item_count -= item_proto->Stackable; 
     1951        } 
     1952 
     1953        items.push_back(ItemPair(item_id,item_count)); 
     1954 
     1955        if(items.size() > MAX_MAIL_ITEMS) 
     1956        { 
     1957            PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS); 
     1958            SetSentErrorMessage(true); 
     1959            return false; 
     1960        } 
     1961    } 
     1962 
    18391963    if(!normalizePlayerName(name)) 
    18401964    { 
     
    18451969 
    18461970    uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name); 
    1847  
    18481971    if(!receiver_guid) 
    1849         return false; 
     1972    { 
     1973        SendSysMessage(LANG_PLAYER_NOT_FOUND); 
     1974        SetSentErrorMessage(true); 
     1975        return false; 
     1976    } 
    18501977 
    18511978    uint32 mailId = objmgr.GenerateMailID(); 
     
    18611988    Player *receiver = objmgr.GetPlayer(receiver_guid); 
    18621989 
    1863     WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_NONE); 
     1990    // fill mail 
     1991    MailItemsInfo mi;                                       // item list preparing 
     1992 
     1993    for(ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr) 
     1994    { 
     1995        if(Item* item = Item::CreateItem(itr->first,itr->second,m_session->GetPlayer())) 
     1996        { 
     1997            item->SaveToDB();                               // save for prevent lost at next mail load, if send fail then item will deleted 
     1998            mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); 
     1999        } 
     2000    } 
     2001 
     2002    WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_NONE); 
    18642003 
    18652004    PSendSysMessage(LANG_MAIL_SENT, name.c_str()); 
  • trunk/src/game/MiscHandler.cpp

    r9 r28  
    14271427        GetPlayer()->TeleportTo(mapid,PositionX,PositionY,PositionZ,Orientation); 
    14281428    else 
    1429         SendNotification("You do not have permission to perform that function"); 
     1429        SendNotification(LANG_YOU_NOT_HAVE_PERMISSION); 
    14301430    sLog.outDebug("Received worldport command from player %s", GetPlayer()->GetName()); 
    14311431} 
     
    14361436 
    14371437    sLog.outDebug("Received opcode CMSG_WHOIS"); 
    1438     std::string charname, acc, email, lastip, msg; 
     1438    std::string charname; 
    14391439    recv_data >> charname; 
    14401440 
    14411441    if (GetSecurity() < SEC_ADMINISTRATOR) 
    14421442    { 
    1443         SendNotification("You do not have permission to perform that function"); 
     1443        SendNotification(LANG_YOU_NOT_HAVE_PERMISSION); 
    14441444        return; 
    14451445    } 
     
    14471447    if(charname.empty()) 
    14481448    { 
    1449         SendNotification("Please provide character name"); 
    1450         return; 
    1451     } 
    1452  
    1453     uint32 accid; 
    1454     Field *fields; 
     1449        SendNotification(LANG_NEED_CHARACTER_NAME); 
     1450        return; 
     1451    } 
    14551452 
    14561453    Player *plr = objmgr.GetPlayer(charname.c_str()); 
    14571454 
    1458     if(plr) 
    1459         accid = plr->GetSession()->GetAccountId(); 
    1460     else 
    1461     { 
    1462         SendNotification("Player %s not found or offline", charname.c_str()); 
    1463         return; 
    1464     } 
    1465  
    1466     if(!accid) 
    1467     { 
    1468         SendNotification("Account for character %s not found", charname.c_str()); 
    1469         return; 
    1470     } 
     1455    if(!plr) 
     1456    { 
     1457        SendNotification(LANG_PLAYER_NOT_EXIST_OR_OFFLINE, charname.c_str()); 
     1458        return; 
     1459    } 
     1460 
     1461    uint32 accid = plr->GetSession()->GetAccountId(); 
    14711462 
    14721463    QueryResult *result = loginDatabase.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid); 
    1473     if(result) 
    1474     { 
    1475         fields = result->Fetch(); 
    1476         acc = fields[0].GetCppString(); 
    1477         if(acc.empty()) 
    1478             acc = "Unknown"; 
    1479         email = fields[1].GetCppString(); 
    1480         if(email.empty()) 
    1481             email = "Unknown"; 
    1482         lastip = fields[2].GetCppString(); 
    1483         if(lastip.empty()) 
    1484             lastip = "Unknown"; 
    1485         msg = charname + "'s " + "account is " + acc + ", e-mail: " + email + ", last ip: " + lastip; 
    1486  
    1487         WorldPacket data(SMSG_WHOIS, msg.size()+1); 
    1488         data << msg; 
    1489         _player->GetSession()->SendPacket(&data); 
    1490     } 
    1491     else 
    1492         SendNotification("Account for character %s not found", charname.c_str()); 
     1464    if(!result) 
     1465    { 
     1466        SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND, charname.c_str()); 
     1467        return; 
     1468    } 
     1469 
     1470    Field *fields = result->Fetch(); 
     1471    std::string acc = fields[0].GetCppString(); 
     1472    if(acc.empty()) 
     1473        acc = "Unknown"; 
     1474    std::string email = fields[1].GetCppString(); 
     1475    if(email.empty()) 
     1476        email = "Unknown"; 
     1477    std::string lastip = fields[2].GetCppString(); 
     1478    if(lastip.empty()) 
     1479        lastip = "Unknown"; 
     1480 
     1481    std::string msg = charname + "'s " + "account is " + acc + ", e-mail: " + email + ", last ip: " + lastip; 
     1482 
     1483    WorldPacket data(SMSG_WHOIS, msg.size()+1); 
     1484    data << msg; 
     1485    _player->GetSession()->SendPacket(&data); 
    14931486 
    14941487    delete result; 
     1488 
    14951489    sLog.outDebug("Received whois command from player %s for character %s", GetPlayer()->GetName(), charname.c_str()); 
    14961490} 
  • trunk/src/game/MotionMaster.cpp

    r2 r28  
    7777MotionMaster::UpdateMotion(const uint32 &diff) 
    7878{ 
    79     if( i_owner->hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED) ) 
     79    if( i_owner->hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED) ) 
    8080        return; 
    8181    assert( !empty() ); 
  • trunk/src/game/ObjectMgr.cpp

    r18 r28  
    66806680    m_mCacheTrainerSpellMap.clear(); 
    66816681 
     6682    std::set<uint32> skip_trainers; 
     6683 
    66826684    QueryResult *result = WorldDatabase.PQuery("SELECT entry, spell,spellcost,reqskill,reqskillvalue,reqlevel FROM npc_trainer"); 
    66836685 
     
    67156717        if(!(cInfo->npcflag & UNIT_NPC_FLAG_TRAINER)) 
    67166718        { 
    6717             sLog.outErrorDb("Table `npc_trainer` have data for not creature template (Entry: %u) without trainer flag, ignore", entry); 
     6719            if(skip_trainers.count(entry) == 0) 
     6720            { 
     6721                sLog.outErrorDb("Table `npc_trainer` have data for not creature template (Entry: %u) without trainer flag, ignore", entry); 
     6722                skip_trainers.insert(entry); 
     6723            } 
    67186724            continue; 
    67196725        } 
     
    67656771    m_mCacheVendorItemMap.clear(); 
    67666772 
     6773    std::set<uint32> skip_vendors; 
     6774 
    67676775    QueryResult *result = WorldDatabase.PQuery("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor"); 
    67686776    if( !result ) 
     
    67916799        uint32 ExtendedCost = fields[4].GetUInt32(); 
    67926800 
    6793         if(!IsVendorItemValid(entry,item_id,maxcount,incrtime,ExtendedCost)) 
     6801        if(!IsVendorItemValid(entry,item_id,maxcount,incrtime,ExtendedCost,NULL,&skip_vendors)) 
    67946802            continue; 
    67956803 
     
    68796887} 
    68806888 
    6881 bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* pl ) const 
     6889bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* pl, std::set<uint32>* skip_vendors ) const 
    68826890{ 
    68836891    CreatureInfo const* cInfo = GetCreatureTemplate(vendor_entry); 
     
    68936901    if(!(cInfo->npcflag & UNIT_NPC_FLAG_VENDOR)) 
    68946902    { 
    6895         if(pl) 
    6896             ChatHandler(pl).SendSysMessage(LANG_COMMAND_VENDORSELECTION); 
    6897         else 
    6898             sLog.outErrorDb("Table `npc_vendor` have data for not creature template (Entry: %u) without vendor flag, ignore", vendor_entry); 
     6903        if(!skip_vendors || skip_vendors->count(vendor_entry)==0) 
     6904        { 
     6905            if(pl) 
     6906                ChatHandler(pl).SendSysMessage(LANG_COMMAND_VENDORSELECTION); 
     6907            else 
     6908                sLog.outErrorDb("Table `npc_vendor` have data for not creature template (Entry: %u) without vendor flag, ignore", vendor_entry); 
     6909 
     6910            if(skip_vendors) 
     6911                skip_vendors->insert(vendor_entry); 
     6912        } 
    68996913        return false; 
    69006914    } 
  • trunk/src/game/ObjectMgr.h

    r18 r28  
    743743        void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost); 
    744744        bool RemoveVendorItem(uint32 entry,uint32 item); 
    745         bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL ) const; 
     745        bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL ) const; 
    746746    protected: 
    747747        uint32 m_auctionid; 
  • trunk/src/game/PetHandler.cpp

    r2 r28  
    3131#include "Util.h" 
    3232#include "Pet.h" 
     33#include "Language.h" 
    3334 
    3435void WorldSession::HandlePetAction( WorldPacket & recv_data ) 
     
    396397    if((!ObjectMgr::IsValidPetName(name)) || (objmgr.IsReservedName(name))) 
    397398    { 
    398         SendNotification("Invalid name"); 
     399        SendNotification(LANG_PET_INVALID_NAME); 
    399400        return; 
    400401    } 
     
    416417        if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname,0),declinedname)) 
    417418        { 
    418             SendNotification("Invalid name"); 
     419            SendNotification(LANG_PET_INVALID_NAME); 
    419420            return; 
    420421        } 
  • trunk/src/game/PetitionsHandler.cpp

    r2 r28  
    112112        if(_player->getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) 
    113113        { 
    114             SendNotification(GetMangosString(LANG_ARENA_ONE_TOOLOW), 70); 
     114            SendNotification(LANG_ARENA_ONE_TOOLOW, 70); 
    115115            return; 
    116116        } 
     
    531531    { 
    532532        // player is too low level to join an arena team 
    533         SendNotification("You must be level %u to join an arena team!",sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)); 
     533        SendNotification(LANG_YOUR_ARENA_LEVEL_REQ_ERROR,sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)); 
    534534        return; 
    535535    } 
  • trunk/src/game/Player.cpp

    r18 r28  
    266266        SetAcceptTicket(true); 
    267267 
    268     // players always and GM if set in config accept whispers by default 
    269     if(GetSession()->GetSecurity() == SEC_PLAYER || sWorld.getConfig(CONFIG_GM_WISPERING_TO)) 
     268    // players always accept  
     269    if(GetSession()->GetSecurity() == SEC_PLAYER) 
    270270        SetAcceptWhispers(true); 
    271271 
     
    14161416    // 0x2 - dnd 
    14171417    // 0x1 - afk 
    1418     if(isGameMaster()) 
     1418    if(isGMChat()) 
    14191419        return 4; 
    14201420    else if(isDND()) 
     
    15561556        } 
    15571557 
    1558         SetSemaphoreTeleport(false); 
    1559  
    15601558        if(!GetSession()->PlayerLogout()) 
     1559        { 
     1560            // don't reset teleport semaphore while logging out, otherwise m_teleport_dest won't be used in Player::SaveToDB 
     1561            SetSemaphoreTeleport(false); 
     1562 
    15611563            UpdateZone(GetZoneId()); 
     1564        } 
    15621565 
    15631566        // new zone 
     
    93239326        if( pProto ) 
    93249327        { 
     9328            // May be here should be more stronger checks; STUNNED checked 
     9329            // ROOT, CONFUSED, DISTRACTED, FLEEING this needs to be checked. 
     9330            if (not_loading && hasUnitState(UNIT_STAT_STUNNED)) 
     9331                return EQUIP_ERR_YOU_ARE_STUNNED; 
     9332 
    93259333            if(pItem->IsBindedNotWith(GetGUID())) 
    93269334                return EQUIP_ERR_DONT_OWN_THAT_ITEM; 
     
    93469354            if(isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer != 0) 
    93479355                return EQUIP_ERR_CANT_DO_RIGHT_NOW;         // maybe exist better err 
     9356 
     9357            if(IsNonMeleeSpellCasted(false)) 
     9358                return EQUIP_ERR_CANT_DO_RIGHT_NOW; 
    93489359 
    93499360            uint8 eslot = FindEquipSlot( pProto, slot, swap ); 
     
    1379913810        switch(sWorld.getConfig(CONFIG_GM_LOGIN_STATE)) 
    1380013811        { 
    13801             case 0:                                         // disable 
    13802                 break; 
    13803             case 1:                                         // enable 
    13804                 SetGameMaster(true); 
    13805                 break; 
     13812            default: 
     13813            case 0:                      break;             // disable 
     13814            case 1: SetGameMaster(true); break;             // enable 
    1380613815            case 2:                                         // save state 
    13807                 if(gmstate) 
     13816                if(gmstate & PLAYER_EXTRA_GM_ON) 
    1380813817                    SetGameMaster(true); 
    1380913818                break; 
     13819        } 
     13820 
     13821        switch(sWorld.getConfig(CONFIG_GM_ACCEPT_TICKETS)) 
     13822        { 
    1381013823            default: 
     13824            case 0:                        break;           // disable 
     13825            case 1: SetAcceptTicket(true); break;           // enable 
     13826            case 2:                                         // save state 
     13827            if(gmstate & PLAYER_EXTRA_GM_ACCEPT_TICKETS) 
     13828                SetAcceptTicket(true); 
     13829            break; 
     13830        } 
     13831 
     13832        switch(sWorld.getConfig(CONFIG_GM_CHAT)) 
     13833        { 
     13834            default: 
     13835            case 0:                  break;                 // disable 
     13836            case 1: SetGMChat(true); break;                 // enable 
     13837            case 2:                                         // save state 
     13838                if(gmstate & PLAYER_EXTRA_GM_CHAT) 
     13839                    SetGMChat(true); 
     13840                break; 
     13841        } 
     13842 
     13843        switch(sWorld.getConfig(CONFIG_GM_WISPERING_TO)) 
     13844        { 
     13845            default: 
     13846            case 0:                          break;         // disable 
     13847            case 1: SetAcceptWhispers(true); break;         // enable 
     13848            case 2:                                         // save state 
     13849                if(gmstate & PLAYER_EXTRA_ACCEPT_WHISPERS) 
     13850                    SetAcceptWhispers(true); 
    1381113851                break; 
    1381213852        } 
     
    1487814918 
    1487914919    ss << ", "; 
    14880     ss << (isGameMaster()? 1 : 0); 
     14920    ss << m_ExtraFlags; 
    1488114921 
    1488214922    ss << ", "; 
     
    1638816428    } 
    1638916429 
    16390     VendorItem const* crItem = vItems->FindItem(item); 
    16391     if(!crItem) 
     16430    size_t vendor_slot = vItems->FindItemSlot(item); 
     16431    if(vendor_slot >= vItems->GetItemCount()) 
    1639216432    { 
    1639316433        SendBuyError( BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); 
    1639416434        return false; 
    1639516435    } 
     16436 
     16437    VendorItem const* crItem = vItems->m_items[vendor_slot]; 
    1639616438 
    1639716439    // check current item amount if it limited 
     
    1652116563            WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); 
    1652216564            data << pCreature->GetGUID(); 
    16523             data << (uint32)crItem->item; 
     16565            data << (uint32)(vendor_slot+1);                // numbered from 1 at client 
    1652416566            data << (uint32)(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); 
    1652516567            data << (uint32)count; 
     
    1656016602            WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); 
    1656116603            data << pCreature->GetGUID(); 
    16562             data << (uint32)crItem->item; 
     16604            data << (uint32)(vendor_slot+1);                // numbered from 1 at client 
    1656316605            data << (uint32)(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); 
    1656416606            data << (uint32)count; 
  • trunk/src/game/Player.h

    r18 r28  
    497497    PLAYER_EXTRA_TAXICHEAT          = 0x0008, 
    498498    PLAYER_EXTRA_GM_INVISIBLE       = 0x0010, 
     499    PLAYER_EXTRA_GM_CHAT            = 0x0020,               // Show GM badge in chat messages 
    499500 
    500501    // other states 
     
    955956        bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; } 
    956957        void SetGameMaster(bool on); 
     958        bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR && (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT); } 
     959        void SetGMChat(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; } 
    957960        bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; } 
    958961        void SetTaxiCheater(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; } 
  • trunk/src/game/PointMovementGenerator.cpp

    r18 r28  
    4242        return false; 
    4343 
    44     if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED)) 
     44    if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED)) 
    4545        return true; 
    4646 
  • trunk/src/game/RandomMovementGenerator.cpp

    r26 r28  
    127127RandomMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff) 
    128128{ 
    129     if(creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED | UNIT_STAT_DISTRACTED)) 
     129    if(creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) 
    130130    { 
    131131        i_nextMoveTime.Update(i_nextMoveTime.GetExpiry());    // Expire the timer 
  • trunk/src/game/SocialMgr.cpp

    r2 r28  
    4242bool PlayerSocial::AddToSocialList(uint32 friend_guid, bool ignore) 
    4343{ 
    44     // prevent list (client-side) overflow 
    45     if(m_playerSocialMap.size() >= (255-1)) 
     44    // client limit 
     45    if(m_playerSocialMap.size() >= 50) 
    4646        return false; 
    4747 
     
    181181    bool gmInWhoList = sWorld.getConfig(CONFIG_GM_IN_WHO_LIST) || security > SEC_PLAYER; 
    182182 
     183    PlayerSocialMap::iterator itr = player->GetSocial()->m_playerSocialMap.find(friendGUID); 
     184    if(itr != player->GetSocial()->m_playerSocialMap.end()) 
     185        friendInfo.Note = itr->second.Note; 
     186 
    183187    // PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters 
    184188    // MODERATOR, GAME MASTER, ADMINISTRATOR can see all 
     
    219223    WorldPacket data; 
    220224    MakeFriendStatusPacket(result, friend_guid, &data); 
     225    GetFriendInfo(player, friend_guid, fi); 
    221226    switch(result) 
    222227    { 
     228        case FRIEND_ADDED_OFFLINE: 
     229        case FRIEND_ADDED_ONLINE: 
     230            data << fi.Note; 
     231            break; 
     232    } 
     233 
     234    switch(result) 
     235    { 
     236        case FRIEND_ADDED_ONLINE: 
    223237        case FRIEND_ONLINE: 
    224             GetFriendInfo(player, friend_guid, fi); 
    225238            data << uint8(fi.Status); 
    226239            data << uint32(fi.Area); 
    227240            data << uint32(fi.Level); 
    228241            data << uint32(fi.Class); 
    229             break; 
    230         case FRIEND_ADDED_ONLINE: 
    231             GetFriendInfo(player, friend_guid, fi); 
    232             data << name; 
    233             data << uint8(fi.Status); 
    234             data << uint32(fi.Area); 
    235             data << uint32(fi.Level); 
    236             data << uint32(fi.Class); 
    237             break; 
    238         case FRIEND_ADDED_OFFLINE: 
    239             data << name; 
    240242            break; 
    241243    } 
     
    300302        social->m_playerSocialMap[friend_guid] = FriendInfo(flags, note); 
    301303 
    302         // prevent list (client-side) overflow 
    303         if(social->m_playerSocialMap.size() >= 255) 
     304        // client limit 
     305        if(social->m_playerSocialMap.size() >= 50) 
    304306            break; 
    305307    } 
  • trunk/src/game/Spell.cpp

    r18 r28  
    987987                if( !(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) ) 
    988988                { 
    989                     if(!unit->IsStandState() && !unit->hasUnitState(UNIT_STAT_STUNDED)) 
     989                    if(!unit->IsStandState() && !unit->hasUnitState(UNIT_STAT_STUNNED)) 
    990990                        unit->SetStandState(PLAYER_STATE_NONE); 
    991991 
     
    24082408 
    24092409                    // check for incapacitating player states 
    2410                     if( m_caster->hasUnitState(UNIT_STAT_STUNDED | UNIT_STAT_CONFUSED)) 
     2410                    if( m_caster->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED)) 
    24112411                        cancel(); 
    24122412 
  • trunk/src/game/SpellAuras.cpp

    r2 r28  
    31903190    if (apply) 
    31913191    { 
    3192         m_target->addUnitState(UNIT_STAT_STUNDED); 
     3192        m_target->addUnitState(UNIT_STAT_STUNNED); 
    31933193        m_target->SetUInt64Value(UNIT_FIELD_TARGET, 0); 
    31943194 
     
    32143214            return; 
    32153215 
    3216         m_target->clearUnitState(UNIT_STAT_STUNDED); 
     3216        m_target->clearUnitState(UNIT_STAT_STUNNED); 
    32173217        m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE); 
    32183218 
     
    34433443        m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16)); 
    34443444 
    3445         if(!m_target->hasUnitState(UNIT_STAT_STUNDED))      // prevent allow move if have also stun effect 
     3445        if(!m_target->hasUnitState(UNIT_STAT_STUNNED))      // prevent allow move if have also stun effect 
    34463446        { 
    34473447            if(m_target->getVictim() && m_target->isAlive()) 
  • trunk/src/game/SpellEffects.cpp

    r18 r28  
    14661466                        return; 
    14671467 
    1468                     if( !unitTarget->hasUnitState(UNIT_STAT_STUNDED) && m_caster->GetTypeId()==TYPEID_PLAYER) 
     1468                    if( !unitTarget->hasUnitState(UNIT_STAT_STUNNED) && m_caster->GetTypeId()==TYPEID_PLAYER) 
    14691469                    { 
    14701470                        // decreased damage (/2) for non-stunned target. 
     
    34023402 
    34033403    // target must be OK to do this 
    3404     if( unitTarget->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNDED | UNIT_STAT_FLEEING ) ) 
     3404    if( unitTarget->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING ) ) 
    34053405        return; 
    34063406 
  • trunk/src/game/TargetedMovementGenerator.cpp

    r18 r28  
    4848        return; 
    4949 
    50     if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED | UNIT_STAT_DISTRACTED) ) 
     50    if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED) ) 
    5151        return; 
    5252 
     
    128128        return true; 
    129129 
    130     if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED | UNIT_STAT_FLEEING | UNIT_STAT_DISTRACTED) ) 
     130    if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_DISTRACTED) ) 
    131131        return true; 
    132132 
  • trunk/src/game/TradeHandler.cpp

    r2 r28  
    2727#include "Item.h" 
    2828#include "SocialMgr.h" 
     29#include "Language.h" 
    2930 
    3031enum TradeStatus 
     
    256257    if( _player->tradeGold > _player->GetMoney() ) 
    257258    { 
    258         SendNotification( "You do not have enough gold" ); 
     259        SendNotification(LANG_NOT_ENOUGH_GOLD); 
    259260        _player->pTrader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); 
    260261        _player->acceptTrade = false; 
     
    265266    if( _player->pTrader->tradeGold > _player->pTrader->GetMoney() ) 
    266267    { 
    267         _player->pTrader->GetSession( )->SendNotification( "You do not have enough gold" ); 
     268        _player->pTrader->GetSession( )->SendNotification(LANG_NOT_ENOUGH_GOLD); 
    268269        SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); 
    269270        _player->pTrader->acceptTrade = false; 
     
    339340        if(!myCanCompleteTrade) 
    340341        { 
    341             SendNotification("You do not have enough free slots"); 
    342             GetPlayer( )->pTrader->GetSession( )->SendNotification("Your partner does not have enough free bag slots"); 
     342            SendNotification(LANG_NOT_FREE_TRADE_SLOTS); 
     343            GetPlayer( )->pTrader->GetSession( )->SendNotification(LANG_NOT_PARTNER_FREE_TRADE_SLOTS); 
    343344            SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); 
    344345            _player->pTrader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); 
     
    347348        else if (!hisCanCompleteTrade) 
    348349        { 
    349             SendNotification("Your partner does not have enough free bag slots"); 
    350             GetPlayer()->pTrader->GetSession()->SendNotification("You do not have enough free slots"); 
     350            SendNotification(LANG_NOT_PARTNER_FREE_TRADE_SLOTS); 
     351            GetPlayer()->pTrader->GetSession()->SendNotification(LANG_NOT_FREE_TRADE_SLOTS); 
    351352            SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); 
    352353            _player->pTrader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); 
     
    462463    } 
    463464 
    464     if( GetPlayer()->hasUnitState(UNIT_STAT_STUNDED) ) 
     465    if( GetPlayer()->hasUnitState(UNIT_STAT_STUNNED) ) 
    465466    { 
    466467        SendTradeStatus(TRADE_STATUS_YOU_STUNNED); 
     
    508509    } 
    509510 
    510     if( pOther->hasUnitState(UNIT_STAT_STUNDED) ) 
     511    if( pOther->hasUnitState(UNIT_STAT_STUNNED) ) 
    511512    { 
    512513        SendTradeStatus(TRADE_STATUS_TARGET_STUNNED); 
  • trunk/src/game/Unit.cpp

    r9 r28  
    471471            RemoveSpellsCausingAura(SPELL_AURA_MOD_INVISIBILITY); 
    472472 
    473         if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNDED)) 
     473        if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNNED)) 
    474474            pVictim->SetStandState(PLAYER_STATE_NONE); 
    475475    } 
     
    21502150void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool extra ) 
    21512151{ 
    2152     if(hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNDED | UNIT_STAT_FLEEING) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) ) 
     2152    if(hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) ) 
    21532153        return; 
    21542154 
     
    29622962float Unit::GetUnitDodgeChance() const 
    29632963{ 
    2964     if(hasUnitState(UNIT_STAT_STUNDED)) 
     2964    if(hasUnitState(UNIT_STAT_STUNNED)) 
    29652965        return 0.0f; 
    29662966    if( GetTypeId() == TYPEID_PLAYER ) 
     
    29812981float Unit::GetUnitParryChance() const 
    29822982{ 
    2983     if ( IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNDED)) 
     2983    if ( IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNNED)) 
    29842984        return 0.0f; 
    29852985 
     
    30133013float Unit::GetUnitBlockChance() const 
    30143014{ 
    3015     if ( IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNDED)) 
     3015    if ( IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNNED)) 
    30163016        return 0.0f; 
    30173017 
     
    79867986    if (spellInfo->Mechanic == MECHANIC_FEAR ) 
    79877987    { 
    7988         if ( hasUnitState(UNIT_STAT_STUNDED) ) 
     7988        if ( hasUnitState(UNIT_STAT_STUNNED) ) 
    79897989            return true; 
    79907990    } 
     
    86638663 
    86648664    //If a mob or player is stunned he will not be able to detect stealth 
    8665     if (u->hasUnitState(UNIT_STAT_STUNDED) && (u != this)) 
     8665    if (u->hasUnitState(UNIT_STAT_STUNNED) && (u != this)) 
    86668666        return false; 
    86678667 
     
    91379137    if(target) 
    91389138    { 
    9139         if(!hasUnitState(UNIT_STAT_STUNDED)) 
     9139        if(!hasUnitState(UNIT_STAT_STUNNED)) 
    91409140            SetInFront(target); 
    91419141        ((Creature*)this)->AI()->AttackStart(target); 
  • trunk/src/game/Unit.h

    r9 r28  
    347347    UNIT_STAT_MELEE_ATTACKING = 0x0002,                     // player is melee attacking someone 
    348348    //UNIT_STAT_MELEE_ATTACK_BY = 0x0004,                     // player is melee attack by someone 
    349     UNIT_STAT_STUNDED         = 0x0008, 
     349    UNIT_STAT_STUNNED         = 0x0008, 
    350350    UNIT_STAT_ROAMING         = 0x0010, 
    351351    UNIT_STAT_CHASE           = 0x0020, 
     
    757757        { 
    758758            return !hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_IN_FLIGHT | 
    759                 UNIT_STAT_ROOT | UNIT_STAT_STUNDED | UNIT_STAT_DISTRACTED ) && GetOwnerGUID()==0; 
     759                UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED ) && GetOwnerGUID()==0; 
    760760        } 
    761761 
  • trunk/src/game/WaypointMovementGenerator.cpp

    r18 r28  
    8686    // Waypoint movement can be switched on/off 
    8787    // This is quite handy for escort quests and other stuff 
    88     if(creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED | UNIT_STAT_DISTRACTED)) 
     88    if(creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) 
    8989        return true; 
    9090 
  • trunk/src/game/World.cpp

    r19 r28  
    643643    } 
    644644 
    645     m_configs[CONFIG_GM_WISPERING_TO] = sConfig.GetBoolDefault("GM.WhisperingTo",false); 
    646     m_configs[CONFIG_GM_IN_GM_LIST]  = sConfig.GetBoolDefault("GM.InGMList",false); 
    647     m_configs[CONFIG_GM_IN_WHO_LIST]  = sConfig.GetBoolDefault("GM.InWhoList",false); 
    648     m_configs[CONFIG_GM_LOGIN_STATE]  = sConfig.GetIntDefault("GM.LoginState",2); 
    649     m_configs[CONFIG_GM_LOG_TRADE] = sConfig.GetBoolDefault("GM.LogTrade", false); 
     645    m_configs[CONFIG_GM_LOGIN_STATE]       = sConfig.GetIntDefault("GM.LoginState",2); 
     646    m_configs[CONFIG_GM_ACCEPT_TICKETS]    = sConfig.GetIntDefault("GM.AcceptTickets",2); 
     647    m_configs[CONFIG_GM_CHAT]              = sConfig.GetIntDefault("GM.Chat",2); 
     648    m_configs[CONFIG_GM_WISPERING_TO]      = sConfig.GetIntDefault("GM.WhisperingTo",2); 
     649 
     650    m_configs[CONFIG_GM_IN_GM_LIST]        = sConfig.GetBoolDefault("GM.InGMList",false); 
     651    m_configs[CONFIG_GM_IN_WHO_LIST]       = sConfig.GetBoolDefault("GM.InWhoList",false); 
     652    m_configs[CONFIG_GM_LOG_TRADE]         = sConfig.GetBoolDefault("GM.LogTrade", false); 
    650653 
    651654    m_configs[CONFIG_GROUP_VISIBILITY] = sConfig.GetIntDefault("Visibility.GroupMode",0); 
  • trunk/src/game/World.h

    r19 r28  
    107107    CONFIG_MAX_PRIMARY_TRADE_SKILL, 
    108108    CONFIG_MIN_PETITION_SIGNS, 
     109    CONFIG_GM_LOGIN_STATE, 
     110    CONFIG_GM_ACCEPT_TICKETS, 
     111    CONFIG_GM_CHAT, 
    109112    CONFIG_GM_WISPERING_TO, 
    110113    CONFIG_GM_IN_GM_LIST, 
    111114    CONFIG_GM_IN_WHO_LIST, 
    112     CONFIG_GM_LOGIN_STATE, 
    113115    CONFIG_GM_LOG_TRADE, 
    114116    CONFIG_GROUP_VISIBILITY, 
  • trunk/src/game/WorldSession.cpp

    r6 r28  
    441441} 
    442442 
     443void WorldSession::SendNotification(int32 string_id,...) 
     444{ 
     445    char const* format = GetMangosString(string_id); 
     446    if(format) 
     447    { 
     448        va_list ap; 
     449        char szStr [1024]; 
     450        szStr[0] = '\0'; 
     451        va_start(ap, format); 
     452        vsnprintf( szStr, 1024, format, ap ); 
     453        va_end(ap); 
     454 
     455        WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr)+1)); 
     456        data << szStr; 
     457        SendPacket(&data); 
     458    } 
     459} 
     460 
    443461const char * WorldSession::GetMangosString( int32 entry ) 
    444462{ 
  • trunk/src/game/WorldSession.h

    r6 r28  
    8080        void SendPacket(WorldPacket const* packet); 
    8181        void SendNotification(const char *format,...) ATTR_PRINTF(2,3); 
     82        void SendNotification(int32 string_id,...); 
    8283        void SendLfgResult(uint32 type, uint32 entry, uint8 lfg_type); 
    8384        void SendPartyResult(PartyOperation operation, std::string member, PartyResult res); 
  • trunk/src/shared/WheatyExceptionReport.cpp

    r2 r28  
    99#pragma warning(disable:4311) 
    1010#include <windows.h> 
     11#include <tlhelp32.h> 
    1112#include <stdio.h> 
    1213#include <tchar.h> 
     
    328329 
    329330//=========================================================================== 
     331void WheatyExceptionReport::printTracesForAllThreads() 
     332{ 
     333  HANDLE hThreadSnap = INVALID_HANDLE_VALUE;  
     334  THREADENTRY32 te32;  
     335  
     336  DWORD dwOwnerPID = GetCurrentProcessId(); 
     337  m_hProcess = GetCurrentProcess(); 
     338  // Take a snapshot of all running threads   
     339  hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );  
     340  if( hThreadSnap == INVALID_HANDLE_VALUE )  
     341    return;  
     342  
     343  // Fill in the size of the structure before using it.  
     344  te32.dwSize = sizeof(THREADENTRY32 );  
     345  
     346  // Retrieve information about the first thread, 
     347  // and exit if unsuccessful 
     348  if( !Thread32First( hThreadSnap, &te32 ) )  
     349  { 
     350    CloseHandle( hThreadSnap );    // Must clean up the 
     351                                   //   snapshot object! 
     352    return; 
     353  } 
     354 
     355  // Now walk the thread list of the system, 
     356  // and display information about each thread 
     357  // associated with the specified process 
     358  do  
     359  {  
     360    if( te32.th32OwnerProcessID == dwOwnerPID ) 
     361    { 
     362        CONTEXT context; 
     363        context.ContextFlags = 0xffffffff; 
     364        HANDLE threadHandle = OpenThread(THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION,false, te32.th32ThreadID); 
     365        if(threadHandle && GetThreadContext(threadHandle, &context)) 
     366        { 
     367            WriteStackDetails( &context, false, threadHandle ); 
     368        } 
     369        CloseHandle(threadHandle); 
     370    } 
     371  } while( Thread32Next(hThreadSnap, &te32 ) );  
     372 
     373//  Don't forget to clean up the snapshot object. 
     374  CloseHandle( hThreadSnap ); 
     375} 
     376 
     377 
     378//=========================================================================== 
    330379// Open the report file, and write the desired information to it.  Called by 
    331380// WheatyUnhandledExceptionFilter 
     
    412461    CONTEXT trashableContext = *pCtx; 
    413462 
    414     WriteStackDetails( &trashableContext, false ); 
     463    WriteStackDetails( &trashableContext, false, NULL ); 
     464    printTracesForAllThreads(); 
    415465 
    416466//    #ifdef _M_IX86                                          // X86 Only! 
     
    420470 
    421471    trashableContext = *pCtx; 
    422     WriteStackDetails( &trashableContext, true ); 
     472    WriteStackDetails( &trashableContext, true, NULL ); 
    423473 
    424474    _tprintf( _T("========================\r\n") ); 
     
    552602void WheatyExceptionReport::WriteStackDetails( 
    553603PCONTEXT pContext, 
    554 bool bWriteVariables )                                      // true if local/params should be output 
     604bool bWriteVariables, HANDLE pThreadHandle)                                      // true if local/params should be output 
    555605{ 
    556606    _tprintf( _T("\r\nCall stack:\r\n") ); 
     
    592642        if ( ! StackWalk64(  dwMachineType, 
    593643            m_hProcess, 
    594             GetCurrentThread(), 
     644            pThreadHandle != NULL ? pThreadHandle : GetCurrentThread(), 
    595645            &sf, 
    596646            pContext, 
  • trunk/src/shared/WheatyExceptionReport.h

    r2 r28  
    8080            PEXCEPTION_POINTERS pExceptionInfo ); 
    8181 
     82        static void printTracesForAllThreads(); 
    8283    private: 
    83  
    8484        // where report info is extracted and generated 
    8585        static void GenerateExceptionReport( PEXCEPTION_POINTERS pExceptionInfo ); 
     
    9393            DWORD& section, DWORD_PTR& offset ); 
    9494 
    95         static void WriteStackDetails( PCONTEXT pContext, bool bWriteVariables ); 
     95        static void WriteStackDetails( PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle); 
    9696 
    9797        static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO,ULONG, PVOID); 
  • trunk/src/trinitycore/TrinityCore.rc

    r18 r28  
    5353 
    5454VS_VERSION_INFO VERSIONINFO 
    55  FILEVERSION 0,3,6731,680 
    56  PRODUCTVERSION 0,3,6731,680 
     55 FILEVERSION 0,4,6743,685 
     56 PRODUCTVERSION 0,4,6743,685 
    5757 FILEFLAGSMASK 0x17L 
    5858#ifdef _DEBUG 
     
    7070        BEGIN 
    7171            VALUE "FileDescription", "TrinityCore" 
    72             VALUE "FileVersion", "0, 3, 6731, 680" 
     72            VALUE "FileVersion", "0, 4, 6743, 685" 
    7373            VALUE "InternalName", "TrinityCore" 
    7474            VALUE "LegalCopyright", "Copyright (C) 2008" 
    7575            VALUE "OriginalFilename", "TrinityCore.exe" 
    7676            VALUE "ProductName", "TrinityCore" 
    77             VALUE "ProductVersion", "0, 3, 6731, 680" 
     77            VALUE "ProductVersion", "0, 4, 6743, 685" 
    7878        END 
    7979    END 
  • trunk/src/trinityrealm/TrinityRealm.rc

    r18 r28  
    5353 
    5454VS_VERSION_INFO VERSIONINFO 
    55  FILEVERSION 0,3,6731,680 
    56  PRODUCTVERSION 0,3,6731,680 
     55 FILEVERSION 0,4,6743,685 
     56 PRODUCTVERSION 0,4,6743,685 
    5757 FILEFLAGSMASK 0x17L 
    5858#ifdef _DEBUG 
     
    7070        BEGIN 
    7171            VALUE "FileDescription", "TrinityRealm" 
    72             VALUE "FileVersion", "0, 3, 6731, 680" 
     72            VALUE "FileVersion", "0, 4, 6743, 685" 
    7373            VALUE "InternalName", "TrinityRealm" 
    7474            VALUE "LegalCopyright", "Copyright (C) 2008" 
    7575            VALUE "OriginalFilename", "TrinityRealm.exe" 
    7676            VALUE "ProductName", "TrinityRealm" 
    77             VALUE "ProductVersion", "0, 3, 6731, 680" 
     77            VALUE "ProductVersion", "0, 4, 6743, 685" 
    7878        END 
    7979    END