summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c7729
1 files changed, 4222 insertions, 3507 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 961e3bf0c..0c5143ffd 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/cbasetypes.h"
#include "../common/socket.h"
@@ -12,6 +13,7 @@
#include "../common/strlib.h"
#include "../common/utils.h"
#include "../common/ers.h"
+#include "../common/conf.h"
#include "map.h"
#include "chrif.h"
@@ -42,6 +44,8 @@
#include "clif.h"
#include "mail.h"
#include "quest.h"
+#include "packets_struct.h"
+#include "irc-bot.h"
#include <stdio.h>
#include <stdlib.h>
@@ -49,28 +53,16 @@
#include <stdarg.h>
#include <time.h>
-/* for clif_clearunit_delayed */
-static struct eri *delay_clearunit_ers;
-
//#define DUMP_UNKNOWN_PACKET
//#define DUMP_INVALID_PACKET
-struct Clif_Config {
- int packet_db_ver; //Preferred packet version.
- int connect_cmd[MAX_PACKET_VER + 1]; //Store the connect command for all versions. [Skotlex]
-} clif_config;
-
-struct s_packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB + 1];
-
//Converts item type in case of pet eggs.
-static inline int itemtype(int type)
-{
+static inline int itemtype(int type) {
return ( type == IT_PETEGG ) ? IT_WEAPON : type;
}
-static inline void WBUFPOS(uint8* p, unsigned short pos, short x, short y, unsigned char dir)
-{
+static inline void WBUFPOS(uint8* p, unsigned short pos, short x, short y, unsigned char dir) {
p += pos;
p[0] = (uint8)(x>>2);
p[1] = (uint8)((x<<6) | ((y>>4)&0x3f));
@@ -79,8 +71,7 @@ static inline void WBUFPOS(uint8* p, unsigned short pos, short x, short y, unsig
// client-side: x0+=sx0*0.0625-0.5 and y0+=sy0*0.0625-0.5
-static inline void WBUFPOS2(uint8* p, unsigned short pos, short x0, short y0, short x1, short y1, unsigned char sx0, unsigned char sy0)
-{
+static inline void WBUFPOS2(uint8* p, unsigned short pos, short x0, short y0, short x1, short y1, unsigned char sx0, unsigned char sy0) {
p += pos;
p[0] = (uint8)(x0>>2);
p[1] = (uint8)((x0<<6) | ((y0>>4)&0x3f));
@@ -91,20 +82,17 @@ static inline void WBUFPOS2(uint8* p, unsigned short pos, short x0, short y0, sh
}
-static inline void WFIFOPOS(int fd, unsigned short pos, short x, short y, unsigned char dir)
-{
+static inline void WFIFOPOS(int fd, unsigned short pos, short x, short y, unsigned char dir) {
WBUFPOS(WFIFOP(fd,pos), 0, x, y, dir);
}
-static inline void WFIFOPOS2(int fd, unsigned short pos, short x0, short y0, short x1, short y1, unsigned char sx0, unsigned char sy0)
-{
+static inline void WFIFOPOS2(int fd, unsigned short pos, short x0, short y0, short x1, short y1, unsigned char sx0, unsigned char sy0) {
WBUFPOS2(WFIFOP(fd,pos), 0, x0, y0, x1, y1, sx0, sy0);
}
-static inline void RBUFPOS(const uint8* p, unsigned short pos, short* x, short* y, unsigned char* dir)
-{
+static inline void RBUFPOS(const uint8* p, unsigned short pos, short* x, short* y, unsigned char* dir) {
p += pos;
if( x ) {
@@ -121,8 +109,7 @@ static inline void RBUFPOS(const uint8* p, unsigned short pos, short* x, short*
}
-static inline void RBUFPOS2(const uint8* p, unsigned short pos, short* x0, short* y0, short* x1, short* y1, unsigned char* sx0, unsigned char* sy0)
-{
+static inline void RBUFPOS2(const uint8* p, unsigned short pos, short* x0, short* y0, short* x1, short* y1, unsigned char* sx0, unsigned char* sy0) {
p += pos;
if( x0 ) {
@@ -151,28 +138,24 @@ static inline void RBUFPOS2(const uint8* p, unsigned short pos, short* x0, short
}
-static inline void RFIFOPOS(int fd, unsigned short pos, short* x, short* y, unsigned char* dir)
-{
+static inline void RFIFOPOS(int fd, unsigned short pos, short* x, short* y, unsigned char* dir) {
RBUFPOS(RFIFOP(fd,pos), 0, x, y, dir);
}
-static inline void RFIFOPOS2(int fd, unsigned short pos, short* x0, short* y0, short* x1, short* y1, unsigned char* sx0, unsigned char* sy0)
-{
+static inline void RFIFOPOS2(int fd, unsigned short pos, short* x0, short* y0, short* x1, short* y1, unsigned char* sx0, unsigned char* sy0) {
RBUFPOS2(WFIFOP(fd,pos), 0, x0, y0, x1, y1, sx0, sy0);
}
//To idenfity disguised characters.
-static inline bool disguised(struct block_list* bl)
-{
- return (bool)( bl->type == BL_PC && ((TBL_PC*)bl)->disguise );
+static inline bool disguised(struct block_list* bl) {
+ return (bool)( bl->type == BL_PC && ((TBL_PC*)bl)->disguise != -1 );
}
//Guarantees that the given string does not exceeds the allowed size, as well as making sure it's null terminated. [Skotlex]
-static inline unsigned int mes_len_check(char* mes, unsigned int len, unsigned int max)
-{
+static inline unsigned int mes_len_check(char* mes, unsigned int len, unsigned int max) {
if( len > max )
len = max;
@@ -181,38 +164,27 @@ static inline unsigned int mes_len_check(char* mes, unsigned int len, unsigned i
return len;
}
-
-static char map_ip_str[128];
-static uint32 map_ip;
-static uint32 bind_ip = INADDR_ANY;
-static uint16 map_port = 5121;
-int map_fd;
-
-static int clif_parse (int fd);
-
/*==========================================
* Ip setting of map-server
*------------------------------------------*/
-int clif_setip(const char* ip)
-{
+int clif_setip(const char* ip) {
char ip_str[16];
- map_ip = host2ip(ip);
- if (!map_ip) {
+ clif->map_ip = host2ip(ip);
+ if (!clif->map_ip) {
ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
return 0;
}
- strncpy(map_ip_str, ip, sizeof(map_ip_str));
- ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(map_ip, ip_str));
+ safestrncpy(clif->map_ip_str, ip, sizeof(clif->map_ip_str));
+ ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(clif->map_ip, ip_str));
return 1;
}
-void clif_setbindip(const char* ip)
-{
- char ip_str[16];
- bind_ip = host2ip(ip);
- if (bind_ip) {
- ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(bind_ip, ip_str));
+void clif_setbindip(const char* ip) {
+ clif->bind_ip = host2ip(ip);
+ if (clif->bind_ip) {
+ char ip_str[16];
+ ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(clif->bind_ip, ip_str));
} else {
ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
}
@@ -224,7 +196,7 @@ void clif_setbindip(const char* ip)
*------------------------------------------*/
void clif_setport(uint16 port)
{
- map_port = port;
+ clif->map_port = port;
}
/*==========================================
@@ -232,21 +204,7 @@ void clif_setport(uint16 port)
*------------------------------------------*/
uint32 clif_getip(void)
{
- return map_ip;
-}
-
-//Refreshes map_server ip, returns the new ip if the ip changed, otherwise it returns 0.
-uint32 clif_refresh_ip(void)
-{
- uint32 new_ip;
-
- new_ip = host2ip(map_ip_str);
- if (new_ip && new_ip != map_ip) {
- map_ip = new_ip;
- ShowInfo("Updating IP resolution of [%s].\n", map_ip_str);
- return map_ip;
- }
- return 0;
+ return clif->map_ip;
}
/*==========================================
@@ -254,23 +212,35 @@ uint32 clif_refresh_ip(void)
*------------------------------------------*/
uint16 clif_getport(void)
{
- return map_port;
+ return clif->map_port;
+}
+
+uint32 clif_refresh_ip(void) {
+ uint32 new_ip;
+
+ new_ip = host2ip(clif->map_ip_str);
+ if (new_ip && new_ip != clif->map_ip) {
+ clif->map_ip = new_ip;
+ ShowInfo("Updating IP resolution of [%s].\n", clif->map_ip_str);
+ return clif->map_ip;
+ }
+ return 0;
}
#if PACKETVER >= 20071106
static inline unsigned char clif_bl_type(struct block_list *bl) {
switch (bl->type) {
- case BL_PC: return disguised(bl)?0x1:0x0; //PC_TYPE
- case BL_ITEM: return 0x2; //ITEM_TYPE
- case BL_SKILL: return 0x3; //SKILL_TYPE
- case BL_CHAT: return 0x4; //UNKNOWN_TYPE
- case BL_MOB: return pcdb_checkid(status_get_viewdata(bl)->class_)?0x0:0x5; //NPC_MOB_TYPE
- case BL_NPC: return 0x6; //NPC_EVT_TYPE
- case BL_PET: return pcdb_checkid(status_get_viewdata(bl)->class_)?0x0:0x7; //NPC_PET_TYPE
- case BL_HOM: return 0x8; //NPC_HOM_TYPE
- case BL_MER: return 0x9; //NPC_MERSOL_TYPE
- case BL_ELEM: return 0xa; //NPC_ELEMENTAL_TYPE
- default: return 0x1; //NPC_TYPE
+ case BL_PC: return (disguised(bl) && !pcdb_checkid(status_get_viewdata(bl)->class_))? 0x1:0x0; //PC_TYPE
+ case BL_ITEM: return 0x2; //ITEM_TYPE
+ case BL_SKILL: return 0x3; //SKILL_TYPE
+ case BL_CHAT: return 0x4; //UNKNOWN_TYPE
+ case BL_MOB: return pcdb_checkid(status_get_viewdata(bl)->class_)?0x0:0x5; //NPC_MOB_TYPE
+ case BL_NPC: return 0x6; //NPC_EVT_TYPE
+ case BL_PET: return pcdb_checkid(status_get_viewdata(bl)->class_)?0x0:0x7; //NPC_PET_TYPE
+ case BL_HOM: return 0x8; //NPC_HOM_TYPE
+ case BL_MER: return 0x9; //NPC_MERSOL_TYPE
+ case BL_ELEM: return 0xa; //NPC_ELEMENTAL_TYPE
+ default: return 0x1; //NPC_TYPE
}
}
#endif
@@ -285,57 +255,51 @@ static inline unsigned char clif_bl_type(struct block_list *bl) {
* - AREA_WOS (AREA WITHOUT SELF) : Not run for self
* - AREA_CHAT_WOC : Everyone in the area of your chat without a chat
*------------------------------------------*/
-static int clif_send_sub(struct block_list *bl, va_list ap)
-{
+int clif_send_sub(struct block_list *bl, va_list ap) {
struct block_list *src_bl;
struct map_session_data *sd;
- unsigned char *buf;
+ void *buf;
int len, type, fd;
nullpo_ret(bl);
nullpo_ret(sd = (struct map_session_data *)bl);
fd = sd->fd;
- if (!fd) //Don't send to disconnected clients.
+ if (!fd || session[fd] == NULL) //Don't send to disconnected clients.
return 0;
- buf = va_arg(ap,unsigned char*);
+ buf = va_arg(ap,void*);
len = va_arg(ap,int);
nullpo_ret(src_bl = va_arg(ap,struct block_list*));
type = va_arg(ap,int);
- switch(type)
- {
- case AREA_WOS:
- if (bl == src_bl)
- return 0;
- break;
- case AREA_WOC:
- if (sd->chatID || bl == src_bl)
- return 0;
- break;
- case AREA_WOSC:
- {
- if(src_bl->type == BL_PC){
- struct map_session_data *ssd = (struct map_session_data *)src_bl;
- if (ssd && sd->chatID && (sd->chatID == ssd->chatID))
- return 0;
- }
- else if(src_bl->type == BL_NPC) {
- struct npc_data *nd = (struct npc_data *)src_bl;
- if (nd && sd->chatID && (sd->chatID == nd->chat_id))
- return 0;
+ switch(type) {
+ case AREA_WOS:
+ if (bl == src_bl)
+ return 0;
+ break;
+ case AREA_WOC:
+ if (sd->chatID || bl == src_bl)
+ return 0;
+ break;
+ case AREA_WOSC: {
+ if(src_bl->type == BL_PC){
+ struct map_session_data *ssd = (struct map_session_data *)src_bl;
+ if (ssd && sd->chatID && (sd->chatID == ssd->chatID))
+ return 0;
+ }
+ else if(src_bl->type == BL_NPC) {
+ struct npc_data *nd = (struct npc_data *)src_bl;
+ if (nd && sd->chatID && (sd->chatID == nd->chat_id))
+ return 0;
+ }
}
+ break;
}
- break;
- }
-
- if (session[fd] == NULL)
- return 0;
WFIFOHEAD(fd, len);
if (WFIFOP(fd,0) == buf) {
- ShowError("WARNING: Invalid use of clif_send function\n");
+ ShowError("WARNING: Invalid use of clif->send function\n");
ShowError(" Packet x%4x use a WFIFO of a player instead of to use a buffer.\n", WBUFW(buf,0));
ShowError(" Please correct your code.\n");
// don't send to not move the pointer of the packet for next sessions in the loop
@@ -344,10 +308,8 @@ static int clif_send_sub(struct block_list *bl, va_list ap)
return 0;
}
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd,len);
- }
+ memcpy(WFIFOP(fd,0), buf, len);
+ WFIFOSET(fd,len);
return 0;
}
@@ -356,8 +318,7 @@ static int clif_send_sub(struct block_list *bl, va_list ap)
* Packet Delegation (called on all packets that require data to be sent to more than one client)
* functions that are sent solely to one use whose ID it posses use WFIFOSET
*------------------------------------------*/
-int clif_send(const uint8* buf, int len, struct block_list* bl, enum send_target type)
-{
+int clif_send(const void* buf, int len, struct block_list* bl, enum send_target type) {
int i;
struct map_session_data *sd, *tsd;
struct party_data *p = NULL;
@@ -366,298 +327,250 @@ int clif_send(const uint8* buf, int len, struct block_list* bl, enum send_target
int x0 = 0, x1 = 0, y0 = 0, y1 = 0, fd;
struct s_mapiterator* iter;
- if( type != ALL_CLIENT && type != CHAT_MAINCHAT )
+ if( type != ALL_CLIENT )
nullpo_ret(bl);
sd = BL_CAST(BL_PC, bl);
switch(type) {
- case ALL_CLIENT: //All player clients.
- iter = mapit_getallusers();
- while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL )
- {
- if( packet_db[tsd->packet_ver][RBUFW(buf,0)].len )
- { // packet must exist for the client version
+ case ALL_CLIENT: //All player clients.
+ iter = mapit_getallusers();
+ while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) {
WFIFOHEAD(tsd->fd, len);
memcpy(WFIFOP(tsd->fd,0), buf, len);
WFIFOSET(tsd->fd,len);
}
- }
- mapit_free(iter);
- break;
+ mapit->free(iter);
+ break;
- case ALL_SAMEMAP: //All players on the same map
- iter = mapit_getallusers();
- while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL )
- {
- if( bl->m == tsd->bl.m && packet_db[tsd->packet_ver][RBUFW(buf,0)].len )
- { // packet must exist for the client version
- WFIFOHEAD(tsd->fd, len);
- memcpy(WFIFOP(tsd->fd,0), buf, len);
- WFIFOSET(tsd->fd,len);
+ case ALL_SAMEMAP: //All players on the same map
+ iter = mapit_getallusers();
+ while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) {
+ if( bl->m == tsd->bl.m ) {
+ WFIFOHEAD(tsd->fd, len);
+ memcpy(WFIFOP(tsd->fd,0), buf, len);
+ WFIFOSET(tsd->fd,len);
+ }
}
- }
- mapit_free(iter);
- break;
+ mapit->free(iter);
+ break;
- case AREA:
- case AREA_WOSC:
- if (sd && bl->prev == NULL) //Otherwise source misses the packet.[Skotlex]
- clif_send (buf, len, bl, SELF);
- case AREA_WOC:
- case AREA_WOS:
- map_foreachinarea(clif_send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE,
- BL_PC, buf, len, bl, type);
- break;
- case AREA_CHAT_WOC:
- map_foreachinarea(clif_send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5),
- bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC);
- break;
+ case AREA:
+ case AREA_WOSC:
+ if (sd && bl->prev == NULL) //Otherwise source misses the packet.[Skotlex]
+ clif->send (buf, len, bl, SELF);
+ case AREA_WOC:
+ case AREA_WOS:
+ map_foreachinarea(clif->send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE,
+ BL_PC, buf, len, bl, type);
+ break;
+ case AREA_CHAT_WOC:
+ map_foreachinarea(clif->send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5),
+ bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC);
+ break;
- case CHAT:
- case CHAT_WOS:
- {
- struct chat_data *cd;
- if (sd) {
- cd = (struct chat_data*)map_id2bl(sd->chatID);
- } else if (bl->type == BL_CHAT) {
- cd = (struct chat_data*)bl;
- } else break;
- if (cd == NULL)
- break;
- for(i = 0; i < cd->users; i++) {
- if (type == CHAT_WOS && cd->usersd[i] == sd)
- continue;
- if (packet_db[cd->usersd[i]->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- if ((fd=cd->usersd[i]->fd) >0 && session[fd]) // Added check to see if session exists [PoW]
- {
+ case CHAT:
+ case CHAT_WOS:
+ {
+ struct chat_data *cd;
+ if (sd) {
+ cd = (struct chat_data*)map_id2bl(sd->chatID);
+ } else if (bl->type == BL_CHAT) {
+ cd = (struct chat_data*)bl;
+ } else break;
+ if (cd == NULL)
+ break;
+ for(i = 0; i < cd->users; i++) {
+ if (type == CHAT_WOS && cd->usersd[i] == sd)
+ continue;
+ if ((fd=cd->usersd[i]->fd) >0 && session[fd]) { // Added check to see if session exists [PoW]
WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
}
}
}
- }
- break;
-
- case CHAT_MAINCHAT: //[LuzZza]
- iter = mapit_getallusers();
- while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL )
- {
- if( tsd->state.mainchat && tsd->chatID == 0 && packet_db[tsd->packet_ver][RBUFW(buf,0)].len )
- { // packet must exist for the client version
- WFIFOHEAD(tsd->fd, len);
- memcpy(WFIFOP(tsd->fd,0), buf, len);
- WFIFOSET(tsd->fd,len);
- }
- }
- mapit_free(iter);
- break;
+ break;
- case PARTY_AREA:
- case PARTY_AREA_WOS:
- x0 = bl->x - AREA_SIZE;
- y0 = bl->y - AREA_SIZE;
- x1 = bl->x + AREA_SIZE;
- y1 = bl->y + AREA_SIZE;
- case PARTY:
- case PARTY_WOS:
- case PARTY_SAMEMAP:
- case PARTY_SAMEMAP_WOS:
- if (sd && sd->status.party_id)
- p = party_search(sd->status.party_id);
-
- if (p) {
- for(i=0;i<MAX_PARTY;i++){
- if( (sd = p->data[i].sd) == NULL )
- continue;
+ case PARTY_AREA:
+ case PARTY_AREA_WOS:
+ x0 = bl->x - AREA_SIZE;
+ y0 = bl->y - AREA_SIZE;
+ x1 = bl->x + AREA_SIZE;
+ y1 = bl->y + AREA_SIZE;
+ case PARTY:
+ case PARTY_WOS:
+ case PARTY_SAMEMAP:
+ case PARTY_SAMEMAP_WOS:
+ if (sd && sd->status.party_id)
+ p = party_search(sd->status.party_id);
+
+ if (p) {
+ for(i=0;i<MAX_PARTY;i++){
+ if( (sd = p->data[i].sd) == NULL )
+ continue;
- if( !(fd=sd->fd) )
- continue;
+ if( !(fd=sd->fd) )
+ continue;
- if( sd->bl.id == bl->id && (type == PARTY_WOS || type == PARTY_SAMEMAP_WOS || type == PARTY_AREA_WOS) )
- continue;
+ if( sd->bl.id == bl->id && (type == PARTY_WOS || type == PARTY_SAMEMAP_WOS || type == PARTY_AREA_WOS) )
+ continue;
- if( type != PARTY && type != PARTY_WOS && bl->m != sd->bl.m )
- continue;
+ if( type != PARTY && type != PARTY_WOS && bl->m != sd->bl.m )
+ continue;
- if( (type == PARTY_AREA || type == PARTY_AREA_WOS) && (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1) )
- continue;
+ if( (type == PARTY_AREA || type == PARTY_AREA_WOS) && (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1) )
+ continue;
- if( packet_db[sd->packet_ver][RBUFW(buf,0)].len )
- { // packet must exist for the client version
WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
}
+ if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
+ break;
+
+ iter = mapit_getallusers();
+ while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) {
+ if( tsd->partyspy == p->party.party_id ) {
+ WFIFOHEAD(tsd->fd, len);
+ memcpy(WFIFOP(tsd->fd,0), buf, len);
+ WFIFOSET(tsd->fd,len);
+ }
+ }
+ mapit->free(iter);
}
- if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
- break;
+ break;
+
+ case DUEL:
+ case DUEL_WOS:
+ if (!sd || !sd->duel_group) break; //Invalid usage.
iter = mapit_getallusers();
- while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL )
- {
- if( tsd->partyspy == p->party.party_id && packet_db[tsd->packet_ver][RBUFW(buf,0)].len )
- { // packet must exist for the client version
+ while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) {
+ if( type == DUEL_WOS && bl->id == tsd->bl.id )
+ continue;
+ if( sd->duel_group == tsd->duel_group ) {
WFIFOHEAD(tsd->fd, len);
memcpy(WFIFOP(tsd->fd,0), buf, len);
WFIFOSET(tsd->fd,len);
}
}
- mapit_free(iter);
- }
- break;
-
- case DUEL:
- case DUEL_WOS:
- if (!sd || !sd->duel_group) break; //Invalid usage.
+ mapit->free(iter);
+ break;
- iter = mapit_getallusers();
- while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL )
- {
- if( type == DUEL_WOS && bl->id == tsd->bl.id )
- continue;
- if( sd->duel_group == tsd->duel_group && packet_db[tsd->packet_ver][RBUFW(buf,0)].len )
- { // packet must exist for the client version
- WFIFOHEAD(tsd->fd, len);
- memcpy(WFIFOP(tsd->fd,0), buf, len);
- WFIFOSET(tsd->fd,len);
+ case SELF:
+ if (sd && (fd=sd->fd) ) {
+ WFIFOHEAD(fd,len);
+ memcpy(WFIFOP(fd,0), buf, len);
+ WFIFOSET(fd,len);
}
- }
- mapit_free(iter);
- break;
-
- case SELF:
- if (sd && (fd=sd->fd) && packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(fd,len);
- memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd,len);
- }
- break;
-
- // New definitions for guilds [Valaris] - Cleaned up and reorganized by [Skotlex]
- case GUILD_AREA:
- case GUILD_AREA_WOS:
- x0 = bl->x - AREA_SIZE;
- y0 = bl->y - AREA_SIZE;
- x1 = bl->x + AREA_SIZE;
- y1 = bl->y + AREA_SIZE;
- case GUILD_SAMEMAP:
- case GUILD_SAMEMAP_WOS:
- case GUILD:
- case GUILD_WOS:
- case GUILD_NOBG:
- if (sd && sd->status.guild_id)
- g = guild_search(sd->status.guild_id);
-
- if (g) {
- for(i = 0; i < g->max_member; i++) {
- if( (sd = g->member[i].sd) != NULL )
- {
- if( !(fd=sd->fd) )
- continue;
-
- if( type == GUILD_NOBG && sd->bg_id )
- continue;
-
- if( sd->bl.id == bl->id && (type == GUILD_WOS || type == GUILD_SAMEMAP_WOS || type == GUILD_AREA_WOS) )
- continue;
-
- if( type != GUILD && type != GUILD_NOBG && type != GUILD_WOS && sd->bl.m != bl->m )
- continue;
-
- if( (type == GUILD_AREA || type == GUILD_AREA_WOS) && (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1) )
- continue;
+ break;
- if( packet_db[sd->packet_ver][RBUFW(buf,0)].len )
- { // packet must exist for the client version
+ // New definitions for guilds [Valaris] - Cleaned up and reorganized by [Skotlex]
+ case GUILD_AREA:
+ case GUILD_AREA_WOS:
+ x0 = bl->x - AREA_SIZE;
+ y0 = bl->y - AREA_SIZE;
+ x1 = bl->x + AREA_SIZE;
+ y1 = bl->y + AREA_SIZE;
+ case GUILD_SAMEMAP:
+ case GUILD_SAMEMAP_WOS:
+ case GUILD:
+ case GUILD_WOS:
+ case GUILD_NOBG:
+ if (sd && sd->status.guild_id)
+ g = sd->guild;
+
+ if (g) {
+ for(i = 0; i < g->max_member; i++) {
+ if( (sd = g->member[i].sd) != NULL ) {
+ if( !(fd=sd->fd) )
+ continue;
+
+ if( type == GUILD_NOBG && sd->bg_id )
+ continue;
+
+ if( sd->bl.id == bl->id && (type == GUILD_WOS || type == GUILD_SAMEMAP_WOS || type == GUILD_AREA_WOS) )
+ continue;
+
+ if( type != GUILD && type != GUILD_NOBG && type != GUILD_WOS && sd->bl.m != bl->m )
+ continue;
+
+ if( (type == GUILD_AREA || type == GUILD_AREA_WOS) && (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1) )
+ continue;
WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
}
}
- }
- if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
- break;
+ if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
+ break;
- iter = mapit_getallusers();
- while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL )
- {
- if( tsd->guildspy == g->guild_id && packet_db[tsd->packet_ver][RBUFW(buf,0)].len )
- { // packet must exist for the client version
- WFIFOHEAD(tsd->fd, len);
- memcpy(WFIFOP(tsd->fd,0), buf, len);
- WFIFOSET(tsd->fd,len);
+ iter = mapit_getallusers();
+ while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) {
+ if( tsd->guildspy == g->guild_id ) {
+ WFIFOHEAD(tsd->fd, len);
+ memcpy(WFIFOP(tsd->fd,0), buf, len);
+ WFIFOSET(tsd->fd,len);
+ }
}
+ mapit->free(iter);
}
- mapit_free(iter);
- }
- break;
+ break;
- case BG_AREA:
- case BG_AREA_WOS:
- x0 = bl->x - AREA_SIZE;
- y0 = bl->y - AREA_SIZE;
- x1 = bl->x + AREA_SIZE;
- y1 = bl->y + AREA_SIZE;
- case BG_SAMEMAP:
- case BG_SAMEMAP_WOS:
- case BG:
- case BG_WOS:
- if( sd && sd->bg_id && (bg = bg_team_search(sd->bg_id)) != NULL )
- {
- for( i = 0; i < MAX_BG_MEMBERS; i++ )
- {
- if( (sd = bg->members[i].sd) == NULL || !(fd = sd->fd) )
- continue;
- if( sd->bl.id == bl->id && (type == BG_WOS || type == BG_SAMEMAP_WOS || type == BG_AREA_WOS) )
- continue;
- if( type != BG && type != BG_WOS && sd->bl.m != bl->m )
- continue;
- if( (type == BG_AREA || type == BG_AREA_WOS) && (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1) )
- continue;
- if( packet_db[sd->packet_ver][RBUFW(buf,0)].len )
- { // packet must exist for the client version
+ case BG_AREA:
+ case BG_AREA_WOS:
+ x0 = bl->x - AREA_SIZE;
+ y0 = bl->y - AREA_SIZE;
+ x1 = bl->x + AREA_SIZE;
+ y1 = bl->y + AREA_SIZE;
+ case BG_SAMEMAP:
+ case BG_SAMEMAP_WOS:
+ case BG:
+ case BG_WOS:
+ if( sd && sd->bg_id && (bg = bg_team_search(sd->bg_id)) != NULL ) {
+ for( i = 0; i < MAX_BG_MEMBERS; i++ ) {
+ if( (sd = bg->members[i].sd) == NULL || !(fd = sd->fd) )
+ continue;
+ if( sd->bl.id == bl->id && (type == BG_WOS || type == BG_SAMEMAP_WOS || type == BG_AREA_WOS) )
+ continue;
+ if( type != BG && type != BG_WOS && sd->bl.m != bl->m )
+ continue;
+ if( (type == BG_AREA || type == BG_AREA_WOS) && (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1) )
+ continue;
WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
}
}
- }
- break;
+ break;
- default:
- ShowError("clif_send: Unrecognized type %d\n",type);
- return -1;
+ default:
+ ShowError("clif->send: Unrecognized type %d\n",type);
+ return -1;
}
return 0;
}
-
/// Notifies the client, that it's connection attempt was accepted.
/// 0073 <start time>.L <position>.3B <x size>.B <y size>.B (ZC_ACCEPT_ENTER)
/// 02eb <start time>.L <position>.3B <x size>.B <y size>.B <font>.W (ZC_ACCEPT_ENTER2)
void clif_authok(struct map_session_data *sd)
{
-#if PACKETVER < 20080102
- const int cmd = 0x73;
-#else
- const int cmd = 0x2eb;
-#endif
- int fd = sd->fd;
-
- WFIFOHEAD(fd,packet_len(cmd));
- WFIFOW(fd, 0) = cmd;
- WFIFOL(fd, 2) = gettick();
- WFIFOPOS(fd, 6, sd->bl.x, sd->bl.y, sd->ud.dir);
- WFIFOB(fd, 9) = 5; // ignored
- WFIFOB(fd,10) = 5; // ignored
+ struct packet_authok p;
+
+ p.PacketType = authokType;
+ p.startTime = gettick();
+ WBUFPOS(&p.PosDir[0],0,sd->bl.x,sd->bl.y,sd->ud.dir); /* do the stupid client math */
+ p.xSize = p.ySize = 5; /* not-used */
+
#if PACKETVER >= 20080102
- WFIFOW(fd,11) = sd->user_font; // FIXME: Font is currently not saved.
+ p.font = sd->user_font; // FIXME: Font is currently not saved.
#endif
- WFIFOSET(fd,packet_len(cmd));
+
+ clif->send(&p,sizeof(p),&sd->bl,SELF);
}
@@ -712,7 +625,7 @@ void clif_authrefuse(int fd, uint8 error_code)
/// ? = disconnected -> MsgStringTable[3]
void clif_authfail_fd(int fd, int type)
{
- if (!fd || !session[fd] || session[fd]->func_parse != clif_parse) //clif_authfail should only be invoked on players!
+ if (!fd || !session[fd] || session[fd]->func_parse != clif->parse) //clif_authfail should only be invoked on players!
return;
WFIFOHEAD(fd, packet_len(0x81));
@@ -746,27 +659,29 @@ void clif_charselectok(int id, uint8 ok)
/// Makes an item appear on the ground.
/// 009e <id>.L <name id>.W <identified>.B <x>.W <y>.W <subX>.B <subY>.B <amount>.W (ZC_ITEM_FALL_ENTRY)
/// 084b (ZC_ITEM_FALL_ENTRY4)
-void clif_dropflooritem(struct flooritem_data* fitem)
-{
- uint8 buf[17];
+void clif_dropflooritem(struct flooritem_data* fitem) {
+ struct packet_dropflooritem p;
int view;
nullpo_retv(fitem);
if (fitem->item_data.nameid <= 0)
return;
-
- WBUFW(buf, 0) = 0x9e;
- WBUFL(buf, 2) = fitem->bl.id;
- WBUFW(buf, 6) = ((view = itemdb_viewid(fitem->item_data.nameid)) > 0) ? view : fitem->item_data.nameid;
- WBUFB(buf, 8) = fitem->item_data.identify;
- WBUFW(buf, 9) = fitem->bl.x;
- WBUFW(buf,11) = fitem->bl.y;
- WBUFB(buf,13) = fitem->subx;
- WBUFB(buf,14) = fitem->suby;
- WBUFW(buf,15) = fitem->item_data.amount;
-
- clif_send(buf, packet_len(0x9e), &fitem->bl, AREA);
+
+ p.PacketType = dropflooritemType;
+ p.ITAID = fitem->bl.id;
+ p.ITID = ((view = itemdb_viewid(fitem->item_data.nameid)) > 0) ? view : fitem->item_data.nameid;
+#if PACKETVER >= 20130000 /* not sure date */
+ p.type = itemtype(itemdb_type(fitem->item_data.nameid));
+#endif
+ p.IsIdentified = fitem->item_data.identify;
+ p.xPos = fitem->bl.x;
+ p.yPos = fitem->bl.y;
+ p.subX = fitem->subx;
+ p.subY = fitem->suby;
+ p.count = fitem->item_data.amount;
+
+ clif->send(&p, sizeof(p), &fitem->bl, AREA);
}
@@ -783,7 +698,7 @@ void clif_clearflooritem(struct flooritem_data *fitem, int fd)
WBUFL(buf,2) = fitem->bl.id;
if (fd == 0) {
- clif_send(buf, packet_len(0xa1), &fitem->bl, AREA);
+ clif->send(buf, packet_len(0xa1), &fitem->bl, AREA);
} else {
WFIFOHEAD(fd,packet_len(0xa1));
memcpy(WFIFOP(fd,0), buf, packet_len(0xa1));
@@ -827,11 +742,11 @@ void clif_clearunit_area(struct block_list* bl, clr_type type)
WBUFL(buf,2) = bl->id;
WBUFB(buf,6) = type;
- clif_send(buf, packet_len(0x80), bl, type == CLR_DEAD ? AREA : AREA_WOS);
+ clif->send(buf, packet_len(0x80), bl, type == CLR_DEAD ? AREA : AREA_WOS);
if(disguised(bl)) {
WBUFL(buf,2) = -bl->id;
- clif_send(buf, packet_len(0x80), bl, SELF);
+ clif->send(buf, packet_len(0x80), bl, SELF);
}
}
@@ -839,24 +754,22 @@ void clif_clearunit_area(struct block_list* bl, clr_type type)
/// Used to make monsters with player-sprites disappear after dying
/// like normal monsters, because the client does not remove those
/// automatically.
-static int clif_clearunit_delayed_sub(int tid, unsigned int tick, int id, intptr_t data)
-{
+int clif_clearunit_delayed_sub(int tid, unsigned int tick, int id, intptr_t data) {
struct block_list *bl = (struct block_list *)data;
- clif_clearunit_area(bl, (clr_type) id);
- ers_free(delay_clearunit_ers,bl);
+ clif->clearunit_area(bl, (clr_type) id);
+ ers_free(clif->delay_clearunit_ers,bl);
return 0;
}
void clif_clearunit_delayed(struct block_list* bl, clr_type type, unsigned int tick)
{
- struct block_list *tbl = ers_alloc(delay_clearunit_ers, struct block_list);
+ struct block_list *tbl = ers_alloc(clif->delay_clearunit_ers, struct block_list);
memcpy (tbl, bl, sizeof (struct block_list));
- add_timer(tick, clif_clearunit_delayed_sub, (int)type, (intptr_t)tbl);
+ add_timer(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl);
}
void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, unsigned short *lhand)
{
- if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER))
- {
+ if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK)) {
*rhand = *lhand = 0;
return;
}
@@ -891,31 +804,23 @@ void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, un
}
//To make the assignation of the level based on limits clearer/easier. [Skotlex]
-static int clif_setlevel_sub(int lv)
-{
- if( lv < battle_config.max_lv )
- {
+static int clif_setlevel_sub(int lv) {
+ if( lv < battle_config.max_lv ) {
;
- }
- else if( lv < battle_config.aura_lv )
- {
+ } else if( lv < battle_config.aura_lv ) {
lv = battle_config.max_lv - 1;
- }
- else
- {
+ } else {
lv = battle_config.max_lv;
}
return lv;
}
-static int clif_setlevel(struct block_list* bl)
-{
+static int clif_setlevel(struct block_list* bl) {
int lv = status_get_lv(bl);
if( battle_config.client_limit_unit_lv&bl->type )
return clif_setlevel_sub(lv);
- switch( bl->type )
- {
+ switch( bl->type ) {
case BL_NPC:
case BL_PET:
// npcs and pets do not have level
@@ -925,13 +830,91 @@ static int clif_setlevel(struct block_list* bl)
}
/*==========================================
- * Prepares 'unit standing/spawning' packet
+ * Prepares 'unit standing' packet
*------------------------------------------*/
-static int clif_set_unit_idle(struct block_list* bl, unsigned char* buffer, bool spawn)
-{
+void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enum send_target target) {
struct map_session_data* sd;
struct status_change* sc = status_get_sc(bl);
struct view_data* vd = status_get_viewdata(bl);
+ struct packet_idle_unit p;
+ int g_id = status_get_guild_id(bl);
+
+ sd = BL_CAST(BL_PC, bl);
+
+ p.PacketType = idle_unitType;
+#if PACKETVER >= 20091103
+ p.PacketLength = sizeof(p);
+ p.objecttype = clif_bl_type(bl);
+#endif
+ p.GID = bl->id;
+ p.speed = status_get_speed(bl);
+ p.bodyState = (sc) ? sc->opt1 : 0;
+ p.healthState = (sc) ? sc->opt2 : 0;
+ p.effectState = (sc) ? sc->option : 0;
+ p.job = vd->class_;
+ p.head = vd->hair_style;
+ p.weapon = vd->weapon;
+ p.accessory = vd->head_bottom;
+#if PACKETVER < 7
+ p.shield = vd->shield;
+#endif
+ p.accessory2 = vd->head_top;
+ p.accessory3 = vd->head_mid;
+ if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this?
+ p.accessory = g_id;
+ p.accessory2 = GetWord(g_id, 1);
+ p.accessory3 = GetWord(g_id, 0);
+ }
+ p.headpalette = vd->hair_color;
+ p.bodypalette = vd->cloth_color;
+ p.headDir = (sd)? sd->head_dir : 0;
+#if PACKETVER >= 20101124
+ p.robe = vd->robe;
+#endif
+ p.GUID = g_id;
+ p.GEmblemVer = status_get_emblem_id(bl);
+ p.honor = (sd) ? sd->status.manner : 0;
+ p.virtue = (sc) ? sc->opt3 : 0;
+ p.isPKModeON = (sd) ? sd->status.karma : 0;
+ p.sex = vd->sex;
+ WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl));
+ p.xSize = p.ySize = (sd) ? 5 : 0;
+ p.state = vd->dead_sit;
+ p.clevel = clif_setlevel(bl);
+#if PACKETVER >= 20080102
+ p.font = (sd) ? sd->user_font : 0;
+#endif
+#if PACKETVER >= 20140000 //actual 20120221
+ if( bl->type == BL_MOB ) {
+ p.maxHP = status_get_max_hp(bl);
+ p.HP = status_get_hp(bl);
+ p.isBoss = ( ((TBL_MOB*)bl)->spawn && ((TBL_MOB*)bl)->spawn->state.boss ) ? 1 : 0;
+ } else {
+ p.maxHP = -1;
+ p.HP = -1;
+ p.isBoss = 0;
+ }
+#endif
+
+ clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,target);
+
+ if( disguised(bl) ) {
+#if PACKETVER >= 20071106
+ p.objecttype = pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
+ p.GID = -bl->id;
+#else
+ p.GID = -bl->id;
+#endif
+ clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,SELF);
+ }
+
+}
+/* todo for packetver 20091103 0x7c non-pc-looking unit handling */
+int clif_spawn_unit2(struct block_list* bl, enum send_target target) {
+ return 0;
+ /*struct map_session_data* sd;
+ struct status_change* sc = status_get_sc(bl);
+ struct view_data* vd = status_get_viewdata(bl);
unsigned char *buf = WBUFP(buffer,0);
#if PACKETVER < 20091103
bool type = !pcdb_checkid(vd->class_);
@@ -941,26 +924,26 @@ static int clif_set_unit_idle(struct block_list* bl, unsigned char* buffer, bool
const char *name;
#endif
sd = BL_CAST(BL_PC, bl);
-
+
#if PACKETVER < 20091103
if(type)
- WBUFW(buf,0) = spawn?0x7c:0x78;
+ WBUFW(buf,0) = 0x7c;
else
#endif
#if PACKETVER < 4
- WBUFW(buf,0) = spawn?0x79:0x78;
+ WBUFW(buf,0) = 0x79;
#elif PACKETVER < 7
- WBUFW(buf,0) = spawn?0x1d9:0x1d8;
+ WBUFW(buf,0) = 0x1d9;
#elif PACKETVER < 20080102
- WBUFW(buf,0) = spawn?0x22b:0x22a;
+ WBUFW(buf,0) = 0x22b;
#elif PACKETVER < 20091103
- WBUFW(buf,0) = spawn?0x2ed:0x2ee;
+ WBUFW(buf,0) = 0x2ed;
#elif PACKETVER < 20101124
- WBUFW(buf,0) = spawn?0x7f8:0x7f9;
+ WBUFW(buf,0) = 0x7f8;
#else
- WBUFW(buf,0) = spawn?0x858:0x857;
+ WBUFW(buf,0) = 0x858;
#endif
-
+
#if PACKETVER >= 20091103
name = status_get_name(bl);
#if PACKETVER < 20110111
@@ -1021,14 +1004,14 @@ static int clif_set_unit_idle(struct block_list* bl, unsigned char* buffer, bool
#endif
WBUFW(buf,24) = vd->head_top;
WBUFW(buf,26) = vd->head_mid;
-
+
if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS )
{ //The hell, why flags work like this?
WBUFW(buf,22) = status_get_emblem_id(bl);
WBUFW(buf,24) = GetWord(status_get_guild_id(bl), 1);
WBUFW(buf,26) = GetWord(status_get_guild_id(bl), 0);
}
-
+
WBUFW(buf,28) = vd->hair_color;
WBUFW(buf,30) = vd->cloth_color;
WBUFW(buf,32) = (sd)? sd->head_dir : 0;
@@ -1088,149 +1071,176 @@ static int clif_set_unit_idle(struct block_list* bl, unsigned char* buffer, bool
#else
return packet_len(WBUFW(buffer,0));
#endif
+ */
}
-/*==========================================
- * Prepares 'unit walking' packet
- *------------------------------------------*/
-static int clif_set_unit_walking(struct block_list* bl, struct unit_data* ud, unsigned char* buffer)
-{
+void clif_spawn_unit(struct block_list* bl, enum send_target target) {
struct map_session_data* sd;
struct status_change* sc = status_get_sc(bl);
struct view_data* vd = status_get_viewdata(bl);
- unsigned char* buf = WBUFP(buffer,0);
-#if PACKETVER >= 7
- unsigned short offset = 0;
-#endif
-#if PACKETVER >= 20091103
- const char *name;
-#endif
+ struct packet_spawn_unit p;
+ int g_id = status_get_guild_id(bl);
sd = BL_CAST(BL_PC, bl);
-
-#if PACKETVER < 4
- WBUFW(buf, 0) = 0x7b;
-#elif PACKETVER < 7
- WBUFW(buf, 0) = 0x1da;
-#elif PACKETVER < 20080102
- WBUFW(buf, 0) = 0x22c;
-#elif PACKETVER < 20091103
- WBUFW(buf, 0) = 0x2ec;
-#elif PACKETVER < 20101124
- WBUFW(buf, 0) = 0x7f7;
-#else
- WBUFW(buf, 0) = 0x856;
-#endif
-
+
+ p.PacketType = spawn_unitType;
#if PACKETVER >= 20091103
- name = status_get_name(bl);
-#if PACKETVER < 20110111
- WBUFW(buf, 2) = 69+strlen(name);
-#else
- WBUFW(buf, 2) = 71+strlen(name);
+ p.PacketLength = sizeof(p);
+ p.objecttype = clif_bl_type(bl);
#endif
- offset+=2;
- buf = WBUFP(buffer,offset);
+ p.GID = bl->id;
+ p.speed = status_get_speed(bl);
+ p.bodyState = (sc) ? sc->opt1 : 0;
+ p.healthState = (sc) ? sc->opt2 : 0;
+ p.effectState = (sc) ? sc->option : 0;
+ p.job = vd->class_;
+ p.head = vd->hair_style;
+ p.weapon = vd->weapon;
+ p.accessory = vd->head_bottom;
+#if PACKETVER < 7
+ p.shield = vd->shield;
#endif
-#if PACKETVER >= 20071106
- WBUFB(buf, 2) = clif_bl_type(bl);
- offset++;
- buf = WBUFP(buffer,offset);
+ p.accessory2 = vd->head_top;
+ p.accessory3 = vd->head_mid;
+ if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this?
+ p.accessory = g_id;
+ p.accessory2 = GetWord(g_id, 1);
+ p.accessory3 = GetWord(g_id, 0);
+ }
+ p.headpalette = vd->hair_color;
+ p.bodypalette = vd->cloth_color;
+ p.headDir = (sd)? sd->head_dir : 0;
+#if PACKETVER >= 20101124
+ p.robe = vd->robe;
#endif
- WBUFL(buf, 2) = bl->id;
- WBUFW(buf, 6) = status_get_speed(bl);
- WBUFW(buf, 8) = (sc)? sc->opt1 : 0;
- WBUFW(buf,10) = (sc)? sc->opt2 : 0;
-#if PACKETVER < 7
- WBUFW(buf,12) = (sc)? sc->option : 0;
-#else
- WBUFL(buf,12) = (sc)? sc->option : 0;
- offset+=2; //Shift the rest of elements by 2 bytes.
- buf = WBUFP(buffer,offset);
+ p.GUID = g_id;
+ p.GEmblemVer = status_get_emblem_id(bl);
+ p.honor = (sd) ? sd->status.manner : 0;
+ p.virtue = (sc) ? sc->opt3 : 0;
+ p.isPKModeON = (sd) ? sd->status.karma : 0;
+ p.sex = vd->sex;
+ WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl));
+ p.xSize = p.ySize = (sd) ? 5 : 0;
+ p.clevel = clif_setlevel(bl);
+#if PACKETVER >= 20080102
+ p.font = (sd) ? sd->user_font : 0;
#endif
- WBUFW(buf,14) = vd->class_;
- WBUFW(buf,16) = vd->hair_style;
- WBUFW(buf,18) = vd->weapon;
-#if PACKETVER < 4
- WBUFW(buf,20) = vd->head_bottom;
- WBUFL(buf,22) = gettick();
- WBUFW(buf,26) = vd->shield;
+#if PACKETVER >= 20140000 //actual 20120221
+ if( bl->type == BL_MOB ) {
+ p.maxHP = status_get_max_hp(bl);
+ p.HP = status_get_hp(bl);
+ p.isBoss = ( ((TBL_MOB*)bl)->spawn && ((TBL_MOB*)bl)->spawn->state.boss ) ? 1 : 0;
+ } else {
+ p.maxHP = -1;
+ p.HP = -1;
+ p.isBoss = 0;
+ }
+#endif
+ clif->send(&p,sizeof(p),bl,target);
+
+ if( disguised(bl) ) {
+#if PACKETVER >= 20071106
+ p.objecttype = pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
+ p.GID = -bl->id;
#else
- WBUFW(buf,20) = vd->shield;
- WBUFW(buf,22) = vd->head_bottom;
- WBUFL(buf,24) = gettick();
+ p.GID = -bl->id;
#endif
- WBUFW(buf,28) = vd->head_top;
- WBUFW(buf,30) = vd->head_mid;
- WBUFW(buf,32) = vd->hair_color;
- WBUFW(buf,34) = vd->cloth_color;
- WBUFW(buf,36) = (sd)? sd->head_dir : 0;
-#if PACKETVER >= 20110111
- WBUFW(buf,38) = vd->robe;
- offset+= 2;
- buf = WBUFP(buffer,offset);
+ clif->send(&p,sizeof(p),bl,SELF);
+ }
+
+}
+
+/*==========================================
+ * Prepares 'unit walking' packet
+ *------------------------------------------*/
+void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, struct unit_data* ud, enum send_target target) {
+ struct map_session_data* sd;
+ struct status_change* sc = status_get_sc(bl);
+ struct view_data* vd = status_get_viewdata(bl);
+ struct packet_unit_walking p;
+ int g_id = status_get_guild_id(bl);
+
+ sd = BL_CAST(BL_PC, bl);
+
+ p.PacketType = unit_walkingType;
+#if PACKETVER >= 20091103
+ p.PacketLength = sizeof(p);
+ p.objecttype = clif_bl_type(bl);
#endif
- WBUFL(buf,38) = status_get_guild_id(bl);
- WBUFW(buf,42) = status_get_emblem_id(bl);
- WBUFW(buf,44) = (sd)? sd->status.manner : 0;
+ p.GID = bl->id;
+ p.speed = status_get_speed(bl);
+ p.bodyState = (sc) ? sc->opt1 : 0;
+ p.healthState = (sc) ? sc->opt2 : 0;
+ p.effectState = (sc) ? sc->option : 0;
+ p.job = vd->class_;
+ p.head = vd->hair_style;
+ p.weapon = vd->weapon;
+ p.accessory = vd->head_bottom;
+ p.moveStartTime = gettick();
#if PACKETVER < 7
- WBUFW(buf,46) = (sc)? sc->opt3 : 0;
-#else
- WBUFL(buf,46) = (sc)? sc->opt3 : 0;
- offset+=2; //Shift the rest of elements by 2 bytes.
- buf = WBUFP(buffer,offset);
+ p.shield = vd->shield;
+#endif
+ p.accessory2 = vd->head_top;
+ p.accessory3 = vd->head_mid;
+ p.headpalette = vd->hair_color;
+ p.bodypalette = vd->cloth_color;
+ p.headDir = (sd)? sd->head_dir : 0;
+#if PACKETVER >= 20101124
+ p.robe = vd->robe;
#endif
- WBUFB(buf,48) = (sd)? sd->status.karma : 0;
- WBUFB(buf,49) = vd->sex;
- WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y,8,8);
- WBUFB(buf,56) = (sd)? 5 : 0;
- WBUFB(buf,57) = (sd)? 5 : 0;
- WBUFW(buf,58) = clif_setlevel(bl);
+ p.GUID = g_id;
+ p.GEmblemVer = status_get_emblem_id(bl);
+ p.honor = (sd) ? sd->status.manner : 0;
+ p.virtue = (sc) ? sc->opt3 : 0;
+ p.isPKModeON = (sd) ? sd->status.karma : 0;
+ p.sex = vd->sex;
+ WBUFPOS2(&p.MoveData[0],0,bl->x,bl->y,ud->to_x,ud->to_y,8,8);
+ p.xSize = p.ySize = (sd) ? 5 : 0;
+ p.clevel = clif_setlevel(bl);
#if PACKETVER >= 20080102
- WBUFW(buf,60) = sd?sd->user_font:0;
+ p.font = (sd) ? sd->user_font : 0;
#endif
-#if PACKETVER >= 20091103
- memcpy((char*)WBUFP(buf,62), name, NAME_LENGTH);
- return WBUFW(buffer,2);
-#else
- return packet_len(WBUFW(buffer,0));
+#if PACKETVER >= 20140000 //actual 20120221
+ if( bl->type == BL_MOB ) {
+ p.maxHP = status_get_max_hp(bl);
+ p.HP = status_get_hp(bl);
+ p.isBoss = ( ((TBL_MOB*)bl)->spawn && ((TBL_MOB*)bl)->spawn->state.boss ) ? 1 : 0;
+ } else {
+ p.maxHP = -1;
+ p.HP = -1;
+ p.isBoss = 0;
+ }
#endif
-}
+
+ clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,target);
-//Modifies the buffer for disguise characters and sends it to self.
-//Used for spawn/walk packets, where the ID offset changes for packetver >=9
-static void clif_setdisguise(struct block_list *bl, unsigned char *buf,int len)
-{
-#if PACKETVER >= 20091103
- WBUFB(buf,4)= pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
- WBUFL(buf,5)=-bl->id;
-#elif PACKETVER >= 20071106
- WBUFB(buf,2)= pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
- WBUFL(buf,3)=-bl->id;
+ if( disguised(bl) ) {
+#if PACKETVER >= 20071106
+ p.objecttype = pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
+ p.GID = -bl->id;
#else
- WBUFL(buf,2)=-bl->id;
-#endif
- clif_send(buf, len, bl, SELF);
+ p.GID = -bl->id;
+#endif
+ clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,SELF);
+ }
}
-
/// Changes sprite of an NPC object (ZC_NPCSPRITE_CHANGE).
/// 01b0 <id>.L <type>.B <value>.L
/// type:
/// unused
void clif_class_change(struct block_list *bl,int class_,int type)
{
- unsigned char buf[16];
-
nullpo_retv(bl);
if(!pcdb_checkid(class_))
{// player classes yield missing sprites
+ unsigned char buf[16];
WBUFW(buf,0)=0x1b0;
WBUFL(buf,2)=bl->id;
WBUFB(buf,6)=type;
WBUFL(buf,7)=class_;
- clif_send(buf,packet_len(0x1b0),bl,AREA);
+ clif->send(buf,packet_len(0x1b0),bl,AREA);
}
}
@@ -1238,8 +1248,7 @@ void clif_class_change(struct block_list *bl,int class_,int type)
/// Notifies the client of an object's spirits.
/// 01d0 <id>.L <amount>.W (ZC_SPIRITS)
/// 01e1 <id>.L <amount>.W (ZC_SPIRITS2)
-static void clif_spiritball_single(int fd, struct map_session_data *sd)
-{
+void clif_spiritball_single(int fd, struct map_session_data *sd) {
WFIFOHEAD(fd, packet_len(0x1e1));
WFIFOW(fd,0)=0x1e1;
WFIFOL(fd,2)=sd->bl.id;
@@ -1250,8 +1259,7 @@ static void clif_spiritball_single(int fd, struct map_session_data *sd)
/*==========================================
* Kagerou/Oboro amulet spirit
*------------------------------------------*/
-static void clif_talisman_single(int fd, struct map_session_data *sd, short type)
-{
+void clif_talisman_single(int fd, struct map_session_data *sd, short type) {
WFIFOHEAD(fd, packet_len(0x08cf));
WFIFOW(fd,0)=0x08cf;
WFIFOL(fd,2)=sd->bl.id;
@@ -1264,8 +1272,7 @@ static void clif_talisman_single(int fd, struct map_session_data *sd, short type
* Run when player changes map / refreshes
* Tells its client to display all weather settings being used by this map
*------------------------------------------*/
-static void clif_weather_check(struct map_session_data *sd)
-{
+void clif_weather_check(struct map_session_data *sd) {
int16 m = sd->bl.m;
int fd = sd->fd;
@@ -1275,34 +1282,24 @@ static void clif_weather_check(struct map_session_data *sd)
|| map[m].flag.fireworks
|| map[m].flag.sakura
|| map[m].flag.leaves
- /**
- * No longer available, keeping here just in case it's back someday. [Ind]
- **/
- //|| map[m].flag.rain
- || map[m].flag.clouds2)
- {
+ || map[m].flag.clouds2) {
if (map[m].flag.snow)
- clif_specialeffect_single(&sd->bl, 162, fd);
+ clif->specialeffect_single(&sd->bl, 162, fd);
if (map[m].flag.clouds)
- clif_specialeffect_single(&sd->bl, 233, fd);
+ clif->specialeffect_single(&sd->bl, 233, fd);
if (map[m].flag.clouds2)
- clif_specialeffect_single(&sd->bl, 516, fd);
+ clif->specialeffect_single(&sd->bl, 516, fd);
if (map[m].flag.fog)
- clif_specialeffect_single(&sd->bl, 515, fd);
+ clif->specialeffect_single(&sd->bl, 515, fd);
if (map[m].flag.fireworks) {
- clif_specialeffect_single(&sd->bl, 297, fd);
- clif_specialeffect_single(&sd->bl, 299, fd);
- clif_specialeffect_single(&sd->bl, 301, fd);
+ clif->specialeffect_single(&sd->bl, 297, fd);
+ clif->specialeffect_single(&sd->bl, 299, fd);
+ clif->specialeffect_single(&sd->bl, 301, fd);
}
if (map[m].flag.sakura)
- clif_specialeffect_single(&sd->bl, 163, fd);
+ clif->specialeffect_single(&sd->bl, 163, fd);
if (map[m].flag.leaves)
- clif_specialeffect_single(&sd->bl, 333, fd);
- /**
- * No longer available, keeping here just in case it's back someday. [Ind]
- **/
- //if (map[m].flag.rain)
- // clif_specialeffect_single(&sd->bl, 161, fd);
+ clif->specialeffect_single(&sd->bl, 333, fd);
}
}
/**
@@ -1314,21 +1311,19 @@ void clif_weather(int16 m)
struct map_session_data *sd=NULL;
iter = mapit_getallusers();
- for( sd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); sd = (struct map_session_data*)mapit_next(iter) )
+ for( sd = (struct map_session_data*)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data*)mapit->next(iter) )
{
if( sd->bl.m == m )
clif_weather_check(sd);
}
- mapit_free(iter);
+ mapit->free(iter);
}
/**
* Main function to spawn a unit on the client (player/mob/pet/etc)
**/
int clif_spawn(struct block_list *bl)
{
- unsigned char buf[128];
struct view_data *vd;
- int len;
vd = status_get_viewdata(bl);
if( !vd || vd->class_ == INVISIBLE_CLASS )
@@ -1340,84 +1335,73 @@ int clif_spawn(struct block_list *bl)
if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
return 0;
- len = clif_set_unit_idle(bl, buf,true);
- clif_send(buf, len, bl, AREA_WOS);
- if (disguised(bl))
- clif_setdisguise(bl, buf, len);
+ clif->spawn_unit(bl,AREA_WOS);
if (vd->cloth_color)
- clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
+ clif->refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
- switch (bl->type)
- {
- case BL_PC:
- {
- TBL_PC *sd = ((TBL_PC*)bl);
- int i;
- if (sd->spiritball > 0)
- clif_spiritball(&sd->bl);
- if(sd->state.size==SZ_BIG) // tiny/big players [Valaris]
- clif_specialeffect(bl,423,AREA);
- else if(sd->state.size==SZ_MEDIUM)
- clif_specialeffect(bl,421,AREA);
- if( sd->bg_id && map[sd->bl.m].flag.battleground )
- clif_sendbgemblem_area(sd);
- if( sd->sc.option&OPTION_MOUNTING ) {
- //New Mounts are not complaint to the original method, so we gotta tell this guy that he is mounting.
- clif_status_load_notick(&sd->bl,SI_ALL_RIDING,2,1,0,0);
+
+ switch (bl->type) {
+ case BL_PC:
+ {
+ TBL_PC *sd = ((TBL_PC*)bl);
+ int i;
+ if (sd->spiritball > 0)
+ clif->spiritball(&sd->bl);
+ if(sd->state.size==SZ_BIG) // tiny/big players [Valaris]
+ clif->specialeffect(bl,423,AREA);
+ else if(sd->state.size==SZ_MEDIUM)
+ clif->specialeffect(bl,421,AREA);
+ if( sd->bg_id && map[sd->bl.m].flag.battleground )
+ clif->sendbgemblem_area(sd);
+ for( i = 0; i < sd->sc_display_count; i++ ) {
+ clif->sc_load(&sd->bl, sd->bl.id,AREA,StatusIconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3);
+ }
+ for(i = 1; i < 5; i++){
+ if( sd->talisman[i] > 0 )
+ clif->talisman(sd, i);
+ }
+ if (sd->status.robe)
+ clif->refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA);
}
- for(i = 1; i < 5; i++){
- if( sd->talisman[i] > 0 )
- clif_talisman(sd, i);
+ break;
+ case BL_MOB:
+ {
+ TBL_MOB *md = ((TBL_MOB*)bl);
+ if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
+ clif->specialeffect(&md->bl,423,AREA);
+ else if(md->special_state.size==SZ_MEDIUM)
+ clif->specialeffect(&md->bl,421,AREA);
}
- #ifdef NEW_CARTS
- if( sd->sc.data[SC_PUSH_CART] )
- clif_status_load_notick(&sd->bl, SI_ON_PUSH_CART, 2, sd->sc.data[SC_PUSH_CART]->val1, 0, 0);
- #endif
- #if PACKETVER <= 20120207
- if (sd->status.robe)
- clif_refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA);
- #endif
- }
- break;
- case BL_MOB:
- {
- TBL_MOB *md = ((TBL_MOB*)bl);
- if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
- clif_specialeffect(&md->bl,423,AREA);
- else if(md->special_state.size==SZ_MEDIUM)
- clif_specialeffect(&md->bl,421,AREA);
- }
- break;
- case BL_NPC:
- {
- TBL_NPC *nd = ((TBL_NPC*)bl);
- if( nd->size == SZ_BIG )
- clif_specialeffect(&nd->bl,423,AREA);
- else if( nd->size == SZ_MEDIUM )
- clif_specialeffect(&nd->bl,421,AREA);
- }
- break;
- case BL_PET:
- if (vd->head_bottom)
- clif_pet_equip_area((TBL_PET*)bl); // needed to display pet equip properly
- break;
+ break;
+ case BL_NPC:
+ {
+ TBL_NPC *nd = ((TBL_NPC*)bl);
+ if( nd->size == SZ_BIG )
+ clif->specialeffect(&nd->bl,423,AREA);
+ else if( nd->size == SZ_MEDIUM )
+ clif->specialeffect(&nd->bl,421,AREA);
+ }
+ break;
+ case BL_PET:
+ if (vd->head_bottom)
+ clif->send_petdata(NULL, (TBL_PET*)bl, 3, vd->head_bottom); // needed to display pet equip properly
+ break;
}
return 0;
}
/// Sends information about owned homunculus to the client (ZC_PROPERTY_HOMUN). [orn]
/// 022e <name>.24B <modified>.B <level>.W <hunger>.W <intimacy>.W <equip id>.W <atk>.W <matk>.W <hit>.W <crit>.W <def>.W <mdef>.W <flee>.W <aspd>.W <hp>.W <max hp>.W <sp>.W <max sp>.W <exp>.L <max exp>.L <skill points>.W <atk range>.W
-void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag)
-{
+void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag) {
struct status_data *status;
unsigned char buf[128];
- int m_class;
+ enum homun_type htype;
nullpo_retv(hd);
status = &hd->battle_status;
- m_class = hom_class2mapid(hd->homunculus.class_);
+ htype = homun->class2type(hd->homunculus.class_);
memset(buf,0,packet_len(0x22e));
WBUFW(buf,0)=0x22e;
@@ -1454,13 +1438,21 @@ void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag)
WBUFW(buf,57)=status->max_sp;
}
WBUFL(buf,59)=hd->homunculus.exp;
- if( ((m_class&HOM_REG) && hd->homunculus.level >= battle_config.hom_max_level) || ((m_class&HOM_S) && hd->homunculus.level >= battle_config.hom_S_max_level) )
- WBUFL(buf,63)=0;
- else
- WBUFL(buf,63)=hd->exp_next;
+ WBUFL(buf,63)=hd->exp_next;
+ switch( htype ) {
+ case HT_REG:
+ case HT_EVO:
+ if( hd->homunculus.level >= battle_config.hom_max_level )
+ WBUFL(buf,63)=0;
+ break;
+ case HT_S:
+ if( hd->homunculus.level >= battle_config.hom_S_max_level )
+ WBUFL(buf,63)=0;
+ break;
+ }
WBUFW(buf,67)=hd->homunculus.skillpts;
WBUFW(buf,69)=status_get_range(&hd->bl);
- clif_send(buf,packet_len(0x22e),&sd->bl,SELF);
+ clif->send(buf,packet_len(0x22e),&sd->bl,SELF);
}
@@ -1479,7 +1471,7 @@ void clif_send_homdata(struct map_session_data *sd, int state, int param)
int fd = sd->fd;
if ( (state == SP_INTIMATE) && (param >= 910) && (sd->hd->homunculus.class_ == sd->hd->homunculusDB->evo_class) )
- merc_hom_calc_skilltree(sd->hd, 0);
+ homun->calc_skilltree(sd->hd, 0);
WFIFOHEAD(fd, packet_len(0x230));
WFIFOW(fd,0)=0x230;
@@ -1491,8 +1483,7 @@ void clif_send_homdata(struct map_session_data *sd, int state, int param)
}
-int clif_homskillinfoblock(struct map_session_data *sd)
-{ //[orn]
+int clif_homskillinfoblock(struct map_session_data *sd) { //[orn]
struct homun_data *hd;
int fd = sd->fd;
int i,j,len=4,id;
@@ -1507,13 +1498,13 @@ int clif_homskillinfoblock(struct map_session_data *sd)
if( (id = hd->homunculus.hskill[i].id) != 0 ){
j = id - HM_SKILLBASE;
WFIFOW(fd,len ) = id;
- WFIFOW(fd,len+2) = skill_get_inf(id);
+ WFIFOW(fd,len+2) = skill->get_inf(id);
WFIFOW(fd,len+4) = 0;
WFIFOW(fd,len+6) = hd->homunculus.hskill[j].lv;
- WFIFOW(fd,len+8) = skill_get_sp(id,hd->homunculus.hskill[j].lv);
- WFIFOW(fd,len+10)= skill_get_range2(&sd->hd->bl, id,hd->homunculus.hskill[j].lv);
- safestrncpy((char*)WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH);
- WFIFOB(fd,len+36) = (hd->homunculus.hskill[j].lv < merc_skill_tree_get_max(id, hd->homunculus.class_))?1:0;
+ WFIFOW(fd,len+8) = skill->get_sp(id,hd->homunculus.hskill[j].lv);
+ WFIFOW(fd,len+10)= skill->get_range2(&sd->hd->bl, id,hd->homunculus.hskill[j].lv);
+ safestrncpy((char*)WFIFOP(fd,len+12), skill->get_name(id), NAME_LENGTH);
+ WFIFOB(fd,len+36) = (hd->homunculus.hskill[j].lv < homun->skill_tree_get_max(id, hd->homunculus.class_))?1:0;
len+=37;
}
}
@@ -1523,8 +1514,7 @@ int clif_homskillinfoblock(struct map_session_data *sd)
return 0;
}
-void clif_homskillup(struct map_session_data *sd, uint16 skill_id)
-{ //[orn]
+void clif_homskillup(struct map_session_data *sd, uint16 skill_id) { //[orn]
struct homun_data *hd;
int fd, idx;
nullpo_retv(sd);
@@ -1537,9 +1527,9 @@ void clif_homskillup(struct map_session_data *sd, uint16 skill_id)
WFIFOW(fd,0) = 0x239;
WFIFOW(fd,2) = skill_id;
WFIFOW(fd,4) = hd->homunculus.hskill[idx].lv;
- WFIFOW(fd,6) = skill_get_sp(skill_id,hd->homunculus.hskill[idx].lv);
- WFIFOW(fd,8) = skill_get_range2(&hd->bl, skill_id,hd->homunculus.hskill[idx].lv);
- WFIFOB(fd,10) = (hd->homunculus.hskill[idx].lv < skill_get_max(hd->homunculus.hskill[idx].id)) ? 1 : 0;
+ WFIFOW(fd,6) = skill->get_sp(skill_id,hd->homunculus.hskill[idx].lv);
+ WFIFOW(fd,8) = skill->get_range2(&hd->bl, skill_id,hd->homunculus.hskill[idx].lv);
+ WFIFOB(fd,10) = (hd->homunculus.hskill[idx].lv < skill->get_max(hd->homunculus.hskill[idx].id)) ? 1 : 0;
WFIFOSET(fd,packet_len(0x239));
}
@@ -1570,46 +1560,37 @@ void clif_walkok(struct map_session_data *sd)
}
-static void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *ud)
-{
- uint8 buf[128];
- int len;
+void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *ud) {
- len = clif_set_unit_walking(bl,ud,buf);
- clif_send(buf,len,bl,AREA_WOS);
- if (disguised(bl))
- clif_setdisguise(bl, buf, len);
+ clif->set_unit_walking(bl,NULL,ud,AREA_WOS);
if(vd->cloth_color)
- clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
+ clif->refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
- switch(bl->type)
- {
- case BL_PC:
- {
- TBL_PC *sd = ((TBL_PC*)bl);
-// clif_movepc(sd);
- if(sd->state.size==SZ_BIG) // tiny/big players [Valaris]
- clif_specialeffect(&sd->bl,423,AREA);
- else if(sd->state.size==SZ_MEDIUM)
- clif_specialeffect(&sd->bl,421,AREA);
- }
- break;
- case BL_MOB:
- {
- TBL_MOB *md = ((TBL_MOB*)bl);
- if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
- clif_specialeffect(&md->bl,423,AREA);
- else if(md->special_state.size==SZ_MEDIUM)
- clif_specialeffect(&md->bl,421,AREA);
- }
- break;
- case BL_PET:
- if( vd->head_bottom )
- {// needed to display pet equip properly
- clif_pet_equip_area((TBL_PET*)bl);
- }
- break;
+ switch(bl->type) {
+ case BL_PC:
+ {
+ TBL_PC *sd = ((TBL_PC*)bl);
+ // clif_movepc(sd);
+ if(sd->state.size==SZ_BIG) // tiny/big players [Valaris]
+ clif->specialeffect(&sd->bl,423,AREA);
+ else if(sd->state.size==SZ_MEDIUM)
+ clif->specialeffect(&sd->bl,421,AREA);
+ }
+ break;
+ case BL_MOB:
+ {
+ TBL_MOB *md = ((TBL_MOB*)bl);
+ if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
+ clif->specialeffect(&md->bl,423,AREA);
+ else if(md->special_state.size==SZ_MEDIUM)
+ clif->specialeffect(&md->bl,421,AREA);
+ }
+ break;
+ case BL_PET:
+ if( vd->head_bottom ) // needed to display pet equip properly
+ clif->send_petdata(NULL, (TBL_PET*)bl, 3, vd->head_bottom);
+ break;
}
}
@@ -1637,7 +1618,7 @@ void clif_move(struct unit_data *ud)
// Since we don't know how to update the speed of other objects,
// use the old walk packet to update the data.
ud->state.speed_changed = 0;
- clif_move2(bl, vd, ud);
+ clif->move2(bl, vd, ud);
return;
}
@@ -1645,11 +1626,11 @@ void clif_move(struct unit_data *ud)
WBUFL(buf,2)=bl->id;
WBUFPOS2(buf,6,bl->x,bl->y,ud->to_x,ud->to_y,8,8);
WBUFL(buf,12)=gettick();
- clif_send(buf, packet_len(0x86), bl, AREA_WOS);
+ clif->send(buf, packet_len(0x86), bl, AREA_WOS);
if (disguised(bl))
{
WBUFL(buf,2)=-bl->id;
- clif_send(buf, packet_len(0x86), bl, SELF);
+ clif->send(buf, packet_len(0x86), bl, SELF);
}
}
@@ -1657,8 +1638,7 @@ void clif_move(struct unit_data *ud)
/*==========================================
* Delays the map_quit of a player after they are disconnected. [Skotlex]
*------------------------------------------*/
-static int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data)
-{
+int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data) {
struct map_session_data *sd = NULL;
//Remove player from map server
@@ -1670,17 +1650,16 @@ static int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data)
/*==========================================
*
*------------------------------------------*/
-void clif_quitsave(int fd,struct map_session_data *sd)
-{
+void clif_quitsave(int fd,struct map_session_data *sd) {
if (!battle_config.prevent_logout ||
DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
map_quit(sd);
- else if (sd->fd)
- { //Disassociate session from player (session is deleted after this function was called)
+ else if (sd->fd) {
+ //Disassociate session from player (session is deleted after this function was called)
//And set a timer to make him quit later.
session[sd->fd]->session_data = NULL;
sd->fd = 0;
- add_timer(gettick() + 10000, clif_delayquit, sd->bl.id, 0);
+ add_timer(gettick() + 10000, clif->delayquit, sd->bl.id, 0);
}
}
@@ -1724,7 +1703,7 @@ void clif_blown(struct block_list *bl)
{
//Aegis packets says fixpos, but it's unsure whether slide works better or not.
// clif_fixpos(bl);
- clif_slide(bl, bl->x, bl->y);
+ clif->slide(bl, bl->x, bl->y);
}
@@ -1741,12 +1720,11 @@ void clif_fixpos(struct block_list *bl)
WBUFL(buf,2) = bl->id;
WBUFW(buf,6) = bl->x;
WBUFW(buf,8) = bl->y;
- clif_send(buf, packet_len(0x88), bl, AREA);
+ clif->send(buf, packet_len(0x88), bl, AREA);
- if( disguised(bl) )
- {
+ if( disguised(bl) ) {
WBUFL(buf,2) = -bl->id;
- clif_send(buf, packet_len(0x88), bl, SELF);
+ clif->send(buf, packet_len(0x88), bl, SELF);
}
}
@@ -1797,7 +1775,24 @@ void clif_buylist(struct map_session_data *sd, struct npc_data *nd)
WFIFOW(fd,2) = 4 + c*11;
WFIFOSET(fd,WFIFOW(fd,2));
}
-
+void clif_hercules_chsys_create(struct hChSysCh *channel, char *name, char *pass, unsigned char color) {
+ channel->users = idb_alloc(DB_OPT_BASE);
+ if( name )
+ safestrncpy(channel->name, name, HCHSYS_NAME_LENGTH);
+ channel->color = color;
+ if( !pass )
+ channel->pass[0] = '\0';
+ else
+ safestrncpy(channel->pass, pass, HCHSYS_NAME_LENGTH);
+
+ channel->opt = hChSys_OPT_BASE;
+ channel->banned = NULL;
+
+ channel->msg_delay = 0;
+
+ if( channel->type != hChSys_MAP && channel->type != hChSys_ALLY )
+ strdb_put(clif->channel_db, channel->name, channel);
+}
/// Presents list of items, that can be sold to an NPC shop (ZC_PC_SELL_ITEMLIST).
/// 00c7 <packet len>.W { <index>.W <price>.L <overcharge price>.L }*
@@ -1911,8 +1906,7 @@ void clif_scriptclose(struct map_session_data *sd, int npcid)
/*==========================================
*
*------------------------------------------*/
-void clif_sendfakenpc(struct map_session_data *sd, int npcid)
-{
+void clif_sendfakenpc(struct map_session_data *sd, int npcid) {
unsigned char *buf;
int fd = sd->fd;
sd->state.using_fake_npc = 1;
@@ -1963,7 +1957,7 @@ void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes)
if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
- clif_sendfakenpc(sd, npcid);
+ clif->sendfakenpc(sd, npcid);
WFIFOHEAD(fd, slen);
WFIFOW(fd,0)=0xb7;
@@ -1995,7 +1989,7 @@ void clif_scriptinput(struct map_session_data *sd, int npcid)
if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
- clif_sendfakenpc(sd, npcid);
+ clif->sendfakenpc(sd, npcid);
fd=sd->fd;
WFIFOHEAD(fd, packet_len(0x142));
@@ -2026,7 +2020,7 @@ void clif_scriptinputstr(struct map_session_data *sd, int npcid)
if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
- clif_sendfakenpc(sd, npcid);
+ clif->sendfakenpc(sd, npcid);
fd=sd->fd;
WFIFOHEAD(fd, packet_len(0x1d4));
@@ -2063,8 +2057,27 @@ void clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, in
WFIFOL(fd,19)=color;
WFIFOSET(fd,packet_len(0x144));
}
-
-
+void clif_hercules_chsys_join(struct hChSysCh *channel, struct map_session_data *sd) {
+ if( idb_put(channel->users, sd->status.char_id, sd) )
+ return;
+
+ RECREATE(sd->channels, struct hChSysCh *, ++sd->channel_count);
+ sd->channels[ sd->channel_count - 1 ] = channel;
+
+ if( sd->stealth ) {
+ sd->stealth = false;
+ } else if( channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) {
+ char message[60];
+ sprintf(message, "#%s '%s' joined",channel->name,sd->status.name);
+ clif->chsys_msg(channel,sd,message);
+ }
+
+ /* someone is cheating, we kindly disconnect the bastard */
+ if( sd->channel_count > 200 ) {
+ set_eof(sd->fd);
+ }
+
+}
/// Displays an illustration image.
/// 0145 <image name>.16B <type>.B (ZC_SHOW_IMAGE)
/// 01b3 <image name>.64B <type>.B (ZC_SHOW_IMAGE2)
@@ -2092,8 +2105,7 @@ void clif_cutin(struct map_session_data* sd, const char* image, int type)
/*==========================================
* Fills in card data from the given item and into the buffer. [Skotlex]
*------------------------------------------*/
-static void clif_addcards(unsigned char* buf, struct item* item)
-{
+void clif_addcards(unsigned char* buf, struct item* item) {
int i=0,j;
if( item == NULL ) { //Blank data
WBUFW(buf,0) = 0;
@@ -2142,79 +2154,99 @@ static void clif_addcards(unsigned char* buf, struct item* item)
WBUFW(buf,6) = item->card[i];
}
+void clif_addcards2(unsigned short *cards, struct item* item) {
+ int i=0,j;
+ if( item == NULL ) { //Blank data
+ cards[0] = 0;
+ cards[1] = 0;
+ cards[2] = 0;
+ cards[3] = 0;
+ return;
+ }
+ if( item->card[0] == CARD0_PET ) { //pet eggs
+ cards[0] = 0;
+ cards[1] = 0;
+ cards[2] = 0;
+ cards[3] = item->card[3]; //Pet renamed flag.
+ return;
+ }
+ if( item->card[0] == CARD0_FORGE || item->card[0] == CARD0_CREATE ) { //Forged/created items
+ cards[0] = item->card[0];
+ cards[1] = item->card[1];
+ cards[2] = item->card[2];
+ cards[3] = item->card[3];
+ return;
+ }
+ //Client only receives four cards.. so randomly send them a set of cards. [Skotlex]
+ if( MAX_SLOTS > 4 && (j = itemdb_slot(item->nameid)) > 4 )
+ i = rnd()%(j-3); //eg: 6 slots, possible i values: 0->3, 1->4, 2->5 => i = rnd()%3;
+
+ //Normal items.
+ if( item->card[i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 )
+ cards[0] = j;
+ else
+ cards[0] = item->card[i];
+
+ if( item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 )
+ cards[1] = j;
+ else
+ cards[1] = item->card[i];
+
+ if( item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 )
+ cards[2] = j;
+ else
+ cards[2] = item->card[i];
+
+ if( item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 )
+ cards[3] = j;
+ else
+ cards[3] = item->card[i];
+}
+
/// Notifies the client, about a received inventory item or the result of a pick-up request.
/// 00a0 <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.W <item type>.B <result>.B (ZC_ITEM_PICKUP_ACK)
/// 029a <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.W <item type>.B <result>.B <expire time>.L (ZC_ITEM_PICKUP_ACK2)
/// 02d4 <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.W <item type>.B <result>.B <expire time>.L <bindOnEquipType>.W (ZC_ITEM_PICKUP_ACK3)
-void clif_additem(struct map_session_data *sd, int n, int amount, int fail)
-{
- int fd;
-#if PACKETVER < 20061218
- const int cmd = 0xa0;
-#elif PACKETVER < 20071002
- const int cmd = 0x29a;
-#else
- const int cmd = 0x2d4;
-#endif
+void clif_additem(struct map_session_data *sd, int n, int amount, int fail) {
+ struct packet_additem p;
nullpo_retv(sd);
- fd = sd->fd;
- if( !session_isActive(fd) ) //Sasuke-
+ if( !session_isActive(sd->fd) ) //Sasuke-
return;
- WFIFOHEAD(fd,packet_len(cmd));
if( fail )
- {
- WFIFOW(fd,0)=cmd;
- WFIFOW(fd,2)=n+2;
- WFIFOW(fd,4)=amount;
- WFIFOW(fd,6)=0;
- WFIFOB(fd,8)=0;
- WFIFOB(fd,9)=0;
- WFIFOB(fd,10)=0;
- WFIFOW(fd,11)=0;
- WFIFOW(fd,13)=0;
- WFIFOW(fd,15)=0;
- WFIFOW(fd,17)=0;
- WFIFOW(fd,19)=0;
- WFIFOB(fd,21)=0;
- WFIFOB(fd,22)=fail;
-#if PACKETVER >= 20061218
- WFIFOL(fd,23)=0;
-#endif
-#if PACKETVER >= 20071002
- WFIFOW(fd,27)=0; // unknown
-#endif
- }
- else
- {
+ memset(&p, 0, sizeof(p));
+
+ p.PacketType = additemType;
+ p.Index = n+2;
+ p.count = amount;
+
+ if( !fail ) {
if( n < 0 || n >= MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL )
return;
-
- WFIFOW(fd,0)=cmd;
- WFIFOW(fd,2)=n+2;
- WFIFOW(fd,4)=amount;
+
if (sd->inventory_data[n]->view_id > 0)
- WFIFOW(fd,6)=sd->inventory_data[n]->view_id;
+ p.nameid = sd->inventory_data[n]->view_id;
else
- WFIFOW(fd,6)=sd->status.inventory[n].nameid;
- WFIFOB(fd,8)=sd->status.inventory[n].identify;
- WFIFOB(fd,9)=sd->status.inventory[n].attribute;
- WFIFOB(fd,10)=sd->status.inventory[n].refine;
- clif_addcards(WFIFOP(fd,11), &sd->status.inventory[n]);
- WFIFOW(fd,19)=pc_equippoint(sd,n);
- WFIFOB(fd,21)=itemtype(sd->inventory_data[n]->type);
- WFIFOB(fd,22)=fail;
+ p.nameid = sd->status.inventory[n].nameid;
+
+ p.IsIdentified = sd->status.inventory[n].identify;
+ p.IsDamaged = sd->status.inventory[n].attribute;
+ p.refiningLevel =sd->status.inventory[n].refine;
+ clif->addcards2(&p.slot.card[0], &sd->status.inventory[n]);
+ p.location = pc_equippoint(sd,n);
+ p.type = itemtype(sd->inventory_data[n]->type);
#if PACKETVER >= 20061218
- WFIFOL(fd,23)=sd->status.inventory[n].expire_time;
+ p.HireExpireDate = sd->status.inventory[n].expire_time;
#endif
#if PACKETVER >= 20071002
- WFIFOW(fd,27)=0; // unknown
+ p.bindOnEquipType = 0; // unused
#endif
}
+ p.result = (unsigned char)fail;
- WFIFOSET(fd,packet_len(cmd));
+ clif->send(&p,sizeof(p),&sd->bl,SELF);
}
@@ -2249,7 +2281,7 @@ void clif_dropitem(struct map_session_data *sd,int n,int amount)
void clif_delitem(struct map_session_data *sd,int n,int amount, short reason)
{
#if PACKETVER < 20091117
- clif_dropitem(sd,n,amount);
+ clif->dropitem(sd,n,amount);
#else
int fd;
@@ -2270,8 +2302,7 @@ void clif_delitem(struct map_session_data *sd,int n,int amount, short reason)
// Simplifies inventory/cart/storage packets by handling the packet section relevant to items. [Skotlex]
// Equip is >= 0 for equippable items (holds the equip-point, is 0 for pet
// armor/egg) -1 for stackable items, -2 for stackable items where arrows must send in the equip-point.
-void clif_item_sub(unsigned char *buf, int n, struct item *i, struct item_data *id, int equip)
-{
+void clif_item_sub(unsigned char *buf, int n, struct item *i, struct item_data *id, int equip) {
if (id->view_id > 0)
WBUFW(buf,n)=id->view_id;
else
@@ -2292,10 +2323,8 @@ void clif_item_sub(unsigned char *buf, int n, struct item *i, struct item_data *
}
}
-void clif_favorite_item(struct map_session_data* sd, unsigned short index);
//Unified inventory function which sends all of the inventory (requires two packets, one for equipable items and one for stackable ones. [Skotlex]
-void clif_inventorylist(struct map_session_data *sd)
-{
+void clif_inventorylist(struct map_session_data *sd) {
int i,n,ne,arrow=-1;
unsigned char *buf;
unsigned char *bufe;
@@ -2326,8 +2355,8 @@ void clif_inventorylist(struct map_session_data *sd)
if( !itemdb_isstackable2(sd->inventory_data[i]) )
{ //Non-stackable (Equippable)
WBUFW(bufe,ne*se+4)=i+2;
- clif_item_sub(bufe, ne*se+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i));
- clif_addcards(WBUFP(bufe, ne*se+16), &sd->status.inventory[i]);
+ clif->item_sub(bufe, ne*se+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i));
+ clif->addcards(WBUFP(bufe, ne*se+16), &sd->status.inventory[i]);
#if PACKETVER >= 20071002
WBUFL(bufe,ne*se+24)=sd->status.inventory[i].expire_time;
WBUFW(bufe,ne*se+28)=0; //Unknown
@@ -2343,11 +2372,11 @@ void clif_inventorylist(struct map_session_data *sd)
else
{ //Stackable.
WBUFW(buf,n*s+4)=i+2;
- clif_item_sub(buf, n*s+6, &sd->status.inventory[i], sd->inventory_data[i], -2);
+ clif->item_sub(buf, n*s+6, &sd->status.inventory[i], sd->inventory_data[i], -2);
if( sd->inventory_data[i]->equip == EQP_AMMO && sd->status.inventory[i].equip )
arrow=i;
#if PACKETVER >= 5
- clif_addcards(WBUFP(buf, n*s+14), &sd->status.inventory[i]);
+ clif->addcards(WBUFP(buf, n*s+14), &sd->status.inventory[i]);
#endif
#if PACKETVER >= 20080102
WBUFL(buf,n*s+22)=sd->status.inventory[i].expire_time;
@@ -2355,8 +2384,7 @@ void clif_inventorylist(struct map_session_data *sd)
n++;
}
}
- if( n )
- {
+ if( n ) {
#if PACKETVER < 5
WBUFW(buf,0)=0xa3;
#elif PACKETVER < 20080102
@@ -2365,20 +2393,19 @@ void clif_inventorylist(struct map_session_data *sd)
WBUFW(buf,0)=0x2e8;
#endif
WBUFW(buf,2)=4+n*s;
- clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
+ clif->send(buf, WBUFW(buf,2), &sd->bl, SELF);
}
if( arrow >= 0 )
- clif_arrowequip(sd,arrow);
+ clif->arrowequip(sd,arrow);
- if( ne )
- {
+ if( ne ) {
#if PACKETVER < 20071002
WBUFW(bufe,0)=0xa4;
#else
WBUFW(bufe,0)=0x2d0;
#endif
WBUFW(bufe,2)=4+ne*se;
- clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
+ clif->send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
}
#if PACKETVER >= 20111122
for( i = 0; i < MAX_INVENTORY; i++ ) {
@@ -2386,7 +2413,7 @@ void clif_inventorylist(struct map_session_data *sd)
continue;
if ( sd->status.inventory[i].favorite )
- clif_favorite_item(sd, i);
+ clif->favorite_item(sd, i);
}
#endif
@@ -2418,8 +2445,8 @@ void clif_equiplist(struct map_session_data *sd)
continue;
//Equippable
WBUFW(buf,n*cmd+4)=i+2;
- clif_item_sub(buf, n*cmd+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i));
- clif_addcards(WBUFP(buf, n*cmd+16), &sd->status.inventory[i]);
+ clif->item_sub(buf, n*cmd+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i));
+ clif->addcards(WBUFP(buf, n*cmd+16), &sd->status.inventory[i]);
#if PACKETVER >= 20071002
WBUFL(buf,n*cmd+24)=sd->status.inventory[i].expire_time;
WBUFW(buf,n*cmd+28)=0; //Unknown
@@ -2475,8 +2502,8 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items
if( !itemdb_isstackable2(id) )
{ //Equippable
WBUFW(bufe,ne*cmd+4)=i+1;
- clif_item_sub(bufe, ne*cmd+6, &items[i], id, id->equip);
- clif_addcards(WBUFP(bufe, ne*cmd+16), &items[i]);
+ clif->item_sub(bufe, ne*cmd+6, &items[i], id, id->equip);
+ clif->addcards(WBUFP(bufe, ne*cmd+16), &items[i]);
#if PACKETVER >= 20071002
WBUFL(bufe,ne*cmd+24)=items[i].expire_time;
WBUFW(bufe,ne*cmd+28)=0; //Unknown
@@ -2486,9 +2513,9 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items
else
{ //Stackable
WBUFW(buf,n*s+4)=i+1;
- clif_item_sub(buf, n*s+6, &items[i], id,-1);
+ clif->item_sub(buf, n*s+6, &items[i], id,-1);
#if PACKETVER >= 5
- clif_addcards(WBUFP(buf,n*s+14), &items[i]);
+ clif->addcards(WBUFP(buf,n*s+14), &items[i]);
#endif
#if PACKETVER >= 20080102
WBUFL(buf,n*s+22)=items[i].expire_time;
@@ -2506,7 +2533,7 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items
WBUFW(buf,0)=0x2ea;
#endif
WBUFW(buf,2)=4+n*s;
- clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
+ clif->send(buf, WBUFW(buf,2), &sd->bl, SELF);
}
if( ne )
{
@@ -2516,7 +2543,7 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items
WBUFW(bufe,0)=0x2d1;
#endif
WBUFW(bufe,2)=4+ne*cmd;
- clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
+ clif->send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
}
if( buf ) aFree(buf);
@@ -2555,8 +2582,8 @@ void clif_cartlist(struct map_session_data *sd)
if( !itemdb_isstackable2(id) )
{ //Equippable
WBUFW(bufe,ne*cmd+4)=i+2;
- clif_item_sub(bufe, ne*cmd+6, &sd->status.cart[i], id, id->equip);
- clif_addcards(WBUFP(bufe, ne*cmd+16), &sd->status.cart[i]);
+ clif->item_sub(bufe, ne*cmd+6, &sd->status.cart[i], id, id->equip);
+ clif->addcards(WBUFP(bufe, ne*cmd+16), &sd->status.cart[i]);
#if PACKETVER >= 20071002
WBUFL(bufe,ne*cmd+24)=sd->status.cart[i].expire_time;
WBUFW(bufe,ne*cmd+28)=0; //Unknown
@@ -2566,9 +2593,9 @@ void clif_cartlist(struct map_session_data *sd)
else
{ //Stackable
WBUFW(buf,n*s+4)=i+2;
- clif_item_sub(buf, n*s+6, &sd->status.cart[i], id,-1);
+ clif->item_sub(buf, n*s+6, &sd->status.cart[i], id,-1);
#if PACKETVER >= 5
- clif_addcards(WBUFP(buf,n*s+14), &sd->status.cart[i]);
+ clif->addcards(WBUFP(buf,n*s+14), &sd->status.cart[i]);
#endif
#if PACKETVER >= 20080102
WBUFL(buf,n*s+22)=sd->status.cart[i].expire_time;
@@ -2586,7 +2613,7 @@ void clif_cartlist(struct map_session_data *sd)
WBUFW(buf,0)=0x2e9;
#endif
WBUFW(buf,2)=4+n*s;
- clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
+ clif->send(buf, WBUFW(buf,2), &sd->bl, SELF);
}
if( ne )
{
@@ -2596,7 +2623,7 @@ void clif_cartlist(struct map_session_data *sd)
WBUFW(bufe,0)=0x2d2;
#endif
WBUFW(bufe,2)=4+ne*cmd;
- clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
+ clif->send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
}
if( buf ) aFree(buf);
@@ -2630,7 +2657,7 @@ void clif_guild_xy(struct map_session_data *sd)
WBUFL(buf,2)=sd->status.account_id;
WBUFW(buf,6)=sd->bl.x;
WBUFW(buf,8)=sd->bl.y;
- clif_send(buf,packet_len(0x1eb),&sd->bl,GUILD_SAMEMAP_WOS);
+ clif->send(buf,packet_len(0x1eb),&sd->bl,GUILD_SAMEMAP_WOS);
}
/*==========================================
@@ -2660,14 +2687,224 @@ void clif_guild_xy_remove(struct map_session_data *sd)
WBUFL(buf,2)=sd->status.account_id;
WBUFW(buf,6)=-1;
WBUFW(buf,8)=-1;
- clif_send(buf,packet_len(0x1eb),&sd->bl,GUILD_SAMEMAP_WOS);
+ clif->send(buf,packet_len(0x1eb),&sd->bl,GUILD_SAMEMAP_WOS);
+}
+void read_channels_config(void) {
+ config_t channels_conf;
+ config_setting_t *chsys = NULL;
+ const char *config_filename = "conf/channels.conf"; // FIXME hardcoded name
+
+ if (conf_read_file(&channels_conf, config_filename))
+ return;
+
+ chsys = config_lookup(&channels_conf, "chsys");
+
+ if (chsys != NULL) {
+ config_setting_t *settings = config_setting_get_elem(chsys, 0);
+ config_setting_t *channels;
+ config_setting_t *colors;
+ int i,k;
+ const char *local_name, *ally_name,
+ *local_color, *ally_color,
+ *irc_name, *irc_color;
+ int ally_enabled = 0, local_enabled = 0,
+ local_autojoin = 0, ally_autojoin = 0,
+ allow_user_channel_creation = 0,
+ irc_enabled = 0;
+
+ if( !config_setting_lookup_string(settings, "map_local_channel_name", &local_name) )
+ local_name = "map";
+ safestrncpy(hChSys.local_name, local_name, HCHSYS_NAME_LENGTH);
+
+ if( !config_setting_lookup_string(settings, "ally_channel_name", &ally_name) )
+ ally_name = "ally";
+ safestrncpy(hChSys.ally_name, ally_name, HCHSYS_NAME_LENGTH);
+
+ if( !config_setting_lookup_string(settings, "irc_channel_name", &irc_name) )
+ irc_name = "irc";
+ safestrncpy(hChSys.irc_name, irc_name, HCHSYS_NAME_LENGTH);
+
+ config_setting_lookup_bool(settings, "map_local_channel", &local_enabled);
+ config_setting_lookup_bool(settings, "ally_channel_enabled", &ally_enabled);
+ config_setting_lookup_bool(settings, "irc_channel_enabled", &irc_enabled);
+
+ if( local_enabled )
+ hChSys.local = true;
+ if( ally_enabled )
+ hChSys.ally = true;
+ if( irc_enabled )
+ hChSys.irc = true;
+
+ hChSys.irc_server[0] = hChSys.irc_channel[0] = hChSys.irc_nick[0] = hChSys.irc_nick_pw[0] = '\0';
+
+ if( hChSys.irc ) {
+ const char *irc_server, *irc_channel,
+ *irc_nick, *irc_nick_pw;
+ if( config_setting_lookup_string(settings, "irc_channel_network", &irc_server) ) {
+ if( !strstr(irc_server,":") ) {
+ hChSys.irc = false;
+ ShowWarning("channels.conf : network port wasn't found in 'irc_channel_network', disabling irc channel...\n");
+ } else {
+ unsigned char d = 0, dlen = strlen(irc_server);
+ char server[40];
+ for(d = 0; d < dlen; d++) {
+ if(irc_server[d] == ':') {
+ memcpy(server, irc_server, d);
+ safestrncpy(hChSys.irc_server, server, 40);
+ memcpy(server, &irc_server[d+1], dlen);
+ hChSys.irc_server_port = atoi(server);
+ break;
+ }
+ }
+ }
+ } else {
+ hChSys.irc = false;
+ ShowWarning("channels.conf : irc channel enabled but irc_channel_network wasn't found, disabling irc channel...\n");
+ }
+ if( config_setting_lookup_string(settings, "irc_channel_channel", &irc_channel) )
+ safestrncpy(hChSys.irc_channel, irc_channel, 20);
+ else {
+ hChSys.irc = false;
+ ShowWarning("channels.conf : irc channel enabled but irc_channel_channel wasn't found, disabling irc channel...\n");
+ }
+ if( config_setting_lookup_string(settings, "irc_channel_nick", &irc_nick) ) {
+ if( strcmpi(irc_nick,"Hercules_chSysBot") == 0 ) {
+ sprintf(hChSys.irc_nick, "Hercules_chSysBot%d",rand()%777);
+ } else
+ safestrncpy(hChSys.irc_nick, irc_nick, 30);
+ } else {
+ hChSys.irc = false;
+ ShowWarning("channels.conf : irc channel enabled but irc_channel_nick wasn't found, disabling irc channel...\n");
+ }
+ if( config_setting_lookup_string(settings, "irc_channel_nick_pw", &irc_nick_pw) )
+ safestrncpy(hChSys.irc_nick_pw, irc_nick_pw, 30);
+
+ }
+
+ config_setting_lookup_bool(settings, "map_local_channel_autojoin", &local_autojoin);
+ config_setting_lookup_bool(settings, "ally_channel_autojoin", &ally_autojoin);
+
+ if( local_autojoin )
+ hChSys.local_autojoin = true;
+ if( ally_autojoin )
+ hChSys.ally_autojoin = true;
+
+ config_setting_lookup_bool(settings, "allow_user_channel_creation", &allow_user_channel_creation);
+
+ if( allow_user_channel_creation )
+ hChSys.allow_user_channel_creation = true;
+
+ if( (colors = config_setting_get_member(settings, "colors")) != NULL ) {
+ int color_count = config_setting_length(colors);
+ CREATE( hChSys.colors, unsigned long, color_count );
+ CREATE( hChSys.colors_name, char *, color_count );
+ for(i = 0; i < color_count; i++) {
+ config_setting_t *color = config_setting_get_elem(colors, i);
+
+ CREATE( hChSys.colors_name[i], char, HCHSYS_NAME_LENGTH );
+
+ safestrncpy(hChSys.colors_name[i], config_setting_name(color), HCHSYS_NAME_LENGTH);
+
+ hChSys.colors[i] = strtoul(config_setting_get_string_elem(colors,i),NULL,0);
+ hChSys.colors[i] = (hChSys.colors[i] & 0x0000FF) << 16 | (hChSys.colors[i] & 0x00FF00) | (hChSys.colors[i] & 0xFF0000) >> 16;//RGB to BGR
+ }
+ hChSys.colors_count = color_count;
+ }
+
+ config_setting_lookup_string(settings, "map_local_channel_color", &local_color);
+
+ for (k = 0; k < hChSys.colors_count; k++) {
+ if( strcmpi(hChSys.colors_name[k],local_color) == 0 )
+ break;
+ }
+
+ if( k < hChSys.colors_count ) {
+ hChSys.local_color = k;
+ } else {
+ ShowError("channels.conf: unknown color '%s' for 'map_local_channel_color', disabling '#%s'...\n",local_color,local_name);
+ hChSys.local = false;
+ }
+
+ config_setting_lookup_string(settings, "ally_channel_color", &ally_color);
+
+ for (k = 0; k < hChSys.colors_count; k++) {
+ if( strcmpi(hChSys.colors_name[k],ally_color) == 0 )
+ break;
+ }
+
+ if( k < hChSys.colors_count ) {
+ hChSys.ally_color = k;
+ } else {
+ ShowError("channels.conf: unknown color '%s' for 'ally_channel_color', disabling '#%s'...\n",ally_color,ally_name);
+ hChSys.ally = false;
+ }
+
+ config_setting_lookup_string(settings, "irc_channel_color", &irc_color);
+
+ for (k = 0; k < hChSys.colors_count; k++) {
+ if( strcmpi(hChSys.colors_name[k],irc_color) == 0 )
+ break;
+ }
+
+ if( k < hChSys.colors_count ) {
+ hChSys.irc_color = k;
+ } else {
+ ShowError("channels.conf: unknown color '%s' for 'irc_channel_color', disabling '#%s'...\n",irc_color,irc_name);
+ hChSys.irc = false;
+ }
+
+ if( hChSys.irc ) {
+ struct hChSysCh *chd;
+ CREATE( chd, struct hChSysCh, 1 );
+
+ safestrncpy(chd->name, hChSys.irc_name, HCHSYS_NAME_LENGTH);
+ chd->type = hChSys_IRC;
+
+ clif->chsys_create(chd,NULL,NULL,hChSys.irc_color);
+ ircbot->channel = chd;
+ }
+
+ if( (channels = config_setting_get_member(settings, "default_channels")) != NULL ) {
+ int channel_count = config_setting_length(channels);
+
+ for(i = 0; i < channel_count; i++) {
+ config_setting_t *channel = config_setting_get_elem(channels, i);
+ const char *name = config_setting_name(channel);
+ const char *color = config_setting_get_string_elem(channels,i);
+ struct hChSysCh *chd;
+
+ for (k = 0; k < hChSys.colors_count; k++) {
+ if( strcmpi(hChSys.colors_name[k],color) == 0 )
+ break;
+ }
+ if( k == hChSys.colors_count ) {
+ ShowError("channels.conf: unknown color '%s' for channel '%s', skipping channel...\n",color,name);
+ continue;
+ }
+ if( strcmpi(name,hChSys.local_name) == 0 || strcmpi(name,hChSys.ally_name) == 0 || strcmpi(name,hChSys.irc_name) == 0 || strdb_exists(clif->channel_db, name) ) {
+ ShowError("channels.conf: duplicate channel '%s', skipping channel...\n",name);
+ continue;
+
+ }
+ CREATE( chd, struct hChSysCh, 1 );
+
+ safestrncpy(chd->name, name, HCHSYS_NAME_LENGTH);
+ chd->type = hChSys_PUBLIC;
+
+ clif->chsys_create(chd,NULL,NULL,k);
+ }
+ }
+
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' channels in '"CL_WHITE"%s"CL_RESET"'.\n", db_size(clif->channel_db), config_filename);
+ config_destroy(&channels_conf);
+ }
}
+
/*==========================================
*
*------------------------------------------*/
-static int clif_hpmeter_sub(struct block_list *bl, va_list ap)
-{
+int clif_hpmeter_sub(struct block_list *bl, va_list ap) {
struct map_session_data *sd, *tsd;
#if PACKETVER < 20100126
const int cmd = 0x106;
@@ -2710,10 +2947,9 @@ static int clif_hpmeter_sub(struct block_list *bl, va_list ap)
* Server tells all players that are allowed to view HP bars
* and are nearby 'sd' that 'sd' hp bar was updated.
*------------------------------------------*/
-static int clif_hpmeter(struct map_session_data *sd)
-{
+int clif_hpmeter(struct map_session_data *sd) {
nullpo_ret(sd);
- map_foreachinarea(clif_hpmeter_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd);
+ map_foreachinarea(clif->hpmeter_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd);
return 0;
}
@@ -2741,205 +2977,205 @@ void clif_updatestatus(struct map_session_data *sd,int type)
WFIFOW(fd,0)=0xb0;
WFIFOW(fd,2)=type;
switch(type){
- // 00b0
- case SP_WEIGHT:
- pc_updateweightstatus(sd);
- WFIFOHEAD(fd,14);
- WFIFOW(fd,0)=0xb0; //Need to re-set as pc_updateweightstatus can alter the buffer. [Skotlex]
- WFIFOW(fd,2)=type;
- WFIFOL(fd,4)=sd->weight;
- break;
- case SP_MAXWEIGHT:
- WFIFOL(fd,4)=sd->max_weight;
- break;
- case SP_SPEED:
- WFIFOL(fd,4)=sd->battle_status.speed;
- break;
- case SP_BASELEVEL:
- WFIFOL(fd,4)=sd->status.base_level;
- break;
- case SP_JOBLEVEL:
- WFIFOL(fd,4)=sd->status.job_level;
- break;
- case SP_KARMA: // Adding this back, I wonder if the client intercepts this - [Lance]
- WFIFOL(fd,4)=sd->status.karma;
- break;
- case SP_MANNER:
- WFIFOL(fd,4)=sd->status.manner;
- break;
- case SP_STATUSPOINT:
- WFIFOL(fd,4)=sd->status.status_point;
- break;
- case SP_SKILLPOINT:
- WFIFOL(fd,4)=sd->status.skill_point;
- break;
- case SP_HIT:
- WFIFOL(fd,4)=sd->battle_status.hit;
- break;
- case SP_FLEE1:
- WFIFOL(fd,4)=sd->battle_status.flee;
- break;
- case SP_FLEE2:
- WFIFOL(fd,4)=sd->battle_status.flee2/10;
- break;
- case SP_MAXHP:
- WFIFOL(fd,4)=sd->battle_status.max_hp;
- break;
- case SP_MAXSP:
- WFIFOL(fd,4)=sd->battle_status.max_sp;
- break;
- case SP_HP:
- WFIFOL(fd,4)=sd->battle_status.hp;
- // TODO: Won't these overwrite the current packet?
- clif_hpmeter(sd);
- if( !battle_config.party_hp_mode && sd->status.party_id )
- clif_party_hp(sd);
- if( sd->bg_id )
- clif_bg_hp(sd);
- break;
- case SP_SP:
- WFIFOL(fd,4)=sd->battle_status.sp;
- break;
- case SP_ASPD:
- WFIFOL(fd,4)=sd->battle_status.amotion;
- break;
- case SP_ATK1:
- WFIFOL(fd,4)=pc_leftside_atk(sd);
- break;
- case SP_DEF1:
- WFIFOL(fd,4)=pc_leftside_def(sd);
- break;
- case SP_MDEF1:
- WFIFOL(fd,4)=pc_leftside_mdef(sd);
- break;
- case SP_ATK2:
- WFIFOL(fd,4)=pc_rightside_atk(sd);
- break;
- case SP_DEF2:
- WFIFOL(fd,4)=pc_rightside_def(sd);
- break;
- case SP_MDEF2: {
- //negative check (in case you have something like Berserk active)
- int mdef2 = pc_rightside_mdef(sd);
+ // 00b0
+ case SP_WEIGHT:
+ pc_updateweightstatus(sd);
+ WFIFOHEAD(fd,14);
+ WFIFOW(fd,0)=0xb0; //Need to re-set as pc_updateweightstatus can alter the buffer. [Skotlex]
+ WFIFOW(fd,2)=type;
+ WFIFOL(fd,4)=sd->weight;
+ break;
+ case SP_MAXWEIGHT:
+ WFIFOL(fd,4)=sd->max_weight;
+ break;
+ case SP_SPEED:
+ WFIFOL(fd,4)=sd->battle_status.speed;
+ break;
+ case SP_BASELEVEL:
+ WFIFOL(fd,4)=sd->status.base_level;
+ break;
+ case SP_JOBLEVEL:
+ WFIFOL(fd,4)=sd->status.job_level;
+ break;
+ case SP_KARMA: // Adding this back, I wonder if the client intercepts this - [Lance]
+ WFIFOL(fd,4)=sd->status.karma;
+ break;
+ case SP_MANNER:
+ WFIFOL(fd,4)=sd->status.manner;
+ break;
+ case SP_STATUSPOINT:
+ WFIFOL(fd,4)=sd->status.status_point;
+ break;
+ case SP_SKILLPOINT:
+ WFIFOL(fd,4)=sd->status.skill_point;
+ break;
+ case SP_HIT:
+ WFIFOL(fd,4)=sd->battle_status.hit;
+ break;
+ case SP_FLEE1:
+ WFIFOL(fd,4)=sd->battle_status.flee;
+ break;
+ case SP_FLEE2:
+ WFIFOL(fd,4)=sd->battle_status.flee2/10;
+ break;
+ case SP_MAXHP:
+ WFIFOL(fd,4)=sd->battle_status.max_hp;
+ break;
+ case SP_MAXSP:
+ WFIFOL(fd,4)=sd->battle_status.max_sp;
+ break;
+ case SP_HP:
+ WFIFOL(fd,4)=sd->battle_status.hp;
+ // TODO: Won't these overwrite the current packet?
+ clif->hpmeter(sd);
+ if( !battle_config.party_hp_mode && sd->status.party_id )
+ clif->party_hp(sd);
+ if( sd->bg_id )
+ clif->bg_hp(sd);
+ break;
+ case SP_SP:
+ WFIFOL(fd,4)=sd->battle_status.sp;
+ break;
+ case SP_ASPD:
+ WFIFOL(fd,4)=sd->battle_status.amotion;
+ break;
+ case SP_ATK1:
+ WFIFOL(fd,4)=pc_leftside_atk(sd);
+ break;
+ case SP_DEF1:
+ WFIFOL(fd,4)=pc_leftside_def(sd);
+ break;
+ case SP_MDEF1:
+ WFIFOL(fd,4)=pc_leftside_mdef(sd);
+ break;
+ case SP_ATK2:
+ WFIFOL(fd,4)=pc_rightside_atk(sd);
+ break;
+ case SP_DEF2:
+ WFIFOL(fd,4)=pc_rightside_def(sd);
+ break;
+ case SP_MDEF2: {
+ //negative check (in case you have something like Berserk active)
+ int mdef2 = pc_rightside_mdef(sd);
- WFIFOL(fd,4)=
-#ifndef RENEWAL
- ( mdef2 < 0 ) ? 0 :
-#endif
- mdef2;
+ WFIFOL(fd,4)=
+ #ifndef RENEWAL
+ ( mdef2 < 0 ) ? 0 :
+ #endif
+ mdef2;
- }
- break;
- case SP_CRITICAL:
- WFIFOL(fd,4)=sd->battle_status.cri/10;
- break;
- case SP_MATK1:
- WFIFOL(fd,4)=pc_rightside_matk(sd);
- break;
- case SP_MATK2:
- WFIFOL(fd,4)=pc_leftside_matk(sd);
- break;
+ }
+ break;
+ case SP_CRITICAL:
+ WFIFOL(fd,4)=sd->battle_status.cri/10;
+ break;
+ case SP_MATK1:
+ WFIFOL(fd,4)=pc_rightside_matk(sd);
+ break;
+ case SP_MATK2:
+ WFIFOL(fd,4)=pc_leftside_matk(sd);
+ break;
- case SP_ZENY:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=sd->status.zeny;
- break;
- case SP_BASEEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=sd->status.base_exp;
- break;
- case SP_JOBEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=sd->status.job_exp;
- break;
- case SP_NEXTBASEEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=pc_nextbaseexp(sd);
- break;
- case SP_NEXTJOBEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=pc_nextjobexp(sd);
- break;
+ case SP_ZENY:
+ WFIFOW(fd,0)=0xb1;
+ WFIFOL(fd,4)=sd->status.zeny;
+ break;
+ case SP_BASEEXP:
+ WFIFOW(fd,0)=0xb1;
+ WFIFOL(fd,4)=sd->status.base_exp;
+ break;
+ case SP_JOBEXP:
+ WFIFOW(fd,0)=0xb1;
+ WFIFOL(fd,4)=sd->status.job_exp;
+ break;
+ case SP_NEXTBASEEXP:
+ WFIFOW(fd,0)=0xb1;
+ WFIFOL(fd,4)=pc_nextbaseexp(sd);
+ break;
+ case SP_NEXTJOBEXP:
+ WFIFOW(fd,0)=0xb1;
+ WFIFOL(fd,4)=pc_nextjobexp(sd);
+ break;
- /**
- * SP_U<STAT> are used to update the amount of points necessary to increase that stat
- **/
- case SP_USTR:
- case SP_UAGI:
- case SP_UVIT:
- case SP_UINT:
- case SP_UDEX:
- case SP_ULUK:
- WFIFOW(fd,0)=0xbe;
- WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR,1);
- len=5;
- break;
+ /**
+ * SP_U<STAT> are used to update the amount of points necessary to increase that stat
+ **/
+ case SP_USTR:
+ case SP_UAGI:
+ case SP_UVIT:
+ case SP_UINT:
+ case SP_UDEX:
+ case SP_ULUK:
+ WFIFOW(fd,0)=0xbe;
+ WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR,1);
+ len=5;
+ break;
- /**
- * Tells the client how far it is allowed to attack (weapon range)
- **/
- case SP_ATTACKRANGE:
- WFIFOW(fd,0)=0x13a;
- WFIFOW(fd,2)=sd->battle_status.rhw.range;
- len=4;
- break;
+ /**
+ * Tells the client how far it is allowed to attack (weapon range)
+ **/
+ case SP_ATTACKRANGE:
+ WFIFOW(fd,0)=0x13a;
+ WFIFOW(fd,2)=sd->battle_status.rhw.range;
+ len=4;
+ break;
- case SP_STR:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.str;
- WFIFOL(fd,10)=sd->battle_status.str - sd->status.str;
- len=14;
- break;
- case SP_AGI:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.agi;
- WFIFOL(fd,10)=sd->battle_status.agi - sd->status.agi;
- len=14;
- break;
- case SP_VIT:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.vit;
- WFIFOL(fd,10)=sd->battle_status.vit - sd->status.vit;
- len=14;
- break;
- case SP_INT:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.int_;
- WFIFOL(fd,10)=sd->battle_status.int_ - sd->status.int_;
- len=14;
- break;
- case SP_DEX:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.dex;
- WFIFOL(fd,10)=sd->battle_status.dex - sd->status.dex;
- len=14;
- break;
- case SP_LUK:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.luk;
- WFIFOL(fd,10)=sd->battle_status.luk - sd->status.luk;
- len=14;
- break;
+ case SP_STR:
+ WFIFOW(fd,0)=0x141;
+ WFIFOL(fd,2)=type;
+ WFIFOL(fd,6)=sd->status.str;
+ WFIFOL(fd,10)=sd->battle_status.str - sd->status.str;
+ len=14;
+ break;
+ case SP_AGI:
+ WFIFOW(fd,0)=0x141;
+ WFIFOL(fd,2)=type;
+ WFIFOL(fd,6)=sd->status.agi;
+ WFIFOL(fd,10)=sd->battle_status.agi - sd->status.agi;
+ len=14;
+ break;
+ case SP_VIT:
+ WFIFOW(fd,0)=0x141;
+ WFIFOL(fd,2)=type;
+ WFIFOL(fd,6)=sd->status.vit;
+ WFIFOL(fd,10)=sd->battle_status.vit - sd->status.vit;
+ len=14;
+ break;
+ case SP_INT:
+ WFIFOW(fd,0)=0x141;
+ WFIFOL(fd,2)=type;
+ WFIFOL(fd,6)=sd->status.int_;
+ WFIFOL(fd,10)=sd->battle_status.int_ - sd->status.int_;
+ len=14;
+ break;
+ case SP_DEX:
+ WFIFOW(fd,0)=0x141;
+ WFIFOL(fd,2)=type;
+ WFIFOL(fd,6)=sd->status.dex;
+ WFIFOL(fd,10)=sd->battle_status.dex - sd->status.dex;
+ len=14;
+ break;
+ case SP_LUK:
+ WFIFOW(fd,0)=0x141;
+ WFIFOL(fd,2)=type;
+ WFIFOL(fd,6)=sd->status.luk;
+ WFIFOL(fd,10)=sd->battle_status.luk - sd->status.luk;
+ len=14;
+ break;
- case SP_CARTINFO:
- WFIFOW(fd,0)=0x121;
- WFIFOW(fd,2)=sd->cart_num;
- WFIFOW(fd,4)=MAX_CART;
- WFIFOL(fd,6)=sd->cart_weight;
- WFIFOL(fd,10)=sd->cart_weight_max;
- len=14;
- break;
+ case SP_CARTINFO:
+ WFIFOW(fd,0)=0x121;
+ WFIFOW(fd,2)=sd->cart_num;
+ WFIFOW(fd,4)=MAX_CART;
+ WFIFOL(fd,6)=sd->cart_weight;
+ WFIFOL(fd,10)=sd->cart_weight_max;
+ len=14;
+ break;
- default:
- ShowError("clif_updatestatus : unrecognized type %d\n",type);
- return;
+ default:
+ ShowError("clif->updatestatus : unrecognized type %d\n",type);
+ return;
}
WFIFOSET(fd,len);
}
@@ -2967,7 +3203,7 @@ void clif_changestatus(struct map_session_data* sd,int type,int val)
return;
}
- clif_send(buf,packet_len(0x1ab),&sd->bl,AREA_WOS);
+ clif->send(buf,packet_len(0x1ab),&sd->bl,AREA_WOS);
}
@@ -2977,7 +3213,7 @@ void clif_changestatus(struct map_session_data* sd,int type,int val)
void clif_changelook(struct block_list *bl,int type,int val)
{
unsigned char buf[16];
- struct map_session_data* sd = NULL;
+ struct map_session_data* sd;
struct status_change* sc;
struct view_data* vd;
enum send_target target = AREA;
@@ -2988,85 +3224,97 @@ void clif_changelook(struct block_list *bl,int type,int val)
vd = status_get_viewdata(bl);
//nullpo_ret(vd);
if( vd ) //temp hack to let Warp Portal change appearance
- switch(type)
- {
- case LOOK_WEAPON:
- if (sd)
- {
- clif_get_weapon_view(sd, &vd->weapon, &vd->shield);
- val = vd->weapon;
- }
- else vd->weapon = val;
- break;
- case LOOK_SHIELD:
- if (sd)
- {
- clif_get_weapon_view(sd, &vd->weapon, &vd->shield);
- val = vd->shield;
- }
- else vd->shield = val;
- break;
- case LOOK_BASE:
- vd->class_ = val;
- if (vd->class_ == JOB_WEDDING || vd->class_ == JOB_XMAS || vd->class_ == JOB_SUMMER)
- vd->weapon = vd->shield = 0;
- if (vd->cloth_color && (
- (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) ||
- (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette) ||
- (vd->class_ == JOB_SUMMER && battle_config.summer_ignorepalette)
- ))
- clif_changelook(bl,LOOK_CLOTHES_COLOR,0);
- break;
- case LOOK_HAIR:
- vd->hair_style = val;
- break;
- case LOOK_HEAD_BOTTOM:
- vd->head_bottom = val;
- break;
- case LOOK_HEAD_TOP:
- vd->head_top = val;
- break;
- case LOOK_HEAD_MID:
- vd->head_mid = val;
- break;
- case LOOK_HAIR_COLOR:
- vd->hair_color = val;
- break;
- case LOOK_CLOTHES_COLOR:
- if (val && (
- (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) ||
- (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette) ||
- (vd->class_ == JOB_SUMMER && battle_config.summer_ignorepalette)
- ))
- val = 0;
- vd->cloth_color = val;
- break;
- case LOOK_SHOES:
-#if PACKETVER > 3
- if (sd) {
- int n;
- if((n = sd->equip_index[2]) >= 0 && sd->inventory_data[n]) {
- if(sd->inventory_data[n]->view_id > 0)
- val = sd->inventory_data[n]->view_id;
- else
- val = sd->status.inventory[n].nameid;
- } else
- val = 0;
- }
-#endif
- //Shoes? No packet uses this....
- break;
- case LOOK_BODY:
- case LOOK_FLOOR:
- // unknown purpose
- break;
- case LOOK_ROBE:
-#if PACKETVER < 20110111
- return;
-#else
- vd->robe = val;
-#endif
- break;
+ switch(type) {
+ case LOOK_WEAPON:
+ if (sd) {
+ clif->get_weapon_view(sd, &vd->weapon, &vd->shield);
+ val = vd->weapon;
+ }
+ else
+ vd->weapon = val;
+ break;
+ case LOOK_SHIELD:
+ if (sd) {
+ clif->get_weapon_view(sd, &vd->weapon, &vd->shield);
+ val = vd->shield;
+ }
+ else
+ vd->shield = val;
+ break;
+ case LOOK_BASE:
+ if( !sd ) break;
+
+ if( sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK) )
+ vd->weapon = vd->shield = 0;
+
+ if( !vd->cloth_color )
+ break;
+
+ if( sd ) {
+ if( sd->sc.option&OPTION_WEDDING && battle_config.wedding_ignorepalette )
+ vd->cloth_color = 0;
+ if( sd->sc.option&OPTION_XMAS && battle_config.xmas_ignorepalette )
+ vd->cloth_color = 0;
+ if( sd->sc.option&OPTION_SUMMER && battle_config.summer_ignorepalette )
+ vd->cloth_color = 0;
+ if( sd->sc.option&OPTION_HANBOK && battle_config.hanbok_ignorepalette )
+ vd->cloth_color = 0;
+ }
+ break;
+ case LOOK_HAIR:
+ vd->hair_style = val;
+ break;
+ case LOOK_HEAD_BOTTOM:
+ vd->head_bottom = val;
+ break;
+ case LOOK_HEAD_TOP:
+ vd->head_top = val;
+ break;
+ case LOOK_HEAD_MID:
+ vd->head_mid = val;
+ break;
+ case LOOK_HAIR_COLOR:
+ vd->hair_color = val;
+ break;
+ case LOOK_CLOTHES_COLOR:
+ if( val && sd ) {
+ if( sd->sc.option&OPTION_WEDDING && battle_config.wedding_ignorepalette )
+ val = 0;
+ if( sd->sc.option&OPTION_XMAS && battle_config.xmas_ignorepalette )
+ val = 0;
+ if( sd->sc.option&OPTION_SUMMER && battle_config.summer_ignorepalette )
+ val = 0;
+ if( sd->sc.option&OPTION_HANBOK && battle_config.hanbok_ignorepalette )
+ val = 0;
+ }
+ vd->cloth_color = val;
+ break;
+ case LOOK_SHOES:
+ #if PACKETVER > 3
+ if (sd) {
+ int n;
+ if((n = sd->equip_index[2]) >= 0 && sd->inventory_data[n]) {
+ if(sd->inventory_data[n]->view_id > 0)
+ val = sd->inventory_data[n]->view_id;
+ else
+ val = sd->status.inventory[n].nameid;
+ } else
+ val = 0;
+ }
+ #endif
+ //Shoes? No packet uses this....
+ break;
+ case LOOK_BODY:
+ case LOOK_FLOOR:
+ // unknown purpose
+ break;
+ case LOOK_ROBE:
+ #if PACKETVER < 20110111
+ return;
+ #else
+ vd->robe = val;
+ #endif
+ break;
}
// prevent leaking the presence of GM-hidden objects
@@ -3078,7 +3326,7 @@ void clif_changelook(struct block_list *bl,int type,int val)
WBUFL(buf,2)=bl->id;
WBUFB(buf,6)=type;
WBUFB(buf,7)=val;
- clif_send(buf,packet_len(0xc3),bl,target);
+ clif->send(buf,packet_len(0xc3),bl,target);
#else
WBUFW(buf,0)=0x1d7;
WBUFL(buf,2)=bl->id;
@@ -3090,7 +3338,11 @@ void clif_changelook(struct block_list *bl,int type,int val)
WBUFB(buf,6)=type;
WBUFL(buf,7)=val;
}
- clif_send(buf,packet_len(0x1d7),bl,target);
+ clif->send(buf,packet_len(0x1d7),bl,target);
+ if( disguised(bl) && ((TBL_PC*)sd)->fontcolor ) {
+ WBUFL(buf,2)=-bl->id;
+ clif->send(buf,packet_len(0x1d7),bl,SELF);
+ }
#endif
}
@@ -3103,14 +3355,14 @@ void clif_changetraplook(struct block_list *bl,int val)
WBUFL(buf,2)=bl->id;
WBUFB(buf,6)=LOOK_BASE;
WBUFB(buf,7)=val;
- clif_send(buf,packet_len(0xc3),bl,AREA);
+ clif->send(buf,packet_len(0xc3),bl,AREA);
#else
WBUFW(buf,0)=0x1d7;
WBUFL(buf,2)=bl->id;
WBUFB(buf,6)=LOOK_BASE;
WBUFW(buf,7)=val;
WBUFW(buf,9)=0;
- clif_send(buf,packet_len(0x1d7),bl,AREA);
+ clif->send(buf,packet_len(0x1d7),bl,AREA);
#endif
}
@@ -3123,14 +3375,14 @@ void clif_refreshlook(struct block_list *bl,int id,int type,int val,enum send_ta
WBUFL(buf,2)=id;
WBUFB(buf,6)=type;
WBUFB(buf,7)=val;
- clif_send(buf,packet_len(0xc3),bl,target);
+ clif->send(buf,packet_len(0xc3),bl,target);
#else
WBUFW(buf,0)=0x1d7;
WBUFL(buf,2)=id;
WBUFB(buf,6)=type;
WBUFW(buf,7)=val;
WBUFW(buf,9)=0;
- clif_send(buf,packet_len(0x1d7),bl,target);
+ clif->send(buf,packet_len(0x1d7),bl,target);
#endif
}
@@ -3140,8 +3392,7 @@ void clif_refreshlook(struct block_list *bl,int id,int type,int val,enum send_ta
/// <int>.B <need int>.B <dex>.B <need dex>.B <luk>.B <need luk>.B <atk>.W <atk2>.W
/// <matk min>.W <matk max>.W <def>.W <def2>.W <mdef>.W <mdef2>.W <hit>.W
/// <flee>.W <flee2>.W <crit>.W <aspd>.W <aspd2>.W
-void clif_initialstatus(struct map_session_data *sd)
-{
+void clif_initialstatus(struct map_session_data *sd) {
int fd, mdef2;
unsigned char *buf;
@@ -3188,15 +3439,15 @@ void clif_initialstatus(struct map_session_data *sd)
WFIFOSET(fd,packet_len(0xbd));
- clif_updatestatus(sd,SP_STR);
- clif_updatestatus(sd,SP_AGI);
- clif_updatestatus(sd,SP_VIT);
- clif_updatestatus(sd,SP_INT);
- clif_updatestatus(sd,SP_DEX);
- clif_updatestatus(sd,SP_LUK);
+ clif->updatestatus(sd,SP_STR);
+ clif->updatestatus(sd,SP_AGI);
+ clif->updatestatus(sd,SP_VIT);
+ clif->updatestatus(sd,SP_INT);
+ clif->updatestatus(sd,SP_DEX);
+ clif->updatestatus(sd,SP_LUK);
- clif_updatestatus(sd,SP_ATTACKRANGE);
- clif_updatestatus(sd,SP_ASPD);
+ clif->updatestatus(sd,SP_ATTACKRANGE);
+ clif->updatestatus(sd,SP_ASPD);
}
@@ -3373,7 +3624,7 @@ void clif_misceffect(struct block_list* bl,int type)
WBUFL(buf,2) = bl->id;
WBUFL(buf,6) = type;
- clif_send(buf,packet_len(0x19b),bl,AREA);
+ clif->send(buf,packet_len(0x19b),bl,AREA);
}
@@ -3399,14 +3650,14 @@ void clif_changeoption(struct block_list* bl)
WBUFL(buf,10) = sc->option;
WBUFB(buf,14) = (sd)? sd->status.karma : 0;
if(disguised(bl)) {
- clif_send(buf,packet_len(0x229),bl,AREA_WOS);
+ clif->send(buf,packet_len(0x229),bl,AREA_WOS);
WBUFL(buf,2) = -bl->id;
- clif_send(buf,packet_len(0x229),bl,SELF);
+ clif->send(buf,packet_len(0x229),bl,SELF);
WBUFL(buf,2) = bl->id;
WBUFL(buf,10) = OPTION_INVISIBLE;
- clif_send(buf,packet_len(0x229),bl,SELF);
+ clif->send(buf,packet_len(0x229),bl,SELF);
} else
- clif_send(buf,packet_len(0x229),bl,AREA);
+ clif->send(buf,packet_len(0x229),bl,AREA);
#else
WBUFW(buf,0) = 0x119;
WBUFL(buf,2) = bl->id;
@@ -3415,14 +3666,14 @@ void clif_changeoption(struct block_list* bl)
WBUFW(buf,10) = sc->option;
WBUFB(buf,12) = (sd)? sd->status.karma : 0;
if(disguised(bl)) {
- clif_send(buf,packet_len(0x119),bl,AREA_WOS);
+ clif->send(buf,packet_len(0x119),bl,AREA_WOS);
WBUFL(buf,2) = -bl->id;
- clif_send(buf,packet_len(0x119),bl,SELF);
+ clif->send(buf,packet_len(0x119),bl,SELF);
WBUFL(buf,2) = bl->id;
WBUFW(buf,10) = OPTION_INVISIBLE;
- clif_send(buf,packet_len(0x119),bl,SELF);
+ clif->send(buf,packet_len(0x119),bl,SELF);
} else
- clif_send(buf,packet_len(0x119),bl,AREA);
+ clif->send(buf,packet_len(0x119),bl,AREA);
#endif
}
@@ -3443,14 +3694,14 @@ void clif_changeoption2(struct block_list* bl)
WBUFL(buf,10) = clif_setlevel(bl);
WBUFL(buf,14) = sc->opt3;
if(disguised(bl)) {
- clif_send(buf,packet_len(0x28a),bl,AREA_WOS);
+ clif->send(buf,packet_len(0x28a),bl,AREA_WOS);
WBUFL(buf,2) = -bl->id;
- clif_send(buf,packet_len(0x28a),bl,SELF);
+ clif->send(buf,packet_len(0x28a),bl,SELF);
WBUFL(buf,2) = bl->id;
WBUFL(buf,6) = OPTION_INVISIBLE;
- clif_send(buf,packet_len(0x28a),bl,SELF);
+ clif->send(buf,packet_len(0x28a),bl,SELF);
} else
- clif_send(buf,packet_len(0x28a),bl,AREA);
+ clif->send(buf,packet_len(0x28a),bl,AREA);
}
@@ -3491,11 +3742,25 @@ void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok)
WBUFL(buf,6)=sd->bl.id;
WBUFW(buf,10)=amount;
WBUFB(buf,12)=ok;
- clif_send(buf,packet_len(0x1c8),&sd->bl,AREA);
+ clif->send(buf,packet_len(0x1c8),&sd->bl,AREA);
#endif
}
}
+void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data *sd, char *msg) {
+ if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), gettick()) > 0 && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ clif->colormes(sd->fd,COLOR_RED,msg_txt(1455));
+ return;
+ } else {
+ char message[150];
+ snprintf(message, 150, "[ #%s ] %s : %s",channel->name,sd->status.name, msg);
+ clif->chsys_msg(channel,sd,message);
+ if( channel->type == hChSys_IRC )
+ ircbot->relay(sd->status.name,msg);
+ if( channel->msg_delay != 0 )
+ sd->hchsysch_tick = gettick();
+ }
+}
/// Inform client whether chatroom creation was successful or not (ZC_ACK_CREATE_CHATROOM).
/// 00d6 <flag>.B
@@ -3550,7 +3815,7 @@ void clif_dispchat(struct chat_data* cd, int fd)
memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2));
WFIFOSET(fd,WBUFW(buf,2));
} else {
- clif_send(buf,WBUFW(buf,2),cd->owner,AREA_WOSC);
+ clif->send(buf,WBUFW(buf,2),cd->owner,AREA_WOSC);
}
}
@@ -3583,7 +3848,7 @@ void clif_changechatstatus(struct chat_data* cd)
WBUFB(buf,16) = type;
memcpy((char*)WBUFP(buf,17), cd->title, strlen(cd->title)); // not zero-terminated
- clif_send(buf,WBUFW(buf,2),cd->owner,CHAT);
+ clif->send(buf,WBUFW(buf,2),cd->owner,CHAT);
}
@@ -3602,7 +3867,7 @@ void clif_clearchat(struct chat_data *cd,int fd)
memcpy(WFIFOP(fd,0),buf,packet_len(0xd8));
WFIFOSET(fd,packet_len(0xd8));
} else {
- clif_send(buf,packet_len(0xd8),cd->owner,AREA_WOSC);
+ clif->send(buf,packet_len(0xd8),cd->owner,AREA_WOSC);
}
}
@@ -3684,7 +3949,7 @@ void clif_addchat(struct chat_data* cd,struct map_session_data *sd)
WBUFW(buf, 0) = 0xdc;
WBUFW(buf, 2) = cd->users;
memcpy(WBUFP(buf, 4),sd->status.name,NAME_LENGTH);
- clif_send(buf,packet_len(0xdc),&sd->bl,CHAT_WOS);
+ clif->send(buf,packet_len(0xdc),&sd->bl,CHAT_WOS);
}
@@ -3708,7 +3973,7 @@ void clif_changechatowner(struct chat_data* cd, struct map_session_data* sd)
WBUFL(buf,32) = 0;
memcpy(WBUFP(buf,36),sd->status.name,NAME_LENGTH);
- clif_send(buf,packet_len(0xe1)*2,&sd->bl,CHAT);
+ clif->send(buf,packet_len(0xe1)*2,&sd->bl,CHAT);
}
@@ -3729,7 +3994,7 @@ void clif_leavechat(struct chat_data* cd, struct map_session_data* sd, bool flag
memcpy(WBUFP(buf,4),sd->status.name,NAME_LENGTH);
WBUFB(buf,28) = flag;
- clif_send(buf,packet_len(0xdd),&sd->bl,CHAT);
+ clif->send(buf,packet_len(0xdd),&sd->bl,CHAT);
}
@@ -3848,7 +4113,7 @@ void clif_tradeadditem(struct map_session_data* sd, struct map_session_data* tsd
WBUFB(buf,8) = sd->status.inventory[index].identify; //identify flag
WBUFB(buf,9) = sd->status.inventory[index].attribute; // attribute
WBUFB(buf,10)= sd->status.inventory[index].refine; //refine
- clif_addcards(WBUFP(buf, 11), &sd->status.inventory[index]);
+ clif->addcards(WBUFP(buf, 11), &sd->status.inventory[index]);
}
WFIFOSET(fd,packet_len(cmd));
}
@@ -3976,7 +4241,7 @@ void clif_storageitemadded(struct map_session_data* sd, struct item* i, int inde
WFIFOB(fd,10) = i->identify; //identify flag
WFIFOB(fd,11) = i->attribute; // attribute
WFIFOB(fd,12) = i->refine; //refine
- clif_addcards(WFIFOP(fd,13), i);
+ clif->addcards(WFIFOP(fd,13), i);
WFIFOSET(fd,packet_len(0xf4));
#else
WFIFOHEAD(fd,packet_len(0x1c4));
@@ -3988,7 +4253,7 @@ void clif_storageitemadded(struct map_session_data* sd, struct item* i, int inde
WFIFOB(fd,11) = i->identify; //identify flag
WFIFOB(fd,12) = i->attribute; // attribute
WFIFOB(fd,13) = i->refine; //refine
- clif_addcards(WFIFOP(fd,14), i);
+ clif->addcards(WFIFOP(fd,14), i);
WFIFOSET(fd,packet_len(0x1c4));
#endif
}
@@ -4028,57 +4293,48 @@ void clif_storageclose(struct map_session_data* sd)
/*==========================================
* Server tells 'sd' player client the abouts of 'dstsd' player
*------------------------------------------*/
-static void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* dstsd)
-{
+void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* dstsd) {
struct block_list *d_bl;
int i;
if( dstsd->chatID ) {
struct chat_data *cd = NULL;
if( (cd = (struct chat_data*)map_id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd)
- clif_dispchat(cd,sd->fd);
+ clif->dispchat(cd,sd->fd);
} else if( dstsd->state.vending )
- clif_showvendingboard(&dstsd->bl,dstsd->message,sd->fd);
+ clif->showvendingboard(&dstsd->bl,dstsd->message,sd->fd);
else if( dstsd->state.buyingstore )
- clif_buyingstore_entry_single(sd, dstsd);
+ clif->buyingstore_entry_single(sd, dstsd);
if(dstsd->spiritball > 0)
- clif_spiritball_single(sd->fd, dstsd);
+ clif->spiritball_single(sd->fd, dstsd);
for(i = 1; i < 5; i++){
if( dstsd->talisman[i] > 0 )
- clif_talisman_single(sd->fd, dstsd, i);
+ clif->talisman_single(sd->fd, dstsd, i);
}
- if( dstsd->sc.option&OPTION_MOUNTING ) {
- //New Mounts are not complaint to the original method, so we gotta tell this guy that I'm mounting.
- clif_status_load_single(sd->fd,dstsd->bl.id,SI_ALL_RIDING,2,1,0,0);
+ for( i = 0; i < dstsd->sc_display_count; i++ ) {
+ clif->sc_load(&sd->bl,dstsd->bl.id,SELF,StatusIconChangeTable[dstsd->sc_display[i]->type],dstsd->sc_display[i]->val1,dstsd->sc_display[i]->val2,dstsd->sc_display[i]->val3);
}
-#ifdef NEW_CARTS
- if( dstsd->sc.data[SC_PUSH_CART] )
- clif_status_load_single(sd->fd, dstsd->bl.id, SI_ON_PUSH_CART, 2, dstsd->sc.data[SC_PUSH_CART]->val1, 0, 0);
-#endif
if( (sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting.
(sd->bg_id && sd->bg_id == dstsd->bg_id) || //BattleGround
pc_has_permission(sd, PC_PERM_VIEW_HPMETER)
)
- clif_hpmeter_single(sd->fd, dstsd->bl.id, dstsd->battle_status.hp, dstsd->battle_status.max_hp);
+ clif->hpmeter_single(sd->fd, dstsd->bl.id, dstsd->battle_status.hp, dstsd->battle_status.max_hp);
// display link (sd - dstsd) to sd
ARR_FIND( 0, 5, i, sd->devotion[i] == dstsd->bl.id );
- if( i < 5 ) clif_devotion(&sd->bl, sd);
+ if( i < 5 ) clif->devotion(&sd->bl, sd);
// display links (dstsd - devotees) to sd
ARR_FIND( 0, 5, i, dstsd->devotion[i] > 0 );
- if( i < 5 ) clif_devotion(&dstsd->bl, sd);
+ if( i < 5 ) clif->devotion(&dstsd->bl, sd);
// display link (dstsd - crusader) to sd
if( dstsd->sc.data[SC_DEVOTION] && (d_bl = map_id2bl(dstsd->sc.data[SC_DEVOTION]->val1)) != NULL )
- clif_devotion(d_bl, sd);
+ clif->devotion(d_bl, sd);
}
-void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl)
-{
- uint8 buf[128];
+void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
struct unit_data *ud;
struct view_data *vd;
- int len;
vd = status_get_viewdata(bl);
if (!vd || vd->class_ == INVISIBLE_CLASS)
@@ -4090,65 +4346,67 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl)
if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
return;
- ud = unit_bl2ud(bl);
- len = ( ud && ud->walktimer != INVALID_TIMER ) ? clif_set_unit_walking(bl,ud,buf) : clif_set_unit_idle(bl,buf,false);
- clif_send(buf,len,&sd->bl,SELF);
+ if ( ( ud = unit_bl2ud(bl) ) && ud->walktimer != INVALID_TIMER )
+ clif->set_unit_walking(bl,sd,ud,SELF);
+ else
+ clif->set_unit_idle(bl,sd,SELF);
if (vd->cloth_color)
- clif_refreshlook(&sd->bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,SELF);
-
- switch (bl->type)
- {
- case BL_PC:
- {
- TBL_PC* tsd = (TBL_PC*)bl;
- clif_getareachar_pc(sd, tsd);
- if(tsd->state.size==SZ_BIG) // tiny/big players [Valaris]
- clif_specialeffect_single(bl,423,sd->fd);
- else if(tsd->state.size==SZ_MEDIUM)
- clif_specialeffect_single(bl,421,sd->fd);
- if( tsd->bg_id && map[tsd->bl.m].flag.battleground )
- clif_sendbgemblem_single(sd->fd,tsd);
- if( tsd->sc.data[SC_CAMOUFLAGE] )
- clif_status_load(bl,SI_CAMOUFLAGE,1);
- }
- break;
- case BL_MER: // Devotion Effects
- if( ((TBL_MER*)bl)->devotion_flag )
- clif_devotion(bl, sd);
- break;
- case BL_NPC:
- {
- TBL_NPC* nd = (TBL_NPC*)bl;
- if( nd->chat_id )
- clif_dispchat((struct chat_data*)map_id2bl(nd->chat_id),sd->fd);
- if( nd->size == SZ_BIG )
- clif_specialeffect_single(bl,423,sd->fd);
- else if( nd->size == SZ_MEDIUM )
- clif_specialeffect_single(bl,421,sd->fd);
- }
- break;
- case BL_MOB:
- {
- TBL_MOB* md = (TBL_MOB*)bl;
- if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
- clif_specialeffect_single(bl,423,sd->fd);
- else if(md->special_state.size==SZ_MEDIUM)
- clif_specialeffect_single(bl,421,sd->fd);
-#if PACKETVER >= 20120404
- if( !(md->status.mode&MD_BOSS) ){
- int i;
- for(i = 0; i < DAMAGELOG_SIZE; i++)// must show hp bar to all char who already hit the mob.
- if( md->dmglog[i].id == sd->status.char_id )
- clif_monster_hp_bar(md, sd->fd);
+ clif->refreshlook(&sd->bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,SELF);
+ switch (bl->type) {
+ case BL_PC:
+ {
+ TBL_PC* tsd = (TBL_PC*)bl;
+ clif->getareachar_pc(sd, tsd);
+ if(tsd->state.size==SZ_BIG) // tiny/big players [Valaris]
+ clif->specialeffect_single(bl,423,sd->fd);
+ else if(tsd->state.size==SZ_MEDIUM)
+ clif->specialeffect_single(bl,421,sd->fd);
+ if( tsd->bg_id && map[tsd->bl.m].flag.battleground )
+ clif->sendbgemblem_single(sd->fd,tsd);
+ if ( tsd->status.robe )
+ clif->refreshlook(&sd->bl,bl->id,LOOK_ROBE,tsd->status.robe,SELF);
}
+ break;
+ case BL_MER: // Devotion Effects
+ if( ((TBL_MER*)bl)->devotion_flag )
+ clif->devotion(bl, sd);
+ break;
+ case BL_NPC:
+ {
+ TBL_NPC* nd = (TBL_NPC*)bl;
+ if( nd->chat_id )
+ clif->dispchat((struct chat_data*)map_id2bl(nd->chat_id),sd->fd);
+ if( nd->size == SZ_BIG )
+ clif->specialeffect_single(bl,423,sd->fd);
+ else if( nd->size == SZ_MEDIUM )
+ clif->specialeffect_single(bl,421,sd->fd);
+ }
+ break;
+ case BL_MOB:
+ {
+ TBL_MOB* md = (TBL_MOB*)bl;
+ if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
+ clif->specialeffect_single(bl,423,sd->fd);
+ else if(md->special_state.size==SZ_MEDIUM)
+ clif->specialeffect_single(bl,421,sd->fd);
+#if PACKETVER >= 20120404
+ if( !(md->status.mode&MD_BOSS) ){
+ int i;
+ for(i = 0; i < DAMAGELOG_SIZE; i++) {// must show hp bar to all char who already hit the mob.
+ if( md->dmglog[i].id == sd->status.char_id ) {
+ clif->monster_hp_bar(md, sd);
+ break;
+ }
+ }
+ }
#endif
- }
- break;
- case BL_PET:
- if (vd->head_bottom)
- clif_pet_equip(sd, (TBL_PET*)bl); // needed to display pet equip properly
- break;
+ }
+ break;
+ case BL_PET:
+ if (vd->head_bottom)
+ clif->send_petdata(NULL, (TBL_PET*)bl, 3, vd->head_bottom); // needed to display pet equip properly
+ break;
}
}
@@ -4162,8 +4420,7 @@ static inline int clif_calc_delay(int type, int div, int damage, int delay)
/*==========================================
* Estimates walk delay based on the damage criteria. [Skotlex]
*------------------------------------------*/
-static int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int damage, int div_)
-{
+int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int damage, int div_) {
if (type == 4 || type == 9 || damage <=0)
return 0;
@@ -4248,11 +4505,11 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic
WBUFB(buf,28)=type;
#endif
if(disguised(dst)) {
- clif_send(buf,packet_len(cmd),dst,AREA_WOS);
+ clif->send(buf,packet_len(cmd),dst,AREA_WOS);
WBUFL(buf,6) = -dst->id;
- clif_send(buf,packet_len(cmd),dst,SELF);
+ clif->send(buf,packet_len(cmd),dst,SELF);
} else
- clif_send(buf,packet_len(cmd),dst,AREA);
+ clif->send(buf,packet_len(cmd),dst,AREA);
if(disguised(src)) {
WBUFL(buf,2) = -src->id;
@@ -4265,14 +4522,14 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic
if(damage > 0) WBUFL(buf,22) = -1;
if(damage2 > 0) WBUFL(buf,29) = -1;
#endif
- clif_send(buf,packet_len(cmd),src,SELF);
+ clif->send(buf,packet_len(cmd),src,SELF);
}
if(src == dst) {
unit_setdir(src,unit_getdir(src));
}
//Return adjusted can't walk delay for further processing.
- return clif_calc_walkdelay(dst,ddelay,type,damage+damage2,div);
+ return clif->calc_walkdelay(dst,ddelay,type,damage+damage2,div);
}
/*==========================================
@@ -4290,7 +4547,7 @@ void clif_takeitem(struct block_list* src, struct block_list* dst)
WBUFL(buf, 2) = src->id;
WBUFL(buf, 6) = dst->id;
WBUFB(buf,26) = 1;
- clif_send(buf, packet_len(0x8a), src, AREA);
+ clif->send(buf, packet_len(0x8a), src, AREA);
}
@@ -4305,11 +4562,11 @@ void clif_sitting(struct block_list* bl)
WBUFW(buf, 0) = 0x8a;
WBUFL(buf, 2) = bl->id;
WBUFB(buf,26) = 2;
- clif_send(buf, packet_len(0x8a), bl, AREA);
+ clif->send(buf, packet_len(0x8a), bl, AREA);
if(disguised(bl)) {
WBUFL(buf, 2) = - bl->id;
- clif_send(buf, packet_len(0x8a), bl, SELF);
+ clif->send(buf, packet_len(0x8a), bl, SELF);
}
}
@@ -4324,11 +4581,11 @@ void clif_standing(struct block_list* bl)
WBUFW(buf, 0) = 0x8a;
WBUFL(buf, 2) = bl->id;
WBUFB(buf,26) = 3;
- clif_send(buf, packet_len(0x8a), bl, AREA);
+ clif->send(buf, packet_len(0x8a), bl, AREA);
if(disguised(bl)) {
WBUFL(buf, 2) = - bl->id;
- clif_send(buf, packet_len(0x8a), bl, SELF);
+ clif->send(buf, packet_len(0x8a), bl, SELF);
}
}
@@ -4358,15 +4615,14 @@ void clif_changemapcell(int fd, int16 m, int x, int y, int type, enum send_targe
dummy_bl.x = x;
dummy_bl.y = y;
dummy_bl.m = m;
- clif_send(buf,packet_len(0x192),&dummy_bl,target);
+ clif->send(buf,packet_len(0x192),&dummy_bl,target);
}
}
/// Notifies the client about an item on floor (ZC_ITEM_ENTRY).
/// 009d <id>.L <name id>.W <identified>.B <x>.W <y>.W <amount>.W <subX>.B <subY>.B
-void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fitem)
-{
+void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fitem) {
int view,fd;
fd=sd->fd;
@@ -4390,8 +4646,7 @@ void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fi
/// Notifies the client of a skill unit.
/// 011f <id>.L <creator id>.L <x>.W <y>.W <unit id>.B <visible>.B (ZC_SKILL_ENTRY)
/// 01c9 <id>.L <creator id>.L <x>.W <y>.W <unit id>.B <visible>.B <has msg>.B <msg>.80B (ZC_SKILL_ENTRY2)
-static void clif_getareachar_skillunit(struct map_session_data *sd, struct skill_unit *unit)
-{
+void clif_getareachar_skillunit(struct map_session_data *sd, struct skill_unit *unit) {
int fd = sd->fd;
if( unit->group->state.guildaura )
@@ -4419,9 +4674,9 @@ static void clif_getareachar_skillunit(struct map_session_data *sd, struct skill
WFIFOL(fd, 6)=unit->group->src_id;
WFIFOW(fd,10)=unit->bl.x;
WFIFOW(fd,12)=unit->bl.y;
- if (battle_config.traps_setting&1 && skill_get_inf2(unit->group->skill_id)&INF2_TRAP)
+ if (battle_config.traps_setting&1 && skill->get_inf2(unit->group->skill_id)&INF2_TRAP)
WFIFOB(fd,14)=UNT_DUMMYSKILL; //Use invisible unit id for traps.
- else if (skill_get_unit_flag(unit->group->skill_id) & UF_RANGEDSINGLEUNIT && !(unit->val2 & UF_RANGEDSINGLEUNIT))
+ else if (skill->get_unit_flag(unit->group->skill_id) & UF_RANGEDSINGLEUNIT && !(unit->val2 & UF_RANGEDSINGLEUNIT))
WFIFOB(fd,14)=UNT_DUMMYSKILL; //Use invisible unit id for traps.
else
WFIFOB(fd,14)=unit->group->unit_id;
@@ -4429,15 +4684,14 @@ static void clif_getareachar_skillunit(struct map_session_data *sd, struct skill
WFIFOSET(fd,packet_len(0x11f));
if(unit->group->skill_id == WZ_ICEWALL)
- clif_changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,5,SELF);
+ clif->changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,5,SELF);
}
/*==========================================
* Server tells client to remove unit of id 'unit->bl.id'
*------------------------------------------*/
-static void clif_clearchar_skillunit(struct skill_unit *unit, int fd)
-{
+void clif_clearchar_skillunit(struct skill_unit *unit, int fd) {
nullpo_retv(unit);
WFIFOHEAD(fd,packet_len(0x120));
@@ -4446,7 +4700,7 @@ static void clif_clearchar_skillunit(struct skill_unit *unit, int fd)
WFIFOSET(fd,packet_len(0x120));
if(unit->group && unit->group->skill_id == WZ_ICEWALL)
- clif_changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2,SELF);
+ clif->changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2,SELF);
}
@@ -4460,7 +4714,7 @@ void clif_skill_delunit(struct skill_unit *unit)
WBUFW(buf, 0)=0x120;
WBUFL(buf, 2)=unit->bl.id;
- clif_send(buf,packet_len(0x120),&unit->bl,AREA);
+ clif->send(buf,packet_len(0x120),&unit->bl,AREA);
}
@@ -4475,15 +4729,14 @@ void clif_skillunit_update(struct block_list* bl)
WBUFW(buf,0) = 0x1ac;
WBUFL(buf,2) = bl->id;
- clif_send(buf,packet_len(0x1ac),bl,AREA);
+ clif->send(buf,packet_len(0x1ac),bl,AREA);
}
/*==========================================
*
*------------------------------------------*/
-static int clif_getareachar(struct block_list* bl,va_list ap)
-{
+int clif_getareachar(struct block_list* bl,va_list ap) {
struct map_session_data *sd;
nullpo_ret(bl);
@@ -4494,17 +4747,17 @@ static int clif_getareachar(struct block_list* bl,va_list ap)
return 0;
switch(bl->type){
- case BL_ITEM:
- clif_getareachar_item(sd,(struct flooritem_data*) bl);
- break;
- case BL_SKILL:
- clif_getareachar_skillunit(sd,(TBL_SKILL*)bl);
- break;
- default:
- if(&sd->bl == bl)
+ case BL_ITEM:
+ clif->getareachar_item(sd,(struct flooritem_data*) bl);
+ break;
+ case BL_SKILL:
+ clif->getareachar_skillunit(sd,(TBL_SKILL*)bl);
+ break;
+ default:
+ if(&sd->bl == bl)
+ break;
+ clif->getareachar_unit(sd,bl);
break;
- clif_getareachar_unit(sd,bl);
- break;
}
return 0;
}
@@ -4522,44 +4775,42 @@ int clif_outsight(struct block_list *bl,va_list ap)
sd = BL_CAST(BL_PC, bl);
tsd = BL_CAST(BL_PC, tbl);
- if (tsd && tsd->fd)
- { //tsd has lost sight of the bl object.
+ if (tsd && tsd->fd) { //tsd has lost sight of the bl object.
switch(bl->type){
- case BL_PC:
- if (sd->vd.class_ != INVISIBLE_CLASS)
- clif_clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd);
- if(sd->chatID){
- struct chat_data *cd;
- cd=(struct chat_data*)map_id2bl(sd->chatID);
- if(cd->usersd[0]==sd)
- clif_dispchat(cd,tsd->fd);
+ case BL_PC:
+ if (sd->vd.class_ != INVISIBLE_CLASS)
+ clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd);
+ if(sd->chatID){
+ struct chat_data *cd;
+ cd=(struct chat_data*)map_id2bl(sd->chatID);
+ if(cd->usersd[0]==sd)
+ clif->dispchat(cd,tsd->fd);
+ }
+ if( sd->state.vending )
+ clif->closevendingboard(bl,tsd->fd);
+ if( sd->state.buyingstore )
+ clif->buyingstore_disappear_entry_single(tsd, sd);
+ break;
+ case BL_ITEM:
+ clif->clearflooritem((struct flooritem_data*)bl,tsd->fd);
+ break;
+ case BL_SKILL:
+ clif->clearchar_skillunit((struct skill_unit *)bl,tsd->fd);
+ break;
+ case BL_NPC:
+ if( !(((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE) )
+ clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd);
+ break;
+ default:
+ if ((vd=status_get_viewdata(bl)) && vd->class_ != INVISIBLE_CLASS)
+ clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd);
+ break;
}
- if( sd->state.vending )
- clif_closevendingboard(bl,tsd->fd);
- if( sd->state.buyingstore )
- clif_buyingstore_disappear_entry_single(tsd, sd);
- break;
- case BL_ITEM:
- clif_clearflooritem((struct flooritem_data*)bl,tsd->fd);
- break;
- case BL_SKILL:
- clif_clearchar_skillunit((struct skill_unit *)bl,tsd->fd);
- break;
- case BL_NPC:
- if( !(((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE) )
- clif_clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd);
- break;
- default:
- if ((vd=status_get_viewdata(bl)) && vd->class_ != INVISIBLE_CLASS)
- clif_clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd);
- break;
- }
}
- if (sd && sd->fd)
- { //sd is watching tbl go out of view.
+ if (sd && sd->fd) { //sd is watching tbl go out of view.
if (((vd=status_get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS) &&
!(tbl->type == BL_NPC && (((TBL_NPC*)tbl)->sc.option&OPTION_INVISIBLE)))
- clif_clearunit_single(tbl->id,CLR_OUTSIGHT,sd->fd);
+ clif->clearunit_single(tbl->id,CLR_OUTSIGHT,sd->fd);
}
return 0;
}
@@ -4578,23 +4829,21 @@ int clif_insight(struct block_list *bl,va_list ap)
sd = BL_CAST(BL_PC, bl);
tsd = BL_CAST(BL_PC, tbl);
- if (tsd && tsd->fd)
- { //Tell tsd that bl entered into his view
+ if (tsd && tsd->fd) { //Tell tsd that bl entered into his view
switch(bl->type){
- case BL_ITEM:
- clif_getareachar_item(tsd,(struct flooritem_data*)bl);
- break;
- case BL_SKILL:
- clif_getareachar_skillunit(tsd,(TBL_SKILL*)bl);
- break;
- default:
- clif_getareachar_unit(tsd,bl);
- break;
+ case BL_ITEM:
+ clif->getareachar_item(tsd,(struct flooritem_data*)bl);
+ break;
+ case BL_SKILL:
+ clif->getareachar_skillunit(tsd,(TBL_SKILL*)bl);
+ break;
+ default:
+ clif->getareachar_unit(tsd,bl);
+ break;
}
}
- if (sd && sd->fd)
- { //Tell sd that tbl walked into his view
- clif_getareachar_unit(sd,tbl);
+ if (sd && sd->fd) { //Tell sd that tbl walked into his view
+ clif->getareachar_unit(sd,tbl);
}
return 0;
}
@@ -4614,22 +4863,20 @@ void clif_skillinfoblock(struct map_session_data *sd)
WFIFOHEAD(fd, MAX_SKILL * 37 + 4);
WFIFOW(fd,0) = 0x10f;
- for ( i = 0, len = 4; i < MAX_SKILL; i++)
- {
- if( (id = sd->status.skill[i].id) != 0 )
- {
+ for ( i = 0, len = 4; i < MAX_SKILL; i++) {
+ if( (id = sd->status.skill[i].id) != 0 ) {
// workaround for bugreport:5348
if (len + 37 > 8192)
break;
WFIFOW(fd,len) = id;
- WFIFOL(fd,len+2) = skill_get_inf(id);
+ WFIFOL(fd,len+2) = skill->get_inf(id);
WFIFOW(fd,len+6) = sd->status.skill[i].lv;
- WFIFOW(fd,len+8) = skill_get_sp(id,sd->status.skill[i].lv);
- WFIFOW(fd,len+10)= skill_get_range2(&sd->bl, id,sd->status.skill[i].lv);
- safestrncpy((char*)WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH);
+ WFIFOW(fd,len+8) = skill->get_sp(id,sd->status.skill[i].lv);
+ WFIFOW(fd,len+10)= skill->get_range2(&sd->bl, id,sd->status.skill[i].lv);
+ safestrncpy((char*)WFIFOP(fd,len+12), skill->get_name(id), NAME_LENGTH);
if(sd->status.skill[i].flag == SKILL_FLAG_PERMANENT)
- WFIFOB(fd,len+36) = (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class_))? 1:0;
+ WFIFOB(fd,len+36) = (sd->status.skill[i].lv < skill->tree_get_max(id, sd->status.class_))? 1:0;
else
WFIFOB(fd,len+36) = 0;
len += 37;
@@ -4639,12 +4886,10 @@ void clif_skillinfoblock(struct map_session_data *sd)
WFIFOSET(fd,len);
// workaround for bugreport:5348; send the remaining skills one by one to bypass packet size limit
- for ( ; i < MAX_SKILL; i++)
- {
- if( (id = sd->status.skill[i].id) != 0 )
- {
- clif_addskill(sd, id);
- clif_skillinfo(sd, id, 0);
+ for ( ; i < MAX_SKILL; i++) {
+ if( (id = sd->status.skill[i].id) != 0 ) {
+ clif->addskill(sd, id);
+ clif->skillinfo(sd, id, 0);
}
}
}
@@ -4656,26 +4901,26 @@ void clif_skillinfoblock(struct map_session_data *sd)
/// 0111 <skill id>.W <type>.L <level>.W <sp cost>.W <attack range>.W <skill name>.24B <upgradable>.B
void clif_addskill(struct map_session_data *sd, int id)
{
- int fd;
+ int fd, idx = skill->get_index(id);
nullpo_retv(sd);
fd = sd->fd;
if (!fd) return;
- if( sd->status.skill[id].id <= 0 )
+ if( sd->status.skill[idx].id <= 0 )
return;
WFIFOHEAD(fd, packet_len(0x111));
WFIFOW(fd,0) = 0x111;
WFIFOW(fd,2) = id;
- WFIFOL(fd,4) = skill_get_inf(id);
- WFIFOW(fd,8) = sd->status.skill[id].lv;
- WFIFOW(fd,10) = skill_get_sp(id,sd->status.skill[id].lv);
- WFIFOW(fd,12)= skill_get_range2(&sd->bl, id,sd->status.skill[id].lv);
- safestrncpy((char*)WFIFOP(fd,14), skill_get_name(id), NAME_LENGTH);
- if( sd->status.skill[id].flag == SKILL_FLAG_PERMANENT )
- WFIFOB(fd,38) = (sd->status.skill[id].lv < skill_tree_get_max(id, sd->status.class_))? 1:0;
+ WFIFOL(fd,4) = skill->get_inf(id);
+ WFIFOW(fd,8) = sd->status.skill[idx].lv;
+ WFIFOW(fd,10) = skill->get_sp(id,sd->status.skill[idx].lv);
+ WFIFOW(fd,12)= skill->get_range2(&sd->bl, id,sd->status.skill[idx].lv);
+ safestrncpy((char*)WFIFOP(fd,14), skill->get_name(id), NAME_LENGTH);
+ if( sd->status.skill[idx].flag == SKILL_FLAG_PERMANENT )
+ WFIFOB(fd,38) = (sd->status.skill[id].lv < skill->tree_get_max(id, sd->status.class_))? 1:0;
else
WFIFOB(fd,38) = 0;
WFIFOSET(fd,packet_len(0x111));
@@ -4698,15 +4943,14 @@ void clif_deleteskill(struct map_session_data *sd, int id)
WFIFOW(fd,2) = id;
WFIFOSET(fd,packet_len(0x441));
#endif
- clif_skillinfoblock(sd);
+ clif->skillinfoblock(sd);
}
/// Updates a skill in the skill tree (ZC_SKILLINFO_UPDATE).
/// 010e <skill id>.W <level>.W <sp cost>.W <attack range>.W <upgradable>.B
-void clif_skillup(struct map_session_data *sd,uint16 skill_id)
-{
- int fd;
+void clif_skillup(struct map_session_data *sd,uint16 skill_id) {
+ int fd, idx = skill->get_index(skill_id);
nullpo_retv(sd);
@@ -4714,29 +4958,30 @@ void clif_skillup(struct map_session_data *sd,uint16 skill_id)
WFIFOHEAD(fd,packet_len(0x10e));
WFIFOW(fd,0) = 0x10e;
WFIFOW(fd,2) = skill_id;
- WFIFOW(fd,4) = sd->status.skill[skill_id].lv;
- WFIFOW(fd,6) = skill_get_sp(skill_id,sd->status.skill[skill_id].lv);
- WFIFOW(fd,8) = skill_get_range2(&sd->bl,skill_id,sd->status.skill[skill_id].lv);
- WFIFOB(fd,10) = (sd->status.skill[skill_id].lv < skill_tree_get_max(sd->status.skill[skill_id].id, sd->status.class_)) ? 1 : 0;
+ WFIFOW(fd,4) = sd->status.skill[idx].lv;
+ WFIFOW(fd,6) = skill->get_sp(skill_id,sd->status.skill[idx].lv);
+ WFIFOW(fd,8) = skill->get_range2(&sd->bl,skill_id,sd->status.skill[idx].lv);
+ WFIFOB(fd,10) = (sd->status.skill[idx].lv < skill->tree_get_max(sd->status.skill[idx].id, sd->status.class_)) ? 1 : 0;
WFIFOSET(fd,packet_len(0x10e));
}
/// Updates a skill in the skill tree (ZC_SKILLINFO_UPDATE2).
/// 07e1 <skill id>.W <type>.L <level>.W <sp cost>.W <attack range>.W <upgradable>.B
-void clif_skillinfo(struct map_session_data *sd,int skill, int inf)
+void clif_skillinfo(struct map_session_data *sd,int skill_id, int inf)
{
const int fd = sd->fd;
+ int idx = skill->get_index(skill_id);
WFIFOHEAD(fd,packet_len(0x7e1));
WFIFOW(fd,0) = 0x7e1;
- WFIFOW(fd,2) = skill;
- WFIFOL(fd,4) = inf?inf:skill_get_inf(skill);
- WFIFOW(fd,8) = sd->status.skill[skill].lv;
- WFIFOW(fd,10) = skill_get_sp(skill,sd->status.skill[skill].lv);
- WFIFOW(fd,12) = skill_get_range2(&sd->bl,skill,sd->status.skill[skill].lv);
- if( sd->status.skill[skill].flag == SKILL_FLAG_PERMANENT )
- WFIFOB(fd,14) = (sd->status.skill[skill].lv < skill_tree_get_max(skill, sd->status.class_))? 1:0;
+ WFIFOW(fd,2) = skill_id;
+ WFIFOL(fd,4) = inf?inf:skill->get_inf(skill_id);
+ WFIFOW(fd,8) = sd->status.skill[idx].lv;
+ WFIFOW(fd,10) = skill->get_sp(skill_id,sd->status.skill[idx].lv);
+ WFIFOW(fd,12) = skill->get_range2(&sd->bl,skill_id,sd->status.skill[idx].lv);
+ if( sd->status.skill[idx].flag == SKILL_FLAG_PERMANENT )
+ WFIFOB(fd,14) = (sd->status.skill[idx].lv < skill->tree_get_max(skill_id, sd->status.class_))? 1:0;
else
WFIFOB(fd,14) = 0;
WFIFOSET(fd,packet_len(0x7e1));
@@ -4780,11 +5025,11 @@ void clif_skillcasting(struct block_list* bl, int src_id, int dst_id, int dst_x,
#endif
if (disguised(bl)) {
- clif_send(buf,packet_len(cmd), bl, AREA_WOS);
+ clif->send(buf,packet_len(cmd), bl, AREA_WOS);
WBUFL(buf,2) = -src_id;
- clif_send(buf,packet_len(cmd), bl, SELF);
+ clif->send(buf,packet_len(cmd), bl, SELF);
} else
- clif_send(buf,packet_len(cmd), bl, AREA);
+ clif->send(buf,packet_len(cmd), bl, AREA);
}
@@ -4798,7 +5043,7 @@ void clif_skillcastcancel(struct block_list* bl)
WBUFW(buf,0) = 0x1b9;
WBUFL(buf,2) = bl->id;
- clif_send(buf,packet_len(0x1b9), bl, AREA);
+ clif->send(buf,packet_len(0x1b9), bl, AREA);
}
@@ -4913,11 +5158,11 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int
WBUFW(buf,28)=div;
WBUFB(buf,30)=type;
if (disguised(dst)) {
- clif_send(buf,packet_len(0x114),dst,AREA_WOS);
+ clif->send(buf,packet_len(0x114),dst,AREA_WOS);
WBUFL(buf,8)=-dst->id;
- clif_send(buf,packet_len(0x114),dst,SELF);
+ clif->send(buf,packet_len(0x114),dst,SELF);
} else
- clif_send(buf,packet_len(0x114),dst,AREA);
+ clif->send(buf,packet_len(0x114),dst,AREA);
if(disguised(src)) {
WBUFL(buf,4)=-src->id;
@@ -4925,7 +5170,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int
WBUFL(buf,8)=dst->id;
if(damage > 0)
WBUFW(buf,24)=-1;
- clif_send(buf,packet_len(0x114),src,SELF);
+ clif->send(buf,packet_len(0x114),src,SELF);
}
#else
WBUFW(buf,0)=0x1de;
@@ -4944,11 +5189,11 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int
WBUFW(buf,30)=div;
WBUFB(buf,32)=type;
if (disguised(dst)) {
- clif_send(buf,packet_len(0x1de),dst,AREA_WOS);
+ clif->send(buf,packet_len(0x1de),dst,AREA_WOS);
WBUFL(buf,8)=-dst->id;
- clif_send(buf,packet_len(0x1de),dst,SELF);
+ clif->send(buf,packet_len(0x1de),dst,SELF);
} else
- clif_send(buf,packet_len(0x1de),dst,AREA);
+ clif->send(buf,packet_len(0x1de),dst,AREA);
if(disguised(src)) {
WBUFL(buf,4)=-src->id;
@@ -4956,12 +5201,12 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int
WBUFL(buf,8)=dst->id;
if(damage > 0)
WBUFL(buf,24)=-1;
- clif_send(buf,packet_len(0x1de),src,SELF);
+ clif->send(buf,packet_len(0x1de),src,SELF);
}
#endif
//Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex]
- return clif_calc_walkdelay(dst,ddelay,type,damage,div);
+ return clif->calc_walkdelay(dst,ddelay,type,damage,div);
}
@@ -5002,12 +5247,12 @@ int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned in
WBUFW(buf,30)=skill_lv;
WBUFW(buf,32)=div;
WBUFB(buf,34)=type;
- clif_send(buf,packet_len(0x115),src,AREA);
+ clif->send(buf,packet_len(0x115),src,AREA);
if(disguised(src)) {
WBUFL(buf,4)=-src->id;
if(damage > 0)
WBUFW(buf,28)=-1;
- clif_send(buf,packet_len(0x115),src,SELF);
+ clif->send(buf,packet_len(0x115),src,SELF);
}
if (disguised(dst)) {
WBUFL(buf,8)=-dst->id;
@@ -5015,7 +5260,7 @@ int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned in
WBUFL(buf,4)=src->id;
else if(damage > 0)
WBUFW(buf,28)=-1;
- clif_send(buf,packet_len(0x115),dst,SELF);
+ clif->send(buf,packet_len(0x115),dst,SELF);
}
//Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex]
@@ -5040,17 +5285,17 @@ int clif_skill_nodamage(struct block_list *src,struct block_list *dst,uint16 ski
WBUFB(buf,14)=fail;
if (disguised(dst)) {
- clif_send(buf,packet_len(0x11a),dst,AREA_WOS);
+ clif->send(buf,packet_len(0x11a),dst,AREA_WOS);
WBUFL(buf,6)=-dst->id;
- clif_send(buf,packet_len(0x11a),dst,SELF);
+ clif->send(buf,packet_len(0x11a),dst,SELF);
} else
- clif_send(buf,packet_len(0x11a),dst,AREA);
+ clif->send(buf,packet_len(0x11a),dst,AREA);
if(src && disguised(src)) {
WBUFL(buf,10)=-src->id;
if (disguised(dst))
WBUFL(buf,6)=dst->id;
- clif_send(buf,packet_len(0x11a),src,SELF);
+ clif->send(buf,packet_len(0x11a),src,SELF);
}
return fail;
@@ -5073,11 +5318,11 @@ void clif_skill_poseffect(struct block_list *src,uint16 skill_id,int val,int x,i
WBUFW(buf,12)=y;
WBUFL(buf,14)=tick;
if(disguised(src)) {
- clif_send(buf,packet_len(0x117),src,AREA_WOS);
+ clif->send(buf,packet_len(0x117),src,AREA_WOS);
WBUFL(buf,4)=-src->id;
- clif_send(buf,packet_len(0x117),src,SELF);
+ clif->send(buf,packet_len(0x117),src,SELF);
} else
- clif_send(buf,packet_len(0x117),src,AREA);
+ clif->send(buf,packet_len(0x117),src,AREA);
}
@@ -5105,7 +5350,7 @@ void clif_skill_setunit(struct skill_unit *unit)
WBUFB(buf,15)=1;
WBUFB(buf,16)=1;
safestrncpy((char*)WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE);
- clif_send(buf,packet_len(0x1c9),&unit->bl,AREA);
+ clif->send(buf,packet_len(0x1c9),&unit->bl,AREA);
return;
}
#endif
@@ -5116,12 +5361,12 @@ void clif_skill_setunit(struct skill_unit *unit)
WBUFW(buf,12)=unit->bl.y;
if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE)
WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE;
- else if (skill_get_unit_flag(unit->group->skill_id) & UF_RANGEDSINGLEUNIT && !(unit->val2 & UF_RANGEDSINGLEUNIT))
+ else if (skill->get_unit_flag(unit->group->skill_id) & UF_RANGEDSINGLEUNIT && !(unit->val2 & UF_RANGEDSINGLEUNIT))
WBUFB(buf, 14) = UNT_DUMMYSKILL; // Only display the unit at center.
else
WBUFB(buf,14)=unit->group->unit_id;
WBUFB(buf,15)=1; // ignored by client (always gets set to 1)
- clif_send(buf,packet_len(0x11f),&unit->bl,AREA);
+ clif->send(buf,packet_len(0x11f),&unit->bl,AREA);
}
@@ -5227,11 +5472,11 @@ void clif_skill_estimation(struct map_session_data *sd,struct block_list *dst)
+(battle_config.estimation_type&2?status->mdef2:0);
WBUFW(buf,18)= status->def_ele;
for(i=0;i<9;i++)
- WBUFB(buf,20+i)= (unsigned char)battle_attr_ratio(i+1,status->def_ele, status->ele_lv);
+ WBUFB(buf,20+i)= (unsigned char)battle->attr_ratio(i+1,status->def_ele, status->ele_lv);
// The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex]
// WBUFB(buf,20+i)= (unsigned char)((fix=battle_attr_ratio(i+1,status->def_ele, status->ele_lv))<0?0:fix);
- clif_send(buf,packet_len(0x18c),&sd->bl,sd->status.party_id>0?PARTY_SAMEMAP:SELF);
+ clif->send(buf,packet_len(0x18c),&sd->bl,sd->status.party_id>0?PARTY_SAMEMAP:SELF);
}
@@ -5254,7 +5499,7 @@ void clif_skill_produce_mix_list(struct map_session_data *sd, int skill_id , int
WFIFOW(fd, 0)=0x18d;
for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){
- if( skill_can_produce_mix(sd,skill_produce_db[i].nameid, trigger, 1) &&
+ if( skill->can_produce_mix(sd,skill_produce_db[i].nameid, trigger, 1) &&
( ( skill_id > 0 && skill_produce_db[i].req_skill == skill_id ) || skill_id < 0 )
){
if((view = itemdb_viewid(skill_produce_db[i].nameid)) > 0)
@@ -5301,7 +5546,7 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id
c = 0;
for( i = 0; i < MAX_SKILL_PRODUCE_DB; i++ ) {
- if( !skill_can_produce_mix(sd,skill_produce_db[i].nameid,trigger, qty) )
+ if( !skill->can_produce_mix(sd,skill_produce_db[i].nameid,trigger, qty) )
continue;
if( (view = itemdb_viewid(skill_produce_db[i].nameid)) > 0 )
@@ -5330,7 +5575,7 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id
if( skill_id != AM_PHARMACY ) { // AM_PHARMACY is used to Cooking.
// It fails.
#if PACKETVER >= 20090922
- clif_msg_skill(sd,skill_id,0x625);
+ clif->msg_skill(sd,skill_id,0x625);
#else
WFIFOW(fd,2) = 6 + 2 * c;
WFIFOSET(fd,WFIFOW(fd,2));
@@ -5339,13 +5584,36 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id
}
}
+void clif_status_change_notick(struct block_list *bl,int type,int flag,int tick,int val1, int val2, int val3) {
+ struct packet_sc_notick p;
+ struct map_session_data *sd;
+
+ nullpo_retv(bl);
+
+ if (!(status_type2relevant_bl_types(type)&bl->type)) // only send status changes that actually matter to the client
+ return;
+
+ if (type == SI_BLANK) //It shows nothing on the client...
+ return;
+
+ sd = BL_CAST(BL_PC, bl);
+
+ p.PacketType = sc_notickType;
+ p.index = type;
+ p.AID = bl->id;
+ p.state = (unsigned char)flag;
+
+ clif->send(&p,packet_len(p.PacketType), bl, (sd && sd->status.option&OPTION_INVISIBLE) ? SELF : AREA);
+}
/// Notifies clients of a status change.
/// 0196 <index>.W <id>.L <state>.B (ZC_MSG_STATE_CHANGE) [used for ending status changes and starting them on non-pc units (when needed)]
/// 043f <index>.W <id>.L <state>.B <remain msec>.L { <val>.L }*3 (ZC_MSG_STATE_CHANGE2) [used exclusively for starting statuses on pcs]
-void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val1, int val2, int val3)
-{
- unsigned char buf[32];
+/// 08ff <id>.L <index>.W <remain msec>.L { <val>.L }*3 (PACKETVER >= 20111108)
+/// 0983 <index>.W <id>.L <state>.B <total msec>.L <remain msec>.L { <val>.L }*3 (PACKETVER >= 20120618)
+/// 0984 <id>.L <index>.W <total msec>.L <remain msec>.L { <val>.L }*3 (PACKETVER >= 20120618)
+void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val1, int val2, int val3) {
+ struct packet_status_change p;
struct map_session_data *sd;
if (type == SI_BLANK) //It shows nothing on the client...
@@ -5353,63 +5621,77 @@ void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val
nullpo_retv(bl);
- sd = BL_CAST(BL_PC, bl);
-
if (!(status_type2relevant_bl_types(type)&bl->type)) // only send status changes that actually matter to the client
return;
-#if PACKETVER >= 20090121
- if(flag && battle_config.display_status_timers && sd)
- WBUFW(buf,0)=0x43f;
- else
+ sd = BL_CAST(BL_PC, bl);
+
+ p.PacketType = status_changeType;
+ p.index = type;
+ p.AID = bl->id;
+ p.state = (unsigned char)flag;
+#if PACKETVER >= 20120618
+ p.Total = tick; /* at this stage remain and total are the same value I believe */
#endif
- WBUFW(buf,0)=0x196;
- WBUFW(buf,2)=type;
- WBUFL(buf,4)=bl->id;
- WBUFB(buf,8)=flag;
#if PACKETVER >= 20090121
- if(flag && battle_config.display_status_timers && sd)
- {
- if (tick <= 0)
- tick = 9999; // this is indeed what official servers do
-
- WBUFL(buf,9) = tick;
- WBUFL(buf,13) = val1;
- WBUFL(buf,17) = val2;
- WBUFL(buf,21) = val3;
- }
+ p.Left = tick;
+ p.val1 = val1;
+ p.val2 = val2;
+ p.val3 = val3;
#endif
- clif_send(buf,packet_len(WBUFW(buf,0)),bl, (sd && sd->status.option&OPTION_INVISIBLE) ? SELF : AREA);
+ clif->send(&p,sizeof(p), bl, (sd && sd->status.option&OPTION_INVISIBLE) ? SELF : AREA);
}
/// Send message (modified by [Yor]) (ZC_NOTIFY_PLAYERCHAT).
/// 008e <packet len>.W <message>.?B
-void clif_displaymessage(const int fd, const char* mes)
-{
+void clif_displaymessage(const int fd, const char* mes) {
nullpo_retv(mes);
+ if( fd == -2 ) {
+ ShowInfo("HCP: %s\n",mes);
+ } else if ( fd > 0 ) {
+ int len;
+
+ if ( ( len = strnlen(mes, 255) ) > 0 ) { // don't send a void message (it's not displaying on the client chat). @help can send void line.
+ WFIFOHEAD(fd, 5 + len);
+ WFIFOW(fd,0) = 0x8e;
+ WFIFOW(fd,2) = 5 + len; // 4 + len + NULL teminate
+ safestrncpy((char *)WFIFOP(fd,4), mes, len + 1);
+ WFIFOSET(fd, 5 + len);
+ }
+ }
+}
+void clif_displaymessage2(const int fd, const char* mes) {
+ // invalid pointer?
+ nullpo_retv(mes);
+
//Scrapped, as these are shared by disconnected players =X [Skotlex]
if (fd == 0)
;
else {
+ // Limit message to 255+1 characters (otherwise it causes a buffer overflow in the client)
char *message, *line;
-
+
message = aStrdup(mes);
line = strtok(message, "\n");
while(line != NULL) {
// Limit message to 255+1 characters (otherwise it causes a buffer overflow in the client)
int len = strnlen(line, 255);
-
+
if (len > 0) { // don't send a void message (it's not displaying on the client chat). @help can send void line.
- WFIFOHEAD(fd, 5 + len);
- WFIFOW(fd,0) = 0x8e;
- WFIFOW(fd,2) = 5 + len; // 4 + len + NULL teminate
- safestrncpy((char *)WFIFOP(fd,4), line, len + 1);
- WFIFOSET(fd, 5 + len);
+ if( fd == -2 ) {
+ ShowInfo("HCP: %s\n",line);
+ } else {
+ WFIFOHEAD(fd, 5 + len);
+ WFIFOW(fd,0) = 0x8e;
+ WFIFOW(fd,2) = 5 + len; // 4 + len + NULL teminate
+ safestrncpy((char *)WFIFOP(fd,4), line, len + 1);
+ WFIFOSET(fd, 5 + len);
+ }
}
line = strtok(NULL, "\n");
}
- aFree(message);
+ aFree(message);
}
}
@@ -5427,7 +5709,7 @@ void clif_broadcast(struct block_list* bl, const char* mes, int len, int type, e
else if (type == 0x20) // bc_woe
WBUFL(buf,4) = 0x73737373; //If there's "ssss", game client will recognize message as 'WoE broadcast'.
memcpy(WBUFP(buf, 4 + lp), mes, len);
- clif_send(buf, WBUFW(buf,2), bl, target);
+ clif->send(buf, WBUFW(buf,2), bl, target);
if (buf)
aFree(buf);
@@ -5456,30 +5738,8 @@ void clif_GlobalMessage(struct block_list* bl, const char* message) {
WBUFW(buf,2)=len+8;
WBUFL(buf,4)=bl->id;
safestrncpy((char *) WBUFP(buf,8),message,len);
- clif_send((unsigned char *) buf,WBUFW(buf,2),bl,ALL_CLIENT);
-
-}
-
-/*==========================================
- * Send main chat message [LuzZza]
- *------------------------------------------*/
-void clif_MainChatMessage(const char* message) {
- uint8 buf[200];
- int len;
+ clif->send((unsigned char *) buf,WBUFW(buf,2),bl,ALL_CLIENT);
- if(!message)
- return;
-
- len = strlen(message)+1;
- if (len+8 > sizeof(buf)) {
- ShowDebug("clif_MainChatMessage: Received message too long (len %d): %s\n", len, message);
- len = sizeof(buf)-8;
- }
- WBUFW(buf,0)=0x8d;
- WBUFW(buf,2)=len+8;
- WBUFL(buf,4)=0;
- safestrncpy((char *) WBUFP(buf,8),message,len);
- clif_send(buf,WBUFW(buf,2),NULL,CHAT_MAINCHAT);
}
/// Send broadcast message with font formatting (ZC_BROADCAST2).
@@ -5496,7 +5756,7 @@ void clif_broadcast2(struct block_list* bl, const char* mes, int len, unsigned l
WBUFW(buf,12) = fontAlign;
WBUFW(buf,14) = fontY;
memcpy(WBUFP(buf,16), mes, len);
- clif_send(buf, WBUFW(buf,2), bl, target);
+ clif->send(buf, WBUFW(buf,2), bl, target);
if (buf)
aFree(buf);
@@ -5528,14 +5788,19 @@ void clif_resurrection(struct block_list *bl,int type)
unsigned char buf[16];
nullpo_retv(bl);
-
+
WBUFW(buf,0)=0x148;
WBUFL(buf,2)=bl->id;
WBUFW(buf,6)=0;
- clif_send(buf,packet_len(0x148),bl,type==1 ? AREA : AREA_WOS);
- if (disguised(bl))
- clif_spawn(bl);
+ clif->send(buf,packet_len(0x148),bl, type == 1 ? AREA : AREA_WOS);
+ if (disguised(bl)) {
+ if( ((TBL_PC*)bl)->fontcolor ) {
+ WBUFL(buf,2)=-bl->id;
+ clif->send(buf,packet_len(0x148),bl, SELF);
+ } else
+ clif->spawn(bl);
+ }
}
@@ -5546,7 +5811,7 @@ void clif_map_property(struct map_session_data* sd, enum map_property property)
int fd;
nullpo_retv(sd);
-
+
fd=sd->fd;
WFIFOHEAD(fd,packet_len(0x199));
WFIFOW(fd,0)=0x199;
@@ -5557,8 +5822,7 @@ void clif_map_property(struct map_session_data* sd, enum map_property property)
/// Set the map type (ZC_NOTIFY_MAPPROPERTY2).
/// 01d6 <type>.W
-void clif_map_type(struct map_session_data* sd, enum map_type type)
-{
+void clif_map_type(struct map_session_data* sd, enum map_type type) {
int fd;
nullpo_retv(sd);
@@ -5592,12 +5856,12 @@ void clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type)
else
WBUFL(buf,6) = pvprank;
WBUFL(buf,10) = pvpnum;
- if(sd->sc.option&OPTION_INVISIBLE || sd->disguise) //Causes crashes when a 'mob' with pvp info dies.
- clif_send(buf,packet_len(0x19a),&sd->bl,SELF);
+ if(sd->sc.option&OPTION_INVISIBLE || sd->disguise != -1) //Causes crashes when a 'mob' with pvp info dies.
+ clif->send(buf,packet_len(0x19a),&sd->bl,SELF);
else if(!type)
- clif_send(buf,packet_len(0x19a),&sd->bl,AREA);
+ clif->send(buf,packet_len(0x19a),&sd->bl,AREA);
else
- clif_send(buf,packet_len(0x19a),&sd->bl,ALL_SAMEMAP);
+ clif->send(buf,packet_len(0x19a),&sd->bl,ALL_SAMEMAP);
}
}
@@ -5609,13 +5873,13 @@ void clif_map_property_mapall(int map, enum map_property property)
{
struct block_list bl;
unsigned char buf[16];
-
+
bl.id = 0;
bl.type = BL_NUL;
bl.m = map;
WBUFW(buf,0)=0x199;
WBUFW(buf,2)=property;
- clif_send(buf,packet_len(0x199),&bl,ALL_SAMEMAP);
+ clif->send(buf,packet_len(0x199),&bl,ALL_SAMEMAP);
}
@@ -5841,7 +6105,7 @@ void clif_item_repair_list(struct map_session_data *sd,struct map_session_data *
WFIFOW(fd,c*13+4) = i;
WFIFOW(fd,c*13+6) = nameid;
WFIFOB(fd,c*13+8) = dstsd->status.inventory[i].refine;
- clif_addcards(WFIFOP(fd,c*13+9), &dstsd->status.inventory[i]);
+ clif->addcards(WFIFOP(fd,c*13+9), &dstsd->status.inventory[i]);
c++;
}
}
@@ -5852,7 +6116,7 @@ void clif_item_repair_list(struct map_session_data *sd,struct map_session_data *
sd->menuskill_val = dstsd->bl.id;
sd->menuskill_val2 = lv;
}else
- clif_skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
}
@@ -5924,7 +6188,7 @@ void clif_item_refine_list(struct map_session_data *sd)
WFIFOW(fd,c*13+ 4)=i+2;
WFIFOW(fd,c*13+ 6)=sd->status.inventory[i].nameid;
WFIFOB(fd,c*13+ 8)=sd->status.inventory[i].refine;
- clif_addcards(WFIFOP(fd,c*13+9), &sd->status.inventory[i]);
+ clif->addcards(WFIFOP(fd,c*13+9), &sd->status.inventory[i]);
c++;
}
}
@@ -5949,12 +6213,12 @@ void clif_item_skill(struct map_session_data *sd,uint16 skill_id,uint16 skill_lv
WFIFOHEAD(fd,packet_len(0x147));
WFIFOW(fd, 0)=0x147;
WFIFOW(fd, 2)=skill_id;
- WFIFOW(fd, 4)=skill_get_inf(skill_id);
+ WFIFOW(fd, 4)=skill->get_inf(skill_id);
WFIFOW(fd, 6)=0;
WFIFOW(fd, 8)=skill_lv;
- WFIFOW(fd,10)=skill_get_sp(skill_id,skill_lv);
- WFIFOW(fd,12)=skill_get_range2(&sd->bl, skill_id,skill_lv);
- safestrncpy((char*)WFIFOP(fd,14),skill_get_name(skill_id),NAME_LENGTH);
+ WFIFOW(fd,10)=skill->get_sp(skill_id,skill_lv);
+ WFIFOW(fd,12)=skill->get_range2(&sd->bl, skill_id,skill_lv);
+ safestrncpy((char*)WFIFOP(fd,14),skill->get_name(skill_id),NAME_LENGTH);
WFIFOB(fd,38)=0;
WFIFOSET(fd,packet_len(0x147));
}
@@ -5987,7 +6251,7 @@ void clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail)
WBUFB(buf,10)=sd->status.cart[n].identify;
WBUFB(buf,11)=sd->status.cart[n].attribute;
WBUFB(buf,12)=sd->status.cart[n].refine;
- clif_addcards(WBUFP(buf,13), &sd->status.cart[n]);
+ clif->addcards(WBUFP(buf,13), &sd->status.cart[n]);
WFIFOSET(fd,packet_len(0x124));
#else
WFIFOHEAD(fd,packet_len(0x1c5));
@@ -6003,7 +6267,7 @@ void clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail)
WBUFB(buf,11)=sd->status.cart[n].identify;
WBUFB(buf,12)=sd->status.cart[n].attribute;
WBUFB(buf,13)=sd->status.cart[n].refine;
- clif_addcards(WBUFP(buf,14), &sd->status.cart[n]);
+ clif->addcards(WBUFP(buf,14), &sd->status.cart[n]);
WFIFOSET(fd,packet_len(0x1c5));
#endif
}
@@ -6062,7 +6326,7 @@ void clif_showvendingboard(struct block_list* bl, const char* message, int fd)
memcpy(WFIFOP(fd,0),buf,packet_len(0x131));
WFIFOSET(fd,packet_len(0x131));
} else {
- clif_send(buf,packet_len(0x131),bl,AREA_WOS);
+ clif->send(buf,packet_len(0x131),bl,AREA_WOS);
}
}
@@ -6082,7 +6346,7 @@ void clif_closevendingboard(struct block_list* bl, int fd)
memcpy(WFIFOP(fd,0),buf,packet_len(0x132));
WFIFOSET(fd,packet_len(0x132));
} else {
- clif_send(buf,packet_len(0x132),bl,AREA_WOS);
+ clif->send(buf,packet_len(0x132),bl,AREA_WOS);
}
}
@@ -6090,7 +6354,7 @@ void clif_closevendingboard(struct block_list* bl, int fd)
/// Sends a list of items in a shop.
/// R 0133 <packet len>.W <owner id>.L { <price>.L <amount>.W <index>.W <type>.B <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W }* (ZC_PC_PURCHASE_ITEMLIST_FROMMC)
/// R 0800 <packet len>.W <owner id>.L <unique id>.L { <price>.L <amount>.W <index>.W <type>.B <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W }* (ZC_PC_PURCHASE_ITEMLIST_FROMMC2)
-void clif_vendinglist(struct map_session_data* sd, int id, struct s_vending* vending)
+void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_vending* vending)
{
int i,fd;
int count;
@@ -6130,7 +6394,7 @@ void clif_vendinglist(struct map_session_data* sd, int id, struct s_vending* ven
WFIFOB(fd,offset+11+i*22) = vsd->status.cart[index].identify;
WFIFOB(fd,offset+12+i*22) = vsd->status.cart[index].attribute;
WFIFOB(fd,offset+13+i*22) = vsd->status.cart[index].refine;
- clif_addcards(WFIFOP(fd,offset+14+i*22), &vsd->status.cart[index]);
+ clif->addcards(WFIFOP(fd,offset+14+i*22), &vsd->status.cart[index]);
}
WFIFOSET(fd,WFIFOW(fd,2));
}
@@ -6178,8 +6442,7 @@ void clif_openvending(struct map_session_data* sd, int id, struct s_vending* ven
WFIFOW(fd,0) = 0x136;
WFIFOW(fd,2) = 8+count*22;
WFIFOL(fd,4) = id;
- for( i = 0; i < count; i++ )
- {
+ for( i = 0; i < count; i++ ) {
int index = vending[i].index;
struct item_data* data = itemdb_search(sd->status.cart[index].nameid);
WFIFOL(fd, 8+i*22) = vending[i].value;
@@ -6190,7 +6453,7 @@ void clif_openvending(struct map_session_data* sd, int id, struct s_vending* ven
WFIFOB(fd,19+i*22) = sd->status.cart[index].identify;
WFIFOB(fd,20+i*22) = sd->status.cart[index].attribute;
WFIFOB(fd,21+i*22) = sd->status.cart[index].refine;
- clif_addcards(WFIFOP(fd,22+i*22), &sd->status.cart[index]);
+ clif->addcards(WFIFOP(fd,22+i*22), &sd->status.cart[index]);
}
WFIFOSET(fd,WFIFOW(fd,2));
}
@@ -6268,7 +6531,7 @@ void clif_party_member_info(struct party_data *p, struct map_session_data *sd)
mapindex_getmapname_ext(map[sd->bl.m].name, (char*)WBUFP(buf,63));
WBUFB(buf,79) = (p->party.item&1)?1:0;
WBUFB(buf,80) = (p->party.item&2)?1:0;
- clif_send(buf,packet_len(0x1e9),&sd->bl,PARTY);
+ clif->send(buf,packet_len(0x1e9),&sd->bl,PARTY);
}
@@ -6307,9 +6570,9 @@ void clif_party_info(struct party_data* p, struct map_session_data *sd)
WBUFW(buf,2) = 28+c*46;
if(sd) { // send only to self
- clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
+ clif->send(buf, WBUFW(buf,2), &sd->bl, SELF);
} else if (party_sd) { // send to whole party
- clif_send(buf, WBUFW(buf,2), &party_sd->bl, PARTY);
+ clif->send(buf, WBUFW(buf,2), &party_sd->bl, PARTY);
}
}
@@ -6327,7 +6590,7 @@ void clif_partyinvitationstate(struct map_session_data* sd)
WFIFOHEAD(fd, packet_len(0x2c9));
WFIFOW(fd, 0) = 0x2c9;
- WFIFOB(fd, 2) = 0; // not implemented
+ WFIFOB(fd, 2) = sd->status.allow_party ? 1 : 0;
WFIFOSET(fd, packet_len(0x2c9));
}
@@ -6381,7 +6644,7 @@ void clif_party_inviteack(struct map_session_data* sd, const char* nick, int res
#if PACKETVER < 20070904
if( result == 7 ) {
- clif_displaymessage(fd, msg_txt(3));
+ clif->message(fd, msg_txt(3));
return;
}
#endif
@@ -6426,7 +6689,8 @@ void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag
if(!sd && flag==0){
int i;
- for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
+ for(i=0;i<MAX_PARTY && !p->data[i].sd;i++)
+ ;
if (i < MAX_PARTY)
sd = p->data[i].sd;
}
@@ -6438,9 +6702,9 @@ void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag
WBUFB(buf,7)=(p->party.item&2)?1:0;
#endif
if(flag==0)
- clif_send(buf,packet_len(cmd),&sd->bl,PARTY);
+ clif->send(buf,packet_len(cmd),&sd->bl,PARTY);
else
- clif_send(buf,packet_len(cmd),&sd->bl,SELF);
+ clif->send(buf,packet_len(cmd),&sd->bl,SELF);
}
@@ -6453,13 +6717,14 @@ void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag
void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, int account_id, const char* name, int flag)
{
unsigned char buf[64];
- int i;
nullpo_retv(p);
if(!sd && (flag&0xf0)==0)
{
- for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
+ int i;
+ for(i=0;i<MAX_PARTY && !p->data[i].sd;i++)
+ ;
if (i < MAX_PARTY)
sd = p->data[i].sd;
}
@@ -6471,9 +6736,9 @@ void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, int
memcpy(WBUFP(buf,6),name,NAME_LENGTH);
WBUFB(buf,30)=flag&0x0f;
if((flag&0xf0)==0)
- clif_send(buf,packet_len(0x105),&sd->bl,PARTY);
+ clif->send(buf,packet_len(0x105),&sd->bl,PARTY);
else
- clif_send(buf,packet_len(0x105),&sd->bl,SELF);
+ clif->send(buf,packet_len(0x105),&sd->bl,SELF);
}
@@ -6501,7 +6766,7 @@ void clif_party_message(struct party_data* p, int account_id, const char* mes, i
WBUFW(buf,2)=len+8;
WBUFL(buf,4)=account_id;
safestrncpy((char *)WBUFP(buf,8), mes, len);
- clif_send(buf,len+8,&sd->bl,PARTY);
+ clif->send(buf,len+8,&sd->bl,PARTY);
}
}
@@ -6518,7 +6783,7 @@ void clif_party_xy(struct map_session_data *sd)
WBUFL(buf,2)=sd->status.account_id;
WBUFW(buf,6)=sd->bl.x;
WBUFW(buf,8)=sd->bl.y;
- clif_send(buf,packet_len(0x107),&sd->bl,PARTY_SAMEMAP_WOS);
+ clif->send(buf,packet_len(0x107),&sd->bl,PARTY_SAMEMAP_WOS);
}
@@ -6564,7 +6829,7 @@ void clif_party_hp(struct map_session_data *sd)
WBUFL(buf,6) = sd->battle_status.hp;
WBUFL(buf,10) = sd->battle_status.max_hp;
#endif
- clif_send(buf,packet_len(cmd),&sd->bl,PARTY_AREA_WOS);
+ clif->send(buf,packet_len(cmd),&sd->bl,PARTY_AREA_WOS);
}
@@ -6633,7 +6898,7 @@ void clif_produceeffect(struct map_session_data* sd,int flag,int nameid)
nullpo_retv(sd);
fd = sd->fd;
- clif_solved_charname(fd, sd->status.char_id, sd->status.name);
+ clif->solved_charname(fd, sd->status.char_id, sd->status.name);
WFIFOHEAD(fd,packet_len(0x18f));
WFIFOW(fd, 0)=0x18f;
WFIFOW(fd, 2)=flag;
@@ -6687,9 +6952,8 @@ void clif_sendegg(struct map_session_data *sd)
nullpo_retv(sd);
fd=sd->fd;
- if (battle_config.pet_no_gvg && map_flag_gvg(sd->bl.m))
- { //Disable pet hatching in GvG grounds during Guild Wars [Skotlex]
- clif_displaymessage(fd, msg_txt(666));
+ if (battle_config.pet_no_gvg && map_flag_gvg(sd->bl.m)) { //Disable pet hatching in GvG grounds during Guild Wars [Skotlex]
+ clif->message(fd, msg_txt(666));
return;
}
WFIFOHEAD(fd, MAX_INVENTORY * 2 + 4);
@@ -6731,9 +6995,9 @@ void clif_send_petdata(struct map_session_data* sd, struct pet_data* pd, int typ
WBUFL(buf,3) = pd->bl.id;
WBUFL(buf,7) = param;
if (sd)
- clif_send(buf, packet_len(0x1a4), &sd->bl, SELF);
+ clif->send(buf, packet_len(0x1a4), &sd->bl, SELF);
else
- clif_send(buf, packet_len(0x1a4), &pd->bl, AREA);
+ clif->send(buf, packet_len(0x1a4), &pd->bl, AREA);
}
@@ -6789,7 +7053,7 @@ void clif_pet_emotion(struct pet_data *pd,int param)
}
WBUFL(buf,6)=param;
- clif_send(buf,packet_len(0x1aa),&pd->bl,AREA);
+ clif->send(buf,packet_len(0x1aa),&pd->bl,AREA);
}
@@ -6865,7 +7129,6 @@ void clif_autospell(struct map_session_data *sd,uint16 skill_lv)
void clif_devotion(struct block_list *src, struct map_session_data *tsd)
{
unsigned char buf[56];
- int i;
nullpo_retv(src);
memset(buf,0,packet_len(0x1cf));
@@ -6878,23 +7141,24 @@ void clif_devotion(struct block_list *src, struct map_session_data *tsd)
if( md && md->master && md->devotion_flag )
WBUFL(buf,6) = md->master->bl.id;
- WBUFW(buf,26) = skill_get_range2(src, ML_DEVOTION, mercenary_checkskill(md, ML_DEVOTION));
+ WBUFW(buf,26) = skill->get_range2(src, ML_DEVOTION, mercenary_checkskill(md, ML_DEVOTION));
}
else
{
+ int i;
struct map_session_data *sd = BL_CAST(BL_PC,src);
if( sd == NULL )
return;
for( i = 0; i < 5; i++ )
WBUFL(buf,6+4*i) = sd->devotion[i];
- WBUFW(buf,26) = skill_get_range2(src, CR_DEVOTION, pc_checkskill(sd, CR_DEVOTION));
+ WBUFW(buf,26) = skill->get_range2(src, CR_DEVOTION, pc_checkskill(sd, CR_DEVOTION));
}
if( tsd )
- clif_send(buf, packet_len(0x1cf), &tsd->bl, SELF);
+ clif->send(buf, packet_len(0x1cf), &tsd->bl, SELF);
else
- clif_send(buf, packet_len(0x1cf), src, AREA);
+ clif->send(buf, packet_len(0x1cf), src, AREA);
}
/*==========================================
@@ -6917,7 +7181,7 @@ void clif_spiritball(struct block_list *bl) {
case BL_PC: WBUFW(buf, 6) = sd->spiritball; break;
case BL_HOM: WBUFW(buf, 6) = hd->homunculus.spiritball; break;
}
- clif_send(buf, packet_len(0x1d0), bl, AREA);
+ clif->send(buf, packet_len(0x1d0), bl, AREA);
}
@@ -6932,7 +7196,7 @@ void clif_combo_delay(struct block_list *bl,int wait)
WBUFW(buf,0)=0x1d2;
WBUFL(buf,2)=bl->id;
WBUFL(buf,6)=wait;
- clif_send(buf,packet_len(0x1d2),bl,AREA);
+ clif->send(buf,packet_len(0x1d2),bl,AREA);
}
@@ -6952,7 +7216,7 @@ void clif_bladestop(struct block_list *src, int dst_id, int active)
WBUFL(buf,6)=dst_id;
WBUFL(buf,10)=active;
- clif_send(buf,packet_len(0x1d1),src,AREA);
+ clif->send(buf,packet_len(0x1d1),src,AREA);
}
@@ -6966,7 +7230,7 @@ void clif_mvp_effect(struct map_session_data *sd)
WBUFW(buf,0)=0x10c;
WBUFL(buf,2)=sd->bl.id;
- clif_send(buf,packet_len(0x10c),&sd->bl,AREA);
+ clif->send(buf,packet_len(0x10c),&sd->bl,AREA);
}
@@ -7053,7 +7317,7 @@ void clif_guild_belonginfo(struct map_session_data *sd, struct guild *g)
nullpo_retv(g);
fd=sd->fd;
- ps=guild_getposition(g,sd);
+ ps=guild->getposition(g,sd);
WFIFOHEAD(fd,packet_len(0x16c));
WFIFOW(fd,0)=0x16c;
WFIFOL(fd,2)=g->guild_id;
@@ -7089,14 +7353,14 @@ void clif_guild_memberlogin_notice(struct guild *g,int idx,int flag)
WBUFW(buf,14) = sd->status.sex;
WBUFW(buf,16) = sd->status.hair;
WBUFW(buf,18) = sd->status.hair_color;
- clif_send(buf,packet_len(0x1f2),&sd->bl,GUILD_WOS);
+ clif->send(buf,packet_len(0x1f2),&sd->bl,GUILD_WOS);
}
- else if( ( sd = guild_getavailablesd(g) ) != NULL )
+ else if( ( sd = guild->getavailablesd(g) ) != NULL )
{
WBUFW(buf,14) = 0;
WBUFW(buf,16) = 0;
WBUFW(buf,18) = 0;
- clif_send(buf,packet_len(0x1f2),&sd->bl,GUILD);
+ clif->send(buf,packet_len(0x1f2),&sd->bl,GUILD);
}
}
@@ -7119,7 +7383,7 @@ void clif_guild_send_onlineinfo(struct map_session_data *sd)
p_len = packet_len(0x16d);
- if(!(g = guild_search(sd->status.guild_id)))
+ if(!(g = sd->guild))
return;
for(i=0; i<g->max_member; i++) {
@@ -7135,7 +7399,7 @@ void clif_guild_send_onlineinfo(struct map_session_data *sd)
}
}
- clif_send(buf, p_len*count, &sd->bl, SELF);
+ clif->send(buf, p_len*count, &sd->bl, SELF);
}
@@ -7173,7 +7437,7 @@ void clif_guild_basicinfo(struct map_session_data *sd) {
nullpo_retv(sd);
fd = sd->fd;
- if( (g = guild_search(sd->status.guild_id)) == NULL )
+ if( (g = sd->guild) == NULL )
return;
WFIFOHEAD(fd,packet_len(0x1b6));
@@ -7192,7 +7456,7 @@ void clif_guild_basicinfo(struct map_session_data *sd) {
memcpy(WFIFOP(fd,46),g->name, NAME_LENGTH);
memcpy(WFIFOP(fd,70),g->master, NAME_LENGTH);
- safestrncpy((char*)WFIFOP(fd,94),msg_txt(300+guild_checkcastles(g)),16); // "'N' castles"
+ safestrncpy((char*)WFIFOP(fd,94),msg_txt(300+guild->checkcastles(g)),16); // "'N' castles"
WFIFOL(fd,110) = 0; // zeny
WFIFOSET(fd,packet_len(0x1b6));
@@ -7207,7 +7471,7 @@ void clif_guild_allianceinfo(struct map_session_data *sd)
struct guild *g;
nullpo_retv(sd);
- if( (g = guild_search(sd->status.guild_id)) == NULL )
+ if( (g = sd->guild) == NULL )
return;
fd = sd->fd;
@@ -7243,7 +7507,7 @@ void clif_guild_memberlist(struct map_session_data *sd)
if( (fd = sd->fd) == 0 )
return;
- if( (g = guild_search(sd->status.guild_id)) == NULL )
+ if( (g = sd->guild) == NULL )
return;
WFIFOHEAD(fd, g->max_member * 104 + 4);
@@ -7273,13 +7537,12 @@ void clif_guild_memberlist(struct map_session_data *sd)
/// Guild position name information (ZC_POSITION_ID_NAME_INFO).
/// 0166 <packet len>.W { <position id>.L <position name>.24B }*
-void clif_guild_positionnamelist(struct map_session_data *sd)
-{
+void clif_guild_positionnamelist(struct map_session_data *sd) {
int i,fd;
struct guild *g;
nullpo_retv(sd);
- if( (g = guild_search(sd->status.guild_id)) == NULL )
+ if( (g = sd->guild) == NULL )
return;
fd = sd->fd;
@@ -7301,13 +7564,12 @@ void clif_guild_positionnamelist(struct map_session_data *sd)
/// &0x10 = allow expel
/// ranking:
/// TODO
-void clif_guild_positioninfolist(struct map_session_data *sd)
-{
+void clif_guild_positioninfolist(struct map_session_data *sd) {
int i,fd;
struct guild *g;
nullpo_retv(sd);
- if( (g = guild_search(sd->status.guild_id)) == NULL )
+ if( (g = sd->guild) == NULL )
return;
fd = sd->fd;
@@ -7351,8 +7613,8 @@ void clif_guild_positionchanged(struct guild *g,int idx)
WBUFL(buf,16)=g->position[idx].exp_mode;
memcpy(WBUFP(buf,20),g->position[idx].name,NAME_LENGTH);
// }*
- if( (sd=guild_getavailablesd(g))!=NULL )
- clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
+ if( (sd=guild->getavailablesd(g))!=NULL )
+ clif->send(buf,WBUFW(buf,2),&sd->bl,GUILD);
}
@@ -7375,8 +7637,8 @@ void clif_guild_memberpositionchanged(struct guild *g,int idx)
WBUFL(buf, 8)=g->member[idx].char_id;
WBUFL(buf,12)=g->member[idx].position;
// }*
- if( (sd=guild_getavailablesd(g))!=NULL )
- clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
+ if( (sd=guild->getavailablesd(g))!=NULL )
+ clif->send(buf,WBUFW(buf,2),&sd->bl,GUILD);
}
@@ -7416,7 +7678,7 @@ void clif_guild_emblem_area(struct block_list* bl)
WBUFL(buf,2) = bl->id;
WBUFL(buf,6) = status_get_guild_id(bl);
WBUFW(buf,10) = status_get_emblem_id(bl);
- clif_send(buf, 12, bl, AREA_WOS);
+ clif->send(buf, 12, bl, AREA_WOS);
}
@@ -7429,26 +7691,24 @@ void clif_guild_skillinfo(struct map_session_data* sd)
int i,c;
nullpo_retv(sd);
- if( (g = guild_search(sd->status.guild_id)) == NULL )
+ if( (g = sd->guild) == NULL )
return;
fd = sd->fd;
WFIFOHEAD(fd, 6 + MAX_GUILDSKILL*37);
WFIFOW(fd,0) = 0x0162;
WFIFOW(fd,4) = g->skill_point;
- for(i = 0, c = 0; i < MAX_GUILDSKILL; i++)
- {
- if(g->skill[i].id > 0 && guild_check_skill_require(g, g->skill[i].id))
- {
+ for(i = 0, c = 0; i < MAX_GUILDSKILL; i++) {
+ if(g->skill[i].id > 0 && guild->check_skill_require(g, g->skill[i].id)) {
int id = g->skill[i].id;
int p = 6 + c*37;
WFIFOW(fd,p+0) = id;
- WFIFOL(fd,p+2) = skill_get_inf(id);
+ WFIFOL(fd,p+2) = skill->get_inf(id);
WFIFOW(fd,p+6) = g->skill[i].lv;
- WFIFOW(fd,p+8) = skill_get_sp(id, g->skill[i].lv);
- WFIFOW(fd,p+10) = skill_get_range(id, g->skill[i].lv);
- safestrncpy((char*)WFIFOP(fd,p+12), skill_get_name(id), NAME_LENGTH);
- WFIFOB(fd,p+36)= (g->skill[i].lv < guild_skill_get_max(id) && sd == g->member[0].sd) ? 1 : 0;
+ WFIFOW(fd,p+8) = skill->get_sp(id, g->skill[i].lv);
+ WFIFOW(fd,p+10) = skill->get_range(id, g->skill[i].lv);
+ safestrncpy((char*)WFIFOP(fd,p+12), skill->get_name(id), NAME_LENGTH);
+ WFIFOB(fd,p+36)= (g->skill[i].lv < guild->skill_get_max(id) && sd == g->member[0].sd) ? 1 : 0;
c++;
}
}
@@ -7532,7 +7792,7 @@ void clif_guild_leave(struct map_session_data *sd,const char *name,const char *m
WBUFW(buf, 0)=0x15a;
memcpy(WBUFP(buf, 2),name,NAME_LENGTH);
memcpy(WBUFP(buf,26),mes,40);
- clif_send(buf,packet_len(0x15a),&sd->bl,GUILD_NOBG);
+ clif->send(buf,packet_len(0x15a),&sd->bl,GUILD_NOBG);
}
@@ -7556,15 +7816,14 @@ void clif_guild_expulsion(struct map_session_data* sd, const char* name, const c
#if PACKETVER < 20100803
memset(WBUFP(buf,66), 0, NAME_LENGTH); // account name (not used for security reasons)
#endif
- clif_send(buf, packet_len(cmd), &sd->bl, GUILD_NOBG);
+ clif->send(buf, packet_len(cmd), &sd->bl, GUILD_NOBG);
}
/// Guild expulsion list (ZC_BAN_LIST).
/// 0163 <packet len>.W { <char name>.24B <account name>.24B <reason>.40B }*
/// 0163 <packet len>.W { <char name>.24B <reason>.40B }* (PACKETVER >= 20100803)
-void clif_guild_expulsionlist(struct map_session_data* sd)
-{
+void clif_guild_expulsionlist(struct map_session_data* sd) {
#if PACKETVER < 20100803
const int offset = NAME_LENGTH*2+40;
#else
@@ -7575,7 +7834,7 @@ void clif_guild_expulsionlist(struct map_session_data* sd)
nullpo_retv(sd);
- if( (g = guild_search(sd->status.guild_id)) == NULL )
+ if( (g = sd->guild) == NULL )
return;
fd = sd->fd;
@@ -7625,8 +7884,8 @@ void clif_guild_message(struct guild *g,int account_id,const char *mes,int len)
WBUFW(buf, 2) = len + 5;
safestrncpy((char*)WBUFP(buf,4), mes, len+1);
- if ((sd = guild_getavailablesd(g)) != NULL)
- clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD_NOBG);
+ if ((sd = guild->getavailablesd(g)) != NULL)
+ clif->send(buf, WBUFW(buf,2), &sd->bl, GUILD_NOBG);
}
@@ -7644,8 +7903,8 @@ int clif_guild_skillup(struct map_session_data *sd,uint16 skill_id,int lv)
WFIFOW(fd,0) = 0x10e;
WFIFOW(fd,2) = skill_id;
WFIFOW(fd,4) = lv;
- WFIFOW(fd,6) = skill_get_sp(skill_id,lv);
- WFIFOW(fd,8) = skill_get_range(skill_id,lv);
+ WFIFOW(fd,6) = skill->get_sp(skill_id,lv);
+ WFIFOW(fd,8) = skill->get_range(skill_id,lv);
WFIFOB(fd,10) = 1;
WFIFOSET(fd,11);
return 0;
@@ -7745,7 +8004,7 @@ void clif_guild_allianceadded(struct guild *g,int idx)
WBUFL(buf,2)=g->alliance[idx].opposition;
WBUFL(buf,6)=g->alliance[idx].guild_id;
memcpy(WBUFP(buf,10),g->alliance[idx].name,NAME_LENGTH);
- clif_send(buf,packet_len(0x185),guild_getavailablesd(g),GUILD);
+ clif->send(buf,packet_len(0x185),guild->getavailablesd(g),GUILD);
}
*/
@@ -7782,7 +8041,7 @@ void clif_emotion(struct block_list *bl,int type)
WBUFW(buf,0)=0xc0;
WBUFL(buf,2)=bl->id;
WBUFB(buf,6)=type;
- clif_send(buf,packet_len(0xc0),bl,AREA);
+ clif->send(buf,packet_len(0xc0),bl,AREA);
}
@@ -7796,7 +8055,7 @@ void clif_talkiebox(struct block_list* bl, const char* talkie)
WBUFW(buf,0) = 0x191;
WBUFL(buf,2) = bl->id;
safestrncpy((char*)WBUFP(buf,6),talkie,MESSAGE_SIZE);
- clif_send(buf,packet_len(0x191),bl,AREA);
+ clif->send(buf,packet_len(0x191),bl,AREA);
}
@@ -7810,7 +8069,7 @@ void clif_wedding_effect(struct block_list *bl)
WBUFW(buf,0) = 0x1ea;
WBUFL(buf,2) = bl->id;
- clif_send(buf, packet_len(0x1ea), bl, AREA);
+ clif->send(buf, packet_len(0x1ea), bl, AREA);
}
@@ -7819,7 +8078,6 @@ void clif_wedding_effect(struct block_list *bl)
void clif_callpartner(struct map_session_data *sd)
{
unsigned char buf[26];
- const char *p;
nullpo_retv(sd);
@@ -7827,6 +8085,7 @@ void clif_callpartner(struct map_session_data *sd)
if( sd->status.partner_id )
{
+ const char *p;
if( ( p = map_charid2nick(sd->status.partner_id) ) != NULL )
{
memcpy(WBUFP(buf,2), p, NAME_LENGTH);
@@ -7841,7 +8100,7 @@ void clif_callpartner(struct map_session_data *sd)
WBUFB(buf,2) = 0;
}
- clif_send(buf, packet_len(0x1e6), &sd->bl, AREA);
+ clif->send(buf, packet_len(0x1e6), &sd->bl, AREA);
}
@@ -7898,9 +8157,8 @@ void clif_marriage_proposal(int fd, struct map_session_data *sd, struct map_sess
/*==========================================
*
*------------------------------------------*/
-void clif_disp_onlyself(struct map_session_data *sd, const char *mes, int len)
-{
- clif_disp_message(&sd->bl, mes, len, SELF);
+void clif_disp_onlyself(struct map_session_data *sd, const char *mes, int len) {
+ clif->disp_message(&sd->bl, mes, len, SELF);
}
/*==========================================
@@ -7910,12 +8168,9 @@ void clif_disp_message(struct block_list* src, const char* mes, int len, enum se
{
unsigned char buf[256];
- if( len == 0 )
- {
+ if( len == 0 ) {
return;
- }
- else if( len > sizeof(buf)-5 )
- {
+ } else if( len > sizeof(buf)-5 ) {
ShowWarning("clif_disp_message: Truncated message '%s' (len=%d, max=%d, aid=%d).\n", mes, len, sizeof(buf)-5, src->id);
len = sizeof(buf)-5;
}
@@ -7923,7 +8178,7 @@ void clif_disp_message(struct block_list* src, const char* mes, int len, enum se
WBUFW(buf, 0) = 0x17f;
WBUFW(buf, 2) = len + 5;
safestrncpy((char*)WBUFP(buf,4), mes, len+1);
- clif_send(buf, WBUFW(buf,2), src, target);
+ clif->send(buf, WBUFW(buf,2), src, target);
}
@@ -7952,12 +8207,12 @@ void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd)
int fd = tsd->fd;
if( fd > 0 )
- clif_authfail_fd(fd, 15);
+ clif->authfail_fd(fd, 15);
else
map_quit(tsd);
if( sd )
- clif_GM_kickack(sd,tsd->status.account_id);
+ clif->GM_kickack(sd,tsd->status.account_id);
}
@@ -8012,8 +8267,7 @@ void clif_GM_silence(struct map_session_data* sd, struct map_session_data* tsd,
/// 0 = success
/// 1 = failure
/// 2 = too many blocks
-void clif_wisexin(struct map_session_data *sd,int type,int flag)
-{
+void clif_wisexin(struct map_session_data *sd,int type,int flag) {
int fd;
nullpo_retv(sd);
@@ -8034,8 +8288,7 @@ void clif_wisexin(struct map_session_data *sd,int type,int flag)
/// result:
/// 0 = success
/// 1 = failure
-void clif_wisall(struct map_session_data *sd,int type,int flag)
-{
+void clif_wisall(struct map_session_data *sd,int type,int flag) {
int fd;
nullpo_retv(sd);
@@ -8106,7 +8359,7 @@ void clif_soundeffectall(struct block_list* bl, const char* name, int type, enum
WBUFB(buf,26) = type;
WBUFL(buf,27) = 0;
WBUFL(buf,31) = bl->id;
- clif_send(buf, packet_len(0x1d3), bl, coverage);
+ clif->send(buf, packet_len(0x1d3), bl, coverage);
}
@@ -8126,16 +8379,15 @@ void clif_specialeffect(struct block_list* bl, int type, enum send_target target
WBUFL(buf,2) = bl->id;
WBUFL(buf,6) = type;
- clif_send(buf, packet_len(0x1f3), bl, target);
+ clif->send(buf, packet_len(0x1f3), bl, target);
if (disguised(bl)) {
WBUFL(buf,2) = -bl->id;
- clif_send(buf, packet_len(0x1f3), bl, SELF);
+ clif->send(buf, packet_len(0x1f3), bl, SELF);
}
}
-void clif_specialeffect_single(struct block_list* bl, int type, int fd)
-{
+void clif_specialeffect_single(struct block_list* bl, int type, int fd) {
WFIFOHEAD(fd,10);
WFIFOW(fd,0) = 0x1f3;
WFIFOL(fd,2) = bl->id;
@@ -8159,26 +8411,26 @@ void clif_specialeffect_value(struct block_list* bl, int effect_id, int num, sen
WBUFL(buf,6) = effect_id;
WBUFL(buf,10) = num;
- clif_send(buf, packet_len(0x284), bl, target);
+ clif->send(buf, packet_len(0x284), bl, target);
if( disguised(bl) )
{
WBUFL(buf,2) = -bl->id;
- clif_send(buf, packet_len(0x284), bl, SELF);
+ clif->send(buf, packet_len(0x284), bl, SELF);
}
}
// Modification of clif_messagecolor to send colored messages to players to chat log only (doesn't display overhead)
/// 02c1 <packet len>.W <id>.L <color>.L <message>.?B
-int clif_colormes(struct map_session_data * sd, enum clif_colors color, const char* msg) {
+int clif_colormes(int fd, enum clif_colors color, const char* msg) {
unsigned short msg_len = strlen(msg) + 1;
- WFIFOHEAD(sd->fd,msg_len + 12);
- WFIFOW(sd->fd,0) = 0x2C1;
- WFIFOW(sd->fd,2) = msg_len + 12;
- WFIFOL(sd->fd,4) = 0;
- WFIFOL(sd->fd,8) = color_table[color];
- safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len);
- clif_send(WFIFOP(sd->fd,0), WFIFOW(sd->fd,2), &sd->bl, SELF);
+ WFIFOHEAD(fd,msg_len + 12);
+ WFIFOW(fd,0) = 0x2C1;
+ WFIFOW(fd,2) = msg_len + 12;
+ WFIFOL(fd,4) = 0;
+ WFIFOL(fd,8) = color_table[color];
+ safestrncpy((char*)WFIFOP(fd,12), msg, msg_len);
+ WFIFOSET(fd, msg_len + 12);
return 0;
}
@@ -8192,8 +8444,7 @@ void clif_messagecolor(struct block_list* bl, unsigned long color, const char* m
nullpo_retv(bl);
- if( msg_len > sizeof(buf)-12 )
- {
+ if( msg_len > sizeof(buf)-12 ) {
ShowWarning("clif_messagecolor: Truncating too long message '%s' (len=%u).\n", msg, msg_len);
msg_len = sizeof(buf)-12;
}
@@ -8204,7 +8455,7 @@ void clif_messagecolor(struct block_list* bl, unsigned long color, const char* m
WBUFL(buf,8) = color;
memcpy(WBUFP(buf,12), msg, msg_len);
- clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC);
+ clif->send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC);
}
/// Public chat message [Valaris] (ZC_NOTIFY_CHAT).
@@ -8224,7 +8475,7 @@ void clif_message(struct block_list* bl, const char* msg) {
WBUFL(buf,4) = bl->id;
safestrncpy((char*)WBUFP(buf,8), msg, msg_len);
- clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC);
+ clif->send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC);
}
// refresh the client's screen, getting rid of any effects
@@ -8233,53 +8484,60 @@ void clif_refresh(struct map_session_data *sd)
int i;
nullpo_retv(sd);
- clif_changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y);
- clif_inventorylist(sd);
+ clif->changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y);
+ clif->inventorylist(sd);
if(pc_iscarton(sd)) {
- clif_cartlist(sd);
- clif_updatestatus(sd,SP_CARTINFO);
- }
- clif_updatestatus(sd,SP_WEIGHT);
- clif_updatestatus(sd,SP_MAXWEIGHT);
- clif_updatestatus(sd,SP_STR);
- clif_updatestatus(sd,SP_AGI);
- clif_updatestatus(sd,SP_VIT);
- clif_updatestatus(sd,SP_INT);
- clif_updatestatus(sd,SP_DEX);
- clif_updatestatus(sd,SP_LUK);
+ clif->cartlist(sd);
+ clif->updatestatus(sd,SP_CARTINFO);
+ }
+ clif->updatestatus(sd,SP_WEIGHT);
+ clif->updatestatus(sd,SP_MAXWEIGHT);
+ clif->updatestatus(sd,SP_STR);
+ clif->updatestatus(sd,SP_AGI);
+ clif->updatestatus(sd,SP_VIT);
+ clif->updatestatus(sd,SP_INT);
+ clif->updatestatus(sd,SP_DEX);
+ clif->updatestatus(sd,SP_LUK);
if (sd->spiritball)
- clif_spiritball_single(sd->fd, sd);
+ clif->spiritball_single(sd->fd, sd);
for(i = 1; i < 5; i++){
if( sd->talisman[i] > 0 )
- clif_talisman_single(sd->fd, sd, i);
+ clif->talisman_single(sd->fd, sd, i);
}
if (sd->vd.cloth_color)
- clif_refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF);
- if(merc_is_hom_active(sd->hd))
- clif_send_homdata(sd,SP_ACK,0);
+ clif->refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF);
+ if(homun_alive(sd->hd))
+ clif->send_homdata(sd,SP_ACK,0);
if( sd->md ) {
- clif_mercenary_info(sd);
- clif_mercenary_skillblock(sd);
+ clif->mercenary_info(sd);
+ clif->mercenary_skillblock(sd);
}
if( sd->ed )
- clif_elemental_info(sd);
- map_foreachinrange(clif_getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd);
- clif_weather_check(sd);
+ clif->elemental_info(sd);
+ map_foreachinrange(clif->getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd);
+ clif->weather_check(sd);
if( sd->chatID )
chat_leavechat(sd,0);
if( sd->state.vending )
- clif_openvending(sd, sd->bl.id, sd->vending);
+ clif->openvending(sd, sd->bl.id, sd->vending);
if( pc_issit(sd) )
- clif_sitting(&sd->bl); // FIXME: just send to self, not area
+ clif->sitting(&sd->bl); // FIXME: just send to self, not area
if( pc_isdead(sd) ) // When you refresh, resend the death packet.
- clif_clearunit_single(sd->bl.id,CLR_DEAD,sd->fd);
+ clif->clearunit_single(sd->bl.id,CLR_DEAD,sd->fd);
else
- clif_changed_dir(&sd->bl, SELF);
+ clif->changed_dir(&sd->bl, SELF);
// unlike vending, resuming buyingstore crashes the client.
- buyingstore_close(sd);
+ buyingstore->close(sd);
mail_clear(sd);
+
+ if( disguised(&sd->bl) ) {/* refresh-da */
+ short disguise = sd->disguise;
+ pc_disguise(sd, -1);
+ pc_disguise(sd, disguise);
+ }
+
}
@@ -8296,127 +8554,121 @@ void clif_charnameack (int fd, struct block_list *bl)
WBUFW(buf,0) = cmd;
WBUFL(buf,2) = bl->id;
- switch( bl->type )
- {
- case BL_PC:
- {
- struct map_session_data *ssd = (struct map_session_data *)bl;
- struct party_data *p = NULL;
- struct guild *g = NULL;
-
- //Requesting your own "shadow" name. [Skotlex]
- if (ssd->fd == fd && ssd->disguise)
- WBUFL(buf,2) = -bl->id;
-
- if( ssd->fakename[0] )
- {
- WBUFW(buf, 0) = cmd = 0x195;
- memcpy(WBUFP(buf,6), ssd->fakename, NAME_LENGTH);
- WBUFB(buf,30) = WBUFB(buf,54) = WBUFB(buf,78) = 0;
- break;
- }
- memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH);
-
- if( ssd->status.party_id )
- {
- p = party_search(ssd->status.party_id);
- }
- if( ssd->status.guild_id )
+ switch( bl->type ) {
+ case BL_PC:
{
- if( ( g = guild_search(ssd->status.guild_id) ) != NULL )
- {
- ARR_FIND(0, g->max_member, i, g->member[i].account_id == ssd->status.account_id && g->member[i].char_id == ssd->status.char_id);
- if( i < g->max_member ) ps = g->member[i].position;
+ struct map_session_data *ssd = (struct map_session_data *)bl;
+ struct party_data *p = NULL;
+ struct guild *g = NULL;
+
+ //Requesting your own "shadow" name. [Skotlex]
+ if (ssd->fd == fd && ssd->disguise != -1)
+ WBUFL(buf,2) = -bl->id;
+
+ if( ssd->fakename[0] ) {
+ WBUFW(buf, 0) = cmd = 0x195;
+ memcpy(WBUFP(buf,6), ssd->fakename, NAME_LENGTH);
+ WBUFB(buf,30) = WBUFB(buf,54) = WBUFB(buf,78) = 0;
+ break;
}
- }
+ memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH);
- if( !battle_config.display_party_name && g == NULL )
- {// do not display party unless the player is also in a guild
- p = NULL;
- }
-
- if (p == NULL && g == NULL)
- break;
+ if( ssd->status.party_id ) {
+ p = party_search(ssd->status.party_id);
+ }
+ if( ssd->status.guild_id ) {
+ if( ( g = ssd->guild ) != NULL ) {
+ ARR_FIND(0, g->max_member, i, g->member[i].account_id == ssd->status.account_id && g->member[i].char_id == ssd->status.char_id);
+ if( i < g->max_member ) ps = g->member[i].position;
+ }
+ }
- WBUFW(buf, 0) = cmd = 0x195;
- if (p)
- memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH);
- else
- WBUFB(buf,30) = 0;
+ if( !battle_config.display_party_name && g == NULL ) {// do not display party unless the player is also in a guild
+ p = NULL;
+ }
- if (g && ps >= 0 && ps < MAX_GUILDPOSITION)
- {
- memcpy(WBUFP(buf,54), g->name,NAME_LENGTH);
- memcpy(WBUFP(buf,78), g->position[ps].name, NAME_LENGTH);
- } else { //Assume no guild.
- WBUFB(buf,54) = 0;
- WBUFB(buf,78) = 0;
- }
- }
- break;
- //[blackhole89]
- case BL_HOM:
- memcpy(WBUFP(buf,6), ((TBL_HOM*)bl)->homunculus.name, NAME_LENGTH);
- break;
- case BL_MER:
- memcpy(WBUFP(buf,6), ((TBL_MER*)bl)->db->name, NAME_LENGTH);
- break;
- case BL_PET:
- memcpy(WBUFP(buf,6), ((TBL_PET*)bl)->pet.name, NAME_LENGTH);
- break;
- case BL_NPC:
- memcpy(WBUFP(buf,6), ((TBL_NPC*)bl)->name, NAME_LENGTH);
- break;
- case BL_MOB:
- {
- struct mob_data *md = (struct mob_data *)bl;
- nullpo_retv(md);
+ if (p == NULL && g == NULL)
+ break;
- memcpy(WBUFP(buf,6), md->name, NAME_LENGTH);
- if( md->guardian_data && md->guardian_data->guild_id )
- {
- WBUFW(buf, 0) = cmd = 0x195;
- WBUFB(buf,30) = 0;
- memcpy(WBUFP(buf,54), md->guardian_data->guild_name, NAME_LENGTH);
- memcpy(WBUFP(buf,78), md->guardian_data->castle->castle_name, NAME_LENGTH);
- }
- else if( battle_config.show_mob_info )
- {
- char mobhp[50], *str_p = mobhp;
WBUFW(buf, 0) = cmd = 0x195;
- if( battle_config.show_mob_info&4 )
- str_p += sprintf(str_p, "Lv. %d | ", md->level);
- if( battle_config.show_mob_info&1 )
- str_p += sprintf(str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp);
- if( battle_config.show_mob_info&2 )
- str_p += sprintf(str_p, "HP: %d%% | ", get_percentage(md->status.hp, md->status.max_hp));
- //Even thought mobhp ain't a name, we send it as one so the client
- //can parse it. [Skotlex]
- if( str_p != mobhp )
+ if (p)
+ memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH);
+ else
+ WBUFB(buf,30) = 0;
+
+ if (g && ps >= 0 && ps < MAX_GUILDPOSITION)
{
- *(str_p-3) = '\0'; //Remove trailing space + pipe.
- memcpy(WBUFP(buf,30), mobhp, NAME_LENGTH);
+ memcpy(WBUFP(buf,54), g->name,NAME_LENGTH);
+ memcpy(WBUFP(buf,78), g->position[ps].name, NAME_LENGTH);
+ } else { //Assume no guild.
WBUFB(buf,54) = 0;
WBUFB(buf,78) = 0;
}
}
- }
- break;
- case BL_CHAT: //FIXME: Clients DO request this... what should be done about it? The chat's title may not fit... [Skotlex]
-// memcpy(WBUFP(buf,6), (struct chat*)->title, NAME_LENGTH);
-// break;
- return;
- case BL_ELEM:
- memcpy(WBUFP(buf,6), ((TBL_ELEM*)bl)->db->name, NAME_LENGTH);
- break;
- default:
- ShowError("clif_charnameack: bad type %d(%d)\n", bl->type, bl->id);
- return;
+ break;
+ //[blackhole89]
+ case BL_HOM:
+ memcpy(WBUFP(buf,6), ((TBL_HOM*)bl)->homunculus.name, NAME_LENGTH);
+ break;
+ case BL_MER:
+ memcpy(WBUFP(buf,6), ((TBL_MER*)bl)->db->name, NAME_LENGTH);
+ break;
+ case BL_PET:
+ memcpy(WBUFP(buf,6), ((TBL_PET*)bl)->pet.name, NAME_LENGTH);
+ break;
+ case BL_NPC:
+ memcpy(WBUFP(buf,6), ((TBL_NPC*)bl)->name, NAME_LENGTH);
+ break;
+ case BL_MOB:
+ {
+ struct mob_data *md = (struct mob_data *)bl;
+ nullpo_retv(md);
+
+ memcpy(WBUFP(buf,6), md->name, NAME_LENGTH);
+ if( md->guardian_data && md->guardian_data->guild_id )
+ {
+ WBUFW(buf, 0) = cmd = 0x195;
+ WBUFB(buf,30) = 0;
+ memcpy(WBUFP(buf,54), md->guardian_data->guild_name, NAME_LENGTH);
+ memcpy(WBUFP(buf,78), md->guardian_data->castle->castle_name, NAME_LENGTH);
+ }
+ else if( battle_config.show_mob_info )
+ {
+ char mobhp[50], *str_p = mobhp;
+ WBUFW(buf, 0) = cmd = 0x195;
+ if( battle_config.show_mob_info&4 )
+ str_p += sprintf(str_p, "Lv. %d | ", md->level);
+ if( battle_config.show_mob_info&1 )
+ str_p += sprintf(str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp);
+ if( battle_config.show_mob_info&2 )
+ str_p += sprintf(str_p, "HP: %d%% | ", get_percentage(md->status.hp, md->status.max_hp));
+ //Even thought mobhp ain't a name, we send it as one so the client
+ //can parse it. [Skotlex]
+ if( str_p != mobhp )
+ {
+ *(str_p-3) = '\0'; //Remove trailing space + pipe.
+ memcpy(WBUFP(buf,30), mobhp, NAME_LENGTH);
+ WBUFB(buf,54) = 0;
+ WBUFB(buf,78) = 0;
+ }
+ }
+ }
+ break;
+ case BL_CHAT: //FIXME: Clients DO request this... what should be done about it? The chat's title may not fit... [Skotlex]
+ // memcpy(WBUFP(buf,6), (struct chat*)->title, NAME_LENGTH);
+ // break;
+ return;
+ case BL_ELEM:
+ memcpy(WBUFP(buf,6), ((TBL_ELEM*)bl)->db->name, NAME_LENGTH);
+ break;
+ default:
+ ShowError("clif_charnameack: bad type %d(%d)\n", bl->type, bl->id);
+ return;
}
// if no receipient specified just update nearby clients
if (fd == 0)
- clif_send(buf, packet_len(cmd), bl, AREA);
+ clif->send(buf, packet_len(cmd), bl, AREA);
else {
WFIFOHEAD(fd, packet_len(cmd));
memcpy(WFIFOP(fd, 0), buf, packet_len(cmd));
@@ -8430,7 +8682,7 @@ void clif_charnameack (int fd, struct block_list *bl)
void clif_charnameupdate (struct map_session_data *ssd)
{
unsigned char buf[103];
- int cmd = 0x195, ps = -1, i;
+ int cmd = 0x195, ps = -1;
struct party_data *p = NULL;
struct guild *g = NULL;
@@ -8445,15 +8697,16 @@ void clif_charnameupdate (struct map_session_data *ssd)
memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH);
if (!battle_config.display_party_name) {
- if (ssd->status.party_id > 0 && ssd->status.guild_id > 0 && (g = guild_search(ssd->status.guild_id)) != NULL)
+ if (ssd->status.party_id > 0 && ssd->status.guild_id > 0 && (g = ssd->guild) != NULL)
p = party_search(ssd->status.party_id);
}else{
if (ssd->status.party_id > 0)
p = party_search(ssd->status.party_id);
}
- if( ssd->status.guild_id > 0 && (g = guild_search(ssd->status.guild_id)) != NULL )
+ if( ssd->status.guild_id > 0 && (g = ssd->guild) != NULL )
{
+ int i;
ARR_FIND(0, g->max_member, i, g->member[i].account_id == ssd->status.account_id && g->member[i].char_id == ssd->status.char_id);
if( i < g->max_member ) ps = g->member[i].position;
}
@@ -8475,7 +8728,7 @@ void clif_charnameupdate (struct map_session_data *ssd)
}
// Update nearby clients
- clif_send(buf, packet_len(cmd), &ssd->bl, AREA);
+ clif->send(buf, packet_len(cmd), &ssd->bl, AREA);
}
@@ -8494,20 +8747,19 @@ void clif_slide(struct block_list *bl, int x, int y)
WBUFL(buf, 2) = bl->id;
WBUFW(buf, 6) = x;
WBUFW(buf, 8) = y;
- clif_send(buf, packet_len(0x1ff), bl, AREA);
+ clif->send(buf, packet_len(0x1ff), bl, AREA);
if( disguised(bl) )
{
WBUFL(buf,2) = -bl->id;
- clif_send(buf, packet_len(0x1ff), bl, SELF);
+ clif->send(buf, packet_len(0x1ff), bl, SELF);
}
}
-/*------------------------------------------
- * @me command by lordalfa, rewritten implementation by Skotlex
- *------------------------------------------*/
-void clif_disp_overhead(struct map_session_data *sd, const char* mes)
+/// Public chat message (ZC_NOTIFY_CHAT). lordalfa/Skotlex - used by @me as well
+/// 008d <packet len>.W <id>.L <message>.?B
+void clif_disp_overhead(struct block_list *bl, const char* mes)
{
unsigned char buf[256]; //This should be more than sufficient, the theorical max is CHAT_SIZE + 8 (pads and extra inserted crap)
int len_mes = strlen(mes)+1; //Account for \0
@@ -8519,15 +8771,18 @@ void clif_disp_overhead(struct map_session_data *sd, const char* mes)
// send message to others
WBUFW(buf,0) = 0x8d;
WBUFW(buf,2) = len_mes + 8; // len of message + 8 (command+len+id)
- WBUFL(buf,4) = sd->bl.id;
+ WBUFL(buf,4) = bl->id;
safestrncpy((char*)WBUFP(buf,8), mes, len_mes);
- clif_send(buf, WBUFW(buf,2), &sd->bl, AREA_CHAT_WOC);
+ clif->send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC);
// send back message to the speaker
- WBUFW(buf,0) = 0x8e;
- WBUFW(buf, 2) = len_mes + 4;
- safestrncpy((char*)WBUFP(buf,4), mes, len_mes);
- clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
+ if( bl->type == BL_PC ) {
+ WBUFW(buf,0) = 0x8e;
+ WBUFW(buf, 2) = len_mes + 4;
+ safestrncpy((char*)WBUFP(buf,4), mes, len_mes);
+ clif->send(buf, WBUFW(buf,2), bl, SELF);
+ }
+
}
/*==========================
@@ -8542,7 +8797,7 @@ void clif_party_xy_remove(struct map_session_data *sd)
WBUFL(buf,2)=sd->status.account_id;
WBUFW(buf,6)=-1;
WBUFW(buf,8)=-1;
- clif_send(buf,packet_len(0x107),&sd->bl,PARTY_SAMEMAP_WOS);
+ clif->send(buf,packet_len(0x107),&sd->bl,PARTY_SAMEMAP_WOS);
}
@@ -8622,7 +8877,7 @@ void clif_feel_info(struct map_session_data* sd, unsigned char feel_level, unsig
char mapname[MAP_NAME_LENGTH_EXT];
mapindex_getmapname_ext(mapindex_id2name(sd->feel_map[feel_level].index), mapname);
- clif_starskill(sd, mapname, 0, feel_level, type ? 1 : 0);
+ clif->starskill(sd, mapname, 0, feel_level, type ? 1 : 0);
}
/*==========================================
@@ -8631,16 +8886,11 @@ void clif_feel_info(struct map_session_data* sd, unsigned char feel_level, unsig
*------------------------------------------*/
void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int class_, unsigned char type)
{
- if( pcdb_checkid(class_) )
- {
- clif_starskill(sd, job_name(class_), class_, hate_level, type ? 10 : 11);
- }
- else if( mobdb_checkid(class_) )
- {
- clif_starskill(sd, mob_db(class_)->jname, class_, hate_level, type ? 10 : 11);
- }
- else
- {
+ if( pcdb_checkid(class_) ) {
+ clif->starskill(sd, job_name(class_), class_, hate_level, type ? 10 : 11);
+ } else if( mobdb_checkid(class_) ) {
+ clif->starskill(sd, mob_db(class_)->jname, class_, hate_level, type ? 10 : 11);
+ } else {
ShowWarning("clif_hate_info: Received invalid class %d for this packet (char_id=%d, hate_level=%u, type=%u).\n", class_, sd->status.char_id, (unsigned int)hate_level, (unsigned int)type);
}
}
@@ -8650,7 +8900,7 @@ void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int cl
*------------------------------------------*/
void clif_mission_info(struct map_session_data *sd, int mob_id, unsigned char progress)
{
- clif_starskill(sd, mob_db(mob_id)->jname, mob_id, progress, 20);
+ clif->starskill(sd, mob_db(mob_id)->jname, mob_id, progress, 20);
}
/*==========================================
@@ -8658,7 +8908,7 @@ void clif_mission_info(struct map_session_data *sd, int mob_id, unsigned char pr
*------------------------------------------*/
void clif_feel_hate_reset(struct map_session_data *sd)
{
- clif_starskill(sd, "", 0, 0, 30);
+ clif->starskill(sd, "", 0, 0, 30);
}
@@ -8752,9 +9002,9 @@ void clif_viewequip_ack(struct map_session_data* sd, struct map_session_data* ts
// Inventory position
WBUFW(buf, n*s+43) = i + 2;
// Add refine, identify flag, element, etc.
- clif_item_sub(WBUFP(buf,0), n*s+45, &tsd->status.inventory[i], tsd->inventory_data[i], pc_equippoint(tsd, i));
+ clif->item_sub(WBUFP(buf,0), n*s+45, &tsd->status.inventory[i], tsd->inventory_data[i], pc_equippoint(tsd, i));
// Add cards
- clif_addcards(WBUFP(buf, n*s+55), &tsd->status.inventory[i]);
+ clif->addcards(WBUFP(buf, n*s+55), &tsd->status.inventory[i]);
// Expiration date stuff, if all of those are set to 0 then the client doesn't show anything related (6 bytes)
WBUFL(buf, n*s+63) = tsd->status.inventory[i].expire_time;
WBUFW(buf, n*s+67) = 0;
@@ -8829,8 +9079,7 @@ void clif_viewequip_fail(struct map_session_data* sd)
/// Returns true if the packet was parsed successfully.
/// Formats: 0 - <packet id>.w <packet len>.w (<name> : <message>).?B 00
/// 1 - <packet id>.w <packet len>.w <name>.24B <message>.?B 00
-static bool clif_process_message(struct map_session_data* sd, int format, char** name_, int* namelen_, char** message_, int* messagelen_)
-{
+bool clif_process_message(struct map_session_data* sd, int format, char** name_, int* namelen_, char** message_, int* messagelen_) {
char *text, *name, *message;
unsigned int packetlen, textlen, namelen, messagelen;
int fd = sd->fd;
@@ -8920,79 +9169,50 @@ static bool clif_process_message(struct map_session_data* sd, int format, char**
return true;
}
-// ---------------------
-// clif_guess_PacketVer
-// ---------------------
-// Parses a WantToConnection packet to try to identify which is the packet version used. [Skotlex]
-// error codes:
-// 0 - Success
-// 1 - Unknown packet_ver
-// 2 - Invalid account_id
-// 3 - Invalid char_id
-// 4 - Invalid login_id1 (reserved)
-// 5 - Invalid client_tick (reserved)
-// 6 - Invalid sex
-// Only the first 'invalid' error that appears is used.
-static int clif_guess_PacketVer(int fd, int get_previous, int *error)
-{
- static int err = 1;
- static int packet_ver = -1;
- int cmd, packet_len, value; //Value is used to temporarily store account/char_id/sex
-
- if (get_previous)
- {//For quick reruns, since the normal code flow is to fetch this once to identify the packet version, then again in the wanttoconnect function. [Skotlex]
- if( error )
- *error = err;
- return packet_ver;
- }
-
- //By default, start searching on the default one.
- err = 1;
- packet_ver = clif_config.packet_db_ver;
- cmd = RFIFOW(fd,0);
- packet_len = RFIFOREST(fd);
-
-#define SET_ERROR(n) \
- if( err == 1 )\
- err = n;\
-//define SET_ERROR
-
- // FIXME: If the packet is not received at once, this will FAIL.
- // Figure out, when it happens, that only part of the packet is
- // received, or fix the function to be able to deal with that
- // case.
-#define CHECK_PACKET_VER() \
- if( cmd != clif_config.connect_cmd[packet_ver] || packet_len != packet_db[packet_ver][cmd].len )\
- ;/* not wanttoconnection or wrong length */\
- else if( (value=(int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[0])) < START_ACCOUNT_NUM || value > END_ACCOUNT_NUM )\
- { SET_ERROR(2); }/* invalid account_id */\
- else if( (value=(int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[1])) <= 0 )\
- { SET_ERROR(3); }/* invalid char_id */\
- /* RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]) - don't care about login_id1 */\
- /* RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]) - don't care about client_tick */\
- else if( (value=(int)RFIFOB(fd, packet_db[packet_ver][cmd].pos[4])) != 0 && value != 1 )\
- { SET_ERROR(6); }/* invalid sex */\
- else\
- {\
- err = 0;\
- if( error )\
- *error = 0;\
- return packet_ver;\
- }\
-//define CHECK_PACKET_VER
-
- CHECK_PACKET_VER();//Default packet version found.
-
- for (packet_ver = MAX_PACKET_VER; packet_ver > 0; packet_ver--)
- { //Start guessing the version, giving priority to the newer ones. [Skotlex]
- CHECK_PACKET_VER();
- }
- if( error )
- *error = err;
- packet_ver = -1;
- return -1;
-#undef SET_ERROR
-#undef CHECK_PACKET_VER
+void clif_hercules_chsys_msg(struct hChSysCh *channel, struct map_session_data *sd, char *msg) {
+ DBIterator *iter = db_iterator(channel->users);
+ struct map_session_data *user;
+ unsigned short msg_len = strlen(msg) + 1;
+
+ WFIFOHEAD(sd->fd,msg_len + 12);
+ WFIFOW(sd->fd,0) = 0x2C1;
+ WFIFOW(sd->fd,2) = msg_len + 12;
+ WFIFOL(sd->fd,4) = 0;
+ WFIFOL(sd->fd,8) = hChSys.colors[channel->color];
+ safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len);
+
+ for( user = dbi_first(iter); dbi_exists(iter); user = dbi_next(iter) ) {
+ if( user->fd == sd->fd )
+ continue;
+ WFIFOHEAD(user->fd,msg_len + 12);
+ memcpy(WFIFOP(user->fd,0), WFIFOP(sd->fd,0), msg_len + 12);
+ WFIFOSET(user->fd, msg_len + 12);
+ }
+
+ WFIFOSET(sd->fd, msg_len + 12);
+
+ dbi_destroy(iter);
+}
+
+void clif_hercules_chsys_msg2(struct hChSysCh *channel, char *msg) {
+ DBIterator *iter = db_iterator(channel->users);
+ struct map_session_data *user;
+ unsigned char buf[210];
+ unsigned short msg_len = strlen(msg) + 1;
+
+ WBUFW(buf,0) = 0x2C1;
+ WBUFW(buf,2) = msg_len + 12;
+ WBUFL(buf,4) = 0;
+ WBUFL(buf,8) = hChSys.colors[channel->color];
+ safestrncpy((char*)WBUFP(buf,12), msg, msg_len);
+
+ for( user = dbi_first(iter); dbi_exists(iter); user = dbi_next(iter) ) {
+ WFIFOHEAD(user->fd,msg_len + 12);
+ memcpy(WFIFOP(user->fd,0), WBUFP(buf,0), msg_len + 12);
+ WFIFOSET(user->fd, msg_len + 12);
+ }
+
+ dbi_destroy(iter);
}
// ------------
@@ -9005,13 +9225,11 @@ static int clif_guess_PacketVer(int fd, int get_previous, int *error)
/// 0072 <account id>.L <char id>.L <auth code>.L <client time>.L <gender>.B (CZ_ENTER)
/// 0436 <account id>.L <char id>.L <auth code>.L <client time>.L <gender>.B (CZ_ENTER2)
/// There are various variants of this packet, some of them have padding between fields.
-void clif_parse_WantToConnection(int fd, TBL_PC* sd)
-{
+void clif_parse_WantToConnection(int fd, struct map_session_data* sd) {
struct block_list* bl;
struct auth_node* node;
int cmd, account_id, char_id, login_id1, sex;
unsigned int client_tick; //The client tick is a tick, therefore it needs be unsigned. [Skotlex]
- int packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
if (sd) {
ShowError("clif_parse_WantToConnection : invalid request (character already logged in)\n");
@@ -9019,31 +9237,16 @@ void clif_parse_WantToConnection(int fd, TBL_PC* sd)
}
// Only valid packet version get here
- packet_ver = clif_guess_PacketVer(fd, 1, NULL);
cmd = RFIFOW(fd,0);
- account_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0]);
- char_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1]);
- login_id1 = RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]);
- client_tick = RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]);
- sex = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4]);
-
- if( packet_ver < 5 || // reject really old client versions
- (packet_ver <= 9 && (battle_config.packet_ver_flag & 1) == 0) || // older than 6sept04
- (packet_ver > 9 && (battle_config.packet_ver_flag & 1<<(packet_ver-9)) == 0)) // version not allowed
- {// packet version rejected
- ShowInfo("Rejected connection attempt, forbidden packet version (AID/CID: '"CL_WHITE"%d/%d"CL_RESET"', Packet Ver: '"CL_WHITE"%d"CL_RESET"', IP: '"CL_WHITE"%s"CL_RESET"').\n", account_id, char_id, packet_ver, ip2str(session[fd]->client_addr, NULL));
- WFIFOHEAD(fd,packet_len(0x6a));
- WFIFOW(fd,0) = 0x6a;
- WFIFOB(fd,2) = 5; // Your Game's EXE file is not the latest version
- WFIFOSET(fd,packet_len(0x6a));
- set_eof(fd);
- return;
- }
+ account_id = RFIFOL(fd, packet_db[cmd].pos[0]);
+ char_id = RFIFOL(fd, packet_db[cmd].pos[1]);
+ login_id1 = RFIFOL(fd, packet_db[cmd].pos[2]);
+ client_tick = RFIFOL(fd, packet_db[cmd].pos[3]);
+ sex = RFIFOB(fd, packet_db[cmd].pos[4]);
- if( runflag != MAPSERVER_ST_RUNNING )
- {// not allowed
- clif_authfail_fd(fd,1);// server closed
+ if( runflag != MAPSERVER_ST_RUNNING ) { // not allowed
+ clif->authfail_fd(fd,1);// server closed
return;
}
@@ -9063,13 +9266,12 @@ void clif_parse_WantToConnection(int fd, TBL_PC* sd)
((node=chrif_search(account_id)) && //An already existing node is valid only if it is for this login.
!(node->account_id == account_id && node->char_id == char_id && node->state == ST_LOGIN)))
{
- clif_authfail_fd(fd, 8); //Still recognizes last connection
+ clif->authfail_fd(fd, 8); //Still recognizes last connection
return;
}
CREATE(sd, TBL_PC, 1);
sd->fd = fd;
- sd->packet_ver = packet_ver;
session[fd]->session_data = sd;
pc_setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd);
@@ -9087,7 +9289,28 @@ void clif_parse_WantToConnection(int fd, TBL_PC* sd)
chrif_authreq(sd);
}
-
+void clif_hercules_chsys_mjoin(struct map_session_data *sd) {
+ if( !map[sd->bl.m].channel ) {
+ CREATE(map[sd->bl.m].channel, struct hChSysCh , 1);
+ safestrncpy(map[sd->bl.m].channel->name, hChSys.local_name, HCHSYS_NAME_LENGTH);
+ map[sd->bl.m].channel->type = hChSys_MAP;
+ map[sd->bl.m].channel->m = sd->bl.m;
+
+ clif->chsys_create(map[sd->bl.m].channel,NULL,NULL,hChSys.local_color);
+ }
+
+ if( map[sd->bl.m].channel->banned && idb_exists(map[sd->bl.m].channel->banned, sd->status.account_id) ) {
+ return;
+ }
+
+ clif->chsys_join(map[sd->bl.m].channel,sd);
+
+ if( !( map[sd->bl.m].channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) {
+ char mout[60];
+ sprintf(mout, msg_txt(1435),hChSys.local_name,map[sd->bl.m].name); // You're now in the '#%s' channel for '%s'
+ clif->colormes(sd->fd, COLOR_DEFAULT, mout);
+ }
+}
/// Notification from the client, that it has finished map loading and is about to display player's character (CZ_NOTIFY_ACTORINIT).
/// 007d
@@ -9096,17 +9319,15 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
if(sd->bl.prev != NULL)
return;
- if (!sd->state.active)
- { //Character loading is not complete yet!
+ if (!sd->state.active) { //Character loading is not complete yet!
//Let pc_reg_received reinvoke this when ready.
sd->state.connect_new = 0;
return;
}
- if (sd->state.rewarp)
- { //Rewarp player.
+ if (sd->state.rewarp) { //Rewarp player.
sd->state.rewarp = 0;
- clif_changemap(sd, sd->mapindex, sd->bl.x, sd->bl.y);
+ clif->changemap(sd, sd->mapindex, sd->bl.x, sd->bl.y);
return;
}
@@ -9114,49 +9335,43 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
// look
#if PACKETVER < 4
- clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
- clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
+ clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
+ clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
#else
- clif_changelook(&sd->bl,LOOK_WEAPON,0);
+ clif->changelook(&sd->bl,LOOK_WEAPON,0);
#endif
if(sd->vd.cloth_color)
- clif_refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF);
-
+ clif->refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF);
// item
- clif_inventorylist(sd); // inventory list first, otherwise deleted items in pc_checkitem show up as 'unknown item'
+ clif->inventorylist(sd); // inventory list first, otherwise deleted items in pc_checkitem show up as 'unknown item'
pc_checkitem(sd);
// cart
if(pc_iscarton(sd)) {
- clif_cartlist(sd);
- clif_updatestatus(sd,SP_CARTINFO);
+ clif->cartlist(sd);
+ clif->updatestatus(sd,SP_CARTINFO);
}
// weight
- clif_updatestatus(sd,SP_WEIGHT);
- clif_updatestatus(sd,SP_MAXWEIGHT);
+ clif->updatestatus(sd,SP_WEIGHT);
+ clif->updatestatus(sd,SP_MAXWEIGHT);
// guild
// (needs to go before clif_spawn() to show guild emblems correctly)
if(sd->status.guild_id)
- guild_send_memberinfoshort(sd,1);
+ guild->send_memberinfoshort(sd,1);
if(battle_config.pc_invincible_time > 0) {
- if(map_flag_gvg(sd->bl.m))
- pc_setinvincibletimer(sd,battle_config.pc_invincible_time<<1);
- else
- pc_setinvincibletimer(sd,battle_config.pc_invincible_time);
+ pc_setinvincibletimer(sd,battle_config.pc_invincible_time);
}
if( map[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs )
map_spawnmobs(sd->bl.m);
- if( !(sd->sc.option&OPTION_INVISIBLE) )
- {// increment the number of pvp players on the map
+ if( !(sd->sc.option&OPTION_INVISIBLE) ) { // increment the number of pvp players on the map
map[sd->bl.m].users_pvp++;
}
- if( map[sd->bl.m].instance_id )
- {
+ if( map[sd->bl.m].instance_id ) {
instance[map[sd->bl.m].instance_id].users++;
instance_check_idle(map[sd->bl.m].instance_id);
}
@@ -9166,16 +9381,16 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
sd->state.callshop = 0;
map_addblock(&sd->bl);
- clif_spawn(&sd->bl);
+ clif->spawn(&sd->bl);
// Party
// (needs to go after clif_spawn() to show hp bars correctly)
if(sd->status.party_id) {
party_send_movemap(sd);
- clif_party_hp(sd); // Show hp after displacement [LuzZza]
+ clif->party_hp(sd); // Show hp after displacement [LuzZza]
}
- if( sd->bg_id ) clif_bg_hp(sd); // BattleGround System
+ if( sd->bg_id ) clif->bg_hp(sd); // BattleGround System
if(map[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) {
if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris]
@@ -9187,92 +9402,85 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
sd->pvp_won = 0;
sd->pvp_lost = 0;
}
- clif_map_property(sd, MAPPROPERTY_FREEPVPZONE);
+ clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
} else
// set flag, if it's a duel [LuzZza]
if(sd->duel_group)
- clif_map_property(sd, MAPPROPERTY_FREEPVPZONE);
+ clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
if (map[sd->bl.m].flag.gvg_dungeon)
- clif_map_property(sd, MAPPROPERTY_FREEPVPZONE); //TODO: Figure out the real packet to send here.
+ clif->map_property(sd, MAPPROPERTY_FREEPVPZONE); //TODO: Figure out the real packet to send here.
if( map_flag_gvg(sd->bl.m) )
- clif_map_property(sd, MAPPROPERTY_AGITZONE);
-
+ clif->map_property(sd, MAPPROPERTY_AGITZONE);
// info about nearby objects
// must use foreachinarea (CIRCULAR_AREA interferes with foreachinrange)
- map_foreachinarea(clif_getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd);
+ map_foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd);
// pet
- if( sd->pd )
- {
- if( battle_config.pet_no_gvg && map_flag_gvg(sd->bl.m) )
- { //Return the pet to egg. [Skotlex]
- clif_displaymessage(sd->fd, msg_txt(666));
+ if( sd->pd ) {
+ if( battle_config.pet_no_gvg && map_flag_gvg(sd->bl.m) ) { //Return the pet to egg. [Skotlex]
+ clif->message(sd->fd, msg_txt(666));
pet_menu(sd, 3); //Option 3 is return to egg.
- }
- else
- {
+ } else {
map_addblock(&sd->pd->bl);
- clif_spawn(&sd->pd->bl);
- clif_send_petdata(sd,sd->pd,0,0);
- clif_send_petstatus(sd);
-// skill_unit_move(&sd->pd->bl,gettick(),1);
+ clif->spawn(&sd->pd->bl);
+ clif->send_petdata(sd,sd->pd,0,0);
+ clif->send_petstatus(sd);
+// skill->unit_move(&sd->pd->bl,gettick(),1);
}
}
//homunculus [blackhole89]
- if( merc_is_hom_active(sd->hd) )
- {
+ if( homun_alive(sd->hd) ) {
map_addblock(&sd->hd->bl);
- clif_spawn(&sd->hd->bl);
- clif_send_homdata(sd,SP_ACK,0);
- clif_hominfo(sd,sd->hd,1);
- clif_hominfo(sd,sd->hd,0); //for some reason, at least older clients want this sent twice
- clif_homskillinfoblock(sd);
+ clif->spawn(&sd->hd->bl);
+ clif->send_homdata(sd,SP_ACK,0);
+ clif->hominfo(sd,sd->hd,1);
+ clif->hominfo(sd,sd->hd,0); //for some reason, at least older clients want this sent twice
+ clif->homskillinfoblock(sd);
if( battle_config.hom_setting&0x8 )
status_calc_bl(&sd->hd->bl, SCB_SPEED); //Homunc mimic their master's speed on each map change
if( !(battle_config.hom_setting&0x2) )
- skill_unit_move(&sd->hd->bl,gettick(),1); // apply land skills immediately
+ skill->unit_move(&sd->hd->bl,gettick(),1); // apply land skills immediately
}
if( sd->md ) {
map_addblock(&sd->md->bl);
- clif_spawn(&sd->md->bl);
- clif_mercenary_info(sd);
- clif_mercenary_skillblock(sd);
+ clif->spawn(&sd->md->bl);
+ clif->mercenary_info(sd);
+ clif->mercenary_skillblock(sd);
status_calc_bl(&sd->md->bl, SCB_SPEED); // Mercenary mimic their master's speed on each map change
}
if( sd->ed ) {
map_addblock(&sd->ed->bl);
- clif_spawn(&sd->ed->bl);
- clif_elemental_info(sd);
- clif_elemental_updatestatus(sd,SP_HP);
- clif_hpmeter_single(sd->fd,sd->ed->bl.id,sd->ed->battle_status.hp,sd->ed->battle_status.max_hp);
- clif_elemental_updatestatus(sd,SP_SP);
+ clif->spawn(&sd->ed->bl);
+ clif->elemental_info(sd);
+ clif->elemental_updatestatus(sd,SP_HP);
+ clif->hpmeter_single(sd->fd,sd->ed->bl.id,sd->ed->battle_status.hp,sd->ed->battle_status.max_hp);
+ clif->elemental_updatestatus(sd,SP_SP);
status_calc_bl(&sd->ed->bl, SCB_SPEED); //Elemental mimic their master's speed on each map change
}
if(sd->state.connect_new) {
int lv;
sd->state.connect_new = 0;
- clif_skillinfoblock(sd);
- clif_hotkeys_send(sd);
- clif_updatestatus(sd,SP_BASEEXP);
- clif_updatestatus(sd,SP_NEXTBASEEXP);
- clif_updatestatus(sd,SP_JOBEXP);
- clif_updatestatus(sd,SP_NEXTJOBEXP);
- clif_updatestatus(sd,SP_SKILLPOINT);
- clif_initialstatus(sd);
+ clif->skillinfoblock(sd);
+ clif->hotkeys(sd);
+ clif->updatestatus(sd,SP_BASEEXP);
+ clif->updatestatus(sd,SP_NEXTBASEEXP);
+ clif->updatestatus(sd,SP_JOBEXP);
+ clif->updatestatus(sd,SP_NEXTJOBEXP);
+ clif->updatestatus(sd,SP_SKILLPOINT);
+ clif->initialstatus(sd);
if (sd->sc.option&OPTION_FALCON)
- clif_status_load(&sd->bl, SI_FALCON, 1);
-
+ clif->status_change(&sd->bl, SI_FALCON, 1, 0, 0, 0, 0);
if (sd->sc.option&OPTION_RIDING)
- clif_status_load(&sd->bl, SI_RIDING, 1);
+ clif->status_change(&sd->bl, SI_RIDING, 1, 0, 0, 0, 0);
else if (sd->sc.option&OPTION_WUGRIDER)
- clif_status_load(&sd->bl, SI_WUGRIDER, 1);
+ clif->status_change(&sd->bl, SI_WUGRIDER, 1, 0, 0, 0, 0);
if(sd->status.manner < 0)
sc_start(&sd->bl,SC_NOCHAT,100,0,0);
@@ -9282,33 +9490,33 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
if(sd->bl.m == sd->feel_map[0].m
|| sd->bl.m == sd->feel_map[1].m
|| sd->bl.m == sd->feel_map[2].m)
- sc_start(&sd->bl, SC_KNOWLEDGE, 100, lv, skill_get_time(SG_KNOWLEDGE, lv));
+ sc_start(&sd->bl, SC_KNOWLEDGE, 100, lv, skill->get_time(SG_KNOWLEDGE, lv));
}
if(sd->pd && sd->pd->pet.intimate > 900)
- clif_pet_emotion(sd->pd,(sd->pd->pet.class_ - 100)*100 + 50 + pet_hungry_val(sd->pd));
+ clif->pet_emotion(sd->pd,(sd->pd->pet.class_ - 100)*100 + 50 + pet_hungry_val(sd->pd));
- if(merc_is_hom_active(sd->hd))
- merc_hom_init_timers(sd->hd);
+ if(homun_alive(sd->hd))
+ homun->init_timers(sd->hd);
if (night_flag && map[sd->bl.m].flag.nightenabled) {
sd->state.night = 1;
- clif_status_load(&sd->bl, SI_NIGHT, 1);
+ clif->status_change(&sd->bl, SI_NIGHT, 1, 0, 0, 0, 0);
}
// Notify everyone that this char logged in [Skotlex].
- map_foreachpc(clif_friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1);
+ map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1);
//Login Event
npc_script_event(sd, NPCE_LOGIN);
} else {
//For some reason the client "loses" these on warp/map-change.
- clif_updatestatus(sd,SP_STR);
- clif_updatestatus(sd,SP_AGI);
- clif_updatestatus(sd,SP_VIT);
- clif_updatestatus(sd,SP_INT);
- clif_updatestatus(sd,SP_DEX);
- clif_updatestatus(sd,SP_LUK);
+ clif->updatestatus(sd,SP_STR);
+ clif->updatestatus(sd,SP_AGI);
+ clif->updatestatus(sd,SP_VIT);
+ clif->updatestatus(sd,SP_INT);
+ clif->updatestatus(sd,SP_DEX);
+ clif->updatestatus(sd,SP_LUK);
// abort currently running script
sd->state.using_fake_npc = 0;
@@ -9319,73 +9527,73 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
npc_event_dequeue(sd);
}
- if( sd->state.changemap )
- {// restore information that gets lost on map-change
+ if( sd->state.changemap ) {// restore information that gets lost on map-change
#if PACKETVER >= 20070918
- clif_partyinvitationstate(sd);
- clif_equipcheckbox(sd);
+ clif->partyinvitationstate(sd);
+ clif->equipcheckbox(sd);
#endif
if( (battle_config.bg_flee_penalty != 100 || battle_config.gvg_flee_penalty != 100) &&
(map_flag_gvg(sd->state.pmap) || map_flag_gvg(sd->bl.m) || map[sd->state.pmap].flag.battleground || map[sd->bl.m].flag.battleground) )
status_calc_bl(&sd->bl, SCB_FLEE); //Refresh flee penalty
- if( night_flag && map[sd->bl.m].flag.nightenabled )
- { //Display night.
- if( !sd->state.night )
- {
+ if( night_flag && map[sd->bl.m].flag.nightenabled ) { //Display night.
+ if( !sd->state.night ) {
sd->state.night = 1;
- clif_status_load(&sd->bl, SI_NIGHT, 1);
+ clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_NIGHT);
}
- }
- else if( sd->state.night )
- { //Clear night display.
+ } else if( sd->state.night ) { //Clear night display.
sd->state.night = 0;
- clif_status_load(&sd->bl, SI_NIGHT, 0);
+ clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_NIGHT);
}
- if( map[sd->bl.m].flag.battleground )
- {
- clif_map_type(sd, MAPTYPE_BATTLEFIELD); // Battleground Mode
+ if( map[sd->bl.m].flag.battleground ) {
+ clif->map_type(sd, MAPTYPE_BATTLEFIELD); // Battleground Mode
if( map[sd->bl.m].flag.battleground == 2 )
- clif_bg_updatescore_single(sd);
+ clif->bg_updatescore_single(sd);
}
- if( map[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) )
- {
+ if( map[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) ) {
char output[128];
sprintf(output, "[ Kill Steal Protection Disable. KS is allowed in this map ]");
- clif_broadcast(&sd->bl, output, strlen(output) + 1, 0x10, SELF);
+ clif->broadcast(&sd->bl, output, strlen(output) + 1, 0x10, SELF);
}
map_iwall_get(sd); // Updates Walls Info on this Map to Client
+ status_calc_pc(sd, false);/* some conditions are map-dependent so we must recalculate */
sd->state.changemap = false;
+
+ if( hChSys.local && hChSys.local_autojoin && !map[sd->bl.m].flag.chsysnolocalaj ) {
+ clif->chsys_mjoin(sd);
+ }
}
mail_clear(sd);
+ clif->maptypeproperty2(&sd->bl,SELF);
+
/* Guild Aura Init */
if( sd->state.gmaster_flag ) {
- guild_guildaura_refresh(sd,GD_LEADERSHIP,guild_checkskill(sd->state.gmaster_flag,GD_LEADERSHIP));
- guild_guildaura_refresh(sd,GD_GLORYWOUNDS,guild_checkskill(sd->state.gmaster_flag,GD_GLORYWOUNDS));
- guild_guildaura_refresh(sd,GD_SOULCOLD,guild_checkskill(sd->state.gmaster_flag,GD_SOULCOLD));
- guild_guildaura_refresh(sd,GD_HAWKEYES,guild_checkskill(sd->state.gmaster_flag,GD_HAWKEYES));
+ guild->aura_refresh(sd,GD_LEADERSHIP,guild->checkskill(sd->state.gmaster_flag,GD_LEADERSHIP));
+ guild->aura_refresh(sd,GD_GLORYWOUNDS,guild->checkskill(sd->state.gmaster_flag,GD_GLORYWOUNDS));
+ guild->aura_refresh(sd,GD_SOULCOLD,guild->checkskill(sd->state.gmaster_flag,GD_SOULCOLD));
+ guild->aura_refresh(sd,GD_HAWKEYES,guild->checkskill(sd->state.gmaster_flag,GD_HAWKEYES));
}
if( sd->state.vending ) { /* show we have a vending */
- clif_openvending(sd,sd->bl.id,sd->vending);
- clif_showvendingboard(&sd->bl,sd->message,0);
+ clif->openvending(sd,sd->bl.id,sd->vending);
+ clif->showvendingboard(&sd->bl,sd->message,0);
}
if(map[sd->bl.m].flag.loadevent) // Lance
npc_script_event(sd, NPCE_LOADMAP);
- if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd))
- clif_status_load(&sd->bl, SI_DEVIL, 1); //blindness [Komurka]
+ if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd)) //blindness [Komurka]
+ clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_DEVIL);
if (sd->sc.opt2) //Client loses these on warp.
- clif_changeoption(&sd->bl);
+ clif->changeoption(&sd->bl);
- clif_weather_check(sd);
+ clif->weather_check(sd);
// For automatic triggering of NPCs after map loading (so you don't need to walk 1 step first)
if (map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC))
@@ -9399,22 +9607,21 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
// If player is dead, and is spawned (such as @refresh) send death packet. [Valaris]
if(pc_isdead(sd))
- clif_clearunit_area(&sd->bl, CLR_DEAD);
+ clif->clearunit_area(&sd->bl, CLR_DEAD);
else {
- skill_usave_trigger(sd);
- clif_changed_dir(&sd->bl, SELF);
+ skill->usave_trigger(sd);
+ clif->changed_dir(&sd->bl, SELF);
}
// Trigger skill effects if you appear standing on them
if(!battle_config.pc_invincible_time)
- skill_unit_move(&sd->bl,gettick(),1);
+ skill->unit_move(&sd->bl,gettick(),1);
}
/// Server's tick (ZC_NOTIFY_TIME).
/// 007f <time>.L
-void clif_notify_time(struct map_session_data* sd, unsigned long time)
-{
+void clif_notify_time(struct map_session_data* sd, unsigned long time) {
int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x7f));
@@ -9430,9 +9637,9 @@ void clif_notify_time(struct map_session_data* sd, unsigned long time)
/// There are various variants of this packet, some of them have padding between fields.
void clif_parse_TickSend(int fd, struct map_session_data *sd)
{
- sd->client_tick = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+ sd->client_tick = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
- clif_notify_time(sd, gettick());
+ clif->notify_time(sd, gettick());
}
@@ -9470,12 +9677,12 @@ void clif_parse_Hotkey(int fd, struct map_session_data *sd) {
int cmd;
cmd = RFIFOW(fd, 0);
- idx = RFIFOW(fd, packet_db[sd->packet_ver][cmd].pos[0]);
+ idx = RFIFOW(fd, packet_db[cmd].pos[0]);
if (idx >= MAX_HOTKEYS) return;
- sd->status.hotkeys[idx].type = RFIFOB(fd, packet_db[sd->packet_ver][cmd].pos[1]);
- sd->status.hotkeys[idx].id = RFIFOL(fd, packet_db[sd->packet_ver][cmd].pos[2]);
- sd->status.hotkeys[idx].lv = RFIFOW(fd, packet_db[sd->packet_ver][cmd].pos[3]);
+ sd->status.hotkeys[idx].type = RFIFOB(fd, packet_db[cmd].pos[1]);
+ sd->status.hotkeys[idx].id = RFIFOL(fd, packet_db[cmd].pos[2]);
+ sd->status.hotkeys[idx].lv = RFIFOW(fd, packet_db[cmd].pos[3]);
#endif
}
@@ -9516,7 +9723,7 @@ void clif_parse_progressbar(int fd, struct map_session_data * sd)
sd->st->state = END;
sd->progressbar.npc_id = sd->progressbar.timeout = 0;
- npc_scriptcont(sd, npc_id);
+ npc_scriptcont(sd, npc_id, false);
}
@@ -9529,14 +9736,14 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd)
short x, y;
if (pc_isdead(sd)) {
- clif_clearunit_area(&sd->bl, CLR_DEAD);
+ clif->clearunit_area(&sd->bl, CLR_DEAD);
return;
}
if (sd->sc.opt1 && ( sd->sc.opt1 == OPT1_STONEWAIT || sd->sc.opt1 == OPT1_BURNING ))
; //You CAN walk on this OPT1 value.
else if( sd->progressbar.npc_id )
- clif_progressbar_abort(sd);
+ clif->progressbar_abort(sd);
else if (pc_cant_act(sd))
return;
@@ -9545,7 +9752,7 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd)
pc_delinvincibletimer(sd);
- RFIFOPOS(fd, packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0], &x, &y, NULL);
+ RFIFOPOS(fd, packet_db[RFIFOW(fd,0)].pos[0], &x, &y, NULL);
//Set last idle time... [Skotlex]
sd->idletime = last_tick;
@@ -9582,9 +9789,9 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd)
(!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
{
set_eof(fd);
- clif_disconnect_ack(sd, 0);
+ clif->disconnect_ack(sd, 0);
} else {
- clif_disconnect_ack(sd, 1);
+ clif->disconnect_ack(sd, 1);
}
}
@@ -9595,7 +9802,7 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd)
/// There are various variants of this packet, some of them have padding between fields.
void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd)
{
- int id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+ int id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
struct block_list* bl;
//struct status_change *sc;
@@ -9625,9 +9832,16 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd)
}
*/
- clif_charnameack(fd, bl);
+ clif->charnameack(fd, bl);
+}
+int clif_undisguise_timer(int tid, unsigned int tick, int id, intptr_t data) {
+ struct map_session_data * sd;
+ if( (sd = map_id2sd(id)) && sd->fontcolor && sd->disguise == sd->status.class_ ) {
+ pc_disguise(sd,-1);
+ }
+ sd->fontcolor_tid = INVALID_TIMER;
+ return 0;
}
-
/// Validates and processes global messages
/// 008c <packet len>.W <text>.?B (<name> : <message>) 00 (CZ_REQUEST_CHAT)
@@ -9643,21 +9857,54 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
bool is_fake;
// validate packet and retrieve name and message
- if( !clif_process_message(sd, 0, &name, &namelen, &message, &messagelen) )
+ if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
- if( is_atcommand(fd, sd, message, 1) )
+ if( atcommand->parse(fd, sd, message, 1) )
return;
if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
return;
- if( battle_config.min_chat_delay )
- { //[Skotlex]
+ if( battle_config.min_chat_delay ) { //[Skotlex]
if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
return;
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
}
+
+ if( sd->gcbind ) {
+ clif->chsys_send(sd->gcbind,sd,message);
+ return;
+ } else if ( sd->fontcolor && !sd->chatID ) {
+ char mout[200];
+ unsigned char mylen = 1;
+
+ if( sd->disguise == -1 ) {
+ pc_disguise(sd,sd->status.class_);
+ if( pc_isdead(sd) )
+ clif_clearunit_single(-sd->bl.id, CLR_DEAD, sd->fd);
+ sd->fontcolor_tid = add_timer(gettick()+5000, clif->undisguise_timer, sd->bl.id, 0);
+ } else if ( sd->disguise == sd->status.class_ && sd->fontcolor_tid != INVALID_TIMER ) {
+ const struct TimerData *timer;
+ if( (timer = get_timer(sd->fontcolor_tid)) ) {
+ settick_timer(sd->fontcolor_tid, timer->tick+5000);
+ }
+ }
+
+ mylen += snprintf(mout, 200, "%s : %s",sd->fakename[0]?sd->fakename:sd->status.name,message);
+
+ WFIFOHEAD(fd,mylen + 12);
+ WFIFOW(fd,0) = 0x2C1;
+ WFIFOW(fd,2) = mylen + 12;
+ WFIFOL(fd,4) = sd->bl.id;
+ WFIFOL(fd,8) = hChSys.colors[sd->fontcolor - 1];
+ safestrncpy((char*)WFIFOP(fd,12), mout, mylen);
+ clif->send(WFIFOP(fd,0), WFIFOW(fd,2), &sd->bl, AREA_WOS);
+ WFIFOL(fd,4) = -sd->bl.id;
+ WFIFOSET(fd, mylen + 12);
+ return;
+ }
+
/**
* Fake Name Design by FatalEror (bug report #9)
**/
@@ -9675,7 +9922,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
WFIFOL(fd,4) = sd->bl.id;
safestrncpy((char*)WFIFOP(fd,8), is_fake ? fakename : text, textlen);
//FIXME: chat has range of 9 only
- clif_send(WFIFOP(fd,0), WFIFOW(fd,2), &sd->bl, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC);
+ clif->send(WFIFOP(fd,0), WFIFOW(fd,2), &sd->bl, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC);
// send back message to the speaker
if( is_fake ) {
@@ -9694,7 +9941,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
#endif
// Chat logging type 'O' / Global Chat
- log_chat(LOG_CHAT_GLOBAL, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
+ logs->chat(LOG_CHAT_GLOBAL, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
}
@@ -9708,8 +9955,8 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd)
map_name = (char*)RFIFOP(fd,2);
map_name[MAP_NAME_LENGTH_EXT-1]='\0';
- sprintf(command, "%cmapmove %s %d %d", atcommand_symbol, map_name, RFIFOW(fd,18), RFIFOW(fd,20));
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%cmapmove %s %d %d", atcommand->at_symbol, map_name, RFIFOW(fd,18), RFIFOW(fd,20));
+ atcommand->parse(fd, sd, command, 1);
}
@@ -9737,12 +9984,12 @@ void clif_changed_dir(struct block_list *bl, enum send_target target)
WBUFW(buf,6) = bl->type==BL_PC?((TBL_PC*)bl)->head_dir:0;
WBUFB(buf,8) = unit_getdir(bl);
- clif_send(buf, packet_len(0x9c), bl, target);
+ clif->send(buf, packet_len(0x9c), bl, target);
if (disguised(bl)) {
WBUFL(buf,2) = -bl->id;
WBUFW(buf,6) = 0;
- clif_send(buf, packet_len(0x9c), bl, SELF);
+ clif->send(buf, packet_len(0x9c), bl, SELF);
}
}
@@ -9755,11 +10002,11 @@ void clif_parse_ChangeDir(int fd, struct map_session_data *sd)
{
unsigned char headdir, dir;
- headdir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- dir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
+ headdir = RFIFOB(fd,packet_db[RFIFOW(fd,0)].pos[0]);
+ dir = RFIFOB(fd,packet_db[RFIFOW(fd,0)].pos[1]);
pc_setdir(sd, dir, headdir);
- clif_changed_dir(&sd->bl, AREA_WOS);
+ clif->changed_dir(&sd->bl, AREA_WOS);
}
@@ -9769,36 +10016,34 @@ void clif_parse_ChangeDir(int fd, struct map_session_data *sd)
/// @see enum emotion_type
void clif_parse_Emotion(int fd, struct map_session_data *sd)
{
- int emoticon = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+ int emoticon = RFIFOB(fd,packet_db[RFIFOW(fd,0)].pos[0]);
if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 2) {
if (emoticon == E_MUTE) {// prevent use of the mute emote [Valaris]
- clif_skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 1);
+ clif->skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 1);
return;
}
// fix flood of emotion icon (ro-proxy): flood only the hacker player
if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
sd->emotionlasttime = time(NULL);
- clif_skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 1);
+ clif->skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 1);
return;
}
sd->emotionlasttime = time(NULL);
- if(battle_config.client_reshuffle_dice && emoticon>=E_DICE1 && emoticon<=E_DICE6)
- {// re-roll dice
+ if(battle_config.client_reshuffle_dice && emoticon>=E_DICE1 && emoticon<=E_DICE6) {// re-roll dice
emoticon = rnd()%6+E_DICE1;
}
- clif_emotion(&sd->bl, emoticon);
+ clif->emotion(&sd->bl, emoticon);
} else
- clif_skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 1);
+ clif->skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 1);
}
/// Amount of currently online players, reply to /w /who (ZC_USER_COUNT).
/// 00c2 <count>.L
-void clif_user_count(struct map_session_data* sd, int count)
-{
+void clif_user_count(struct map_session_data* sd, int count) {
int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0xc2));
@@ -9813,14 +10058,14 @@ void clif_user_count(struct map_session_data* sd, int count)
/// 00c1
void clif_parse_HowManyConnections(int fd, struct map_session_data *sd)
{
- clif_user_count(sd, map_getusers());
+ clif->user_count(sd, map_getusers());
}
void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick)
{
if (pc_isdead(sd)) {
- clif_clearunit_area(&sd->bl, CLR_DEAD);
+ clif->clearunit_area(&sd->bl, CLR_DEAD);
return;
}
@@ -9839,69 +10084,179 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
if(target_id<0 && -target_id == sd->bl.id) // for disguises [Valaris]
target_id = sd->bl.id;
- switch(action_type)
- {
- case 0x00: // once attack
- case 0x07: // continuous attack
+ switch(action_type) {
+ case 0x00: // once attack
+ case 0x07: // continuous attack
- if( pc_cant_act(sd) || sd->sc.option&OPTION_HIDE )
- return;
+ if( pc_cant_act(sd) || sd->sc.option&OPTION_HIDE )
+ return;
- if( sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER) )
- return;
+ if( sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK) )
+ return;
- if( sd->sc.data[SC_BASILICA] || sd->sc.data[SC__SHADOWFORM] )
- return;
+ if( sd->sc.data[SC_BASILICA] || sd->sc.data[SC__SHADOWFORM] )
+ return;
+
+ if (!battle_config.sdelay_attack_enable && pc_checkskill(sd, SA_FREECAST) <= 0) {
+ if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) {
+ clif->skill_fail(sd, 1, USESKILL_FAIL_SKILLINTERVAL, 0);
+ return;
+ }
+ }
+
+ pc_delinvincibletimer(sd);
+ sd->idletime = last_tick;
+ unit_attack(&sd->bl, target_id, action_type != 0);
+ break;
+ case 0x02: // sitdown
+ if (battle_config.basic_skill_check && pc_checkskill(sd, NV_BASIC) < 3) {
+ clif->skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 2);
+ break;
+ }
- if (!battle_config.sdelay_attack_enable && pc_checkskill(sd, SA_FREECAST) <= 0) {
- if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) {
- clif_skill_fail(sd, 1, USESKILL_FAIL_SKILLINTERVAL, 0);
+ if(pc_issit(sd)) {
+ //Bugged client? Just refresh them.
+ clif->sitting(&sd->bl);
return;
}
- }
- pc_delinvincibletimer(sd);
- sd->idletime = last_tick;
- unit_attack(&sd->bl, target_id, action_type != 0);
- break;
- case 0x02: // sitdown
- if (battle_config.basic_skill_check && pc_checkskill(sd, NV_BASIC) < 3) {
- clif_skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 2);
- break;
- }
+ if (sd->ud.skilltimer != INVALID_TIMER || (sd->sc.opt1 && sd->sc.opt1 != OPT1_BURNING ))
+ break;
- if(pc_issit(sd)) {
- //Bugged client? Just refresh them.
- clif_sitting(&sd->bl);
- return;
- }
+ if (sd->sc.count && (
+ sd->sc.data[SC_DANCING] ||
+ (sd->sc.data[SC_GRAVITATION] && sd->sc.data[SC_GRAVITATION]->val3 == BCT_SELF)
+ )) //No sitting during these states either.
+ break;
- if (sd->ud.skilltimer != INVALID_TIMER || (sd->sc.opt1 && sd->sc.opt1 != OPT1_BURNING ))
- break;
+ pc_setsit(sd);
+ skill->sit(sd,1);
+ clif->sitting(&sd->bl);
+ break;
+ case 0x03: // standup
+ if (!pc_issit(sd)) {
+ //Bugged client? Just refresh them.
+ clif->standing(&sd->bl);
+ return;
+ }
+ pc_setstand(sd);
+ skill->sit(sd,0);
+ clif->standing(&sd->bl);
+ break;
+ }
+}
- if (sd->sc.count && (
- sd->sc.data[SC_DANCING] ||
- (sd->sc.data[SC_GRAVITATION] && sd->sc.data[SC_GRAVITATION]->val3 == BCT_SELF)
- )) //No sitting during these states either.
+void clif_hercules_chsys_left(struct hChSysCh *channel, struct map_session_data *sd) {
+ unsigned char i;
+
+ if ( !idb_remove(channel->users,sd->status.char_id) )
+ return;
+
+ if( channel == sd->gcbind )
+ sd->gcbind = NULL;
+
+ if( !db_size(channel->users) && channel->type == hChSys_PRIVATE ) {
+ clif->chsys_delete(channel);
+ } else if( !hChSys.closing && (channel->opt & hChSys_OPT_ANNOUNCE_JOIN) ) {
+ char message[60];
+ sprintf(message, "#%s '%s' left",channel->name,sd->status.name);
+ clif->chsys_msg(channel,sd,message);
+ }
+
+ for( i = 0; i < sd->channel_count; i++ ) {
+ if( sd->channels[i] == channel ) {
+ sd->channels[i] = NULL;
break;
-
- pc_setsit(sd);
- skill_sit(sd,1);
- clif_sitting(&sd->bl);
- break;
- case 0x03: // standup
- if (!pc_issit(sd)) {
- //Bugged client? Just refresh them.
- clif_standing(&sd->bl);
- return;
}
- pc_setstand(sd);
- skill_sit(sd,0);
- clif_standing(&sd->bl);
- break;
}
+
+ if( i < sd->channel_count ) {
+ unsigned char cursor = 0;
+ for( i = 0; i < sd->channel_count; i++ ) {
+ if( sd->channels[i] == NULL )
+ continue;
+ if( cursor != i ) {
+ sd->channels[cursor] = sd->channels[i];
+ }
+ cursor++;
+ }
+ if ( !(sd->channel_count = cursor) ) {
+ aFree(sd->channels);
+ sd->channels = NULL;
+ }
+ }
+
}
+void clif_hercules_chsys_quitg(struct map_session_data *sd) {
+ unsigned char i;
+ struct hChSysCh *channel = NULL;
+
+ for( i = 0; i < sd->channel_count; i++ ) {
+ if( (channel = sd->channels[i] ) != NULL && channel->type == hChSys_ALLY ) {
+
+ if ( !idb_remove(channel->users,sd->status.char_id) )
+ continue;
+
+ if( channel == sd->gcbind )
+ sd->gcbind = NULL;
+
+ if( !db_size(channel->users) && channel->type == hChSys_PRIVATE ) {
+ clif->chsys_delete(channel);
+ } else if( !hChSys.closing && (channel->opt & hChSys_OPT_ANNOUNCE_JOIN) ) {
+ char message[60];
+ sprintf(message, "#%s '%s' left",channel->name,sd->status.name);
+ clif->chsys_msg(channel,sd,message);
+ }
+ sd->channels[i] = NULL;
+ }
+ }
+
+ if( i < sd->channel_count ) {
+ unsigned char cursor = 0;
+ for( i = 0; i < sd->channel_count; i++ ) {
+ if( sd->channels[i] == NULL )
+ continue;
+ if( cursor != i ) {
+ sd->channels[cursor] = sd->channels[i];
+ }
+ cursor++;
+ }
+ if ( !(sd->channel_count = cursor) ) {
+ aFree(sd->channels);
+ sd->channels = NULL;
+ }
+ }
+
+}
+
+
+void clif_hercules_chsys_quit(struct map_session_data *sd) {
+ unsigned char i;
+ struct hChSysCh *channel = NULL;
+
+ for( i = 0; i < sd->channel_count; i++ ) {
+ if( (channel = sd->channels[i] ) != NULL ) {
+ idb_remove(channel->users,sd->status.char_id);
+
+ if( channel == sd->gcbind )
+ sd->gcbind = NULL;
+
+ if( !db_size(channel->users) && channel->type == hChSys_PRIVATE ) {
+ clif->chsys_delete(channel);
+ } else if( !hChSys.closing && (channel->opt & hChSys_OPT_ANNOUNCE_JOIN) ) {
+ char message[60];
+ sprintf(message, "#%s '%s' left",channel->name,sd->status.name);
+ clif->chsys_msg(channel,sd,message);
+ }
+
+ }
+ }
+
+ sd->channel_count = 0;
+ aFree(sd->channels);
+ sd->channels = NULL;
+}
/// Request for an action.
/// 0089 <target id>.L <action>.B (CZ_REQUEST_ACT)
@@ -9916,9 +10271,9 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
/// There are various variants of this packet, some of them have padding between fields.
void clif_parse_ActionRequest(int fd, struct map_session_data *sd)
{
- clif_parse_ActionRequest_sub(sd,
- RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]),
- RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
+ clif->pActionRequest_sub(sd,
+ RFIFOB(fd,packet_db[RFIFOW(fd,0)].pos[1]),
+ RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]),
gettick()
);
}
@@ -9929,22 +10284,21 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd)
/// type:
/// 0 = restart (respawn)
/// 1 = char-select (disconnect)
-void clif_parse_Restart(int fd, struct map_session_data *sd)
-{
+void clif_parse_Restart(int fd, struct map_session_data *sd) {
switch(RFIFOB(fd,2)) {
- case 0x00:
- pc_respawn(sd,CLR_RESPAWN);
- break;
- case 0x01:
- /* Rovert's Prevent logout option - Fixed [Valaris] */
- if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] &&
- (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
- { //Send to char-server for character selection.
- chrif_charselectreq(sd, session[fd]->client_addr);
- } else {
- clif_disconnect_ack(sd, 1);
- }
- break;
+ case 0x00:
+ pc_respawn(sd,CLR_RESPAWN);
+ break;
+ case 0x01:
+ /* Rovert's Prevent logout option - Fixed [Valaris] */
+ if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] &&
+ (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
+ { //Send to char-server for character selection.
+ chrif_charselectreq(sd, session[fd]->client_addr);
+ } else {
+ clif->disconnect_ack(sd, 1);
+ }
+ break;
}
}
@@ -9960,10 +10314,10 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
int namelen, messagelen;
// validate packet and retrieve name and message
- if( !clif_process_message(sd, 1, &target, &namelen, &message, &messagelen) )
+ if( !clif->process_message(sd, 1, &target, &namelen, &message, &messagelen) )
return;
- if ( is_atcommand(fd, sd, message, 1) )
+ if ( atcommand->parse(fd, sd, message, 1) )
return;
if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT))
@@ -9977,13 +10331,12 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
}
// Chat logging type 'W' / Whisper
- log_chat(LOG_CHAT_WHISPER, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, target, message);
+ logs->chat(LOG_CHAT_WHISPER, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, target, message);
//-------------------------------------------------------//
// Lordalfa - Paperboy - To whisper NPC commands //
//-------------------------------------------------------//
- if (target[0] && (strncasecmp(target,"NPC:",4) == 0) && (strlen(target) > 4))
- {
+ if (target[0] && (strncasecmp(target,"NPC:",4) == 0) && (strlen(target) > 4)) {
char* str = target+4; //Skip the NPC: string part.
struct npc_data* npc;
if ((npc = npc_name2id(str))) {
@@ -10018,15 +10371,48 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
return;
}
- } else if(strcmpi(target, main_chat_nick) == 0) { // Main chat [LuzZza]
- if(!sd->state.mainchat)
- clif_displaymessage(fd, msg_txt(388)); // You should enable main chat with "@main on" command.
- else {
- // send the main message using inter-server system
- intif_main_message( sd, message );
+ } else if( target[0] == '#' ) {
+ struct hChSysCh *channel = NULL;
+ char* chname = target;
+
+ chname++;
+
+ if( hChSys.local && strcmpi(chname, hChSys.local_name) == 0 ) {
+ if( !map[sd->bl.m].channel ) {
+ clif->chsys_mjoin(sd);
+ }
+ channel = map[sd->bl.m].channel;
+ } else if( hChSys.ally && sd->status.guild_id && strcmpi(chname, hChSys.ally_name) == 0 ) {
+ struct guild *g = sd->guild;
+ if( !g ) return;
+ channel = (struct hChSysCh *)g->channel;
+ }
+ if( channel || (channel = strdb_get(clif->channel_db,chname)) ) {
+ unsigned char k;
+ for( k = 0; k < sd->channel_count; k++ ) {
+ if( sd->channels[k] == channel )
+ break;
+ }
+ if( k < sd->channel_count ) {
+ clif->chsys_send(channel,sd,message);
+ } else if( channel->pass[0] == '\0' && !(channel->banned && idb_exists(channel->banned, sd->status.account_id)) ) {
+ if( channel->type == hChSys_ALLY ) {
+ struct guild *g = sd->guild, *sg = NULL;
+ int k;
+ for (k = 0; k < MAX_GUILDALLIANCE; k++) {
+ if( g->alliance[k].opposition == 0 && g->alliance[k].guild_id && (sg = guild->search(g->alliance[k].guild_id) ) ) {
+ if( !(((struct hChSysCh*)sg->channel)->banned && idb_exists(((struct hChSysCh*)sg->channel)->banned, sd->status.account_id)))
+ clif->chsys_join((struct hChSysCh *)sg->channel,sd);
+ }
+ }
+ }
+ clif->chsys_join(channel,sd);
+ clif->chsys_send(channel,sd,message);
+ } else {
+ clif->message(fd, msg_txt(1402));
+ }
+ return;
}
-
- return;
}
// searching destination character
@@ -10045,9 +10431,9 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
// if player ignores everyone
if (dstsd->state.ignoreAll) {
if (dstsd->sc.option & OPTION_INVISIBLE && pc_get_group_level(sd) < pc_get_group_level(dstsd))
- clif_wis_end(fd, 1); // 1: target character is not loged in
+ clif->wis_end(fd, 1); // 1: target character is not loged in
else
- clif_wis_end(fd, 3); // 3: everyone ignored by target
+ clif->wis_end(fd, 3); // 3: everyone ignored by target
return;
}
@@ -10055,22 +10441,22 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
if( dstsd->state.autotrade == 1 ) {
char output[256];
sprintf(output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name);
- clif_wis_message(fd, wisp_server_name, output, strlen(output) + 1);
+ clif->wis_message(fd, wisp_server_name, output, strlen(output) + 1);
return;
}
// if player ignores the source character
ARR_FIND(0, MAX_IGNORE_LIST, i, dstsd->ignore[i].name[0] == '\0' || strcmp(dstsd->ignore[i].name, sd->status.name) == 0);
if(i < MAX_IGNORE_LIST && dstsd->ignore[i].name[0] != '\0') { // source char present in ignore list
- clif_wis_end(fd, 2); // 2: ignored by target
+ clif->wis_end(fd, 2); // 2: ignored by target
return;
}
// notify sender of success
- clif_wis_end(fd, 0); // 0: success to send wisper
+ clif->wis_end(fd, 0); // 0: success to send wisper
// Normal message
- clif_wis_message(dstsd->fd, sd->status.name, message, messagelen);
+ clif->wis_message(dstsd->fd, sd->status.name, message, messagelen);
}
@@ -10085,8 +10471,8 @@ void clif_parse_Broadcast(int fd, struct map_session_data* sd) {
// as the length varies depending on the command used, just block unreasonably long strings
mes_len_check(msg, len, CHAT_SIZE_MAX);
- sprintf(command, "%ckami %s", atcommand_symbol, msg);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%ckami %s", atcommand->at_symbol, msg);
+ atcommand->parse(fd, sd, command, 1);
}
@@ -10099,20 +10485,27 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd)
struct flooritem_data *fitem;
int map_object_id;
- map_object_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+ map_object_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
fitem = (struct flooritem_data*)map_id2bl(map_object_id);
do {
if (pc_isdead(sd)) {
- clif_clearunit_area(&sd->bl, CLR_DEAD);
+ clif->clearunit_area(&sd->bl, CLR_DEAD);
break;
}
if (fitem == NULL || fitem->bl.type != BL_ITEM || fitem->bl.m != sd->bl.m)
break;
- if( sd->sc.cant.pickup )
+ if( sd->sc.count && (
+ sd->sc.data[SC_HIDING] ||
+ sd->sc.data[SC_CLOAKING] ||
+ sd->sc.data[SC_TRICKDEAD] ||
+ sd->sc.data[SC_BLADESTOP] ||
+ sd->sc.data[SC_CLOAKINGEXCEED] ||
+ (sd->sc.data[SC_NOCHAT] &&sd->sc.data[SC_NOCHAT]->val1&MANNER_NOITEM)
+ ) )
break;
if (pc_cant_act(sd))
@@ -10124,7 +10517,7 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd)
return;
} while (0);
// Client REQUIRES a fail packet or you can no longer pick items.
- clif_additem(sd,0,0,6);
+ clif->additem(sd,0,0,6);
}
@@ -10134,14 +10527,14 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd)
/// There are various variants of this packet, some of them have padding between fields.
void clif_parse_DropItem(int fd, struct map_session_data *sd)
{
- int item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
- int item_amount = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
+ int item_index = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0])-2;
+ int item_amount = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[1]);
for(;;) {
if (pc_isdead(sd))
break;
- if (pc_cant_act(sd))
+ if ( pc_cant_act2(sd) )
break;
if (sd->sc.count && (
@@ -10158,7 +10551,7 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd)
}
//Because the client does not like being ignored.
- clif_dropitem(sd, item_index,0);
+ clif->dropitem(sd, item_index,0);
}
@@ -10171,26 +10564,21 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd)
int n;
if (pc_isdead(sd)) {
- clif_clearunit_area(&sd->bl, CLR_DEAD);
+ clif->clearunit_area(&sd->bl, CLR_DEAD);
return;
}
- //This flag enables you to use items while in an NPC. [Skotlex]
- if (sd->npc_id) {
- if (sd->npc_id != sd->npc_item_flag)
- return;
- }
- else if (pc_istrading(sd))
+ if ( (!sd->npc_id && pc_istrading(sd)) || sd->chatID )
return;
//Whether the item is used or not is irrelevant, the char ain't idle. [Skotlex]
sd->idletime = last_tick;
- n = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
+ n = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0])-2;
if(n <0 || n >= MAX_INVENTORY)
return;
if (!pc_useitem(sd,n))
- clif_useitemack(sd,n,0,false); //Send an empty ack packet or the client gets stuck.
+ clif->useitemack(sd,n,0,false); //Send an empty ack packet or the client gets stuck.
}
@@ -10201,23 +10589,23 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd)
int index;
if(pc_isdead(sd)) {
- clif_clearunit_area(&sd->bl,CLR_DEAD);
+ clif->clearunit_area(&sd->bl,CLR_DEAD);
return;
}
index = RFIFOW(fd,2)-2;
if (index < 0 || index >= MAX_INVENTORY)
return; //Out of bounds check.
- if(sd->npc_id) {
- if (sd->npc_id != sd->npc_item_flag)
+ if( sd->npc_id ) {
+ if ( !sd->npc_item_flag )
return;
- } else if (sd->state.storage_flag || sd->sc.opt1)
+ } else if ( sd->state.storage_flag || sd->sc.opt1 )
; //You can equip/unequip stuff while storage is open/under status changes
- else if (pc_cant_act(sd))
+ else if ( pc_cant_act2(sd) )
return;
if(!sd->status.inventory[index].identify) {
- clif_equipitemack(sd,index,0,0); // fail
+ clif->equipitemack(sd,index,0,0); // fail
return;
}
@@ -10236,6 +10624,94 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd)
pc_equipitem(sd,index,RFIFOW(fd,4));
}
+void clif_hercules_chsys_delete(struct hChSysCh *channel) {
+ if( db_size(channel->users) && !hChSys.closing ) {
+ DBIterator *iter;
+ struct map_session_data *sd;
+ unsigned char i;
+ iter = db_iterator(channel->users);
+ for( sd = dbi_first(iter); dbi_exists(iter); sd = dbi_next(iter) ) {
+ for( i = 0; i < sd->channel_count; i++ ) {
+ if( sd->channels[i] == channel ) {
+ sd->channels[i] = NULL;
+ break;
+ }
+ }
+ if( i < sd->channel_count ) {
+ unsigned char cursor = 0;
+ for( i = 0; i < sd->channel_count; i++ ) {
+ if( sd->channels[i] == NULL )
+ continue;
+ if( cursor != i ) {
+ sd->channels[cursor] = sd->channels[i];
+ }
+ cursor++;
+ }
+ if ( !(sd->channel_count = cursor) ) {
+ aFree(sd->channels);
+ sd->channels = NULL;
+ }
+ }
+ }
+ dbi_destroy(iter);
+ }
+ if( channel->banned ) {
+ db_destroy(channel->banned);
+ channel->banned = NULL;
+ }
+ db_destroy(channel->users);
+ if( channel->m ) {
+ map[channel->m].channel = NULL;
+ aFree(channel);
+ } else if ( channel->type == hChSys_ALLY )
+ aFree(channel);
+ else if( !hChSys.closing )
+ strdb_remove(clif->channel_db, channel->name);
+}
+void clif_hercules_chsys_gjoin(struct guild *g1,struct guild *g2) {
+ struct map_session_data *sd;
+ struct hChSysCh *channel;
+ int j;
+
+ if( (channel = (struct hChSysCh*)g1->channel) ) {
+ for(j = 0; j < g2->max_member; j++) {
+ if( (sd = g2->member[j].sd) != NULL ) {
+ if( !(((struct hChSysCh*)g1->channel)->banned && idb_exists(((struct hChSysCh*)g1->channel)->banned, sd->status.account_id)))
+ clif->chsys_join(channel,sd);
+ }
+ }
+ }
+
+ if( (channel = (struct hChSysCh*)g2->channel) ) {
+ for(j = 0; j < g1->max_member; j++) {
+ if( (sd = g1->member[j].sd) != NULL ) {
+ if( !(((struct hChSysCh*)g2->channel)->banned && idb_exists(((struct hChSysCh*)g2->channel)->banned, sd->status.account_id)))
+ clif->chsys_join(channel,sd);
+ }
+ }
+ }
+}
+void clif_hercules_chsys_gleave(struct guild *g1,struct guild *g2) {
+ struct map_session_data *sd;
+ struct hChSysCh *channel;
+ int j;
+
+ if( (channel = (struct hChSysCh*)g1->channel) ) {
+ for(j = 0; j < g2->max_member; j++) {
+ if( (sd = g2->member[j].sd) != NULL ) {
+ clif->chsys_left(channel,sd);
+ }
+ }
+ }
+
+ if( (channel = (struct hChSysCh*)g2->channel) ) {
+ for(j = 0; j < g1->max_member; j++) {
+ if( (sd = g1->member[j].sd) != NULL ) {
+ clif->chsys_left(channel,sd);
+ }
+ }
+ }
+}
/// Request to take off an equip (CZ_REQ_TAKEOFF_EQUIP).
/// 00ab <index>.W
@@ -10244,13 +10720,16 @@ void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
int index;
if(pc_isdead(sd)) {
- clif_clearunit_area(&sd->bl,CLR_DEAD);
+ clif->clearunit_area(&sd->bl,CLR_DEAD);
return;
}
- if (sd->state.storage_flag || sd->sc.opt1)
+ if( sd->npc_id ) {
+ if ( !sd->npc_item_flag )
+ return;
+ } else if ( sd->state.storage_flag || sd->sc.opt1 )
; //You can equip/unequip stuff while storage is open/under status changes
- else if (pc_cant_act(sd))
+ else if ( pc_cant_act2(sd) )
return;
index = RFIFOW(fd,2)-2;
@@ -10272,7 +10751,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
return;
}
- if (pc_cant_act(sd))
+ if ( pc_cant_act2(sd) )
return;
bl = map_id2bl(RFIFOL(fd,2));
@@ -10280,7 +10759,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
switch (bl->type) {
case BL_MOB:
case BL_PC:
- clif_parse_ActionRequest_sub(sd, 0x07, bl->id, gettick());
+ clif->pActionRequest_sub(sd, 0x07, bl->id, gettick());
break;
case BL_NPC:
if( bl->m != -1 )// the user can't click floating npcs directly (hack attempt)
@@ -10310,8 +10789,7 @@ void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd)
/// 1 = "You do not have enough zeny."
/// 2 = "You are over your Weight Limit."
/// 3 = "Out of the maximum capacity, you have too many items."
-void clif_npc_buy_result(struct map_session_data* sd, unsigned char result)
-{
+void clif_npc_buy_result(struct map_session_data* sd, unsigned char result) {
int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0xca));
@@ -10336,7 +10814,7 @@ void clif_parse_NpcBuyListSend(int fd, struct map_session_data* sd)
sd->npc_shopid = 0; //Clear shop data.
- clif_npc_buy_result(sd, result);
+ clif->npc_buy_result(sd, result);
}
@@ -10345,8 +10823,7 @@ void clif_parse_NpcBuyListSend(int fd, struct map_session_data* sd)
/// result:
/// 0 = "The deal has successfully completed."
/// 1 = "The deal has failed."
-void clif_npc_sell_result(struct map_session_data* sd, unsigned char result)
-{
+void clif_npc_sell_result(struct map_session_data* sd, unsigned char result) {
int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0xcb));
@@ -10373,7 +10850,7 @@ void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
sd->npc_shopid = 0; //Clear shop data.
- clif_npc_sell_result(sd, fail);
+ clif->npc_sell_result(sd, fail);
}
@@ -10395,7 +10872,15 @@ void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd)
if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM)
return;
if(battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 4) {
- clif_skill_fail(sd,1,USESKILL_FAIL_LEVEL,3);
+ clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,3);
+ return;
+ }
+ if( npc_isnear(&sd->bl) ) {
+ // uncomment for more verbose message.
+ //char output[150];
+ //sprintf(output, msg_txt(662), battle_config.min_npc_vendchat_distance);
+ //clif_displaymessage(sd->fd, output);
+ clif->skill_fail(sd,1,USESKILL_FAIL_THERE_ARE_NPC_AROUND,0);
return;
}
@@ -10475,16 +10960,15 @@ void clif_parse_ChatLeave(int fd, struct map_session_data* sd)
//Handles notifying asker and rejecter of what has just ocurred.
//Type is used to determine the correct msg_txt to use:
//0:
-static void clif_noask_sub(struct map_session_data *src, struct map_session_data *target, int type)
-{
+void clif_noask_sub(struct map_session_data *src, struct map_session_data *target, int type) {
const char* msg;
char output[256];
// Your request has been rejected by autoreject option.
msg = msg_txt(392);
- clif_disp_onlyself(src, msg, strlen(msg));
+ clif->disp_onlyself(src, msg, strlen(msg));
//Notice that a request was rejected.
snprintf(output, 256, msg_txt(393+type), src->status.name, 256);
- clif_disp_onlyself(target, output, strlen(output));
+ clif->disp_onlyself(target, output, strlen(output));
}
@@ -10501,13 +10985,12 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
// @noask [LuzZza]
if(t_sd && t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 0);
+ clif->noask_sub(sd, t_sd, 0);
return;
}
- if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 1)
- {
- clif_skill_fail(sd,1,USESKILL_FAIL_LEVEL,0);
+ if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 1) {
+ clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,0);
return;
}
@@ -10662,36 +11145,34 @@ void clif_parse_SkillUp(int fd,struct map_session_data *sd)
pc_skillup(sd,RFIFOW(fd,2));
}
-static void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id)
+void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id)
{
int lv;
if( !hd )
return;
- if( skillnotok_hom(skill_id, hd) )
+ if( skill->not_ok_hom(skill_id, hd) )
return;
- if( hd->bl.id != target_id && skill_get_inf(skill_id)&INF_SELF_SKILL )
+ if( hd->bl.id != target_id && skill->get_inf(skill_id)&INF_SELF_SKILL )
target_id = hd->bl.id;
- if( hd->ud.skilltimer != INVALID_TIMER )
- {
+ if( hd->ud.skilltimer != INVALID_TIMER ) {
if( skill_id != SA_CASTCANCEL && skill_id != SO_SPELLFIST ) return;
- }
- else if( DIFF_TICK(tick, hd->ud.canact_tick) < 0 )
+ } else if( DIFF_TICK(tick, hd->ud.canact_tick) < 0 )
return;
- lv = merc_hom_checkskill(hd, skill_id);
+ lv = homun->checkskill(hd, skill_id);
if( skill_lv > lv )
skill_lv = lv;
if( skill_lv )
unit_skilluse_id(&hd->bl, target_id, skill_id, skill_lv);
}
-static void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo)
+void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo)
{
int lv;
if( !hd )
return;
- if( skillnotok_hom(skill_id, hd) )
+ if( skill->not_ok_hom(skill_id, hd) )
return;
if( hd->ud.skilltimer != INVALID_TIMER ) {
if( skill_id != SA_CASTCANCEL && skill_id != SO_SPELLFIST ) return;
@@ -10700,28 +11181,26 @@ static void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_ses
if( hd->sc.data[SC_BASILICA] )
return;
- lv = merc_hom_checkskill(hd, skill_id);
+ lv = homun->checkskill(hd, skill_id);
if( skill_lv > lv )
skill_lv = lv;
if( skill_lv )
unit_skilluse_pos(&hd->bl, x, y, skill_id, skill_lv);
}
-static void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id)
+void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id)
{
int lv;
if( !md )
return;
- if( skillnotok_mercenary(skill_id, md) )
+ if( skill->not_ok_mercenary(skill_id, md) )
return;
- if( md->bl.id != target_id && skill_get_inf(skill_id)&INF_SELF_SKILL )
+ if( md->bl.id != target_id && skill->get_inf(skill_id)&INF_SELF_SKILL )
target_id = md->bl.id;
- if( md->ud.skilltimer != INVALID_TIMER )
- {
+ if( md->ud.skilltimer != INVALID_TIMER ) {
if( skill_id != SA_CASTCANCEL && skill_id != SO_SPELLFIST ) return;
- }
- else if( DIFF_TICK(tick, md->ud.canact_tick) < 0 )
+ } else if( DIFF_TICK(tick, md->ud.canact_tick) < 0 )
return;
lv = mercenary_checkskill(md, skill_id);
@@ -10731,18 +11210,17 @@ static void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct
unit_skilluse_id(&md->bl, target_id, skill_id, skill_lv);
}
-static void clif_parse_UseSkillToPos_mercenary(struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo)
+void clif_parse_UseSkillToPos_mercenary(struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo)
{
int lv;
if( !md )
return;
- if( skillnotok_mercenary(skill_id, md) )
+ if( skill->not_ok_mercenary(skill_id, md) )
return;
if( md->ud.skilltimer != INVALID_TIMER )
return;
- if( DIFF_TICK(tick, md->ud.canact_tick) < 0 )
- {
- clif_skill_fail(md->master, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0);
+ if( DIFF_TICK(tick, md->ud.canact_tick) < 0 ) {
+ clif->skill_fail(md->master, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0);
return;
}
@@ -10766,37 +11244,41 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
int tmp, target_id;
unsigned int tick = gettick();
- skill_lv = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- skill_id = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
- target_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
+ skill_lv = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0]);
+ skill_id = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[1]);
+ target_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[2]);
if( skill_lv < 1 ) skill_lv = 1; //No clue, I have seen the client do this with guild skills :/ [Skotlex]
- tmp = skill_get_inf(skill_id);
+ tmp = skill->get_inf(skill_id);
if (tmp&INF_GROUND_SKILL || !tmp)
return; //Using a ground/passive skill on a target? WRONG.
- if( skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE + MAX_HOMUNSKILL )
- {
- clif_parse_UseSkillToId_homun(sd->hd, sd, tick, skill_id, skill_lv, target_id);
+ if( skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE + MAX_HOMUNSKILL ) {
+ clif->pUseSkillToId_homun(sd->hd, sd, tick, skill_id, skill_lv, target_id);
return;
}
- if( skill_id >= MC_SKILLBASE && skill_id < MC_SKILLBASE + MAX_MERCSKILL )
- {
- clif_parse_UseSkillToId_mercenary(sd->md, sd, tick, skill_id, skill_lv, target_id);
+ if( skill_id >= MC_SKILLBASE && skill_id < MC_SKILLBASE + MAX_MERCSKILL ) {
+ clif->pUseSkillToId_mercenary(sd->md, sd, tick, skill_id, skill_lv, target_id);
return;
}
// Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
sd->idletime = last_tick;
+ if( sd->npc_id ){
+#ifdef RENEWAL
+ clif->msg(sd, 0x783); // TODO look for the client date that has this message.
+#endif
+ return;
+ }
if( pc_cant_act(sd) && skill_id != RK_REFRESH && !(skill_id == SR_GENTLETOUCH_CURE && (sd->sc.opt1 == OPT1_STONE || sd->sc.opt1 == OPT1_FREEZE || sd->sc.opt1 == OPT1_STUN)) )
return;
if( pc_issit(sd) )
return;
- if( skillnotok(skill_id, sd) )
+ if( skill->not_ok(skill_id, sd) )
return;
if( sd->bl.id != target_id && tmp&INF_SELF_SKILL )
@@ -10805,21 +11287,17 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
if( target_id < 0 && -target_id == sd->bl.id ) // for disguises [Valaris]
target_id = sd->bl.id;
- if( sd->ud.skilltimer != INVALID_TIMER )
- {
+ if( sd->ud.skilltimer != INVALID_TIMER ) {
if( skill_id != SA_CASTCANCEL && skill_id != SO_SPELLFIST )
return;
- }
- else if( DIFF_TICK(tick, sd->ud.canact_tick) < 0 )
- {
- if( sd->skillitem != skill_id )
- {
- clif_skill_fail(sd, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0);
+ } else if( DIFF_TICK(tick, sd->ud.canact_tick) < 0 ) {
+ if( sd->skillitem != skill_id ) {
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0);
return;
}
}
- if( sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER) )
+ if( sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK) )
return;
if( sd->sc.data[SC_BASILICA] && (skill_id != HP_BASILICA || sd->sc.data[SC_BASILICA]->val4 != sd->bl.id) )
@@ -10844,7 +11322,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
if( skill_id >= GD_SKILLBASE ) {
if( sd->state.gmaster_flag )
- skill_lv = guild_checkskill(sd->state.gmaster_flag, skill_id);
+ skill_lv = guild->checkskill(sd->state.gmaster_flag, skill_id);
else
skill_lv = 0;
} else {
@@ -10862,34 +11340,31 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
/*==========================================
* Client tells server he'd like to use AoE skill id 'skill_id' of level 'skill_lv' on 'x','y' location
*------------------------------------------*/
-static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 skill_lv, uint16 skill_id, short x, short y, int skillmoreinfo)
+void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 skill_lv, uint16 skill_id, short x, short y, int skillmoreinfo)
{
unsigned int tick = gettick();
- if( !(skill_get_inf(skill_id)&INF_GROUND_SKILL) )
+ if( !(skill->get_inf(skill_id)&INF_GROUND_SKILL) )
return; //Using a target skill on the ground? WRONG.
if( skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE + MAX_HOMUNSKILL ) {
- clif_parse_UseSkillToPos_homun(sd->hd, sd, tick, skill_id, skill_lv, x, y, skillmoreinfo);
+ clif->pUseSkillToPos_homun(sd->hd, sd, tick, skill_id, skill_lv, x, y, skillmoreinfo);
return;
}
- if( skill_id >= MC_SKILLBASE && skill_id < MC_SKILLBASE + MAX_MERCSKILL )
- {
- clif_parse_UseSkillToPos_mercenary(sd->md, sd, tick, skill_id, skill_lv, x, y, skillmoreinfo);
+ if( skill_id >= MC_SKILLBASE && skill_id < MC_SKILLBASE + MAX_MERCSKILL ) {
+ clif->pUseSkillToPos_mercenary(sd->md, sd, tick, skill_id, skill_lv, x, y, skillmoreinfo);
return;
}
//Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
sd->idletime = last_tick;
- if( skillnotok(skill_id, sd) )
+ if( skill->not_ok(skill_id, sd) )
return;
- if( skillmoreinfo != -1 )
- {
- if( pc_issit(sd) )
- {
- clif_skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
+ if( skillmoreinfo != -1 ) {
+ if( pc_issit(sd) ) {
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
return;
}
//You can't use Graffiti/TalkieBox AND have a vending open, so this is safe.
@@ -10901,12 +11376,12 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin
if( DIFF_TICK(tick, sd->ud.canact_tick) < 0 ) {
if( sd->skillitem != skill_id ) {
- clif_skill_fail(sd, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0);
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0);
return;
}
}
- if( sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER) )
+ if( sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK) )
return;
if( sd->sc.data[SC_BASILICA] && (skill_id != HP_BASILICA || sd->sc.data[SC_BASILICA]->val4 != sd->bl.id) )
@@ -10948,11 +11423,11 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd)
if (pc_issit(sd))
return;
- clif_parse_UseSkillToPosSub(fd, sd,
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), //skill lv
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), //skill num
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), //pos x
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]), //pos y
+ clif->pUseSkillToPosSub(fd, sd,
+ RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0]), //skill lv
+ RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[1]), //skill num
+ RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[2]), //pos x
+ RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[3]), //pos y
-1 //Skill more info.
);
}
@@ -10969,12 +11444,12 @@ void clif_parse_UseSkillToPosMoreInfo(int fd, struct map_session_data *sd)
if (pc_issit(sd))
return;
- clif_parse_UseSkillToPosSub(fd, sd,
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), //Skill lv
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), //Skill num
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), //pos x
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]), //pos y
- packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[4] //skill more info
+ clif->pUseSkillToPosSub(fd, sd,
+ RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0]), //Skill lv
+ RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[1]), //Skill num
+ RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[2]), //pos x
+ RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[3]), //pos y
+ packet_db[RFIFOW(fd,0)].pos[4] //skill more info
);
}
@@ -10996,7 +11471,7 @@ void clif_parse_UseSkillMap(int fd, struct map_session_data* sd)
}
pc_delinvincibletimer(sd);
- skill_castend_map(sd,skill_id,map_name);
+ skill->castend_map(sd,skill_id,map_name);
}
@@ -11024,12 +11499,12 @@ void clif_parse_ProduceMix(int fd,struct map_session_data *sd)
}
if (pc_istrading(sd)) {
//Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
clif_menuskill_clear(sd);
return;
}
- if( skill_can_produce_mix(sd,RFIFOW(fd,2),sd->menuskill_val, 1) )
- skill_produce_mix(sd,0,RFIFOW(fd,2),RFIFOW(fd,4),RFIFOW(fd,6),RFIFOW(fd,8), 1);
+ if( skill->can_produce_mix(sd,RFIFOW(fd,2),sd->menuskill_val, 1) )
+ skill->produce_mix(sd,0,RFIFOW(fd,2),RFIFOW(fd,4),RFIFOW(fd,6),RFIFOW(fd,8), 1);
clif_menuskill_clear(sd);
}
@@ -11052,12 +11527,12 @@ void clif_parse_Cooking(int fd,struct map_session_data *sd) {
if (pc_istrading(sd)) {
//Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
clif_menuskill_clear(sd);
return;
}
- if( skill_can_produce_mix(sd,nameid,sd->menuskill_val, amount) )
- skill_produce_mix(sd,(type>1?sd->menuskill_id:0),nameid,0,0,0,amount);
+ if( skill->can_produce_mix(sd,nameid,sd->menuskill_val, amount) )
+ skill->produce_mix(sd,(type>1?sd->menuskill_id:0),nameid,0,0,0,amount);
clif_menuskill_clear(sd);
}
@@ -11070,11 +11545,11 @@ void clif_parse_RepairItem(int fd, struct map_session_data *sd)
return;
if (pc_istrading(sd)) {
//Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
clif_menuskill_clear(sd);
return;
}
- skill_repairweapon(sd,RFIFOW(fd,2));
+ skill->repairweapon(sd,RFIFOW(fd,2));
clif_menuskill_clear(sd);
}
@@ -11089,12 +11564,12 @@ void clif_parse_WeaponRefine(int fd, struct map_session_data *sd)
return;
if (pc_istrading(sd)) {
//Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
clif_menuskill_clear(sd);
return;
}
- idx = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- skill_weaponrefine(sd, idx-2);
+ idx = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
+ skill->weaponrefine(sd, idx-2);
clif_menuskill_clear(sd);
}
@@ -11111,16 +11586,21 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
int npc_id = RFIFOL(fd,2);
uint8 select = RFIFOB(fd,6);
- if( (select > sd->npc_menu && select != 0xff) || select == 0 )
- {
- TBL_NPC* nd = map_id2nd(npc_id);
- ShowWarning("Invalid menu selection on npc %d:'%s' - got %d, valid range is [%d..%d] (player AID:%d, CID:%d, name:'%s')!\n", npc_id, (nd)?nd->name:"invalid npc id", select, 1, sd->npc_menu, sd->bl.id, sd->status.char_id, sd->status.name);
- clif_GM_kick(NULL,sd);
+ if( (select > sd->npc_menu && select != 0xff) || select == 0 ) {
+#ifdef SECURE_NPCTIMEOUT
+ if( sd->npc_idle_timer != INVALID_TIMER ) {
+#endif
+ TBL_NPC* nd = map_id2nd(npc_id);
+ ShowWarning("Invalid menu selection on npc %d:'%s' - got %d, valid range is [%d..%d] (player AID:%d, CID:%d, name:'%s')!\n", npc_id, (nd)?nd->name:"invalid npc id", select, 1, sd->npc_menu, sd->bl.id, sd->status.char_id, sd->status.name);
+ clif->GM_kick(NULL,sd);
+#ifdef SECURE_NPCTIMEOUT
+ }
+#endif
return;
}
sd->npc_menu = select;
- npc_scriptcont(sd,npc_id);
+ npc_scriptcont(sd,npc_id, false);
}
@@ -11128,7 +11608,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
/// 00b9 <npc id>.L
void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
{
- npc_scriptcont(sd,RFIFOL(fd,2));
+ npc_scriptcont(sd,RFIFOL(fd,2), false);
}
@@ -11140,7 +11620,7 @@ void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
int amount = (int)RFIFOL(fd,6);
sd->npc_amount = amount;
- npc_scriptcont(sd, npcid);
+ npc_scriptcont(sd, npcid, false);
}
@@ -11156,7 +11636,7 @@ void clif_parse_NpcStringInput(int fd, struct map_session_data* sd)
return; // invalid input
safestrncpy(sd->npc_str, message, min(message_len,CHATBOX_SIZE));
- npc_scriptcont(sd, npcid);
+ npc_scriptcont(sd, npcid, false);
}
@@ -11166,7 +11646,7 @@ void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
{
if (!sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex]
return;
- npc_scriptcont(sd,RFIFOL(fd,2));
+ npc_scriptcont(sd, RFIFOL(fd,2), true);
}
@@ -11184,7 +11664,7 @@ void clif_parse_ItemIdentify(int fd,struct map_session_data *sd)
clif_menuskill_clear(sd);
return;
}
- skill_identify(sd,idx-2);
+ skill->identify(sd,idx-2);
clif_menuskill_clear(sd);
}
@@ -11195,25 +11675,25 @@ void clif_parse_SelectArrow(int fd,struct map_session_data *sd)
{
if (pc_istrading(sd)) {
//Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
clif_menuskill_clear(sd);
return;
}
switch( sd->menuskill_id ) {
case AC_MAKINGARROW:
- skill_arrow_create(sd,RFIFOW(fd,2));
+ skill->arrow_create(sd,RFIFOW(fd,2));
break;
case SA_CREATECON:
- skill_produce_mix(sd,SA_CREATECON,RFIFOW(fd,2),0,0,0, 1);
+ skill->produce_mix(sd,SA_CREATECON,RFIFOW(fd,2),0,0,0, 1);
break;
case WL_READING_SB:
- skill_spellbook(sd,RFIFOW(fd,2));
+ skill->spellbook(sd,RFIFOW(fd,2));
break;
case GC_POISONINGWEAPON:
- skill_poisoningweapon(sd,RFIFOW(fd,2));
+ skill->poisoningweapon(sd,RFIFOW(fd,2));
break;
case NC_MAGICDECOY:
- skill_magicdecoy(sd,RFIFOW(fd,2));
+ skill->magicdecoy(sd,RFIFOW(fd,2));
break;
}
@@ -11227,7 +11707,7 @@ void clif_parse_AutoSpell(int fd,struct map_session_data *sd)
{
if (sd->menuskill_id != SA_AUTOSPELL)
return;
- skill_autospell(sd,RFIFOL(fd,2));
+ skill->autospell(sd,RFIFOL(fd,2));
clif_menuskill_clear(sd);
}
@@ -11238,7 +11718,7 @@ void clif_parse_UseCard(int fd,struct map_session_data *sd)
{
if (sd->state.trading != 0)
return;
- clif_use_card(sd,RFIFOW(fd,2)-2);
+ clif->use_card(sd,RFIFOW(fd,2)-2);
}
@@ -11260,7 +11740,7 @@ void clif_parse_SolveCharName(int fd, struct map_session_data *sd)
{
int charid;
- charid = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+ charid = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
map_reqnickdb(sd, charid);
}
@@ -11275,11 +11755,11 @@ void clif_parse_ResetChar(int fd, struct map_session_data *sd) {
char cmd[15];
if( RFIFOW(fd,2) )
- sprintf(cmd,"%cresetskill",atcommand_symbol);
+ sprintf(cmd,"%cresetskill",atcommand->at_symbol);
else
- sprintf(cmd,"%cresetstat",atcommand_symbol);
+ sprintf(cmd,"%cresetstat",atcommand->at_symbol);
- is_atcommand(fd, sd, cmd, 1);
+ atcommand->parse(fd, sd, cmd, 1);
}
@@ -11295,8 +11775,8 @@ void clif_parse_LocalBroadcast(int fd, struct map_session_data* sd)
// as the length varies depending on the command used, just block unreasonably long strings
mes_len_check(msg, len, CHAT_SIZE_MAX);
- sprintf(command, "%clkami %s", atcommand_symbol, msg);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%clkami %s", atcommand->at_symbol, msg);
+ atcommand->parse(fd, sd, command, 1);
}
@@ -11311,8 +11791,8 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd)
if (pc_istrading(sd))
return;
- item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
- item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
+ item_index = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0])-2;
+ item_amount = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[1]);
if (item_index < 0 || item_index >= MAX_INVENTORY || item_amount < 1)
return;
@@ -11332,13 +11812,12 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd)
{
int item_index, item_amount;
- item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-1;
- item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
+ item_index = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0])-1;
+ item_amount = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[1]);
if (sd->state.storage_flag == 1)
storage_storageget(sd, item_index, item_amount);
- else
- if(sd->state.storage_flag == 2)
+ else if(sd->state.storage_flag == 2)
storage_guild_storageget(sd, item_index, item_amount);
}
@@ -11383,8 +11862,7 @@ void clif_parse_CloseKafra(int fd, struct map_session_data *sd)
{
if( sd->state.storage_flag == 1 )
storage_storageclose(sd);
- else
- if( sd->state.storage_flag == 2 )
+ else if( sd->state.storage_flag == 2 )
storage_guild_storageclose(sd);
}
@@ -11450,14 +11928,12 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd)
char* name = (char*)RFIFOP(fd,2);
name[NAME_LENGTH-1] = '\0';
- if( map[sd->bl.m].flag.partylock )
- {// Party locked.
- clif_displaymessage(fd, msg_txt(227));
+ if( map[sd->bl.m].flag.partylock ) { // Party locked.
+ clif->message(fd, msg_txt(227));
return;
}
- if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 7 )
- {
- clif_skill_fail(sd,1,USESKILL_FAIL_LEVEL,4);
+ if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 7 ) {
+ clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,4);
return;
}
@@ -11471,14 +11947,12 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd)
int item2 = RFIFOB(fd,27);
name[NAME_LENGTH-1] = '\0';
- if( map[sd->bl.m].flag.partylock )
- {// Party locked.
- clif_displaymessage(fd, msg_txt(227));
+ if( map[sd->bl.m].flag.partylock ) {// Party locked.
+ clif->message(fd, msg_txt(227));
return;
}
- if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 7 )
- {
- clif_skill_fail(sd,1,USESKILL_FAIL_LEVEL,4);
+ if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 7 ) {
+ clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,4);
return;
}
@@ -11493,17 +11967,15 @@ void clif_parse_PartyInvite(int fd, struct map_session_data *sd)
{
struct map_session_data *t_sd;
- if(map[sd->bl.m].flag.partylock)
- {// Party locked.
- clif_displaymessage(fd, msg_txt(227));
+ if(map[sd->bl.m].flag.partylock) {// Party locked.
+ clif->message(fd, msg_txt(227));
return;
}
t_sd = map_id2sd(RFIFOL(fd,2));
- if(t_sd && t_sd->state.noask)
- {// @noask [LuzZza]
- clif_noask_sub(sd, t_sd, 1);
+ if(t_sd && t_sd->state.noask) {// @noask [LuzZza]
+ clif->noask_sub(sd, t_sd, 1);
return;
}
@@ -11516,17 +11988,15 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd)
char *name = (char*)RFIFOP(fd,2);
name[NAME_LENGTH-1] = '\0';
- if(map[sd->bl.m].flag.partylock)
- {// Party locked.
- clif_displaymessage(fd, msg_txt(227));
+ if(map[sd->bl.m].flag.partylock) { // Party locked.
+ clif->message(fd, msg_txt(227));
return;
}
t_sd = map_nick2sd(name);
- if(t_sd && t_sd->state.noask)
- {// @noask [LuzZza]
- clif_noask_sub(sd, t_sd, 1);
+ if(t_sd && t_sd->state.noask) { // @noask [LuzZza]
+ clif->noask_sub(sd, t_sd, 1);
return;
}
@@ -11555,9 +12025,8 @@ void clif_parse_ReplyPartyInvite2(int fd,struct map_session_data *sd)
/// 0100
void clif_parse_LeaveParty(int fd, struct map_session_data *sd)
{
- if(map[sd->bl.m].flag.partylock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(227));
+ if(map[sd->bl.m].flag.partylock) { //Guild locked.
+ clif->message(fd, msg_txt(227));
return;
}
party_leave(sd);
@@ -11568,9 +12037,8 @@ void clif_parse_LeaveParty(int fd, struct map_session_data *sd)
/// 0103 <account id>.L <char name>.24B
void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd)
{
- if(map[sd->bl.m].flag.partylock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(227));
+ if(map[sd->bl.m].flag.partylock) { //Guild locked.
+ clif->message(fd, msg_txt(227));
return;
}
party_removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
@@ -11619,10 +12087,10 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
int namelen, messagelen;
// validate packet and retrieve name and message
- if( !clif_process_message(sd, 0, &name, &namelen, &message, &messagelen) )
+ if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
- if( is_atcommand(fd, sd, message, 1) )
+ if( atcommand->parse(fd, sd, message, 1) )
return;
if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
@@ -11731,7 +12199,7 @@ void clif_PartyBookingSearchAck(int fd, struct party_booking_ad_info** results,
void clif_parse_PartyBookingDeleteReq(int fd, struct map_session_data* sd)
{
if(party_booking_delete(sd))
- clif_PartyBookingDeleteAck(sd, 0);
+ clif->PartyBookingDeleteAck(sd, 0);
}
@@ -11785,7 +12253,7 @@ void clif_PartyBookingInsertNotify(struct map_session_data* sd, struct party_boo
for(i=0; i<PARTY_BOOKING_JOBS; i++)
WBUFW(buf,38+i*2) = pb_ad->p_detail.job[i];
- clif_send(buf, packet_len(0x809), &sd->bl, ALL_CLIENT);
+ clif->send(buf, packet_len(0x809), &sd->bl, ALL_CLIENT);
}
@@ -11802,7 +12270,7 @@ void clif_PartyBookingUpdateNotify(struct map_session_data* sd, struct party_boo
WBUFL(buf,2) = pb_ad->index;
for(i=0; i<PARTY_BOOKING_JOBS; i++)
WBUFW(buf,6+i*2) = pb_ad->p_detail.job[i];
- clif_send(buf,packet_len(0x80a),&sd->bl,ALL_CLIENT); // Now UPDATE all client.
+ clif->send(buf,packet_len(0x80a),&sd->bl,ALL_CLIENT); // Now UPDATE all client.
}
@@ -11815,7 +12283,7 @@ void clif_PartyBookingDeleteNotify(struct map_session_data* sd, int index)
WBUFW(buf,0) = 0x80b;
WBUFL(buf,2) = index;
- clif_send(buf, packet_len(0x80b), &sd->bl, ALL_CLIENT); // Now UPDATE all client.
+ clif->send(buf, packet_len(0x80b), &sd->bl, ALL_CLIENT); // Now UPDATE all client.
}
@@ -11823,7 +12291,7 @@ void clif_PartyBookingDeleteNotify(struct map_session_data* sd, int index)
/// 012e
void clif_parse_CloseVending(int fd, struct map_session_data* sd)
{
- vending_closevending(sd);
+ vending->close(sd);
}
@@ -11831,11 +12299,10 @@ void clif_parse_CloseVending(int fd, struct map_session_data* sd)
/// 0130 <account id>.L
void clif_parse_VendingListReq(int fd, struct map_session_data* sd)
{
- if( sd->npc_id )
- {// using an NPC
+ if( sd->npc_id ) {// using an NPC
return;
}
- vending_vendinglistreq(sd,RFIFOL(fd,2));
+ vending->list(sd,RFIFOL(fd,2));
}
@@ -11847,7 +12314,7 @@ void clif_parse_PurchaseReq(int fd, struct map_session_data* sd)
int id = (int)RFIFOL(fd,4);
const uint8* data = (uint8*)RFIFOP(fd,8);
- vending_purchasereq(sd, id, sd->vended_id, data, len/4);
+ vending->purchase(sd, id, sd->vended_id, data, len/4);
// whether it fails or not, the buy window is closed
sd->vended_id = 0;
@@ -11863,7 +12330,7 @@ void clif_parse_PurchaseReq2(int fd, struct map_session_data* sd)
int uid = (int)RFIFOL(fd,8);
const uint8* data = (uint8*)RFIFOP(fd,12);
- vending_purchasereq(sd, aid, uid, data, len/4);
+ vending->purchase(sd, aid, uid, data, len/4);
// whether it fails or not, the buy window is closed
sd->vended_id = 0;
@@ -11882,33 +12349,27 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd)
const char* message = (char*)RFIFOP(fd,4);
bool flag = (bool)RFIFOB(fd,84);
const uint8* data = (uint8*)RFIFOP(fd,85);
+
+ if( !flag )
+ sd->state.prevend = 0;
if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM )
return;
if( map[sd->bl.m].flag.novending ) {
- clif_displaymessage (sd->fd, msg_txt(276)); // "You can't open a shop on this map"
+ clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map"
return;
}
if( map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) ) {
- clif_displaymessage (sd->fd, msg_txt(204)); // "You can't open a shop on this cell."
- return;
- }
-
- if( vending_checknearnpc(&sd->bl) ) {
- char output[150];
- sprintf(output, msg_txt(662), battle_config.min_npc_vending_distance);
- clif_displaymessage(sd->fd, output);
- clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
+ clif->message (sd->fd, msg_txt(204)); // "You can't open a shop on this cell."
return;
}
if( message[0] == '\0' ) // invalid input
return;
- vending_openvending(sd, message, flag, data, len/8);
+ vending->open(sd, message, data, len/8);
}
-
/// Guild creation request (CZ_REQ_MAKE_GUILD).
/// 0165 <char id>.L <guild name>.24B
void clif_parse_CreateGuild(int fd,struct map_session_data *sd)
@@ -11916,13 +12377,12 @@ void clif_parse_CreateGuild(int fd,struct map_session_data *sd)
char* name = (char*)RFIFOP(fd,6);
name[NAME_LENGTH-1] = '\0';
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
+ if(map[sd->bl.m].flag.guildlock) { //Guild locked.
+ clif->message(fd, msg_txt(228));
return;
}
- guild_create(sd, name);
+ guild->create(sd, name);
}
@@ -11930,7 +12390,7 @@ void clif_parse_CreateGuild(int fd,struct map_session_data *sd)
/// 014d
void clif_parse_GuildCheckMaster(int fd, struct map_session_data *sd)
{
- clif_guild_masterormember(sd);
+ clif->guild_masterormember(sd);
}
@@ -11949,29 +12409,28 @@ void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd)
if( !sd->status.guild_id && !sd->bg_id )
return;
- switch( RFIFOL(fd,2) )
- {
- case 0: // Basic Information Guild, hostile alliance information
- clif_guild_basicinfo(sd);
- clif_guild_allianceinfo(sd);
- break;
- case 1: // Members list, list job title
- clif_guild_positionnamelist(sd);
- clif_guild_memberlist(sd);
- break;
- case 2: // List job title, title information list
- clif_guild_positionnamelist(sd);
- clif_guild_positioninfolist(sd);
- break;
- case 3: // Skill list
- clif_guild_skillinfo(sd);
- break;
- case 4: // Expulsion list
- clif_guild_expulsionlist(sd);
- break;
- default:
- ShowError("clif: guild request info: unknown type %d\n", RFIFOL(fd,2));
- break;
+ switch( RFIFOL(fd,2) ) {
+ case 0: // Basic Information Guild, hostile alliance information
+ clif->guild_basicinfo(sd);
+ clif->guild_allianceinfo(sd);
+ break;
+ case 1: // Members list, list job title
+ clif->guild_positionnamelist(sd);
+ clif->guild_memberlist(sd);
+ break;
+ case 2: // List job title, title information list
+ clif->guild_positionnamelist(sd);
+ clif->guild_positioninfolist(sd);
+ break;
+ case 3: // Skill list
+ clif->guild_skillinfo(sd);
+ break;
+ case 4: // Expulsion list
+ clif->guild_expulsionlist(sd);
+ break;
+ default:
+ ShowError("clif: guild request info: unknown type %d\n", RFIFOL(fd,2));
+ break;
}
}
@@ -11986,7 +12445,7 @@ void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd)
return;
for(i = 4; i < RFIFOW(fd,2); i += 40 ){
- guild_change_position(sd->status.guild_id, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16));
+ guild->change_position(sd->status.guild_id, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16));
}
}
@@ -12001,7 +12460,7 @@ void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd)
return;
for(i=4;i<RFIFOW(fd,2);i+=12){
- guild_change_memberposition(sd->status.guild_id,
+ guild->change_memberposition(sd->status.guild_id,
RFIFOL(fd,i),RFIFOL(fd,i+4),RFIFOL(fd,i+8));
}
}
@@ -12014,14 +12473,13 @@ void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd)
struct guild* g;
int guild_id = RFIFOL(fd,2);
- if( (g = guild_search(guild_id)) != NULL )
- clif_guild_emblem(sd,g);
+ if( (g = guild->search(guild_id)) != NULL )
+ clif->guild_emblem(sd,g);
}
/// Validates data of a guild emblem (compressed bitmap)
-static bool clif_validate_emblem(const uint8* emblem, unsigned long emblem_len)
-{
+bool clif_validate_emblem(const uint8* emblem, unsigned long emblem_len) {
bool success;
uint8 buf[1800]; // no well-formed emblem bitmap is larger than 1782 (24 bit) / 1654 (8 bit) bytes
unsigned long buf_len = sizeof(buf);
@@ -12046,13 +12504,12 @@ void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd)
if( !emblem_len || !sd->state.gmaster_flag )
return;
- if( !clif_validate_emblem(emblem, emblem_len) )
- {
+ if( !clif->validate_emblem(emblem, emblem_len) ) {
ShowWarning("clif_parse_GuildChangeEmblem: Rejected malformed guild emblem (size=%lu, accound_id=%d, char_id=%d, guild_id=%d).\n", emblem_len, sd->status.account_id, sd->status.char_id, sd->status.guild_id);
return;
}
- guild_change_emblem(sd, emblem_len, (const char*)emblem);
+ guild->change_emblem(sd, emblem_len, (const char*)emblem);
}
@@ -12072,34 +12529,50 @@ void clif_parse_GuildChangeNotice(int fd, struct map_session_data* sd)
if (msg2[0] == '|' && msg2[3] == '|') msg2+= 3; // skip duplicate marker
if (msg2[0] == '|') msg2[strnlen(msg2, MAX_GUILDMES2)-1] = '\0'; // delete extra space at the end of string
- guild_change_notice(sd, guild_id, msg1, msg2);
+ guild->change_notice(sd, guild_id, msg1, msg2);
}
+// Helper function for guild invite functions
+int
+clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_session_data *t_sd) {
+ if (t_sd == NULL) {// not online or does not exist
+ return 1;
+ }
+
+ if (map[sd->bl.m].flag.guildlock) { //Guild locked.
+ clif->message(fd, msg_txt(228));
+ return 1;
+ }
+
+ if (t_sd && t_sd->state.noask) {// @noask [LuzZza]
+ clif->noask_sub(sd, t_sd, 2);
+ return 1;
+ }
+
+ guild->invite(sd,t_sd);
+ return 0;
+}
/// Guild invite request (CZ_REQ_JOIN_GUILD).
/// 0168 <account id>.L <inviter account id>.L <inviter char id>.L
void clif_parse_GuildInvite(int fd,struct map_session_data *sd)
{
- struct map_session_data *t_sd;
+ struct map_session_data *t_sd = map_id2sd(RFIFOL(fd,2));
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
+ if (clif_sub_guild_invite(fd, sd, t_sd))
return;
- }
-
- t_sd = map_id2sd(RFIFOL(fd,2));
+}
- // @noask [LuzZza]
- if(t_sd && t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 2);
+/// Guild invite request (/guildinvite) (CZ_REQ_JOIN_GUILD2).
+/// 0916 <char name>.24B
+void clif_parse_GuildInvite2(int fd, struct map_session_data *sd)
+{
+ struct map_session_data *t_sd = map_nick2sd((char *)RFIFOP(fd, 2));
+
+ if (clif_sub_guild_invite(fd, sd, t_sd))
return;
- }
-
- guild_invite(sd,t_sd);
}
-
/// Answer to guild invitation (CZ_JOIN_GUILD).
/// 016b <guild id>.L <answer>.L
/// answer:
@@ -12107,7 +12580,7 @@ void clif_parse_GuildInvite(int fd,struct map_session_data *sd)
/// 1 = accept
void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd)
{
- guild_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
+ guild->reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
}
@@ -12115,18 +12588,16 @@ void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd)
/// 0159 <guild id>.L <account id>.L <char id>.L <reason>.40B
void clif_parse_GuildLeave(int fd,struct map_session_data *sd)
{
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
+ if(map[sd->bl.m].flag.guildlock) { //Guild locked.
+ clif->message(fd, msg_txt(228));
return;
}
- if( sd->bg_id )
- {
- clif_displaymessage(fd, msg_txt(670)); //"You can't leave battleground guilds."
+ if( sd->bg_id ) {
+ clif->message(fd, msg_txt(670)); //"You can't leave battleground guilds."
return;
}
- guild_leave(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
+ guild->leave(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
}
@@ -12134,12 +12605,11 @@ void clif_parse_GuildLeave(int fd,struct map_session_data *sd)
/// 015b <guild id>.L <account id>.L <char id>.L <reason>.40B
void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd)
{
- if( map[sd->bl.m].flag.guildlock || sd->bg_id )
- { // Guild locked.
- clif_displaymessage(fd, msg_txt(228));
+ if( map[sd->bl.m].flag.guildlock || sd->bg_id ) { // Guild locked.
+ clif->message(fd, msg_txt(228));
return;
}
- guild_expulsion(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
+ guild->expulsion(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
}
@@ -12154,10 +12624,10 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
int namelen, messagelen;
// validate packet and retrieve name and message
- if( !clif_process_message(sd, 0, &name, &namelen, &message, &messagelen) )
+ if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
- if( is_atcommand(fd, sd, message, 1) )
+ if( atcommand->parse(fd, sd, message, 1) )
return;
if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
@@ -12173,7 +12643,7 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
if( sd->bg_id )
bg_send_message(sd, text, textlen);
else
- guild_send_message(sd, text, textlen);
+ guild->send_message(sd, text, textlen);
}
@@ -12186,9 +12656,8 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd)
if(!sd->state.gmaster_flag)
return;
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
+ if(map[sd->bl.m].flag.guildlock) { //Guild locked.
+ clif->message(fd, msg_txt(228));
return;
}
@@ -12196,11 +12665,11 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd)
// @noask [LuzZza]
if(t_sd && t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 3);
+ clif->noask_sub(sd, t_sd, 3);
return;
}
- guild_reqalliance(sd,t_sd);
+ guild->reqalliance(sd,t_sd);
}
@@ -12211,7 +12680,7 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd)
/// 1 = accept
void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd)
{
- guild_reply_reqalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
+ guild->reply_reqalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
}
@@ -12225,12 +12694,11 @@ void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd)
if(!sd->state.gmaster_flag)
return;
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
+ if(map[sd->bl.m].flag.guildlock) { //Guild locked.
+ clif->message(fd, msg_txt(228));
return;
}
- guild_delalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
+ guild->delalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
}
@@ -12243,9 +12711,8 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd)
if(!sd->state.gmaster_flag)
return;
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
+ if(map[sd->bl.m].flag.guildlock) { //Guild locked.
+ clif->message(fd, msg_txt(228));
return;
}
@@ -12253,11 +12720,11 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd)
// @noask [LuzZza]
if(t_sd && t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 4);
+ clif->noask_sub(sd, t_sd, 4);
return;
}
- guild_opposition(sd,t_sd);
+ guild->opposition(sd,t_sd);
}
@@ -12268,12 +12735,11 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd)
/// field name and size is same as the one in CH_DELETE_CHAR.
void clif_parse_GuildBreak(int fd, struct map_session_data *sd)
{
- if( map[sd->bl.m].flag.guildlock )
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
+ if( map[sd->bl.m].flag.guildlock ) { //Guild locked.
+ clif->message(fd, msg_txt(228));
return;
}
- guild_break(sd,(char*)RFIFOP(fd,2));
+ guild->dobreak(sd,(char*)RFIFOP(fd,2));
}
@@ -12306,10 +12772,9 @@ void clif_parse_CatchPet(int fd, struct map_session_data *sd)
/// 01a7 <index>.W
void clif_parse_SelectEgg(int fd, struct map_session_data *sd)
{
- if (sd->menuskill_id != SA_TAMINGMONSTER || sd->menuskill_val != -1)
- {
+ if (sd->menuskill_id != SA_TAMINGMONSTER || sd->menuskill_val != -1) {
//Forged packet, disconnect them [Kevin]
- clif_authfail_fd(fd, 0);
+ clif->authfail_fd(fd, 0);
return;
}
pet_select_egg(sd,RFIFOW(fd,2)-2);
@@ -12344,7 +12809,7 @@ void clif_parse_SelectEgg(int fd, struct map_session_data *sd)
void clif_parse_SendEmotion(int fd, struct map_session_data *sd)
{
if(sd->pd)
- clif_pet_emotion(sd->pd,RFIFOL(fd,2));
+ clif->pet_emotion(sd->pd,RFIFOL(fd,2));
}
@@ -12368,45 +12833,45 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
tid = RFIFOL(fd,2);
target = map_id2bl(tid);
if (!target) {
- clif_GM_kickack(sd, 0);
+ clif->GM_kickack(sd, 0);
return;
}
switch (target->type) {
- case BL_PC:
- {
- char command[NAME_LENGTH+6];
- sprintf(command, "%ckick %s", atcommand_symbol, status_get_name(target));
- is_atcommand(fd, sd, command, 1);
- }
- break;
+ case BL_PC:
+ {
+ char command[NAME_LENGTH+6];
+ sprintf(command, "%ckick %s", atcommand->at_symbol, status_get_name(target));
+ atcommand->parse(fd, sd, command, 1);
+ }
+ break;
- /**
- * This one does not invoke any atcommand, so we need to check for permissions.
- */
- case BL_MOB:
- {
- char command[100];
- if( !pc_can_use_command(sd, "killmonster", COMMAND_ATCOMMAND)) {
- clif_GM_kickack(sd, 0);
- return;
+ /**
+ * This one does not invoke any atcommand, so we need to check for permissions.
+ */
+ case BL_MOB:
+ {
+ char command[100];
+ if( !pc_can_use_command(sd, "@killmonster")) {
+ clif->GM_kickack(sd, 0);
+ return;
+ }
+ sprintf(command, "/kick %s (%d)", status_get_name(target), status_get_class(target));
+ logs->atcommand(sd, command);
+ status_percent_damage(&sd->bl, target, 100, 0, true); // can invalidate 'target'
}
- sprintf(command, "/kick %s (%d)", status_get_name(target), status_get_class(target));
- log_atcommand(sd, command);
- status_percent_damage(&sd->bl, target, 100, 0, true); // can invalidate 'target'
- }
- break;
+ break;
- case BL_NPC:
- {
- char command[NAME_LENGTH+11];
- sprintf(command, "%cunloadnpc %s", atcommand_symbol, status_get_name(target));
- is_atcommand(fd, sd, command, 1);
- }
- break;
+ case BL_NPC:
+ {
+ char command[NAME_LENGTH+11];
+ sprintf(command, "%cunloadnpc %s", atcommand->at_symbol, status_get_name(target));
+ atcommand->parse(fd, sd, command, 1);
+ }
+ break;
- default:
- clif_GM_kickack(sd, 0);
+ default:
+ clif->GM_kickack(sd, 0);
}
}
@@ -12416,8 +12881,8 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
/// 00ce
void clif_parse_GMKickAll(int fd, struct map_session_data* sd) {
char cmd[15];
- sprintf(cmd,"%ckickall",atcommand_symbol);
- is_atcommand(fd, sd, cmd, 1);
+ sprintf(cmd,"%ckickall",atcommand->at_symbol);
+ atcommand->parse(fd, sd, cmd, 1);
}
@@ -12436,8 +12901,8 @@ void clif_parse_GMShift(int fd, struct map_session_data *sd)
player_name = (char*)RFIFOP(fd,2);
player_name[NAME_LENGTH-1] = '\0';
- sprintf(command, "%cjumpto %s", atcommand_symbol, player_name);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%cjumpto %s", atcommand->at_symbol, player_name);
+ atcommand->parse(fd, sd, command, 1);
}
@@ -12449,12 +12914,11 @@ void clif_parse_GMRemove2(int fd, struct map_session_data* sd)
int account_id;
struct map_session_data* pl_sd;
- account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- if( (pl_sd = map_id2sd(account_id)) != NULL )
- {
+ account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
+ if( (pl_sd = map_id2sd(account_id)) != NULL ) {
char command[NAME_LENGTH+8];
- sprintf(command, "%cjumpto %s", atcommand_symbol, pl_sd->status.name);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%cjumpto %s", atcommand->at_symbol, pl_sd->status.name);
+ atcommand->parse(fd, sd, command, 1);
}
}
@@ -12474,8 +12938,8 @@ void clif_parse_GMRecall(int fd, struct map_session_data *sd)
player_name = (char*)RFIFOP(fd,2);
player_name[NAME_LENGTH-1] = '\0';
- sprintf(command, "%crecall %s", atcommand_symbol, player_name);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%crecall %s", atcommand->at_symbol, player_name);
+ atcommand->parse(fd, sd, command, 1);
}
@@ -12487,12 +12951,11 @@ void clif_parse_GMRecall2(int fd, struct map_session_data* sd)
int account_id;
struct map_session_data* pl_sd;
- account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- if( (pl_sd = map_id2sd(account_id)) != NULL )
- {
+ account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
+ if( (pl_sd = map_id2sd(account_id)) != NULL ) {
char command[NAME_LENGTH+8];
- sprintf(command, "%crecall %s", atcommand_symbol, pl_sd->status.name);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%crecall %s", atcommand->at_symbol, pl_sd->status.name);
+ atcommand->parse(fd, sd, command, 1);
}
}
@@ -12511,16 +12974,16 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd)
// FIXME: Should look for item first, then for monster.
// FIXME: /monster takes mob_db Sprite_Name as argument
if( mobdb_searchname(monster_item_name) ) {
- snprintf(command, sizeof(command)-1, "%cmonster %s", atcommand_symbol, monster_item_name);
- is_atcommand(fd, sd, command, 1);
+ snprintf(command, sizeof(command)-1, "%cmonster %s", atcommand->at_symbol, monster_item_name);
+ atcommand->parse(fd, sd, command, 1);
return;
}
// FIXME: Stackables have a quantity of 20.
// FIXME: Equips are supposed to be unidentified.
if( itemdb_searchname(monster_item_name) ) {
- snprintf(command, sizeof(command)-1, "%citem %s", atcommand_symbol, monster_item_name);
- is_atcommand(fd, sd, command, 1);
+ snprintf(command, sizeof(command)-1, "%citem %s", atcommand->at_symbol, monster_item_name);
+ atcommand->parse(fd, sd, command, 1);
return;
}
}
@@ -12533,9 +12996,9 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd)
void clif_parse_GMHide(int fd, struct map_session_data *sd) {
char cmd[6];
- sprintf(cmd,"%chide",atcommand_symbol);
+ sprintf(cmd,"%chide",atcommand->at_symbol);
- is_atcommand(fd, sd, cmd, 1);
+ atcommand->parse(fd, sd, cmd, 1);
}
@@ -12567,8 +13030,8 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd)
if( dstsd == NULL )
return;
- sprintf(command, "%cmute %d %s", atcommand_symbol, value, dstsd->status.name);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%cmute %d %s", atcommand->at_symbol, value, dstsd->status.name);
+ atcommand->parse(fd, sd, command, 1);
}
@@ -12581,15 +13044,14 @@ void clif_parse_GMRc(int fd, struct map_session_data* sd)
char *name = (char*)RFIFOP(fd,2);
name[NAME_LENGTH-1] = '\0';
- sprintf(command, "%cmute %d %s", atcommand_symbol, 60, name);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%cmute %d %s", atcommand->at_symbol, 60, name);
+ atcommand->parse(fd, sd, command, 1);
}
/// Result of request to resolve account name (ZC_ACK_ACCOUNTNAME).
/// 01e0 <account id>.L <account name>.24B
-void clif_account_name(struct map_session_data* sd, int account_id, const char* accname)
-{
+void clif_account_name(struct map_session_data* sd, int account_id, const char* accname) {
int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x1e0));
@@ -12607,7 +13069,7 @@ void clif_parse_GMReqAccountName(int fd, struct map_session_data *sd)
int account_id = RFIFOL(fd,2);
//TODO: find out if this works for any player or only for authorized GMs
- clif_account_name(sd, account_id, ""); // insert account name here >_<
+ clif->account_name(sd, account_id, ""); // insert account name here >_<
}
@@ -12629,7 +13091,7 @@ void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd)
type = RFIFOW(fd,6);
map_setgatcell(sd->bl.m,x,y,type);
- clif_changemapcell(0,sd->bl.m,x,y,type,ALL_SAMEMAP);
+ clif->changemapcell(0,sd->bl.m,x,y,type,ALL_SAMEMAP);
//FIXME: once players leave the map, the client 'forgets' this information.
}
@@ -12650,37 +13112,31 @@ void clif_parse_PMIgnore(int fd, struct map_session_data* sd)
nick[NAME_LENGTH-1] = '\0'; // to be sure that the player name has at most 23 characters
type = RFIFOB(fd,26);
- if( type == 0 )
- { // Add name to ignore list (block)
+ if( type == 0 ) { // Add name to ignore list (block)
if (strcmp(wisp_server_name, nick) == 0) {
- clif_wisexin(sd, type, 1); // fail
+ clif->wisexin(sd, type, 1); // fail
return;
}
// try to find a free spot, while checking for duplicates at the same time
ARR_FIND( 0, MAX_IGNORE_LIST, i, sd->ignore[i].name[0] == '\0' || strcmp(sd->ignore[i].name, nick) == 0 );
- if( i == MAX_IGNORE_LIST )
- {// no space for new entry
- clif_wisexin(sd, type, 2); // too many blocks
+ if( i == MAX_IGNORE_LIST ) {// no space for new entry
+ clif->wisexin(sd, type, 2); // too many blocks
return;
}
- if( sd->ignore[i].name[0] != '\0' )
- {// name already exists
- clif_wisexin(sd, type, 0); // Aegis reports success.
+ if( sd->ignore[i].name[0] != '\0' ) { // name already exists
+ clif->wisexin(sd, type, 0); // Aegis reports success.
return;
}
//Insert in position i
safestrncpy(sd->ignore[i].name, nick, NAME_LENGTH);
- }
- else
- { // Remove name from ignore list (unblock)
+ } else { // Remove name from ignore list (unblock)
// find entry
ARR_FIND( 0, MAX_IGNORE_LIST, i, sd->ignore[i].name[0] == '\0' || strcmp(sd->ignore[i].name, nick) == 0 );
- if( i == MAX_IGNORE_LIST || sd->ignore[i].name[i] == '\0' )
- { //Not found
- clif_wisexin(sd, type, 1); // fail
+ if( i == MAX_IGNORE_LIST || sd->ignore[i].name[i] == '\0' ) { //Not found
+ clif->wisexin(sd, type, 1); // fail
return;
}
// move everything one place down to overwrite removed entry
@@ -12689,7 +13145,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data* sd)
memset(sd->ignore[MAX_IGNORE_LIST-1].name, 0, sizeof(sd->ignore[0].name));
}
- clif_wisexin(sd, type, 0); // success
+ clif->wisexin(sd, type, 0); // success
}
@@ -12703,17 +13159,14 @@ void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd)
{
int type = RFIFOB(fd,2), flag;
- if( type == 0 )
- {// Deny all
+ if( type == 0 ) {// Deny all
if( sd->state.ignoreAll ) {
flag = 1; // fail
} else {
sd->state.ignoreAll = 1;
flag = 0; // success
}
- }
- else
- {//Unblock everyone
+ } else {//Unblock everyone
if( sd->state.ignoreAll ) {
sd->state.ignoreAll = 0;
flag = 0; // success
@@ -12728,21 +13181,19 @@ void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd)
}
}
- clif_wisall(sd, type, flag);
+ clif->wisall(sd, type, flag);
}
/// Whisper ignore list (ZC_WHISPER_LIST).
/// 00d4 <packet len>.W { <char name>.24B }*
-void clif_PMIgnoreList(struct map_session_data* sd)
-{
+void clif_PMIgnoreList(struct map_session_data* sd) {
int i, fd = sd->fd;
WFIFOHEAD(fd,4+ARRAYLENGTH(sd->ignore)*NAME_LENGTH);
WFIFOW(fd,0) = 0xd4;
- for( i = 0; i < ARRAYLENGTH(sd->ignore) && sd->ignore[i].name[0]; i++ )
- {
+ for( i = 0; i < ARRAYLENGTH(sd->ignore) && sd->ignore[i].name[0]; i++ ) {
memcpy(WFIFOP(fd,4+i*NAME_LENGTH), sd->ignore[i].name, NAME_LENGTH);
}
@@ -12755,7 +13206,7 @@ void clif_PMIgnoreList(struct map_session_data* sd)
/// 00d3
void clif_parse_PMIgnoreList(int fd,struct map_session_data *sd)
{
- clif_PMIgnoreList(sd);
+ clif->PMIgnoreList(sd);
}
@@ -12765,8 +13216,7 @@ void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd)
{
if (sd->state.doridori) return;
- switch (sd->class_&MAPID_UPPERMASK)
- {
+ switch (sd->class_&MAPID_UPPERMASK) {
case MAPID_SOUL_LINKER:
case MAPID_STAR_GLADIATOR:
case MAPID_TAEKWON:
@@ -12789,18 +13239,15 @@ void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd)
/// "Help me out~ Please~ T_T"
void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd)
{
- if( ( sd->class_&MAPID_UPPERMASK ) == MAPID_SUPER_NOVICE )
- {
+ if( ( sd->class_&MAPID_UPPERMASK ) == MAPID_SUPER_NOVICE ) {
unsigned int next = pc_nextbaseexp(sd);
if( next == 0 ) next = pc_thisbaseexp(sd);
- if( next )
- {
+ if( next ) {
int percent = (int)( ( (float)sd->status.base_exp/(float)next )*1000. );
- if( percent && ( percent%100 ) == 0 )
- {// 10.0%, 20.0%, ..., 90.0%
- sc_start(&sd->bl, status_skill2sc(MO_EXPLOSIONSPIRITS), 100, 17, skill_get_time(MO_EXPLOSIONSPIRITS, 5)); //Lv17-> +50 critical (noted by Poki) [Skotlex]
- clif_skill_nodamage(&sd->bl, &sd->bl, MO_EXPLOSIONSPIRITS, 5, 1); // prayer always shows successful Lv5 cast and disregards noskill restrictions
+ if( percent && ( percent%100 ) == 0 ) {// 10.0%, 20.0%, ..., 90.0%
+ sc_start(&sd->bl, status_skill2sc(MO_EXPLOSIONSPIRITS), 100, 17, skill->get_time(MO_EXPLOSIONSPIRITS, 5)); //Lv17-> +50 critical (noted by Poki) [Skotlex]
+ clif->skill_nodamage(&sd->bl, &sd->bl, MO_EXPLOSIONSPIRITS, 5, 1); // prayer always shows successful Lv5 cast and disregards noskill restrictions
}
}
}
@@ -12815,8 +13262,7 @@ void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd)
/// state:
/// 0 = online
/// 1 = offline
-void clif_friendslist_toggle(struct map_session_data *sd,int account_id, int char_id, int online)
-{
+void clif_friendslist_toggle(struct map_session_data *sd,int account_id, int char_id, int online) {
int i, fd = sd->fd;
//Seek friend.
@@ -12842,7 +13288,7 @@ int clif_friendslist_toggle_sub(struct map_session_data *sd,va_list ap)
account_id = va_arg(ap, int);
char_id = va_arg(ap, int);
online = va_arg(ap, int);
- clif_friendslist_toggle(sd, account_id, char_id, online);
+ clif->friendslist_toggle(sd, account_id, char_id, online);
return 0;
}
@@ -12856,8 +13302,7 @@ void clif_friendslist_send(struct map_session_data *sd)
// Send friends list
WFIFOHEAD(fd, MAX_FRIENDS * 32 + 4);
WFIFOW(fd, 0) = 0x201;
- for(i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id; i++)
- {
+ for(i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id; i++) {
WFIFOL(fd, 4 + 32 * i + 0) = sd->status.friends[i].account_id;
WFIFOL(fd, 4 + 32 * i + 4) = sd->status.friends[i].char_id;
memcpy(WFIFOP(fd, 4 + 32 * i + 8), &sd->status.friends[i].name, NAME_LENGTH);
@@ -12868,10 +13313,9 @@ void clif_friendslist_send(struct map_session_data *sd)
WFIFOSET(fd, WFIFOW(fd,2));
}
- for (n = 0; n < i; n++)
- { //Sending the online players
+ for (n = 0; n < i; n++) { //Sending the online players
if (map_charid2sd(sd->status.friends[n].char_id))
- clif_friendslist_toggle(sd, sd->status.friends[n].account_id, sd->status.friends[n].char_id, 1);
+ clif->friendslist_toggle(sd, sd->status.friends[n].account_id, sd->status.friends[n].char_id, 1);
}
}
@@ -12892,8 +13336,7 @@ void clif_friendslist_reqack(struct map_session_data *sd, struct map_session_dat
WFIFOHEAD(fd,packet_len(0x209));
WFIFOW(fd,0) = 0x209;
WFIFOW(fd,2) = type;
- if (f_sd)
- {
+ if (f_sd) {
WFIFOL(fd,4) = f_sd->status.account_id;
WFIFOL(fd,8) = f_sd->status.char_id;
memcpy(WFIFOP(fd, 12), f_sd->status.name,NAME_LENGTH);
@@ -12904,8 +13347,7 @@ void clif_friendslist_reqack(struct map_session_data *sd, struct map_session_dat
/// Asks a player for permission to be added as friend (ZC_REQ_ADD_FRIENDS).
/// 0207 <req account id>.L <req char id>.L <req char name>.24B
-void clif_friendlist_req(struct map_session_data* sd, int account_id, int char_id, const char* name)
-{
+void clif_friendlist_req(struct map_session_data* sd, int account_id, int char_id, const char* name) {
int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x207));
@@ -12930,31 +13372,30 @@ void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd)
ARR_FIND(0, MAX_FRIENDS, i, sd->status.friends[i].char_id == 0);
if( i == MAX_FRIENDS ) {
- clif_friendslist_reqack(sd, f_sd, 2);
+ clif->friendslist_reqack(sd, f_sd, 2);
return;
}
// Friend doesn't exist (no player with this name)
if (f_sd == NULL) {
- clif_displaymessage(fd, msg_txt(3));
+ clif->message(fd, msg_txt(3));
return;
}
- if( sd->bl.id == f_sd->bl.id )
- {// adding oneself as friend
+ if( sd->bl.id == f_sd->bl.id ) { // adding oneself as friend
return;
}
// @noask [LuzZza]
if(f_sd->state.noask) {
- clif_noask_sub(sd, f_sd, 5);
+ clif->noask_sub(sd, f_sd, 5);
return;
}
// Friend already exists
for (i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id != 0; i++) {
if (sd->status.friends[i].char_id == f_sd->status.char_id) {
- clif_displaymessage(fd, msg_txt(671)); //"Friend already exists."
+ clif->message(fd, msg_txt(671)); //"Friend already exists."
return;
}
}
@@ -12962,7 +13403,7 @@ void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd)
f_sd->friend_req = sd->status.char_id;
sd->friend_req = f_sd->status.char_id;
- clif_friendlist_req(f_sd, sd->status.account_id, sd->status.char_id, sd->status.name);
+ clif->friendlist_req(f_sd, sd->status.account_id, sd->status.char_id, sd->status.name);
}
@@ -12986,8 +13427,7 @@ void clif_parse_FriendsListReply(int fd, struct map_session_data *sd)
reply = RFIFOL(fd,10);
#endif
- if( sd->bl.id == account_id )
- {// adding oneself as friend
+ if( sd->bl.id == account_id ) { // adding oneself as friend
return;
}
@@ -12996,7 +13436,7 @@ void clif_parse_FriendsListReply(int fd, struct map_session_data *sd)
return;
if (reply == 0 || !( sd->friend_req == f_sd->status.char_id && f_sd->friend_req == sd->status.char_id ) )
- clif_friendslist_reqack(f_sd, sd, 1);
+ clif->friendslist_reqack(f_sd, sd, 1);
else {
int i;
// Find an empty slot
@@ -13004,14 +13444,14 @@ void clif_parse_FriendsListReply(int fd, struct map_session_data *sd)
if (f_sd->status.friends[i].char_id == 0)
break;
if (i == MAX_FRIENDS) {
- clif_friendslist_reqack(f_sd, sd, 2);
+ clif->friendslist_reqack(f_sd, sd, 2);
return;
}
f_sd->status.friends[i].account_id = sd->status.account_id;
f_sd->status.friends[i].char_id = sd->status.char_id;
memcpy(f_sd->status.friends[i].name, sd->status.name, NAME_LENGTH);
- clif_friendslist_reqack(f_sd, sd, 0);
+ clif->friendslist_reqack(f_sd, sd, 0);
if (battle_config.friend_auto_add) {
// Also add f_sd to sd's friendlist.
@@ -13022,14 +13462,14 @@ void clif_parse_FriendsListReply(int fd, struct map_session_data *sd)
break;
}
if (i == MAX_FRIENDS) {
- clif_friendslist_reqack(sd, f_sd, 2);
+ clif->friendslist_reqack(sd, f_sd, 2);
return;
}
sd->status.friends[i].account_id = f_sd->status.account_id;
sd->status.friends[i].char_id = f_sd->status.char_id;
memcpy(sd->status.friends[i].name, f_sd->status.name, NAME_LENGTH);
- clif_friendslist_reqack(sd, f_sd, 0);
+ clif->friendslist_reqack(sd, f_sd, 0);
}
}
}
@@ -13051,7 +13491,7 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd)
(sd->status.friends[i].char_id != char_id || sd->status.friends[i].account_id != account_id); i++);
if (i == MAX_FRIENDS) {
- clif_displaymessage(fd, msg_txt(672)); //"Name not found in list."
+ clif->message(fd, msg_txt(672)); //"Name not found in list."
return;
}
@@ -13076,7 +13516,7 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd)
} else { //friend not online -- ask char server to delete from his friendlist
if(chrif_removefriend(char_id,sd->status.char_id)) { // char-server offline, abort
- clif_displaymessage(fd, msg_txt(673)); //"This action can't be performed at the moment. Please try again later."
+ clif->message(fd, msg_txt(673)); //"This action can't be performed at the moment. Please try again later."
return;
}
}
@@ -13089,7 +13529,7 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd)
memcpy(&sd->status.friends[j-1], &sd->status.friends[j], sizeof(sd->status.friends[0]));
memset(&sd->status.friends[MAX_FRIENDS-1], 0, sizeof(sd->status.friends[MAX_FRIENDS-1]));
- clif_displaymessage(fd, msg_txt(674)); //"Friend removed"
+ clif->message(fd, msg_txt(674)); //"Friend removed"
WFIFOHEAD(fd,packet_len(0x20a));
WFIFOW(fd,0) = 0x20a;
@@ -13101,8 +13541,7 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd)
/// /pvpinfo list (ZC_ACK_PVPPOINT).
/// 0210 <char id>.L <account id>.L <win point>.L <lose point>.L <point>.L
-void clif_PVPInfo(struct map_session_data* sd)
-{
+void clif_PVPInfo(struct map_session_data* sd) {
int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x210));
@@ -13121,7 +13560,7 @@ void clif_PVPInfo(struct map_session_data* sd)
void clif_parse_PVPInfo(int fd,struct map_session_data *sd)
{
// TODO: Is there a way to use this on an another player (char/acc id)?
- clif_PVPInfo(sd);
+ clif->PVPInfo(sd);
}
@@ -13160,7 +13599,7 @@ void clif_blacksmith(struct map_session_data* sd)
/// 0217
void clif_parse_Blacksmith(int fd,struct map_session_data *sd)
{
- clif_blacksmith(sd);
+ clif->blacksmith(sd);
}
@@ -13180,8 +13619,7 @@ void clif_fame_blacksmith(struct map_session_data *sd, int points)
/// /alchemist list (ZC_ALCHEMIST_RANK).
/// 021a { <name>.24B }*10 { <point>.L }*10
-void clif_alchemist(struct map_session_data* sd)
-{
+void clif_alchemist(struct map_session_data* sd) {
int i, fd = sd->fd;
const char* name;
@@ -13213,7 +13651,7 @@ void clif_alchemist(struct map_session_data* sd)
/// 0218
void clif_parse_Alchemist(int fd,struct map_session_data *sd)
{
- clif_alchemist(sd);
+ clif->alchemist(sd);
}
@@ -13233,8 +13671,7 @@ void clif_fame_alchemist(struct map_session_data *sd, int points)
/// /taekwon list (ZC_TAEKWON_RANK).
/// 0226 { <name>.24B }*10 { <point>.L }*10
-void clif_taekwon(struct map_session_data* sd)
-{
+void clif_taekwon(struct map_session_data* sd) {
int i, fd = sd->fd;
const char* name;
@@ -13265,7 +13702,7 @@ void clif_taekwon(struct map_session_data* sd)
/// 0225
void clif_parse_Taekwon(int fd,struct map_session_data *sd)
{
- clif_taekwon(sd);
+ clif->taekwon(sd);
}
@@ -13285,8 +13722,7 @@ void clif_fame_taekwon(struct map_session_data *sd, int points)
/// /pk list (ZC_KILLER_RANK).
/// 0238 { <name>.24B }*10 { <point>.L }*10
-void clif_ranking_pk(struct map_session_data* sd)
-{
+void clif_ranking_pk(struct map_session_data* sd) {
int i, fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x238));
@@ -13303,7 +13739,7 @@ void clif_ranking_pk(struct map_session_data* sd)
/// 0237
void clif_parse_RankingPk(int fd,struct map_session_data *sd)
{
- clif_ranking_pk(sd);
+ clif->ranking_pk(sd);
}
@@ -13328,7 +13764,7 @@ void clif_parse_FeelSaveOk(int fd,struct map_session_data *sd)
//Are these really needed? Shouldn't they show up automatically from the feel save packet?
// clif_misceffect2(&sd->bl, 0x1b0);
// clif_misceffect2(&sd->bl, 0x21f);
- clif_feel_info(sd, i, 0);
+ clif->feel_info(sd, i, 0);
clif_menuskill_clear(sd);
}
@@ -13352,9 +13788,8 @@ void clif_feel_req(int fd, struct map_session_data *sd, uint16 skill_lv)
/// Request to change homunculus' name (CZ_RENAME_MER).
/// 0231 <name>.24B
-void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd)
-{
- merc_hom_change_name(sd,(char*)RFIFOP(fd,2));
+void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) {
+ homun->change_name(sd,(char*)RFIFOP(fd,2));
}
@@ -13368,7 +13803,7 @@ void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd)
if( sd->md && sd->md->bl.id == id )
bl = &sd->md->bl;
- else if( merc_is_hom_active(sd->hd) && sd->hd->bl.id == id )
+ else if( homun_alive(sd->hd) && sd->hd->bl.id == id )
bl = &sd->hd->bl; // Moving Homunculus
else
return;
@@ -13387,11 +13822,11 @@ void clif_parse_HomMoveTo(int fd, struct map_session_data *sd)
struct block_list *bl = NULL;
short x, y;
- RFIFOPOS(fd, packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1], &x, &y, NULL);
+ RFIFOPOS(fd, packet_db[RFIFOW(fd,0)].pos[1], &x, &y, NULL);
if( sd->md && sd->md->bl.id == id )
bl = &sd->md->bl; // Moving Mercenary
- else if( merc_is_hom_active(sd->hd) && sd->hd->bl.id == id )
+ else if( homun_alive(sd->hd) && sd->hd->bl.id == id )
bl = &sd->hd->bl; // Moving Homunculus
else
return;
@@ -13411,7 +13846,7 @@ void clif_parse_HomAttack(int fd,struct map_session_data *sd)
target_id = RFIFOL(fd,6),
action_type = RFIFOB(fd,10);
- if( merc_is_hom_active(sd->hd) && sd->hd->bl.id == id )
+ if( homun_alive(sd->hd) && sd->hd->bl.id == id )
bl = &sd->hd->bl;
else if( sd->md && sd->md->bl.id == id )
bl = &sd->md->bl;
@@ -13430,16 +13865,15 @@ void clif_parse_HomAttack(int fd,struct map_session_data *sd)
/// 0 = homunculus information
/// 1 = feed
/// 2 = delete
-void clif_parse_HomMenu(int fd, struct map_session_data *sd)
-{ //[orn]
+void clif_parse_HomMenu(int fd, struct map_session_data *sd) { //[orn]
int cmd;
cmd = RFIFOW(fd,0);
- if(!merc_is_hom_active(sd->hd))
+ if(!homun_alive(sd->hd))
return;
- merc_menu(sd,RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[1]));
+ homun->menu(sd,RFIFOB(fd,packet_db[cmd].pos[1]));
}
@@ -13458,7 +13892,7 @@ void clif_parse_AutoRevive(int fd, struct map_session_data *sd)
if (!status_revive(&sd->bl, 100, 100))
return;
- clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
+ clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
pc_delitem(sd, item_position, 1, 0, 1, LOG_TYPE_CONSUME);
}
@@ -13470,8 +13904,7 @@ void clif_parse_AutoRevive(int fd, struct map_session_data *sd)
/// <itemdefPower>.W <plusdefPower>.W <mdefPower>.W <plusmdefPower>.W
/// <hitSuccessValue>.W <avoidSuccessValue>.W <plusAvoidSuccessValue>.W
/// <criticalSuccessValue>.W <ASPD>.W <plusASPD>.W
-void clif_check(int fd, struct map_session_data* pl_sd)
-{
+void clif_check(int fd, struct map_session_data* pl_sd) {
WFIFOHEAD(fd,packet_len(0x214));
WFIFOW(fd, 0) = 0x214;
WFIFOB(fd, 2) = min(pl_sd->status.str, UINT8_MAX);
@@ -13515,14 +13948,13 @@ void clif_parse_Check(int fd, struct map_session_data *sd)
if(!pc_has_permission(sd, PC_PERM_USE_CHECK))
return;
- safestrncpy(charname, (const char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), sizeof(charname));
+ safestrncpy(charname, (const char*)RFIFOP(fd,packet_db[RFIFOW(fd,0)].pos[0]), sizeof(charname));
- if( ( pl_sd = map_nick2sd(charname) ) == NULL || pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
- {
+ if( ( pl_sd = map_nick2sd(charname) ) == NULL || pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) {
return;
}
- clif_check(fd, pl_sd);
+ clif->check(fd, pl_sd);
}
@@ -13665,11 +14097,10 @@ void clif_Mail_refreshinbox(struct map_session_data *sd)
}
WFIFOSET(fd,len);
- if( md->full )
- {// TODO: is this official?
+ if( md->full ) {// TODO: is this official?
char output[100];
sprintf(output, "Inbox is full (Max %d). Delete some mails.", MAIL_MAX_INBOX);
- clif_disp_onlyself(sd, output, strlen(output));
+ clif->disp_onlyself(sd, output, strlen(output));
}
}
@@ -13683,7 +14114,7 @@ void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd)
if( md->amount < MAIL_MAX_INBOX && (md->full || sd->mail.changed) )
intif_Mail_requestinbox(sd->status.char_id, 1);
else
- clif_Mail_refreshinbox(sd);
+ clif->mail_refreshinbox(sd);
mail_removeitem(sd, 0);
mail_removezeny(sd, 0);
@@ -13699,14 +14130,11 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
int i, fd = sd->fd;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
- if( i == MAIL_MAX_INBOX )
- {
- clif_Mail_return(sd->fd, mail_id, 1); // Mail doesn't exist
+ if( i == MAIL_MAX_INBOX ) {
+ clif->mail_return(sd->fd, mail_id, 1); // Mail doesn't exist
ShowWarning("clif_parse_Mail_read: char '%s' trying to read a message not the inbox.\n", sd->status.name);
return;
- }
- else
- {
+ } else {
struct mail_message *msg = &sd->mail.inbox.msg[i];
struct item *item = &msg->item;
struct item_data *data;
@@ -13728,8 +14156,7 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
WFIFOL(fd,72) = 0;
WFIFOL(fd,76) = msg->zeny;
- if( item->nameid && (data = itemdb_exists(item->nameid)) != NULL )
- {
+ if( item->nameid && (data = itemdb_exists(item->nameid)) != NULL ) {
WFIFOL(fd,80) = item->amount;
WFIFOW(fd,84) = (data->view_id)?data->view_id:item->nameid;
WFIFOW(fd,86) = data->type;
@@ -13740,8 +14167,7 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
WFIFOW(fd,93) = item->card[1];
WFIFOW(fd,95) = item->card[2];
WFIFOW(fd,97) = item->card[3];
- }
- else // no item, set all to zero
+ } else // no item, set all to zero
memset(WFIFOP(fd,80), 0x00, 19);
WFIFOB(fd,99) = (unsigned char)msg_len;
@@ -13751,7 +14177,7 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
if (msg->status == MAIL_UNREAD) {
msg->status = MAIL_READ;
intif_Mail_read(mail_id);
- clif_parse_Mail_refreshinbox(fd, sd);
+ clif->pMail_refreshinbox(fd, sd);
}
}
}
@@ -13768,7 +14194,7 @@ void clif_parse_Mail_read(int fd, struct map_session_data *sd)
if( mail_invalid_operation(sd) )
return;
- clif_Mail_read(sd, RFIFOL(fd,2));
+ clif->mail_read(sd, RFIFOL(fd,2));
}
@@ -13794,22 +14220,19 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
if( sd->mail.inbox.msg[i].zeny < 1 && (sd->mail.inbox.msg[i].item.nameid < 1 || sd->mail.inbox.msg[i].item.amount < 1) )
return;
- if( sd->mail.inbox.msg[i].zeny + sd->status.zeny > MAX_ZENY )
- {
- clif_Mail_getattachment(fd, 1);
+ if( sd->mail.inbox.msg[i].zeny + sd->status.zeny > MAX_ZENY ) {
+ clif->mail_getattachment(fd, 1);
return;
}
- if( sd->mail.inbox.msg[i].item.nameid > 0 )
- {
+ if( sd->mail.inbox.msg[i].item.nameid > 0 ) {
struct item_data *data;
unsigned int weight;
if ((data = itemdb_exists(sd->mail.inbox.msg[i].item.nameid)) == NULL)
return;
- switch( pc_checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) )
- {
+ switch( pc_checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) ) {
case ADDITEM_NEW:
fail = ( pc_inventoryblank(sd) == 0 );
break;
@@ -13817,23 +14240,21 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
fail = true;
}
- if( fail )
- {
- clif_Mail_getattachment(fd, 1);
+ if( fail ) {
+ clif->mail_getattachment(fd, 1);
return;
}
weight = data->weight * sd->mail.inbox.msg[i].item.amount;
- if( sd->weight + weight > sd->max_weight )
- {
- clif_Mail_getattachment(fd, 2);
+ if( sd->weight + weight > sd->max_weight ) {
+ clif->mail_getattachment(fd, 2);
return;
}
}
sd->mail.inbox.msg[i].zeny = 0;
memset(&sd->mail.inbox.msg[i].item, 0, sizeof(struct item));
- clif_Mail_read(sd, mail_id);
+ clif->mail_read(sd, mail_id);
intif_Mail_getattach(sd->status.char_id, mail_id);
}
@@ -13854,13 +14275,11 @@ void clif_parse_Mail_delete(int fd, struct map_session_data *sd)
return;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
- if (i < MAIL_MAX_INBOX)
- {
+ if (i < MAIL_MAX_INBOX) {
struct mail_message *msg = &sd->mail.inbox.msg[i];
- if( (msg->item.nameid > 0 && msg->item.amount > 0) || msg->zeny > 0 )
- {// can't delete mail without removing attachment first
- clif_Mail_delete(sd->fd, mail_id, 1);
+ if( (msg->item.nameid > 0 && msg->item.amount > 0) || msg->zeny > 0 ) {// can't delete mail without removing attachment first
+ clif->mail_delete(sd->fd, mail_id, 1);
return;
}
@@ -13885,7 +14304,7 @@ void clif_parse_Mail_return(int fd, struct map_session_data *sd)
if( i < MAIL_MAX_INBOX && sd->mail.inbox.msg[i].send_id != 0 )
intif_Mail_return(sd->status.char_id, mail_id);
else
- clif_Mail_return(sd->fd, mail_id, 1);
+ clif->mail_return(sd->fd, mail_id, 1);
}
@@ -13903,7 +14322,7 @@ void clif_parse_Mail_setattach(int fd, struct map_session_data *sd)
return;
flag = mail_setitem(sd, idx, amount);
- clif_Mail_setattachment(fd,idx,flag);
+ clif->mail_setattachment(fd,idx,flag);
}
@@ -13941,10 +14360,9 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
return;
}
- if( DIFF_TICK(sd->cansendmail_tick, gettick()) > 0 )
- {
- clif_displaymessage(sd->fd,msg_txt(675)); //"Cannot send mails too fast!!."
- clif_Mail_send(fd, true); // fail
+ if( DIFF_TICK(sd->cansendmail_tick, gettick()) > 0 ) {
+ clif->message(sd->fd,msg_txt(675)); //"Cannot send mails too fast!!."
+ clif->mail_send(fd, true); // fail
return;
}
@@ -13953,9 +14371,8 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
if (body_len > MAIL_BODY_LENGTH)
body_len = MAIL_BODY_LENGTH;
- if( !mail_setattachment(sd, &msg) )
- { // Invalid Append condition
- clif_Mail_send(sd->fd, true); // fail
+ if( !mail_setattachment(sd, &msg) ) { // Invalid Append condition
+ clif->mail_send(sd->fd, true); // fail
mail_removeitem(sd,0);
mail_removezeny(sd,0);
return;
@@ -14023,8 +14440,7 @@ void clif_Auction_results(struct map_session_data *sd, short count, short pages,
WFIFOL(fd,4) = pages;
WFIFOL(fd,8) = count;
- for( i = 0; i < count; i++ )
- {
+ for( i = 0; i < count; i++ ) {
memcpy(&auction, RBUFP(buf,i * len), len);
k = 12 + (i * 83);
@@ -14059,8 +14475,7 @@ void clif_Auction_results(struct map_session_data *sd, short count, short pages,
/// result:
/// 0 = success
/// 1 = failure
-static void clif_Auction_setitem(int fd, int index, bool fail)
-{
+void clif_Auction_setitem(int fd, int index, bool fail) {
WFIFOHEAD(fd,packet_len(0x256));
WFIFOW(fd,0) = 0x256;
WFIFOW(fd,2) = index;
@@ -14078,7 +14493,7 @@ static void clif_Auction_setitem(int fd, int index, bool fail)
void clif_parse_Auction_cancelreg(int fd, struct map_session_data *sd)
{
if( sd->auction.amount > 0 )
- clif_additem(sd, sd->auction.index, sd->auction.amount, 0);
+ clif->additem(sd, sd->auction.index, sd->auction.amount, 0);
sd->auction.amount = 0;
}
@@ -14095,34 +14510,32 @@ void clif_parse_Auction_setitem(int fd, struct map_session_data *sd)
if( sd->auction.amount > 0 )
sd->auction.amount = 0;
- if( idx < 0 || idx >= MAX_INVENTORY )
- {
+ if( idx < 0 || idx >= MAX_INVENTORY ) {
ShowWarning("Character %s trying to set invalid item index in auctions.\n", sd->status.name);
return;
}
- if( amount != 1 || amount > sd->status.inventory[idx].amount )
- { // By client, amount is always set to 1. Maybe this is a future implementation.
+ if( amount != 1 || amount > sd->status.inventory[idx].amount ) { // By client, amount is always set to 1. Maybe this is a future implementation.
ShowWarning("Character %s trying to set invalid amount in auctions.\n", sd->status.name);
return;
}
if( (item = itemdb_exists(sd->status.inventory[idx].nameid)) != NULL && !(item->type == IT_ARMOR || item->type == IT_PETARMOR || item->type == IT_WEAPON || item->type == IT_CARD || item->type == IT_ETC) )
{ // Consumable or pets are not allowed
- clif_Auction_setitem(sd->fd, idx, true);
+ clif->auction_setitem(sd->fd, idx, true);
return;
}
if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time ||
!sd->status.inventory[idx].identify ||
!itemdb_canauction(&sd->status.inventory[idx],pc_get_group_level(sd)) ) { // Quest Item or something else
- clif_Auction_setitem(sd->fd, idx, true);
+ clif->auction_setitem(sd->fd, idx, true);
return;
}
sd->auction.index = idx;
sd->auction.amount = amount;
- clif_Auction_setitem(fd, idx + 2, false);
+ clif->auction_setitem(fd, idx + 2, false);
}
/// Result from an auction action (ZC_AUCTION_RESULT).
@@ -14174,28 +14587,24 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
auction.hours = RFIFOW(fd,10);
// Invalid Situations...
- if( sd->auction.amount < 1 )
- {
+ if( sd->auction.amount < 1 ) {
ShowWarning("Character %s trying to register auction without item.\n", sd->status.name);
return;
}
- if( auction.price >= auction.buynow )
- {
+ if( auction.price >= auction.buynow ) {
ShowWarning("Character %s trying to alter auction prices.\n", sd->status.name);
return;
}
- if( auction.hours < 1 || auction.hours > 48 )
- {
+ if( auction.hours < 1 || auction.hours > 48 ) {
ShowWarning("Character %s trying to enter an invalid time for auction.\n", sd->status.name);
return;
}
// Auction checks...
- if( sd->status.zeny < (auction.hours * battle_config.auction_feeperhour) )
- {
- clif_Auction_message(fd, 5); // You do not have enough zeny to pay the Auction Fee.
+ if( sd->status.zeny < (auction.hours * battle_config.auction_feeperhour) ) {
+ clif->auction_message(fd, 5); // You do not have enough zeny to pay the Auction Fee.
return;
}
@@ -14214,13 +14623,13 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
if( sd->status.inventory[sd->auction.index].nameid == 0 || sd->status.inventory[sd->auction.index].amount < sd->auction.amount )
{
- clif_Auction_message(fd, 2); // The auction has been canceled
+ clif->auction_message(fd, 2); // The auction has been canceled
return;
}
if( (item = itemdb_exists(sd->status.inventory[sd->auction.index].nameid)) == NULL )
{ // Just in case
- clif_Auction_message(fd, 2); // The auction has been canceled
+ clif->auction_message(fd, 2); // The auction has been canceled
return;
}
@@ -14231,7 +14640,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
auction.timestamp = 0;
if( !intif_Auction_register(&auction) )
- clif_Auction_message(fd, 4); // No Char Server? lets say something to the client
+ clif->auction_message(fd, 4); // No Char Server? lets say something to the client
else
{
int zeny = auction.hours*battle_config.auction_feeperhour;
@@ -14272,16 +14681,16 @@ void clif_parse_Auction_bid(int fd, struct map_session_data *sd)
int bid = RFIFOL(fd,6);
if( !pc_can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish]
- clif_displaymessage(sd->fd, msg_txt(246));
+ clif->message(sd->fd, msg_txt(246));
return;
}
if( bid <= 0 )
- clif_Auction_message(fd, 0); // You have failed to bid into the auction
+ clif->auction_message(fd, 0); // You have failed to bid into the auction
else if( bid > sd->status.zeny )
- clif_Auction_message(fd, 8); // You do not have enough zeny
+ clif->auction_message(fd, 8); // You do not have enough zeny
else if ( CheckForCharServer() ) // char server is down (bugreport:1138)
- clif_Auction_message(fd, 0); // You have failed to bid into the auction
+ clif->auction_message(fd, 0); // You have failed to bid into the auction
else {
pc_payzeny(sd, bid, LOG_TYPE_AUCTION, NULL);
intif_Auction_bid(sd->status.char_id, sd->status.name, auction_id, bid);
@@ -14304,7 +14713,7 @@ void clif_parse_Auction_search(int fd, struct map_session_data* sd)
short type = RFIFOW(fd,2), page = RFIFOW(fd,32);
int price = RFIFOL(fd,4); // FIXME: bug #5071
- clif_parse_Auction_cancelreg(fd, sd);
+ clif->pAuction_cancelreg(fd, sd);
safestrncpy(search_text, (char*)RFIFOP(fd,8), sizeof(search_text));
intif_Auction_requestlist(sd->status.char_id, type, price, search_text, page);
@@ -14319,7 +14728,7 @@ void clif_parse_Auction_search(int fd, struct map_session_data* sd)
void clif_parse_Auction_buysell(int fd, struct map_session_data* sd)
{
short type = RFIFOW(fd,2) + 6;
- clif_parse_Auction_cancelreg(fd, sd);
+ clif->pAuction_cancelreg(fd, sd);
intif_Auction_requestlist(sd->status.char_id, type, 0, "", 1);
}
@@ -14353,8 +14762,7 @@ void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd)
WFIFOL(fd,8) = sd->kafraPoints; // Kafra Points
#endif
- for( i = 0; i < nd->u.shop.count; i++ )
- {
+ for( i = 0; i < nd->u.shop.count; i++ ) {
struct item_data* id = itemdb_search(nd->u.shop.shop_item[i].nameid);
WFIFOL(fd,offset+0+i*11) = nd->u.shop.shop_item[i].value;
WFIFOL(fd,offset+4+i*11) = nd->u.shop.shop_item[i].value; // Discount Price
@@ -14378,8 +14786,7 @@ void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd)
/// 6 = You do not have enough Kafra Credit Points. (ERROR_TYPE_MONEY)
/// 7 = You can purchase up to 10 items.
/// 8 = Some items could not be purchased.
-void clif_cashshop_ack(struct map_session_data* sd, int error)
-{
+void clif_cashshop_ack(struct map_session_data* sd, int error) {
int fd = sd->fd;
WFIFOHEAD(fd, packet_len(0x289));
@@ -14406,8 +14813,7 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd)
if( sd->state.trading || !sd->npc_shopid )
fail = 1;
- else
- {
+ else {
#if PACKETVER < 20101116
short nameid = RFIFOW(fd,2);
short amount = RFIFOW(fd,4);
@@ -14429,7 +14835,7 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd)
#endif
}
- clif_cashshop_ack(sd,fail);
+ clif->cashshop_ack(sd,fail);
}
@@ -14455,8 +14861,7 @@ void clif_Adopt_reply(struct map_session_data *sd, int type)
/// Adoption confirmation (ZC_REQ_BABY).
/// 01f6 <account id>.L <char id>.L <name>.B
-void clif_Adopt_request(struct map_session_data *sd, struct map_session_data *src, int p_id)
-{
+void clif_Adopt_request(struct map_session_data *sd, struct map_session_data *src, int p_id) {
int fd = sd->fd;
WFIFOHEAD(fd,34);
@@ -14474,10 +14879,9 @@ void clif_parse_Adopt_request(int fd, struct map_session_data *sd)
{
struct map_session_data *tsd = map_id2sd(RFIFOL(fd,2)), *p_sd = map_charid2sd(sd->status.partner_id);
- if( pc_can_Adopt(sd, p_sd, tsd) )
- {
+ if( pc_can_Adopt(sd, p_sd, tsd) ) {
tsd->adopt_invite = sd->status.account_id;
- clif_Adopt_request(tsd, sd, p_sd->status.account_id);
+ clif->adopt_request(tsd, sd, p_sd->status.account_id);
}
}
@@ -14524,21 +14928,15 @@ void clif_bossmapinfo(int fd, struct mob_data *md, short flag)
memset(WFIFOP(fd,0),0,70);
WFIFOW(fd,0) = 0x293;
- if( md != NULL )
- {
- if( md->bl.prev != NULL )
- { // Boss on This Map
- if( flag )
- {
+ if( md != NULL ) {
+ if( md->bl.prev != NULL ) { // Boss on This Map
+ if( flag ) {
WFIFOB(fd,2) = 1;
WFIFOL(fd,3) = md->bl.x;
WFIFOL(fd,7) = md->bl.y;
- }
- else
+ } else
WFIFOB(fd,2) = 2; // First Time
- }
- else if (md->spawn_timer != INVALID_TIMER)
- { // Boss is Dead
+ } else if (md->spawn_timer != INVALID_TIMER) { // Boss is Dead
const struct TimerData * timer_data = get_timer(md->spawn_timer);
unsigned int seconds;
int hours, minutes;
@@ -14570,9 +14968,9 @@ void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd)
return;
if( tsd->status.show_equip || pc_has_permission(sd, PC_PERM_VIEW_EQUIPMENT) )
- clif_viewequip_ack(sd, tsd);
+ clif->viewequip_ack(sd, tsd);
else
- clif_viewequip_fail(sd);
+ clif->viewequip_fail(sd);
}
@@ -14587,9 +14985,19 @@ void clif_parse_EquipTick(int fd, struct map_session_data* sd)
{
bool flag = (bool)RFIFOL(fd,6);
sd->status.show_equip = flag;
- clif_equiptickack(sd, flag);
+ clif->equiptickack(sd, flag);
}
+/// Request to change party invitation tick.
+/// value:
+/// 0 = disabled
+/// 1 = enabled
+void clif_parse_PartyTick(int fd, struct map_session_data* sd)
+{
+ bool flag = RFIFOB(fd,6)?true:false;
+ sd->status.allow_party = flag;
+ clif->partytickack(sd, flag);
+}
/// Questlog System [Kevin] [Inkfish]
///
@@ -14607,8 +15015,7 @@ void clif_quest_send_list(struct map_session_data * sd)
WFIFOW(fd, 2) = len;
WFIFOL(fd, 4) = sd->avail_quests;
- for( i = 0; i < sd->avail_quests; i++ )
- {
+ for( i = 0; i < sd->avail_quests; i++ ) {
WFIFOL(fd, i*5+8) = sd->quest_log[i].quest_id;
WFIFOB(fd, i*5+12) = sd->quest_log[i].state;
}
@@ -14631,8 +15038,7 @@ void clif_quest_send_mission(struct map_session_data * sd)
WFIFOW(fd, 2) = len;
WFIFOL(fd, 4) = sd->avail_quests;
- for( i = 0; i < sd->avail_quests; i++ )
- {
+ for( i = 0; i < sd->avail_quests; i++ ) {
WFIFOL(fd, i*104+8) = sd->quest_log[i].quest_id;
WFIFOL(fd, i*104+12) = sd->quest_log[i].time - quest_db[sd->quest_index[i]].time;
WFIFOL(fd, i*104+16) = sd->quest_log[i].time;
@@ -14667,8 +15073,7 @@ void clif_quest_add(struct map_session_data * sd, struct quest * qd, int index)
WFIFOL(fd, 11) = qd->time;
WFIFOW(fd, 15) = quest_db[index].num_objectives;
- for( i = 0; i < quest_db[index].num_objectives; i++ )
- {
+ for( i = 0; i < quest_db[index].num_objectives; i++ ) {
WFIFOL(fd, i*30+17) = quest_db[index].mob[i];
WFIFOW(fd, i*30+21) = qd->count[i];
mob = mob_db(quest_db[index].mob[i]);
@@ -14705,8 +15110,7 @@ void clif_quest_update_objective(struct map_session_data * sd, struct quest * qd
WFIFOW(fd, 2) = len;
WFIFOW(fd, 4) = quest_db[index].num_objectives;
- for( i = 0; i < quest_db[index].num_objectives; i++ )
- {
+ for( i = 0; i < quest_db[index].num_objectives; i++ ) {
WFIFOL(fd, i*12+6) = qd->quest_id;
WFIFOL(fd, i*12+10) = quest_db[index].mob[i];
WFIFOW(fd, i*12+14) = quest_db[index].count[i];
@@ -14785,8 +15189,7 @@ void clif_mercenary_updatestatus(struct map_session_data *sd, int type)
WFIFOHEAD(fd,packet_len(0x2a2));
WFIFOW(fd,0) = 0x2a2;
WFIFOW(fd,2) = type;
- switch( type )
- {
+ switch( type ) {
case SP_ATK1:
{
int atk = rnd()%(status->rhw.atk2 - status->rhw.atk + 1) + status->rhw.atk;
@@ -14902,11 +15305,11 @@ void clif_mercenary_skillblock(struct map_session_data *sd)
continue;
j = id - MC_SKILLBASE;
WFIFOW(fd,len) = id;
- WFIFOL(fd,len+2) = skill_get_inf(id);
+ WFIFOL(fd,len+2) = skill->get_inf(id);
WFIFOW(fd,len+6) = md->db->skill[j].lv;
- WFIFOW(fd,len+8) = skill_get_sp(id, md->db->skill[j].lv);
- WFIFOW(fd,len+10) = skill_get_range2(&md->bl, id, md->db->skill[j].lv);
- safestrncpy((char*)WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH);
+ WFIFOW(fd,len+8) = skill->get_sp(id, md->db->skill[j].lv);
+ WFIFOW(fd,len+10) = skill->get_range2(&md->bl, id, md->db->skill[j].lv);
+ safestrncpy((char*)WFIFOP(fd,len+12), skill->get_name(id), NAME_LENGTH);
WFIFOB(fd,len+36) = 0; // Skillable for Mercenary?
len += 37;
}
@@ -14938,7 +15341,7 @@ void clif_parse_mercenary_action(int fd, struct map_session_data* sd)
/// 3 = Your mercenary soldier has ran away.
void clif_mercenary_message(struct map_session_data* sd, int message)
{
- clif_msg(sd, 1266 + message);
+ clif->msg(sd, 1266 + message);
}
@@ -15004,7 +15407,7 @@ void clif_bg_hp(struct map_session_data *sd)
WBUFW(buf,32) = sd->battle_status.max_hp;
}
- clif_send(buf, packet_len(cmd), &sd->bl, BG_AREA_WOS);
+ clif->send(buf, packet_len(cmd), &sd->bl, BG_AREA_WOS);
}
@@ -15022,7 +15425,7 @@ void clif_bg_xy(struct map_session_data *sd)
WBUFW(buf,32)=sd->bl.x;
WBUFW(buf,34)=sd->bl.y;
- clif_send(buf, packet_len(0x2df), &sd->bl, BG_SAMEMAP_WOS);
+ clif->send(buf, packet_len(0x2df), &sd->bl, BG_SAMEMAP_WOS);
}
void clif_bg_xy_remove(struct map_session_data *sd)
@@ -15037,7 +15440,7 @@ void clif_bg_xy_remove(struct map_session_data *sd)
WBUFW(buf,32)=-1;
WBUFW(buf,34)=-1;
- clif_send(buf, packet_len(0x2df), &sd->bl, BG_SAMEMAP_WOS);
+ clif->send(buf, packet_len(0x2df), &sd->bl, BG_SAMEMAP_WOS);
}
@@ -15057,7 +15460,7 @@ void clif_bg_message(struct battleground_data *bg, int src_id, const char *name,
WBUFL(buf,4) = src_id;
memcpy(WBUFP(buf,8), name, NAME_LENGTH);
memcpy(WBUFP(buf,32), mes, len);
- clif_send(buf,WBUFW(buf,2), &sd->bl, BG);
+ clif->send(buf,WBUFW(buf,2), &sd->bl, BG);
if( buf )
aFree(buf);
@@ -15074,17 +15477,16 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd)
char *name, *message;
int namelen, messagelen;
- if( !clif_process_message(sd, 0, &name, &namelen, &message, &messagelen) )
+ if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
- if( is_atcommand(fd, sd, message, 1) )
+ if( atcommand->parse(fd, sd, message, 1) )
return;
if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
return;
- if( battle_config.min_chat_delay )
- {
+ if( battle_config.min_chat_delay ) {
if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
return;
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
@@ -15108,7 +15510,7 @@ void clif_bg_updatescore(int16 m)
WBUFW(buf,0) = 0x2de;
WBUFW(buf,2) = map[m].bgscore_lion;
WBUFW(buf,4) = map[m].bgscore_eagle;
- clif_send(buf,packet_len(0x2de),&bl,ALL_SAMEMAP);
+ clif->send(buf,packet_len(0x2de),&bl,ALL_SAMEMAP);
}
void clif_bg_updatescore_single(struct map_session_data *sd)
@@ -15136,7 +15538,7 @@ void clif_sendbgemblem_area(struct map_session_data *sd)
WBUFL(buf,2) = sd->bl.id;
safestrncpy((char*)WBUFP(buf,6), sd->status.name, NAME_LENGTH); // name don't show in screen.
WBUFW(buf,30) = sd->bg_id;
- clif_send(buf,packet_len(0x2dd), &sd->bl, AREA);
+ clif->send(buf,packet_len(0x2dd), &sd->bl, AREA);
}
void clif_sendbgemblem_single(int fd, struct map_session_data *sd)
@@ -15161,7 +15563,7 @@ void clif_font(struct map_session_data *sd)
WBUFW(buf,0) = 0x2ef;
WBUFL(buf,2) = sd->bl.id;
WBUFW(buf,6) = sd->user_font;
- clif_send(buf, packet_len(0x2ef), &sd->bl, AREA);
+ clif->send(buf, packet_len(0x2ef), &sd->bl, AREA);
#endif
}
@@ -15178,79 +15580,73 @@ int clif_instance(int instance_id, int type, int flag)
if( (p = party_search(instance[instance_id].party_id)) == NULL || (sd = party_getavailablesd(p)) == NULL )
return 0;
- switch( type )
- {
- case 1:
- // S 0x2cb <Instance name>.61B <Standby Position>.W
- // Required to start the instancing information window on Client
- // This window re-appear each "refresh" of client automatically until type 4 is send to client.
- WBUFW(buf,0) = 0x02CB;
- memcpy(WBUFP(buf,2),instance[instance_id].name,INSTANCE_NAME_LENGTH);
- WBUFW(buf,63) = flag;
- clif_send(buf,packet_len(0x02CB),&sd->bl,PARTY);
- break;
- case 2:
- // S 0x2cc <Standby Position>.W
- // To announce Instancing queue creation if no maps available
- WBUFW(buf,0) = 0x02CC;
- WBUFW(buf,2) = flag;
- clif_send(buf,packet_len(0x02CC),&sd->bl,PARTY);
- break;
- case 3:
- case 4:
- // S 0x2cd <Instance Name>.61B <Instance Remaining Time>.L <Instance Noplayers close time>.L
- WBUFW(buf,0) = 0x02CD;
- memcpy(WBUFP(buf,2),instance[instance_id].name,61);
- if( type == 3 )
- {
- WBUFL(buf,63) = (uint32)instance[instance_id].progress_timeout;
- WBUFL(buf,67) = 0;
- }
- else
- {
- WBUFL(buf,63) = 0;
- WBUFL(buf,67) = (uint32)instance[instance_id].idle_timeout;
- }
- clif_send(buf,packet_len(0x02CD),&sd->bl,PARTY);
- break;
- case 5:
- // S 0x2ce <Message ID>.L
- // 0 = Notification (EnterLimitDate update?)
- // 1 = The Memorial Dungeon expired; it has been destroyed
- // 2 = The Memorial Dungeon's entry time limit expired; it has been destroyed
- // 3 = The Memorial Dungeon has been removed.
- // 4 = Create failure (removes the instance window)
- WBUFW(buf,0) = 0x02CE;
- WBUFL(buf,2) = flag;
- //WBUFL(buf,6) = EnterLimitDate;
- clif_send(buf,packet_len(0x02CE),&sd->bl,PARTY);
- break;
+ switch( type ) {
+ case 1:
+ // S 0x2cb <Instance name>.61B <Standby Position>.W
+ // Required to start the instancing information window on Client
+ // This window re-appear each "refresh" of client automatically until type 4 is send to client.
+ WBUFW(buf,0) = 0x02CB;
+ memcpy(WBUFP(buf,2),instance[instance_id].name,INSTANCE_NAME_LENGTH);
+ WBUFW(buf,63) = flag;
+ clif->send(buf,packet_len(0x02CB),&sd->bl,PARTY);
+ break;
+ case 2:
+ // S 0x2cc <Standby Position>.W
+ // To announce Instancing queue creation if no maps available
+ WBUFW(buf,0) = 0x02CC;
+ WBUFW(buf,2) = flag;
+ clif->send(buf,packet_len(0x02CC),&sd->bl,PARTY);
+ break;
+ case 3:
+ case 4:
+ // S 0x2cd <Instance Name>.61B <Instance Remaining Time>.L <Instance Noplayers close time>.L
+ WBUFW(buf,0) = 0x02CD;
+ memcpy(WBUFP(buf,2),instance[instance_id].name,61);
+ if( type == 3 )
+ {
+ WBUFL(buf,63) = (uint32)instance[instance_id].progress_timeout;
+ WBUFL(buf,67) = 0;
+ }
+ else
+ {
+ WBUFL(buf,63) = 0;
+ WBUFL(buf,67) = (uint32)instance[instance_id].idle_timeout;
+ }
+ clif->send(buf,packet_len(0x02CD),&sd->bl,PARTY);
+ break;
+ case 5:
+ // S 0x2ce <Message ID>.L
+ // 0 = Notification (EnterLimitDate update?)
+ // 1 = The Memorial Dungeon expired; it has been destroyed
+ // 2 = The Memorial Dungeon's entry time limit expired; it has been destroyed
+ // 3 = The Memorial Dungeon has been removed.
+ // 4 = Create failure (removes the instance window)
+ WBUFW(buf,0) = 0x02CE;
+ WBUFL(buf,2) = flag;
+ //WBUFL(buf,6) = EnterLimitDate;
+ clif->send(buf,packet_len(0x02CE),&sd->bl,PARTY);
+ break;
}
return 0;
}
void clif_instance_join(int fd, int instance_id)
{
- if( instance[instance_id].idle_timer != INVALID_TIMER )
- {
+ if( instance[instance_id].idle_timer != INVALID_TIMER ) {
WFIFOHEAD(fd,packet_len(0x02CD));
WFIFOW(fd,0) = 0x02CD;
memcpy(WFIFOP(fd,2),instance[instance_id].name,61);
WFIFOL(fd,63) = 0;
WFIFOL(fd,67) = (uint32)instance[instance_id].idle_timeout;
WFIFOSET(fd,packet_len(0x02CD));
- }
- else if( instance[instance_id].progress_timer != INVALID_TIMER )
- {
+ } else if( instance[instance_id].progress_timer != INVALID_TIMER ) {
WFIFOHEAD(fd,packet_len(0x02CD));
WFIFOW(fd,0) = 0x02CD;
memcpy(WFIFOP(fd,2),instance[instance_id].name,61);
WFIFOL(fd,63) = (uint32)instance[instance_id].progress_timeout;;
WFIFOL(fd,67) = 0;
WFIFOSET(fd,packet_len(0x02CD));
- }
- else
- {
+ } else {
WFIFOHEAD(fd,packet_len(0x02CB));
WFIFOW(fd,0) = 0x02CB;
memcpy(WFIFOP(fd,2),instance[instance_id].name,61);
@@ -15282,10 +15678,10 @@ void clif_party_show_picker(struct map_session_data * sd, struct item * item_dat
WBUFB(buf,8) = item_data->identify;
WBUFB(buf,9) = item_data->attribute;
WBUFB(buf,10) = item_data->refine;
- clif_addcards(WBUFP(buf,11), item_data);
+ clif->addcards(WBUFP(buf,11), item_data);
WBUFW(buf,19) = id->equip; // equip location
WBUFB(buf,21) = itemtype(id->type); // item type
- clif_send(buf, packet_len(0x2b8), &sd->bl, PARTY_SAMEMAP_WOS);
+ clif->send(buf, packet_len(0x2b8), &sd->bl, PARTY_SAMEMAP_WOS);
#endif
}
@@ -15347,7 +15743,7 @@ void clif_showdigit(struct map_session_data* sd, unsigned char type, int value)
/// Graffiti.
void clif_parse_LessEffect(int fd, struct map_session_data* sd)
{
- int isLess = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+ int isLess = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
sd->state.lesseffect = ( isLess != 0 );
}
@@ -15374,11 +15770,11 @@ void clif_parse_ItemListWindowSelected(int fd, struct map_session_data* sd) {
switch( type ) {
case 0: // Change Material
- skill_changematerial(sd,n,item_list);
+ skill->changematerial(sd,n,item_list);
break;
case 1: // Level 1: Pure to Rough
case 2: // Level 2: Rough to Pure
- skill_elementalanalysis(sd,n,type,item_list);
+ skill->elementalanalysis(sd,n,type,item_list);
break;
}
clif_menuskill_clear(sd);
@@ -15462,15 +15858,14 @@ void clif_buyingstore_open(struct map_session_data* sd)
/// result:
/// 0 = cancel
/// 1 = open
-static void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data* sd)
-{
+void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data* sd) {
const unsigned int blocksize = 8;
uint8* itemlist;
char storename[MESSAGE_SIZE];
unsigned char result;
int zenylimit;
unsigned int count, packet_len;
- struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
+ struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
packet_len = RFIFOW(fd,info->pos[0]);
@@ -15496,7 +15891,7 @@ static void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data* sd)
}
count = packet_len/blocksize;
- buyingstore_create(sd, zenylimit, result, storename, itemlist, count);
+ buyingstore->create(sd, zenylimit, result, storename, itemlist, count);
}
@@ -15554,7 +15949,7 @@ void clif_buyingstore_entry(struct map_session_data* sd)
WBUFL(buf,2) = sd->bl.id;
memcpy(WBUFP(buf,6), sd->message, MESSAGE_SIZE);
- clif_send(buf, packet_len(0x814), &sd->bl, AREA_WOS);
+ clif->send(buf, packet_len(0x814), &sd->bl, AREA_WOS);
}
void clif_buyingstore_entry_single(struct map_session_data* sd, struct map_session_data* pl_sd)
{
@@ -15570,9 +15965,8 @@ void clif_buyingstore_entry_single(struct map_session_data* sd, struct map_sessi
/// Request to close own buying store (CZ_REQ_CLOSE_BUYING_STORE).
/// 0815
-static void clif_parse_ReqCloseBuyingStore(int fd, struct map_session_data* sd)
-{
- buyingstore_close(sd);
+void clif_parse_ReqCloseBuyingStore(int fd, struct map_session_data* sd) {
+ buyingstore->close(sd);
}
@@ -15585,7 +15979,7 @@ void clif_buyingstore_disappear_entry(struct map_session_data* sd)
WBUFW(buf,0) = 0x816;
WBUFL(buf,2) = sd->bl.id;
- clif_send(buf, packet_len(0x816), &sd->bl, AREA_WOS);
+ clif->send(buf, packet_len(0x816), &sd->bl, AREA_WOS);
}
void clif_buyingstore_disappear_entry_single(struct map_session_data* sd, struct map_session_data* pl_sd)
{
@@ -15600,13 +15994,13 @@ void clif_buyingstore_disappear_entry_single(struct map_session_data* sd, struct
/// Request to open someone else's buying store (CZ_REQ_CLICK_TO_BUYING_STORE).
/// 0817 <account id>.L
-static void clif_parse_ReqClickBuyingStore(int fd, struct map_session_data* sd)
+void clif_parse_ReqClickBuyingStore(int fd, struct map_session_data* sd)
{
int account_id;
- account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+ account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
- buyingstore_open(sd, account_id);
+ buyingstore->open(sd, account_id);
}
@@ -15638,13 +16032,12 @@ void clif_buyingstore_itemlist(struct map_session_data* sd, struct map_session_d
/// Request to sell items to a buying store (CZ_REQ_TRADE_BUYING_STORE).
/// 0819 <packet len>.W <account id>.L <store id>.L { <index>.W <name id>.W <amount>.W }*
-static void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data* sd)
-{
+void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data* sd) {
const unsigned int blocksize = 6;
uint8* itemlist;
int account_id;
unsigned int count, packet_len, buyer_id;
- struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
+ struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
packet_len = RFIFOW(fd,info->pos[0]);
@@ -15663,12 +16056,12 @@ static void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data* sd)
if( packet_len%blocksize )
{
- ShowError("clif_parse_ReqTradeBuyingStore: Unexpected item list size %u (account_id=%d, buyer_id=%d, block size=%u)\n", packet_len, sd->bl.id, account_id, blocksize);
+ ShowError("clif_parse_ReqTradeBuyingStore: Unexpected item list size %u (account_id=%d, buyer_id=%u, block size=%u)\n", packet_len, sd->bl.id, account_id, blocksize);
return;
}
count = packet_len/blocksize;
- buyingstore_trade(sd, account_id, buyer_id, itemlist, count);
+ buyingstore->trade(sd, account_id, buyer_id, itemlist, count);
}
@@ -15754,14 +16147,13 @@ void clif_buyingstore_trade_failed_seller(struct map_session_data* sd, short res
/// NOTE: The client determines the item ids by specifying a name and optionally,
/// amount of card slots. If the client does not know about the item it
/// cannot be searched.
-static void clif_parse_SearchStoreInfo(int fd, struct map_session_data* sd)
-{
+void clif_parse_SearchStoreInfo(int fd, struct map_session_data* sd) {
const unsigned int blocksize = 2;
const uint8* itemlist;
const uint8* cardlist;
unsigned char type;
unsigned int min_price, max_price, packet_len, count, item_count, card_count;
- struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
+ struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
packet_len = RFIFOW(fd,info->pos[0]);
@@ -15795,7 +16187,7 @@ static void clif_parse_SearchStoreInfo(int fd, struct map_session_data* sd)
return;
}
- searchstore_query(sd, type, min_price, max_price, (const unsigned short*)itemlist, item_count, (const unsigned short*)cardlist, card_count);
+ searchstore->query(sd, type, min_price, max_price, (const unsigned short*)itemlist, item_count, (const unsigned short*)cardlist, card_count);
}
@@ -15820,11 +16212,10 @@ void clif_search_store_info_ack(struct map_session_data* sd)
WFIFOW(fd,0) = 0x836;
WFIFOW(fd,2) = 7+(end-start)*blocksize;
WFIFOB(fd,4) = !sd->searchstore.pages;
- WFIFOB(fd,5) = searchstore_querynext(sd);
+ WFIFOB(fd,5) = searchstore->querynext(sd);
WFIFOB(fd,6) = (unsigned char)min(sd->searchstore.uses, UINT8_MAX);
- for( i = start; i < end; i++ )
- {
+ for( i = start; i < end; i++ ) {
struct s_search_store_info_item* ssitem = &sd->searchstore.items[i];
struct item it;
@@ -15843,7 +16234,7 @@ void clif_search_store_info_ack(struct map_session_data* sd)
it.nameid = ssitem->nameid;
it.amount = ssitem->amount;
- clif_addcards(WFIFOP(fd,i*blocksize+25+MESSAGE_SIZE), &it);
+ clif->addcards(WFIFOP(fd,i*blocksize+25+MESSAGE_SIZE), &it);
}
WFIFOSET(fd,WFIFOW(fd,2));
@@ -15871,9 +16262,9 @@ void clif_search_store_info_failed(struct map_session_data* sd, unsigned char re
/// Request to display next page of results (CZ_SEARCH_STORE_INFO_NEXT_PAGE).
/// 0838
-static void clif_parse_SearchStoreInfoNextPage(int fd, struct map_session_data* sd)
+void clif_parse_SearchStoreInfoNextPage(int fd, struct map_session_data* sd)
{
- searchstore_next(sd);
+ searchstore->next(sd);
}
@@ -15898,25 +16289,25 @@ void clif_open_search_store_info(struct map_session_data* sd)
/// Request to close the store search window (CZ_CLOSE_SEARCH_STORE_INFO).
/// 083b
-static void clif_parse_CloseSearchStoreInfo(int fd, struct map_session_data* sd)
+void clif_parse_CloseSearchStoreInfo(int fd, struct map_session_data* sd)
{
- searchstore_close(sd);
+ searchstore->close(sd);
}
/// Request to invoke catalog effect on a store from search results (CZ_SSILIST_ITEM_CLICK).
/// 083c <account id>.L <store id>.L <nameid>.W
-static void clif_parse_SearchStoreInfoListItemClick(int fd, struct map_session_data* sd)
+void clif_parse_SearchStoreInfoListItemClick(int fd, struct map_session_data* sd)
{
unsigned short nameid;
int account_id, store_id;
- struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
+ struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
account_id = RFIFOL(fd,info->pos[0]);
store_id = RFIFOL(fd,info->pos[1]);
nameid = RFIFOW(fd,info->pos[2]);
- searchstore_click(sd, account_id, store_id, nameid);
+ searchstore->click(sd, account_id, store_id, nameid);
}
@@ -15935,29 +16326,20 @@ void clif_search_store_info_click_ack(struct map_session_data* sd, short x, shor
/// Parse function for packet debugging.
-void clif_parse_debug(int fd,struct map_session_data *sd)
-{
+void clif_parse_debug(int fd,struct map_session_data *sd) {
int cmd, packet_len;
// clif_parse ensures, that there is at least 2 bytes of data
cmd = RFIFOW(fd,0);
- if( sd )
- {
- packet_len = packet_db[sd->packet_ver][cmd].len;
+ if( sd ) {
+ packet_len = packet_db[cmd].len;
- if( packet_len == 0 )
- {// unknown
- packet_len = RFIFOREST(fd);
- }
- else if( packet_len == -1 )
- {// variable length
+ if( packet_len == -1 ) {// variable length
packet_len = RFIFOW(fd,2); // clif_parse ensures, that this amount of data is already received
}
ShowDebug("Packet debug of 0x%04X (length %d), %s session #%d, %d/%d (AID/CID)\n", cmd, packet_len, sd->state.active ? "authed" : "unauthed", fd, sd->status.account_id, sd->status.char_id);
- }
- else
- {
+ } else {
packet_len = RFIFOREST(fd);
ShowDebug("Packet debug of 0x%04X (length %d), session #%d\n", cmd, packet_len, fd);
}
@@ -15980,7 +16362,7 @@ int clif_elementalconverter_list(struct map_session_data *sd) {
WFIFOW(fd, 0)=0x1ad;
for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){
- if( skill_can_produce_mix(sd,skill_produce_db[i].nameid,23, 1) ){
+ if( skill->can_produce_mix(sd,skill_produce_db[i].nameid,23, 1) ){
if((view = itemdb_viewid(skill_produce_db[i].nameid)) > 0)
WFIFOW(fd,c*2+ 4)= view;
else
@@ -16008,7 +16390,7 @@ void clif_millenniumshield(struct map_session_data *sd, short shields ) {
WBUFL(buf,2) = sd->bl.id;
WBUFW(buf,6) = shields;
WBUFW(buf,8) = 0;
- clif_send(buf,packet_len(0x440),&sd->bl,AREA);
+ clif->send(buf,packet_len(0x440),&sd->bl,AREA);
#endif
}
/**
@@ -16046,7 +16428,7 @@ int clif_spellbook_list(struct map_session_data *sd)
}
else{
status_change_end(&sd->bl,SC_STOP,INVALID_TIMER);
- clif_skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK, 0);
+ clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK, 0);
}
return 1;
@@ -16081,7 +16463,7 @@ int clif_magicdecoy_list(struct map_session_data *sd, uint16 skill_lv, short x,
WFIFOW(fd,2) = c * 2 + 4;
WFIFOSET(fd, WFIFOW(fd, 2));
} else {
- clif_skill_fail(sd,NC_MAGICDECOY,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,NC_MAGICDECOY,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -16115,7 +16497,7 @@ int clif_poison_list(struct map_session_data *sd, uint16 skill_lv) {
WFIFOW(fd,2) = c * 2 + 4;
WFIFOSET(fd, WFIFOW(fd, 2));
} else {
- clif_skill_fail(sd,GC_POISONINGWEAPON,USESKILL_FAIL_GUILLONTINE_POISON,0);
+ clif->skill_fail(sd,GC_POISONINGWEAPON,USESKILL_FAIL_GUILLONTINE_POISON,0);
return 0;
}
@@ -16134,7 +16516,7 @@ int clif_autoshadowspell_list(struct map_session_data *sd) {
WFIFOW(fd,0) = 0x442;
for( i = 0, c = 0; i < MAX_SKILL; i++ )
if( sd->status.skill[i].flag == SKILL_FLAG_PLAGIARIZED && sd->status.skill[i].id > 0 &&
- sd->status.skill[i].id < GS_GLITTERING && skill_get_type(sd->status.skill[i].id) == BF_MAGIC )
+ sd->status.skill[i].id < GS_GLITTERING && skill->get_type(sd->status.skill[i].id) == BF_MAGIC )
{ // Can't auto cast both Extended class and 3rd class skills.
WFIFOW(fd,8+c*2) = sd->status.skill[i].id;
c++;
@@ -16148,7 +16530,7 @@ int clif_autoshadowspell_list(struct map_session_data *sd) {
sd->menuskill_val = c;
} else {
status_change_end(&sd->bl,SC_STOP,INVALID_TIMER);
- clif_skill_fail(sd,SC_AUTOSHADOWSPELL,USESKILL_FAIL_IMITATION_SKILL_NONE,0);
+ clif->skill_fail(sd,SC_AUTOSHADOWSPELL,USESKILL_FAIL_IMITATION_SKILL_NONE,0);
}
return 1;
@@ -16182,40 +16564,6 @@ int clif_skill_itemlistwindow( struct map_session_data *sd, uint16 skill_id, uin
return 1;
}
-/**
- * Sends a new status without a tick (currently used by the new mounts)
- **/
-int clif_status_load_notick(struct block_list *bl,int type,int flag,int val1, int val2, int val3) {
- unsigned char buf[32];
-
- nullpo_ret(bl);
-
- WBUFW(buf,0)=0x043f;
- WBUFW(buf,2)=type;
- WBUFL(buf,4)=bl->id;
- WBUFB(buf,8)=flag;
- WBUFL(buf,9) = 0;
- WBUFL(buf,13) = val1;
- WBUFL(buf,17) = val2;
- WBUFL(buf,21) = val3;
-
- clif_send(buf,packet_len(0x043f),bl,AREA);
- return 0;
-}
-//Notifies FD of ID's type
-int clif_status_load_single(int fd, int id,int type,int flag,int val1, int val2, int val3) {
- WFIFOHEAD(fd, packet_len(0x043f));
- WFIFOW(fd,0)=0x043f;
- WFIFOW(fd,2)=type;
- WFIFOL(fd,4)=id;
- WFIFOB(fd,8)=flag;
- WFIFOL(fd,9) = 0;
- WFIFOL(fd,13) = val1;
- WFIFOL(fd,17) = val2;
- WFIFOL(fd,21) = val3;
- WFIFOSET(fd, packet_len(0x043f));
- return 0;
-}
// msgstringtable.txt
// 0x291 <line>.W
void clif_msgtable(int fd, int line) {
@@ -16246,12 +16594,12 @@ void clif_parse_SkillSelectMenu(int fd, struct map_session_data *sd) {
return;
if( pc_istrading(sd) ) {
- clif_skill_fail(sd,sd->ud.skill_id,0,0);
+ clif->skill_fail(sd,sd->ud.skill_id,0,0);
clif_menuskill_clear(sd);
return;
}
- skill_select_menu(sd,RFIFOW(fd,6));
+ skill->select_menu(sd,RFIFOW(fd,6));
clif_menuskill_clear(sd);
}
@@ -16268,7 +16616,7 @@ void clif_talisman(struct map_session_data *sd,short type)
WBUFL(buf,2)=sd->bl.id;
WBUFW(buf,6)=type;
WBUFW(buf,8)=sd->talisman[type];
- clif_send(buf,packet_len(0x08cf),&sd->bl,AREA);
+ clif->send(buf,packet_len(0x08cf),&sd->bl,AREA);
}
/// Move Item from or to Personal Tab (CZ_WHATSOEVER) [FE]
/// 0907 <index>.W
@@ -16298,11 +16646,80 @@ void clif_parse_MoveItem(int fd, struct map_session_data *sd) {
else
return;/* nothing to do. */
- clif_favorite_item(sd, index);
+ clif->favorite_item(sd, index);
#endif
}
-
-
+/* [Ind/Hercules] */
+void clif_cashshop_db(void) {
+ config_t cashshop_conf;
+ config_setting_t *cashshop = NULL;
+ const char *config_filename = "db/cashshop_db.conf"; // FIXME hardcoded name
+ int i;
+ for( i = 0; i < CASHSHOP_TAB_MAX; i++ ) {
+ CREATE(clif->cs.data[i], struct hCSData *, 1);
+ clif->cs.item_count[i] = 0;
+ }
+
+ if (conf_read_file(&cashshop_conf, config_filename)) {
+ ShowError("can't read %s\n", config_filename);
+ return;
+ }
+
+ cashshop = config_lookup(&cashshop_conf, "cash_shop");
+
+ if (cashshop != NULL) {
+ config_setting_t *cats = config_setting_get_elem(cashshop, 0);
+ config_setting_t *cat;
+ int k, item_count_t = 0;
+
+ for(i = 0; i < CASHSHOP_TAB_MAX; i++) {
+ char entry_name[10];
+
+ sprintf(entry_name,"cat_%d",i);
+
+ if( (cat = config_setting_get_member(cats, entry_name)) != NULL ) {
+ int item_count = config_setting_length(cat);
+
+ for(k = 0; k < item_count; k++) {
+ config_setting_t *entry = config_setting_get_elem(cat,k);
+ const char *name = config_setting_name(entry);
+ int price = config_setting_get_int(entry);
+ struct item_data * data = NULL;
+
+ if( price < 1 ) {
+ ShowWarning("cashshop_db: unsupported price '%d' for entry named '%s' in category '%s'\n", price, name, entry_name);
+ continue;
+ }
+
+ if( name[0] == 'I' && name[1] == 'D' && strlen(name) <= 7 ) {
+ if( !( data = itemdb_exists(atoi(name+2))) ) {
+ ShowWarning("cashshop_db: unknown item id '%s' in category '%s'\n", name+2, entry_name);
+ continue;
+ }
+ } else {
+ if( !( data = itemdb_searchname(name) ) ) {
+ ShowWarning("cashshop_db: unknown item name '%s' in category '%s'\n", name, entry_name);
+ continue;
+ }
+ }
+
+
+ RECREATE(clif->cs.data[i], struct hCSData *, ++clif->cs.item_count[i]);
+ CREATE(clif->cs.data[i][ clif->cs.item_count[i] - 1 ], struct hCSData , 1);
+
+ clif->cs.data[i][ clif->cs.item_count[i] - 1 ]->id = data->nameid;
+ clif->cs.data[i][ clif->cs.item_count[i] - 1 ]->price = price;
+ item_count_t++;
+ }
+ } else {
+ ShowError("cashshop_db: category '%s' (%d) not found!!\n",entry_name,i);
+ }
+ }
+
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", item_count_t, config_filename);
+ config_destroy(&cashshop_conf);
+ }
+}
/// Items that are in favorite tab of inventory (ZC_ITEM_FAVORITE).
/// 0900 <index>.W <favorite>.B
void clif_favorite_item(struct map_session_data* sd, unsigned short index) {
@@ -16323,776 +16740,387 @@ void clif_snap( struct block_list *bl, short x, short y ) {
WBUFW(buf,6) = x;
WBUFW(buf,8) = y;
- clif_send(buf,packet_len(0x8d2),bl,AREA);
+ clif->send(buf,packet_len(0x8d2),bl,AREA);
}
-void clif_monster_hp_bar( struct mob_data* md, int fd ) {
-#if PACKETVER >= 20120404
- WFIFOHEAD(fd,packet_len(0x977));
+void clif_monster_hp_bar( struct mob_data* md, struct map_session_data *sd ) {
+ struct packet_monster_hp p;
+
+ p.PacketType = monsterhpType;
+ p.GID = md->bl.id;
+ p.HP = md->status.hp;
+ p.MaxHP = md->status.max_hp;
+
+ clif->send(&p,sizeof(p),&sd->bl,SELF);
+}
+/* [Ind/Hercules] placeholder for unsupported incoming packets (avoids server disconnecting client) */
+void __attribute__ ((unused)) clif_parse_dull(int fd,struct map_session_data *sd) {
+ return;
+}
- WFIFOW(fd,0) = 0x977;
- WFIFOL(fd,2) = md->bl.id;
- WFIFOL(fd,6) = md->status.hp;
- WFIFOL(fd,10) = md->status.max_hp;
+void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) {
+ WFIFOHEAD(fd, 10);
+ WFIFOW(fd, 0) = 0x845;
+ WFIFOL(fd, 2) = sd->cashPoints; //[Ryuuzaki] - switched positions to reflect proper values
+ WFIFOL(fd, 6) = sd->kafraPoints;
+ WFIFOSET(fd, 10);
+}
+
+void clif_parse_CashShopClose(int fd, struct map_session_data *sd) {
+ /* TODO apply some state tracking */
+}
- WFIFOSET(fd,packet_len(0x977));
+void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd) {
+ int i, j = 0;
+
+ for( i = 0; i < CASHSHOP_TAB_MAX; i++ ) {
+ WFIFOHEAD(fd, 8 + ( clif->cs.item_count[i] * 6 ) );
+ WFIFOW(fd, 0) = 0x8ca;
+ WFIFOW(fd, 2) = 8 + ( clif->cs.item_count[i] * 6 );
+ WFIFOW(fd, 4) = clif->cs.item_count[i];
+ WFIFOW(fd, 6) = i;
+
+ for( j = 0; j < clif->cs.item_count[i]; j++ ) {
+ WFIFOW(fd, 8 + ( 6 * j ) ) = clif->cs.data[i][j]->id;
+ WFIFOL(fd, 10 + ( 6 * j ) ) = clif->cs.data[i][j]->price;
+ }
+
+ WFIFOSET(fd, 8 + ( clif->cs.item_count[i] * 6 ));
+ }
+}
+void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
+ unsigned short limit = RFIFOW(fd, 4), i, j;
+ unsigned int kafra_pay = RFIFOL(fd, 6);// [Ryuuzaki] - These are free cash points (strangely #CASH = main cash curreny for us, confusing)
+
+ for(i = 0; i < limit; i++) {
+ int qty = RFIFOL(fd, 14 + ( i * 10 ));
+ int id = RFIFOL(fd, 10 + ( i * 10 ));
+ short tab = RFIFOW(fd, 18 + ( i * 10 ));
+ enum CASH_SHOP_BUY_RESULT result = CSBR_UNKNOWN;
+
+ if( tab < 0 || tab > CASHSHOP_TAB_MAX )
+ continue;
+
+ for( j = 0; j < clif->cs.item_count[tab]; j++ ) {
+ if( clif->cs.data[tab][j]->id == id )
+ break;
+ }
+ if( j < clif->cs.item_count[tab] ) {
+ struct item_data *data;
+ if( sd->kafraPoints < kafra_pay ) {
+ result = CSBR_SHORTTAGE_CASH;
+ } else if( (sd->cashPoints+kafra_pay) < (clif->cs.data[tab][j]->price * qty) ) {
+ result = CSBR_SHORTTAGE_CASH;
+ } else if ( !( data = itemdb_exists(clif->cs.data[tab][j]->id) ) ) {
+ result = CSBR_UNKONWN_ITEM;
+ } else {
+ struct item item_tmp;
+ int k, get_count;
+
+ get_count = qty;
+
+ if (!itemdb_isstackable2(data))
+ get_count = 1;
+
+ pc_paycash(sd, clif->cs.data[tab][j]->price * qty, kafra_pay);// [Ryuuzaki]
+ for (k = 0; k < qty; k += get_count) {
+ if (!pet_create_egg(sd, data->nameid)) {
+ memset(&item_tmp, 0, sizeof(item_tmp));
+ item_tmp.nameid = data->nameid;
+ item_tmp.identify = 1;
+
+ switch (pc_additem(sd, &item_tmp, get_count, LOG_TYPE_NPC)) {
+ case 0:
+ result = CSBR_SUCCESS;
+ break;
+ case 1:
+ result = CSBR_EACHITEM_OVERCOUNT;
+ break;
+ case 2:
+ result = CSBR_INVENTORY_WEIGHT;
+ break;
+ case 4:
+ result = CSBR_INVENTORY_ITEMCNT;
+ break;
+ case 5:
+ result = CSBR_EACHITEM_OVERCOUNT;
+ break;
+ case 7:
+ result = CSBR_RUNE_OVERCOUNT;
+ break;
+ }
+
+ if( result != CSBR_SUCCESS )
+ pc_getcash(sd, clif->cs.data[tab][j]->price * get_count,0);
+ }
+ }
+ }
+ } else {
+ result = CSBR_UNKONWN_ITEM;
+ }
+
+ WFIFOHEAD(fd, 16);
+ WFIFOW(fd, 0) = 0x849;
+ WFIFOL(fd, 2) = id;
+ WFIFOW(fd, 6) = result;/* result */
+ WFIFOL(fd, 8) = sd->cashPoints;/* current cash point */
+ WFIFOL(fd, 12) = sd->kafraPoints;// [Ryuuzaki]
+ WFIFOSET(fd, 16);
+
+ }
+}
+/* [Ind/Hercules] */
+void clif_parse_CashShopReqTab(int fd, struct map_session_data *sd) {
+ short tab = RFIFOW(fd, 2);
+ int j;
+
+ if( tab < 0 || tab > CASHSHOP_TAB_MAX )
+ return;
+
+ WFIFOHEAD(fd, 10 + ( clif->cs.item_count[tab] * 6 ) );
+ WFIFOW(fd, 0) = 0x8c0;
+ WFIFOW(fd, 2) = 10 + ( clif->cs.item_count[tab] * 6 );
+ WFIFOL(fd, 4) = tab;
+ WFIFOW(fd, 8) = clif->cs.item_count[tab];
+
+ for( j = 0; j < clif->cs.item_count[tab]; j++ ) {
+ WFIFOW(fd, 10 + ( 6 * j ) ) = clif->cs.data[tab][j]->id;
+ WFIFOL(fd, 12 + ( 6 * j ) ) = clif->cs.data[tab][j]->price;
+ }
+
+ WFIFOSET(fd, 10 + ( clif->cs.item_count[tab] * 6 ));
+}
+/* [Ind/Hercules] */
+void clif_maptypeproperty2(struct block_list *bl,enum send_target t) {
+#if PACKETVER >= 20121010
+ struct packet_maptypeproperty2 p;
+
+ p.PacketType = maptypeproperty2Type;
+ p.type = 0x28;
+ p.flag.usecart = 1;
+ p.flag.party = 1;
+ p.flag.guild = 1;
+ p.flag.siege = map_flag_gvg2(bl->m) ? 1: 0;
+ p.flag.mineffect = 1;
+ p.flag.nolockon = 0;
+ p.flag.countpk = map[bl->m].flag.pvp ? 1 : 0;
+ p.flag.nopartyformation = 0;
+ p.flag.noitemconsumption = 0;
+ p.flag.summonstarmiracle = 0;
+ p.flag.bg = map[bl->m].flag.battleground ? 1 : 0;
+
+ clif->send(&p,sizeof(p),bl,t);
#endif
}
+void clif_status_change2(struct block_list *bl, int tid, enum send_target target, int type, int val1, int val2, int val3) {
+ struct packet_status_change2 p;
+
+ p.PacketType = status_change2Type;
+ p.index = type;
+ p.AID = tid;
+ p.state = 1;
+ p.Left = -1;// officially its 9999 but -1 is a explicit "no-duration" which behaves best [Ind/Hercules]
+ p.val1 = val1;
+ p.val2 = val2;
+ p.val3 = val3;
+
+ clif->send(&p,sizeof(p), bl, target);
+}
+
+void clif_partytickack(struct map_session_data* sd, bool flag) {
+
+ WFIFOHEAD(sd->fd, packet_len(0x2c9));
+ WFIFOW(sd->fd, 0) = 0x2c9;
+ WFIFOB(sd->fd, 2) = flag;
+ WFIFOSET(sd->fd, packet_len(0x2c9));
+}
+
+void clif_status_change_end(struct block_list *bl, int tid, enum send_target target, int type) {
+ struct packet_status_change_end p;
+
+ p.PacketType = status_change_endType;
+ p.index = type;
+ p.AID = tid;
+ p.state = 0;
+
+ clif->send(&p,sizeof(p), bl, target);
+}
+
/*==========================================
* Main client packet processing function
*------------------------------------------*/
-static int clif_parse(int fd)
-{
- int cmd, packet_ver, packet_len, err;
+int clif_parse(int fd) {
+ int cmd, packet_len;
TBL_PC* sd;
int pnum;
-
+
//TODO apply delays or disconnect based on packet throughput [FlavioJS]
// Note: "click masters" can do 80+ clicks in 10 seconds
-
- for( pnum = 0; pnum < 3; ++pnum )// Limit max packets per cycle to 3 (delay packet spammers) [FlavioJS] -- This actually aids packet spammers, but stuff like /str+ gets slow without it [Ai4rei]
- { // begin main client packet processing loop
-
- sd = (TBL_PC *)session[fd]->session_data;
- if (session[fd]->flag.eof) {
- if (sd) {
- if (sd->state.autotrade) {
- //Disassociate character from the socket connection.
- session[fd]->session_data = NULL;
- sd->fd = 0;
- ShowInfo("Character '"CL_WHITE"%s"CL_RESET"' logged off (using @autotrade).\n", sd->status.name);
- } else
- if (sd->state.active) {
- // Player logout display [Valaris]
- ShowInfo("Character '"CL_WHITE"%s"CL_RESET"' logged off.\n", sd->status.name);
- clif_quitsave(fd, sd);
+
+ for( pnum = 0; pnum < 3; ++pnum ) { // Limit max packets per cycle to 3 (delay packet spammers) [FlavioJS] -- This actually aids packet spammers, but stuff like /str+ gets slow without it [Ai4rei]
+ // begin main client packet processing loop
+
+ sd = (TBL_PC *)session[fd]->session_data;
+ if (session[fd]->flag.eof) {
+ if (sd) {
+ if (sd->state.autotrade) {
+ //Disassociate character from the socket connection.
+ session[fd]->session_data = NULL;
+ sd->fd = 0;
+ ShowInfo("Character '"CL_WHITE"%s"CL_RESET"' logged off (using @autotrade).\n", sd->status.name);
+ } else
+ if (sd->state.active) {
+ // Player logout display [Valaris]
+ ShowInfo("Character '"CL_WHITE"%s"CL_RESET"' logged off.\n", sd->status.name);
+ clif->quitsave(fd, sd);
+ } else {
+ //Unusual logout (during log on/off/map-changer procedure)
+ ShowInfo("Player AID:%d/CID:%d logged off.\n", sd->status.account_id, sd->status.char_id);
+ map_quit(sd);
+ }
} else {
- //Unusual logout (during log on/off/map-changer procedure)
- ShowInfo("Player AID:%d/CID:%d logged off.\n", sd->status.account_id, sd->status.char_id);
- map_quit(sd);
+ ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip2str(session[fd]->client_addr, NULL));
}
- } else {
- ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip2str(session[fd]->client_addr, NULL));
+ do_close(fd);
+ return 0;
}
- do_close(fd);
- return 0;
- }
-
- if (RFIFOREST(fd) < 2)
- return 0;
-
- cmd = RFIFOW(fd,0);
-
- // identify client's packet version
- if (sd) {
- packet_ver = sd->packet_ver;
- } else {
- // check authentification packet to know packet version
- packet_ver = clif_guess_PacketVer(fd, 0, &err);
- if( err ) {// failed to identify packet version
- ShowInfo("clif_parse: Disconnecting session #%d with unknown packet version%s (p:0x%04x,l:%d).\n", fd, (
- err == 1 ? "" :
- err == 2 ? ", possibly for having an invalid account_id" :
- err == 3 ? ", possibly for having an invalid char_id." :
- /* Uncomment when checks are added in clif_guess_PacketVer. [FlavioJS]
- err == 4 ? ", possibly for having an invalid login_id1." :
- err == 5 ? ", possibly for having an invalid client_tick." :
- */
- err == 6 ? ", possibly for having an invalid sex." :
- ". ERROR invalid error code"), cmd, RFIFOREST(fd));
- WFIFOHEAD(fd,packet_len(0x6a));
- WFIFOW(fd,0) = 0x6a;
- WFIFOB(fd,2) = 3; // Rejected from Server
- WFIFOSET(fd,packet_len(0x6a));
-
+
+ if (RFIFOREST(fd) < 2)
+ return 0;
+
+ cmd = RFIFOW(fd,0);
+ // filter out invalid / unsupported packets
+ if (cmd > MAX_PACKET_DB || packet_db[cmd].len == 0) {
+ ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x, %d bytes received), disconnecting session #%d.\n", cmd, RFIFOREST(fd), fd);
#ifdef DUMP_INVALID_PACKET
ShowDump(RFIFOP(fd,0), RFIFOREST(fd));
#endif
-
- RFIFOSKIP(fd, RFIFOREST(fd));
set_eof(fd);
return 0;
}
- }
-
- // filter out invalid / unsupported packets
- if (cmd > MAX_PACKET_DB || packet_db[packet_ver][cmd].len == 0) {
- ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x, %d bytes received), disconnecting session #%d.\n", cmd, RFIFOREST(fd), fd);
+ // determine real packet length
+ packet_len = packet_db[cmd].len;
+ if (packet_len == -1) { // variable-length packet
+ if (RFIFOREST(fd) < 4)
+ return 0;
+
+ packet_len = RFIFOW(fd,2);
+ if (packet_len < 4 || packet_len > 32768) {
+ ShowWarning("clif_parse: Received packet 0x%04x specifies invalid packet_len (%d), disconnecting session #%d.\n", cmd, packet_len, fd);
#ifdef DUMP_INVALID_PACKET
- ShowDump(RFIFOP(fd,0), RFIFOREST(fd));
+ ShowDump(RFIFOP(fd,0), RFIFOREST(fd));
#endif
- set_eof(fd);
- return 0;
- }
-
- // determine real packet length
- packet_len = packet_db[packet_ver][cmd].len;
- if (packet_len == -1) { // variable-length packet
- if (RFIFOREST(fd) < 4)
- return 0;
-
- packet_len = RFIFOW(fd,2);
- if (packet_len < 4 || packet_len > 32768) {
- ShowWarning("clif_parse: Received packet 0x%04x specifies invalid packet_len (%d), disconnecting session #%d.\n", cmd, packet_len, fd);
-#ifdef DUMP_INVALID_PACKET
- ShowDump(RFIFOP(fd,0), RFIFOREST(fd));
-#endif
- set_eof(fd);
- return 0;
+ set_eof(fd);
+ return 0;
+ }
+ }
+ if ((int)RFIFOREST(fd) < packet_len)
+ return 0; // not enough data received to form the packet
+
+ if( packet_db[cmd].func == clif->pDebug )
+ packet_db[cmd].func(fd, sd);
+ else if( packet_db[cmd].func != NULL ) {
+ if( !sd && packet_db[cmd].func != clif->pWantToConnection )
+ ; //Only valid packet when there is no session
+ else
+ if( sd && sd->bl.prev == NULL && packet_db[cmd].func != clif->pLoadEndAck )
+ ; //Only valid packet when player is not on a map
+ else
+ packet_db[cmd].func(fd, sd);
}
- }
- if ((int)RFIFOREST(fd) < packet_len)
- return 0; // not enough data received to form the packet
-
- if( packet_db[packet_ver][cmd].func == clif_parse_debug )
- packet_db[packet_ver][cmd].func(fd, sd);
- else if( packet_db[packet_ver][cmd].func != NULL ) {
- if( !sd && packet_db[packet_ver][cmd].func != clif_parse_WantToConnection )
- ; //Only valid packet when there is no session
- else
- if( sd && sd->bl.prev == NULL && packet_db[packet_ver][cmd].func != clif_parse_LoadEndAck )
- ; //Only valid packet when player is not on a map
- else
- if( sd && session[sd->fd]->flag.eof )
- ; //No more packets accepted
- else
- packet_db[packet_ver][cmd].func(fd, sd);
- }
#ifdef DUMP_UNKNOWN_PACKET
- else {
- const char* packet_txt = "save/packet.txt";
- FILE* fp;
-
- if( ( fp = fopen( packet_txt , "a" ) ) != NULL ) {
- if( sd ) {
- fprintf(fp, "Unknown packet 0x%04X (length %d), %s session #%d, %d/%d (AID/CID)\n", cmd, packet_len, sd->state.active ? "authed" : "unauthed", fd, sd->status.account_id, sd->status.char_id);
- } else {
- fprintf(fp, "Unknown packet 0x%04X (length %d), session #%d\n", cmd, packet_len, fd);
- }
-
- WriteDump(fp, RFIFOP(fd,0), packet_len);
- fprintf(fp, "\n");
- fclose(fp);
- } else {
- ShowError("Failed to write '%s'.\n", packet_txt);
-
- // Dump on console instead
- if( sd ) {
- ShowDebug("Unknown packet 0x%04X (length %d), %s session #%d, %d/%d (AID/CID)\n", cmd, packet_len, sd->state.active ? "authed" : "unauthed", fd, sd->status.account_id, sd->status.char_id);
+ else {
+ const char* packet_txt = "save/packet.txt";
+ FILE* fp;
+
+ if( ( fp = fopen( packet_txt , "a" ) ) != NULL ) {
+ if( sd ) {
+ fprintf(fp, "Unknown packet 0x%04X (length %d), %s session #%d, %d/%d (AID/CID)\n", cmd, packet_len, sd->state.active ? "authed" : "unauthed", fd, sd->status.account_id, sd->status.char_id);
+ } else {
+ fprintf(fp, "Unknown packet 0x%04X (length %d), session #%d\n", cmd, packet_len, fd);
+ }
+
+ WriteDump(fp, RFIFOP(fd,0), packet_len);
+ fprintf(fp, "\n");
+ fclose(fp);
} else {
- ShowDebug("Unknown packet 0x%04X (length %d), session #%d\n", cmd, packet_len, fd);
+ ShowError("Failed to write '%s'.\n", packet_txt);
+
+ // Dump on console instead
+ if( sd ) {
+ ShowDebug("Unknown packet 0x%04X (length %d), %s session #%d, %d/%d (AID/CID)\n", cmd, packet_len, sd->state.active ? "authed" : "unauthed", fd, sd->status.account_id, sd->status.char_id);
+ } else {
+ ShowDebug("Unknown packet 0x%04X (length %d), session #%d\n", cmd, packet_len, fd);
+ }
+
+ ShowDump(RFIFOP(fd,0), packet_len);
}
-
- ShowDump(RFIFOP(fd,0), packet_len);
}
- }
#endif
-
- RFIFOSKIP(fd, packet_len);
-
+
+ RFIFOSKIP(fd, packet_len);
+
}; // main loop end
-
+
return 0;
}
-/*==========================================
- * Reads packet_db.txt and setups its array reference
- *------------------------------------------*/
-static int packetdb_readdb(void)
-{
- FILE *fp;
- char line[1024];
- int ln=0;
- int cmd,i,j,packet_ver;
- int max_cmd=-1;
- int skip_ver = 0;
- int warned = 0;
- char *str[64],*p,*str2[64],*p2,w1[64],w2[64];
- int packet_len_table[MAX_PACKET_DB] = {
- 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0040
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-#if PACKETVER <= 20081217
- 0, 0, 0, 0, 55, 17, 3, 37, 46, -1, 23, -1, 3,110, 3, 2,
-#else
- 0, 0, 0, 0, 55, 17, 3, 37, 46, -1, 23, -1, 3,114, 3, 2,
-#endif
-#if PACKETVER < 2
- 3, 28, 19, 11, 3, -1, 9, 5, 52, 51, 56, 58, 41, 2, 6, 6,
-#elif PACKETVER < 20071106 // 78-7b Lv99 effect for later Kameshima
- 3, 28, 19, 11, 3, -1, 9, 5, 54, 53, 58, 60, 41, 2, 6, 6,
-#elif PACKETVER <= 20081217 // change in 0x78 and 0x7c
- 3, 28, 19, 11, 3, -1, 9, 5, 55, 53, 58, 60, 42, 2, 6, 6,
-#else
- 3, 28, 19, 11, 3, -1, 9, 5, 55, 53, 58, 60, 44, 2, 6, 6,
-#endif
- //#0x0080
- 7, 3, 2, 2, 2, 5, 16, 12, 10, 7, 29, 2, -1, -1, -1, 0, // 0x8b changed to 2 (was 23)
- 7, 22, 28, 2, 6, 30, -1, -1, 3, -1, -1, 5, 9, 17, 17, 6,
-#if PACKETVER <= 20100622
- 23, 6, 6, -1, -1, -1, -1, 8, 7, 6, 7, 4, 7, 0, -1, 6,
-#else
- 23, 6, 6, -1, -1, -1, -1, 8, 7, 6, 9, 4, 7, 0, -1, 6, // 0xaa changed to 9 (was 7)
-#endif
- 8, 8, 3, 3, -1, 6, 6, -1, 7, 6, 2, 5, 6, 44, 5, 3,
- //#0x00C0
- 7, 2, 6, 8, 6, 7, -1, -1, -1, -1, 3, 3, 6, 3, 2, 27, // 0xcd change to 3 (was 6)
- 3, 4, 4, 2, -1, -1, 3, -1, 6, 14, 3, -1, 28, 29, -1, -1,
- 30, 30, 26, 2, 6, 26, 3, 3, 8, 19, 5, 2, 3, 2, 2, 2,
- 3, 2, 6, 8, 21, 8, 8, 2, 2, 26, 3, -1, 6, 27, 30, 10,
- //#0x0100
- 2, 6, 6, 30, 79, 31, 10, 10, -1, -1, 4, 6, 6, 2, 11, -1,
- 10, 39, 4, 10, 31, 35, 10, 18, 2, 13, 15, 20, 68, 2, 3, 16,
- 6, 14, -1, -1, 21, 8, 8, 8, 8, 8, 2, 2, 3, 4, 2, -1,
- 6, 86, 6, -1, -1, 7, -1, 6, 3, 16, 4, 4, 4, 6, 24, 26,
- //#0x0140
- 22, 14, 6, 10, 23, 19, 6, 39, 8, 9, 6, 27, -1, 2, 6, 6,
- 110, 6, -1, -1, -1, -1, -1, 6, -1, 54, 66, 54, 90, 42, 6, 42,
- -1, -1, -1, -1, -1, 30, -1, 3, 14, 3, 30, 10, 43, 14,186,182,
- 14, 30, 10, 3, -1, 6,106, -1, 4, 5, 4, -1, 6, 7, -1, -1,
- //#0x0180
- 6, 3,106, 10, 10, 34, 0, 6, 8, 4, 4, 4, 29, -1, 10, 6,
-#if PACKETVER < 1
- 90, 86, 24, 6, 30,102, 8, 4, 8, 4, 14, 10, -1, 6, 2, 6,
-#else // 196 comodo icon status display for later
- 90, 86, 24, 6, 30,102, 9, 4, 8, 4, 14, 10, -1, 6, 2, 6,
-#endif
-#if PACKETVER < 20081126
- 3, 3, 35, 5, 11, 26, -1, 4, 4, 6, 10, 12, 6, -1, 4, 4,
-#else // 0x1a2 changed (35->37)
- 3, 3, 37, 5, 11, 26, -1, 4, 4, 6, 10, 12, 6, -1, 4, 4,
-#endif
- 11, 7, -1, 67, 12, 18,114, 6, 3, 6, 26, 26, 26, 26, 2, 3,
- //#0x01C0, Set 0x1d5=-1
- 2, 14, 10, -1, 22, 22, 4, 2, 13, 97, 3, 9, 9, 30, 6, 28,
- 8, 14, 10, 35, 6, -1, 4, 11, 54, 53, 60, 2, -1, 47, 33, 6,
- 30, 8, 34, 14, 2, 6, 26, 2, 28, 81, 6, 10, 26, 2, -1, -1,
- -1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10,
- //#0x0200
- 26, -1, 26, 10, 18, 26, 11, 34, 14, 36, 10, 0, 0, -1, 32, 10, // 0x20c change to 0 (was 19)
- 22, 0, 26, 26, 42, 6, 6, 2, 2,282,282, 10, 10, -1, -1, 66,
-#if PACKETVER < 20071106
- 10, -1, -1, 8, 10, 2,282, 18, 18, 15, 58, 57, 64, 5, 71, 5,
-#else // 0x22c changed
- 10, -1, -1, 8, 10, 2,282, 18, 18, 15, 58, 57, 65, 5, 71, 5,
-#endif
- 12, 26, 9, 11, -1, -1, 10, 2,282, 11, 4, 36, 6, -1, 4, 2,
- //#0x0240
- -1, -1, -1, -1, -1, 3, 4, 8, -1, 3, 70, 4, 8, 12, 4, 10,
- 3, 32, -1, 3, 3, 5, 5, 8, 2, 3, -1, 6, 4, 6, 4, 6,
- 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0280
-#if PACKETVER < 20070711
- 0, 0, 0, 6, 14, 0, 0, -1, 6, 8, 18, 0, 0, 0, 0, 0,
-#else
- 0, 0, 0, 6, 14, 0, 0, -1, 10, 12, 18, 0, 0, 0, 0, 0, // 0x288, 0x289 increase by 4 (kafra points)
-#endif
- 0, 4, 0, 70, 10, 0, 0, 0, 8, 6, 27, 80, 0, -1, 0, 0,
- 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 85, -1, -1,107, 6, -1, 7, 7, 22,191, 0, 8, 0, 0, 0, 0,
- //#0x02C0
- 0, -1, 0, 0, 0, 30, 30, 0, 0, 3, 0, 65, 4, 71, 10, 0,
- -1, -1, -1, 0, 29, 0, 6, -1, 10, 10, 3, 0, -1, 32, 6, 36,
- 34, 33, 0, 0, 0, 0, 0, 0, -1, -1, -1, 13, 67, 59, 60, 8,
- 10, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0300
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0340
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0380
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x03C0
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0400
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 25,
- //#0x0440
- 10, 4, -1, 0, 0, 0, 14, 0, 0, 0, 6, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0480
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x04C0
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0500
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25,
- //#0x0540
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0580
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x05C0
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0600
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25,
- //#0x0640
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0680
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x06C0
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0700
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25,
- //#0x0740
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0780
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x07C0
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-#if PACKETVER < 20090617
- 6, 2, -1, 4, 4, 4, 4, 8, 8,254, 6, 8, 6, 54, 30, 54,
-#else // 0x7d9 changed
- 6, 2, -1, 4, 4, 4, 4, 8, 8,268, 6, 8, 6, 54, 30, 54,
-#endif
- 0, 15, 8, 6, -1, 8, 8, 32, -1, 5, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 14, -1, -1, -1, 8, 25, 0, 0, 26, 0,
- //#0x0800
-#if PACKETVER < 20091229
- -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 20,
-#else // for Party booking ( PACKETVER >= 20091229 )
- -1, -1, 18, 4, 8, 6, 2, 4, 14, 50, 18, 6, 2, 3, 14, 20,
-#endif
- 3, -1, 8, -1, 86, 2, 6, 6, -1, -1, 4, 10, 10, 0, 0, 0,
- 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, -1, -1, 3, 2, 66, 5, 2, 12, 6, 0, 0,
- //#0x0840
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0880
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x08C0
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
- 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0900
- 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0940
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0,
-
- };
- struct {
- void (*func)(int, struct map_session_data *);
- char *name;
- } clif_parse_func[]={
- {clif_parse_WantToConnection,"wanttoconnection"},
- {clif_parse_LoadEndAck,"loadendack"},
- {clif_parse_TickSend,"ticksend"},
- {clif_parse_WalkToXY,"walktoxy"},
- {clif_parse_QuitGame,"quitgame"},
- {clif_parse_GetCharNameRequest,"getcharnamerequest"},
- {clif_parse_GlobalMessage,"globalmessage"},
- {clif_parse_MapMove,"mapmove"},
- {clif_parse_ChangeDir,"changedir"},
- {clif_parse_Emotion,"emotion"},
- {clif_parse_HowManyConnections,"howmanyconnections"},
- {clif_parse_ActionRequest,"actionrequest"},
- {clif_parse_Restart,"restart"},
- {clif_parse_WisMessage,"wis"},
- {clif_parse_Broadcast,"broadcast"},
- {clif_parse_TakeItem,"takeitem"},
- {clif_parse_DropItem,"dropitem"},
- {clif_parse_UseItem,"useitem"},
- {clif_parse_EquipItem,"equipitem"},
- {clif_parse_UnequipItem,"unequipitem"},
- {clif_parse_NpcClicked,"npcclicked"},
- {clif_parse_NpcBuySellSelected,"npcbuysellselected"},
- {clif_parse_NpcBuyListSend,"npcbuylistsend"},
- {clif_parse_NpcSellListSend,"npcselllistsend"},
- {clif_parse_CreateChatRoom,"createchatroom"},
- {clif_parse_ChatAddMember,"chataddmember"},
- {clif_parse_ChatRoomStatusChange,"chatroomstatuschange"},
- {clif_parse_ChangeChatOwner,"changechatowner"},
- {clif_parse_KickFromChat,"kickfromchat"},
- {clif_parse_ChatLeave,"chatleave"},
- {clif_parse_TradeRequest,"traderequest"},
- {clif_parse_TradeAck,"tradeack"},
- {clif_parse_TradeAddItem,"tradeadditem"},
- {clif_parse_TradeOk,"tradeok"},
- {clif_parse_TradeCancel,"tradecancel"},
- {clif_parse_TradeCommit,"tradecommit"},
- {clif_parse_StopAttack,"stopattack"},
- {clif_parse_PutItemToCart,"putitemtocart"},
- {clif_parse_GetItemFromCart,"getitemfromcart"},
- {clif_parse_RemoveOption,"removeoption"},
- {clif_parse_ChangeCart,"changecart"},
- {clif_parse_StatusUp,"statusup"},
- {clif_parse_SkillUp,"skillup"},
- {clif_parse_UseSkillToId,"useskilltoid"},
- {clif_parse_UseSkillToPos,"useskilltopos"},
- {clif_parse_UseSkillToPosMoreInfo,"useskilltoposinfo"},
- {clif_parse_UseSkillMap,"useskillmap"},
- {clif_parse_RequestMemo,"requestmemo"},
- {clif_parse_ProduceMix,"producemix"},
- {clif_parse_Cooking,"cooking"},
- {clif_parse_NpcSelectMenu,"npcselectmenu"},
- {clif_parse_NpcNextClicked,"npcnextclicked"},
- {clif_parse_NpcAmountInput,"npcamountinput"},
- {clif_parse_NpcStringInput,"npcstringinput"},
- {clif_parse_NpcCloseClicked,"npccloseclicked"},
- {clif_parse_ItemIdentify,"itemidentify"},
- {clif_parse_SelectArrow,"selectarrow"},
- {clif_parse_AutoSpell,"autospell"},
- {clif_parse_UseCard,"usecard"},
- {clif_parse_InsertCard,"insertcard"},
- {clif_parse_RepairItem,"repairitem"},
- {clif_parse_WeaponRefine,"weaponrefine"},
- {clif_parse_SolveCharName,"solvecharname"},
- {clif_parse_ResetChar,"resetchar"},
- {clif_parse_LocalBroadcast,"localbroadcast"},
- {clif_parse_MoveToKafra,"movetokafra"},
- {clif_parse_MoveFromKafra,"movefromkafra"},
- {clif_parse_MoveToKafraFromCart,"movetokafrafromcart"},
- {clif_parse_MoveFromKafraToCart,"movefromkafratocart"},
- {clif_parse_CloseKafra,"closekafra"},
- {clif_parse_CreateParty,"createparty"},
- {clif_parse_CreateParty2,"createparty2"},
- {clif_parse_PartyInvite,"partyinvite"},
- {clif_parse_PartyInvite2,"partyinvite2"},
- {clif_parse_ReplyPartyInvite,"replypartyinvite"},
- {clif_parse_ReplyPartyInvite2,"replypartyinvite2"},
- {clif_parse_LeaveParty,"leaveparty"},
- {clif_parse_RemovePartyMember,"removepartymember"},
- {clif_parse_PartyChangeOption,"partychangeoption"},
- {clif_parse_PartyMessage,"partymessage"},
- {clif_parse_PartyChangeLeader,"partychangeleader"},
- {clif_parse_CloseVending,"closevending"},
- {clif_parse_VendingListReq,"vendinglistreq"},
- {clif_parse_PurchaseReq,"purchasereq"},
- {clif_parse_PurchaseReq2,"purchasereq2"},
- {clif_parse_OpenVending,"openvending"},
- {clif_parse_CreateGuild,"createguild"},
- {clif_parse_GuildCheckMaster,"guildcheckmaster"},
- {clif_parse_GuildRequestInfo,"guildrequestinfo"},
- {clif_parse_GuildChangePositionInfo,"guildchangepositioninfo"},
- {clif_parse_GuildChangeMemberPosition,"guildchangememberposition"},
- {clif_parse_GuildRequestEmblem,"guildrequestemblem"},
- {clif_parse_GuildChangeEmblem,"guildchangeemblem"},
- {clif_parse_GuildChangeNotice,"guildchangenotice"},
- {clif_parse_GuildInvite,"guildinvite"},
- {clif_parse_GuildReplyInvite,"guildreplyinvite"},
- {clif_parse_GuildLeave,"guildleave"},
- {clif_parse_GuildExpulsion,"guildexpulsion"},
- {clif_parse_GuildMessage,"guildmessage"},
- {clif_parse_GuildRequestAlliance,"guildrequestalliance"},
- {clif_parse_GuildReplyAlliance,"guildreplyalliance"},
- {clif_parse_GuildDelAlliance,"guilddelalliance"},
- {clif_parse_GuildOpposition,"guildopposition"},
- {clif_parse_GuildBreak,"guildbreak"},
- {clif_parse_PetMenu,"petmenu"},
- {clif_parse_CatchPet,"catchpet"},
- {clif_parse_SelectEgg,"selectegg"},
- {clif_parse_SendEmotion,"sendemotion"},
- {clif_parse_ChangePetName,"changepetname"},
-
- {clif_parse_GMKick,"gmkick"},
- {clif_parse_GMHide,"gmhide"},
- {clif_parse_GMReqNoChat,"gmreqnochat"},
- {clif_parse_GMReqAccountName,"gmreqaccname"},
- {clif_parse_GMKickAll,"killall"},
- {clif_parse_GMRecall,"recall"},
- {clif_parse_GMRecall,"summon"},
- {clif_parse_GM_Monster_Item,"itemmonster"},
- {clif_parse_GMShift,"remove"},
- {clif_parse_GMShift,"shift"},
- {clif_parse_GMChangeMapType,"changemaptype"},
- {clif_parse_GMRc,"rc"},
- {clif_parse_GMRecall2,"recall2"},
- {clif_parse_GMRemove2,"remove2"},
-
- {clif_parse_NoviceDoriDori,"sndoridori"},
- {clif_parse_NoviceExplosionSpirits,"snexplosionspirits"},
- {clif_parse_PMIgnore,"wisexin"},
- {clif_parse_PMIgnoreList,"wisexlist"},
- {clif_parse_PMIgnoreAll,"wisall"},
- {clif_parse_FriendsListAdd,"friendslistadd"},
- {clif_parse_FriendsListRemove,"friendslistremove"},
- {clif_parse_FriendsListReply,"friendslistreply"},
- {clif_parse_Blacksmith,"blacksmith"},
- {clif_parse_Alchemist,"alchemist"},
- {clif_parse_Taekwon,"taekwon"},
- {clif_parse_RankingPk,"rankingpk"},
- {clif_parse_FeelSaveOk,"feelsaveok"},
- {clif_parse_debug,"debug"},
- {clif_parse_ChangeHomunculusName,"changehomunculusname"},
- {clif_parse_HomMoveToMaster,"hommovetomaster"},
- {clif_parse_HomMoveTo,"hommoveto"},
- {clif_parse_HomAttack,"homattack"},
- {clif_parse_HomMenu,"hommenu"},
- {clif_parse_StoragePassword,"storagepassword"},
- {clif_parse_Hotkey,"hotkey"},
- {clif_parse_AutoRevive,"autorevive"},
- {clif_parse_Check,"check"},
- {clif_parse_Adopt_request,"adoptrequest"},
- {clif_parse_Adopt_reply,"adoptreply"},
- // MAIL SYSTEM
- {clif_parse_Mail_refreshinbox,"mailrefresh"},
- {clif_parse_Mail_read,"mailread"},
- {clif_parse_Mail_getattach,"mailgetattach"},
- {clif_parse_Mail_delete,"maildelete"},
- {clif_parse_Mail_return,"mailreturn"},
- {clif_parse_Mail_setattach,"mailsetattach"},
- {clif_parse_Mail_winopen,"mailwinopen"},
- {clif_parse_Mail_send,"mailsend"},
- // AUCTION SYSTEM
- {clif_parse_Auction_search,"auctionsearch"},
- {clif_parse_Auction_buysell,"auctionbuysell"},
- {clif_parse_Auction_setitem,"auctionsetitem"},
- {clif_parse_Auction_cancelreg,"auctioncancelreg"},
- {clif_parse_Auction_register,"auctionregister"},
- {clif_parse_Auction_cancel,"auctioncancel"},
- {clif_parse_Auction_close,"auctionclose"},
- {clif_parse_Auction_bid,"auctionbid"},
- // Quest Log System
- {clif_parse_questStateAck,"queststate"},
- {clif_parse_cashshop_buy,"cashshopbuy"},
- {clif_parse_ViewPlayerEquip,"viewplayerequip"},
- {clif_parse_EquipTick,"equiptickbox"},
- {clif_parse_BattleChat,"battlechat"},
- {clif_parse_mercenary_action,"mermenu"},
- {clif_parse_progressbar,"progressbar"},
- {clif_parse_SkillSelectMenu,"skillselectmenu"},
- {clif_parse_ItemListWindowSelected,"itemlistwindowselected"},
-#if PACKETVER >= 20091229
- {clif_parse_PartyBookingRegisterReq,"bookingregreq"},
- {clif_parse_PartyBookingSearchReq,"bookingsearchreq"},
- {clif_parse_PartyBookingUpdateReq,"bookingupdatereq"},
- {clif_parse_PartyBookingDeleteReq,"bookingdelreq"},
-#endif
- {clif_parse_PVPInfo,"pvpinfo"},
- {clif_parse_LessEffect,"lesseffect"},
- // Buying Store
- {clif_parse_ReqOpenBuyingStore,"reqopenbuyingstore"},
- {clif_parse_ReqCloseBuyingStore,"reqclosebuyingstore"},
- {clif_parse_ReqClickBuyingStore,"reqclickbuyingstore"},
- {clif_parse_ReqTradeBuyingStore,"reqtradebuyingstore"},
- // Store Search
- {clif_parse_SearchStoreInfo,"searchstoreinfo"},
- {clif_parse_SearchStoreInfoNextPage,"searchstoreinfonextpage"},
- {clif_parse_CloseSearchStoreInfo,"closesearchstoreinfo"},
- {clif_parse_SearchStoreInfoListItemClick,"searchstoreinfolistitemclick"},
- /* */
- { clif_parse_MoveItem , "moveitem" },
- {NULL,NULL}
- };
-
- // initialize packet_db[SERVER] from hardcoded packet_len_table[] values
- memset(packet_db,0,sizeof(packet_db));
- for( i = 0; i < ARRAYLENGTH(packet_len_table); ++i )
- packet_len(i) = packet_len_table[i];
-
- sprintf(line, "%s/packet_db.txt", db_path);
- if( (fp=fopen(line,"r"))==NULL ){
- ShowFatalError("can't read %s\n", line);
- exit(EXIT_FAILURE);
- }
-
- clif_config.packet_db_ver = MAX_PACKET_VER;
- packet_ver = MAX_PACKET_VER; // read into packet_db's version by default
- while( fgets(line, sizeof(line), fp) )
- {
- ln++;
- if(line[0]=='/' && line[1]=='/')
- continue;
- if (sscanf(line,"%256[^:]: %256[^\r\n]",w1,w2) == 2)
- {
- if(strcmpi(w1,"packet_ver")==0) {
- int prev_ver = packet_ver;
- skip_ver = 0;
- packet_ver = atoi(w2);
- if ( packet_ver > MAX_PACKET_VER )
- { //Check to avoid overflowing. [Skotlex]
- if( (warned&1) == 0 )
- ShowWarning("The packet_db table only has support up to version %d.\n", MAX_PACKET_VER);
- warned &= 1;
- skip_ver = 1;
- }
- else if( packet_ver < 0 )
- {
- if( (warned&2) == 0 )
- ShowWarning("Negative packet versions are not supported.\n");
- warned &= 2;
- skip_ver = 1;
- }
- else if( packet_ver == SERVER )
- {
- if( (warned&4) == 0 )
- ShowWarning("Packet version %d is reserved for server use only.\n", SERVER);
- warned &= 4;
- skip_ver = 1;
- }
-
- if( skip_ver )
- {
- ShowWarning("Skipping packet version %d.\n", packet_ver);
- packet_ver = prev_ver;
- continue;
- }
- // copy from previous version into new version and continue
- // - indicating all following packets should be read into the newer version
- memcpy(&packet_db[packet_ver], &packet_db[prev_ver], sizeof(packet_db[0]));
- continue;
- } else if(strcmpi(w1,"packet_db_ver")==0) {
- if(strcmpi(w2,"default")==0) //This is the preferred version.
- clif_config.packet_db_ver = MAX_PACKET_VER;
- else // to manually set the packet DB version
- clif_config.packet_db_ver = cap_value(atoi(w2), 0, MAX_PACKET_VER);
-
- continue;
- }
- }
-
- if( skip_ver != 0 )
- continue; // Skipping current packet version
-
- memset(str,0,sizeof(str));
- for(j=0,p=line;j<4 && p; ++j)
- {
- str[j]=p;
- p=strchr(p,',');
- if(p) *p++=0;
- }
- if(str[0]==NULL)
- continue;
- cmd=strtol(str[0],(char **)NULL,0);
- if(max_cmd < cmd)
- max_cmd = cmd;
- if(cmd <= 0 || cmd > MAX_PACKET_DB)
- continue;
- if(str[1]==NULL){
- ShowError("packet_db: packet len error\n");
- continue;
- }
-
- packet_db[packet_ver][cmd].len = (short)atoi(str[1]);
-
- if(str[2]==NULL){
- packet_db[packet_ver][cmd].func = NULL;
- ln++;
- continue;
- }
-
- // look up processing function by name
- ARR_FIND( 0, ARRAYLENGTH(clif_parse_func), j, clif_parse_func[j].name != NULL && strcmp(str[2],clif_parse_func[j].name)==0 );
- if( j < ARRAYLENGTH(clif_parse_func) )
- packet_db[packet_ver][cmd].func = clif_parse_func[j].func;
-
- // set the identifying cmd for the packet_db version
- if (strcmp(str[2],"wanttoconnection")==0)
- clif_config.connect_cmd[packet_ver] = cmd;
-
- if(str[3]==NULL){
- ShowError("packet_db: packet error\n");
- exit(EXIT_FAILURE);
- }
- for(j=0,p2=str[3];p2;j++){
- short k;
- str2[j]=p2;
- p2=strchr(p2,':');
- if(p2) *p2++=0;
- k = atoi(str2[j]);
- // if (packet_db[packet_ver][cmd].pos[j] != k && clif_config.prefer_packet_db) // not used for now
-
- if( j >= MAX_PACKET_POS )
- {
- ShowError("Too many positions found for packet 0x%04x (max=%d).\n", cmd, MAX_PACKET_POS);
- break;
- }
-
- packet_db[packet_ver][cmd].pos[j] = k;
- }
- }
- fclose(fp);
- if(max_cmd > MAX_PACKET_DB)
- {
- ShowWarning("Found packets up to 0x%X, ignored 0x%X and above.\n", max_cmd, MAX_PACKET_DB);
- ShowWarning("Please increase MAX_PACKET_DB and recompile.\n");
- }
- if (!clif_config.connect_cmd[clif_config.packet_db_ver])
- { //Locate the nearest version that we still support. [Skotlex]
- for(j = clif_config.packet_db_ver; j >= 0 && !clif_config.connect_cmd[j]; j--);
-
- clif_config.packet_db_ver = j?j:MAX_PACKET_VER;
+static void __attribute__ ((unused)) packetdb_addpacket(short cmd, int len, ...) {
+ va_list va;
+ int i;
+ int pos;
+ pFunc func;
+
+ if (cmd > MAX_PACKET_DB) {
+ ShowError("Packet Error: packet 0x%x is greater than the maximum allowed (0x%x), skipping...\n", cmd, MAX_PACKET_DB);
+ return;
+ }
+
+ packet_db[cmd].len = len;
+
+ va_start(va,len);
+
+ pos = va_arg(va, int);
+
+ if( pos == 0xFFFF ) /* nothing more to do */
+ return;
+
+ va_end(va);
+ va_start(va,len);
+
+ func = va_arg(va,pFunc);
+
+ packet_db[cmd].func = func;
+
+ for (i = 0; i < MAX_PACKET_POS; i++) {
+ pos = va_arg(va, int);
+
+ if (pos == 0xFFFF)
+ break;
+
+ packet_db[cmd].pos[i] = pos;
}
- ShowStatus("Done reading packet database from '"CL_WHITE"%s"CL_RESET"'. Using default packet version: "CL_WHITE"%d"CL_RESET".\n", "packet_db.txt", clif_config.packet_db_ver);
- return 0;
}
-
+void packetdb_loaddb(void) {
+
+ memset(packet_db,0,sizeof(packet_db));
+
+ #define packet(id, size, ...) packetdb_addpacket(id, size, ##__VA_ARGS__, 0xFFFF)
+ #include "packets.h" /* load structure data */
+ #undef packet
+}
+void clif_bc_ready(void) {
+ if( battle_config.display_status_timers )
+ clif->status_change = clif_status_change;
+ else
+ clif->status_change = clif_status_change_notick;
+}
/*==========================================
*
*------------------------------------------*/
int do_init_clif(void) {
- const char* colors[COLOR_MAX] = { "0xFF0000" };
+ const char* colors[COLOR_MAX] = { "0xFF0000", "0x00ff00", "0xffffff" };
int i;
/**
* Setup Color Table (saves unnecessary load of strtoul on every call)
@@ -17101,28 +17129,715 @@ int do_init_clif(void) {
color_table[i] = strtoul(colors[i],NULL,0);
color_table[i] = (color_table[i] & 0x0000FF) << 16 | (color_table[i] & 0x00FF00) | (color_table[i] & 0xFF0000) >> 16;//RGB to BGR
}
-
- clif_config.packet_db_ver = -1; // the main packet version of the DB
- memset(clif_config.connect_cmd, 0, sizeof(clif_config.connect_cmd)); //The default connect command will be determined after reading the packet_db [Skotlex]
-
- memset(packet_db,0,sizeof(packet_db));
- //Using the packet_db file is the only way to set up packets now [Skotlex]
- packetdb_readdb();
-
- set_defaultparse(clif_parse);
- if( make_listen_bind(bind_ip,map_port) == -1 ) {
- ShowFatalError("can't bind game port\n");
+
+ packetdb_loaddb();
+
+ set_defaultparse(clif->parse);
+ if( make_listen_bind(clif->bind_ip,clif->map_port) == -1 ) {
+ ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",clif->map_port);
exit(EXIT_FAILURE);
}
- add_timer_func_list(clif_clearunit_delayed_sub, "clif_clearunit_delayed_sub");
- add_timer_func_list(clif_delayquit, "clif_delayquit");
+ add_timer_func_list(clif->clearunit_delayed_sub, "clif_clearunit_delayed_sub");
+ add_timer_func_list(clif->delayquit, "clif_delayquit");
- delay_clearunit_ers = ers_new(sizeof(struct block_list),"clif.c::delay_clearunit_ers",ERS_OPT_CLEAR);
+ clif->delay_clearunit_ers = ers_new(sizeof(struct block_list),"clif.c::delay_clearunit_ers",ERS_OPT_CLEAR);
+ clif->channel_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, HCHSYS_NAME_LENGTH);
+ hChSys.ally = hChSys.local = hChSys.irc = hChSys.ally_autojoin = hChSys.local_autojoin = false;
+ clif->chann_config_read();
+
return 0;
}
void do_final_clif(void) {
- ers_destroy(delay_clearunit_ers);
+ DBIterator *iter = db_iterator(clif->channel_db);
+ struct hChSysCh *channel;
+ unsigned char i;
+
+ for( channel = dbi_first(iter); dbi_exists(iter); channel = dbi_next(iter) ) {
+ clif->chsys_delete(channel);
+ }
+
+ dbi_destroy(iter);
+
+ for(i = 0; i < hChSys.colors_count; i++) {
+ aFree(hChSys.colors_name[i]);
+ }
+
+ if( hChSys.colors_count ) {
+ aFree(hChSys.colors_name);
+ aFree(hChSys.colors);
+ }
+
+ db_destroy(clif->channel_db);
+ ers_destroy(clif->delay_clearunit_ers);
+
+ for(i = 0; i < CASHSHOP_TAB_MAX; i++) {
+ int k;
+ for( k = 0; k < clif->cs.item_count[i]; k++ ) {
+ aFree(clif->cs.data[i][k]);
+ }
+ aFree(clif->cs.data[i]);
+ }
+
+}
+void clif_defaults(void) {
+ clif = &clif_s;
+ /* vars */
+ clif->bind_ip = INADDR_ANY;
+ clif->map_port = 5121;
+ /* core */
+ clif->init = do_init_clif;
+ clif->final = do_final_clif;
+ clif->setip = clif_setip;
+ clif->setbindip = clif_setbindip;
+ clif->setport = clif_setport;
+ clif->refresh_ip = clif_refresh_ip;
+ clif->send = clif_send;
+ clif->send_sub = clif_send_sub;
+ clif->parse = clif_parse;
+ /* auth */
+ clif->authok = clif_authok;
+ clif->authrefuse = clif_authrefuse;
+ clif->authfail_fd = clif_authfail_fd;
+ clif->charselectok = clif_charselectok;
+ /* item-related */
+ clif->dropflooritem = clif_dropflooritem;
+ clif->clearflooritem = clif_clearflooritem;
+ clif->additem = clif_additem;
+ clif->dropitem = clif_dropitem;
+ clif->delitem = clif_delitem;
+ clif->takeitem = clif_takeitem;
+ clif->arrowequip = clif_arrowequip;
+ clif->arrow_fail = clif_arrow_fail;
+ clif->use_card = clif_use_card;
+ clif->cart_additem = clif_cart_additem;
+ clif->cart_delitem = clif_cart_delitem;
+ clif->equipitemack = clif_equipitemack;
+ clif->unequipitemack = clif_unequipitemack;
+ clif->useitemack = clif_useitemack;
+ clif->addcards = clif_addcards;
+ clif->addcards2 = clif_addcards2;
+ clif->item_sub = clif_item_sub;
+ clif->getareachar_item = clif_getareachar_item;
+ /* unit-related */
+ clif->clearunit_single = clif_clearunit_single;
+ clif->clearunit_area = clif_clearunit_area;
+ clif->clearunit_delayed = clif_clearunit_delayed;
+ clif->walkok = clif_walkok;
+ clif->move = clif_move;
+ clif->move2 = clif_move2;
+ clif->blown = clif_blown;
+ clif->slide = clif_slide;
+ clif->fixpos = clif_fixpos;
+ clif->changelook = clif_changelook;
+ clif->changetraplook = clif_changetraplook;
+ clif->refreshlook = clif_refreshlook;
+ clif->class_change = clif_class_change;
+ clif->skill_setunit = clif_skill_setunit;
+ clif->skill_delunit = clif_skill_delunit;
+ clif->skillunit_update = clif_skillunit_update;
+ clif->clearunit_delayed_sub = clif_clearunit_delayed_sub;
+ clif->set_unit_idle = clif_set_unit_idle;
+ clif->spawn_unit = clif_spawn_unit;
+ clif->set_unit_walking = clif_set_unit_walking;
+ clif->calc_walkdelay = clif_calc_walkdelay;
+ clif->getareachar_skillunit = clif_getareachar_skillunit;
+ clif->getareachar_unit = clif_getareachar_unit;
+ clif->clearchar_skillunit = clif_clearchar_skillunit;
+ clif->getareachar = clif_getareachar;
+ /* main unit spawn */
+ clif->spawn = clif_spawn;
+ /* map-related */
+ clif->changemap = clif_changemap;
+ clif->changemapcell = clif_changemapcell;
+ clif->map_property = clif_map_property;
+ clif->pvpset = clif_pvpset;
+ clif->map_property_mapall = clif_map_property_mapall;
+ clif->bossmapinfo = clif_bossmapinfo;
+ clif->map_type = clif_map_type;
+ clif->maptypeproperty2 = clif_maptypeproperty2;
+ /* multi-map-server */
+ clif->changemapserver = clif_changemapserver;
+ /* npc-shop-related */
+ clif->npcbuysell = clif_npcbuysell;
+ clif->buylist = clif_buylist;
+ clif->selllist = clif_selllist;
+ clif->cashshop_show = clif_cashshop_show;
+ clif->npc_buy_result = clif_npc_buy_result;
+ clif->npc_sell_result = clif_npc_sell_result;
+ clif->cashshop_ack = clif_cashshop_ack;
+ /* npc-script-related */
+ clif->scriptmes = clif_scriptmes;
+ clif->scriptnext = clif_scriptnext;
+ clif->scriptclose = clif_scriptclose;
+ clif->scriptmenu = clif_scriptmenu;
+ clif->scriptinput = clif_scriptinput;
+ clif->scriptinputstr = clif_scriptinputstr;
+ clif->cutin = clif_cutin;
+ clif->sendfakenpc = clif_sendfakenpc;
+ /* client-user-interface-related */
+ clif->viewpoint = clif_viewpoint;
+ clif->damage = clif_damage;
+ clif->sitting = clif_sitting;
+ clif->standing = clif_standing;
+ clif->arrow_create_list = clif_arrow_create_list;
+ clif->refresh = clif_refresh;
+ clif->fame_blacksmith = clif_fame_blacksmith;
+ clif->fame_alchemist = clif_fame_alchemist;
+ clif->fame_taekwon = clif_fame_taekwon;
+ clif->hotkeys = clif_hotkeys_send;
+ clif->insight = clif_insight;
+ clif->outsight = clif_outsight;
+ clif->skillcastcancel = clif_skillcastcancel;
+ clif->skill_fail = clif_skill_fail;
+ clif->skill_cooldown = clif_skill_cooldown;
+ clif->skill_memomessage = clif_skill_memomessage;
+ clif->skill_teleportmessage = clif_skill_teleportmessage;
+ clif->skill_produce_mix_list = clif_skill_produce_mix_list;
+ clif->cooking_list = clif_cooking_list;
+ clif->autospell = clif_autospell;
+ clif->combo_delay = clif_combo_delay;
+ clif->status_change = clif_status_change;
+ clif->insert_card = clif_insert_card;
+ clif->inventorylist = clif_inventorylist;
+ clif->equiplist = clif_equiplist;
+ clif->cartlist = clif_cartlist;
+ clif->favorite_item = clif_favorite_item;
+ clif->clearcart = clif_clearcart;
+ clif->item_identify_list = clif_item_identify_list;
+ clif->item_identified = clif_item_identified;
+ clif->item_repair_list = clif_item_repair_list;
+ clif->item_repaireffect = clif_item_repaireffect;
+ clif->item_damaged = clif_item_damaged;
+ clif->item_refine_list = clif_item_refine_list;
+ clif->item_skill = clif_item_skill;
+ clif->mvp_item = clif_mvp_item;
+ clif->mvp_exp = clif_mvp_exp;
+ clif->mvp_noitem = clif_mvp_noitem;
+ clif->changed_dir = clif_changed_dir;
+ clif->charnameack = clif_charnameack;
+ clif->monster_hp_bar = clif_monster_hp_bar;
+ clif->hpmeter = clif_hpmeter;
+ clif->hpmeter_single = clif_hpmeter_single;
+ clif->hpmeter_sub = clif_hpmeter_sub;
+ clif->upgrademessage = clif_upgrademessage;
+ clif->get_weapon_view = clif_get_weapon_view;
+ clif->gospel_info = clif_gospel_info;
+ clif->feel_req = clif_feel_req;
+ clif->starskill = clif_starskill;
+ clif->feel_info = clif_feel_info;
+ clif->hate_info = clif_hate_info;
+ clif->mission_info = clif_mission_info;
+ clif->feel_hate_reset = clif_feel_hate_reset;
+ clif->partytickack = clif_partytickack;
+ clif->equiptickack = clif_equiptickack;
+ clif->viewequip_ack = clif_viewequip_ack;
+ clif->viewequip_fail = clif_viewequip_fail;
+ clif->equipcheckbox = clif_equipcheckbox;
+ clif->displayexp = clif_displayexp;
+ clif->font = clif_font;
+ clif->progressbar = clif_progressbar;
+ clif->progressbar_abort = clif_progressbar_abort;
+ clif->showdigit = clif_showdigit;
+ clif->elementalconverter_list = clif_elementalconverter_list;
+ clif->spellbook_list = clif_spellbook_list;
+ clif->magicdecoy_list = clif_magicdecoy_list;
+ clif->poison_list = clif_poison_list;
+ clif->autoshadowspell_list = clif_autoshadowspell_list;
+ clif->skill_itemlistwindow = clif_skill_itemlistwindow;
+ clif->sc_load = clif_status_change2;
+ clif->sc_end = clif_status_change_end;
+ clif->initialstatus = clif_initialstatus;
+ /* player-unit-specific-related */
+ clif->updatestatus = clif_updatestatus;
+ clif->changestatus = clif_changestatus;
+ clif->statusupack = clif_statusupack;
+ clif->movetoattack = clif_movetoattack;
+ clif->solved_charname = clif_solved_charname;
+ clif->charnameupdate = clif_charnameupdate;
+ clif->delayquit = clif_delayquit;
+ clif->getareachar_pc = clif_getareachar_pc;
+ clif->disconnect_ack = clif_disconnect_ack;
+ clif->PVPInfo = clif_PVPInfo;
+ clif->blacksmith = clif_blacksmith;
+ clif->alchemist = clif_alchemist;
+ clif->taekwon = clif_taekwon;
+ clif->ranking_pk = clif_ranking_pk;
+ clif->quitsave = clif_quitsave;
+ /* visual effects client-side */
+ clif->misceffect = clif_misceffect;
+ clif->changeoption = clif_changeoption;
+ clif->changeoption2 = clif_changeoption2;
+ clif->emotion = clif_emotion;
+ clif->talkiebox = clif_talkiebox;
+ clif->wedding_effect = clif_wedding_effect;
+ clif->divorced = clif_divorced;
+ clif->callpartner = clif_callpartner;
+ clif->skill_damage = clif_skill_damage;
+ clif->skill_nodamage = clif_skill_nodamage;
+ clif->skill_poseffect = clif_skill_poseffect;
+ clif->skill_estimation = clif_skill_estimation;
+ clif->skill_warppoint = clif_skill_warppoint;
+ clif->skillcasting = clif_skillcasting;
+ clif->produce_effect = clif_produceeffect;
+ clif->devotion = clif_devotion;
+ clif->spiritball = clif_spiritball;
+ clif->spiritball_single = clif_spiritball_single;
+ clif->bladestop = clif_bladestop;
+ clif->mvp_effect = clif_mvp_effect;
+ clif->heal = clif_heal;
+ clif->resurrection = clif_resurrection;
+ clif->refine = clif_refine;
+ clif->weather = clif_weather;
+ clif->specialeffect = clif_specialeffect;
+ clif->specialeffect_single = clif_specialeffect_single;
+ clif->specialeffect_value = clif_specialeffect_value;
+ clif->millenniumshield = clif_millenniumshield;
+ clif->talisman = clif_talisman;
+ clif->talisman_single = clif_talisman_single;
+ clif->snap = clif_snap;
+ clif->weather_check = clif_weather_check;
+ /* sound effects client-side */
+ clif->playBGM = clif_playBGM;
+ clif->soundeffect = clif_soundeffect;
+ clif->soundeffectall = clif_soundeffectall;
+ /* chat/message-related */
+ clif->GlobalMessage = clif_GlobalMessage;
+ clif->createchat = clif_createchat;
+ clif->dispchat = clif_dispchat;
+ clif->joinchatfail = clif_joinchatfail;
+ clif->joinchatok = clif_joinchatok;
+ clif->addchat = clif_addchat;
+ clif->changechatowner = clif_changechatowner;
+ clif->clearchat = clif_clearchat;
+ clif->leavechat = clif_leavechat;
+ clif->changechatstatus = clif_changechatstatus;
+ clif->wis_message = clif_wis_message;
+ clif->wis_end = clif_wis_end;
+ clif->disp_onlyself = clif_disp_onlyself;
+ clif->disp_message = clif_disp_message;
+ clif->broadcast = clif_broadcast;
+ clif->broadcast2 = clif_broadcast2;
+ clif->messagecolor = clif_messagecolor;
+ clif->disp_overhead = clif_disp_overhead;
+ clif->msg = clif_msg;
+ clif->msg_value = clif_msg_value;
+ clif->msg_skill = clif_msg_skill;
+ clif->msgtable = clif_msgtable;
+ clif->msgtable_num = clif_msgtable_num;
+ clif->message = clif_displaymessage;
+ clif->messageln = clif_displaymessage2;
+ clif->colormes = clif_colormes;
+ clif->process_message = clif_process_message;
+ clif->wisexin = clif_wisexin;
+ clif->wisall = clif_wisall;
+ clif->PMIgnoreList = clif_PMIgnoreList;
+ /* trade handling */
+ clif->traderequest = clif_traderequest;
+ clif->tradestart = clif_tradestart;
+ clif->tradeadditem = clif_tradeadditem;
+ clif->tradeitemok = clif_tradeitemok;
+ clif->tradedeal_lock = clif_tradedeal_lock;
+ clif->tradecancelled = clif_tradecancelled;
+ clif->tradecompleted = clif_tradecompleted;
+ clif->tradeundo = clif_tradeundo;
+ /* vending handling */
+ clif->openvendingreq = clif_openvendingreq;
+ clif->showvendingboard = clif_showvendingboard;
+ clif->closevendingboard = clif_closevendingboard;
+ clif->vendinglist = clif_vendinglist;
+ clif->buyvending = clif_buyvending;
+ clif->openvending = clif_openvending;
+ clif->vendingreport = clif_vendingreport;
+ /* storage handling */
+ clif->storagelist = clif_storagelist;
+ clif->updatestorageamount = clif_updatestorageamount;
+ clif->storageitemadded = clif_storageitemadded;
+ clif->storageitemremoved = clif_storageitemremoved;
+ clif->storageclose = clif_storageclose;
+ /* skill-list handling */
+ clif->skillinfoblock = clif_skillinfoblock;
+ clif->skillup = clif_skillup;
+ clif->skillinfo = clif_skillinfo;
+ clif->addskill = clif_addskill;
+ clif->deleteskill = clif_deleteskill;
+ /* party-specific */
+ clif->party_created = clif_party_created;
+ clif->party_member_info = clif_party_member_info;
+ clif->party_info = clif_party_info;
+ clif->party_invite = clif_party_invite;
+ clif->party_inviteack = clif_party_inviteack;
+ clif->party_option = clif_party_option;
+ clif->party_withdraw = clif_party_withdraw;
+ clif->party_message = clif_party_message;
+ clif->party_xy = clif_party_xy;
+ clif->party_xy_single = clif_party_xy_single;
+ clif->party_hp = clif_party_hp;
+ clif->party_xy_remove = clif_party_xy_remove;
+ clif->party_show_picker = clif_party_show_picker;
+ clif->partyinvitationstate = clif_partyinvitationstate;
+ /* guild-specific */
+ clif->guild_created = clif_guild_created;
+ clif->guild_belonginfo = clif_guild_belonginfo;
+ clif->guild_masterormember = clif_guild_masterormember;
+ clif->guild_basicinfo = clif_guild_basicinfo;
+ clif->guild_allianceinfo = clif_guild_allianceinfo;
+ clif->guild_memberlist = clif_guild_memberlist;
+ clif->guild_skillinfo = clif_guild_skillinfo;
+ clif->guild_send_onlineinfo = clif_guild_send_onlineinfo;
+ clif->guild_memberlogin_notice = clif_guild_memberlogin_notice;
+ clif->guild_invite = clif_guild_invite;
+ clif->guild_inviteack = clif_guild_inviteack;
+ clif->guild_leave = clif_guild_leave;
+ clif->guild_expulsion = clif_guild_expulsion;
+ clif->guild_positionchanged = clif_guild_positionchanged;
+ clif->guild_memberpositionchanged = clif_guild_memberpositionchanged;
+ clif->guild_emblem = clif_guild_emblem;
+ clif->guild_emblem_area = clif_guild_emblem_area;
+ clif->guild_notice = clif_guild_notice;
+ clif->guild_message = clif_guild_message;
+ clif->guild_skillup = clif_guild_skillup;
+ clif->guild_reqalliance = clif_guild_reqalliance;
+ clif->guild_allianceack = clif_guild_allianceack;
+ clif->guild_delalliance = clif_guild_delalliance;
+ clif->guild_oppositionack = clif_guild_oppositionack;
+ clif->guild_broken = clif_guild_broken;
+ clif->guild_xy = clif_guild_xy;
+ clif->guild_xy_single = clif_guild_xy_single;
+ clif->guild_xy_remove = clif_guild_xy_remove;
+ clif->guild_positionnamelist = clif_guild_positionnamelist;
+ clif->guild_positioninfolist = clif_guild_positioninfolist;
+ clif->guild_expulsionlist = clif_guild_expulsionlist;
+ clif->validate_emblem = clif_validate_emblem;
+ /* battleground-specific */
+ clif->bg_hp = clif_bg_hp;
+ clif->bg_xy = clif_bg_xy;
+ clif->bg_xy_remove = clif_bg_xy_remove;
+ clif->bg_message = clif_bg_message;
+ clif->bg_updatescore = clif_bg_updatescore;
+ clif->bg_updatescore_single = clif_bg_updatescore_single;
+ clif->sendbgemblem_area = clif_sendbgemblem_area;
+ clif->sendbgemblem_single = clif_sendbgemblem_single;
+ /* instance-related */
+ clif->instance = clif_instance;
+ clif->instance_join = clif_instance_join;
+ clif->instance_leave = clif_instance_leave;
+ /* pet-related */
+ clif->catch_process = clif_catch_process;
+ clif->pet_roulette = clif_pet_roulette;
+ clif->sendegg = clif_sendegg;
+ clif->send_petstatus = clif_send_petstatus;
+ clif->send_petdata = clif_send_petdata;
+ clif->pet_emotion = clif_pet_emotion;
+ clif->pet_food = clif_pet_food;
+ /* friend-related */
+ clif->friendslist_toggle_sub = clif_friendslist_toggle_sub;
+ clif->friendslist_send = clif_friendslist_send;
+ clif->friendslist_reqack = clif_friendslist_reqack;
+ clif->friendslist_toggle = clif_friendslist_toggle;
+ clif->friendlist_req = clif_friendlist_req;
+ /* gm-related */
+ clif->GM_kickack = clif_GM_kickack;
+ clif->GM_kick = clif_GM_kick;
+ clif->manner_message = clif_manner_message;
+ clif->GM_silence = clif_GM_silence;
+ clif->account_name = clif_account_name;
+ clif->check = clif_check;
+ /* hom-related */
+ clif->hominfo = clif_hominfo;
+ clif->homskillinfoblock = clif_homskillinfoblock;
+ clif->homskillup = clif_homskillup;
+ clif->hom_food = clif_hom_food;
+ clif->send_homdata = clif_send_homdata;
+ /* questlog-related */
+ clif->quest_send_list = clif_quest_send_list;
+ clif->quest_send_mission = clif_quest_send_mission;
+ clif->quest_add = clif_quest_add;
+ clif->quest_delete = clif_quest_delete;
+ clif->quest_update_status = clif_quest_update_status;
+ clif->quest_update_objective = clif_quest_update_objective;
+ clif->quest_show_event = clif_quest_show_event;
+ /* mail-related */
+ clif->mail_window = clif_Mail_window;
+ clif->mail_read = clif_Mail_read;
+ clif->mail_delete = clif_Mail_delete;
+ clif->mail_return = clif_Mail_return;
+ clif->mail_send = clif_Mail_send;
+ clif->mail_new = clif_Mail_new;
+ clif->mail_refreshinbox = clif_Mail_refreshinbox;
+ clif->mail_getattachment = clif_Mail_getattachment;
+ clif->mail_setattachment = clif_Mail_setattachment;
+ /* auction-related */
+ clif->auction_openwindow = clif_Auction_openwindow;
+ clif->auction_results = clif_Auction_results;
+ clif->auction_message = clif_Auction_message;
+ clif->auction_close = clif_Auction_close;
+ clif->auction_setitem = clif_Auction_setitem;
+ /* mercenary-related */
+ clif->mercenary_info = clif_mercenary_info;
+ clif->mercenary_skillblock = clif_mercenary_skillblock;
+ clif->mercenary_message = clif_mercenary_message;
+ clif->mercenary_updatestatus = clif_mercenary_updatestatus;
+ /* item rental */
+ clif->rental_time = clif_rental_time;
+ clif->rental_expired = clif_rental_expired;
+ /* party booking related */
+ clif->PartyBookingRegisterAck = clif_PartyBookingRegisterAck;
+ clif->PartyBookingDeleteAck = clif_PartyBookingDeleteAck;
+ clif->PartyBookingSearchAck = clif_PartyBookingSearchAck;
+ clif->PartyBookingUpdateNotify = clif_PartyBookingUpdateNotify;
+ clif->PartyBookingDeleteNotify = clif_PartyBookingDeleteNotify;
+ clif->PartyBookingInsertNotify = clif_PartyBookingInsertNotify;
+ /* buying store-related */
+ clif->buyingstore_open = clif_buyingstore_open;
+ clif->buyingstore_open_failed = clif_buyingstore_open_failed;
+ clif->buyingstore_myitemlist = clif_buyingstore_myitemlist;
+ clif->buyingstore_entry = clif_buyingstore_entry;
+ clif->buyingstore_entry_single = clif_buyingstore_entry_single;
+ clif->buyingstore_disappear_entry = clif_buyingstore_disappear_entry;
+ clif->buyingstore_disappear_entry_single = clif_buyingstore_disappear_entry_single;
+ clif->buyingstore_itemlist = clif_buyingstore_itemlist;
+ clif->buyingstore_trade_failed_buyer = clif_buyingstore_trade_failed_buyer;
+ clif->buyingstore_update_item = clif_buyingstore_update_item;
+ clif->buyingstore_delete_item = clif_buyingstore_delete_item;
+ clif->buyingstore_trade_failed_seller = clif_buyingstore_trade_failed_seller;
+ /* search store-related */
+ clif->search_store_info_ack = clif_search_store_info_ack;
+ clif->search_store_info_failed = clif_search_store_info_failed;
+ clif->open_search_store_info = clif_open_search_store_info;
+ clif->search_store_info_click_ack = clif_search_store_info_click_ack;
+ /* elemental-related */
+ clif->elemental_info = clif_elemental_info;
+ clif->elemental_updatestatus = clif_elemental_updatestatus;
+ /* misc-handling */
+ clif->adopt_reply = clif_Adopt_reply;
+ clif->adopt_request = clif_Adopt_request;
+ clif->readbook = clif_readbook;
+ clif->notify_time = clif_notify_time;
+ clif->user_count = clif_user_count;
+ clif->noask_sub = clif_noask_sub;
+ clif->chsys_create = clif_hercules_chsys_create;
+ clif->chsys_msg = clif_hercules_chsys_msg;
+ clif->chsys_msg2 = clif_hercules_chsys_msg2;
+ clif->chsys_send = clif_hercules_chsys_send;
+ clif->chsys_join = clif_hercules_chsys_join;
+ clif->chsys_left = clif_hercules_chsys_left;
+ clif->chsys_delete = clif_hercules_chsys_delete;
+ clif->chsys_mjoin = clif_hercules_chsys_mjoin;
+ clif->chsys_quit = clif_hercules_chsys_quit;
+ clif->chsys_quitg = clif_hercules_chsys_quitg;
+ clif->chsys_gjoin = clif_hercules_chsys_gjoin;
+ clif->chsys_gleave = clif_hercules_chsys_gleave;
+ clif->cashshop_load = clif_cashshop_db;
+ clif->bc_ready = clif_bc_ready;
+ clif->undisguise_timer = clif_undisguise_timer;
+ /*------------------------
+ *- Parse Incoming Packet
+ *------------------------*/
+ clif->pWantToConnection = clif_parse_WantToConnection;
+ clif->pLoadEndAck = clif_parse_LoadEndAck;
+ clif->pTickSend = clif_parse_TickSend;
+ clif->pHotkey = clif_parse_Hotkey;
+ clif->pProgressbar = clif_parse_progressbar;
+ clif->pWalkToXY = clif_parse_WalkToXY;
+ clif->pQuitGame = clif_parse_QuitGame;
+ clif->pGetCharNameRequest = clif_parse_GetCharNameRequest;
+ clif->pGlobalMessage = clif_parse_GlobalMessage;
+ clif->pMapMove = clif_parse_MapMove;
+ clif->pChangeDir = clif_parse_ChangeDir;
+ clif->pEmotion = clif_parse_Emotion;
+ clif->pHowManyConnections = clif_parse_HowManyConnections;
+ clif->pActionRequest = clif_parse_ActionRequest;
+ clif->pActionRequest_sub = clif_parse_ActionRequest_sub;
+ clif->pRestart = clif_parse_Restart;
+ clif->pWisMessage = clif_parse_WisMessage;
+ clif->pBroadcast = clif_parse_Broadcast;
+ clif->pTakeItem = clif_parse_TakeItem;
+ clif->pDropItem = clif_parse_DropItem;
+ clif->pUseItem = clif_parse_UseItem;
+ clif->pEquipItem = clif_parse_EquipItem;
+ clif->pUnequipItem = clif_parse_UnequipItem;
+ clif->pNpcClicked = clif_parse_NpcClicked;
+ clif->pNpcBuySellSelected = clif_parse_NpcBuySellSelected;
+ clif->pNpcBuyListSend = clif_parse_NpcBuyListSend;
+ clif->pNpcSellListSend = clif_parse_NpcSellListSend;
+ clif->pCreateChatRoom = clif_parse_CreateChatRoom;
+ clif->pChatAddMember = clif_parse_ChatAddMember;
+ clif->pChatRoomStatusChange = clif_parse_ChatRoomStatusChange;
+ clif->pChangeChatOwner = clif_parse_ChangeChatOwner;
+ clif->pKickFromChat = clif_parse_KickFromChat;
+ clif->pChatLeave = clif_parse_ChatLeave;
+ clif->pTradeRequest = clif_parse_TradeRequest;
+ clif->pTradeAck = clif_parse_TradeAck;
+ clif->pTradeAddItem = clif_parse_TradeAddItem;
+ clif->pTradeOk = clif_parse_TradeOk;
+ clif->pTradeCancel = clif_parse_TradeCancel;
+ clif->pTradeCommit = clif_parse_TradeCommit;
+ clif->pStopAttack = clif_parse_StopAttack;
+ clif->pPutItemToCart = clif_parse_PutItemToCart;
+ clif->pGetItemFromCart = clif_parse_GetItemFromCart;
+ clif->pRemoveOption = clif_parse_RemoveOption;
+ clif->pChangeCart = clif_parse_ChangeCart;
+ clif->pStatusUp = clif_parse_StatusUp;
+ clif->pSkillUp = clif_parse_SkillUp;
+ clif->pUseSkillToId = clif_parse_UseSkillToId;
+ clif->pUseSkillToId_homun = clif_parse_UseSkillToId_homun;
+ clif->pUseSkillToId_mercenary = clif_parse_UseSkillToId_mercenary;
+ clif->pUseSkillToPos = clif_parse_UseSkillToPos;
+ clif->pUseSkillToPosSub = clif_parse_UseSkillToPosSub;
+ clif->pUseSkillToPos_homun = clif_parse_UseSkillToPos_homun;
+ clif->pUseSkillToPos_mercenary = clif_parse_UseSkillToPos_mercenary;
+ clif->pUseSkillToPosMoreInfo = clif_parse_UseSkillToPosMoreInfo;
+ clif->pUseSkillMap = clif_parse_UseSkillMap;
+ clif->pRequestMemo = clif_parse_RequestMemo;
+ clif->pProduceMix = clif_parse_ProduceMix;
+ clif->pCooking = clif_parse_Cooking;
+ clif->pRepairItem = clif_parse_RepairItem;
+ clif->pWeaponRefine = clif_parse_WeaponRefine;
+ clif->pNpcSelectMenu = clif_parse_NpcSelectMenu;
+ clif->pNpcNextClicked = clif_parse_NpcNextClicked;
+ clif->pNpcAmountInput = clif_parse_NpcAmountInput;
+ clif->pNpcStringInput = clif_parse_NpcStringInput;
+ clif->pNpcCloseClicked = clif_parse_NpcCloseClicked;
+ clif->pItemIdentify = clif_parse_ItemIdentify;
+ clif->pSelectArrow = clif_parse_SelectArrow;
+ clif->pAutoSpell = clif_parse_AutoSpell;
+ clif->pUseCard = clif_parse_UseCard;
+ clif->pInsertCard = clif_parse_InsertCard;
+ clif->pSolveCharName = clif_parse_SolveCharName;
+ clif->pResetChar = clif_parse_ResetChar;
+ clif->pLocalBroadcast = clif_parse_LocalBroadcast;
+ clif->pMoveToKafra = clif_parse_MoveToKafra;
+ clif->pMoveFromKafra = clif_parse_MoveFromKafra;
+ clif->pMoveToKafraFromCart = clif_parse_MoveToKafraFromCart;
+ clif->pMoveFromKafraToCart = clif_parse_MoveFromKafraToCart;
+ clif->pCloseKafra = clif_parse_CloseKafra;
+ clif->pStoragePassword = clif_parse_StoragePassword;
+ clif->pCreateParty = clif_parse_CreateParty;
+ clif->pCreateParty2 = clif_parse_CreateParty2;
+ clif->pPartyInvite = clif_parse_PartyInvite;
+ clif->pPartyInvite2 = clif_parse_PartyInvite2;
+ clif->pReplyPartyInvite = clif_parse_ReplyPartyInvite;
+ clif->pReplyPartyInvite2 = clif_parse_ReplyPartyInvite2;
+ clif->pLeaveParty = clif_parse_LeaveParty;
+ clif->pRemovePartyMember = clif_parse_RemovePartyMember;
+ clif->pPartyChangeOption = clif_parse_PartyChangeOption;
+ clif->chann_config_read = read_channels_config;
+ clif->pPartyMessage = clif_parse_PartyMessage;
+ clif->pPartyChangeLeader = clif_parse_PartyChangeLeader;
+ clif->pPartyBookingRegisterReq = clif_parse_PartyBookingRegisterReq;
+ clif->pPartyBookingSearchReq = clif_parse_PartyBookingSearchReq;
+ clif->pPartyBookingDeleteReq = clif_parse_PartyBookingDeleteReq;
+ clif->pPartyBookingUpdateReq = clif_parse_PartyBookingUpdateReq;
+ clif->pCloseVending = clif_parse_CloseVending;
+ clif->pVendingListReq = clif_parse_VendingListReq;
+ clif->pPurchaseReq = clif_parse_PurchaseReq;
+ clif->pPurchaseReq2 = clif_parse_PurchaseReq2;
+ clif->pOpenVending = clif_parse_OpenVending;
+ clif->pCreateGuild = clif_parse_CreateGuild;
+ clif->pGuildCheckMaster = clif_parse_GuildCheckMaster;
+ clif->pGuildRequestInfo = clif_parse_GuildRequestInfo;
+ clif->pGuildChangePositionInfo = clif_parse_GuildChangePositionInfo;
+ clif->pGuildChangeMemberPosition = clif_parse_GuildChangeMemberPosition;
+ clif->pGuildRequestEmblem = clif_parse_GuildRequestEmblem;
+ clif->pGuildChangeEmblem = clif_parse_GuildChangeEmblem;
+ clif->pGuildChangeNotice = clif_parse_GuildChangeNotice;
+ clif->pGuildInvite = clif_parse_GuildInvite;
+ clif->pGuildReplyInvite = clif_parse_GuildReplyInvite;
+ clif->pGuildLeave = clif_parse_GuildLeave;
+ clif->pGuildExpulsion = clif_parse_GuildExpulsion;
+ clif->pGuildMessage = clif_parse_GuildMessage;
+ clif->pGuildRequestAlliance = clif_parse_GuildRequestAlliance;
+ clif->pGuildReplyAlliance = clif_parse_GuildReplyAlliance;
+ clif->pGuildDelAlliance = clif_parse_GuildDelAlliance;
+ clif->pGuildOpposition = clif_parse_GuildOpposition;
+ clif->pGuildBreak = clif_parse_GuildBreak;
+ clif->pPetMenu = clif_parse_PetMenu;
+ clif->pCatchPet = clif_parse_CatchPet;
+ clif->pSelectEgg = clif_parse_SelectEgg;
+ clif->pSendEmotion = clif_parse_SendEmotion;
+ clif->pChangePetName = clif_parse_ChangePetName;
+ clif->pGMKick = clif_parse_GMKick;
+ clif->pGMKickAll = clif_parse_GMKickAll;
+ clif->pGMShift = clif_parse_GMShift;
+ clif->pGMRemove2 = clif_parse_GMRemove2;
+ clif->pGMRecall = clif_parse_GMRecall;
+ clif->pGMRecall2 = clif_parse_GMRecall2;
+ clif->pGM_Monster_Item = clif_parse_GM_Monster_Item;
+ clif->pGMHide = clif_parse_GMHide;
+ clif->pGMReqNoChat = clif_parse_GMReqNoChat;
+ clif->pGMRc = clif_parse_GMRc;
+ clif->pGMReqAccountName = clif_parse_GMReqAccountName;
+ clif->pGMChangeMapType = clif_parse_GMChangeMapType;
+ clif->pPMIgnore = clif_parse_PMIgnore;
+ clif->pPMIgnoreAll = clif_parse_PMIgnoreAll;
+ clif->pPMIgnoreList = clif_parse_PMIgnoreList;
+ clif->pNoviceDoriDori = clif_parse_NoviceDoriDori;
+ clif->pNoviceExplosionSpirits = clif_parse_NoviceExplosionSpirits;
+ clif->pFriendsListAdd = clif_parse_FriendsListAdd;
+ clif->pFriendsListReply = clif_parse_FriendsListReply;
+ clif->pFriendsListRemove = clif_parse_FriendsListRemove;
+ clif->pPVPInfo = clif_parse_PVPInfo;
+ clif->pBlacksmith = clif_parse_Blacksmith;
+ clif->pAlchemist = clif_parse_Alchemist;
+ clif->pTaekwon = clif_parse_Taekwon;
+ clif->pRankingPk = clif_parse_RankingPk;
+ clif->pFeelSaveOk = clif_parse_FeelSaveOk;
+ clif->pChangeHomunculusName = clif_parse_ChangeHomunculusName;
+ clif->pHomMoveToMaster = clif_parse_HomMoveToMaster;
+ clif->pHomMoveTo = clif_parse_HomMoveTo;
+ clif->pHomAttack = clif_parse_HomAttack;
+ clif->pHomMenu = clif_parse_HomMenu;
+ clif->pAutoRevive = clif_parse_AutoRevive;
+ clif->pCheck = clif_parse_Check;
+ clif->pMail_refreshinbox = clif_parse_Mail_refreshinbox;
+ clif->pMail_read = clif_parse_Mail_read;
+ clif->pMail_getattach = clif_parse_Mail_getattach;
+ clif->pMail_delete = clif_parse_Mail_delete;
+ clif->pMail_return = clif_parse_Mail_return;
+ clif->pMail_setattach = clif_parse_Mail_setattach;
+ clif->pMail_winopen = clif_parse_Mail_winopen;
+ clif->pMail_send = clif_parse_Mail_send;
+ clif->pAuction_cancelreg = clif_parse_Auction_cancelreg;
+ clif->pAuction_setitem = clif_parse_Auction_setitem;
+ clif->pAuction_register = clif_parse_Auction_register;
+ clif->pAuction_cancel = clif_parse_Auction_cancel;
+ clif->pAuction_close = clif_parse_Auction_close;
+ clif->pAuction_bid = clif_parse_Auction_bid;
+ clif->pAuction_search = clif_parse_Auction_search;
+ clif->pAuction_buysell = clif_parse_Auction_buysell;
+ clif->pcashshop_buy = clif_parse_cashshop_buy;
+ clif->pAdopt_request = clif_parse_Adopt_request;
+ clif->pAdopt_reply = clif_parse_Adopt_reply;
+ clif->pViewPlayerEquip = clif_parse_ViewPlayerEquip;
+ clif->pEquipTick = clif_parse_EquipTick;
+ clif->pquestStateAck = clif_parse_questStateAck;
+ clif->pmercenary_action = clif_parse_mercenary_action;
+ clif->pBattleChat = clif_parse_BattleChat;
+ clif->pLessEffect = clif_parse_LessEffect;
+ clif->pItemListWindowSelected = clif_parse_ItemListWindowSelected;
+ clif->pReqOpenBuyingStore = clif_parse_ReqOpenBuyingStore;
+ clif->pReqCloseBuyingStore = clif_parse_ReqCloseBuyingStore;
+ clif->pReqClickBuyingStore = clif_parse_ReqClickBuyingStore;
+ clif->pReqTradeBuyingStore = clif_parse_ReqTradeBuyingStore;
+ clif->pSearchStoreInfo = clif_parse_SearchStoreInfo;
+ clif->pSearchStoreInfoNextPage = clif_parse_SearchStoreInfoNextPage;
+ clif->pCloseSearchStoreInfo = clif_parse_CloseSearchStoreInfo;
+ clif->pSearchStoreInfoListItemClick = clif_parse_SearchStoreInfoListItemClick;
+ clif->pDebug = clif_parse_debug;
+ clif->pSkillSelectMenu = clif_parse_SkillSelectMenu;
+ clif->pMoveItem = clif_parse_MoveItem;
+ /* RagExe Cash Shop [Ind/Hercules] */
+ clif->pCashShopOpen = clif_parse_CashShopOpen;
+ clif->pCashShopClose = clif_parse_CashShopClose;
+ clif->pCashShopReqTab = clif_parse_CashShopReqTab;
+ clif->pCashShopSchedule = clif_parse_CashShopSchedule;
+ clif->pCashShopBuy = clif_parse_CashShopBuy;
+ /* */
+ clif->pPartyTick = clif_parse_PartyTick;
+ clif->pGuildInvite2 = clif_parse_GuildInvite2;
+ /* dull */
+ clif->pDull = clif_parse_dull;
}