From f31e0e405f41d616c40feba04eadea37f3877897 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Fri, 9 Oct 2015 10:53:53 +0200 Subject: [PATCH 01/12] Add gamerules offsets for supported mods --- .../cstrike/offsets-cgamerules.txt | 53 ++ .../cstrike/offsets-chalflifemultiplay.txt | 710 ++++++++++++++++++ .../cstrike/offsets-chalflifetraining.txt | 79 ++ .../dod/offsets-cdodteamplay.txt | 660 ++++++++++++++++ .../dod/offsets-cspdodrules.txt | 243 ++++++ .../gearbox/offsets-chalflifecoopplay.txt | 52 ++ .../gearbox/offsets-chalflifectfplay.txt | 88 +++ .../gearbox/offsets-chalflifemultiplay.txt | 51 ++ .../gearbox/offsets-chalflifeteamplay.txt | 71 ++ .../gamerules.games/master.games.txt | 90 +++ .../tfc/offsets-chalflifemultiplay.txt | 60 ++ .../tfc/offsets-chalflifeteamplay.txt | 52 ++ .../tfc/offsets-cteamfortress.txt | 44 ++ .../valve/offsets-chalflifemultiplay.txt | 51 ++ .../valve/offsets-chalflifeteamplay.txt | 71 ++ support/PackageScript | 45 ++ 16 files changed, 2420 insertions(+) create mode 100644 gamedata/common.games/gamerules.games/cstrike/offsets-cgamerules.txt create mode 100644 gamedata/common.games/gamerules.games/cstrike/offsets-chalflifemultiplay.txt create mode 100644 gamedata/common.games/gamerules.games/cstrike/offsets-chalflifetraining.txt create mode 100644 gamedata/common.games/gamerules.games/dod/offsets-cdodteamplay.txt create mode 100644 gamedata/common.games/gamerules.games/dod/offsets-cspdodrules.txt create mode 100644 gamedata/common.games/gamerules.games/gearbox/offsets-chalflifecoopplay.txt create mode 100644 gamedata/common.games/gamerules.games/gearbox/offsets-chalflifectfplay.txt create mode 100644 gamedata/common.games/gamerules.games/gearbox/offsets-chalflifemultiplay.txt create mode 100644 gamedata/common.games/gamerules.games/gearbox/offsets-chalflifeteamplay.txt create mode 100644 gamedata/common.games/gamerules.games/master.games.txt create mode 100644 gamedata/common.games/gamerules.games/tfc/offsets-chalflifemultiplay.txt create mode 100644 gamedata/common.games/gamerules.games/tfc/offsets-chalflifeteamplay.txt create mode 100644 gamedata/common.games/gamerules.games/tfc/offsets-cteamfortress.txt create mode 100644 gamedata/common.games/gamerules.games/valve/offsets-chalflifemultiplay.txt create mode 100644 gamedata/common.games/gamerules.games/valve/offsets-chalflifeteamplay.txt diff --git a/gamedata/common.games/gamerules.games/cstrike/offsets-cgamerules.txt b/gamedata/common.games/gamerules.games/cstrike/offsets-cgamerules.txt new file mode 100644 index 00000000..b424504a --- /dev/null +++ b/gamedata/common.games/gamerules.games/cstrike/offsets-cgamerules.txt @@ -0,0 +1,53 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CGameRules" + { + "Offsets" + { + "m_bFreezePeriod" // BOOL + { + "type" "integer" + + "windows" "4" + "linux" "4" + "mac" "4" + } + + "m_bBombDropped" // BOOL + { + "type" "integer" + + "windows" "8" + "linux" "8" + "mac" "8" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CHalfLifeMultiplay + * CHalfLifeTraining + * CHalfLifeRules + */ diff --git a/gamedata/common.games/gamerules.games/cstrike/offsets-chalflifemultiplay.txt b/gamedata/common.games/gamerules.games/cstrike/offsets-chalflifemultiplay.txt new file mode 100644 index 00000000..967f481b --- /dev/null +++ b/gamedata/common.games/gamerules.games/cstrike/offsets-chalflifemultiplay.txt @@ -0,0 +1,710 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CHalfLifeMultiplay" + { + "Offsets" + { + "m_VoiceGameMgr" // class CVoiceGameMgr + { + "type" "class" + + "windows" "16" + "linux" "12" + "mac" "12" + } + + "m_fTeamCount" // float + { + "type" "float" + + "windows" "48" + "linux" "40" + "mac" "40" + } + + "m_flCheckWinConditions" // float + { + "type" "float" + + "windows" "52" + "linux" "44" + "mac" "44" + } + + "m_fRoundCount" // float + { + "type" "float" + + "windows" "56" + "linux" "48" + "mac" "48" + } + + "m_iRoundTime" // int + { + "type" "integer" + + "windows" "60" + "linux" "52" + "mac" "52" + } + + "m_iRoundTimeSecs" // int + { + "type" "integer" + + "windows" "64" + "linux" "56" + "mac" "56" + } + + "m_iIntroRoundTime" // int + { + "type" "integer" + + "windows" "68" + "linux" "60" + "mac" "60" + } + + "m_fIntroRoundCount" // float + { + "type" "float" + + "windows" "72" + "linux" "64" + "mac" "64" + } + + "m_iAccountTerrorist" // int + { + "type" "integer" + + "windows" "76" + "linux" "68" + "mac" "68" + } + + "m_iAccountCT" // int + { + "type" "integer" + + "windows" "80" + "linux" "72" + "mac" "72" + } + + "m_iNumTerrorist" // int + { + "type" "integer" + + "windows" "84" + "linux" "76" + "mac" "76" + } + + "m_iNumCT" // int + { + "type" "integer" + + "windows" "88" + "linux" "80" + "mac" "80" + } + + "m_iNumSpawnableTerrorist" // int + { + "type" "integer" + + "windows" "92" + "linux" "84" + "mac" "84" + } + + "m_iNumSpawnableCT" // int + { + "type" "integer" + + "windows" "96" + "linux" "88" + "mac" "88" + } + + "m_iSpawnPointCount_Terrorist" // int + { + "type" "integer" + + "windows" "100" + "linux" "92" + "mac" "92" + } + + "m_iSpawnPointCount_CT" // int + { + "type" "integer" + + "windows" "104" + "linux" "96" + "mac" "96" + } + + "m_iHostagesRescued" // int + { + "type" "integer" + + "windows" "108" + "linux" "100" + "mac" "100" + } + + "m_iHostagesTouched" // int + { + "type" "integer" + + "windows" "112" + "linux" "104" + "mac" "104" + } + + "m_iRoundWinStatus" // int + { + "type" "integer" + + "windows" "116" + "linux" "108" + "mac" "108" + } + + "m_iNumCTWins" // short int + { + "type" "short" + + "windows" "120" + "linux" "112" + "mac" "112" + } + + "m_iNumTerroristWins" // short int + { + "type" "short" + + "windows" "122" + "linux" "114" + "mac" "114" + } + + "m_bTargetBombed" // bool + { + "type" "boolean" + + "windows" "124" + "linux" "116" + "mac" "116" + } + + "m_bBombDefused" // bool + { + "type" "boolean" + + "windows" "125" + "linux" "117" + "mac" "117" + } + + "m_bMapHasBombTarget" // bool + { + "type" "boolean" + + "windows" "126" + "linux" "118" + "mac" "118" + } + + "m_bMapHasBombZone" // bool + { + "type" "boolean" + + "windows" "127" + "linux" "119" + "mac" "119" + } + + "m_bMapHasBuyZone" // bool + { + "type" "boolean" + + "windows" "128" + "linux" "120" + "mac" "120" + } + + "m_bMapHasRescueZone" // bool + { + "type" "boolean" + + "windows" "129" + "linux" "121" + "mac" "121" + } + + "m_bMapHasEscapeZone" // bool + { + "type" "boolean" + + "windows" "130" + "linux" "122" + "mac" "122" + } + + "m_iMapHasVIPSafetyZone" // int + { + "type" "integer" + + "windows" "132" + "linux" "124" + "mac" "124" + } + + "m_bMapHasCameras" // int + { + "type" "integer" + + "windows" "136" + "linux" "128" + "mac" "128" + } + + "m_iC4Timer" // int + { + "type" "integer" + + "windows" "140" + "linux" "132" + "mac" "132" + } + + "m_iC4Guy" // int + { + "type" "integer" + + "windows" "144" + "linux" "136" + "mac" "136" + } + + "m_iLoserBonus" // int + { + "type" "integer" + + "windows" "148" + "linux" "140" + "mac" "140" + } + + "m_iNumConsecutiveCTLoses" // int + { + "type" "integer" + + "windows" "152" + "linux" "144" + "mac" "144" + } + + "m_iNumConsecutiveTerroristLoses" // int + { + "type" "integer" + + "windows" "156" + "linux" "148" + "mac" "148" + } + + "m_fMaxIdlePeriod" // float + { + "type" "float" + + "windows" "160" + "linux" "152" + "mac" "152" + } + + "m_iLimitTeams" // int + { + "type" "integer" + + "windows" "164" + "linux" "156" + "mac" "156" + } + + "m_bLevelInitialized" // bool + { + "type" "boolean" + + "windows" "168" + "linux" "160" + "mac" "160" + } + + "m_bRoundTerminating" // bool + { + "type" "boolean" + + "windows" "169" + "linux" "161" + "mac" "161" + } + + "m_bCompleteReset" // bool + { + "type" "boolean" + + "windows" "170" + "linux" "162" + "mac" "162" + } + + "m_flRequiredEscapeRatio" // float + { + "type" "float" + + "windows" "172" + "linux" "164" + "mac" "164" + } + + "m_iNumEscapers" // int + { + "type" "integer" + + "windows" "176" + "linux" "168" + "mac" "168" + } + + "m_iHaveEscaped" // int + { + "type" "integer" + + "windows" "180" + "linux" "172" + "mac" "172" + } + + "m_bCTCantBuy" // bool + { + "type" "boolean" + + "windows" "184" + "linux" "176" + "mac" "176" + } + + "m_bTCantBuy" // bool + { + "type" "boolean" + + "windows" "185" + "linux" "177" + "mac" "177" + } + + "m_flBombRadius" // float + { + "type" "float" + + "windows" "188" + "linux" "180" + "mac" "180" + } + + "m_iConsecutiveVIP" // int + { + "type" "integer" + + "windows" "192" + "linux" "184" + "mac" "184" + } + + "m_iTotalGunCount" // int + { + "type" "integer" + + "windows" "196" + "linux" "188" + "mac" "188" + } + + "m_iTotalGrenadeCount" // int + { + "type" "integer" + + "windows" "200" + "linux" "192" + "mac" "192" + } + + "m_iTotalArmourCount" // int + { + "type" "integer" + + "windows" "204" + "linux" "196" + "mac" "196" + } + + "m_iUnBalancedRounds" // int + { + "type" "integer" + + "windows" "208" + "linux" "200" + "mac" "200" + } + + "m_iNumEscapeRounds" // int + { + "type" "integer" + + "windows" "212" + "linux" "204" + "mac" "204" + } + + "m_iMapVotes" // int[100] + { + "type" "integer" + "size" "100" + + "windows" "216" + "linux" "208" + "mac" "208" + } + + "m_iLastPick" // int + { + "type" "integer" + + "windows" "616" + "linux" "608" + "mac" "608" + } + + "m_iMaxMapTime" // int + { + "type" "integer" + + "windows" "620" + "linux" "612" + "mac" "612" + } + + "m_iMaxRounds" // int + { + "type" "integer" + + "windows" "624" + "linux" "616" + "mac" "616" + } + + "m_iTotalRoundsPlayed" // int + { + "type" "integer" + + "windows" "628" + "linux" "620" + "mac" "620" + } + + "m_iMaxRoundsWon" // int + { + "type" "integer" + + "windows" "632" + "linux" "624" + "mac" "624" + } + + "m_iStoredSpectValue" // int + { + "type" "integer" + + "windows" "636" + "linux" "628" + "mac" "628" + } + + "m_flForceCameraValue" // float + { + "type" "float" + + "windows" "640" + "linux" "632" + "mac" "632" + } + + "m_flForceChaseCamValue" // float + { + "type" "float" + + "windows" "644" + "linux" "636" + "mac" "636" + } + + "m_flFadeToBlackValue" // float + { + "type" "float" + + "windows" "648" + "linux" "640" + "mac" "640" + } + + "m_pVIP" // CBasePlayer* + { + "type" "classptr" + + "windows" "652" + "linux" "644" + "mac" "644" + } + + "VIPQueue" // CBasePlayer*[5] + { + "type" "classptr" + "size" "5" + + "windows" "656" + "linux" "648" + "mac" "648" + } + + "m_flIntermissionEndTime" // float + { + "type" "float" + + "windows" "676" + "linux" "668" + "mac" "668" + } + + "m_flIntermissionStartTime" // float + { + "type" "float" + + "windows" "680" + "linux" "672" + "mac" "672" + } + + "m_iEndIntermissionButtonHit" // BOOL + { + "type" "integer" + + "windows" "684" + "linux" "676" + "mac" "676" + } + + "m_tmNextPeriodicThink" // float + { + "type" "float" + + "windows" "688" + "linux" "680" + "mac" "680" + } + + "m_bFirstConnected" // bool + { + "type" "boolean" + + "windows" "692" + "linux" "684" + "mac" "684" + } + + "m_bInCareerGame" // bool + { + "type" "boolean" + + "windows" "693" + "linux" "685" + "mac" "685" + } + + "m_fCareerRoundMenuTime" // float + { + "type" "float" + + "windows" "696" + "linux" "688" + "mac" "688" + } + + "m_iCareerMatchWins" // int + { + "type" "integer" + + "windows" "700" + "linux" "692" + "mac" "692" + } + + "m_iRoundWinDifference" // int + { + "type" "integer" + + "windows" "704" + "linux" "696" + "mac" "696" + } + + "m_fCareerMatchMenuTime" // float + { + "type" "float" + + "windows" "708" + "linux" "700" + "mac" "700" + } + + "m_bSkipSpawn" // bool + { + "type" "boolean" + + "windows" "712" + "linux" "704" + "mac" "704" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CHalfLifeMultiplay + */ diff --git a/gamedata/common.games/gamerules.games/cstrike/offsets-chalflifetraining.txt b/gamedata/common.games/gamerules.games/cstrike/offsets-chalflifetraining.txt new file mode 100644 index 00000000..6f52ca83 --- /dev/null +++ b/gamedata/common.games/gamerules.games/cstrike/offsets-chalflifetraining.txt @@ -0,0 +1,79 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CHalfLifeTraining" + { + "Offsets" + { + "FillAccountTime" // float + { + "type" "float" + + "windows" "708" + "linux" "708" + "mac" "708" + } + + "ServerRestartTime" // float + { + "type" "float" + + "windows" "712" + "linux" "712" + "mac" "712" + } + + "fInBuyArea" // BOOL + { + "type" "integer" + + "windows" "716" + "linux" "716" + "mac" "716" + } + + "fVisitedBuyArea" // BOOL + { + "type" "integer" + + "windows" "720" + "linux" "720" + "mac" "720" + } + + "fVGUIMenus" // bool + { + "type" "boolean" + + "windows" "724" + "linux" "724" + "mac" "724" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CHalfLifeMultiplay + * CHalfLifeTraining + */ diff --git a/gamedata/common.games/gamerules.games/dod/offsets-cdodteamplay.txt b/gamedata/common.games/gamerules.games/dod/offsets-cdodteamplay.txt new file mode 100644 index 00000000..fdc30e5d --- /dev/null +++ b/gamedata/common.games/gamerules.games/dod/offsets-cdodteamplay.txt @@ -0,0 +1,660 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CDoDTeamPlay" + { + "Offsets" + { + "m_RoundDoesCount" // int + { + "type" "integer" + + "windows" "4" + "linux" "4" + "mac" "4" + } + + "m_DoDCameraState" // int + { + "type" "integer" + + "windows" "8" + "linux" "8" + "mac" "8" + } + + "m_RoundParaCanJoin" // int + { + "type" "integer" + + "windows" "12" + "linux" "12" + "mac" "12" + } + + "m_flGoodToGoTime" // float + { + "type" "float" + + "windows" "16" + "linux" "16" + "mac" "16" + } + + "m_flRoundTime" // float + { + "type" "float" + + "windows" "20" + "linux" "20" + "mac" "20" + } + + "m_flCanJoinTime" // float + { + "type" "float" + + "windows" "24" + "linux" "24" + "mac" "24" + } + + "m_flRestartTime" // float + { + "type" "float" + + "windows" "28" + "linux" "28" + "mac" "28" + } + + "m_flFinalCheckTime" // float + { + "type" "float" + + "windows" "32" + "linux" "32" + "mac" "32" + } + + "m_flDoDMapTime" // float + { + "type" "float" + + "windows" "36" + "linux" "36" + "mac" "36" + } + + "m_flAlliesWaveTime" // float + { + "type" "float" + + "windows" "40" + "linux" "40" + "mac" "40" + } + + "m_flAxisWaveTime" // float + { + "type" "float" + + "windows" "44" + "linux" "44" + "mac" "44" + } + + "m_flAlliesRespawn" // float + { + "type" "float" + + "windows" "48" + "linux" "48" + "mac" "48" + } + + "m_flAxisRespawn" // float + { + "type" "float" + + "windows" "52" + "linux" "52" + "mac" "52" + } + + "m_iTeamScores" // int[32] + { + "type" "integer" + "size" "32" + + "windows" "56" + "linux" "56" + "mac" "56" + } + + "m_szTeamNames" // char*[32] + { + "type" "stringptr" + "size" "32" + + "windows" "184" + "linux" "184" + "mac" "184" + } + + "m_flSpamResetTime" // float + { + "type" "float" + + "windows" "312" + "linux" "312" + "mac" "312" + } + + "m_bClanMatch" // bool + { + "type" "boolean" + + "windows" "316" + "linux" "316" + "mac" "316" + } + + "m_bClanMatchActive" // bool + { + "type" "boolean" + + "windows" "317" + "linux" "317" + "mac" "317" + } + + "m_szAuthID" // char[32] + { + "type" "string" + "size" "32" + + "windows" "318" + "linux" "318" + "mac" "318" + } + + "m_vKickENT" // CBasePlayer* + { + "type" "classptr" + + "windows" "352" + "linux" "352" + "mac" "352" + } + + "m_vKick" // int + { + "type" "integer" + + "windows" "356" + "linux" "356" + "mac" "356" + } + + "m_vKickVotes" // int + { + "type" "integer" + + "windows" "360" + "linux" "360" + "mac" "360" + } + + "m_vKickSessionState" // int + { + "type" "integer" + + "windows" "364" + "linux" "364" + "mac" "364" + } + + "m_vKickTime" // float + { + "type" "float" + + "windows" "368" + "linux" "368" + "mac" "368" + } + + "m_rRoundStartCount" // float + { + "type" "float" + + "windows" "372" + "linux" "372" + "mac" "372" + } + + "m_rReadyToUnFreeze" // int + { + "type" "integer" + + "windows" "376" + "linux" "376" + "mac" "376" + } + + "gr_gameRules" // int + { + "type" "integer" + + "windows" "380" + "linux" "380" + "mac" "380" + } + + "m_GamePlayRules" // gameplay_rules_t + { + "type" "structure" + + "windows" "384" + "linux" "384" + "mac" "384" + } + + "m_iNumAlliesAlive" // int + { + "type" "integer" + + "windows" "432" + "linux" "432" + "mac" "432" + } + + "m_iNumAxisAlive" // int + { + "type" "integer" + + "windows" "436" + "linux" "436" + "mac" "436" + } + + "m_iNumAlliesOnTeam" // int + { + "type" "integer" + + "windows" "440" + "linux" "440" + "mac" "440" + } + + "m_iNumAxisOnTeam" // int + { + "type" "integer" + + "windows" "444" + "linux" "444" + "mac" "444" + } + + "m_Camera" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "448" + "linux" "448" + "mac" "448" + } + + "m_usVoice" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "450" + "linux" "450" + "mac" "450" + } + + "m_bodyDamage" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "452" + "linux" "452" + "mac" "452" + } + + "m_roundRestartSound" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "454" + "linux" "454" + "mac" "454" + } + + "m_gerVoice" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "456" + "linux" "456" + "mac" "456" + } + + "m_Pain" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "458" + "linux" "458" + "mac" "458" + } + + "m_Smoke" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "460" + "linux" "460" + "mac" "460" + } + + "m_Prone" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "462" + "linux" "462" + "mac" "462" + } + + "m_BloodSprite" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "464" + "linux" "464" + "mac" "464" + } + + "m_BloodStream" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "466" + "linux" "466" + "mac" "466" + } + + "m_BulletTracers" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "468" + "linux" "468" + "mac" "468" + } + + "m_SparkShower" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "470" + "linux" "470" + "mac" "470" + } + + "m_ScreenFades" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "472" + "linux" "472" + "mac" "472" + } + + "m_BubbleTrails" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "474" + "linux" "474" + "mac" "474" + } + + "m_Bubbles" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "476" + "linux" "476" + "mac" "476" + } + + "m_Shards" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "478" + "linux" "478" + "mac" "478" + } + + "m_Explosion" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "480" + "linux" "480" + "mac" "480" + } + + "m_PopHelmet" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "482" + "linux" "482" + "mac" "482" + } + + "m_RoundReset" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "484" + "linux" "484" + "mac" "484" + } + + "m_RocketTrail" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "486" + "linux" "486" + "mac" "486" + } + + "sNextMap" // char[32] + { + "type" "string" + "size" "32" + + "windows" "488" + "linux" "488" + "mac" "488" + } + + "MapChangeFromTime" // int + { + "type" "integer" + + "windows" "520" + "linux" "520" + "mac" "520" + } + + "m_bIsRoundFrozen" // bool + { + "type" "boolean" + + "windows" "524" + "linux" "524" + "mac" "524" + } + + "m_DisableDeathMessages" // BOOL + { + "type" "integer" + + "windows" "528" + "linux" "528" + "mac" "528" + } + + "m_DisableDeathPenalty" // BOOL + { + "type" "integer" + + "windows" "532" + "linux" "532" + "mac" "532" + } + + "m_pParaTimer" // CDodParaRoundTimer* + { + "type" "classptr" + + "windows" "536" + "linux" "536" + "mac" "536" + } + + "m_RoundState" // int + { + "type" "integer" + + "windows" "540" + "linux" "540" + "mac" "540" + } + + "m_bRoundRestarting" // BOOL + { + "type" "integer" + + "windows" "544" + "linux" "544" + "mac" "544" + } + + "m_bAwaitingReadyRestart" // BOOL + { + "type" "integer" + + "windows" "548" + "linux" "548" + "mac" "548" + } + + "m_bHeardAlliesReady" // BOOL + { + "type" "integer" + + "windows" "552" + "linux" "552" + "mac" "552" + } + + "m_bHeardAxisReady" // BOOL + { + "type" "integer" + + "windows" "556" + "linux" "556" + "mac" "556" + } + + "m_flRestartRoundTime" // float + { + "type" "float" + + "windows" "560" + "linux" "560" + "mac" "560" + } + + "m_fLogScoresTime" // float + { + "type" "float" + + "windows" "564" + "linux" "564" + "mac" "564" + } + + "m_flIntermissionEndTime" // float + { + "type" "float" + + "windows" "568" + "linux" "568" + "mac" "568" + } + + "m_iEndIntermissionButtonHit" // BOOL + { + "type" "integer" + + "windows" "572" + "linux" "572" + "mac" "572" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CDoDTeamPlay + */ diff --git a/gamedata/common.games/gamerules.games/dod/offsets-cspdodrules.txt b/gamedata/common.games/gamerules.games/dod/offsets-cspdodrules.txt new file mode 100644 index 00000000..4d1410e2 --- /dev/null +++ b/gamedata/common.games/gamerules.games/dod/offsets-cspdodrules.txt @@ -0,0 +1,243 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CSPDoDRules" + { + "Offsets" + { + "m_Camera" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "4" + "linux" "4" + "mac" "4" + } + + "m_usVoice" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "6" + "linux" "6" + "mac" "6" + } + + "m_bodyDamage" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "8" + "linux" "8" + "mac" "8" + } + + "m_roundRestartSound" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "10" + "linux" "10" + "mac" "10" + } + + "m_gerVoice" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "12" + "linux" "12" + "mac" "12" + } + + "m_Pain" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "14" + "linux" "14" + "mac" "14" + } + + "m_Smoke" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "16" + "linux" "16" + "mac" "16" + } + + "m_BloodSprite" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "18" + "linux" "18" + "mac" "18" + } + + "m_Prone" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "20" + "linux" "20" + "mac" "20" + } + + "m_BloodStream" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "22" + "linux" "22" + "mac" "22" + } + + "m_BulletTracers" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "24" + "linux" "24" + "mac" "24" + } + + "m_SparkShower" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "26" + "linux" "26" + "mac" "26" + } + + "m_ScreenFades" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "28" + "linux" "28" + "mac" "28" + } + + "m_BubbleTrails" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "30" + "linux" "30" + "mac" "30" + } + + "m_Bubbles" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "32" + "linux" "32" + "mac" "32" + } + + "m_Shards" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "34" + "linux" "34" + "mac" "34" + } + + "m_Explosion" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "36" + "linux" "36" + "mac" "36" + } + + "m_DeadBodies" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "38" + "linux" "38" + "mac" "38" + } + + "m_PopHelmet" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "40" + "linux" "40" + "mac" "40" + } + + "m_RoundReset" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "42" + "linux" "42" + "mac" "42" + } + + "m_RocketTrail" // short unsigned int + { + "type" "short" + "unsigned" "1" + + "windows" "44" + "linux" "44" + "mac" "44" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CSPDoDRules + */ diff --git a/gamedata/common.games/gamerules.games/gearbox/offsets-chalflifecoopplay.txt b/gamedata/common.games/gamerules.games/gearbox/offsets-chalflifecoopplay.txt new file mode 100644 index 00000000..a0073660 --- /dev/null +++ b/gamedata/common.games/gamerules.games/gearbox/offsets-chalflifecoopplay.txt @@ -0,0 +1,52 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CHalfLifeCoopplay" + { + "Offsets" + { + "m_DisableDeathMessages" // BOOL + { + "type" "integer" + + "windows" "12" + "linux" "12" + "mac" "12" + } + + "m_DisableDeathPenalty" // BOOL + { + "type" "integer" + + "windows" "16" + "linux" "16" + "mac" "16" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CHalfLifeMultiplay + * CHalfLifeCoopplay + */ diff --git a/gamedata/common.games/gamerules.games/gearbox/offsets-chalflifectfplay.txt b/gamedata/common.games/gamerules.games/gearbox/offsets-chalflifectfplay.txt new file mode 100644 index 00000000..d4e4dd12 --- /dev/null +++ b/gamedata/common.games/gamerules.games/gearbox/offsets-chalflifectfplay.txt @@ -0,0 +1,88 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CHalfLifeCTFplay" + { + "Offsets" + { + "m_DisableDeathMessages" // BOOL + { + "type" "integer" + + "windows" "12" + "linux" "12" + "mac" "12" + } + + "m_DisableDeathPenalty" // BOOL + { + "type" "integer" + + "windows" "16" + "linux" "16" + "mac" "16" + } + + "m_fRefreshScores" // BOOL + { + "type" "integer" + + "windows" "20" + "linux" "20" + "mac" "20" + } + + "m_flNextStatsSend" // float + { + "type" "float" + + "windows" "24" + "linux" "24" + "mac" "24" + } + + "m_iStatsPhase" // int + { + "type" "integer" + + "windows" "28" + "linux" "28" + "mac" "28" + } + + "m_iStatsPlayer" // int + { + "type" "integer" + + "windows" "32" + "linux" "32" + "mac" "32" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CHalfLifeMultiplay + * CHalfLifeCTFplay + */ diff --git a/gamedata/common.games/gamerules.games/gearbox/offsets-chalflifemultiplay.txt b/gamedata/common.games/gamerules.games/gearbox/offsets-chalflifemultiplay.txt new file mode 100644 index 00000000..9931d094 --- /dev/null +++ b/gamedata/common.games/gamerules.games/gearbox/offsets-chalflifemultiplay.txt @@ -0,0 +1,51 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CHalfLifeMultiplay" + { + "Offsets" + { + "m_flIntermissionEndTime" // float + { + "type" "float" + + "windows" "4" + "linux" "4" + "mac" "4" + } + + "m_iEndIntermissionButtonHit" // BOOL + { + "type" "integer" + + "windows" "8" + "linux" "8" + "mac" "8" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CHalfLifeMultiplay + */ diff --git a/gamedata/common.games/gamerules.games/gearbox/offsets-chalflifeteamplay.txt b/gamedata/common.games/gamerules.games/gearbox/offsets-chalflifeteamplay.txt new file mode 100644 index 00000000..efaa6429 --- /dev/null +++ b/gamedata/common.games/gamerules.games/gearbox/offsets-chalflifeteamplay.txt @@ -0,0 +1,71 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CHalfLifeTeamplay" + { + "Offsets" + { + "m_DisableDeathMessages" // BOOL + { + "type" "integer" + + "windows" "12" + "linux" "12" + "mac" "12" + } + + "m_DisableDeathPenalty" // BOOL + { + "type" "integer" + + "windows" "16" + "linux" "16" + "mac" "16" + } + + "m_teamLimit" // BOOL + { + "type" "integer" + + "windows" "20" + "linux" "20" + "mac" "20" + } + + "m_szTeamList" // char[512] + { + "type" "string" + "size" "512" + + "windows" "24" + "linux" "24" + "mac" "24" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CHalfLifeMultiplay + * CHalfLifeTeamplay + */ diff --git a/gamedata/common.games/gamerules.games/master.games.txt b/gamedata/common.games/gamerules.games/master.games.txt new file mode 100644 index 00000000..86f73f66 --- /dev/null +++ b/gamedata/common.games/gamerules.games/master.games.txt @@ -0,0 +1,90 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Game Master" +{ + "cstrike/offsets-cgamerules.txt" + { + "game" "cstrike" + "game" "czero" + } + + "cstrike/offsets-chalflifemultiplay.txt" + { + "game" "cstrike" + "game" "czero" + } + + "cstrike/offsets-chalflifetraining.txt" + { + "game" "cstrike" + "game" "czero" + } + + + "dod/offsets-cdodteamplay.txt" + { + "game" "dod" + } + + "dod/offsets-cspdodrules.txt" + { + "game" "dod" + } + + + "gearbox/offsets-chalflifemultiplay.txt" + { + "game" "gearbox" + } + + "gearbox/offsets-chalflifectfplay.txt" + { + "game" "gearbox" + } + + "gearbox/offsets-chalflifecoopplay.txt" + { + "game" "gearbox" + } + + "gearbox/offsets-chalflifeteamplay.txt" + { + "game" "gearbox" + } + + + "tfc/offsets-chalflifemultiplay.txt" + { + "game" "tfc" + } + + "tfc/offsets-chalflifeteamplay.txt" + { + "game" "tfc" + } + + "tfc/offsets-cteamfortress.txt" + { + "game" "tfc" + } + + + "valve/offsets-chalflifemultiplay.txt" + { + "game" "valve" + } + + "valve/offsets-chalflifeteamplay.txt" + { + "game" "valve" + } +} diff --git a/gamedata/common.games/gamerules.games/tfc/offsets-chalflifemultiplay.txt b/gamedata/common.games/gamerules.games/tfc/offsets-chalflifemultiplay.txt new file mode 100644 index 00000000..54caf6ca --- /dev/null +++ b/gamedata/common.games/gamerules.games/tfc/offsets-chalflifemultiplay.txt @@ -0,0 +1,60 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CHalfLifeMultiplay" + { + "Offsets" + { + "m_flIntermissionEndTime" // float + { + "type" "float" + + "windows" "4" + "linux" "4" + "mac" "4" + } + + "m_flIntermissionStartTime" // float + { + "type" "float" + + "windows" "8" + "linux" "8" + "mac" "8" + } + + "m_iEndIntermissionButtonHit" // BOOL + { + "type" "integer" + + "windows" "12" + "linux" "12" + "mac" "12" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CHalfLifeMultiplay + */ diff --git a/gamedata/common.games/gamerules.games/tfc/offsets-chalflifeteamplay.txt b/gamedata/common.games/gamerules.games/tfc/offsets-chalflifeteamplay.txt new file mode 100644 index 00000000..12a3b6a7 --- /dev/null +++ b/gamedata/common.games/gamerules.games/tfc/offsets-chalflifeteamplay.txt @@ -0,0 +1,52 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CHalfLifeTeamplay" + { + "Offsets" + { + "m_DisableDeathMessages" // BOOL + { + "type" "integer" + + "windows" "16" + "linux" "16" + "mac" "16" + } + + "m_DisableDeathPenalty" // BOOL + { + "type" "integer" + + "windows" "20" + "linux" "20" + "mac" "20" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CHalfLifeMultiplay + * CHalfLifeTeamplay + */ diff --git a/gamedata/common.games/gamerules.games/tfc/offsets-cteamfortress.txt b/gamedata/common.games/gamerules.games/tfc/offsets-cteamfortress.txt new file mode 100644 index 00000000..1ea819a0 --- /dev/null +++ b/gamedata/common.games/gamerules.games/tfc/offsets-cteamfortress.txt @@ -0,0 +1,44 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CTeamFortress" + { + "Offsets" + { + "m_VoiceGameMgr" // class CVoiceGameMgr + { + "type" "class" + + "windows" "28" + "linux" "24" + "mac" "24" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CHalfLifeMultiplay + * CHalfLifeTeamplay + * CTeamFortress + */ diff --git a/gamedata/common.games/gamerules.games/valve/offsets-chalflifemultiplay.txt b/gamedata/common.games/gamerules.games/valve/offsets-chalflifemultiplay.txt new file mode 100644 index 00000000..9931d094 --- /dev/null +++ b/gamedata/common.games/gamerules.games/valve/offsets-chalflifemultiplay.txt @@ -0,0 +1,51 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CHalfLifeMultiplay" + { + "Offsets" + { + "m_flIntermissionEndTime" // float + { + "type" "float" + + "windows" "4" + "linux" "4" + "mac" "4" + } + + "m_iEndIntermissionButtonHit" // BOOL + { + "type" "integer" + + "windows" "8" + "linux" "8" + "mac" "8" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CHalfLifeMultiplay + */ diff --git a/gamedata/common.games/gamerules.games/valve/offsets-chalflifeteamplay.txt b/gamedata/common.games/gamerules.games/valve/offsets-chalflifeteamplay.txt new file mode 100644 index 00000000..efaa6429 --- /dev/null +++ b/gamedata/common.games/gamerules.games/valve/offsets-chalflifeteamplay.txt @@ -0,0 +1,71 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your AMX Mod X 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 AMXX's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(AMX_Mod_X) + */ + +"Games" +{ + "#default" + { + "Classes" + { + "CHalfLifeTeamplay" + { + "Offsets" + { + "m_DisableDeathMessages" // BOOL + { + "type" "integer" + + "windows" "12" + "linux" "12" + "mac" "12" + } + + "m_DisableDeathPenalty" // BOOL + { + "type" "integer" + + "windows" "16" + "linux" "16" + "mac" "16" + } + + "m_teamLimit" // BOOL + { + "type" "integer" + + "windows" "20" + "linux" "20" + "mac" "20" + } + + "m_szTeamList" // char[512] + { + "type" "string" + "size" "512" + + "windows" "24" + "linux" "24" + "mac" "24" + } + } + } + } + } +} + + +/** + * Class Hierarchy + * - + * CGameRules + * CHalfLifeMultiplay + * CHalfLifeTeamplay + */ diff --git a/support/PackageScript b/support/PackageScript index 3dc7cd78..1d42f07e 100644 --- a/support/PackageScript +++ b/support/PackageScript @@ -29,6 +29,12 @@ folder_list = [ 'base/addons/amxmodx/data/gamedata/common.games/hostages.games/cstrike', 'base/addons/amxmodx/data/gamedata/common.games/others.games', 'base/addons/amxmodx/data/gamedata/common.games/others.games/cstrike', + 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games', + 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/cstrike', + 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/dod', + 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/tfc', + 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/gearbox', + 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/valve', 'base/addons/amxmodx/data/gamedata/modules.games', 'base/addons/amxmodx/data/lang', 'base/addons/amxmodx/dlls', @@ -1212,6 +1218,45 @@ CopyFiles('gamedata/common.games/entities.games/valve', 'base/addons/amxmodx/dat ] ) +CopyFiles('gamedata/common.games/gamerules.games/cstrike', 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/cstrike', + [ + 'offsets-cgamerules.txt', + 'offsets-chalflifemultiplay.txt', + 'offsets-chalflifetraining.txt', + ] +) + +CopyFiles('gamedata/common.games/gamerules.games/dod', 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/dod', + [ + 'offsets-cdodteamplay.txt', + 'offsets-cspdodrules.txt', + ] +) + +CopyFiles('gamedata/common.games/gamerules.games/gearbox', 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/gearbox', + [ + 'offsets-chalflifecoopplay.txt', + 'offsets-chalflifectfplay.txt', + 'offsets-chalflifemultiplay.txt', + 'offsets-chalflifeteamplay.txt', + ] +) + +CopyFiles('gamedata/common.games/gamerules.games/tfc', 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/tfc', + [ + 'offsets-chalflifemultiplay.txt', + 'offsets-chalflifeteamplay.txt', + 'offsets-cteamfortress.txt', + ] +) + +CopyFiles('gamedata/common.games/gamerules.games/valve', 'base/addons/amxmodx/data/gamedata/common.games/gamerules.games/valve', + [ + 'offsets-chalflifemultiplay.txt', + 'offsets-chalflifeteamplay.txt', + ] +) + # Copy license files licenses = [ 'ACKNOWLEDGEMENTS.txt', From 483ef98af3dd43c3c84b1bf38f466b68caf41139 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Fri, 9 Oct 2015 11:01:12 +0200 Subject: [PATCH 02/12] Load gamerules address and offsets --- gamedata/common.games/globalvars.engine.txt | 20 +++++++++++++ modules/fakemeta/fakemeta_amxx.cpp | 31 ++++++++++++++++++--- modules/fakemeta/fakemeta_amxx.h | 2 ++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/gamedata/common.games/globalvars.engine.txt b/gamedata/common.games/globalvars.engine.txt index e0389709..ccc3b2b9 100644 --- a/gamedata/common.games/globalvars.engine.txt +++ b/gamedata/common.games/globalvars.engine.txt @@ -40,6 +40,18 @@ "read" "2" } } + + "g_pGameRules" + { + "signature" "g_pGameRules" + + "windows" + { + "read" "2" + } + + "read" "0" + } } "Signatures" @@ -66,6 +78,14 @@ "linux" "@realtime" "mac" "@realtime" } + + "g_pGameRules" // CGameRules *g_pGameRules + { + "library" "server" + "windows" "\x8B\x2A\x2A\x2A\x2A\x2A\x85\x2A\x74\x2A\x8B\x2A\xFF\x2A\x2A\xA1" // StartFrame() + "linux" "@g_pGameRules" + "mac" "@g_pGameRules" + } } } } diff --git a/modules/fakemeta/fakemeta_amxx.cpp b/modules/fakemeta/fakemeta_amxx.cpp index 5814ed44..ca0eb3df 100644 --- a/modules/fakemeta/fakemeta_amxx.cpp +++ b/modules/fakemeta/fakemeta_amxx.cpp @@ -15,9 +15,12 @@ #include "sh_stack.h" IGameConfig *CommonConfig; +IGameConfig *GamerulesConfig; IGameConfigManager *ConfigManager; HLTypeConversion TypeConversion; +void *GameRulesReferenceAddress; +void *GameRulesAddress; void OnAmxxAttach() { @@ -39,13 +42,25 @@ void OnAmxxAttach() ConfigManager = MF_GetConfigManager(); - char error[256]; - error[0] = '\0'; + char error[256] = ""; if (!ConfigManager->LoadGameConfigFile("common.games", &CommonConfig, error, sizeof(error)) && error[0] != '\0') { - MF_Log("Could not read common.games gamedata: %s", error); - MF_Log("get/set/find_ent_data* natives have been disabled"); + MF_Log("get/set_ent_data* natives have been disabled because common.games gamedata could not be read: %s", error); + return; + } + + *error = '\0'; + + if (!ConfigManager->LoadGameConfigFile("common.games/gamerules.games", &GamerulesConfig, error, sizeof(error)) && error[0] != '\0') + { + MF_Log("get/set_gamerules_* natives have been disabled because common.games/gamerules.games gamedata could not be read: %s", error); + return; + } + + if (!CommonConfig->GetAddress("g_pGameRules", &GameRulesReferenceAddress) || !GameRulesReferenceAddress) + { + MF_Log("get/set_gamerules_* natives have been disabled because g_pGameRules address could not be found. "); return; } @@ -63,6 +78,9 @@ extern ke::Vector g_FreeKVDWs; void OnAmxxDetach() { + ConfigManager->CloseGameConfigFile(CommonConfig); + ConfigManager->CloseGameConfigFile(GamerulesConfig); + while (!g_FreeTRs.empty()) { delete g_FreeTRs.front(); @@ -78,6 +96,11 @@ void OnAmxxDetach() void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) { + if (GameRulesReferenceAddress) + { + GameRulesAddress = **reinterpret_cast(GameRulesReferenceAddress); + } + g_pFunctionTable_Post->pfnServerDeactivate = FMH_ServerDeactivate_Post; RETURN_META(MRES_IGNORED); } diff --git a/modules/fakemeta/fakemeta_amxx.h b/modules/fakemeta/fakemeta_amxx.h index e61b4f61..c796fb10 100644 --- a/modules/fakemeta/fakemeta_amxx.h +++ b/modules/fakemeta/fakemeta_amxx.h @@ -75,9 +75,11 @@ extern NEW_DLL_FUNCTIONS *g_pNewFunctionsTable; extern NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post; extern IGameConfig *CommonConfig; +extern IGameConfig *GamerulesConfig; extern IGameConfigManager *ConfigManager; extern HLTypeConversion TypeConversion; +extern void *GameRulesAddress; #endif //_FAKEMETA_INCLUDE_H From 234b537ad9e154551b98eab4e96e248ed02cc286 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Fri, 9 Oct 2015 11:13:33 +0200 Subject: [PATCH 03/12] Factorize gamerules data code --- modules/fakemeta/pdata_gc.cpp | 226 ++++++++++++++++++++++++++++++++++ public/HLTypeConversion.h | 8 +- 2 files changed, 233 insertions(+), 1 deletion(-) diff --git a/modules/fakemeta/pdata_gc.cpp b/modules/fakemeta/pdata_gc.cpp index 1df45d48..e40b8ca5 100644 --- a/modules/fakemeta/pdata_gc.cpp +++ b/modules/fakemeta/pdata_gc.cpp @@ -112,6 +112,232 @@ static BaseFieldType GetBaseDataType(TypeDescription &data) return 0; \ } + +cell GetData(void *pObject, TypeDescription &data, int element) +{ + switch (data.fieldType) + { + case FieldType::FIELD_INTEGER: + case FieldType::FIELD_STRINGINT: + { + return get_pdata(pObject, data.fieldOffset, element); + } + case FieldType::FIELD_CLASS: + case FieldType::FIELD_STRUCTURE: + { + return get_pdata_direct(pObject, data.fieldOffset); + } + case FieldType::FIELD_POINTER: + case FieldType::FIELD_FUNCTION: + { + return reinterpret_cast(get_pdata(pObject, data.fieldOffset, element)); + } + case FieldType::FIELD_SHORT: + { + if (data.fieldUnsigned) + { + return get_pdata(pObject, data.fieldOffset, element); + } + else + { + return get_pdata(pObject, data.fieldOffset, element); + } + } + case FieldType::FIELD_CHARACTER: + { + if (data.fieldUnsigned) + { + return get_pdata(pObject, data.fieldOffset, element); + } + else + { + return get_pdata(pObject, data.fieldOffset, element); + } + } + case FieldType::FIELD_BOOLEAN: + { + return get_pdata(pObject, data.fieldOffset, element) ? 1 : 0; + } + } + + return 0; +} + +void SetData(void *pObject, TypeDescription &data, cell value, int element) +{ + switch (data.fieldType) + { + case FieldType::FIELD_INTEGER: + case FieldType::FIELD_STRINGINT: + { + set_pdata(pObject, data.fieldOffset, static_cast(value), element); + break; + } + case FieldType::FIELD_POINTER: + case FieldType::FIELD_FUNCTION: + { + set_pdata(pObject, data.fieldOffset, reinterpret_cast(value), element); + break; + } + case FieldType::FIELD_SHORT: + { + if (data.fieldUnsigned) + { + set_pdata(pObject, data.fieldOffset, static_cast(value), element); + } + else + { + set_pdata(pObject, data.fieldOffset, static_cast(value), element); + } + break; + } + case FieldType::FIELD_CHARACTER: + { + if (data.fieldUnsigned) + { + set_pdata(pObject, data.fieldOffset, static_cast(value), element); + } + else + { + set_pdata(pObject, data.fieldOffset, static_cast(value), element); + } + break; + } + case FieldType::FIELD_BOOLEAN: + { + set_pdata(pObject, data.fieldOffset, value != 0, element); + break; + } + } +} + +cell GetDataFloat(void *pObject, TypeDescription &data, int element) +{ + return amx_ftoc(get_pdata(pObject, data.fieldOffset, element)); +} + +void SetDataFloat(void *pObject, TypeDescription &data, float value, int element) +{ + set_pdata(pObject, data.fieldOffset, value, element); +} + +void GetDataVector(void *pObject, TypeDescription &data, cell *pVector, int element) +{ + auto vector = get_pdata(pObject, data.fieldOffset, element); + + pVector[0] = amx_ftoc(vector.x); + pVector[1] = amx_ftoc(vector.y); + pVector[2] = amx_ftoc(vector.z); +} + +void SetDataVector(void *pObject, TypeDescription &data, cell *pVector, int element) +{ + Vector vector(amx_ctof(pVector[0]), amx_ctof(pVector[1]), amx_ctof(pVector[2])); + + set_pdata(pObject, data.fieldOffset, vector, element); +} + +cell GetDataEntity(void *pObject, TypeDescription &data, int element) +{ + switch (data.fieldType) + { + case FieldType::FIELD_CLASSPTR: + { + return TypeConversion.cbase_to_id(get_pdata(pObject, data.fieldOffset, element)); + } + case FieldType::FIELD_ENTVARS: + { + return TypeConversion.entvars_to_id(get_pdata(pObject, data.fieldOffset, element)); + } + case FieldType::FIELD_EDICT: + { + return TypeConversion.edict_to_id(get_pdata(pObject, data.fieldOffset, element)); + } + case FieldType::FIELD_EHANDLE: + { + return TypeConversion.edict_to_id(get_pdata(pObject, data.fieldOffset, element).Get()); + } + } + + return 0; +} + +void SetDataEntity(void *pObject, TypeDescription &data, int value, int element) +{ + switch (data.fieldType) + { + case FieldType::FIELD_CLASSPTR: + { + set_pdata(pObject, data.fieldOffset, value != -1 ? TypeConversion.id_to_cbase(value) : nullptr, element); + break; + } + case FieldType::FIELD_ENTVARS: + { + set_pdata(pObject, data.fieldOffset, value != -1 ? TypeConversion.id_to_entvars(value) : nullptr, element); + break; + } + case FieldType::FIELD_EDICT: + { + set_pdata(pObject, data.fieldOffset, value != -1 ? TypeConversion.id_to_edict(value) : nullptr, element); + break; + } + case FieldType::FIELD_EHANDLE: + { + get_pdata(pObject, data.fieldOffset, element).Set(value != -1 ? TypeConversion.id_to_edict(value) : nullptr); + break; + } + } +} + +char* GetDataString(void *pObject, TypeDescription &data, int element) +{ + switch (data.fieldType) + { + case FieldType::FIELD_STRING: + { + return get_pdata_direct(pObject, data.fieldOffset, element, data.fieldSize); + } + case FieldType::FIELD_STRINGPTR: + { + return get_pdata(pObject, data.fieldOffset, element); + } + } + + return nullptr; +} + +cell SetDataString(void *pObject, TypeDescription &data, const char *value, int maxlen, int element) +{ + switch (data.fieldType) + { + case FieldType::FIELD_STRING: + { + auto buffer = get_pdata_direct(pObject, data.fieldOffset); + return strncopy(buffer, value, ke::Min(maxlen + 1, data.fieldSize)); + } + case FieldType::FIELD_STRINGPTR: + { + auto buffer = get_pdata(pObject, data.fieldOffset, element); + + if (!buffer || maxlen > static_cast(strlen(buffer))) + { + if (buffer) + { + free(buffer); + } + + buffer = reinterpret_cast(malloc(maxlen + 1)); + set_pdata(pObject, data.fieldOffset, buffer, element); + } + + return strncopy(buffer, value, maxlen + 1); + } + } + + return 0; +} + + // native any:get_ent_data(entity, const class[], const member[], element = 0); static cell AMX_NATIVE_CALL get_ent_data(AMX *amx, cell *params) { diff --git a/public/HLTypeConversion.h b/public/HLTypeConversion.h index 2c135b11..e99993ed 100644 --- a/public/HLTypeConversion.h +++ b/public/HLTypeConversion.h @@ -19,11 +19,17 @@ template static inline T& ref_pdata(void *pPrivateData, int offset, } +template inline T get_pdata_direct(void *pPrivateData, int offset, int element = 0, int size = 0) +{ + return reinterpret_cast(reinterpret_cast(pPrivateData) + offset + (element * size)); +} + template inline T get_pdata_direct(edict_t *pEntity, int offset, int element = 0, int size = 0) { - return reinterpret_cast((reinterpret_cast(pEntity->pvPrivateData) + offset + (element * size))); + return get_pdata_direct(pEntity->pvPrivateData, offset, element, size); } + template inline T& get_pdata(void *pPrivateData, int offset, int element = 0) { return ref_pdata(pPrivateData, offset, element); From d9c7e72d4be4097bb153fe7d52b9446b1ec0f3df Mon Sep 17 00:00:00 2001 From: Arkshine Date: Fri, 9 Oct 2015 11:16:20 +0200 Subject: [PATCH 04/12] Update macros to support gamerules configs --- modules/fakemeta/pdata_gc.cpp | 41 +++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/modules/fakemeta/pdata_gc.cpp b/modules/fakemeta/pdata_gc.cpp index e40b8ca5..5b8a5f95 100644 --- a/modules/fakemeta/pdata_gc.cpp +++ b/modules/fakemeta/pdata_gc.cpp @@ -75,20 +75,40 @@ static BaseFieldType GetBaseDataType(TypeDescription &data) return BaseFieldType::None; } -#define GET_TYPE_DESCRIPTION(position, data, baseType) \ + +#define GET_TYPE_DESCRIPTION(position, data, baseType, list) \ + GET_TYPE_DESCRIPTION_START(position, data, baseType) \ + CHECK_##list##_OFFSET(className, memberName, data) \ + CHECK_ERROR(className, memberName) \ + GET_TYPE_DESCRIPTION_END(memberName, data, baseType) + +#define GET_TYPE_DESCRIPTION_START(position, data, baseType) \ int classLength, memberLength; \ - const char *className = MF_GetAmxString(amx, params[position], 0, &classLength); \ + const char *className = MF_GetAmxString(amx, params[position], 0, &classLength); \ const char *memberName = MF_GetAmxString(amx, params[position + 1], 1, &memberLength); \ if (!classLength || !memberLength) \ { \ MF_LogError(amx, AMX_ERR_NATIVE, "Either class (\"%s\") or member (\"%s\") is empty", className, memberName); \ return 0; \ - } \ - else if (!CommonConfig->GetOffsetByClass(className, memberName, &data)) \ - { \ + } + +#define CHECK_ENTITY_OFFSET(className, memberName, data) \ + else if (!CommonConfig->GetOffsetByClass(className, memberName, &data)) + +#define CHECK_GAMERULES_OFFSET(className, memberName, data) \ + else if (!GamerulesConfig->GetOffsetByClass(className, memberName, &data)) + +#define CHECK_ALL_OFFSET(className, memberName, data) \ + else if (!CommonConfig->GetOffsetByClass(className, memberName, &data) && \ + !GamerulesConfig->GetOffsetByClass(className, memberName, &data)) + +#define CHECK_ERROR(className, memberName) \ + { \ MF_LogError(amx, AMX_ERR_NATIVE, "Could not find class \"%s\" and/or member \"%s\" in gamedata", className, memberName); \ - return 0; \ - } \ + return 0; \ + } + +#define GET_TYPE_DESCRIPTION_END(memberName, data, baseType) \ else if (data.fieldOffset < 0) \ { \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset %d retrieved from \"%s\" member", data.fieldOffset, memberName); \ @@ -112,6 +132,13 @@ static BaseFieldType GetBaseDataType(TypeDescription &data) return 0; \ } +#define CHECK_GAMERULES() \ + if (!GameRulesAddress) \ + { \ + MF_LogError(amx, AMX_ERR_NATIVE, "%s is disabled. Check your AMXX log.", __FUNCTION__); \ + return 0; \ + } + cell GetData(void *pObject, TypeDescription &data, int element) { From df507a675b9f5e5f220e2677dca835e6b5d4dff7 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Fri, 9 Oct 2015 11:20:22 +0200 Subject: [PATCH 05/12] Reflect changes on get/set_data* natives --- modules/fakemeta/pdata_gc.cpp | 255 +++++----------------------------- 1 file changed, 34 insertions(+), 221 deletions(-) diff --git a/modules/fakemeta/pdata_gc.cpp b/modules/fakemeta/pdata_gc.cpp index 5b8a5f95..562ae6a7 100644 --- a/modules/fakemeta/pdata_gc.cpp +++ b/modules/fakemeta/pdata_gc.cpp @@ -372,59 +372,12 @@ static cell AMX_NATIVE_CALL get_ent_data(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Integer); + GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Integer, ENTITY); int element = params[4]; CHECK_ELEMENT(element); - auto pEntity = TypeConversion.id_to_edict(entity); - - switch (data.fieldType) - { - case FieldType::FIELD_INTEGER: - case FieldType::FIELD_STRINGINT: - { - return get_pdata(pEntity, data.fieldOffset, element); - } - case FieldType::FIELD_CLASS: - case FieldType::FIELD_STRUCTURE: - { - return reinterpret_cast(reinterpret_cast(pEntity->pvPrivateData) + data.fieldOffset); - } - case FieldType::FIELD_POINTER: - case FieldType::FIELD_FUNCTION: - { - return reinterpret_cast(get_pdata(pEntity, data.fieldOffset, element)); - } - case FieldType::FIELD_SHORT: - { - if (data.fieldUnsigned) - { - return get_pdata(pEntity, data.fieldOffset, element); - } - else - { - return get_pdata(pEntity, data.fieldOffset, element); - } - } - case FieldType::FIELD_CHARACTER: - { - if (data.fieldUnsigned) - { - return get_pdata(pEntity, data.fieldOffset, element); - } - else - { - return get_pdata(pEntity, data.fieldOffset, element); - } - } - case FieldType::FIELD_BOOLEAN: - { - return get_pdata(pEntity, data.fieldOffset, element) ? 1 : 0; - } - } - - return 0; + return GetData(TypeConversion.id_to_edict(entity)->pvPrivateData, data, element); } // native set_ent_data(entity, const class[], const member[], any:value, element = 0); @@ -434,66 +387,20 @@ static cell AMX_NATIVE_CALL set_ent_data(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Integer); + GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Integer, ENTITY); int element = params[5]; CHECK_ELEMENT(element); - auto pEntity = TypeConversion.id_to_edict(entity); - auto value = params[4]; - - switch (data.fieldType) + if (data.fieldType == FieldType::FIELD_STRUCTURE || data.fieldType == FieldType::FIELD_CLASS) { - case FieldType::FIELD_INTEGER: - case FieldType::FIELD_STRINGINT: - { - set_pdata(pEntity, data.fieldOffset, static_cast(value), element); - break; - } - case FieldType::FIELD_CLASS: - case FieldType::FIELD_STRUCTURE: - { - MF_LogError(amx, AMX_ERR_NATIVE, "Setting directly to a class or structure address is not available"); - return 0; - } - case FieldType::FIELD_POINTER: - case FieldType::FIELD_FUNCTION: - { - set_pdata(pEntity, data.fieldOffset, reinterpret_cast(value), element); - break; - } - case FieldType::FIELD_SHORT: - { - if (data.fieldUnsigned) - { - set_pdata(pEntity, data.fieldOffset, static_cast(value), element); - } - else - { - set_pdata(pEntity, data.fieldOffset, static_cast(value), element); - } - break; - } - case FieldType::FIELD_CHARACTER: - { - if (data.fieldUnsigned) - { - set_pdata(pEntity, data.fieldOffset, static_cast(value), element); - } - else - { - set_pdata(pEntity, data.fieldOffset, static_cast(value), element); - } - break; - } - case FieldType::FIELD_BOOLEAN: - { - set_pdata(pEntity, data.fieldOffset, value != 0, element); - break; - } + MF_LogError(amx, AMX_ERR_NATIVE, "Setting directly to a class or structure address is not available"); + return 0; } - return 0; + SetData(TypeConversion.id_to_edict(entity)->pvPrivateData, data, params[4], element); + + return 1; } @@ -504,12 +411,12 @@ static cell AMX_NATIVE_CALL get_ent_data_float(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Float); + GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Float, ENTITY); int element = params[4]; CHECK_ELEMENT(element); - return amx_ftoc(get_pdata(TypeConversion.id_to_edict(entity), data.fieldOffset, element)); + return GetDataFloat(TypeConversion.id_to_edict(entity)->pvPrivateData, data, element); } // native set_ent_data_float(entity, const classname[], const member[], Float:value, element = 0); @@ -519,12 +426,12 @@ static cell AMX_NATIVE_CALL set_ent_data_float(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Float); + GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Float, ENTITY); int element = params[5]; CHECK_ELEMENT(element); - set_pdata(TypeConversion.id_to_edict(entity), data.fieldOffset, amx_ctof(params[4]), element); + SetDataFloat(TypeConversion.id_to_edict(entity)->pvPrivateData, data, amx_ctof(params[4]), element); return 1; } @@ -537,17 +444,12 @@ static cell AMX_NATIVE_CALL get_ent_data_vector(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Vector); + GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Vector, ENTITY); int element = params[5]; CHECK_ELEMENT(element); - auto refvec = MF_GetAmxAddr(amx, params[4]); - auto vector = get_pdata(TypeConversion.id_to_edict(entity), data.fieldOffset, element); - - refvec[0] = amx_ftoc(vector.x); - refvec[1] = amx_ftoc(vector.y); - refvec[2] = amx_ftoc(vector.z); + GetDataVector(TypeConversion.id_to_edict(entity)->pvPrivateData, data, MF_GetAmxAddr(amx, params[4]), element); return 1; } @@ -559,15 +461,12 @@ static cell AMX_NATIVE_CALL set_ent_data_vector(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Vector); + GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Vector, ENTITY); int element = params[5]; CHECK_ELEMENT(element); - auto refvec = MF_GetAmxAddr(amx, params[4]); - Vector vector(amx_ctof(refvec[0]), amx_ctof(refvec[1]), amx_ctof(refvec[2])); - - set_pdata(TypeConversion.id_to_edict(entity), data.fieldOffset, vector, element); + SetDataVector(TypeConversion.id_to_edict(entity)->pvPrivateData, data, MF_GetAmxAddr(amx, params[4]), element); return 1; } @@ -580,41 +479,19 @@ static cell AMX_NATIVE_CALL get_ent_data_entity(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Entity); + GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Entity, ENTITY); int element = params[4]; CHECK_ELEMENT(element); - auto pEntity = TypeConversion.id_to_edict(entity); - - switch (data.fieldType) - { - case FieldType::FIELD_CLASSPTR: - { - return TypeConversion.cbase_to_id(get_pdata(pEntity, data.fieldOffset, element)); - } - case FieldType::FIELD_ENTVARS: - { - return TypeConversion.entvars_to_id(get_pdata(pEntity, data.fieldOffset, element)); - } - case FieldType::FIELD_EDICT: - { - return TypeConversion.edict_to_id(get_pdata(pEntity, data.fieldOffset, element)); - } - case FieldType::FIELD_EHANDLE: - { - return TypeConversion.edict_to_id(get_pdata(pEntity, data.fieldOffset, element).Get()); - } - } - - return 0; + return GetDataEntity(TypeConversion.id_to_edict(entity)->pvPrivateData, data, element); } // native set_ent_data_entity(entity, const class[], const member[], value, element = 0); static cell AMX_NATIVE_CALL set_ent_data_entity(AMX *amx, cell *params) { int entity = params[1]; - int value = params[4]; + int value = params[4]; CHECK_ENTITY(entity); @@ -624,38 +501,14 @@ static cell AMX_NATIVE_CALL set_ent_data_entity(AMX *amx, cell *params) } TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Entity); + GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Entity, ENTITY); int element = params[5]; CHECK_ELEMENT(element); - auto pEntity = TypeConversion.id_to_edict(entity); + SetDataEntity(TypeConversion.id_to_edict(entity)->pvPrivateData, data, value, element); - switch (data.fieldType) - { - case FieldType::FIELD_CLASSPTR: - { - set_pdata(pEntity, data.fieldOffset, value != -1 ? TypeConversion.id_to_cbase(value) : nullptr, element); - break; - } - case FieldType::FIELD_ENTVARS: - { - set_pdata(pEntity, data.fieldOffset, value != -1 ? TypeConversion.id_to_entvars(value) : nullptr, element); - break; - } - case FieldType::FIELD_EDICT: - { - set_pdata(pEntity, data.fieldOffset, value != -1 ? TypeConversion.id_to_edict(value) : nullptr, element); - break; - } - case FieldType::FIELD_EHANDLE: - { - get_pdata(pEntity, data.fieldOffset, element).Set(value != -1 ? TypeConversion.id_to_edict(value) : nullptr); - break; - } - } - - return 0; + return 1; } @@ -666,34 +519,22 @@ static cell AMX_NATIVE_CALL get_ent_data_string(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::String); + GET_TYPE_DESCRIPTION(2, data, BaseFieldType::String, ENTITY); int element = params[6]; CHECK_ELEMENT(element); - auto pEntity = TypeConversion.id_to_edict(entity); + auto buffer = params[4]; + auto maxlen = params[5]; - cell buffer = params[4]; - int maxlen = params[5]; + auto string = GetDataString(TypeConversion.id_to_edict(entity)->pvPrivateData, data, element); - switch (data.fieldType) + if (data.fieldSize) { - case FieldType::FIELD_STRING: - { - maxlen = ke::Min(maxlen, static_cast(data.fieldSize)); - char *string = get_pdata_direct(pEntity, data.fieldOffset, element, data.fieldSize); - - return MF_SetAmxStringUTF8Char(amx, buffer, string ? string : "", string ? strlen(string) : 0, maxlen); - } - case FieldType::FIELD_STRINGPTR: - { - char *string = get_pdata(pEntity, data.fieldOffset, element); - - return MF_SetAmxStringUTF8Char(amx, buffer, string ? string : "", string ? strlen(string) : 0, maxlen); - } + maxlen = ke::Min(maxlen, data.fieldSize); } - return 0; + return MF_SetAmxStringUTF8Char(amx, buffer, string ? string : "", string ? strlen(string) : 0, maxlen); } // native set_ent_data_string(entity, const class[], const member[], const value[], element = 0); @@ -703,43 +544,15 @@ static cell AMX_NATIVE_CALL set_ent_data_string(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::String); + GET_TYPE_DESCRIPTION(2, data, BaseFieldType::String, ENTITY); int element = params[5]; CHECK_ELEMENT(element); - auto pEntity = TypeConversion.id_to_edict(entity); - int length; const char *value = MF_GetAmxString(amx, params[4], 0, &length); - switch (data.fieldType) - { - case FieldType::FIELD_STRING: - { - auto buffer = reinterpret_cast(pEntity->pvPrivateData) + data.fieldOffset; - return strncopy(buffer, value, ke::Min(length + 1, data.fieldSize)); - } - case FieldType::FIELD_STRINGPTR: - { - auto buffer = get_pdata(pEntity, data.fieldOffset, element); - - if (!buffer || length > static_cast(strlen(buffer))) - { - if (buffer) - { - free(buffer); - } - - buffer = reinterpret_cast(malloc(length + 1)); - set_pdata(pEntity, data.fieldOffset, buffer, element); - } - - return strncopy(buffer, value, length + 1); - } - } - - return 0; + return SetDataString(TypeConversion.id_to_edict(entity)->pvPrivateData, data, value, length, element); } @@ -747,7 +560,7 @@ static cell AMX_NATIVE_CALL set_ent_data_string(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_ent_data_size(AMX *amx, cell *params) { TypeDescription data; - GET_TYPE_DESCRIPTION(0, data, BaseFieldType::None); + GET_TYPE_DESCRIPTION(0, data, BaseFieldType::None, ALL); return data.fieldSize; } @@ -756,7 +569,7 @@ static cell AMX_NATIVE_CALL get_ent_data_size(AMX *amx, cell *params) static cell AMX_NATIVE_CALL find_ent_data_info(AMX *amx, cell *params) { TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None); + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, ALL); *MF_GetAmxAddr(amx, params[3]) = static_cast(data.fieldType); *MF_GetAmxAddr(amx, params[4]) = ke::Max(0, data.fieldSize); From 68f99bc2d5ee104ce1e3693c1e0068999171e2bb Mon Sep 17 00:00:00 2001 From: Arkshine Date: Fri, 9 Oct 2015 11:26:40 +0200 Subject: [PATCH 06/12] Add get/Set_gamerules_* natives --- modules/fakemeta/pdata_gc.cpp | 216 ++++++++++++++++++++++++++++++++-- plugins/include/fakemeta.inc | 177 ++++++++++++++++++++++++++++ 2 files changed, 380 insertions(+), 13 deletions(-) diff --git a/modules/fakemeta/pdata_gc.cpp b/modules/fakemeta/pdata_gc.cpp index 562ae6a7..7089ff6d 100644 --- a/modules/fakemeta/pdata_gc.cpp +++ b/modules/fakemeta/pdata_gc.cpp @@ -556,6 +556,189 @@ static cell AMX_NATIVE_CALL set_ent_data_string(AMX *amx, cell *params) } + +// native any:get_gamerules_int(const class[], const member[], element = 0); +static cell AMX_NATIVE_CALL get_gamerules_int(AMX *amx, cell *params) +{ + CHECK_GAMERULES(); + + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Integer, GAMERULES); + + int element = params[3]; + CHECK_ELEMENT(element); + + return GetData(GameRulesAddress, data, element); +} + +// native set_gamerules_int(const class[], const member[], any:value, element = 0); +static cell AMX_NATIVE_CALL set_gamerules_int(AMX *amx, cell *params) +{ + CHECK_GAMERULES(); + + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Integer, GAMERULES); + + int element = params[4]; + CHECK_ELEMENT(element); + + if (data.fieldType == FieldType::FIELD_STRUCTURE || data.fieldType == FieldType::FIELD_CLASS) + { + MF_LogError(amx, AMX_ERR_NATIVE, "Setting directly to a class or structure address is not available"); + return 0; + } + + SetData(GameRulesAddress, data, params[3], element); + + return 0; +} + + +// native Float:get_gamerules_float(const class[], const member[], element = 0); +static cell AMX_NATIVE_CALL get_gamerules_float(AMX *amx, cell *params) +{ + CHECK_GAMERULES(); + + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Float, GAMERULES); + + int element = params[3]; + CHECK_ELEMENT(element); + + return GetDataFloat(GameRulesAddress, data, element); +} + +// native set_gamerules_float(const class[], const member[], Float:value, element = 0); +static cell AMX_NATIVE_CALL set_gamerules_float(AMX *amx, cell *params) +{ + CHECK_GAMERULES(); + + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Float, GAMERULES); + + int element = params[4]; + CHECK_ELEMENT(element); + + SetDataFloat(GameRulesAddress, data, amx_ctof(params[3]), element); + + return 1; +} + + +// native get_gamerules_vector(const class[], const member[], Float:value[3], element = 0); +static cell AMX_NATIVE_CALL get_gamerules_vector(AMX *amx, cell *params) +{ + CHECK_GAMERULES(); + + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Vector, GAMERULES); + + int element = params[4]; + CHECK_ELEMENT(element); + + GetDataVector(GameRulesAddress, data, MF_GetAmxAddr(amx, params[3]), element); + + return 1; +} + +// native set_gamerules_vector(const class[], const member[], Float:value[3], element = 0); +static cell AMX_NATIVE_CALL set_gamerules_vector(AMX *amx, cell *params) +{ + CHECK_GAMERULES(); + + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Vector, GAMERULES); + + int element = params[4]; + CHECK_ELEMENT(element); + + GetDataVector(GameRulesAddress, data, MF_GetAmxAddr(amx, params[3]), element); + + return 1; +} + + +// native get_gamerules_entity(const class[], const member[], element = 0); +static cell AMX_NATIVE_CALL get_gamerules_entity(AMX *amx, cell *params) +{ + CHECK_GAMERULES(); + + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Entity, GAMERULES); + + int element = params[3]; + CHECK_ELEMENT(element); + + return GetDataEntity(GameRulesAddress, data, element); +} + +// native set_gamerules_entity(const class[], const member[], value, element = 0); +static cell AMX_NATIVE_CALL set_gamerules_entity(AMX *amx, cell *params) +{ + CHECK_GAMERULES(); + + int value = params[3]; + + if (value != -1) + { + CHECK_ENTITY(value); + } + + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Entity, GAMERULES); + + int element = params[4]; + CHECK_ELEMENT(element); + + SetDataEntity(GameRulesAddress, data, params[3], element); + + return 0; +} + + +// native get_gamerules_string(const class[], const member[], value[], maxlen, element = 0); +static cell AMX_NATIVE_CALL get_gamerules_string(AMX *amx, cell *params) +{ + CHECK_GAMERULES(); + + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::String, GAMERULES); + + int element = params[5]; + CHECK_ELEMENT(element); + + auto buffer = params[3]; + auto maxlen = params[4]; + + auto string = GetDataString(GameRulesAddress, data, element); + + if (data.fieldSize) + { + maxlen = ke::Min(maxlen, data.fieldSize); + } + + return MF_SetAmxStringUTF8Char(amx, buffer, string ? string : "", string ? strlen(string) : 0, maxlen); +} + +// native set_gamerules_string(const class[], const member[], const value[], element = 0); +static cell AMX_NATIVE_CALL set_gamerules_string(AMX *amx, cell *params) +{ + CHECK_GAMERULES(); + + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::String, GAMERULES); + + int element = params[4]; + CHECK_ELEMENT(element); + + int length; + const char *value = MF_GetAmxString(amx, params[3], 0, &length); + + return SetDataString(GameRulesAddress, data, value, length, element); +} + + + // native get_ent_data_size(const class[], const member[]); static cell AMX_NATIVE_CALL get_ent_data_size(AMX *amx, cell *params) { @@ -581,20 +764,27 @@ static cell AMX_NATIVE_CALL find_ent_data_info(AMX *amx, cell *params) AMX_NATIVE_INFO pdata_gc_natives[] = { - { "get_ent_data" , get_ent_data }, - { "set_ent_data" , set_ent_data }, + { "get_ent_data" , get_ent_data }, + { "set_ent_data" , set_ent_data }, + { "get_ent_data_float" , get_ent_data_float }, + { "set_ent_data_float" , set_ent_data_float }, + { "get_ent_data_vector" , get_ent_data_vector }, + { "set_ent_data_vector" , set_ent_data_vector }, + { "get_ent_data_entity" , get_ent_data_entity }, + { "set_ent_data_entity" , set_ent_data_entity }, + { "get_ent_data_string" , get_ent_data_string }, + { "set_ent_data_string" , set_ent_data_string }, - { "get_ent_data_float" , get_ent_data_float }, - { "set_ent_data_float" , set_ent_data_float }, - - { "get_ent_data_vector", get_ent_data_vector }, - { "set_ent_data_vector", set_ent_data_vector }, - - { "get_ent_data_entity", get_ent_data_entity }, - { "set_ent_data_entity", set_ent_data_entity }, - - { "get_ent_data_string", get_ent_data_string }, - { "set_ent_data_string", set_ent_data_string }, + { "get_gamerules_int" , get_gamerules_int }, + { "set_gamerules_int" , set_gamerules_int }, + { "get_gamerules_float" , get_gamerules_float }, + { "set_gamerules_float" , set_gamerules_float }, + { "get_gamerules_vector", get_gamerules_vector }, + { "set_gamerules_vector", set_gamerules_vector }, + { "get_gamerules_entity", get_gamerules_entity }, + { "set_gamerules_entity", set_gamerules_entity }, + { "get_gamerules_string", get_gamerules_string }, + { "set_gamerules_string", set_gamerules_string }, { "get_ent_data_size" , get_ent_data_size }, { "find_ent_data_info" , find_ent_data_info }, diff --git a/plugins/include/fakemeta.inc b/plugins/include/fakemeta.inc index ff7d4531..a8183ceb 100755 --- a/plugins/include/fakemeta.inc +++ b/plugins/include/fakemeta.inc @@ -808,6 +808,183 @@ native get_ent_data_string(entity, const class[], const member[], value[], maxle */ native set_ent_data_string(entity, const class[], const member[], const value[], element = 0); +/** + * Retrieves an integer value from the gamerules object based off a class + * and member name. + * + * @note This native is used to access the following (C++/engine) data types: + * integer, boolean, short, character, pointer, structure, class, + * stringint and function. Unsigned variants (if applicable) are supported + * and will be converted automatically. + * + * @param class Class name + * @param member Member name + * @param element Element to retrieve (starting from 0) if member is an array + * + * @return Integer value + * @error If member is empty, no offset is found or an invalid offset + * is retrieved, or the data type does not match, an error will + * be thrown. + */ +native any:get_gamerules_int(const class[], const member[], element = 0); + +/** + * Sets an integer value to the gamerules objecta based off a class + * and member name. + * + * @note This native is used to access the following (C++/engine) data types: + * integer, boolean, short, character, pointer, stringint and function. + * Unsigned variants (if applicable) are supported and will be converted + * automatically. + * + * @param class Class name + * @param member Member name + * @param value Value to set + * @param element Element to set (starting from 0) if member is an array + * + * @noreturn + * @error If member is empty, no offset is found or an invalid offset + * is retrieved, or the data type does not match, an error will + * be thrown. + */ +native set_gamerules_int(const class[], const member[], any:value, element = 0); + +/** + * Retrieves a float value from the gamerules object based off a class + * and member name. + * + * @param class Class name + * @param member Member name + * @param element Element to retrieve (starting from 0) if member is an array + * + * @return Float value + * @error If member is empty, no offset is found or an invalid offset + * is retrieved, or the data type does not match, an error will + * be thrown. + */ +native Float:get_gamerules_float(const class[], const member[], element = 0); + +/** + * Sets a float value to the gamerules object based off a class + * and member name. + * + * @param class Class name + * @param member Member name + * @param value Value to set + * @param element Element to set (starting from 0) if member is an array + * + * @noreturn + * @error If member is empty, no offset is found or an invalid offset + * is retrieved, or the data type does not match, an error will + * be thrown. + */ +native set_gamerules_float(const class[], const member[], Float:value, element = 0); + +/** + * Retrieves a vector from the gamerules object based off a class and member name. + * + * @param class Class name + * @param member Member name + * @param value Vector buffer to store data in + * @param element Element to retrieve (starting from 0) if member is an array + * + * @noreturn + * @error If member is empty, no offset is found or an invalid offset + * is retrieved, or the data type does not match, an error will + * be thrown. + */ +native get_gamerules_vector(const class[], const member[], Float:value[3], element = 0); + +/** + * Sets a vector to the gamerules object based off a class and member name. + * + * @param class Class name + * @param member Member name + * @param value Vector to set + * @param element Element to set (starting from 0) if member is an array + * + * @noreturn + * @error If member is empty, no offset is found or an invalid offset + * is retrieved, or the data type does not match, an error will + * be thrown. + */ +native set_gamerules_vector(const class[], const member[], Float:value[3], element = 0); + +/** + * Retrieves an entity index from the gamerules object based off a class + * and member name. + * + * @note This native is used to access the following (C++/engine) data types: + * classptr, entvars, edict and ehandle. + * + * @param class Class name + * @param member Member name + * @param element Element to retrieve (starting from 0) if member is an array + * + * @return Entity index if found, -1 otherwise + * @error If member is empty, no offset is found or an invalid offset + * is retrieved, or the data type does not match, an error will + * be thrown. + */ +native get_gamerules_entity(const class[], const member[], element = 0); + +/** + * Sets an entity index to the gamerules object based off a class + * and member name. + * + * @note This native is used to access the following (C++/engine) data types: + * classptr, entvars, edict and ehandle. + * @note Pass -1 as value to act as C++ NULL. + * + * @param class Class name + * @param member Member name + * @param value Entity index to set + * @param element Element to set (starting from 0) if member is an array + * + * @noreturn + * @error If member is empty, no offset is found or an invalid offset + * is retrieved, or the data type does not match, an error will + * be thrown. + */ +native set_gamerules_entity(const class[], const member[], value, element = 0); + +/** + * Retrieves a string from the gamerules object based off a class and member name. + * + * @note This native is used to access the following (C++/engine) data types: + * string, stringptr. + * + * @param class Class name + * @param member Member name + * @param value Buffer to store data in + * @param maxlen Maximum size of the buffer + * @param element Element to retrieve (starting from 0) if member is an array + * + * @return Number of cells written to buffer + * @error If member is empty, no offset is found or an invalid offset + * is retrieved, or the data type does not match, an error will + * be thrown. + */ +native get_gamerules_string(const class[], const member[], value[], maxlen, element = 0); + +/** + * Sets a string to the gamerules object based off a class and member name. + * + * @note This native is used to access the following (C++/engine) data types: + * string, stringptr. + * + * @param class Class name + * @param member Member name + * @param value String to set + * @param element Element to set (starting from 0) if member is an array + * + * @return Number of cells written to buffer + * @error If member is empty, no offset is found or an invalid offset + * is retrieved, or the data type does not match, an error will + * be thrown. + */ +native set_gamerules_string(const class[], const member[], const value[], element = 0); + /** * Retrieves the size of array of a class member. * From 02c1b20ed7631afff34d9438fb6347f1373b2fca Mon Sep 17 00:00:00 2001 From: Arkshine Date: Fri, 9 Oct 2015 11:32:06 +0200 Subject: [PATCH 07/12] Rename get_ent_data_size/info/basetype to be more generic --- modules/fakemeta/pdata_gc.cpp | 18 +++++++++++------- plugins/include/fakemeta.inc | 10 +++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/modules/fakemeta/pdata_gc.cpp b/modules/fakemeta/pdata_gc.cpp index 7089ff6d..ba25086e 100644 --- a/modules/fakemeta/pdata_gc.cpp +++ b/modules/fakemeta/pdata_gc.cpp @@ -739,18 +739,22 @@ static cell AMX_NATIVE_CALL set_gamerules_string(AMX *amx, cell *params) -// native get_ent_data_size(const class[], const member[]); -static cell AMX_NATIVE_CALL get_ent_data_size(AMX *amx, cell *params) +// native get_member_size(const class[], const member[]); +static cell AMX_NATIVE_CALL get_member_size(AMX *amx, cell *params) { + CHECK_GAMERULES(); + TypeDescription data; - GET_TYPE_DESCRIPTION(0, data, BaseFieldType::None, ALL); + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, ALL); return data.fieldSize; } -// native find_ent_data_info(const class[], const member[], &FieldType:type = FIELD_NONE, &arraysize = 0, &bool:unsigned = false); -static cell AMX_NATIVE_CALL find_ent_data_info(AMX *amx, cell *params) +// native find_member_info(const class[], const member[], &FieldType:type = FIELD_NONE, &arraysize = 0, &bool:unsigned = false); +static cell AMX_NATIVE_CALL find_member_info(AMX *amx, cell *params) { + CHECK_GAMERULES(); + TypeDescription data; GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, ALL); @@ -786,8 +790,8 @@ AMX_NATIVE_INFO pdata_gc_natives[] = { "get_gamerules_string", get_gamerules_string }, { "set_gamerules_string", set_gamerules_string }, - { "get_ent_data_size" , get_ent_data_size }, - { "find_ent_data_info" , find_ent_data_info }, + { "get_member_size" , get_member_size }, + { "find_member_info" , find_member_info }, { nullptr , nullptr } }; diff --git a/plugins/include/fakemeta.inc b/plugins/include/fakemeta.inc index a8183ceb..ce29dc8f 100755 --- a/plugins/include/fakemeta.inc +++ b/plugins/include/fakemeta.inc @@ -995,7 +995,7 @@ native set_gamerules_string(const class[], const member[], const value[], elemen * @error If either class or member is empty, no offset is found or an invalid * offset is retrieved, an error will be thrown. */ -native get_ent_data_size(const class[], const member[]); +native get_member_size(const class[], const member[]); /** * Finds an offset based off a class and member name. @@ -1008,9 +1008,9 @@ native get_ent_data_size(const class[], const member[]); * * @return Class member offset * @error If either class or member is empty, no offset is found or an invalid - * offset is retrieved, an error will be thrown. + * offset is retrieved, an error will be thrown. */ -native find_ent_data_info(const class[], const member[], &FieldType:type = FIELD_NONE, &arraysize = 0, &bool:unsigned = false); +native find_member_info(const class[], const member[], &FieldType:type = FIELD_NONE, &arraysize = 0, &bool:unsigned = false); /** * Returns the data field base type based off a specific field type. @@ -1025,9 +1025,9 @@ native find_ent_data_info(const class[], const member[], &FieldType:type = FIELD * * @return Base field type (BASEFIELD_* constants) */ -stock BaseFieldType:get_ent_data_basetype(FieldType:type, type_name[] = "", maxlen = 0) +stock BaseFieldType:get_field_basetype(FieldType:type, type_name[] = "", maxlen = 0) { - static baseFieldTypeNames[BaseFieldType][] = + static const baseFieldTypeNames[BaseFieldType][] = { "none", "integer", From c07b269c94c576de6c381e2c872ce28816a1e7ac Mon Sep 17 00:00:00 2001 From: Arkshine Date: Thu, 29 Oct 2015 11:28:16 +0100 Subject: [PATCH 08/12] Refactor 1 - Move shared code to its own file and reflect changes --- modules/fakemeta/msvc12/fakemeta.vcxproj | 1 + .../fakemeta/msvc12/fakemeta.vcxproj.filters | 3 + modules/fakemeta/pdata_gc.cpp | 329 +-------------- modules/fakemeta/pdata_shared.h | 375 ++++++++++++++++++ 4 files changed, 400 insertions(+), 308 deletions(-) create mode 100644 modules/fakemeta/pdata_shared.h diff --git a/modules/fakemeta/msvc12/fakemeta.vcxproj b/modules/fakemeta/msvc12/fakemeta.vcxproj index d2d7df5c..5acfc961 100644 --- a/modules/fakemeta/msvc12/fakemeta.vcxproj +++ b/modules/fakemeta/msvc12/fakemeta.vcxproj @@ -122,6 +122,7 @@ + diff --git a/modules/fakemeta/msvc12/fakemeta.vcxproj.filters b/modules/fakemeta/msvc12/fakemeta.vcxproj.filters index b48aead2..ebd2ff7d 100644 --- a/modules/fakemeta/msvc12/fakemeta.vcxproj.filters +++ b/modules/fakemeta/msvc12/fakemeta.vcxproj.filters @@ -118,6 +118,9 @@ Memtools + + Header Files + diff --git a/modules/fakemeta/pdata_gc.cpp b/modules/fakemeta/pdata_gc.cpp index ba25086e..832aa09d 100644 --- a/modules/fakemeta/pdata_gc.cpp +++ b/modules/fakemeta/pdata_gc.cpp @@ -12,69 +12,7 @@ // #include "fakemeta_amxx.h" -#include - -enum class BaseFieldType -{ - None, - Integer, - Float, - Vector, - Entity, - String, -}; - -static const char *BaseFieldTypeName[] = -{ - "none", - "integer", - "float", - "vector", - "entity", - "string", -}; - -static BaseFieldType GetBaseDataType(TypeDescription &data) -{ - switch (data.fieldType) - { - case FieldType::FIELD_INTEGER: - case FieldType::FIELD_STRINGINT: - case FieldType::FIELD_SHORT: - case FieldType::FIELD_CHARACTER: - case FieldType::FIELD_CLASS: - case FieldType::FIELD_STRUCTURE: - case FieldType::FIELD_POINTER: - case FieldType::FIELD_FUNCTION: - case FieldType::FIELD_BOOLEAN: - { - return BaseFieldType::Integer; - } - case FieldType::FIELD_FLOAT: - { - return BaseFieldType::Float; - } - case FieldType::FIELD_VECTOR: - { - return BaseFieldType::Vector; - } - case FieldType::FIELD_CLASSPTR: - case FieldType::FIELD_ENTVARS: - case FieldType::FIELD_EDICT: - case FieldType::FIELD_EHANDLE: - { - return BaseFieldType::Entity; - } - case FieldType::FIELD_STRINGPTR: - case FieldType::FIELD_STRING: - { - return BaseFieldType::String; - } - } - - return BaseFieldType::None; -} - +#include "pdata_shared.h" #define GET_TYPE_DESCRIPTION(position, data, baseType, list) \ GET_TYPE_DESCRIPTION_START(position, data, baseType) \ @@ -140,231 +78,6 @@ static BaseFieldType GetBaseDataType(TypeDescription &data) } -cell GetData(void *pObject, TypeDescription &data, int element) -{ - switch (data.fieldType) - { - case FieldType::FIELD_INTEGER: - case FieldType::FIELD_STRINGINT: - { - return get_pdata(pObject, data.fieldOffset, element); - } - case FieldType::FIELD_CLASS: - case FieldType::FIELD_STRUCTURE: - { - return get_pdata_direct(pObject, data.fieldOffset); - } - case FieldType::FIELD_POINTER: - case FieldType::FIELD_FUNCTION: - { - return reinterpret_cast(get_pdata(pObject, data.fieldOffset, element)); - } - case FieldType::FIELD_SHORT: - { - if (data.fieldUnsigned) - { - return get_pdata(pObject, data.fieldOffset, element); - } - else - { - return get_pdata(pObject, data.fieldOffset, element); - } - } - case FieldType::FIELD_CHARACTER: - { - if (data.fieldUnsigned) - { - return get_pdata(pObject, data.fieldOffset, element); - } - else - { - return get_pdata(pObject, data.fieldOffset, element); - } - } - case FieldType::FIELD_BOOLEAN: - { - return get_pdata(pObject, data.fieldOffset, element) ? 1 : 0; - } - } - - return 0; -} - -void SetData(void *pObject, TypeDescription &data, cell value, int element) -{ - switch (data.fieldType) - { - case FieldType::FIELD_INTEGER: - case FieldType::FIELD_STRINGINT: - { - set_pdata(pObject, data.fieldOffset, static_cast(value), element); - break; - } - case FieldType::FIELD_POINTER: - case FieldType::FIELD_FUNCTION: - { - set_pdata(pObject, data.fieldOffset, reinterpret_cast(value), element); - break; - } - case FieldType::FIELD_SHORT: - { - if (data.fieldUnsigned) - { - set_pdata(pObject, data.fieldOffset, static_cast(value), element); - } - else - { - set_pdata(pObject, data.fieldOffset, static_cast(value), element); - } - break; - } - case FieldType::FIELD_CHARACTER: - { - if (data.fieldUnsigned) - { - set_pdata(pObject, data.fieldOffset, static_cast(value), element); - } - else - { - set_pdata(pObject, data.fieldOffset, static_cast(value), element); - } - break; - } - case FieldType::FIELD_BOOLEAN: - { - set_pdata(pObject, data.fieldOffset, value != 0, element); - break; - } - } -} - -cell GetDataFloat(void *pObject, TypeDescription &data, int element) -{ - return amx_ftoc(get_pdata(pObject, data.fieldOffset, element)); -} - -void SetDataFloat(void *pObject, TypeDescription &data, float value, int element) -{ - set_pdata(pObject, data.fieldOffset, value, element); -} - -void GetDataVector(void *pObject, TypeDescription &data, cell *pVector, int element) -{ - auto vector = get_pdata(pObject, data.fieldOffset, element); - - pVector[0] = amx_ftoc(vector.x); - pVector[1] = amx_ftoc(vector.y); - pVector[2] = amx_ftoc(vector.z); -} - -void SetDataVector(void *pObject, TypeDescription &data, cell *pVector, int element) -{ - Vector vector(amx_ctof(pVector[0]), amx_ctof(pVector[1]), amx_ctof(pVector[2])); - - set_pdata(pObject, data.fieldOffset, vector, element); -} - -cell GetDataEntity(void *pObject, TypeDescription &data, int element) -{ - switch (data.fieldType) - { - case FieldType::FIELD_CLASSPTR: - { - return TypeConversion.cbase_to_id(get_pdata(pObject, data.fieldOffset, element)); - } - case FieldType::FIELD_ENTVARS: - { - return TypeConversion.entvars_to_id(get_pdata(pObject, data.fieldOffset, element)); - } - case FieldType::FIELD_EDICT: - { - return TypeConversion.edict_to_id(get_pdata(pObject, data.fieldOffset, element)); - } - case FieldType::FIELD_EHANDLE: - { - return TypeConversion.edict_to_id(get_pdata(pObject, data.fieldOffset, element).Get()); - } - } - - return 0; -} - -void SetDataEntity(void *pObject, TypeDescription &data, int value, int element) -{ - switch (data.fieldType) - { - case FieldType::FIELD_CLASSPTR: - { - set_pdata(pObject, data.fieldOffset, value != -1 ? TypeConversion.id_to_cbase(value) : nullptr, element); - break; - } - case FieldType::FIELD_ENTVARS: - { - set_pdata(pObject, data.fieldOffset, value != -1 ? TypeConversion.id_to_entvars(value) : nullptr, element); - break; - } - case FieldType::FIELD_EDICT: - { - set_pdata(pObject, data.fieldOffset, value != -1 ? TypeConversion.id_to_edict(value) : nullptr, element); - break; - } - case FieldType::FIELD_EHANDLE: - { - get_pdata(pObject, data.fieldOffset, element).Set(value != -1 ? TypeConversion.id_to_edict(value) : nullptr); - break; - } - } -} - -char* GetDataString(void *pObject, TypeDescription &data, int element) -{ - switch (data.fieldType) - { - case FieldType::FIELD_STRING: - { - return get_pdata_direct(pObject, data.fieldOffset, element, data.fieldSize); - } - case FieldType::FIELD_STRINGPTR: - { - return get_pdata(pObject, data.fieldOffset, element); - } - } - - return nullptr; -} - -cell SetDataString(void *pObject, TypeDescription &data, const char *value, int maxlen, int element) -{ - switch (data.fieldType) - { - case FieldType::FIELD_STRING: - { - auto buffer = get_pdata_direct(pObject, data.fieldOffset); - return strncopy(buffer, value, ke::Min(maxlen + 1, data.fieldSize)); - } - case FieldType::FIELD_STRINGPTR: - { - auto buffer = get_pdata(pObject, data.fieldOffset, element); - - if (!buffer || maxlen > static_cast(strlen(buffer))) - { - if (buffer) - { - free(buffer); - } - - buffer = reinterpret_cast(malloc(maxlen + 1)); - set_pdata(pObject, data.fieldOffset, buffer, element); - } - - return strncopy(buffer, value, maxlen + 1); - } - } - - return 0; -} - - // native any:get_ent_data(entity, const class[], const member[], element = 0); static cell AMX_NATIVE_CALL get_ent_data(AMX *amx, cell *params) { @@ -377,7 +90,7 @@ static cell AMX_NATIVE_CALL get_ent_data(AMX *amx, cell *params) int element = params[4]; CHECK_ELEMENT(element); - return GetData(TypeConversion.id_to_edict(entity)->pvPrivateData, data, element); + return PvData::GetInt(entity, data, element); } // native set_ent_data(entity, const class[], const member[], any:value, element = 0); @@ -398,7 +111,7 @@ static cell AMX_NATIVE_CALL set_ent_data(AMX *amx, cell *params) return 0; } - SetData(TypeConversion.id_to_edict(entity)->pvPrivateData, data, params[4], element); + PvData::SetInt(entity, data, params[4], element); return 1; } @@ -416,7 +129,7 @@ static cell AMX_NATIVE_CALL get_ent_data_float(AMX *amx, cell *params) int element = params[4]; CHECK_ELEMENT(element); - return GetDataFloat(TypeConversion.id_to_edict(entity)->pvPrivateData, data, element); + return PvData::GetFloat(entity, data, element); } // native set_ent_data_float(entity, const classname[], const member[], Float:value, element = 0); @@ -431,7 +144,7 @@ static cell AMX_NATIVE_CALL set_ent_data_float(AMX *amx, cell *params) int element = params[5]; CHECK_ELEMENT(element); - SetDataFloat(TypeConversion.id_to_edict(entity)->pvPrivateData, data, amx_ctof(params[4]), element); + PvData::SetFloat(entity, data, amx_ctof(params[4]), element); return 1; } @@ -449,7 +162,7 @@ static cell AMX_NATIVE_CALL get_ent_data_vector(AMX *amx, cell *params) int element = params[5]; CHECK_ELEMENT(element); - GetDataVector(TypeConversion.id_to_edict(entity)->pvPrivateData, data, MF_GetAmxAddr(amx, params[4]), element); + PvData::GetVector(entity, data, MF_GetAmxAddr(amx, params[4]), element); return 1; } @@ -466,7 +179,7 @@ static cell AMX_NATIVE_CALL set_ent_data_vector(AMX *amx, cell *params) int element = params[5]; CHECK_ELEMENT(element); - SetDataVector(TypeConversion.id_to_edict(entity)->pvPrivateData, data, MF_GetAmxAddr(amx, params[4]), element); + PvData::SetVector(entity, data, MF_GetAmxAddr(amx, params[4]), element); return 1; } @@ -484,7 +197,7 @@ static cell AMX_NATIVE_CALL get_ent_data_entity(AMX *amx, cell *params) int element = params[4]; CHECK_ELEMENT(element); - return GetDataEntity(TypeConversion.id_to_edict(entity)->pvPrivateData, data, element); + return PvData::GetEntity(entity, data, element); } // native set_ent_data_entity(entity, const class[], const member[], value, element = 0); @@ -506,7 +219,7 @@ static cell AMX_NATIVE_CALL set_ent_data_entity(AMX *amx, cell *params) int element = params[5]; CHECK_ELEMENT(element); - SetDataEntity(TypeConversion.id_to_edict(entity)->pvPrivateData, data, value, element); + PvData::SetEntity(entity, data, value, element); return 1; } @@ -527,7 +240,7 @@ static cell AMX_NATIVE_CALL get_ent_data_string(AMX *amx, cell *params) auto buffer = params[4]; auto maxlen = params[5]; - auto string = GetDataString(TypeConversion.id_to_edict(entity)->pvPrivateData, data, element); + auto string = PvData::GetString(entity, data, element); if (data.fieldSize) { @@ -552,7 +265,7 @@ static cell AMX_NATIVE_CALL set_ent_data_string(AMX *amx, cell *params) int length; const char *value = MF_GetAmxString(amx, params[4], 0, &length); - return SetDataString(TypeConversion.id_to_edict(entity)->pvPrivateData, data, value, length, element); + return PvData::SetString(entity, data, value, length, element); } @@ -568,7 +281,7 @@ static cell AMX_NATIVE_CALL get_gamerules_int(AMX *amx, cell *params) int element = params[3]; CHECK_ELEMENT(element); - return GetData(GameRulesAddress, data, element); + return PvData::GetInt(GameRulesAddress, data, element); } // native set_gamerules_int(const class[], const member[], any:value, element = 0); @@ -588,7 +301,7 @@ static cell AMX_NATIVE_CALL set_gamerules_int(AMX *amx, cell *params) return 0; } - SetData(GameRulesAddress, data, params[3], element); + PvData::SetInt(GameRulesAddress, data, params[3], element); return 0; } @@ -605,7 +318,7 @@ static cell AMX_NATIVE_CALL get_gamerules_float(AMX *amx, cell *params) int element = params[3]; CHECK_ELEMENT(element); - return GetDataFloat(GameRulesAddress, data, element); + return PvData::GetFloat(GameRulesAddress, data, element); } // native set_gamerules_float(const class[], const member[], Float:value, element = 0); @@ -619,7 +332,7 @@ static cell AMX_NATIVE_CALL set_gamerules_float(AMX *amx, cell *params) int element = params[4]; CHECK_ELEMENT(element); - SetDataFloat(GameRulesAddress, data, amx_ctof(params[3]), element); + PvData::SetFloat(GameRulesAddress, data, amx_ctof(params[3]), element); return 1; } @@ -636,7 +349,7 @@ static cell AMX_NATIVE_CALL get_gamerules_vector(AMX *amx, cell *params) int element = params[4]; CHECK_ELEMENT(element); - GetDataVector(GameRulesAddress, data, MF_GetAmxAddr(amx, params[3]), element); + PvData::GetVector(GameRulesAddress, data, MF_GetAmxAddr(amx, params[3]), element); return 1; } @@ -652,7 +365,7 @@ static cell AMX_NATIVE_CALL set_gamerules_vector(AMX *amx, cell *params) int element = params[4]; CHECK_ELEMENT(element); - GetDataVector(GameRulesAddress, data, MF_GetAmxAddr(amx, params[3]), element); + PvData::GetVector(GameRulesAddress, data, MF_GetAmxAddr(amx, params[3]), element); return 1; } @@ -669,7 +382,7 @@ static cell AMX_NATIVE_CALL get_gamerules_entity(AMX *amx, cell *params) int element = params[3]; CHECK_ELEMENT(element); - return GetDataEntity(GameRulesAddress, data, element); + return PvData::GetEntity(GameRulesAddress, data, element); } // native set_gamerules_entity(const class[], const member[], value, element = 0); @@ -690,7 +403,7 @@ static cell AMX_NATIVE_CALL set_gamerules_entity(AMX *amx, cell *params) int element = params[4]; CHECK_ELEMENT(element); - SetDataEntity(GameRulesAddress, data, params[3], element); + PvData::SetEntity(GameRulesAddress, data, params[3], element); return 0; } @@ -710,7 +423,7 @@ static cell AMX_NATIVE_CALL get_gamerules_string(AMX *amx, cell *params) auto buffer = params[3]; auto maxlen = params[4]; - auto string = GetDataString(GameRulesAddress, data, element); + auto string = PvData::GetString(GameRulesAddress, data, element); if (data.fieldSize) { @@ -734,7 +447,7 @@ static cell AMX_NATIVE_CALL set_gamerules_string(AMX *amx, cell *params) int length; const char *value = MF_GetAmxString(amx, params[3], 0, &length); - return SetDataString(GameRulesAddress, data, value, length, element); + return PvData::SetString(GameRulesAddress, data, value, length, element); } diff --git a/modules/fakemeta/pdata_shared.h b/modules/fakemeta/pdata_shared.h new file mode 100644 index 00000000..983cc9e1 --- /dev/null +++ b/modules/fakemeta/pdata_shared.h @@ -0,0 +1,375 @@ +// +// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO"). +// Copyright (C) The AMX Mod X Development Team. +// +// This software is licensed under the GNU General Public License, version 3 or higher. +// Additional exceptions apply. For full license details, see LICENSE.txt or visit: +// https://alliedmods.net/amxmodx-license + +#ifndef _PDATA_SHARED_H_ +#define _PDATA_SHARED_H_ + +#include +#include +#include +#include + +extern HLTypeConversion TypeConversion; + +enum class BaseFieldType +{ + None, + Integer, + Float, + Vector, + Entity, + String, +}; + +class PvData +{ +public: + + static cell GetInt(int index, TypeDescription &data, int element) + { + return GetInt(TypeConversion.id_to_edict(index)->pvPrivateData, data, element); + } + + static cell GetInt(void *pObject, TypeDescription &data, int element) + { + switch (data.fieldType) + { + case FieldType::FIELD_INTEGER: + case FieldType::FIELD_STRINGINT: + { + return get_pdata(pObject, data.fieldOffset, element); + } + case FieldType::FIELD_CLASS: + case FieldType::FIELD_STRUCTURE: + { + return get_pdata_direct(pObject, data.fieldOffset); + } + case FieldType::FIELD_POINTER: + case FieldType::FIELD_FUNCTION: + { + return reinterpret_cast(get_pdata(pObject, data.fieldOffset, element)); + } + case FieldType::FIELD_SHORT: + { + if (data.fieldUnsigned) + { + return get_pdata(pObject, data.fieldOffset, element); + } + else + { + return get_pdata(pObject, data.fieldOffset, element); + } + } + case FieldType::FIELD_CHARACTER: + { + if (data.fieldUnsigned) + { + return get_pdata(pObject, data.fieldOffset, element); + } + else + { + return get_pdata(pObject, data.fieldOffset, element); + } + } + case FieldType::FIELD_BOOLEAN: + { + return get_pdata(pObject, data.fieldOffset, element) ? 1 : 0; + } + } + + return 0; + } + + + static void SetInt(int index, TypeDescription &data, cell value, int element) + { + SetInt(TypeConversion.id_to_edict(index)->pvPrivateData, data, value, element); + } + + static void SetInt(void *pObject, TypeDescription &data, cell value, int element) + { + switch (data.fieldType) + { + case FieldType::FIELD_INTEGER: + case FieldType::FIELD_STRINGINT: + { + set_pdata(pObject, data.fieldOffset, static_cast(value), element); + break; + } + case FieldType::FIELD_POINTER: + case FieldType::FIELD_FUNCTION: + { + set_pdata(pObject, data.fieldOffset, reinterpret_cast(value), element); + break; + } + case FieldType::FIELD_SHORT: + { + if (data.fieldUnsigned) + { + set_pdata(pObject, data.fieldOffset, static_cast(value), element); + } + else + { + set_pdata(pObject, data.fieldOffset, static_cast(value), element); + } + break; + } + case FieldType::FIELD_CHARACTER: + { + if (data.fieldUnsigned) + { + set_pdata(pObject, data.fieldOffset, static_cast(value), element); + } + else + { + set_pdata(pObject, data.fieldOffset, static_cast(value), element); + } + break; + } + case FieldType::FIELD_BOOLEAN: + { + set_pdata(pObject, data.fieldOffset, value != 0, element); + break; + } + } + } + + + static cell GetFloat(int index, TypeDescription &data, int element) + { + return GetFloat(TypeConversion.id_to_edict(index)->pvPrivateData, data, element); + } + + static cell GetFloat(void *pObject, TypeDescription &data, int element) + { + return amx_ftoc(get_pdata(pObject, data.fieldOffset, element)); + } + + + static void SetFloat(int index, TypeDescription &data, float value, int element) + { + SetFloat(TypeConversion.id_to_edict(index)->pvPrivateData, data, value, element); + } + + static void SetFloat(void *pObject, TypeDescription &data, float value, int element) + { + set_pdata(pObject, data.fieldOffset, value, element); + } + + + static void GetVector(int index, TypeDescription &data, cell *pVector, int element) + { + return GetVector(TypeConversion.id_to_edict(index)->pvPrivateData, data, pVector, element); + } + + static void GetVector(void *pObject, TypeDescription &data, cell *pVector, int element) + { + auto vector = get_pdata(pObject, data.fieldOffset, element); + + pVector[0] = amx_ftoc(vector.x); + pVector[1] = amx_ftoc(vector.y); + pVector[2] = amx_ftoc(vector.z); + } + + + static void SetVector(int index, TypeDescription &data, cell *pVector, int element) + { + SetVector(TypeConversion.id_to_edict(index)->pvPrivateData, data, pVector, element); + } + + static void SetVector(void *pObject, TypeDescription &data, cell *pVector, int element) + { + Vector vector(amx_ctof(pVector[0]), amx_ctof(pVector[1]), amx_ctof(pVector[2])); + + set_pdata(pObject, data.fieldOffset, vector, element); + } + + + static cell GetEntity(int index, TypeDescription &data, int element) + { + return GetEntity(TypeConversion.id_to_edict(index)->pvPrivateData, data, element); + } + + static cell GetEntity(void *pObject, TypeDescription &data, int element) + { + switch (data.fieldType) + { + case FieldType::FIELD_CLASSPTR: + { + return TypeConversion.cbase_to_id(get_pdata(pObject, data.fieldOffset, element)); + } + case FieldType::FIELD_ENTVARS: + { + return TypeConversion.entvars_to_id(get_pdata(pObject, data.fieldOffset, element)); + } + case FieldType::FIELD_EDICT: + { + return TypeConversion.edict_to_id(get_pdata(pObject, data.fieldOffset, element)); + } + case FieldType::FIELD_EHANDLE: + { + return TypeConversion.edict_to_id(get_pdata(pObject, data.fieldOffset, element).Get()); + } + } + + return 0; + } + + + static void SetEntity(int index, TypeDescription &data, int value, int element) + { + SetEntity(TypeConversion.id_to_edict(index)->pvPrivateData, data, value, element); + } + + static void SetEntity(void *pObject, TypeDescription &data, int value, int element) + { + switch (data.fieldType) + { + case FieldType::FIELD_CLASSPTR: + { + set_pdata(pObject, data.fieldOffset, value != -1 ? TypeConversion.id_to_cbase(value) : nullptr, element); + break; + } + case FieldType::FIELD_ENTVARS: + { + set_pdata(pObject, data.fieldOffset, value != -1 ? TypeConversion.id_to_entvars(value) : nullptr, element); + break; + } + case FieldType::FIELD_EDICT: + { + set_pdata(pObject, data.fieldOffset, value != -1 ? TypeConversion.id_to_edict(value) : nullptr, element); + break; + } + case FieldType::FIELD_EHANDLE: + { + get_pdata(pObject, data.fieldOffset, element).Set(value != -1 ? TypeConversion.id_to_edict(value) : nullptr); + break; + } + } + } + + + static char* GetString(int index, TypeDescription &data, int element) + { + return GetString(TypeConversion.id_to_edict(index)->pvPrivateData, data, element); + } + + static char* GetString(void *pObject, TypeDescription &data, int element) + { + switch (data.fieldType) + { + case FieldType::FIELD_STRING: + { + return get_pdata_direct(pObject, data.fieldOffset, element, data.fieldSize); + } + case FieldType::FIELD_STRINGPTR: + { + return get_pdata(pObject, data.fieldOffset, element); + } + } + + return nullptr; + } + + + static cell SetString(int index, TypeDescription &data, const char *value, int maxlen, int element) + { + return SetString(TypeConversion.id_to_edict(index)->pvPrivateData, data, value, maxlen, element); + } + + static cell SetString(void *pObject, TypeDescription &data, const char *value, int maxlen, int element) + { + switch (data.fieldType) + { + case FieldType::FIELD_STRING: + { + auto buffer = get_pdata_direct(pObject, data.fieldOffset); + return strncopy(buffer, value, ke::Min(maxlen + 1, data.fieldSize)); + } + case FieldType::FIELD_STRINGPTR: + { + auto buffer = get_pdata(pObject, data.fieldOffset, element); + + if (!buffer || maxlen > static_cast(strlen(buffer))) + { + if (buffer) + { + free(buffer); + } + + buffer = reinterpret_cast(malloc(maxlen + 1)); + set_pdata(pObject, data.fieldOffset, buffer, element); + } + + return strncopy(buffer, value, maxlen + 1); + } + } + + return 0; + } + +public: + + static BaseFieldType GetBaseDataType(TypeDescription &data) + { + switch (data.fieldType) + { + case FieldType::FIELD_INTEGER: + case FieldType::FIELD_STRINGINT: + case FieldType::FIELD_SHORT: + case FieldType::FIELD_CHARACTER: + case FieldType::FIELD_CLASS: + case FieldType::FIELD_STRUCTURE: + case FieldType::FIELD_POINTER: + case FieldType::FIELD_FUNCTION: + case FieldType::FIELD_BOOLEAN: + { + return BaseFieldType::Integer; + } + case FieldType::FIELD_FLOAT: + { + return BaseFieldType::Float; + } + case FieldType::FIELD_VECTOR: + { + return BaseFieldType::Vector; + } + case FieldType::FIELD_CLASSPTR: + case FieldType::FIELD_ENTVARS: + case FieldType::FIELD_EDICT: + case FieldType::FIELD_EHANDLE: + { + return BaseFieldType::Entity; + } + case FieldType::FIELD_STRINGPTR: + case FieldType::FIELD_STRING: + { + return BaseFieldType::String; + } + } + + return BaseFieldType::None; + } + + static const char* GetBaseTypeName(BaseFieldType baseType) + { + static const char *BaseFieldTypeName[] = + { + "none", + "integer", + "float", + "vector", + "entity", + "string", + }; + + return BaseFieldTypeName[static_cast(baseType)]; + } +}; + +#endif // _PDATA_SHARED_H_ From dc6f171f209993d153f9b09baebd26ff631a0ac9 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Thu, 29 Oct 2015 11:55:25 +0100 Subject: [PATCH 09/12] Refactor 2 - Duplicate get_member_* for each set of natives for consistency --- modules/fakemeta/pdata_gc.cpp | 46 ++++++++++++++++++++++++++--------- plugins/include/fakemeta.inc | 36 ++++++++++++++++++++++++--- 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/modules/fakemeta/pdata_gc.cpp b/modules/fakemeta/pdata_gc.cpp index 832aa09d..bacbfdfe 100644 --- a/modules/fakemeta/pdata_gc.cpp +++ b/modules/fakemeta/pdata_gc.cpp @@ -269,6 +269,30 @@ static cell AMX_NATIVE_CALL set_ent_data_string(AMX *amx, cell *params) } +// native get_ent_data_size(const class[], const member[]); +static cell AMX_NATIVE_CALL get_ent_data_size(AMX *amx, cell *params) +{ + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, ENTITY); + + return data.fieldSize; +} + +// native find_ent_data_info(const class[], const member[], &FieldType:type = FIELD_NONE, &arraysize = 0, &bool:unsigned = false); +static cell AMX_NATIVE_CALL find_ent_data_info(AMX *amx, cell *params) +{ + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, ENTITY); + + *MF_GetAmxAddr(amx, params[3]) = static_cast(data.fieldType); + *MF_GetAmxAddr(amx, params[4]) = ke::Max(0, data.fieldSize); + *MF_GetAmxAddr(amx, params[5]) = data.fieldUnsigned != 0; + + return data.fieldOffset; +} + + + // native any:get_gamerules_int(const class[], const member[], element = 0); static cell AMX_NATIVE_CALL get_gamerules_int(AMX *amx, cell *params) @@ -451,25 +475,24 @@ static cell AMX_NATIVE_CALL set_gamerules_string(AMX *amx, cell *params) } - -// native get_member_size(const class[], const member[]); -static cell AMX_NATIVE_CALL get_member_size(AMX *amx, cell *params) +// native get_gamerules_size(const class[], const member[]); +static cell AMX_NATIVE_CALL get_gamerules_size(AMX *amx, cell *params) { CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, ALL); + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, GAMERULES); return data.fieldSize; } -// native find_member_info(const class[], const member[], &FieldType:type = FIELD_NONE, &arraysize = 0, &bool:unsigned = false); -static cell AMX_NATIVE_CALL find_member_info(AMX *amx, cell *params) +// native find_gamerules_info(const class[], const member[], &FieldType:type = FIELD_NONE, &arraysize = 0, &bool:unsigned = false); +static cell AMX_NATIVE_CALL find_gamerules_info(AMX *amx, cell *params) { CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, ALL); + GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, GAMERULES); *MF_GetAmxAddr(amx, params[3]) = static_cast(data.fieldType); *MF_GetAmxAddr(amx, params[4]) = ke::Max(0, data.fieldSize); @@ -491,6 +514,8 @@ AMX_NATIVE_INFO pdata_gc_natives[] = { "set_ent_data_entity" , set_ent_data_entity }, { "get_ent_data_string" , get_ent_data_string }, { "set_ent_data_string" , set_ent_data_string }, + { "get_ent_data_size" , get_ent_data_size }, + { "find_ent_data_info" , find_ent_data_info }, { "get_gamerules_int" , get_gamerules_int }, { "set_gamerules_int" , set_gamerules_int }, @@ -502,9 +527,8 @@ AMX_NATIVE_INFO pdata_gc_natives[] = { "set_gamerules_entity", set_gamerules_entity }, { "get_gamerules_string", get_gamerules_string }, { "set_gamerules_string", set_gamerules_string }, + { "get_gamerules_size" , get_gamerules_size }, + { "find_gamerules_info" , find_gamerules_info }, - { "get_member_size" , get_member_size }, - { "find_member_info" , find_member_info }, - - { nullptr , nullptr } + { nullptr , nullptr } }; diff --git a/plugins/include/fakemeta.inc b/plugins/include/fakemeta.inc index ce29dc8f..8c04f8e1 100755 --- a/plugins/include/fakemeta.inc +++ b/plugins/include/fakemeta.inc @@ -808,6 +808,34 @@ native get_ent_data_string(entity, const class[], const member[], value[], maxle */ native set_ent_data_string(entity, const class[], const member[], const value[], element = 0); +/** + * Retrieves the size of array of n entity class member. + * + * @param class Class name + * @param member Member name + * + * @return Size of array (in elements), otherwise 1 if member is not an array + * @error If either class or member is empty, no offset is found or an invalid + * offset is retrieved, an error will be thrown. + */ +native get_ent_data_size(const class[], const member[]); + +/** + * Finds a offset based off an entity class and member name. + * + * @param class Class name + * @param member Member name + * @param type Optional variable to store member type in (FIELD_* constants) + * @param arraysize Optional variable to store array size in, if member is an array + * @param unsigned Optional variable to store whether member is unsigned (short and char types only) + * + * @return Class member offset + * @error If either class or member is empty, no offset is found or an invalid + * offset is retrieved, an error will be thrown. + */ +native find_ent_data_info(const class[], const member[], &FieldType:type = FIELD_NONE, &arraysize = 0, &bool:unsigned = false); + + /** * Retrieves an integer value from the gamerules object based off a class * and member name. @@ -986,7 +1014,7 @@ native get_gamerules_string(const class[], const member[], value[], maxlen, elem native set_gamerules_string(const class[], const member[], const value[], element = 0); /** - * Retrieves the size of array of a class member. + * Retrieves the size of array of a gamerules class member. * * @param class Class name * @param member Member name @@ -995,10 +1023,10 @@ native set_gamerules_string(const class[], const member[], const value[], elemen * @error If either class or member is empty, no offset is found or an invalid * offset is retrieved, an error will be thrown. */ -native get_member_size(const class[], const member[]); +native get_gamerules_size(const class[], const member[]); /** - * Finds an offset based off a class and member name. + * Finds a gamerules offset based off a class and member name. * * @param class Class name * @param member Member name @@ -1010,7 +1038,7 @@ native get_member_size(const class[], const member[]); * @error If either class or member is empty, no offset is found or an invalid * offset is retrieved, an error will be thrown. */ -native find_member_info(const class[], const member[], &FieldType:type = FIELD_NONE, &arraysize = 0, &bool:unsigned = false); +native find_gamerules_info(const class[], const member[], &FieldType:type = FIELD_NONE, &arraysize = 0, &bool:unsigned = false); /** * Returns the data field base type based off a specific field type. From 1032fbdbd05dca15f87d51394d0c9a2ccea2ecf9 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Thu, 29 Oct 2015 12:12:26 +0100 Subject: [PATCH 10/12] Refactor 3 - Simplify macros and move them to shared file as well --- modules/fakemeta/pdata_gc.cpp | 144 ++++++++++---------------------- modules/fakemeta/pdata_shared.h | 37 ++++++++ 2 files changed, 81 insertions(+), 100 deletions(-) diff --git a/modules/fakemeta/pdata_gc.cpp b/modules/fakemeta/pdata_gc.cpp index bacbfdfe..3c5942bf 100644 --- a/modules/fakemeta/pdata_gc.cpp +++ b/modules/fakemeta/pdata_gc.cpp @@ -14,62 +14,6 @@ #include "fakemeta_amxx.h" #include "pdata_shared.h" -#define GET_TYPE_DESCRIPTION(position, data, baseType, list) \ - GET_TYPE_DESCRIPTION_START(position, data, baseType) \ - CHECK_##list##_OFFSET(className, memberName, data) \ - CHECK_ERROR(className, memberName) \ - GET_TYPE_DESCRIPTION_END(memberName, data, baseType) - -#define GET_TYPE_DESCRIPTION_START(position, data, baseType) \ - int classLength, memberLength; \ - const char *className = MF_GetAmxString(amx, params[position], 0, &classLength); \ - const char *memberName = MF_GetAmxString(amx, params[position + 1], 1, &memberLength); \ - if (!classLength || !memberLength) \ - { \ - MF_LogError(amx, AMX_ERR_NATIVE, "Either class (\"%s\") or member (\"%s\") is empty", className, memberName); \ - return 0; \ - } - -#define CHECK_ENTITY_OFFSET(className, memberName, data) \ - else if (!CommonConfig->GetOffsetByClass(className, memberName, &data)) - -#define CHECK_GAMERULES_OFFSET(className, memberName, data) \ - else if (!GamerulesConfig->GetOffsetByClass(className, memberName, &data)) - -#define CHECK_ALL_OFFSET(className, memberName, data) \ - else if (!CommonConfig->GetOffsetByClass(className, memberName, &data) && \ - !GamerulesConfig->GetOffsetByClass(className, memberName, &data)) - -#define CHECK_ERROR(className, memberName) \ - { \ - MF_LogError(amx, AMX_ERR_NATIVE, "Could not find class \"%s\" and/or member \"%s\" in gamedata", className, memberName); \ - return 0; \ - } - -#define GET_TYPE_DESCRIPTION_END(memberName, data, baseType) \ - else if (data.fieldOffset < 0) \ - { \ - MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset %d retrieved from \"%s\" member", data.fieldOffset, memberName); \ - return 0; \ - } \ - else if (baseType > BaseFieldType::None && baseType != GetBaseDataType(data)) \ - { \ - MF_LogError(amx, AMX_ERR_NATIVE, "Data field is not %s-based", BaseFieldTypeName[static_cast(baseType)]); \ - return 0; \ - } - -#define CHECK_ELEMENT(element) \ - if (element < 0 || (element > 0 && element >= data.fieldSize)) \ - { \ - MF_LogError(amx, AMX_ERR_NATIVE, "Invalid element index %d, value must be between 0 and %d", element, data.fieldSize); \ - return 0; \ - } \ - else if (element > 0 && !data.fieldSize) \ - { \ - MF_LogError(amx, AMX_ERR_NATIVE, "Member \"%s\" is not an array. Element %d is invalid.", memberName, element);\ - return 0; \ - } - #define CHECK_GAMERULES() \ if (!GameRulesAddress) \ { \ @@ -85,10 +29,10 @@ static cell AMX_NATIVE_CALL get_ent_data(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Integer, ENTITY); + GET_TYPE_DESCRIPTION(2, data, CommonConfig); int element = params[4]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Integer); return PvData::GetInt(entity, data, element); } @@ -100,10 +44,10 @@ static cell AMX_NATIVE_CALL set_ent_data(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Integer, ENTITY); + GET_TYPE_DESCRIPTION(2, data, CommonConfig); int element = params[5]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Integer); if (data.fieldType == FieldType::FIELD_STRUCTURE || data.fieldType == FieldType::FIELD_CLASS) { @@ -124,10 +68,10 @@ static cell AMX_NATIVE_CALL get_ent_data_float(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Float, ENTITY); + GET_TYPE_DESCRIPTION(2, data, CommonConfig); int element = params[4]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Float); return PvData::GetFloat(entity, data, element); } @@ -139,10 +83,10 @@ static cell AMX_NATIVE_CALL set_ent_data_float(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Float, ENTITY); + GET_TYPE_DESCRIPTION(2, data, CommonConfig); int element = params[5]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Float); PvData::SetFloat(entity, data, amx_ctof(params[4]), element); @@ -157,10 +101,10 @@ static cell AMX_NATIVE_CALL get_ent_data_vector(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Vector, ENTITY); + GET_TYPE_DESCRIPTION(2, data, CommonConfig); int element = params[5]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Vector); PvData::GetVector(entity, data, MF_GetAmxAddr(amx, params[4]), element); @@ -174,10 +118,10 @@ static cell AMX_NATIVE_CALL set_ent_data_vector(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Vector, ENTITY); + GET_TYPE_DESCRIPTION(2, data, CommonConfig); int element = params[5]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Vector); PvData::SetVector(entity, data, MF_GetAmxAddr(amx, params[4]), element); @@ -192,10 +136,10 @@ static cell AMX_NATIVE_CALL get_ent_data_entity(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Entity, ENTITY); + GET_TYPE_DESCRIPTION(2, data, CommonConfig); int element = params[4]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Entity); return PvData::GetEntity(entity, data, element); } @@ -214,10 +158,10 @@ static cell AMX_NATIVE_CALL set_ent_data_entity(AMX *amx, cell *params) } TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::Entity, ENTITY); + GET_TYPE_DESCRIPTION(2, data, CommonConfig); int element = params[5]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Entity); PvData::SetEntity(entity, data, value, element); @@ -232,10 +176,10 @@ static cell AMX_NATIVE_CALL get_ent_data_string(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::String, ENTITY); + GET_TYPE_DESCRIPTION(2, data, CommonConfig); int element = params[6]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::String); auto buffer = params[4]; auto maxlen = params[5]; @@ -257,10 +201,10 @@ static cell AMX_NATIVE_CALL set_ent_data_string(AMX *amx, cell *params) CHECK_ENTITY(entity); TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, BaseFieldType::String, ENTITY); + GET_TYPE_DESCRIPTION(2, data, CommonConfig); int element = params[5]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::String); int length; const char *value = MF_GetAmxString(amx, params[4], 0, &length); @@ -273,7 +217,7 @@ static cell AMX_NATIVE_CALL set_ent_data_string(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_ent_data_size(AMX *amx, cell *params) { TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, ENTITY); + GET_TYPE_DESCRIPTION(1, data, CommonConfig); return data.fieldSize; } @@ -282,7 +226,7 @@ static cell AMX_NATIVE_CALL get_ent_data_size(AMX *amx, cell *params) static cell AMX_NATIVE_CALL find_ent_data_info(AMX *amx, cell *params) { TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, ENTITY); + GET_TYPE_DESCRIPTION(1, data, CommonConfig); *MF_GetAmxAddr(amx, params[3]) = static_cast(data.fieldType); *MF_GetAmxAddr(amx, params[4]) = ke::Max(0, data.fieldSize); @@ -300,10 +244,10 @@ static cell AMX_NATIVE_CALL get_gamerules_int(AMX *amx, cell *params) CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Integer, GAMERULES); + GET_TYPE_DESCRIPTION(1, data, GamerulesConfig); int element = params[3]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Integer); return PvData::GetInt(GameRulesAddress, data, element); } @@ -314,10 +258,10 @@ static cell AMX_NATIVE_CALL set_gamerules_int(AMX *amx, cell *params) CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Integer, GAMERULES); + GET_TYPE_DESCRIPTION(1, data, GamerulesConfig); int element = params[4]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Integer); if (data.fieldType == FieldType::FIELD_STRUCTURE || data.fieldType == FieldType::FIELD_CLASS) { @@ -337,10 +281,10 @@ static cell AMX_NATIVE_CALL get_gamerules_float(AMX *amx, cell *params) CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Float, GAMERULES); + GET_TYPE_DESCRIPTION(1, data, GamerulesConfig); int element = params[3]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Float); return PvData::GetFloat(GameRulesAddress, data, element); } @@ -351,10 +295,10 @@ static cell AMX_NATIVE_CALL set_gamerules_float(AMX *amx, cell *params) CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Float, GAMERULES); + GET_TYPE_DESCRIPTION(1, data, GamerulesConfig); int element = params[4]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Float); PvData::SetFloat(GameRulesAddress, data, amx_ctof(params[3]), element); @@ -368,10 +312,10 @@ static cell AMX_NATIVE_CALL get_gamerules_vector(AMX *amx, cell *params) CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Vector, GAMERULES); + GET_TYPE_DESCRIPTION(1, data, GamerulesConfig); int element = params[4]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Vector); PvData::GetVector(GameRulesAddress, data, MF_GetAmxAddr(amx, params[3]), element); @@ -384,10 +328,10 @@ static cell AMX_NATIVE_CALL set_gamerules_vector(AMX *amx, cell *params) CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Vector, GAMERULES); + GET_TYPE_DESCRIPTION(1, data, GamerulesConfig); int element = params[4]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Vector); PvData::GetVector(GameRulesAddress, data, MF_GetAmxAddr(amx, params[3]), element); @@ -401,10 +345,10 @@ static cell AMX_NATIVE_CALL get_gamerules_entity(AMX *amx, cell *params) CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Entity, GAMERULES); + GET_TYPE_DESCRIPTION(1, data, GamerulesConfig); int element = params[3]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Entity); return PvData::GetEntity(GameRulesAddress, data, element); } @@ -422,10 +366,10 @@ static cell AMX_NATIVE_CALL set_gamerules_entity(AMX *amx, cell *params) } TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Entity, GAMERULES); + GET_TYPE_DESCRIPTION(1, data, GamerulesConfig); int element = params[4]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::Entity); PvData::SetEntity(GameRulesAddress, data, params[3], element); @@ -439,10 +383,10 @@ static cell AMX_NATIVE_CALL get_gamerules_string(AMX *amx, cell *params) CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::String, GAMERULES); + GET_TYPE_DESCRIPTION(1, data, GamerulesConfig); int element = params[5]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::String); auto buffer = params[3]; auto maxlen = params[4]; @@ -463,10 +407,10 @@ static cell AMX_NATIVE_CALL set_gamerules_string(AMX *amx, cell *params) CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::String, GAMERULES); + GET_TYPE_DESCRIPTION(1, data, GamerulesConfig); int element = params[4]; - CHECK_ELEMENT(element); + CHECK_DATA(data, element, BaseFieldType::String); int length; const char *value = MF_GetAmxString(amx, params[3], 0, &length); @@ -481,7 +425,7 @@ static cell AMX_NATIVE_CALL get_gamerules_size(AMX *amx, cell *params) CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, GAMERULES); + GET_TYPE_DESCRIPTION(1, data, GamerulesConfig); return data.fieldSize; } @@ -492,7 +436,7 @@ static cell AMX_NATIVE_CALL find_gamerules_info(AMX *amx, cell *params) CHECK_GAMERULES(); TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, BaseFieldType::None, GAMERULES); + GET_TYPE_DESCRIPTION(1, data, GamerulesConfig); *MF_GetAmxAddr(amx, params[3]) = static_cast(data.fieldType); *MF_GetAmxAddr(amx, params[4]) = ke::Max(0, data.fieldSize); diff --git a/modules/fakemeta/pdata_shared.h b/modules/fakemeta/pdata_shared.h index 983cc9e1..ba922765 100644 --- a/modules/fakemeta/pdata_shared.h +++ b/modules/fakemeta/pdata_shared.h @@ -26,6 +26,43 @@ enum class BaseFieldType String, }; +#define GET_TYPE_DESCRIPTION(position, data, conf) \ + int classLength, memberLength; \ + char const *className = MF_GetAmxString(amx, params[position], 0, &classLength); \ + char const *memberName = MF_GetAmxString(amx, params[position + 1], 1, &memberLength); \ + if (!classLength || !memberLength) \ + { \ + MF_LogError(amx, AMX_ERR_NATIVE, "Either class (\"%s\") or member (\"%s\") is empty", className, memberName); \ + return 0; \ + } \ + else if (!conf->GetOffsetByClass(className, memberName, &data)) \ + { \ + MF_LogError(amx, AMX_ERR_NATIVE, "Could not find class \"%s\" and/or member \"%s\" in gamedata", className, memberName); \ + return 0; \ + } \ + else if (data.fieldOffset < 0) \ + { \ + MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset %d retrieved from \"%s\" member", data.fieldOffset, memberName); \ + return 0; \ + } + +#define CHECK_DATA(data, element, baseType) \ + if (baseType > BaseFieldType::None && baseType != PvData::GetBaseDataType(data)) \ + { \ + MF_LogError(amx, AMX_ERR_NATIVE, "Data field is not %s-based", PvData::GetBaseTypeName(baseType)); \ + return 0; \ + } \ + else if (element < 0 || (element > 0 && element >= data.fieldSize)) \ + { \ + MF_LogError(amx, AMX_ERR_NATIVE, "Invalid element index %d, value must be between 0 and %d", element, data.fieldSize); \ + return 0; \ + } \ + else if (element > 0 && !data.fieldSize) \ + { \ + MF_LogError(amx, AMX_ERR_NATIVE, "Member \"%s\" is not an array. Element %d is invalid.", memberName, element); \ + return 0; \ + } + class PvData { public: From 433325557198f56509ac57401cc95a7a72db37c7 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Thu, 29 Oct 2015 12:23:14 +0100 Subject: [PATCH 11/12] Refactor 4 - Move entities natives to its own file and reflect changes --- modules/fakemeta/AMBuilder | 1 + modules/fakemeta/fakemeta_amxx.cpp | 1 + modules/fakemeta/fakemeta_amxx.h | 1 + modules/fakemeta/msvc12/fakemeta.vcxproj | 1 + .../fakemeta/msvc12/fakemeta.vcxproj.filters | 3 + modules/fakemeta/pdata_entities.cpp | 246 ++++++++++++++++++ modules/fakemeta/pdata_gc.cpp | 231 ---------------- 7 files changed, 253 insertions(+), 231 deletions(-) create mode 100644 modules/fakemeta/pdata_entities.cpp diff --git a/modules/fakemeta/AMBuilder b/modules/fakemeta/AMBuilder index 9419bb1c..f2d81457 100644 --- a/modules/fakemeta/AMBuilder +++ b/modules/fakemeta/AMBuilder @@ -14,6 +14,7 @@ binary.sources = [ 'engfunc.cpp', 'fakemeta_amxx.cpp', 'pdata.cpp', + 'pdata_entities.cpp', 'pdata_gc.cpp', 'forward.cpp', 'fm_tr.cpp', diff --git a/modules/fakemeta/fakemeta_amxx.cpp b/modules/fakemeta/fakemeta_amxx.cpp index ca0eb3df..54b9da8a 100644 --- a/modules/fakemeta/fakemeta_amxx.cpp +++ b/modules/fakemeta/fakemeta_amxx.cpp @@ -64,6 +64,7 @@ void OnAmxxAttach() return; } + MF_AddNatives(pdata_entities_natives); MF_AddNatives(pdata_gc_natives); } diff --git a/modules/fakemeta/fakemeta_amxx.h b/modules/fakemeta/fakemeta_amxx.h index c796fb10..f3f1e661 100644 --- a/modules/fakemeta/fakemeta_amxx.h +++ b/modules/fakemeta/fakemeta_amxx.h @@ -55,6 +55,7 @@ extern AMX_NATIVE_INFO engfunc_natives[]; extern AMX_NATIVE_INFO dllfunc_natives[]; extern AMX_NATIVE_INFO forward_natives[]; extern AMX_NATIVE_INFO pdata_natives[]; +extern AMX_NATIVE_INFO pdata_entities_natives[]; extern AMX_NATIVE_INFO pdata_gc_natives[]; extern AMX_NATIVE_INFO tr_Natives[]; extern AMX_NATIVE_INFO pev_natives[]; diff --git a/modules/fakemeta/msvc12/fakemeta.vcxproj b/modules/fakemeta/msvc12/fakemeta.vcxproj index 5acfc961..4230b3be 100644 --- a/modules/fakemeta/msvc12/fakemeta.vcxproj +++ b/modules/fakemeta/msvc12/fakemeta.vcxproj @@ -104,6 +104,7 @@ + diff --git a/modules/fakemeta/msvc12/fakemeta.vcxproj.filters b/modules/fakemeta/msvc12/fakemeta.vcxproj.filters index ebd2ff7d..5c3af686 100644 --- a/modules/fakemeta/msvc12/fakemeta.vcxproj.filters +++ b/modules/fakemeta/msvc12/fakemeta.vcxproj.filters @@ -77,6 +77,9 @@ Memtools + + Source Files + diff --git a/modules/fakemeta/pdata_entities.cpp b/modules/fakemeta/pdata_entities.cpp new file mode 100644 index 00000000..039e3fca --- /dev/null +++ b/modules/fakemeta/pdata_entities.cpp @@ -0,0 +1,246 @@ +// vim: set ts=4 sw=4 tw=99 noet: +// +// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO"). +// Copyright (C) The AMX Mod X Development Team. +// +// This software is licensed under the GNU General Public License, version 3 or higher. +// Additional exceptions apply. For full license details, see LICENSE.txt or visit: +// https://alliedmods.net/amxmodx-license + +// +// Fakemeta Module +// + +#include "fakemeta_amxx.h" +#include "pdata_shared.h" + +// native any:get_ent_data(entity, const class[], const member[], element = 0); +static cell AMX_NATIVE_CALL get_ent_data(AMX *amx, cell *params) +{ + int entity = params[1]; + CHECK_ENTITY(entity); + + TypeDescription data; + GET_TYPE_DESCRIPTION(2, data, CommonConfig); + + int element = params[4]; + CHECK_DATA(data, element, BaseFieldType::Integer); + + return PvData::GetInt(entity, data, element); +} + +// native set_ent_data(entity, const class[], const member[], any:value, element = 0); +static cell AMX_NATIVE_CALL set_ent_data(AMX *amx, cell *params) +{ + int entity = params[1]; + CHECK_ENTITY(entity); + + TypeDescription data; + GET_TYPE_DESCRIPTION(2, data, CommonConfig); + + int element = params[5]; + CHECK_DATA(data, element, BaseFieldType::Integer); + + if (data.fieldType == FieldType::FIELD_STRUCTURE || data.fieldType == FieldType::FIELD_CLASS) + { + MF_LogError(amx, AMX_ERR_NATIVE, "Setting directly to a class or structure address is not available"); + return 0; + } + + PvData::SetInt(entity, data, params[4], element); + + return 1; +} + + +// native Float:get_ent_data_float(entity, const class[], const member[], element = 0); +static cell AMX_NATIVE_CALL get_ent_data_float(AMX *amx, cell *params) +{ + int entity = params[1]; + CHECK_ENTITY(entity); + + TypeDescription data; + GET_TYPE_DESCRIPTION(2, data, CommonConfig); + + int element = params[4]; + CHECK_DATA(data, element, BaseFieldType::Float); + + return PvData::GetFloat(entity, data, element); +} + +// native set_ent_data_float(entity, const classname[], const member[], Float:value, element = 0); +static cell AMX_NATIVE_CALL set_ent_data_float(AMX *amx, cell *params) +{ + int entity = params[1]; + CHECK_ENTITY(entity); + + TypeDescription data; + GET_TYPE_DESCRIPTION(2, data, CommonConfig); + + int element = params[5]; + CHECK_DATA(data, element, BaseFieldType::Float); + + PvData::SetFloat(entity, data, amx_ctof(params[4]), element); + + return 1; +} + + +// native get_ent_data_vector(entity, const class[], const member[], Float:value[3], element = 0); +static cell AMX_NATIVE_CALL get_ent_data_vector(AMX *amx, cell *params) +{ + int entity = params[1]; + CHECK_ENTITY(entity); + + TypeDescription data; + GET_TYPE_DESCRIPTION(2, data, CommonConfig); + + int element = params[5]; + CHECK_DATA(data, element, BaseFieldType::Vector); + + PvData::GetVector(entity, data, MF_GetAmxAddr(amx, params[4]), element); + + return 1; +} + +// native set_ent_data_vector(entity, const class[], const member[], Float:value[3], element = 0); +static cell AMX_NATIVE_CALL set_ent_data_vector(AMX *amx, cell *params) +{ + int entity = params[1]; + CHECK_ENTITY(entity); + + TypeDescription data; + GET_TYPE_DESCRIPTION(2, data, CommonConfig); + + int element = params[5]; + CHECK_DATA(data, element, BaseFieldType::Vector); + + PvData::SetVector(entity, data, MF_GetAmxAddr(amx, params[4]), element); + + return 1; +} + + +// native get_ent_data_entity(entity, const class[], const member[], element = 0); +static cell AMX_NATIVE_CALL get_ent_data_entity(AMX *amx, cell *params) +{ + int entity = params[1]; + CHECK_ENTITY(entity); + + TypeDescription data; + GET_TYPE_DESCRIPTION(2, data, CommonConfig); + + int element = params[4]; + CHECK_DATA(data, element, BaseFieldType::Entity); + + return PvData::GetEntity(entity, data, element); +} + +// native set_ent_data_entity(entity, const class[], const member[], value, element = 0); +static cell AMX_NATIVE_CALL set_ent_data_entity(AMX *amx, cell *params) +{ + int entity = params[1]; + int value = params[4]; + + CHECK_ENTITY(entity); + + if (value != -1) + { + CHECK_ENTITY(value); + } + + TypeDescription data; + GET_TYPE_DESCRIPTION(2, data, CommonConfig); + + int element = params[5]; + CHECK_DATA(data, element, BaseFieldType::Entity); + + PvData::SetEntity(entity, data, value, element); + + return 1; +} + + +// native get_ent_data_string(entity, const class[], const member[], value[], maxlen, element = 0); +static cell AMX_NATIVE_CALL get_ent_data_string(AMX *amx, cell *params) +{ + int entity = params[1]; + CHECK_ENTITY(entity); + + TypeDescription data; + GET_TYPE_DESCRIPTION(2, data, CommonConfig); + + int element = params[6]; + CHECK_DATA(data, element, BaseFieldType::String); + + auto buffer = params[4]; + auto maxlen = params[5]; + + auto string = PvData::GetString(entity, data, element); + + if (data.fieldSize) + { + maxlen = ke::Min(maxlen, data.fieldSize); + } + + return MF_SetAmxStringUTF8Char(amx, buffer, string ? string : "", string ? strlen(string) : 0, maxlen); +} + +// native set_ent_data_string(entity, const class[], const member[], const value[], element = 0); +static cell AMX_NATIVE_CALL set_ent_data_string(AMX *amx, cell *params) +{ + int entity = params[1]; + CHECK_ENTITY(entity); + + TypeDescription data; + GET_TYPE_DESCRIPTION(2, data, CommonConfig); + + int element = params[5]; + CHECK_DATA(data, element, BaseFieldType::String); + + int length; + const char *value = MF_GetAmxString(amx, params[4], 0, &length); + + return PvData::SetString(entity, data, value, length, element); +} + + +// native get_ent_data_size(const class[], const member[]); +static cell AMX_NATIVE_CALL get_ent_data_size(AMX *amx, cell *params) +{ + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, CommonConfig); + + return data.fieldSize; +} + +// native find_ent_data_info(const class[], const member[], &FieldType:type = FIELD_NONE, &arraysize = 0, &bool:unsigned = false); +static cell AMX_NATIVE_CALL find_ent_data_info(AMX *amx, cell *params) +{ + TypeDescription data; + GET_TYPE_DESCRIPTION(1, data, CommonConfig); + + *MF_GetAmxAddr(amx, params[3]) = static_cast(data.fieldType); + *MF_GetAmxAddr(amx, params[4]) = ke::Max(0, data.fieldSize); + *MF_GetAmxAddr(amx, params[5]) = data.fieldUnsigned != 0; + + return data.fieldOffset; +} + + +AMX_NATIVE_INFO pdata_entities_natives[] = +{ + { "get_ent_data" , get_ent_data }, + { "set_ent_data" , set_ent_data }, + { "get_ent_data_float" , get_ent_data_float }, + { "set_ent_data_float" , set_ent_data_float }, + { "get_ent_data_vector" , get_ent_data_vector }, + { "set_ent_data_vector" , set_ent_data_vector }, + { "get_ent_data_entity" , get_ent_data_entity }, + { "set_ent_data_entity" , set_ent_data_entity }, + { "get_ent_data_string" , get_ent_data_string }, + { "set_ent_data_string" , set_ent_data_string }, + { "get_ent_data_size" , get_ent_data_size }, + { "find_ent_data_info" , find_ent_data_info }, + { nullptr , nullptr } +}; \ No newline at end of file diff --git a/modules/fakemeta/pdata_gc.cpp b/modules/fakemeta/pdata_gc.cpp index 3c5942bf..e665ccad 100644 --- a/modules/fakemeta/pdata_gc.cpp +++ b/modules/fakemeta/pdata_gc.cpp @@ -21,223 +21,6 @@ return 0; \ } - -// native any:get_ent_data(entity, const class[], const member[], element = 0); -static cell AMX_NATIVE_CALL get_ent_data(AMX *amx, cell *params) -{ - int entity = params[1]; - CHECK_ENTITY(entity); - - TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, CommonConfig); - - int element = params[4]; - CHECK_DATA(data, element, BaseFieldType::Integer); - - return PvData::GetInt(entity, data, element); -} - -// native set_ent_data(entity, const class[], const member[], any:value, element = 0); -static cell AMX_NATIVE_CALL set_ent_data(AMX *amx, cell *params) -{ - int entity = params[1]; - CHECK_ENTITY(entity); - - TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, CommonConfig); - - int element = params[5]; - CHECK_DATA(data, element, BaseFieldType::Integer); - - if (data.fieldType == FieldType::FIELD_STRUCTURE || data.fieldType == FieldType::FIELD_CLASS) - { - MF_LogError(amx, AMX_ERR_NATIVE, "Setting directly to a class or structure address is not available"); - return 0; - } - - PvData::SetInt(entity, data, params[4], element); - - return 1; -} - - -// native Float:get_ent_data_float(entity, const class[], const member[], element = 0); -static cell AMX_NATIVE_CALL get_ent_data_float(AMX *amx, cell *params) -{ - int entity = params[1]; - CHECK_ENTITY(entity); - - TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, CommonConfig); - - int element = params[4]; - CHECK_DATA(data, element, BaseFieldType::Float); - - return PvData::GetFloat(entity, data, element); -} - -// native set_ent_data_float(entity, const classname[], const member[], Float:value, element = 0); -static cell AMX_NATIVE_CALL set_ent_data_float(AMX *amx, cell *params) -{ - int entity = params[1]; - CHECK_ENTITY(entity); - - TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, CommonConfig); - - int element = params[5]; - CHECK_DATA(data, element, BaseFieldType::Float); - - PvData::SetFloat(entity, data, amx_ctof(params[4]), element); - - return 1; -} - - -// native get_ent_data_vector(entity, const class[], const member[], Float:value[3], element = 0); -static cell AMX_NATIVE_CALL get_ent_data_vector(AMX *amx, cell *params) -{ - int entity = params[1]; - CHECK_ENTITY(entity); - - TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, CommonConfig); - - int element = params[5]; - CHECK_DATA(data, element, BaseFieldType::Vector); - - PvData::GetVector(entity, data, MF_GetAmxAddr(amx, params[4]), element); - - return 1; -} - -// native set_ent_data_vector(entity, const class[], const member[], Float:value[3], element = 0); -static cell AMX_NATIVE_CALL set_ent_data_vector(AMX *amx, cell *params) -{ - int entity = params[1]; - CHECK_ENTITY(entity); - - TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, CommonConfig); - - int element = params[5]; - CHECK_DATA(data, element, BaseFieldType::Vector); - - PvData::SetVector(entity, data, MF_GetAmxAddr(amx, params[4]), element); - - return 1; -} - - -// native get_ent_data_entity(entity, const class[], const member[], element = 0); -static cell AMX_NATIVE_CALL get_ent_data_entity(AMX *amx, cell *params) -{ - int entity = params[1]; - CHECK_ENTITY(entity); - - TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, CommonConfig); - - int element = params[4]; - CHECK_DATA(data, element, BaseFieldType::Entity); - - return PvData::GetEntity(entity, data, element); -} - -// native set_ent_data_entity(entity, const class[], const member[], value, element = 0); -static cell AMX_NATIVE_CALL set_ent_data_entity(AMX *amx, cell *params) -{ - int entity = params[1]; - int value = params[4]; - - CHECK_ENTITY(entity); - - if (value != -1) - { - CHECK_ENTITY(value); - } - - TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, CommonConfig); - - int element = params[5]; - CHECK_DATA(data, element, BaseFieldType::Entity); - - PvData::SetEntity(entity, data, value, element); - - return 1; -} - - -// native get_ent_data_string(entity, const class[], const member[], value[], maxlen, element = 0); -static cell AMX_NATIVE_CALL get_ent_data_string(AMX *amx, cell *params) -{ - int entity = params[1]; - CHECK_ENTITY(entity); - - TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, CommonConfig); - - int element = params[6]; - CHECK_DATA(data, element, BaseFieldType::String); - - auto buffer = params[4]; - auto maxlen = params[5]; - - auto string = PvData::GetString(entity, data, element); - - if (data.fieldSize) - { - maxlen = ke::Min(maxlen, data.fieldSize); - } - - return MF_SetAmxStringUTF8Char(amx, buffer, string ? string : "", string ? strlen(string) : 0, maxlen); -} - -// native set_ent_data_string(entity, const class[], const member[], const value[], element = 0); -static cell AMX_NATIVE_CALL set_ent_data_string(AMX *amx, cell *params) -{ - int entity = params[1]; - CHECK_ENTITY(entity); - - TypeDescription data; - GET_TYPE_DESCRIPTION(2, data, CommonConfig); - - int element = params[5]; - CHECK_DATA(data, element, BaseFieldType::String); - - int length; - const char *value = MF_GetAmxString(amx, params[4], 0, &length); - - return PvData::SetString(entity, data, value, length, element); -} - - -// native get_ent_data_size(const class[], const member[]); -static cell AMX_NATIVE_CALL get_ent_data_size(AMX *amx, cell *params) -{ - TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, CommonConfig); - - return data.fieldSize; -} - -// native find_ent_data_info(const class[], const member[], &FieldType:type = FIELD_NONE, &arraysize = 0, &bool:unsigned = false); -static cell AMX_NATIVE_CALL find_ent_data_info(AMX *amx, cell *params) -{ - TypeDescription data; - GET_TYPE_DESCRIPTION(1, data, CommonConfig); - - *MF_GetAmxAddr(amx, params[3]) = static_cast(data.fieldType); - *MF_GetAmxAddr(amx, params[4]) = ke::Max(0, data.fieldSize); - *MF_GetAmxAddr(amx, params[5]) = data.fieldUnsigned != 0; - - return data.fieldOffset; -} - - - - // native any:get_gamerules_int(const class[], const member[], element = 0); static cell AMX_NATIVE_CALL get_gamerules_int(AMX *amx, cell *params) { @@ -448,19 +231,6 @@ static cell AMX_NATIVE_CALL find_gamerules_info(AMX *amx, cell *params) AMX_NATIVE_INFO pdata_gc_natives[] = { - { "get_ent_data" , get_ent_data }, - { "set_ent_data" , set_ent_data }, - { "get_ent_data_float" , get_ent_data_float }, - { "set_ent_data_float" , set_ent_data_float }, - { "get_ent_data_vector" , get_ent_data_vector }, - { "set_ent_data_vector" , set_ent_data_vector }, - { "get_ent_data_entity" , get_ent_data_entity }, - { "set_ent_data_entity" , set_ent_data_entity }, - { "get_ent_data_string" , get_ent_data_string }, - { "set_ent_data_string" , set_ent_data_string }, - { "get_ent_data_size" , get_ent_data_size }, - { "find_ent_data_info" , find_ent_data_info }, - { "get_gamerules_int" , get_gamerules_int }, { "set_gamerules_int" , set_gamerules_int }, { "get_gamerules_float" , get_gamerules_float }, @@ -473,6 +243,5 @@ AMX_NATIVE_INFO pdata_gc_natives[] = { "set_gamerules_string", set_gamerules_string }, { "get_gamerules_size" , get_gamerules_size }, { "find_gamerules_info" , find_gamerules_info }, - { nullptr , nullptr } }; From 49184c86a317cde2412cbc6f31b363f3f5517372 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Thu, 29 Oct 2015 12:29:30 +0100 Subject: [PATCH 12/12] Refactor 5 - Rename original file/var for gamerules --- modules/fakemeta/AMBuilder | 2 +- modules/fakemeta/fakemeta_amxx.cpp | 2 +- modules/fakemeta/fakemeta_amxx.h | 2 +- modules/fakemeta/msvc12/fakemeta.vcxproj | 2 +- modules/fakemeta/msvc12/fakemeta.vcxproj.filters | 6 +++--- .../fakemeta/{pdata_gc.cpp => pdata_gamerules.cpp} | 9 +-------- modules/fakemeta/pdata_shared.h | 11 +++++++++-- 7 files changed, 17 insertions(+), 17 deletions(-) rename modules/fakemeta/{pdata_gc.cpp => pdata_gamerules.cpp} (93%) diff --git a/modules/fakemeta/AMBuilder b/modules/fakemeta/AMBuilder index f2d81457..7b83a3f4 100644 --- a/modules/fakemeta/AMBuilder +++ b/modules/fakemeta/AMBuilder @@ -15,7 +15,7 @@ binary.sources = [ 'fakemeta_amxx.cpp', 'pdata.cpp', 'pdata_entities.cpp', - 'pdata_gc.cpp', + 'pdata_gamerules.cpp', 'forward.cpp', 'fm_tr.cpp', 'pev.cpp', diff --git a/modules/fakemeta/fakemeta_amxx.cpp b/modules/fakemeta/fakemeta_amxx.cpp index 54b9da8a..4be7c85a 100644 --- a/modules/fakemeta/fakemeta_amxx.cpp +++ b/modules/fakemeta/fakemeta_amxx.cpp @@ -65,7 +65,7 @@ void OnAmxxAttach() } MF_AddNatives(pdata_entities_natives); - MF_AddNatives(pdata_gc_natives); + MF_AddNatives(pdata_gamerules_natives); } void OnPluginsLoaded() diff --git a/modules/fakemeta/fakemeta_amxx.h b/modules/fakemeta/fakemeta_amxx.h index f3f1e661..a41cccda 100644 --- a/modules/fakemeta/fakemeta_amxx.h +++ b/modules/fakemeta/fakemeta_amxx.h @@ -56,7 +56,7 @@ extern AMX_NATIVE_INFO dllfunc_natives[]; extern AMX_NATIVE_INFO forward_natives[]; extern AMX_NATIVE_INFO pdata_natives[]; extern AMX_NATIVE_INFO pdata_entities_natives[]; -extern AMX_NATIVE_INFO pdata_gc_natives[]; +extern AMX_NATIVE_INFO pdata_gamerules_natives[]; extern AMX_NATIVE_INFO tr_Natives[]; extern AMX_NATIVE_INFO pev_natives[]; extern AMX_NATIVE_INFO glb_natives[]; diff --git a/modules/fakemeta/msvc12/fakemeta.vcxproj b/modules/fakemeta/msvc12/fakemeta.vcxproj index 4230b3be..68d2e4a6 100644 --- a/modules/fakemeta/msvc12/fakemeta.vcxproj +++ b/modules/fakemeta/msvc12/fakemeta.vcxproj @@ -105,7 +105,7 @@ - + diff --git a/modules/fakemeta/msvc12/fakemeta.vcxproj.filters b/modules/fakemeta/msvc12/fakemeta.vcxproj.filters index 5c3af686..67380042 100644 --- a/modules/fakemeta/msvc12/fakemeta.vcxproj.filters +++ b/modules/fakemeta/msvc12/fakemeta.vcxproj.filters @@ -71,15 +71,15 @@ Module SDK\SDK Base - - Source Files - Memtools Source Files + + Source Files + diff --git a/modules/fakemeta/pdata_gc.cpp b/modules/fakemeta/pdata_gamerules.cpp similarity index 93% rename from modules/fakemeta/pdata_gc.cpp rename to modules/fakemeta/pdata_gamerules.cpp index e665ccad..6ad806d1 100644 --- a/modules/fakemeta/pdata_gc.cpp +++ b/modules/fakemeta/pdata_gamerules.cpp @@ -14,13 +14,6 @@ #include "fakemeta_amxx.h" #include "pdata_shared.h" -#define CHECK_GAMERULES() \ - if (!GameRulesAddress) \ - { \ - MF_LogError(amx, AMX_ERR_NATIVE, "%s is disabled. Check your AMXX log.", __FUNCTION__); \ - return 0; \ - } - // native any:get_gamerules_int(const class[], const member[], element = 0); static cell AMX_NATIVE_CALL get_gamerules_int(AMX *amx, cell *params) { @@ -229,7 +222,7 @@ static cell AMX_NATIVE_CALL find_gamerules_info(AMX *amx, cell *params) } -AMX_NATIVE_INFO pdata_gc_natives[] = +AMX_NATIVE_INFO pdata_gamerules_natives[] = { { "get_gamerules_int" , get_gamerules_int }, { "set_gamerules_int" , set_gamerules_int }, diff --git a/modules/fakemeta/pdata_shared.h b/modules/fakemeta/pdata_shared.h index ba922765..8384fa73 100644 --- a/modules/fakemeta/pdata_shared.h +++ b/modules/fakemeta/pdata_shared.h @@ -63,6 +63,13 @@ enum class BaseFieldType return 0; \ } +#define CHECK_GAMERULES() \ + if (!GameRulesAddress) \ + { \ + MF_LogError(amx, AMX_ERR_NATIVE, "%s is disabled. Check your AMXX log.", __FUNCTION__); \ + return 0; \ + } + class PvData { public: @@ -152,7 +159,7 @@ public: } else { - set_pdata(pObject, data.fieldOffset, static_cast(value), element); + set_pdata(pObject, data.fieldOffset, static_cast(value), element); } break; } @@ -164,7 +171,7 @@ public: } else { - set_pdata(pObject, data.fieldOffset, static_cast(value), element); + set_pdata(pObject, data.fieldOffset, static_cast(value), element); } break; }