Skip to content
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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

jezztify
Copy link
Contributor

@jezztify jezztify commented Jun 2, 2017

  • Addressed Issue(s): N/A
  • Server Mode: Both
  • Description of Pull Request: To improve the Guild Activity Logging of rAthena.
    It works for the following Guild Logging activities:
  1. Guild Creation
  2. Guild Breakage
  3. Guild Member Addition
  4. Guild Member Removal/Leave
  5. Guild Alliance Formation
  6. Guild Alliance Breakage
  7. Guild Antagonist Formation
  8. Guild Antagonist Breakage
  9. Guild Castle Occupancy
  10. Guild Castle Abandonment

Source Modification + Database Modification

Copy link
Member

@secretdataz secretdataz left a comment

Upgrade file still missing.
Style changes could be removed for minimal diff.
Revert the function header change.

`target` VARCHAR(255) NULL DEFAULT NULL,
`castle_id` INT(11) NULL DEFAULT NULL
)
COLLATE='latin1_swedish_ci'
Copy link
Member

@secretdataz secretdataz Jun 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.


CREATE TABLE IF NOT EXISTS `interlog` (
`time` DATETIME NULL DEFAULT NULL,
`activity` VARCHAR(255) NULL DEFAULT NULL,
Copy link
Member

@secretdataz secretdataz Jun 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be an enum.

Copy link
Contributor Author

@jezztify jezztify Jun 3, 2017

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)
Copy link
Member

@secretdataz secretdataz Jun 3, 2017

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);
Copy link
Member

@secretdataz secretdataz Jun 3, 2017

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.

jezztify added 2 commits Jun 3, 2017
…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
}
}
}

// 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);

Copy link
Contributor

@aleos89 aleos89 Jun 3, 2017

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?

@@ -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);

Copy link
Contributor

@aleos89 aleos89 Jun 3, 2017

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
Copy link
Contributor

@aleos89 aleos89 Jun 3, 2017

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;
Copy link
Contributor

@aleos89 aleos89 Jun 3, 2017

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;

@Jeybla
Copy link
Contributor

@Jeybla Jeybla commented Jun 4, 2017

Looks like you want to move the inter_log from sql-files/main.sql to sql-files/logs.sql.
But you're still using the main sql-handle: sql_handle. Afaik logmysql_handle is only available for the map-server, so you may want to keep the definition of the inter_log table in sql-files/main.sql .

@jezztify
Copy link
Contributor Author

@jezztify jezztify commented Jun 4, 2017

@Jeybla noted on that. I will put it back. I wasn't aware of such thing. Thanks :)

aleos89
aleos89 approved these changes Jun 5, 2017
`target` VARCHAR(255) NULL DEFAULT NULL,
`castle_id` INT(11) NULL DEFAULT NULL
)
ENGINE=MyISAM;
Copy link
Contributor

@aleos89 aleos89 Jun 5, 2017

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.

@@ -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;
Copy link
Contributor

@aleos89 aleos89 Jun 5, 2017

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;
Copy link
Contributor

@aleos89 aleos89 Jun 5, 2017

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++) {
Copy link
Member

@secretdataz secretdataz Jun 5, 2017

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, ...);
Copy link
Member

@secretdataz secretdataz Jun 5, 2017

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
Copy link
Contributor

@aleos89 aleos89 Jun 16, 2017

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, ...)
Copy link
Contributor

@aleos89 aleos89 Jul 25, 2017

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.

Copy link

@anacondaq anacondaq Jul 25, 2017

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.

Copy link
Contributor Author

@jezztify jezztify Jul 26, 2017

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.

Copy link
Contributor

@aleos89 aleos89 Jul 26, 2017

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. 👍

Copy link
Contributor Author

@jezztify jezztify Jul 27, 2017

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)

@Akkarinage
Copy link
Member

@Akkarinage Akkarinage commented Oct 6, 2017

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants