Calling get_msg_origin in a hooked message can sometimes result in a server crash. I think this is due to the fact that only messages with a destination of MSG_PVS, MSG_PAS, MSG_PVS_R, or MSG_PAS_R will pass an origin. So if the message destination is anything other than what I mentioned, this is what will cause the crash with get_msg_origin. I understand that I should only use get_msg_origin in those circumstances, however I think you should protect against someone trying to call it. Here's how this can be fixed.
In messages.cpp of the engine module, get_msg_origin probably should be:
Code:
static cell AMX_NATIVE_CALL get_msg_origin(AMX *amx, cell *params)
{
if (!inhook) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
vec3_t vRet = (Vector)msgOrigin;
cell *cAddr = MF_GetAmxAddr(amx, params[1]);
if (msgDest >= MSG_PVS && msgDest <= MSG_PAS_R) {
cAddr[0] = amx_ftoc(vRet.x);
cAddr[1] = amx_ftoc(vRet.y);
cAddr[2] = amx_ftoc(vRet.z);
} else {
cAddr[0] = 0;
cAddr[1] = 0;
cAddr[2] = 0;
}
return 1;
}
So if the message destination is not PVS or PAS, it will make the origin {0, 0, 0}. Since most people use {0, 0, 0} as the origin when they call message_begin with a destination of anything other than PVS or PAS, this is probably the best way to handle it.