void Fixup<MemoryDeviceMappedAddress>(MemoryDeviceMappedAddress& p) { if(p.startAddress32 != UINT32_MAX) p.startAddress = u64(p.startAddress32) * KiB; if(p.endAddress32 != UINT32_MAX) p.endAddress = u64(p.endAddress32) * KiB; }
void CParticlesPlayer::LoadParticles(CKinematics* K) { VERIFY (K); m_Bones.clear(); //считать список косточек и соответствующих //офсетов куда можно вешать партиклы CInifile* ini = K->LL_UserData(); if(ini&&ini->section_exist("particle_bones")) { bone_mask = 0; CInifile::Sect& data = ini->r_section("particle_bones"); for (CInifile::SectIt I=data.begin(); I!=data.end(); I++) { CInifile::Item& item = *I; u16 index = K->LL_BoneID(*item.first); R_ASSERT3(index != BI_NONE, "Particles bone not found", *item.first); Fvector offs; sscanf (*item.second,"%f,%f,%f",&offs.x,&offs.y,&offs.z); m_Bones.push_back (SBoneInfo(index,offs)); bone_mask |= u64(1)<<u64(index); } } if(m_Bones.empty()) { bone_mask = u64(1)<<u64(0); m_Bones.push_back (SBoneInfo(K->LL_GetBoneRoot(),Fvector().set(0,0,0))); } }
std::size_t payload_request::parse(packet::ptr_t pkt, const_buffer buf) { const packed_request* req = buffer_cast<const packed_request*>(buf); pkt->source(network_key(req->key)); pkt->payload(boost::make_shared<payload_request>(u64(req->content_size), u64(req->min_oob_threshold))); return sizeof(packed_request) + pkt->name().parse(buf + sizeof(packed_request)); }
std::vector<const_buffer> payload_request::serialize(packet::const_ptr_t pkt, std::size_t threshold, mutable_buffer scratch) const { packed_request* req = buffer_cast<packed_request*>(scratch); pkt->source().encode(req->key); u64(req->content_size, size); u64(req->min_oob_threshold, min_oob_threshold); return std::vector<const_buffer>(1, buffer(scratch, sizeof(packed_request) + pkt->name().serialize(scratch + sizeof(packed_request)))); }
void Fixup<MemoryDevice>(MemoryDevice& p) { if(p.size16 != INT16_MAX) p.size = u64(bits(p.size16, 0, 14)) * (IsBitSet(p.size16, 15)? 1*KiB : 1*MiB); else p.size = u64(bits(p.size32, 0, 30)) * MiB; p.rank = bits(p.attributes, 0, 3); }
CParticlesPlayer::SBoneInfo* CParticlesPlayer::get_nearest_bone_info(CKinematics* K, u16 bone_index) { u16 play_bone = bone_index; while((BI_NONE!=play_bone)&&!(bone_mask&(u64(1)<<u64(play_bone)))) { play_bone = K->LL_GetData(play_bone).GetParentID(); } return get_bone_info(play_bone); }
u16 CParticlesPlayer::GetNearestBone (CKinematics* K, u16 bone_id) { u16 play_bone = bone_id; while((BI_NONE!=play_bone)&&!(bone_mask&(u64(1)<<u64(play_bone)))) { play_bone = K->LL_GetData(play_bone).GetParentID(); } return play_bone; }
CParticlesPlayer::CParticlesPlayer () { bone_mask = u64(1)<<u64(0); m_bActiveBones = false; m_Bones.push_back (SBoneInfo(0,Fvector().set(0,0,0))); SetParentVel (zero_vel); m_self_object = 0; }
TEST(BitWise, xor){ uint256_t t ((bool) true); uint256_t f ((bool) false); uint256_t u8 ((uint8_t) 0xaaULL); uint256_t u16((uint16_t) 0xaaaaULL); uint256_t u32((uint32_t) 0xaaaaaaaaULL); uint256_t u64((uint64_t) 0xaaaaaaaaaaaaaaaa); const uint256_t val(0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f0f0f0ULL); EXPECT_EQ(t ^ val, uint256_t(0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f0f0f1ULL)); EXPECT_EQ(f ^ val, uint256_t(0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f0f0f0ULL)); EXPECT_EQ(u8 ^ val, uint256_t(0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f0f05aULL)); EXPECT_EQ(u16 ^ val, uint256_t(0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f05a5aULL)); EXPECT_EQ(u32 ^ val, uint256_t(0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f05a5a5a5aULL)); EXPECT_EQ(u64 ^ val, uint256_t(0xf0f0f0f0f0f0f0f0ULL, 0x5a5a5a5a5a5a5a5aULL)); EXPECT_EQ(t ^= val, uint256_t(0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f0f0f1ULL)); EXPECT_EQ(f ^= val, uint256_t(0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f0f0f0ULL)); EXPECT_EQ(u8 ^= val, uint256_t(0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f0f05aULL)); EXPECT_EQ(u16 ^= val, uint256_t(0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f05a5aULL)); EXPECT_EQ(u32 ^= val, uint256_t(0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f05a5a5a5aULL)); EXPECT_EQ(u64 ^= val, uint256_t(0xf0f0f0f0f0f0f0f0ULL, 0x5a5a5a5a5a5a5a5aULL)); // zero EXPECT_EQ(uint256_t() ^ val, val); }
virtual std::vector<const_buffer> serialize(packet::const_ptr_t pkt, std::size_t threshold, mutable_buffer scratch) const { packed_error* error = buffer_cast<packed_error*>(scratch); pkt->source().encode(error->key); u64(error->content_size, size); return std::vector<const_buffer>(1, buffer(scratch, sizeof(packed_error) + pkt->name().serialize(scratch + sizeof(packed_error)))); }
//------------------------------------------------------------------------------ void GLMesh::Bind(GLShader* glShader) noexcept { auto vertexFormat = m_renderMesh->GetVertexFormat(); //TODO: This should be pre-calculated. GLint maxVertexAttributes = 0; glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttributes); CS_ASSERT(u32(maxVertexAttributes) >= vertexFormat.GetNumElements(), "Too many vertex elements."); glBindBuffer(GL_ARRAY_BUFFER, m_vertexBufferHandle); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferHandle); CS_ASSERT_NOGLERROR("An OpenGL error occurred while binding GLMesh."); for (u32 i = 0; i < vertexFormat.GetNumElements(); ++i) { glEnableVertexAttribArray(i); auto elementType = vertexFormat.GetElement(i); auto name = GLMeshUtils::GetAttributeName(elementType); auto numComponents = ChilliSource::VertexFormat::GetNumComponents(elementType); auto type = GLMeshUtils::GetGLType(ChilliSource::VertexFormat::GetDataType(elementType)); auto normalised = GLMeshUtils::IsNormalised(elementType); auto offset = reinterpret_cast<const GLvoid*>(u64(vertexFormat.GetElementOffset(i))); glShader->SetAttribute(name, numComponents, type, normalised, vertexFormat.GetSize(), offset); } for (s32 i = vertexFormat.GetNumElements(); i < maxVertexAttributes; ++i) { glDisableVertexAttribArray(i); } }
void StreamWrite::bits(u32 value, s32 bits) { vi_assert(bits > 0); vi_assert(bits <= 32); value &= (u64(1) << bits) - 1; scratch |= u64(value) << scratch_bits; scratch_bits += bits; if (scratch_bits >= 32) { data.add(u32(scratch & 0xFFFFFFFF)); scratch >>= 32; scratch_bits -= 32; }
void CContextMenu::Select(int I) { if (I>=0 && I<(int)(Items.size())){ MenuItem& M = Items[I]; Engine.Event.Signal(M.Event, u64(M.Param)); } }
//------------------------------------------------------------------------------ void GLDynamicMesh::ApplyVertexAttributes(GLShader* glShader) const noexcept { //TODO: This should be pre-calculated. GLint maxVertexAttributes = 0; glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttributes); CS_ASSERT(u32(maxVertexAttributes) >= m_vertexFormat.GetNumElements(), "Too many vertex elements."); for (u32 i = 0; i < m_vertexFormat.GetNumElements(); ++i) { glEnableVertexAttribArray(i); auto elementType = m_vertexFormat.GetElement(i); auto name = GLMeshUtils::GetAttributeName(elementType); auto numComponents = ChilliSource::VertexFormat::GetNumComponents(elementType); auto type = GLMeshUtils::GetGLType(ChilliSource::VertexFormat::GetDataType(elementType)); auto normalised = GLMeshUtils::IsNormalised(elementType); auto offset = reinterpret_cast<const GLvoid*>(u64(m_vertexFormat.GetElementOffset(i))); glShader->SetAttribute(name, numComponents, type, normalised, m_vertexFormat.GetSize(), offset); } for (s32 i = m_vertexFormat.GetNumElements(); i < maxVertexAttributes; ++i) { glDisableVertexAttribArray(i); } }
void CZoneEffector::Stop() { if (!m_pp_effector) return; m_pActor->Cameras().RemovePPEffector(EEffectorPPType( u32(u64(this) & u32(-1)) )); m_pp_effector = NULL; m_pActor = NULL; };
static std::size_t parse(packet::ptr_t pkt, const_buffer buf) { const packed_error* error = buffer_cast<const packed_error*>(buf); pkt->source(network_key(error->key)); pkt->payload(boost::make_shared<payload_failure>(u64(error->content_size))); return sizeof(packed_error) + pkt->name().parse(buf + sizeof(packed_error)); }
void CPhysicsShellHolder::PHSaveState(NET_Packet &P) { //CPhysicsShell* pPhysicsShell=PPhysicsShell(); CKinematics* K =smart_cast<CKinematics*>(Visual()); //Flags8 lflags; //if(pPhysicsShell&&pPhysicsShell->isActive()) lflags.set(CSE_PHSkeleton::flActive,pPhysicsShell->isEnabled()); // P.w_u8 (lflags.get()); if(K) { P.w_u64(K->LL_GetBonesVisible()); P.w_u16(K->LL_GetBoneRoot()); } else { P.w_u64(u64(-1)); P.w_u16(0); } ///////////////////////////// Fvector min,max; min.set(flt_max,flt_max,flt_max); max.set(-flt_max,-flt_max,-flt_max); ///////////////////////////////////// u16 bones_number=PHGetSyncItemsNumber(); for(u16 i=0;i<bones_number;i++) { SPHNetState state; PHGetSyncItem(i)->get_State(state); Fvector& p=state.position; if(p.x<min.x)min.x=p.x; if(p.y<min.y)min.y=p.y; if(p.z<min.z)min.z=p.z; if(p.x>max.x)max.x=p.x; if(p.y>max.y)max.y=p.y; if(p.z>max.z)max.z=p.z; } min.sub(2.f*EPS_L); max.add(2.f*EPS_L); VERIFY(!min.similar(max)); P.w_vec3(min); P.w_vec3(max); P.w_u16(bones_number); for(u16 i=0;i<bones_number;i++) { SPHNetState state; PHGetSyncItem(i)->get_State(state); state.net_Save(P,min,max); } }
/* if end - start > screen set to begin */ bool goto_beginning_of_line(event * msg) { app_log << __FUNCTION__ << "\n"; auto buffer = get_buffer_info_by_ll_bid(msg->byte_buffer_id); auto screen = get_previous_screen_by_id(msg->view_id); screen_line_t * l; size_t scr_line_index; size_t scr_col_index; text_buffer::iterator & rdr_it = *buffer->rdr_begin(); // u64 old_rdr_begin = rdr_it.offset(); text_buffer::iterator & it = *buffer->cursor_it(); app_log << __FUNCTION__ << "\n"; it.toBeginningOfLine(); assert(it.column() == 0); app_log << __FUNCTION__ << "\n"; u64 cur_off = it.offset(); codepoint_info_s start_cpi; bool found = screen->get_line_by_offset(cur_off, &l, scr_line_index, scr_col_index); if (!found) { app_log << __PRETTY_FUNCTION__ << " : ! found on screen\n"; rdr_it = it; } else { app_log << __PRETTY_FUNCTION__ << " : found cursor @ (l="<<scr_line_index<< ", c=" << scr_col_index<< ")\n"; start_cpi = screen->first_cpinfo; } while (!found) { found = screen->get_line_by_offset(cur_off, &l, scr_line_index, scr_col_index); if (found) { app_log << __FUNCTION__ << " found cursor_offset("<<cur_off<<") on screen\n"; start_cpi = screen->first_cpinfo; break; } page_up_internal(msg, start_cpi); build_screen_layout(msg, &start_cpi, screen); } assert(it.column() == 0); // need centering ? // while !found offset page_up(); assert(start_cpi.cp_index != u64(-1)); set_mark_changed_flag(process_ev_ctx); set_ui_next_screen_start_cpi(process_ev_ctx, &start_cpi); return true; }
void CPHSkeleton::SaveNetState(NET_Packet& P) { CPhysicsShellHolder* obj=PPhysicsShellHolder(); CPhysicsShell* pPhysicsShell=obj->PPhysicsShell(); IKinematics* K =smart_cast<IKinematics*>(obj->Visual()); if(pPhysicsShell&&pPhysicsShell->isActive()) m_flags.set(CSE_PHSkeleton::flActive,pPhysicsShell->isEnabled()); P.w_u8 (m_flags.get()); if(K) { P.w_u64(K->LL_GetBonesVisible()); P.w_u16(K->LL_GetBoneRoot()); } else { P.w_u64(u64(-1)); P.w_u16(0); } ///////////////////////////// Fvector min,max; min.set(F_MAX,F_MAX,F_MAX); max.set(-F_MAX,-F_MAX,-F_MAX); ///////////////////////////////////// u16 bones_number=obj->PHGetSyncItemsNumber(); for(u16 i=0;i<bones_number;i++) { SPHNetState state; obj->PHGetSyncItem(i)->get_State(state); Fvector& p=state.position; if(p.x<min.x)min.x=p.x; if(p.y<min.y)min.y=p.y; if(p.z<min.z)min.z=p.z; if(p.x>max.x)max.x=p.x; if(p.y>max.y)max.y=p.y; if(p.z>max.z)max.z=p.z; } min.sub(2.f*EPS_L); max.add(2.f*EPS_L); P.w_vec3(min); P.w_vec3(max); P.w_u16(bones_number); for(u16 i=0;i<bones_number;i++) { SPHNetState state; obj->PHGetSyncItem(i)->get_State(state); state.net_Save(P,min,max); } }
void arx::time::force_time_restore(const float &time) { u64 requested_time = u64(time * 1000.0f); start_time = Time::getElapsedUs(requested_time); delta_time_us = requested_time; pause_time = 0; paused = false; }
void GameTime::force_time_restore(const ArxInstant time) { u64 requested_time = u64(time * 1000); start_time = platform::getElapsedUs(requested_time); m_now_us = requested_time; pause_time = 0; paused = false; }
void CHangingLamp::RespawnInit() { Init(); if(Visual()){ CKinematics* K = smart_cast<CKinematics*>(Visual()); K->LL_SetBonesVisible(u64(-1)); K->CalculateBones_Invalidate(); K->CalculateBones (); } }
/* void CSheduler::Switch () { if (fibered) { fibered = FALSE; SwitchToFiber (fiber_main); } } */ void CSheduler::Update () { R_ASSERT (Device.Statistic); // Initialize Device.Statistic->Sheduler.Begin(); cycles_start = CPU::QPC (); cycles_limit = CPU::qpc_freq * u64 (iCeil(psShedulerCurrent)) / 1000i64 + cycles_start; internal_Registration (); g_bSheduleInProgress = TRUE; #ifdef DEBUG_SCHEDULER Msg ("SCHEDULER: PROCESS STEP %d",Device.dwFrame); #endif // DEBUG_SCHEDULER // Realtime priority m_processing_now = true; u32 dwTime = Device.dwTimeGlobal; for (u32 it=0; it<ItemsRT.size(); it++) { Item& T = ItemsRT[it]; R_ASSERT (T.Object); #ifdef DEBUG_SCHEDULER Msg ("SCHEDULER: process step [%s][%x][true]",*T.Object->shedule_Name(),T.Object); #endif // DEBUG_SCHEDULER if(!T.Object->shedule_Needed()){ #ifdef DEBUG_SCHEDULER Msg ("SCHEDULER: process unregister [%s][%x][%s]",*T.Object->shedule_Name(),T.Object,"false"); #endif // DEBUG_SCHEDULER T.dwTimeOfLastExecute = dwTime; continue; } u32 Elapsed = dwTime-T.dwTimeOfLastExecute; #ifdef DEBUG VERIFY (T.Object->dbg_startframe != Device.dwFrame); T.Object->dbg_startframe = Device.dwFrame; #endif T.Object->shedule_Update (Elapsed); T.dwTimeOfLastExecute = dwTime; } // Normal (sheduled) ProcessStep (); m_processing_now = false; #ifdef DEBUG_SCHEDULER Msg ("SCHEDULER: PROCESS STEP FINISHED %d",Device.dwFrame); #endif // DEBUG_SCHEDULER clamp (psShedulerTarget,3.f,66.f); psShedulerCurrent = 0.9f*psShedulerCurrent + 0.1f*psShedulerTarget; Device.Statistic->fShedulerLoad = psShedulerCurrent; // Finalize g_bSheduleInProgress = FALSE; internal_Registration (); Device.Statistic->Sheduler.End (); }
SPHBonesData::SPHBonesData() { bones_mask =u64(-1); root_bone =0; Fvector _mn, _mx; _mn.set (-100.f,-100.f,-100.f); _mx.set (100.f,100.f,100.f); set_min_max (_mn, _mx); }
bytes MixBlockChain::createGenesisBlock(h256 _stateRoot) { RLPStream block(3); block.appendList(15) << h256() << EmptyListSHA3 << h160() << _stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_mixGenesisDifficulty << 0 << c_genesisGasLimit << 0 << (unsigned)0 << std::string() << h256() << h64(u64(42)); block.appendRaw(RLPEmptyList); block.appendRaw(RLPEmptyList); return block.out(); }
void CZoneEffector::Activate() { m_pActor = smart_cast<CActor*>(Level().CurrentEntity()); if(!m_pActor) return; m_pp_effector = xr_new<CPostprocessAnimatorLerp>(); m_pp_effector->SetType (EEffectorPPType( u32(u64(this) & u32(-1)) )); m_pp_effector->SetCyclic (true); m_pp_effector->SetFactorFunc (GET_KOEFF_FUNC(this, &CZoneEffector::GetFactor)); m_pp_effector->Load (*m_pp_fname); m_pActor->Cameras().AddPPEffector (m_pp_effector); }
// Throws std::invalid_argument str::operator u64() const { u64 ret = 0; for (usize i = 0; i < length_; ++i) { if (!isdigit(u8((*this)[i]))) { std::stringstream err; err << "Attempted to parse str to u64, but invalid character found: " << (*this)[i]; throw std::invalid_argument(err.str()); } ret = ret * 10 + u64(((*this)[i] - '0')); } return ret; }
u64 GetNow() { // get frequency of the performance counter LARGE_INTEGER frequency; if (QueryPerformanceFrequency(&frequency) && frequency.QuadPart != 0) { LARGE_INTEGER now; if (QueryPerformanceCounter(&now)) { return 1000000 * u64(now.QuadPart) / frequency.QuadPart; } } // no performance counter, so use the Win32 multimedia timer return timeGetTime() * 1000; }
virtual void Execute(LPCSTR args) { /* if (g_pGameLevel) { Log ("! Please disconnect/unload first"); return; } */ string4096 op_server, op_client, op_demo; op_server[0] = 0; op_client[0] = 0; parse(op_server, args, "server"); // 1. server parse(op_client, args, "client"); // 2. client parse(op_demo, args, "demo"); // 3. demo strlwr(op_server); protect_Name_strlwr(op_client); if (!op_client[0] && strstr(op_server, "single")) xr_strcpy(op_client, "localhost"); if ((0 == xr_strlen(op_client)) && (0 == xr_strlen(op_demo))) { Log("! Can't start game without client. Arguments: '%s'.", args); return; } if (g_pGameLevel) Engine.Event.Defer("KERNEL:disconnect"); if (xr_strlen(op_demo)) { Engine.Event.Defer("KERNEL:start_mp_demo", u64(xr_strdup(op_demo)), 0); } else { Engine.Event.Defer("KERNEL:start", u64(xr_strlen(op_server) ? xr_strdup(op_server) : 0), u64(xr_strdup(op_client))); } }
void CKinematics::Depart () { inherited::Depart (); // wallmarks ClearWallmarks (); // unmask all bones visimask.zero (); if(bones) { for (u32 b=0; b<bones->size(); b++) visimask.set((u64(1)<<b),TRUE); } // visibility children.insert (children.end(),children_invisible.begin(),children_invisible.end()); children_invisible.clear (); }