• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ checker函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中checker函数的典型用法代码示例。如果您正苦于以下问题:C++ checker函数的具体用法?C++ checker怎么用?C++ checker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了checker函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: checker

int ShaderBinder::create(lua_State* L)
{
	StackChecker checker(L, "ShaderBinder::create", 1);

    Binder binder(L);

	const char* vs = luaL_checkstring(L, 1);
	const char* ps = luaL_checkstring(L, 2);
	int flags=luaL_checkinteger(L,3);
    luaL_checktype(L, 4, LUA_TTABLE);
    luaL_checktype(L, 5, LUA_TTABLE);

	std::vector<ShaderProgram::ConstantDesc> constants;
	std::vector<ShaderProgram::DataDesc> datas;

    int n = luaL_getn(L, 4);  /* get size of table */
    for (int i=1; i<=n; i++) {
    	ShaderProgram::ConstantDesc cst={"",ShaderProgram::CINT,1,ShaderProgram::SysConst_None,false,0,NULL};
        lua_rawgeti(L, 4, i);  /* push t[i] */
        luaL_checktype(L,-1,LUA_TTABLE); //Check table
        lua_getfield(L,-1,"name");
        cst.name=luaL_checkstring(L,-1);
        lua_getfield(L,-2,"type");
        cst.type=(ShaderProgram::ConstantType)luaL_checkinteger(L,-1);
        lua_getfield(L,-3,"vertex");
        cst.vertexShader=lua_toboolean(L,-1);
        lua_getfield(L,-4,"sys");
        cst.sys=(ShaderProgram::SystemConstant) luaL_optinteger(L,-1,0);
        lua_getfield(L,-5,"mult");
        cst.mult=luaL_optinteger(L,-1,1);
        lua_pop(L,6);
    	constants.push_back(cst);
      }

    n = luaL_getn(L, 5);  /* get size of table */
    for (int i=1; i<=n; i++) {
    	ShaderProgram::DataDesc cst={"",ShaderProgram::DFLOAT,0,0,0};
        lua_rawgeti(L, 5, i);  /* push t[i] */
        luaL_checktype(L,-1,LUA_TTABLE); //Check table
        lua_getfield(L,-1,"name");
        cst.name=luaL_checkstring(L,-1);
        lua_getfield(L,-2,"type");
        cst.type=(ShaderProgram::DataType)luaL_checkinteger(L,-1);
        lua_getfield(L,-3,"mult");
        cst.mult=luaL_checkinteger(L,-1);
        lua_getfield(L,-4,"slot");
        cst.slot=luaL_optinteger(L,-1,0);
        lua_getfield(L,-5,"offset");
        cst.offset=luaL_optinteger(L,-1,0);
        lua_pop(L,6);
    	datas.push_back(cst);
      }


	ShaderProgram::ConstantDesc clast={"",ShaderProgram::CINT,1,ShaderProgram::SysConst_None,false,0,NULL};
	ShaderProgram::DataDesc dlast={"",ShaderProgram::DFLOAT,0,0,0};
	constants.push_back(clast);
	datas.push_back(dlast);
    ShaderProgram *shader=ShaderEngine::Engine->createShaderProgram(vs,ps,flags,&(constants[0]),&(datas[0]));
    if (!shader->isValid())
    {
    	lua_pushstring(L,shader->compilationLog());
    	lua_error(L);
    }
    binder.pushInstance("Shader", shader);
	return 1;
}
开发者ID:gideros,项目名称:gideros,代码行数:67,代码来源:shaderbinder.cpp


示例2: HandlePlayerLeave

