CRuleScriptBridge::AddRuleFromScript
0x0080c8e0 · 991 bytes · __cdecl
_ZN17CRuleScriptBridge17AddRuleFromScriptEPN3rr211IResponseDBEP9HSCRIPT__b
Decompiled
undefined (3 params)
/* CRuleScriptBridge::AddRuleFromScript(rr2::IResponseDB*, HSCRIPT__*, bool) */
uint CRuleScriptBridge::AddRuleFromScript(IResponseDB *param_1,HSCRIPT__ *param_2,bool param_3)
{
HSCRIPT__ *pHVar1;
void *pvVar2;
char cVar3;
int iVar4;
CSpeechResponse_t *this;
char *pcVar5;
int iVar6;
uint uVar7;
int local_4c;
HSCRIPT__ *local_48;
int local_44;
void *local_40;
undefined4 local_3c;
ushort local_38;
ushort local_36;
void *local_34;
undefined4 local_30;
undefined2 local_2c;
ushort local_2a;
CRuleBuilder local_28 [4];
int local_24;
local_38 = 0;
local_36 = 0;
local_2c = 0;
local_4c = 0;
local_48 = (HSCRIPT__ *)0x0;
local_40 = (void *)0x0;
local_2a = 0;
local_34 = (void *)0x0;
/* try { // try from 0080c940 to 0080c959 has its CatchHandler @ 0080cd64 */
cVar3 = (**(code **)(*g_pScriptVM + 0x90))(g_pScriptVM,param_2,"rulename",&local_34);
pvVar2 = local_34;
if (cVar3 == '\0') {
Warning("Bad rule passed to Script_AddDecisionRule: no rulename\n");
}
else {
/* try { // try from 0080ca09 to 0080ca6e has its CatchHandler @ 0080cd64 */
cVar3 = GetValueToAutoRef((CScriptAutoRef *)&local_4c,param_2,"criteria");
if (cVar3 == '\0') {
/* try { // try from 0080cbef to 0080cc0b has its CatchHandler @ 0080cd64 */
Warning("Bad rule passed to Script_AddDecisionRule: no criteria\n");
}
else {
uVar7 = GetValueToAutoRef((CScriptAutoRef *)&local_48,param_2,"responses");
if ((char)uVar7 == '\0') {
Warning("Bad rule passed to Script_AddDecisionRule: no responses\n");
}
else {
iVar4 = (**(code **)(*g_pScriptVM + 0xac))(g_pScriptVM,local_4c);
if (param_3) {
/* try { // try from 0080cc76 to 0080ccaa has its CatchHandler @ 0080cd64 */
Msg("\tPROCESSING RESPONSE RULE FROM .NUT :\nrulename is %s\n",pvVar2);
Msg("criteria is an array of %d\n",iVar4);
}
if (0 < iVar4) {
rr2::IResponseDB::AddRule();
local_28[0] = (CRuleBuilder)0x1;
/* try { // try from 0080ca8e to 0080cb1f has its CatchHandler @ 0080cd91 */
rr2::CRuleBuilder::ReserveStaticCriteria(local_28,iVar4,false);
rr2::CRuleBuilder::ReserveStaticCriteria(local_28,iVar4,true);
rr2::CRuleBuilder::ReserveLambdaCriteria(local_28,iVar4,true);
iVar6 = 0;
do {
(**(code **)(*g_pScriptVM + 0x94))(g_pScriptVM,local_4c,iVar6,&local_40);
if (local_38 != 0x20) {
pcVar5 = "unknown_variant_type";
if (local_38 < 0x29) {
pcVar5 = *(char **)(CSWTCH_760 + (uint)local_38 * 4);
}
/* try { // try from 0080cc3c to 0080cc40 has its CatchHandler @ 0080cd91 */
Warning("An entry in rule %s\'s \"criterion\" array wasn\'t a script table. Instead it was a %s.\n\tRejecting rule."
,pvVar2,pcVar5);
goto LAB_0080cc41;
}
local_44 = 0;
if (local_40 != (void *)0x0) {
local_44 = (**(code **)(*g_pScriptVM + 0x40))(g_pScriptVM,local_40);
}
/* try { // try from 0080cb2d to 0080cb31 has its CatchHandler @ 0080cd6e */
AddCriterionFromScript(local_28,(CScriptAutoRef *)&local_44);
if (local_44 != 0) {
(**(code **)(*g_pScriptVM + 0x30))(g_pScriptVM,local_44);
}
/* try { // try from 0080cb5c to 0080cb7c has its CatchHandler @ 0080cd91 */
(**(code **)(*g_pScriptVM + 0x30))(g_pScriptVM,local_40);
pHVar1 = local_48;
iVar6 = iVar6 + 1;
} while (iVar6 != iVar4);
this = ::operator_new(0x10);
/* try { // try from 0080cb90 to 0080cb94 has its CatchHandler @ 0080ccdf */
CSpeechScriptBridge::CSpeechResponse_t::CSpeechResponse_t(this,param_2,pHVar1);
if ((((this == (CSpeechResponse_t *)0x0) || (*(int *)(this + 4) == 0)) ||
(*(int *)(this + 8) == 0)) || (*(int *)(this + 0xc) == 0)) {
/* try { // try from 0080ccbe to 0080ccc2 has its CatchHandler @ 0080cd91 */
Warning("Couldn\'t make response array for rule %s . Rejecting.\n",pvVar2);
if (this != (CSpeechResponse_t *)0x0) {
(**(code **)(*(int *)this + 4))(this);
}
LAB_0080cc41:
uVar7 = (uint)(byte)local_28[0];
if (local_28[0] != (CRuleBuilder)0x0) {
if (local_24 == 0) {
uVar7 = 0;
}
else {
uVar7 = 0;
rr2::CRuleBuilder::Cancel(local_28);
}
}
}
else {
/* try { // try from 0080cbc5 to 0080cbc9 has its CatchHandler @ 0080cd91 */
rr2::CRuleBuilder::SetPayload(local_28,(IRulePayload *)this);
local_28[0] = (CRuleBuilder)0x0;
}
rr2::CRuleBuilder::Done(local_28);
rr2::CRuleBuilder::OnDestructAsserts();
goto LAB_0080c95c;
}
Warning("Rule %s had no criteria. Rejected!\n",pvVar2);
}
}
}
uVar7 = 0;
LAB_0080c95c:
if ((local_2a & 1) != 0) {
free(local_34);
local_2a = local_2a & 0xfffe;
}
local_34 = (void *)0x0;
local_30 = 0;
local_2c = 0;
if ((local_36 & 1) != 0) {
free(local_40);
local_36 = local_36 & 0xfffe;
}
local_40 = (void *)0x0;
local_3c = 0;
local_38 = 0;
if (local_48 != (HSCRIPT__ *)0x0) {
(**(code **)(*g_pScriptVM + 0x30))(g_pScriptVM,local_48);
local_48 = (HSCRIPT__ *)0x0;
}
if (local_4c != 0) {
(**(code **)(*g_pScriptVM + 0x30))(g_pScriptVM,local_4c);
}
return uVar7;
}
SourceMod gamedata
paste intoaddons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)
Just a Signatures{} block, ready to drop into a gamedata
file. Wire it up in your plugin however you like - SDKCall, DHooks,
raw memory ops, or anything else.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.