Skip to content

Commit

Permalink
[10086] Implement use .go command with shiftlinks or player name.
Browse files Browse the repository at this point in the history
* Now if for .go command provided no X Y Z args command will not teleport player to nowhere.
* Instead command allow used with player name and work as simplifed .goname
  (teleport to player _point_ in user instance binding, not to player instance)
* Also command can be used with diferent point coordinates provided shift-links:
  - player (result for example .lookup player account)
  - creature (result .list creature command)
  - gameobject (result .list object command)
  - tele (result .lookup tele)
  - taxinode (result .lookup taxinode)
  • Loading branch information
VladimirMangos committed Jun 20, 2010
1 parent aec0b4d commit cae6fd0
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 110 deletions.
3 changes: 2 additions & 1 deletion sql/mangos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0',
`required_10056_01_mangos_spell_proc_event` bit(1) default NULL
`required_10086_01_mangos_command` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';

--
Expand Down Expand Up @@ -577,6 +577,7 @@ INSERT INTO `command` VALUES
('gm ingame',0,'Syntax: .gm ingame\r\n\r\nDisplay a list of available in game Game Masters.'),
('gm list',3,'Syntax: .gm list\r\n\r\nDisplay a list of all Game Masters accounts and security levels.'),
('gm visible',1,'Syntax: .gm visible on/off\r\n\r\nOutput current visibility state or make GM visible(on) and invisible(off) for other players.'),
('go',1,'Syntax: .go [$playername|pointlink|#x #y #z [#mapid]]\r\nTeleport your character to point with coordinates of player $playername, or coordinates of one from shift-link types: player, tele, taxinode, creature, gameobject, or explicit #x #y #z #mapid coordinates.'),
('go creature',1,'Syntax: .go creature #creature_guid\r\nTeleport your character to creature with guid #creature_guid.\r\n.gocreature #creature_name\r\nTeleport your character to creature with this name.\r\n.gocreature id #creature_id\r\nTeleport your character to a creature that was spawned from the template with this entry.\r\n*If* more than one creature is found, then you are teleported to the first that is found inside the database.'),
('go graveyard',1,'Syntax: .go graveyard #graveyardId\r\n Teleport to graveyard with the graveyardId specified.'),
('go grid',1,'Syntax: .go grid #gridX #gridY [#mapId]\r\n\r\nTeleport the gm to center of grid with provided indexes at map #mapId (or current map if it not provided).'),
Expand Down
5 changes: 5 additions & 0 deletions sql/updates/10086_01_mangos_command.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE db_version CHANGE COLUMN required_10056_01_mangos_spell_proc_event required_10086_01_mangos_command bit;

DELETE FROM command WHERE name IN('go');
INSERT INTO command (name, security, help) VALUES
('go',1,'Syntax: .go [$playername|pointlink|#x #y #z [#mapid]]\r\nTeleport your character to point with coordinates of player $playername, or coordinates of one from shift-link types: player, tele, taxinode, creature, gameobject, or explicit #x #y #z #mapid coordinates.');
2 changes: 2 additions & 0 deletions sql/updates/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pkgdata_DATA = \
10045_01_mangos_spell_proc_event.sql \
10051_01_characters_character_aura.sql \
10056_01_mangos_spell_proc_event.sql \
10086_01_mangos_command.sql \
README

## Additional files to include when running 'make dist'
Expand Down Expand Up @@ -158,4 +159,5 @@ EXTRA_DIST = \
10045_01_mangos_spell_proc_event.sql \
10051_01_characters_character_aura.sql \
10056_01_mangos_spell_proc_event.sql \
10086_01_mangos_command.sql \
README
126 changes: 125 additions & 1 deletion src/game/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ ChatCommand * ChatHandler::getCommandTable()
{ "zonexy", SEC_MODERATOR, false, &ChatHandler::HandleGoZoneXYCommand, "", NULL },
{ "xy", SEC_MODERATOR, false, &ChatHandler::HandleGoXYCommand, "", NULL },
{ "xyz", SEC_MODERATOR, false, &ChatHandler::HandleGoXYZCommand, "", NULL },
{ "", SEC_MODERATOR, false, &ChatHandler::HandleGoXYZCommand, "", NULL },
{ "", SEC_MODERATOR, false, &ChatHandler::HandleGoCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};

