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

Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]


Post New Thread Reply   
 
Thread Tools Display Modes
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 04-21-2016 , 07:15   Re: Dynamic Objects and Properties - v.0.0.13 - [2016.04.10]
Reply With Quote #61

Maybe a long shot, but how feasible you think it would be to allow saving/loading dynamics to files and/or databases ? this way plugins can request certain dynamics based on maps/players.

Dynamic.Load(LoadFromFile,"%s",charMapname);

Dynamic.Load(LoadFromDatabase,"%s_%s",charTab leName,charMapname);

OnClientPutInServer ->
Dynamic.Load(LoadFromDatabase,"players_steami d_%s",charSteamID);
__________________

Last edited by ImACow; 04-21-2016 at 07:17.
ImACow is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-21-2016 , 19:08   Re: Dynamic Objects and Properties - v.0.0.13 - [2016.04.10]
Reply With Quote #62

I've gotten a bit side tracked on the current features update as per my last post.

Funny thing is. It's related to your request.

I've completed:

- Reserved view_as<Dynamic>(1-MAXPLAYERS) for player based objects
- Added <Dynamic>Dynamic.ReadConfig(const char[] filepath, bool use_valve_fs=false);

I'm adding object.WriteConfig(const char []filepath); before I push the next release.

Wont be long.
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-23-2016 , 03:34   Re: Dynamic Objects and Properties - v.0.0.14 - [2016.04.23]
Reply With Quote #63

Version 0.0.14
- Reserved view_as<Dynamic>(0) for global server settings.
- Reserved view_as<Dynamic>(1-MAXPLAYERS) for player based objects.
- Added support to read and write flag config files.

Client Index Reservation
Player indices are now reserved in Dynamic. This allows you to do the following to store additional player settings that you would want to share between plugins.
Code:
Dynamic playersettings = Dynamic.GetPlayerSettings(client);
playersettings.SetInt("someint", 66);
int someint = playersettings.GetInt("someint")
You can also obtain a playersettings object slightly quicker with this hack.
Code:
Dynamic playersettings = view_as<Dynamic>(client);
Server Settings Reservation
Server based settings are now reserved to allow plugins to quickly store and retrieve server based settings between themselves.
Code:
Dynamic settings = Dynamic.GetSettings();
settings.SetInt("someint", 66);
int someint = settings.GetInt("someint")
You can also obtain the settings object slightly quicker with this hack.
Code:
Dynamic playersettings = view_as<Dynamic>(0);
Flat Configs
Refers to config files in a format like server.cfg or autoexec.cfg.

You can now easily load a flat config using dynamic:
Code:
Dynamic serverconfig = Dynamic();
serverconfig.ReadConfig("cfg/server.cfg");
You can then make updates and write the config back to disk.
Note: Comments are stripped if you read/ulter/write a config!
Code:
serverconfig.WriteConfig("cfg/server.cfg");
__________________

Last edited by Neuro Toxin; 04-26-2016 at 01:10.
Neuro Toxin is offline
kossolax
AlliedModders Donor
Join Date: Jan 2008
Location: Belgium
Old 05-04-2016 , 17:16   Re: Dynamic Objects and Properties - v.0.0.14 - [2016.04.23]
Reply With Quote #64

To continue about this:
Quote:
Originally Posted by Neuro Toxin View Post
You could use Dynamic for cross plugin data storage.
My needs to use Dynamic is more like "dynamic rows" or stack.

Well... something like:

PHP Code:
DynamicArray memory DynamicArray(descriptor);
memory.push(...);
memory.push(...);
memory.push(...);

Dynamic obj Memory.GetAtIndex(2);
memory.deleteobj );

Dynamic rows memory.GetIterator();
while ( 
rows.hasNext() ) {
   
Dynamic row rows.next();
   
int a row.GetInt("someint");
   
int b row.GetInt("someint");

or anything equivalent.



Which I think is not *yet* supported.
kossolax is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 05-04-2016 , 18:11   Re: Dynamic Objects and Properties - v.0.0.14 - [2016.04.23]
Reply With Quote #65

When you add members to a dynamic object they are internally pushed into a offset array.

Code:
someobj.SetInt("someint", 1);  <<< index 0
someobj.SetFloat("somefloat", 512.7); <<< index 1
someobj.SetBool("somebool", true); <<< index 2
You can use the iterator support to either grab a specific index or loop everything.

I could also add support for PushInt/Float/String/ect along with Get*ByIndex.
__________________
Neuro Toxin is offline
kossolax
AlliedModders Donor
Join Date: Jan 2008
Location: Belgium
Old 05-05-2016 , 04:36   Re: Dynamic Objects and Properties - v.0.0.14 - [2016.04.23]
Reply With Quote #66

That's right but I think name must be unique. Sorry for confusing, but I was talking about row like in a table. I'm using DataPack because I have to add/remove row index on the fly, and there is no max size. Mostly to cache mysql data-result. I had issue with ADTArray and ADTTries, but I forgot which was it...

kossolax is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 05-05-2016 , 05:08   Re: Dynamic Objects and Properties - v.0.0.14 - [2016.04.23]
Reply With Quote #67

Quote:
Originally Posted by kossolax

I have to add/remove row index on the fly
This will break Dynamic as you cant remove members.

Either way: Push* and Get*ByIndex are still usefull so I've starting implementing them.
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 06-07-2016 , 19:58   Re: Dynamic Objects and Properties - v.0.0.14 - [2016.04.23]
Reply With Quote #68

Version 0.0.15 has been pushed.

This is a major update.

- Added support to push members without a name
- Added support to get a member by index
- Added support for Dynamic.Parent property
- Added Dynamic.Read/WriteKeyValues
- Type conversion for Dynamic.ReadConfig and Dynamic.ReadKeyValues
- Minor memory leak fix in ReadConfig/KeyValues
- Reduce Handle count for each Dynamic Object
- General optimisation mainly around member iteration
- Fixed bug for GetMemberCount
- Fix bug in parenting when using PushObject
- Unnamed keys in ReadKeyValues are pushed as objects internally
- Negative int/floats now convert correctly for ReadConfig/KeyValues

The example and test files dont reflect these changes.

The example file will be split into examples because it's to big.
__________________
Neuro Toxin is offline
Chief149
Member
Join Date: Sep 2010
Old 06-08-2016 , 20:20   Re: Dynamic Objects and Properties - v.0.0.15 - [2016.06.08]
Reply With Quote #69

Out of curiosity how would block size/size affect performance versus memory usage?

Can strings be longer than the set blocksize? Is there a limit to the number of class members versus block size? The reason I ask this is there's a lot going on in your code. Enough so that it's much easier to ask about this here.
Chief149 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 06-09-2016 , 02:04   Re: Dynamic Objects and Properties - v.0.0.15 - [2016.06.08]
Reply With Quote #70

The internal blocksize is the array index length.

A larger blocksize has better performance on offset calculations. This would be minor...

Larger blocksizes will use more memory.

If your objects will have large member counts. Use a bigger blocksize.

There is not limits to member counts as the internal array size expands if required.

Strings can be longer than the blocksize as the get/set string functions wrap over multiple indicies if required.

Strings are a set length and cant be expanded once the member is set.
__________________
Neuro Toxin is offline
Reply



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 14:08.


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