More bugs?

1) New hookable GameDLL func: CreateBaseline
2) New hookable Engine func: CreateInstancedBaseline
3) New GameDLL func that can be called via dllfunc: CreateBaseline
4) New GameDLL func that can be called via engfunc: CreateInstancedBaseline
This commit is contained in:
Scott Ehlert 2006-05-05 08:04:19 +00:00
parent 133c7d6815
commit ed19c53552
7 changed files with 107 additions and 12 deletions

View File

@ -15,6 +15,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
int iparam1; int iparam1;
int iparam2; int iparam2;
int iparam3; int iparam3;
entity_state_t *es;
int len; int len;
cell *cRet; cell *cRet;
type = params[1]; type = params[1];
@ -261,8 +262,6 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
return 1; return 1;
case DLLFunc_AddToFullPack: // int ) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet) case DLLFunc_AddToFullPack: // int ) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet)
entity_state_t *es;
cRet = MF_GetAmxAddr(amx, params[2]); cRet = MF_GetAmxAddr(amx, params[2]);
if (*cRet == 0) if (*cRet == 0)
@ -324,6 +323,41 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
gpGamedllFuncs->dllapi_table->pfnCmdEnd(INDEXENT2(index)); gpGamedllFuncs->dllapi_table->pfnCmdEnd(INDEXENT2(index));
return 1;
case DLLFunc_CreateBaseline: // void ) (int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs);
cRet = MF_GetAmxAddr(amx, params[2]);
iparam1 = cRet[0];
cRet = MF_GetAmxAddr(amx, params[3]);
iparam2 = cRet[0];
cRet = MF_GetAmxAddr(amx, params[4]);
if (*cRet == 0)
es = &g_es_glb;
else
es = reinterpret_cast<entity_state_t *>(*cRet);
cRet = MF_GetAmxAddr(amx, params[5]);
index = cRet[0];
cRet = MF_GetAmxAddr(amx, params[6]);
iparam3 = cRet[0];
CHECK_ENTITY(index);
cRet = MF_GetAmxAddr(amx, params[7]);
Vec1.x = amx_ctof(cRet[0]);
Vec1.y = amx_ctof(cRet[1]);
Vec1.z = amx_ctof(cRet[2]);
cRet = MF_GetAmxAddr(amx, params[8]);
Vec2.x = amx_ctof(cRet[0]);
Vec2.y = amx_ctof(cRet[1]);
Vec2.z = amx_ctof(cRet[2]);
gpGamedllFuncs->dllapi_table->pfnCreateBaseline(iparam1, iparam2, es, INDEXENT2(index), iparam3, Vec1, Vec2);
return 1; return 1;
default: default:
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown dllfunc entry %d", type); MF_LogError(amx, AMX_ERR_NATIVE, "Unknown dllfunc entry %d", type);

View File

@ -59,7 +59,8 @@ enum
DLLFunc_AddToFullPack, // int ) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet); DLLFunc_AddToFullPack, // int ) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet);
// You can pass in 0 for global usercmd handle or another usercmd handle here // You can pass in 0 for global usercmd handle or another usercmd handle here
DLLFunc_CmdStart, // void ) (const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed); DLLFunc_CmdStart, // void ) (const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed);
DLLFunc_CmdEnd // void ) (const edict_t *player); DLLFunc_CmdEnd, // void ) (const edict_t *player);
DLLFunc_CreateBaseline // void ) (int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs);
}; };
#endif //_INCLUDE_DLLFUNC_H #endif //_INCLUDE_DLLFUNC_H

View File

@ -1017,13 +1017,27 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
return 1; return 1;
case EngFunc_SetClientKeyValue: // void ) (int clientIndex, char *infobuffer, char *key, char *value); case EngFunc_SetClientKeyValue: // void ) (int clientIndex, char *infobuffer, char *key, char *value);
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx, params[2]);
index = cRet[0]; index = cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
temp = MF_GetAmxString(amx,params[3],0,&len); temp = MF_GetAmxString(amx, params[3], 0, &len);
temp2 = MF_GetAmxString(amx,params[4],1,&len); temp2 = MF_GetAmxString(amx, params[4], 1, &len);
(*g_engfuncs.pfnSetClientKeyValue)(index,(*g_engfuncs.pfnGetInfoKeyBuffer)(INDEXENT2(index)),temp,temp2); (*g_engfuncs.pfnSetClientKeyValue)(index,(*g_engfuncs.pfnGetInfoKeyBuffer)(INDEXENT2(index)),temp,temp2);
return 1; return 1;
case EngFunc_CreateInstancedBaseline: // int ) (int classname, struct entity_state_s *baseline);
cRet = MF_GetAmxAddr(amx, params[2]);
iparam1 = cRet[0];
entity_state_t *es;
cRet = MF_GetAmxAddr(amx, params[3]);
if (*cRet == 0)
es = &g_es_glb;
else
es = reinterpret_cast<entity_state_t *>(*cRet);
return (*g_engfuncs.pfnCreateInstancedBaseline)(iparam1, es);
default: default:
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown engfunc type %d", type); MF_LogError(amx, AMX_ERR_NATIVE, "Unknown engfunc type %d", type);
return 0; return 0;

View File