bool BfCapturePoint::Update(uint32 diff)
{
    if (!m_capturePointGUID)
        return false;

    if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID))
    {
        float radius = capturePoint->GetGOInfo()->capturePoint.radius;

        for (uint8 team = 0; team < 2; ++team)
        {
            for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();)
            {
                if (Player* player = sObjectAccessor->FindPlayer(*itr))
                {
                    if (!capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
                        itr = HandlePlayerLeave(player);
                    else
                        ++itr;
                }
                else
                    ++itr;
            }
        }

        std::list<Player*> players;
        Trinity::AnyPlayerInObjectRangeCheck checker(capturePoint, radius);
        Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(capturePoint, players, checker);
        capturePoint->VisitNearbyWorldObject(radius, searcher);

        for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr)
            if ((*itr)->IsOutdoorPvPActive())
                if (m_activePlayers[(*itr)->GetTeamId()].insert((*itr)->GetGUID()).second)
                    HandlePlayerEnter(*itr);
    }

    // get the difference of numbers
    float fact_diff = ((float) m_activePlayers[0].size() - (float) m_activePlayers[1].size()) * diff / BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL;
    if (G3D::fuzzyEq(fact_diff, 0.0f))
        return false;

    uint32 Challenger = 0;
    float maxDiff = m_maxSpeed * diff;

    if (fact_diff < 0)
    {
        // horde is in majority, but it's already horde-controlled -> no change
        if (m_State == BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE && m_value <= -m_maxValue)
            return false;

        if (fact_diff < -maxDiff)
            fact_diff = -maxDiff;

        Challenger = HORDE;
    }
    else
    {
        // ally is in majority, but it's already ally-controlled -> no change
        if (m_State == BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE && m_value >= m_maxValue)
            return false;

        if (fact_diff > maxDiff)
            fact_diff = maxDiff;

        Challenger = ALLIANCE;
    }

    float oldValue = m_value;
    TeamId oldTeam = m_team;

    m_OldState = m_State;

    m_value += fact_diff;

    if (m_value < -m_minValue)                              // red
    {
        if (m_value < -m_maxValue)
            m_value = -m_maxValue;
        m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE;
        m_team = TEAM_HORDE;
    }
    else if (m_value > m_minValue)                          // blue
    {
        if (m_value > m_maxValue)
            m_value = m_maxValue;
        m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE;
        m_team = TEAM_ALLIANCE;
    }
    else if (oldValue * m_value <= 0)                       // grey, go through mid point
    {
        // if challenger is ally, then n->a challenge
        if (Challenger == ALLIANCE)
            m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE;
        // if challenger is horde, then n->h challenge
        else if (Challenger == HORDE)
            m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE;
        m_team = TEAM_NEUTRAL;
    }
    else                                                    // grey, did not go through mid point
    {
//.........这里部分代码省略.........
开发者ID:Dramacydal,项目名称:Trinitycore-5.3.0,代码行数:101,代码来源:Battlefield.cpp


示例3: HandlePlayerLeave

bool OPvPCapturePoint::Update(uint32 diff)
{
    if (!m_capturePoint)
        return false;

    float radius = (float)m_capturePoint->GetGOInfo()->capturePoint.radius;

    for (uint32 team = 0; team < 2; ++team)
    {
        for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();)
        {
            Player* player = *itr;
            ++itr;
            if (!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
                HandlePlayerLeave(player);
        }
    }

    std::list<Player*> players;
    SkyFire::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius);
    SkyFire::PlayerListSearcher<SkyFire::AnyPlayerInObjectRangeCheck> searcher(m_capturePoint, players, checker);
    m_capturePoint->VisitNearbyWorldObject(radius, searcher);

    for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr)
    {
        if ((*itr)->IsOutdoorPvPActive())
        {
            if (m_activePlayers[(*itr)->GetTeamId()].insert(*itr).second)
                HandlePlayerEnter(*itr);
        }
    }

    // get the difference of numbers
    float fact_diff = ((float)m_activePlayers[0].size() - (float)m_activePlayers[1].size()) * diff / OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL;
    if (!fact_diff)
        return false;

    uint32 Challenger = 0;
    float maxDiff = m_maxSpeed * diff;

    if (fact_diff < 0)
    {
        // horde is in majority, but it's already horde-controlled -> no change
        if (m_State == OBJECTIVESTATE_HORDE && m_value <= -m_maxValue)
            return false;

        if (fact_diff < -maxDiff)
            fact_diff = -maxDiff;

        Challenger = HORDE;
    }
    else
    {
        // ally is in majority, but it's already ally-controlled -> no change
        if (m_State == OBJECTIVESTATE_ALLIANCE && m_value >= m_maxValue)
            return false;

        if (fact_diff > maxDiff)
            fact_diff = maxDiff;

        Challenger = ALLIANCE;
    }

    float oldValue = m_value;
    TeamId oldTeam = _team;

    m_OldState = m_State;

    m_value += fact_diff;

    if (m_value < -m_minValue) // red
    {
        if (m_value < -m_maxValue)
            m_value = -m_maxValue;
        m_State = OBJECTIVESTATE_HORDE;
        _team = TEAM_HORDE;
    }
    else if (m_value > m_minValue) // blue
    {
        if (m_value > m_maxValue)
            m_value = m_maxValue;
        m_State = OBJECTIVESTATE_ALLIANCE;
        _team = TEAM_ALLIANCE;
    }
    else if (oldValue * m_value <= 0) // grey, go through mid point
    {
        // if challenger is ally, then n->a challenge
        if (Challenger == ALLIANCE)
            m_State = OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE;
        // if challenger is horde, then n->h challenge
        else if (Challenger == HORDE)
            m_State = OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE;
        _team = TEAM_NEUTRAL;
    }
    else // grey, did not go through mid point
    {
        // old phase and current are on the same side, so one team challenges the other
        if (Challenger == ALLIANCE && (m_OldState == OBJECTIVESTATE_HORDE || m_OldState == OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE))
            m_State = OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE;
        else if (Challenger == HORDE && (m_OldState == OBJECTIVESTATE_ALLIANCE || m_OldState == OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE))
//.........这里部分代码省略.........
开发者ID:Asandru,项目名称:Script-Land,代码行数:101,代码来源:OutdoorPvP.cpp


示例4: u_check

void TotemAI::UpdateAI(const uint32 /*diff*/)
{
    if (i_totem.GetTotemType() != TOTEM_ACTIVE)
        return;

    i_totem.SetSelection(0);

    if (!i_totem.isAlive() || i_totem.IsNonMeleeSpellCasted(false))
        return;

    // Search spell
    SpellEntry const *spellInfo = sSpellStore.LookupEntry(i_totem.GetSpell());
    if (!spellInfo)
        return;

    // Get spell rangy
    SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
    float max_range = SpellMgr::GetSpellMaxRange(srange);

    // SPELLMOD_RANGE not applied in this place just because not existence range mods for attacking totems

    // pointer to appropriate target if found any
    Unit* victim = i_victimGuid ? i_totem.GetMap()->GetUnit(i_victimGuid) : NULL;

    if (!max_range)
        victim = &i_totem;

    // Search victim if no, not attackable, or out of range, or friendly (possible in case duel end)
    if (!victim || (!SpellMgr::SpellIgnoreLOS(spellInfo, 0) && !i_totem.IsWithinLOSInMap(victim)) ||
        !victim->isTargetableForAttack() || !i_totem.IsWithinDistInMap(victim, max_range) ||
        (i_totem.IsFriendlyTo(victim) && victim != &i_totem) || !victim->isVisibleForOrDetect(&i_totem, &i_totem, false))
    {
        victim = NULL;

        Looking4group::NearestAttackableUnitInObjectRangeCheck u_check(&i_totem, &i_totem, max_range);
        Looking4group::UnitLastSearcher<Looking4group::NearestAttackableUnitInObjectRangeCheck> checker(victim, u_check);

        Cell::VisitAllObjects(m_creature, checker, max_range);
    }

    // If have target
    if (victim)
    {
        //this should prevent target-type totems from attacking from unattackable zones and attacking while being unattackable
        if ((i_totem.isInSanctuary() || victim->isInSanctuary()) && victim->GetCharmerOrOwnerPlayerOrPlayerItself())
            return;
        // remember
        i_victimGuid = victim->GetGUID();

        // attack
        i_totem.CastSpell(victim, i_totem.GetSpell(), false, NULL, NULL, i_totem.GetOwner()->GetGUID());
    }
    else
        i_victimGuid = 0;

    //i_totem.SetFacingToObject(&i_totem);
}
开发者ID:Dolmero,项目名称:L4G_Core,代码行数:57,代码来源:TotemAI.cpp


示例5: testInsertBIG

boolean testInsertBIG (tree *tr, nodeptr p, nodeptr q)
{
  double  qz[NUM_BRANCHES], pz[NUM_BRANCHES];
  nodeptr  r;
  boolean doIt = TRUE;
  double startLH = tr->endLH;
  int i;
  
  r = q->back; 
  for(i = 0; i < tr->numBranches; i++)
    {
      qz[i] = q->z[i];
      pz[i] = p->z[i];
    }
  
  if(tr->grouped)
    {
      int rNumber, qNumber, pNumber;
      
      doIt = FALSE;
      
      rNumber = tr->constraintVector[r->number];
      qNumber = tr->constraintVector[q->number];
      pNumber = tr->constraintVector[p->number];
      
      if(pNumber == -9)
	pNumber = checker(tr, p->back);
      if(pNumber == -9)
	doIt = TRUE;
      else
	{
	  if(qNumber == -9)
	    qNumber = checker(tr, q);
	  
	  if(rNumber == -9)
	    rNumber = checker(tr, r);
	  
	  if(pNumber == rNumber || pNumber == qNumber)
	    doIt = TRUE;    	  
	}
    }
  
  if(doIt)
    {     
      if (! insertBIG(tr, p, q, tr->numBranches))       return FALSE;         
      
      evaluateGeneric(tr, p->next->next);   
       
      if(tr->likelihood > tr->bestOfNode)
	{
	  tr->bestOfNode = tr->likelihood;
	  tr->insertNode = q;
	  tr->removeNode = p;   
	  for(i = 0; i < tr->numBranches; i++)
	    {
	      tr->currentZQR[i] = tr->zqr[i];           
	      tr->currentLZR[i] = tr->lzr[i];
	      tr->currentLZQ[i] = tr->lzq[i];
	      tr->currentLZS[i] = tr->lzs[i];      
	    }
	}
      
      if(tr->likelihood > tr->endLH)
	{			  
	  tr->insertNode = q;
	  tr->removeNode = p;   
	  for(i = 0; i < tr->numBranches; i++)
	    tr->currentZQR[i] = tr->zqr[i];      
	  tr->endLH = tr->likelihood;                      
	}        
      
      hookup(q, r, qz, tr->numBranches);
      
      p->next->next->back = p->next->back = (nodeptr) NULL;
      
      if(Thorough)
	{
	  nodeptr s = p->back;
	  hookup(p, s, pz, tr->numBranches);      
	} 
      
      if((tr->doCutoff) && (tr->likelihood < startLH))
	{
	  tr->lhAVG += (startLH - tr->likelihood);
	  tr->lhDEC++;
	  if((startLH - tr->likelihood) >= tr->lhCutoff)
	    return FALSE;	    
	  else
	    return TRUE;
	}
      else
	return TRUE;
    }
  else
    return TRUE;  
}
开发者ID:gtb-togerther,项目名称:standard-RAxML,代码行数:96,代码来源:searchAlgo.c


示例6: visit

	virtual void visit(TouchEvent* v)
	{
		StackChecker checker(L, "visit(TouchEvent* v)", 0);

		Binder binder(L);

		// get closure
		luaL_rawgetptr(L, LUA_REGISTRYINDEX, &key_eventClosures);
		lua_pushlightuserdata(L, bridge_);
		lua_rawget(L, -2);
		lua_remove(L, -2);		// remove env["eventClosures"]

		luaL_rawgetptr(L, LUA_REGISTRYINDEX, &key_TouchEvent);

		lua_getfield(L, -1, "__uniqueid");

		if (lua_isnil(L, -1) || lua_tointeger(L, -1) != v->uniqueid())
		{
			lua_pop(L, 1);

			lua_pushinteger(L, v->uniqueid());
			lua_setfield(L, -2, "__uniqueid");

			binder.setInstance(-1, v);

			lua_pushstring(L, v->type()); // TODO: buna artik ihtiyac yok. direk Event'te getType() fonksiyonu var
			lua_setfield(L, -2, "type");

            // touch
            getOrCreateTouch(&v->event->touch, v->sx, v->sy, v->tx, v->ty);
            lua_setfield(L, -2, "touch");

            // touches (it has only 1 element)
			lua_getfield(L, -1, "touches");
			if (lua_isnil(L, -1))
			{
				lua_pop(L, 1);
				lua_newtable(L);
			}
			else
			{
				int n = lua_objlen(L, -1);
				for (int i = n; i >= 1; --i)
				{
					lua_pushnil(L);
					lua_rawseti(L, -2, i);
				}
			}
            getOrCreateTouch(&v->event->touch, v->sx, v->sy, v->tx, v->ty);
            lua_rawseti(L, -2, 1);
			lua_setfield(L, -2, "touches");

            // allTouches
			lua_getfield(L, -1, "allTouches");
			if (lua_isnil(L, -1))
			{
				lua_pop(L, 1);
				lua_newtable(L);
			}
			else
			{
				int n = lua_objlen(L, -1);
				for (int i = n; i >= 1; --i)
				{
					lua_pushnil(L);
					lua_rawseti(L, -2, i);
				}
			}
            for (std::size_t i = 0; i < v->event->allTouchesCount; ++i)
			{
                getOrCreateTouch(&v->event->allTouches[i], v->sx, v->sy, v->tx, v->ty);
                lua_rawseti(L, -2, i + 1);
			}
			lua_setfield(L, -2, "allTouches");
		}
		else
		{
			lua_pop(L, 1);
		}
		
		lua_call(L, 1, 0);
	}
开发者ID:popcade,项目名称:gideros,代码行数:82,代码来源:eventdispatcherbinder.cpp


示例7: tictoc


//.........这里部分代码省略.........
  for (size_t i=0; i<num_faces; i++) 
  {
    Eigen::MatrixXi w_out(1,2), w_in(1,2);
    w_out << W(i,0), W(i,2);
    w_in  << W(i,1), W(i,3);
    Wr(i,0) = wind_num_op(w_out);
    Wr(i,1) = wind_num_op(w_in);
  }
#ifdef MESH_BOOLEAN_TIMING
  log_time("compute_output_winding_number");
#endif

  // Extract boundary separating inside from outside.
  auto index_to_signed_index = [&](size_t i, bool ori) -> int
  {
    return (i+1)*(ori?1:-1);
  };
  //auto signed_index_to_index = [&](int i) -> size_t {
  //    return abs(i) - 1;
  //};
  std::vector<int> selected;
  for(size_t i=0; i<num_faces; i++) 
  {
    auto should_keep = keep(Wr(i,0), Wr(i,1));
    if (should_keep > 0) 
    {
      selected.push_back(index_to_signed_index(i, true));
    } else if (should_keep < 0) 
    {
      selected.push_back(index_to_signed_index(i, false));
    }
  }

  const size_t num_selected = selected.size();
  DerivedFC kept_faces(num_selected, 3);
  DerivedJ  kept_face_indices(num_selected, 1);
  for (size_t i=0; i<num_selected; i++) 
  {
    size_t idx = abs(selected[i]) - 1;
    if (selected[i] > 0) 
    {
      kept_faces.row(i) = F.row(idx);
    } else 
    {
      kept_faces.row(i) = F.row(idx).reverse();
    }
    kept_face_indices(i, 0) = CJ[idx];
  }
#ifdef MESH_BOOLEAN_TIMING
  log_time("extract_output");
#endif

  // Finally, remove duplicated faces and unreferenced vertices.
  {
    DerivedFC G;
    DerivedJ JJ;
    igl::resolve_duplicated_faces(kept_faces, G, JJ);
    igl::slice(kept_face_indices, JJ, 1, J);

#ifdef DOUBLE_CHECK_EXACT_OUTPUT
    {
      // Sanity check on exact output.
      igl::copyleft::cgal::RemeshSelfIntersectionsParam params;
      params.detect_only = true;
      params.first_only = true;
      MatrixXES dummy_VV;
      DerivedFC dummy_FF, dummy_IF;
      Eigen::VectorXi dummy_J, dummy_IM;
      igl::copyleft::cgal::SelfIntersectMesh<
        Kernel,
        MatrixXES, DerivedFC,
        MatrixXES, DerivedFC,
        DerivedFC,
        Eigen::VectorXi,
        Eigen::VectorXi
      > checker(V, G, params,
          dummy_VV, dummy_FF, dummy_IF, dummy_J, dummy_IM);
      if (checker.count != 0) 
      {
        throw "Self-intersection not fully resolved.";
      }
    }
#endif

    MatrixX3S Vs(V.rows(), V.cols());
    for (size_t i=0; i<(size_t)V.rows(); i++)
    {
      for (size_t j=0; j<(size_t)V.cols(); j++)
      {
        igl::copyleft::cgal::assign_scalar(V(i,j), Vs(i,j));
      }
    }
    Eigen::VectorXi newIM;
    igl::remove_unreferenced(Vs,G,VC,FC,newIM);
  }
#ifdef MESH_BOOLEAN_TIMING
  log_time("clean_up");
#endif
  return valid;
}
开发者ID:stigersh,项目名称:libigl,代码行数:101,代码来源:mesh_boolean.cpp


