コード例 #1
0
ファイル: Ban.cpp プロジェクト: Dragonji/jaymod
void
Ban::doBan( User& user, User& authority, int duration, const string& reason, Buffer& out, const Client* client )
{
    out << xvalue( user.namex ) << " banned " << (duration ? "for " : "")
        << (duration ? str::toStringSecondsRemaining( duration, true ) : "permanently")
        << '.';

    userDB.unindex( user );

    // Set up ban record
    user.banned = true;
    user.banTime = time( NULL );
    user.banExpiry = duration ? user.banTime + duration : 0; // 0 is a permanent ban
    user.banReason = reason;
    user.banAuthority = authority.name;
    user.banAuthorityx = authority.namex;

    userDB.index( user );

    if (!client)
        return;

    Buffer buf;
    buf << '\n' << "user: "******"duration:"
        << '\n' << xvalue( duration ? str::toStringSecondsRemaining( duration, true ) : "PERMANENT" )
        << '\n'
        << '\n' << "reason:"
        << '\n' << xvalue( reason );
    SEngine::dropClient( client->slot, buf, "You have been banned." );
}
コード例 #2
0
ファイル: Ban.cpp プロジェクト: Dragonji/jaymod
Ban::Ban()
    : AbstractBuiltin( "ban" )
{
    __usage << xvalue( "!" + _name )
            << ' ' << xvalue( "PLAYER" )
            << ' ' << _ovalue( "SECONDS" )
            << ' ' << _ovalue( "REASON" );

    __descr << "Ban an online player.";
}
コード例 #3
0
ファイル: arraydata.cpp プロジェクト: MelroLeandro/gromacs
void
AbstractAnalysisArrayData::valuesReady()
{
    GMX_RELEASE_ASSERT(isAllocated(), "There must be some data");
    if (bReady_)
    {
        return;
    }
    bReady_ = true;

    std::vector<AnalysisDataValue>::const_iterator valueIter = value_.begin();
    AnalysisDataModuleManager                     &modules   = moduleManager();
    modules.notifyDataStart(this);
    for (int i = 0; i < rowCount(); ++i, valueIter += columnCount())
    {
        AnalysisDataFrameHeader header(i, xvalue(i), 0);
        modules.notifyFrameStart(header);
        modules.notifyPointsAdd(
                AnalysisDataPointSetRef(
                        header, pointSetInfo_,
                        constArrayRefFromVector<AnalysisDataValue>(valueIter,
                                                                   valueIter + columnCount())));
        modules.notifyFrameFinish(header);
    }
    modules.notifyDataFinish();
}
コード例 #4
0
ファイル: DbSave.cpp プロジェクト: Dragonji/jaymod
AbstractCommand::PostAction
DbSave::doExecute( Context& txt )
{
    if (txt._args.size() != 1)
        return PA_USAGE;

    levelDB.save();
    userDB.save();

    Buffer buf;
    buf << "saved: " << xvalue( int(levelDB.mapLEVEL.size()) ) << " levels\n"
        << "saved: " << xvalue( int(userDB.mapGUID.size()) ) << " users\n";
    printCpm( txt._client, buf, true );

    return PA_NONE;
}
コード例 #5
0
ファイル: BanList.cpp プロジェクト: Dragonji/jaymod
BanList::BanList()
    : AbstractBuiltin( "banlist" )
{
    __usage << xvalue( "!" + _name )
            << ' ' << _ovalue( "-ip IP" )
            << ' ' << _ovalue( "-level LEVEL" )
            << ' ' << _ovalue( "-name NAME" )
            << ' ' << _ovalue( "-since SECONDS" )
            << ' ' << _ovalue( "-auth AUTHORITY" );

    __descr << "List banned users.";
}
コード例 #6
0
ファイル: arraydata.cpp プロジェクト: MelroLeandro/gromacs
AnalysisDataFrameRef
AbstractAnalysisArrayData::tryGetDataFrameInternal(int index) const
{
    if (!isAllocated())
    {
        return AnalysisDataFrameRef();
    }
    std::vector<AnalysisDataValue>::const_iterator begin
        = value_.begin() + index * columnCount();
    return AnalysisDataFrameRef(
            AnalysisDataFrameHeader(index, xvalue(index), 0.0),
            constArrayRefFromVector<AnalysisDataValue>(begin, begin + columnCount()),
            constArrayRefFromArray(&pointSetInfo_, 1));
}
コード例 #7
0
ファイル: Time.cpp プロジェクト: Dragonji/jaymod
AbstractCommand::PostAction
Time::doExecute( Context& txt )
{
    if (txt._args.size() > 1)
        return PA_USAGE;

    time_t now;
    if (!time( &now )) {
        txt._ebuf << "Unable to determine system time.";
        return PA_ERROR;
    }

    tm* lt = localtime( &now );
    char s[32];
    strftime( s, sizeof(s), "%I:%M%p %Z", lt );

    Buffer buf;
    buf << _name << ": " << xvalue( s );
    printChat( txt._client, buf );

    return PA_NONE;
}
コード例 #8
0
ファイル: Finger.cpp プロジェクト: Dragonji/jaymod
Finger::Finger()
    : AbstractBuiltin( "finger" )
{
    __usage << xvalue( "!" + _name ) << ' ' << xvalue( "PLAYER" );
    __descr << "Get information about a player.";
}
コード例 #9
0
ファイル: PanzerWar.cpp プロジェクト: Dragonji/jaymod
PanzerWar::PanzerWar()
    : AbstractBuiltin( "panzerwar" )
{
    __usage << xvalue( "!" + _name ) << " [" << xvalue( "on" ) << '|' << xvalue( "off" ) << ']';
    __descr << "A panzerfaust frag-fest. No argument reports status.";
}
コード例 #10
0
ファイル: PanzerWar.cpp プロジェクト: Dragonji/jaymod
AbstractCommand::PostAction
PanzerWar::doExecute( Context& txt )
{
    if (txt._args.size() > 2)
        return PA_USAGE;

    const bool enabled = cvars::bg_panzerWar.ivalue;
    Buffer buf;

    // If there are no arguments, just report status
    if (txt._args.size() == 1) {
        buf << _name << ": Panzer war is " << xvalue( enabled ? "enabled" : "disabled" ) << '.';
        printChat( txt._client, buf );
        return PA_NONE;
    }
        
    string action = txt._args[1];
    str::toLower(action);
    
    if (action == "on") {
        if (enabled) {
            txt._ebuf << "Panzer war is already " << xvalue( "enabled" ) << '.';
            return PA_ERROR;
        }

		for (int i = 0; i < level.numConnectedClients; i++) {
            gentity_t* ent = &g_entities[i];

            if (ent->client->sess.sessionTeam == TEAM_SPECTATOR)
                continue;

            G_Damage( ent, NULL, NULL, NULL, NULL, 10000, DAMAGE_JAY_NO_PROTECTION, MOD_UNKNOWN );
		}

        cvars::bg_panzerWar.set( "1" );
        buf << _name << ": Panzer war is now " << xvalue( "enabled" ) << '.';
        printCpm( txt._client, buf, true );
    }
    else if (action == "off") {
        if (!enabled) {
            txt._ebuf << "Panzer war is already " << xvalue( "disabled" ) << '.';
            return PA_ERROR;
        }

		for (int i = 0; i < level.numConnectedClients; i++) {
            gentity_t* ent = &g_entities[i];

            if (ent->client->sess.sessionTeam == TEAM_SPECTATOR)
                continue;

            G_Damage( ent, NULL, NULL, NULL, NULL, 10000, DAMAGE_JAY_NO_PROTECTION, MOD_UNKNOWN );
		}

        cvars::bg_panzerWar.set( "0" );
        buf << _name << ": Panzer war is now " << xvalue( "disabled" ) << '.';
        printCpm( txt._client, buf, true );
    }
    else {
        txt._ebuf << "Invalid argument: " << xvalue( txt._args[1] );
        return PA_ERROR;
    }

    return PA_NONE;
}
コード例 #11
0
ファイル: DbSave.cpp プロジェクト: Dragonji/jaymod
DbSave::DbSave()
    : AbstractBuiltin( "dbsave" )
{
    __usage << xvalue( "!" + _name );
    __descr << "Save the in-memory Admin System database to disk.";
}
コード例 #12
0
ファイル: BanList.cpp プロジェクト: Dragonji/jaymod
AbstractCommand::PostAction
BanList::doExecute( Context& txt )
{
    // bail if nothing to display
    if (userDB.mapBANTIME.empty()) {
        txt._ebuf << "There are no banned users.";
        return PA_ERROR;
    }

    struct Filter {
        string auth;  
        string ip;
        int    level;
        string name;  
        int    since; 
    };
    Filter filter = { "", "", -1, "", 0 };

    // parse filter options    
    {
        const vector<string>::size_type max = txt._args.size();
        for ( vector<string>::size_type i = 1; i < max; i++ ) {
            // pairs of args are expected
            if ((max - i) < 2)
                return PA_USAGE;

            string s = txt._args[i];
            str::toLower( s );

            if (s == "-auth" ) {
                filter.auth = txt._args[++i];
                str::toLower( filter.auth );
            }
            else if (s == "-ip" ) {
                filter.ip = txt._args[++i];
            }
            else if (s == "-level") {
                const string& s = txt._args[++i];
                string err;
                Level& lev = lookupLEVEL( s, txt );
                if (lev == Level::BAD)
                    return PA_ERROR;
                filter.level = lev.level;
            }
            else if (s == "-name") {
                filter.name = txt._args[++i];
                str::toLower( filter.name );
            }
            else if (s == "-since") {
                filter.since = str::toSeconds( txt._args[++i] );
            }
            else {
                return PA_USAGE;
            }
        }
    }

    InlineText cID      = xheader;
    InlineText cWhen    = xheader;
    InlineText cSubject = xheader;
    InlineText cRemain  = xheader;
    InlineText cAuth    = xheader;

    cID.flags      |= ios::left;
    cWhen.flags    |= ios::left;
    cSubject.flags |= ios::left;

    cID.width      = 8;
    cWhen.width    = 24;
    cSubject.width = 25;
    cRemain.width  = 13;

    cWhen.prefixOutside    = ' ';
    cSubject.prefixOutside = ' ';
    cRemain.prefixOutside  = ' ';
    cAuth.prefixOutside    = ' ';

    Buffer buf;
    buf << cID      ( "ID" )
        << cWhen    ( "WHEN" )
        << cSubject ( "SUBJECT" )
        << cRemain  ( "REMAINING" )
        << cAuth    ( "AUTHORITY" );

    cID.color      = xcnone;
    cWhen.color    = xcnone;
    cSubject.color = xcnone;
    cRemain.color  = xcnone;
    cAuth.color    = xcnone;

    const time_t now = time( NULL );
    string tmp;

    uint32 numExpired = 0;
    uint32 num = 0;
    const UserDB::mapBANTIME_t::const_reverse_iterator max = userDB.mapBANTIME.rend();
    for ( UserDB::mapBANTIME_t::const_reverse_iterator it = userDB.mapBANTIME.rbegin(); it != max; it++ ) {
        const User& user = *it->second;
        const string id = (user.guid.length() == 32) ? user.guid.substr( 24 ) : "";

        const time_t deltaTime = user.banExpiry - now;

        // skip if ban has expired
        if (user.banExpiry && deltaTime < 0) {
            numExpired++;
            continue;
        }

        if (!filter.auth.empty()) {
            tmp = user.banAuthority;
            str::toLower( tmp );
            if (tmp.find( filter.auth ) == string::npos)
                continue;
        }

        if (!filter.ip.empty() && (user.ip.find( filter.ip ) == string::npos))
            continue;

        if (filter.level != -1 && user.authLevel != filter.level)
            continue;

        if (!filter.name.empty()) {
            tmp = user.name;
            str::toLower( tmp );
            if (tmp.find( filter.name ) == string::npos)
                continue;
        }

        if (filter.since > 0 && ((now - user.timestamp) > filter.since))
            continue;

        if (++num > (Page::maxLines * Page::maxPages))
            break;

        // format ban time
        char ftime[32];
        strftime( ftime, sizeof(ftime), "%c", localtime( &user.banTime ));

        buf << '\n'
            << cID      ( id )
            << cWhen    ( ftime )
            << cSubject ( str::etAlignLeft( user.namex, cSubject.width, tmp ));

        ostringstream remain;
        if (!user.banExpiry) {
            remain << "permanent";
        }
        else {
            int secs = (user.banExpiry - now);

            int days = secs / (60*60*24);
            secs -= (days * (60*60*24));

            int hours = secs / (60*60);
            secs -= (hours * (60*60));

            int mins = secs / 60;
            secs -= (mins * 60);

            if (days > 999)
                remain << "999d-";
            else if (days > 0)
                remain << days << "d-";

            remain << setw(2) << setfill('0') << hours
                   << ':' << setw(2) << setfill('0') << mins
                   << ':' << setw(2) << setfill('0') << secs;
        }

        buf << cRemain ( remain.str() )
            << cAuth   ( user.banAuthorityx );
    }

    Page::report( txt._client, buf );

    if (numExpired) {
        buf.reset();
        buf << xcheader << "--there were " << xvalue( numExpired ) << " expired-bans not listed.";
        print( txt._client, buf );
    }

    return PA_NONE;
}
コード例 #13
0
ファイル: Time.cpp プロジェクト: Dragonji/jaymod
Time::Time()
    : AbstractBuiltin( "time", true )
{
    __usage << xvalue( "!" + _name );
    __descr << "Shows the current local (server) time.";
}
コード例 #14
0
ファイル: Pop.cpp プロジェクト: Dragonji/jaymod
Pop::Pop()
    : AbstractBuiltin( "pop" )
{
    __usage << xvalue( "!" + _name ) << ' ' << _ovalue( "PLAYER_FILTER" );
    __descr << "Let all players pop off their helmets.";
}
コード例 #15
0
ファイル: Pop.cpp プロジェクト: Dragonji/jaymod
AbstractCommand::PostAction
Pop::doExecute( Context& txt )
{
    if (txt._args.size() > 2)
        return PA_USAGE;

    vector<Client*> targets;

    if (txt._args.size() > 1) {
        // bail if no valid targets
        if (lookupPLAYER( txt._args[1], txt, targets, "PLAYER_FILTER" ))
            return PA_ERROR;
    }
    else {
        // populate with all
        for (int i = 0; i < level.numConnectedClients; i++)
            targets.push_back( &g_clientObjects[i] );
    }

    // bail if no targets
    if (targets.empty()) {
        txt._ebuf << "No players found.";
        return PA_ERROR;
    }
    
    Client* const single = (targets.size() == 1) ? targets.front() : NULL;
    int num = 0;

    const vector<Client*>::iterator max = targets.end();
    for ( vector<Client*>::iterator it = targets.begin(); it != max; it++ ) {
        Client& c = **it;
        gentity_t* const ent = &c.gentity;

        if (single) {
            if (isHigherLevelError( c, txt ))
                return PA_ERROR;

            if (isNotOnTeamError( c, txt ))
                return PA_ERROR;

           if (ent->client->ps.eFlags & EF_HEADSHOT) {
               const User& u = *connectedUsers[c.slot];
               txt._ebuf << xvalue( u.namex ) << " has no helmet.";
               return PA_ERROR;
           }
        }

        if (isHigherLevel( c, txt._client ))
            continue;

        if (!ISONTEAM( ent ))
            continue;

        if (ent->client->ps.eFlags & EF_HEADSHOT)
            continue;

        vec3_t fwd;
        AngleVectors( c.gclient.ps.viewangles, fwd, NULL, NULL );
        G_AddEvent( ent, EV_LOSE_HAT, DirToByte(fwd) );

        num++;
    }

    Buffer buf;
    buf << _name << ": ";
    if (single) {
       const User& u = *connectedUsers[single->slot];
       buf << xvalue( u.namex ) << " was pop'd.";
    }
    else {
       buf << xvalue( num ) << " player" << (num == 1 ? "" : "s") << " pop'd.";
    }

    printCpm( txt._client, buf, true );
    return PA_NONE;
}
コード例 #16
0
ファイル: ListPlayers.cpp プロジェクト: Dragonji/jaymod
ListPlayers::ListPlayers()
    : AbstractBuiltin( "listplayers" )
{
    __usage << xvalue( "!" + _name );
    __descr << "Display all players connected, their client numbers and admin levels.";
}
コード例 #17
0
void chargedist(double xyzr[MAXATOMS][XYZRWIDTH],
double* chratm, Mat<>& charget, Mat<>& corlocqt, Mat<size_t>& loc_qt, size_t iatm){
	double x_q = xyzr[iatm-1][0];
	double y_q = xyzr[iatm-1][1];
	double z_q = xyzr[iatm-1][2];
	double q_q = chratm[iatm-1];

	size_t i_q = inverx(x_q);
	int j_q = invery(y_q);
	int k_q = inverz(z_q);


	Mat<size_t> loc_q(8,3);
	Mat<> corlocq(8,3);
	for (size_t i = 0; i <= 1; ++i) {
		for (size_t j = 0; j <= 1; ++j) {
			for (size_t k = 0; k <= 1; ++k) {
				size_t ind = 4*k + 2*j + i + 1;

				size_t ind_i = i_q + i;
				size_t ind_j = j_q + j;
				size_t ind_k = k_q + k;

				corlocq(ind,1) = xvalue(ind_i);
				corlocq(ind,2) = yvalue(ind_j);
				corlocq(ind,3) = zvalue(ind_k);

				loc_q(ind,1) = ind_i;
				loc_q(ind,2) = ind_j;
				loc_q(ind,3) = ind_k;
			}
		}
	}

	double x = xvalue(i_q);
	double y = yvalue(j_q);
	double z = zvalue(k_q);

	double xd1 = x_q - x;
	double yd1 = y_q - y;
	double zd1 = z_q - z;

	std::valarray<double> charge(0.0, 8);
	if (xd1 != 0 && yd1 != 0 && zd1 != 0) {
		for (int i = 0; i <= 1; ++i) {
			for (int j = 0; j <= 1; ++j) {
				for (int k = 0; k <= 1; ++k) {
					int ind = 4*k + 2*j + i;

					double xd = i*comdata.deltax - xd1;
					double yd = j*comdata.deltay - yd1;
					double zd = k*comdata.deltaz - zd1;

					charge[ind] = 1.0/fabs(xd*yd*zd);
				}
			}
		}
	} else if ((xd1 != 0 && yd1 != 0) || (xd1 != 0 && zd1 != 0) ||
					(yd1 != 0 && zd1 != 0)) {
		if (xd1 == 0) {
			for (int j = 0; j <= 1; ++j) {
				for (int k = 0; k <= 1; ++k) {
					double yd = j*comdata.deltay - yd1;
					double zd = k*comdata.deltaz - zd1;
					charge[4*j + 2*k] = 1.0/fabs(yd*zd);
				}
			}
		} else if (yd1 == 0) {
			for (int i = 0; i <= 1; ++i) {
				for (int k = 0; k <= 1; ++k) {
					double xd = i*comdata.deltax - xd1;
					double zd = k*comdata.deltaz - zd1;
					charge[i + 4*k] = 1.0/fabs(xd*zd);
				}
			}
		} else if (zd1 == 0) {
			for (int i = 0; i <= 1; ++i){
				for (int j = 0; j <= 1; ++j){
					double xd = i*comdata.deltax - xd1;
					double yd = j*comdata.deltay - yd1;
					charge[i + 2*j] = 1.0/fabs(xd*yd);
				}
			}
		}
	} else if (xd1 != 0 || yd1 != 0 || zd1 != 0 ) {
		if (xd1 != 0) {
			charge[0] = 1.0/xd1;
			charge[1] = 1.0/(comdata.deltax-xd1);
		} else if (yd1 != 0) {
			charge[0] = 1.0/yd1;
			charge[2] = 1.0/(comdata.deltay-yd1);
		} else if (zd1 != 0) {
			charge[0] = 1.0/zd1;
			charge[4] = 1.0/(comdata.deltaz-zd1);
		}
	} else {
		charge[0] = 1.0;
	}

	charge=q_q*charge/charge.sum();

	for (size_t j = 1; j <= charget.ny(); ++j) {
		charget(iatm,j) = charge[j-1];
		for (size_t k = 1; k <= corlocqt.nz(); ++k) {
			corlocqt(iatm,j,k) = corlocq(j,k);
			loc_qt(iatm,j,k) = loc_q(j,k);

		}
	}
}
コード例 #18
0
ファイル: CryBaby.cpp プロジェクト: Dragonji/jaymod
CryBaby::CryBaby()
    : AbstractBuiltin( "crybaby" )
{
    __usage << xvalue( "!" + _name ) << ' ' << xvalue( "PLAYER" );
    __descr << "Make a player cry like a baby.";
}