Exemple #1
0
/** 
* Initialisation. Called from all constructors.
*/
void RS_Entity::init() {
    resetBorders();

	setFlags(RS2::FlagVisible);
	//
	//
	updateEnabled = true;
	setLayerToActive();
	initId();
}
Exemple #2
0
/**
 * Initialisation. Called from all constructors.
 */
void RS_Entity::init() {
    resetBorders();

    setFlag(RS2::FlagVisible);
    //layer = NULL;
    //pen = RS_Pen();
	updateEnabled = true;
    setLayerToActive();
    setPenToActive();
    initId();
}
Exemple #3
0
static void init()
{
    struct sigaction sigactionUSR, sigactionCHLD;
    //associer le signal SIGCHLD a son handler
    sigactionCHLD.sa_sigaction = &sigChldHandler;
    sigemptyset(&(sigactionCHLD.sa_mask));
    sigactionCHLD.sa_flags = SA_SIGINFO;
    sigaction(SIGCHLD, &sigactionCHLD, NULL);
    //associer le signal SIGUSR2 a son handler
    sigactionUSR.sa_handler = &sigUsr2Handler;
    sigemptyset(&(sigactionUSR.sa_mask));
    sigaddset(&(sigactionUSR.sa_mask), SIGCHLD);
    // on recoit SIGUSR2 une seule fois avant destruction de ce processus
    sigactionUSR.sa_flags = SA_RESETHAND;
    sigaction(SIGUSR2, &sigactionUSR, NULL);
    //initialistion des ID des resources partagees
    initId();
    //attachement des memoires partagees
    attachSharedMemory();
}
void main()
{
  mode = MODE_LEGACY;

  //Init the chip ID
  initId();
  //Init the led and set the leds until the usb is not ready
#ifndef CRPA
  ledInit(CR_LED_RED, CR_LED_GREEN);
#else
  ledInit(CRPA_LED_RED, CRPA_LED_GREEN);
#endif
  ledSet(LED_GREEN | LED_RED, true);

  // Initialise the radio
#ifdef CRPA
    // Enable LNA (PA RX)
    P0DIR &= ~(1<<CRPA_PA_RXEN);
    P0 |= (1<<CRPA_PA_RXEN);
#endif
  radioInit(RADIO_MODE_PTX);
#ifdef PPM_JOYSTICK
  // Initialise the PPM acquisition
  ppmInit();
#endif //PPM_JOYSTICK
  // Initialise and connect the USB
  usbInit();

  //Globally activate the interruptions
  IEN0 |= 0x80;

  //Wait for the USB to be addressed
  while (usbGetState() != ADDRESS);

  //Reset the LEDs
  ledSet(LED_GREEN | LED_RED, false);

  //Wait for the USB to be ready
  while (usbGetState() != CONFIGURED);

  //Activate OUT1
  OUT1BC=0xFF;

  while(1)
  {
    if (mode == MODE_LEGACY)
    {
      // Run legacy mode
      legacyRun();
    }
    else if (mode == MODE_CMD)
    {
      // Run cmd mode
      cmdRun();
    }
    else if (mode == MODE_PRX)
    {
      // Run PRX mode
      prxRun();
    }

    //USB vendor setup handling
    if(usbIsVendorSetup())
      handleUsbVendorSetup();
  }
}
void CharacterManager::LoadDemoCharacters()
{
	auto statMgr( StatManager::Instance().lock() );
	assert(statMgr);

	const int	initId  = statMgr->initId();
	const int	spotId	= statMgr->spotId();
	const int	listenId= statMgr->listenId();
	const int	willId	= statMgr->willId();
	const int	levelId	= statMgr->levelId();

	Combatant::Character::pointer_t ch( new Combatant::Character() );
	ch->name( "Errol" );
	ch->monster( false );
	ch->baseHP( 36 );
	ch->setMod( initId, 4 );
	ch->setMod( spotId, 2 );
	ch->setMod( listenId, 1 );
	ch->setMod( willId, 4 );
	ch->setMod( levelId, 5 );
	f_chars.push_back( ch );
	//
	ch.reset( new Combatant::Character() );
	ch->name( "Stubs" );
	ch->monster( false );
	ch->baseHP( 45 );
	ch->setMod( initId, 1 );
	ch->setMod( spotId, -1 );
	ch->setMod( listenId, -1 );
	ch->setMod( willId, 5 );
	ch->setMod( levelId, 5 );
	Effects::Effect::pointer_t effect( new Effects::Effect );
	effect->name( "Bull Strength" );
	effect->description( "Gives a +4 to strength" );
	effect->totalRounds( 110 );
	ch->addEffect( effect );
	f_chars.push_back( ch );
	//
	ch.reset( new Combatant::Character() );
	ch->name( "Ariel" );
	ch->monster( false );
	ch->baseHP( 24 );
	ch->setMod( initId, 1 );
	ch->setMod( spotId, 1 );
	ch->setMod( listenId, 1 );
	ch->setMod( willId, 4 );
	ch->setMod( levelId, 5 );
	f_chars.push_back( ch );
	//
	ch.reset( new Combatant::Character() );
	ch->name( "K the Knife" );
	ch->monster( false );
	ch->baseHP( 37 );
	ch->setMod( initId, 4 );
	ch->setMod( spotId, 4 );
	ch->setMod( listenId, 4 );
	ch->setMod( willId, 6 );
	ch->setMod( levelId, 5 );
	f_chars.push_back( ch );
	//
	ch.reset( new Combatant::Character() );
	ch->name( "Sinclair" );
	ch->monster( true );
	ch->baseHP( 35 );
	ch->setMod( initId, 4 );
	ch->setMod( spotId, 2 );
	ch->setMod( listenId, 2 );
	ch->setMod( willId, 8 );
	ch->setMod( levelId, 5 );
	f_chars.push_back( ch );
	//
	ch.reset( new Combatant::Character() );
	ch->name( "Dench" );
	ch->monster( true );
	ch->baseHP( 90 );
	ch->setMod( initId, 3 );
	ch->setMod( spotId, 1 );
	ch->setMod( listenId, 1 );
	ch->setMod( willId, 6 );
	ch->setMod( levelId, 5 );
	f_chars.push_back( ch );
}
StubChainAdaptor::StubChainAdaptor(QObject* parent)
    : QObject(parent)
{
    auto orphanage = message.getOrphanage();
    auto coinOrphan = orphanage.newOrphan<Coin>();
    auto coin = coinOrphan.get();
    coin.setName("BTS");
    coin.setId(0);
    coin.setPrecision(5);
    coins.emplace_back(kj::mv(coinOrphan));

    coinOrphan = orphanage.newOrphan<Coin>();
    coin = coinOrphan.get();
    coin.setName("FMV");
    coin.setId(1);
    coin.setPrecision(0);
    coins.emplace_back(kj::mv(coinOrphan));

    coinOrphan = orphanage.newOrphan<Coin>();
    coin = coinOrphan.get();
    coin.setName("USD");
    coin.setId(2);
    coin.setPrecision(2);
    coins.emplace_back(kj::mv(coinOrphan));

    std::reference_wrapper<std::vector<capnp::Orphan<Balance>>> bals = balances["nathan"];
    auto balanceOrphan = orphanage.newOrphan<Balance>();
    auto balance = balanceOrphan.get();
    balance.setAmount(50000000);
    balance.initId(1)[0] = 0;
    balance.setType(0);
    bals.get().emplace_back(kj::mv(balanceOrphan));

    balanceOrphan = orphanage.newOrphan<Balance>();
    balance = balanceOrphan.get();
    balance.setAmount(10);
    balance.initId(1)[0] = 1;
    balance.setType(1);
    bals.get().emplace_back(kj::mv(balanceOrphan));

    balanceOrphan = orphanage.newOrphan<Balance>();
    balance = balanceOrphan.get();
    balance.setAmount(5000);
    balance.initId(1)[0] = 2;
    balance.setType(2);
    bals.get().emplace_back(kj::mv(balanceOrphan));

    bals = balances["dev.nathanhourt.com"];

    balanceOrphan = orphanage.newOrphan<Balance>();
    balance = balanceOrphan.get();
    balance.setAmount(10000000);
    balance.initId(1)[0] = 3;
    balance.setType(0);
    bals.get().emplace_back(kj::mv(balanceOrphan));

    bals = balances["adam"];

    balanceOrphan = orphanage.newOrphan<Balance>();
    balance = balanceOrphan.get();
    balance.setAmount(88);
    balance.initId(1)[0] = 4;
    balance.setType(1);
    bals.get().emplace_back(kj::mv(balanceOrphan));

    auto contestOrphan = orphanage.newOrphan<Contest>();
    auto contest = contestOrphan.get();
    auto ucontest = contest.getContest();
    contest.initSignature(0);
    ucontest.initId(1)[0] = 0;
    ucontest.setCoin(1);
    ucontest.setName("Lunch poll");
    ucontest.setDescription("Where should we go for lunch?");
    ucontest.setStartTime(static_cast<uint64_t>(QDateTime::fromString("2015-09-20T12:00:00",
                                                                      Qt::ISODate).toMSecsSinceEpoch()));
    auto tags = ucontest.initTags(1);
    tags[0].setKey("category");
    tags[0].setValue("food");
    auto contestants = ucontest.initContestants(3);
    contestants[0].setName("Wikiteria");
    contestants[0].setDescription("Cafeteria on the CRC campus");
    contestants[1].setName("Wicked Taco");
    contestants[1].setDescription("Restaurant on Prices Fork");
    contestants[2].setName("Firehouse");
    contestants[2].setDescription("Sub Shop on University City Blvd");
    contests.emplace_back(kj::mv(contestOrphan));

    contestOrphan = orphanage.newOrphan<Contest>();
    contest = contestOrphan.get();
    ucontest = contest.getContest();
    contest.initSignature(0);
    ucontest.initId(1)[0] = 1;
    ucontest.setCoin(0);
    ucontest.setName("Upgrade Authorization");
    ucontest.setDescription("Do the BitShares stakeholders accept the upgrade to version 2.0, "
                            "using the Graphene Toolkit?");
    ucontest.setStartTime(static_cast<uint64_t>(QDateTime::fromString("2015-09-11T12:00:00",
                                                                      Qt::ISODate).toMSecsSinceEpoch()));
    tags = ucontest.initTags(1);
    tags[0].setKey("category");
    tags[0].setValue("hard-forks");
    contestants = ucontest.initContestants(2);
    contestants[0].setName("Yes");
    contestants[0].setDescription("Accept the upgrade, and hard-fork to BitShares 2.0");
    contestants[1].setName("No");
    contestants[1].setDescription("Reject the upgrade, and continue using BitShares 0.9.x");
    contests.emplace_back(kj::mv(contestOrphan));
}
Exemple #7
0
void Stat::Load( moPropBagRef& propBag )
{
    moPropStringRef id               ( f_idName               );
    moPropStringRef abilityId        ( f_abilityIdName        );
    moPropIntRef    legacyId         ( f_legacyIdName         );
    moPropIntRef    legacyType       ( f_legacyTypeName       );
    moPropStringRef name             ( f_nameName             );
    moPropIntRef    dice             ( f_diceName             );
    moPropIntRef    faces            ( f_facesName            );
    moPropIntRef    modifier         ( f_modifierName         );
    moPropIntRef    deleted          ( f_deletedName          );
    moPropStringRef accel            ( f_accelName            );
    moPropIntRef    showOnToolbar    ( f_showOnToolbarName    );
    moPropIntRef    showOnHUD        ( f_showOnHUDName        );
    moPropIntRef    showMonsterOnHUD ( f_showMonsterOnHUDName );
    moPropIntRef    internal         ( f_internalName         );
    moPropIntRef    ability          ( f_abilityName          );
    moPropIntRef    order            ( f_orderName            );

    id       			.Link( propBag );
    abilityId			.Link( propBag );
    legacyId 			.Link( propBag );
    legacyType			.Link( propBag );
    name     			.Link( propBag );
    dice     			.Link( propBag );
    faces    			.Link( propBag );
    modifier 			.Link( propBag );
    deleted  			.Link( propBag );
    accel    			.Link( propBag );
    showOnToolbar		.Link( propBag );
    showOnHUD			.Link( propBag );
    showMonsterOnHUD	.Link( propBag );
    internal			.Link( propBag );
    ability				.Link( propBag );
    order				.Link( propBag );

    if( id.HasProp() )
    {
        f_id 			= moName( static_cast<moWCString>(id) );
    }
    else if( legacyId.HasProp() && legacyType.HasProp() )
    {
        f_legacyId 		= legacyId;
        f_legacyType	= legacyType;
    }
    else
    {
        throw moError( "Bad Stat data for object!" );
    }

    if( abilityId.HasProp() )
    {
        f_abilityId = moName( static_cast<moWCString>(abilityId) );
    }
    else
    {
        f_abilityId = moName( "UNNAMED" );
    }

    f_name     = static_cast<moWCString>(name).c_str();
    f_dice     = dice;
    f_faces    = faces;
    f_modifier = modifier;
    f_deleted  = deleted? true: false;
    //
    if( showMonsterOnHUD.HasProp() && showOnToolbar.HasProp() && showOnHUD.HasProp() )
    {
        f_showOnToolbar		= showOnToolbar? true: false;
        f_showOnHUD			= showOnHUD? true: false;
        f_showMonsterOnHUD	= showMonsterOnHUD? true: false;
    }
    //
    if( accel.HasProp() )
    {
        // This is a bug in moProps--if a blank string, then we should have a property
        //
        f_accel = static_cast<moWCString>(accel).c_str();
    }

    if( internal.HasProp() ) f_internal = internal;
    if( ability.HasProp()  ) f_ability  = ability;
    if( order.HasProp()    ) f_order    = order;

    if( f_legacyId != -1 )
    {
        f_showMonsterOnHUD = f_showOnToolbar = f_showOnHUD = f_internal = f_ability = false;

        auto statMgr = StatManager::Instance().lock();
        assert(statMgr);

        // We must assign the custom stat value for later editing in the StatEditor.
        // The idea is that certain stats are fixed, immutable, but others, like
        // Spot/Listen/Will are custom, plus new stats are also.
        //
        if( f_name == "Spot" 		) {
            f_id = statMgr->spotId();
            f_showOnToolbar = true;
            f_accel = "s";
        }
        else if( f_name == "Listen"		) {
            f_id = statMgr->listenId();
            f_showOnToolbar = true;
            f_accel = "l";
        }
        else if( f_name == "Will"		) {
            f_id = statMgr->willId();
            f_showOnToolbar = true;
            f_accel = "w";
        }
        else if( f_name == "Init"  		) {
            f_id = statMgr->initId();
            f_internal = true;
        }
        else if( f_name == "Hit Points"	) {
            f_id = statMgr->hpId();
            f_internal = true;
        }
        else if( f_name == "Level" 		) {
            f_id = statMgr->levelId();
            f_internal = true;
        }

#ifdef DEBUG
        std::cerr	<< "Legacy Id: " 	 << f_legacyId
                    << ", Legacy Type: " << f_legacyType
                    << ", ID name= " 	 << f_name.c_str()
                    << ", NEW ID=" 		 << moWCString(moName(f_id)).c_str()
                    << std::endl;
#endif
    }

    f_statChanged.emit();
}