AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Dynamic Objects and Properties - v.0.0.32 - [2018.05.08] (https://forums.alliedmods.net/showthread.php?t=270519)

Neuro Toxin 02-20-2016 09:58

Re: [2016.02.21] Dynamic Objects and Properties - v004
 
I just moved this to Github and released version 004.

The main post has been updated.

A new example is included on how this is used that covers almost all features of Dynamic.

Neuro Toxin 02-26-2016 20:51

Re: [2016.02.27] Dynamic Objects and Properties - v005
 
As we know, methodmaps require data backing the properties which steers people away from using them.

You can create methodmaps that inherit the Dynamic class and write properties that use the dynamic object to back the properties.

dynamic-example.inc

Quote:

In the linked example, I use static offsets in each property of the methodmap to cache member positions in the dynamic object to increase performance.

This then requires all the dynamic members to be in the same positions.

To get around this, you can see I set all the members in the initialiser for MyClass, this means over multiple instances of MyClass, the member offsets will always correct.
The key points to following when making your own dynamic classes are:

1. All members must be set to their default values in the constructer
2. Use static offsets in each property to increase performance

I'm about to make a webpage where you can define your class. It will then spit out the methodmap to make that class using Dynamic.

Neuro Toxin 02-27-2016 01:17

Re: [2016.02.27] Dynamic Objects and Properties - v005
 
Dynamic Classes
- Extend Dynamic to create your own Dynamic Classes
- A Class Builder to quickly generate basic Dynamic Classes
- You dont have to muck around with Dynamic Member Offsets to improve performance
- All of the same features that come with Dynamic Objects

I just finished a basic web based class builder.

I used these settings to...

Generate this methodmap...

Which can be used like this in a plugin!

zipcore 02-27-2016 03:23

Re: [2016.02.27] Dynamic Objects and Properties - v005
 
not bad... not bad

Neuro Toxin 02-27-2016 05:14

Re: [2016.02.27] Dynamic Objects and Properties - v005
 
The latest profile stats...


I'm really curious around why the reading of members using a string membername is quicker than using integer offsets.

Quote:

Read 99000 dynamic member(s) in 0.139648 second(s)
Read 99000 dynamic member(s) using offsets in 0.141601 second(s)

Read 99000 dynamic member(s) in 0.139648 second(s)
Read 99000 dynamic member(s) using offsets in 0.141601 second(s)

Read 99000 dynamic member(s) in 0.139648 second(s)
Read 99000 dynamic member(s) using offsets in 0.141601 second(s)

Neuro Toxin 03-15-2016 07:05

Re: [2016.02.27] Dynamic Objects and Properties - v005
 
Just updated Dynamic to version 0.0.6

Changes...

The technical answer as to why offsets are now faster...

The latest profile stats...

Member name lookups vs Offset lookups...


Github Changes
Download

Edit:

I've completed a code generate tweak for the Dynamic Class Generator.

- Member offsets are stored when a member is set for the first time

Neuro Toxin 03-17-2016 04:30

Re: Dynamic Objects and Properties - v006 - [2016.03.15]
 
Just realised I need to add support for boolean types.

I'll do this soon by wrapping Get/SetBool around integer support. This will be similar to how Get/SetObject works if your familiar with how the Dynamic methodmap works.

In the mean time booleans can be used with Get/SetInt.

kossolax 03-18-2016 04:35

Re: Dynamic Objects and Properties - v006 - [2016.03.15]
 
Quote:

Originally Posted by Neuro Toxin (Post 2403212)
Just realised I need to add support for boolean types.

What about handle types ?

Neuro Toxin 03-18-2016 05:05

Re: Dynamic Objects and Properties - v006 - [2016.03.15]
 
Great question.

Handles can currently be used via Get/SetInt. You might need view_as casting to avoid type mismatch warnings.

I will however add support for Handles after completing bool support.

ImACow 03-18-2016 08:14

Re: Dynamic Objects and Properties - v006 - [2016.03.15]
 
This is amazing.

Thanks for this! this saved me hours of writing natives to cross communicate with plugins


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

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