Beispiel #1
0
int P4ClientAPI::ConnectOrReconnect()
{
    if( IsTrackMode() )
	client.SetProtocol( "track", "" );

    Error e;

    ResetFlags();
    client.Init( &e );
    if ( e.Test() && exceptionLevel ) {
		return Except( "P4:connect()", &e );
    }

    if ( e.Test() )
		return 0;

    // If an iterator is defined, reset the break functionality
    // for the KeepAlive function

    if( ui.GetHandler() != LUA_NOREF )
    {
		client.SetBreak( &ui );
    }

    SetConnected();

	lua_pushboolean( L, true );
	return 1;
}
Beispiel #2
0
// Loads member's data from database.
// If member has broken fields (level, class) returns false.
// In this case member has to be removed from guild.
bool Guild::Member::LoadFromDB(Field* fields)
{
    m_publicNote  = fields[3].GetString();
    m_officerNote = fields[4].GetString();

    for (uint8 i = 0; i <= GUILD_BANK_MAX_TABS; ++i)
        m_bankWithdraw[i] = fields[5 + i].GetUInt32();

    SetStats(fields[12].GetString(),
             fields[13].GetUInt8(),                         // characters.level
             fields[14].GetUInt8(),                         // characters.class
             fields[15].GetUInt16(),                        // characters.zone
             fields[16].GetUInt32());                       // characters.account
    m_logoutTime = fields[17].GetUInt32();                  // characters.logout_time

    if (!CheckStats())
        return false;

    if (!m_zoneId)
    {
        TC_LOG_ERROR(LOG_FILTER_GUILD, "Player (GUID: %u) has broken zone-data", GUID_LOPART(m_guid));
        m_zoneId = Player::GetZoneIdFromDB(m_guid);
    }
    ResetFlags();
    return true;
}
Beispiel #3
0
void Player::HandleMovement(float deltaTime) {
	

	if(mUpp && hitbox.y > 0){
		playerPositionY -= (0.1/deltaTime);
		hitbox.y = playerPositionY;
		printf("moveUpp\n");
	}else if(mDown && hitbox.y < (Graphics::SCREEN_HEIGHT - hitbox.h)){
		playerPositionY += (0.1/deltaTime);
		hitbox.y = playerPositionY;
		printf("moveDown\n");
	}
	
	if(mLeft && hitbox.x > 0){
		playerPositionX -= (0.1/deltaTime);
		hitbox.x = playerPositionX;
		printf("moveLeft\n");
	}else if(mRight && hitbox.x < (Graphics::SCREEN_WIDTH - hitbox.h)){
		playerPositionX += (0.1/deltaTime);
		hitbox.x = playerPositionX;
		printf("moveRight\n");
	}
	ResetFlags();
	
}
void CWspCOTransaction::InitRequestL()
	{
	__ASSERT_DEBUG( iMethodState == ENullMethod, Panic(KWspPanicMethodAlreadyActive) );

	// Reset all the flags
	ResetFlags();

	// Set the request data
	STATIC_CAST(CWspCOTxData*, iTxData)->SetRequestDataL();
	}
