| 968 | #endif // >= ORANGEBOX && != TF2 |
| 969 | |
| 970 | static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *params) |
| 971 | { |
| 972 | #if SOURCE_ENGINE == SE_TF2 \ |
| 973 | || SOURCE_ENGINE == SE_DODS \ |
| 974 | || SOURCE_ENGINE == SE_HL2DM \ |
| 975 | || SOURCE_ENGINE == SE_CSS \ |
| 976 | || SOURCE_ENGINE == SE_BMS \ |
| 977 | || SOURCE_ENGINE == SE_SDK2013 \ |
| 978 | || SOURCE_ENGINE == SE_BLADE \ |
| 979 | || SOURCE_ENGINE == SE_NUCLEARDAWN \ |
| 980 | || SOURCE_ENGINE == SE_PVKII |
| 981 | |
| 982 | static bool bHasServerTools3 = !!g_SMAPI->GetServerFactory(false)("VSERVERTOOLS003", nullptr); |
| 983 | if (bHasServerTools3) |
| 984 | { |
| 985 | CBaseEntity *pStartEnt = NULL; |
| 986 | if (params[1] != -1) |
| 987 | { |
| 988 | pStartEnt = gamehelpers->ReferenceToEntity(params[1]); |
| 989 | if (!pStartEnt) |
| 990 | { |
| 991 | return pContext->ThrowNativeError("Entity %d (%d) is invalid", |
| 992 | gamehelpers->ReferenceToIndex(params[1]), |
| 993 | params[1]); |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | char *searchname; |
| 998 | pContext->LocalToString(params[2], &searchname); |
| 999 | |
| 1000 | CBaseEntity *pEntity = servertools->FindEntityByClassname(pStartEnt, searchname); |
| 1001 | return gamehelpers->EntityToBCompatRef(pEntity); |
| 1002 | } |
| 1003 | #endif |
| 1004 | |
| 1005 | static ValveCall *pCall = NULL; |
| 1006 | static bool bProbablyNoFEBC = false; |
| 1007 | |
| 1008 | #if SOURCE_ENGINE >= SE_ORANGEBOX |
| 1009 | if (bProbablyNoFEBC) |
| 1010 | { |
| 1011 | return NativeFindEntityByClassname(pContext, params); |
| 1012 | } |
| 1013 | #endif // >= SE_ORANGEBOX |
| 1014 | |
| 1015 | if (!pCall) |
| 1016 | { |
| 1017 | ValvePassInfo pass[3]; |
| 1018 | InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL|VDECODE_FLAG_ALLOWWORLD); |
| 1019 | InitPass(pass[1], Valve_String, PassType_Basic, PASSFLAG_BYVAL); |
| 1020 | InitPass(pass[2], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL); |
| 1021 | |
| 1022 | char error[256]; |
| 1023 | error[0] = '\0'; |
| 1024 | if (!CreateBaseCall("FindEntityByClassname", ValveCall_EntityList, &pass[2], pass, 2, &pCall)) |
| 1025 | { |
| 1026 | g_pSM->Format(error, sizeof(error), "\"FindEntityByClassname\" not supported by this mod"); |
| 1027 | } else if (!pCall) { |
nothing calls this directly
no test coverage detected