diff options
Diffstat (limited to 'src/map/clif.cpp')
-rw-r--r-- | src/map/clif.cpp | 94 |
1 files changed, 44 insertions, 50 deletions
diff --git a/src/map/clif.cpp b/src/map/clif.cpp index eb008e4..3e57a6f 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -159,11 +159,11 @@ void clif_delete(Session *s) pc_logout(sd); clif_quitsave(s, sd); - PRINTF("Player [%s] has logged off your server.\n", sd->status_key.name); // Player logout display [Valaris] + PRINTF("Player [%s] has logged off your server.\n"_fmt, sd->status_key.name); // Player logout display [Valaris] } else if (sd) { // not authentified! (refused by char-server or disconnect before to be authentified) - PRINTF("Player with account [%d] has logged off your server (not auth account).\n", sd->bl_id); // Player logout display [Yor] + PRINTF("Player with account [%d] has logged off your server (not auth account).\n"_fmt, sd->bl_id); // Player logout display [Yor] map_deliddb(sd); // account_id has been included in the DB before auth answer } } @@ -487,7 +487,7 @@ int clif_send(const uint8_t *buf, int len, dumb_ptr<block_list> bl, SendWho type default: if (battle_config.error_log) - PRINTF("clif_send まだ作ってないよー\n"); + PRINTF("clif_send まだ作ってないよー\n"_fmt); return -1; } @@ -1791,7 +1791,7 @@ int clif_updatestatus(dumb_ptr<map_session_data> sd, SP type) default: if (battle_config.error_log) - PRINTF("clif_updatestatus : make %d routine\n", + PRINTF("clif_updatestatus : make %d routine\n"_fmt, type); return 1; } @@ -2578,7 +2578,7 @@ void clif_getareachar(dumb_ptr<block_list> bl, dumb_ptr<map_session_data> sd) break; default: if (battle_config.error_log) - PRINTF("get area char ??? %d\n", + PRINTF("get area char ??? %d\n"_fmt, bl->bl_type); break; } @@ -3091,8 +3091,6 @@ void clif_party_option(struct party *p, dumb_ptr<map_session_data> sd, int flag) nullpo_retv(p); -// if(battle_config.etc_log) -// PRINTF("clif_party_option: %d %d %d\n",p->exp,p->item,flag); if (sd == NULL && flag == 0) { int i; @@ -3195,8 +3193,6 @@ int clif_party_xy(struct party *, dumb_ptr<map_session_data> sd) WBUFW(buf, 6) = sd->bl_x; WBUFW(buf, 8) = sd->bl_y; clif_send(buf, clif_parse_func_table[0x107].len, sd, SendWho::PARTY_SAMEMAP_WOS); -// if(battle_config.etc_log) -// PRINTF("clif_party_xy %d\n",sd->status_key.account_id); return 0; } @@ -3216,8 +3212,6 @@ int clif_party_hp(struct party *, dumb_ptr<map_session_data> sd) WBUFW(buf, 8) = (sd->status.max_hp > 0x7fff) ? 0x7fff : sd->status.max_hp; clif_send(buf, clif_parse_func_table[0x106].len, sd, SendWho::PARTY_AREA_WOS); -// if(battle_config.etc_log) -// PRINTF("clif_party_hp %d\n",sd->status_key.account_id); return 0; } @@ -3395,7 +3389,7 @@ void clif_parse_WantToConnection(Session *s, dumb_ptr<map_session_data> sd) if (sd) { if (battle_config.error_log) - PRINTF("clif_parse_WantToConnection : invalid request?\n"); + PRINTF("clif_parse_WantToConnection : invalid request?\n"_fmt); return; } @@ -3415,7 +3409,7 @@ void clif_parse_WantToConnection(Session *s, dumb_ptr<map_session_data> sd) { clif_authfail_fd(s, 2); // same id clif_authfail_fd(old_sd->sess, 2); // same id - PRINTF("clif_parse_WantToConnection: Double connection for account %d (sessions: #%d (new) and #%d (old)).\n", + PRINTF("clif_parse_WantToConnection: Double connection for account %d (sessions: #%d (new) and #%d (old)).\n"_fmt, account_id, s, old_sd->sess); } else @@ -3644,7 +3638,7 @@ void clif_parse_GetCharNameRequest(Session *s, dumb_ptr<map_session_data> sd) nullpo_retv(ssd); if (ssd->state.shroud_active) - WFIFO_STRING(s, 6, "", 24); + WFIFO_STRING(s, 6, ""_s, 24); else WFIFO_STRING(s, 6, ssd->status_key.name.to__actual(), 24); WFIFOSET(s, clif_parse_func_table[0x95].len); @@ -3666,9 +3660,9 @@ void clif_parse_GetCharNameRequest(Session *s, dumb_ptr<map_session_data> sd) WFIFOW(s, 0) = 0x195; WFIFOL(s, 2) = account_id; WFIFO_STRING(s, 6, party_name, 24); - WFIFO_STRING(s, 30, "", 24); - WFIFO_STRING(s, 54, "", 24); - WFIFO_STRING(s, 78, "", 24); // We send this value twice because the client expects it + WFIFO_STRING(s, 30, ""_s, 24); + WFIFO_STRING(s, 54, ""_s, 24); + WFIFO_STRING(s, 78, ""_s, 24); // We send this value twice because the client expects it WFIFOSET(s, clif_parse_func_table[0x195].len); } @@ -3710,7 +3704,7 @@ void clif_parse_GetCharNameRequest(Session *s, dumb_ptr<map_session_data> sd) break; default: if (battle_config.error_log) - PRINTF("clif_parse_GetCharNameRequest : bad type %d (%d)\n", + PRINTF("clif_parse_GetCharNameRequest : bad type %d (%d)\n"_fmt, bl->bl_type, account_id); break; } @@ -3731,7 +3725,7 @@ void clif_parse_GlobalMessage(Session *s, dumb_ptr<map_session_data> sd) AString mbuf = clif_validate_chat(sd, ChatType::Global); if (!mbuf) { - clif_displaymessage(s, "Your message could not be sent."); + clif_displaymessage(s, "Your message could not be sent."_s); return; } @@ -3743,7 +3737,7 @@ void clif_parse_GlobalMessage(Session *s, dumb_ptr<map_session_data> sd) /* Don't send chat that results in an automatic ban. */ if (tmw_CheckChatSpam(sd, mbuf)) { - clif_displaymessage(s, "Your message could not be sent."); + clif_displaymessage(s, "Your message could not be sent."_s); return; } @@ -3996,7 +3990,7 @@ void clif_parse_Wis(Session *s, dumb_ptr<map_session_data> sd) AString mbuf = clif_validate_chat(sd, ChatType::Whisper); if (!mbuf) { - clif_displaymessage(s, "Your message could not be sent."); + clif_displaymessage(s, "Your message could not be sent."_s); return; } @@ -4008,7 +4002,7 @@ void clif_parse_Wis(Session *s, dumb_ptr<map_session_data> sd) /* Don't send chat that results in an automatic ban. */ if (tmw_CheckChatSpam(sd, mbuf)) { - clif_displaymessage(s, "Your message could not be sent."); + clif_displaymessage(s, "Your message could not be sent."_s); return; } @@ -4027,7 +4021,7 @@ void clif_parse_Wis(Session *s, dumb_ptr<map_session_data> sd) /* Refuse messages addressed to self. */ if (dstsd->sess == s) { - ZString mes = "You cannot page yourself."; + ZString mes = "You cannot page yourself."_s; clif_wis_message(s, wisp_server_name, mes); } else @@ -4100,13 +4094,13 @@ void clif_parse_DropItem(Session *s, dumb_ptr<map_session_data> sd) } if (sd->bl_m->flag.get(MapFlag::NO_PLAYER_DROPS)) { - clif_displaymessage(sd->sess, "Can't drop items here."); + clif_displaymessage(sd->sess, "Can't drop items here."_s); return; } if (sd->npc_id != 0 || sd->opt1 != Opt1::ZERO) { - clif_displaymessage(sd->sess, "Can't drop items right now."); + clif_displaymessage(sd->sess, "Can't drop items right now."_s); return; } @@ -4593,7 +4587,7 @@ void clif_parse_PartyMessage(Session *s, dumb_ptr<map_session_data> sd) AString mbuf = clif_validate_chat(sd, ChatType::Party); if (!mbuf) { - clif_displaymessage(s, "Your message could not be sent."); + clif_displaymessage(s, "Your message could not be sent."_s); return; } @@ -4603,7 +4597,7 @@ void clif_parse_PartyMessage(Session *s, dumb_ptr<map_session_data> sd) /* Don't send chat that results in an automatic ban. */ if (tmw_CheckChatSpam(sd, mbuf)) { - clif_displaymessage(s, "Your message could not be sent."); + clif_displaymessage(s, "Your message could not be sent."_s); return; } @@ -5223,7 +5217,7 @@ int clif_check_packet_flood(Session *s, int cmd) if (sd->packet_flood_in >= battle_config.packet_spam_flood) { - PRINTF("packet flood detected from %s [0x%x]\n", sd->status_key.name, cmd); + PRINTF("packet flood detected from %s [0x%x]\n"_fmt, sd->status_key.name, cmd); if (battle_config.packet_spam_kick) { s->set_eof(); @@ -5240,9 +5234,9 @@ int clif_check_packet_flood(Session *s, int cmd) } inline -void WARN_MALFORMED_MSG(dumb_ptr<map_session_data> sd, const char *msg) +void WARN_MALFORMED_MSG(dumb_ptr<map_session_data> sd, ZString msg) { - PRINTF("clif_validate_chat(): %s (ID %d) sent a malformed message: %s.\n", + PRINTF("clif_validate_chat(): %s (ID %d) sent a malformed message: %s.\n"_fmt, sd->status_key.name, sd->status_key.account_id, msg); } /** @@ -5287,14 +5281,14 @@ AString clif_validate_chat(dumb_ptr<map_session_data> sd, ChatType type) /* The player just sent the header (2) and length (2) words. */ if (!msg_len) { - WARN_MALFORMED_MSG(sd, "no message sent"); + WARN_MALFORMED_MSG(sd, "no message sent"_s); return AString(); } /* The client sent (or claims to have sent) an empty message. */ if (msg_len == min_len) { - WARN_MALFORMED_MSG(sd, "empty message"); + WARN_MALFORMED_MSG(sd, "empty message"_s); return AString(); } @@ -5303,7 +5297,7 @@ AString clif_validate_chat(dumb_ptr<map_session_data> sd, ChatType type) { /* Disallow malformed messages. */ clif_setwaitclose(s); - WARN_MALFORMED_MSG(sd, "illegal target name"); + WARN_MALFORMED_MSG(sd, "illegal target name"_s); return AString(); } @@ -5325,18 +5319,18 @@ AString clif_validate_chat(dumb_ptr<map_session_data> sd, ChatType type) */ if (buf_len >= battle_config.chat_maxline) { - WARN_MALFORMED_MSG(sd, "exceeded maximum message length"); + WARN_MALFORMED_MSG(sd, "exceeded maximum message length"_s); return AString(); } if (type == ChatType::Global) { XString p = pbuf; - if (!(p.startswith(sd->status_key.name.to__actual()) && p.xslice_t(name_len).startswith(" : "))) + if (!(p.startswith(sd->status_key.name.to__actual()) && p.xslice_t(name_len).startswith(" : "_s))) { /* Disallow malformed/spoofed messages. */ clif_setwaitclose(s); - WARN_MALFORMED_MSG(sd, "spoofed name/invalid format"); + WARN_MALFORMED_MSG(sd, "spoofed name/invalid format"_s); return AString(); } /* Step beyond the separator. */ @@ -5443,32 +5437,32 @@ void clif_parse(Session *s) if (battle_config.error_log) { if (s) - PRINTF("\nclif_parse: session #%d, packet 0x%x, lenght %d\n", + PRINTF("\nclif_parse: session #%d, packet 0x%x, lenght %d\n"_fmt, s, cmd, packet_len); #ifdef DUMP_UNKNOWN_PACKET { int i; - ZString packet_txt = "save/packet.txt"; - PRINTF("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F"); + ZString packet_txt = "save/packet.txt"_s; + PRINTF("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F"_fmt); for (i = 0; i < packet_len; i++) { if ((i & 15) == 0) - PRINTF("\n%04X ", i); - PRINTF("%02X ", RFIFOB(s, i)); + PRINTF("\n%04X "_fmt, i); + PRINTF("%02X "_fmt, RFIFOB(s, i)); } if (sd && sd->state.auth) { - PRINTF("\nAccount ID %d, character ID %d, player name %s.\n", + PRINTF("\nAccount ID %d, character ID %d, player name %s.\n"_fmt, sd->status_key.account_id, sd->status_key.char_id, sd->status_key.name); } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified) - PRINTF("\nAccount ID %d.\n", sd->bl_id); + PRINTF("\nAccount ID %d.\n"_fmt, sd->bl_id); io::AppendFile fp(packet_txt); if (!fp.is_open()) { - PRINTF("clif.c: cant write [%s] !!! data is lost !!!\n", + PRINTF("clif.c: cant write [%s] !!! data is lost !!!\n"_fmt, packet_txt); return; } @@ -5479,25 +5473,25 @@ void clif_parse(Session *s) if (sd && sd->state.auth) { FPRINTF(fp, - "%s\nPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n", + "%s\nPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n"_fmt, now, sd->status_key.account_id, sd->status_key.char_id, sd->status_key.name); } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified) FPRINTF(fp, - "%s\nPlayer with account ID %d sent wrong packet:\n", + "%s\nPlayer with account ID %d sent wrong packet:\n"_fmt, now, sd->bl_id); FPRINTF(fp, - "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F"); + "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F"_fmt); for (i = 0; i < packet_len; i++) { if ((i & 15) == 0) - FPRINTF(fp, "\n\t%04X ", i); - FPRINTF(fp, "%02X ", RFIFOB(s, i)); + FPRINTF(fp, "\n\t%04X "_fmt, i); + FPRINTF(fp, "%02X "_fmt, RFIFOB(s, i)); } - FPRINTF(fp, "\n\n"); + FPRINTF(fp, "\n\n"_fmt); } } #endif |