Jump to content

Recommended Posts

Posted

I found the following in a old bug tracker issue, moving it to developers chat so it is not lost (again).

In all honesty, I'd like to see some areas of the struct map_session_data; object being re-written or re-organized. The whole thing is one big lump of confused and mixed-up values.

IE:

unsigned int canlog_tick;

unsigned int canuseitem_tick; // [skotlex]

unsigned int canusecashfood_tick;

unsigned int canequip_tick; // [inkfish]

unsigned int cantalk_tick;

unsigned int canskill_tick; // used to prevent abuse from no-delay ACT files

unsigned int cansendmail_tick; // [Mail System Flood Protection]

unsigned int ks_floodprotect_tick; // [Kill Steal Protection]

Could be condensed down to:

struct {

unsigned int logout;

unsigned int item;

unsigned int cashfood;

unsigned int equip;

unsigned int talk;

unsigned int skill;

unsigned int mail;

unsigned int ks_floodprotect;

} tick;

That's only an example, there's likely to be a better way to write that block, however the point I'm making is that storing these values in an inline struct makes no difference to performance, it still points to the same memory address. This is definitely something worth looking into.

I'd also consider removing a lot of the static types in the structure, such as 'unsigned int' for time tick values, replacing them with system specific 'time_t' values (I believe some operating systems handle this type differently (ulong vs. uint) and it also adds structure/definition to the entire file header).

  • Upvote 2
  • 6 months later...

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...