示例8: checker

int AudioBinder::Sound_create(lua_State *L)
{
    StackChecker checker(L, "AudioBinder::Sound_create", 1);

    Binder binder(L);

    const char *fileName = luaL_checkstring(L, 1);

    std::vector<char> sig;
    int flags = gpath_getDriveFlags(gpath_getPathDrive(fileName));
    if (flags & GPATH_RO)
    {
        append(sig, fileName, strlen(fileName) + 1);
    }
    else
    {
        if (flags & GPATH_REAL)
        {
            append(sig, fileName, strlen(fileName) + 1);

            struct stat s;
            stat(gpath_transform(fileName), &s);
            append(sig, &s.st_mtime, sizeof(s.st_mtime));
        }
    }

    GGSound *sound = NULL;

    luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keySound);

    if (sig.empty())
    {
        lua_pushnil(L);
    }
    else
    {
        lua_pushlstring(L, &sig[0], sig.size());
        lua_rawget(L, -2);
    }

    if (!lua_isnil(L, -1))
    {
        sound = static_cast<GGSound*>(lua_touserdata(L, -1));
        sound->ref();
    }
    else
    {
        gaudio_Error error;
        sound = new GGSound(L, fileName, &error, sig);

        switch (error)
        {
        case GAUDIO_NO_ERROR:
            break;
        case GAUDIO_CANNOT_OPEN_FILE:
            sound->unref();
            luaL_error(L, "%s: No such file or directory.", fileName);
            break;
        case GAUDIO_UNRECOGNIZED_FORMAT:
            sound->unref();
            luaL_error(L, "%s: Sound format is not recognized.", fileName);
            break;
        case GAUDIO_ERROR_WHILE_READING:
            sound->unref();
            luaL_error(L, "%s: Error while reading.", fileName);
            break;
        case GAUDIO_UNSUPPORTED_FORMAT:
            sound->unref();
            luaL_error(L, "%s: Sound format is not supported.", fileName);
            break;
        case GAUDIO_INTERNAL_ERROR:
            sound->unref();
            luaL_error(L, "%s: Sound internal error.", fileName);
            break;
        }
    }

    lua_pop(L, 2);

    binder.pushInstance("Sound", sound);

    return 1;
}
开发者ID:marynate,项目名称:gideros,代码行数:83,代码来源:audiobinder.cpp