@ -77,7 +77,8 @@ enum {
EngFunc_WriteAngle, // void ) (float flValue) EngFunc_WriteAngle, // void ) (float flValue)
EngFunc_InfoKeyValue, // char*) (char *infobuffer, char *key); EngFunc_InfoKeyValue, // char*) (char *infobuffer, char *key);
EngFunc_SetKeyValue, // void ) (char *infobuffer, char *key, char *value); EngFunc_SetKeyValue, // void ) (char *infobuffer, char *key, char *value);
EngFunc_SetClientKeyValue // void ) (int clientIndex, char *infobuffer, char *key, char *value); EngFunc_SetClientKeyValue, // void ) (int clientIndex, char *infobuffer, char *key, char *value);
EngFunc_CreateInstancedBaseline // int ) (int classname, struct entity_state_s *baseline);
}; };
#endif //_ENGFUNC_INCLUDE_H #endif //_ENGFUNC_INCLUDE_H

View File

@ -139,6 +139,7 @@ void FMH_ServerDeactivate()
RESETE(CVarSetFloat); RESETE(CVarSetFloat);
RESETE(CVarSetString); RESETE(CVarSetString);
RESETE(AlertMessage); RESETE(AlertMessage);
RESETE(CreateInstancedBaseline);
RESETD(Spawn); RESETD(Spawn);
RESETD(Think); RESETD(Think);
@ -172,6 +173,7 @@ void FMH_ServerDeactivate()
RESETD(AddToFullPack); RESETD(AddToFullPack);
RESETD(CmdStart); RESETD(CmdStart);
RESETD(CmdEnd); RESETD(CmdEnd);
RESETD(CreateBaseline);
RESETN(OnFreeEntPrivateData); RESETN(OnFreeEntPrivateData);
RESETN(GameShutdown); RESETN(GameShutdown);

View File

@ -610,6 +610,21 @@ SIMPLE_UINT_HOOK_EDICT(GetPlayerWONId);
SIMPLE_INT_HOOK_STRING(IsMapValid); SIMPLE_INT_HOOK_STRING(IsMapValid);
int CreateInstancedBaseline(int classname, struct entity_state_s *baseline)
{
g_es_hook = baseline;
FM_ENG_HANDLE(FM_CreateInstancedBaseline, (Engine[FM_CreateInstancedBaseline].at(i), (cell)classname, (cell)baseline));
RETURN_META_VALUE(mswi(lastFmRes), (int)mlCellResult);
}
int CreateInstancedBaseline_post(int classname, struct entity_state_s *baseline)
{
g_es_hook = baseline;
origCellRet = META_RESULT_ORIG_RET(int);
FM_ENG_HANDLE_POST(FM_CreateInstancedBaseline, (EnginePost[FM_CreateInstancedBaseline].at(i), (cell)classname, (cell)baseline));
RETURN_META_VALUE(MRES_IGNORED, (int)mlCellResult);
}
/* /*
* Beginning of Engine->Game DLL hooks * Beginning of Engine->Game DLL hooks
*/ */
@ -735,6 +750,24 @@ void CmdStart_post(const edict_t *player, const struct usercmd_s *cmd, unsigned
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void CreateBaseline(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs)
{
g_es_hook = baseline;
PREPARE_VECTOR(player_mins);
PREPARE_VECTOR(player_maxs);
FM_ENG_HANDLE(FM_CreateBaseline, (Engine[FM_CreateBaseline].at(i), (cell)player, (cell)eindex, (cell)baseline, (cell)ENTINDEX(entity), (cell)playermodelindex, p_player_mins, p_player_maxs));
RETURN_META(mswi(lastFmRes));
}
void CreateBaseline_post(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs)
{
g_es_hook = baseline;
PREPARE_VECTOR(player_mins);
PREPARE_VECTOR(player_maxs);
FM_ENG_HANDLE_POST(FM_CreateBaseline, (EnginePost[FM_CreateBaseline].at(i), (cell)player, (cell)eindex, (cell)baseline, (cell)ENTINDEX(entity), (cell)playermodelindex, p_player_mins, p_player_maxs));
RETURN_META(MRES_IGNORED);
}
// pfnCmdEnd // pfnCmdEnd
SIMPLE_VOID_HOOK_CONSTEDICT(CmdEnd); SIMPLE_VOID_HOOK_CONSTEDICT(CmdEnd);
@ -1399,6 +1432,14 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_DONE); fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_DONE);
DLLHOOK(CmdEnd); DLLHOOK(CmdEnd);
break; break;
case FM_CreateInstancedBaseline:
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_DONE);
ENGHOOK(CreateInstancedBaseline);
break;
case FM_CreateBaseline:
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_ARRAY, FP_ARRAY, FP_DONE);
DLLHOOK(CreateBaseline);
break;
#if 0 #if 0
// I know this does not fit with DLLFUNC(), but I dont want another native just for it. // I know this does not fit with DLLFUNC(), but I dont want another native just for it.

View File

@ -1,7 +1,7 @@
#ifndef _INCLUDE_FORWARD_H #ifndef _INCLUDE_FORWARD_H
#define _INCLUDE_FORWARD_H #define _INCLUDE_FORWARD_H
#define ENGFUNC_NUM FM_LAST_DONT_USE_ME // 127 #define ENGFUNC_NUM FM_LAST_DONT_USE_ME // 129
#define FMV_STRING 1 #define FMV_STRING 1
#define FMV_FLOAT 2 #define FMV_FLOAT 2
@ -160,6 +160,8 @@ enum {
FM_AddToFullPack, FM_AddToFullPack,
FM_CmdStart, FM_CmdStart,
FM_CmdEnd, FM_CmdEnd,
FM_CreateInstancedBaseline,
FM_CreateBaseline,
FM_LAST_DONT_USE_ME FM_LAST_DONT_USE_ME
}; };