added fix for binlog bug with failed plugins

added experimental emsg natives
fixed target's velbyaim bug find
added native for setting player curweapon
This commit is contained in:
David Anderson 2006-06-28 10:07:20 +00:00
parent d3af14c957
commit 9dcdba439a
6 changed files with 200 additions and 36 deletions

View File

@ -3932,6 +3932,11 @@ static cell AMX_NATIVE_CALL ShowSyncHudMsg(AMX *amx, cell *params)
return len;
}
static cell AMX_NATIVE_CALL is_user_hacking(AMX *amx, cell *params)
{
return g_bmod_cstrike ? 1 : 0;
}
static cell AMX_NATIVE_CALL arrayset(AMX *amx, cell *params)
{
memset(get_amxaddr(amx, params[1]), params[2], params[3] * sizeof(cell));
@ -3939,6 +3944,27 @@ static cell AMX_NATIVE_CALL arrayset(AMX *amx, cell *params)
return 1;
}
static cell AMX_NATIVE_CALL amxx_setpl_curweap(AMX *amx, cell *params)
{
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid client %d", params[1]);
return 0;
}
CPlayer *p = GET_PLAYER_POINTER_I(params[1]);
if (!p->ingame)
{
LogError(amx, AMX_ERR_NATIVE, "Player %d not ingame", params[1]);
return 0;
}
p->current = params[2];
return 1;
}
AMX_NATIVE_INFO amxmodx_Natives[] =
{
{"abort", amx_abort},
@ -4043,6 +4069,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"is_user_bot", is_user_bot},
{"is_user_connected", is_user_connected},
{"is_user_connecting", is_user_connecting},
{"is_user_hacking", is_user_hacking},
{"is_user_hltv", is_user_hltv},
{"lang_exists", lang_exists},
{"log_amx", log_amx},

View File

@ -338,4 +338,6 @@ struct func_s
const char *desc;
};
extern enginefuncs_t *g_pEngTable;
#endif // AMXMODX_H

View File

@ -227,6 +227,8 @@ void BinLog::WritePluginDB(FILE *fp)
if (c && pl->isDebug())
c = 2;
fwrite(&c, sizeof(char), 1, fp);
if (c)
{
len = (char)strlen(pl->getName());
fwrite(&len, sizeof(char), 1, fp);
len++;
@ -254,6 +256,15 @@ void BinLog::WritePluginDB(FILE *fp)
len++;
fwrite(name, sizeof(char), len, fp);
}
} else {
char empty[] = " ";
len = 1;
fwrite(&len, sizeof(char), 1, fp);
fwrite(empty, sizeof(char), len, fp);
int no = 0;
fwrite(&no, sizeof(int), 1, fp);
fwrite(&no, sizeof(int), 1, fp);
}
}
}

View File

