All pastes #457542 Raw Edit

Unnamed

public cpp v1 · immutable
#457542 ·published 2007-04-25 13:31 UTC
rendered paste body
static void PlayerConsoleOut_conf(std::istream &s){                    tString msg;                    msg.ReadLine( s, true );                    int current_place=0; // current place in buffer_name.                    // search for end of recipient and store recipient in buffer_name                    tString buffer_name;                    while (current_place < msg.Len() && !isblank(msg[current_place])) {                        buffer_name[current_place]=msg[current_place];                        current_place++;                    }                    buffer_name[current_place] = '\0';                    buffer_name = ePlayerNetID::FilterName(buffer_name);                    // Check for match                    int num_matches=-1;                    ePlayerNetID * receiver = CompareBufferToPlayerNames(buffer_name, num_matches);                    // One match, send it.                    if (num_matches == 1) {                        // extract rest of message: it is the true message to send                        tString msg_core;                        while (current_place < msg.Len()-1) {                            current_place++;                            msg_core += msg[current_place];                        }                        // build chat string                        //tColoredString toServer = se_BuildChatString( p, receiver, msg_core );                        tColoredString toServer;                        se_AppendChat( toServer, msg_core );                        toServer << '\n';                        // log locally                        sn_ConsoleOut(toServer,0);                        // send to receiver                        //se_SendPrivateMessage( p, receiver, msg_core );                        sn_ConsoleOut(toServer, receiver->Owner());                        return;                    }                    // More than than one match for the current buffer. Complain about that.                    else if (num_matches > 1) {                        tOutput toSender;                        toSender.SetTemplateParameter(1, buffer_name);                        toSender << "$msg_toomanymatches";                        sn_ConsoleOut(toSender,0);                        return;                    }                    // 0 matches. The user can't spell. Complain about that, too.                    else {                        tOutput toSender;                        toSender.SetTemplateParameter(1, buffer_name);                        toSender << "$msg_nomatch";                        sn_ConsoleOut(toSender, 0);                        return;                    }}static tConfItemFunc PlayerConsoleOut_c("PLAYER_MESSAGE",&PlayerConsoleOut_conf);