/**
 * Do not edit this file.  Any changes will be overwritten by the gamedata
 * updater or by upgrading your SourceMod install.
 *
 * To override data in this file, create a subdirectory named "custom" and
 * place your own gamedata file(s) inside of it.  Such files will be parsed
 * after SM's own.
 *
 * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(SourceMod)
 */

"Games"
{
	/* Sounds */
	"#default"
	{
		"Keys"
		{
			"SlapSoundCount"	"7"
			"SlapSound1"		"vo/axe/axe_pain_01.mp3"
			"SlapSound1"		"vo/axe/axe_pain_02.mp3"
			"SlapSound1"		"vo/axe/axe_pain_03.mp3"
			"SlapSound1"		"vo/axe/axe_pain_04.mp3"
			"SlapSound1"		"vo/axe/axe_pain_05.mp3"
			"SlapSound1"		"vo/axe/axe_pain_06.mp3"
			"SlapSound1"		"vo/axe/axe_pain_07.mp3"
		}
	}
	
	/* General Temp Entities */
	"#default"
	{
		"Offsets"
		{
			//Offset into CBaseTempEntity constructor
			"s_pTempEntities"
			{
				"windows"	"7"
				"linux"		"9"
			}
			"GetTEName"
			{
				"windows"	"4"
				"linux"		"4"
				"mac"		"4"
			}
			"GetTENext"
			{
				"windows"	"8"
				"linux"		"8"
				"mac"		"8"
			}
			"TE_GetServerClass"
			{
				"windows"	"0"
				"linux"		"0"
				"mac"		"0"
			}
		}

		"Signatures"
		{
			"CBaseTempEntity"
			{
				"library"	"server"
				"windows"	"\xFF\x2A\x2A\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x89\x2A\x2A\x2A\x2A\x2A\x85\xC0\x74\x2A\x8D"
				"linux"		"\x55\x89\xE5\x53\x83\xEC\x2A\x8B\x2A\x2A\x2A\x2A\x2A\x85\xDB\x74\x2A\x8D\xB4\x26\x00\x00\x00\x00\x8B"
			}
			"s_pTempEntities"
			{
				"library"	"server"
				"mac"		"@_ZN15CBaseTempEntity15s_pTempEntitiesE"
			}
		}
	}
	
	/* CGlobalEntityList */
	"#default"
	{
		"Signatures"
		{
			/* Functions in CGlobalEntityList */
			"FindEntityByClassname"
			{
				"library"	"server"
				// Fallback to IServerTools method instead on Windows, lest we add custom logic since it's not a thiscall on Windows in Dota
				"linux"		"\x55\x89\xE5\x57\x56\x53\x83\xEC\x1C\x8B\x45\x0C\x8B\x5D\x08\x8B\x7D\x10\x85\xC0\x74\x7A\x8B\x10\x89"
				"mac"		"@_ZN17CGlobalEntityList21FindEntityByClassnameEP11CBaseEntityPKc"
			}
		}
	}

	/* General GameRules */
	"#default"
	{
		"Keys"
		{
			"GameRulesProxy"	"CDOTAGamerulesProxy"
		}
		
		"Offsets"
		{
			/* Offset into CreateGameRulesObject */
			"g_pGameRules"
			{
				"windows"	"3"
				"linux"		"9"
			}
		}
		
		"Signatures"
		{
			/* This signature sometimes has multiple matches, but this
			 * does not matter as g_pGameRules is involved in all of them.
			 * The same g_pGameRules offset applies to each match.
			 *
			 * Sometimes this block of bytes is at the beginning of the static
			 * CreateGameRulesObject function and sometimes it is in the middle
			 * of an entirely different function. This depends on the game.
			 */
			"CreateGameRulesObject"
			{
				"library"	"server"
				"windows"	"\x51\x8B\x0D\x2A\x2A\x2A\x2A\x85\xC9\x74\x06\x8B\x01\x6A\x01\xFF\x10\xC7\x05\x2A\x2A\x2A\x2A\x00\x00\x00\x00\xE8"
				"linux"		"\x55\x89\xE5\x56\x53\x83\xEC\x2A\xA1\x2A\x2A\x2A\x2A\x8B\x5D\x08\x85\xC0\x74\x08\x8B"
			}
			"g_pGameRules"
			{
				"library"	"server"
				"mac"		"@g_pGameRules"
			}
		}
	}

	/* IServer interface pointer */
	"#default"
	{
		"Keys"
		{
			/* Signature for the beginning of IVEngineServer::CreateFakeClient.
			 *
			 * The engine binary is not actually scanned in order to look for
			 * this. SourceHook is used to used to determine the address of the
			 * function and this signature is used to verify that it contains
			 * the expected code. A pointer to sv (IServer interface) is used
			 * here.
			 */
			"CreateFakeClient_Windows"	"\x55\x8B\xEC\x56\xFF\x75\x0C\xB9\x2A\x2A\x2A\x2A\xE8"
			"CreateFakeClient_Linux"	"\x55\x89\xE5\x83\xEC\x2A\x8B\x45\x10\x89\x5D\xF8\x89\x75\xFC\x8B\x5D\x08\xC7\x04\x24\x2A\x2A\x2A\x2A\x89"
		}
		
		"Offsets"
		{
			/* Offset into IVEngineServer::CreateFakeClient */
			"sv"
			{
				"windows"	"8"
				"linux"		"21"
			}
		}
		
		"Signatures"
		{
			/* CBaseServer object for IServer interface */
			"sv"
			{
				"library"	"engine"
				"mac"		"@sv"
			}
		}
	}
	
	/* Resource Entity override */
	"#default"
	{
		// Dota's player manager does not have DT_PlayerResource embedded, unlike most other games
		"Keys"
		{
			"ResourceEntityClassname"	"dota_player_manager"
		}
	}
	
	/* EntityFactoryDictionary function */
	"#default"
	{
		"Signatures"
		{
			"EntityFactory"
			{
				"library"	"server"
				"mac"		"@_Z23EntityFactoryDictionaryv"
			}
			
			"EntityFactoryFinder"
			{
				// EntityFactoryDictionary gets inlined on Windows in Dota 2. The pointer to the static factory becomes a global.
				"library"	"server"
				"windows"	"\xFF\x2A\x2A\xB9\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x8B\xC8\xC7"
			}

			// EntityFactoryDictionary is difficult to find on Linux due to multiple matches. This finds a caller of it instead.
			"EntityFactoryCaller"
			{
				"library"	"server"
				"linux"		"\x55\x89\xE5\x57\x56\x53\x83\xEC\x2A\xE8\x2A\x2A\x2A\x2A\x85\xC0\x89\x45"
			}
		}
		
		"Offsets"
		{
			"EntityFactoryOffset"
			{
				"windows" 	"4"
			}

			// This is the offset into the address found by the EntityFactoryCaller signature.
			"EntityFactoryCallOffset"
			{
				"linux"		"10"
			}
		}
	}

	/* CBaseEntityOutput::FireOutput */
	"#default"
	{
		"Signatures"
		{
			"FireOutput"
			{
				"library"	"server"
				"windows"	"\x55\x8B\xEC\x83\xE4\xC0\x81\xEC\x2A\x2A\x2A\x2A\x8B\xC1\x53"
				"linux"		"\x55\x89\xE5\x57\x56\x53\x81\xEC\x2A\x2A\x2A\x2A\x8B\x55\x08\x8B\x75\x14\x8B\x5A\x14\x85\xDB\x0F"
				"mac"		"@_ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f"
			}
		}
	}
	
	/* SetUserInfo data */
	"#default"
	{
		"Offsets"
		{
			/**
			 * CBaseClient::SetUserCVar(char  const*,char  const*);
			 * Linux offset straight from VTable dump.
			 * Windows offset is crazy. Found the windows SetName function using string "(%d)%-.*s" (aD_S in IDA)
			 * Cross referenced back to the vtable and counted manually (SetUserCvar is 1 higher, offsets start from 1)
			 */
			"SetUserCvar"
			{
				"windows"	"26"
				"linux"		"62"
				"mac"		"62"
			}
			/**
			 * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made.
			 * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end.
			 * Linux: 	mov     byte ptr [esi+0B0h], 0
			 * Win:		mov     byte ptr [esi+0B0h], 0
			 *
			 * L4D2: This has been moved into CBaseClient::UpdateUserSettings(), rest of the details are still relevant.
			 */
			"InfoChanged"
			{
				"windows"	"212"
				"linux"		"212"
				"mac"		"212"
			}
		}
	}
	
	"dota"
	{
		"Offsets"
		{
			"GiveNamedItem"
			{
				"windows"	"438"
				"linux"		"439"
				"mac"		"439"
			}
			"RemovePlayerItem"
			{
				"windows"	"300"
				"linux"		"301"
				"mac"		"301"
			}
			"Weapon_GetSlot"
			{
				"windows"	"288"
				"linux"		"289"
				"mac"		"289"
			}
			"Ignite"
			{
				"windows"	"226"
				"linux"		"227"
				"mac"		"227"
			}
			"Extinguish"
			{
				"windows"	"229"
				"linux"		"230"
				"mac"		"230"
			}
			"Teleport"
			{
				"windows"	"116"
				"linux"		"117"
				"mac"		"117"
			}
			"CommitSuicide"
			{
				"windows"	"482"
				"linux"		"482"
				"mac"		"482"
			}
			"GetVelocity"
			{
				"windows"	"149"
				"linux"		"150"
				"mac"		"150"
			}
			"EyeAngles"
			{
				"windows"	"140"
				"linux"		"141"
				"mac"		"141"
			}
			"AcceptInput"
			{
				"windows"	"43"
				"linux"		"44"
				"mac"		"44"
			}
			"SetEntityModel"
			{
				"windows"	"28"
				"linux"		"29"
				"mac"		"29"
			}
			"WeaponEquip"
			{
				"windows"	"291"
				"linux"		"292"
				"mac"		"292"
			}
			"Activate"
			{
				"windows"	"39"
				"linux"		"40"
				"mac"		"40"
			}
			"PlayerRunCmd"
			{
				"windows"	"458"
				"linux"		"459"
				"mac"		"459"
			}
		}
	}
}