示例9: UpdateAI


//.........这里部分代码省略.........
                        } break;
                        case 7: EventStartedPart1 = false; EventStartedPart2 = true; Phase = 8; break;
                        default: break;
                    }
                }
            }
            if(EventStartedPart2)
            {
                if(Player* pPlayer = me->GetPlayer(*me, PlayerGuid))
                if(Creature* pCreature = me->FindNearestCreature(42852, 40.0f, true))
                if(Creature* pCrushcog = me->FindNearestCreature(42839, 40.0f, true))
                {
                    switch(Phase)
                    {
                        case 8: pCrushcog->MonsterSay("You! How did you escape detection by my sentry-bots?", 0, 0); Timer = 3000; Phase++; break;
                        case 9: pCrushcog->MonsterSay("No matter! My guardians and I will make short work of you. To arms, men!", 0, 0); Timer = 2000; Phase++; break;
                        case 10: AttackPhase = true; Phase++; Timer = 250; break;
                        case 11:
                        {
                            AddRemoveFlagsFromAdds();
                            pCrushcog->MonsterSay("You will never defeat the true sons of Gnomergan", 0, 0);
                            pCrushcog->SetReactState(REACT_AGGRESSIVE);
                            pCrushcog->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            pCrushcog->CombatStart(me, true);
                            me->Attack(pCrushcog, true);
                            Phase = 12;
                        } break;
                        default: break;
                    }
                    if(pCrushcog)
                        Timer = 7000;
                }
                if(Creature* pCreature = me->FindNearestCreature(42852, 40.0f, true))
                if(Creature* pCrushcog = me->FindNearestCreature(42839, 40.0f, false))
                {
                    switch(Phase)
                    {
                        case 12:
                        {
                            RemoveCrushcogAdds();
                            pCreature->MonsterSay("That'll teach you to mess with the might of Ironforge and Gnomeregan!", 0, 0);
                            Timer = 1500; Phase++;
                        } break;
                        case 13: me->MonsterSay("We've done it! We're victorious!", 0, 0); Timer = 4500; Phase++; break;
                        case 14: me->MonsterSay("With Crushcog defeated. Thermaplugg is sure to be quaking in his mechano-tank, and rightly so. You're next Thermaplugg. You're next!", 0, 0); Phase++; Timer = 4000; break;
                        case 15:
                        {
                            AddQuestComplete();
                            me->GetMotionMaster()->MovePoint(1, -5261.2f, 119.33f, 393.79f);
                            pCreature->GetMotionMaster()->MovePoint(2, -5260.88f, 123.25f, 393.88f);
                            Phase++;
                            Timer = 16000;
                        }
                        case 16:
                        {
                            me->GetMotionMaster()->MoveTargetedHome();
                            pCreature->GetMotionMaster()->MoveTargetedHome();
                            me->AI()->Reset();
                            pCreature->AI()->Reset();
                        } break;
                        default: break;
                    }
                }
                if(Creature* pCrushcog = me->FindNearestCreature(42839, 10.0f, true))
                if(Creature* pRayTarget = me->FindNearestCreature(42929, 50.0f, true))
                {
                    //Niestety Spelle jeszcze niedzia?aj? wiec work-around
                    //me->CastSpell(pRayTarget, RayType[urand(0,3)], true);
                    me->MonsterYell("Mekkatorque-Ray!", 0, 0);

                    std::list<Unit*> BeamTarget;
                    Trinity::AnyUnitInObjectRangeCheck checker(me, 15);
                    Trinity::UnitListSearcher<Trinity::AnyUnitInObjectRangeCheck> searcher(me, BeamTarget, checker);
                    me->VisitNearbyWorldObject(15.0f, searcher);

                    for (std::list<Unit*>::iterator itr = BeamTarget.begin(); itr != BeamTarget.end(); ++itr)
                    {
                        if((*itr)->GetTypeId() == TYPEID_PLAYER)
                            return;

                        me->CastSpell((*itr), RayType[urand(0,3)], true);
                        me->DealDamage((*itr), ((*itr)->GetHealth()*0.15), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                    }
                    me->CastSpell(pCrushcog, RayType[urand(0,3)], true);
                    me->DealDamage(pCrushcog, (pCrushcog->GetHealth()*0.15), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                    pRayTarget->DespawnOrUnsummon();
                }
            //I know it's imposible but...
                if(Creature* pCreature = me->FindNearestCreature(42852, 40.0f, false))
                    me->AI()->Reset();

                if(me->isDead())
                {
                    Creature* pCreature = me->FindNearestCreature(42852, 40.0f, false);
                    if(pCreature)
                        pCreature->AI()->Reset();
                }
            }
        } else Timer -= diff;
    }