Beispiel #5
0
void CGraphNodeStates::ResetFlags (const CVisibleGraphNode* node, DWORD flags)
{
    // this node's flags

    DWORD current = GetFlags (node->GetBase());

    // find the nodes whose flags that manifest at the given node
    // and reset these flags

    if ((COLLAPSED_ABOVE | SPLIT_ABOVE) & flags)
    {
        TFlaggedNode previousFlags = FindPreviousRelevant (node, current, false);
        if (previousFlags.first)
            ResetFlags (previousFlags.first, previousFlags.second);
    }

    if ((COLLAPSED_BELOW | SPLIT_BELOW) & flags)
    {
        TFlaggedNode nextFlags = FindNextRelevant (node, current, false);
        if (nextFlags.first)
            ResetFlags (nextFlags.first, nextFlags.second);
    }

    if (COLLAPSED_RIGHT & flags)
    {
        TFlaggedNode nextFlags = FindRightRelevant (node);
        if (nextFlags.first)
            ResetFlags (nextFlags.first, COLLAPSED_RIGHT);
    }

    if (SPLIT_RIGHT & flags)
    {
        TFlaggedNodes nodes = FindSplitSubtrees (node);
        for (size_t i = nodes.size(); i > 0; --i)
            ResetFlags (nodes[i-1], SPLIT_ABOVE);
    }
}
Beispiel #6
0
bool CAncodePattern::InitAncodePattern()
{
    ResetFlags();
    m_bUnkGramcodes = m_GramCodes.empty() || ((unsigned char)m_GramCodes[0] == '?');	
    

	if	(		!m_GramCodes.empty()
			&& 	(m_GramCodes[0] != '?') 
		)
	{
		for (size_t j=0; j < m_GramCodes.length(); j+=2)
		{
				QWORD CurrGrammems = 0;		
				bool b = GetGramTab()->GetGrammems(m_GramCodes.c_str() + j, CurrGrammems);
				assert (b);
				if (!b)
				{
                    ErrorMessage(Format("Cannot get grammems by gramcode %s ",m_GramCodes.substr(j,2).c_str()));
				};
				m_iGrammems |= CurrGrammems;
                BYTE pos = GetGramTab()->GetPartOfSpeech(m_GramCodes.c_str() + j);
				m_iPoses |= (1 << pos);
				
		}		
	}
	
	if	(		(m_CommonGramCode.length() == 2)
			&&	(m_CommonGramCode != "??")
		)
	{
		bool b = GetGramTab()->GetGrammems(m_CommonGramCode.c_str(), m_TypeGrammems);
		assert (b);
		if (!b)
		{
			ErrorMessage(Format("Cannot get grammems by type gramcode %s ",m_CommonGramCode.c_str()));
		};
	};


	return true;
};
Beispiel #7
0
int P4ClientAPI::Disconnect()
{
	if ( P4LUADEBUG_COMMANDS )
		fprintf( stderr, "[P4] Disconnect\n" );

    if ( ! IsConnected() )
	{
//		rb_warn( "P4:disconnect - not connected" );
		return 0;
	}

	Error	e;
	client.Final( &e );
    ResetFlags();

	// Clear the specdef cache.
	specMgr.Reset();

    // Clear out any results from the last command
    ui.Reset();

	return 0;
}
Beispiel #8
0
void CWordAppUi::UpdateToolbarsL()
	{
	UpdateToolbandButtonsL();
	UpdateFileNameLabelL();
	ResetFlags();
	}
