mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 01:37:00 +00:00
[2008_10_27_01_npc_option.sql,2008_10_27_02_locales_npc_option.sql] Implement npc_option localization support, also store in DB BoxText/BoxMoney/Coded.
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
74ddd38af3
commit
94e29ce6a8
11 changed files with 206 additions and 24 deletions
|
|
@ -1803,6 +1803,42 @@ LOCK TABLES `locales_item` WRITE;
|
|||
/*!40000 ALTER TABLE `locales_item` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
--
|
||||
-- Table structure for table `locales_npc_option`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `locales_npc_option`;
|
||||
CREATE TABLE `locales_npc_option` (
|
||||
`entry` mediumint(8) unsigned NOT NULL default '0',
|
||||
`option_text_loc1` text,
|
||||
`option_text_loc2` text,
|
||||
`option_text_loc3` text,
|
||||
`option_text_loc4` text,
|
||||
`option_text_loc5` text,
|
||||
`option_text_loc6` text,
|
||||
`option_text_loc7` text,
|
||||
`option_text_loc8` text,
|
||||
`box_text_loc1` text,
|
||||
`box_text_loc2` text,
|
||||
`box_text_loc3` text,
|
||||
`box_text_loc4` text,
|
||||
`box_text_loc5` text,
|
||||
`box_text_loc6` text,
|
||||
`box_text_loc7` text,
|
||||
`box_text_loc8` text,
|
||||
PRIMARY KEY (`entry`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Dumping data for table `locales_npc_option`
|
||||
--
|
||||
|
||||
LOCK TABLES `locales_npc_option` WRITE;
|
||||
/*!40000 ALTER TABLE `locales_npc_option` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `locales_npc_option` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `locales_npc_text`
|
||||
--
|
||||
|
|
@ -2707,12 +2743,15 @@ UNLOCK TABLES;
|
|||
|
||||
DROP TABLE IF EXISTS `npc_option`;
|
||||
CREATE TABLE `npc_option` (
|
||||
`id` tinyint(3) unsigned NOT NULL default '0',
|
||||
`gossip_id` tinyint(3) unsigned NOT NULL default '0',
|
||||
`id` mediumint(8) unsigned NOT NULL default '0',
|
||||
`gossip_id` mediumint(8) unsigned NOT NULL default '0',
|
||||
`npcflag` int(10) unsigned NOT NULL default '0',
|
||||
`icon` tinyint(3) unsigned NOT NULL default '0',
|
||||
`action` tinyint(3) unsigned NOT NULL default '0',
|
||||
`action` mediumint(8) unsigned NOT NULL default '0',
|
||||
`box_money` int(10) unsigned NOT NULL default '0',
|
||||
`coded` tinyint(3) unsigned NOT NULL default '0',
|
||||
`option_text` text,
|
||||
`box_text` text,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
|
|||
7
sql/updates/2008_10_27_01_npc_option.sql
Normal file
7
sql/updates/2008_10_27_01_npc_option.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
ALTER TABLE `npc_option`
|
||||
CHANGE COLUMN `id` `id` mediumint(8) unsigned NOT NULL default '0',
|
||||
CHANGE COLUMN `gossip_id` `gossip_id` mediumint(8) unsigned NOT NULL default '0',
|
||||
CHANGE COLUMN `action` `action` mediumint(8) unsigned NOT NULL default '0',
|
||||
ADD COLUMN `box_money` int(10) unsigned NOT NULL default '0' AFTER `action`,
|
||||
ADD COLUMN `coded` tinyint(3) unsigned NOT NULL default '0' AFTER `box_money`,
|
||||
ADD COLUMN `box_text` text AFTER `option_text`;
|
||||
22
sql/updates/2008_10_27_02_locales_npc_option.sql
Normal file
22
sql/updates/2008_10_27_02_locales_npc_option.sql
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
CREATE TABLE `locales_npc_option` (
|
||||
`entry` mediumint(8) unsigned NOT NULL default '0',
|
||||
`option_text_loc1` text,
|
||||
`option_text_loc2` text,
|
||||
`option_text_loc3` text,
|
||||
`option_text_loc4` text,
|
||||
`option_text_loc5` text,
|
||||
`option_text_loc6` text,
|
||||
`option_text_loc7` text,
|
||||
`option_text_loc8` text,
|
||||
`box_text_loc1` text,
|
||||
`box_text_loc2` text,
|
||||
`box_text_loc3` text,
|
||||
`box_text_loc4` text,
|
||||
`box_text_loc5` text,
|
||||
`box_text_loc6` text,
|
||||
`box_text_loc7` text,
|
||||
`box_text_loc8` text,
|
||||
PRIMARY KEY (`entry`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
|
@ -107,6 +107,8 @@ pkgdata_DATA = \
|
|||
2008_10_23_04_mangos_command.sql \
|
||||
2008_10_23_05_mangos_command.sql \
|
||||
2008_10_26_01_mangos_mangos_string.sql \
|
||||
2008_10_27_01_npc_option.sql \
|
||||
2008_10_27_02_locales_npc_option.sql \
|
||||
README
|
||||
|
||||
## Additional files to include when running 'make dist'
|
||||
|
|
@ -195,4 +197,6 @@ EXTRA_DIST = \
|
|||
2008_10_23_04_mangos_command.sql \
|
||||
2008_10_23_05_mangos_command.sql \
|
||||
2008_10_26_01_mangos_mangos_string.sql \
|
||||
2008_10_27_01_npc_option.sql \
|
||||
2008_10_27_02_locales_npc_option.sql \
|
||||
README
|
||||
|
|
|
|||
|
|
@ -738,14 +738,30 @@ void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid )
|
|||
case GOSSIP_OPTION_AUCTIONEER:
|
||||
break; // no checks
|
||||
default:
|
||||
sLog.outErrorDb("Creature %u (entry: %u) have unknown gossip option %u",GetGUIDLow(),GetEntry(),gso->Action);
|
||||
sLog.outErrorDb("Creature %u (entry: %u) have unknown gossip option %u",GetDBTableGUIDLow(),GetEntry(),gso->Action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//note for future dev: should have database fields for BoxMessage & BoxMoney
|
||||
if(!gso->OptionText.empty() && cantalking)
|
||||
pm->GetGossipMenu().AddMenuItem((uint8)gso->Icon,gso->OptionText, gossipid,gso->Action,"",0,false);
|
||||
{
|
||||
std::string OptionText = gso->OptionText;
|
||||
std::string BoxText = gso->BoxText;
|
||||
int loc_idx = pPlayer->GetSession()->GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
NpcOptionLocale const *no = objmgr.GetNpcOptionLocale(gso->Id);
|
||||
if (no)
|
||||
{
|
||||
if (no->OptionText.size() > loc_idx && !no->OptionText[loc_idx].empty())
|
||||
OptionText=no->OptionText[loc_idx];
|
||||
if (no->BoxText.size() > loc_idx && !no->BoxText[loc_idx].empty())
|
||||
BoxText=no->BoxText[loc_idx];
|
||||
}
|
||||
}
|
||||
pm->GetGossipMenu().AddMenuItem((uint8)gso->Icon,OptionText, gossipid,gso->Action,BoxText,gso->BoxMoney,gso->Coded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,10 @@ struct GossipOption
|
|||
uint32 NpcFlag;
|
||||
uint32 Icon;
|
||||
uint32 Action;
|
||||
uint32 BoxMoney;
|
||||
bool Coded;
|
||||
std::string OptionText;
|
||||
std::string BoxText;
|
||||
};
|
||||
|
||||
enum CreatureFlagsExtra
|
||||
|
|
@ -207,6 +210,12 @@ struct CreatureLocale
|
|||
std::vector<std::string> SubName;
|
||||
};
|
||||
|
||||
struct NpcOptionLocale
|
||||
{
|
||||
std::vector<std::string> OptionText;
|
||||
std::vector<std::string> BoxText;
|
||||
};
|
||||
|
||||
struct EquipmentInfo
|
||||
{
|
||||
uint32 entry;
|
||||
|
|
@ -467,8 +476,8 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
|||
CreatureDataAddon const* GetCreatureAddon() const;
|
||||
char const* GetScriptName() const;
|
||||
|
||||
void prepareGossipMenu( Player *pPlayer,uint32 gossipid );
|
||||
void sendPreparedGossip( Player* player);
|
||||
void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 );
|
||||
void sendPreparedGossip( Player* player );
|
||||
void OnGossipSelect(Player* player, uint32 option);
|
||||
void OnPoiSelect(Player* player, GossipOption const *gossip);
|
||||
|
||||
|
|
|
|||
|
|
@ -295,8 +295,8 @@ void WorldSession::HandleGossipHelloOpcode( WorldPacket & recv_data )
|
|||
if(!Script->GossipHello( _player, unit ))
|
||||
{
|
||||
_player->TalkedToCreature(unit->GetEntry(),unit->GetGUID());
|
||||
unit->prepareGossipMenu(_player,0);
|
||||
unit->sendPreparedGossip( _player );
|
||||
unit->prepareGossipMenu(_player);
|
||||
unit->sendPreparedGossip(_player);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -335,14 +335,14 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data )
|
|||
|
||||
if(!code.empty())
|
||||
{
|
||||
|
||||
if(!Script->GossipSelectWithCode( _player, unit, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str()) )
|
||||
unit->OnGossipSelect( _player, option );
|
||||
if (!Script->GossipSelectWithCode(_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str()))
|
||||
unit->OnGossipSelect (_player, option);
|
||||
}
|
||||
else
|
||||
|
||||
if(!Script->GossipSelect( _player, unit, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option )) )
|
||||
unit->OnGossipSelect( _player, option );
|
||||
{
|
||||
if (!Script->GossipSelect (_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction (option)))
|
||||
unit->OnGossipSelect (_player, option);
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleSpiritHealerActivateOpcode( WorldPacket & recv_data )
|
||||
|
|
|
|||
|
|
@ -563,6 +563,74 @@ void ObjectMgr::LoadCreatureLocales()
|
|||
sLog.outString( ">> Loaded %u creature locale strings", mCreatureLocaleMap.size() );
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadNpcOptionLocales()
|
||||
{
|
||||
mNpcOptionLocaleMap.clear(); // need for reload case
|
||||
|
||||
QueryResult *result = WorldDatabase.Query("SELECT entry,"
|
||||
"option_text_loc1,box_text_loc1,option_text_loc2,box_text_loc2,"
|
||||
"option_text_loc3,box_text_loc3,option_text_loc4,box_text_loc4,"
|
||||
"option_text_loc5,box_text_loc5,option_text_loc6,box_text_loc6,"
|
||||
"option_text_loc7,box_text_loc7,option_text_loc8,box_text_loc8 "
|
||||
"FROM locales_npc_option");
|
||||
|
||||
if(!result)
|
||||
{
|
||||
barGoLink bar(1);
|
||||
|
||||
bar.step();
|
||||
|
||||
sLog.outString("");
|
||||
sLog.outString(">> Loaded 0 npc_option locale strings. DB table `locales_npc_option` is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
barGoLink bar(result->GetRowCount());
|
||||
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
bar.step();
|
||||
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
|
||||
NpcOptionLocale& data = mNpcOptionLocaleMap[entry];
|
||||
|
||||
for(int i = 1; i < MAX_LOCALE; ++i)
|
||||
{
|
||||
std::string str = fields[1+2*(i-1)].GetCppString();
|
||||
if(!str.empty())
|
||||
{
|
||||
int idx = GetOrNewIndexForLocale(LocaleConstant(i));
|
||||
if(idx >= 0)
|
||||
{
|
||||
if(data.OptionText.size() <= idx)
|
||||
data.OptionText.resize(idx+1);
|
||||
|
||||
data.OptionText[idx] = str;
|
||||
}
|
||||
}
|
||||
str = fields[1+2*(i-1)+1].GetCppString();
|
||||
if(!str.empty())
|
||||
{
|
||||
int idx = GetOrNewIndexForLocale(LocaleConstant(i));
|
||||
if(idx >= 0)
|
||||
{
|
||||
if(data.BoxText.size() <= idx)
|
||||
data.BoxText.resize(idx+1);
|
||||
|
||||
data.BoxText[idx] = str;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded %u npc_option locale strings", mNpcOptionLocaleMap.size() );
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadCreatureTemplates()
|
||||
{
|
||||
sCreatureStorage.Load();
|
||||
|
|
@ -6886,7 +6954,11 @@ void ObjectMgr::LoadNpcOptions()
|
|||
{
|
||||
m_mCacheNpcOptionList.clear(); // For reload case
|
||||
|
||||
QueryResult *result = WorldDatabase.Query( "SELECT id,gossip_id,npcflag,icon,action,option_text FROM npc_option");
|
||||
QueryResult *result = WorldDatabase.Query(
|
||||
// 0 1 2 3 4 5 6 7 8
|
||||
"SELECT id,gossip_id,npcflag,icon,action,box_money,coded,option_text,box_text "
|
||||
"FROM npc_option");
|
||||
|
||||
if( !result )
|
||||
{
|
||||
barGoLink bar( 1 );
|
||||
|
|
@ -6914,7 +6986,10 @@ void ObjectMgr::LoadNpcOptions()
|
|||
go.NpcFlag = fields[2].GetUInt32();
|
||||
go.Icon = fields[3].GetUInt32();
|
||||
go.Action = fields[4].GetUInt32();
|
||||
go.OptionText = fields[5].GetCppString();
|
||||
go.BoxMoney = fields[5].GetUInt32();
|
||||
go.Coded = fields[6].GetUInt8()!=0;
|
||||
go.OptionText = fields[7].GetCppString();
|
||||
go.BoxText = fields[8].GetCppString();
|
||||
|
||||
m_mCacheNpcOptionList.push_back(go);
|
||||
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ typedef HM_NAMESPACE::hash_map<uint32,QuestLocale> QuestLocaleMap;
|
|||
typedef HM_NAMESPACE::hash_map<uint32,NpcTextLocale> NpcTextLocaleMap;
|
||||
typedef HM_NAMESPACE::hash_map<uint32,PageTextLocale> PageTextLocaleMap;
|
||||
typedef HM_NAMESPACE::hash_map<uint32,MangosStringLocale> MangosStringLocaleMap;
|
||||
typedef HM_NAMESPACE::hash_map<uint32,NpcOptionLocale> NpcOptionLocaleMap;
|
||||
|
||||
typedef std::multimap<uint32,uint32> QuestRelations;
|
||||
|
||||
|
|
@ -515,6 +516,7 @@ class ObjectMgr
|
|||
void LoadQuestLocales();
|
||||
void LoadNpcTextLocales();
|
||||
void LoadPageTextLocales();
|
||||
void LoadNpcOptionLocales();
|
||||
void LoadInstanceTemplate();
|
||||
|
||||
void LoadGossipText();
|
||||
|
|
@ -639,6 +641,12 @@ class ObjectMgr
|
|||
if(itr==mPageTextLocaleMap.end()) return NULL;
|
||||
return &itr->second;
|
||||
}
|
||||
NpcOptionLocale const* GetNpcOptionLocale(uint32 entry) const
|
||||
{
|
||||
NpcOptionLocaleMap::const_iterator itr = mNpcOptionLocaleMap.find(entry);
|
||||
if(itr==mNpcOptionLocaleMap.end()) return NULL;
|
||||
return &itr->second;
|
||||
}
|
||||
|
||||
GameObjectData const* GetGOData(uint32 guid) const
|
||||
{
|
||||
|
|
@ -844,6 +852,7 @@ class ObjectMgr
|
|||
NpcTextLocaleMap mNpcTextLocaleMap;
|
||||
PageTextLocaleMap mPageTextLocaleMap;
|
||||
MangosStringLocaleMap mMangosStringLocaleMap;
|
||||
NpcOptionLocaleMap mNpcOptionLocaleMap;
|
||||
RespawnTimes mCreatureRespawnTimes;
|
||||
RespawnTimes mGORespawnTimes;
|
||||
|
||||
|
|
|
|||
|
|
@ -103,8 +103,8 @@ void WorldSession::HandleQuestgiverHelloOpcode( WorldPacket & recv_data )
|
|||
if(Script->GossipHello( _player, pCreature ) )
|
||||
return;
|
||||
|
||||
pCreature->prepareGossipMenu(_player,0);
|
||||
pCreature->sendPreparedGossip( _player );
|
||||
pCreature->prepareGossipMenu(_player);
|
||||
pCreature->sendPreparedGossip(_player);
|
||||
}
|
||||
|
||||
void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data )
|
||||
|
|
|
|||
|
|
@ -945,6 +945,7 @@ void World::SetInitialWorldSettings()
|
|||
objmgr.LoadQuestLocales();
|
||||
objmgr.LoadNpcTextLocales();
|
||||
objmgr.LoadPageTextLocales();
|
||||
objmgr.LoadNpcOptionLocales();
|
||||
objmgr.SetDBCLocaleIndex(GetDefaultDbcLocale()); // Get once for all the locale index of DBC language (console/broadcasts)
|
||||
|
||||
sLog.outString( "Loading Page Texts..." );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue