Ejemplo n.º 1
0
void WBSDCalibrateCanisterwindow::reload(int aSpeed){
	theSpeed=aSpeed;
    _isdone = false;
	if (theSpeed==1){
		ParameterMsg msg1(Message::MCB,Message::AP,24);
        msg1.getFloat();
		itsBaseWindow->addMessageToQue(msg1);
   } else if (theSpeed==2){
		ParameterMsg msg1(Message::MCB,Message::AP,25);
        msg1.getFloat();
		itsBaseWindow->addMessageToQue(msg1);
   } else {
		ParameterMsg msg1(Message::MCB,Message::AP,26);
        msg1.getFloat();
		itsBaseWindow->addMessageToQue(msg1);
   }



    ParameterMsg gmsg1(Message::MCB,Message::DV,ParameterMsg::SET_PARAMETER);
	gmsg1.setNibble(0,theSpeed);
	itsBaseWindow->addMessageToQue(gmsg1);
	updateData();

}
Ejemplo n.º 2
0
static int mainloop(const struct command* commands)
{
  if (!respond_line(220, 1, str_welcome.s, str_welcome.len)) return 0;
  while (ibuf_getstr_crlf(&inbuf, &line))
    if (!smtp_dispatch(commands)) {
      if (ibuf_eof(&inbuf))
	msg1("Connection dropped");
      if (ibuf_timedout(&inbuf))
	msg1("Timed out");
      return 1;
    }
  return 0;
}
	bool PhysicsEngine::update(float deltaTime){
		_world->stepSimulation(deltaTime, 60);

		//iterate across the contacts map
		for(auto contactsIter = contacts.begin(); contactsIter!=contacts.end(); ++contactsIter){
			//get the entity key from  teh current entry in the map
			Entity* collider0 = contactsIter->first;
			//get the set of colliders from the current entry in the map
			std::set<Entity*>& set = contactsIter->second;
			//iterate thru all the entities in the set
			for(auto entityIter = set.begin(); entityIter!=set.end(); ++entityIter){
				// get the other colider from the iterator
				Entity* collider1 = *entityIter;
				//create 2 messages - one for collider and one for the entity being hit
				Message msg1(collider0, "COLLISION", collider1);
				Message msg2(collider1, "COLLISION", collider0);
				//dispatch teh messages
				MessageHandler::sendMessage(msg1);
				MessageHandler::sendMessage(msg2);
			}
		}
		//empty the contacts map ready for next time
		contacts.clear();

		//for now
		return true;
	}
Ejemplo n.º 4
0
  TEST(Serialization, WriteBitsHard)
  {
    QByteArray msg1(2, 'a');
    QBitArray bits1(12, true);

    Serialization::WriteBitArray(bits1, msg1, 0);
    EXPECT_EQ((char)0xFF, (char)msg1[0]);
    EXPECT_EQ((char)0x0F, (char)msg1[1]);

    bits1.setBit(0, false);
    Serialization::WriteBitArray(bits1, msg1, 0);
    EXPECT_EQ((char)0x7F, (char)msg1[0]);
    EXPECT_EQ((char)0x0F, (char)msg1[1]);

    bits1.setBit(11, false);
    Serialization::WriteBitArray(bits1, msg1, 0);
    EXPECT_EQ((char)0x7F, (char)msg1[0]);
    EXPECT_EQ((char)0x0E, (char)msg1[1]);

    QByteArray msg2(3, 'b');
    Serialization::WriteBitArray(bits1, msg2, 1);
    EXPECT_EQ((char)'b', (char)msg2[0]);
    EXPECT_EQ((char)0x7F, (char)msg2[1]);
    EXPECT_EQ((char)0x0E, (char)msg2[2]);
  }