Beispiel #9
0
//------------------------------------------------------------------------------
void CoordSystemConfigPanel::SaveData()
{
   canClose = true;
   std::string originName = originComboBox->GetValue().Trim().c_str();
   
   //-----------------------------------------------------------------
   // save values to base, base code should do the range checking
   //-----------------------------------------------------------------
   try
   {
      //-------------------------------------------------------
      // check/set new epoch
      //-------------------------------------------------------
      if (mEpochChanged)
      {
         std::string savedEpoch = (mCoordPanel->epochValue).c_str();
         Real epoch;
         std::string str = mCoordPanel->GetEpochTextCtrl()->GetValue().c_str();
         #if DEBUG_COORD_PANEL_SAVE
         MessageInterface::ShowMessage("Epoch data has been changed!!!!\n");
         MessageInterface::ShowMessage
            ("CoordSystemConfigPanel::SaveData() epoch value = %s\n",
             str.c_str());
         #endif
         bool isValid = CheckReal(epoch, str, "Epoch", "Real Number >= 0");
         #if DEBUG_COORD_PANEL_SAVE
         MessageInterface::ShowMessage
            ("CoordSystemConfigPanel::SaveData() isValid = %s, and epoch real value = %12.10f\n",
             (isValid? "true" : "false"), epoch);
         #endif

         // check range here too
         if (isValid)
            isValid = CheckRealRange(str, epoch, "Epoch", DateUtil::EARLIEST_VALID_MJD_VALUE, DateUtil::LATEST_VALID_MJD_VALUE, true, true, true, true);
         if (!isValid)
         {
            canClose = false;
         }
      }

      if (!canClose)
         return;

      //-------------------------------------------------------
      // set new axis system
      //-------------------------------------------------------
      if (mObjRefChanged)
      {
         AxisSystem *oldAxis = (AxisSystem*) theCoordSys->GetRefObject(Gmat::AXIS_SYSTEM, "");
         AxisSystem *axis = mCoordPanel->CreateAxis();
         #ifdef DEBUG_COORD_PANEL_XYZ
            MessageInterface::ShowMessage("CoordSystemConfigPanel:: CreateAxis returned %s\n",
                  (axis? "not NULL" : "NULL"));
         #endif
         
         if (axis != NULL)
         {
            #ifdef DEBUG_COORD_PANEL_XYZ
               MessageInterface::ShowMessage("CoordSystemConfigPanel:: executing axis not equal to NULL part ...\n");
            #endif
            canClose = mCoordPanel->SaveData(theCoordSys->GetName(), axis, mEpochFormat);
            
            if (canClose)
            {
               try
               {
                  // only set these if there was no error creating or initializing the coordinate system
                  theCoordSys->SetRefObject(axis, Gmat::AXIS_SYSTEM, "");
                  theCoordSys->Initialize();
               }
               catch (BaseException &be)
               {
                  // reset the CS to have the axis system it started with
                  theCoordSys->SetRefObject(oldAxis, Gmat::AXIS_SYSTEM, "");
                  theCoordSys->Initialize();
                  throw;
               }
            }
         }
         else
         {
            #ifdef DEBUG_COORD_PANEL_XYZ
               MessageInterface::ShowMessage("CoordSystemConfigPanel:: executing axis EQUAL to NULL part ...\n");
            #endif
            MessageInterface::ShowMessage
               ("CoordSystemConfigPanel::SaveData() Cannot create AxisSystem.\n");
            canClose = false;
         }
      }

      //-------------------------------------------------------
      // set new origin - needs to be done after setting of the axis system
      //-------------------------------------------------------
      if (mOriginChanged)
      {
         #if DEBUG_COORD_PANEL_SAVE
         MessageInterface::ShowMessage
            ("CoordSystemConfigPanel::SaveData() originName = %s\n",
             originName.c_str());
         #endif

         // set coordinate system origin
         SpacePoint *origin =
            (SpacePoint*)theGuiInterpreter->GetConfiguredObject(originName);
         theCoordSys->SetStringParameter("Origin", originName);
         theCoordSys->SetOrigin(origin);

         mOriginChanged = false;

         // set Earth as J000Body if NULL
         if (origin->GetJ2000Body() == NULL)
         {
            SpacePoint *j2000body =
               (SpacePoint*)theGuiInterpreter->GetConfiguredObject("Earth");
            origin->SetJ2000Body(j2000body);
         }
      }
      ResetFlags();

   }
   catch (BaseException &e)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, e.GetFullMessage());
      canClose = false;
   }
}
Beispiel #10
0
CAncodePattern::CAncodePattern(const	CAgramtab* pGramTab): m_pGramTab(pGramTab)
{
    ResetFlags();
    m_LemSign = 0;
};
Beispiel #11
0
static void RunWithFlags(const test::TestInfo *info,
                         Flags flags,
                         std::string desc,
                         uint64_t arg1,
                         uint64_t arg2,
                         uint64_t arg3) {
  LOG(INFO) << "Testing instruction: " << info->test_name << ": " << desc;
  if (sigsetjmp(gUnsupportedInstrBuf, true)) {
    LOG(INFO) << "Unsupported instruction " << info->test_name;
    return;
  }

  // Set up the GPR mask just in case an error occurs when we execute this
  // instruction.
  if (64 == ADDRESS_SIZE_BITS) {
    gRegMask32 = std::numeric_limits<uint64_t>::max();
    gRegMask64 = gRegMask32;
  } else {
    gRegMask32 = std::numeric_limits<uint32_t>::max();
    gRegMask64 = 0;
  }

  memcpy(&gLiftedStack, &gRandomStack, sizeof(gLiftedStack));
  memset(&gLiftedState, 0, sizeof(gLiftedState));
  memset(&gNativeState, 0, sizeof(gNativeState));

  auto lifted_state = reinterpret_cast<State *>(&gLiftedState);
  auto native_state = reinterpret_cast<State *>(&gNativeState);

  // This will be used to initialize the native flags state before executing
  // the native test.
  lifted_state->rflag = flags;

  // Set up the run's info.
  gTestToRun = info->test_begin;
  gStackSwitcher = &(gLiftedStack._redzone2[0]);

  ResetFlags();

  // This will execute on `gStack`. The mechanism behind this is that the
  // stack pointer is swapped with `gStackSwitcher`. The idea here is that
  // we want to run the native and lifted testcases on the same stack so that
  // we can compare that they both operate on the stack in the same ways.
  auto native_test_faulted = false;
  if (!sigsetjmp(gJmpBuf, true)) {
    gInNativeTest = true;
    InvokeTestCase(arg1, arg2, arg3);
  } else {
    native_test_faulted = true;
  }
  ResetFlags();

  // Copy out whatever was recorded on the stack so that we can compare it
  // with how the lifted program mutates the stack.
  memcpy(&gNativeStack, &gLiftedStack, sizeof(gLiftedStack));
  memcpy(&gLiftedStack, &gRandomStack, sizeof(gLiftedStack));

  // This will execute on our stack but the lifted code will operate on
  // `gStack`. The mechanism behind this is that `gStateBefore` is the native
  // program state recorded before executing the native testcase, but after
  // swapping execution to operate on `gStack`.
  if (!sigsetjmp(gJmpBuf, true)) {
    gInNativeTest = false;
    info->lifted_func(lifted_state);
  } else {
    EXPECT_TRUE(native_test_faulted);
  }

  ResetFlags();

  // Don't compare the program counters. The code that is lifted is equivalent
  // to the code that is tested but because they are part of separate binaries
  // it means that there is not necessarily any relation between their values.
  //
  // This also lets us compare 32-bit-only lifted code with 32-bit only
  // testcases, where the native 32-bit code actually emulates the 32-bit
  // behavior in 64-bit (because all of this code is compiled as 64-bit).
  lifted_state->gpr.rip.qword = 0;
  native_state->gpr.rip.qword = 0;

  CopyXMMRegsIntoFPU(lifted_state);

  // Copy the aflags state back into the rflags state.
  lifted_state->rflag.cf = lifted_state->aflag.cf;
  lifted_state->rflag.pf = lifted_state->aflag.pf;
  lifted_state->rflag.af = lifted_state->aflag.af;
  lifted_state->rflag.zf = lifted_state->aflag.zf;
  lifted_state->rflag.sf = lifted_state->aflag.sf;
  lifted_state->rflag.df = lifted_state->aflag.df;
  lifted_state->rflag.of = lifted_state->aflag.of;

  // No longer want to compare these.
  memset(&(native_state->aflag), 0, sizeof(native_state->aflag));
  memset(&(lifted_state->aflag), 0, sizeof(lifted_state->aflag));

  // Only compare the non-undefined flags state.
  native_state->rflag.flat |= info->ignored_flags_mask;
  lifted_state->rflag.flat |= info->ignored_flags_mask;

  // Don't even bother with the MXCSR (SSE control/status register).
  lifted_state->fpu.mxcsr.flat = native_state->fpu.mxcsr.flat;

  // Compare the register states.
  EXPECT_TRUE(lifted_state->fpu == native_state->fpu);
  for (auto i = 0UL; i < kNumVecRegisters; ++i) {
    EXPECT_TRUE(lifted_state->vec[i] == native_state->vec[i]);
  }
  EXPECT_TRUE(lifted_state->aflag == native_state->aflag);
  EXPECT_TRUE(lifted_state->rflag == native_state->rflag);
  EXPECT_TRUE(lifted_state->seg == native_state->seg);
  EXPECT_TRUE(lifted_state->gpr == native_state->gpr);
  if (gLiftedState != gNativeState) {
    EXPECT_TRUE(!"Lifted and native states did not match.");
  }
  if (gLiftedStack != gNativeStack) {
    EXPECT_TRUE(!"Lifted and native stacks did not match.");
  }
}
// -----------------------------------------------------------------------------
// CTestSettingPage::TestResetFlags
// -----------------------------------------------------------------------------
//
void CTestSettingPage::TestResetFlags()
    {
    ResetFlags();
    }
