diff --git a/src/char/char_mapif.cpp b/src/char/char_mapif.cpp index 2e451fed8f..ef635e9b6c 100644 --- a/src/char/char_mapif.cpp +++ b/src/char/char_mapif.cpp @@ -162,24 +162,26 @@ void chmapif_sendall_playercount(int users){ * Send some misc info to new map-server. * - Server name for whisper name * - Default map - * HZ 0x2afb .W .B .24B .11B .W .W + * HZ 0x2afb .W .B .24B .11B .W .W .24B * @param fd **/ void chmapif_send_misc(int fd) { uint16 offs = 5; - unsigned char buf[45]; + unsigned char buf[45+NAME_LENGTH]; memset(buf, '\0', sizeof(buf)); WBUFW(buf, 0) = 0x2afb; // 0 succes, 1:failure WBUFB(buf, 4) = 0; // Send name for wisp to player - memcpy(WBUFP(buf, 5), charserv_config.wisp_server_name, NAME_LENGTH); + safestrncpy( WBUFCP( buf, 5 ), charserv_config.wisp_server_name, NAME_LENGTH ); // Default map - memcpy(WBUFP(buf, (offs+=NAME_LENGTH)), charserv_config.default_map, MAP_NAME_LENGTH); // 29 + safestrncpy( WBUFCP( buf, ( offs += NAME_LENGTH ) ), charserv_config.default_map, MAP_NAME_LENGTH ); // 29 WBUFW(buf, (offs+=MAP_NAME_LENGTH)) = charserv_config.default_map_x; // 41 WBUFW(buf, (offs+=2)) = charserv_config.default_map_y; // 43 offs+=2; + safestrncpy( WBUFCP( buf, offs ), charserv_config.server_name, sizeof( charserv_config.server_name ) ); // 45 + offs += NAME_LENGTH; // Length WBUFW(buf, 2) = offs; diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index 2d431c6751..e3f358498c 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -114,6 +114,7 @@ static uint16 char_port = 6121; static char userid[NAME_LENGTH], passwd[NAME_LENGTH]; static int chrif_state = 0; int other_mapserver_count=0; //Holds count of how many other map servers are online (apart of this instance) [Skotlex] +char charserver_name[NAME_LENGTH]; //Interval at which map server updates online listing. [Valaris] #define CHECK_INTERVAL 3600000 @@ -608,14 +609,19 @@ int chrif_sendmapack(int fd) { exit(EXIT_FAILURE); } - // Server name - memcpy(wisp_server_name, RFIFOP(fd,5), NAME_LENGTH); - ShowStatus("Map-server connected to char-server '" CL_WHITE "%s" CL_RESET "'.\n", wisp_server_name); + // Whisper name + safestrncpy( wisp_server_name, RFIFOCP( fd, offs ), NAME_LENGTH ); // Default map - memcpy(map_default.mapname, RFIFOP(fd, (offs+=NAME_LENGTH)), MAP_NAME_LENGTH); + safestrncpy( map_default.mapname, RFIFOCP( fd, ( offs += NAME_LENGTH ) ), MAP_NAME_LENGTH ); map_default.x = RFIFOW(fd, (offs+=MAP_NAME_LENGTH)); map_default.y = RFIFOW(fd, (offs+=2)); + + // Server name + safestrncpy( charserver_name, RFIFOCP( fd, ( offs += 2 ) ), NAME_LENGTH ); + + ShowStatus( "Map-server connected to char-server '" CL_WHITE "%s" CL_RESET "' (whispername: %s).\n", charserver_name, wisp_server_name ); + if (battle_config.etc_log) ShowInfo("Received default map from char-server '" CL_WHITE "%s %d,%d" CL_RESET "'.\n", map_default.mapname, map_default.x, map_default.y); diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp index 6e9bcb3302..c88144bc06 100644 --- a/src/map/chrif.hpp +++ b/src/map/chrif.hpp @@ -7,6 +7,7 @@ #include #include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" // NAME_LENGTH #include "../common/timer.hpp" // t_tick #include "../common/socket.hpp" // enum chrif_req_op @@ -46,6 +47,7 @@ void chrif_check_shutdown(void); extern int chrif_connected; extern int other_mapserver_count; +extern char charserver_name[NAME_LENGTH]; struct auth_node* chrif_search(uint32 account_id); struct auth_node* chrif_auth_check(uint32 account_id, uint32 char_id, enum sd_state state);