Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new natives to read/write on entity's private data based off class/member name using gamedata files #284

Merged
merged 1 commit into from
Sep 19, 2015

Conversation

Arkshine
Copy link
Member

Based on #282.

This introduces a new set of natives to handle an entity's private data.

Unlike the [get|set]_pdata_* natives that require compiling the class member offset into the plugin, those new ones instead retrieve the necessary offset from the AMXX gamedata files at runtime, based on the provided class and member name.

The use of gamedata files has the advantage to make these natives much safer than [get|set]_pdata_* as it can perform stricter offset and typing checks.

@Arkshine Arkshine changed the title Introduce new natives to read/write on entity's private data based off class/member name available from gamedata files Introduce new natives to read/write on entity's private data based off class/member name using gamedata files Aug 13, 2015
@Arkshine Arkshine force-pushed the feature/new-pdata-natives branch 2 times, most recently from 34d5214 to 3e63ace Compare September 7, 2015 07:41
#define GET_TYPE_DESCRIPTION(position, data, baseType) \
int classLength, memberLength; \
const char *className = MF_GetAmxString(amx, params[position + 1], 0, &classLength); \
const char *memberName = MF_GetAmxString(amx, params[position + 2], 1, &memberLength); \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this offset by 1/2 instead of 0/1? It looks like you are retrieving the same parameter twice in code:

int entity = params[1];
CHECK_ENTITY(entity);

TypeDescription data;
GET_TYPE_DESCRIPTION(1, data, BaseFieldType::Integer);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know why I've passed the position zero-based. It should be for sure more understandable that position index starts to 1, likes params.

@Arkshine Arkshine force-pushed the feature/new-pdata-natives branch 4 times, most recently from 906d4cc to 16f6566 Compare September 19, 2015 18:07
@Nextra
Copy link
Contributor

Nextra commented Sep 19, 2015

🚢

Arkshine added a commit that referenced this pull request Sep 19, 2015
Introduce new natives to read/write on entity's private data based off class/member name using gamedata files
@Arkshine Arkshine merged commit 9a4731d into alliedmodders:master Sep 19, 2015
@Arkshine Arkshine deleted the feature/new-pdata-natives branch September 19, 2015 18:56
Amaroq7 referenced this pull request in Amaroq7/AMXX-CTW Nov 28, 2015
Replace set_pdata_float native with set_ent_data_float which is safer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants