-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring of chat struct #8013
base: master
Are you sure you want to change the base?
Refactoring of chat struct #8013
Conversation
Converted C constructs to modern cpp * Conversion of regular arrays to std::array, that allows iterating and size info * Conversion of functions to class methods when appropriate * Conversion of Macros to inline constexpr for easier: ** Scoping ** Rebuild ** Debugging * Declaration and definition on the same line, the closest to where it's used * Removed class-specifiers when possible Converted unused int return types to void Added namespace chats:: Applied google guidelines for naming conventions * CamelCase for structs, classes, typedefs, templates and functions * Underscore for local variables and namespaces * A trailing _ for private members
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Havent checked most of the chat.cpp changes, will do in the future
struct block_list* owner; | ||
uint32 min_level; // minimum base level to join | ||
uint32 max_level; // maximum base level allowed to join | ||
std::array<map_session_data*,MAX_CHAT_USERS> usersd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want an array here? can we use a vector instead? or is it so we don't have to change too much of the implementation
int chat_changechatowner(map_session_data* sd, const char* nextownername); | ||
int chat_changechatstatus(map_session_data* sd, const char* title, const char* pass, int limit, bool pub); | ||
int chat_kickchat(map_session_data* sd, const char* kickusername); | ||
void TriggerEvent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a nitpick, but we have more methods that are camelCase than PascalCase, I like the former more imo
uint32 users; // current user count | ||
uint32 limit; // join limit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why to increase the storage of these?
if it's to keep in line with MAX_CHAT_USERS, we can either change the storage type of MAX_CHAT_USERS, or have some static_assert comparing with std::numeric_limit<decltype(ChatData::users)>::max()
|
||
nullpo_ret(sd); | ||
ChatData* cd = (ChatData*)map_id2bl(chatid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should replace every usage of (ChatData*)map_id2bl(chatid)
with map_id2cd(chatid)
; we get the BL_CAST for free
Refactoring of chat struct
Converted C constructs to modern cpp
Converted unused int return types to void
Added namespace chats::
Applied google guidelines for naming conventions