Skip to content
Permalink
Browse files

Merge pull request #2378 from 4144/interfaces

Different interfaces fixes
  • Loading branch information...
MishimaHaruna committed Mar 11, 2019
2 parents c2bf968 + 63062f9 commit 23b515f67f912078268767ec2d28b65711d39b2f
@@ -79,8 +79,6 @@
static struct socket_interface sockt_s;
struct socket_interface *sockt;

static const char *SOCKET_CONF_FILENAME = "conf/common/socket.conf";

#ifdef SEND_SHORTLIST
// Add a fd to the shortlist so that it'll be recognized as a fd that needs
// sending done on it.
@@ -462,7 +460,7 @@ static int recv_to_fifo(int fd)
socket_data_ci += len;
}
#endif // SHOW_SERVER_STATS
return 0;
return (int)len;
}

static int send_from_fifo(int fd)
@@ -648,7 +646,7 @@ static int make_listen_bind(uint32 ip, uint16 port)
if(sockt->fd_max <= fd) sockt->fd_max = fd + 1;


create_session(fd, connect_client, null_send, null_parse);
create_session(fd, sockt->connect_client, null_send, null_parse);
sockt->session[fd]->client_addr = 0; // just listens
sockt->session[fd]->rdata_tick = 0; // disable timeouts on this socket
return fd;
@@ -1505,7 +1503,7 @@ static bool socket_config_read(const char *filename, bool imported)

