This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Using an array of enum hack to an adt_array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dilalmon
AlliedModders Donor
Join Date: Apr 2013
Old 04-14-2015 , 17:36   Using an array of enum hack to an adt_array
Reply With Quote #1

Is this possible? To add an array of enum hack into an adt_array?

I'm trying to add this into an adt_array.
Code:
enum ItemData
{
    EntityID,
    String:ItemTag[32],
    StartHP
};
I need to have an array of the enum hack sized about 1500 (I'm using about 1300 of it and still expanding) and it started causing some instabilities during server restarts and plugin loads at start.

I was wondering if I can use it into an adt_array?
dilalmon is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 04-14-2015 , 17:55   Re: Using an array of enum hack to an adt_array
Reply With Quote #2

Why would a dynamic array be faster than a static one?

Also, you can divide string lengths by 4 in enum hack things, it thinks it's a cell array and so would allocate 32 * 4 bytes for you with that
Miu is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 04-14-2015 , 19:27   Re: Using an array of enum hack to an adt_array
Reply With Quote #3

Quote:
Originally Posted by dilalmon View Post
[...]and it started causing some instabilities during server restarts and plugin loads at start.[...]

Then you're doing something wrong.
What? We will never know, probably.
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
dilalmon
AlliedModders Donor
Join Date: Apr 2013
Old 04-14-2015 , 22:48   Re: Using an array of enum hack to an adt_array
Reply With Quote #4

Quote:
Originally Posted by Miu View Post
Why would a dynamic array be faster than a static one?

Also, you can divide string lengths by 4 in enum hack things, it thinks it's a cell array and so would allocate 32 * 4 bytes for you with that
I don't think it's faster, but I had some errors saying "invalid memory access" on the console on a flawless statement (literally "new hello[5]; hello[2] = 3;") so I figured it would be related to an array with 1500 indexes.

As for the enum hack, does that mean I can put new String:foo[16] instead of [64] and still use it as if it's 64 long?
dilalmon is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-15-2015 , 16:31   Re: Using an array of enum hack to an adt_array
Reply With Quote #5

Quote:
Originally Posted by Miu View Post
Also, you can divide string lengths by 4 in enum hack things, it thinks it's a cell array and so would allocate 32 * 4 bytes for you with that
It is a cell array, do not do that.
__________________
asherkin is offline
dilalmon
AlliedModders Donor
Join Date: Apr 2013
Old 04-15-2015 , 16:38   Re: Using an array of enum hack to an adt_array
Reply With Quote #6

Wait, so I shouldn't use 16 for a 64-long String array in enum hack?
dilalmon is offline
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 04-15-2015 , 16:57   Re: Using an array of enum hack to an adt_array
Reply With Quote #7

You shouldn't be using an enum struct in the first place. You won't find support for it from anyone other than the people crazy enough and that already understand how they work.
__________________
VoiDeD is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-15-2015 , 17:23   Re: Using an array of enum hack to an adt_array
Reply With Quote #8

Quote:
Originally Posted by VoiDeD View Post
You shouldn't be using an enum struct in the first place. You won't find support for it from anyone other than the people crazy enough and that already understand how they work.
I'd feel better about that statement if enum structs weren't present in the core adminmenu plugin, added by pRED back in 2008.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 04-15-2015 , 17:53   Re: Using an array of enum hack to an adt_array
Reply With Quote #9

__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-15-2015 , 17:54   Re: Using an array of enum hack to an adt_array
Reply With Quote #10

Well have a 2015 statement: The use of enum structs is discouraged.
__________________
asherkin 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 13:35.


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