|
@@ -112,7 +112,7 @@ int inter_guild_tosql(struct guild *g,int flag)
|
|
// GS_POSITION `guild_position` (`guild_id`,`position`,`name`,`mode`,`exp_mode`)
|
|
// GS_POSITION `guild_position` (`guild_id`,`position`,`name`,`mode`,`exp_mode`)
|
|
// GS_ALLIANCE `guild_alliance` (`guild_id`,`opposition`,`alliance_id`,`name`)
|
|
// GS_ALLIANCE `guild_alliance` (`guild_id`,`opposition`,`alliance_id`,`name`)
|
|
// GS_EXPULSION `guild_expulsion` (`guild_id`,`account_id`,`name`,`mes`)
|
|
// GS_EXPULSION `guild_expulsion` (`guild_id`,`account_id`,`name`,`mes`)
|
|
- // GS_SKILL `guild_skill` (`guild_id`,`id`,`lv`)
|
|
|
|
|
|
+ // GS_SKILL `guild_skill` (`guild_id`,`id`,`lv`)
|
|
|
|
|
|
// temporary storage for str convertion. They must be twice the size of the
|
|
// temporary storage for str convertion. They must be twice the size of the
|
|
// original string to ensure no overflows will occur. [Skotlex]
|
|
// original string to ensure no overflows will occur. [Skotlex]
|
|
@@ -123,7 +123,7 @@ int inter_guild_tosql(struct guild *g,int flag)
|
|
int i=0;
|
|
int i=0;
|
|
|
|
|
|
if (g->guild_id<=0 && g->guild_id != -1) return 0;
|
|
if (g->guild_id<=0 && g->guild_id != -1) return 0;
|
|
-
|
|
|
|
|
|
+
|
|
#ifdef NOISY
|
|
#ifdef NOISY
|
|
ShowInfo("Save guild request ("CL_BOLD"%d"CL_RESET" - flag 0x%x).",g->guild_id, flag);
|
|
ShowInfo("Save guild request ("CL_BOLD"%d"CL_RESET" - flag 0x%x).",g->guild_id, flag);
|
|
#endif
|
|
#endif
|
|
@@ -179,7 +179,7 @@ int inter_guild_tosql(struct guild *g,int flag)
|
|
StringBuf_Printf(&buf, "`emblem_len`=%d, `emblem_id`=%d, `emblem_data`='%s'", g->emblem_len, g->emblem_id, emblem_data);
|
|
StringBuf_Printf(&buf, "`emblem_len`=%d, `emblem_id`=%d, `emblem_data`='%s'", g->emblem_len, g->emblem_id, emblem_data);
|
|
add_comma = true;
|
|
add_comma = true;
|
|
}
|
|
}
|
|
- if (flag & GS_BASIC)
|
|
|
|
|
|
+ if (flag & GS_BASIC)
|
|
{
|
|
{
|
|
strcat(t_info, " basic");
|
|
strcat(t_info, " basic");
|
|
if( add_comma )
|
|
if( add_comma )
|
|
@@ -273,8 +273,8 @@ int inter_guild_tosql(struct guild *g,int flag)
|
|
|
|
|
|
if (flag&GS_ALLIANCE)
|
|
if (flag&GS_ALLIANCE)
|
|
{
|
|
{
|
|
- // Delete current alliances
|
|
|
|
- // NOTE: no need to do it on both sides since both guilds in memory had
|
|
|
|
|
|
+ // Delete current alliances
|
|
|
|
+ // NOTE: no need to do it on both sides since both guilds in memory had
|
|
// their info changed, not to mention this would also mess up oppositions!
|
|
// their info changed, not to mention this would also mess up oppositions!
|
|
// [Skotlex]
|
|
// [Skotlex]
|
|
//if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d' OR `alliance_id`='%d'", guild_alliance_db, g->guild_id, g->guild_id) )
|
|
//if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d' OR `alliance_id`='%d'", guild_alliance_db, g->guild_id, g->guild_id) )
|
|
@@ -516,7 +516,7 @@ struct guild * inter_guild_fromsql(int guild_id)
|
|
|
|
|
|
idb_put(guild_db_, guild_id, g); //Add to cache
|
|
idb_put(guild_db_, guild_id, g); //Add to cache
|
|
g->save_flag |= GS_REMOVE; //But set it to be removed, in case it is not needed for long.
|
|
g->save_flag |= GS_REMOVE; //But set it to be removed, in case it is not needed for long.
|
|
-
|
|
|
|
|
|
+
|
|
if (save_log)
|
|
if (save_log)
|
|
ShowInfo("Guild loaded (%d - %s)\n", guild_id, g->name);
|
|
ShowInfo("Guild loaded (%d - %s)\n", guild_id, g->name);
|
|
|
|
|
|
@@ -602,12 +602,12 @@ static struct guild_castle* inter_guildcastle_fromsql(int castle_id)
|
|
static bool exp_guild_parse_row(char* split[], int column, int current)
|
|
static bool exp_guild_parse_row(char* split[], int column, int current)
|
|
{
|
|
{
|
|
int exp = atoi(split[0]);
|
|
int exp = atoi(split[0]);
|
|
-
|
|
|
|
|
|
+
|
|
if (exp < 0 || exp >= INT_MAX) {
|
|
if (exp < 0 || exp >= INT_MAX) {
|
|
ShowError("exp_guild: Invalid exp %d at line %d\n", exp, current);
|
|
ShowError("exp_guild: Invalid exp %d at line %d\n", exp, current);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
guild_exp[current] = exp;
|
|
guild_exp[current] = exp;
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -617,7 +617,7 @@ int inter_guild_CharOnline(int char_id, int guild_id)
|
|
{
|
|
{
|
|
struct guild *g;
|
|
struct guild *g;
|
|
int i;
|
|
int i;
|
|
-
|
|
|
|
|
|
+
|
|
if (guild_id == -1) {
|
|
if (guild_id == -1) {
|
|
//Get guild_id from the database
|
|
//Get guild_id from the database
|
|
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
|
|
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
|
|
@@ -641,7 +641,7 @@ int inter_guild_CharOnline(int char_id, int guild_id)
|
|
}
|
|
}
|
|
if (guild_id == 0)
|
|
if (guild_id == 0)
|
|
return 0; //No guild...
|
|
return 0; //No guild...
|
|
-
|
|
|
|
|
|
+
|
|
g = inter_guild_fromsql(guild_id);
|
|
g = inter_guild_fromsql(guild_id);
|
|
if(!g) {
|
|
if(!g) {
|
|
ShowError("Character %d's guild %d not found!\n", char_id, guild_id);
|
|
ShowError("Character %d's guild %d not found!\n", char_id, guild_id);
|
|
@@ -692,7 +692,7 @@ int inter_guild_CharOffline(int char_id, int guild_id)
|
|
}
|
|
}
|
|
if (guild_id == 0)
|
|
if (guild_id == 0)
|
|
return 0; //No guild...
|
|
return 0; //No guild...
|
|
-
|
|
|
|
|
|
+
|
|
//Character has a guild, set character offline and check if they were the only member online
|
|
//Character has a guild, set character offline and check if they were the only member online
|
|
g = inter_guild_fromsql(guild_id);
|
|
g = inter_guild_fromsql(guild_id);
|
|
if (g == NULL) //Guild not found?
|
|
if (g == NULL) //Guild not found?
|
|
@@ -758,7 +758,7 @@ int search_guildname(char *str)
|
|
{
|
|
{
|
|
int guild_id;
|
|
int guild_id;
|
|
char esc_name[NAME_LENGTH*2+1];
|
|
char esc_name[NAME_LENGTH*2+1];
|
|
-
|
|
|
|
|
|
+
|
|
Sql_EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
|
|
Sql_EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
|
|
//Lookup guilds with the same name
|
|
//Lookup guilds with the same name
|
|
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE name='%s'", guild_db, esc_name) )
|
|
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE name='%s'", guild_db, esc_name) )
|
|
@@ -837,13 +837,13 @@ int guild_calcinfo(struct guild *g)
|
|
g->next_exp = nextexp;
|
|
g->next_exp = nextexp;
|
|
|
|
|
|
// Set the max number of members, Guild Extention skill - currently adds 6 to max per skill lv.
|
|
// Set the max number of members, Guild Extention skill - currently adds 6 to max per skill lv.
|
|
- g->max_member = 16 + guild_checkskill(g, GD_EXTENSION) * 6;
|
|
|
|
|
|
+ g->max_member = 16 + guild_checkskill(g, GD_EXTENSION) * 6;
|
|
if(g->max_member > MAX_GUILD)
|
|
if(g->max_member > MAX_GUILD)
|
|
{
|
|
{
|
|
ShowError("Guild %d:%s has capacity for too many guild members (%d), max supported is %d\n", g->guild_id, g->name, g->max_member, MAX_GUILD);
|
|
ShowError("Guild %d:%s has capacity for too many guild members (%d), max supported is %d\n", g->guild_id, g->name, g->max_member, MAX_GUILD);
|
|
g->max_member = MAX_GUILD;
|
|
g->max_member = MAX_GUILD;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Compute the guild average level level
|
|
// Compute the guild average level level
|
|
g->average_lv=0;
|
|
g->average_lv=0;
|
|
g->connect_member=0;
|
|
g->connect_member=0;
|
|
@@ -1193,7 +1193,7 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
ShowInfo("Created Guild %d - %s (Guild Master: %s)\n", g->guild_id, g->name, g->master);
|
|
ShowInfo("Created Guild %d - %s (Guild Master: %s)\n", g->guild_id, g->name, g->master);
|
|
-
|
|
|
|
|
|
+
|
|
//Add to cache
|
|
//Add to cache
|
|
idb_put(guild_db_, g->guild_id, g);
|
|
idb_put(guild_db_, g->guild_id, g);
|
|
|
|
|
|
@@ -1326,7 +1326,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id,int account_id,in
|
|
g = inter_guild_fromsql(guild_id);
|
|
g = inter_guild_fromsql(guild_id);
|
|
if(g==NULL)
|
|
if(g==NULL)
|
|
return 0;
|
|
return 0;
|
|
-
|
|
|
|
|
|
+
|
|
ARR_FIND( 0, g->max_member, i, g->member[i].account_id == account_id && g->member[i].char_id == char_id );
|
|
ARR_FIND( 0, g->max_member, i, g->member[i].account_id == account_id && g->member[i].char_id == char_id );
|
|
if( i < g->max_member )
|
|
if( i < g->max_member )
|
|
{
|
|
{
|
|
@@ -1372,7 +1372,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id,int account_id,in
|
|
int mapif_parse_BreakGuild(int fd,int guild_id)
|
|
int mapif_parse_BreakGuild(int fd,int guild_id)
|
|
{
|
|
{
|
|
struct guild * g;
|
|
struct guild * g;
|
|
-
|
|
|
|
|
|
+
|
|
g = inter_guild_fromsql(guild_id);
|
|
g = inter_guild_fromsql(guild_id);
|
|
if(g==NULL)
|
|
if(g==NULL)
|
|
return 0;
|
|
return 0;
|
|
@@ -1423,7 +1423,7 @@ int mapif_parse_GuildMessage(int fd,int guild_id,int account_id,char *mes,int le
|
|
return mapif_guild_message(guild_id,account_id,mes,len, fd);
|
|
return mapif_guild_message(guild_id,account_id,mes,len, fd);
|
|
}
|
|
}
|
|
|
|
|
|
-// Modification of the guild
|
|
|
|
|
|
+// Modification of the guild
|
|
int mapif_parse_GuildBasicInfoChange(int fd,int guild_id,int type,const char *data,int len)
|
|
int mapif_parse_GuildBasicInfoChange(int fd,int guild_id,int type,const char *data,int len)
|
|
{
|
|
{
|
|
struct guild * g;
|
|
struct guild * g;
|
|
@@ -1453,7 +1453,7 @@ int mapif_parse_GuildBasicInfoChange(int fd,int guild_id,int type,const char *da
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-// Modification of the guild
|
|
|
|
|
|
+// Modification of the guild
|
|
int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int char_id,int type,const char *data,int len)
|
|
int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int char_id,int type,const char *data,int len)
|
|
{
|
|
{
|
|
// Could make some improvement in speed, because only change guild_member
|
|
// Could make some improvement in speed, because only change guild_member
|
|
@@ -1598,7 +1598,7 @@ int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
mapif_guild_info(-1,g);
|
|
mapif_guild_info(-1,g);
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1653,7 +1653,7 @@ static int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int ac
|
|
|
|
|
|
strcpy(name, g->alliance[i].name);
|
|
strcpy(name, g->alliance[i].name);
|
|
g->alliance[i].guild_id=0;
|
|
g->alliance[i].guild_id=0;
|
|
-
|
|
|
|
|
|
+
|
|
mapif_guild_alliance(g->guild_id,guild_id,account_id1,account_id2,flag,g->name,name);
|
|
mapif_guild_alliance(g->guild_id,guild_id,account_id1,account_id2,flag,g->name,name);
|
|
g->save_flag |= GS_ALLIANCE;
|
|
g->save_flag |= GS_ALLIANCE;
|
|
return 0;
|
|
return 0;
|
|
@@ -1670,7 +1670,7 @@ int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,int account_id1
|
|
|
|
|
|
if(g[0] && g[1]==NULL && (flag & GUILD_ALLIANCE_REMOVE)) //Requested to remove an alliance with a not found guild.
|
|
if(g[0] && g[1]==NULL && (flag & GUILD_ALLIANCE_REMOVE)) //Requested to remove an alliance with a not found guild.
|
|
return mapif_parse_GuildDeleteAlliance(g[0], guild_id2, account_id1, account_id2, flag); //Try to do a manual removal of said guild.
|
|
return mapif_parse_GuildDeleteAlliance(g[0], guild_id2, account_id1, account_id2, flag); //Try to do a manual removal of said guild.
|
|
-
|
|
|
|
|
|
+
|
|
if(g[0]==NULL || g[1]==NULL)
|
|
if(g[0]==NULL || g[1]==NULL)
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
@@ -1794,16 +1794,16 @@ int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int le
|
|
int pos;
|
|
int pos;
|
|
|
|
|
|
g = inter_guild_fromsql(guild_id);
|
|
g = inter_guild_fromsql(guild_id);
|
|
-
|
|
|
|
|
|
+
|
|
if(g==NULL || len > NAME_LENGTH)
|
|
if(g==NULL || len > NAME_LENGTH)
|
|
return 0;
|
|
return 0;
|
|
-
|
|
|
|
|
|
+
|
|
// Find member (name)
|
|
// Find member (name)
|
|
for (pos = 0; pos < g->max_member && strncmp(g->member[pos].name, name, len); pos++);
|
|
for (pos = 0; pos < g->max_member && strncmp(g->member[pos].name, name, len); pos++);
|
|
|
|
|
|
if (pos == g->max_member)
|
|
if (pos == g->max_member)
|
|
return 0; //Character not found??
|
|
return 0; //Character not found??
|
|
-
|
|
|
|
|
|
+
|
|
// Switch current and old GM
|
|
// Switch current and old GM
|
|
memcpy(&gm, &g->member[pos], sizeof (struct guild_member));
|
|
memcpy(&gm, &g->member[pos], sizeof (struct guild_member));
|
|
memcpy(&g->member[pos], &g->member[0], sizeof(struct guild_member));
|
|
memcpy(&g->member[pos], &g->member[0], sizeof(struct guild_member));
|