Ejemplo n.º 5
0
void
raw_sender(zmq::socket_t& s)
{
  for (size_t i = 0; i < ITERS; ++i)
  {
    zmq::message_t msg1(ARRAY_LEN(PART1)-1);
    memcpy(msg1.data(), PART1, msg1.size());
    s.send(msg1, ZMQ_SNDMORE);

    zmq::message_t msg2(ARRAY_LEN(PART2)-1);
    memcpy(msg2.data(), PART2, msg2.size());
    s.send(msg2, ZMQ_SNDMORE);

    zmq::message_t msg3(ARRAY_LEN(PART3)-1);
    memcpy(msg3.data(), PART3, msg3.size());
    s.send(msg3);

    zmq::message_t msg_res;
    s.recv(&msg_res, 0);

    if (i % 1000 == 0)
    {
      std::cout << ".";
      std::cout.flush();
    }
  }
}
void CGT_CDiagMsg::sysErr(
    HRESULT          hr, 
    const CG_Edipos* pEdp, 
    const TCHAR*     pszHint,
    const TCHAR*      pszHint2
)
{
    FC_CString jot(MAX_PATH);
    FC_CString jot2;

    if(pszHint)
    {
        jot<<_T("'")<<pszHint;

        if(pszHint2)
            jot<<pszHint2;
            
        jot<<_T("' ");
    }

    jot.appendWsprintf(_T("returned 0x%x: "), hr);
    jot2.fmtSysErr(hr);
    jot<<jot2;
    msg1(CG_E_COM_ERROR, pEdp, jot);
}
Ejemplo n.º 7
0
void CollationRegressionTest::assertEqual(CollationElementIterator &i1, CollationElementIterator &i2)
{
    int32_t c1, c2, count = 0;
    UErrorCode status = U_ZERO_ERROR;

    do
    {
        c1 = i1.next(status);
        c2 = i2.next(status);

        if (c1 != c2)
        {
            UnicodeString msg, msg1("    ");

            msg += msg1 + count;
            msg += ": strength(0x";
            appendHex(c1, 8, msg);
            msg += ") != strength(0x";
            appendHex(c2, 8, msg);
            msg += ")";

            errln(msg);
            break;
        }

        count += 1;
    }
    while (c1 != CollationElementIterator::NULLORDER);
}
Ejemplo n.º 8
0
bool CTrueTalkNPC::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *msg) {
	_npcFlags |= NPCFLAG_SPEAKING;
	++_field100;

	if (!(_npcFlags & NPCFLAG_8)) {
		if (_speechTimerId)
			stopTimer(_speechTimerId);

		_soundId = msg->_soundId;
		_fieldF0 = getTicksCount();

		if (hasActiveMovie() || (_npcFlags & NPCFLAG_2)) {
			_npcFlags &= ~NPCFLAG_2;
			stopMovie();

			CNPCPlayTalkingAnimationMsg msg1(_soundId, 0, 0);
			msg1.execute(this);

			if (msg1._names) {
				CNPCPlayAnimationMsg msg2(msg1._names, msg1._value1);
				msg2.execute(this);
			}
		}
	}

	return true;
}
Ejemplo n.º 9
0
static const response* message_end(int fd)
{
  struct stat st;
  char buf[1024];
  long rd;
  char* lf;
  char* ptr;

  if (fd >= 0) {
    /* Log the first two lines of the message, usually a Received: header */
    lseek(fd, 0, SEEK_SET);
    rd = read(fd, buf, sizeof buf - 1);
    buf[rd] = 0;
    if ((lf = strchr(buf, LF)) != 0) {
      str_copyb(&tmp, buf, lf-buf);
      ptr = lf + 1;
      if ((lf = strchr(ptr, LF)) != 0)
	str_catb(&tmp, ptr, lf-ptr);
      msg1(tmp.s);
    }

    fstat(fd, &st);
    databytes = st.st_size;
  }

  str_copys(&tmp, "Received ");
  str_catu(&tmp, databytes);
  str_cats(&tmp, " bytes.");
  resp.message = tmp.s;
  return &resp;
  (void)fd;
}
Ejemplo n.º 10
0
bool CTrueTalkNPC::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *msg) {
	debugC(ERROR_DETAILED, kDebugScripts, "%s TrueTalkNotifySpeechStartedMsg flags=%x dialogueId=%d",
		getName().c_str(), _npcFlags, msg->_dialogueId);

	_npcFlags |= NPCFLAG_SPEAKING;
	++_speechCounter;

	if (!(_npcFlags & NPCFLAG_8)) {
		// Stop any previous animation
		if (_speechTimerId)
			stopAnimTimer(_speechTimerId);
		_speechTimerId = 0;

		_speechDuration = msg->_speechDuration;
		_startTicks = getTicksCount();

		if (!hasActiveMovie() || (_npcFlags & NPCFLAG_IDLING)) {
			_npcFlags &= ~NPCFLAG_IDLING;
			stopMovie();

			CNPCPlayTalkingAnimationMsg msg1(_speechDuration, 0, nullptr);
			msg1.execute(this);

			if (msg1._names) {
				CNPCPlayAnimationMsg msg2(msg1._names, msg1._speechDuration);
				msg2.execute(this);
			}
		}
	}

	return true;
}
Ejemplo n.º 11
0
int main(int argc, char* argv[])
{
  const char* ip;
  const char* tmp;
  
  if (argc < 2) die1(1, "usage: relay-ctrl-check program [arguments]\n");
  log_ips = getenv("RELAY_CTRL_LOG_IPS") != 0;
  log_env = getenv("RELAY_CTRL_LOG_ENV") != 0;
  if (getenv("RELAYCLIENT") == 0) {
    expiry = 0;
    if ((tmp = getenv("RELAY_CTRL_EXPIRY")) != 0) expiry = atol(tmp);
    if (expiry <= 0) expiry = 900;
    if ((rc = getenv("RELAY_CTRL_RELAYCLIENT")) == 0) rc = "";
    if ((ip = getenv("TCPREMOTEIP")) == 0)
      warn1("$TCPREMOTEIP not set, not checking IP");
    else if (do_chdir(0))
      stat_ip(ip);
  }
  else {
    if (log_ips)
      msg1("$RELAYCLIENT already set, not checking IP");
  }
  execvp(argv[1], argv+1);
  die1(111, "execution of program failed!\n");
  return 111;
  argc = 0;
}
Ejemplo n.º 12
0
void WBSDCalibrateCanisterwindow::updateData()
{
    qDebug() << "WBSDInstantWindow::updateData";
    ParameterMsg msg1(Message::MCB,Message::DV,17);
	msg1.getWord();
    itsBaseWindow->addMessageToQue(msg1);
}
Ejemplo n.º 13
0
bool CPlayGameVorticon::init()
{
	CVorticonMapLoaderWithPlayer MapLoader( mMap, m_Player, mSpriteObjectContainer );
	MapLoader.m_checkpointset = m_checkpointset;

	// load level map
	if( !MapLoader.load( m_Episode, m_Level, m_Gamepath ) ) return false;
	gpSaveGameController->setLevel(m_Level);

	//// If those worked fine, continue the initialization
	// draw level map
	mMap->drawAll();

	// Now Scroll to the position of the player and center him
	mMap->gotoPos( 32, 64 ); // Assure that the edges are never seen

	setupPlayers();

	// Well, all players are living because they were newly spawn.
	g_pTimer->ResetSecondsTimer();

	g_pInput->flushAll();

	// Initialize the AI
	mpObjectAI.reset( new CVorticonSpriteObjectAI(mMap.get(), mSpriteObjectContainer, m_Player,
			m_NumPlayers, m_Episode, m_Level,
			mMap->m_Dark) );

	// Check if Player meets the conditions to show a cutscene. This also happens, when finale of episode has reached
	verifyFinales();

	// When Level starts it's never dark!
	g_pGfxEngine->Palette.setdark(false);

	if(m_level_command == GOTO_FINALE)
		createFinale();
	else
		if(m_showKeensLeft)	g_pSound->playSound(SOUND_KEENSLEFT, PLAY_NOW);

	// In the case that we are in Episode 3 last Level, show Mortimer Messages
	if( m_Episode == 3 && m_Level == 16 )
	{
	    std::unique_ptr<CMessageBoxVort> msg1(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER"),false, true));
	    std::unique_ptr<CMessageBoxVort> msg2(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER2"),false, true));
	    std::unique_ptr<CMessageBoxVort> msg3(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER3"),false, true));
	    std::unique_ptr<CMessageBoxVort> msg4(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER4"),false, true));
	    std::unique_ptr<CMessageBoxVort> msg5(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER5"),false, true));
	    std::unique_ptr<CMessageBoxVort> msg6(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER6"),false, true));
	    mMessageBoxes.push_back(move(msg1));
	    mMessageBoxes.push_back(move(msg2));
	    mMessageBoxes.push_back(move(msg3));
	    mMessageBoxes.push_back(move(msg4));
	    mMessageBoxes.push_back(move(msg5));
	    mMessageBoxes.push_back(move(msg6));
	    g_pSound->playSound(SOUND_MORTIMER);
	}

	return true;
}
Ejemplo n.º 14
0
void usage(const char* msg)
{
  if(msg)
    msg1(msg);
  obuf_putf(&errbuf, usage_str, program, usage_args, usage_post);
  obuf_flush(&errbuf);
  exit(111);
}
Ejemplo n.º 15
0
void SpinoffDragAndDrop::TouchesEnded(const std::vector<cocos2d::Touch *> &touches, cocos2d::Event *event)
{
	if (!_isEnabled) {
		return;
	}

	if (_state == State::DRAG)
	{
		Vector2 touch_world = touches[0]->getLocation();
		Vector2 touch_local = convertToNodeSpace(touch_world);

		_texture->SetCurrentImage("normal");
		_state = State::DROP;
		_isEnabled = false;
		event->stopPropagation();

		float create_cell = false;

		TownMapWidget *town_widget = _worldMapLayer->GetNearestTownWidget(touch_world, _attractionDist);
		if (town_widget) {
			Town::WeakPtr town_ptr = town_widget->GetTown();
			if (!town_ptr.lock()->IsCellPresented()) {
				create_cell = true;
			}
		}

		if (create_cell)
		{
			Message msg1("CreateCell");
			msg1.variables.SetString("TOWN_NAME", town_widget->GetTown()->GetName());
			msg1.variables.SetInt("PARENT_UID", _cellFrom.lock()->GetUid());
			MessageManager::Instance().PutMessage(msg1);

			Message msg2 = Message("SpinoffWithDragEnded");
			msg2.variables.SetBool("SHOW_TOWNS", false);
			MessageManager::Instance().PutMessage(msg2);
		}
		else
		{
			cocos2d::CallFunc *func_end = cocos2d::CallFunc::create([&]()
			{
				Message msg = Message("SpinoffWithDragEnded");
				msg.variables.SetBool("SHOW_TOWNS", false);
				MessageManager::Instance().PutMessage(msg);
			});
			
			cocos2d::MoveTo *move = cocos2d::MoveTo::create(0.2f, convertToNodeSpace(getParent()->getPosition()));
			cocos2d::ScaleTo *scale = cocos2d::ScaleTo::create(0.2f, 0.5f, 0.5f, 1.0f);
			cocos2d::FadeOut *fade = cocos2d::FadeOut::create(0.2f);
			cocos2d::Spawn *stage = cocos2d::Spawn::create(move, scale, fade, nullptr);
			cocos2d::Sequence *seq = cocos2d::Sequence::create(stage, func_end, nullptr);

			_texture->stopAllActions();
			_texture->runAction(seq);
			_strip->runAction(fade);
		}
	}
}
Ejemplo n.º 16
0
void report_io_bytes(void)
{
  static str tmp;
  if (str_copys(&tmp, "bytes in: ") &&
      str_catu(&tmp, inbuf.io.offset) &&
      str_cats(&tmp, " bytes out: ") &&
      str_catu(&tmp, outbuf.io.offset))
    msg1(tmp.s);
}
Ejemplo n.º 17
0
BOOST_FIXTURE_TEST_CASE(can_read_payload, F)
{
  logsvc::prot::Message msg0(13);
  msg0.read_payload(std::string("\x56\x34\0\0a message", 13));
  BOOST_CHECK_EQUAL("a message", msg0.get_message());
  BOOST_CHECK(logsvc::prot::FileHandle(0x3456) == msg0.get_filehandle());

  logsvc::prot::Message msg1(9);
  msg1.read_payload(std::string("\x67\x45\0\0stuff", 9));
  BOOST_CHECK_EQUAL("stuff", msg1.get_message());
  BOOST_CHECK(logsvc::prot::FileHandle(0x4567) == msg1.get_filehandle());
}
Ejemplo n.º 18
0
bool CTrueTalkNPC::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) {
	_npcFlags &= ~NPCFLAG_SPEAKING;
	--_field100;
	_soundId = 0;

	if (!(_npcFlags & NPCFLAG_8)) {
		CNPCPlayTalkingAnimationMsg msg1(0, 2, 0);
		msg1.execute(this);
		CNPCQueueIdleAnimMsg msg2;
		msg2.execute(this);
	}

	return true;
}
Ejemplo n.º 19
0
void CollationIteratorTest::TestOffset(/* char* par */)
{
    CollationElementIterator *iter = en_us->createCollationElementIterator(test1);
    UErrorCode status = U_ZERO_ERROR;
    // testing boundaries
    iter->setOffset(0, status);
    if (U_FAILURE(status) || iter->previous(status) != UCOL_NULLORDER) {
        errln("Error: After setting offset to 0, we should be at the end "
                "of the backwards iteration");
    }
    iter->setOffset(test1.length(), status);
    if (U_FAILURE(status) || iter->next(status) != UCOL_NULLORDER) {
        errln("Error: After setting offset to end of the string, we should "
                "be at the end of the backwards iteration");
    }

    // Run all the way through the iterator, then get the offset
    int32_t orderLength = 0;
    Order *orders = getOrders(*iter, orderLength);

    int32_t offset = iter->getOffset();

    if (offset != test1.length())
    {
        UnicodeString msg1("offset at end != length: ");
        UnicodeString msg2(" vs ");

        errln(msg1 + offset + msg2 + test1.length());
    }

    // Now set the offset back to the beginning and see if it works
    CollationElementIterator *pristine = en_us->createCollationElementIterator(test1);

    iter->setOffset(0, status);

    if (U_FAILURE(status))
    {
        errln("setOffset failed.");
    }
    else
    {
        assertEqual(*iter, *pristine);
    }

    // TODO: try iterating halfway through a messy string.

    delete pristine;
    delete[] orders;
    delete iter;
}
Ejemplo n.º 20
0
void WBSDCalibrateCanisterwindow::on_doubleSpinBox_editingFinished()
{

    if(this->ui->doubleSpinBox->value() < _minValue)
    {
        QMessageBox::warning(this,QObject::tr("Warning"),QObject::tr("Calibration value is out of range,it will be over written by min-value,Be aware that the actual dosing won't be in line with the setting."),QMessageBox::Ok);
        this->ui->doubleSpinBox->setValue(_minValue);
    }
	if (theSpeed==1){
		ParameterMsg msg1(Message::MCB,Message::AP,24,ParameterMsg::SET_PARAMETER);
		msg1.setFloat(this->ui->doubleSpinBox->value()/10);
		itsBaseWindow->addMessageToQue(msg1);
   } else if (theSpeed==2){
		ParameterMsg msg1(Message::MCB,Message::AP,25,ParameterMsg::SET_PARAMETER);
		msg1.setFloat(this->ui->doubleSpinBox->value()/10);
		itsBaseWindow->addMessageToQue(msg1);
   } else {
		ParameterMsg msg1(Message::MCB,Message::AP,26,ParameterMsg::SET_PARAMETER);
		msg1.setFloat(this->ui->doubleSpinBox->value()/10);
		itsBaseWindow->addMessageToQue(msg1);
   }

	if (theSpeed==1){
		ParameterMsg gmsg1(Message::MCB,Message::AP,24);
		gmsg1.getWord();
		itsBaseWindow->addMessageToQue(gmsg1);
   } else if (theSpeed==2){
		ParameterMsg gmsg1(Message::MCB,Message::AP,25);
		gmsg1.getWord();
		itsBaseWindow->addMessageToQue(gmsg1);
   } else {
		ParameterMsg ggmsg1(Message::MCB,Message::AP,26);
		ggmsg1.getWord();
		itsBaseWindow->addMessageToQue(ggmsg1);
   }

}
Ejemplo n.º 21
0
bool CTrueTalkNPC::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) {
	debugC(ERROR_DETAILED, kDebugScripts, "%s TrueTalkNotifySpeechEndedMsg flags=%x dialogueId=%d", getName().c_str(), _npcFlags, msg->_dialogueId);
	_npcFlags &= ~NPCFLAG_SPEAKING;
	--_speechCounter;
	_speechDuration = 0;

	if (!(_npcFlags & NPCFLAG_8)) {
		CNPCPlayTalkingAnimationMsg msg1(0, 2, nullptr);
		msg1.execute(this);
		CNPCQueueIdleAnimMsg msg2;
		msg2.execute(this);
	}

	return true;
}
Ejemplo n.º 22
0
static const response* data_block(const char* bytes, unsigned long len)
{
  if (databytes == 0) {
    /* First line is always Received, log the first two lines. */
    const char* ch;
    ch = strchr(bytes, '\n');
    str_copyb(&tmp, bytes, ch-bytes);
    bytes = ch + 1;
    if ((ch = strchr(bytes, '\n')) != 0)
      str_catb(&tmp, bytes, ch-bytes);
    msg1(tmp.s);
  }
  databytes += len;
  return 0;
}
Ejemplo n.º 23
0
int main(int argc, char* argv[])
{
  struct connection conn;
  iopoll_fd fds[2];
  int selfpipe;
  int i;

  msg_debug_init();
  testmode = getenv("TESTMODE") != 0;

  if ((shell_argv = malloc((argc + 3) * sizeof *argv)) == 0)
    die_oom(111);
  for (i = 1; i < argc; ++i)
    shell_argv[i-1] = argv[i];
  for (; i < argc + 4; ++i)
    shell_argv[i-1] = 0;
  shell_argc = argc - 1;

  if ((path = getenv("PATH")) == 0)
    die1(111, "No PATH is set");
  if ((devnull = open("/dev/null", O_RDWR)) == -1)
    die1sys(111, "Could not open \"/dev/null\"");
  if (!nonblock_on(0))
    die1sys(111, "Could not set non-blocking status");
  if ((selfpipe = selfpipe_init()) == -1)
    die1sys(111, "Could not create self-pipe");
  init_slots();
  connection_init(&conn, 0, 0);
  fds[0].fd = 0;
  fds[0].events = IOPOLL_READ;
  fds[1].fd = selfpipe;
  fds[1].events = IOPOLL_READ;
  for (;;) {
    if (iopoll_restart(fds, 2, -1) == -1)
      die1sys(111, "Poll failed");
    if (fds[0].revents)
      if (connection_read(&conn, handle_packet) <= 0)
	break;
    if (fds[1].revents) {
      read(selfpipe, &i, 1);
      handle_child(WNOHANG);
    }
  }
  msg1("Waiting for remaining slots to complete");
  while (slots_used > 0)
    handle_child(0);
  return 0;
}
Ejemplo n.º 24
0
  TEST(Serialization, WriteBitsEasy)
  {
    QByteArray msg(1, 'a');
    QBitArray bits(1, false);

    Serialization::WriteBitArray(bits, msg, 0);
    EXPECT_EQ((char)0x00, (char)msg[0]);

    QByteArray msg1(1, 'a');
    QBitArray bits1(0, false);

    Serialization::WriteBitArray(bits1, msg1, 0);
    EXPECT_EQ((char)0x00, (char)msg1[0]);

    QByteArray msg2(1, 'a');
    QBitArray bits2(1, true);

    Serialization::WriteBitArray(bits2, msg2, 0);
    EXPECT_EQ((char)0x01, (char)msg2[0]);

    QByteArray msg3(2, 'a');
    QBitArray bits3(8, true);

    Serialization::WriteBitArray(bits3, msg3, 0);
    EXPECT_EQ((char)0xFF, (char)msg3[0]);
    EXPECT_EQ((char)'a', (char)msg3[1]);

    QByteArray msg4(2, 'a');
    QBitArray bits4(8, true);

    Serialization::WriteBitArray(bits4, msg4, 1);
    EXPECT_EQ((char)'a', (char)msg4[0]);
    EXPECT_EQ((char)0xFF, (char)msg4[1]);

    QByteArray msg5(2, 'a');
    QBitArray bits5(9, true);

    Serialization::WriteBitArray(bits5, msg5, 0);
    EXPECT_EQ((char)0xFF, (char)msg5[0]);
    EXPECT_EQ((char)0x01, (char)msg5[1]);

    QByteArray msg6(2, 'a');
    QBitArray bits6(10, true);

    Serialization::WriteBitArray(bits6, msg6, 0);
    EXPECT_EQ((char)0xFF, (char)msg6[0]);
    EXPECT_EQ((char)0x03, (char)msg6[1]);
  }
Ejemplo n.º 25
0
	//! render function is called for creating a thread for a play function with a thread id t1.
	void render()
	{
			if(!calledOnce && !calledTwice)
			{
				int result = pthread_create(&t1,0,Ball::play,this);	
				result=1;
				calledOnce=true;
			}
			else if(calledOnce)
			{
				calledTwice=true;	
				std::string msg1 ("hello");
				std::cout<<"here\n";
			}
			calledOnce=true;
		return;
	}
Ejemplo n.º 26
0
 void ToXmlV2Encoding() const {
     {
         std::list<ErrorLogger::ErrorMessage::FileLocation> locs;
         ErrorMessage msg(locs, emptyString, Severity::error, "Programming error.\nComparing \"\203\" with \"\003\"", "errorId", false);
         const std::string expected("        <error id=\"errorId\" severity=\"error\" msg=\"Programming error.\" verbose=\"Comparing &quot;\\203&quot; with &quot;\\003&quot;\"/>");
         ASSERT_EQUALS(expected, msg.toXML());
     }
     {
         const char code1[]="äöü";
         const char code2[]="\x12\x00\x00\x01";
         std::list<ErrorLogger::ErrorMessage::FileLocation> locs;
         ErrorMessage msg1(locs, emptyString, Severity::error, std::string("Programming error.\nReading \"")+code1+"\"", "errorId", false);
         ASSERT_EQUALS("        <error id=\"errorId\" severity=\"error\" msg=\"Programming error.\" verbose=\"Reading &quot;\\303\\244\\303\\266\\303\\274&quot;\"/>", msg1.toXML());
         ErrorMessage msg2(locs, emptyString, Severity::error, std::string("Programming error.\nReading \"")+code2+"\"", "errorId", false);
         ASSERT_EQUALS("        <error id=\"errorId\" severity=\"error\" msg=\"Programming error.\" verbose=\"Reading &quot;\\022&quot;\"/>", msg2.toXML());
     }
 }
	void SimulatorParameters::getParametersDirectoryPath(){

		// read numeric parameters
		ifstream fid;
		fid.open("simulation-parameters/filenameParameters.dat");
		if ( !fid.is_open() ){
			throw Exception(__LINE__,__FILE__,"filenameParameters.dat could not be opened or it does not exist\n");
		}

		setPositionToRead(fid,"path:");
		fid >> parametersPath;

		// check if numeric.dat physical.dat slope_limiters.dat and solve.dat files are presented
		string checkForNumeric(parametersPath + "/numeric.dat");
		string checkForPhysical(parametersPath + "physical.dat");
		string checkForSlope_limiters(parametersPath + "/slope_limiters.dat");
		string checkForSolve(parametersPath + "/solve.dat");

		ifstream fid1, fid2, fid3, fid4;
		fid1.open(checkForNumeric.c_str());
		fid2.open(checkForPhysical.c_str());
		fid3.open(checkForSlope_limiters.c_str());
		fid4.open(checkForSolve.c_str());

		string msg1("could not be opened or it does not exist\n");
		char msg[256];

		if ( !fid1.is_open() ) sprintf(msg,"numeric.dat %s",msg1.c_str());
		if ( !fid2.is_open() ) sprintf(msg,"physical.dat %s",msg1.c_str());
		if ( !fid3.is_open() ) sprintf(msg,"slope-limiters.dat %s",msg1.c_str());
		if ( !fid4.is_open() ) sprintf(msg,"solve.dat %s",msg1.c_str());

		string failMsg(msg);

		if (!failMsg.length()){
			throw Exception(__LINE__,__FILE__,msg);
		}
		else{
			fid1.close();
			fid2.close();
			fid3.close();
			fid4.close();
		}
	}
Ejemplo n.º 28
0
void PhysicsSystem::SendCollisionMessages()
{
    GameObjectCache& GOC = GameObjectCache::Instance();

    for(unsigned int i = 0; i < contacts.size(); ++i)
    {
        Contact& c1 = contacts[i];

        ContactMessage msg(c1, 0);
        GameObject* obj1 = GOC.Get(c1.ObjIDs[msg.recieverIndex]);
        PhysicsComponent& phys = *obj1->getComponent<PhysicsComponent>();
        phys.CollideEvent(&msg);

        ContactMessage msg1(c1, 1);
        GameObject* obj2 = GOC.Get(c1.ObjIDs[(msg.recieverIndex+1)%2]);
        PhysicsComponent& phys2 = *obj2->getComponent<PhysicsComponent>();
        phys2.CollideEvent(&msg1);
        
    }
}
void CGT_CDiagMsg::errNS3(
    const CG_Edipos* pEdp, 
    const TCHAR*     psz1,
    const TCHAR*     psz2,
    const TCHAR*     psz3
)
{ 
    FC_CString jot(MAX_PATH);

    if(psz1)
        jot<<psz1;
    if(psz2)
        jot<<psz2;
    if(psz3)
        jot<<psz3;

    HRESULT errId =  CG_E_NOT_SUPP_TRG;
    if(m_NSName.isEmpty())
        msg1(CG_E_NOT_SUPPORTED, pEdp, jot);
    else
        msg2(CG_E_NOT_SUPP_TRG, pEdp, m_NSName, jot);
}
Ejemplo n.º 30
0
bool CTrueTalkNPC::MovieEndMsg(CMovieEndMsg *msg) {
	if (_npcFlags & NPCFLAG_2) {
		_npcFlags &= ~NPCFLAG_2;
		CNPCQueueIdleAnimMsg idleMsg;
		idleMsg.execute(this);
		return true;
	} else if (!(_npcFlags & NPCFLAG_SPEAKING)) {
		return false;
	}

	int diff = getTicksCount() - _fieldF0;
	int ticks = MAX((int)_soundId - diff, 0);
	CNPCPlayTalkingAnimationMsg msg1(ticks, ticks > 1000 ? 2 : 1, 0);
	msg1.execute(this);

	if (msg1._names) {
		CNPCPlayAnimationMsg msg2(msg1._names, msg1._value1);
		msg2.execute(this);
	}

	return true;
}