Add ewrite_[coord_f/angle_f], write_[coord_f/angle_f] and [e]message_begin_f natives (bug 5829, r=arkshine)

Former-commit-id: 34ab529d53729009fce913582838b609077b5f37
This commit is contained in:
Nextra 2013-08-10 10:22:38 +02:00
parent 86f5c9f031
commit 917c52ec96
2 changed files with 81 additions and 11 deletions

View File

@ -362,7 +362,7 @@ void C_MessageEnd(void)
RETURN_META(MRES_IGNORED);
}
static cell AMX_NATIVE_CALL message_begin(AMX *amx, cell *params) /* 4 param */
static cell _message_begin(AMX *amx, cell *params, bool useFloat) /* 4 param */
{
int numparam = *params / sizeof(cell);
float vecOrigin[3];
@ -392,9 +392,16 @@ static cell AMX_NATIVE_CALL message_begin(AMX *amx, cell *params) /* 4 param */
cpOrigin = get_amxaddr(amx, params[3]);
vecOrigin[0] = static_cast<float>(*cpOrigin);
vecOrigin[1] = static_cast<float>(*(cpOrigin + 1));
vecOrigin[2] = static_cast<float>(*(cpOrigin + 2));
if (!useFloat)
{
vecOrigin[0] = static_cast<float>(*cpOrigin);
vecOrigin[1] = static_cast<float>(*(cpOrigin + 1));
vecOrigin[2] = static_cast<float>(*(cpOrigin + 2));
} else {
vecOrigin[0] = amx_ctof(*cpOrigin);
vecOrigin[1] = amx_ctof(*(cpOrigin + 1));
vecOrigin[2] = amx_ctof(*(cpOrigin + 2));
}
MESSAGE_BEGIN(params[1], params[2], vecOrigin);
@ -414,6 +421,16 @@ static cell AMX_NATIVE_CALL message_begin(AMX *amx, cell *params) /* 4 param */
return 1;
}
static cell AMX_NATIVE_CALL message_begin(AMX *amx, cell *params) /* 4 param */
{
return _message_begin(amx, params, false);
}
static cell AMX_NATIVE_CALL message_begin_f(AMX *amx, cell *params) /* 4 param */
{
return _message_begin(amx, params, true);
}
static cell AMX_NATIVE_CALL message_end(AMX *amx, cell *params)
{
MESSAGE_END();
@ -456,12 +473,24 @@ static cell AMX_NATIVE_CALL write_angle(AMX *amx, cell *params) /* 1 param */
return 1;
}
static cell AMX_NATIVE_CALL write_angle_f(AMX *amx, cell *params) /* 1 param */
{
WRITE_ANGLE(amx_ctof(params[1]));
return 1;
}
static cell AMX_NATIVE_CALL write_coord(AMX *amx, cell *params) /* 1 param */
{
WRITE_COORD(static_cast<float>(params[1]));
return 1;
}
static cell AMX_NATIVE_CALL write_coord_f(AMX *amx, cell *params) /* 1 param */
{
WRITE_COORD(amx_ctof(params[1]));
return 1;
}
static cell AMX_NATIVE_CALL write_string(AMX *amx, cell *params) /* 1 param */
{
int a;
@ -681,7 +710,7 @@ static cell AMX_NATIVE_CALL get_msg_origin(AMX *amx, cell *params)
return 1;
}
static cell AMX_NATIVE_CALL emessage_begin(AMX *amx, cell *params) /* 4 param */
static cell _emessage_begin(AMX *amx, cell *params, bool useFloat)
{
int numparam = *params / sizeof(cell);
float vecOrigin[3];
@ -711,9 +740,16 @@ static cell AMX_NATIVE_CALL emessage_begin(AMX *amx, cell *params) /* 4 param */
cpOrigin = get_amxaddr(amx, params[3]);
vecOrigin[0] = static_cast<float>(*cpOrigin);
vecOrigin[1] = static_cast<float>(*(cpOrigin + 1));
vecOrigin[2] = static_cast<float>(*(cpOrigin + 2));
if (!useFloat)
{
vecOrigin[0] = static_cast<float>(*cpOrigin);
vecOrigin[1] = static_cast<float>(*(cpOrigin + 1));
vecOrigin[2] = static_cast<float>(*(cpOrigin + 2));
} else {
vecOrigin[0] = amx_ctof(*cpOrigin);
vecOrigin[1] = amx_ctof(*(cpOrigin + 1));
vecOrigin[2] = amx_ctof(*(cpOrigin + 2));
}
g_pEngTable->pfnMessageBegin(params[1], params[2], vecOrigin, NULL);
@ -733,6 +769,16 @@ static cell AMX_NATIVE_CALL emessage_begin(AMX *amx, cell *params) /* 4 param */
return 1;
}
static cell AMX_NATIVE_CALL emessage_begin(AMX *amx, cell *params) /* 4 param */
{
return _emessage_begin(amx, params, false);
}
static cell AMX_NATIVE_CALL emessage_begin_f(AMX *amx, cell *params) /* 4 param */
{
return _emessage_begin(amx, params, true);
}
static cell AMX_NATIVE_CALL emessage_end(AMX *amx, cell *params)
{
g_pEngTable->pfnMessageEnd();
@ -775,12 +821,24 @@ static cell AMX_NATIVE_CALL ewrite_angle(AMX *amx, cell *params) /* 1 param */
return 1;
}
static cell AMX_NATIVE_CALL ewrite_angle_f(AMX *amx, cell *params) /* 1 param */
{
g_pEngTable->pfnWriteAngle(amx_ctof(params[1]));
return 1;
}
static cell AMX_NATIVE_CALL ewrite_coord(AMX *amx, cell *params) /* 1 param */
{
g_pEngTable->pfnWriteCoord(static_cast<float>(params[1]));
return 1;
}
static cell AMX_NATIVE_CALL ewrite_coord_f(AMX *amx, cell *params) /* 1 param */
{
g_pEngTable->pfnWriteCoord(amx_ctof(params[1]));
return 1;
}
static cell AMX_NATIVE_CALL ewrite_string(AMX *amx, cell *params) /* 1 param */
{
int a;
@ -792,12 +850,15 @@ static cell AMX_NATIVE_CALL ewrite_string(AMX *amx, cell *params) /* 1 param */
AMX_NATIVE_INFO msg_Natives[] =
{
{"message_begin", message_begin},
{"message_begin_f", message_begin_f},
{"message_end", message_end},
{"write_angle", write_angle},
{"write_angle_f", write_angle_f},
{"write_byte", write_byte},
{"write_char", write_char},
{"write_coord", write_coord},
{"write_coord_f", write_coord_f},
{"write_entity", write_entity},
{"write_long", write_long},
{"write_short", write_short},
@ -820,12 +881,15 @@ AMX_NATIVE_INFO msg_Natives[] =
{"get_msg_origin", get_msg_origin},
{"emessage_begin", emessage_begin},
{"emessage_begin_f", emessage_begin_f},
{"emessage_end", emessage_end},
{"ewrite_angle", ewrite_angle},
{"ewrite_angle_f", ewrite_angle_f},
{"ewrite_byte", ewrite_byte},
{"ewrite_char", ewrite_char},
{"ewrite_coord", ewrite_coord},
{"ewrite_coord_f", ewrite_coord_f},
{"ewrite_entity", ewrite_entity},
{"ewrite_long", ewrite_long},
{"ewrite_short", ewrite_short},

View File

@ -17,6 +17,7 @@
* intermission and many many others messages.
* See HL SDK for more examples. */
native message_begin(dest, msg_type, const origin[3] = {0,0,0}, player = 0);
native message_begin_f(dest, msg_type, const Float:origin[3] = {0.0,0.0,0.0}, player = 0);
native message_end();
native write_byte(x);
native write_char(x);
@ -24,7 +25,9 @@ native write_short(x);
native write_long(x);
native write_entity(x);
native write_angle(x);
native write_angle_f(Float:x);
native write_coord(x);
native write_coord_f(Float:x);
native write_string(const x[]);
/* These are the same as above, except that the messages sent
@ -36,6 +39,7 @@ native write_string(const x[]);
* NOTE! These natives are experimental.
*/
native emessage_begin(dest, msg_type, const origin[3] = {0,0,0}, player = 0);
native emessage_begin_f(dest, msg_type, const Float:origin[3] = {0.0,0.0,0.0}, player = 0);
native emessage_end();
native ewrite_byte(x);
native ewrite_char(x);
@ -43,7 +47,9 @@ native ewrite_short(x);
native ewrite_long(x);
native ewrite_entity(x);
native ewrite_angle(x);
native ewrite_angle_f(Float:x);
native ewrite_coord(x);
native ewrite_coord_f(Float:x);
native ewrite_string(const x[]);
/* Sets/Gets what engine messages are blocked. */