// import should overwrite any previous configuration, so it should be called last
if (libconfig->lookup_string(&config, "import", &import) == CONFIG_TRUE) {
if (strcmp(import, filename) == 0 || strcmp(import, SOCKET_CONF_FILENAME) == 0) {
if (strcmp(import, filename) == 0 || strcmp(import, sockt->SOCKET_CONF_FILENAME) == 0) {
ShowWarning("socket_config_read: Loop detected! Skipping 'import'...\n");
} else {
if (!socket_config_read(import, true))
@@ -1714,7 +1712,7 @@ static void socket_init(void)
// Get initial local ips
sockt->naddr_ = sockt->getips(sockt->addr_,16);

socket_config_read(SOCKET_CONF_FILENAME, false);
socket_config_read(sockt->SOCKET_CONF_FILENAME, false);

#ifndef SOCKET_EPOLL
// Select based Event Dispatcher:
@@ -2143,6 +2141,8 @@ void socket_defaults(void)
{
sockt = &sockt_s;

sockt->SOCKET_CONF_FILENAME = "conf/common/socket.conf";

sockt->fd_max = 0;
/* */
sockt->stall_time = 60;
@@ -2177,6 +2177,7 @@ void socket_defaults(void)
/* */
sockt->flush = flush_fifo;
sockt->flush_fifos = flush_fifos;
sockt->connect_client = connect_client;
sockt->set_nonblocking = set_nonblocking;
sockt->set_defaultparse = set_defaultparse;
sockt->host2ip = host2ip;
@@ -178,6 +178,7 @@ struct socket_interface {
time_t stall_time;
time_t last_tick;

const char *SOCKET_CONF_FILENAME;
/* */
uint32 addr_[16]; // ip addresses of local host (host byte order)
int naddr_; // # of ip addresses
@@ -212,6 +213,7 @@ struct socket_interface {
/* */
void (*flush) (int fd);
void (*flush_fifos) (void);
int (*connect_client) (int listen_fd);
void (*set_nonblocking) (int fd, unsigned long yes);
void (*set_defaultparse) (ParseFunc defaultparse);
/* hostname/ip conversion functions */
@@ -10716,6 +10716,9 @@ void atcommand_defaults(void)
{
atcommand = &atcommand_s;

atcommand->atcmd_output = &atcmd_output;
atcommand->atcmd_player_name = &atcmd_player_name;

atcommand->db = NULL;
atcommand->alias_db = NULL;

@@ -21,9 +21,11 @@
#ifndef MAP_ATCOMMAND_H
#define MAP_ATCOMMAND_H

#include "map/mapdefines.h"
#include "map/pc_groups.h"
#include "common/hercules.h"
#include "common/db.h"
#include "common/mmo.h"

#include <stdarg.h>

@@ -90,6 +92,8 @@ struct atcmd_binding_data {
* Interface
**/
struct atcommand_interface {
char (*atcmd_output)[CHAT_SIZE_MAX];
char (*atcmd_player_name)[NAME_LENGTH];
unsigned char at_symbol;
unsigned char char_symbol;
/* atcommand binding */
@@ -45,42 +45,6 @@ enum E_MAPSERVER_ST {
MAPSERVER_ST_LAST
};

#define MAX_NPC_PER_MAP 512
#define AREA_SIZE (battle->bc->area_size)
#define CHAT_AREA_SIZE (battle->bc->chat_area_size)
#define DEAD_AREA_SIZE (battle->bc->dead_area_size)
#define DAMAGELOG_SIZE 30
#define LOOTITEM_SIZE 10
#define MAX_MOBSKILL 50
#define MAX_MOB_LIST_PER_MAP 100
#define MAX_EVENTQUEUE 2
#define MAX_EVENTTIMER 32
#define NATURAL_HEAL_INTERVAL 500
#define MIN_FLOORITEM 2
#define MAX_FLOORITEM START_ACCOUNT_NUM
#define MAX_IGNORE_LIST 20 // official is 14
#define MAX_VENDING 12
#define MAX_MAP_SIZE (512*512) // Wasn't there something like this already? Can't find it.. [Shinryo]

#define BLOCK_SIZE 8
#define block_free_max 1048576
#define BL_LIST_MAX 1048576

// The following system marks a different job ID system used by the map server,
// which makes a lot more sense than the normal one. [Skotlex]
// These marks the "level" of the job.
#define JOBL_2_1 0x0100
#define JOBL_2_2 0x0200
#define JOBL_2 0x0300 // JOBL_2_1 | JOBL_2_2
#define JOBL_UPPER 0x1000
#define JOBL_BABY 0x2000
#define JOBL_THIRD 0x4000

// For filtering and quick checking.
#define MAPID_BASEMASK 0x00ff
#define MAPID_UPPERMASK 0x0fff
#define MAPID_THIRDMASK (JOBL_THIRD|MAPID_UPPERMASK)

//First Jobs
//Note the oddity of the novice:
//Super Novices are considered the 2-1 version of the novice! Novices are considered a first class type.
@@ -344,36 +308,6 @@ enum {

STATIC_ASSERT(((MAPID_1_1_MAX - 1) | MAPID_BASEMASK) == MAPID_BASEMASK, "First class map IDs do not fit into MAPID_BASEMASK");

// Max size for inputs to Graffiti, Talkie Box and Vending text prompts
#define MESSAGE_SIZE (79 + 1)
// String length you can write in the 'talking box'
#define CHATBOX_SIZE (70 + 1)
// Chatroom-related string sizes
#define CHATROOM_TITLE_SIZE (36 + 1)
#define CHATROOM_PASS_SIZE (8 + 1)
// Max allowed chat text length
#define CHAT_SIZE_MAX (255 + 1)
// 24 for npc name + 24 for label + 2 for a "::" and 1 for EOS
#define EVENT_NAME_LENGTH ( NAME_LENGTH * 2 + 3 )
#define DEFAULT_AUTOSAVE_INTERVAL (5*60*1000)
// Specifies maps where players may hit each other
#define map_flag_vs(m) ( \
map->list[m].flag.pvp \
|| map->list[m].flag.gvg_dungeon \
|| map->list[m].flag.gvg \
|| ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle) \
|| map->list[m].flag.battleground \
|| map->list[m].flag.cvc \
)
// Specifies maps that have special GvG/WoE restrictions
#define map_flag_gvg(m) (map->list[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle))
// Specifies if the map is tagged as GvG/WoE (regardless of map->agit_flag status)
#define map_flag_gvg2(m) (map->list[m].flag.gvg || map->list[m].flag.gvg_castle)
// No Kill Steal Protection
#define map_flag_ks(m) (map->list[m].flag.town || map->list[m].flag.pvp || map->list[m].flag.gvg || map->list[m].flag.battleground)
// No ViewID
#define map_no_view(m, view) (map->list[m].flag.noviewid & (view))

//This stackable implementation does not means a BL can be more than one type at a time, but it's
// meant to make it easier to check for multiple types at a time on invocations such as map_foreach* calls [Skotlex]
enum bl_type {
@@ -392,9 +326,6 @@ enum bl_type {
BL_ALL = 0xFFF,
};

// For common mapforeach calls. Since pets cannot be affected, they aren't included here yet.
#define BL_CHAR (BL_PC|BL_MOB|BL_HOM|BL_MER|BL_ELEM)

enum npc_subtype { WARP, SHOP, SCRIPT, CASHSHOP, TOMB };

/**
@@ -748,16 +679,6 @@ enum map_zone_merge_type {
MZMT_NEVERMERGE, ///< Cannot merge with any zones.
};

#define MAP_ZONE_NAME_LENGTH 60
#define MAP_ZONE_ALL_NAME "All"
#define MAP_ZONE_NORMAL_NAME "Normal"
#define MAP_ZONE_PVP_NAME "PvP"
#define MAP_ZONE_GVG_NAME "GvG"
#define MAP_ZONE_BG_NAME "Battlegrounds"
#define MAP_ZONE_CVC_NAME "CvC"
#define MAP_ZONE_PK_NAME "PK Mode"
#define MAP_ZONE_MAPFLAG_LENGTH 65

struct map_zone_data {
char name[MAP_ZONE_NAME_LENGTH];/* 20'd */
enum map_zone_merge_type merge_type;
@@ -0,0 +1,103 @@
/**
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
* Copyright (C) 2012-2018 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MAP_MAPDEFINES_H
#define MAP_MAPDEFINES_H

#define MAX_NPC_PER_MAP 512
#define AREA_SIZE (battle->bc->area_size)
#define CHAT_AREA_SIZE (battle->bc->chat_area_size)
#define DEAD_AREA_SIZE (battle->bc->dead_area_size)
#define DAMAGELOG_SIZE 30
#define LOOTITEM_SIZE 10
#define MAX_MOBSKILL 50
#define MAX_MOB_LIST_PER_MAP 100
#define MAX_EVENTQUEUE 2
#define MAX_EVENTTIMER 32
#define NATURAL_HEAL_INTERVAL 500
#define MIN_FLOORITEM 2
#define MAX_FLOORITEM START_ACCOUNT_NUM
#define MAX_IGNORE_LIST 20 // official is 14
#define MAX_VENDING 12
#define MAX_MAP_SIZE (512*512) // Wasn't there something like this already? Can't find it.. [Shinryo]

#define BLOCK_SIZE 8
#define block_free_max 1048576
#define BL_LIST_MAX 1048576

// The following system marks a different job ID system used by the map server,
// which makes a lot more sense than the normal one. [Skotlex]
// These marks the "level" of the job.
#define JOBL_2_1 0x0100
#define JOBL_2_2 0x0200
#define JOBL_2 0x0300 // JOBL_2_1 | JOBL_2_2
#define JOBL_UPPER 0x1000
#define JOBL_BABY 0x2000
#define JOBL_THIRD 0x4000

// For filtering and quick checking.
#define MAPID_BASEMASK 0x00ff
#define MAPID_UPPERMASK 0x0fff
#define MAPID_THIRDMASK (JOBL_THIRD|MAPID_UPPERMASK)

// Max size for inputs to Graffiti, Talkie Box and Vending text prompts
#define MESSAGE_SIZE (79 + 1)
// String length you can write in the 'talking box'
#define CHATBOX_SIZE (70 + 1)
// Chatroom-related string sizes
#define CHATROOM_TITLE_SIZE (36 + 1)
#define CHATROOM_PASS_SIZE (8 + 1)
// Max allowed chat text length
#define CHAT_SIZE_MAX (255 + 1)
// 24 for npc name + 24 for label + 2 for a "::" and 1 for EOS
#define EVENT_NAME_LENGTH ( NAME_LENGTH * 2 + 3 )
#define DEFAULT_AUTOSAVE_INTERVAL (5*60*1000)
// Specifies maps where players may hit each other
#define map_flag_vs(m) ( \
map->list[m].flag.pvp \
|| map->list[m].flag.gvg_dungeon \
|| map->list[m].flag.gvg \
|| ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle) \
|| map->list[m].flag.battleground \
|| map->list[m].flag.cvc \
)
// Specifies maps that have special GvG/WoE restrictions
#define map_flag_gvg(m) (map->list[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle))
// Specifies if the map is tagged as GvG/WoE (regardless of map->agit_flag status)
#define map_flag_gvg2(m) (map->list[m].flag.gvg || map->list[m].flag.gvg_castle)
// No Kill Steal Protection
#define map_flag_ks(m) (map->list[m].flag.town || map->list[m].flag.pvp || map->list[m].flag.gvg || map->list[m].flag.battleground)
// No ViewID
#define map_no_view(m, view) (map->list[m].flag.noviewid & (view))

// For common mapforeach calls. Since pets cannot be affected, they aren't included here yet.
#define BL_CHAR (BL_PC|BL_MOB|BL_HOM|BL_MER|BL_ELEM)

#define MAP_ZONE_NAME_LENGTH 60
#define MAP_ZONE_ALL_NAME "All"
#define MAP_ZONE_NORMAL_NAME "Normal"
#define MAP_ZONE_PVP_NAME "PvP"
#define MAP_ZONE_GVG_NAME "GvG"
#define MAP_ZONE_BG_NAME "Battlegrounds"
#define MAP_ZONE_CVC_NAME "CvC"
#define MAP_ZONE_PK_NAME "PK Mode"
#define MAP_ZONE_MAPFLAG_LENGTH 65

#endif /* MAP_MAPDEFINES_H */
typedef void (*HPMHOOK_post_sockt_flush) (int fd);
typedef void (*HPMHOOK_pre_sockt_flush_fifos) (void);
typedef void (*HPMHOOK_post_sockt_flush_fifos) (void);
typedef int (*HPMHOOK_pre_sockt_connect_client) (int *listen_fd);
typedef int (*HPMHOOK_post_sockt_connect_client) (int retVal___, int listen_fd);
typedef void (*HPMHOOK_pre_sockt_set_nonblocking) (int *fd, unsigned long *yes);
typedef void (*HPMHOOK_post_sockt_set_nonblocking) (int fd, unsigned long yes);
typedef void (*HPMHOOK_pre_sockt_set_defaultparse) (ParseFunc *defaultparse);
@@ -1422,6 +1422,8 @@ struct {
struct HPMHookPoint *HP_sockt_flush_post;
struct HPMHookPoint *HP_sockt_flush_fifos_pre;
struct HPMHookPoint *HP_sockt_flush_fifos_post;
struct HPMHookPoint *HP_sockt_connect_client_pre;
struct HPMHookPoint *HP_sockt_connect_client_post;
struct HPMHookPoint *HP_sockt_set_nonblocking_pre;
struct HPMHookPoint *HP_sockt_set_nonblocking_post;
struct HPMHookPoint *HP_sockt_set_defaultparse_pre;
@@ -3059,6 +3061,8 @@ struct {
int HP_sockt_flush_post;
int HP_sockt_flush_fifos_pre;
int HP_sockt_flush_fifos_post;
int HP_sockt_connect_client_pre;
int HP_sockt_connect_client_post;
int HP_sockt_set_nonblocking_pre;
int HP_sockt_set_nonblocking_post;
int HP_sockt_set_defaultparse_pre;
@@ -758,6 +758,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(sockt->session_is_active, HP_sockt_session_is_active) },
{ HP_POP(sockt->flush, HP_sockt_flush) },
{ HP_POP(sockt->flush_fifos, HP_sockt_flush_fifos) },
{ HP_POP(sockt->connect_client, HP_sockt_connect_client) },
{ HP_POP(sockt->set_nonblocking, HP_sockt_set_nonblocking) },
{ HP_POP(sockt->set_defaultparse, HP_sockt_set_defaultparse) },
{ HP_POP(sockt->host2ip, HP_sockt_host2ip) },
}
return;
}
int HP_sockt_connect_client(int listen_fd) {
int hIndex = 0;
int retVal___ = 0;
if (HPMHooks.count.HP_sockt_connect_client_pre > 0) {
int (*preHookFunc) (int *listen_fd);
*HPMforce_return = false;
for (hIndex = 0; hIndex < HPMHooks.count.HP_sockt_connect_client_pre; hIndex++) {
preHookFunc = HPMHooks.list.HP_sockt_connect_client_pre[hIndex].func;
retVal___ = preHookFunc(&listen_fd);
}
if (*HPMforce_return) {
*HPMforce_return = false;
return retVal___;
}
}
{
retVal___ = HPMHooks.source.sockt.connect_client(listen_fd);
}
if (HPMHooks.count.HP_sockt_connect_client_post > 0) {
int (*postHookFunc) (int retVal___, int listen_fd);
for (hIndex = 0; hIndex < HPMHooks.count.HP_sockt_connect_client_post; hIndex++) {
postHookFunc = HPMHooks.list.HP_sockt_connect_client_post[hIndex].func;
retVal___ = postHookFunc(retVal___, listen_fd);
}
}
return retVal___;
}
void HP_sockt_set_nonblocking(int fd, unsigned long yes) {
int hIndex = 0;
if (HPMHooks.count.HP_sockt_set_nonblocking_pre > 0) {
Oops, something went wrong.

0 comments on commit 23b515f

Please sign in to comment.
You can’t perform that action at this time.