TShock icon indicating copy to clipboard operation
TShock copied to clipboard

Natively implement better support for BitFlags

Open hakusaro opened this issue 6 years ago • 5 comments

In PlayerUpdateEventArgs and other arg types for packets, we just pass off a byte for a couple BitFlag operations.

If Terraria doesn't natively have enums for these, we should move to creating enums for the different options according to the MP packet structure and then deriving what we do based on interpreting these enums. Right now, we just do a lot of checking magic numbers, which is unclear to developers what's actually going on.

hakusaro avatar Dec 10 '17 16:12 hakusaro

Just FYI: Neither the receiving or sending methods have enums for BitFlag operations. Receiving Sending

bartico6 avatar Dec 10 '17 16:12 bartico6

Do you have an example of how you'd like this implemented @hakusaro ?

QuiCM avatar Dec 11 '17 23:12 QuiCM

@QuiCM http://www.cplusplus.com/forum/general/1590/#msg5591

hakusaro avatar Dec 11 '17 23:12 hakusaro

This will result in the creation of a number of different enums to support the different 'options' cases we get with these packets. Should plan out how we'll structure this (file-wise)

  • All {Type}Options in one file (yuck)
  • One {Type}Options per file (also yuck)

QuiCM avatar Dec 11 '17 23:12 QuiCM

image

image

image

This is my implementation. Idk if it's good.

AxeelAnder avatar May 05 '20 11:05 AxeelAnder