Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: arcemu-world/Chat.cpp
- ===================================================================
- --- arcemu-world/Chat.cpp (revision 2907)
- +++ arcemu-world/Chat.cpp (working copy)
- @@ -59,6 +59,8 @@
- return _petCommandTable;
- else if(!stricmp(name, "recall"))
- return _recallCommandTable;
- + else if(!stricmp(name, "house"))
- + return _houseCommandTable;
- else if(!stricmp(name, "guild"))
- return _GuildCommandTable;
- else if(!stricmp(name, "gm"))
- @@ -207,6 +209,7 @@
- free( _honorCommandTable );
- free( _petCommandTable );
- free( _recallCommandTable );
- + free( _houseCommandTable );
- free( _questCommandTable );
- free( _serverCommandTable );
- free( _gmCommandTable );
- @@ -520,6 +523,15 @@
- };
- dupe_command_table(recallCommandTable, _recallCommandTable);
- + static ChatCommand houseCommandTable[] =
- + {
- + { "buy", '0', &ChatHandler::HandleHouseAddCommand, "Buy a house location", NULL, 0, 0, 0 },
- + { "del", '0', &ChatHandler::HandleHouseDelCommand, "Remove a house location", NULL, 0, 0, 0 },
- + { "port", '0', &ChatHandler::HandleHouseGoCommand, "Teleports you to house location", NULL, 0, 0, 0 },
- + { NULL, '0', NULL, "", NULL, 0, 0, 0 }
- + };
- + dupe_command_table(houseCommandTable, _houseCommandTable);
- +
- static ChatCommand questCommandTable[] =
- {
- { "addboth", '2', &ChatHandler::HandleQuestAddBothCommand, "Add quest <id> to the targeted NPC as start & finish", NULL, 0, 0, 0 },
- @@ -732,6 +744,7 @@
- { "quest", 'q', NULL, "", questCommandTable, 0, 0, 0 },
- { "pet", 'm', NULL, "", petCommandTable, 0, 0, 0 },
- { "recall", 'q', NULL, "", recallCommandTable, 0, 0, 0 },
- + { "house", '0', NULL, "", houseCommandTable, 0, 0, 0 },
- { "guild", 'm', NULL, "", GuildCommandTable, 0, 0, 0 },
- { "server", '0', NULL, "", serverCommandTable, 0, 0, 0 },
- { "character", '0', NULL, "", characterCommandTable, 0, 0, 0 },
- Index: arcemu-world/Chat.h
- ===================================================================
- --- arcemu-world/Chat.h (revision 2907)
- +++ arcemu-world/Chat.h (working copy)
- @@ -172,6 +172,7 @@
- ChatCommand* _honorCommandTable;
- ChatCommand* _petCommandTable;
- ChatCommand* _recallCommandTable;
- + ChatCommand* _houseCommandTable;
- ChatCommand* _questCommandTable;
- ChatCommand* _serverCommandTable;
- ChatCommand* _gmCommandTable;
- @@ -525,6 +526,9 @@
- bool HandleGlobalPlaySoundCommand(const char* args, WorldSession * m_session);
- bool HandleRecallPortPlayerCommand(const char* args, WorldSession * m_session);
- bool HandleRecallPortUsCommand(const char* args, WorldSession * m_session);
- + bool HandleHouseGoCommand(const char* args, WorldSession *m_session);
- + bool HandleHouseAddCommand(const char* args, WorldSession *m_session);
- + bool HandleHouseDelCommand(const char* args, WorldSession *m_session);
- // Bans
- bool HandleIPBanCommand(const char * args, WorldSession * m_session);
- Index: arcemu-world/RecallCommands.cpp
- ===================================================================
- --- arcemu-world/RecallCommands.cpp (revision 2907)
- +++ arcemu-world/RecallCommands.cpp (working copy)
- @@ -260,3 +260,139 @@
- delete result;
- return false;
- }
- +
- +bool GetHouseLocation(const char* location, uint32 &map, LocationVector &v)
- +{
- + QueryResult *result = WorldDatabase.Query( "SELECT * FROM house ORDER BY name" );
- +
- + if( result == NULL)
- + return false;
- +
- + do
- + {
- + Field* fields = result->Fetch();
- + const char* locname = fields[1].GetString();
- + uint32 locmap = fields[2].GetUInt32();
- + float x = fields[3].GetFloat();
- + float y = fields[4].GetFloat();
- + float z = fields[5].GetFloat();
- + float o = fields[6].GetFloat();
- +
- + if( strnicmp( const_cast< char* >( location ), locname, strlen( location ) ) == 0 )
- + {
- + map = locmap;
- + v.x = x;
- + v.y = y;
- + v.z = z;
- + v.o = o;
- + delete result;
- + return true;
- + }
- +
- + }while (result->NextRow());
- +
- + delete result;
- + return false;
- +
- +}
- +
- +bool ChatHandler::HandleHouseGoCommand(const char* args, WorldSession *m_session)
- +{
- + if( args == NULL )
- + return false;
- +
- + if( !*args )
- + return false;
- +
- + if( m_session == NULL )
- + return false;
- +
- + uint32 map;
- + LocationVector v;
- + if (GetHouseLocation(args, map, v))
- + {
- + if( m_session->GetPlayer() != NULL )
- + {
- + m_session->GetPlayer()->SafeTeleport(map, 0, v);
- + return true;
- + }
- + return false;
- + }
- + return false;
- +}
- +
- +bool ChatHandler::HandleHouseAddCommand(const char* args, WorldSession *m_session)
- +{
- + if(!*args)
- + return false;
- +
- + QueryResult *result = WorldDatabase.Query( "SELECT name FROM house" );
- + if(!result)
- + return false;
- + do
- + {
- + Field *fields = result->Fetch();
- + const char * locname = fields[0].GetString();
- + if (strncmp((char*)args,locname,strlen(locname))==0)
- + {
- + RedSystemMessage(m_session, "Name in use, please use another name for your location.");
- + delete result;
- + return true;
- + }
- + }while (result->NextRow());
- + delete result;
- +
- + Player* plr = m_session->GetPlayer();
- + std::stringstream ss;
- +
- + string rc_locname = string(args);
- +
- + ss << "INSERT INTO house (name, mapid, positionX, positionY, positionZ, Orientation) VALUES ('"
- + << WorldDatabase.EscapeString(rc_locname).c_str() << "' , "
- + << plr->GetMapId() << ", "
- + << plr->GetPositionX() << ", "
- + << plr->GetPositionY() << ", "
- + << plr->GetPositionZ() << ", "
- + << plr->GetOrientation() << ");";
- + WorldDatabase.Execute( ss.str( ).c_str( ) );
- +
- + char buf[256];
- + snprintf((char*)buf, 256, "Added location to DB with MapID: %d, X: %f, Y: %f, Z: %f, O: %f",
- + (unsigned int)plr->GetMapId(), plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetOrientation());
- + GreenSystemMessage(m_session, buf);
- + sGMLog.writefromsession(m_session, "used house add, added \"%s\" location to database.", rc_locname.c_str());
- +
- + return true;
- +}
- +
- +bool ChatHandler::HandleHouseDelCommand(const char* args, WorldSession *m_session)
- +{
- + if(!*args)
- + return false;
- +
- + QueryResult *result = WorldDatabase.Query( "SELECT id,name FROM house" );
- + if(!result)
- + return false;
- +
- + do
- + {
- + Field *fields = result->Fetch();
- + float id = fields[0].GetFloat();
- + const char * locname = fields[1].GetString();
- +
- + if (strnicmp((char*)args,locname,strlen(locname))==0)
- + {
- + std::stringstream ss;
- + ss << "DELETE FROM house WHERE id = "<< (int)id <<";";
- + WorldDatabase.Execute( ss.str( ).c_str( ) );
- + GreenSystemMessage(m_session, "House location removed.");
- + sGMLog.writefromsession(m_session, "used house delete, removed \"%s\" location from database.", args);
- + delete result;
- + return true;
- + }
- +
- + }while (result->NextRow());
- +
- + delete result;
- + return false;
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement