Changeset 112 for trunk/src/game/World.h
- Timestamp:
- 11/19/08 13:37:14 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/World.h
r102 r112 29 29 #include "Timer.h" 30 30 #include "Policies/Singleton.h" 31 #include "SharedDefines.h" 31 32 32 33 #include <map> … … 41 42 struct ScriptAction; 42 43 struct ScriptInfo; 43 class CliCommandHolder;44 44 class SqlResultQueue; 45 45 class QueryResult; … … 297 297 }; 298 298 299 /// Ban function return codes300 enum BanReturn301 {302 BAN_SUCCESS,303 BAN_SYNTAX_ERROR,304 BAN_NOTFOUND305 };306 307 299 // DB scripting commands 308 300 #define SCRIPT_COMMAND_TALK 0 // source = unit, target=any, datalong ( 0=say, 1=whisper, 2=yell, 3=emote text) … … 322 314 #define SCRIPT_COMMAND_CAST_SPELL 15 // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id 323 315 324 /// CLI related stuff, define here to prevent cyclic dependancies325 326 typedef int(* pPrintf)(const char*,...);327 typedef void(* pCliFunc)(char *,pPrintf);328 329 /// Command Template class330 struct CliCommand331 {332 char const * cmd;333 pCliFunc Func;334 char const * description;335 };336 337 316 /// Storage class for commands issued for delayed execution 338 class CliCommandHolder 339 { 340 private: 341 const CliCommand *cmd; 342 char *args; 343 pPrintf m_zprintf; 344 public: 345 CliCommandHolder(const CliCommand *command, const char *arguments, pPrintf p_zprintf) 346 : cmd(command), m_zprintf(p_zprintf) 347 { 348 size_t len = strlen(arguments)+1; 349 args = new char[len]; 350 memcpy(args, arguments, len); 351 } 352 ~CliCommandHolder() { delete[] args; } 353 void Execute() const { cmd->Func(args, m_zprintf); } 354 pPrintf GetOutputMethod() const {return (m_zprintf);} 317 struct CliCommandHolder 318 { 319 typedef void Print(const char*); 320 321 char *m_command; 322 Print* m_print; 323 324 CliCommandHolder(const char *command, Print* zprint) 325 : m_print(zprint) 326 { 327 size_t len = strlen(command)+1; 328 m_command = new char[len]; 329 memcpy(m_command, command, len); 330 } 331 332 ~CliCommandHolder() { delete[] m_command; } 355 333 }; 356 334 … … 475 453 void KickAllLess(AccountTypes sec); 476 454 void KickAllQueued(); 477 uint8 BanAccount(std::string type, std::string nameOrIP, std::string duration, std::string reason, std::string author);478 bool RemoveBanAccount(std::string type, std::string nameOrIP);455 BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author); 456 bool RemoveBanAccount(BanMode mode, std::string nameOrIP); 479 457 480 458 void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target); … … 493 471 494 472 void ProcessCliCommands(); 495 void QueueCliCommand( CliCommandHolder* command) { cliCmdQueue.add(command); }473 void QueueCliCommand( CliCommandHolder::Print* zprintf, char const* input ) { cliCmdQueue.add(new CliCommandHolder(input, zprintf)); } 496 474 497 475 void UpdateResultQueue();