开发者ID:AwkwardDev,项目名称:WoWSource434,代码行数:101,代码来源:zone_dun_morogh.cpp


示例10: PropagateNoContraction

void PropagateNoContraction(const glslang::TIntermediate& intermediate)
{
    // First, traverses the AST, records symbols with their defining operations
    // and collects the initial set of precise symbols (symbol nodes that marked
    // as 'noContraction') and precise return nodes.
    auto mappings_and_precise_objects =
        getSymbolToDefinitionMappingAndPreciseSymbolIDs(intermediate);

    // The mapping of symbol node IDs to their defining nodes. This enables us
    // to get the defining node directly from a given symbol ID without
    // traversing the tree again.
    NodeMapping& symbol_definition_mapping = std::get<0>(mappings_and_precise_objects);

    // The mapping of object nodes to their access chains recorded.
    AccessChainMapping& accesschain_mapping = std::get<1>(mappings_and_precise_objects);

    // The initial set of 'precise' objects which are represented as the
    // access chain toward them.
    ObjectAccesschainSet& precise_object_accesschains = std::get<2>(mappings_and_precise_objects);

    // The set of 'precise' return nodes.
    ReturnBranchNodeSet& precise_return_nodes = std::get<3>(mappings_and_precise_objects);

    // Second, uses the initial set of precise objects as a work list, pops an
    // access chain, extract the symbol ID from it. Then:
    //  1) Check the assignee object, see if it is 'precise' object node or
    //  contains 'precise' object. Obtain the incremental access chain from the
    //  assignee node to its nested 'precise' node (if any).
    //  2) If the assignee object node is 'precise' or it contains 'precise'
    //  objects, traverses the right side of the assignment operation
    //  expression to mark arithmetic operations as 'noContration' and update
    //  'precise' access chain work list with new found object nodes.
    // Repeat above steps until the work list is empty.
    TNoContractionAssigneeCheckingTraverser checker(accesschain_mapping);
    TNoContractionPropagator propagator(&precise_object_accesschains, accesschain_mapping);

    // We have two initial precise work lists to handle:
    //  1) precise return nodes
    //  2) precise object access chains
    // We should process the precise return nodes first and the involved
    // objects in the return expression should be added to the precise object
    // access chain set.
    while (!precise_return_nodes.empty()) {
        glslang::TIntermBranch* precise_return_node = *precise_return_nodes.begin();
        propagator.propagateNoContractionInReturnNode(precise_return_node);
        precise_return_nodes.erase(precise_return_node);
    }

    while (!precise_object_accesschains.empty()) {
        // Get the access chain of a precise object from the work list.
        ObjectAccessChain precise_object_accesschain = *precise_object_accesschains.begin();
        // Get the symbol id from the access chain.
        ObjectAccessChain symbol_id = getFrontElement(precise_object_accesschain);
        // Get all the defining nodes of that symbol ID.
        std::pair<NodeMapping::iterator, NodeMapping::iterator> range =
            symbol_definition_mapping.equal_range(symbol_id);
        // Visits all the assignment nodes of that symbol ID and
        //  1) Check if the assignee node is 'precise' or contains 'precise'
        //  objects.
        //  2) Propagate the 'precise' to the top layer object nodes
        //  in the right side of the assignment operation, update the 'precise'
        //  work list with new access chains representing the new 'precise'
        //  objects, and mark arithmetic operations as 'noContraction'.
        for (NodeMapping::iterator defining_node_iter = range.first;
             defining_node_iter != range.second; defining_node_iter++) {
            TIntermOperator* defining_node = defining_node_iter->second;
            // Check the assignee node.
            auto checker_result = checker.getPrecisenessAndRemainedAccessChain(
                defining_node, precise_object_accesschain);
            bool& contain_precise = std::get<0>(checker_result);
            ObjectAccessChain& remained_accesschain = std::get<1>(checker_result);
            // If the assignee node is 'precise' or contains 'precise', propagate the
            // 'precise' to the right. Otherwise just skip this assignment node.
            if (contain_precise) {
                propagator.propagateNoContractionInOneExpression(defining_node,
                                                                 remained_accesschain);
            }
        }
        // Remove the last processed 'precise' object from the work list.
        precise_object_accesschains.erase(precise_object_accesschain);
    }
}
开发者ID:Alcaro,项目名称:RetroArch,代码行数:82,代码来源:propagateNoContraction.cpp


