gamedata: implement GetMemSig (#1345)
This commit is contained in:
		
							parent
							
								
									6fd9d1ce11
								
							
						
					
					
						commit
						589d6df75d
					
				| @ -162,6 +162,38 @@ static cell_t smn_GameConfGetAddress(IPluginContext *pCtx, const cell_t *params) | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static cell_t smn_GameConfGetMemSig(IPluginContext *pCtx, const cell_t *params) | ||||||
|  | { | ||||||
|  | 	Handle_t hndl = static_cast<Handle_t>(params[1]); | ||||||
|  | 	HandleError herr; | ||||||
|  | 	HandleSecurity sec; | ||||||
|  | 	IGameConfig *gc; | ||||||
|  | 
 | ||||||
|  | 	sec.pOwner = NULL; | ||||||
|  | 	sec.pIdentity = g_pCoreIdent; | ||||||
|  | 
 | ||||||
|  | 	if ((herr=handlesys->ReadHandle(hndl, g_GameConfigsType, &sec, (void **)&gc)) | ||||||
|  | 		!= HandleError_None) | ||||||
|  | 	{ | ||||||
|  | 		return pCtx->ThrowNativeError("Invalid game config handle %x (error %d)", hndl, herr); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	char *key; | ||||||
|  | 	void *val; | ||||||
|  | 	pCtx->LocalToString(params[2], &key); | ||||||
|  | 
 | ||||||
|  | 	if (!gc->GetMemSig(key, &val)) | ||||||
|  | 	{ | ||||||
|  | 		return 0; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | #ifdef PLATFORM_X86 | ||||||
|  | 	return (cell_t)val; | ||||||
|  | #else | ||||||
|  | 	return pseudoAddr.ToPseudoAddress(val); | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static GameConfigsNatives s_GameConfigsNatives; | static GameConfigsNatives s_GameConfigsNatives; | ||||||
| 
 | 
 | ||||||
| REGISTER_NATIVES(gameconfignatives) | REGISTER_NATIVES(gameconfignatives) | ||||||
| @ -176,5 +208,6 @@ REGISTER_NATIVES(gameconfignatives) | |||||||
| 	{"GameData.GetOffset",			smn_GameConfGetOffset}, | 	{"GameData.GetOffset",			smn_GameConfGetOffset}, | ||||||
| 	{"GameData.GetKeyValue",		smn_GameConfGetKeyValue}, | 	{"GameData.GetKeyValue",		smn_GameConfGetKeyValue}, | ||||||
| 	{"GameData.GetAddress",			smn_GameConfGetAddress}, | 	{"GameData.GetAddress",			smn_GameConfGetAddress}, | ||||||
|  | 	{"GameData.GetMemSig", 			smn_GameConfGetMemSig}, | ||||||
| 	{NULL,							NULL} | 	{NULL,							NULL} | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -113,6 +113,12 @@ methodmap GameData < Handle | |||||||
| 	// @param name          Name of the property to find.
 | 	// @param name          Name of the property to find.
 | ||||||
| 	// @return              An address calculated on success, or 0 on failure.
 | 	// @return              An address calculated on success, or 0 on failure.
 | ||||||
| 	public native Address GetAddress(const char[] name); | 	public native Address GetAddress(const char[] name); | ||||||
|  | 
 | ||||||
|  | 	// Returns a function address calculated from a signature.
 | ||||||
|  | 	//
 | ||||||
|  | 	// @param name          Name of the property to find.
 | ||||||
|  | 	// @return              An address calculated on success, or 0 on failure.
 | ||||||
|  | 	public native Address GetMemSig(const char[] name); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user