Expand Down Expand Up @@ -2133,6 +2133,130 @@ uint64 ChatHandler::extractGuidFromLink(char* text)
return 0;
}

enum LocationLinkType
{
LOCATION_LINK_PLAYER = 0, // must be first for selection in not link case
LOCATION_LINK_TELE = 1,
LOCATION_LINK_TAXINODE = 2,
LOCATION_LINK_CREATURE = 3,
LOCATION_LINK_GAMEOBJECT = 4
};

static char const* const locationKeys[] =
{
"Htele",
"Htaxinode",
"Hplayer",
"Hcreature",
"Hgameobject",
NULL
};

bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, float& y, float& z)
{
int type = 0;

// |color|Hplayer:name|h[name]|h|r
// |color|Htele:id|h[name]|h|r
// |color|Htaxinode:id|h[name]|h|r
// |color|Hcreature:creature_guid|h[name]|h|r
// |color|Hgameobject:go_guid|h[name]|h|r
char* idS = extractKeyFromLink(text,locationKeys,&type);
if(!idS)
return false;

switch(type)
{
// it also fail case
case LOCATION_LINK_PLAYER:
{
// not link and not name, possible coordinates/etc
if (isNumeric(idS[0]))
return false;

std::string name = idS;
if(!normalizePlayerName(name))
return false;

if(Player* player = sObjectMgr.GetPlayer(name.c_str()))
{
mapid = player->GetMapId();
x = player->GetPositionX();
y = player->GetPositionY();
z = player->GetPositionZ();
return true;
}

if(uint64 guid = sObjectMgr.GetPlayerGUIDByName(name))
{
// to point where player stay (if loaded)
float o;
bool in_flight;
return Player::LoadPositionFromDB(mapid, x, y, z, o, in_flight, guid);
}

return false;
}
case LOCATION_LINK_TELE:
{
uint32 id = (uint32)atol(idS);
GameTele const* tele = sObjectMgr.GetGameTele(id);
if (!tele)
return false;
mapid = tele->mapId;
x = tele->position_x;
y = tele->position_y;
z = tele->position_z;
return true;
}
case LOCATION_LINK_TAXINODE:
{
uint32 id = (uint32)atol(idS);
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
if (!node)
return false;
mapid = node->map_id;
x = node->x;
y = node->y;
z = node->z;
return true;
}
case LOCATION_LINK_CREATURE:
{
uint32 lowguid = (uint32)atol(idS);

if(CreatureData const* data = sObjectMgr.GetCreatureData(lowguid) )
{
mapid = data->mapid;
x = data->posX;
y = data->posY;
z = data->posZ;
return true;
}
else
return false;
}
case LOCATION_LINK_GAMEOBJECT:
{
uint32 lowguid = (uint32)atol(idS);

if(GameObjectData const* data = sObjectMgr.GetGOData(lowguid) )
{
mapid = data->mapid;
x = data->posX;
y = data->posY;
z = data->posZ;
return true;
}
else
return false;
}
}

// unknown type?
return false;
}

std::string ChatHandler::extractPlayerNameFromLink(char* text)
{
// |color|Hplayer:name|h[name]|h|r
Expand Down
3 changes: 3 additions & 0 deletions src/game/Chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ class ChatHandler
uint32 extractSpellIdFromLink(char* text);
uint64 extractGuidFromLink(char* text);
GameTele const* extractGameTeleFromLink(char* text);
bool extractLocationFromLink(char* text, uint32& mapid, float& x, float& y, float& z);
std::string extractPlayerNameFromLink(char* text);
// select by arg (name/link) or in-game selection online/offline player
bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = NULL, std::string* player_name = NULL);
Expand All @@ -558,6 +559,8 @@ class ChatHandler
void HandleCharacterLevel(Player* player, uint64 player_guid, uint32 oldlevel, uint32 newlevel);
void HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id);
void ShowSpellListHelper(Player* target, SpellEntry const* spellInfo, LocaleConstant loc);
bool HandleGoHelper(Player* _player, uint32 mapid, float x, float y, float const* zPtr = NULL);


/**
* Stores informations about a deleted character
Expand Down

2 comments on commit cae6fd0

@technoir42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very helpful, thanks! (especially for creature and gameobjects)

.go creature
.go object

So old commands can be dropped?

@VladimirMangos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, old commands let be used in cases for example explicit guid number or id. But possible i will add creature_template/go_template shift links case also

Please sign in to comment.