bool CHalfLife2::FindSendPropInfo(const char *classname, const char *offset, sm_sendprop_info_t *info)
{
	DataTableInfo *pInfo;
	sm_sendprop_info_t *prop;

	if ((pInfo = _FindServerClass(classname)) == NULL)
	{
		return false;
	}

	if ((prop = pInfo->lookup.retrieve(offset)) == NULL)
	{
		sm_sendprop_info_t temp_info;

		if (!UTIL_FindInSendTable(pInfo->sc->m_pTable, offset, &temp_info, 0))
		{
			return false;
		}

		pInfo->lookup.insert(offset, temp_info);
		*info = temp_info;
	}
	else
	{
		*info = *prop;
	}
	
	return true;
}
bool UTIL_FindInSendTable(SendTable *pTable, 
						  const char *name,
						  sm_sendprop_info_t *info,
						  unsigned int offset)
{
	const char *pname;
	int props = pTable->GetNumProps();
	SendProp *prop;

	for (int i=0; i<props; i++)
	{
		prop = pTable->GetProp(i);
		pname = prop->GetName();
		if (pname && strcmp(name, pname) == 0)
		{
			info->prop = prop;
			info->actual_offset = offset + info->prop->GetOffset();
			return true;
		}
		if (prop->GetDataTable())
		{
			if (UTIL_FindInSendTable(prop->GetDataTable(), 
				name,
				info,
				offset + prop->GetOffset())
				)
			{
				return true;
			}
		}
	}

	return false;
}
Example #3
0
bool UTIL_FindSendPropInfo(ServerClass *pInfo, const char *szType, unsigned int *offset)
{
	if ( !pInfo )
	{
		return false;
	}

	sm_sendprop_info_t temp_info;

	if (!UTIL_FindInSendTable(pInfo->m_pTable, szType, &temp_info, 0))
	{
		return false;
	}

	*offset = temp_info.actual_offset;

	return true;
}
Example #4
0
bool UTIL_FindInSendTable(SendTable *pTable, 
						  const char *name,
						  sm_sendprop_info_t *info,
						  unsigned int offset)
{
	const char *pname;
	int props = pTable->GetNumProps();
	SendProp *prop;

	for (int i=0; i<props; i++)
	{
		prop = pTable->GetProp(i);
		pname = prop->GetName();

		if ( g_PrintProps )
			Msg("%d : %s\n",offset + prop->GetOffset(),pname);

		if (pname && strcmp(name, pname) == 0)
		{
			info->prop = prop;
			// for some reason offset is sometimes negative when it shouldn't be
			// so take the absolute value
			info->actual_offset = offset + abs(info->prop->GetOffset());
			return true;
		}
		if (prop->GetDataTable())
		{
			if (UTIL_FindInSendTable(prop->GetDataTable(), 
				name,
				info,
				offset + prop->GetOffset())
				)
			{
				return true;
			}
		}
	}

	return false;
}
Example #5
0
void GameRulesHelper::OnServerActivated()
{
	
	printf("Doin stuf\n");
	m_pGameRulesProxy = UTIL_FindEntityByClassname(nullptr, "dota_gamerules");
	m_pGameManagerProxy = UTIL_FindEntityByClassname(nullptr, "dota_gamemanager");

	auto *pSendTable = ((IServerUnknown *) m_pGameRulesProxy)->GetNetworkable()->GetServerClass()->m_pTable;
	auto *pManagerSendTable = ((IServerUnknown *)m_pGameManagerProxy)->GetNetworkable()->GetServerClass()->m_pTable;

	if (!s_bHaveOffsets)
	{
		m_Offsets.m_nSeriesType = UTIL_FindInSendTable(pSendTable, "m_nSeriesType");
		m_Offsets.m_nRadiantSeriesWins = UTIL_FindInSendTable(pSendTable, "m_nRadiantSeriesWins");
		m_Offsets.m_nDireSeriesWins = UTIL_FindInSendTable(pSendTable, "m_nDireSeriesWins");
		m_Offsets.m_nGameState = UTIL_FindInSendTable(pSendTable, "m_nGameState");
		m_Offsets.m_fGameTime = UTIL_FindInSendTable(pSendTable, "m_fGameTime");
		m_Offsets.m_nGGTeam = UTIL_FindInSendTable(pSendTable, "m_nGGTeam");
		m_Offsets.m_flGGEndsAtTime = UTIL_FindInSendTable(pSendTable, "m_flGGEndsAtTime");
		m_Offsets.m_iGameMode = UTIL_FindInSendTable(pSendTable, "m_iGameMode");
		m_Offsets.m_bGamePaused = UTIL_FindInSendTable(pSendTable, "m_bGamePaused");
		m_Offsets.m_iPauseTeam = UTIL_FindInSendTable(pSendTable, "m_iPauseTeam");
		m_Offsets.m_StableHeroAvailable = UTIL_FindInSendTable(pManagerSendTable, "m_StableHeroAvailable");
		m_Offsets.m_CurrentHeroAvailable = UTIL_FindInSendTable(pManagerSendTable, "m_CurrentHeroAvailable");
		m_Offsets.m_CulledHeroes = UTIL_FindInSendTable(pManagerSendTable, "m_CulledHeroes");

		s_bHaveOffsets = true;
	}

	m_pGameRules = nullptr;
	m_pGameManager = nullptr;

	for (int i = 0; i < pSendTable->GetNumProps(); i++)
	{
		auto pProp = pSendTable->GetProp(i);

		if (pProp->GetDataTable() && !Q_strcmp("dota_gamerules_data", pProp->GetName()))
		{
			auto proxyFn = pProp->GetDataTableProxyFn();
			if (proxyFn)
			{
				CSendProxyRecipients recp;
				m_pGameRules = proxyFn(NULL, NULL, NULL, &recp, 0);
			}

			break;
		}
	}

	for (int i = 0; i < pManagerSendTable->GetNumProps(); i++)
	{
		auto pProp = pManagerSendTable->GetProp(i);

		if (pProp->GetDataTable() && !Q_strcmp("dota_gamemanager_data", pProp->GetName()))
		{
			auto proxyFn = pProp->GetDataTableProxyFn();

			if (proxyFn)
			{
				CSendProxyRecipients recp;
				m_pGameManager = proxyFn(NULL, NULL, NULL, &recp, 0);
				printf("Manager name: %d\n", m_pGameManager);
			}

			break;
		}
	}

	const char *pszBannedHeroes = CommandLine()->ParmValue("-d2bannedheroes", "");
	if (pszBannedHeroes && pszBannedHeroes[0])
	{
		V_SplitString(pszBannedHeroes, ",", bannedHeroes);
	}

	BanThem();
}