1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
/*
* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "Common.h"
#include "Database/DatabaseEnv.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "World.h"
#include "Player.h"
#include "Opcodes.h"
#include "Chat.h"
#include "MapManager.h"
#include "ObjectAccessor.h"
#include "Language.h"
#include "AccountMgr.h"
#include "SystemConfig.h"
#include "Util.h"
bool ChatHandler::HandleHelpCommand(const char* args)
{
if(!*args)
return false;
char* cmd = strtok((char*)args, " ");
if(!cmd)
return false;
if(!ShowHelpForCommand(getCommandTable(), cmd))
SendSysMessage(LANG_NO_HELP_CMD);
return true;
}
bool ChatHandler::HandleCommandsCommand(const char* args)
{
ShowHelpForCommand(getCommandTable(), "");
return true;
}
bool ChatHandler::HandleAcctCommand(const char* /*args*/)
{
uint32 gmlevel = m_session->GetSecurity();
PSendSysMessage(LANG_ACCOUNT_LEVEL, gmlevel);
return true;
}
bool ChatHandler::HandleStartCommand(const char* /*args*/)
{
Player *chr = m_session->GetPlayer();
if(chr->isInFlight())
{
SendSysMessage(LANG_YOU_IN_FLIGHT);
SetSentErrorMessage(true);
return false;
}
if(chr->isInCombat())
{
SendSysMessage(LANG_YOU_IN_COMBAT);
SetSentErrorMessage(true);
return false;
}
// cast spell Stuck
chr->CastSpell(chr,7355,false);
return true;
}
bool ChatHandler::HandleInfoCommand(const char* /*args*/)
{
uint32 activeClientsNum = sWorld.GetActiveSessionCount();
uint32 queuedClientsNum = sWorld.GetQueuedSessionCount();
uint32 maxActiveClientsNum = sWorld.GetMaxActiveSessionCount();
uint32 maxQueuedClientsNum = sWorld.GetMaxQueuedSessionCount();
std::string str = secsToTimeString(sWorld.GetUptime());
PSendSysMessage(_FULLVERSION);
PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum);
PSendSysMessage(LANG_UPTIME, str.c_str());
return true;
}
bool ChatHandler::HandleDismountCommand(const char* /*args*/)
{
//If player is not mounted, so go out :)
if (!m_session->GetPlayer( )->IsMounted())
{
SendSysMessage(LANG_CHAR_NON_MOUNTED);
SetSentErrorMessage(true);
return false;
}
if(m_session->GetPlayer( )->isInFlight())
{
SendSysMessage(LANG_YOU_IN_FLIGHT);
SetSentErrorMessage(true);
return false;
}
m_session->GetPlayer()->Unmount();
m_session->GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
return true;
}
bool ChatHandler::HandleSaveCommand(const char* /*args*/)
{
Player *player=m_session->GetPlayer();
// save GM account without delay and output message (testing, etc)
if(m_session->GetSecurity())
{
player->SaveToDB();
SendSysMessage(LANG_PLAYER_SAVED);
return true;
}
// save or plan save after 20 sec (logout delay) if current next save time more this value and _not_ output any messages to prevent cheat planning
uint32 save_interval = sWorld.getConfig(CONFIG_INTERVAL_SAVE);
if(save_interval==0 || save_interval > 20*1000 && player->GetSaveTimer() <= save_interval - 20*1000)
player->SaveToDB();
return true;
}
bool ChatHandler::HandleGMListCommand(const char* /*args*/)
{
bool first = true;
HashMapHolder<Player>::MapType &m = HashMapHolder<Player>::GetContainer();
HashMapHolder<Player>::MapType::iterator itr = m.begin();
for(; itr != m.end(); ++itr)
{
if( itr->second->GetSession()->GetSecurity() && (itr->second->isGameMaster() || sWorld.getConfig(CONFIG_GM_IN_GM_LIST) ) &&
itr->second->IsVisibleGloballyFor(m_session->GetPlayer()) )
{
if(first)
{
SendSysMessage(LANG_GMS_ON_SRV);
first = false;
}
SendSysMessage(itr->second->GetName());
}
}
if(first)
SendSysMessage(LANG_GMS_NOT_LOGGED);
return true;
}
bool ChatHandler::HandlePasswordCommand(const char* args)
{
if(!*args)
return false;
char *old_pass = strtok ((char*)args, " ");
char *new_pass = strtok (NULL, " ");
char *new_pass_c = strtok (NULL, " ");
if( !old_pass || !new_pass || !new_pass_c )
return false;
std::string password_old = old_pass;
std::string password_new = new_pass;
std::string password_new_c = new_pass_c;
if(!accmgr.CheckPassword(m_session->GetAccountId(), password_old) || password_new != password_new_c)
{
SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
SetSentErrorMessage(true);
return false;
}
AccountOpResult result = accmgr.ChangePassword(m_session->GetAccountId(), password_new);
switch(result)
{
case AOR_OK:
SendSysMessage(LANG_COMMAND_PASSWORD);
break;
default:
SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
SetSentErrorMessage(true);
return false;
}
return true;
}
bool ChatHandler::HandleLockAccountCommand(const char* args)
{
if (!*args)
{
SendSysMessage(LANG_USE_BOL);
return true;
}
std::string argstr = (char*)args;
if (argstr == "on")
{
loginDatabase.PExecute( "UPDATE account SET locked = '1' WHERE id = '%d'",m_session->GetAccountId());
PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
return true;
}
if (argstr == "off")
{
loginDatabase.PExecute( "UPDATE account SET locked = '0' WHERE id = '%d'",m_session->GetAccountId());
PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
return true;
}
SendSysMessage(LANG_USE_BOL);
return true;
}
|