Exemplo n.º 1
0
void gep::HavokWorld::castRay(const RayCastInput& input, RayCastOutput& output) const
{
    hkpWorldRayCastInput actualInput;
    hkpWorldRayCastOutput actualOutput;

    // Process input
    conversion::hk::to(input.from, actualInput.m_from);
    conversion::hk::to(input.to, actualInput.m_to);
    actualInput.m_filterInfo = input.filterInfo;

    // Cast the ray
    {
        m_pWorld->lock();
        m_pWorld->castRay(actualInput, actualOutput);
        m_pWorld->unlock();
    }

    // Process output
    output.hitFraction = actualOutput.m_hitFraction;
    conversion::hk::from(actualOutput.m_normal, output.normal);
    if (actualOutput.m_rootCollidable)
    {
        // We only support rigid bodies right now.
        auto actualEntity = static_cast<hkpEntity*>(actualOutput.m_rootCollidable->getOwner());
        output.pHitBody = static_cast<IRigidBody*>(reinterpret_cast<IPhysicsEntity*>(actualEntity->getUserData()));
    }
}
Exemplo n.º 2
0
struct jData *
copyJData(struct jData *jp)
{
    struct jData *jData;
    struct rqHistory *reqHistory;
    int          i;

    jData = initJData(jp->shared);

    if (jData->jobSpoolDir) {
        FREEUP(jData->jobSpoolDir);
    }
    reqHistory = jData->reqHistory;
    memcpy((char *)jData, (char *)jp, sizeof(struct jData));
    jData->reqHistory = reqHistory;
    jData->numRef = 0;
    jData->nextJob = NULL;

    jData->userName = safeSave(jp->userName);
    jData->schedHost = safeSave(jp->schedHost);
    jData->uPtr = getUserData(jData->userName);

    if (jp->askedPtr) {
        jData->askedPtr = (struct askedHost *) my_calloc (jp->numAskedPtr,
                                                          sizeof(struct askedHost), "copyJData");
        for (i = 0; i < jp->numAskedPtr; i++) {
            jData->askedPtr[i].hData = jp->askedPtr[i].hData;
            jData->askedPtr[i].priority = jp->askedPtr[i].priority;
        }
    }
    if (jp->jobSpoolDir) {
        jData->jobSpoolDir = safeSave(jp->jobSpoolDir);
    }
    return(jData);
}
Exemplo n.º 3
0
static void interruption_hook(lua_State *L, lua_Debug *)
{
    if (getUserData(L).is_interrupted()) {
        lua_pushnil(L);
        lua_error(L);
    }
}
Exemplo n.º 4
0
//读取用户输入的信息,我们将会得到用户的身份证号码,密码,开户的余额
int main_getServiceId(int* serviceId,struct account* acc){
	printf("请输入需要办理的业务编号\n");
	scanf(" %d",serviceId);
	int res;
	switch(*serviceId){
		case 1:printf("您正在办理开户业务\n");
			   do{
				   res = getUserData(acc);
				   if(-1 == res)
					   puts("您的输入有误\n");
			   }while(-1 == res);
				acc->idNum = generatorId();
			   return 0;
		case 2:printf("您正在办理销户业务\n");
			   return 0;
		case 3:printf("您正在办理存款业务\n");
			   return 0;
		case 4:printf("您正在办理取款业务\n");
			   return 0;
		case 5:printf("您正在办理查询业务\n");
			   return 0;
		case 6:printf("您正在办理转帐业务\n");
			   return 0;
		case 0:printf("正在退出系统\n");
			   exit(0);
			   return 0;
		defult:printf("您的输入有误\n");
			   return -1;
	}

}
Exemplo n.º 5
0
	static LRESULT CALLBACK WndProc(HWND i_hwnd, UINT i_message,
									WPARAM i_wParam, LPARAM i_lParam) {
		Target *wc;
		getUserData(i_hwnd, &wc);
		if (!wc)
			switch (i_message) {
			case WM_CREATE:
				wc = setUserData(i_hwnd, new Target(i_hwnd));
				return wc->wmCreate((CREATESTRUCT *)i_lParam);
			}
		else
			switch (i_message) {
			case WM_PAINT:
				return wc->wmPaint();
			case WM_LBUTTONDOWN:
				return wc->wmLButtonDown((WORD)i_wParam, (short)LOWORD(i_lParam),
										 (short)HIWORD(i_lParam));
			case WM_LBUTTONUP:
				return wc->wmLButtonUp((WORD)i_wParam, (short)LOWORD(i_lParam),
									   (short)HIWORD(i_lParam));
			case WM_MOUSEMOVE:
				return wc->wmMouseMove((WORD)i_wParam, (short)LOWORD(i_lParam),
									   (short)HIWORD(i_lParam));
			case WM_NCDESTROY:
				delete wc;
				return 0;
			}
		return DefWindowProc(i_hwnd, i_message, i_wParam, i_lParam);
	}