@ -10,6 +10,7 @@ float *msgOrigin;
edict_t *msgpEntity;
bool inhook = false;
bool inblock = false;
enginefuncs_t *g_pEngTable = NULL;
void ClearMessages()
{
@ -651,6 +652,114 @@ 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 */
{
int numparam = *params / sizeof(cell);
float vecOrigin[3];
cell *cpOrigin;
if (params[2] < 1 || ((params[2] > 63) // maximal number of engine messages
&& !GET_USER_MSG_NAME(PLID, params[2], NULL)))
{
LogError(amx, AMX_ERR_NATIVE, "Plugin called message_begin with an invalid message id (%d).", params[2]);
return 0;
}
switch (params[1])
{
case MSG_BROADCAST:
case MSG_ALL:
case MSG_SPEC:
g_pEngTable->pfnMessageBegin(params[1], params[2], NULL, NULL);
break;
case MSG_PVS: case MSG_PAS:
case MSG_PVS_R: case MSG_PAS_R:
if (numparam < 3)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid number of parameters passed");
return 0;
}
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));
g_pEngTable->pfnMessageBegin(params[1], params[2], vecOrigin, NULL);
break;
case MSG_ONE_UNRELIABLE:
case MSG_ONE:
if (numparam < 4)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid number of parameters passed");
return 0;
}
g_pEngTable->pfnMessageBegin(params[1], params[2], NULL, INDEXENT(params[4]));
break;
}
return 1;
}
static cell AMX_NATIVE_CALL emessage_end(AMX *amx, cell *params)
{
g_pEngTable->pfnMessageEnd();
return 1;
}
static cell AMX_NATIVE_CALL ewrite_byte(AMX *amx, cell *params) /* 1 param */
{
g_pEngTable->pfnWriteByte(params[1]);
return 1;
}
static cell AMX_NATIVE_CALL ewrite_char(AMX *amx, cell *params) /* 1 param */
{
g_pEngTable->pfnWriteChar(params[1]);
return 1;
}
static cell AMX_NATIVE_CALL ewrite_short(AMX *amx, cell *params) /* 1 param */
{
g_pEngTable->pfnWriteShort(params[1]);
return 1;
}
static cell AMX_NATIVE_CALL ewrite_long(AMX *amx, cell *params) /* 1 param */
{
g_pEngTable->pfnWriteLong(params[1]);
return 1;
}
static cell AMX_NATIVE_CALL ewrite_entity(AMX *amx, cell *params) /* 1 param */
{
g_pEngTable->pfnWriteEntity(params[1]);
return 1;
}
static cell AMX_NATIVE_CALL ewrite_angle(AMX *amx, cell *params) /* 1 param */
{
g_pEngTable->pfnWriteAngle(static_cast<float>(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_string(AMX *amx, cell *params) /* 1 param */
{
int a;
g_pEngTable->pfnWriteString(get_amxstring(amx, params[1], 3, a));
return 1;
}
AMX_NATIVE_INFO msg_Natives[] =
{
{"message_begin", message_begin},
@ -680,5 +789,17 @@ AMX_NATIVE_INFO msg_Natives[] =
{"set_msg_arg_string", set_msg_arg_string},
{"get_msg_origin", get_msg_origin},
{"emessage_begin", emessage_begin},
{"emessage_end", emessage_end},
{"ewrite_angle", ewrite_angle},
{"ewrite_byte", ewrite_byte},
{"ewrite_char", ewrite_char},
{"ewrite_coord", ewrite_coord},
{"ewrite_entity", ewrite_entity},
{"ewrite_long", ewrite_long},
{"ewrite_short", ewrite_short},
{"ewrite_string", ewrite_string},
{NULL, NULL},
};

View File

@ -1351,6 +1351,8 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
// This will also call modules Meta_Query and Meta_Attach functions
loadModules(get_localinfo("amxx_modules", "addons/amxmodx/configs/modules.ini"), now);
GET_HOOK_TABLES(PLID, &g_pEngTable, NULL, NULL);
return (TRUE);
}

View File

@ -67,6 +67,7 @@ static cell AMX_NATIVE_CALL VelocityByAim(AMX *amx, cell *params)
int iVelocity = params[2];
cell *vRet = get_amxaddr(amx, params[3]);
Vector vVector = Vector(0, 0, 0);
edict_t *pEnt = NULL;
if (iEnt < 0 || iEnt > gpGlobals->maxEntities)
{
@ -75,24 +76,24 @@ static cell AMX_NATIVE_CALL VelocityByAim(AMX *amx, cell *params)
}
else
{
if (iEnt <= gpGlobals->maxClients && !GET_PLAYER_POINTER_I(iEnt)->ingame)
if (iEnt > 0 && iEnt <= gpGlobals->maxClients)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", iEnt);
if (!GET_PLAYER_POINTER_I(iEnt)->ingame)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not ingame)", iEnt);
return 0;
}
else if (iEnt != 0 && FNullEnt(INDEXENT(iEnt)))
{
LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", iEnt);
return 0;
}
}
edict_t *pEnt;
if (iEnt >= 1 || iEnt <= gpGlobals->maxClients)
pEnt = GET_PLAYER_POINTER_I(iEnt)->pEdict;
else
} else {
pEnt = INDEXENT(iEnt);
}
}
if (!pEnt)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d (nullent)", iEnt);
return 0;
}
MAKE_VECTORS(pEnt->v.v_angle);
vVector = gpGlobals->v_forward * iVelocity;