示例11: RectToScr

void cbHintAnimationPlugin::DoDrawHintRect( wxRect& rect, bool isInClientRect)
{
    wxRect scrRect;

    RectToScr( rect, scrRect );

    int prevLF = mpScrDc->GetLogicalFunction();

    mpScrDc->SetLogicalFunction( wxXOR );

    if ( isInClientRect )
    {
        // BUG BUG BUG (wx):: somehow stippled brush works only
        //                      when the bitmap created on stack, not
        //                      as a member of the class

        wxBitmap checker( (const char*)_gCheckerImg, 8,8 );

        wxBrush checkerBrush( checker );

        mpScrDc->SetPen( mpLayout->mNullPen );
        mpScrDc->SetBrush( checkerBrush );

        int half = mInClientHintBorder / 2;

        mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y - half,
                                scrRect.width + 2*half, mInClientHintBorder );

        mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y + scrRect.height - half,
                                scrRect.width + 2*half, mInClientHintBorder );

        mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y + half - 1,
                                mInClientHintBorder, scrRect.height - 2*half + 2);

        mpScrDc->DrawRectangle( scrRect.x + scrRect.width - half,
                                scrRect.y + half - 1,
                                mInClientHintBorder, scrRect.height - 2*half + 2);

        mpScrDc->SetBrush( wxNullBrush );
    }
    else
    {
        // otherwise draw 1-pixel thin borders

        mpScrDc->SetPen( mpLayout->mBlackPen );

        mpScrDc->DrawLine( scrRect.x, scrRect.y,
                           scrRect.x + scrRect.width, scrRect.y );

        mpScrDc->DrawLine( scrRect.x, scrRect.y + 1,
                           scrRect.x, scrRect.y + scrRect.height );

        mpScrDc->DrawLine( scrRect.x+1, scrRect.y + scrRect.height,
                           scrRect.x + scrRect.width, scrRect.y + scrRect.height );

        mpScrDc->DrawLine( scrRect.x + scrRect.width , scrRect.y,
                           scrRect.x + scrRect.width, scrRect.y + scrRect.height + 1);
    }

    mpScrDc->SetLogicalFunction( prevLF );
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:61,代码来源:hintanimpl.cpp


