summaryrefslogtreecommitdiff
path: root/src/char/int_guild.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/char/int_guild.c')
-rw-r--r--src/char/int_guild.c553
1 files changed, 123 insertions, 430 deletions
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 38c79ec28..c74c7f008 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -891,277 +891,7 @@ int inter_guild_calcinfo(struct guild *g)
return 0;
}
-//-------------------------------------------------------------------
-// Packet sent to map server
-
-int mapif_guild_created(int fd, int account_id, struct guild *g)
-{
- WFIFOHEAD(fd, 10);
- WFIFOW(fd,0)=0x3830;
- WFIFOL(fd,2)=account_id;
- if(g != NULL)
- {
- WFIFOL(fd,6)=g->guild_id;
- ShowInfo("int_guild: Guild created (%d - %s)\n",g->guild_id,g->name);
- } else
- WFIFOL(fd,6)=0;
-
- WFIFOSET(fd,10);
- return 0;
-}
-
-// Guild not found
-int mapif_guild_noinfo(int fd, int guild_id)
-{
- unsigned char buf[12];
- WBUFW(buf,0)=0x3831;
- WBUFW(buf,2)=8;
- WBUFL(buf,4)=guild_id;
- ShowWarning("int_guild: info not found %d\n",guild_id);
- if(fd<0)
- mapif->sendall(buf,8);
- else
- mapif->send(fd,buf,8);
- return 0;
-}
-
-// Send guild info
-int mapif_guild_info(int fd, struct guild *g)
-{
- unsigned char buf[8+sizeof(struct guild)];
- nullpo_ret(g);
- WBUFW(buf,0)=0x3831;
- WBUFW(buf,2)=4+sizeof(struct guild);
- memcpy(buf+4,g,sizeof(struct guild));
- if(fd<0)
- mapif->sendall(buf,WBUFW(buf,2));
- else
- mapif->send(fd,buf,WBUFW(buf,2));
- return 0;
-}
-
-// ACK member add
-int mapif_guild_memberadded(int fd, int guild_id, int account_id, int char_id, int flag)
-{
- WFIFOHEAD(fd, 15);
- WFIFOW(fd,0)=0x3832;
- WFIFOL(fd,2)=guild_id;
- WFIFOL(fd,6)=account_id;
- WFIFOL(fd,10)=char_id;
- WFIFOB(fd,14)=flag;
- WFIFOSET(fd,15);
- return 0;
-}
-
-// ACK member leave
-int mapif_guild_withdraw(int guild_id,int account_id,int char_id,int flag, const char *name, const char *mes)
-{
- unsigned char buf[55+NAME_LENGTH];
-
- nullpo_ret(name);
- nullpo_ret(mes);
-
- WBUFW(buf, 0)=0x3834;
- WBUFL(buf, 2)=guild_id;
- WBUFL(buf, 6)=account_id;
- WBUFL(buf,10)=char_id;
- WBUFB(buf,14)=flag;
- memcpy(WBUFP(buf,15),mes,40);
- memcpy(WBUFP(buf,55),name,NAME_LENGTH);
- mapif->sendall(buf,55+NAME_LENGTH);
- ShowInfo("int_guild: guild withdraw (%d - %d: %s - %s)\n",guild_id,account_id,name,mes);
- return 0;
-}
-
-// Send short member's info
-int mapif_guild_memberinfoshort(struct guild *g, int idx)
-{
- unsigned char buf[23];
- nullpo_ret(g);
- Assert_ret(idx >= 0 && idx < MAX_GUILD);
- WBUFW(buf, 0)=0x3835;
- WBUFL(buf, 2)=g->guild_id;
- WBUFL(buf, 6)=g->member[idx].account_id;
- WBUFL(buf,10)=g->member[idx].char_id;
- WBUFB(buf,14)=(unsigned char)g->member[idx].online;
- WBUFW(buf,15)=g->member[idx].lv;
- WBUFW(buf,17)=g->member[idx].class;
- WBUFL(buf,19)=g->member[idx].last_login;
- mapif->sendall(buf,23);
- return 0;
-}
-
-// Send guild broken
-int mapif_guild_broken(int guild_id, int flag)
-{
- unsigned char buf[7];
- WBUFW(buf,0)=0x3836;
- WBUFL(buf,2)=guild_id;
- WBUFB(buf,6)=flag;
- mapif->sendall(buf,7);
- ShowInfo("int_guild: Guild broken (%d)\n",guild_id);
- return 0;
-}
-
-// Send guild message
-int mapif_guild_message(int guild_id, int account_id, const char *mes, int len, int sfd)
-{
- unsigned char buf[512];
- nullpo_ret(mes);
- if (len > 500)
- len = 500;
- WBUFW(buf,0)=0x3837;
- WBUFW(buf,2)=len+12;
- WBUFL(buf,4)=guild_id;
- WBUFL(buf,8)=account_id;
- memcpy(WBUFP(buf,12),mes,len);
- mapif->sendallwos(sfd, buf,len+12);
- return 0;
-}
-
-// Send basic info
-int mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int len)
-{
- unsigned char buf[2048];
- nullpo_ret(data);
- if (len > 2038)
- len = 2038;
- WBUFW(buf, 0)=0x3839;
- WBUFW(buf, 2)=len+10;
- WBUFL(buf, 4)=guild_id;
- WBUFW(buf, 8)=type;
- memcpy(WBUFP(buf,10),data,len);
- mapif->sendall(buf,len+10);
- return 0;
-}
-
-// Send member info
-int mapif_guild_memberinfochanged(int guild_id, int account_id, int char_id, int type, const void *data, int len)
-{
- unsigned char buf[2048];
- nullpo_ret(data);
- if (len > 2030)
- len = 2030;
- WBUFW(buf, 0)=0x383a;
- WBUFW(buf, 2)=len+18;
- WBUFL(buf, 4)=guild_id;
- WBUFL(buf, 8)=account_id;
- WBUFL(buf,12)=char_id;
- WBUFW(buf,16)=type;
- memcpy(WBUFP(buf,18),data,len);
- mapif->sendall(buf,len+18);
- return 0;
-}
-
-// ACK guild skill up
-int mapif_guild_skillupack(int guild_id, uint16 skill_id, int account_id)
-{
- unsigned char buf[14];
- WBUFW(buf, 0)=0x383c;
- WBUFL(buf, 2)=guild_id;
- WBUFL(buf, 6)=skill_id;
- WBUFL(buf,10)=account_id;
- mapif->sendall(buf,14);
- return 0;
-}
-
-// ACK guild alliance
-int mapif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag, const char *name1, const char *name2)
-{
- unsigned char buf[19+2*NAME_LENGTH];
- nullpo_ret(name1);
- nullpo_ret(name2);
- WBUFW(buf, 0)=0x383d;
- WBUFL(buf, 2)=guild_id1;
- WBUFL(buf, 6)=guild_id2;
- WBUFL(buf,10)=account_id1;
- WBUFL(buf,14)=account_id2;
- WBUFB(buf,18)=flag;
- memcpy(WBUFP(buf,19),name1,NAME_LENGTH);
- memcpy(WBUFP(buf,19+NAME_LENGTH),name2,NAME_LENGTH);
- mapif->sendall(buf,19+2*NAME_LENGTH);
- return 0;
-}
-
-// Send a guild position desc
-int mapif_guild_position(struct guild *g, int idx)
-{
- unsigned char buf[12 + sizeof(struct guild_position)];
- nullpo_ret(g);
- Assert_ret(idx >= 0 && idx < MAX_GUILDPOSITION);
- WBUFW(buf,0)=0x383b;
- WBUFW(buf,2)=sizeof(struct guild_position)+12;
- WBUFL(buf,4)=g->guild_id;
- WBUFL(buf,8)=idx;
- memcpy(WBUFP(buf,12),&g->position[idx],sizeof(struct guild_position));
- mapif->sendall(buf,WBUFW(buf,2));
- return 0;
-}
-
-// Send the guild notice
-int mapif_guild_notice(struct guild *g)
-{
- unsigned char buf[256];
- nullpo_ret(g);
- WBUFW(buf,0)=0x383e;
- WBUFL(buf,2)=g->guild_id;
- memcpy(WBUFP(buf,6),g->mes1,MAX_GUILDMES1);
- memcpy(WBUFP(buf,66),g->mes2,MAX_GUILDMES2);
- mapif->sendall(buf,186);
- return 0;
-}
-
-// Send emblem data
-int mapif_guild_emblem(struct guild *g)
-{
- unsigned char buf[12 + sizeof(g->emblem_data)];
- nullpo_ret(g);
- WBUFW(buf,0)=0x383f;
- WBUFW(buf,2)=g->emblem_len+12;
- WBUFL(buf,4)=g->guild_id;
- WBUFL(buf,8)=g->emblem_id;
- memcpy(WBUFP(buf,12),g->emblem_data,g->emblem_len);
- mapif->sendall(buf,WBUFW(buf,2));
- return 0;
-}
-
-int mapif_guild_master_changed(struct guild *g, int aid, int cid)
-{
- unsigned char buf[14];
- nullpo_ret(g);
- WBUFW(buf,0)=0x3843;
- WBUFL(buf,2)=g->guild_id;
- WBUFL(buf,6)=aid;
- WBUFL(buf,10)=cid;
- mapif->sendall(buf,14);
- return 0;
-}
-
-int mapif_guild_castle_dataload(int fd, int sz, const int *castle_ids)
-{
- struct guild_castle *gc = NULL;
- int num = (sz - 4) / sizeof(int);
- int len = 4 + num * sizeof(*gc);
- int i;
-
- nullpo_ret(castle_ids);
- WFIFOHEAD(fd, len);
- WFIFOW(fd, 0) = 0x3840;
- WFIFOW(fd, 2) = len;
- for (i = 0; i < num; i++) {
- gc = inter_guild->castle_fromsql(*(castle_ids++));
- memcpy(WFIFOP(fd, 4 + i * sizeof(*gc)), gc, sizeof(*gc));
- }
- WFIFOSET(fd, len);
- return 0;
-}
-
-//-------------------------------------------------------------------
-// Packet received from map server
-
-
-// Guild creation request
-int mapif_parse_CreateGuild(int fd, int account_id, const char *name, const struct guild_member *master)
+struct guild *inter_guild_create(const char *name, const struct guild_member *master)
{
struct guild *g;
int i=0;
@@ -1172,21 +902,18 @@ int mapif_parse_CreateGuild(int fd, int account_id, const char *name, const stru
nullpo_ret(master);
if(inter_guild->search_guildname(name) != 0){
ShowInfo("int_guild: guild with same name exists [%s]\n",name);
- mapif->guild_created(fd,account_id,NULL);
- return 0;
+ return NULL;
}
// Check Authorized letters/symbols in the name of the character
if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorized
for (i = 0; i < NAME_LENGTH && name[i]; i++)
if (strchr(char_name_letters, name[i]) == NULL) {
- mapif->guild_created(fd,account_id,NULL);
- return 0;
+ return NULL;
}
} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
for (i = 0; i < NAME_LENGTH && name[i]; i++)
if (strchr(char_name_letters, name[i]) != NULL) {
- mapif->guild_created(fd,account_id,NULL);
- return 0;
+ return NULL;
}
}
@@ -1222,108 +949,79 @@ int mapif_parse_CreateGuild(int fd, int account_id, const char *name, const stru
if (!inter_guild->tosql(g,GS_BASIC|GS_POSITION|GS_SKILL|GS_MEMBER)) {
//Failed to Create guild....
ShowError("Failed to create Guild %s (Guild Master: %s)\n", g->name, g->master);
- mapif->guild_created(fd,account_id,NULL);
aFree(g);
- return 0;
+ return NULL;
}
ShowInfo("Created Guild %d - %s (Guild Master: %s)\n", g->guild_id, g->name, g->master);
//Add to cache
idb_put(inter_guild->guild_db, g->guild_id, g);
- // Report to client
- mapif->guild_created(fd,account_id,g);
- mapif->guild_info(fd,g);
-
if (inter->enable_logs)
inter->log("guild %s (id=%d) created by master %s (id=%d)\n",
name, g->guild_id, master->name, master->account_id);
- return 0;
-}
-
-// Return guild info to client
-int mapif_parse_GuildInfo(int fd, int guild_id)
-{
- struct guild * g = inter_guild->fromsql(guild_id); //We use this because on start-up the info of castle-owned guilds is required. [Skotlex]
- if(g)
- {
- if (!inter_guild->calcinfo(g))
- mapif->guild_info(fd,g);
- }
- else
- mapif->guild_noinfo(fd,guild_id); // Failed to load info
- return 0;
+ return g;
}
// Add member to guild
-int mapif_parse_GuildAddMember(int fd, int guild_id, const struct guild_member *m)
+bool inter_guild_add_member(int guild_id, const struct guild_member *member)
{
struct guild * g;
int i;
+ nullpo_ret(member);
- nullpo_ret(m);
g = inter_guild->fromsql(guild_id);
- if(g==NULL){
- mapif->guild_memberadded(fd,guild_id,m->account_id,m->char_id,1); // 1: Failed to add
- return 0;
- }
+ if (g == NULL)
+ return false;
// Find an empty slot
- for(i=0;i<g->max_member;i++)
- {
- if(g->member[i].account_id==0)
- {
- memcpy(&g->member[i],m,sizeof(struct guild_member));
+ for (i = 0; i < g->max_member; i++) {
+ if (g->member[i].account_id == 0) {
+ g->member[i] = *member;
g->member[i].modified = (GS_MEMBER_NEW | GS_MEMBER_MODIFIED);
- mapif->guild_memberadded(fd,guild_id,m->account_id,m->char_id,0); // 0: success
if (!inter_guild->calcinfo(g)) //Send members if it was not invoked.
- mapif->guild_info(-1,g);
+ mapif->guild_info(-1, g);
g->save_flag |= GS_MEMBER;
if (g->save_flag&GS_REMOVE)
g->save_flag&=~GS_REMOVE;
- return 0;
+ return true;
}
}
-
- mapif->guild_memberadded(fd,guild_id,m->account_id,m->char_id,1); // 1: Failed to add
- return 0;
+ return false;
}
// Delete member from guild
-int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, int flag, const char *mes)
+bool inter_guild_leave(int guild_id, int account_id, int char_id, int flag, const char *mes, int map_fd)
{
int i;
- struct guild* g = inter_guild->fromsql(guild_id);
- if( g == NULL )
- {
+ struct guild *g = inter_guild->fromsql(guild_id);
+ if (g == NULL) {
// Unknown guild, just update the player
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `account_id`='%d' AND `char_id`='%d'", char_db, account_id, char_id) )
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `account_id`='%d' AND `char_id`='%d'", char_db, account_id, char_id))
Sql_ShowDebug(inter->sql_handle);
// mapif->guild_withdraw(guild_id,account_id,char_id,flag,g->member[i].name,mes);
- return 0;
+ return false;
}
nullpo_ret(mes);
// Find the member
- 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 )
- {
+ 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) {
//TODO
- return 0;
+ return false;
}
if (flag) {
// Write expulsion reason
// Find an empty slot
int j;
- ARR_FIND( 0, MAX_GUILDEXPULSION, j, g->expulsion[j].account_id == 0 );
- if( j == MAX_GUILDEXPULSION )
- {
+ ARR_FIND(0, MAX_GUILDEXPULSION, j, g->expulsion[j].account_id == 0);
+ if (j == MAX_GUILDEXPULSION) {
// Expulsion list is full, flush the oldest one
- for( j = 0; j < MAX_GUILDEXPULSION - 1; j++ )
+ for (j = 0; j < MAX_GUILDEXPULSION - 1; j++)
g->expulsion[j] = g->expulsion[j+1];
j = MAX_GUILDEXPULSION-1;
}
@@ -1338,39 +1036,38 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in
memset(&g->member[i],0,sizeof(struct guild_member));
- if( inter_guild->check_empty(g) )
- mapif->parse_BreakGuild(-1,guild_id); //Break the guild.
- else {
+ if (inter_guild->check_empty(g)) {
+ inter_guild->disband(guild_id);
+ } else {
//Update member info.
if (!inter_guild->calcinfo(g))
- mapif->guild_info(fd,g);
+ mapif->guild_info(map_fd,g);
g->save_flag |= GS_EXPULSION;
}
- return 0;
+ return true;
}
// Change member info
-int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int16 class)
+bool inter_guild_update_member_info_short(int guild_id, int account_id, int char_id, int online, int lv, int16 class)
{
// Could speed up by manipulating only guild_member
- struct guild * g;
+ struct guild *g;
int i,sum,c;
int prev_count, prev_alv;
g = inter_guild->fromsql(guild_id);
- if(g==NULL)
- return 0;
+ if (g == NULL)
+ return false;
- 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 )
- {
+ 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) {
g->member[i].online = online;
g->member[i].lv = lv;
g->member[i].class = class;
g->member[i].last_login = (uint32)time(NULL);
g->member[i].modified = GS_MEMBER_MODIFIED;
- mapif->guild_memberinfoshort(g,i);
+ mapif->guild_memberinfoshort(g, i);
}
prev_count = g->connect_member;
@@ -1381,99 +1078,90 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id,
c = 0;
sum = 0;
- for( i = 0; i < g->max_member; i++ )
- {
- if( g->member[i].account_id > 0 )
- {
+ for (i = 0; i < g->max_member; i++) {
+ if (g->member[i].account_id > 0) {
sum += g->member[i].lv;
c++;
}
- if( g->member[i].online )
+ if (g->member[i].online)
g->connect_member++;
}
- if( c ) // this check should always succeed...
- {
+ if (c != 0) { // this check should always succeed...
g->average_lv = sum / c;
- if( g->connect_member != prev_count || g->average_lv != prev_alv )
+ if (g->connect_member != prev_count || g->average_lv != prev_alv)
g->save_flag |= GS_CONNECT;
- if( g->save_flag & GS_REMOVE )
+ if (g->save_flag & GS_REMOVE)
g->save_flag &= ~GS_REMOVE;
}
g->save_flag |= GS_MEMBER; //Update guild member data
- return 0;
+ return true;
}
// BreakGuild
-int mapif_parse_BreakGuild(int fd, int guild_id)
+bool inter_guild_disband(int guild_id)
{
- struct guild * g;
-
- g = inter_guild->fromsql(guild_id);
- if(g==NULL)
- return 0;
+ struct guild *g = inter_guild->fromsql(guild_id);
+ if (g == NULL)
+ return false;
// Delete guild from sql
//printf("- Delete guild %d from guild\n",guild_id);
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_db, guild_id) )
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_db, guild_id))
Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_member_db, guild_id) )
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_member_db, guild_id))
Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_castle_db, guild_id) )
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_castle_db, guild_id))
Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_storage_db, guild_id) )
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_storage_db, guild_id))
Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d' OR `alliance_id` = '%d'", guild_alliance_db, guild_id, guild_id) )
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d' OR `alliance_id` = '%d'", guild_alliance_db, guild_id, guild_id))
Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_position_db, guild_id) )
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_position_db, guild_id))
Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_skill_db, guild_id) )
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_skill_db, guild_id))
Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_expulsion_db, guild_id) )
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_expulsion_db, guild_id))
Sql_ShowDebug(inter->sql_handle);
//printf("- Update guild %d of char\n",guild_id);
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'", char_db, guild_id) )
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'", char_db, guild_id))
Sql_ShowDebug(inter->sql_handle);
- mapif->guild_broken(guild_id,0);
+ mapif->guild_broken(guild_id, 0);
if (inter->enable_logs)
inter->log("guild %s (id=%d) broken\n", g->name, guild_id);
//Remove the guild from memory. [Skotlex]
idb_remove(inter_guild->guild_db, guild_id);
- return 0;
-}
-// Forward Guild message to others map servers
-int mapif_parse_GuildMessage(int fd, int guild_id, int account_id, const char *mes, int len)
-{
- return mapif->guild_message(guild_id,account_id,mes,len, fd);
+ return true;
}
/**
* Changes basic guild information
* The types are available in mmo.h::guild_basic_info
**/
-int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const void *data, int len) {
+bool inter_guild_update_basic_info(int guild_id, int type, const void *data, int len)
+{
struct guild *g;
struct guild_skill gd_skill;
short value;
g = inter_guild->fromsql(guild_id);
- if( g == NULL )
- return 0;
+ if (g == NULL)
+ return false;
nullpo_ret(data);
- switch(type) {
+ switch (type) {
case GBI_EXP:
value = *((const int16 *)data);
if( value < 0 && abs(value) > g->exp )
@@ -1509,26 +1197,25 @@ int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const void
default:
ShowError("int_guild: GuildBasicInfoChange: Unknown type %d, see mmo.h::guild_basic_info for more information\n",type);
- return 0;
+ return false;
}
mapif->guild_info(-1,g);
g->save_flag |= GS_LEVEL;
- // Information is already sent in mapif->guild_info
- //mapif->guild_basicinfochanged(guild_id,type,data,len);
- return 0;
+
+ return true;
}
// 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)
+bool inter_guild_update_member_info(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
int i;
- struct guild * g;
+ struct guild *g;
nullpo_ret(data);
g = inter_guild->fromsql(guild_id);
if(g==NULL)
- return 0;
+ return false;
// Search the member
for (i = 0; i < g->max_member; i++) {
@@ -1540,7 +1227,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
if(i==g->max_member){
ShowWarning("int_guild: GuildMemberChange: Not found %d,%d in guild (%d - %s)\n",
account_id,char_id,guild_id,g->name);
- return 0;
+ return false;
}
switch(type)
@@ -1621,14 +1308,15 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
}
default:
ShowError("int_guild: GuildMemberInfoChange: Unknown type %d\n",type);
+ return false;
break;
}
- return 0;
+ return true;
}
int inter_guild_sex_changed(int guild_id, int account_id, int char_id, short gender)
{
- return mapif->parse_GuildMemberInfoChange(0, guild_id, account_id, char_id, GMI_GENDER, (const char*)&gender, sizeof(gender));
+ return inter_guild->update_member_info(guild_id, account_id, char_id, GMI_GENDER, (const char*)&gender, sizeof(gender));
}
int inter_guild_charname_changed(int guild_id, int account_id, int char_id, char *name)
@@ -1669,35 +1357,34 @@ int inter_guild_charname_changed(int guild_id, int account_id, int char_id, char
}
// Change a position desc
-int mapif_parse_GuildPosition(int fd, int guild_id, int idx, const struct guild_position *p)
+bool inter_guild_update_position(int guild_id, int idx, const struct guild_position *p)
{
// Could make some improvement in speed, because only change guild_position
- struct guild * g;
+ struct guild *g;
nullpo_ret(p);
g = inter_guild->fromsql(guild_id);
if(g==NULL || idx<0 || idx>=MAX_GUILDPOSITION)
- return 0;
+ return false;
memcpy(&g->position[idx],p,sizeof(struct guild_position));
mapif->guild_position(g,idx);
g->position[idx].modified = GS_POSITION_MODIFIED;
g->save_flag |= GS_POSITION; // Change guild_position
- return 0;
+ return true;
}
// Guild Skill UP
-int mapif_parse_GuildSkillUp(int fd, int guild_id, uint16 skill_id, int account_id, int max)
+bool inter_guild_use_skill_point(int guild_id, uint16 skill_id, int account_id, int max)
{
struct guild * g;
int idx = skill_id - GD_SKILLBASE;
g = inter_guild->fromsql(guild_id);
if(g == NULL || idx < 0 || idx >= MAX_GUILDSKILL)
- return 0;
+ return false;
- if(g->skill_point>0 && g->skill[idx].id>0 && g->skill[idx].lv<max )
- {
+ if (g->skill_point > 0 && g->skill[idx].id > 0 && g->skill[idx].lv < max) {
g->skill[idx].lv++;
g->skill_point--;
if (!inter_guild->calcinfo(g))
@@ -1705,11 +1392,11 @@ int mapif_parse_GuildSkillUp(int fd, int guild_id, uint16 skill_id, int account_
mapif->guild_skillupack(guild_id,skill_id,account_id);
g->save_flag |= (GS_LEVEL|GS_SKILL); // Change guild & guild_skill
}
- return 0;
+ return true;
}
//Manual deletion of an alliance when partnering guild does not exists. [Skotlex]
-int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int account_id1, int account_id2, int flag)
+bool inter_guild_remove_alliance(struct guild *g, int guild_id, int account_id1, int account_id2, int flag)
{
int i;
char name[NAME_LENGTH];
@@ -1717,18 +1404,18 @@ int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int account_i
nullpo_retr(-1, g);
ARR_FIND( 0, MAX_GUILDALLIANCE, i, g->alliance[i].guild_id == guild_id );
if( i == MAX_GUILDALLIANCE )
- return -1;
+ return false;
strcpy(name, g->alliance[i].name);
g->alliance[i].guild_id=0;
mapif->guild_alliance(g->guild_id,guild_id,account_id1,account_id2,flag,g->name,name);
g->save_flag |= GS_ALLIANCE;
- return 0;
+ return true;
}
// Alliance modification
-int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_id1, int account_id2, int flag)
+bool inter_guild_change_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag)
{
// Could speed up
struct guild *g[2] = { NULL };
@@ -1737,10 +1424,10 @@ int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_
g[1] = inter_guild->fromsql(guild_id2);
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 inter_guild->remove_alliance(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)
- return 0;
+ return false;
if( flag&GUILD_ALLIANCE_REMOVE ) {
// Remove alliance/opposition, in case of alliance, remove on both side
@@ -1769,11 +1456,11 @@ int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_
// Mark the two guild to be saved
g[0]->save_flag |= GS_ALLIANCE;
g[1]->save_flag |= GS_ALLIANCE;
- return 0;
+ return true;
}
// Change guild message
-int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char *mes2)
+bool inter_guild_update_notice(int guild_id, const char *mes1, const char *mes2)
{
struct guild *g;
@@ -1781,22 +1468,23 @@ int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char *
nullpo_ret(mes2);
g = inter_guild->fromsql(guild_id);
if(g==NULL)
- return 0;
+ return false;
memcpy(g->mes1,mes1,MAX_GUILDMES1);
memcpy(g->mes2,mes2,MAX_GUILDMES2);
g->save_flag |= GS_MES; //Change mes of guild
- return mapif->guild_notice(g);
+ mapif->guild_notice(g);
+ return true;
}
-int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char *data)
+bool inter_guild_update_emblem(int len, int guild_id, const char *data)
{
struct guild * g;
nullpo_ret(data);
g = inter_guild->fromsql(guild_id);
if(g==NULL)
- return 0;
+ return false;
if (len > sizeof(g->emblem_data))
len = sizeof(g->emblem_data);
@@ -1805,21 +1493,17 @@ int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char
g->emblem_len=len;
g->emblem_id++;
g->save_flag |= GS_EMBLEM; //Change guild
- return mapif->guild_emblem(g);
-}
-
-int mapif_parse_GuildCastleDataLoad(int fd, int len, const int *castle_ids)
-{
- return mapif->guild_castle_dataload(fd, len, castle_ids);
+ mapif->guild_emblem(g);
+ return true;
}
-int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value)
+bool inter_guild_update_castle_data(int castle_id, int index, int value)
{
struct guild_castle *gc = inter_guild->castle_fromsql(castle_id);
if (gc == NULL) {
- ShowError("mapif->parse_GuildCastleDataSave: castle id=%d not found\n", castle_id);
- return 0;
+ ShowError("inter_guild->update_castle_data: castle id=%d not found\n", castle_id);
+ return false;
}
switch (index) {
@@ -1845,14 +1529,14 @@ int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value)
gc->guardian[index-10].visible = value;
break;
}
- ShowError("mapif->parse_GuildCastleDataSave: not found index=%d\n", index);
- return 0;
+ ShowError("inter_guild->update_castle_data: not found index=%d\n", index);
+ return false;
}
inter_guild->castle_tosql(gc);
- return 0;
+ return true;
}
-int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int len)
+bool inter_guild_change_leader(int guild_id, const char *name, int len)
{
struct guild * g;
struct guild_member gm;
@@ -1887,7 +1571,8 @@ int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int le
ShowInfo("int_guild: Guildmaster Changed to %s (Guild %d - %s)\n",g->master, guild_id, g->name);
g->save_flag |= (GS_BASIC|GS_MEMBER); //Save main data and member data.
- return mapif->guild_master_changed(g, g->member[0].account_id, g->member[0].char_id);
+ mapif->guild_master_changed(g, g->member[0].account_id, g->member[0].char_id);
+ return true;
}
// Communication from the map server
@@ -1926,12 +1611,6 @@ int inter_guild_parse_frommap(int fd)
return 1;
}
-//Leave request from the server (for deleting character from guild)
-int inter_guild_leave(int guild_id, int account_id, int char_id)
-{
- return mapif->parse_GuildLeave(-1, guild_id, account_id, char_id, 0, "** Character Deleted **");
-}
-
int inter_guild_broken(int guild_id)
{
return mapif->guild_broken(guild_id, 0);
@@ -1965,6 +1644,20 @@ void inter_guild_defaults(void)
inter_guild->sex_changed = inter_guild_sex_changed;
inter_guild->charname_changed = inter_guild_charname_changed;
inter_guild->parse_frommap = inter_guild_parse_frommap;
- inter_guild->leave = inter_guild_leave;
inter_guild->broken = inter_guild_broken;
+ inter_guild->create = inter_guild_create;
+ inter_guild->add_member = inter_guild_add_member;
+ inter_guild->leave = inter_guild_leave;
+ inter_guild->update_member_info_short = inter_guild_update_member_info_short;
+ inter_guild->update_member_info = inter_guild_update_member_info;
+ inter_guild->disband = inter_guild_disband;
+ inter_guild->update_basic_info = inter_guild_update_basic_info;
+ inter_guild->update_position = inter_guild_update_position;
+ inter_guild->use_skill_point = inter_guild_use_skill_point;
+ inter_guild->remove_alliance = inter_guild_remove_alliance;
+ inter_guild->change_alliance = inter_guild_change_alliance;
+ inter_guild->update_notice = inter_guild_update_notice;
+ inter_guild->update_emblem = inter_guild_update_emblem;
+ inter_guild->update_castle_data = inter_guild_update_castle_data;
+ inter_guild->change_leader = inter_guild_change_leader;
}