reapi icon indicating copy to clipboard operation
reapi copied to clipboard

The rh_emit_sound2 native is broken

Open DarthMan opened this issue 3 years ago • 2 comments

Hello, it seems that the rh_emit_sound2 native is broken. I wrote a plugin example that I tested on TFC.

Didn't test in other mods, but since it's broken on Team Fortress Classic, I guess it is on all of them. Hope it will be fixed :)

#include <amxmodx>
#include <reapi>

new const umbrella_sound[] = "weapons/cbar_miss1.wav";

public plugin_init() {
    register_clcmd("say /sound", "PlaySound");
}

public PlaySound(id) {
    rh_emit_sound2(id, id, CHAN_ITEM, umbrella_sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
}

public plugin_precache() {
    precache_sound(umbrella_sound);
}

DarthMan avatar Feb 14 '22 16:02 DarthMan

rh_emit_sound2 uses checks that are specific to the CS gamedll: https://github.com/s1lentq/reapi/blob/efcc3952b5d2a96280521d98d1ec6072c5d39175/reapi/src/natives/natives_misc.cpp#L2657-L2663

CHECK_CONNECTED uses has_disconnected field which is present only in CS. IsNetClient also cannot be used in cross-game code because function offsets inside vtables aren't the same across the different games.

rh_update_user_info is also affected by this: https://github.com/s1lentq/reapi/blob/efcc3952b5d2a96280521d98d1ec6072c5d39175/reapi/src/natives/natives_misc.cpp#L2689-L2690

There are also common natives affected:

  • GetGrenadeType - but I hope it should be CS-specific anyway
  • engset_view
  • GetBonePosition - not sure
  • GetAttachment - not sure
  • SetThink - should rely on gamedata to be not CS-specific
  • SetTouch - same as SetThink
  • SetUse - same as SetThink
  • SetBlocked - same as SetThink
  • SetMoveDone - same as SetThink
  • is_entity

WPMGPRoSToTeMa avatar Feb 14 '22 21:02 WPMGPRoSToTeMa

rh_emit_sound2 uses checks that are specific to the CS gamedll:

https://github.com/s1lentq/reapi/blob/efcc3952b5d2a96280521d98d1ec6072c5d39175/reapi/src/natives/natives_misc.cpp#L2657-L2663

CHECK_CONNECTED uses has_disconnected field which is present only in CS. IsNetClient also cannot be used in cross-game code because function offsets inside vtables aren't the same across the different games.

rh_update_user_info is also affected by this:

https://github.com/s1lentq/reapi/blob/efcc3952b5d2a96280521d98d1ec6072c5d39175/reapi/src/natives/natives_misc.cpp#L2689-L2690

There are also common natives affected:

  • GetGrenadeType - but I hope it should be RG specific anyway
  • engset_view
  • GetBonePosition - not sure
  • GetAttachment - not sure
  • SetThink - should rely on gamedata to be not RG specific
  • SetTouch - same as SetThink
  • SetUse - same as SetThink
  • SetBlocked - same as SetThink
  • SetMoveDone - same as SetThink
  • is_entity

Then I guess since they rely on CS they must be moved to regamedll or if not in the native description it should be stated that all the mentioned natives are only for CS only.

DarthMan avatar Feb 14 '22 23:02 DarthMan