Jump to content

Skill Data Filling


Maki

Recommended Posts


  • Group:  Members
  • Topic Count:  146
  • Topics Per Day:  0.03
  • Content Count:  1195
  • Reputation:   467
  • Joined:  11/15/11
  • Last Seen:  

Ind

We have about to...1k skills (and don't even have 3.2x in yet!)? The structure of each skill is filled of arrays limited by MAX_SKILL_LEVEL

struct s_skill_db {
char name[NAME_LENGTH];
char desc[40];
int range[MAX_SKILL_LEVEL],hit,inf,element[MAX_SKILL_LEVEL],nk,splash[MAX_SKILL_LEVEL],max;
int num[MAX_SKILL_LEVEL];
int cast[MAX_SKILL_LEVEL],walkdelay[MAX_SKILL_LEVEL],delay[MAX_SKILL_LEVEL];
int upkeep_time[MAX_SKILL_LEVEL],upkeep_time2[MAX_SKILL_LEVEL];
int castcancel,cast_def_rate;
int inf2,maxcount[MAX_SKILL_LEVEL],skill_type;
int blewcount[MAX_SKILL_LEVEL];
int hp[MAX_SKILL_LEVEL],sp[MAX_SKILL_LEVEL],mhp[MAX_SKILL_LEVEL],hp_rate[MAX_SKILL_LEVEL],sp_rate[MAX_SKILL_LEVEL],zeny[MAX_SKILL_LEVEL];
int weapon,ammo,ammo_qty[MAX_SKILL_LEVEL],state,spiritball[MAX_SKILL_LEVEL];
int itemid[MAX_SKILL_ITEM_REQUIRE],amount[MAX_SKILL_ITEM_REQUIRE];
int castnodex[MAX_SKILL_LEVEL], delaynodex[MAX_SKILL_LEVEL];
int nocast;
int unit_id[2];
int unit_layout_type[MAX_SKILL_LEVEL];
int unit_range[MAX_SKILL_LEVEL];
int unit_interval;
int unit_target;
int unit_flag;
};

And these arrays are not even left empty, after normal maximum level (say 10) is filled. All loaders auto populate empty values with the last valid value so that if ever (!!!) it receives a, say heal lvl 50, it answers with the last known value (which is for skill lvl 10). I've did a small test by reducing the MAX_SKILL_LEVEL from 100 to 10, and the RAM used by the map server after boot gone from 193MB down to 157MB. And it's not only about ram, its about that looping through these arrays when it wants info from a certain level, so during runtime it consumes extra CPU too.

Whats your opinion on this? Do you see/know the actual reason behind this monster?

Thank you for your time.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  146
  • Topics Per Day:  0.03
  • Content Count:  1195
  • Reputation:   467
  • Joined:  11/15/11
  • Last Seen:  

These "auto-populate"'rs I talked about are like this one from skill_split_atoi (the function behind all values delimited by a ':')

//Single value, have the whole range have the same value.
	for (; i < MAX_SKILL_LEVEL; i++)
		val[i] = val[i-1];

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  146
  • Topics Per Day:  0.03
  • Content Count:  1195
  • Reputation:   467
  • Joined:  11/15/11
  • Last Seen:  

GodLesZ

I think the main reason for this is "more memory but less cpu", just for request skill informations (skill_get_*()).

If they only save the available data, they had to check for sizeof() array for bound-checking.

Maybe this is less efficient?

Some sort of this could be the main purpose.

The second one is - eAthena, laziness. "Its working, so why changing?"..

There are some other ways for doing this, for sure.

I.e. using sizeof() to check the max bounds. So theres no need to fill up wasted space.

Maybe a *_count variable for storing array size after database loading ("more memory but less cpu" compromise) to save sizeof() calls.

In my C# server i used these two ways.

All data is stored in flat arrays, only available data of course, and a *_count variable saved the available count.

On a information request the *_count variable is checked against lv -1 and if fitting bounds, information will be returned.

Consumes less memory than 90 slots of wasted space and no cpu for live-time sizeof() checks.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...