示例12: checker

glm::vec3 BoundingBoxMesh::getColor(const glm::vec3& position) const {

  if( equalsEpsilon(position.z, zLimits_.y) ) {
    return glm::vec3(0.5f, 0.8f, 0.5f);
  }

  if( equalsEpsilon(position.x, xLimits_.x) ) {
    glm::vec2 len{zLimits_.y - zLimits_.x, 
                  yLimits_.y - yLimits_.x};

    glm::vec2 uv{(zLimits_.y - position.z) / len.x, 
                 (yLimits_.y - position.y) / len.y};

    uv.y = 1.0f - uv.y;
    unsigned int row = uv.y * bitmapHeight_;
    unsigned int col = uv.x * bitmapWidth_;

    // std::cout << "width: " << bitmapHeight_ << std::endl;
    // std::cout << "height: " << bitmapWidth_ << std::endl;
    // std::cout << "size: " << bitmapSize_ << std::endl;
    // std::cout << "pos: " << row << " " << col << std::endl;

    unsigned int index = (row * bitmapWidth_ + col) * bitmapChannels_;
    // std::cout << "index: " << index << std::endl;
    // unsigned char alfa = bitmapData_[index];
    unsigned char red;   
    unsigned char green;
    unsigned char blue;

    // if( bitmapChannels_ == 3 ) {
      red = bitmapData_[index];
      green = bitmapData_[index + 1];
      blue = bitmapData_[index + 2];
    // } else {
    //   red = bitmapData_[index + 3];
    //   green = bitmapData_[index + 2];
    //   blue = bitmapData_[index + 1];
    // }

    glm::vec3 color{(float)red/(float)255, (float)green/(float)255, (float)blue/(float)255};
    // std::cout << "uv: " << uv.x << " " << uv.y << std::endl;
    // return glm::vec3(uv.y, 1.0f - uv.y, 0.0f);
    return color;
    // return glm::vec3(0.1f, 0.12f, 1.0f);
  }

  if( equalsEpsilon(position.x, xLimits_.y) ) {
    return glm::vec3(1.0f, 0.1f, 0.12f);
  }

  if( equalsEpsilon(position.y, yLimits_.x) ) {
    // glm::vec2 len{zLimits_.y - zLimits_.x, xLimits_.y - xLimits_.x};
    // glm::vec2 uv{(position.z / len.x), (position.x / len.y)};
    const glm::vec3 color1 = glm::vec3{0.9f, 0.9, 0.9f};
    const glm::vec3 color2 = glm::vec3{0.1f, 0.1f, 0.1f};
    return checker(position, color1, color2);
  }

  if( equalsEpsilon(position.y, yLimits_.y) ) {
    return glm::vec3(1.0f, 0.968627451f, 0.8f);
  }

  // return glm::vec3(0.1f, 0.12f, 1.0f);
  return glm::vec3(1.0f, 1.0f, 0.1f);

}
开发者ID:niklasandersson,项目名称:MonteCarloRaytracing,代码行数:66,代码来源:BoundingBoxMesh.cpp


示例13: genCode