Beispiel #13
0
CStreamBase::CStreamBase()
{
	ResetFlags();
}
Beispiel #14
0
Expression* X86Architecture::UpdateFlags(Instruction& rInsn, Expression* pResultExpr)
{
  u32 RegFlags = m_CpuInfo.GetRegisterByType(CpuInformation::FlagRegister, rInsn.GetMode());
  u32 RegFlagsSize = m_CpuInfo.GetSizeOfRegisterInBit(RegFlags);
  assert(RegFlags != 0 && "Invalid flags");

  u32 Bit = rInsn.Operand(0)->GetSizeInBit();
  assert(Bit && "Invalid operand");

  auto InsnLen = static_cast<u8>(rInsn.GetLength());

  std::list<Expression *> FlagExprs;

  switch (rInsn.GetOpcode())
  {
  case X86_Opcode_Inc: case X86_Opcode_Add:
    FlagExprs.push_back(new IfElseConditionExpression(IfElseConditionExpression::CondUlt,
      pResultExpr->Clone(), rInsn.Operand(0)->GetSemantic(rInsn.GetMode(), &m_CpuInfo, InsnLen),
      SetFlags(rInsn, X86_FlCf), ResetFlags(rInsn, X86_FlCf)));
    break;

  case X86_Opcode_Adc:
    FlagExprs.push_back(new IfElseConditionExpression(IfElseConditionExpression::CondUlt,
      pResultExpr->Clone(),
      new OperationExpression(OperationExpression::OpAdd, rInsn.Operand(0)->GetSemantic(rInsn.GetMode(), &m_CpuInfo, InsnLen), ExtractFlag(rInsn, X86_FlCf)),
      SetFlags(rInsn, X86_FlCf), ResetFlags(rInsn, X86_FlCf)));
    break;

  case X86_Opcode_Dec:
    FlagExprs.push_back(new IfElseConditionExpression(IfElseConditionExpression::CondUlt,
      rInsn.Operand(0)->GetSemantic(rInsn.GetMode(), &m_CpuInfo, InsnLen), new ConstantExpression(Bit, 1),
      SetFlags(rInsn, X86_FlCf), ResetFlags(rInsn, X86_FlCf)));
    break;

  case X86_Opcode_Sub: case X86_Opcode_Cmp:
    FlagExprs.push_back(new IfElseConditionExpression(IfElseConditionExpression::CondUlt,
      rInsn.Operand(0)->GetSemantic(rInsn.GetMode(), &m_CpuInfo, InsnLen), rInsn.Operand(1)->GetSemantic(rInsn.GetMode(), &m_CpuInfo, InsnLen),
      SetFlags(rInsn, X86_FlCf), ResetFlags(rInsn, X86_FlCf)));
    break;

  case X86_Opcode_Sbb:
    FlagExprs.push_back(new IfElseConditionExpression(IfElseConditionExpression::CondUlt,
      pResultExpr->Clone(),
      new OperationExpression(OperationExpression::OpSub, rInsn.Operand(0)->GetSemantic(rInsn.GetMode(), &m_CpuInfo, InsnLen), ExtractFlag(rInsn, X86_FlCf)),
      SetFlags(rInsn, X86_FlCf), ResetFlags(rInsn, X86_FlCf)));
    break;
  }

  auto UpdatedFlags = rInsn.GetUpdatedFlags();

  if (UpdatedFlags & X86_FlZf)
  {
    FlagExprs.push_back(new IfElseConditionExpression(ConditionExpression::CondEq,
      pResultExpr->Clone(),
      new ConstantExpression(Bit, 0x0),
      SetFlags(rInsn, X86_FlZf), ResetFlags(rInsn, X86_FlZf)));
  }

  if (UpdatedFlags & X86_FlSf)
  {
    FlagExprs.push_back(new IfElseConditionExpression(ConditionExpression::CondEq,
      new OperationExpression(OperationExpression::OpAnd, pResultExpr->Clone(), new ConstantExpression(Bit, 1 << (Bit - 1))),
      new ConstantExpression(Bit, 1 << (Bit - 1)),
      SetFlags(rInsn, X86_FlSf), ResetFlags(rInsn, X86_FlSf)));
  }

  if (FlagExprs.empty())
    return pResultExpr;

  delete pResultExpr;
  return new BindExpression(FlagExprs);
}