Advertisement
Guest User

Untitled

a guest
Sep 18th, 2009
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.21 KB | None | 0 0
  1. Index: arcemu-world/Chat.cpp
  2. ===================================================================
  3. --- arcemu-world/Chat.cpp (revision 2907)
  4. +++ arcemu-world/Chat.cpp (working copy)
  5. @@ -59,6 +59,8 @@
  6. return _petCommandTable;
  7. else if(!stricmp(name, "recall"))
  8. return _recallCommandTable;
  9. + else if(!stricmp(name, "house"))
  10. + return _houseCommandTable;
  11. else if(!stricmp(name, "guild"))
  12. return _GuildCommandTable;
  13. else if(!stricmp(name, "gm"))
  14. @@ -207,6 +209,7 @@
  15. free( _honorCommandTable );
  16. free( _petCommandTable );
  17. free( _recallCommandTable );
  18. + free( _houseCommandTable );
  19. free( _questCommandTable );
  20. free( _serverCommandTable );
  21. free( _gmCommandTable );
  22. @@ -520,6 +523,15 @@
  23. };
  24. dupe_command_table(recallCommandTable, _recallCommandTable);
  25.  
  26. + static ChatCommand houseCommandTable[] =
  27. + {
  28. + { "buy", '0', &ChatHandler::HandleHouseAddCommand, "Buy a house location", NULL, 0, 0, 0 },
  29. + { "del", '0', &ChatHandler::HandleHouseDelCommand, "Remove a house location", NULL, 0, 0, 0 },
  30. + { "port", '0', &ChatHandler::HandleHouseGoCommand, "Teleports you to house location", NULL, 0, 0, 0 },
  31. + { NULL, '0', NULL, "", NULL, 0, 0, 0 }
  32. + };
  33. + dupe_command_table(houseCommandTable, _houseCommandTable);
  34. +
  35. static ChatCommand questCommandTable[] =
  36. {
  37. { "addboth", '2', &ChatHandler::HandleQuestAddBothCommand, "Add quest <id> to the targeted NPC as start & finish", NULL, 0, 0, 0 },
  38. @@ -732,6 +744,7 @@
  39. { "quest", 'q', NULL, "", questCommandTable, 0, 0, 0 },
  40. { "pet", 'm', NULL, "", petCommandTable, 0, 0, 0 },
  41. { "recall", 'q', NULL, "", recallCommandTable, 0, 0, 0 },
  42. + { "house", '0', NULL, "", houseCommandTable, 0, 0, 0 },
  43. { "guild", 'm', NULL, "", GuildCommandTable, 0, 0, 0 },
  44. { "server", '0', NULL, "", serverCommandTable, 0, 0, 0 },
  45. { "character", '0', NULL, "", characterCommandTable, 0, 0, 0 },
  46. Index: arcemu-world/Chat.h
  47. ===================================================================
  48. --- arcemu-world/Chat.h (revision 2907)
  49. +++ arcemu-world/Chat.h (working copy)
  50. @@ -172,6 +172,7 @@
  51. ChatCommand* _honorCommandTable;
  52. ChatCommand* _petCommandTable;
  53. ChatCommand* _recallCommandTable;
  54. + ChatCommand* _houseCommandTable;
  55. ChatCommand* _questCommandTable;
  56. ChatCommand* _serverCommandTable;
  57. ChatCommand* _gmCommandTable;
  58. @@ -525,6 +526,9 @@
  59. bool HandleGlobalPlaySoundCommand(const char* args, WorldSession * m_session);
  60. bool HandleRecallPortPlayerCommand(const char* args, WorldSession * m_session);
  61. bool HandleRecallPortUsCommand(const char* args, WorldSession * m_session);
  62. + bool HandleHouseGoCommand(const char* args, WorldSession *m_session);
  63. + bool HandleHouseAddCommand(const char* args, WorldSession *m_session);
  64. + bool HandleHouseDelCommand(const char* args, WorldSession *m_session);
  65.  
  66. // Bans
  67. bool HandleIPBanCommand(const char * args, WorldSession * m_session);
  68. Index: arcemu-world/RecallCommands.cpp
  69. ===================================================================
  70. --- arcemu-world/RecallCommands.cpp (revision 2907)
  71. +++ arcemu-world/RecallCommands.cpp (working copy)
  72. @@ -260,3 +260,139 @@
  73. delete result;
  74. return false;
  75. }
  76. +
  77. +bool GetHouseLocation(const char* location, uint32 &map, LocationVector &v)
  78. +{
  79. + QueryResult *result = WorldDatabase.Query( "SELECT * FROM house ORDER BY name" );
  80. +
  81. + if( result == NULL)
  82. + return false;
  83. +
  84. + do
  85. + {
  86. + Field* fields = result->Fetch();
  87. + const char* locname = fields[1].GetString();
  88. + uint32 locmap = fields[2].GetUInt32();
  89. + float x = fields[3].GetFloat();
  90. + float y = fields[4].GetFloat();
  91. + float z = fields[5].GetFloat();
  92. + float o = fields[6].GetFloat();
  93. +
  94. + if( strnicmp( const_cast< char* >( location ), locname, strlen( location ) ) == 0 )
  95. + {
  96. + map = locmap;
  97. + v.x = x;
  98. + v.y = y;
  99. + v.z = z;
  100. + v.o = o;
  101. + delete result;
  102. + return true;
  103. + }
  104. +
  105. + }while (result->NextRow());
  106. +
  107. + delete result;
  108. + return false;
  109. +
  110. +}
  111. +
  112. +bool ChatHandler::HandleHouseGoCommand(const char* args, WorldSession *m_session)
  113. +{
  114. + if( args == NULL )
  115. + return false;
  116. +
  117. + if( !*args )
  118. + return false;
  119. +
  120. + if( m_session == NULL )
  121. + return false;
  122. +
  123. + uint32 map;
  124. + LocationVector v;
  125. + if (GetHouseLocation(args, map, v))
  126. + {
  127. + if( m_session->GetPlayer() != NULL )
  128. + {
  129. + m_session->GetPlayer()->SafeTeleport(map, 0, v);
  130. + return true;
  131. + }
  132. + return false;
  133. + }
  134. + return false;
  135. +}
  136. +
  137. +bool ChatHandler::HandleHouseAddCommand(const char* args, WorldSession *m_session)
  138. +{
  139. + if(!*args)
  140. + return false;
  141. +
  142. + QueryResult *result = WorldDatabase.Query( "SELECT name FROM house" );
  143. + if(!result)
  144. + return false;
  145. + do
  146. + {
  147. + Field *fields = result->Fetch();
  148. + const char * locname = fields[0].GetString();
  149. + if (strncmp((char*)args,locname,strlen(locname))==0)
  150. + {
  151. + RedSystemMessage(m_session, "Name in use, please use another name for your location.");
  152. + delete result;
  153. + return true;
  154. + }
  155. + }while (result->NextRow());
  156. + delete result;
  157. +
  158. + Player* plr = m_session->GetPlayer();
  159. + std::stringstream ss;
  160. +
  161. + string rc_locname = string(args);
  162. +
  163. + ss << "INSERT INTO house (name, mapid, positionX, positionY, positionZ, Orientation) VALUES ('"
  164. + << WorldDatabase.EscapeString(rc_locname).c_str() << "' , "
  165. + << plr->GetMapId() << ", "
  166. + << plr->GetPositionX() << ", "
  167. + << plr->GetPositionY() << ", "
  168. + << plr->GetPositionZ() << ", "
  169. + << plr->GetOrientation() << ");";
  170. + WorldDatabase.Execute( ss.str( ).c_str( ) );
  171. +
  172. + char buf[256];
  173. + snprintf((char*)buf, 256, "Added location to DB with MapID: %d, X: %f, Y: %f, Z: %f, O: %f",
  174. + (unsigned int)plr->GetMapId(), plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetOrientation());
  175. + GreenSystemMessage(m_session, buf);
  176. + sGMLog.writefromsession(m_session, "used house add, added \"%s\" location to database.", rc_locname.c_str());
  177. +
  178. + return true;
  179. +}
  180. +
  181. +bool ChatHandler::HandleHouseDelCommand(const char* args, WorldSession *m_session)
  182. +{
  183. + if(!*args)
  184. + return false;
  185. +
  186. + QueryResult *result = WorldDatabase.Query( "SELECT id,name FROM house" );
  187. + if(!result)
  188. + return false;
  189. +
  190. + do
  191. + {
  192. + Field *fields = result->Fetch();
  193. + float id = fields[0].GetFloat();
  194. + const char * locname = fields[1].GetString();
  195. +
  196. + if (strnicmp((char*)args,locname,strlen(locname))==0)
  197. + {
  198. + std::stringstream ss;
  199. + ss << "DELETE FROM house WHERE id = "<< (int)id <<";";
  200. + WorldDatabase.Execute( ss.str( ).c_str( ) );
  201. + GreenSystemMessage(m_session, "House location removed.");
  202. + sGMLog.writefromsession(m_session, "used house delete, removed \"%s\" location from database.", args);
  203. + delete result;
  204. + return true;
  205. + }
  206. +
  207. + }while (result->NextRow());
  208. +
  209. + delete result;
  210. + return false;
  211. +}
  212. \ No newline at end of file
  213.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement