Example #1
0
void BattleListTab::OnListJoin(wxListEvent& event)
{
	try {
		ASSERT_LOGIC(m_battle_list != 0, "m_battle_list = 0");
	} catch (...) {
		return;
	}
	if (event.GetIndex() < 0)
		return;

	int id = m_battle_list->GetSelectedData()->GetBattleId();
	DoJoin(serverSelector().GetServer().battles_iter->GetBattle(id));
}
Example #2
0
void BattleListTab::OnJoin( wxCommandEvent& /*unused*/ )
{
	try
	{
		ASSERT_LOGIC( m_battle_list != 0, _T( "m_battle_list = 0" ) );
	} catch ( ... ) {
		return;
	}

	if ( m_battle_list->GetSelectedIndex() < 0 ) return;

	int id = m_battle_list->GetSelectedData()->GetBattleId();
	DoJoin( serverSelector().GetServer().battles_iter->GetBattle( id ) );
}
Example #3
0
void BattleListTab::OnJoin(wxCommandEvent& /*unused*/)
{
	try {
		ASSERT_LOGIC(m_battle_list != 0, "m_battle_list = 0");
	} catch (...) {
		return;
	}

	if (m_battle_list->GetSelectedIndex() < 0)
		return;
	const IBattle* battle = m_battle_list->GetSelectedData();
	assert(battle != NULL);
	const int id = battle->GetBattleId();
	DoJoin(serverSelector().GetServer().battles_iter->GetBattle(id));
}
Example #4
0
int main(
    int argc,
    char* argv[]
    )
{
    LWException *exc = NULL;
    int columns;
    PSTR pszLogFilePath = NULL;
    BOOLEAN bNoLog = FALSE;
    PSTR logLevel = "warning";
    DWORD dwLogLevel;
    BOOLEAN showHelp = FALSE;
    BOOLEAN showInternalHelp = FALSE;
    int remainingArgs = argc;
    char **argPos = argv;
    int i;
    BOOLEAN directoryExists = FALSE;

    if(CTGetTerminalWidth(fileno(stdout), &columns))
        columns = -1;

    /* Skip the program name */
    argPos++;
    remainingArgs--;

    setlocale(LC_ALL, "");

    while(remainingArgs > 0 && CTStrStartsWith(argPos[0], "--"))
    {
        if(!strcmp(argPos[0], "--help"))
            showHelp = TRUE;
        else if(!strcmp(argPos[0], "--help-internal"))
            showInternalHelp = TRUE;
        else if(!strcmp(argPos[0], "--nolog"))
            bNoLog = TRUE;
        //All options after this point take an argument
        else if(remainingArgs < 2)
            showHelp = TRUE;
        else if(!strcmp(argPos[0], "--logfile"))
        {
            pszLogFilePath = (++argPos)[0];
            remainingArgs--;
        }
        else if(!strcmp(argPos[0], "--loglevel"))
        {
            logLevel = (++argPos)[0];
            remainingArgs--;
        }
        else
            break;
        remainingArgs--;
        argPos++;
    }

    if(remainingArgs < 1)
        showHelp = TRUE;

    if (showInternalHelp) {
        ShowUsageInternal();
        goto cleanup;
    }

    if (showHelp) {
        ShowUsage();
        goto cleanup;
    }

    if (!strcasecmp(logLevel, "error"))
    {
        dwLogLevel = LOG_LEVEL_ERROR;
        LwRtlLogSetLevel(LW_RTL_LOG_LEVEL_ERROR);
    }
    else if (!strcasecmp(logLevel, "warning"))
    {
        dwLogLevel = LOG_LEVEL_WARNING;
        LwRtlLogSetLevel(LW_RTL_LOG_LEVEL_WARNING);
    }
    else if (!strcasecmp(logLevel, "info"))
    {
        dwLogLevel = LOG_LEVEL_INFO;
        LwRtlLogSetLevel(LW_RTL_LOG_LEVEL_INFO);
    }
    else if (!strcasecmp(logLevel, "verbose"))
    {
        dwLogLevel = LOG_LEVEL_VERBOSE;
        LwRtlLogSetLevel(LW_RTL_LOG_LEVEL_VERBOSE);
    }
    else if (!strcasecmp(logLevel, "debug"))
    {
        dwLogLevel = LOG_LEVEL_VERBOSE;
        LwRtlLogSetLevel(LW_RTL_LOG_LEVEL_DEBUG);
    }
    else {
        LW_CLEANUP_CTERR(&exc, LW_ERROR_INVALID_LOG_LEVEL);
    }

    if (pszLogFilePath == NULL)
    {
        // Determine the default log path
        LW_CLEANUP_CTERR(&exc,
                CTCheckDirectoryExists("/var/log", &directoryExists));
        if (directoryExists)
        {
            pszLogFilePath = "/var/log/domainjoin-cli.log";
        }
        else
        {
            pszLogFilePath = "/var/adm/domainjoin-cli.log";
        }
    }

    if (bNoLog) {
        LW_CLEANUP_CTERR(&exc, dj_disable_logging());
    } else if (!strcmp(pszLogFilePath, ".")) {
        LW_CLEANUP_CTERR(&exc, dj_init_logging_to_console(dwLogLevel));
    } else {
        DWORD ceError = dj_init_logging_to_file(dwLogLevel, pszLogFilePath);
        if(ceError == ERROR_ACCESS_DENIED)
        {
            fprintf(stderr, "Warning: insufficient permissions to log to %s. To enable logging, please specify a different filename with --logfile <file>.\n",
                    pszLogFilePath);
            ceError = ERROR_SUCCESS;
            LW_CLEANUP_CTERR(&exc, dj_disable_logging());
        }
        else if (ceError == ERROR_FILE_NOT_FOUND)
        {
            fprintf(stderr, "Warning: parent directory of log file %s does not exist. To enable logging, please specify a different filename with --logfile <file>.\n",
                    pszLogFilePath);
            ceError = ERROR_SUCCESS;
            LW_CLEANUP_CTERR(&exc, dj_disable_logging());
        }
        LW_CLEANUP_CTERR(&exc, ceError);
    }
    LwRtlLogSetCallback(RtlLogCallback, NULL);

    if (!strcmp(argPos[0], "join") || !strcmp(argPos[0], "leave"))
    {
        DJ_LOG_INFO("Domainjoin invoked with the %s command (remaining arguments will be printed later):", argPos[0]);
        // Only print up to the 'join' part
        for (i = 0; i <= argPos - argv; i++)
        {
            DJ_LOG_INFO("    [%s]", argv[i]);
        }
    }
    else
    {
        DJ_LOG_INFO("Domainjoin invoked with %d arg(s):", argc);
        for (i = 0; i < argc; i++)
        {
            DJ_LOG_INFO("    [%s]", argv[i]);
        }
    }

    if(!strcmp(argPos[0], "setname"))
    {
        PSTR pDomainSuffix = 0;
        argPos++;
        if(--remainingArgs != 1)
        {
            ShowUsage();
            goto cleanup;
        }

        pDomainSuffix = strchr(argPos[0], '.');
        if (pDomainSuffix)
        {
            *pDomainSuffix = 0;
            pDomainSuffix++;
        }
        else
        {
            pDomainSuffix = "";
        }
        LW_TRY(&exc, DJSetComputerName(argPos[0], pDomainSuffix, &LW_EXC));
    }
    else if(!strcmp(argPos[0], "join"))
    {
        argPos++;
        remainingArgs--;
        LW_TRY(&exc, DoJoin(remainingArgs, argPos, columns, &LW_EXC));
    }
    else if(!strcmp(argPos[0], "leave"))
    {
        argPos++;
        remainingArgs--;
        LW_TRY(&exc, DoLeaveNew(remainingArgs, argPos, columns, &LW_EXC));
    }
    else if(!strcmp(argPos[0], "query"))
    {
        LW_TRY(&exc, DoQuery(&LW_EXC));
    }
    else if(!strcmp(argPos[0], "fixfqdn"))
        LW_TRY(&exc, DoFixFqdn(&LW_EXC));
#ifndef ENABLE_MINIMAL
    else if(!strcmp(argPos[0], "configure"))
    {
        argPos++;
        remainingArgs--;
        LW_TRY(&exc, DoConfigure(remainingArgs, argPos, &LW_EXC));
    }
#endif
    else if(!strcmp(argPos[0], "get_os_type") ||
        !strcmp(argPos[0], "get_arch") ||
        !strcmp(argPos[0], "get_distro") ||
        !strcmp(argPos[0], "get_distro_version"))
    {
        LW_TRY(&exc, DoGetDistroInfo(remainingArgs, argPos, &LW_EXC));
    }
    else
    {
        LW_RAISE(&exc, LW_ERROR_SHOW_USAGE);
        goto cleanup;
    }

cleanup:

    if (!LW_IS_OK(exc) && exc->code == LW_ERROR_SHOW_USAGE)
    {
        ShowUsage();
        LWHandle(&exc);
    }
    else if (!LW_IS_OK(exc))
    {
        //Ignoring the return value from this because we can't do anything
        //if there is an error
        fprintf(stdout, "\n");
        LWPrintException(stdout, exc, FALSE);
        DJLogException(LOG_LEVEL_ERROR, exc);
        LWHandle(&exc);
        dj_close_log();
        return 1;
    }

    dj_close_log();

    return 0;
}
void Path::DoStroke(int off, int N, Shape *dest, bool doClose, double width, JoinType join,
		    ButtType butt, double miter, bool /*justAdd*/)
{
    if (N <= 1) {
        return;
    }

    Geom::Point prevP, nextP;
    int prevI, nextI;
    int upTo;

    int curI = 0;
    Geom::Point curP = pts[off].p;

    if (doClose) {

        prevI = N - 1;
        while (prevI > 0) {
            prevP = pts[off + prevI].p;
            Geom::Point diff = curP - prevP;
            double dist = dot(diff, diff);
            if (dist > 0.001) {
                break;
            }
            prevI--;
        }
        if (prevI <= 0) {
            return;
        }
        upTo = prevI;

    } else {

        prevP = curP;
        prevI = curI;
        upTo = N - 1;
    }

    {
        nextI = 1;
        while (nextI <= upTo) {
            nextP = pts[off + nextI].p;
            Geom::Point diff = curP - nextP;
            double dist = dot(diff, diff);
            if (dist > 0.0) { // more tolerance for the first distance, to give the cap the right direction
                break;
            }
            nextI++;
        }
        if (nextI > upTo) {
            if (butt == butt_round) {  // special case: zero length round butt is a circle
                int last[2] = { -1, -1 };
                Geom::Point dir;
                dir[0] = 1;
                dir[1] = 0;
                DoButt(dest, width, butt, curP, dir, last[RIGHT], last[LEFT]);
                int end[2];
                dir = -dir;
                DoButt(dest, width, butt, curP, dir, end[LEFT], end[RIGHT]);
                dest->AddEdge (end[LEFT], last[LEFT]);
                dest->AddEdge (last[RIGHT], end[RIGHT]);
            }
            return;
        }
    }

    int start[2] = { -1, -1 };
    int last[2] = { -1, -1 };
    Geom::Point prevD = curP - prevP;
    Geom::Point nextD = nextP - curP;
    double prevLe = Geom::L2(prevD);
    double nextLe = Geom::L2(nextD);
    prevD = StrokeNormalize(prevD, prevLe);
    nextD = StrokeNormalize(nextD, nextLe);

    if (doClose) {
        DoJoin(dest,  width, join, curP, prevD, nextD, miter, prevLe, nextLe, start, last);
    } else {
        nextD = -nextD;
        DoButt(dest,  width, butt, curP, nextD, last[RIGHT], last[LEFT]);
        nextD = -nextD;
    }

    do {
        prevP = curP;
        prevI = curI;
        curP = nextP;
        curI = nextI;
        prevD = nextD;
        prevLe = nextLe;
        nextI++;
        while (nextI <= upTo) {
            nextP = pts[off + nextI].p;
            Geom::Point diff = curP - nextP;
            double dist = dot(diff, diff);
            if (dist > 0.001 || (nextI == upTo && dist > 0.0)) { // more tolerance for the last distance too, for the right cap direction
                break;
            }
            nextI++;
        }
        if (nextI > upTo) {
            break;
        }

        nextD = nextP - curP;
        nextLe = Geom::L2(nextD);
        nextD = StrokeNormalize(nextD, nextLe);
        int nSt[2] = { -1, -1 };
        int nEn[2] = { -1, -1 };
        DoJoin(dest, width, join, curP, prevD, nextD, miter, prevLe, nextLe, nSt, nEn);
        dest->AddEdge(nSt[LEFT], last[LEFT]);
        last[LEFT] = nEn[LEFT];
        dest->AddEdge(last[RIGHT], nSt[RIGHT]);
        last[RIGHT] = nEn[RIGHT];
    } while (nextI <= upTo);

    if (doClose) {
        /*		prevP=curP;
                        prevI=curI;
                        curP=nextP;
                        curI=nextI;
                        prevD=nextD;*/
        nextP = pts[off].p;

        nextD = nextP - curP;
        nextLe = Geom::L2(nextD);
        nextD = StrokeNormalize(nextD, nextLe);
        int nSt[2] = { -1, -1 };
        int nEn[2] = { -1, -1 };
        DoJoin(dest,  width, join, curP, prevD, nextD, miter, prevLe, nextLe, nSt, nEn);
        dest->AddEdge (nSt[LEFT], last[LEFT]);
        last[LEFT] = nEn[LEFT];
        dest->AddEdge (last[RIGHT], nSt[RIGHT]);
        last[RIGHT] = nEn[RIGHT];

        dest->AddEdge (start[LEFT], last[LEFT]);
        dest->AddEdge (last[RIGHT], start[RIGHT]);

    } else {

        int end[2];
        DoButt (dest,  width, butt, curP, prevD, end[LEFT], end[RIGHT]);
        dest->AddEdge (end[LEFT], last[LEFT]);
        dest->AddEdge (last[RIGHT], end[RIGHT]);
    }
}