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
Feature/improved guild logging #2185
base: master
Are you sure you want to change the base?
Conversation
Upgrade file still missing.
Style changes could be removed for minimal diff.
Revert the function header change.
sql-files/logs.sql
Outdated
| `target` VARCHAR(255) NULL DEFAULT NULL, | ||
| `castle_id` INT(11) NULL DEFAULT NULL | ||
| ) | ||
| COLLATE='latin1_swedish_ci' |
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.
Remove this.
sql-files/logs.sql
Outdated
|
|
||
| CREATE TABLE IF NOT EXISTS `interlog` ( | ||
| `time` DATETIME NULL DEFAULT NULL, | ||
| `activity` VARCHAR(255) NULL DEFAULT NULL, |
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.
Could be an enum.
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.
How about existing logs? Should we preserve them for the upgrades part of the sql?
src/char/inter.c
Outdated
| @@ -815,18 +815,14 @@ static int inter_config_read(const char* cfgName) | |||
| } | |||
|
|
|||
| // Save interlog into sql | |||
| int inter_log(char* fmt, ...) | |||
| int inter_log(char* activity, char* origin, char* target, struct guild *g, int castle_id) | |||
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.
Use the va_list instead of changing the function header.
src/char/inter.h
Outdated
| @@ -26,7 +26,7 @@ void mapif_accinfo_ack(bool success, int map_fd, int u_fd, int u_aid, int accoun | |||
| int group_id, int logincount, int state, const char *email, const char *last_ip, const char *lastlogin, | |||
| const char *birthdate, const char *user_pass, const char *pincode, const char *userid); | |||
|
|
|||
| int inter_log(char *fmt,...); | |||
| int inter_log(char* activity, char* initiator, char* guild_member, struct guild *g, int castle_id); | |||
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.
Use the va_list instead of changing the function header.
…ged activity column to enum type. Used va_list in inter_log function. Reverted interlog header but changed to receive int ArgNum to count passed arguments. Thanks @secretdataz
src/char/int_guild.c
Outdated
| } | ||
| } | ||
| } | ||
|
|
||
| // Send on all map the new alliance/opposition | ||
| mapif_guild_alliance(guild_id1,guild_id2,account_id1,account_id2,flag,g[0]->name,g[1]->name); | ||
|
|
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.
Can you add this space back since it's not related to the PR?
src/char/int_guild.c
Outdated
| @@ -1760,7 +1774,6 @@ int mapif_parse_GuildCastleDataLoad(int fd, int len, int *castle_ids) | |||
| int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value) | |||
| { | |||
| struct guild_castle *gc = inter_guildcastle_fromsql(castle_id); | |||
|
|
|||
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.
Can you add this space back since it's not related to the PR?
src/char/inter.c
Outdated
| int inter_log(char* fmt, ...) | ||
| { | ||
| // order of passed args: | ||
| // activity, origin, target, guild pointer, castle_id |
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.
/**
* Save interlog values to SQL
* @param ArgNum: Number of arguments
* Supplied arguments: activity, origin, target, guild pointer, castle_id
* @return 0
*/
src/char/inter.c
Outdated
| char* target; | ||
| int gid = 0; | ||
| int castle_id = 0; | ||
| int i; |
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.
You could line all these up so each one doesn't have it's own declaration line. IE:
char *activity, *origin, *target;
int gid = 0, castle_id = 0, i;|
Looks like you want to move the inter_log from |
|
@Jeybla noted on that. I will put it back. I wasn't aware of such thing. Thanks :) |
| `target` VARCHAR(255) NULL DEFAULT NULL, | ||
| `castle_id` INT(11) NULL DEFAULT NULL | ||
| ) | ||
| ENGINE=MyISAM; |
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.
Don't forget to add a newline here at the end of the file.
sql-files/logs.sql
Outdated
| @@ -224,4 +224,4 @@ CREATE TABLE IF NOT EXISTS `zenylog` ( | |||
| `map` varchar(11) NOT NULL default '', | |||
| PRIMARY KEY (`id`), | |||
| INDEX (`type`) | |||
| ) ENGINE=MyISAM AUTO_INCREMENT=1; | |||
| ) ENGINE=MyISAM AUTO_INCREMENT=1; | |||
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.
Don't forget to add a newline here at the end of the file.
| `target` VARCHAR(255) NULL DEFAULT NULL, | ||
| `castle_id` INT(11) NULL DEFAULT NULL | ||
| ) | ||
| ENGINE=MyISAM; |
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.
Don't forget to add a newline here at the end of the file.
src/char/inter.c
Outdated
| int gid = 0, castle_id = 0, i; | ||
|
|
||
| va_start(ap, ArgNum); | ||
| for (i = 0; i < ArgNum; i++) { |
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.
Unnecessary for-loop. Just do
a = va_arg(ap, type);
b = va_arg(ap, type);
...
x = va_arg(ap, type);
src/char/inter.h
Outdated
| @@ -26,7 +26,7 @@ void mapif_accinfo_ack(bool success, int map_fd, int u_fd, int u_aid, int accoun | |||
| int group_id, int logincount, int state, const char *email, const char *last_ip, const char *lastlogin, | |||
| const char *birthdate, const char *user_pass, const char *pincode, const char *userid); | |||
|
|
|||
| int inter_log(char *fmt,...); | |||
| int inter_log(int ArgNum, ...); | |||
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.
ArgNum is not needed.
…ted back to original inter_log header and va_list handling. Thanks @aleos89 @secretdataz
src/char/inter.c
Outdated
| @@ -820,32 +820,18 @@ static int inter_config_read(const char* cfgName) | |||
| * Supplied arguments: activity, origin, target, guild pointer, castle_id | |||
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.
The line above this, you will need to adjust the comment now from:
@param ArgNum: Number of arguments
to
@param fmt: Pointer containing the type of activity to be stored
| * @param fmt: Pointer containing the type of activity to be stored | ||
| * Supplied arguments: activity, origin, target, guild pointer, castle_id | ||
| * @return 0 | ||
| */ | ||
| int inter_log(char* fmt, ...) |
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.
I'm thinking that if we always pass the same amount of arguments over to the log function, why are we using va_arg? It would be best to just define all the parameters out.
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.
Because a lot of code in *athena wrote by people who wish just show their skills in coding and show how they are good, without thinking that others must read their codes and continue development. Good code = short, and easy to understand, well documented, or self-documented.
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.
@aleos89 that's actually one of the reasons why I wanted to explicitly pass the values in that function and another thing is that, we're using SQL which is rigid.
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.
Right. Whenever you have the time and want to update the function to reflect the changes we can start the process of getting this merged into master.
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.
alright. I'll find some time. THank you. (y)
|
It'd be great if we can get the ball rolling again on this PR - @jezznar do you have any updates for this in your local branch? |
It works for the following Guild Logging activities:
Source Modification + Database Modification