Permalink
Browse files

[z1194] Restore check scripting lib API at load.

Also report result of script library load/reload to chat/console.

(based on master commit e125a5e)
(based on master commit 626d527)

(based on commit e5bf651)
(based on commit 9d59b28)
  • Loading branch information...
1 parent 2e63d69 commit e48ed1904b24654f82e3dfe2e6db6a81ae56e8d3 VladimirMangos committed Jan 1, 2011
View
@@ -24,7 +24,7 @@ DROP TABLE IF EXISTS `db_version`;
CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
- `required_z1192_s0612_02_mangos_spell_chain` bit(1) default NULL
+ `required_z1194_s0611_01_mangos_mangos_string` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -3629,6 +3629,9 @@ INSERT INTO `mangos_string` VALUES
(1158,'You modify for %s hex field:%u %s %x = %x (hex)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1159,'Modify %s float field:%u to sum with:%f = %f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1160,'You modify for %s float field:%u to sum with:%f = %f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
+(1166,'Scripting library not found or not accessable.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
+(1167,'Scripting library has wrong list functions (outdated?).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
+(1168,'Scripting library reloaded.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1200,'You try to view cinemitic %u but it doesn\'t exist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1400,'Private ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1401,'Corporal ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
View
@@ -191,7 +191,8 @@ pkgdata_DATA = \
z1159_s0566_01_mangos_mangos_string.sql \
z1186_s0600_01_mangos_game_event_creature_data.sql \
z1192_s0612_01_mangos_spell_proc_event.sql \
- z1192_s0612_02_mangos_spell_chain.sql
+ z1192_s0612_02_mangos_spell_chain.sql \
+ z1194_s0611_01_mangos_mangos_string.sql
## Additional files to include when running 'make dist'
# SQL update files, to upgrade database schema from older revisions
@@ -361,4 +362,5 @@ EXTRA_DIST = \
z1159_s0566_01_mangos_mangos_string.sql \
z1186_s0600_01_mangos_game_event_creature_data.sql \
z1192_s0612_01_mangos_spell_proc_event.sql \
- z1192_s0612_02_mangos_spell_chain.sql
+ z1192_s0612_02_mangos_spell_chain.sql \
+ z1194_s0611_01_mangos_mangos_string.sql
@@ -0,0 +1,8 @@
+ALTER TABLE db_version CHANGE COLUMN required_z1192_s0612_02_mangos_spell_chain required_z1194_s0611_01_mangos_mangos_string bit;
+
+DELETE FROM mangos_string WHERE entry IN (1166,1167,1168);
+
+INSERT INTO mangos_string VALUES
+(1166,'Scripting library not found or not accessable.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
+(1167,'Scripting library has wrong list functions (outdated?).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
+(1168,'Scripting library reloaded.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
View
@@ -368,7 +368,7 @@ enum MangosStrings
// Room for more level 2 376-399 not used
// level 3 chat
- LANG_SCRIPTS_RELOADED = 400,
+ LANG_SCRIPTS_RELOADED_ANNOUNCE = 400,
LANG_YOU_CHANGE_SECURITY = 401,
LANG_YOURS_SECURITY_CHANGED = 402,
LANG_YOURS_SECURITY_IS_LOW = 403,
@@ -883,7 +883,11 @@ enum MangosStrings
// 1162 used in master branch
// 1163 used in master branch
// 1164 used in master branch
- // Room for more level 3 1165-1199 not used
+ // 1165 used in master branch
+ LANG_SCRIPTS_NOT_FOUND = 1166,
+ LANG_SCRIPTS_WRONG_API = 1167,
+ LANG_SCRIPTS_RELOADED_OK = 1168,
+ // Room for more level 3 1169-1199 not used
// Debug commands
LANG_CINEMATIC_NOT_EXIST = 1200,
View
@@ -855,10 +855,20 @@ bool ChatHandler::HandleLoadScriptsCommand(char* args)
if (!*args)
return false;
- if (!sScriptMgr.LoadScriptLibrary(args))
- return true;
+ switch(sScriptMgr.LoadScriptLibrary(args))
+ {
+ case SCRIPT_LOAD_OK:
+ sWorld.SendWorldText(LANG_SCRIPTS_RELOADED_ANNOUNCE);
+ SendSysMessage(LANG_SCRIPTS_RELOADED_OK);
+ break;
+ case SCRIPT_LOAD_ERR_NOT_FOUND:
+ SendSysMessage(LANG_SCRIPTS_NOT_FOUND);
+ break;
+ case SCRIPT_LOAD_ERR_WRONG_API:
+ SendSysMessage(LANG_SCRIPTS_WRONG_API);
+ break;
+ }
- sWorld.SendWorldText(LANG_SCRIPTS_RELOADED);
return true;
}
View
@@ -997,7 +997,7 @@ bool ScriptMgr::OnAuraDummy(Aura const* pAura, bool apply)
return m_pOnAuraDummy != NULL && m_pOnAuraDummy(pAura, apply);
}
-bool ScriptMgr::LoadScriptLibrary(const char* libName)
+ScriptLoadResult ScriptMgr::LoadScriptLibrary(const char* libName)
{
UnloadScriptLibrary();
@@ -1007,7 +1007,7 @@ bool ScriptMgr::LoadScriptLibrary(const char* libName)
m_hScriptLib = MANGOS_LOAD_LIBRARY(name.c_str());
if (!m_hScriptLib)
- return false;
+ return SCRIPT_LOAD_ERR_NOT_FOUND;
GetScriptHookPtr(m_pOnInitScriptLibrary, "InitScriptLibrary");
GetScriptHookPtr(m_pOnFreeScriptLibrary, "FreeScriptLibrary");
@@ -1038,13 +1038,24 @@ bool ScriptMgr::LoadScriptLibrary(const char* libName)
GetScriptHookPtr(m_pOnEffectDummyItem, "EffectDummyItem");
GetScriptHookPtr(m_pOnAuraDummy, "AuraDummy");
+ if (!m_pOnInitScriptLibrary || !m_pOnFreeScriptLibrary || !m_pGetScriptLibraryVersion ||
+ !m_pGetCreatureAI || !m_pCreateInstanceData ||
+ !m_pOnGossipHello || !m_pOnGOGossipHello || !m_pOnGossipSelect ||
+ !m_pOnGOGossipSelect || !m_pOnGossipSelectWithCode || !m_pOnGOGossipSelectWithCode ||
+ !m_pOnQuestAccept || !m_pOnGOQuestAccept || !m_pOnItemQuestAccept ||
+ !m_pOnQuestRewarded || !m_pOnGOQuestRewarded || !m_pGetNPCDialogStatus ||
+ !m_pGetGODialogStatus || !m_pOnGOUse || !m_pOnItemUse ||
+ !m_pOnAreaTrigger || !m_pOnProcessEvent || !m_pOnEffectDummyCreature ||
+ !m_pOnEffectDummyGO || !m_pOnEffectDummyItem || !m_pOnAuraDummy)
+ return SCRIPT_LOAD_ERR_WRONG_API;
+
if (m_pOnInitScriptLibrary)
m_pOnInitScriptLibrary();
if (m_pGetScriptLibraryVersion)
sWorld.SetScriptsVersion(m_pGetScriptLibraryVersion());
- return true;
+ return SCRIPT_LOAD_OK;
}
void ScriptMgr::UnloadScriptLibrary()
View
@@ -296,6 +296,13 @@ extern ScriptMapMap sEventScripts;
extern ScriptMapMap sGossipScripts;
extern ScriptMapMap sCreatureMovementScripts;
+enum ScriptLoadResult
+{
+ SCRIPT_LOAD_OK,
+ SCRIPT_LOAD_ERR_NOT_FOUND,
+ SCRIPT_LOAD_ERR_WRONG_API
+};
+
class ScriptMgr
{
public:
@@ -322,7 +329,7 @@ class ScriptMgr
const char* GetScriptName(uint32 id) const { return id < m_scriptNames.size() ? m_scriptNames[id].c_str() : ""; }
uint32 GetScriptId(const char *name) const;
- bool LoadScriptLibrary(const char* libName);
+ ScriptLoadResult LoadScriptLibrary(const char* libName);
void UnloadScriptLibrary();
CreatureAI* GetCreatureAI(Creature* pCreature);
View
@@ -1156,8 +1156,19 @@ void World::SetInitialWorldSettings()
sLog.outString( "Loading CreatureEventAI Scripts...");
sEventAIMgr.LoadCreatureEventAI_Scripts();
- sLog.outString( "Initializing Scripts..." );
- sScriptMgr.LoadScriptLibrary(MANGOS_SCRIPT_NAME);
+ sLog.outString("Initializing Scripts...");
+ switch(sScriptMgr.LoadScriptLibrary(MANGOS_SCRIPT_NAME))
+ {
+ case SCRIPT_LOAD_OK:
+ sLog.outString("Scripting library loaded.");
+ break;
+ case SCRIPT_LOAD_ERR_NOT_FOUND:
+ sLog.outError("Scripting library not found or not accessable.");
+ break;
+ case SCRIPT_LOAD_ERR_WRONG_API:
+ sLog.outError("Scripting library has wrong list functions (outdated?).");
+ break;
+ }
///- Initialize game time and timers
sLog.outString( "DEBUG:: Initialize game time and timers" );
View
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "1193"
+ #define REVISION_NR "1194"
#endif // __REVISION_NR_H__
@@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_z1142_s0531_01_characters_bugreport"
- #define REVISION_DB_MANGOS "required_z1192_s0612_02_mangos_spell_chain"
+ #define REVISION_DB_MANGOS "required_z1194_s0611_01_mangos_mangos_string"
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
#endif // __REVISION_SQL_H__

0 comments on commit e48ed19

Please sign in to comment.