Raised This Month: $12 Target: $400
 3% 

[REQ] FakeMeta - glb_pStringBase


  
 
 
Thread Tools Display Modes
Author Message
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 07-18-2006 , 06:29   [REQ] FakeMeta - glb_pStringBase
#1

It is to my understanding that is suppose to convert pointers to strings ala HL eng (STRING) which this isnt.

glb.cpp - line 155 add this:
Code:
else if (paramnum == 3) {     cell size = *(MF_GetAmxAddr(amx, params[4]));     if (Valtype == Ret_PChar)     {         cell *str = MF_GetAmxAddr(amx, params[2]);         return MF_SetAmxString(amx, params[3], STRING((int)*str), size);     }     MF_LogError(amx, AMX_ERR_NATIVE, "Invalid return type"); }
How it works (example):
Code:
new pointer = pev(id, pev_viewmodel) global_get(glb_pStringBase, pointer, temp, 127)

As you see it makes this redundant:
pev_string2_begin, /* anything after here are string corrections */
pev_weaponmodel2,
pev_viewmodel2,


Another suggestion changing this:

pev.cpp - line 277
Code:
if (ValType == Ret_String) {     const char *str = STRING(rets.s);     if (!str)         str = "";     int num = MF_SetAmxString(amx, params[3], str, size);     return num;

To:
Code:
if (ValType == Ret_String) {     const char *str = STRING(rets.s);     if (!str)         str = "";     MF_SetAmxString(amx, params[3], str, size);     return (int)rets.s;
Reason being, why was it originally returning the string length? We have a native to check that! Least with this way it returns the pointer and we can check the pointer at any given time with the other code above.


Regards,

Orangutanz
Orangutanz is offline
DS
SourceMod Developer
Join Date: Sep 2004
Location: WI, USA
Old 07-19-2006 , 00:29   Re: [REQ] FakeMeta - glb_pStringBase
#2

This has been added to SVN revision 2878.

The first suggesstion has been added as-is. But the second one concerning pev works a bit differently. I did not change the return value of pev used with strings for the sake of backwards compatibility. Who knows where that return value may be used. So instead, I have allowed an optional byref ptr paramater to store the pointer. Or you may also soley retrieve the pointer, in which case it will be a return value. This is documented in fakemeta.inc.
__________________
エル・プサイ・コングルゥ
DS is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode