bool test_object_id (Test *test) { TITLE (); CATCH (object_id () != 0); CATCH (object_id () != 1); CATCH (object_id () != 2); PASS (); }
Object sensor_visobjs_member(TCOD_list_t l, Object o) { for(int i = 0; i < TCOD_list_size(l); i++) { Object o2 = TCOD_list_get(l, i); if(strcmp(object_id(o), object_id(o2)) == 0) { return o2; } } return NULL; }
bool test_object_id_set_counter (Test *test) { TITLE (); object_id_set_counter (123); CATCH (object_id () != 123); object_id_set_counter (0); CATCH (object_id () != 0); object_id_set_counter (ULLONG_MAX); CATCH (object_id () != ULLONG_MAX); error_reset (); PASS (); }
bool test_object_id_overflow (Test *test) { TITLE (); object_id_set_counter (ULLONG_MAX - 1); CATCH (object_id () != ULLONG_MAX - 1); CATCH (object_id () != ULLONG_MAX); CATCH (error_count () == 0); CATCH (error_at (0).error != ErrorOverflow); CATCH (object_id () != 0); CATCH (object_id () != 1); PASS (); }
void sobject_raw_move(Object o, mapVec amt) { ObjectInfo oi = object_context(o); Object o2 = objectinfo_attached_object(oi); AttachMode mode = objectinfo_attach_mode(oi); if(o2) { if(mode == AttachCarry) { map_move_object(object_map(o), object_id(o), amt); map_move_object(object_map(o), object_id(o2), amt); } else if(mode == AttachLatch) { TUG(o, o2, x, <, left); TUG(o, o2, x, >, right); TUG(o, o2, y, <, back); TUG(o, o2, y, >, forward); } } else {
void CSoundMemoryManager::enable (const CObject *object, bool enable) { xr_vector<CSoundObject>::iterator J = std::find(m_sounds->begin(),m_sounds->end(),object_id(object)); if (J == m_sounds->end()) return; (*J).m_enabled = enable; }
transform_feedback::transform_feedback( render_device& in_device, const stream_output_setup& in_setup) : render_device_child(in_device) , _stream_out_setup(in_setup) , _active(false) , _captured_topology(PRIMITIVE_POINTS) { if (SCM_GL_CORE_OPENGL_TYPE >= SCM_GL_CORE_OPENGL_CORE_VERSION_400) { const opengl::gl_core& glapi = in_device.opengl_api(); util::gl_error glerror(glapi); glapi.glGenTransformFeedbacks(1, &(context_bindable_object::_gl_object_id)); if (0 == object_id()) { state().set(object_state::OS_BAD); } else { context_bindable_object::_gl_object_target = GL_TRANSFORM_FEEDBACK; context_bindable_object::_gl_object_binding = GL_TRANSFORM_FEEDBACK_BINDING; if (!initialize_transform_feedback_object(in_device)) { // the state is set in the functions to more detailed error states } } gl_assert(glapi, leaving transform_feedback::transform_feedback()); } }
//Test if this mgSysGL includes gel(return true) or not. bool mgSys2GL::includes(const MGGel* gel)const{ if(gel==object_id()) return true; if(m_gel2==gel) return true; return false; }
void CHitMemoryManager::add (const CHitObject &_hit_object) { #ifndef MASTER_GOLD if (_hit_object.m_object && smart_cast<CActor const*>(_hit_object.m_object) && psAI_Flags.test(aiIgnoreActor)) return; #endif // MASTER_GOLD VERIFY (m_hits); if (!object().g_Alive()) return; CHitObject hit_object = _hit_object; hit_object.m_squad_mask.set (m_stalker->agent_manager().member().mask(m_stalker),TRUE); const CEntityAlive *entity_alive = hit_object.m_object; HITS::iterator J = std::find(m_hits->begin(),m_hits->end(),object_id(entity_alive)); if (m_hits->end() == J) { if (m_max_hit_count <= m_hits->size()) { HITS::iterator I = std::min_element(m_hits->begin(),m_hits->end(),SLevelTimePredicate<CEntityAlive>()); VERIFY (m_hits->end() != I); *I = hit_object; } else m_hits->push_back (hit_object); } else { hit_object.m_squad_mask.assign (hit_object.m_squad_mask.get() | (*J).m_squad_mask.get()); *J = hit_object; } }
void CHitMemoryManager::enable (const CObject *object, bool enable) { HITS::iterator J = std::find(m_hits->begin(),m_hits->end(),object_id(object)); if (J == m_hits->end()) return; (*J).m_enabled = enable; }
void transform_feedback::bind(render_context& in_context) const { assert(state().ok()); if (SCM_GL_CORE_OPENGL_CORE_VERSION >= SCM_GL_CORE_OPENGL_CORE_VERSION_400) { assert(object_id() != 0); const opengl::gl_core& glapi = in_context.opengl_api(); glapi.glBindTransformFeedback(object_target(), object_id()); gl_assert(glapi, transform_feedback::bind() after glBindTransformFeedback()); } else { bind_stream_out_buffers(in_context); } gl_assert(in_context.opengl_api(), leaving transform_feedback:bind()); }
transform_feedback::~transform_feedback() { if (SCM_GL_CORE_OPENGL_TYPE >= SCM_GL_CORE_OPENGL_CORE_VERSION_400) { const opengl::gl_core& glapi = parent_device().opengl_api(); assert(0 != object_id()); glapi.glDeleteTransformFeedbacks(1, &(context_bindable_object::_gl_object_id)); gl_assert(glapi, leaving transform_feedback::~transform_feedback()); } }
//replace gel_old to gel_new. //If gel_old is not included in this, do nothing. void mgSys2GL::replace( const MGGel* gel_old, //gel_old must be a MGCurve. const MGGel* gel_new //gel_new must be a MGFSurface. ){ if(gel_old==object_id()){ set_object_id(const_cast<MGGel*>(gel_new)); }else{ if(m_gel2==gel_old){ m_gel2=gel_new; } } }
void CSoundMemoryManager::add (const CSoundObject &sound_object, bool check_for_existance) { if (check_for_existance) { if (m_sounds->end() != std::find(m_sounds->begin(),m_sounds->end(),object_id(sound_object.m_object))) return; } VERIFY (m_max_sound_count); if (m_max_sound_count <= m_sounds->size()) { xr_vector<CSoundObject>::iterator I = std::min_element(m_sounds->begin(),m_sounds->end(),SLevelTimePredicate<CGameObject>()); VERIFY (m_sounds->end() != I); *I = sound_object; } else m_sounds->push_back (sound_object); }
void DBSqlServer::CheckTableAttribute(const std::string& tname, std::string& keyName, int& columnNum, bool& isIdentity) { if (!GetIsLinking()) { FULOG("the sql server have not start!"); return ; } auto iter = m_TableAttriMap.find(tname); if (iter != m_TableAttriMap.end()) { isIdentity = iter->second->_identity; keyName = iter->second->_primarykey; columnNum = iter->second->_columnNum; return; } std::string sqlStr = fu_string_format( "select tab1.name, tab2.is_identity, tab3.columnNum from (select a.name from sysobjects t, syscolumns a, sysindexkeys b \ where t.name = '%s' and t.id = a.id and t.id = b.id and b.keyno = 1 and a.colid = b.colid) tab1, sys.columns tab2, \ (select count(*) as columnNum from sys.columns where object_id = object_id('%s')) tab3 \ where tab1.name = tab2.name and tab2.object_id = object_id('%s'); ", tname.c_str(), tname.c_str(), tname.c_str()); SQLHSTMT hstmt = SQL_NULL_HSTMT; if (!st_ExcuteSql((SQLHDBC)m_hDbc, sqlStr.c_str(), &hstmt)) { FUError("CheckTableAttribute[%s] failed!", sqlStr); return; } if (SQLFetch(hstmt) != SQL_NO_DATA) { std::string keyStr, idenStr, columnStr; st_CollectField(hstmt, 1, keyStr); st_CollectField(hstmt, 2, idenStr); CTabAttri_t* pAtrri = new CTabAttri_t; pAtrri->_primarykey = keyStr; pAtrri->_identity = (idenStr == "1"); pAtrri->_columnNum = (int)fu_str_to_integer(columnStr.c_str(), columnStr.length()); keyName = pAtrri->_primarykey; isIdentity = pAtrri->_identity; columnNum = pAtrri->_columnNum; m_TableAttriMap.insert(std::make_pair(tname, pAtrri)); } //ÊÍ·ÅÓï¾ä¾ä±ú st_ReleaseHstmt(hstmt); }
bool transform_feedback::initialize_transform_feedback_object(const render_device& in_device) { if (_stream_out_setup.empty()) { state().set(object_state::OS_ERROR_INVALID_VALUE); return false; } if (SCM_GL_CORE_OPENGL_CORE_VERSION >= SCM_GL_CORE_OPENGL_CORE_VERSION_400) { // GL4.x MAX_TRANSFORM_FEEDBACK_BUFFERS if (_stream_out_setup.used_streams() > in_device.capabilities()._max_transform_feedback_buffers) { state().set(object_state::OS_ERROR_INVALID_VALUE); return false; } } else { // GL3.x MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS if (_stream_out_setup.used_streams() > in_device.capabilities()._max_transform_feedback_separate_attribs) { state().set(object_state::OS_ERROR_INVALID_VALUE); return false; } } const render_context_ptr context = in_device.main_context(); if (SCM_GL_CORE_OPENGL_CORE_VERSION >= SCM_GL_CORE_OPENGL_CORE_VERSION_400) { const opengl::gl_core& glapi = in_device.opengl_api(); util::gl_error glerror(glapi); util::transform_feedback_binding_guard guard(glapi, object_target(), object_binding()); glapi.glBindTransformFeedback(object_target(), object_id()); bind_stream_out_buffers(*context); if (glerror) { state().set(glerror.to_object_state()); unbind(*context); return false; } } return true; }
void CInventoryItem::SetDropManual(BOOL val) { m_flags.set(FdropManual, val); #ifdef DEBUG if (!IsGameTypeSingle()) { if (!!m_name) { Msg("! WARNING: trying to set drop manual flag to item [%d][%s] to %d", object_id(), m_name.c_str(), val); } } #endif // #ifdef DEBUG if (!IsGameTypeSingle()) { if (val == TRUE) DenyTrade(); else AllowTrade(); } }
void FE_Utils::create_uses_multiple_stuff (AST_Component *c, AST_Uses *u, const char *prefix) { ACE_CString struct_name (prefix); if (!struct_name.empty ()) { struct_name += '_'; } struct_name += u->local_name ()->get_string (); struct_name += "Connection"; Identifier struct_id (struct_name.c_str ()); UTL_ScopedName sn (&struct_id, 0); // In case this call comes from the backend. We // will pop the scope before returning. idl_global->scopes ().push (c); AST_Structure *connection = idl_global->gen ()->create_structure (&sn, 0, 0); struct_id.destroy (); /// If the field type is a param holder, we want /// to use the lookup to create a fresh one, /// since the field will own it and destroy it. UTL_ScopedName *fn = u->uses_type ()->name (); AST_Decl *d = idl_global->root ()->lookup_by_name (fn, true, false); AST_Type *ft = AST_Type::narrow_from_decl (d); Identifier object_id ("objref"); UTL_ScopedName object_name (&object_id, 0); AST_Field *object_field = idl_global->gen ()->create_field (ft, &object_name, AST_Field::vis_NA); (void) DeclAsScope (connection)->fe_add_field (object_field); object_id.destroy (); Identifier local_id ("Cookie"); UTL_ScopedName local_name (&local_id, 0); Identifier module_id ("Components"); UTL_ScopedName scoped_name (&module_id, &local_name); d = c->lookup_by_name (&scoped_name, true); local_id.destroy (); module_id.destroy (); if (d == 0) { // This would happen if we haven't included Components.idl. idl_global->err ()->lookup_error (&scoped_name); return; } AST_ValueType *cookie = AST_ValueType::narrow_from_decl (d); Identifier cookie_id ("ck"); UTL_ScopedName cookie_name (&cookie_id, 0); AST_Field *cookie_field = idl_global->gen ()->create_field (cookie, &cookie_name, AST_Field::vis_NA); (void) DeclAsScope (connection)->fe_add_field (cookie_field); cookie_id.destroy (); (void) c->fe_add_structure (connection); ACE_CDR::ULong bound = 0; AST_Expression *bound_expr = idl_global->gen ()->create_expr (bound, AST_Expression::EV_ulong); AST_Sequence *sequence = idl_global->gen ()->create_sequence (bound_expr, connection, 0, 0, 0); ACE_CString seq_string (struct_name); seq_string += 's'; Identifier seq_id (seq_string.c_str ()); UTL_ScopedName seq_name (&seq_id, 0); AST_Typedef *connections = idl_global->gen ()->create_typedef (sequence, &seq_name, 0, 0); seq_id.destroy (); (void) c->fe_add_typedef (connections); // In case this call comes from the backend. idl_global->scopes ().pop (); }
void test_bulk_next_hop_group_member_create() { SWSS_LOG_ENTER(); swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_NOTICE); clearDB(); meta_init_db(); redis_clear_switch_ids(); auto consumerThreads = new std::thread(bulk_nhgm_consumer_worker); swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG); sai_status_t status; sai_next_hop_group_api_t *sai_next_hop_group_api = NULL; sai_switch_api_t *sai_switch_api = NULL; sai_api_query(SAI_API_NEXT_HOP_GROUP, (void**)&sai_next_hop_group_api); sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api); uint32_t count = 3; std::vector<sai_route_entry_t> routes; std::vector<sai_attribute_t> attrs; sai_attribute_t swattr; swattr.id = SAI_SWITCH_ATTR_INIT_SWITCH; swattr.value.booldata = true; sai_object_id_t switch_id; status = sai_switch_api->create_switch(&switch_id, 1, &swattr); ASSERT_SUCCESS("Failed to create switch"); std::vector<std::vector<sai_attribute_t>> nhgm_attrs; std::vector<sai_attribute_t *> nhgm_attrs_array; std::vector<uint32_t> nhgm_attrs_count; // next hop group sai_object_id_t hopgroup = create_dummy_object_id(SAI_OBJECT_TYPE_NEXT_HOP_GROUP); object_reference_insert(hopgroup); sai_object_meta_key_t meta_key_hopgruop = { .objecttype = SAI_OBJECT_TYPE_NEXT_HOP_GROUP, .objectkey = { .key = { .object_id = hopgroup } } }; std::string hopgroup_key = sai_serialize_object_meta_key(meta_key_hopgruop); ObjectAttrHash[hopgroup_key] = { }; sai_object_id_t hopgroup_vid = translate_rid_to_vid(hopgroup, switch_id); for (uint32_t i = 0; i < count; ++i) { // next hop sai_object_id_t hop = create_dummy_object_id(SAI_OBJECT_TYPE_NEXT_HOP); object_reference_insert(hop); sai_object_meta_key_t meta_key_hop = { .objecttype = SAI_OBJECT_TYPE_NEXT_HOP, .objectkey = { .key = { .object_id = hop } } }; std::string hop_key = sai_serialize_object_meta_key(meta_key_hop); ObjectAttrHash[hop_key] = { }; sai_object_id_t hop_vid = translate_rid_to_vid(hop, switch_id); std::vector<sai_attribute_t> list(2); sai_attribute_t &attr1 = list[0]; sai_attribute_t &attr2 = list[1]; attr1.id = SAI_NEXT_HOP_GROUP_MEMBER_ATTR_NEXT_HOP_GROUP_ID; attr1.value.oid = hopgroup_vid; attr2.id = SAI_NEXT_HOP_GROUP_MEMBER_ATTR_NEXT_HOP_ID; attr2.value.oid = hop_vid; nhgm_attrs.push_back(list); nhgm_attrs_count.push_back(2); } for (size_t j = 0; j < nhgm_attrs.size(); j++) { nhgm_attrs_array.push_back(nhgm_attrs[j].data()); } std::vector<sai_status_t> statuses(count); std::vector<sai_object_id_t> object_id(count); sai_bulk_create_next_hop_group_members(switch_id, count, nhgm_attrs_count.data(), nhgm_attrs_array.data() , SAI_BULK_OP_TYPE_INGORE_ERROR, object_id.data(), statuses.data()); ASSERT_SUCCESS("Failed to bulk create nhgm"); for (size_t j = 0; j < statuses.size(); j++) { status = statuses[j]; ASSERT_SUCCESS("Failed to create nhgm # %zu", j); } consumerThreads->join(); delete consumerThreads; // check the created nhgm for (size_t i = 0; i < created_next_hop_group_member.size(); i++) { auto& created = created_next_hop_group_member[i]; auto& created_attrs = std::get<2>(created); assert(created_attrs.size() == 2); assert(created_attrs[1].value.oid == nhgm_attrs[i][1].value.oid); } status = sai_bulk_remove_next_hop_group_members(count, object_id.data(), SAI_BULK_OP_TYPE_INGORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to bulk remove nhgm"); }
void CHitMemoryManager::add (float amount, const Fvector &vLocalDir, const CObject *who, s16 element) { #ifndef MASTER_GOLD if (who && smart_cast<CActor const*>(who) && psAI_Flags.test(aiIgnoreActor)) return; #endif // MASTER_GOLD VERIFY (m_hits); if (!object().g_Alive()) return; if (who && (m_object->ID() == who->ID())) return; if (who && !fis_zero(amount)) { m_last_hit_object_id = who->ID(); m_last_hit_time = Device.dwTimeGlobal; } object().callback(GameObject::eHit)( m_object->lua_game_object(), amount, vLocalDir, smart_cast<const CGameObject*>(who)->lua_game_object(), element ); Fvector direction; m_object->XFORM().transform_dir (direction,vLocalDir); const CEntityAlive *entity_alive = smart_cast<const CEntityAlive*>(who); if (!entity_alive || (m_object->tfGetRelationType(entity_alive) == ALife::eRelationTypeFriend)) return; HITS::iterator J = std::find(m_hits->begin(),m_hits->end(),object_id(who)); if (m_hits->end() == J) { CHitObject hit_object; hit_object.fill (entity_alive,m_object,!m_stalker ? squad_mask_type(-1) : m_stalker->agent_manager().member().mask(m_stalker)); #ifdef USE_FIRST_GAME_TIME hit_object.m_first_game_time = Level().GetGameTime(); #endif #ifdef USE_FIRST_LEVEL_TIME hit_object.m_first_level_time = Device.dwTimeGlobal; #endif hit_object.m_amount = amount; if (m_max_hit_count <= m_hits->size()) { HITS::iterator I = std::min_element(m_hits->begin(),m_hits->end(),SLevelTimePredicate<CEntityAlive>()); VERIFY (m_hits->end() != I); *I = hit_object; } else m_hits->push_back (hit_object); } else { (*J).fill (entity_alive,m_object,(!m_stalker ? (*J).m_squad_mask.get() : ((*J).m_squad_mask.get() | m_stalker->agent_manager().member().mask(m_stalker)))); (*J).m_amount = _max(amount,(*J).m_amount); } }
void CSoundMemoryManager::add (const CObject *object, int sound_type, const Fvector &position, float sound_power) { #ifndef SAVE_OWN_SOUNDS // we do not want to save our own sounds if (object && (m_object->ID() == object->ID())) return; #endif #ifndef SAVE_OWN_ITEM_SOUNDS // we do not want to save the sounds which was from the items we own if (object && object->H_Parent() && (object->H_Parent()->ID() == m_object->ID())) return; #endif #ifndef SAVE_NON_ALIVE_OBJECT_SOUNDS // we do not want to save sounds from the non-alive objects (?!) if (object && !m_object->memory().enemy().selected() && !smart_cast<const CEntityAlive*>(object)) return; #endif #ifndef SAVE_FRIEND_ITEM_SOUNDS // we do not want to save sounds from the teammates items CEntityAlive *me = m_object; if (object && object->H_Parent() && (me->tfGetRelationType(smart_cast<const CEntityAlive*>(object->H_Parent())) == ALife::eRelationTypeFriend)) return; #endif #ifndef SAVE_FRIEND_SOUNDS const CEntityAlive *entity_alive = smart_cast<const CEntityAlive*>(object); // we do not want to save sounds from the teammates if (entity_alive && me && (me->tfGetRelationType(entity_alive) == ALife::eRelationTypeFriend)) return; #endif #ifndef SAVE_VISIBLE_OBJECT_SOUNDS # ifdef SAVE_FRIEND_SOUNDS const CEntityAlive *entity_alive = smart_cast<const CEntityAlive*>(object); # endif // we do not save sounds from the objects we see (?!) if (m_object->memory().visual().visible_now(entity_alive)) return; #endif const CGameObject *game_object = smart_cast<const CGameObject*>(object); if (!game_object && object) return; const CGameObject *self = m_object; xr_vector<CSoundObject>::iterator J = std::find(m_sounds->begin(),m_sounds->end(),object_id(object)); if (m_sounds->end() == J) { CSoundObject sound_object; sound_object.fill (game_object,self,ESoundTypes(sound_type),sound_power,!m_stalker ? squad_mask_type(-1) : m_stalker->agent_manager().member().mask(m_stalker)); if (!game_object) sound_object.m_object_params.m_position = position; #ifdef USE_FIRST_GAME_TIME sound_object.m_first_game_time = Level().GetGameTime(); #endif #ifdef USE_FIRST_LEVEL_TIME sound_object.m_first_level_time = Device.dwTimeGlobal; #endif add (sound_object); } else { (*J).fill (game_object,self,ESoundTypes(sound_type),sound_power,(!m_stalker ? (*J).m_squad_mask.get() : ((*J).m_squad_mask.get() | m_stalker->agent_manager().member().mask(m_stalker)))); if (!game_object) (*J).m_object_params.m_position = position; } }