Exemplo n.º 6
0
 bool
 ActionBarIconDragDropTarget::dragContainer_DragDropped(
     const CEGUI::EventArgs& args)
 {
   const boost::any* anyData = getUserData(args);
   if (anyData)
     {
       if (typeid(GenericIconUserData<ActionBarIcon> ) == anyData->type())
         {
           const GenericIconUserData<ActionBarIcon>& mUserData =
               boost::any_cast<const GenericIconUserData<ActionBarIcon>&>(
                   *anyData);
           if (&mUserData.getIcon())
             return handleDragActionBarIconDropped(args,
                 &mUserData.getIcon());
         }
       if (typeid(GenericIconUserData<EntityIcon> ) == anyData->type())
         {
           const GenericIconUserData<EntityIcon>& mUserData =
               boost::any_cast<const GenericIconUserData<EntityIcon>&>(
                   *anyData);
           if (&mUserData.getIcon())
             return handleDragEntityIconDropped(args, &mUserData.getIcon());
         }
     }
   return true;
 }
Exemplo n.º 7
0
void ComponentLua::onEnter()
{
    if (_succeedLoadingScript && getLuaFunction(ComponentLua::ON_ENTER))
    {
        getUserData();
        LuaEngine::getInstance()->getLuaStack()->executeFunction(1);
    }
}
Exemplo n.º 8
0
LuaInterruptionHandle makeInterruptable(lua_State *L, OperationInterrupter &interrupter)
{
    auto &userData = getUserData(L);
    lua_sethook(L, interruption_hook, LUA_MASKCOUNT, 1024);
    return LuaInterruptionHandle(
            L,
            interrupter.addInterruptionFunction([&]{userData.set_interrupted(true);}));
}
void RenderableShapeEntityItem::setUserData(const QString& value) {
    if (value != getUserData()) {
        ShapeEntityItem::setUserData(value);
        if (_procedural) {
            _procedural->parse(value);
        }
    }
}
Exemplo n.º 10
0
//----------------------------------------------------------------------------
void dmSphericalLink::draw() const
{
    glTranslatef(m_p[0], m_p[1], m_p[2]);
    glRotatef(m_q[2]*RADTODEG, 0.0, 0.0, 1.0);
    glRotatef(m_q[1]*RADTODEG, 0.0, 1.0, 0.0);
    glRotatef(m_q[0]*RADTODEG, 1.0, 0.0, 0.0);

    glCallList(*((GLuint *) getUserData()));
}
// 收到网络客户端发往内部服务的消息				  
int CSrvMsgHandler::onClientMessage(const char* msgData, const unsigned int msgLen, const unsigned int msgId,
								    unsigned int serviceId, unsigned short moduleId, unsigned short protocolId, Connect* conn)
{
    if (protocolId >= MaxProtocolIDCount || serviceId <= ServiceIdBaseValue)
	{
		OptErrorLog("receive net client msg error, serviceId = %d, protocolId = %d, ip = %s, port = %d, id = %lld, fd = %d, userCb = %p",
		serviceId, protocolId, CSocket::toIPStr(conn->peerIp), conn->peerPort, conn->id, conn->fd, conn->userCb);
		
		return InvalidParam;
	}

	ConnectUserData* userData = (ConnectUserData*)getUserData(conn);
	if (userData == NULL)
	{
		++m_connectIndex;
		m_idx2Connects[m_connectIndex] = ConnectUserData();
		userData = &(m_idx2Connects[m_connectIndex]);
		userData->index = m_connectIndex;
		userData->conn = conn;
		resetUserData(conn, userData);
		
		++m_gatewayProxySrvData.currentPersons;
		
		OptInfoLog("add new connect, serviceId = %d, userFlag = %d, protocolId = %d, ip = %s, port = %d, id = %lld, fd = %d",
		serviceId, userData->index, protocolId, CSocket::toIPStr(conn->peerIp), conn->peerPort, conn->id, conn->fd);
	}
	
	const unsigned int serviceType = serviceId / ServiceIdBaseValue;
	if (serviceType == ServiceType::GameHallSrv) getDestServiceID(serviceType, userData->index, serviceId);  // 游戏大厅

    // 支持客户端使用同一个网络TCP连接,发送消息到不同的服务
	// 这里如果服务多了,可以改为位数组查找,这样效率比较高,目前没必要
	// 第一条消息会携带客户端连接地址信息
	const char* conAddrData = NULL;
	unsigned int conAddDataLen = 0;
	if (userData->serviceId2ConnectIdx.find(serviceId) == userData->serviceId2ConnectIdx.end())
	{
		static ConnectAddress connectAddress;
		connectAddress.peerIp = conn->peerIp;
		connectAddress.peerPort = conn->peerPort;
		conAddrData = (const char*)&connectAddress;
		conAddDataLen = sizeof(connectAddress);
	}
	
	// 把客户端的网络消息转换成内部服务消息发送给指定的服务
	if (sendMessage(msgData, msgLen, userData->index, conAddrData, conAddDataLen, serviceId, protocolId, moduleId, 0, msgId) == Success && conAddDataLen > 0)
	{
		// 相同的服务ID直接覆盖,以避免使用数组存储时候的查找开销
		// 支持客户端使用同一个网络TCP连接,发送消息到不同的服务
		userData->serviceId2ConnectIdx[serviceId] = userData->index;
		
		OptInfoLog("first add service, serviceId = %d, userFlag = %d, protocolId = %d, ip = %s, port = %d, id = %lld, fd = %d",
		serviceId, userData->index, protocolId, CSocket::toIPStr(conn->peerIp), conn->peerPort, conn->id, conn->fd);
	}
	
	return Success;
}
Exemplo n.º 12
0
//----------------------------------------------------------------------------
void dmArticulation::draw() const
{

    glPushMatrix();

    glTranslatef(m_p_ICS[0], m_p_ICS[1], m_p_ICS[2]);

    Float len = sqrt(m_quat_ICS[0]*m_quat_ICS[0] +
                     m_quat_ICS[1]*m_quat_ICS[1] +
                     m_quat_ICS[2]*m_quat_ICS[2]);
    if (len > 1.0e-6)
    {
        float angle = 2.0*atan2(len, m_quat_ICS[3]);
        glRotatef(angle*RADTODEG,
                  m_quat_ICS[0]/len, m_quat_ICS[1]/len, m_quat_ICS[2]/len);
    }

    // render some sort of base element
    if (getUserData())
        glCallList(*((GLuint *) getUserData()));

    for (unsigned int j=0; j<m_link_list.size(); j++)
    {
        if (m_link_list[j]->parent == NULL)
        {
            glPushMatrix();

            // draw base link
            m_link_list[j]->link->draw();

            // recurse through the children
            for (unsigned int i=0; i<m_link_list[j]->child_list.size(); i++)
            {
                glPushMatrix();
                drawTraversal(m_link_list[j]->child_list[i]);
                glPopMatrix();
            }

            glPopMatrix();
        }
    }

    glPopMatrix();
}
Exemplo n.º 13
0
void ComponentLua::update(float delta)
{
    if (_succeedLoadingScript && getLuaFunction(ComponentLua::UPDATE))
    {
        getUserData();
        lua_State *l = LuaEngine::getInstance()->getLuaStack()->getLuaState();
        lua_pushnumber(l, delta);
        LuaEngine::getInstance()->getLuaStack()->executeFunction(2);
    }
}
Exemplo n.º 14
0
void Composite::setUserData(const hold_any& data)
{
    Behavior::setUserData(data);
    for(Composite::BehaviorList::iterator it = mChildren.begin();
        it != mChildren.end(); ++it)
    {
        // Pass on the data to all child nodes.
        (*it)->setUserData(getUserData());
    }
}
Exemplo n.º 15
0
void RenderableShapeEntityItem::render(RenderArgs* args) {
    PerformanceTimer perfTimer("RenderableShapeEntityItem::render");
    //Q_ASSERT(getType() == EntityTypes::Shape);
    Q_ASSERT(args->_batch);
    checkFading();

    if (!_procedural) {
        _procedural.reset(new Procedural(getUserData()));
        _procedural->_vertexSource = simple_vert;
        _procedural->_fragmentSource = simple_frag;
        _procedural->_opaqueState->setCullMode(gpu::State::CULL_NONE);
        _procedural->_opaqueState->setDepthTest(true, true, gpu::LESS_EQUAL);
        PrepareStencil::testMaskDrawShape(*_procedural->_opaqueState);
        _procedural->_opaqueState->setBlendFunction(false,
            gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
            gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
    }

    gpu::Batch& batch = *args->_batch;
    glm::vec4 color(toGlm(getXColor()), getLocalRenderAlpha());
    bool success;
    Transform modelTransform = getTransformToCenter(success);
    if (!success) {
        return;
    }
    if (_shape == entity::Sphere) {
        modelTransform.postScale(SPHERE_ENTITY_SCALE);
    }
    batch.setModelTransform(modelTransform); // use a transform with scale, rotation, registration point and translation
    if (_procedural->ready()) {
        _procedural->prepare(batch, getPosition(), getDimensions(), getOrientation());
        auto outColor = _procedural->getColor(color);
        outColor.a *= _procedural->isFading() ? Interpolate::calculateFadeRatio(_procedural->getFadeStartTime()) : 1.0f;
        batch._glColor4f(outColor.r, outColor.g, outColor.b, outColor.a);
        if (render::ShapeKey(args->_globalShapeKey).isWireframe()) {
            DependencyManager::get<GeometryCache>()->renderWireShape(batch, MAPPING[_shape]);
        } else {
            DependencyManager::get<GeometryCache>()->renderShape(batch, MAPPING[_shape]);
        }
    } else {
        // FIXME, support instanced multi-shape rendering using multidraw indirect
        color.a *= _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
        auto geometryCache = DependencyManager::get<GeometryCache>();
        auto pipeline = color.a < 1.0f ? geometryCache->getTransparentShapePipeline() : geometryCache->getOpaqueShapePipeline();
        
        if (render::ShapeKey(args->_globalShapeKey).isWireframe()) {
            geometryCache->renderWireShapeInstance(args, batch, MAPPING[_shape], color, pipeline);
        } else {
            geometryCache->renderSolidShapeInstance(args, batch, MAPPING[_shape], color, pipeline);
        }
    }

    static const auto triCount = DependencyManager::get<GeometryCache>()->getShapeTriangleCount(MAPPING[_shape]);
    args->_details._trianglesRendered += (int)triCount;
}
Exemplo n.º 16
0
/**
 * @brief Main code generator dispatch.
 *
 * According to the type of the input signal, generateCode calls
 * the appropriate generator with appropriate arguments.
 *
 * @param	sig			The signal expression to compile.
 * @param	priority	The environment priority of the expression.
 * @return	<string>	The LaTeX code translation of the signal.
 */
string DocCompiler::generateCode (Tree sig, int priority)
{
	int 	i;
	double	r;
    Tree 	c, sel, x, y, z, u, label, ff, largs, type, name, file;
	
	if ( getUserData(sig) )							{ printGCCall(sig,"generateXtended");	return generateXtended	(sig, priority);		}
	else if ( isSigInt(sig, &i) ) 					{ printGCCall(sig,"generateNumber");	return generateNumber	(sig, docT(i));			}
	else if ( isSigReal(sig, &r) ) 					{ printGCCall(sig,"generateNumber");	return generateNumber	(sig, docT(r));			}
	else if ( isSigInput(sig, &i) ) 				{ printGCCall(sig,"generateInput");		return generateInput	(sig, docT(i+1)); 		}
	else if ( isSigOutput(sig, &i, x) ) 			{ printGCCall(sig,"generateOutput");	return generateOutput	(sig, docT(i+1), CS(x, priority));	}
	
	else if ( isSigFixDelay(sig, x, y) ) 			{ printGCCall(sig,"generateFixDelay");	return generateFixDelay	(sig, x, y, priority); 	}
	else if ( isSigPrefix(sig, x, y) ) 				{ printGCCall(sig,"generatePrefix");	return generatePrefix	(sig, x, y, priority); 	}
	else if ( isSigIota(sig, x) ) 					{ printGCCall(sig,"generateIota");		return generateIota 	(sig, x); 				}
	
	else if ( isSigBinOp(sig, &i, x, y) )			{ printGCCall(sig,"generateBinOp");		return generateBinOp	(sig, i, x, y, priority); 		}
	else if ( isSigFFun(sig, ff, largs) )			{ printGCCall(sig,"generateFFun");		return generateFFun 	(sig, ff, largs, priority); 	}
    else if ( isSigFConst(sig, type, name, file) )  { printGCCall(sig,"generateFConst");	return generateFConst	(sig, tree2str(file), tree2str(name)); }
    else if ( isSigFVar(sig, type, name, file) )    { printGCCall(sig,"generateFVar");		return generateFVar		(sig, tree2str(file), tree2str(name)); }
	
    // new special tables for documentation purposes

    else if ( isSigDocConstantTbl(sig, x, y) )      { printGCCall(sig,"generateDocConstantTbl");    return generateDocConstantTbl (sig, x, y);	}
    else if ( isSigDocWriteTbl(sig,x,y,z,u) )       { printGCCall(sig,"generateDocWriteTbl");       return generateDocWriteTbl (sig, x, y, z, u); }
    else if ( isSigDocAccessTbl(sig, x, y) )        { printGCCall(sig, "generateDocAccessTbl");     return generateDocAccessTbl(sig, x, y); }


	else if ( isSigSelect2(sig, sel, x, y) ) 		{ printGCCall(sig,"generateSelect2");	return generateSelect2 	(sig, sel, x, y, priority); 	}
	else if ( isSigSelect3(sig, sel, x, y, z) ) 	{ printGCCall(sig,"generateSelect3");	return generateSelect3 	(sig, sel, x, y, z, priority); 	}
	
    else if ( isProj(sig, &i, x) )                  { printGCCall(sig,"generateRecProj");	return generateRecProj	(sig, x, i, priority);	}
	
	else if ( isSigIntCast(sig, x) ) 				{ printGCCall(sig,"generateIntCast");	return generateIntCast	(sig, x, priority); 	}
	else if ( isSigFloatCast(sig, x) ) 				{ printGCCall(sig,"generateFloatCast");	return generateFloatCast(sig, x, priority); 	}
	
	else if ( isSigButton(sig, label) ) 			{ printGCCall(sig,"generateButton");	return generateButton   (sig, label); 			}
	else if ( isSigCheckbox(sig, label) ) 			{ printGCCall(sig,"generateCheckbox");	return generateCheckbox (sig, label); 			}
	else if ( isSigVSlider(sig, label,c,x,y,z) )	{ printGCCall(sig,"generateVSlider");	return generateVSlider 	(sig, label, c,x,y,z);	}
	else if ( isSigHSlider(sig, label,c,x,y,z) )	{ printGCCall(sig,"generateHSlider");	return generateHSlider 	(sig, label, c,x,y,z);	}
	else if ( isSigNumEntry(sig, label,c,x,y,z) )	{ printGCCall(sig,"generateNumEntry");	return generateNumEntry (sig, label, c,x,y,z);	}
	
	else if ( isSigVBargraph(sig, label,x,y,z) )	{ printGCCall(sig,"generateVBargraph");	return CS(z, priority);}//generateVBargraph 	(sig, label, x, y, CS(z, priority)); }
	else if ( isSigHBargraph(sig, label,x,y,z) )	{ printGCCall(sig,"generateHBargraph");	return CS(z, priority);}//generateHBargraph 	(sig, label, x, y, CS(z, priority)); }
    else if ( isSigAttach(sig, x, y) )				{ printGCCall(sig,"generateAttach");	return generateAttach	(sig, x, y, priority); }
    else if ( isSigEnable(sig, x, y) )				{ printGCCall(sig,"generateEnable");      return generateEnable	(sig, x, y, priority); }

	else {
        stringstream error;
        error << "ERROR in d signal, unrecognized signal : " << *sig << endl;
        throw faustexception(error.str());
	}
    faustassert(0);
	return "error in generate code";
}
Exemplo n.º 17
0
ActionBarIcon* ActionBarIconDragDropTarget::parseIcon(const CEGUI::EventArgs& args)
{
    const boost::any* anyData = getUserData(args);
    if (anyData)
    {
        if (typeid(GenericIconUserData<ActionBarIcon>) == anyData->type()) {
            const GenericIconUserData<ActionBarIcon>& mUserData = boost::any_cast<const GenericIconUserData<ActionBarIcon>&>(*anyData);
            return &mUserData.getIcon();
        }
    }
    return 0;
}
Exemplo n.º 18
0
ostream& ppsig::printextended (ostream& fout, Tree sig) const
{
    string 		sep = "";
    xtended* 	p = (xtended*) getUserData(sig);

    fout << p->name() << '(';
    for (int i = 0; i < sig->arity(); i++) {
        fout << sep << ppsig(sig->branch(i), fEnv);
        sep = ", ";
    }
    fout << ')';
    return fout;
}
// note if device is not connected it will fail writing the data.
void DallasTemperature::setUserData(const uint8_t* deviceAddress, int16_t data)
{
    // return when stored value == new value
    if(getUserData(deviceAddress) == data) return;

    ScratchPad scratchPad;
    if (isConnected(deviceAddress, scratchPad))
    {
        scratchPad[HIGH_ALARM_TEMP] = data >> 8;
        scratchPad[LOW_ALARM_TEMP] = data & 255;
        writeScratchPad(deviceAddress, scratchPad);
    }
}
Exemplo n.º 20
0
//----------------------------------------------------------------------------
void dmQuaternionLink::draw() const
{
    glTranslatef(m_p[0], m_p[1], m_p[2]);

    Float len = sqrt(m_q[0]*m_q[0] + m_q[1]*m_q[1] + m_q[2]*m_q[2]);
    if (len > 1.0e-6)
    {
        float angle = 2.0*atan2(len, m_q[3]);
        glRotatef(angle*RADTODEG, m_q[0]/len, m_q[1]/len, m_q[2]/len);
    }

    glCallList(*((GLuint *) getUserData()));
}
Exemplo n.º 21
0
   int run(void* taskArg)
      {
         char mynum[3];
         sprintf(mynum, "%02d", getUserData());
         UtlString startMsg("  start  ");
         UtlString finishMsg("  finish ");
         startMsg.append(mynum);
         finishMsg.append(mynum);

         timer.addEvent(startMsg.data());
         doListOperations();
         timer.addEvent(finishMsg.data());
         return 0;
      }
Exemplo n.º 22
0
// that is the second part of original setParameter function
void MdpCtrl::setSrcFormat(const utils::Whf& whf) {

    //By default mdp src format is the same as buffer's
    mOVInfo.src.format = whf.format;

    //If rotation is used and input formats are tiled then output of rotator is
    //non-tiled.
    // FIXME mRotInfo.enable = 1; for enable
    if (getUserData()) { // if rotations enabled in MdpCtrl
        if (whf.format == MDP_Y_CRCB_H2V2_TILE)
            mOVInfo.src.format = MDP_Y_CRCB_H2V2;
        else if (whf.format == MDP_Y_CBCR_H2V2_TILE)
            mOVInfo.src.format = MDP_Y_CBCR_H2V2;
        return;
    }

}
Exemplo n.º 23
0
void App::loadUserData()
{
	std::string configFileContent = getUserData();

	rapidjson::Document doc;
	rapidjson::Value value;
	if (doc.Parse<0>(configFileContent.c_str()).HasParseError()) {
		CCLOG("Confid parse error");
		return;
	}

	const rapidjson::Value & worldsArr = doc["worldAndLevels"];
	assert(worldsArr.IsArray());


	const rapidjson::Value & worldsAvaibleArr = doc["worldAndAvalibleLevels"];
	assert(worldsAvaibleArr.IsArray());

	for (size_t i = 0; i < COUNT_WORLDS; i++)
	{
		
		const rapidjson::Value & levels = worldsArr[i];
		assert(worldsArr.IsArray());

		const rapidjson::Value & avaibleLevels = worldsAvaibleArr[i];
		assert(worldsAvaibleArr.IsArray());

		for (size_t j = 0; j < COUNT_LVLS_ON_1_WORLD; j++)
		{
			const rapidjson::Value & objValue = levels[j];
			assert(objValue.IsBool());
			_userData._complitedLvls[i][j] = objValue.GetBool();

			const rapidjson::Value & objValue2 = avaibleLevels[j];
			assert(objValue2.IsBool());
			_userData._availableLvls[i][j] = objValue2.GetBool();
			
		}
		
	}

		
	CCLOG(("Local config file:" + configFileContent).c_str());
	CCLOG(_userData.toStr().c_str());
}
Exemplo n.º 24
0
//----------------------------------------------------------------------------
void dmRevoluteLink::draw() const
{
    // set static portion of the MDH transformation.
    if (m_alphaMDH != 0.0)
    {
        glRotatef(m_alphaMDH*RADTODEG, 1.0, 0.0, 0.0);
    }

    if ((m_aMDH != 0.0) || (m_dMDH != 0.0))
    {
        glTranslatef(m_aMDH, 0.0, m_dMDH);
    }

    // set dynamic z-axis transformation.
    glRotatef(m_thetaMDH*RADTODEG, 0.0, 0.0, 1.0);

    glCallList(*((GLuint *) getUserData()));
}
Exemplo n.º 25
0
/**
 * retrieve the type annotation of sig
 * @param sig the signal we want to know the type
 */
string DocCompiler::generateXtended 	(Tree sig, int priority)
{
	xtended* p = (xtended*) getUserData(sig);
	vector<string> args;
	vector<Type> types;

	for (int i=0; i<sig->arity(); i++) {
		args.push_back(CS(sig->branch(i), 0));
		types.push_back(getCertifiedSigType(sig->branch(i)));
	}

	if (p->needCache()) {
		//cerr << "!! generateXtended : <needCache> : calls generateCacheCode(sig, p->generateLateq(fLateq, args, types))" << endl;
		return generateCacheCode(sig, p->generateLateq(fLateq, args, types));
	} else {
		//cerr << "!! generateXtended : <do not needCache> : calls p->generateLateq(fLateq, args, types)" << endl;
		return p->generateLateq(fLateq, args, types);
	}
}
Exemplo n.º 26
0
Sprite*  Stratosphere::createCloud()
{

	std::string filename = JsonReader::getInstance()->getPathFromJson("cloud");
	auto cloud = Sprite::createWithSpriteFrameName(filename);
	cloud->setPosition(getRandomPosition().x, getRandomPosition().y);
	float *speed = new float(this->getRandomSpeed());

	cloud->setUserData(speed);
#if 0
	CCLOG("%s:%f", "cloud position!!!", cloud->getPosition().x);
	CCLOG("%f:random scale", this->getRandomScale());
	CCLOG("%s:%f", "cloud speed!", *(float*)(cloud->getUserData()));
#endif

	cloud->setScale(this->getRandomScale());
	cloud->setOpacity(this->getRandomOpacity());
	//cloud->setRotation(this->getRandomRotation());
	return cloud;
	
}
Exemplo n.º 27
0
const UGen& VoicerBaseUGenInternal::chooseReleasee(const int midiChannel, const int midiNote) throw()
{
	ugen_assert(midiChannel == char(midiChannel));
	ugen_assert(midiNote == char(midiNote));

	const int numEvents = events.size();
	
	for(int i = numEvents-1; i >= 0; i--) // release in reverse ?
	{
		UGen& releasee = events[i];
		VoicerUserDataStruct data = getUserData(releasee.userData);
		if((data.midiChannel == midiChannel)
		   && (data.midiNote == midiNote) 
		   // && (releasee.isReleasing() == false // something like this would be useful but tricky to implement
		   )
		{
			return releasee;
		}
	}
	
	return UGen::getNull();
}
Exemplo n.º 28
0
bool UIColorEditor::beginTouchColor(cocos2d::Touch* touch, cocos2d::Event* event){
    auto target = static_cast<Sprite*>(event->getCurrentTarget());

    Point locationInNode = target->convertTouchToNodeSpace(touch);

    Size size = target->getContentSize();
    Rect rect = Rect(0, 0, size.width, size.height);

    if (rect.containsPoint(locationInNode)){
        void* p = target->getUserData();
        int index = *(int*)p;

#if _COLOR_DEBUG_
        char num[10];
        sprintf(num, "%d", index);
        UILayer::Layer->addMessage(num);
#endif

        if (onSetColorFunc != nullptr)
            onSetColorFunc(mPaletteIndexArray[index], mPaletteColorArray[index]);
    }
    return false;
}
Exemplo n.º 29
0
int main(){
    
    /* First item of the programming assignment */
    printf("-> Hello! Let's play with user data\n");
    getUserData();

    /* Second item of the programming assignment */
    printf("\n-> Now let's swap two integers. Choose first integer:\n");
    scanf("%i", &firstInteger);  
    printf("and now the second integer:\n");
    scanf("%i", &secondInteger);  
    swapIntegers(firstInteger, secondInteger);
    
    /* Third item of the programming assignment */
    printf("\n-> Last but not least, let's now play with some number averaging \n");
    printf("Enter first number - must be an integer!\n");
    scanf("%i", &firstInteger);
    printf("Enter second number - must be an integer!\n");
    scanf("%i", &secondInteger);
    printf("The result is %.2f\n", avgIntegers(firstInteger, secondInteger));


    return 0;
}
Exemplo n.º 30
0
void BattleUI::BufferEffect(int bufferId)
{
    
    CfgDataRow dataRow(bufferId);
    auto talentHit = BattleData::getInstance()->m_TalentHit;
    CfgDataRow monsterDataRow(BattleData::getInstance()->m_MonsterId);
    auto monsterEvasion = monsterDataRow.GetValue(CfgField::Evasion)->asInt();
    auto bufferHit = dataRow.GetValue(CfgField::BuffHit)->asInt();
    
    auto rvHit = (bufferHit + talentHit - monsterEvasion);
    auto rv = RandomEngine::getInstance()->GetDefaultRandomValue(1, 100);
    if (rv > rvHit) return; //判断buffer 是否命中
    
    auto layout_Top = m_RootWidget->getChildByName<Layout*>("Layout_Top");
    auto lview_Buffer = layout_Top->getChildByName<ListView*>("LView_Buffer");
    
    auto layout_Template = m_RootWidget->getChildByName<Layout*>("Template");
    
    auto bufferType = dataRow.GetValue(CfgField::Bufftype)->asInt();
    
    switch (bufferType)
    {
        case (int)BufferCfgId::PersistDamage: //持续伤害
        {
            auto buffer_Template = layout_Template->getChildByName<Layout*>("Buffer100801");
            auto layout_Buffer = (Layout*)buffer_Template->clone();
            auto text_Time = layout_Buffer->getChildByName<Text*>("Text_Time1");
            
            auto bs = new BufferSchedule();
            layout_Buffer->setUserData(bs);
            
            bs->m_TimeText = text_Time;
            bs->m_LayoutBuffer = layout_Buffer;
            bs->m_ScheduleName = GetNewScheduleName();
            bs->m_DelOrHidelLayoutBuffer = true;
            bs->m_TotalTime = dataRow.GetValue(CfgField::BuffDuration_F)->asFloat();
            bs->m_CbIntervalTime = dataRow.GetValue(CfgField::BuffInterval_F)->asFloat();
            bs->m_CallBack = ([=]()
               {
                   BattleData::getInstance()->BufferAttack(bufferId);
               });
            
            layout_Buffer->schedule([bs](float t)
            {
                bs->Update(t);
                
            }, bs->m_ScheduleName);
            
            layout_Buffer->setVisible(true);
            lview_Buffer->addChild(layout_Buffer);
            
            break;
        }
        case (int)BufferCfgId::ReduceDamage: //怪物中这个buffer 怪物攻击减少
        {
            auto layout_Buffer = (Layout*)lview_Buffer->getChildByName("Buffer100802");
            auto text_Time = layout_Buffer->getChildByName<Text*>("Text_Time2");
            
            auto bufferVal = dataRow.GetValue(CfgField::BuffMitigation)->asInt();
            
            BattleData::getInstance()->m_BufferReduceDamage = bufferVal;
            
            if(layout_Buffer->isVisible())
            {
                layout_Buffer->unschedule("BufferSchedule");
            }
            
            BufferSchedule* bs = new BufferSchedule();
            layout_Buffer->setUserData(bs);
            
            bs->m_TimeText = text_Time;
            bs->m_LayoutBuffer = layout_Buffer;
            bs->m_ScheduleName = "BufferSchedule";
            bs->m_DelOrHidelLayoutBuffer = false;
            bs->m_TotalTime = dataRow.GetValue(CfgField::BuffDuration_F)->asFloat();
            bs->m_CbIntervalTime = bs->m_TotalTime;
            bs->m_CallBack = ([=]()
              {
                  BattleData::getInstance()->m_BufferReduceDamage = 0;
              });
            
            layout_Buffer->schedule([=](float t)
            {
                bs->Update(t);
                
            }, bs->m_ScheduleName);

            lview_Buffer->setVisible(true);
            
            break;
        }
        case (int)BufferCfgId::Dizziness: //眩晕
        {
            auto Lbar_MonsterSkill = layout_Top->getChildByName<LoadingBar*>("LBar_Skill");
            auto pb = (ProgressBar*)Lbar_MonsterSkill->getUserData();
            pb->AddRemainTime(dataRow.GetValue(CfgField::BuffDuration_F)->asFloat());
            
            auto layout_Buffer = (Layout*)lview_Buffer->getChildByName("Buffer100803");
            
            auto text_Time = layout_Buffer->getChildByName<Text*>("Text_Time3");
            
            if(layout_Buffer->isVisible())
            {
                layout_Buffer->unschedule("BufferSchedule");
            }
            
            BufferSchedule* bs = new BufferSchedule();
            layout_Buffer->setUserData(bs);
            
            bs->m_TimeText = text_Time;
            bs->m_LayoutBuffer = layout_Buffer;
            bs->m_ScheduleName = "BufferSchedule";
            bs->m_DelOrHidelLayoutBuffer = false;
            bs->m_TotalTime = dataRow.GetValue(CfgField::BuffDuration_F)->asFloat();
            bs->m_CbIntervalTime = bs->m_TotalTime;

            bs->m_CallBack = ([=](){ /*delete bs;*/ });
            
            layout_Buffer->schedule([=](float t)
                {
                    bs->Update(t);
                }, bs->m_ScheduleName);
            
            layout_Buffer->setVisible(true);
            break;
        }
        case (int)BufferCfgId::PersistRecover: //持续恢复
        {
            auto buffer_Template = layout_Template->getChildByName<Layout*>("Buffer100805");
            
            auto layout_Buffer = (Layout*)buffer_Template->clone();
            
            auto bs = new BufferSchedule();
            layout_Buffer->setUserData(bs);
            
            bs->m_LayoutBuffer = layout_Buffer;
            bs->m_ScheduleName = GetNewScheduleName();
            bs->m_DelOrHidelLayoutBuffer = true;
            bs->m_TotalTime = dataRow.GetValue(CfgField::BuffDuration_F)->asFloat();
            bs->m_CbIntervalTime = dataRow.GetValue(CfgField::BuffInterval_F)->asFloat();
            bs->m_CallBack = ([=]()
              {
                  BattleData::getInstance()->BufferAttack(bufferId);
              });
            
            layout_Buffer->schedule([=](float t)
            {
                bs->Update(t);
            }, bs->m_ScheduleName);
            
            lview_Buffer->addChild(layout_Buffer);
            
            break;
        }
    }
    
}