Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: clif.c
- ===================================================================
- --- clif.c (revisão 16294)
- +++ clif.c (cópia de trabalho)
- @@ -9325,6 +9325,19 @@
- }
- +/// Server's tick (ZC_NOTIFY_TIME).
- +/// 007f <time>.L
- +void clif_notify_time(struct map_session_data* sd, unsigned long time)
- +{
- + int fd = sd->fd;
- +
- + WFIFOHEAD(fd,packet_len(0x7f));
- + WFIFOW(fd,0) = 0x7f;
- + WFIFOL(fd,2) = time;
- + WFIFOSET(fd,packet_len(0x7f));
- +}
- +
- +
- /// Request for server's tick.
- /// 007e <client tick>.L (CZ_REQUEST_TIME)
- /// 0360 <client tick>.L (CZ_REQUEST_TIME2)
- @@ -9333,12 +9346,7 @@
- {
- sd->client_tick = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- - WFIFOHEAD(fd, packet_len(0x7f));
- - WFIFOW(fd,0)=0x7f;
- - WFIFOL(fd,2)=gettick();
- - WFIFOSET(fd,packet_len(0x7f));
- - // removed until the socket problems are fixed. [FlavioJS]
- - //flush_fifo(fd); // try to send immediatly so the client gets more accurate "pings"
- + clif_notify_time(sd, gettick());
- }
- @@ -9460,25 +9468,38 @@
- }
- +/// Notification about the result of a disconnect request (ZC_ACK_REQ_DISCONNECT).
- +/// 018b <result>.W
- +/// result:
- +/// 0 = disconnect (quit)
- +/// 1 = cannot disconnect (wait 10 seconds)
- +/// ? = ignored
- +void clif_disconnect_ack(struct map_session_data* sd, short result)
- +{
- + int fd = sd->fd;
- +
- + WFIFOHEAD(fd,packet_len(0x18b));
- + WFIFOW(fd,0) = 0x18b;
- + WFIFOW(fd,2) = result;
- + WFIFOSET(fd,packet_len(0x18b));
- +}
- +
- +
- /// Request to disconnect from server (CZ_REQ_DISCONNECT).
- /// 018a <type>.W
- /// type:
- /// 0 = quit
- void clif_parse_QuitGame(int fd, struct map_session_data *sd)
- {
- - WFIFOHEAD(fd,packet_len(0x18b));
- - WFIFOW(fd,0) = 0x18b;
- -
- /* 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] &&
- + if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] &&
- (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
- {
- set_eof(fd);
- - WFIFOW(fd,2)=0;
- + clif_disconnect_ack(sd, 0);
- } else {
- - WFIFOW(fd,2)=1;
- + clif_disconnect_ack(sd, 1);
- }
- - WFIFOSET(fd,packet_len(0x18b));
- }
- @@ -9688,15 +9709,25 @@
- }
- +/// 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)
- +{
- + int fd = sd->fd;
- +
- + WFIFOHEAD(fd,packet_len(0xc2));
- + WFIFOW(fd,0) = 0xc2;
- + WFIFOL(fd,2) = count;
- + WFIFOSET(fd,packet_len(0xc2));
- +}
- +
- +
- /// /w /who (CZ_REQ_USER_COUNT).
- /// Request to display amount of currently connected players.
- /// 00c1
- void clif_parse_HowManyConnections(int fd, struct map_session_data *sd)
- {
- - WFIFOHEAD(fd,packet_len(0xc2));
- - WFIFOW(fd,0) = 0xc2;
- - WFIFOL(fd,2) = map_getusers();
- - WFIFOSET(fd,packet_len(0xc2));
- + clif_user_count(sd, map_getusers());
- }
- @@ -9820,16 +9851,12 @@
- 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] &&
- + if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] &&
- (!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 {
- - WFIFOHEAD(fd,packet_len(0x18b));
- - WFIFOW(fd,0)=0x18b;
- - WFIFOW(fd,2)=1;
- -
- - WFIFOSET(fd,packet_len(0x018b));
- + clif_disconnect_ack(sd, 1);
- }
- break;
- }
- @@ -10205,14 +10232,26 @@
- }
- +/// Notification about the result of a purchase attempt from an NPC shop (ZC_PC_PURCHASE_RESULT).
- +/// 00ca <result>.B
- +/// result:
- +/// 0 = "The deal has successfully completed."
- +/// 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)
- +{
- + int fd = sd->fd;
- +
- + WFIFOHEAD(fd,packet_len(0xca));
- + WFIFOW(fd,0) = 0xca;
- + WFIFOB(fd,2) = result;
- + WFIFOSET(fd,packet_len(0xca));
- +}
- +
- +
- /// Request to buy chosen items from npc shop (CZ_PC_PURCHASE_ITEMLIST).
- /// 00c8 <packet len>.W { <amount>.W <name id>.W }*
- -///
- -/// R 00ca <result>.b
- -/// result = 00 -> "The deal has successfully completed."
- -/// result = 01 -> "You do not have enough zeny."
- -/// result = 02 -> "You are over your Weight Limit."
- -/// result = 03 -> "Out of the maximum capacity, you have too many items."
- void clif_parse_NpcBuyListSend(int fd, struct map_session_data* sd)
- {
- int n = (RFIFOW(fd,2)-4) /4;
- @@ -10226,19 +10265,28 @@
- sd->npc_shopid = 0; //Clear shop data.
- - WFIFOHEAD(fd,packet_len(0xca));
- - WFIFOW(fd,0) = 0xca;
- + clif_npc_buy_result(sd, result);
- +}
- +
- +
- +/// Notification about the result of a sell attempt to an NPC shop (ZC_PC_SELL_RESULT).
- +/// 00cb <result>.B
- +/// 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)
- +{
- + int fd = sd->fd;
- +
- + WFIFOHEAD(fd,packet_len(0xcb));
- + WFIFOW(fd,0) = 0xcb;
- WFIFOB(fd,2) = result;
- - WFIFOSET(fd,packet_len(0xca));
- + WFIFOSET(fd,packet_len(0xcb));
- }
- /// Request to sell chosen items to npc shop (CZ_PC_SELL_ITEMLIST).
- /// 00c9 <packet len>.W { <index>.W <amount>.W }*
- -///
- -/// S 00cb <result>.B
- -/// result = 00 -> "The deal has successfully completed."
- -/// result = 01 -> "The deal has failed."
- void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
- {
- int fail=0,n;
- @@ -10254,10 +10302,7 @@
- sd->npc_shopid = 0; //Clear shop data.
- - WFIFOHEAD(fd,packet_len(0xcb));
- - WFIFOW(fd,0)=0xcb;
- - WFIFOB(fd,2)=fail;
- - WFIFOSET(fd,packet_len(0xcb));
- + clif_npc_sell_result(sd, fail);
- }
- @@ -12427,25 +12472,31 @@
- }
- -/// GM requesting account name (for right-click gm menu) (CZ_REQ_ACCOUNTNAME).
- -/// 01df <account id>.L
- /// Result of request to resolve account name (ZC_ACK_ACCOUNTNAME).
- /// 01e0 <account id>.L <account name>.24B
- -void clif_parse_GMReqAccountName(int fd, struct map_session_data *sd)
- +void clif_account_name(struct map_session_data* sd, int account_id, const char* accname)
- {
- - int tid;
- - tid = RFIFOL(fd,2);
- + int fd = sd->fd;
- - //TODO: find out if this works for any player or only for authorized GMs
- -
- WFIFOHEAD(fd,packet_len(0x1e0));
- WFIFOW(fd,0) = 0x1e0;
- - WFIFOL(fd,2) = tid;
- - safestrncpy((char*)WFIFOP(fd,6), "", 24); // insert account name here >_<
- - WFIFOSET(fd, packet_len(0x1e0));
- + WFIFOL(fd,2) = account_id;
- + safestrncpy((char*)WFIFOP(fd,6), accname, NAME_LENGTH);
- + WFIFOSET(fd,packet_len(0x1e0));
- }
- +/// GM requesting account name (for right-click gm menu) (CZ_REQ_ACCOUNTNAME).
- +/// 01df <account id>.L
- +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 >_<
- +}
- +
- +
- /// /changemaptype <x> <y> <type> (CZ_CHANGE_MAPTYPE).
- /// GM single cell type change request.
- /// 0198 <x>.W <y>.W <type>.W
- @@ -12484,17 +12535,11 @@
- nick = (char*)RFIFOP(fd,2); // speed up
- nick[NAME_LENGTH-1] = '\0'; // to be sure that the player name has at most 23 characters
- type = RFIFOB(fd,26);
- -
- - // FIXME: Use clif_wisexin.
- - WFIFOHEAD(fd,packet_len(0xd1));
- - WFIFOW(fd,0) = 0x0d1;
- - WFIFOB(fd,2) = type;
- if( type == 0 )
- { // Add name to ignore list (block)
- if (strcmp(wisp_server_name, nick) == 0) {
- - WFIFOB(fd,3) = 1; // fail
- - WFIFOSET(fd, packet_len(0x0d1));
- + clif_wisexin(sd, type, 1); // fail
- return;
- }
- @@ -12502,22 +12547,18 @@
- 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
- - WFIFOB(fd,3) = 2; // fail
- - WFIFOSET(fd, packet_len(0x0d1));
- + clif_wisexin(sd, type, 2); // too many blocks
- return;
- }
- if( sd->ignore[i].name[0] != '\0' )
- {// name already exists
- - WFIFOB(fd,3) = 0; // Aegis reports success.
- - WFIFOSET(fd, packet_len(0x0d1));
- + clif_wisexin(sd, type, 0); // Aegis reports success.
- return;
- }
- //Insert in position i
- safestrncpy(sd->ignore[i].name, nick, NAME_LENGTH);
- - WFIFOB(fd,3) = 0; // success
- - WFIFOSET(fd, packet_len(0x0d1));
- }
- else
- { // Remove name from ignore list (unblock)
- @@ -12526,18 +12567,16 @@
- 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
- - WFIFOB(fd,3) = 1; // fail
- - WFIFOSET(fd, packet_len(0x0d1));
- + clif_wisexin(sd, type, 1); // fail
- return;
- }
- // move everything one place down to overwrite removed entry
- memmove(sd->ignore[i].name, sd->ignore[i+1].name, (MAX_IGNORE_LIST-i-1)*sizeof(sd->ignore[0].name));
- // wipe last entry
- memset(sd->ignore[MAX_IGNORE_LIST-1].name, 0, sizeof(sd->ignore[0].name));
- + }
- - WFIFOB(fd,3) = 0; // success
- - WFIFOSET(fd, packet_len(0x0d1));
- - }
- + clif_wisexin(sd, type, 0); // success
- }
- @@ -12549,57 +12588,64 @@
- /// 1 = (/inall) allow all speech
- void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd)
- {
- - // FIXME: Use clif_wisall.
- - WFIFOHEAD(fd,packet_len(0xd2));
- - WFIFOW(fd,0) = 0x0d2;
- - WFIFOB(fd,2) = RFIFOB(fd,2);
- + int type = RFIFOB(fd,2), flag;
- - if( RFIFOB(fd,2) == 0 )
- + if( type == 0 )
- {// Deny all
- if( sd->state.ignoreAll ) {
- - WFIFOB(fd,3) = 1; // fail
- + flag = 1; // fail
- } else {
- sd->state.ignoreAll = 1;
- - WFIFOB(fd,3) = 0; // success
- + flag = 0; // success
- }
- }
- else
- {//Unblock everyone
- if( sd->state.ignoreAll ) {
- sd->state.ignoreAll = 0;
- - WFIFOB(fd,3) = 0; // success
- + flag = 0; // success
- } else {
- if (sd->ignore[0].name[0] != '\0')
- { //Wipe the ignore list.
- memset(sd->ignore, 0, sizeof(sd->ignore));
- - WFIFOB(fd,3) = 0; // success
- + flag = 0; // success
- } else {
- - WFIFOB(fd,3) = 1; // fail
- + flag = 1; // fail
- }
- }
- }
- - WFIFOSET(fd, packet_len(0x0d2));
- + clif_wisall(sd, type, flag);
- }
- -/// Whisper ignore list request (CZ_REQ_WHISPER_LIST).
- -/// 00d3
- -void clif_parse_PMIgnoreList(int fd,struct map_session_data *sd)
- +/// Whisper ignore list (ZC_WHISPER_LIST).
- +/// 00d4 <packet len>.W { <char name>.24B }*
- +void clif_PMIgnoreList(struct map_session_data* sd)
- {
- - int i;
- + int i, fd = sd->fd;
- - WFIFOHEAD(fd, 4 + (NAME_LENGTH * MAX_IGNORE_LIST));
- + WFIFOHEAD(fd,4+ARRAYLENGTH(sd->ignore)*NAME_LENGTH);
- WFIFOW(fd,0) = 0xd4;
- - for(i = 0; i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0'; i++)
- - memcpy(WFIFOP(fd, 4 + i * NAME_LENGTH),sd->ignore[i].name, NAME_LENGTH);
- + 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);
- + }
- - WFIFOW(fd,2) = 4 + i * NAME_LENGTH;
- - WFIFOSET(fd, WFIFOW(fd,2));
- + WFIFOW(fd,2) = 4+i*NAME_LENGTH;
- + WFIFOSET(fd,WFIFOW(fd,2));
- }
- +/// Whisper ignore list request (CZ_REQ_WHISPER_LIST).
- +/// 00d3
- +void clif_parse_PMIgnoreList(int fd,struct map_session_data *sd)
- +{
- + clif_PMIgnoreList(sd);
- +}
- +
- +
- /// Request to invoke the /doridori recovery bonus (CZ_DORIDORI).
- /// 01e7
- void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd)
- @@ -12743,12 +12789,27 @@
- }
- +/// 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)
- +{
- + int fd = sd->fd;
- +
- + WFIFOHEAD(fd,packet_len(0x207));
- + WFIFOW(fd,0) = 0x207;
- + WFIFOL(fd,2) = account_id;
- + WFIFOL(fd,6) = char_id;
- + memcpy(WFIFOP(fd,10), name, NAME_LENGTH);
- + WFIFOSET(fd,packet_len(0x207));
- +}
- +
- +
- /// Request to add a player as friend (CZ_ADD_FRIENDS).
- /// 0202 <name>.24B
- void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd)
- {
- struct map_session_data *f_sd;
- - int i, f_fd;
- + int i;
- f_sd = map_nick2sd((char*)RFIFOP(fd,2));
- @@ -12785,16 +12846,13 @@
- }
- }
- - f_sd->friend_req = sd->status.char_id;
- - sd->friend_req = f_sd->status.char_id;
- + if (i == MAX_FRIENDS) {
- + //No space, list full.
- + clif_friendslist_reqack(sd, f_sd, 2);
- + return;
- + }
- - f_fd = f_sd->fd;
- - WFIFOHEAD(f_fd,packet_len(0x207));
- - WFIFOW(f_fd,0) = 0x207;
- - WFIFOL(f_fd,2) = sd->status.account_id;
- - WFIFOL(f_fd,6) = sd->status.char_id;
- - memcpy(WFIFOP(f_fd,10), sd->status.name, NAME_LENGTH);
- - WFIFOSET(f_fd, packet_len(0x207));
- + clif_friendlist_req(f_sd, sd->status.account_id, sd->status.char_id, sd->status.name);
- }
- @@ -12931,12 +12989,12 @@
- }
- -/// /pvpinfo (CZ_REQ_PVPPOINT).
- -/// 020f <char id>.L <account id>.L
- /// /pvpinfo list (ZC_ACK_PVPPOINT).
- /// 0210 <char id>.L <account id>.L <win point>.L <lose point>.L <point>.L
- -void clif_parse_PVPInfo(int fd,struct map_session_data *sd)
- +void clif_PVPInfo(struct map_session_data* sd)
- {
- + int fd = sd->fd;
- +
- WFIFOHEAD(fd,packet_len(0x210));
- WFIFOW(fd,0) = 0x210;
- WFIFOL(fd,2) = sd->status.char_id;
- @@ -12948,13 +13006,20 @@
- }
- -/// /blacksmith (CZ_BLACKSMITH_RANK).
- -/// 0217
- +/// /pvpinfo (CZ_REQ_PVPPOINT).
- +/// 020f <char id>.L <account id>.L
- +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);
- +}
- +
- +
- /// /blacksmith list (ZC_BLACKSMITH_RANK).
- /// 0219 { <name>.24B }*10 { <point>.L }*10
- -void clif_parse_Blacksmith(int fd,struct map_session_data *sd)
- +void clif_blacksmith(struct map_session_data* sd)
- {
- - int i;
- + int i, fd = sd->fd;
- const char* name;
- WFIFOHEAD(fd,packet_len(0x219));
- @@ -12981,11 +13046,20 @@
- }
- +/// /blacksmith (CZ_BLACKSMITH_RANK).
- +/// 0217
- +void clif_parse_Blacksmith(int fd,struct map_session_data *sd)
- +{
- + clif_blacksmith(sd);
- +}
- +
- +
- /// Notification about backsmith points (ZC_BLACKSMITH_POINT).
- /// 021b <points>.L <total points>.L
- void clif_fame_blacksmith(struct map_session_data *sd, int points)
- {
- int fd = sd->fd;
- +
- WFIFOHEAD(fd,packet_len(0x21b));
- WFIFOW(fd,0) = 0x21b;
- WFIFOL(fd,2) = points;
- @@ -12994,13 +13068,11 @@
- }
- -/// /alchemist (CZ_ALCHEMIST_RANK).
- -/// 0218
- /// /alchemist list (ZC_ALCHEMIST_RANK).
- /// 021a { <name>.24B }*10 { <point>.L }*10
- -void clif_parse_Alchemist(int fd,struct map_session_data *sd)
- +void clif_alchemist(struct map_session_data* sd)
- {
- - int i;
- + int i, fd = sd->fd;
- const char* name;
- WFIFOHEAD(fd,packet_len(0x21a));
- @@ -13027,11 +13099,20 @@
- }
- +/// /alchemist (CZ_ALCHEMIST_RANK).
- +/// 0218
- +void clif_parse_Alchemist(int fd,struct map_session_data *sd)
- +{
- + clif_alchemist(sd);
- +}
- +
- +
- /// Notification about alchemist points (ZC_ALCHEMIST_POINT).
- /// 021c <points>.L <total points>.L
- void clif_fame_alchemist(struct map_session_data *sd, int points)
- {
- int fd = sd->fd;
- +
- WFIFOHEAD(fd,packet_len(0x21c));
- WFIFOW(fd,0) = 0x21c;
- WFIFOL(fd,2) = points;
- @@ -13040,13 +13121,11 @@
- }
- -/// /taekwon (CZ_TAEKWON_RANK).
- -/// 0225
- /// /taekwon list (ZC_TAEKWON_RANK).
- /// 0226 { <name>.24B }*10 { <point>.L }*10
- -void clif_parse_Taekwon(int fd,struct map_session_data *sd)
- +void clif_taekwon(struct map_session_data* sd)
- {
- - int i;
- + int i, fd = sd->fd;
- const char* name;
- WFIFOHEAD(fd,packet_len(0x226));
- @@ -13072,11 +13151,20 @@
- }
- +/// /taekwon (CZ_TAEKWON_RANK).
- +/// 0225
- +void clif_parse_Taekwon(int fd,struct map_session_data *sd)
- +{
- + clif_taekwon(sd);
- +}
- +
- +
- /// Notification about taekwon points (ZC_TAEKWON_POINT).
- /// 0224 <points>.L <total points>.L
- void clif_fame_taekwon(struct map_session_data *sd, int points)
- {
- int fd = sd->fd;
- +
- WFIFOHEAD(fd,packet_len(0x224));
- WFIFOW(fd,0) = 0x224;
- WFIFOL(fd,2) = points;
- @@ -13085,13 +13173,11 @@
- }
- -/// /pk (CZ_KILLER_RANK).
- -/// 0237
- /// /pk list (ZC_KILLER_RANK).
- /// 0238 { <name>.24B }*10 { <point>.L }*10
- -void clif_parse_RankingPk(int fd,struct map_session_data *sd)
- +void clif_ranking_pk(struct map_session_data* sd)
- {
- - int i;
- + int i, fd = sd->fd;
- WFIFOHEAD(fd,packet_len(0x238));
- WFIFOW(fd,0) = 0x238;
- @@ -13103,6 +13189,14 @@
- }
- +/// /pk (CZ_KILLER_RANK).
- +/// 0237
- +void clif_parse_RankingPk(int fd,struct map_session_data *sd)
- +{
- + clif_ranking_pk(sd);
- +}
- +
- +
- /// SG Feel save OK [Komurka] (CZ_AGREE_STARPLACE).
- /// 0254 <which>.B
- /// which:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement