Merge branch 'master' into 303

This commit is contained in:
tomrus88 2008-11-18 21:10:48 +03:00
commit b2ca98fa4e
10 changed files with 119 additions and 112 deletions

View file

@ -89,7 +89,7 @@ bool ArenaTeam::AddMember(uint64 PlayerGuid)
Player *pl = objmgr.GetPlayer(PlayerGuid);
if(pl)
{
if(pl->GetArenaTeamId(GetType()))
if(pl->GetArenaTeamId(GetSlot()))
{
sLog.outError("Arena::AddMember() : player already in this sized team");
return false;

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';
@ -142,21 +142,21 @@ bool WaypointMovementGenerator<Creature>::Update(Creature &creature, const uint3
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;