Session check standarization (#5388)

Thanks to @Lemongrass3110
This commit is contained in:
Daegaladh
2021-01-14 15:57:30 +01:00
committed by GitHub
parent ae4e2b9cba
commit ecb4cc0a42
8 changed files with 66 additions and 70 deletions

View File

@@ -29,7 +29,7 @@ int chmapif_sendall(unsigned char *buf, unsigned int len){
c = 0;
for(i = 0; i < ARRAYLENGTH(map_server); i++) {
int fd;
if ((fd = map_server[i].fd) > 0) {
if (session_isValid(fd = map_server[i].fd)) {
WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
@@ -53,7 +53,7 @@ int chmapif_sendallwos(int sfd, unsigned char *buf, unsigned int len){
c = 0;
for(i = 0; i < ARRAYLENGTH(map_server); i++) {
int fd;
if ((fd = map_server[i].fd) > 0 && fd != sfd) {
if (session_isValid(fd = map_server[i].fd) && fd != sfd) {
WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
@@ -72,7 +72,7 @@ int chmapif_sendallwos(int sfd, unsigned char *buf, unsigned int len){
* @return : the number of map-serv the packet was sent to (O|1)
*/
int chmapif_send(int fd, unsigned char *buf, unsigned int len){
if (fd >= 0) {
if (session_isValid(fd)) {
int i;
ARR_FIND( 0, ARRAYLENGTH(map_server), i, fd == map_server[i].fd );
if( i < ARRAYLENGTH(map_server) )
@@ -122,7 +122,7 @@ int chmapif_send_fame_list(int fd){
// add total packet length
WBUFW(buf, 2) = len;
if (fd != -1)
if (session_isValid(fd))
chmapif_send(fd, buf, len);
else
chmapif_sendall(buf, len);
@@ -212,7 +212,7 @@ void chmapif_send_maps(int fd, int map_id, int count, unsigned char *mapbuf) {
// Transmitting the maps of the other map-servers to the new map-server
for (x = 0; x < ARRAYLENGTH(map_server); x++) {
if (map_server[x].fd > 0 && x != map_id) {
if (session_isValid(map_server[x].fd) && x != map_id) {
uint16 i, j;
WFIFOHEAD(fd,10 +4*map_server[x].map.size());