CVoteController::VoteControllerThink
0x00b40120 · 2102 bytes · __thiscall
_ZN15CVoteController19VoteControllerThinkEv
Decompiled
undefined (1 param)
/* CVoteController::VoteControllerThink() */
void __thiscall CVoteController::VoteControllerThink(CVoteController *this)
{
float fVar1;
bool bVar2;
bool bVar3;
bool bVar4;
char cVar5;
int iVar6;
int iVar7;
CBaseEntity *this_00;
int iVar8;
undefined4 uVar9;
int *piVar10;
char *pcVar11;
int in_GS_OFFSET;
longdouble lVar12;
float local_a4;
float local_9c;
float local_94;
float local_90;
undefined **local_80 [8];
char local_60 [64];
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
if ((*(int *)(this + 0x440) < 0) || (*(int *)(this + 0x54c) <= *(int *)(this + 0x440))) {
CBaseEntity::SetNextThink((CBaseEntity *)this,*(float *)(gpGlobals + 0xc) + 0.5,(char *)0x0);
goto LAB_00b40174;
}
if (0.0 < *(float *)(this + 0x45c)) {
lVar12 = (longdouble)CountdownTimer::Now();
if (*(float *)(this + 0x45c) <= (float)lVar12) {
if (*(float *)(this + 0x45c) != -1.0) {
(**(code **)(*(int *)(this + 0x454) + 4))(this + 0x454,this + 0x45c);
*(undefined4 *)(this + 0x45c) = 0xbf800000;
}
pcVar11 = (char *)(*(int *)(*(int *)(this + 0x540) + *(int *)(this + 0x440) * 4) + 4);
iVar6 = _V_strlen(pcVar11);
iVar7 = V_strncmp(pcVar11,"ChangeAllTalk",iVar6);
cVar5 = CTerrorGameRules::IsVersusMode();
if ((cVar5 == '\0') || (iVar6 = V_strncmp(pcVar11,"RestartGame",iVar6), iVar6 != 0)) {
if (iVar7 == 0) {
bVar4 = false;
goto LAB_00b40257;
}
if (*(int *)(this + 0x44c) < *(int *)(this + 0x448)) goto LAB_00b40399;
}
else {
bVar4 = true;
LAB_00b40257:
local_a4 = 0.0;
local_9c = 0.0;
local_94 = 0.0;
local_90 = 0.0;
iVar6 = 0;
do {
this_00 = (CBaseEntity *)UTIL_PlayerByIndex(iVar6);
if (((((this_00 != (CBaseEntity *)0x0) && (*(int *)(this_00 + 0x30) != 0)) &&
(*(int *)(this_00 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4 != 0)) &&
((cVar5 = (**(code **)(*(int *)this_00 + 0x16c))(this_00), cVar5 != '\0' &&
(*(int *)(this_00 + 0x1f6c) != 2)))) &&
(cVar5 = (**(code **)(*(int *)this_00 + 0x778))(this_00), cVar5 == '\0')) {
iVar8 = CBaseEntity::GetTeamNumber(this_00);
if (iVar8 == 2) {
local_90 = local_90 + 1.0;
if (*(int *)(this + iVar6 * 4 + 0x4b8) != 1) {
local_94 = local_94 + 1.0;
}
}
else {
iVar8 = CBaseEntity::GetTeamNumber(this_00);
if ((iVar8 == 3) &&
(local_9c = local_9c + 1.0, *(int *)(this + iVar6 * 4 + 0x4b8) != 1)) {
local_a4 = local_a4 + 1.0;
}
}
}
iVar6 = iVar6 + 1;
} while (iVar6 != 0x20);
bVar2 = local_90 * 0.5 < local_94;
bVar3 = local_9c * 0.5 < local_a4;
if (bVar4) {
bVar4 = bVar3 && bVar2;
}
else {
if (iVar7 != 0) goto LAB_00b4081d;
bVar4 = bVar3 || bVar2;
if (*(int *)(sv_alltalk._28_4_ + 0x30) == 0) {
bVar4 = bVar2 && bVar3;
}
}
if (bVar4) {
LAB_00b40399:
RecordVoteCallerHistory(this,true);
piVar10 = *(int **)(*(int *)(this + 0x540) + *(int *)(this + 0x440) * 4);
uVar9 = (**(code **)(*piVar10 + 8))(piVar10);
UTIL_LogPrintf("Vote succeeded \"%s %s\"\n",
*(int *)(*(int *)(this + 0x540) + *(int *)(this + 0x440) * 4) + 4,uVar9);
fVar1 = *(float *)(sv_vote_command_delay._28_4_ + 0x2c);
lVar12 = (longdouble)CountdownTimer::Now();
if ((float)lVar12 + fVar1 != *(float *)(this + 0x468)) {
(**(code **)(*(int *)(this + 0x460) + 4))(this + 0x460,this + 0x468);
*(float *)(this + 0x468) = (float)lVar12 + fVar1;
}
if (fVar1 != *(float *)(this + 0x464)) {
(**(code **)(*(int *)(this + 0x460) + 4))(this + 0x460,this + 0x464);
*(float *)(this + 0x464) = fVar1;
}
piVar10 = *(int **)(*(int *)(this + 0x540) + *(int *)(this + 0x440) * 4);
(**(code **)(*piVar10 + 0x10))(piVar10);
piVar10 = *(int **)(*(int *)(this + 0x540) + *(int *)(this + 0x440) * 4);
pcVar11 = (char *)(**(code **)(*piVar10 + 8))(piVar10);
V_strncpy(local_60,pcVar11,0x40);
CRecipientFilter::CRecipientFilter((CRecipientFilter *)local_80);
local_80[0] = &PTR__CBroadcastRecipientFilter_00c09928;
/* try { // try from 00b404ec to 00b404f0 has its CatchHandler @ 00b40980 */
CRecipientFilter::AddAllPlayers((CRecipientFilter *)local_80);
/* try { // try from 00b404f4 to 00b405fb has its CatchHandler @ 00b40967 */
CRecipientFilter::MakeReliable((CRecipientFilter *)local_80);
UserMessageBegin((IRecipientFilter *)local_80,"VotePass");
MessageWriteByte(*(int *)(this + 0x444));
piVar10 = *(int **)(*(int *)(this + 0x540) + *(int *)(this + 0x440) * 4);
pcVar11 = (char *)(**(code **)(*piVar10 + 0x34))(piVar10);
MessageWriteString(pcVar11);
MessageWriteString(local_60);
MessageEnd();
piVar10 = (int *)UTIL_EntityByIndex(*(int *)(this + 0x538));
if ((piVar10 != (int *)0x0) &&
(cVar5 = (**(code **)(*piVar10 + 0x16c))(piVar10), cVar5 != '\0')) {
if ((float)piVar10[0x787] != -1.0) {
(**(code **)(piVar10[0x786] + 4))(piVar10 + 0x786,piVar10 + 0x787);
piVar10[0x787] = -0x40800000;
}
}
lVar12 = (longdouble)CountdownTimer::Now();
if ((float)lVar12 + 5.0 != *(float *)(this + 0x4b4)) {
(**(code **)(*(int *)(this + 0x4ac) + 4))(this + 0x4ac,this + 0x4b4);
*(float *)(this + 0x4b4) = (float)lVar12 + 5.0;
}
if (*(float *)(this + 0x4b0) != 5.0) {
/* try { // try from 00b4090b to 00b40957 has its CatchHandler @ 00b40967 */
(**(code **)(*(int *)(this + 0x4ac) + 4))(this + 0x4ac,this + 0x4b0);
*(undefined4 *)(this + 0x4b0) = 0x40a00000;
}
piVar10 = *(int **)(*(int *)(this + 0x540) + *(int *)(this + 0x440) * 4);
pcVar11 = (char *)(**(code **)(*piVar10 + 0x34))(piVar10);
CL4DGameStats::HandleVotePassed((CL4DGameStats *)CL4D_GameStats,pcVar11);
local_80[0] = &PTR__CBroadcastRecipientFilter_00c09928;
CRecipientFilter::~CRecipientFilter((CRecipientFilter *)local_80);
goto LAB_00b4061b;
}
}
LAB_00b4081d:
RecordVoteCallerHistory(this,false);
NotifyVoteFailed(this);
piVar10 = *(int **)(*(int *)(this + 0x540) + *(int *)(this + 0x440) * 4);
(**(code **)(*piVar10 + 0x14))(piVar10);
lVar12 = (longdouble)CountdownTimer::Now();
if ((float)lVar12 + 5.0 != *(float *)(this + 0x4b4)) {
(**(code **)(*(int *)(this + 0x4ac) + 4))(this + 0x4ac,this + 0x4b4);
*(float *)(this + 0x4b4) = (float)lVar12 + 5.0;
}
if (*(float *)(this + 0x4b0) != 5.0) {
(**(code **)(*(int *)(this + 0x4ac) + 4))(this + 0x4ac,this + 0x4b0);
*(undefined4 *)(this + 0x4b0) = 0x40a00000;
}
}
}
LAB_00b4061b:
if (0.0 < *(float *)(this + 0x468)) {
lVar12 = (longdouble)CountdownTimer::Now();
if (*(float *)(this + 0x468) <= (float)lVar12) {
if (*(float *)(this + 0x468) != -1.0) {
(**(code **)(*(int *)(this + 0x460) + 4))(this + 0x460,this + 0x468);
*(undefined4 *)(this + 0x468) = 0xbf800000;
}
piVar10 = *(int **)(*(int *)(this + 0x540) + *(int *)(this + 0x440) * 4);
(**(code **)(*piVar10 + 0x2c))(piVar10);
}
}
if (0.0 < *(float *)(this + 0x4b4)) {
lVar12 = (longdouble)CountdownTimer::Now();
if ((*(float *)(this + 0x4b4) <= (float)lVar12) &&
(ResetData(this), *(float *)(this + 0x4b4) != -1.0)) {
(**(code **)(*(int *)(this + 0x4ac) + 4))(this + 0x4ac,this + 0x4b4);
*(undefined4 *)(this + 0x4b4) = 0xbf800000;
}
}
CBaseEntity::SetNextThink((CBaseEntity *)this,*(float *)(gpGlobals + 0xc) + 0.5,(char *)0x0);
LAB_00b40174:
if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return;
}
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.