Example #1
0
void UnLockSystem::LoadUnLockData()
{
    int32_t unlockEventId;
    
    const ValueMapIntKey* cfgRowData;
    
    //      事件Id     触发条件       获取结果
    tuple<uint32_t, ValueMapIntMultiKey, ValueMapIntMultiKey> tupleData;
    
    const vector<uint32_t>* vi = CfgData::getInstance()->GetCfgTableId("UnlockEvent");
    ValueVector* vv = &UserData::getInstance()->GetUserData(UserDataEnum::UnLockIdList)->asValueVector();
    
    vector<tuple<uint32_t, ValueMapIntMultiKey, ValueMapIntMultiKey>>* eventData;
    vector<tuple<uint32_t, ValueMapIntMultiKey, ValueMapIntMultiKey>>* getItemEvent = &sm_UnLockData->at((int)UserEventType::GetItemEvent);
    vector<tuple<uint32_t, ValueMapIntMultiKey, ValueMapIntMultiKey>>* makeBuildEvent = &sm_UnLockData->at((int)UserEventType::MakeBuildEvent);
    vector<tuple<uint32_t, ValueMapIntMultiKey, ValueMapIntMultiKey>>* goToNewMapEvent = &sm_UnLockData->at((int)UserEventType::GoToNewMapEvent);
    vector<tuple<uint32_t, ValueMapIntMultiKey, ValueMapIntMultiKey>>* captureBuildEvent = &sm_UnLockData->at((int)UserEventType::CaptureBuildEvent);
    
    
    for (auto vi_iter = vi->begin(); vi_iter != vi->end(); vi_iter++)
    {
        unlockEventId = *vi_iter;
        if(find(vv->begin(), vv->end(), Value(unlockEventId)) == vv->end())
        {
            eventData = nullptr;
            switch (unlockEventId / 1000)
            {
                case 300001:
                    eventData = makeBuildEvent;
                    break;
                case 300002:
                    eventData = getItemEvent;
                    break;
                case 300003:
                    eventData = captureBuildEvent;
                    break;
                case 300004:
                    eventData = goToNewMapEvent;
                    break;
                    
                default:
                    break;
            }
            
            if (eventData != nullptr)
            {
                cfgRowData = CfgData::getInstance()->GetCfgRow(unlockEventId);
                if (cfgRowData == nullptr)  continue;
                tupleData = make_tuple(unlockEventId, cfgRowData->at((int)CfgField::TriggerID_M).asIntMultiKeyMap(),
                                       cfgRowData->at((int)CfgField::FunctionID_M).asIntMultiKeyMap());
                
                eventData->push_back(tupleData);
                CfgData::getInstance()->DeleteCfgId(unlockEventId);
            }
            
        }
    }

}
Example #2
0
bool UIHeroDetailLayer::loadRepoEquips( eEquipType type, int page_index ) {
    this->setSelectedRepoCell( nullptr );
    if( page_index >= 0 ) {
        int start_index = 6 * page_index;
        ValueVector data = PlayerInfo::getInstance()->getEquipsByRange( (int)type, start_index, 7, 2 );
        
        if( _current_equip_list->getPages().size() <= page_index ) {
            ui::Layout* new_page = ui::Layout::create();
            _current_equip_list->addPage( new_page );
        }
        ui::Layout* page = _current_equip_list->getPages().at( page_index );
        page->removeAllChildren();
        
        if( data.size() > 0 ) {
            int i = 0;
            for( auto itr = data.begin(); itr != data.end(); ++itr ) {
                UIEquipmentCell* cell = UIEquipmentCell::create( itr->asValueMap(), "ui_detail_icon01.png" );
                Point cell_pos = Point::ZERO;
                switch( i ) {
                    case 0:
                        cell_pos = Point( 120, 250 );
                        break;
                    case 1:
                        cell_pos = Point( 315, 250 );
                        break;
                    case 2:
                        cell_pos = Point( 510, 250 );
                        break;
                    case 3:
                        cell_pos = Point( 120, 90 );
                        break;
                    case 4:
                        cell_pos = Point( 315, 90 );
                        break;
                    case 5:
                        cell_pos = Point( 510, 90 );
                        break;
                    default:
                        break;
                }
                cell->setPosition( cell_pos );
                page->addChild( cell );
                if( ++i >= 6 ) {
                    break;
                }
            }
        }
        
        _btn_prev->setVisible( start_index > 0 );
        _btn_next->setVisible( data.size() == 7 );
        
        return true;
    }

    return false;
}
Example #3
0
void ShapeCacher::addShapesWithDictionary(ValueMap &dictionary, PhysicsBody *body)
{
	//decode the plist file
	int format = 0;
	// get the format
	if (dictionary.find("metadata") != dictionary.end())
	{
		ValueMap& metadataDict = dictionary["metadata"].asValueMap();
		format = metadataDict["format"].asInt();
	}
	// check the format
	CCASSERT(format == 1, "format is not supported for #addShapesWithDictionary#:");

	ValueMap& bodyDict = dictionary["bodies"].asValueMap();

	for (auto iter = bodyDict.begin(); iter != bodyDict.end(); ++iter)
	{
		ValueMap& dataDict = iter->second.asValueMap();

		/****************not used yet!***********************/
		//set anchorpoint	
		//Point anchorPoint = PointFromString(dataDict["anchorpoint"].asString());
	
		ValueVector& fixtureVector = dataDict["fixtures"].asValueVector();

		for (auto iter = fixtureVector.begin(); iter != fixtureVector.end(); ++iter)
		{
			ValueMap& fixtureDict =(ValueMap&)(*iter).asValueMap();

			/****************not used yet!***********************/

			/* //body->setCategoryBitmask(fixtureDict["filter_categoryBits"].asInt);
			/* //body->setCollisionBitmask(fixtureDict["filter_maskBits"].asInt);
			/* //body->setGroup(fixtureDict["filter_groupIndex"].asInt);

			/* //float friction    = fixtureDict["friction"].asFloat;
			/* //float density     = fixtureDict["density"].asFloat;
			/* //float restitution = fixtureDict["restitution"].asFloat;
			/* //int   isSensor    = fixtureDict["isSensor"].asInt;
			/* //std::string userdata = fixtureDict["userdataCbValue"].asString;
			/* 
			/* //std::string fixtureType = fixtureDict["fixture_type"].asString();
			/* 
			/* if (fixtureType == "POLYGON") 
			{*/
			/****************not used yet!***********************/
			ValueVector& polygonsVector = (fixtureDict["polygons"].asValueVector());

			for (auto iter = polygonsVector.begin(); iter != polygonsVector.end(); ++iter) 
			{
				int vertexNum = (*iter).asValueVector().size();;
				ValueVector polygonArray = (*iter).asValueVector();
				Point *polyVertex = new Point[vertexNum];
				int i = 0;
				for (auto piter = polygonArray.begin(); piter != polygonArray.end(), i < vertexNum; ++piter ,i++)
				{
					Point vertex = PointFromString((*piter).asString());
					polyVertex[i] = vertex;
				}
				body->addShape(PhysicsShapePolygon::create(polyVertex, vertexNum));
				CC_SAFE_DELETE_ARRAY(polyVertex);
			}

		}
		//	else if (fixtureType == "CIRCLE") 
		//	{

		//		continue;
		//		//ObjectDict *circleData = (ObjectDict *)fixtureData->objectForKey("circle");

		//		//b2CircleShape *circleShape = new b2CircleShape();

		//		//circleShape->m_radius = static_cast<CCString *>(circleData->objectForKey("radius"))->toFloat() / ptmRatio;
		//		//CCPoint p = CCPointFromString(static_cast<CCString *>(circleData->objectForKey("position"))->toStdString().c_str());
		//		//circleShape->m_p = b2Vec2(p.x / ptmRatio, p.y / ptmRatio);
		//		//fix->fixture.shape = circleShape;

		//		//// create a list
		//		//*nextFixtureDef = fix;
		//		//nextFixtureDef = &(fix->next);

		//	}
		//	else 
		//	{
		//		CCAssert(0, "Unknown fixtureType");
		//	}
		//}
	}
}
Example #4
0
static jobject ValueVector2SFSArray(JNIEnv* env, const ValueVector& valueVector, jobject javaObj)
{
    jclass cls = env->GetObjectClass(javaObj);
    if (!cls) return javaObj;

    for (auto it = valueVector.begin(); it != valueVector.end(); ++it)
    {
        if (it->getType() == Value::Type::BYTE)
        {
            jmethodID mid = env->GetMethodID(cls, "addByte", "(B)V");
            if (mid) env->CallVoidMethod(javaObj, mid, it->asByte());
        }
        else if (it->getType() == Value::Type::INTEGER)
        {
            jmethodID mid = env->GetMethodID(cls, "addInt", "(I)V");
            if (mid) env->CallVoidMethod(javaObj, mid, it->asInt());
        }
        else if (it->getType() == Value::Type::FLOAT)
        {
            jmethodID mid = env->GetMethodID(cls, "addFloat", "(F)V");
            if (mid) env->CallVoidMethod(javaObj, mid, it->asFloat());
        }
        else if (it->getType() == Value::Type::DOUBLE)
        {
            jmethodID mid = env->GetMethodID(cls, "addFloat", "(F)V");
            if (mid) env->CallVoidMethod(javaObj, mid, it->asDouble());
        }
        else if (it->getType() == Value::Type::BOOLEAN)
        {
            jmethodID mid = env->GetMethodID(cls, "addBool", "(Z)V");
            if (mid) env->CallVoidMethod(javaObj, mid, it->asBool());
        }
        else if (it->getType() == Value::Type::STRING)
        {
            jmethodID mid = env->GetMethodID(cls, "addUtfString", "(Ljava/lang/String;)V");
            if (mid)
            {
                jobject javaValue = env->NewStringUTF(it->asString().c_str());
                env->CallVoidMethod(javaObj, mid, javaValue);
                env->DeleteLocalRef(javaValue);
            }
        }
        else if (it->getType() == Value::Type::VECTOR)
        {
            jmethodID mid = env->GetMethodID(cls, "addSFSArray", "(Lcom/smartfoxserver/v2/entities/data/ISFSArray;)V");
            if (mid)
            {
                jobject javaSFSArray = getSFSArray(env);
                jobject javaValue = ValueVector2SFSArray(env, it->asValueVector(), javaSFSArray);
                env->CallVoidMethod(javaObj, mid, javaValue);
                env->DeleteLocalRef(javaValue);
            }
        }
        else if (it->getType() == Value::Type::MAP)
        {
            jmethodID mid = env->GetMethodID(cls, "addSFSObject", "(Lcom/smartfoxserver/v2/entities/data/ISFSObject;)V");
            if (mid)
            {
                jobject sub_obj = getSFSObject(env);
                jobject javaValue = ValueMap2SFSObject(env, it->asValueMap(), sub_obj);
                env->CallVoidMethod(javaObj, mid, javaValue);
                env->DeleteLocalRef(javaValue);
            }
        }
        else if (it->getType() == Value::Type::INT_KEY_MAP)
        {

        }
    }
    env->DeleteLocalRef(cls);

    return javaObj;
}
Example #5
0
File: pass.cpp Project: shvo/canyon
    bool runOnFunction(Function &F) override {
    	AliasAnalysis AA = getAnalysis<AliasAnalysis>();
        DependenceAnalysis *DA = &(getAnalysis<DependenceAnalysis>());
        // iterate over basic blocks
        Function *func = &F;
        unsigned bb_num = 0;
        for (Function::iterator BB = func->begin(), BE = func->end();
       BB != BE; ++BB) {
        	errs() << "BB-" << bb_num << "\n";
            bb_num++;
            // iterator over instructions
            unsigned inst_num = 0;
            for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E;++I) {
                Instruction *Ins = dyn_cast<Instruction>(I);
                if (!Ins)
                    return false;
                LoadInst *Ld = dyn_cast<LoadInst>(I);
                StoreInst *St = dyn_cast<StoreInst>(I);
                if (!St && !Ld)
                    continue;
                if (Ld && !Ld->isSimple())
                    return false;
                if (St && !St->isSimple())
                    return false;
                inst_num++;
                MemInstr.push_back(&*I);
                errs() << "MemInst-" << inst_num << ":" << *I << "\n";
            }

        	ValueVector::iterator I, IE, J, JE;
            for (I = MemInstr.begin(), IE = MemInstr.end(); I != IE; ++I) {
            for (J = I, JE = MemInstr.end(); J != JE; ++J) {
                std::vector<char> Dep;
                Instruction *Src = dyn_cast<Instruction>(*I);
                Instruction *Des = dyn_cast<Instruction>(*J);
                if (Src == Des)
                    continue;
                if (isa<LoadInst>(Src) && isa<LoadInst>(Des))
                    continue;
                if (auto D = DA->depends(Src, Des, true)) {
                    errs() << "Found Dependency between:\nSrc:" << *Src << "\nDes:" << *Des
                     << "\n";
                	if (D->isFlow()) {
                    	errs () << "Flow dependence not handled";
                    	return false;
                	}
                
                	if (D->isAnti()) {
                    	errs() << "Found Anti dependence \n";

						AliasAnalysis::AliasResult AA_dep = AA.alias(Src, Des);
                        AliasAnalysis::AliasResult AA_dep_1 = AA.alias(Des, Src);
                    	errs() << "The Ld->St alias result is " << AA_dep << "\n";
                    	errs() << "The St->Ld alias result is " << AA_dep_1 << "\n";
                    	
                        unsigned Levels = D->getLevels();
                    	errs() << "levels = " << Levels << "\n";
                    	char Direction;
                    	for (unsigned II = 1; II <= Levels; ++II) {
                        	const SCEV *Distance = D->getDistance(II);
                        	const SCEVConstant *SCEVConst = dyn_cast_or_null<SCEVConstant>(Distance);
                        	if (SCEVConst) {
                            	const ConstantInt *CI = SCEVConst->getValue();
                                //int64_t it_dist = CI->getUniqueInteger().getSExtValue();
                                //int it_dist = CI->getUniqueInteger().getSExtValue();
                               	unsigned it_dist = abs(CI->getUniqueInteger().getSExtValue());
                            	errs() << "distance is not null\n";
                            	//errs() << "distance = "<< *CI << "\n";
                            	errs() << "distance = "<< it_dist << "\n";
                       			if (CI->isNegative())
                            		Direction = '<';
                        		else if (CI->isZero())
                            		Direction = '=';
                        		else
                            		Direction = '>';
                        		Dep.push_back(Direction);
                        	} 
                        	else if (D->isScalar(II)) {
                        		Direction = 'S';
                        		Dep.push_back(Direction);
                        	} 
                        	else {
                            	unsigned Dir = D->getDirection(II);
                            	if (Dir == Dependence::DVEntry::LT || Dir == Dependence::DVEntry::LE)
                                	Direction = '<';
                            	else if (Dir == Dependence::DVEntry::GT || Dir == Dependence::DVEntry::GE)
                                	Direction = '>';
                            	else if (Dir == Dependence::DVEntry::EQ)
                                	Direction = '=';
                            	else
                                	Direction = '*';
                            	Dep.push_back(Direction);
                        	}
                    	}
                	}
              	}
            }
        	}
        }
        errs() << "------Hello World!--------\n";
        return false;
    }