Guest User

Untitled

a guest
Oct 21st, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.23 KB | None | 0 0
  1. @@ -260,6 +260,10 @@
  2.  
  3.  static cell_t ExtinguishEntity(IPluginContext *pContext, const cell_t *params)
  4.  {
  5. -   static ValveCall *pCall = NULL;
  6. -   if (!pCall)
  7. +#if SOURCE_ENGINE == SE_ORANGEBOXVALVE
  8. +   /*
  9. +    * For some reason, extinguish (removing the FL_ONFIRE effect) does not work on CS:S.
  10. +    * See bug 3390.
  11. +    */
  12. +   if (strcmp(g_pSM->GetGameFolderName(), "cstrike") == 0)
  13.     {
  14. @@ -265,3 +269,5 @@
  15.     {
  16. -       if (!CreateBaseCall("Extinguish", ValveCall_Entity, NULL, NULL, 0, &pCall))
  17. +       CBaseEntity *pEntity = NULL;
  18. +       int index = gamehelpers->ReferenceToIndex(params[1]);
  19. +       if ((unsigned)index == INVALID_EHANDLE_INDEX && params[1] != -1)
  20.         {
  21. @@ -267,5 +273,3 @@
  22.         {
  23. -           return pContext->ThrowNativeError("\"Extinguish\" not supported by this mod");
  24. -       } else if (!pCall) {
  25. -           return pContext->ThrowNativeError("\"Extinguish\" wrapper failed to initialize");
  26. +           return pContext->ThrowNativeError("Entity %d is not valid", params[1]);
  27.         }
  28. @@ -271,2 +275,65 @@
  29.         }
  30. +
  31. +       if (index >= 1 && index <= playerhelpers->GetMaxClients())
  32. +       {
  33. +           IGamePlayer *player = playerhelpers->GetGamePlayer(index);
  34. +           if (!player->IsInGame())
  35. +           {
  36. +               return pContext->ThrowNativeError("Client %d is not in game", params[1]);
  37. +           }
  38. +       }
  39. +
  40. +       pEntity = gamehelpers->ReferenceToEntity(params[1]);
  41. +
  42. +       sm_sendprop_info_t info;
  43. +       IServerNetworkable *pNet = ((IServerUnknown *)pEntity)->GetNetworkable();
  44. +       if (!pNet)
  45. +       {
  46. +           return pContext->ThrowNativeError("Edict %d (%d) is not networkable", gamehelpers->ReferenceToIndex(params[1]), params[1]);
  47. +       }
  48. +       if (!gamehelpers->FindSendPropInfo(pNet->GetServerClass()->GetName(), "m_hEffectEntity", &info))
  49. +       {
  50. +           return pContext->ThrowNativeError("Property \"m_hEffectEntity\" not found (entity %d)", params[1]);
  51. +       }
  52. +
  53. +       CBaseHandle &hEffectEntity = *(CBaseHandle *)((uint8_t *)pEntity + info.actual_offset);
  54. +
  55. +       edict_t *pEffectEdict = gamehelpers->GetHandleEntity(hEffectEntity);
  56. +       if (pEffectEdict)
  57. +       {
  58. +           if (strcmp(pEffectEdict->GetNetworkable()->GetServerClass()->GetName(), "CEntityFlame") == 0)
  59. +           {
  60. +               datamap_t *pMap;
  61. +               typedescription_t *td;
  62. +               if ((pMap = gamehelpers->GetDataMap(pEntity)) == NULL)
  63. +               {
  64. +                   return pContext->ThrowNativeError("Could not retrieve datamap");
  65. +               }
  66. +               if ((td = gamehelpers->FindInDataMap(pMap, "m_flLifetime")) == NULL)
  67. +               {
  68. +                   return pContext->ThrowNativeError("Property \"m_flLifetime\" not found (entity %d)", params[1]);
  69. +               }
  70. +          
  71. +               *(float *)((uint8_t *)pEntity + GetTypeDescOffs(td)) = 0.0f;
  72. +           }
  73. +       }
  74. +   }  // if "cstrike"
  75. +   else
  76. +   {
  77. +#endif  // if SOURCE_ENGINE == SE_EPISODE2VALVE
  78. +       static ValveCall *pCall = NULL;
  79. +       if (!pCall)
  80. +       {
  81. +           if (!CreateBaseCall("Extinguish", ValveCall_Entity, NULL, NULL, 0, &pCall))
  82. +           {
  83. +               return pContext->ThrowNativeError("\"Extinguish\" not supported by this mod");
  84. +           } else if (!pCall) {
  85. +               return pContext->ThrowNativeError("\"Extinguish\" wrapper failed to initialize");
  86. +           }
  87. +       }
  88. +
  89. +       START_CALL();
  90. +       DECODE_VALVE_PARAM(1, thisinfo, 0);
  91. +       FINISH_CALL_SIMPLE(NULL);
  92. +#if SOURCE_ENGINE == SE_ORANGEBOXVALVE
  93.     }
  94. @@ -272,8 +339,5 @@
  95.     }
  96. -
  97. -   START_CALL();
  98. -   DECODE_VALVE_PARAM(1, thisinfo, 0);
  99. -   FINISH_CALL_SIMPLE(NULL);
  100. +#endif
  101.  
  102.     return 1;
  103.  }
Add Comment
Please, Sign In to add comment