Changeset 5
- Timestamp:
- 11/19/08 13:21:11 (17 years ago)
- Location:
- trunk/src/bindings/scripts
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bindings/scripts/ScriptMgr.cpp
r2 r5 81 81 //*** End EventAI data *** 82 82 83 DatabaseMysql ScriptDev2DB;84 Config SD2Config;83 DatabaseMysql TScriptDB; 84 Config TScriptConfig; 85 85 uint32 Locale; 86 86 … … 598 598 //Get db string from file 599 599 char const* dbstring = NULL; 600 if (!SD2Config.GetString("ScriptDev2DatabaseInfo", &dbstring))601 error_log(" SD2: Missing ScriptDev2 Database Info fromconfiguration file");600 if(!TScriptConfig.GetString("TScriptDatabaseInfo", &dbstring)) 601 error_log("TSCR: Missing Trinity Script Database Info in configuration file"); 602 602 603 603 //Initilize connection to DB 604 if (!dbstring || !ScriptDev2DB.Initialize(dbstring))605 error_db_log(" SD2: Unable to connect to Database");604 if(!dbstring || !TScriptDB.Initialize(dbstring)) 605 error_db_log("TSCR: Unable to connect to Database"); 606 606 else 607 607 { … … 610 610 611 611 //Get Version information 612 result = ScriptDev2DB.PQuery("SELECT `version`"613 "FROM `s d2_db_version`");612 result = TScriptDB.PQuery("SELECT `version`" 613 "FROM `script_db_version`"); 614 614 615 615 if (result) … … 617 617 Field *fields = result->Fetch(); 618 618 outstring_log(" "); 619 outstring_log(" SD2: Database version is: %s", fields[0].GetString());619 outstring_log("TSCR: Database version is: %s", fields[0].GetString()); 620 620 outstring_log(" "); 621 621 delete result; 622 622 623 }else error_db_log(" SD2: Missing sd2_db_version information.");623 }else error_db_log("TSCR: Missing script_db_version information."); 624 624 625 625 // Drop existing Event AI Localized Text hash map … … 627 627 628 628 // Gather EventAI Localized Texts 629 result = ScriptDev2DB.PQuery("SELECT `id`,`locale_1`,`locale_2`,`locale_3`,`locale_4`,`locale_5`,`locale_6`,`locale_7`,`locale_8`"629 result = TScriptDB.PQuery("SELECT `id`,`locale_1`,`locale_2`,`locale_3`,`locale_4`,`locale_5`,`locale_6`,`locale_7`,`locale_8`" 630 630 "FROM `eventai_localized_texts`"); 631 631 632 632 if(result) 633 633 { 634 outstring_log(" Loading EAI Localized Texts....");634 outstring_log("TSCR: Loading EAI Localized Texts...."); 635 635 barGoLink bar(result->GetRowCount()); 636 636 uint32 count = 0; … … 662 662 663 663 outstring_log(""); 664 outstring_log(" SD2: Loaded %u EventAI Localized Texts", count);665 }else outstring_log(" SD2: WARNING >> Loaded 0 EventAI Localized Texts. Database table `eventai_localized_texts` is empty");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 666 667 667 // Drop Existing Script Localized Text Hash Map … … 669 669 670 670 // Gather Script Localized Texts 671 result = ScriptDev2DB.PQuery("SELECT `id`,`locale_1`,`locale_2`,`locale_3`,`locale_4`,`locale_5`,`locale_6`,`locale_7`,`locale_8`"671 result = TScriptDB.PQuery("SELECT `id`,`locale_1`,`locale_2`,`locale_3`,`locale_4`,`locale_5`,`locale_6`,`locale_7`,`locale_8`" 672 672 "FROM `script_localized_texts`"); 673 673 674 674 if(result) 675 675 { 676 outstring_log(" Loading Script Localized Texts....");676 outstring_log("TSCR: Loading Script Localized Texts...."); 677 677 barGoLink bar(result->GetRowCount()); 678 678 uint32 count = 0; … … 704 704 705 705 outstring_log(""); 706 outstring_log(" SD2: Loaded %u Script Localized Texts", count);707 }else outstring_log(" SD2: WARNING >> Loaded 0 Script Localized Texts. Database table `script_localized_texts` is empty");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 708 709 709 //Drop existing EventAI Text hash map … … 711 711 712 712 //Gather EventAI Text Entries 713 result = ScriptDev2DB.PQuery("SELECT `id`,`text` FROM `eventai_texts`");713 result = TScriptDB.PQuery("SELECT `id`,`text` FROM `eventai_texts`"); 714 714 715 715 if (result) 716 716 { 717 outstring_log( " SD2: Loading EventAI_Texts...");717 outstring_log( "TSCR: Loading EventAI_Texts..."); 718 718 barGoLink bar(result->GetRowCount()); 719 719 uint32 Count = 0; … … 729 729 730 730 if (!strlen(text.c_str())) 731 error_db_log(" SD2: EventAI text %u is empty", i);731 error_db_log("TSCR: EventAI text %u is empty", i); 732 732 733 733 EventAI_Text_Map[i] = text; … … 739 739 740 740 outstring_log(""); 741 outstring_log(" SD2: >> Loaded %u EventAI_Texts", Count);742 743 }else outstring_log(" SD2: WARNING >> Loaded 0 EventAI_Texts. DB table `EventAI_Texts` is empty.");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 744 745 745 //Gather event data 746 result = ScriptDev2DB.PQuery("SELECT `id`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`"746 result = TScriptDB.PQuery("SELECT `id`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`" 747 747 "FROM `eventai_summons`"); 748 748 … … 752 752 if (result) 753 753 { 754 outstring_log( " SD2: Loading EventAI_Summons...");754 outstring_log( "TSCR: Loading EventAI_Summons..."); 755 755 barGoLink bar(result->GetRowCount()); 756 756 uint32 Count = 0; … … 778 778 delete result; 779 779 outstring_log(""); 780 outstring_log(" SD2: >> Loaded %u EventAI_Summons", Count);781 782 }else outstring_log(" SD2: WARNING >> Loaded 0 EventAI_Summons. DB table `EventAI_Summons` is empty.");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 783 784 784 //Gather event data 785 result = ScriptDev2DB.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`"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 786 "FROM `eventai_scripts`"); 787 787 … … 791 791 if (result) 792 792 { 793 outstring_log( " SD2: Loading EventAI_Scripts...");793 outstring_log( "TSCR: Loading EventAI_Scripts..."); 794 794 barGoLink bar(result->GetRowCount()); 795 795 uint32 Count = 0; … … 816 816 //Report any errors in event 817 817 if (temp.event_type >= EVENT_T_END) 818 error_db_log(" SD2: Event %u has incorrect event type. Maybe DB requires updated version of SD2.", i);818 error_db_log("TSCR: Event %u has incorrect event type. Maybe DB requires updated version of SD2.", i); 819 819 820 820 //No chance of this event occuring 821 821 if (temp.event_chance == 0) 822 error_db_log(" SD2: Event %u has 0 percent chance. Event will never trigger!", i);822 error_db_log("TSCR: Event %u has 0 percent chance. Event will never trigger!", i); 823 823 //Chance above 100, force it to be 100 824 824 if (temp.event_chance > 100) 825 825 { 826 error_db_log(" SD2: Creature %u are using event %u with more than 100 percent chance. Adjusting to 100 percent.", temp.creature_id, i);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 827 temp.event_chance = 100; 828 828 } … … 831 831 switch (temp.event_type) 832 832 { 833 case EVENT_T_HP: 834 case EVENT_T_MANA: 835 case EVENT_T_TARGET_HP: 836 { 837 if (temp.event_param2 > 100) 838 error_db_log("SD2: 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("SD2: 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) 833 case EVENT_T_HP: 834 case EVENT_T_MANA: 835 case EVENT_T_TARGET_HP: 844 836 { 845 error_db_log("SD2: 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; 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 } 847 848 } 848 } 849 break; 850 851 case EVENT_T_SPELLHIT: 852 { 853 if (temp.event_param1) 849 break; 850 851 case EVENT_T_SPELLHIT: 854 852 { 855 SpellEntry const* pSpell = GetSpellStore()->LookupEntry(temp.event_param1); 856 if (!pSpell) 853 if (temp.event_param1) 857 854 { 858 error_db_log("SD2: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.event_param1, i); 859 continue; 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); 860 864 } 861 865 862 if (temp.event_param2_s != -1 && temp.event_param2 != pSpell->SchoolMask) 863 error_db_log("SD2: 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); 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); 864 873 } 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("SD2: 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("SD2: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); 873 } 874 break; 875 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: 881 { 882 if (temp.event_param4 < temp.event_param3) 883 error_db_log("SD2: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); 884 } 885 break; 886 887 case EVENT_T_TIMER: 888 case EVENT_T_TIMER_OOC: 889 { 890 if (temp.event_param2 < temp.event_param1) 891 error_db_log("SD2: 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("SD2: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); 895 } 896 break; 897 898 case EVENT_T_KILL: 899 case EVENT_T_TARGET_CASTING: 900 { 901 if (temp.event_param2 < temp.event_param1) 902 error_db_log("SD2: Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); 903 } 904 break; 905 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) 874 break; 875 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: 912 881 { 913 error_db_log("SD2: 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;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); 915 884 } 916 } 917 break; 885 break; 886 887 case EVENT_T_TIMER: 888 case EVENT_T_TIMER_OOC: 889 { 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); 895 } 896 break; 897 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 } 904 break; 905 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 } 917 break; 918 918 }; 919 919 … … 928 928 switch (temp.action[j].type) 929 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("SD2: 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("SD2: 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("SD2: 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("SD2: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param1); 955 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: 956 998 if (temp.action[j].param2 >= TARGET_T_END) 957 error_db_log("SD2: 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("SD2: 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("SD2: 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("SD2: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param2); 975 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: 976 1004 if (temp.action[j].param3 >= TARGET_T_END) 977 error_db_log("SD2: 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("SD2: 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("SD2: 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("SD2: 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("SD2: 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("SD2: 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("SD2: 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("SD2 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("SD2: 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; 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 1030 } 1031 1031 1032 1032 if (temp.action[j].type >= ACTION_T_END) 1033 error_db_log(" SD2: Event %u Action %u has incorrect action type. Maybe DB requires updated version of SD2.", i, j+1);1033 error_db_log("TSCR: Event %u Action %u has incorrect action type. Maybe DB requires updated version of SD2.", i, j+1); 1034 1034 } 1035 1035 … … 1042 1042 delete result; 1043 1043 outstring_log(""); 1044 outstring_log(" SD2: >> Loaded %u EventAI_Events", Count);1045 1046 }else outstring_log(" SD2: WARNING >> Loaded 0 EventAI_Scripts. DB table `EventAI_Scripts` is empty.");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 1047 1048 1048 // Gather Script Text 1049 result = ScriptDev2DB.PQuery("SELECT `id`, `sound`, `type`, `language`, `text`"1049 result = TScriptDB.PQuery("SELECT `id`, `sound`, `type`, `language`, `text`" 1050 1050 "FROM `script_texts`;"); 1051 1051 … … 1055 1055 if(result) 1056 1056 { 1057 outstring_log(" SD2: Loading Script Text...");1057 outstring_log("TSCR: Loading Script Text..."); 1058 1058 barGoLink bar(result->GetRowCount()); 1059 1059 uint32 count = 0; … … 1074 1074 { 1075 1075 if (!GetSoundEntriesStore()->LookupEntry(temp.SoundId)) 1076 error_db_log(" SD2: Id %u in table script_texts has soundid %u but sound does not exist.",i,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 1077 } 1078 1078 1079 1079 if(!strlen(temp.Text.c_str())) 1080 error_db_log(" SD2: Id %u in table script_texts has no text.", i);1080 error_db_log("TSCR: Id %u in table script_texts has no text.", i); 1081 1081 1082 1082 Script_TextMap[i] = temp; … … 1088 1088 1089 1089 outstring_log(""); 1090 outstring_log(" SD2: Loaded %u Script Texts", count);1091 1092 }else outstring_log(" SD2WARNING >> Loaded 0 Script Texts. Database table `script_texts` is empty.");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 1093 1094 1094 //Free database thread and resources 1095 ScriptDev2DB.HaltDelayThread();1095 TScriptDB.HaltDelayThread(); 1096 1096 1097 1097 //***End DB queries*** … … 1120 1120 void ScriptsInit() 1121 1121 { 1122 //ScriptDev2 startup 1122 //Trinity Script startup 1123 outstring_log("|_ _| __(_)_ __ (_) |_ _ _/ ___| ___ _ __(_)_ __ | |_ "); 1124 outstring_log(" | || '__| | '_ \\| | __| | | \\___ \\ / __| \\'__| | \\'_ \\| __|"); 1125 outstring_log(" | || | | | | | | | |_| |_| |___) | (__| | | | |_) | |_ "); 1126 outstring_log(" |_||_| |_|_| |_|_|\\__|\\__, |____/ \\___|_| |_| .__/ \\__|"); 1127 outstring_log(" |___/ |_| "); 1128 outstring_log("Trinity Script initializing %s", _FULLVERSION); 1123 1129 outstring_log(""); 1124 outstring_log(" MMM MMM MM");1125 outstring_log("M MM M M M M");1126 outstring_log("MM M M M");1127 outstring_log(" MMM M M M");1128 outstring_log(" MM M M MMMM");1129 outstring_log("MM M M M ");1130 outstring_log(" MMM MMM http://www.scriptdev2.com");1131 outstring_log("");1132 1133 outstring_log("ScriptDev2 initializing %s", _FULLVERSION);1134 1135 outstring_log("");1136 1130 1137 1131 //Get configuration file 1138 if (! SD2Config.SetSource(_TRINITY_SCRIPT_CONFIG))1139 error_log(" SD2: Unable to open configuration file, Database will be unaccessible");1140 else outstring_log(" SD2: Using configuration file %s", _TRINITY_SCRIPT_CONFIG);1132 if (!TScriptConfig.SetSource(_TRINITY_SCRIPT_CONFIG)) 1133 error_log("TSCR: Unable to open configuration file, Database will be unaccessible"); 1134 else outstring_log("TSCR: Using configuration file %s", _TRINITY_SCRIPT_CONFIG); 1141 1135 1142 1136 1143 1137 //Check config file version 1144 if ( SD2Config.GetIntDefault("ConfVersion", 0) != _TSCRIPTCONFVERSION)1145 error_log(" SD2: Configuration file version doesn't match expected version. Some config variables may be wrong or missing.");1138 if (TScriptConfig.GetIntDefault("ConfVersion", 0) != _TSCRIPTCONFVERSION) 1139 error_log("TSCR: Configuration file version doesn't match expected version. Some config variables may be wrong or missing."); 1146 1140 1147 1141 //Locale 1148 Locale = SD2Config.GetIntDefault("Locale", 0);1142 Locale = TScriptConfig.GetIntDefault("Locale", 0); 1149 1143 1150 1144 if (Locale > 8) 1151 1145 { 1152 1146 Locale = 0; 1153 error_log(" SD2: Locale set to invalid language id. Defaulting to 0.");1147 error_log("TSCR: Locale set to invalid language id. Defaulting to 0."); 1154 1148 } 1155 1149 1156 outstring_log(" SD2: Using locale %u", Locale);1150 outstring_log("TSCR: Using locale %u", Locale); 1157 1151 outstring_log(""); 1158 1152 1159 EAI_ErrorLevel = SD2Config.GetIntDefault("EAIErrorLevel", 1);1153 EAI_ErrorLevel = TScriptConfig.GetIntDefault("EAIErrorLevel", 1); 1160 1154 1161 1155 switch (EAI_ErrorLevel) 1162 1156 { 1163 case 0:1164 outstring_log("SD2: EventAI Error Reporting level set to 0 (Startup Errors only)");1165 break;1166 1167 case 1:1168 outstring_log("SD2: EventAI Error Reporting level set to 1 (Startup errors and Runtime event errors)");1169 break;1170 1171 case 2:1172 outstring_log("SD2: EventAI Error Reporting level set to 2 (Startup errors, Runtime event errors, and Creation errors)");1173 break;1174 1175 default:1176 outstring_log("SD2: Unknown EventAI Error Reporting level. Defaulting to 1 (Startup errors and Runtime event errors)");1177 EAI_ErrorLevel = 1;1178 break;1157 case 0: 1158 outstring_log("TSCR: EventAI Error Reporting level set to 0 (Startup Errors only)"); 1159 break; 1160 1161 case 1: 1162 outstring_log("TSCR: EventAI Error Reporting level set to 1 (Startup errors and Runtime event errors)"); 1163 break; 1164 1165 case 2: 1166 outstring_log("TSCR: EventAI Error Reporting level set to 2 (Startup errors, Runtime event errors, and Creation errors)"); 1167 break; 1168 1169 default: 1170 outstring_log("TSCR: Unknown EventAI Error Reporting level. Defaulting to 1 (Startup errors and Runtime event errors)"); 1171 EAI_ErrorLevel = 1; 1172 break; 1179 1173 } 1180 1174 outstring_log(""); 1181 1175 1182 //Load database (must be called after SD2Config.SetSource)1176 //Load database (must be called after TScriptConfig.SetSource) 1183 1177 LoadDatabase(); 1184 1178 … … 1698 1692 // ------------------- 1699 1693 1700 outstring_log(" SD2: Loaded %u C++ Scripts", nrscripts);1694 outstring_log("TSCR: Loaded %u C++ Scripts", nrscripts); 1701 1695 outstring_log(""); 1702 1696 } … … 1708 1702 { 1709 1703 if (entry == 0xffffffff) 1710 error_log(" SD2: Entry = -1, GetEventAILocalizedText should not be called in this case.");1704 error_log("TSCR: Entry = -1, GetEventAILocalizedText should not be called in this case."); 1711 1705 1712 1706 const char* temp = NULL; … … 1716 1710 if (i == EventAI_LocalizedTextMap.end()) 1717 1711 { 1718 error_log(" SD2: EventAI Localized Text %u not found", entry);1712 error_log("TSCR: EventAI Localized Text %u not found", entry); 1719 1713 return DEFAULT_TEXT; 1720 1714 } … … 1769 1763 if (i == Script_LocalizedTextMap.end()) 1770 1764 { 1771 error_log(" SD2: Script Localized Text %u not found", entry);1765 error_log("TSCR: Script Localized Text %u not found", entry); 1772 1766 return DEFAULT_TEXT; 1773 1767 } … … 1817 1811 { 1818 1812 if(entry == 0xffffffff) 1819 error_log(" SD2: Entry = -1, GetEventAIText should not be called in this case.");1813 error_log("TSCR: Entry = -1, GetEventAIText should not be called in this case."); 1820 1814 1821 1815 const char* str = NULL; … … 1824 1818 if(itr == EventAI_Text_Map.end()) 1825 1819 { 1826 error_log(" SD2 ERROR: Unable to find EventAI Text %u", entry);1820 error_log("TSCR: Unable to find EventAI Text %u", entry); 1827 1821 return DEFAULT_TEXT; 1828 1822 } … … 1843 1837 if (!pSource) 1844 1838 { 1845 error_log(" SD2: ProcessScriptText invalid Source pointer.");1839 error_log("TSCR: ProcessScriptText invalid Source pointer."); 1846 1840 return; 1847 1841 } … … 1851 1845 if (i == Script_TextMap.end()) 1852 1846 { 1853 error_log(" SD2: ProcessScriptText could not find id %u.",id);1847 error_log("TSCR: ProcessScriptText could not find id %u.",id); 1854 1848 return; 1855 1849 } … … 1865 1859 } 1866 1860 else 1867 error_log(" SD2: ProcessScriptText id %u tried to process invalid soundid %u.",id,(*i).second.SoundId);1861 error_log("TSCR: ProcessScriptText id %u tried to process invalid soundid %u.",id,(*i).second.SoundId); 1868 1862 } 1869 1863 … … 1890 1884 if (target && target->GetTypeId() == TYPEID_PLAYER) 1891 1885 pSource->MonsterWhisper((*i).second.Text.c_str(), target->GetGUID()); 1892 else error_log(" SD2: ProcessScriptText id %u cannot whisper without target unit (TYPEID_PLAYER).", id);1886 else error_log("TSCR: ProcessScriptText id %u cannot whisper without target unit (TYPEID_PLAYER).", id); 1893 1887 }break; 1894 1888 … … 1897 1891 if (target && target->GetTypeId() == TYPEID_PLAYER) 1898 1892 pSource->MonsterWhisper((*i).second.Text.c_str(), target->GetGUID(), true); 1899 else error_log(" SD2: ProcessScriptText id %u cannot whisper without target unit (TYPEID_PLAYER).", id);1893 else error_log("TSCR: ProcessScriptText id %u cannot whisper without target unit (TYPEID_PLAYER).", id); 1900 1894 }break; 1901 1895 } … … 1931 1925 bool GossipSelect( Player *player, Creature *_Creature, uint32 sender, uint32 action ) 1932 1926 { 1933 debug_log(" SD2: Gossip selection, sender: %d, action: %d",sender, action);1927 debug_log("TSCR: Gossip selection, sender: %d, action: %d",sender, action); 1934 1928 1935 1929 Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); … … 1943 1937 bool GossipSelectWithCode( Player *player, Creature *_Creature, uint32 sender, uint32 action, const char* sCode ) 1944 1938 { 1945 debug_log(" SD2: Gossip selection with code, sender: %d, action: %d",sender, action);1939 debug_log("TSCR: Gossip selection with code, sender: %d, action: %d",sender, action); 1946 1940 1947 1941 Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); -
trunk/src/bindings/scripts/ScriptMgr.h
r2 r5 27 27 #define VISIBLE_RANGE (166.0f) 28 28 29 #define DEFAULT_TEXT "< ScriptDev2Text Entry Missing!>"29 #define DEFAULT_TEXT "<Trinity Script Text Entry Missing!>" 30 30 31 31 // -
trunk/src/bindings/scripts/sql/create_database.sql
r2 r5 1 CREATE DATABASE ` scriptdev2` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;1 CREATE DATABASE `trinityscript` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; 2 2 3 GRANT ALL PRIVILEGES ON `scriptdev2` . * TO 'mangos'@'localhost' WITH GRANT OPTION; 4 3 GRANT ALL PRIVILEGES ON `trinityscript` . * TO 'trinity'@'localhost' WITH GRANT OPTION; -
trunk/src/bindings/scripts/sql/scriptdev2_structure.sql
r2 r5 100 100 101 101 102 DROP TABLE IF EXISTS `s d2_db_version`;103 CREATE TABLE `s d2_db_version` (104 `version` varchar(255) NOT NULL default '' COMMENT ' Database version string'102 DROP TABLE IF EXISTS `script_db_version`; 103 CREATE TABLE `script_db_version` ( 104 `version` varchar(255) NOT NULL default '' COMMENT 'Script Database version string' 105 105 ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -
trunk/src/bindings/scripts/trinityscript.conf.dist
r2 r5 1 # ScriptDev2Configuration file2 # This file must be placed within the directory which holds mangosd.conf and realmd.conf1 # TrinityScript Configuration file 2 # This file must be placed within the directory which holds TrinityCore.conf and TrinityRealm.conf 3 3 ConfVersion=2008100201 4 4 … … 9 9 # .;/path/to/unix_socket;username;password;database - use Unix sockets at Unix/Linux 10 10 # Unix sockets: experimental, not tested 11 ScriptDev2DatabaseInfo = "127.0.0.1;3306;mangos;mangos;scriptdev2"11 TScriptDatabaseInfo = "127.0.0.1;3306;trinity;trinity;trinityscript" 12 12 13 13 # Setting for current locale to use