Changeset 112 for trunk/src/game/World.h

Show
Ignore:
Timestamp:
11/19/08 13:37:14 (17 years ago)
Author:
yumileroy
Message:

[svn] * Merge CLI Commands with regular commands and give them level4 access. sec_console. Source mangos - thanks to ogeraisi for the amalgamated patch.
* Redid/Fixed/Added some lang strings.
* As usual remember this is a trunk rev so stability only guaranteed on northern countries of Mars and western parts of Pluto. No warranties outside the solar system, sorry :( . Check with your local government or dictator on regulations regarding export.

Original author: KingPin?
Date: 2008-10-26 13:32:42-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/World.h

    r102 r112  
    2929#include "Timer.h" 
    3030#include "Policies/Singleton.h" 
     31#include "SharedDefines.h" 
    3132 
    3233#include <map> 
     
    4142struct ScriptAction; 
    4243struct ScriptInfo; 
    43 class CliCommandHolder; 
    4444class SqlResultQueue; 
    4545class QueryResult; 
     
    297297}; 
    298298 
    299 /// Ban function return codes 
    300 enum BanReturn 
    301 { 
    302     BAN_SUCCESS, 
    303     BAN_SYNTAX_ERROR, 
    304     BAN_NOTFOUND 
    305 }; 
    306  
    307299// DB scripting commands 
    308300#define SCRIPT_COMMAND_TALK                  0              // source = unit, target=any, datalong ( 0=say, 1=whisper, 2=yell, 3=emote text) 
     
    322314#define SCRIPT_COMMAND_CAST_SPELL           15              // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id 
    323315 
    324 /// CLI related stuff, define here to prevent cyclic dependancies 
    325  
    326 typedef int(* pPrintf)(const char*,...); 
    327 typedef void(* pCliFunc)(char *,pPrintf); 
    328  
    329 /// Command Template class 
    330 struct CliCommand 
    331 { 
    332     char const * cmd; 
    333     pCliFunc Func; 
    334     char const * description; 
    335 }; 
    336  
    337316/// 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);} 
     317struct 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; } 
    355333}; 
    356334 
     
    475453        void KickAllLess(AccountTypes sec); 
    476454        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); 
    479457 
    480458        void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target); 
     
    493471 
    494472        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)); } 
    496474 
    497475        void UpdateResultQueue();