void genCode(astree* root, SymbolTable* table){
   if (root == NULL) {
	  return;
   }
   
   string currsym = get_yytname(root->symbol);

   if (currsym == "program") {
      for (size_t child = 0; child < root->children.size(); ++child) {
         string currsymbol = get_yytname(root->children[child]->symbol);
		 
         if (currsymbol == "vardecl") {
            string child2 = get_yytname(root->children[child]->children[2]->symbol);
            string ident = root->children[child]->children[1]->lexinfo->c_str();
            string declt = root->children[child]->children[0]->children[0]->children[0]->lexinfo->c_str();
            string newtype = converter(declt);
			
            if(root->children[child]->children[0]->children.size() == 2){
               declt = declt + "[]";
               newtype = converter(declt);
               fprintf(oilFile, "%s__%s;\n", newtype.c_str(), ident.c_str());
            } else {
               fprintf(oilFile, "%s__%s;\n", newtype.c_str(), ident.c_str());
            }
         }
         if (currsymbol == "struct_") {
			genCode(root->children[child], table);
		 }
      }

      fprintf(oilFile, "void __ocmain ()\n{\n");

      for (size_t child = 0; child < root->children.size(); ++child) {
         string currsymbol = get_yytname(root->children[child]->symbol);
         if (currsymbol != "vardecl" && currsymbol != "struct_") {
			genCode(root->children[child], table);
		 }
      }
      fprintf(oilFile, "}\n");
   }

   if (currsym == "vardecl") {
      string ident = root->children[1]->lexinfo->c_str();
      string dect = checker(root->children[1], table);
      if (root->children[0]->children.size() == 2) dect = dect + "[]";
      dect = converter(dect);
      string child2 = get_yytname(root->children[2]->symbol);
      if (child2 == "constant") {
         fprintf(oilFile, "%s_%d_%s = __%s\n", dect.c_str(),table->numBack(), ident.c_str(), root->children[2]->children[0]->lexinfo->c_str());
	  }
      if (child2 == "variable") {
         fprintf(oilFile, "%s_%d_%s = _%d_%s\n", dect.c_str(),table->numBack(), ident.c_str(), table->numBack(), root->children[2]->children[0]->lexinfo->c_str());
	  }
   }

   if (currsym == "binop") {
      string op = root->children[1]->lexinfo->c_str();
      if (op == "+" || op == "-" || op == "/" || op == "%" || op == "*") {
         int counter = icount++;
         string child0 = get_yytname(root->children[0]->symbol);
         string child2 = get_yytname(root->children[2]->symbol);
         if (child0 != "constant" && child0 != "constant") {
            genCode(root->children[0], table);
            fprintf(oilFile, "i%d = i%d ", counter, counter-1);
         }
         else if (child2 != "constant" && child2 != "constant") {
            genCode(root->children[2], table);
            fprintf(oilFile, "i%d = i%d ", counter, counter-1);
         } else {
			fprintf(oilFile, "i%d = ", counter);
		 }

         if(child0 == "constant") {
			fprintf(oilFile, "%s ", root->children[0]->children[0]->lexinfo->c_str());
		 }
         if(child0 == "variable") {
			fprintf(oilFile, "_%d_%s ", table->numBack(), root->children[0]->children[0]->lexinfo->c_str());
		 }
         fprintf(oilFile, "%s ", root->children[1]->lexinfo->c_str());
         if(child2 == "constant") {
			fprintf(oilFile, "%s;\n", root->children[2]->children[0]->lexinfo->c_str());
		 }
         if(child2 == "variable") {
			fprintf(oilFile, "_%d_%s;\n", table->numBack(), root->children[2]->children[0]->lexinfo->c_str());
		 }      
      }
	  
      if (op == ">" || op == "<" || op == ">=" || op == "<=" || op == "!=" || op == "==") {
         int counter = bcount++;
         string child0 = get_yytname(root->children[0]->symbol);
         string child2 = get_yytname(root->children[2]->symbol);
         if (child0 != "constant" && child0 != "constant") {
            genCode(root->children[0], table);
            fprintf(oilFile, "b%d = b%d ", counter, counter-1);
         }
         else if (child2 != "constant" && child2 != "constant") {
            genCode(root->children[2], table);
            fprintf(oilFile, "b%d = b%d ", counter, counter-1);
         } else {
			fprintf(oilFile, "b%d = ", counter);
//.........这里部分代码省略.........
开发者ID:Nicojaw,项目名称:104a-A5,代码行数:101,代码来源:astree.cpp


示例14: checker

string checker(astree* root, SymbolTable* table){
   if(root == NULL) return NULL;
   string names = get_yytname(root->symbol);

   if(names == "TOK_INT" || names == "TOK_INTCON") return "int";
   if(names == "TOK_CHAR" || names == "TOK_CHARCON") return "char";
   if(names == "TOK_STRING" || names == "TOK_STRINGCON") return "string";
   if(names == "TOK_BOOL" || names == "TOK_TRUE" || names == "TOK_FALSE") return "bool";
   if(names == "TOK_NULL") return "null";

   if(names == "TOK_IDENT") return table->lookup(root->lexinfo->c_str());
   if(names == "constant") return checker(root->children[0], table);
   if(names == "type"){
      if(root->children.size() == 2){
         string type = checker(root->children[0],table);
         type = type + "[]";
         return type;
      }
    return checker(root->children[0], table);
   }
   if(names == "basetype"){
      string offSpr = get_yytname(root->children[0]->symbol);
      string ident = root->children[0]->lexinfo->c_str();
      if(offSpr == "TOK_IDENT"){
         if (strSym->lookup2(ident) != NULL) return ident;
      }
      return checker(root->children[0], table);

   }
   if(names == "variable") {
      if(root->children.size() == 1) return checker(root->children[0], table);
      if(root->children.size() == 2){
         string offSpr2 = get_yytname(root->children[1]->symbol);
         SymbolTable* curnt;
         if(offSpr2 == "TOK_IDENT"){
            string offSpr = checker(root->children[0],table);
            string ident = root->children[1]->lexinfo->c_str();
            if(strSym->lookup2(offSpr) != NULL){
               curnt = strSym->lookup2(offSpr);
               if (curnt == NULL){ 
                  errprintf("Not a variable of this struct!\n");
                  return "";
               }
               return curnt->lookup(ident);
            }
         }else{
            if(checker(root->children[1],table) == "int" && checker(root->children[0],table) == "string") return "char"; 
            if(checker(root->children[1],table) == "int" && checker(root->children[0],table) == "int[]") return "int";
            if(checker(root->children[1],table) == "int" && checker(root->children[0],table) == "bool[]") return "bool";
            if(checker(root->children[1],table) == "int" && checker(root->children[0],table) == "char[]") return "char";
            if(checker(root->children[1],table) == "int" && checker(root->children[0],table) == "struct[]") return "struct";
            if(checker(root->children[1],table) == "int" && checker(root->children[0],table) == "string[]") return "string";
         }
      }

   }

   i 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ checkerr函数代码示例发布时间:2022-05-30
下一篇:
C++ checked_get_container_size函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap