[6838] [2008_11_18_01_mangos_creature_movement.sql 2008_11_18_02_mangos_mangos_string.sql] Implement localization support for creature_movemant.

Implemented in same way as db script localization. creature_movemant now store indexes in db_script_string.
In game waypoint text setting disabled. Unclear how this possible implement with localization data.
This commit is contained in:
VladimirMangos 2008-11-18 20:18:40 +03:00
parent 8032d6d5a4
commit e3abf5c936
9 changed files with 118 additions and 111 deletions

View file

@ -22,7 +22,7 @@
DROP TABLE IF EXISTS `db_version`;
CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`required_2008_11_16_01_mangos_command` bit(1) default NULL
`required_2008_11_18_02_mangos_mangos_string` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
--
@ -622,11 +622,11 @@ CREATE TABLE `creature_movement` (
`position_y` float NOT NULL default '0',
`position_z` float NOT NULL default '0',
`waittime` int(10) unsigned NOT NULL default '0',
`text1` text,
`text2` text,
`text3` text,
`text4` text,
`text5` text,
`textid1` int(11) NOT NULL default '0',
`textid2` int(11) NOT NULL default '0',
`textid3` int(11) NOT NULL default '0',
`textid4` int(11) NOT NULL default '0',
`textid5` int(11) NOT NULL default '0',
`emote` mediumint(8) unsigned NOT NULL default '0',
`spell` mediumint(8) unsigned NOT NULL default '0',
`wpguid` int(11) NOT NULL default '0',
@ -2368,7 +2368,7 @@ INSERT INTO `mangos_string` VALUES
(248,'Model %d: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(249,'Emote: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(250,'Spell: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(251,'Text %d: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(251,'Text%d (ID: %i): %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(252,'AIScript: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(253,'Forced rename for player %s will be requested at next login.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(254,'Forced rename for player %s (GUID #%u) will be requested at next login.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),

View file

@ -0,0 +1,13 @@
ALTER TABLE db_version CHANGE COLUMN required_2008_11_16_01_mangos_command required_2008_11_18_01_mangos_creature_movement bit;
ALTER TABLE creature_movement
DROP `text1`,
DROP `text2`,
DROP `text3`,
DROP `text4`,
DROP `text5`,
ADD COLUMN textid1 int(11) NOT NULL default '0' AFTER waittime,
ADD COLUMN textid2 int(11) NOT NULL default '0' AFTER textid1,
ADD COLUMN textid3 int(11) NOT NULL default '0' AFTER textid2,
ADD COLUMN textid4 int(11) NOT NULL default '0' AFTER textid3,
ADD COLUMN textid5 int(11) NOT NULL default '0' AFTER textid4;

View file

@ -0,0 +1,5 @@
ALTER TABLE db_version CHANGE COLUMN required_2008_11_18_01_mangos_creature_movement required_2008_11_18_02_mangos_mangos_string bit;
DELETE FROM mangos_string WHERE entry IN (251);
INSERT INTO mangos_string VALUES
(251,'Text%d (ID: %i): %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);

View file

@ -134,7 +134,9 @@ pkgdata_DATA = \
2008_11_11_02_mangos_scripts.sql \
2008_11_12_01_character_character_aura.sql \
2008_11_14_01_mangos_scripts.sql \
2008_11_16_01_mangos_command.sql
2008_11_16_01_mangos_command.sql \
2008_11_18_01_mangos_creature_movement.sql \
2008_11_18_02_mangos_mangos_string.sql \
README
## Additional files to include when running 'make dist'
@ -250,5 +252,7 @@ EXTRA_DIST = \
2008_11_11_02_mangos_scripts.sql \
2008_11_12_01_character_character_aura.sql \
2008_11_14_01_mangos_scripts.sql \
2008_11_16_01_mangos_command.sql
2008_11_16_01_mangos_command.sql \
2008_11_18_01_mangos_creature_movement.sql \
2008_11_18_02_mangos_mangos_string.sql \
README

View file

@ -2359,8 +2359,8 @@ bool ChatHandler::HandleWpModifyCommand(const char* args)
std::string show = show_str;
// Check
// Remember: "show" must also be the name of a column!
if( (show != "emote") && (show != "spell") && (show != "text1") && (show != "text2")
&& (show != "text3") && (show != "text4") && (show != "text5")
if( (show != "emote") && (show != "spell") && (show != "textid1") && (show != "textid2")
&& (show != "textid3") && (show != "textid4") && (show != "textid5")
&& (show != "waittime") && (show != "del") && (show != "move") && (show != "add")
&& (show != "model1") && (show != "model2") && (show != "orientation"))
{
@ -2703,6 +2703,13 @@ bool ChatHandler::HandleWpModifyCommand(const char* args)
return false;
}
// set in game textids not supported
if( show == "textid1" || show == "textid2" || show == "textid3" ||
show == "textid4" || show == "textid5" )
{
return false;
}
WaypointMgr.SetNodeText(lowguid, point, show_str, arg_str);
Creature* npcCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT));
@ -2840,7 +2847,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
//pCreature->GetPositionX();
QueryResult *result =
WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE wpguid = %u",
WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE wpguid = %u",
target->GetGUIDLow() );
if(!result)
{
@ -2852,7 +2859,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
const char* maxDIFF = "0.01";
PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUID());
result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )",
result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )",
target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF);
if(!result)
{
@ -2869,11 +2876,9 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
int waittime = fields[2].GetUInt32();
uint32 emote = fields[3].GetUInt32();
uint32 spell = fields[4].GetUInt32();
const char * text1 = fields[5].GetString();
const char * text2 = fields[6].GetString();
const char * text3 = fields[7].GetString();
const char * text4 = fields[8].GetString();
const char * text5 = fields[9].GetString();
uint32 textid[MAX_WAYPOINT_TEXT];
for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i)
textid[i] = fields[5+i].GetUInt32();
uint32 model1 = fields[10].GetUInt32();
uint32 model2 = fields[11].GetUInt32();
@ -2886,11 +2891,8 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
PSendSysMessage(LANG_WAYPOINT_INFO_MODEL, 2, model2);
PSendSysMessage(LANG_WAYPOINT_INFO_EMOTE, emote);
PSendSysMessage(LANG_WAYPOINT_INFO_SPELL, spell);
PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 1, text1);
PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 2, text2);
PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 3, text3);
PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 4, text4);
PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 5, text5);
for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i)
PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, i+1, textid[i], (textid[i] ? GetMangosString(textid[i]) : ""));
}while( result->NextRow() );
// Cleanup memory
@ -3211,8 +3213,8 @@ bool ChatHandler::HandleWpExportCommand(const char *args)
PSendSysMessage("DEBUG: wp export, GUID: %u", lowguid);
QueryResult *result = WorldDatabase.PQuery(
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
"SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid );
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
"SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid );
if (!result)
{
@ -3229,7 +3231,7 @@ bool ChatHandler::HandleWpExportCommand(const char *args)
Field *fields = result->Fetch();
outfile << "INSERT INTO creature_movement ";
outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5 ) VALUES ";
outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5 ) VALUES ";
outfile << "( ";
outfile << fields[15].GetUInt32(); // id
@ -3254,65 +3256,15 @@ bool ChatHandler::HandleWpExportCommand(const char *args)
outfile << ", ";
outfile << fields[9].GetUInt32(); // spell
outfile << ", ";
const char *tmpChar = fields[10].GetString();
if( !tmpChar )
{
outfile << "NULL"; // text1
}
else
{
outfile << "'";
outfile << tmpChar; // text1
outfile << "'";
}
outfile << fields[10].GetUInt32(); // textid1
outfile << ", ";
tmpChar = fields[11].GetString();
if( !tmpChar )
{
outfile << "NULL"; // text2
}
else
{
outfile << "'";
outfile << tmpChar; // text2
outfile << "'";
}
outfile << fields[11].GetUInt32(); // textid2
outfile << ", ";
tmpChar = fields[12].GetString();
if( !tmpChar )
{
outfile << "NULL"; // text3
}
else
{
outfile << "'";
outfile << tmpChar; // text3
outfile << "'";
}
outfile << fields[12].GetUInt32(); // textid3
outfile << ", ";
tmpChar = fields[13].GetString();
if( !tmpChar )
{
outfile << "NULL"; // text4
}
else
{
outfile << "'";
outfile << tmpChar; // text4
outfile << "'";
}
outfile << fields[13].GetUInt32(); // textid4
outfile << ", ";
tmpChar = fields[14].GetString();
if( !tmpChar )
{
outfile << "NULL"; // text5
}
else
{
outfile << "'";
outfile << tmpChar; // text5
outfile << "'";
}
outfile << fields[14].GetUInt32(); // textid5
outfile << ");\n ";
} while( result->NextRow() );

