| 2679 | } |
| 2680 | |
| 2681 | static cell_t GetEntityFlags(IPluginContext *pContext, const cell_t *params) |
| 2682 | { |
| 2683 | CBaseEntity *pEntity = g_HL2.ReferenceToEntity(params[1]); |
| 2684 | if (!pEntity) |
| 2685 | { |
| 2686 | return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]); |
| 2687 | } |
| 2688 | |
| 2689 | const char *prop = g_pGameConf->GetKeyValue("m_fFlags"); |
| 2690 | if (!prop) |
| 2691 | { |
| 2692 | return pContext->ThrowNativeError("Could not find m_fFlags prop in gamedata"); |
| 2693 | } |
| 2694 | |
| 2695 | datamap_t *pMap; |
| 2696 | |
| 2697 | if ((pMap = CBaseEntity_GetDataDescMap(pEntity)) == NULL) |
| 2698 | { |
| 2699 | return pContext->ThrowNativeError("Could not retrieve datamap"); |
| 2700 | } |
| 2701 | |
| 2702 | sm_datatable_info_t info; |
| 2703 | if (!g_HL2.FindDataMapInfo(pMap, prop, &info)) |
| 2704 | { |
| 2705 | return pContext->ThrowNativeError("Property \"%s\" not found (entity %d)", |
| 2706 | prop, |
| 2707 | params[1]); |
| 2708 | } |
| 2709 | |
| 2710 | int offset = info.actual_offset; |
| 2711 | |
| 2712 | int32_t actual_flags = *(int32_t *)((uint8_t *)pEntity + offset); |
| 2713 | int32_t sm_flags = 0; |
| 2714 | |
| 2715 | for (int32_t i = 0; i < 32; i++) |
| 2716 | { |
| 2717 | int32_t flag = (1U<<i); |
| 2718 | if ((actual_flags & flag) == flag) |
| 2719 | { |
| 2720 | sm_flags |= SDKEntFlagToSMEntFlag(flag); |
| 2721 | } |
| 2722 | } |
| 2723 | |
| 2724 | return sm_flags; |
| 2725 | } |
| 2726 | |
| 2727 | static cell_t SetEntityFlags(IPluginContext *pContext, const cell_t *params) |
| 2728 | { |
nothing calls this directly
no test coverage detected