WOLDiags.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifdef WWDEBUG
  19. /******************************************************************************
  20. *
  21. * FILE
  22. * $Archive: /Commando/Code/Commando/WOLDiags.cpp $
  23. *
  24. * DESCRIPTION
  25. *
  26. * PROGRAMMER
  27. * $Author: Denzil_l $
  28. *
  29. * VERSION INFO
  30. * $Revision: 4 $
  31. * $Modtime: 1/11/02 5:43p $
  32. *
  33. ******************************************************************************/
  34. #include "WOLDiags.h"
  35. #include <WWOnline\WOLSession.h>
  36. #include <WWOnline\WOLServer.h>
  37. using namespace WWOnline;
  38. void ShowWOLVersion(const RefPtr<Session>& session)
  39. {
  40. unsigned long ver = 0;
  41. session->GetChatObject()->GetVersion(&ver);
  42. ConsoleFunctionClass::Print("WOLAPI V%u.%u\n", (ver >> 16), (ver & 0xFFFF));
  43. }
  44. void ShowServer(const RefPtr<Session>& session)
  45. {
  46. const RefPtr<IRCServerData>& server = session->GetCurrentServer();
  47. if (server.IsValid())
  48. {
  49. WOL::Server& data = server->GetData();
  50. ConsoleFunctionClass::Print("Server: %s:%s TimeZone: %d Position:: %f/%f\n",
  51. (const char*)data.connlabel, (const char*)data.name, data.timezone, data.longitude, data.lattitude);
  52. }
  53. else
  54. {
  55. ConsoleFunctionClass::Print("WOL not connected\n");
  56. }
  57. }
  58. void ShowTopic(const RefPtr<Session>& session)
  59. {
  60. ConsoleFunctionClass::Print("Channel Topic: %s\n", session->GetChannelTopic());
  61. }
  62. void ShowPingServers(const RefPtr<Session>& session)
  63. {
  64. const PingServerList& pingServers = session->GetPingServerList();
  65. unsigned int count = pingServers.size();
  66. for (unsigned int index = 0; index < count; index++)
  67. {
  68. const RefPtr<PingServerData>& ping = pingServers[index];
  69. ConsoleFunctionClass::Print("%-18s %-4dms - %s\n",
  70. ping->GetHostAddress(), ping->GetPingTime(), ping->GetName());
  71. }
  72. }
  73. struct Dispatch
  74. {
  75. const char* Cmd;
  76. void (*Func)(const RefPtr<Session>&);
  77. };
  78. const char* WOLConsoleFunctionClass::Get_Help(void)
  79. {
  80. return ("WOL <command> - Show WOL information");
  81. }
  82. void WOLConsoleFunctionClass::Activate(const char* input)
  83. {
  84. static Dispatch _dispatch[] =
  85. {
  86. {"pings", ShowPingServers},
  87. {"server", ShowServer},
  88. {"topic", ShowTopic},
  89. {"ver", ShowWOLVersion},
  90. {NULL, NULL}
  91. };
  92. RefPtr<Session> session = Session::GetInstance(false);
  93. if (!session.IsValid())
  94. {
  95. ConsoleFunctionClass::Print("Westwood Online not active\n");
  96. return;
  97. }
  98. int index = 0;
  99. const char* cmd = _dispatch[0].Cmd;
  100. while (cmd != NULL)
  101. {
  102. if (stricmp(cmd, input) == 0)
  103. {
  104. _dispatch[index].Func(session);
  105. return;
  106. }
  107. ++index;
  108. cmd = _dispatch[index].Cmd;
  109. }
  110. }
  111. #endif // WWDEBUG