Exemple #1
0
BOOL CMDHist::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    Channel* chan=nullptr;
    std::list <HistoryNode*> *history = nullptr;;
    TimeInfo tm;

    if (!args.size())
        {
            mobile->Message(MSG_ERROR,"Syntax: hist [channel name].");
            return false;
        }

    chan=world->FindChannel(args[0]);
    if (!chan)
        {
            mobile->Message(MSG_ERROR,"That channel doesn't exist.");
            return false;
        }

    history=chan->GetHistory();
    if ((!history) || (!history->size()))
        {
            mobile->Message(MSG_INFO,"There is no recorded history, perhaps you should say something?");
            return true;
        }

    for (auto it: *history)
        {
            tm.Calculate(time(NULL) - it->when);
            mobile->Message(MSG_LIST,tm.ToString() + ": " + it->message);
        }

    return true;
}
Exemple #2
0
CEVENT(Channel, SubscribeChannels)
{
    World* world = World::GetPtr();

    std::list <std::string> *names=new std::list<std::string>();
    std::list <std::string>::iterator it, itEnd;
    Channel* chan=NULL;
    Player* mobile=(Player*)caller;
    mobile->events.AddCallback("OptionChanged", std::bind(&Channel::OptionChanged, std::placeholders::_1, std::placeholders::_2));
    world->GetChannelNames(names);

    itEnd = names->end();
    for (it = names->begin(); it != itEnd; ++it)
        {
            if (GetOptionValue((*it), mobile).GetInt() == 1)
                {
                    chan=world->FindChannel((*it));
                    if (chan)
                        {
                            chan->AddListener(mobile,true);
                        }
                }
        }
    delete names;
}
Exemple #3
0
BOOL CMDChan::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    Channel* chan = world->FindChannel(subcmd);
    std::string message=Explode(args);

    if (chan==nullptr)
        {
            mobile->Message(MSG_ERROR,"That channel doesn't exist.");
            return false;
        }

    chan->Broadcast(mobile,message,true);
    return true;
}
Exemple #4
0
CEVENT(Channel, OptionChanged)
{
    World* world = World::GetPtr();
    Player* mobile = (Player*)caller;
    OptionChangedArgs* arg = (OptionChangedArgs*)args;
    Option* node = arg->opt;
    Channel* chan = world->FindChannel(node->GetMeta()->GetName());

    if (chan)
        {
            if (node->GetValue().GetInt())
                {
                    chan->AddListener(mobile);
                }
            else
                {
                    chan->RemoveListener(mobile);
                }
        }
}
Exemple #5
0
CEVENT(Channel, UnsubscribeChannels)
{
    World* world = World::GetPtr();

    std::list <std::string>* names=new std::list <std::string>();
    std::list <std::string>::iterator it, itEnd;
    Channel* chan=NULL;
    Player* mobile=(Player*)caller;
    world->GetChannelNames(names);

    itEnd=names->end();
    for (it = names->begin(); it != itEnd; ++it)
        {
            chan=world->FindChannel((*it));
            if (chan)
                {
                    chan->RemoveListener(mobile,true);
                }
        }
    delete names;
}