View file

@ -22,20 +22,30 @@
#include "WaypointManager.h"
#include "ProgressBar.h"
#include "MapManager.h"
#include "ObjectMgr.h"
INSTANTIATE_SINGLETON_1(WaypointManager);
bool WaypointBehavior::isEmpty()
{
return emote == 0 && spell == 0 && model1 == 0 && model2 == 0 && text[0].empty() &&
text[1].empty() && text[2].empty() && text[3].empty() && text[4].empty();
if (emote || spell || model1 || model2)
return false;
for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i)
if(textid[i])
return false;
return true;
}
WaypointBehavior::WaypointBehavior(const WaypointBehavior &b)
{
emote = b.emote; spell = b.spell; model1 = b.model1; model2 = b.model2;
text[0] = b.text[0]; text[1] = b.text[1]; text[2] = b.text[2];
text[3] = b.text[3]; text[4] = b.text[4];
emote = b.emote;
spell = b.spell;
model1 = b.model1;
model2 = b.model2;
for(int i=0; i < MAX_WAYPOINT_TEXT; ++i)
textid[i] = b.textid[i];
}
void WaypointManager::Load()
@ -64,7 +74,7 @@ void WaypointManager::Load()
delete result;
}
result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5, id, point FROM creature_movement");
result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id, point FROM creature_movement");
if(result)
{
barGoLink bar( result->GetRowCount() );
@ -111,11 +121,33 @@ void WaypointManager::Load()
be.model2 = fields[5].GetUInt32();
be.emote = fields[7].GetUInt32();
be.spell = fields[8].GetUInt32();
be.text[0] = fields[9].GetCppString();
be.text[1] = fields[10].GetCppString();
be.text[2] = fields[11].GetCppString();
be.text[3] = fields[12].GetCppString();
be.text[4] = fields[13].GetCppString();
// load and store without holes in array
int j = 0;
for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i)
{
be.textid[j] = fields[9+i].GetUInt32();
if(be.textid[j])
{
if (be.textid[j] < MIN_DB_SCRIPT_STRING_ID || be.textid[j] >= MAX_DB_SCRIPT_STRING_ID)
{
sLog.outErrorDb( "Table `db_script_string` not have string id %u", be.textid[j]);
continue;
}
if (!objmgr.GetMangosStringLocale (be.textid[j]))
{
sLog.outErrorDb("ERROR: Waypoint path %d (point %d), have invalid text id (%i) in `textid%d, ignored.",
id, point, be.textid[j], i+1);
continue;
}
++j; // to next internal field
}
}
// fill array tail
for(; j < MAX_WAYPOINT_TEXT; ++j)
be.textid[j] = 0;
// save memory by not storing empty behaviors
if(!be.isEmpty())
@ -263,11 +295,11 @@ void WaypointManager::SetNodeText(uint32 id, uint32 point, const char *text_fiel
WaypointNode &node = itr->second[point-1];
if(!node.behavior) node.behavior = new WaypointBehavior();
if(field == "text1") node.behavior->text[0] = text ? text : "";
if(field == "text2") node.behavior->text[1] = text ? text : "";
if(field == "text3") node.behavior->text[2] = text ? text : "";
if(field == "text4") node.behavior->text[3] = text ? text : "";
if(field == "text5") node.behavior->text[4] = text ? text : "";
// if(field == "text1") node.behavior->text[0] = text ? text : "";
// if(field == "text2") node.behavior->text[1] = text ? text : "";
// if(field == "text3") node.behavior->text[2] = text ? text : "";
// if(field == "text4") node.behavior->text[3] = text ? text : "";
// if(field == "text5") node.behavior->text[4] = text ? text : "";
if(field == "emote") node.behavior->emote = text ? atoi(text) : 0;
if(field == "spell") node.behavior->spell = text ? atoi(text) : 0;
if(field == "model1") node.behavior->model1 = text ? atoi(text) : 0;

View file

@ -23,11 +23,12 @@
#include <string>
#include "Utilities/UnorderedMap.h"
#define MAX_WAYPOINT_TEXT 5
struct WaypointBehavior
{
uint32 emote;
uint32 spell;
std::string text[5];
int32 textid[MAX_WAYPOINT_TEXT];
uint32 model1;
uint32 model2;

View file

@ -19,11 +19,11 @@
/*
creature_movement Table
alter table creature_movement add `text1` varchar(255) default NULL;
alter table creature_movement add `text2` varchar(255) default NULL;
alter table creature_movement add `text3` varchar(255) default NULL;
alter table creature_movement add `text4` varchar(255) default NULL;
alter table creature_movement add `text5` varchar(255) default NULL;
alter table creature_movement add `textid1` int(11) NOT NULL default '0';
alter table creature_movement add `textid2` int(11) NOT NULL default '0';
alter table creature_movement add `textid3` int(11) NOT NULL default '0';
alter table creature_movement add `textid4` int(11) NOT NULL default '0';
alter table creature_movement add `textid5` int(11) NOT NULL default '0';
alter table creature_movement add `emote` int(10) unsigned default '0';
alter table creature_movement add `spell` int(5) unsigned default '0';
alter table creature_movement add `wpguid` int(11) default '0';
@ -146,21 +146,21 @@ WaypointMovementGenerator<Creature>::Update(Creature &creature, const uint32 &di
creature.CastSpell(&creature,behavior->spell, false);
if(behavior->model1 != 0)
creature.SetDisplayId(behavior->model1);
if(!behavior->text[0].empty())
if(behavior->textid[0])
{
// Only one text is set
if( !behavior->text[1].empty() )
// Not only one text is set
if( behavior->textid[1] )
{
// Select one from max 5 texts (0 and 1 laready checked)
int i = 2;
for( ; i < 5; ++i )
if( behavior->text[i].empty() )
for( ; i < MAX_WAYPOINT_TEXT; ++i )
if( !behavior->textid[i] )
break;
creature.Say(behavior->text[rand() % i].c_str(), 0, 0);
creature.Say(behavior->textid[rand() % i], 0, 0);
}
else
creature.Say(behavior->text[0].c_str(), 0, 0);
creature.Say(behavior->textid[0], 0, 0);
}
i_hasDone[idx] = true;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "6837"
#define REVISION_NR "6838"
#endif // __REVISION_NR_H__