Raised This Month: $32 Target: $400
 8% 

[ENGINE] get_msg_origin Crash


  
 
 
Thread Tools Display Modes
Author Message
DS
SourceMod Developer
Join Date: Sep 2004
Location: WI, USA
Old 10-19-2004 , 20:57   [ENGINE] get_msg_origin Crash
#1

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.
DS is offline
BAILOPAN
Join Date: Jan 2004
Old 10-23-2004 , 21:11  
#2

Thanks, fixed
__________________
egg
BAILOPAN is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode