summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/Makefile.in4
-rw-r--r--src/map/atcommand.c5191
-rw-r--r--src/map/atcommand.h98
-rw-r--r--src/map/battle.c134
-rw-r--r--src/map/battle.h2
-rw-r--r--src/map/buyingstore.c31
-rw-r--r--src/map/buyingstore.h31
-rw-r--r--src/map/chat.c7
-rw-r--r--src/map/clif.c1428
-rw-r--r--src/map/clif.h45
-rw-r--r--src/map/duel.c10
-rw-r--r--src/map/guild.c28
-rw-r--r--src/map/intif.c2
-rw-r--r--src/map/irc-bot.c272
-rw-r--r--src/map/irc-bot.h58
-rw-r--r--src/map/itemdb.c33
-rw-r--r--src/map/itemdb.h3
-rw-r--r--src/map/log.c608
-rw-r--r--src/map/log.h84
-rw-r--r--src/map/mail.c2
-rw-r--r--src/map/map.c495
-rw-r--r--src/map/map.h51
-rw-r--r--src/map/mob.c71
-rw-r--r--src/map/npc.c62
-rw-r--r--src/map/npc.h7
-rw-r--r--src/map/packets.h5
-rw-r--r--src/map/packets_struct.h376
-rw-r--r--src/map/party.c17
-rw-r--r--src/map/pc.c215
-rw-r--r--src/map/pc.h27
-rw-r--r--src/map/pc_groups.c40
-rw-r--r--src/map/pc_groups.h5
-rw-r--r--src/map/pet.c12
-rw-r--r--src/map/script.c6959
-rw-r--r--src/map/script.h4
-rw-r--r--src/map/searchstore.c201
-rw-r--r--src/map/searchstore.h42
-rw-r--r--src/map/skill.c59
-rw-r--r--src/map/skill.h1
-rw-r--r--src/map/sql/CMakeLists.txt5
-rw-r--r--src/map/status.c232
-rw-r--r--src/map/status.h1
-rw-r--r--src/map/trade.c7
-rw-r--r--src/map/unit.c79
-rw-r--r--src/map/vending.c183
-rw-r--r--src/map/vending.h31
46 files changed, 9423 insertions, 7835 deletions
diff --git a/src/map/Makefile.in b/src/map/Makefile.in
index a49a6edb4..bb99b6a05 100644
--- a/src/map/Makefile.in
+++ b/src/map/Makefile.in
@@ -17,7 +17,7 @@ MAP_OBJ = map.o chrif.o clif.o pc.o status.o npc.o \
storage.o skill.o atcommand.o battle.o battleground.o \
intif.o trade.o party.o vending.o guild.o pet.o \
log.o mail.o date.o unit.o homunculus.o mercenary.o quest.o instance.o \
- buyingstore.o searchstore.o duel.o pc_groups.o elemental.o
+ buyingstore.o searchstore.o duel.o pc_groups.o elemental.o irc-bot.o
MAP_SQL_OBJ = $(MAP_OBJ:%=obj_sql/%) \
obj_sql/mapreg_sql.o
MAP_H = map.h chrif.h clif.h pc.h status.h npc.h \
@@ -27,7 +27,7 @@ MAP_H = map.h chrif.h clif.h pc.h status.h npc.h \
log.h mail.h date.h unit.h homunculus.h mercenary.h quest.h instance.h mapreg.h \
buyingstore.h searchstore.h duel.h pc_groups.h \
../config/core.h ../config/renewal.h ../config/secure.h ../config/const.h \
- ../config/classes/general.h elemental.h packets.h
+ ../config/classes/general.h elemental.h packets.h packets_struct.h irc-bot.h
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index d9c01b0fb..e9c8c5fba 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/cbasetypes.h"
#include "../common/mmo.h"
@@ -43,6 +44,7 @@
#include "unit.h"
#include "mapreg.h"
#include "quest.h"
+#include "searchstore.h"
#include <stdio.h>
#include <stdlib.h>
@@ -50,36 +52,11 @@
#include <math.h>
-#define ATCOMMAND_LENGTH 50
-#define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
-#define MAX_MSG 1500
-
-
-typedef struct AtCommandInfo AtCommandInfo;
-typedef struct AliasInfo AliasInfo;
-
-int atcmd_binding_count = 0;
-
-struct AtCommandInfo {
- char command[ATCOMMAND_LENGTH];
- AtCommandFunc func;
- char* at_groups;/* quick @commands "can-use" lookup */
- char* char_groups;/* quick @charcommands "can-use" lookup */
-};
-
-struct AliasInfo {
- AtCommandInfo *command;
- char alias[ATCOMMAND_LENGTH];
-};
-
-
-char atcommand_symbol = '@'; // first char of the commands
-char charcommand_symbol = '#';
+#define ACMD(x) static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info)
static char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
-static config_t atcommand_config;
static char atcmd_output[CHAT_SIZE_MAX];
static char atcmd_player_name[NAME_LENGTH];
@@ -92,12 +69,12 @@ static void atcommand_get_suggestions(struct map_session_data* sd, const char *n
struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
int i = 0;
- if( *name == atcommand_symbol || *name == charcommand_symbol )
+ if( *name == atcommand->at_symbol || *name == atcommand->char_symbol )
name++; // for backwards compatibility
- ARR_FIND( 0, atcmd_binding_count, i, strcmp(atcmd_binding[i]->command, name) == 0 );
+ ARR_FIND( 0, atcommand->binding_count, i, strcmp(atcommand->binding[i]->command, name) == 0 );
- return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
+ return ( i < atcommand->binding_count ) ? atcommand->binding[i] : NULL;
}
//-----------------------------------------------------------
@@ -169,107 +146,79 @@ void do_final_msg(void)
/**
* retrieves the help string associated with a given command.
- *
- * @param name the name of the command to retrieve help information for
- * @return the string associated with the command, or NULL
*/
-static const char* atcommand_help_string(const char* command)
-{
- const char* str = NULL;
- config_setting_t* info;
-
- if( *command == atcommand_symbol || *command == charcommand_symbol )
- {// remove the prefix symbol for the raw name of the command
- command ++;
- }
-
- // convert alias to the real command name
- command = atcommand_checkalias(command);
-
- // attept to find the first default help command
- info = config_lookup(&atcommand_config, "help");
-
- if( info == NULL )
- {// failed to find the help property in the configuration file
- return NULL;
- }
-
- if( !config_setting_lookup_string( info, command, &str ) )
- {// failed to find the matching help string
- return NULL;
- }
-
- // push the result from the method
- return str;
+static inline const char* atcommand_help_string(AtCommandInfo *info) {
+ return info->help;
}
+
/*==========================================
* @send (used for testing packet sends from the client)
*------------------------------------------*/
-ACMD_FUNC(send)
+ACMD(send)
{
int len=0,off,end,type;
long num;
-
+
// read message type as hex number (without the 0x)
if(!message || !*message ||
- !((sscanf(message, "len %x", &type)==1 && (len=1))
- || sscanf(message, "%x", &type)==1) )
+ !((sscanf(message, "len %x", &type)==1 && (len=1))
+ || sscanf(message, "%x", &type)==1) )
{
int i;
for (i = 900; i <= 903; ++i)
clif->message(fd, msg_txt(i));
- return -1;
+ return false;
}
-
+
#define PARSE_ERROR(error,p) \
- {\
- clif->message(fd, (error));\
- sprintf(atcmd_output, ">%s", (p));\
- clif->message(fd, atcmd_output);\
- }
-//define PARSE_ERROR
-
+{\
+clif->message(fd, (error));\
+sprintf(atcmd_output, ">%s", (p));\
+clif->message(fd, atcmd_output);\
+}
+ //define PARSE_ERROR
+
#define CHECK_EOS(p) \
- if(*(p) == 0){\
- clif->message(fd, "Unexpected end of string");\
- return -1;\
- }
-//define CHECK_EOS
-
+if(*(p) == 0){\
+clif->message(fd, "Unexpected end of string");\
+return false;\
+}
+ //define CHECK_EOS
+
#define SKIP_VALUE(p) \
- {\
- while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
- while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
- }
-//define SKIP_VALUE
-
+{\
+while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
+while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
+}
+ //define SKIP_VALUE
+
#define GET_VALUE(p,num) \
- {\
- if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
- PARSE_ERROR("Invalid number in:",(p));\
- return -1;\
- }\
- }
-//define GET_VALUE
-
+{\
+if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
+PARSE_ERROR("Invalid number in:",(p));\
+return false;\
+}\
+}
+ //define GET_VALUE
+
if (type > 0 && type < MAX_PACKET_DB) {
-
+
if(len)
{// show packet length
sprintf(atcmd_output, msg_txt(904), type, packet_db[type].len); // Packet 0x%x length: %d
clif->message(fd, atcmd_output);
- return 0;
+ return true;
}
-
+
len=packet_db[type].len;
off=2;
if(len == 0)
{// unknown packet - ERROR
sprintf(atcmd_output, msg_txt(905), type); // Unknown packet: 0x%x
clif->message(fd, atcmd_output);
- return -1;
+ return false;
} else if(len == -1)
{// dynamic packet
len=SHRT_MAX-4; // maximum length
@@ -277,7 +226,7 @@ ACMD_FUNC(send)
}
WFIFOHEAD(fd, len);
WFIFOW(fd,0)=TOW(type);
-
+
// parse packet contents
SKIP_VALUE(message);
while(*message != 0 && off < len){
@@ -316,12 +265,12 @@ ACMD_FUNC(send)
{// find start of string
if(*message == 0 || ISSPACE(*message)){
PARSE_ERROR(msg_txt(906),message); // Not a string:
- return -1;
+ return false;
}
++message;
}
}
-
+
// parse string
++message;
CHECK_EOS(message);
@@ -346,7 +295,7 @@ ACMD_FUNC(send)
CHECK_EOS(message);
if(!ISXDIGIT(*message)){
PARSE_ERROR(msg_txt(907),message); // Not a hexadecimal digit:
- return -1;
+ return false;
}
num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
if(ISXDIGIT(*message)){
@@ -399,7 +348,7 @@ ACMD_FUNC(send)
++message;
CHECK_EOS(message);
}
-
+
// terminate the string
if(off < end)
{// fill the rest with 0's
@@ -409,11 +358,11 @@ ACMD_FUNC(send)
} else
{// unknown
PARSE_ERROR(msg_txt(908),message); // Unknown type of value in:
- return -1;
+ return false;
}
SKIP_VALUE(message);
}
-
+
if(packet_db[type].len == -1) {// send dynamic packet
WFIFOW(fd,2)=TOW(off);
WFIFOSET(fd,off);
@@ -424,11 +373,11 @@ ACMD_FUNC(send)
}
} else {
clif->message(fd, msg_txt(259)); // Invalid packet
- return -1;
+ return false;
}
sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
clif->message(fd, atcmd_output);
- return 0;
+ return true;
#undef PARSE_ERROR
#undef CHECK_EOS
#undef SKIP_VALUE
@@ -438,34 +387,34 @@ ACMD_FUNC(send)
/*==========================================
* @rura, @warp, @mapmove
*------------------------------------------*/
-ACMD_FUNC(mapmove)
+ACMD(mapmove)
{
char map_name[MAP_NAME_LENGTH_EXT];
unsigned short mapindex;
short x = 0, y = 0;
int16 m = -1;
-
+
nullpo_retr(-1, sd);
-
+
memset(map_name, '\0', sizeof(map_name));
-
+
if (!message || !*message ||
(sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
-
+
clif->message(fd, msg_txt(909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
- return -1;
- }
-
+ return false;
+ }
+
mapindex = mapindex_name2id(map_name);
if (mapindex)
m = map_mapindex2mapid(mapindex);
-
+
if (!mapindex) { // m < 0 means on different server! [Kevin]
clif->message(fd, msg_txt(1)); // Map not found.
- return -1;
+ return false;
}
-
+
if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
{ //This is to prevent the pc_setpos call from printing an error.
clif->message(fd, msg_txt(2));
@@ -474,138 +423,138 @@ ACMD_FUNC(mapmove)
}
if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(247));
- return -1;
+ return false;
}
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(248));
- return -1;
+ return false;
}
if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
clif->message(fd, msg_txt(1)); // Map not found.
- return -1;
+ return false;
}
-
+
clif->message(fd, msg_txt(0)); // Warped.
- return 0;
+ return true;
}
/*==========================================
* Displays where a character is. Corrected version by Silent. [Skotlex]
*------------------------------------------*/
-ACMD_FUNC(where)
+ACMD(where)
{
struct map_session_data* pl_sd;
-
+
nullpo_retr(-1, sd);
memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(910)); // Please enter a player name (usage: @where <char name>).
- return -1;
+ return false;
}
-
+
pl_sd = map_nick2sd(atcmd_player_name);
if (pl_sd == NULL ||
strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
(pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
- ) {
+ ) {
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
clif->message(fd, atcmd_output);
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(jumpto)
+ACMD(jumpto)
{
struct map_session_data *pl_sd = NULL;
-
+
nullpo_retr(-1, sd);
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
- return -1;
+ return false;
}
-
+
if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
{
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
{
clif->message(fd, msg_txt(247)); // You are not authorized to warp to this map.
- return -1;
+ return false;
}
-
+
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
{
clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map.
- return -1;
+ return false;
}
-
+
if( pc_isdead(sd) )
{
clif->message(fd, msg_txt(664));
- return -1;
+ return false;
}
-
+
pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
clif->message(fd, atcmd_output);
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(jump)
+ACMD(jump)
{
short x = 0, y = 0;
-
+
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
sscanf(message, "%hd %hd", &x, &y);
-
+
if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map.
- return -1;
+ return false;
}
-
+
if( pc_isdead(sd) )
{
clif->message(fd, msg_txt(664));
- return -1;
+ return false;
}
-
+
if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
{ //This is to prevent the pc_setpos call from printing an error.
clif->message(fd, msg_txt(2));
if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
x = y = 0; //Invalid cell, use random spot.
}
-
+
pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
clif->message(fd, atcmd_output);
- return 0;
+ return true;
}
/*==========================================
* Display list of online characters with
* various info.
*------------------------------------------*/
-ACMD_FUNC(who)
+ACMD(who)
{
struct map_session_data *pl_sd = NULL;
struct s_mapiterator *iter = NULL;
@@ -621,24 +570,24 @@ ACMD_FUNC(who)
*/
int display_type = 1;
int map_id = -1;
-
+
nullpo_retr(-1, sd);
-
+
if (strstr(command, "map") != NULL) {
if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
} else {
sscanf(message, "%23s", player_name);
}
-
+
if (strstr(command, "2") != NULL)
display_type = 2;
else if (strstr(command, "3") != NULL)
display_type = 3;
-
+
level = pc_get_group_level(sd);
StringBuf_Init(&buf);
-
+
iter = mapit_getallusers();
for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
@@ -651,7 +600,7 @@ ACMD_FUNC(who)
if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
StringBuf_Printf(&buf, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level,
- job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
+ job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
break;
}
case 3: {
@@ -666,7 +615,7 @@ ACMD_FUNC(who)
default: {
struct party_data *p = party_search(pl_sd->status.party_id);
struct guild *g = pl_sd->guild;
-
+
StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
@@ -683,7 +632,7 @@ ACMD_FUNC(who)
}
}
mapit_free(iter);
-
+
if (map_id < 0) {
if (count == 0)
StringBuf_Printf(&buf, msg_txt(28)); // No player found.
@@ -701,13 +650,13 @@ ACMD_FUNC(who)
}
clif->message(fd, StringBuf_Value(&buf));
StringBuf_Destroy(&buf);
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(whogm)
+ACMD(whogm)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
@@ -717,28 +666,28 @@ ACMD_FUNC(whogm)
char player_name[NAME_LENGTH];
struct guild *g;
struct party_data *p;
-
+
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(match_text, '\0', sizeof(match_text));
memset(player_name, '\0', sizeof(player_name));
-
+
if (sscanf(message, "%199[^\n]", match_text) < 1)
strcpy(match_text, "");
for (j = 0; match_text[j]; j++)
match_text[j] = TOLOWER(match_text[j]);
-
+
count = 0;
level = pc_get_group_level(sd);
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
pl_level = pc_get_group_level(pl_sd);
if (!pl_level)
continue;
-
+
if (match_text[0])
{
memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
@@ -756,28 +705,28 @@ ACMD_FUNC(whogm)
count++;
continue;
}
-
+
sprintf(atcmd_output, msg_txt(914), // Name: %s (GM:%d) | Location: %s %d %d
- pl_sd->status.name, pl_level,
- mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
+ pl_sd->status.name, pl_level,
+ mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
clif->message(fd, atcmd_output);
-
+
sprintf(atcmd_output, msg_txt(915), // BLvl: %d | Job: %s (Lvl: %d)
- pl_sd->status.base_level,
- job_name(pl_sd->status.class_), pl_sd->status.job_level);
+ pl_sd->status.base_level,
+ job_name(pl_sd->status.class_), pl_sd->status.job_level);
clif->message(fd, atcmd_output);
-
+
p = party_search(pl_sd->status.party_id);
g = pl_sd->guild;
-
+
sprintf(atcmd_output,msg_txt(916), // Party: '%s' | Guild: '%s'
- p?p->party.name:msg_txt(917), g?g->name:msg_txt(917)); // None.
-
+ p?p->party.name:msg_txt(917), g?g->name:msg_txt(917)); // None.
+
clif->message(fd, atcmd_output);
count++;
}
mapit_free(iter);
-
+
if (count == 0)
clif->message(fd, msg_txt(150)); // No GM found.
else if (count == 1)
@@ -786,167 +735,173 @@ ACMD_FUNC(whogm)
sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
clif->message(fd, atcmd_output);
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(save)
+ACMD(save)
{
nullpo_retr(-1, sd);
-
+
pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
if (sd->status.pet_id > 0 && sd->pd)
intif_save_petdata(sd->status.account_id, &sd->pd->pet);
-
+
chrif_save(sd,0);
-
+
clif->message(fd, msg_txt(6)); // Your save point has been changed.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(load)
+ACMD(load)
{
int16 m;
-
+
nullpo_retr(-1, sd);
-
+
m = map_mapindex2mapid(sd->status.save_point.map);
if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(249)); // You are not authorized to warp to your save map.
- return -1;
+ return false;
}
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map.
- return -1;
+ return false;
}
-
+
pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
clif->message(fd, msg_txt(7)); // Warping to save point..
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(speed)
+ACMD(speed)
{
int speed;
-
+
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
sprintf(atcmd_output, msg_txt(918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
clif->message(fd, atcmd_output);
- return -1;
+ return false;
+ }
+
+ if (speed < 0) {
+ sd->base_status.speed = DEFAULT_WALK_SPEED;
+ sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
+ } else {
+ sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
+ sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
}
-
- sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
status_calc_bl(&sd->bl, SCB_SPEED);
clif->message(fd, msg_txt(8)); // Speed changed.
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(storage)
+ACMD(storage)
{
nullpo_retr(-1, sd);
-
+
if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
- return -1;
-
+ return false;
+
if (storage_storageopen(sd) == 1)
{ //Already open.
clif->message(fd, msg_txt(250));
- return -1;
+ return false;
}
-
+
clif->message(fd, msg_txt(919)); // Storage opened.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(guildstorage)
+ACMD(guildstorage)
{
nullpo_retr(-1, sd);
-
+
if (!sd->status.guild_id) {
clif->message(fd, msg_txt(252));
- return -1;
+ return false;
}
-
+
if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
- return -1;
-
+ return false;
+
if (sd->state.storage_flag == 1) {
clif->message(fd, msg_txt(250));
- return -1;
+ return false;
}
-
+
if (sd->state.storage_flag == 2) {
clif->message(fd, msg_txt(251));
- return -1;
+ return false;
}
-
+
storage_guild_storageopen(sd);
clif->message(fd, msg_txt(920)); // Guild storage opened.
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(option)
+ACMD(option)
{
int param1 = 0, param2 = 0, param3 = 0;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
{// failed to match the parameters so inform the user of the options
const char* text;
-
+
// attempt to find the setting information for this command
- text = atcommand_help_string( command );
-
+ text = atcommand_help_string( info );
+
// notify the user of the requirement to enter an option
clif->message(fd, msg_txt(921)); // Please enter at least one option.
-
+
if( text )
{// send the help text associated with this command
clif->message( fd, text );
}
-
- return -1;
+
+ return false;
}
-
+
sd->sc.opt1 = param1;
sd->sc.opt2 = param2;
pc_setoption(sd, param3);
-
+
clif->message(fd, msg_txt(9)); // Options changed.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(hide)
+ACMD(hide)
{
nullpo_retr(-1, sd);
if (sd->sc.option & OPTION_INVISIBLE) {
@@ -956,10 +911,10 @@ ACMD_FUNC(hide)
else
status_set_viewdata(&sd->bl, sd->status.class_);
clif->message(fd, msg_txt(10)); // Invisible: Off
-
+
// increment the number of pvp players on the map
map[sd->bl.m].users_pvp++;
-
+
if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
{// register the player for ranking calculations
sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
@@ -970,10 +925,10 @@ ACMD_FUNC(hide)
sd->sc.option |= OPTION_INVISIBLE;
sd->vd.class_ = INVISIBLE_CLASS;
clif->message(fd, msg_txt(11)); // Invisible: On
-
+
// decrement the number of pvp players on the map
map[sd->bl.m].users_pvp--;
-
+
if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
{// unregister the player for ranking
delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
@@ -981,109 +936,119 @@ ACMD_FUNC(hide)
}
}
clif->changeoption(&sd->bl);
-
- return 0;
+
+ return true;
}
/*==========================================
* Changes a character's class
*------------------------------------------*/
-ACMD_FUNC(jobchange)
+ACMD(jobchange)
{
int job = 0, upper = 0;
const char* text;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
- int i, found = 0;
-
- for (i = JOB_NOVICE; i < JOB_MAX; ++i) {
- if (strncmpi(message, job_name(i), 16) == 0) {
- job = i;
- upper = 0;
- found = 1;
- break;
+ int i;
+ bool found = false;
+
+ upper = 0;
+
+ // Normal Jobs
+ for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ){
+ if (strncmpi(message, job_name(i), 16) == 0) {
+ job = i;
+ found = true;
}
}
-
+
+ // High Jobs, Babys and Third
+ for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ){
+ if (strncmpi(message, job_name(i), 16) == 0) {
+ job = i;
+ found = true;
+ }
+ }
+
if (!found) {
- text = atcommand_help_string(command);
+ text = atcommand_help_string(info);
if (text)
clif->message(fd, text);
- return -1;
+ return false;
}
}
-
+
if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER
|| job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
- || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
- ) // Deny direct transformation into dummy jobs
- {clif->message(fd, msg_txt(923)); //"You can not change to this job by command."
- return 0;}
-
+ || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
+ ) // Deny direct transformation into dummy jobs
+ {clif->message(fd, msg_txt(923)); //"You can not change to this job by command."
+ return true;}
+
if (pcdb_checkid(job))
{
if (pc_jobchange(sd, job, upper) == 0)
clif->message(fd, msg_txt(12)); // Your job has been changed.
else {
clif->message(fd, msg_txt(155)); // You are unable to change your job.
- return -1;
+ return false;
}
} else {
- text = atcommand_help_string(command);
+ text = atcommand_help_string(info);
if (text)
clif->message(fd, text);
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(kill)
+ACMD(kill)
{
nullpo_retr(-1, sd);
status_kill(&sd->bl);
clif->message(sd->fd, msg_txt(13)); // A pity! You've died.
if (fd != sd->fd)
clif->message(fd, msg_txt(14)); // Character killed.
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(alive)
+ACMD(alive)
{
nullpo_retr(-1, sd);
if (!status_revive(&sd->bl, 100, 100))
{
clif->message(fd, msg_txt(667));
- return -1;
+ return false;
}
clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
clif->message(fd, msg_txt(16)); // You've been revived! It's a miracle!
- return 0;
+ return true;
}
/*==========================================
* +kamic [LuzZza]
*------------------------------------------*/
-ACMD_FUNC(kami)
+ACMD(kami)
{
unsigned long color=0;
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if(*(command + 5) != 'c' && *(command + 5) != 'C') {
if (!message || !*message) {
clif->message(fd, msg_txt(980)); // Please enter a message (usage: @kami <message>).
- return -1;
+ return false;
}
-
+
sscanf(message, "%199[^\n]", atcmd_output);
if (strstr(command, "l") != NULL)
clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
@@ -1092,22 +1057,22 @@ ACMD_FUNC(kami)
} else {
if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
clif->message(fd, msg_txt(981)); // Please enter color and message (usage: @kamic <color> <message>).
- return -1;
+ return false;
}
-
+
if(color > 0xFFFFFF) {
clif->message(fd, msg_txt(982)); // Invalid color.
- return -1;
+ return false;
}
intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
}
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(heal)
+ACMD(heal)
{
int hp = 0, sp = 0; // [Valaris] thanks to fov
nullpo_retr(-1, sd);
@@ -1117,30 +1082,30 @@ ACMD_FUNC(heal)
// some overflow checks
if( hp == INT_MIN ) hp++;
if( sp == INT_MIN ) sp++;
-
+
if ( hp == 0 && sp == 0 ) {
if (!status_percent_heal(&sd->bl, 100, 100))
clif->message(fd, msg_txt(157)); // HP and SP have already been recovered.
else
clif->message(fd, msg_txt(17)); // HP, SP recovered.
- return 0;
+ return true;
}
-
+
if ( hp > 0 && sp >= 0 ) {
if(!status_heal(&sd->bl, hp, sp, 0))
clif->message(fd, msg_txt(157)); // HP and SP are already with the good value.
else
clif->message(fd, msg_txt(17)); // HP, SP recovered.
- return 0;
+ return true;
}
-
+
if ( hp < 0 && sp <= 0 ) {
status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
clif->damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
clif->message(fd, msg_txt(156)); // HP or/and SP modified.
- return 0;
+ return true;
}
-
+
//Opposing signs.
if ( hp ) {
if (hp > 0)
@@ -1150,22 +1115,22 @@ ACMD_FUNC(heal)
clif->damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
}
}
-
+
if ( sp ) {
if (sp > 0)
status_heal(&sd->bl, 0, sp, 0);
else
status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
}
-
+
clif->message(fd, msg_txt(156)); // HP or/and SP modified.
- return 0;
+ return true;
}
/*==========================================
* @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
*------------------------------------------*/
-ACMD_FUNC(item)
+ACMD(item)
{
char item_name[100];
int number = 0, item_id, flag = 0;
@@ -1173,54 +1138,54 @@ ACMD_FUNC(item)
struct item_data *item_data;
int get_count, i;
nullpo_retr(-1, sd);
-
+
memset(item_name, '\0', sizeof(item_name));
-
+
if (!message || !*message || (
- sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
- sscanf(message, "%99s %d", item_name, &number) < 1
- )) {
+ sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
+ sscanf(message, "%99s %d", item_name, &number) < 1
+ )) {
clif->message(fd, msg_txt(983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
- return -1;
+ return false;
}
-
+
if (number <= 0)
number = 1;
-
+
if ((item_data = itemdb_searchname(item_name)) == NULL &&
(item_data = itemdb_exists(atoi(item_name))) == NULL)
{
clif->message(fd, msg_txt(19)); // Invalid item ID or name.
- return -1;
+ return false;
}
-
+
item_id = item_data->nameid;
get_count = number;
//Check if it's stackable.
if (!itemdb_isstackable2(item_data))
get_count = 1;
-
+
for (i = 0; i < number; i += get_count) {
// if not pet egg
if (!pet_create_egg(sd, item_id)) {
memset(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = item_id;
item_tmp.identify = 1;
-
+
if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
clif->additem(sd, 0, 0, flag);
}
}
-
+
if (flag == 0)
clif->message(fd, msg_txt(18)); // Item created.
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(item2)
+ACMD(item2)
{
struct item item_tmp;
struct item_data *item_data;
@@ -1229,26 +1194,26 @@ ACMD_FUNC(item2)
int identify = 0, refine = 0, attr = 0;
int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
nullpo_retr(-1, sd);
-
+
memset(item_name, '\0', sizeof(item_name));
-
+
if (!message || !*message || (
- sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
- sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
- )) {
+ sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
+ sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
+ )) {
clif->message(fd, msg_txt(984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
clif->message(fd, msg_txt(985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
- return -1;
+ return false;
}
-
+
if (number <= 0)
number = 1;
-
+
item_id = 0;
if ((item_data = itemdb_searchname(item_name)) != NULL ||
(item_data = itemdb_exists(atoi(item_name))) != NULL)
item_id = item_data->nameid;
-
+
if (item_id > 500) {
int flag = 0;
int loop, get_count, i;
@@ -1283,59 +1248,59 @@ ACMD_FUNC(item2)
if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
clif->additem(sd, 0, 0, flag);
}
-
+
if (flag == 0)
clif->message(fd, msg_txt(18)); // Item created.
} else {
clif->message(fd, msg_txt(19)); // Invalid item ID or name.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(itemreset)
+ACMD(itemreset)
{
int i;
nullpo_retr(-1, sd);
-
+
for (i = 0; i < MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
}
}
clif->message(fd, msg_txt(20)); // All of your items have been removed.
-
- return 0;
+
+ return true;
}
/*==========================================
* Atcommand @lvlup
*------------------------------------------*/
-ACMD_FUNC(baselevelup)
+ACMD(baselevelup)
{
int level=0, i=0, status_point=0;
nullpo_retr(-1, sd);
level = atoi(message);
-
+
if (!message || !*message || !level) {
clif->message(fd, msg_txt(986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
- return -1;
+ return false;
}
-
+
if (level > 0) {
if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
clif->message(fd, msg_txt(47)); // Base level can't go any higher.
- return -1;
+ return false;
} // End Addition
if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
level = pc_maxbaselv(sd) - sd->status.base_level;
for (i = 0; i < level; i++)
status_point += pc_gets_status_point(sd->status.base_level + i);
-
+
sd->status.status_point += status_point;
sd->status.base_level += (unsigned int)level;
status_percent_heal(&sd->bl, 100, 100);
@@ -1344,7 +1309,7 @@ ACMD_FUNC(baselevelup)
} else {
if (sd->status.base_level == 1) {
clif->message(fd, msg_txt(158)); // Base level can't go any lower.
- return -1;
+ return false;
}
level*=-1;
if ((unsigned int)level >= sd->status.base_level)
@@ -1369,27 +1334,27 @@ ACMD_FUNC(baselevelup)
pc_baselevelchanged(sd);
if(sd->status.party_id)
party_send_levelup(sd);
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(joblevelup)
+ACMD(joblevelup)
{
int level=0;
nullpo_retr(-1, sd);
-
+
level = atoi(message);
-
+
if (!message || !*message || !level) {
clif->message(fd, msg_txt(987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
- return -1;
+ return false;
}
if (level > 0) {
if (sd->status.job_level >= pc_maxjoblv(sd)) {
clif->message(fd, msg_txt(23)); // Job level can't go any higher.
- return -1;
+ return false;
}
if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
level = pc_maxjoblv(sd) - sd->status.job_level;
@@ -1400,7 +1365,7 @@ ACMD_FUNC(joblevelup)
} else {
if (sd->status.job_level == 1) {
clif->message(fd, msg_txt(159)); // Job level can't go any lower.
- return -1;
+ return false;
}
level *=-1;
if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
@@ -1420,60 +1385,54 @@ ACMD_FUNC(joblevelup)
clif->updatestatus(sd, SP_NEXTJOBEXP);
clif->updatestatus(sd, SP_SKILLPOINT);
status_calc_pc(sd, 0);
-
- return 0;
+
+ return true;
}
/*==========================================
* @help
*------------------------------------------*/
-ACMD_FUNC(help)
-{
- config_setting_t *help;
- const char *text = NULL;
+ACMD(help) {
const char *command_name = NULL;
char *default_command = "help";
-
+ AtCommandInfo *tinfo = NULL;
+
nullpo_retr(-1, sd);
-
- help = config_lookup(&atcommand_config, "help");
- if (help == NULL) {
- clif->message(fd, msg_txt(27)); // "Commands help is not available."
- return -1;
- }
-
+
if (!message || !*message) {
command_name = default_command; // If no command_name specified, display help for @help.
} else {
- if (*message == atcommand_symbol || *message == charcommand_symbol)
+ if (*message == atcommand->at_symbol || *message == atcommand->char_symbol)
++message;
command_name = atcommand_checkalias(message);
}
-
- if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
+
+ if (!atcommand->can_use2(sd, command_name, COMMAND_ATCOMMAND)) {
sprintf(atcmd_output, msg_txt(153), message); // "%s is Unknown Command"
clif->message(fd, atcmd_output);
atcommand_get_suggestions(sd, command_name, true);
- return -1;
+ return false;
}
-
- if (!config_setting_lookup_string(help, command_name, &text)) {
- sprintf(atcmd_output, msg_txt(988), atcommand_symbol, command_name); // There is no help for %c%s.
+
+ tinfo = get_atcommandinfo_byname(atcommand_checkalias(command_name));
+
+ if ( !tinfo || tinfo->help == NULL ) {
+ sprintf(atcmd_output, msg_txt(988), atcommand->at_symbol, command_name); // There is no help for %c%s.
clif->message(fd, atcmd_output);
atcommand_get_suggestions(sd, command_name, true);
- return -1;
+ return false;
}
-
- sprintf(atcmd_output, msg_txt(989), atcommand_symbol, command_name); // Help for command %c%s:
+
+ sprintf(atcmd_output, msg_txt(989), atcommand->at_symbol, command_name); // Help for command %c%s:
clif->message(fd, atcmd_output);
-
+
{ // Display aliases
DBIterator* iter;
AtCommandInfo *command_info;
AliasInfo *alias_info = NULL;
StringBuf buf;
bool has_aliases = false;
-
+
StringBuf_Init(&buf);
StringBuf_AppendStr(&buf, msg_txt(990)); // Available aliases:
command_info = get_atcommandinfo_byname(command_name);
@@ -1489,10 +1448,10 @@ ACMD_FUNC(help)
clif->message(fd, StringBuf_Value(&buf));
StringBuf_Destroy(&buf);
}
-
+
// Display help contents
- clif->message(fd, text);
- return 0;
+ clif->message(fd, tinfo->help);
+ return true;
}
// helper function, used in foreach calls to stop auto-attack timers
@@ -1522,24 +1481,26 @@ static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
return 0;
}
-ACMD_FUNC(pvpoff)
+ACMD(pvpoff)
{
nullpo_retr(-1, sd);
-
+
if (!map[sd->bl.m].flag.pvp) {
clif->message(fd, msg_txt(160)); // PvP is already Off.
- return -1;
+ return false;
}
-
+
map_zone_change2(sd->bl.m,map[sd->bl.m].prev_zone);
map[sd->bl.m].flag.pvp = 0;
-
- if (!battle_config.pk_mode)
+
+ if (!battle_config.pk_mode) {
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
+ clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
+ }
map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
clif->message(fd, msg_txt(31)); // PvP: Off.
- return 0;
+ return true;
}
/*==========================================
@@ -1559,192 +1520,195 @@ static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
return 0;
}
-ACMD_FUNC(pvpon)
+ACMD(pvpon)
{
nullpo_retr(-1, sd);
-
+
if (map[sd->bl.m].flag.pvp) {
clif->message(fd, msg_txt(161)); // PvP is already On.
- return -1;
+ return false;
}
map_zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME));
map[sd->bl.m].flag.pvp = 1;
-
+
if (!battle_config.pk_mode) {// display pvp circle and rank
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
+ clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
}
-
+
clif->message(fd, msg_txt(32)); // PvP: On.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(gvgoff)
+ACMD(gvgoff)
{
nullpo_retr(-1, sd);
-
+
if (!map[sd->bl.m].flag.gvg) {
clif->message(fd, msg_txt(162)); // GvG is already Off.
- return -1;
+ return false;
}
-
+
map_zone_change2(sd->bl.m,map[sd->bl.m].prev_zone);
map[sd->bl.m].flag.gvg = 0;
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
+ clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
clif->message(fd, msg_txt(33)); // GvG: Off.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(gvgon)
+ACMD(gvgon)
{
nullpo_retr(-1, sd);
-
+
if (map[sd->bl.m].flag.gvg) {
clif->message(fd, msg_txt(163)); // GvG is already On.
- return -1;
+ return false;
}
map_zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME));
map[sd->bl.m].flag.gvg = 1;
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
+ clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
clif->message(fd, msg_txt(34)); // GvG: On.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(model)
+ACMD(model)
{
int hair_style = 0, hair_color = 0, cloth_color = 0;
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
sprintf(atcmd_output, msg_txt(991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
-
+
if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
- pc_changelook(sd, LOOK_HAIR, hair_style);
- pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
- pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
- clif->message(fd, msg_txt(36)); // Appearence changed.
+ pc_changelook(sd, LOOK_HAIR, hair_style);
+ pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
+ pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
+ clif->message(fd, msg_txt(36)); // Appearence changed.
} else {
clif->message(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* @dye && @ccolor
*------------------------------------------*/
-ACMD_FUNC(dye)
+ACMD(dye)
{
int cloth_color = 0;
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
sprintf(atcmd_output, msg_txt(992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
-
+
if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
clif->message(fd, msg_txt(36)); // Appearence changed.
} else {
clif->message(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* @hairstyle && @hstyle
*------------------------------------------*/
-ACMD_FUNC(hair_style)
+ACMD(hair_style)
{
int hair_style = 0;
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
sprintf(atcmd_output, msg_txt(993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
-
+
if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
- pc_changelook(sd, LOOK_HAIR, hair_style);
- clif->message(fd, msg_txt(36)); // Appearence changed.
+ pc_changelook(sd, LOOK_HAIR, hair_style);
+ clif->message(fd, msg_txt(36)); // Appearence changed.
} else {
clif->message(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* @haircolor && @hcolor
*------------------------------------------*/
-ACMD_FUNC(hair_color)
+ACMD(hair_color)
{
int hair_color = 0;
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
sprintf(atcmd_output, msg_txt(994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
-
+
if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
- pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
- clif->message(fd, msg_txt(36)); // Appearence changed.
+ pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
+ clif->message(fd, msg_txt(36)); // Appearence changed.
} else {
clif->message(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* @go [city_number or city_name] - Updated by Harbin
*------------------------------------------*/
-ACMD_FUNC(go)
+ACMD(go)
{
int i;
int town;
char map_name[MAP_NAME_LENGTH];
int16 m;
-
+
const struct {
char map[MAP_NAME_LENGTH];
int x, y;
@@ -1790,37 +1754,32 @@ ACMD_FUNC(go)
{ MAP_MALAYA, 242, 211 }, // 34=Malaya Port
{ MAP_ECLAGE, 110, 39 }, // 35=Eclage
};
-
+
nullpo_retr(-1, sd);
-
- if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
- clif->message(sd->fd,msg_txt(995)); // You cannot use @go on this map.
- return 0;
- }
-
+
memset(map_name, '\0', sizeof(map_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
// get the number
town = atoi(message);
-
+
if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
{// no value matched so send the list of locations
const char* text;
-
+
// attempt to find the text help string
- text = atcommand_help_string( command );
-
+ text = atcommand_help_string( info );
+
clif->message(fd, msg_txt(38)); // Invalid location number, or name.
-
+
if( text )
{// send the text to the client
clif->message( fd, text );
}
-
- return -1;
+
+ return false;
}
-
+
// get possible name of the city
map_name[MAP_NAME_LENGTH-1] = '\0';
for (i = 0; map_name[i]; i++)
@@ -1909,36 +1868,36 @@ ACMD_FUNC(go)
} else if (strncmp(map_name, "eclage", 3) == 0) {
town = 35;
}
-
+
if (town >= 0 && town < ARRAYLENGTH(data))
{
m = map_mapname2mapid(data[town].map);
if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(247));
- return -1;
+ return false;
}
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(248));
- return -1;
+ return false;
}
if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
clif->message(fd, msg_txt(0)); // Warped.
} else {
clif->message(fd, msg_txt(1)); // Map not found.
- return -1;
+ return false;
}
} else { // if you arrive here, you have an error in town variable when reading of names
clif->message(fd, msg_txt(38)); // Invalid location number or name.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(monster)
+ACMD(monster)
{
char name[NAME_LENGTH];
char monster[NAME_LENGTH];
@@ -1950,14 +1909,14 @@ ACMD_FUNC(monster)
short mx, my;
unsigned int size;
nullpo_retr(-1, sd);
-
+
memset(name, '\0', sizeof(name));
memset(monster, '\0', sizeof(monster));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message) {
- clif->message(fd, msg_txt(80)); // Give the display name or monster name/id please.
- return -1;
+ clif->message(fd, msg_txt(80)); // Give the display name or monster name/id please.
+ return false;
}
if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
@@ -1973,42 +1932,42 @@ ACMD_FUNC(monster)
name[0] = '\0';
} else {
clif->message(fd, msg_txt(80)); // Give a display name and monster name/id please.
- return -1;
+ return false;
}
-
+
if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
mob_id = mobdb_checkid(atoi(monster));
-
+
if (mob_id == 0) {
clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
- return -1;
+ return false;
}
-
+
if (mob_id == MOBID_EMPERIUM) {
clif->message(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
- return -1;
+ return false;
}
-
+
if (number <= 0)
number = 1;
-
+
if( !name[0] )
strcpy(name, "--ja--");
-
+
// If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
number = battle_config.atc_spawn_quantity_limit;
-
+
if (strcmp(command+1, "monstersmall") == 0)
size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
else if (strcmp(command+1, "monsterbig") == 0)
size = SZ_BIG;
else
size = SZ_SMALL;
-
+
if (battle_config.etc_log)
ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
-
+
count = 0;
range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
for (i = 0; i < number; i++) {
@@ -2016,7 +1975,7 @@ ACMD_FUNC(monster)
k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
count += (k != 0) ? 1 : 0;
}
-
+
if (count != 0)
if (number == count)
clif->message(fd, msg_txt(39)); // All monster summoned!
@@ -2024,12 +1983,12 @@ ACMD_FUNC(monster)
sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
clif->message(fd, atcmd_output);
}
- else {
- clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
- return -1;
- }
-
- return 0;
+ else {
+ clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
+ return false;
+ }
+
+ return true;
}
/*==========================================
@@ -2039,13 +1998,13 @@ static int atkillmonster_sub(struct block_list *bl, va_list ap)
{
struct mob_data *md;
int flag;
-
+
nullpo_ret(md=(struct mob_data *)bl);
flag = va_arg(ap, int);
-
+
if (md->guardian_data)
return 0; //Do not touch WoE mobs!
-
+
if (flag)
status_zap(bl,md->status.hp, 0);
else
@@ -2053,41 +2012,41 @@ static int atkillmonster_sub(struct block_list *bl, va_list ap)
return 1;
}
-ACMD_FUNC(killmonster)
+ACMD(killmonster)
{
int map_id, drop_flag;
char map_name[MAP_NAME_LENGTH_EXT];
nullpo_retr(-1, sd);
-
+
memset(map_name, '\0', sizeof(map_name));
-
+
if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
map_id = sd->bl.m;
else {
if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
-
+
drop_flag = strcmp(command+1, "killmonster2");
-
+
map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
-
+
clif->message(fd, msg_txt(165)); // All monsters killed!
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(refine)
+ACMD(refine)
{
int i,j, position = 0, refine = 0, current_position, final_refine;
int count;
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
clif->message(fd, msg_txt(996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
sprintf(atcmd_output, msg_txt(997), EQP_HEAD_LOW); // %d: Lower Headgear
@@ -2110,11 +2069,11 @@ ACMD_FUNC(refine)
clif->message(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(1006), EQP_HEAD_MID); // %d: Mid Headgear
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
-
+
refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
-
+
count = 0;
for (j = 0; j < EQI_MAX-1; j++) {
if ((i = sd->equip_index[j]) < 0)
@@ -2125,10 +2084,10 @@ ACMD_FUNC(refine)
continue;
if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
continue;
-
+
if(position && !(sd->status.inventory[i].equip & position))
continue;
-
+
final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
if (sd->status.inventory[i].refine != final_refine) {
sd->status.inventory[i].refine = final_refine;
@@ -2142,7 +2101,7 @@ ACMD_FUNC(refine)
count++;
}
}
-
+
if (count == 0)
clif->message(fd, msg_txt(166)); // No item has been refined.
else if (count == 1)
@@ -2151,40 +2110,40 @@ ACMD_FUNC(refine)
sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
clif->message(fd, atcmd_output);
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(produce)
+ACMD(produce)
{
char item_name[100];
int item_id, attribute = 0, star = 0;
struct item_data *item_data;
struct item tmp_item;
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(item_name, '\0', sizeof(item_name));
-
+
if (!message || !*message || (
- sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
- sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
- )) {
+ sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
+ sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
+ )) {
clif->message(fd, msg_txt(1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
- return -1;
+ return false;
}
-
+
if ( (item_data = itemdb_searchname(item_name)) == NULL &&
- (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
+ (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
clif->message(fd, msg_txt(170)); //This item is not an equipment.
- return -1;
+ return false;
}
-
+
item_id = item_data->nameid;
-
+
if (itemdb_isequip2(item_data)) {
int flag = 0;
if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
@@ -2197,33 +2156,33 @@ ACMD_FUNC(produce)
tmp_item.identify = 1;
tmp_item.card[0] = CARD0_FORGE;
tmp_item.card[1] = item_data->type==IT_WEAPON?
- ((star*5) << 8) + attribute:0;
+ ((star*5) << 8) + attribute:0;
tmp_item.card[2] = GetWord(sd->status.char_id, 0);
tmp_item.card[3] = GetWord(sd->status.char_id, 1);
clif->produce_effect(sd, 0, item_id);
clif->misceffect(&sd->bl, 3);
-
+
if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
clif->additem(sd, 0, 0, flag);
} else {
sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(memo)
+ACMD(memo)
{
int position = 0;
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if( !message || !*message || sscanf(message, "%d", &position) < 1 )
{
int i;
@@ -2236,78 +2195,78 @@ ACMD_FUNC(memo)
sprintf(atcmd_output, msg_txt(171), i); // %d - void
clif->message(sd->fd, atcmd_output);
}
- return 0;
+ return true;
}
-
+
if( position < 0 || position >= MAX_MEMOPOINTS )
{
sprintf(atcmd_output, msg_txt(1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
-
+
pc_memo(sd, position);
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(gat)
+ACMD(gat)
{
int y;
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
for (y = 2; y >= -2; y--) {
sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
- map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
- map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
- map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
- map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
- map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
- map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
-
+ map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
+ map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
+ map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
+ map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
+ map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
+ map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
+
clif->message(fd, atcmd_output);
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(displaystatus)
+ACMD(displaystatus)
{
int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
clif->message(fd, msg_txt(1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
- return -1;
+ return false;
}
if (i < 2) flag = 1;
if (i < 3) tick = 0;
-
+
clif->status_change(&sd->bl, type, flag, tick, val1, val2, val3);
-
- return 0;
+
+ return true;
}
/*==========================================
* @stpoint (Rewritten by [Yor])
*------------------------------------------*/
-ACMD_FUNC(statuspoint)
+ACMD(statuspoint)
{
int point;
unsigned int new_status_point;
-
+
if (!message || !*message || (point = atoi(message)) == 0) {
clif->message(fd, msg_txt(1010)); // Please enter a number (usage: @stpoint <number of points>).
- return -1;
+ return false;
}
-
+
if(point < 0)
{
if(sd->status.status_point < (unsigned int)(-point))
@@ -2327,7 +2286,7 @@ ACMD_FUNC(statuspoint)
{
new_status_point = sd->status.status_point + point;
}
-
+
if (new_status_point != sd->status.status_point) {
sd->status.status_point = new_status_point;
clif->updatestatus(sd, SP_STATUSPOINT);
@@ -2337,26 +2296,26 @@ ACMD_FUNC(statuspoint)
clif->message(fd, msg_txt(41)); // Unable to decrease the number/value.
else
clif->message(fd, msg_txt(149)); // Unable to increase the number/value.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* @skpoint (Rewritten by [Yor])
*------------------------------------------*/
-ACMD_FUNC(skillpoint)
+ACMD(skillpoint)
{
int point;
unsigned int new_skill_point;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || (point = atoi(message)) == 0) {
clif->message(fd, msg_txt(1011)); // Please enter a number (usage: @skpoint <number of points>).
- return -1;
+ return false;
}
-
+
if(point < 0)
{
if(sd->status.skill_point < (unsigned int)(-point))
@@ -2376,7 +2335,7 @@ ACMD_FUNC(skillpoint)
{
new_skill_point = sd->status.skill_point + point;
}
-
+
if (new_skill_point != sd->status.skill_point) {
sd->status.skill_point = new_skill_point;
clif->updatestatus(sd, SP_SKILLPOINT);
@@ -2386,75 +2345,75 @@ ACMD_FUNC(skillpoint)
clif->message(fd, msg_txt(41)); // Unable to decrease the number/value.
else
clif->message(fd, msg_txt(149)); // Unable to increase the number/value.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* @zeny
*------------------------------------------*/
-ACMD_FUNC(zeny)
+ACMD(zeny)
{
int zeny=0, ret=-1;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || (zeny = atoi(message)) == 0) {
clif->message(fd, msg_txt(1012)); // Please enter an amount (usage: @zeny <amount>).
- return -1;
+ return false;
}
-
+
if(zeny > 0){
if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
- clif->message(fd, msg_txt(149)); // Unable to increase the number/value.
+ clif->message(fd, msg_txt(149)); // Unable to increase the number/value.
}
else {
if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
- clif->message(fd, msg_txt(41)); // Unable to decrease the number/value.
+ clif->message(fd, msg_txt(41)); // Unable to decrease the number/value.
}
if(!ret) clif->message(fd, msg_txt(176)); //ret=0 mean cmd success
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(param)
+ACMD(param)
{
int i, value = 0, new_value, max;
const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
short* status[6];
//we don't use direct initialization because it isn't part of the c standard.
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
clif->message(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
- return -1;
+ return false;
}
-
+
ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
-
+
if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
clif->message(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
- return -1;
+ return false;
}
-
+
status[0] = &sd->status.str;
status[1] = &sd->status.agi;
status[2] = &sd->status.vit;
status[3] = &sd->status.int_;
status[4] = &sd->status.dex;
status[5] = &sd->status.luk;
-
+
if( battle_config.atcommand_max_stat_bypass )
max = SHRT_MAX;
else
max = pc_maxparameter(sd);
-
+
if(value < 0 && *status[i] <= -value) {
new_value = 1;
} else if(max - *status[i] < value) {
@@ -2462,7 +2421,7 @@ ACMD_FUNC(param)
} else {
new_value = *status[i] + value;
}
-
+
if (new_value != *status[i]) {
*status[i] = new_value;
clif->updatestatus(sd, SP_STR + i);
@@ -2474,29 +2433,29 @@ ACMD_FUNC(param)
clif->message(fd, msg_txt(41)); // Unable to decrease the number/value.
else
clif->message(fd, msg_txt(149)); // Unable to increase the number/value.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Stat all by fritz (rewritten by [Yor])
*------------------------------------------*/
-ACMD_FUNC(stat_all)
+ACMD(stat_all)
{
int index, count, value, max, new_value;
short* status[6];
//we don't use direct initialization because it isn't part of the c standard.
nullpo_retr(-1, sd);
-
+
status[0] = &sd->status.str;
status[1] = &sd->status.agi;
status[2] = &sd->status.vit;
status[3] = &sd->status.int_;
status[4] = &sd->status.dex;
status[5] = &sd->status.luk;
-
+
if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
value = pc_maxparameter(sd);
max = pc_maxparameter(sd);
@@ -2506,17 +2465,17 @@ ACMD_FUNC(stat_all)
else
max = pc_maxparameter(sd);
}
-
+
count = 0;
for (index = 0; index < ARRAYLENGTH(status); index++) {
-
+
if (value > 0 && *status[index] > max - value)
new_value = max;
else if (value < 0 && *status[index] <= -value)
new_value = 1;
else
new_value = *status[index] +value;
-
+
if (new_value != (int)*status[index]) {
*status[index] = new_value;
clif->updatestatus(sd, SP_STR + index);
@@ -2524,7 +2483,7 @@ ACMD_FUNC(stat_all)
count++;
}
}
-
+
if (count > 0) { // if at least 1 stat modified
status_calc_pc(sd, 0);
clif->message(fd, msg_txt(84)); // All stats changed!
@@ -2533,268 +2492,268 @@ ACMD_FUNC(stat_all)
clif->message(fd, msg_txt(177)); // You cannot decrease that stat anymore.
else
clif->message(fd, msg_txt(178)); // You cannot increase that stat anymore.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(guildlevelup)
+ACMD(guildlevelup)
{
int level = 0;
short added_level;
struct guild *guild_info;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
clif->message(fd, msg_txt(1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
- return -1;
+ return false;
}
-
+
if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
clif->message(fd, msg_txt(43)); // You're not in a guild.
- return -1;
+ return false;
}
//if (strcmp(sd->status.name, guild_info->master) != 0) {
// clif->message(fd, msg_txt(44)); // You're not the master of your guild.
- // return -1;
+ // return false;
//}
-
+
added_level = (short)level;
if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
added_level = 1 - guild_info->guild_lv;
-
+
if (added_level != 0) {
intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
clif->message(fd, msg_txt(179)); // Guild level changed.
} else {
clif->message(fd, msg_txt(45)); // Guild level change failed.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(makeegg)
+ACMD(makeegg)
{
struct item_data *item_data;
int id, pet_id;
nullpo_retr(-1, sd);
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
- return -1;
+ return false;
}
-
+
if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
id = item_data->nameid;
else
- if ((id = mobdb_searchname(message)) != 0) // for monster name
- ;
- else
- id = atoi(message);
-
+ if ((id = mobdb_searchname(message)) != 0) // for monster name
+ ;
+ else
+ id = atoi(message);
+
pet_id = search_petDB_index(id, PET_CLASS);
if (pet_id < 0)
pet_id = search_petDB_index(id, PET_EGG);
if (pet_id >= 0) {
sd->catch_target_class = pet_db[pet_id].class_;
intif_create_pet(
- sd->status.account_id, sd->status.char_id,
- (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
- (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
- 100, 0, 1, pet_db[pet_id].jname);
+ sd->status.account_id, sd->status.char_id,
+ (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
+ (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
+ 100, 0, 1, pet_db[pet_id].jname);
} else {
clif->message(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(hatch)
+ACMD(hatch)
{
nullpo_retr(-1, sd);
if (sd->status.pet_id <= 0)
clif->sendegg(sd);
else {
clif->message(fd, msg_txt(181)); // You already have a pet.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(petfriendly)
+ACMD(petfriendly)
{
int friendly;
struct pet_data *pd;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || (friendly = atoi(message)) < 0) {
clif->message(fd, msg_txt(1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
- return -1;
+ return false;
}
-
+
pd = sd->pd;
if (!pd) {
clif->message(fd, msg_txt(184)); // Sorry, but you have no pet.
- return -1;
+ return false;
}
-
+
if (friendly < 0 || friendly > 1000)
{
clif->message(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
+ return false;
}
-
+
if (friendly == pd->pet.intimate) {
clif->message(fd, msg_txt(183)); // Pet intimacy is already at maximum.
- return -1;
+ return false;
}
-
+
pet_set_intimate(pd, friendly);
clif->send_petstatus(sd);
clif->message(fd, msg_txt(182)); // Pet intimacy changed.
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(pethungry)
+ACMD(pethungry)
{
int hungry;
struct pet_data *pd;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || (hungry = atoi(message)) < 0) {
clif->message(fd, msg_txt(1017)); // Please enter a valid number (usage: @pethungry <0-100>).
- return -1;
+ return false;
}
-
+
pd = sd->pd;
if (!sd->status.pet_id || !pd) {
clif->message(fd, msg_txt(184)); // Sorry, but you have no pet.
- return -1;
+ return false;
}
if (hungry < 0 || hungry > 100) {
clif->message(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
+ return false;
}
if (hungry == pd->pet.hungry) {
clif->message(fd, msg_txt(186)); // Pet hunger is already at maximum.
- return -1;
+ return false;
}
-
+
pd->pet.hungry = hungry;
clif->send_petstatus(sd);
clif->message(fd, msg_txt(185)); // Pet hunger changed.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(petrename)
+ACMD(petrename)
{
struct pet_data *pd;
nullpo_retr(-1, sd);
if (!sd->status.pet_id || !sd->pd) {
clif->message(fd, msg_txt(184)); // Sorry, but you have no pet.
- return -1;
+ return false;
}
pd = sd->pd;
if (!pd->pet.rename_flag) {
clif->message(fd, msg_txt(188)); // You can already rename your pet.
- return -1;
+ return false;
}
-
+
pd->pet.rename_flag = 0;
intif_save_petdata(sd->status.account_id, &pd->pet);
clif->send_petstatus(sd);
clif->message(fd, msg_txt(187)); // You can now rename your pet.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(recall) {
+ACMD(recall) {
struct map_session_data *pl_sd = NULL;
-
+
nullpo_retr(-1, sd);
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1018)); // Please enter a player name (usage: @recall <char name/ID>).
- return -1;
+ return false;
}
-
+
if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
{
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
{
clif->message(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
- return -1;
+ return false;
}
-
+
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(1019)); // You are not authorized to warp someone to this map.
- return -1;
+ return false;
}
if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(1020)); // You are not authorized to warp this player from their map.
- return -1;
+ return false;
}
if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
- return -1;
+ return false;
}
pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
clif->message(fd, atcmd_output);
-
- return 0;
+
+ return true;
}
/*==========================================
* charblock command (usage: charblock <player_name>)
* This command do a definitiv ban on a player
*------------------------------------------*/
-ACMD_FUNC(char_block)
+ACMD(char_block)
{
nullpo_retr(-1, sd);
-
+
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1021)); // Please enter a player name (usage: @charblock/@block <char name>).
- return -1;
+ return false;
}
-
+
chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it.
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -2812,24 +2771,24 @@ ACMD_FUNC(char_block)
* <example> @ban +1m-2mn1s-6y test_player
* this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
*------------------------------------------*/
-ACMD_FUNC(char_ban)
+ACMD(char_ban)
{
char * modif_p;
int year, month, day, hour, minute, second, value;
time_t timestamp;
struct tm *tmtime;
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
clif->message(fd, msg_txt(1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <char name>).
- return -1;
+ return false;
}
-
+
atcmd_output[sizeof(atcmd_output)-1] = '\0';
-
+
modif_p = atcmd_output;
year = month = day = hour = minute = second = 0;
while (modif_p[0] != '\0') {
@@ -2869,7 +2828,7 @@ ACMD_FUNC(char_ban)
}
if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
clif->message(fd, msg_txt(85)); // Invalid time for ban command.
- return -1;
+ return false;
}
/**
* We now check if you can adjust the ban to negative (and if this is the case)
@@ -2883,103 +2842,103 @@ ACMD_FUNC(char_ban)
tmtime->tm_min = tmtime->tm_min + minute;
tmtime->tm_sec = tmtime->tm_sec + second;
timestamp = mktime(tmtime);
- if( timestamp <= time(NULL) && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) ) {
+ if( timestamp <= time(NULL) && !pc_can_use_command(sd, "@unban") ) {
clif->message(fd,msg_txt(1023)); // You are not allowed to reduce the length of a ban.
- return -1;
+ return false;
}
-
+
chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it.
-
- return 0;
+
+ return true;
}
/*==========================================
* charunblock command (usage: charunblock <player_name>)
*------------------------------------------*/
-ACMD_FUNC(char_unblock)
+ACMD(char_unblock)
{
nullpo_retr(-1, sd);
-
+
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1024)); // Please enter a player name (usage: @charunblock <char name>).
- return -1;
+ return false;
}
-
+
// send answer to login server via char-server
chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it.
-
- return 0;
+
+ return true;
}
/*==========================================
* charunban command (usage: charunban <player_name>)
*------------------------------------------*/
-ACMD_FUNC(char_unban)
+ACMD(char_unban)
{
nullpo_retr(-1, sd);
-
+
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1025)); // Please enter a player name (usage: @charunban <char name>).
- return -1;
+ return false;
}
-
+
// send answer to login server via char-server
chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(night)
+ACMD(night)
{
nullpo_retr(-1, sd);
-
+
if (night_flag != 1) {
map_night_timer(night_timer_tid, 0, 0, 1);
} else {
clif->message(fd, msg_txt(89)); // Night mode is already enabled.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(day)
+ACMD(day)
{
nullpo_retr(-1, sd);
-
+
if (night_flag != 0) {
map_day_timer(day_timer_tid, 0, 0, 1);
} else {
clif->message(fd, msg_txt(90)); // Day mode is already enabled.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(doom)
+ACMD(doom)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
-
+
nullpo_retr(-1, sd);
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
@@ -2991,22 +2950,22 @@ ACMD_FUNC(doom)
}
}
mapit_free(iter);
-
+
clif->message(fd, msg_txt(62)); // Judgement was made.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(doommap)
+ACMD(doommap)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
-
+
nullpo_retr(-1, sd);
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
@@ -3018,19 +2977,19 @@ ACMD_FUNC(doommap)
}
}
mapit_free(iter);
-
+
clif->message(fd, msg_txt(62)); // Judgement was made.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
static void atcommand_raise_sub(struct map_session_data* sd) {
-
+
status_revive(&sd->bl, 100, 100);
-
+
clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
clif->message(sd->fd, msg_txt(63)); // Mercy has been shown.
}
@@ -3038,86 +2997,86 @@ static void atcommand_raise_sub(struct map_session_data* sd) {
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(raise)
+ACMD(raise)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
-
+
nullpo_retr(-1, sd);
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
if( pc_isdead(pl_sd) )
atcommand_raise_sub(pl_sd);
mapit_free(iter);
-
+
clif->message(fd, msg_txt(64)); // Mercy has been granted.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(raisemap)
+ACMD(raisemap)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
-
+
nullpo_retr(-1, sd);
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
atcommand_raise_sub(pl_sd);
mapit_free(iter);
-
+
clif->message(fd, msg_txt(64)); // Mercy has been granted.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(kick)
+ACMD(kick)
{
struct map_session_data *pl_sd;
nullpo_retr(-1, sd);
-
+
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1026)); // Please enter a player name (usage: @kick <char name/ID>).
- return -1;
+ return false;
}
-
+
if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
{
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
{
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
+ return false;
}
-
+
clif->GM_kick(sd, pl_sd);
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(kickall)
+ACMD(kickall)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
nullpo_retr(-1, sd);
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
@@ -3127,192 +3086,192 @@ ACMD_FUNC(kickall)
}
}
mapit_free(iter);
-
+
clif->message(fd, msg_txt(195)); // All players have been kicked!
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(allskill)
+ACMD(allskill)
{
nullpo_retr(-1, sd);
pc_allskillup(sd); // all skills
sd->status.skill_point = 0; // 0 skill points
clif->updatestatus(sd, SP_SKILLPOINT); // update
clif->message(fd, msg_txt(76)); // All skills have been added to your skill tree.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(questskill)
+ACMD(questskill)
{
uint16 skill_id;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || (skill_id = atoi(message)) <= 0)
{// also send a list of skills applicable to this command
const char* text;
-
+
// attempt to find the text corresponding to this command
- text = atcommand_help_string( command );
-
+ text = atcommand_help_string( info );
+
// send the error message as always
clif->message(fd, msg_txt(1027)); // Please enter a quest skill number.
-
+
if( text )
{// send the skill ID list associated with this command
clif->message( fd, text );
}
-
- return -1;
+
+ return false;
}
if (skill_id >= MAX_SKILL_DB) {
clif->message(fd, msg_txt(198)); // This skill number doesn't exist.
- return -1;
+ return false;
}
if (!(skill->get_inf2(skill_id) & INF2_QUEST_SKILL)) {
clif->message(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
- return -1;
+ return false;
}
if (pc_checkskill(sd, skill_id) > 0) {
clif->message(fd, msg_txt(196)); // You already have this quest skill.
- return -1;
+ return false;
}
-
+
pc_skill(sd, skill_id, 1, 0);
clif->message(fd, msg_txt(70)); // You have learned the skill.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(lostskill)
+ACMD(lostskill)
{
uint16 skill_id;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || (skill_id = atoi(message)) <= 0)
{// also send a list of skills applicable to this command
const char* text;
-
+
// attempt to find the text corresponding to this command
- text = atcommand_help_string( command );
-
+ text = atcommand_help_string( info );
+
// send the error message as always
clif->message(fd, msg_txt(1027)); // Please enter a quest skill number.
-
+
if( text )
{// send the skill ID list associated with this command
clif->message( fd, text );
}
-
- return -1;
+
+ return false;
}
if (skill_id >= MAX_SKILL) {
clif->message(fd, msg_txt(198)); // This skill number doesn't exist.
- return -1;
+ return false;
}
if (!(skill->get_inf2(skill_id) & INF2_QUEST_SKILL)) {
clif->message(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
- return -1;
+ return false;
}
if (pc_checkskill(sd, skill_id) == 0) {
clif->message(fd, msg_txt(201)); // You don't have this quest skill.
- return -1;
+ return false;
}
-
+
sd->status.skill[skill_id].lv = 0;
sd->status.skill[skill_id].flag = 0;
clif->deleteskill(sd,skill_id);
clif->message(fd, msg_txt(71)); // You have forgotten the skill.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(spiritball)
+ACMD(spiritball)
{
int max_spiritballs;
int number;
nullpo_retr(-1, sd);
-
+
max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
-
+
if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
{
char msg[CHAT_SIZE_MAX];
safesnprintf(msg, sizeof(msg), msg_txt(1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
clif->message(fd, msg);
- return -1;
+ return false;
}
-
+
if( sd->spiritball > 0 )
pc_delspiritball(sd, sd->spiritball, 1);
sd->spiritball = number;
clif->spiritball(&sd->bl);
// no message, player can look the difference
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(party)
+ACMD(party)
{
char party[NAME_LENGTH];
nullpo_retr(-1, sd);
-
+
memset(party, '\0', sizeof(party));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
clif->message(fd, msg_txt(1029)); // Please enter a party name (usage: @party <party_name>).
- return -1;
+ return false;
}
-
+
party_create(sd, party, 0, 0);
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(guild)
+ACMD(guild)
{
char guild[NAME_LENGTH];
int prev;
nullpo_retr(-1, sd);
-
+
memset(guild, '\0', sizeof(guild));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
clif->message(fd, msg_txt(1030)); // Please enter a guild name (usage: @guild <guild_name>).
- return -1;
+ return false;
}
-
+
prev = battle_config.guild_emperium_check;
battle_config.guild_emperium_check = 0;
guild_create(sd, guild);
battle_config.guild_emperium_check = prev;
-
- return 0;
+
+ return true;
}
-ACMD_FUNC(breakguild)
+ACMD(breakguild)
{
nullpo_retr(-1, sd);
-
+
if (sd->status.guild_id) { // Check if the player has a guild
struct guild *g;
g = sd->guild; // Search the guild
@@ -3321,126 +3280,126 @@ ACMD_FUNC(breakguild)
int ret = 0;
ret = guild_break(sd, g->name); // Break guild
if (ret) { // Check if anything went wrong
- return 0; // Guild was broken
+ return true; // Guild was broken
} else {
- return -1; // Something went wrong
+ return false; // Something went wrong
}
} else { // Not guild master
clif->message(fd, msg_txt(1181)); // You need to be a Guild Master to use this command.
- return -1;
+ return false;
}
} else { // Guild was not found. HOW?
clif->message(fd, msg_txt(252)); // You are not in a guild.
- return -1;
+ return false;
}
} else { // Player does not have a guild
clif->message(fd, msg_txt(252)); // You are not in a guild.
- return -1;
+ return false;
}
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(agitstart)
+ACMD(agitstart)
{
nullpo_retr(-1, sd);
if (agit_flag == 1) {
clif->message(fd, msg_txt(73)); // War of Emperium is currently in progress.
- return -1;
+ return false;
}
-
+
agit_flag = 1;
guild_agit_start();
clif->message(fd, msg_txt(72)); // War of Emperium has been initiated.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(agitstart2)
+ACMD(agitstart2)
{
nullpo_retr(-1, sd);
if (agit2_flag == 1) {
clif->message(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
- return -1;
+ return false;
}
-
+
agit2_flag = 1;
guild_agit2_start();
clif->message(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(agitend)
+ACMD(agitend)
{
nullpo_retr(-1, sd);
if (agit_flag == 0) {
clif->message(fd, msg_txt(75)); // War of Emperium is currently not in progress.
- return -1;
+ return false;
}
-
+
agit_flag = 0;
guild_agit_end();
clif->message(fd, msg_txt(74)); // War of Emperium has been ended.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(agitend2)
+ACMD(agitend2)
{
nullpo_retr(-1, sd);
if (agit2_flag == 0) {
clif->message(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
- return -1;
+ return false;
}
-
+
agit2_flag = 0;
guild_agit2_end();
clif->message(fd, msg_txt(405)); // "War of Emperium SE has been ended."
-
- return 0;
+
+ return true;
}
/*==========================================
* @mapexit - shuts down the map server
*------------------------------------------*/
-ACMD_FUNC(mapexit)
+ACMD(mapexit)
{
nullpo_retr(-1, sd);
-
+
do_shutdown();
- return 0;
+ return true;
}
/*==========================================
* idsearch <part_of_name>: revrited by [Yor]
*------------------------------------------*/
-ACMD_FUNC(idsearch)
+ACMD(idsearch)
{
char item_name[100];
unsigned int i, match;
struct item_data *item_array[MAX_SEARCH];
nullpo_retr(-1, sd);
-
+
memset(item_name, '\0', sizeof(item_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
clif->message(fd, msg_txt(1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
- return -1;
+ return false;
}
-
+
sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
clif->message(fd, atcmd_output);
match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
@@ -3455,27 +3414,27 @@ ACMD_FUNC(idsearch)
}
sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
clif->message(fd, atcmd_output);
-
- return 0;
+
+ return true;
}
/*==========================================
* Recall All Characters Online To Your Location
*------------------------------------------*/
-ACMD_FUNC(recallall)
+ACMD(recallall)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
int count;
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
- return -1;
+ return false;
}
-
+
count = 0;
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
@@ -3496,20 +3455,20 @@ ACMD_FUNC(recallall)
}
}
mapit_free(iter);
-
+
clif->message(fd, msg_txt(92)); // All characters recalled!
if (count) {
sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
clif->message(fd, atcmd_output);
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Recall online characters of a guild to your location
*------------------------------------------*/
-ACMD_FUNC(guildrecall)
+ACMD(guildrecall)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
@@ -3517,29 +3476,29 @@ ACMD_FUNC(guildrecall)
char guild_name[NAME_LENGTH];
struct guild *g;
nullpo_retr(-1, sd);
-
+
memset(guild_name, '\0', sizeof(guild_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
clif->message(fd, msg_txt(1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
- return -1;
+ return false;
}
-
+
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
- return -1;
+ return false;
}
-
+
if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
(g = guild_search(atoi(message))) == NULL)
{
clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
- return -1;
+ return false;
}
-
+
count = 0;
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
@@ -3554,21 +3513,21 @@ ACMD_FUNC(guildrecall)
}
}
mapit_free(iter);
-
+
sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
clif->message(fd, atcmd_output);
if (count) {
sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
clif->message(fd, atcmd_output);
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Recall online characters of a party to your location
*------------------------------------------*/
-ACMD_FUNC(partyrecall)
+ACMD(partyrecall)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
@@ -3576,29 +3535,29 @@ ACMD_FUNC(partyrecall)
struct party_data *p;
int count;
nullpo_retr(-1, sd);
-
+
memset(party_name, '\0', sizeof(party_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
clif->message(fd, msg_txt(1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
- return -1;
+ return false;
}
-
+
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
- return -1;
+ return false;
}
-
+
if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
(p = party_search(atoi(message))) == NULL)
{
clif->message(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
- return -1;
+ return false;
}
-
+
count = 0;
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
@@ -3613,33 +3572,33 @@ ACMD_FUNC(partyrecall)
}
}
mapit_free(iter);
-
+
sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
clif->message(fd, atcmd_output);
if (count) {
sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
clif->message(fd, atcmd_output);
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(reloaditemdb)
+ACMD(reloaditemdb)
{
nullpo_retr(-1, sd);
itemdb_reload();
clif->message(fd, msg_txt(97)); // Item database has been reloaded.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(reloadmobdb)
+ACMD(reloadmobdb)
{
nullpo_retr(-1, sd);
mob_reload();
@@ -3649,14 +3608,14 @@ ACMD_FUNC(reloadmobdb)
read_mercenary_skilldb();
reload_elementaldb();
clif->message(fd, msg_txt(98)); // Monster database has been reloaded.
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(reloadskilldb)
+ACMD(reloadskilldb)
{
nullpo_retr(-1, sd);
skill->reload();
@@ -3664,130 +3623,130 @@ ACMD_FUNC(reloadskilldb)
reload_elemental_skilldb();
read_mercenary_skilldb();
clif->message(fd, msg_txt(99)); // Skill database has been reloaded.
-
- return 0;
+
+ return true;
}
/*==========================================
* @reloadatcommand - reloads conf/atcommand.conf conf/groups.conf
*------------------------------------------*/
void atcommand_doload();
-ACMD_FUNC(reloadatcommand) {
+ACMD(reloadatcommand) {
config_t run_test;
-
+
if (conf_read_file(&run_test, "conf/groups.conf")) {
clif->message(fd, msg_txt(1036)); // Error reading groups.conf, reload failed.
- return -1;
+ return false;
}
-
+
config_destroy(&run_test);
-
+
if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
clif->message(fd, msg_txt(1037)); // Error reading atcommand.conf, reload failed.
- return -1;
+ return false;
}
-
+
config_destroy(&run_test);
-
+
atcommand_doload();
pc_groups_reload();
clif->message(fd, msg_txt(254));
- return 0;
+ return true;
}
/*==========================================
* @reloadbattleconf - reloads /conf/battle.conf
*------------------------------------------*/
-ACMD_FUNC(reloadbattleconf)
+ACMD(reloadbattleconf)
{
struct Battle_Config prev_config;
memcpy(&prev_config, &battle_config, sizeof(prev_config));
-
+
battle->config_read(BATTLE_CONF_FILENAME);
-
+
if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
- || prev_config.item_rate_common != battle_config.item_rate_common
- || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
- || prev_config.item_rate_card != battle_config.item_rate_card
- || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
- || prev_config.item_rate_equip != battle_config.item_rate_equip
- || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
- || prev_config.item_rate_heal != battle_config.item_rate_heal
- || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
- || prev_config.item_rate_use != battle_config.item_rate_use
- || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
- || prev_config.item_rate_treasure != battle_config.item_rate_treasure
- || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
- || prev_config.logarithmic_drops != battle_config.logarithmic_drops
- || prev_config.item_drop_common_min != battle_config.item_drop_common_min
- || prev_config.item_drop_common_max != battle_config.item_drop_common_max
- || prev_config.item_drop_card_min != battle_config.item_drop_card_min
- || prev_config.item_drop_card_max != battle_config.item_drop_card_max
- || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
- || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
- || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
- || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
- || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
- || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
- || prev_config.item_drop_use_min != battle_config.item_drop_use_min
- || prev_config.item_drop_use_max != battle_config.item_drop_use_max
- || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
- || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
- || prev_config.base_exp_rate != battle_config.base_exp_rate
- || prev_config.job_exp_rate != battle_config.job_exp_rate
- )
+ || prev_config.item_rate_common != battle_config.item_rate_common
+ || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
+ || prev_config.item_rate_card != battle_config.item_rate_card
+ || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
+ || prev_config.item_rate_equip != battle_config.item_rate_equip
+ || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
+ || prev_config.item_rate_heal != battle_config.item_rate_heal
+ || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
+ || prev_config.item_rate_use != battle_config.item_rate_use
+ || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
+ || prev_config.item_rate_treasure != battle_config.item_rate_treasure
+ || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
+ || prev_config.logarithmic_drops != battle_config.logarithmic_drops
+ || prev_config.item_drop_common_min != battle_config.item_drop_common_min
+ || prev_config.item_drop_common_max != battle_config.item_drop_common_max
+ || prev_config.item_drop_card_min != battle_config.item_drop_card_min
+ || prev_config.item_drop_card_max != battle_config.item_drop_card_max
+ || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
+ || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
+ || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
+ || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
+ || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
+ || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
+ || prev_config.item_drop_use_min != battle_config.item_drop_use_min
+ || prev_config.item_drop_use_max != battle_config.item_drop_use_max
+ || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
+ || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
+ || prev_config.base_exp_rate != battle_config.base_exp_rate
+ || prev_config.job_exp_rate != battle_config.job_exp_rate
+ )
{ // Exp or Drop rates changed.
mob_reload(); //Needed as well so rate changes take effect.
chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
}
clif->message(fd, msg_txt(255));
- return 0;
+ return true;
}
/*==========================================
* @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
*------------------------------------------*/
-ACMD_FUNC(reloadstatusdb)
+ACMD(reloadstatusdb)
{
status_readdb();
clif->message(fd, msg_txt(256));
- return 0;
+ return true;
}
/*==========================================
* @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
*------------------------------------------*/
-ACMD_FUNC(reloadpcdb)
+ACMD(reloadpcdb)
{
pc_readdb();
clif->message(fd, msg_txt(257));
- return 0;
+ return true;
}
/*==========================================
* @reloadmotd - reloads motd.txt
*------------------------------------------*/
-ACMD_FUNC(reloadmotd)
+ACMD(reloadmotd)
{
pc_read_motd();
clif->message(fd, msg_txt(268));
- return 0;
+ return true;
}
/*==========================================
* @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
*------------------------------------------*/
-ACMD_FUNC(reloadscript)
+ACMD(reloadscript)
{
nullpo_retr(-1, sd);
//atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
//atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
-
+
flush_fifos();
map_reloadnpc(true); // reload config files seeking for npcs
script_reload();
npc_reload();
-
+
clif->message(fd, msg_txt(100)); // Scripts have been reloaded.
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -3799,7 +3758,7 @@ ACMD_FUNC(reloadscript)
* 3 = Shows the chats in that map
TODO# add the missing mapflags e.g. adjust_skill_damage to display
*------------------------------------------*/
-ACMD_FUNC(mapinfo) {
+ACMD(mapinfo) {
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
struct npc_data *nd = NULL;
@@ -3808,35 +3767,35 @@ ACMD_FUNC(mapinfo) {
int i, m_id, chat_num = 0, list = 0, vend_num = 0;
unsigned short m_index;
char mapname[24];
-
+
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(mapname, '\0', sizeof(mapname));
memset(direction, '\0', sizeof(direction));
-
+
sscanf(message, "%d %23[^\n]", &list, mapname);
-
+
if (list < 0 || list > 3) {
clif->message(fd, msg_txt(1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
- return -1;
+ return false;
}
-
+
if (mapname[0] == '\0') {
safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
m_id = map_mapindex2mapid(sd->mapindex);
} else {
m_id = map_mapname2mapid(mapname);
}
-
+
if (m_id < 0) {
clif->message(fd, msg_txt(1)); // Map not found.
- return -1;
+ return false;
}
m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
-
+
clif->message(fd, msg_txt(1039)); // ------ Map Info ------
-
+
// count chats (for initial message)
chat_num = 0;
iter = mapit_getallusers();
@@ -3849,21 +3808,21 @@ ACMD_FUNC(mapinfo) {
}
}
mapit_free(iter);
-
+
sprintf(atcmd_output, msg_txt(1040), mapname, map[m_id].zone->name, map[m_id].users, map[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
clif->message(fd, atcmd_output);
clif->message(fd, msg_txt(1041)); // ------ Map Flags ------
if (map[m_id].flag.town)
clif->message(fd, msg_txt(1042)); // Town Map
-
+
if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
clif->message(fd, msg_txt(1043)); // Autotrade Enabled
else
clif->message(fd, msg_txt(1044)); // Autotrade Disabled
-
+
if (map[m_id].flag.battleground)
clif->message(fd, msg_txt(1045)); // Battlegrounds ON
-
+
strcpy(atcmd_output,msg_txt(1046)); // PvP Flags:
if (map[m_id].flag.pvp)
strcat(atcmd_output, msg_txt(1047)); // Pvp ON |
@@ -3876,7 +3835,7 @@ ACMD_FUNC(mapinfo) {
if (map[m_id].flag.pvp_nocalcrank)
strcat(atcmd_output, msg_txt(1051)); // NoCalcRank |
clif->message(fd, atcmd_output);
-
+
strcpy(atcmd_output,msg_txt(1052)); // GvG Flags:
if (map[m_id].flag.gvg)
strcat(atcmd_output, msg_txt(1053)); // GvG ON |
@@ -3887,7 +3846,7 @@ ACMD_FUNC(mapinfo) {
if (map[m_id].flag.gvg_noparty)
strcat(atcmd_output, msg_txt(1056)); // NoParty |
clif->message(fd, atcmd_output);
-
+
strcpy(atcmd_output,msg_txt(1057)); // Teleport Flags:
if (map[m_id].flag.noteleport)
strcat(atcmd_output, msg_txt(1058)); // NoTeleport |
@@ -3899,16 +3858,14 @@ ACMD_FUNC(mapinfo) {
strcat(atcmd_output, msg_txt(1061)); // NoWarpTo |
if (map[m_id].flag.noreturn)
strcat(atcmd_output, msg_txt(1062)); // NoReturn |
- if (map[m_id].flag.nogo)
- strcat(atcmd_output, msg_txt(1063)); // NoGo |
if (map[m_id].flag.nomemo)
strcat(atcmd_output, msg_txt(1064)); // NoMemo |
clif->message(fd, atcmd_output);
-
+
sprintf(atcmd_output, msg_txt(1065), // No Exp Penalty: %s | No Zeny Penalty: %s
- (map[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), (map[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off
+ (map[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), (map[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off
clif->message(fd, atcmd_output);
-
+
if (map[m_id].flag.nosave) {
if (!map[m_id].save.map)
clif->message(fd, msg_txt(1068)); // No Save (Return to last Save Point)
@@ -3918,11 +3875,11 @@ ACMD_FUNC(mapinfo) {
}
else {
sprintf(atcmd_output, msg_txt(1070), // No Save, Save Point: %s,%d,%d
- mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
+ mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
clif->message(fd, atcmd_output);
}
}
-
+
strcpy(atcmd_output,msg_txt(1071)); // Weather Flags:
if (map[m_id].flag.snow)
strcat(atcmd_output, msg_txt(1072)); // Snow |
@@ -3941,7 +3898,7 @@ ACMD_FUNC(mapinfo) {
if (map[m_id].flag.nightenabled)
strcat(atcmd_output, msg_txt(1080)); // Displays Night |
clif->message(fd, atcmd_output);
-
+
strcpy(atcmd_output,msg_txt(1081)); // Other Flags:
if (map[m_id].flag.nobranch)
strcat(atcmd_output, msg_txt(1082)); // NoBranch |
@@ -3960,7 +3917,7 @@ ACMD_FUNC(mapinfo) {
if (map[m_id].flag.reset)
strcat(atcmd_output, msg_txt(1089)); // Reset |
clif->message(fd, atcmd_output);
-
+
strcpy(atcmd_output,msg_txt(1090)); // Other Flags:
if (map[m_id].nocommand)
strcat(atcmd_output, msg_txt(1091)); // NoCommand |
@@ -3977,90 +3934,90 @@ ACMD_FUNC(mapinfo) {
if (map[m_id].flag.guildlock)
strcat(atcmd_output, msg_txt(1097)); // GuildLock |
clif->message(fd, atcmd_output);
-
+
switch (list) {
- case 0:
- // Do nothing. It's list 0, no additional display.
- break;
- case 1:
- clif->message(fd, msg_txt(1098)); // ----- Players in Map -----
- iter = mapit_getallusers();
- for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
- {
- if (pl_sd->mapindex == m_index) {
- sprintf(atcmd_output, msg_txt(1099), // Player '%s' (session #%d) | Location: %d,%d
- pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
- clif->message(fd, atcmd_output);
- }
- }
- mapit_free(iter);
- break;
- case 2:
- clif->message(fd, msg_txt(1100)); // ----- NPCs in Map -----
- for (i = 0; i < map[m_id].npc_num;)
- {
- nd = map[m_id].npc[i];
- switch(nd->ud.dir) {
- case 0: strcpy(direction, msg_txt(1101)); break; // North
- case 1: strcpy(direction, msg_txt(1102)); break; // North West
- case 2: strcpy(direction, msg_txt(1103)); break; // West
- case 3: strcpy(direction, msg_txt(1104)); break; // South West
- case 4: strcpy(direction, msg_txt(1105)); break; // South
- case 5: strcpy(direction, msg_txt(1106)); break; // South East
- case 6: strcpy(direction, msg_txt(1107)); break; // East
- case 7: strcpy(direction, msg_txt(1108)); break; // North East
- case 9: strcpy(direction, msg_txt(1109)); break; // North
- default: strcpy(direction, msg_txt(1110)); break; // Unknown
+ case 0:
+ // Do nothing. It's list 0, no additional display.
+ break;
+ case 1:
+ clif->message(fd, msg_txt(1098)); // ----- Players in Map -----
+ iter = mapit_getallusers();
+ for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
+ {
+ if (pl_sd->mapindex == m_index) {
+ sprintf(atcmd_output, msg_txt(1099), // Player '%s' (session #%d) | Location: %d,%d
+ pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
+ clif->message(fd, atcmd_output);
+ }
}
- if(strcmp(nd->name,nd->exname) == 0)
- sprintf(atcmd_output, msg_txt(1111), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
- ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
- else
- sprintf(atcmd_output, msg_txt(1112), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
- ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
- clif->message(fd, atcmd_output);
- }
- break;
- case 3:
- clif->message(fd, msg_txt(1113)); // ----- Chats in Map -----
- iter = mapit_getallusers();
- for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
- {
- if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
- pl_sd->mapindex == m_index &&
- cd->usersd[0] == pl_sd)
+ mapit_free(iter);
+ break;
+ case 2:
+ clif->message(fd, msg_txt(1100)); // ----- NPCs in Map -----
+ for (i = 0; i < map[m_id].npc_num;)
{
- sprintf(atcmd_output, msg_txt(1114), // Chat: %s | Player: %s | Location: %d %d
- cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
- clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_txt(1115), // Users: %d/%d | Password: %s | Public: %s
- cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(1116) : msg_txt(1117)); // Yes / No
+ nd = map[m_id].npc[i];
+ switch(nd->ud.dir) {
+ case 0: strcpy(direction, msg_txt(1101)); break; // North
+ case 1: strcpy(direction, msg_txt(1102)); break; // North West
+ case 2: strcpy(direction, msg_txt(1103)); break; // West
+ case 3: strcpy(direction, msg_txt(1104)); break; // South West
+ case 4: strcpy(direction, msg_txt(1105)); break; // South
+ case 5: strcpy(direction, msg_txt(1106)); break; // South East
+ case 6: strcpy(direction, msg_txt(1107)); break; // East
+ case 7: strcpy(direction, msg_txt(1108)); break; // North East
+ case 9: strcpy(direction, msg_txt(1109)); break; // North
+ default: strcpy(direction, msg_txt(1110)); break; // Unknown
+ }
+ if(strcmp(nd->name,nd->exname) == 0)
+ sprintf(atcmd_output, msg_txt(1111), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
+ ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
+ else
+ sprintf(atcmd_output, msg_txt(1112), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
+ ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
clif->message(fd, atcmd_output);
}
- }
- mapit_free(iter);
- break;
- default: // normally impossible to arrive here
- clif->message(fd, msg_txt(1118)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
- return -1;
- break;
+ break;
+ case 3:
+ clif->message(fd, msg_txt(1113)); // ----- Chats in Map -----
+ iter = mapit_getallusers();
+ for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
+ {
+ if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
+ pl_sd->mapindex == m_index &&
+ cd->usersd[0] == pl_sd)
+ {
+ sprintf(atcmd_output, msg_txt(1114), // Chat: %s | Player: %s | Location: %d %d
+ cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
+ clif->message(fd, atcmd_output);
+ sprintf(atcmd_output, msg_txt(1115), // Users: %d/%d | Password: %s | Public: %s
+ cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(1116) : msg_txt(1117)); // Yes / No
+ clif->message(fd, atcmd_output);
+ }
+ }
+ mapit_free(iter);
+ break;
+ default: // normally impossible to arrive here
+ clif->message(fd, msg_txt(1118)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
+ return false;
+ break;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(mount_peco)
+ACMD(mount_peco)
{
nullpo_retr(-1, sd);
-
+
if (sd->disguise) {
clif->message(fd, msg_txt(212)); // Cannot mount while in disguise.
- return -1;
+ return false;
}
-
+
if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
if( !(sd->sc.option&OPTION_DRAGON1) ) {
clif->message(sd->fd,msg_txt(1119)); // You have mounted your Dragon.
@@ -4069,7 +4026,7 @@ ACMD_FUNC(mount_peco)
clif->message(sd->fd,msg_txt(1120)); // You have released your Dragon.
pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
}
- return 0;
+ return true;
}
if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 ) {
if( !pc_isridingwug(sd) ) {
@@ -4079,7 +4036,7 @@ ACMD_FUNC(mount_peco)
clif->message(sd->fd,msg_txt(1122)); // You have released your Warg.
pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
}
- return 0;
+ return true;
}
if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
if( !pc_ismadogear(sd) ) {
@@ -4089,47 +4046,47 @@ ACMD_FUNC(mount_peco)
clif->message(sd->fd,msg_txt(1124)); // You have released your Mado Gear.
pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
}
- return 0;
+ return true;
}
if (!pc_isriding(sd)) { // if actually no peco
-
+
if (!pc_checkskill(sd, KN_RIDING)) {
clif->message(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
- return -1;
+ return false;
}
-
+
pc_setoption(sd, sd->sc.option | OPTION_RIDING);
clif->message(fd, msg_txt(102)); // You have mounted a Peco Peco.
} else {//Dismount
pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
clif->message(fd, msg_txt(214)); // You have released your Peco Peco.
}
-
- return 0;
+
+ return true;
}
/*==========================================
*Spy Commands by Syrus22
*------------------------------------------*/
-ACMD_FUNC(guildspy)
+ACMD(guildspy)
{
char guild_name[NAME_LENGTH];
struct guild *g;
nullpo_retr(-1, sd);
-
+
memset(guild_name, '\0', sizeof(guild_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!enable_spy)
{
clif->message(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
- return -1;
+ return false;
}
if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
clif->message(fd, msg_txt(1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
- return -1;
+ return false;
}
-
+
if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
(g = guild_search(atoi(message))) != NULL) {
if (sd->guildspy == g->guild_id) {
@@ -4143,35 +4100,35 @@ ACMD_FUNC(guildspy)
}
} else {
clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(partyspy)
+ACMD(partyspy)
{
char party_name[NAME_LENGTH];
struct party_data *p;
nullpo_retr(-1, sd);
-
+
memset(party_name, '\0', sizeof(party_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!enable_spy)
{
clif->message(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
- return -1;
+ return false;
}
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
clif->message(fd, msg_txt(1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
- return -1;
+ return false;
}
-
+
if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
(p = party_search(atoi(message))) != NULL) {
if (sd->partyspy == p->party.party_id) {
@@ -4185,20 +4142,20 @@ ACMD_FUNC(partyspy)
}
} else {
clif->message(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* @repairall [Valaris]
*------------------------------------------*/
-ACMD_FUNC(repairall)
+ACMD(repairall)
{
int count, i;
nullpo_retr(-1, sd);
-
+
count = 0;
for (i = 0; i < MAX_INVENTORY; i++) {
if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
@@ -4207,180 +4164,180 @@ ACMD_FUNC(repairall)
count++;
}
}
-
+
if (count > 0) {
clif->misceffect(&sd->bl, 3);
clif->equiplist(sd);
clif->message(fd, msg_txt(107)); // All items have been repaired.
} else {
clif->message(fd, msg_txt(108)); // No item need to be repaired.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* @nuke [Valaris]
*------------------------------------------*/
-ACMD_FUNC(nuke)
+ACMD(nuke)
{
struct map_session_data *pl_sd;
nullpo_retr(-1, sd);
-
+
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1128)); // Please enter a player name (usage: @nuke <char name>).
- return -1;
+ return false;
}
-
+
if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
clif->message(fd, msg_txt(109)); // Player has been nuked!
} else {
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
+ return false;
}
} else {
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* @tonpc
*------------------------------------------*/
-ACMD_FUNC(tonpc)
+ACMD(tonpc)
{
char npcname[NAME_LENGTH+1];
struct npc_data *nd;
-
+
nullpo_retr(-1, sd);
-
+
memset(npcname, 0, sizeof(npcname));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
clif->message(fd, msg_txt(1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
- return -1;
+ return false;
}
-
+
if ((nd = npc_name2id(npcname)) != NULL) {
if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
clif->message(fd, msg_txt(0)); // Warped.
else
- return -1;
+ return false;
} else {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(shownpc)
+ACMD(shownpc)
{
char NPCname[NAME_LENGTH+1];
nullpo_retr(-1, sd);
-
+
memset(NPCname, '\0', sizeof(NPCname));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
clif->message(fd, msg_txt(1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
- return -1;
+ return false;
}
-
+
if (npc_name2id(NPCname) != NULL) {
npc_enable(NPCname, 1);
clif->message(fd, msg_txt(110)); // Npc Enabled.
} else {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(hidenpc)
+ACMD(hidenpc)
{
char NPCname[NAME_LENGTH+1];
nullpo_retr(-1, sd);
-
+
memset(NPCname, '\0', sizeof(NPCname));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
clif->message(fd, msg_txt(1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
- return -1;
+ return false;
}
-
+
if (npc_name2id(NPCname) == NULL) {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
- return -1;
+ return false;
}
-
+
npc_enable(NPCname, 0);
clif->message(fd, msg_txt(112)); // Npc Disabled.
- return 0;
+ return true;
}
-ACMD_FUNC(loadnpc)
+ACMD(loadnpc)
{
FILE *fp;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1132)); // Please enter a script file name (usage: @loadnpc <file name>).
- return -1;
+ return false;
}
-
+
// check if script file exists
if ((fp = fopen(message, "r")) == NULL) {
clif->message(fd, msg_txt(261));
- return -1;
+ return false;
}
fclose(fp);
-
+
// add to list of script sources and run it
npc_addsrcfile(message);
npc_parsesrcfile(message,true);
npc_read_event_script();
-
+
clif->message(fd, msg_txt(262));
-
- return 0;
+
+ return true;
}
-ACMD_FUNC(unloadnpc)
+ACMD(unloadnpc)
{
struct npc_data *nd;
char NPCname[NAME_LENGTH+1];
nullpo_retr(-1, sd);
-
+
memset(NPCname, '\0', sizeof(NPCname));
-
+
if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
clif->message(fd, msg_txt(1133)); // Please enter a NPC name (usage: @npcoff <NPC_name>).
- return -1;
+ return false;
}
-
+
if ((nd = npc_name2id(NPCname)) == NULL) {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
- return -1;
+ return false;
}
-
+
npc_unload_duplicates(nd);
npc_unload(nd,true);
npc_read_event_script();
clif->message(fd, msg_txt(112)); // Npc Disabled.
- return 0;
+ return true;
}
/*==========================================
@@ -4391,17 +4348,17 @@ char* txt_time(unsigned int duration)
int days, hours, minutes, seconds;
char temp[CHAT_SIZE_MAX];
static char temp1[CHAT_SIZE_MAX];
-
+
memset(temp, '\0', sizeof(temp));
memset(temp1, '\0', sizeof(temp1));
-
+
days = duration / (60 * 60 * 24);
duration = duration - (60 * 60 * 24 * days);
hours = duration / (60 * 60);
duration = duration - (60 * 60 * hours);
minutes = duration / 60;
seconds = duration - (60 * minutes);
-
+
if (days == 1)
sprintf(temp, msg_txt(219), days); // %d day
else if (days > 1)
@@ -4418,7 +4375,7 @@ char* txt_time(unsigned int duration)
sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
else if (seconds > 1)
sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
-
+
return temp1;
}
@@ -4426,7 +4383,7 @@ char* txt_time(unsigned int duration)
* @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
* Calculation management of GM modification (@day/@night GM commands) is done
*------------------------------------------*/
-ACMD_FUNC(servertime)
+ACMD(servertime)
{
const struct TimerData * timer_data;
const struct TimerData * timer_data2;
@@ -4434,15 +4391,15 @@ ACMD_FUNC(servertime)
struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
char temp[CHAT_SIZE_MAX];
nullpo_retr(-1, sd);
-
+
memset(temp, '\0', sizeof(temp));
-
+
time(&time_server); // get time in seconds since 1/1/1970
datetime = localtime(&time_server); // convert seconds in structure
// like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
clif->message(fd, temp);
-
+
if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
if (night_flag == 0)
clif->message(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
@@ -4456,43 +4413,43 @@ ACMD_FUNC(servertime)
clif->message(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
} else
clif->message(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
- else if (battle_config.day_duration == 0)
- if (night_flag == 0) { // we start with day
- timer_data = get_timer(night_timer_tid);
- sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
- clif->message(fd, temp);
- clif->message(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
- } else
- clif->message(fd, msg_txt(232)); // Game time: The game is in permanent night.
- else {
- if (night_flag == 0) {
- timer_data = get_timer(night_timer_tid);
- timer_data2 = get_timer(day_timer_tid);
- sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
- clif->message(fd, temp);
- if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
- sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
- else
- sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
- clif->message(fd, temp);
- sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
- clif->message(fd, temp);
- } else {
- timer_data = get_timer(day_timer_tid);
- timer_data2 = get_timer(night_timer_tid);
- sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
- clif->message(fd, temp);
- if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
- sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
- else
- sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
- clif->message(fd, temp);
- sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
- clif->message(fd, temp);
- }
- }
-
- return 0;
+ else if (battle_config.day_duration == 0)
+ if (night_flag == 0) { // we start with day
+ timer_data = get_timer(night_timer_tid);
+ sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
+ clif->message(fd, temp);
+ clif->message(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
+ } else
+ clif->message(fd, msg_txt(232)); // Game time: The game is in permanent night.
+ else {
+ if (night_flag == 0) {
+ timer_data = get_timer(night_timer_tid);
+ timer_data2 = get_timer(day_timer_tid);
+ sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
+ clif->message(fd, temp);
+ if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
+ sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
+ else
+ sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
+ clif->message(fd, temp);
+ sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
+ clif->message(fd, temp);
+ } else {
+ timer_data = get_timer(day_timer_tid);
+ timer_data2 = get_timer(night_timer_tid);
+ sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
+ clif->message(fd, temp);
+ if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
+ sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
+ else
+ sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
+ clif->message(fd, temp);
+ sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
+ clif->message(fd, temp);
+ }
+ }
+
+ return true;
}
//Added by Coltaro
@@ -4504,7 +4461,7 @@ static void get_jail_time(int jailtime, int* year, int* month, int* day, int* ho
const int factor_month = 43200; //30*24*60 = 43200
const int factor_day = 1440; //24*60 = 1440
const int factor_hour = 60;
-
+
*year = jailtime/factor_year;
jailtime -= *year*factor_year;
*month = jailtime/factor_month;
@@ -4514,7 +4471,7 @@ static void get_jail_time(int jailtime, int* year, int* month, int* day, int* ho
*hour = jailtime/factor_hour;
jailtime -= *hour*factor_hour;
*minute = jailtime;
-
+
*year = *year > 0? *year : 0;
*month = *month > 0? *month : 0;
*day = *day > 0? *day : 0;
@@ -4527,97 +4484,97 @@ static void get_jail_time(int jailtime, int* year, int* month, int* day, int* ho
* @jail <char_name> by [Yor]
* Special warp! No check with nowarp and nowarpto flag
*------------------------------------------*/
-ACMD_FUNC(jail)
+ACMD(jail)
{
struct map_session_data *pl_sd;
int x, y;
unsigned short m_index;
nullpo_retr(-1, sd);
-
+
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1134)); // Please enter a player name (usage: @jail <char_name>).
- return -1;
+ return false;
}
-
+
if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
{ // you can jail only lower or same GM
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
+ return false;
}
-
+
if (pl_sd->sc.data[SC_JAILED])
{
clif->message(fd, msg_txt(118)); // Player warped in jails.
- return -1;
+ return false;
}
-
+
switch(rnd() % 2) { //Jail Locations
- case 0:
- m_index = mapindex_name2id(MAP_JAIL);
- x = 24;
- y = 75;
- break;
- default:
- m_index = mapindex_name2id(MAP_JAIL);
- x = 49;
- y = 75;
- break;
+ case 0:
+ m_index = mapindex_name2id(MAP_JAIL);
+ x = 24;
+ y = 75;
+ break;
+ default:
+ m_index = mapindex_name2id(MAP_JAIL);
+ x = 49;
+ y = 75;
+ break;
}
-
+
//Duration of INT_MAX to specify infinity.
sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
clif->message(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
clif->message(fd, msg_txt(118)); // Player warped in jails.
- return 0;
+ return true;
}
/*==========================================
* @unjail/@discharge <char_name> by [Yor]
* Special warp! No check with nowarp and nowarpto flag
*------------------------------------------*/
-ACMD_FUNC(unjail)
+ACMD(unjail)
{
struct map_session_data *pl_sd;
-
+
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
+
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
- return -1;
+ return false;
}
-
+
if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
-
+
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
+ return false;
}
-
+
if (!pl_sd->sc.data[SC_JAILED])
{
clif->message(fd, msg_txt(119)); // This player is not in jails.
- return -1;
+ return false;
}
-
+
//Reset jail time to 1 sec.
sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
clif->message(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
clif->message(fd, msg_txt(121)); // Player unjailed.
- return 0;
+ return true;
}
-ACMD_FUNC(jailfor)
+ACMD(jailfor)
{
struct map_session_data *pl_sd = NULL;
int year, month, day, hour, minute, value;
@@ -4625,14 +4582,14 @@ ACMD_FUNC(jailfor)
int jailtime = 0,x,y;
short m_index = 0;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
clif->message(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
- return -1;
+ return false;
}
-
+
atcmd_output[sizeof(atcmd_output)-1] = '\0';
-
+
modif_p = atcmd_output;
year = month = day = hour = minute = 0;
while (modif_p[0] != '\0') {
@@ -4667,32 +4624,32 @@ ACMD_FUNC(jailfor)
}
}
}
-
+
if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
clif->message(fd, msg_txt(1136)); // Invalid time for jail command.
- return -1;
+ return false;
}
-
+
if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
+ return false;
}
-
+
jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
-
+
if(jailtime==0) {
clif->message(fd, msg_txt(1136)); // Invalid time for jail command.
- return -1;
+ return false;
}
-
+
//Added by Coltaro
if(pl_sd->sc.data[SC_JAILED] &&
- pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
+ pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
{ //Update the player's jail time
jailtime += pl_sd->sc.data[SC_JAILED]->val1;
if (jailtime <= 0) {
@@ -4708,9 +4665,9 @@ ACMD_FUNC(jailfor)
}
} else if (jailtime < 0) {
clif->message(fd, msg_txt(1136));
- return -1;
+ return false;
}
-
+
//Jail locations, add more as you wish.
switch(rnd()%2)
{
@@ -4723,56 +4680,56 @@ ACMD_FUNC(jailfor)
x = 24; y = 75;
break;
}
-
+
sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
- return 0;
+ return true;
}
//By Coltaro
-ACMD_FUNC(jailtime)
+ACMD(jailtime)
{
int year, month, day, hour, minute;
-
+
nullpo_retr(-1, sd);
-
+
if (!sd->sc.data[SC_JAILED]) {
clif->message(fd, msg_txt(1139)); // You are not in jail.
- return -1;
+ return false;
}
-
+
if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
clif->message(fd, msg_txt(1140)); // You have been jailed indefinitely.
- return 0;
+ return true;
}
-
+
if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
clif->message(fd, msg_txt(1141)); // You have been jailed for an unknown amount of time.
- return -1;
+ return false;
}
-
+
//Get remaining jail time
get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
sprintf(atcmd_output,msg_txt(402),msg_txt(1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
-
+
clif->message(fd, atcmd_output);
-
- return 0;
+
+ return true;
}
/*==========================================
* @disguise <mob_id> by [Valaris] (simplified by [Yor])
*------------------------------------------*/
-ACMD_FUNC(disguise)
+ACMD(disguise)
{
int id = 0;
nullpo_retr(-1, sd);
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
- return -1;
+ return false;
}
-
+
if ((id = atoi(message)) > 0)
{ //Acquired an ID
if (!mobdb_checkid(id) && !npcdb_checkid(id))
@@ -4785,75 +4742,75 @@ ACMD_FUNC(disguise)
id = nd->class_;
}
}
-
+
if (id == 0)
{
clif->message(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
- return -1;
+ return false;
}
-
+
if(pc_isriding(sd))
{
clif->message(fd, msg_txt(1144)); // Character cannot be disguised while mounted.
- return -1;
+ return false;
}
-
+
pc_disguise(sd, id);
clif->message(fd, msg_txt(122)); // Disguise applied.
-
- return 0;
+
+ return true;
}
/*==========================================
* DisguiseAll
*------------------------------------------*/
-ACMD_FUNC(disguiseall)
+ACMD(disguiseall)
{
int mob_id=0;
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
nullpo_retr(-1, sd);
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
- return -1;
+ return false;
}
-
+
if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
mob_id = atoi(message);
-
+
if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
clif->message(fd, msg_txt(123)); // Monster/NPC name/id not found.
- return -1;
+ return false;
}
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
pc_disguise(pl_sd, mob_id);
mapit_free(iter);
-
+
clif->message(fd, msg_txt(122)); // Disguise applied.
- return 0;
+ return true;
}
/*==========================================
* DisguiseGuild
*------------------------------------------*/
-ACMD_FUNC(disguiseguild)
+ACMD(disguiseguild)
{
int id = 0, i;
char monster[NAME_LENGTH], guild[NAME_LENGTH];
struct map_session_data *pl_sd;
struct guild *g;
-
+
memset(monster, '\0', sizeof(monster));
memset(guild, '\0', sizeof(guild));
-
+
if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
clif->message(fd, msg_txt(1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>).
- return -1;
+ return false;
}
-
+
if( (id = atoi(monster)) > 0 ) {
if( !mobdb_checkid(id) && !npcdb_checkid(id) )
id = 0;
@@ -4864,30 +4821,30 @@ ACMD_FUNC(disguiseguild)
id = nd->class_;
}
}
-
+
if( id == 0 ) {
clif->message(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
- return -1;
+ return false;
}
-
+
if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
- return -1;
+ return false;
}
-
+
for( i = 0; i < g->max_member; i++ )
if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
pc_disguise(pl_sd, id);
-
+
clif->message(fd, msg_txt(122)); // Disguise applied.
- return 0;
+ return true;
}
/*==========================================
* @undisguise by [Yor]
*------------------------------------------*/
-ACMD_FUNC(undisguise)
+ACMD(undisguise)
{
nullpo_retr(-1, sd);
if (sd->disguise) {
@@ -4895,341 +4852,341 @@ ACMD_FUNC(undisguise)
clif->message(fd, msg_txt(124)); // Undisguise applied.
} else {
clif->message(fd, msg_txt(125)); // You're not disguised.
- return -1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* UndisguiseAll
*------------------------------------------*/
-ACMD_FUNC(undisguiseall)
+ACMD(undisguiseall)
{
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
nullpo_retr(-1, sd);
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
if( pl_sd->disguise )
pc_disguise(pl_sd, 0);
mapit_free(iter);
-
+
clif->message(fd, msg_txt(124)); // Undisguise applied.
-
- return 0;
+
+ return true;
}
/*==========================================
* UndisguiseGuild
*------------------------------------------*/
-ACMD_FUNC(undisguiseguild)
+ACMD(undisguiseguild)
{
char guild_name[NAME_LENGTH];
struct map_session_data *pl_sd;
struct guild *g;
int i;
nullpo_retr(-1, sd);
-
+
memset(guild_name, '\0', sizeof(guild_name));
-
+
if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
clif->message(fd, msg_txt(1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
- return -1;
+ return false;
}
-
+
if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
- return -1;
+ return false;
}
-
+
for(i = 0; i < g->max_member; i++)
if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
pc_disguise(pl_sd, 0);
-
+
clif->message(fd, msg_txt(124)); // Undisguise applied.
-
- return 0;
+
+ return true;
}
/*==========================================
* @exp by [Skotlex]
*------------------------------------------*/
-ACMD_FUNC(exp)
+ACMD(exp)
{
char output[CHAT_SIZE_MAX];
double nextb, nextj;
nullpo_retr(-1, sd);
memset(output, '\0', sizeof(output));
-
+
nextb = pc_nextbaseexp(sd);
if (nextb)
nextb = sd->status.base_exp*100.0/nextb;
-
+
nextj = pc_nextjobexp(sd);
if (nextj)
nextj = sd->status.job_exp*100.0/nextj;
-
+
sprintf(output, msg_txt(1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
clif->message(fd, output);
- return 0;
+ return true;
}
/*==========================================
* @broadcast by [Valaris]
*------------------------------------------*/
-ACMD_FUNC(broadcast)
+ACMD(broadcast)
{
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1149)); // Please enter a message (usage: @broadcast <message>).
- return -1;
+ return false;
}
-
+
sprintf(atcmd_output, "%s: %s", sd->status.name, message);
intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
-
- return 0;
+
+ return true;
}
/*==========================================
* @localbroadcast by [Valaris]
*------------------------------------------*/
-ACMD_FUNC(localbroadcast)
+ACMD(localbroadcast)
{
nullpo_retr(-1, sd);
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1150)); // Please enter a message (usage: @localbroadcast <message>).
- return -1;
+ return false;
}
-
+
sprintf(atcmd_output, "%s: %s", sd->status.name, message);
-
+
clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
-
- return 0;
+
+ return true;
}
/*==========================================
* @email <actual@email> <new@email> by [Yor]
*------------------------------------------*/
-ACMD_FUNC(email)
+ACMD(email)
{
char actual_email[100];
char new_email[100];
nullpo_retr(-1, sd);
-
+
memset(actual_email, '\0', sizeof(actual_email));
memset(new_email, '\0', sizeof(new_email));
-
+
if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
clif->message(fd, msg_txt(1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
- return -1;
+ return false;
}
-
+
if (e_mail_check(actual_email) == 0) {
clif->message(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
- return -1;
+ return false;
} else if (e_mail_check(new_email) == 0) {
clif->message(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
- return -1;
+ return false;
} else if (strcmpi(new_email, "a@a.com") == 0) {
clif->message(fd, msg_txt(146)); // New email must be a real e-mail.
- return -1;
+ return false;
} else if (strcmpi(actual_email, new_email) == 0) {
clif->message(fd, msg_txt(147)); // New email must be different of the actual e-mail.
- return -1;
+ return false;
}
-
+
chrif_changeemail(sd->status.account_id, actual_email, new_email);
clif->message(fd, msg_txt(148)); // Information sended to login-server via char-server.
- return 0;
+ return true;
}
/*==========================================
*@effect
*------------------------------------------*/
-ACMD_FUNC(effect)
+ACMD(effect)
{
int type = 0, flag = 0;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || sscanf(message, "%d", &type) < 1) {
clif->message(fd, msg_txt(1152)); // Please enter an effect number (usage: @effect <effect number>).
- return -1;
+ return false;
}
-
+
clif->specialeffect(&sd->bl, type, (send_target)flag);
clif->message(fd, msg_txt(229)); // Your effect has changed.
- return 0;
+ return true;
}
/*==========================================
* @killer by MouseJstr
* enable killing players even when not in pvp
*------------------------------------------*/
-ACMD_FUNC(killer)
+ACMD(killer)
{
nullpo_retr(-1, sd);
sd->state.killer = !sd->state.killer;
-
+
if(sd->state.killer)
clif->message(fd, msg_txt(241));
else {
clif->message(fd, msg_txt(292));
pc_stop_attack(sd);
}
- return 0;
+ return true;
}
/*==========================================
* @killable by MouseJstr
* enable other people killing you
*------------------------------------------*/
-ACMD_FUNC(killable)
+ACMD(killable)
{
nullpo_retr(-1, sd);
sd->state.killable = !sd->state.killable;
-
+
if(sd->state.killable)
clif->message(fd, msg_txt(242));
else {
clif->message(fd, msg_txt(288));
map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
}
- return 0;
+ return true;
}
/*==========================================
* @skillon by MouseJstr
* turn skills on for the map
*------------------------------------------*/
-ACMD_FUNC(skillon)
+ACMD(skillon)
{
nullpo_retr(-1, sd);
map[sd->bl.m].flag.noskill = 0;
clif->message(fd, msg_txt(244));
- return 0;
+ return true;
}
/*==========================================
* @skilloff by MouseJstr
* Turn skills off on the map
*------------------------------------------*/
-ACMD_FUNC(skilloff)
+ACMD(skilloff)
{
nullpo_retr(-1, sd);
map[sd->bl.m].flag.noskill = 1;
clif->message(fd, msg_txt(243));
- return 0;
+ return true;
}
/*==========================================
* @npcmove by MouseJstr
* move a npc
*------------------------------------------*/
-ACMD_FUNC(npcmove)
+ACMD(npcmove)
{
int x = 0, y = 0, m;
struct npc_data *nd = 0;
nullpo_retr(-1, sd);
memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
-
+
if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
clif->message(fd, msg_txt(1153)); // Usage: @npcmove <X> <Y> <npc_name>
- return -1;
+ return false;
}
-
+
if ((nd = npc_name2id(atcmd_player_name)) == NULL)
{
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
- return -1;
+ return false;
}
-
+
if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
{
clif->message(fd, msg_txt(1154)); // NPC is not on this map.
- return -1; //Not on a map.
+ return false; //Not on a map.
}
-
+
x = cap_value(x, 0, map[m].xs-1);
y = cap_value(y, 0, map[m].ys-1);
map_foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
map_moveblock(&nd->bl, x, y, gettick());
map_foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
clif->message(fd, msg_txt(1155)); // NPC moved.
-
- return 0;
+
+ return true;
}
/*==========================================
* @addwarp by MouseJstr
* Create a new static warp point.
*------------------------------------------*/
-ACMD_FUNC(addwarp)
+ACMD(addwarp)
{
char mapname[32], warpname[NAME_LENGTH+1];
int x,y;
unsigned short m;
struct npc_data* nd;
-
+
nullpo_retr(-1, sd);
memset(warpname, '\0', sizeof(warpname));
-
+
if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
clif->message(fd, msg_txt(1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
- return -1;
+ return false;
}
-
+
m = mapindex_name2id(mapname);
if( m == 0 )
{
sprintf(atcmd_output, msg_txt(1157), mapname); // Unknown map '%s'.
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
-
+
nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
if( nd == NULL )
- return -1;
-
+ return false;
+
sprintf(atcmd_output, msg_txt(1158), nd->exname); // New warp NPC '%s' created.
clif->message(fd, atcmd_output);
- return 0;
+ return true;
}
/*==========================================
* @follow by [MouseJstr]
* Follow a player .. staying no more then 5 spaces away
*------------------------------------------*/
-ACMD_FUNC(follow)
+ACMD(follow)
{
struct map_session_data *pl_sd = NULL;
nullpo_retr(-1, sd);
-
+
if (!message || !*message) {
if (sd->followtarget == -1)
- return -1;
-
+ return false;
+
pc_stop_following (sd);
clif->message(fd, msg_txt(1159)); // Follow mode OFF.
- return 0;
+ return true;
}
-
+
if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
{
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
if (sd->followtarget == pl_sd->bl.id) {
pc_stop_following (sd);
clif->message(fd, msg_txt(1159)); // Follow mode OFF.
@@ -5237,8 +5194,8 @@ ACMD_FUNC(follow)
pc_follow(sd, pl_sd->bl.id);
clif->message(fd, msg_txt(1160)); // Follow mode ON.
}
-
- return 0;
+
+ return true;
}
@@ -5246,37 +5203,37 @@ ACMD_FUNC(follow)
* @dropall by [MouseJstr]
* Drop all your possession on the ground
*------------------------------------------*/
-ACMD_FUNC(dropall)
+ACMD(dropall)
{
int i;
nullpo_retr(-1, sd);
for (i = 0; i < MAX_INVENTORY; i++) {
- if (sd->status.inventory[i].amount) {
- if(sd->status.inventory[i].equip != 0)
- pc_unequipitem(sd, i, 3);
+ if (sd->status.inventory[i].amount) {
+ if(sd->status.inventory[i].equip != 0)
+ pc_unequipitem(sd, i, 3);
pc_dropitem(sd, i, sd->status.inventory[i].amount);
}
}
- return 0;
+ return true;
}
/*==========================================
* @storeall by [MouseJstr]
* Put everything into storage
*------------------------------------------*/
-ACMD_FUNC(storeall)
+ACMD(storeall)
{
int i;
nullpo_retr(-1, sd);
-
+
if (sd->state.storage_flag != 1)
{ //Open storage.
if( storage_storageopen(sd) == 1 ) {
clif->message(fd, msg_txt(1161)); // You currently cannot open your storage.
- return -1;
+ return false;
}
}
-
+
for (i = 0; i < MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount) {
if(sd->status.inventory[i].equip != 0)
@@ -5285,60 +5242,60 @@ ACMD_FUNC(storeall)
}
}
storage_storageclose(sd);
-
+
clif->message(fd, msg_txt(1162)); // All items stored.
- return 0;
+ return true;
}
-ACMD_FUNC(clearstorage)
+ACMD(clearstorage)
{
int i, j;
nullpo_retr(-1, sd);
-
+
if (sd->state.storage_flag == 1) {
clif->message(fd, msg_txt(250));
- return -1;
+ return false;
}
-
+
j = sd->status.storage.storage_amount;
for (i = 0; i < j; ++i) {
storage_delitem(sd, i, sd->status.storage.items[i].amount);
}
storage_storageclose(sd);
-
+
clif->message(fd, msg_txt(1394)); // Your storage was cleaned.
- return 0;
+ return true;
}
-ACMD_FUNC(cleargstorage)
+ACMD(cleargstorage)
{
int i, j;
struct guild *g;
struct guild_storage *gstorage;
nullpo_retr(-1, sd);
-
+
g = sd->guild;
-
+
if (g == NULL) {
clif->message(fd, msg_txt(43));
- return -1;
+ return false;
}
-
+
if (sd->state.storage_flag == 1) {
clif->message(fd, msg_txt(250));
- return -1;
+ return false;
}
-
+
if (sd->state.storage_flag == 2) {
clif->message(fd, msg_txt(251));
- return -1;
+ return false;
}
-
+
gstorage = guild2storage2(sd->status.guild_id);
if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
- return -1;
+ return false;
}
-
+
j = gstorage->storage_amount;
gstorage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
for (i = 0; i < j; ++i) {
@@ -5346,34 +5303,34 @@ ACMD_FUNC(cleargstorage)
}
storage_guild_storageclose(sd);
gstorage->lock = 0; // Cleaning done, release lock
-
+
clif->message(fd, msg_txt(1395)); // Your guild storage was cleaned.
- return 0;
+ return true;
}
-ACMD_FUNC(clearcart)
+ACMD(clearcart)
{
int i;
nullpo_retr(-1, sd);
-
+
if (pc_iscarton(sd) == 0) {
clif->message(fd, msg_txt(1396)); // You do not have a cart to be cleaned.
- return -1;
+ return false;
}
-
+
if (sd->state.vending == 1) { //Somehow...
- return -1;
+ return false;
}
-
+
for( i = 0; i < MAX_CART; i++ )
if(sd->status.cart[i].nameid > 0)
pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
-
+
clif->clearcart(fd);
clif->updatestatus(sd,SP_CARTINFO);
-
+
clif->message(fd, msg_txt(1397)); // Your cart was cleaned.
- return 0;
+ return true;
}
/*==========================================
@@ -5382,7 +5339,7 @@ ACMD_FUNC(clearcart)
*------------------------------------------*/
#define MAX_SKILLID_PARTIAL_RESULTS 5
#define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 /* "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33) */
-ACMD_FUNC(skillid) {
+ACMD(skillid) {
int skillen, idx, i, found = 0;
DBIterator* iter;
DBKey key;
@@ -5390,12 +5347,12 @@ ACMD_FUNC(skillid) {
char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
nullpo_retr(-1, sd);
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
- return -1;
+ return false;
}
-
+
skillen = strlen(message);
iter = db_iterator(skilldb_name2id);
@@ -5421,14 +5378,14 @@ ACMD_FUNC(skillid) {
clif->message(fd, partials[i]);
}
- return 0;
+ return true;
}
/*==========================================
* @useskill by [MouseJstr]
* A way of using skills without having to find them in the skills menu
*------------------------------------------*/
-ACMD_FUNC(useskill)
+ACMD(useskill)
{
struct map_session_data *pl_sd = NULL;
struct block_list *bl;
@@ -5436,36 +5393,36 @@ ACMD_FUNC(useskill)
uint16 skill_lv;
char target[100];
nullpo_retr(-1, sd);
-
+
if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
clif->message(fd, msg_txt(1165)); // Usage: @useskill <skill ID> <skill level> <target>
- return -1;
+ return false;
}
-
+
if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
else if ( (pl_sd = map_nick2sd(target)) == NULL ){
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
{
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
+ return false;
}
-
+
if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL
&& sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
bl = &sd->hd->bl;
else
bl = &sd->bl;
-
+
if (skill->get_inf(skill_id)&INF_GROUND_SKILL)
unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
else
unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -5473,32 +5430,32 @@ ACMD_FUNC(useskill)
* Debug command to locate new skill IDs. It sends the
* three possible skill-effect packets to the area.
*------------------------------------------*/
-ACMD_FUNC(displayskill)
+ACMD(displayskill)
{
struct status_data * status;
unsigned int tick;
uint16 skill_id;
uint16 skill_lv = 1;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1)
{
clif->message(fd, msg_txt(1166)); // Usage: @displayskill <skill ID> {<skill level>}
- return -1;
+ return false;
}
status = status_get_status_data(&sd->bl);
tick = gettick();
clif->skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
clif->skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
clif->skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
- return 0;
+ return true;
}
/*==========================================
* @skilltree by [MouseJstr]
* prints the skill tree for a player required to get to a skill
*------------------------------------------*/
-ACMD_FUNC(skilltree)
+ACMD(skilltree)
{
struct map_session_data *pl_sd = NULL;
uint16 skill_id;
@@ -5506,33 +5463,33 @@ ACMD_FUNC(skilltree)
char target[NAME_LENGTH];
struct skill_tree_entry *ent;
nullpo_retr(-1, sd);
-
+
if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) {
clif->message(fd, msg_txt(1167)); // Usage: @skilltree <skill ID> <target>
- return -1;
+ return false;
}
-
+
if ( (pl_sd = map_nick2sd(target)) == NULL )
{
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
c = pc_calc_skilltree_normalize_job(pl_sd);
c = pc_mapid2jobid(c, pl_sd->status.sex);
-
+
sprintf(atcmd_output, msg_txt(1168), job_name(c), pc_checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
clif->message(fd, atcmd_output);
-
+
ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
{
clif->message(fd, msg_txt(1169)); // The player cannot use that skill.
- return 0;
+ return true;
}
-
+
ent = &skill_tree[c][j];
-
+
meets = 1;
for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
{
@@ -5546,8 +5503,8 @@ ACMD_FUNC(skilltree)
if (meets == 1) {
clif->message(fd, msg_txt(1171)); // The player meets all the requirements for that skill.
}
-
- return 0;
+
+ return true;
}
// Hand a ring with partners name on it to this char
@@ -5556,14 +5513,14 @@ void getring (struct map_session_data* sd)
int flag, item_id;
struct item item_tmp;
item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
-
+
memset(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = item_id;
item_tmp.identify = 1;
item_tmp.card[0] = 255;
item_tmp.card[2] = sd->status.partner_id;
item_tmp.card[3] = sd->status.partner_id >> 16;
-
+
if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
clif->additem(sd,0,0,flag);
map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
@@ -5574,66 +5531,66 @@ void getring (struct map_session_data* sd)
* @marry by [MouseJstr], fixed by Lupus
* Marry two players
*------------------------------------------*/
-ACMD_FUNC(marry)
+ACMD(marry)
{
struct map_session_data *pl_sd = NULL;
char player_name[NAME_LENGTH] = "";
-
+
nullpo_retr(-1, sd);
-
+
if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
clif->message(fd, msg_txt(1172)); // Usage: @marry <char name>
- return -1;
+ return false;
}
-
+
if ((pl_sd = map_nick2sd(player_name)) == NULL) {
clif->message(fd, msg_txt(3));
- return -1;
+ return false;
}
-
+
if (pc_marriage(sd, pl_sd) == 0) {
clif->message(fd, msg_txt(1173)); // They are married... wish them well.
clif->wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
getring(sd); // Auto-give named rings (Aru)
getring(pl_sd);
- return 0;
+ return true;
}
-
+
clif->message(fd, msg_txt(1174)); // The two cannot wed because one is either a baby or already married.
- return -1;
+ return false;
}
/*==========================================
* @divorce by [MouseJstr], fixed by [Lupus]
* divorce two players
*------------------------------------------*/
-ACMD_FUNC(divorce)
+ACMD(divorce)
{
nullpo_retr(-1, sd);
-
+
if (pc_divorce(sd) != 0) {
sprintf(atcmd_output, msg_txt(1175), sd->status.name); // '%s' is not married.
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
-
+
sprintf(atcmd_output, msg_txt(1176), sd->status.name); // '%s' and his/her partner are now divorced.
clif->message(fd, atcmd_output);
- return 0;
+ return true;
}
/*==========================================
* @changelook by [Celest]
*------------------------------------------*/
-ACMD_FUNC(changelook)
+ACMD(changelook)
{
int i, j = 0, k = 0;
int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
-
+
if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
clif->message(fd, msg_txt(1177)); // Usage: @changelook {<position>} <view id>
clif->message(fd, msg_txt(1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
- return -1;
+ return false;
} else if ( i == 2 ) {
if (j < 1 || j > 7)
j = 1;
@@ -5642,170 +5599,149 @@ ACMD_FUNC(changelook)
k = j; // swap
j = LOOK_HEAD_TOP;
}
-
+
clif->changelook(&sd->bl,j,k);
-
- return 0;
+
+ return true;
}
/*==========================================
* @autotrade by durf [Lupus] [Paradox924X]
* Turns on/off Autotrade for a specific player
*------------------------------------------*/
-ACMD_FUNC(autotrade) {
- int i;
+ACMD(autotrade) {
nullpo_retr(-1, sd);
-
+
if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
clif->message(fd, msg_txt(1179)); // Autotrade is not allowed on this map.
- return -1;
+ return false;
}
-
+
if( pc_isdead(sd) ) {
clif->message(fd, msg_txt(1180)); // You cannot autotrade when dead.
- return -1;
+ return false;
}
-
+
if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
clif->message(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
- return -1;
+ return false;
}
-
+
sd->state.autotrade = 1;
if( battle_config.at_timeout ) {
int timeout = atoi(message);
status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
}
- if( hChSys.ally && sd->status.guild_id ) {
- struct guild *g = sd->guild, *sg;
- if( g ) {
- if( idb_exists(((struct hChSysCh *)g->channel)->users, sd->status.char_id) )
- clif->chsys_left((struct hChSysCh *)g->channel,sd);
- for (i = 0; i < MAX_GUILDALLIANCE; i++) {
- if( g->alliance[i].guild_id && (sg = guild_search(g->alliance[i].guild_id) ) ) {
- if( idb_exists(((struct hChSysCh *)sg->channel)->users, sd->status.char_id) )
- clif->chsys_left((struct hChSysCh *)sg->channel,sd);
- break;
- }
- }
- }
- }
-
- if( sd->channel_count ) {
- for( i = 0; i < sd->channel_count; i++ ) {
- if( sd->channels[i] != NULL )
- clif->chsys_left(sd->channels[i],sd);
- }
- }
+ clif->chsys_quit(sd);
clif->authfail_fd(sd->fd, 15);
-
- return 0;
+
+ return true;
}
/*==========================================
* @changegm by durf (changed by Lupus)
* Changes Master of your Guild to a specified guild member
*------------------------------------------*/
-ACMD_FUNC(changegm)
+ACMD(changegm)
{
struct guild *g;
struct map_session_data *pl_sd;
nullpo_retr(-1, sd);
-
+
if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
clif->message(fd, msg_txt(1181)); // You need to be a Guild Master to use this command.
- return -1;
+ return false;
}
-
+
if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
clif->message(fd, msg_txt(1182)); // You cannot change guild leaders on this map.
- return -1;
+ return false;
}
-
+
if( !message[0] ) {
clif->message(fd, msg_txt(1183)); // Usage: @changegm <guild_member_name>
- return -1;
+ return false;
}
-
+
if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
clif->message(fd, msg_txt(1184)); // Target character must be online and be a guild member.
- return -1;
+ return false;
}
-
+
guild_gm_change(sd->status.guild_id, pl_sd);
- return 0;
+ return true;
}
/*==========================================
* @changeleader by Skotlex
* Changes the leader of a party.
*------------------------------------------*/
-ACMD_FUNC(changeleader)
+ACMD(changeleader)
{
nullpo_retr(-1, sd);
-
+
if( !message[0] )
{
clif->message(fd, msg_txt(1185)); // Usage: @changeleader <party_member_name>
- return -1;
+ return false;
}
-
+
if (party_changeleader(sd, map_nick2sd((char *) message)))
- return 0;
- return -1;
+ return true;
+ return false;
}
/*==========================================
* @partyoption by Skotlex
* Used to change the item share setting of a party.
*------------------------------------------*/
-ACMD_FUNC(partyoption)
+ACMD(partyoption)
{
struct party_data *p;
int mi, option;
char w1[16], w2[16];
nullpo_retr(-1, sd);
-
+
if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
{
clif->message(fd, msg_txt(282));
- return -1;
+ return false;
}
-
+
ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
if (mi == MAX_PARTY)
- return -1; //Shouldn't happen
-
+ return false; //Shouldn't happen
+
if (!p->party.member[mi].leader)
{
clif->message(fd, msg_txt(282));
- return -1;
+ return false;
}
-
+
if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
{
clif->message(fd, msg_txt(1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
- return -1;
+ return false;
}
-
+
option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
-
+
//Change item share type.
if (option != p->party.item)
party_changeoption(sd, p->party.exp, option);
else
clif->message(fd, msg_txt(286));
-
- return 0;
+
+ return true;
}
/*==========================================
* @autoloot by Upa-Kun
* Turns on/off AutoLoot for a specific player
*------------------------------------------*/
-ACMD_FUNC(autoloot)
+ACMD(autoloot)
{
int rate;
nullpo_retr(-1, sd);
@@ -5823,26 +5759,26 @@ ACMD_FUNC(autoloot)
}
if (rate < 0) rate = 0;
if (rate > 10000) rate = 10000;
-
+
sd->state.autoloot = rate;
if (sd->state.autoloot) {
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below.
clif->message(fd, atcmd_output);
}else
clif->message(fd, msg_txt(1188)); // Autoloot is now off.
-
- return 0;
+
+ return true;
}
/*==========================================
* @alootid
*------------------------------------------*/
-ACMD_FUNC(autolootitem)
+ACMD(autolootitem)
{
struct item_data *item_data = NULL;
int i;
int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
-
+
if (message && *message) {
if (message[0] == '+') {
message++;
@@ -5855,7 +5791,7 @@ ACMD_FUNC(autolootitem)
else if (!strcmp(message,"reset"))
action = 4;
}
-
+
if (action < 3) // add or remove
{
if ((item_data = itemdb_exists(atoi(message))) == NULL)
@@ -5863,71 +5799,71 @@ ACMD_FUNC(autolootitem)
if (!item_data) {
// No items founds in the DB with Id or Name
clif->message(fd, msg_txt(1189)); // Item not found.
- return -1;
+ return false;
}
}
-
+
switch(action) {
- case 1:
- ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
- if (i != AUTOLOOTITEM_SIZE) {
- clif->message(fd, msg_txt(1190)); // You're already autolooting this item.
- return -1;
- }
- ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
- if (i == AUTOLOOTITEM_SIZE) {
- clif->message(fd, msg_txt(1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
- return -1;
- }
- sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
- sprintf(atcmd_output, msg_txt(1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
- clif->message(fd, atcmd_output);
- sd->state.autolooting = 1;
- break;
- case 2:
- ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
- if (i == AUTOLOOTITEM_SIZE) {
- clif->message(fd, msg_txt(1193)); // You're currently not autolooting this item.
- return -1;
- }
- sd->state.autolootid[i] = 0;
- sprintf(atcmd_output, msg_txt(1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
- clif->message(fd, atcmd_output);
- ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
- if (i == AUTOLOOTITEM_SIZE) {
- sd->state.autolooting = 0;
- }
- break;
- case 3:
- sprintf(atcmd_output, msg_txt(1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
- clif->message(fd, atcmd_output);
- clif->message(fd, msg_txt(1196)); // To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
- clif->message(fd, msg_txt(1197)); // "@alootid reset" will clear your autolootitem list.
- ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
- if (i == AUTOLOOTITEM_SIZE) {
- clif->message(fd, msg_txt(1198)); // Your autolootitem list is empty.
- } else {
- clif->message(fd, msg_txt(1199)); // Items on your autolootitem list:
- for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
- {
- if (sd->state.autolootid[i] == 0)
- continue;
- if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
- ShowDebug("Non-existant item %d on autolootitem list (account_id: %d, char_id: %d)", sd->state.autolootid[i], sd->status.account_id, sd->status.char_id);
- continue;
+ case 1:
+ ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
+ if (i != AUTOLOOTITEM_SIZE) {
+ clif->message(fd, msg_txt(1190)); // You're already autolooting this item.
+ return false;
+ }
+ ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
+ if (i == AUTOLOOTITEM_SIZE) {
+ clif->message(fd, msg_txt(1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
+ return false;
+ }
+ sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
+ sprintf(atcmd_output, msg_txt(1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
+ clif->message(fd, atcmd_output);
+ sd->state.autolooting = 1;
+ break;
+ case 2:
+ ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
+ if (i == AUTOLOOTITEM_SIZE) {
+ clif->message(fd, msg_txt(1193)); // You're currently not autolooting this item.
+ return false;
+ }
+ sd->state.autolootid[i] = 0;
+ sprintf(atcmd_output, msg_txt(1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
+ clif->message(fd, atcmd_output);
+ ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
+ if (i == AUTOLOOTITEM_SIZE) {
+ sd->state.autolooting = 0;
+ }
+ break;
+ case 3:
+ sprintf(atcmd_output, msg_txt(1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
+ clif->message(fd, atcmd_output);
+ clif->message(fd, msg_txt(1196)); // To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
+ clif->message(fd, msg_txt(1197)); // "@alootid reset" will clear your autolootitem list.
+ ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
+ if (i == AUTOLOOTITEM_SIZE) {
+ clif->message(fd, msg_txt(1198)); // Your autolootitem list is empty.
+ } else {
+ clif->message(fd, msg_txt(1199)); // Items on your autolootitem list:
+ for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
+ {
+ if (sd->state.autolootid[i] == 0)
+ continue;
+ if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
+ ShowDebug("Non-existant item %d on autolootitem list (account_id: %d, char_id: %d)", sd->state.autolootid[i], sd->status.account_id, sd->status.char_id);
+ continue;
+ }
+ sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
+ clif->message(fd, atcmd_output);
}
- sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
- clif->message(fd, atcmd_output);
}
- }
- break;
- case 4:
- memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
- clif->message(fd, msg_txt(1200)); // Your autolootitem list has been reset.
- sd->state.autolooting = 0;
- break;
+ break;
+ case 4:
+ memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
+ clif->message(fd, msg_txt(1200)); // Your autolootitem list has been reset.
+ sd->state.autolooting = 0;
+ break;
}
- return 0;
+ return true;
}
/**
* No longer available, keeping here just in case it's back someday. [Ind]
@@ -5935,7 +5871,7 @@ ACMD_FUNC(autolootitem)
/*==========================================
* It is made to rain.
*------------------------------------------*/
-//ACMD_FUNC(rain)
+//ACMD(rain)
//{
// nullpo_retr(-1, sd);
// if (map[sd->bl.m].flag.rain) {
@@ -5947,13 +5883,13 @@ ACMD_FUNC(autolootitem)
// clif->weather(sd->bl.m);
// clif->message(fd, msg_txt(1202)); // It has started to rain.
// }
-// return 0;
+// return true;
//}
/*==========================================
* It is made to snow.
*------------------------------------------*/
-ACMD_FUNC(snow)
+ACMD(snow)
{
nullpo_retr(-1, sd);
if (map[sd->bl.m].flag.snow) {
@@ -5965,14 +5901,14 @@ ACMD_FUNC(snow)
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(1204)); // It has started to snow.
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Cherry tree snowstorm is made to fall. (Sakura)
*------------------------------------------*/
-ACMD_FUNC(sakura)
+ACMD(sakura)
{
nullpo_retr(-1, sd);
if (map[sd->bl.m].flag.sakura) {
@@ -5984,13 +5920,13 @@ ACMD_FUNC(sakura)
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(1206)); // Cherry tree leaves have begun to fall.
}
- return 0;
+ return true;
}
/*==========================================
* Clouds appear.
*------------------------------------------*/
-ACMD_FUNC(clouds)
+ACMD(clouds)
{
nullpo_retr(-1, sd);
if (map[sd->bl.m].flag.clouds) {
@@ -6002,14 +5938,14 @@ ACMD_FUNC(clouds)
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(1208)); // Clouds appear.
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Different type of clouds using effect 516
*------------------------------------------*/
-ACMD_FUNC(clouds2)
+ACMD(clouds2)
{
nullpo_retr(-1, sd);
if (map[sd->bl.m].flag.clouds2) {
@@ -6021,14 +5957,14 @@ ACMD_FUNC(clouds2)
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(1210)); // Alternative clouds appear.
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Fog hangs over.
*------------------------------------------*/
-ACMD_FUNC(fog)
+ACMD(fog)
{
nullpo_retr(-1, sd);
if (map[sd->bl.m].flag.fog) {
@@ -6040,13 +5976,13 @@ ACMD_FUNC(fog)
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(1212)); // Fog hangs over.
}
- return 0;
+ return true;
}
/*==========================================
* Fallen leaves fall.
*------------------------------------------*/
-ACMD_FUNC(leaves)
+ACMD(leaves)
{
nullpo_retr(-1, sd);
if (map[sd->bl.m].flag.leaves) {
@@ -6058,14 +5994,14 @@ ACMD_FUNC(leaves)
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(1214)); // Fallen leaves fall.
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Fireworks appear.
*------------------------------------------*/
-ACMD_FUNC(fireworks)
+ACMD(fireworks)
{
nullpo_retr(-1, sd);
if (map[sd->bl.m].flag.fireworks) {
@@ -6077,14 +6013,14 @@ ACMD_FUNC(fireworks)
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(1216)); // Fireworks have launched.
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Clearing Weather Effects by Dexity
*------------------------------------------*/
-ACMD_FUNC(clearweather)
+ACMD(clearweather)
{
nullpo_retr(-1, sd);
/**
@@ -6100,75 +6036,75 @@ ACMD_FUNC(clearweather)
map[sd->bl.m].flag.leaves=0;
clif->weather(sd->bl.m);
clif->message(fd, msg_txt(291));
-
- return 0;
+
+ return true;
}
/*===============================================================
* Sound Command - plays a sound for everyone around! [Codemaster]
*---------------------------------------------------------------*/
-ACMD_FUNC(sound)
+ACMD(sound)
{
char sound_file[100];
-
+
memset(sound_file, '\0', sizeof(sound_file));
-
- if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
+
+ if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
clif->message(fd, msg_txt(1217)); // Please enter a sound filename (usage: @sound <filename>).
- return -1;
+ return false;
}
-
+
if(strstr(sound_file, ".wav") == NULL)
strcat(sound_file, ".wav");
-
+
clif->soundeffectall(&sd->bl, sound_file, 0, AREA);
-
- return 0;
+
+ return true;
}
/*==========================================
* MOB Search
*------------------------------------------*/
-ACMD_FUNC(mobsearch)
+ACMD(mobsearch)
{
char mob_name[100];
int mob_id;
int number = 0;
struct s_mapiterator* it;
-
+
nullpo_retr(-1, sd);
-
+
if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
clif->message(fd, msg_txt(1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
- return -1;
+ return false;
}
-
+
if ((mob_id = atoi(mob_name)) == 0)
- mob_id = mobdb_searchname(mob_name);
+ mob_id = mobdb_searchname(mob_name);
if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1219),mob_name); // Invalid mob ID %s!
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
- strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
-// strcpy(mob_name,mob_db(mob_id)->name); // --en--
-
+ strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
+ // strcpy(mob_name,mob_db(mob_id)->name); // --en--
+
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
clif->message(fd, atcmd_output);
-
+
it = mapit_geteachmob();
for(;;)
{
TBL_MOB* md = (TBL_MOB*)mapit_next(it);
if( md == NULL )
break;// no more mobs
-
+
if( md->bl.m != sd->bl.m )
continue;
if( mob_id != -1 && md->class_ != mob_id )
continue;
-
+
++number;
if( md->spawn_timer == INVALID_TIMER )
snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
@@ -6177,8 +6113,8 @@ ACMD_FUNC(mobsearch)
clif->message(fd, atcmd_output);
}
mapit_free(it);
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -6189,21 +6125,21 @@ static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
{
nullpo_ret(bl);
map_clearflooritem(bl);
-
+
return 0;
}
-ACMD_FUNC(cleanmap)
+ACMD(cleanmap)
{
map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
clif->message(fd, msg_txt(1221)); // All dropped items have been cleaned up.
- return 0;
+ return true;
}
-ACMD_FUNC(cleanarea)
+ACMD(cleanarea)
{
int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
-
+
if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - (AREA_SIZE * 2), sd->bl.y - (AREA_SIZE * 2), sd->bl.x + (AREA_SIZE * 2), sd->bl.y + (AREA_SIZE * 2), BL_ITEM);
}
@@ -6213,83 +6149,83 @@ ACMD_FUNC(cleanarea)
else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
}
-
+
clif->message(fd, msg_txt(1221)); // All dropped items have been cleaned up.
- return 0;
+ return true;
}
/*==========================================
* make a NPC/PET talk
* @npctalkc [SnakeDrak]
*------------------------------------------*/
-ACMD_FUNC(npctalk)
+ACMD(npctalk)
{
char name[NAME_LENGTH],mes[100],temp[100];
struct npc_data *nd;
bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
unsigned long color=0;
-
+
if (sd->sc.count && //no "chatting" while muted.
(sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
- (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
- return -1;
-
+ (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
+ return false;
+
if(!ifcolor) {
if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
clif->message(fd, msg_txt(1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
- return -1;
+ return false;
}
}
else {
if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
clif->message(fd, msg_txt(1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
- return -1;
+ return false;
}
}
-
+
if (!(nd = npc_name2id(name))) {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist
- return -1;
+ return false;
}
-
+
strtok(name, "#"); // discard extra name identifier if present
snprintf(temp, sizeof(temp), "%s : %s", name, mes);
-
+
if(ifcolor) clif->messagecolor(&nd->bl,color,temp);
else clif->disp_overhead(&nd->bl, temp);
-
- return 0;
+
+ return true;
}
-ACMD_FUNC(pettalk)
+ACMD(pettalk)
{
char mes[100],temp[100];
struct pet_data *pd;
-
+
nullpo_retr(-1, sd);
-
+
if ( battle_config.min_chat_delay ) {
if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
- return 0;
+ return true;
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
}
-
+
if(!sd->status.pet_id || !(pd=sd->pd))
{
clif->message(fd, msg_txt(184));
- return -1;
+ return false;
}
-
+
if (sd->sc.count && //no "chatting" while muted.
(sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
- (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
- return -1;
-
+ (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
+ return false;
+
if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
clif->message(fd, msg_txt(1224)); // Please enter a message (usage: @pettalk <message>).
- return -1;
+ return false;
}
-
+
if (message[0] == '/')
{// pet emotion processing
const char* emo[] = {
@@ -6309,35 +6245,35 @@ ACMD_FUNC(pettalk)
if( i < ARRAYLENGTH(emo) )
{
if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
- sd->emotionlasttime = time(NULL);
- return 0;
+ sd->emotionlasttime = time(NULL);
+ return true;
}
sd->emotionlasttime = time(NULL);
-
+
clif->emotion(&pd->bl, i);
- return 0;
+ return true;
}
}
-
+
snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
clif->disp_overhead(&pd->bl, temp);
-
- return 0;
+
+ return true;
}
/// @users - displays the number of players present on each map (and percentage)
/// #users displays on the target user instead of self
-ACMD_FUNC(users)
+ACMD(users)
{
char buf[CHAT_SIZE_MAX];
int i;
int users[MAX_MAPINDEX];
int users_all;
struct s_mapiterator* iter;
-
+
memset(users, 0, sizeof(users));
users_all = 0;
-
+
// count users on each map
iter = mapit_getallusers();
for(;;)
@@ -6345,81 +6281,81 @@ ACMD_FUNC(users)
struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
if( sd2 == NULL )
break;// no more users
-
+
if( sd2->mapindex >= MAX_MAPINDEX )
continue;// invalid mapindex
-
+
if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
if( users_all < INT_MAX ) ++users_all;
}
mapit_free(iter);
-
+
// display results for each map
for( i = 0; i < MAX_MAPINDEX; ++i )
{
if( users[i] == 0 )
continue;// empty
-
+
safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
clif->message(sd->fd, buf);
}
-
+
// display overall count
safesnprintf(buf, sizeof(buf), "all: %d", users_all);
clif->message(sd->fd, buf);
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(reset)
+ACMD(reset)
{
pc_resetstate(sd);
pc_resetskill(sd,1);
sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
clif->message(fd, atcmd_output);
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-ACMD_FUNC(summon)
+ACMD(summon)
{
char name[NAME_LENGTH];
int mob_id = 0;
int duration = 0;
struct mob_data *md;
unsigned int tick=gettick();
-
+
nullpo_retr(-1, sd);
-
+
if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
{
clif->message(fd, msg_txt(1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
- return -1;
+ return false;
}
-
+
if (duration < 1)
duration =1;
else if (duration > 60)
duration =60;
-
+
if ((mob_id = atoi(name)) == 0)
mob_id = mobdb_searchname(name);
if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
{
clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
- return -1;
+ return false;
}
-
+
md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
-
+
if(!md)
- return -1;
-
+ return false;
+
md->master_id=sd->bl.id;
md->special_state.ai=1;
md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
@@ -6428,8 +6364,8 @@ ACMD_FUNC(summon)
sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
clif->skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
clif->message(fd, msg_txt(39)); // All monster summoned!
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -6437,116 +6373,116 @@ ACMD_FUNC(summon)
* Temporarily move player to another group
* Useful during beta testing to allow players to use GM commands for short periods of time
*------------------------------------------*/
-ACMD_FUNC(adjgroup)
+ACMD(adjgroup)
{
int new_group = 0;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
clif->message(fd, msg_txt(1226)); // Usage: @adjgroup <group_id>
- return -1;
+ return false;
}
-
+
if (!pc_group_exists(new_group)) {
clif->message(fd, msg_txt(1227)); // Specified group does not exist.
- return -1;
+ return false;
}
-
+
sd->group_id = new_group;
pc_group_pc_load(sd);/* update cache */
clif->message(fd, msg_txt(1228)); // Group changed successfully.
clif->message(sd->fd, msg_txt(1229)); // Your group has changed.
- return 0;
+ return true;
}
/*==========================================
* @trade by [MouseJstr]
* Open a trade window with a remote player
*------------------------------------------*/
-ACMD_FUNC(trade)
+ACMD(trade)
{
struct map_session_data *pl_sd = NULL;
nullpo_retr(-1, sd);
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1230)); // Please enter a player name (usage: @trade <char name>).
- return -1;
+ return false;
}
-
+
if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
{
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
trade_traderequest(sd, pl_sd);
- return 0;
+ return true;
}
/*==========================================
* @setbattleflag by [MouseJstr]
* set a battle_config flag without having to reboot
*------------------------------------------*/
-ACMD_FUNC(setbattleflag)
+ACMD(setbattleflag)
{
char flag[128], value[128];
nullpo_retr(-1, sd);
-
+
if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
- clif->message(fd, msg_txt(1231)); // Usage: @setbattleflag <flag> <value>
- return -1;
+ clif->message(fd, msg_txt(1231)); // Usage: @setbattleflag <flag> <value>
+ return false;
}
-
+
if (battle->config_set_value(flag, value) == 0) {
clif->message(fd, msg_txt(1232)); // Unknown battle_config flag.
- return -1;
+ return false;
}
-
+
clif->message(fd, msg_txt(1233)); // Set battle_config as requested.
-
- return 0;
+
+ return true;
}
/*==========================================
* @unmute [Valaris]
*------------------------------------------*/
-ACMD_FUNC(unmute)
+ACMD(unmute)
{
struct map_session_data *pl_sd = NULL;
nullpo_retr(-1, sd);
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1234)); // Please enter a player name (usage: @unmute <char name>).
- return -1;
+ return false;
}
-
+
if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
{
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
if(!pl_sd->sc.data[SC_NOCHAT]) {
clif->message(sd->fd,msg_txt(1235)); // Player is not muted.
- return -1;
+ return false;
}
-
+
pl_sd->status.manner = 0;
status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
clif->message(sd->fd,msg_txt(1236)); // Player unmuted.
-
- return 0;
+
+ return true;
}
/*==========================================
* @uptime by MC Cameri
*------------------------------------------*/
-ACMD_FUNC(uptime)
+ACMD(uptime)
{
unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
- minute = 60, days = 0, hours = 0, minutes = 0;
+ minute = 60, days = 0, hours = 0, minutes = 0;
nullpo_retr(-1, sd);
-
+
seconds = get_uptime();
days = seconds/day;
seconds -= (seconds/day>0)?(seconds/day)*day:0;
@@ -6554,18 +6490,18 @@ ACMD_FUNC(uptime)
seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
minutes = seconds/minute;
seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
-
+
snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
clif->message(fd, atcmd_output);
-
- return 0;
+
+ return true;
}
/*==========================================
* @changesex <sex>
* => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
*------------------------------------------*/
-ACMD_FUNC(changesex)
+ACMD(changesex)
{
int i;
nullpo_retr(-1, sd);
@@ -6574,38 +6510,38 @@ ACMD_FUNC(changesex)
for( i=0; i<EQI_MAX; i++ )
if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
chrif_changesex(sd);
- return 0;
+ return true;
}
/*================================================
* @mute - Mutes a player for a set amount of time
*------------------------------------------------*/
-ACMD_FUNC(mute)
+ACMD(mute)
{
struct map_session_data *pl_sd = NULL;
int manner;
nullpo_retr(-1, sd);
-
+
if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
clif->message(fd, msg_txt(1237)); // Usage: @mute <time> <char name>
- return -1;
+ return false;
}
-
+
if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
{
clif->message(fd, msg_txt(3)); // Character not found.
- return -1;
+ return false;
}
-
+
if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
{
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
+ return false;
}
-
+
clif->manner_message(sd, 0);
clif->manner_message(pl_sd, 5);
-
+
if( pl_sd->status.manner < manner ) {
pl_sd->status.manner -= manner;
sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
@@ -6613,45 +6549,45 @@ ACMD_FUNC(mute)
pl_sd->status.manner = 0;
status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
}
-
+
clif->GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
-
- return 0;
+
+ return true;
}
/*==========================================
* @refresh (like @jumpto <<yourself>>)
*------------------------------------------*/
-ACMD_FUNC(refresh)
+ACMD(refresh)
{
nullpo_retr(-1, sd);
clif->refresh(sd);
- return 0;
+ return true;
}
-ACMD_FUNC(refreshall)
+ACMD(refreshall)
{
struct map_session_data* iter_sd;
struct s_mapiterator* iter;
nullpo_retr(-1, sd);
-
+
iter = mapit_getallusers();
for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
clif->refresh(iter_sd);
mapit_free(iter);
- return 0;
+ return true;
}
/*==========================================
* @identify
* => GM's magnifier.
*------------------------------------------*/
-ACMD_FUNC(identify)
+ACMD(identify)
{
int i,num;
-
+
nullpo_retr(-1, sd);
-
+
for(i=num=0;i<MAX_INVENTORY;i++){
if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
num++;
@@ -6662,76 +6598,76 @@ ACMD_FUNC(identify)
} else {
clif->message(fd,msg_txt(1238)); // There are no items to appraise.
}
- return 0;
+ return true;
}
/*==========================================
* @gmotd (Global MOTD)
* by davidsiaw :P
*------------------------------------------*/
-ACMD_FUNC(gmotd)
+ACMD(gmotd)
{
FILE* fp;
-
+
if( ( fp = fopen(motd_txt, "r") ) != NULL )
{
char buf[CHAT_SIZE_MAX];
size_t len;
-
+
while( fgets(buf, sizeof(buf), fp) )
{
if( buf[0] == '/' && buf[1] == '/' )
{
continue;
}
-
+
len = strlen(buf);
-
+
while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
{// strip trailing EOL characters
len--;
}
-
+
if( len )
{
buf[len] = 0;
-
+
intif_broadcast(buf, len+1, 0);
}
}
fclose(fp);
}
- return 0;
+ return true;
}
-ACMD_FUNC(misceffect)
+ACMD(misceffect)
{
int effect = 0;
nullpo_retr(-1, sd);
if (!message || !*message)
- return -1;
+ return false;
if (sscanf(message, "%d", &effect) < 1)
- return -1;
+ return false;
clif->misceffect(&sd->bl,effect);
-
- return 0;
+
+ return true;
}
/*==========================================
* MAIL SYSTEM
*------------------------------------------*/
-ACMD_FUNC(mail)
+ACMD(mail)
{
nullpo_ret(sd);
mail_openmail(sd);
- return 0;
+ return true;
}
/*==========================================
* Show Monster DB Info v 1.0
* originally by [Lupus]
*------------------------------------------*/
-ACMD_FUNC(mobinfo)
+ACMD(mobinfo)
{
unsigned char msize[3][7] = {"Small", "Medium", "Large"};
unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
@@ -6741,15 +6677,15 @@ ACMD_FUNC(mobinfo)
struct mob_db *mob, *mob_array[MAX_SEARCH];
int count;
int i, j, k;
-
+
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(atcmd_output2, '\0', sizeof(atcmd_output2));
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
- return -1;
+ return false;
}
-
+
// If monster identifier/name argument is a name
if ((i = mobdb_checkid(atoi(message))))
{
@@ -6757,12 +6693,12 @@ ACMD_FUNC(mobinfo)
count = 1;
} else
count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
-
+
if (!count) {
clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
- return -1;
+ return false;
}
-
+
if (count > MAX_SEARCH) {
sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
clif->message(fd, atcmd_output);
@@ -6770,7 +6706,7 @@ ACMD_FUNC(mobinfo)
}
for (k = 0; k < count; k++) {
mob = mob_array[k];
-
+
// stats
if (mob->mexp)
sprintf(atcmd_output, msg_txt(1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
@@ -6780,14 +6716,14 @@ ACMD_FUNC(mobinfo)
sprintf(atcmd_output, msg_txt(1242), mob->lv, mob->status.max_hp, mob->base_exp, mob->job_exp,MOB_HIT(mob), MOB_FLEE(mob)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
clif->message(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
- mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
- mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
+ mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
+ mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
clif->message(fd, atcmd_output);
-
+
sprintf(atcmd_output, msg_txt(1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
- mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
- mob->range2 , mob->range3, msize[mob->status.size],
- mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
+ mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
+ mob->range2 , mob->range3, msize[mob->status.size],
+ mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
clif->message(fd, atcmd_output);
// drops
clif->message(fd, msg_txt(1245)); // Drops:
@@ -6798,7 +6734,7 @@ ACMD_FUNC(mobinfo)
if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
continue;
droprate = mob->dropitem[i].p;
-
+
if (item_data->slot)
sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
else
@@ -6837,53 +6773,53 @@ ACMD_FUNC(mobinfo)
clif->message(fd, atcmd_output);
}
}
- return 0;
+ return true;
}
/*=========================================
-* @showmobs by KarLaeda
-* => For 15 sec displays the mobs on minimap
-*------------------------------------------*/
-ACMD_FUNC(showmobs)
+ * @showmobs by KarLaeda
+ * => For 15 sec displays the mobs on minimap
+ *------------------------------------------*/
+ACMD(showmobs)
{
char mob_name[100];
int mob_id;
int number = 0;
struct s_mapiterator* it;
-
+
nullpo_retr(-1, sd);
-
+
if(sscanf(message, "%99[^\n]", mob_name) < 0)
- return -1;
-
+ return false;
+
if((mob_id = atoi(mob_name)) == 0)
mob_id = mobdb_searchname(mob_name);
if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1250),mob_name); // Invalid mob id %s!
clif->message(fd, atcmd_output);
- return 0;
+ return true;
}
-
+
if(mob_db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
clif->message(fd, msg_txt(1251)); // Can't show boss mobs!
- return 0;
+ return true;
}
-
+
if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
- //strcpy(mob_name,mob_db(mob_id)->name); // --en--
-
+ //strcpy(mob_name,mob_db(mob_id)->name); // --en--
+
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1252), // Mob Search... %s %s
- mob_name, mapindex_id2name(sd->mapindex));
+ mob_name, mapindex_id2name(sd->mapindex));
clif->message(fd, atcmd_output);
-
+
it = mapit_geteachmob();
for(;;)
{
TBL_MOB* md = (TBL_MOB*)mapit_next(it);
if( md == NULL )
break;// no more mobs
-
+
if( md->bl.m != sd->bl.m )
continue;
if( mob_id != -1 && md->class_ != mob_id )
@@ -6892,360 +6828,360 @@ ACMD_FUNC(showmobs)
continue; // hide slaves and player summoned mobs
if( md->spawn_timer != INVALID_TIMER )
continue; // hide mobs waiting for respawn
-
+
++number;
clif->viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
}
mapit_free(it);
-
- return 0;
+
+ return true;
}
/*==========================================
* homunculus level up [orn]
*------------------------------------------*/
-ACMD_FUNC(homlevel)
+ACMD(homlevel)
{
TBL_HOM * hd;
int level = 0;
-
+
nullpo_retr(-1, sd);
-
+
if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
clif->message(fd, msg_txt(1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
- return -1;
+ return false;
}
-
+
if ( !merc_is_hom_active(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
- return -1;
+ return false;
}
-
+
hd = sd->hd;
-
+
if ( battle_config.hom_max_level == hd->homunculus.level ) // Already reach maximum level
- return 0;
-
+ return true;
+
do{
hd->homunculus.exp += hd->exp_next;
}while( hd->homunculus.level < level && merc_hom_levelup(hd) );
-
+
status_calc_homunculus(hd,0);
status_percent_heal(&hd->bl, 100, 100);
clif->specialeffect(&hd->bl,568,AREA);
- return 0;
+ return true;
}
/*==========================================
* homunculus evolution H [orn]
*------------------------------------------*/
-ACMD_FUNC(homevolution)
+ACMD(homevolution)
{
nullpo_retr(-1, sd);
-
+
if ( !merc_is_hom_active(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
- return -1;
+ return false;
}
-
+
if ( !merc_hom_evolution(sd->hd) ) {
clif->message(fd, msg_txt(1255)); // Your homunculus doesn't evolve.
- return -1;
+ return false;
}
clif->homskillinfoblock(sd);
- return 0;
+ return true;
}
-ACMD_FUNC(hommutate)
+ACMD(hommutate)
{
int homun_id, m_class = 0, m_id;
nullpo_retr(-1, sd);
-
+
if (!merc_is_hom_active(sd->hd)) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
- return -1;
+ return false;
}
-
+
if (!message || !*message) {
homun_id = 6048 + (rnd() % 4);
} else {
homun_id = atoi(message);
}
-
+
m_class = hom_class2mapid(sd->hd->homunculus.class_);
m_id = hom_class2mapid(homun_id);
-
+
if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
hom_mutate(sd->hd, homun_id);
} else {
clif->emotion(&sd->hd->bl, E_SWT);
}
- return 0;
+ return true;
}
/*==========================================
* call choosen homunculus [orn]
*------------------------------------------*/
-ACMD_FUNC(makehomun)
+ACMD(makehomun)
{
int homunid;
nullpo_retr(-1, sd);
-
+
if ( sd->status.hom_id ) {
clif->message(fd, msg_txt(450));
- return -1;
+ return false;
}
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
- return -1;
+ return false;
}
-
+
homunid = atoi(message);
if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
{
clif->message(fd, msg_txt(1257)); // Invalid Homunculus ID.
- return -1;
+ return false;
}
-
+
merc_create_homunculus_request(sd,homunid);
- return 0;
+ return true;
}
/*==========================================
* modify homunculus intimacy [orn]
*------------------------------------------*/
-ACMD_FUNC(homfriendly)
+ACMD(homfriendly)
{
int friendly = 0;
-
+
nullpo_retr(-1, sd);
-
+
if ( !merc_is_hom_active(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
- return -1;
+ return false;
}
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
- return -1;
+ return false;
}
-
+
friendly = atoi(message);
friendly = cap_value(friendly, 0, 1000);
-
+
sd->hd->homunculus.intimacy = friendly * 100 ;
clif->send_homdata(sd,SP_INTIMATE,friendly);
- return 0;
+ return true;
}
/*==========================================
* modify homunculus hunger [orn]
*------------------------------------------*/
-ACMD_FUNC(homhungry)
+ACMD(homhungry)
{
int hungry = 0;
-
+
nullpo_retr(-1, sd);
-
+
if ( !merc_is_hom_active(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
- return -1;
+ return false;
}
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
- return -1;
+ return false;
}
-
+
hungry = atoi(message);
hungry = cap_value(hungry, 0, 100);
-
+
sd->hd->homunculus.hunger = hungry;
clif->send_homdata(sd,SP_HUNGRY,hungry);
- return 0;
+ return true;
}
/*==========================================
* make the homunculus speak [orn]
*------------------------------------------*/
-ACMD_FUNC(homtalk)
+ACMD(homtalk)
{
char mes[100],temp[100];
-
+
nullpo_retr(-1, sd);
-
+
if ( battle_config.min_chat_delay ) {
if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
- return 0;
+ return true;
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
}
-
+
if (sd->sc.count && //no "chatting" while muted.
(sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
- (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
- return -1;
-
+ (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
+ return false;
+
if ( !merc_is_hom_active(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
- return -1;
+ return false;
}
-
+
if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
clif->message(fd, msg_txt(1260)); // Please enter a message (usage: @homtalk <message>).
- return -1;
+ return false;
}
-
+
snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
clif->disp_overhead(&sd->hd->bl, temp);
-
- return 0;
+
+ return true;
}
/*==========================================
* Show homunculus stats
*------------------------------------------*/
-ACMD_FUNC(hominfo)
+ACMD(hominfo)
{
struct homun_data *hd;
struct status_data *status;
nullpo_retr(-1, sd);
-
+
if ( !merc_is_hom_active(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
- return -1;
+ return false;
}
-
+
hd = sd->hd;
status = status_get_status_data(&hd->bl);
clif->message(fd, msg_txt(1261)); // Homunculus stats:
-
+
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1262), // HP: %d/%d - SP: %d/%d
- status->hp, status->max_hp, status->sp, status->max_sp);
+ status->hp, status->max_hp, status->sp, status->max_sp);
clif->message(fd, atcmd_output);
-
+
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1263), // ATK: %d - MATK: %d~%d
- status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
+ status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
clif->message(fd, atcmd_output);
-
+
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1264), // Hungry: %d - Intimacy: %u
- hd->homunculus.hunger, hd->homunculus.intimacy/100);
+ hd->homunculus.hunger, hd->homunculus.intimacy/100);
clif->message(fd, atcmd_output);
-
+
snprintf(atcmd_output, sizeof(atcmd_output) ,
- msg_txt(1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
- status->str, status->agi, status->vit,
- status->int_, status->dex, status->luk);
+ msg_txt(1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
+ status->str, status->agi, status->vit,
+ status->int_, status->dex, status->luk);
clif->message(fd, atcmd_output);
-
- return 0;
+
+ return true;
}
-ACMD_FUNC(homstats)
+ACMD(homstats)
{
struct homun_data *hd;
struct s_homunculus_db *db;
struct s_homunculus *hom;
int lv, min, max, evo;
-
+
nullpo_retr(-1, sd);
-
+
if ( !merc_is_hom_active(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
- return -1;
+ return false;
}
-
+
hd = sd->hd;
-
+
hom = &hd->homunculus;
db = hd->homunculusDB;
lv = hom->level;
-
+
snprintf(atcmd_output, sizeof(atcmd_output) ,
- msg_txt(1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
+ msg_txt(1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
clif->message(fd, atcmd_output);
lv--; //Since the first increase is at level 2.
-
+
evo = (hom->class_ == db->evo_class);
min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1269), hom->str/10, min, max); // Str: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1272), hom->int_/10, min, max); // Int: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
clif->message(fd, atcmd_output);
-
+
min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
clif->message(fd, atcmd_output);
-
- return 0;
+
+ return true;
}
-ACMD_FUNC(homshuffle)
+ACMD(homshuffle)
{
nullpo_retr(-1, sd);
-
+
if(!sd->hd)
- return -1; // nothing to do
-
+ return false; // nothing to do
+
if(!merc_hom_shuffle(sd->hd))
- return -1;
-
+ return false;
+
clif->message(sd->fd, msg_txt(1275)); // Homunculus stats altered.
- atcommand_homstats(fd, sd, command, message); //Print out the new stats
- return 0;
+ atcommand_homstats(fd, sd, command, message, info); //Print out the new stats
+ return true;
}
/*==========================================
* Show Items DB Info v 1.0
* originally by [Lupus]
*------------------------------------------*/
-ACMD_FUNC(iteminfo)
+ACMD(iteminfo)
{
struct item_data *item_data, *item_array[MAX_SEARCH];
int i, count = 1;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
- return -1;
+ return false;
}
if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
-
+
if (!count) {
clif->message(fd, msg_txt(19)); // Invalid item ID or name.
- return -1;
+ return false;
}
-
+
if (count > MAX_SEARCH) {
sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
clif->message(fd, atcmd_output);
@@ -7254,15 +7190,15 @@ ACMD_FUNC(iteminfo)
for (i = 0; i < count; i++) {
item_data = item_array[i];
sprintf(atcmd_output, msg_txt(1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
- item_data->name,item_data->jname,item_data->slot,item_data->nameid,
- itemdb_typename(item_data->type),
- (item_data->script==NULL)? msg_txt(1278) : msg_txt(1279) // None / With script
- );
+ item_data->name,item_data->jname,item_data->slot,item_data->nameid,
+ itemdb_typename(item_data->type),
+ (item_data->script==NULL)? msg_txt(1278) : msg_txt(1279) // None / With script
+ );
clif->message(fd, atcmd_output);
-
+
sprintf(atcmd_output, msg_txt(1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
clif->message(fd, atcmd_output);
-
+
if (item_data->maxchance == -1)
strcpy(atcmd_output, msg_txt(1281)); // - Available in the shops only.
else if (!battle_config.atcommand_mobinfo_type && item_data->maxchance)
@@ -7270,31 +7206,31 @@ ACMD_FUNC(iteminfo)
else
strcpy(atcmd_output, msg_txt(1283)); // - Monsters don't drop this item.
clif->message(fd, atcmd_output);
-
+
}
- return 0;
+ return true;
}
/*==========================================
* Show who drops the item.
*------------------------------------------*/
-ACMD_FUNC(whodrops)
+ACMD(whodrops)
{
struct item_data *item_data, *item_array[MAX_SEARCH];
int i,j, count = 1;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
- return -1;
+ return false;
}
if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
-
+
if (!count) {
clif->message(fd, msg_txt(19)); // Invalid item ID or name.
- return -1;
+ return false;
}
-
+
if (count > MAX_SEARCH) {
sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
clif->message(fd, atcmd_output);
@@ -7304,14 +7240,14 @@ ACMD_FUNC(whodrops)
item_data = item_array[i];
sprintf(atcmd_output, msg_txt(1285), item_data->jname,item_data->slot); // Item: '%s'[%d]
clif->message(fd, atcmd_output);
-
+
if (item_data->mob[0].chance == 0) {
strcpy(atcmd_output, msg_txt(1286)); // - Item is not dropped by mobs.
clif->message(fd, atcmd_output);
} else {
sprintf(atcmd_output, msg_txt(1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
clif->message(fd, atcmd_output);
-
+
for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
{
sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
@@ -7319,20 +7255,20 @@ ACMD_FUNC(whodrops)
}
}
}
- return 0;
+ return true;
}
-ACMD_FUNC(whereis)
+ACMD(whereis)
{
struct mob_db *mob, *mob_array[MAX_SEARCH];
int count;
int i, j, k;
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
- return -1;
+ return false;
}
-
+
// If monster identifier/name argument is a name
if ((i = mobdb_checkid(atoi(message))))
{
@@ -7340,12 +7276,12 @@ ACMD_FUNC(whereis)
count = 1;
} else
count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
-
+
if (!count) {
clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
- return -1;
+ return false;
}
-
+
if (count > MAX_SEARCH) {
sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
clif->message(fd, atcmd_output);
@@ -7355,7 +7291,7 @@ ACMD_FUNC(whereis)
mob = mob_array[k];
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), mob->jname); // %s spawns in:
clif->message(fd, atcmd_output);
-
+
for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
{
j = map_mapindex2mapid(mob->spawn[i].mapindex);
@@ -7366,14 +7302,14 @@ ACMD_FUNC(whereis)
if (i == 0)
clif->message(fd, msg_txt(1290)); // This monster does not spawn normally.
}
-
- return 0;
+
+ return true;
}
-ACMD_FUNC(version) {
+ACMD(version) {
const char *git = get_git_hash();
const char *svn = get_svn_revision();
-
+
if ( git[0] != HERC_UNKNOWN_VER ) {
sprintf(atcmd_output,msg_txt(1295),git); // Git Hash '%s'
clif->message(fd,atcmd_output);
@@ -7382,8 +7318,8 @@ ACMD_FUNC(version) {
clif->message(fd,atcmd_output);
} else
clif->message(fd,msg_txt(1296)); // Cannot determine version
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -7391,15 +7327,15 @@ ACMD_FUNC(version) {
*------------------------------------------*/
static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
{
-
+
int time, id;
struct map_session_data *pl_sd = (struct map_session_data *)bl;
if (pl_sd == NULL)
return 0;
-
+
id = va_arg(ap, int);
time = va_arg(ap, int);
-
+
if (id != bl->id && !pc_get_group_level(pl_sd)) {
pl_sd->status.manner -= time;
if (pl_sd->status.manner < 0)
@@ -7410,113 +7346,113 @@ static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
return 0;
}
-ACMD_FUNC(mutearea)
+ACMD(mutearea)
{
int time;
nullpo_ret(sd);
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
- return -1;
+ return false;
}
-
+
time = atoi(message);
-
+
map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
- sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
- sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
-
- return 0;
+ sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
+ sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
+
+ return true;
}
-ACMD_FUNC(rates)
+ACMD(rates)
{
char buf[CHAT_SIZE_MAX];
-
+
nullpo_ret(sd);
memset(buf, '\0', sizeof(buf));
-
+
snprintf(buf, CHAT_SIZE_MAX, msg_txt(1298), // Experience rates: Base %.2fx / Job %.2fx
- battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
+ battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
clif->message(fd, buf);
snprintf(buf, CHAT_SIZE_MAX, msg_txt(1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
- battle_config.item_rate_common/100., battle_config.item_rate_heal/100., battle_config.item_rate_use/100., battle_config.item_rate_equip/100., battle_config.item_rate_card/100.);
+ battle_config.item_rate_common/100., battle_config.item_rate_heal/100., battle_config.item_rate_use/100., battle_config.item_rate_equip/100., battle_config.item_rate_card/100.);
clif->message(fd, buf);
snprintf(buf, CHAT_SIZE_MAX, msg_txt(1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
- battle_config.item_rate_common_boss/100., battle_config.item_rate_heal_boss/100., battle_config.item_rate_use_boss/100., battle_config.item_rate_equip_boss/100., battle_config.item_rate_card_boss/100.);
+ battle_config.item_rate_common_boss/100., battle_config.item_rate_heal_boss/100., battle_config.item_rate_use_boss/100., battle_config.item_rate_equip_boss/100., battle_config.item_rate_card_boss/100.);
clif->message(fd, buf);
snprintf(buf, CHAT_SIZE_MAX, msg_txt(1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
- battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
+ battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
clif->message(fd, buf);
-
- return 0;
+
+ return true;
}
/*==========================================
* @me by lordalfa
* => Displays the OUTPUT string on top of the Visible players Heads.
*------------------------------------------*/
-ACMD_FUNC(me)
+ACMD(me)
{
char tempmes[CHAT_SIZE_MAX];
nullpo_retr(-1, sd);
-
+
memset(tempmes, '\0', sizeof(tempmes));
memset(atcmd_output, '\0', sizeof(atcmd_output));
-
+
if (sd->sc.count && //no "chatting" while muted.
(sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
- (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
- return -1;
-
+ (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
+ return false;
+
if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
clif->message(fd, msg_txt(1302)); // Please enter a message (usage: @me <message>).
- return -1;
+ return false;
}
-
+
sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
clif->disp_overhead(&sd->bl, atcmd_output);
-
- return 0;
-
+
+ return true;
+
}
/*==========================================
* @size
* => Resize your character sprite. [Valaris]
*------------------------------------------*/
-ACMD_FUNC(size)
+ACMD(size)
{
int size = 0;
nullpo_retr(-1, sd);
-
+
size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
-
+
if(sd->state.size) {
sd->state.size = SZ_SMALL;
pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
}
-
+
sd->state.size = size;
if( size == SZ_MEDIUM )
clif->specialeffect(&sd->bl,420,AREA);
else if( size == SZ_BIG )
clif->specialeffect(&sd->bl,422,AREA);
-
+
clif->message(fd, msg_txt(1303)); // Size change applied.
- return 0;
+ return true;
}
-ACMD_FUNC(sizeall)
+ACMD(sizeall)
{
int size;
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
-
+
size = atoi(message);
size = cap_value(size,0,2);
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
if( pl_sd->state.size != size ) {
@@ -7524,7 +7460,7 @@ ACMD_FUNC(sizeall)
pl_sd->state.size = SZ_SMALL;
pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
}
-
+
pl_sd->state.size = size;
if( size == SZ_MEDIUM )
clif->specialeffect(&pl_sd->bl,420,AREA);
@@ -7533,40 +7469,40 @@ ACMD_FUNC(sizeall)
}
}
mapit_free(iter);
-
+
clif->message(fd, msg_txt(1303)); // Size change applied.
- return 0;
+ return true;
}
-ACMD_FUNC(sizeguild)
+ACMD(sizeguild)
{
int size = 0, i;
char guild[NAME_LENGTH];
struct map_session_data *pl_sd;
struct guild *g;
nullpo_retr(-1, sd);
-
+
memset(guild, '\0', sizeof(guild));
-
+
if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
clif->message(fd, msg_txt(1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
- return -1;
+ return false;
}
-
+
if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
- return -1;
+ return false;
}
-
+
size = cap_value(size,SZ_SMALL,SZ_BIG);
-
+
for( i = 0; i < g->max_member; i++ ) {
if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
if( pl_sd->state.size ) {
pl_sd->state.size = SZ_SMALL;
pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
}
-
+
pl_sd->state.size = size;
if( size == SZ_MEDIUM )
clif->specialeffect(&pl_sd->bl,420,AREA);
@@ -7574,19 +7510,19 @@ ACMD_FUNC(sizeguild)
clif->specialeffect(&pl_sd->bl,422,AREA);
}
}
-
+
clif->message(fd, msg_txt(1303)); // Size change applied.
- return 0;
+ return true;
}
/*==========================================
* @monsterignore
* => Makes monsters ignore you. [Valaris]
*------------------------------------------*/
-ACMD_FUNC(monsterignore)
+ACMD(monsterignore)
{
nullpo_retr(-1, sd);
-
+
if (!sd->state.monster_ignore) {
sd->state.monster_ignore = 1;
clif->message(sd->fd, msg_txt(1305)); // You are now immune to attacks.
@@ -7594,17 +7530,17 @@ ACMD_FUNC(monsterignore)
sd->state.monster_ignore = 0;
clif->message(sd->fd, msg_txt(1306)); // Returned to normal state.
}
-
- return 0;
+
+ return true;
}
/*==========================================
* @fakename
* => Gives your character a fake name. [Valaris]
*------------------------------------------*/
-ACMD_FUNC(fakename)
+ACMD(fakename)
{
nullpo_retr(-1, sd);
-
+
if( !message || !*message )
{
if( sd->fakename[0] )
@@ -7612,43 +7548,43 @@ ACMD_FUNC(fakename)
sd->fakename[0] = '\0';
clif->charnameack(0, &sd->bl);
clif->message(sd->fd, msg_txt(1307)); // Returned to real name.
- return 0;
+ return true;
}
-
+
clif->message(sd->fd, msg_txt(1308)); // You must enter a name.
- return -1;
+ return false;
}
-
+
if( strlen(message) < 2 )
{
clif->message(sd->fd, msg_txt(1309)); // Fake name must be at least two characters.
- return -1;
+ return false;
}
-
+
safestrncpy(sd->fakename, message, sizeof(sd->fakename));
clif->charnameack(0, &sd->bl);
clif->message(sd->fd, msg_txt(1310)); // Fake name enabled.
-
- return 0;
+
+ return true;
}
/*==========================================
* Ragnarok Resources
*------------------------------------------*/
-ACMD_FUNC(mapflag) {
+ACMD(mapflag) {
#define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd)
#define setflag( cmd ) \
- if ( strcmp( flag_name , #cmd ) == 0 ){\
- map[ sd->bl.m ].flag.cmd = flag;\
- sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
- clif->message(sd->fd,atcmd_output);\
- return 0;\
- }
- char flag_name[100];
+if ( strcmp( flag_name , #cmd ) == 0 ){\
+map[ sd->bl.m ].flag.cmd = flag;\
+sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
+clif->message(sd->fd,atcmd_output);\
+return true;\
+}
+ char flag_name[100];
short flag=0,i;
nullpo_retr(-1, sd);
memset(flag_name, '\0', sizeof(flag_name));
-
+
if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
clif->message(sd->fd,msg_txt(1311)); // Enabled Mapflags in this map:
clif->message(sd->fd,"----------------------------------");
@@ -7660,7 +7596,7 @@ ACMD_FUNC(mapflag) {
checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
- checkflag(nogo); checkflag(nobaseexp);
+ checkflag(nobaseexp);
checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
checkflag(nodrop); checkflag(novending); checkflag(loadevent);
checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
@@ -7670,7 +7606,7 @@ ACMD_FUNC(mapflag) {
return 1;
}
for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
-
+
if ( strcmp( flag_name , "gvg" ) == 0 ) {
if( flag && !map[sd->bl.m].flag.gvg )
map_zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME));
@@ -7696,7 +7632,7 @@ ACMD_FUNC(mapflag) {
setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
- setflag(nogo); setflag(nobaseexp);
+ setflag(nobaseexp);
setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
setflag(nodrop); setflag(novending); setflag(loadevent);
setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
@@ -7709,56 +7645,56 @@ ACMD_FUNC(mapflag) {
clif->message(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
clif->message(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
clif->message(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
- clif->message(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
+ clif->message(sd->fd,"fog, fireworks, sakura, leaves, nobaseexp, nojobexp, nomobloot,");
clif->message(sd->fd,"nomvploot, nightenabled, nodrop, novending, loadevent, nochat, partylock,");
clif->message(sd->fd,"guildlock, src4instance");
-
+
#undef checkflag
#undef setflag
-
- return 0;
+
+ return true;
}
/*===================================
* Remove some messages
*-----------------------------------*/
-ACMD_FUNC(showexp)
+ACMD(showexp)
{
if (sd->state.showexp) {
sd->state.showexp = 0;
clif->message(fd, msg_txt(1316)); // Gained exp will not be shown.
- return 0;
+ return true;
}
-
+
sd->state.showexp = 1;
clif->message(fd, msg_txt(1317)); // Gained exp is now shown.
- return 0;
+ return true;
}
-ACMD_FUNC(showzeny)
+ACMD(showzeny)
{
if (sd->state.showzeny) {
sd->state.showzeny = 0;
clif->message(fd, msg_txt(1318)); // Gained zeny will not be shown.
- return 0;
+ return true;
}
-
+
sd->state.showzeny = 1;
clif->message(fd, msg_txt(1319)); // Gained zeny is now shown.
- return 0;
+ return true;
}
-ACMD_FUNC(showdelay)
+ACMD(showdelay)
{
if (sd->state.showdelay) {
sd->state.showdelay = 0;
clif->message(fd, msg_txt(1320)); // Skill delay failures will not be shown.
- return 0;
+ return true;
}
-
+
sd->state.showdelay = 1;
clif->message(fd, msg_txt(1321)); // Skill delay failures are now shown.
- return 0;
+ return true;
}
/*==========================================
@@ -7770,78 +7706,78 @@ ACMD_FUNC(showdelay)
* @reject - reject invitation
* @leave - leave duel
*------------------------------------------*/
-ACMD_FUNC(invite)
+ACMD(invite)
{
unsigned int did = sd->duel_group;
struct map_session_data *target_sd = map_nick2sd((char *)message);
-
+
if(did == 0) {
// "Duel: @invite without @duel."
clif->message(fd, msg_txt(350));
- return 0;
+ return true;
}
-
+
if(duel_list[did].max_players_limit > 0 &&
- duel_list[did].members_count >= duel_list[did].max_players_limit) {
-
+ duel_list[did].members_count >= duel_list[did].max_players_limit) {
+
// "Duel: Limit of players is reached."
clif->message(fd, msg_txt(351));
- return 0;
+ return true;
}
-
+
if(target_sd == NULL) {
// "Duel: Player not found."
clif->message(fd, msg_txt(352));
- return 0;
+ return true;
}
-
+
if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
// "Duel: Player already in duel."
clif->message(fd, msg_txt(353));
- return 0;
+ return true;
}
-
+
if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
{
sprintf(atcmd_output, msg_txt(364), message);
clif->message(fd, atcmd_output);
- return 0;
+ return true;
}
-
+
duel_invite(did, sd, target_sd);
// "Duel: Invitation has been sent."
clif->message(fd, msg_txt(354));
- return 0;
+ return true;
}
-ACMD_FUNC(duel)
+ACMD(duel)
{
unsigned int maxpl = 0;
-
+
if(sd->duel_group > 0) {
duel_showinfo(sd->duel_group, sd);
- return 0;
+ return true;
}
-
+
if(sd->duel_invite > 0) {
// "Duel: @duel without @reject."
clif->message(fd, msg_txt(355));
- return 0;
+ return true;
}
-
+
if(!duel_checktime(sd)) {
char output[CHAT_SIZE_MAX];
// "Duel: You can take part in duel only one time per %d minutes."
sprintf(output, msg_txt(356), battle_config.duel_time_interval);
clif->message(fd, output);
- return 0;
+ return true;
}
-
+
if( message[0] ) {
if(sscanf(message, "%d", &maxpl) >= 1) {
if(maxpl < 2 || maxpl > 65535) {
clif->message(fd, msg_txt(357)); // "Duel: Invalid value."
- return 0;
+ return true;
}
duel_create(sd, maxpl);
} else {
@@ -7852,7 +7788,7 @@ ACMD_FUNC(duel)
if((newduel = duel_create(sd, 2)) != -1) {
if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
clif->message(fd, msg_txt(353)); // "Duel: Player already in duel."
- return 0;
+ return true;
}
duel_invite(newduel, sd, target_sd);
clif->message(fd, msg_txt(354)); // "Duel: Invitation has been sent."
@@ -7860,87 +7796,87 @@ ACMD_FUNC(duel)
} else {
// "Duel: Player not found."
clif->message(fd, msg_txt(352));
- return 0;
+ return true;
}
}
} else
duel_create(sd, 0);
-
- return 0;
+
+ return true;
}
-ACMD_FUNC(leave)
+ACMD(leave)
{
if(sd->duel_group <= 0) {
// "Duel: @leave without @duel."
clif->message(fd, msg_txt(358));
- return 0;
+ return true;
}
-
+
duel_leave(sd->duel_group, sd);
clif->message(fd, msg_txt(359)); // "Duel: You left the duel."
- return 0;
+ return true;
}
-ACMD_FUNC(accept)
+ACMD(accept)
{
if(!duel_checktime(sd)) {
char output[CHAT_SIZE_MAX];
// "Duel: You can take part in duel only one time per %d minutes."
sprintf(output, msg_txt(356), battle_config.duel_time_interval);
clif->message(fd, output);
- return 0;
+ return true;
}
-
+
if(sd->duel_invite <= 0) {
// "Duel: @accept without invititation."
clif->message(fd, msg_txt(360));
- return 0;
+ return true;
}
-
+
if( duel_list[sd->duel_invite].max_players_limit > 0 && duel_list[sd->duel_invite].members_count >= duel_list[sd->duel_invite].max_players_limit )
{
// "Duel: Limit of players is reached."
clif->message(fd, msg_txt(351));
- return 0;
+ return true;
}
-
+
duel_accept(sd->duel_invite, sd);
// "Duel: Invitation has been accepted."
clif->message(fd, msg_txt(361));
- return 0;
+ return true;
}
-ACMD_FUNC(reject)
+ACMD(reject)
{
if(sd->duel_invite <= 0) {
// "Duel: @reject without invititation."
clif->message(fd, msg_txt(362));
- return 0;
+ return true;
}
-
+
duel_reject(sd->duel_invite, sd);
// "Duel: Invitation has been rejected."
clif->message(fd, msg_txt(363));
- return 0;
+ return true;
}
/*===================================
* Cash Points
*-----------------------------------*/
-ACMD_FUNC(cash)
+ACMD(cash)
{
char output[128];
int value;
int ret=0;
nullpo_retr(-1, sd);
-
+
if( !message || !*message || (value = atoi(message)) == 0 ) {
clif->message(fd, msg_txt(1322)); // Please enter an amount.
- return -1;
+ return false;
}
-
+
if( !strcmpi(command+1,"cash") )
{
if( value > 0 ) {
@@ -7973,70 +7909,70 @@ ACMD_FUNC(cash)
else clif->message(fd, msg_txt(41)); // Unable to decrease the number/value.
}
}
-
- return 0;
+
+ return true;
}
// @clone/@slaveclone/@evilclone <playername> [Valaris]
-ACMD_FUNC(clone)
+ACMD(clone)
{
int x=0,y=0,flag=0,master=0,i=0;
struct map_session_data *pl_sd=NULL;
-
+
if (!message || !*message) {
clif->message(sd->fd,msg_txt(1323)); // You must enter a player name or ID.
- return 0;
+ return true;
}
-
+
if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
- return 0;
+ return true;
}
-
+
if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
clif->message(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
- return 0;
+ return true;
}
-
+
if (strcmpi(command+1, "clone") == 0)
flag = 1;
else if (strcmpi(command+1, "slaveclone") == 0) {
flag = 2;
if(pc_isdead(sd)){
clif->message(fd, msg_txt(129+flag*2));
- return 0;
+ return true;
}
master = sd->bl.id;
if (battle_config.atc_slave_clone_limit
&& mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
clif->message(fd, msg_txt(127)); // You've reached your slave clones limit.
- return 0;
+ return true;
}
}
-
+
do {
x = sd->bl.x + (rnd() % 10 - 5);
y = sd->bl.y + (rnd() % 10 - 5);
} while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
-
+
if (i >= 10) {
x = sd->bl.x;
y = sd->bl.y;
}
-
+
if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
clif->message(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
- return 0;
+ return true;
}
clif->message(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
- return 0;
+ return true;
}
/*=====================================
* Autorejecting Invites/Deals [LuzZza]
* Usage: @noask
*-------------------------------------*/
-ACMD_FUNC(noask)
+ACMD(noask)
{
if(sd->state.noask) {
clif->message(fd, msg_txt(391)); // Autorejecting is deactivated.
@@ -8045,58 +7981,58 @@ ACMD_FUNC(noask)
clif->message(fd, msg_txt(390)); // Autorejecting is activated.
sd->state.noask = 1;
}
-
- return 0;
+
+ return true;
}
/*=====================================
* Send a @request message to all GMs of lowest_gm_level.
* Usage: @request <petition>
*-------------------------------------*/
-ACMD_FUNC(request)
+ACMD(request)
{
if (!message || !*message) {
clif->message(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
- return -1;
+ return false;
}
-
+
sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
clif->disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
clif->message(sd->fd,msg_txt(279)); // @request sent.
- return 0;
+ return true;
}
/*==========================================
* Feel (SG save map) Reset [HiddenDragon]
*------------------------------------------*/
-ACMD_FUNC(feelreset)
+ACMD(feelreset)
{
pc_resetfeel(sd);
clif->message(fd, msg_txt(1324)); // Reset 'Feeling' maps.
-
- return 0;
+
+ return true;
}
/*==========================================
* AUCTION SYSTEM
*------------------------------------------*/
-ACMD_FUNC(auction)
+ACMD(auction)
{
nullpo_ret(sd);
-
+
clif->auction_openwindow(sd);
-
- return 0;
+
+ return true;
}
/*==========================================
* Kill Steal Protection
*------------------------------------------*/
-ACMD_FUNC(ksprotection)
+ACMD(ksprotection)
{
nullpo_retr(-1,sd);
-
+
if( sd->state.noks ) {
sd->state.noks = 0;
clif->message(fd, msg_txt(1325)); // [ K.S Protection Inactive ]
@@ -8121,15 +8057,15 @@ ACMD_FUNC(ksprotection)
else
clif->message(fd, msg_txt(1329)); // Usage: @noks <self|party|guild>
}
- return 0;
+ return true;
}
/*==========================================
* Map Kill Steal Protection Setting
*------------------------------------------*/
-ACMD_FUNC(allowks)
+ACMD(allowks)
{
nullpo_retr(-1,sd);
-
+
if( map[sd->bl.m].flag.allowks ) {
map[sd->bl.m].flag.allowks = 0;
clif->message(fd, msg_txt(1330)); // [ Map K.S Protection Active ]
@@ -8137,27 +8073,27 @@ ACMD_FUNC(allowks)
map[sd->bl.m].flag.allowks = 1;
clif->message(fd, msg_txt(1331)); // [ Map K.S Protection Inactive ]
}
- return 0;
+ return true;
}
-ACMD_FUNC(resetstat)
+ACMD(resetstat)
{
nullpo_retr(-1, sd);
-
+
pc_resetstate(sd);
sprintf(atcmd_output, msg_txt(207), sd->status.name);
clif->message(fd, atcmd_output);
- return 0;
+ return true;
}
-ACMD_FUNC(resetskill)
+ACMD(resetskill)
{
nullpo_retr(-1,sd);
-
+
pc_resetskill(sd,1);
sprintf(atcmd_output, msg_txt(206), sd->status.name);
clif->message(fd, atcmd_output);
- return 0;
+ return true;
}
/*==========================================
@@ -8165,16 +8101,16 @@ ACMD_FUNC(resetskill)
* #cartlist: Displays contents of target's cart.
* #itemlist: Displays contents of target's inventory.
*------------------------------------------*/
-ACMD_FUNC(itemlist)
+ACMD(itemlist)
{
int i, j, count, counter;
const char* location;
const struct item* items;
int size;
StringBuf buf;
-
+
nullpo_retr(-1, sd);
-
+
if( strcmp(command+1, "storagelist") == 0 )
{
location = "storage";
@@ -8182,49 +8118,49 @@ ACMD_FUNC(itemlist)
size = MAX_STORAGE;
}
else
- if( strcmp(command+1, "cartlist") == 0 )
- {
- location = "cart";
- items = sd->status.cart;
- size = MAX_CART;
- }
- else
- if( strcmp(command+1, "itemlist") == 0 )
- {
- location = "inventory";
- items = sd->status.inventory;
- size = MAX_INVENTORY;
- }
- else
- return 1;
-
+ if( strcmp(command+1, "cartlist") == 0 )
+ {
+ location = "cart";
+ items = sd->status.cart;
+ size = MAX_CART;
+ }
+ else
+ if( strcmp(command+1, "itemlist") == 0 )
+ {
+ location = "inventory";
+ items = sd->status.inventory;
+ size = MAX_INVENTORY;
+ }
+ else
+ return 1;
+
StringBuf_Init(&buf);
-
+
count = 0; // total slots occupied
counter = 0; // total items found
for( i = 0; i < size; ++i )
{
const struct item* it = &items[i];
struct item_data* itd;
-
+
if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
continue;
-
+
counter += it->amount;
count++;
-
+
if( count == 1 )
{
StringBuf_Printf(&buf, msg_txt(1332), location, sd->status.name); // ------ %s items list of '%s' ------
clif->message(fd, StringBuf_Value(&buf));
StringBuf_Clear(&buf);
}
-
+
if( it->refine )
StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
else
StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
-
+
if( it->equip )
{
char equipstr[CHAT_SIZE_MAX];
@@ -8261,10 +8197,10 @@ ACMD_FUNC(itemlist)
equipstr[strlen(equipstr) - 2] = '\0';
StringBuf_AppendStr(&buf, equipstr);
}
-
+
clif->message(fd, StringBuf_Value(&buf));
StringBuf_Clear(&buf);
-
+
if( it->card[0] == CARD0_PET )
{// pet egg
if (it->card[3])
@@ -8273,60 +8209,60 @@ ACMD_FUNC(itemlist)
StringBuf_Printf(&buf, msg_txt(1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
}
else
- if(it->card[0] == CARD0_FORGE)
- {// forged item
- StringBuf_Printf(&buf, msg_txt(1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d)
- }
- else
- if(it->card[0] == CARD0_CREATE)
- {// created item
- StringBuf_Printf(&buf, msg_txt(1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
- }
- else
- {// normal item
- int counter2 = 0;
-
- for( j = 0; j < itd->slot; ++j )
- {
- struct item_data* card;
-
- if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
- continue;
-
- counter2++;
-
- if( counter2 == 1 )
- StringBuf_AppendStr(&buf, msg_txt(1352)); // -> (card(s):
-
- if( counter2 != 1 )
- StringBuf_AppendStr(&buf, ", ");
-
- StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
+ if(it->card[0] == CARD0_FORGE)
+ {// forged item
+ StringBuf_Printf(&buf, msg_txt(1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d)
}
-
- if( counter2 > 0 )
- StringBuf_AppendStr(&buf, ")");
- }
-
+ else
+ if(it->card[0] == CARD0_CREATE)
+ {// created item
+ StringBuf_Printf(&buf, msg_txt(1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
+ }
+ else
+ {// normal item
+ int counter2 = 0;
+
+ for( j = 0; j < itd->slot; ++j )
+ {
+ struct item_data* card;
+
+ if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
+ continue;
+
+ counter2++;
+
+ if( counter2 == 1 )
+ StringBuf_AppendStr(&buf, msg_txt(1352)); // -> (card(s):
+
+ if( counter2 != 1 )
+ StringBuf_AppendStr(&buf, ", ");
+
+ StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
+ }
+
+ if( counter2 > 0 )
+ StringBuf_AppendStr(&buf, ")");
+ }
+
if( StringBuf_Length(&buf) > 0 )
clif->message(fd, StringBuf_Value(&buf));
-
+
StringBuf_Clear(&buf);
}
-
+
if( count == 0 )
StringBuf_Printf(&buf, msg_txt(1353), location); // No item found in this player's %s.
else
StringBuf_Printf(&buf, msg_txt(1354), counter, count, location); // %d item(s) found in %d %s slots.
-
+
clif->message(fd, StringBuf_Value(&buf));
-
+
StringBuf_Destroy(&buf);
-
- return 0;
+
+ return true;
}
-ACMD_FUNC(stats)
+ACMD(stats)
{
char job_jobname[100];
char output[CHAT_SIZE_MAX];
@@ -8353,10 +8289,10 @@ ACMD_FUNC(stats)
{ "JobChangeLvl (3rd) - %d", 0 },
{ NULL, 0 }
};
-
+
memset(job_jobname, '\0', sizeof(job_jobname));
memset(output, '\0', sizeof(output));
-
+
//direct array initialization with variables is not standard C compliant.
output_table[0].value = sd->status.base_level;
output_table[1].format = job_jobname;
@@ -8375,34 +8311,34 @@ ACMD_FUNC(stats)
output_table[13].value = sd->status.skill_point;
output_table[14].value = sd->change_level_2nd;
output_table[15].value = sd->change_level_3rd;
-
+
sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
-
+
clif->message(fd, output);
-
+
for (i = 0; output_table[i].format != NULL; i++) {
sprintf(output, output_table[i].format, output_table[i].value);
clif->message(fd, output);
}
-
- return 0;
+
+ return true;
}
-ACMD_FUNC(delitem)
+ACMD(delitem)
{
char item_name[100];
int nameid, amount = 0, total, idx;
struct item_data* id;
-
+
nullpo_retr(-1, sd);
-
+
if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
{
clif->message(fd, msg_txt(1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
- return -1;
+ return false;
}
-
+
if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
{
nameid = id->nameid;
@@ -8410,29 +8346,29 @@ ACMD_FUNC(delitem)
else
{
clif->message(fd, msg_txt(19)); // Invalid item ID or name.
- return -1;
+ return false;
}
-
+
total = amount;
-
+
// delete items
while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
{
int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
-
+
if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
{// delete pet
intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
}
pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
-
+
amount-= delamount;
}
-
+
// notify target
sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
clif->message(sd->fd, atcmd_output);
-
+
// notify source
if( amount == total )
{
@@ -8448,18 +8384,18 @@ ACMD_FUNC(delitem)
sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
clif->message(fd, atcmd_output);
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Custom Fonts
*------------------------------------------*/
-ACMD_FUNC(font)
+ACMD(font)
{
int font_id;
nullpo_retr(-1,sd);
-
+
font_id = atoi(message);
if( font_id == 0 )
{
@@ -8485,8 +8421,8 @@ ACMD_FUNC(font)
}
else
clif->message(fd, msg_txt(1361)); // Already using this font.
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -8499,15 +8435,15 @@ static void atcommand_commands_sub(struct map_session_data* sd, const int fd, At
AtCommandInfo* cmd;
DBIterator *iter = db_iterator(atcommand_db);
int count = 0;
-
+
memset(line_buff,' ',CHATBOX_SIZE);
line_buff[CHATBOX_SIZE-1] = 0;
-
+
clif->message(fd, msg_txt(273)); // "Commands available:"
-
+
for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
unsigned int slen = 0;
-
+
switch( type ) {
case COMMAND_CHARCOMMAND:
if( cmd->char_groups[sd->group_pos] == 0 )
@@ -8520,10 +8456,10 @@ static void atcommand_commands_sub(struct map_session_data* sd, const int fd, At
default:
continue;
}
-
-
+
+
slen = strlen(cmd->command);
-
+
// flush the text buffer if this command won't fit into it
if ( slen + cur - line_buff >= CHATBOX_SIZE )
{
@@ -8532,41 +8468,41 @@ static void atcommand_commands_sub(struct map_session_data* sd, const int fd, At
memset(line_buff,' ',CHATBOX_SIZE);
line_buff[CHATBOX_SIZE-1] = 0;
}
-
+
memcpy(cur,cmd->command,slen);
cur += slen+(10-slen%10);
-
+
count++;
}
dbi_destroy(iter);
clif->message(fd,line_buff);
-
+
sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
clif->message(fd, atcmd_output);
-
+
return;
}
/*==========================================
* @commands Lists available @ commands to you
*------------------------------------------*/
-ACMD_FUNC(commands)
+ACMD(commands)
{
atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
- return 0;
+ return true;
}
/*==========================================
* @charcommands Lists available # commands to you
*------------------------------------------*/
-ACMD_FUNC(charcommands)
+ACMD(charcommands)
{
atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
- return 0;
+ return true;
}
/* for new mounts */
-ACMD_FUNC(mount2) {
-
+ACMD(mount2) {
+
clif->message(sd->fd,msg_txt(1362)); // NOTICE: If you crash with mount your LUA is outdated.
if( !(sd->sc.option&OPTION_MOUNTING) ) {
clif->message(sd->fd,msg_txt(1363)); // You have mounted.
@@ -8575,72 +8511,72 @@ ACMD_FUNC(mount2) {
clif->message(sd->fd,msg_txt(1364)); // You have released your mount.
pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
}
- return 0;
+ return true;
}
-ACMD_FUNC(accinfo) {
+ACMD(accinfo) {
char query[NAME_LENGTH];
-
+
if (!message || !*message || strlen(message) > NAME_LENGTH ) {
clif->message(fd, msg_txt(1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
clif->message(fd, msg_txt(1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
- return -1;
+ return false;
}
-
+
//remove const type
safestrncpy(query, message, NAME_LENGTH);
-
+
intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query );
-
- return 0;
+
+ return true;
}
/* [Ind] */
-ACMD_FUNC(set) {
+ACMD(set) {
char reg[32], val[128];
struct script_data* data;
int toset = 0, len;
bool is_str = false;
-
+
if( !message || !*message || (toset = sscanf(message, "%31s %128[^\n]s", reg, val)) < 1 ) {
clif->message(fd, msg_txt(1367)); // Usage: @set <variable name> <value>
clif->message(fd, msg_txt(1368)); // Usage: ex. "@set PoringCharVar 50"
clif->message(fd, msg_txt(1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
clif->message(fd, msg_txt(1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
- return -1;
+ return false;
}
-
+
/* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
if( reg[0] == '.' ) {
clif->message(fd, msg_txt(1371)); // NPC variables may not be used with @set.
- return -1;
+ return false;
} else if( reg[0] == '\'' ) {
clif->message(fd, msg_txt(1372)); // Instance variables may not be used with @set.
- return -1;
+ return false;
}
-
+
is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
-
+
if( ( len = strlen(val) ) > 1 ) {
if( val[0] == '"' && val[len-1] == '"') {
val[len-1] = '\0'; //Strip quotes.
memmove(val, val+1, len-1);
}
}
-
+
if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
if( is_str )
set_var(sd, reg, (void*) val);
else
- set_var(sd, reg, (void*)__64BPRTSIZE((atoi(val))));
-
+ set_var(sd, reg, (void*)__64BPTRSIZE((atoi(val))));
+
}
-
+
CREATE(data, struct script_data,1);
-
-
+
+
if( is_str ) {// string variable
-
+
switch( reg[0] ) {
case '@':
data->u.str = pc_readregstr(sd, add_str(reg));
@@ -8658,7 +8594,7 @@ ACMD_FUNC(set) {
data->u.str = pc_readglobalreg_str(sd, reg);
break;
}
-
+
if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
data->type = C_CONSTSTR;
data->u.str = "";
@@ -8666,9 +8602,9 @@ ACMD_FUNC(set) {
data->type = C_STR;
data->u.str = aStrdup(data->u.str);
}
-
+
} else {// integer variable
-
+
data->type = C_INT;
switch( reg[0] ) {
case '@':
@@ -8687,10 +8623,10 @@ ACMD_FUNC(set) {
data->u.num = pc_readglobalreg(sd, reg);
break;
}
-
+
}
-
-
+
+
switch( data->type ) {
case C_INT:
sprintf(atcmd_output,msg_txt(1373),reg,data->u.num); // %s value is now :%d
@@ -8705,23 +8641,23 @@ ACMD_FUNC(set) {
sprintf(atcmd_output,msg_txt(1376),reg,data->type); // %s data type is not supported :%u
break;
}
-
+
clif->message(fd, atcmd_output);
-
+
aFree(data);
-
- return 0;
+
+ return true;
}
-ACMD_FUNC(reloadquestdb) {
+ACMD(reloadquestdb) {
do_reload_quest();
clif->message(fd, msg_txt(1377)); // Quest database has been reloaded.
- return 0;
+ return true;
}
-ACMD_FUNC(addperm) {
+ACMD(addperm) {
int perm_size = ARRAYLENGTH(pc_g_permission_name);
bool add = (strcmpi(command+1, "addperm") == 0) ? true : false;
int i;
-
+
if( !message || !*message ) {
sprintf(atcmd_output, msg_txt(1378),command); // Usage: %s <permission_name>
clif->message(fd, atcmd_output);
@@ -8730,11 +8666,11 @@ ACMD_FUNC(addperm) {
sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
clif->message(fd, atcmd_output);
}
- return -1;
+ return false;
}
-
+
ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
-
+
if( i == perm_size ) {
sprintf(atcmd_output,msg_txt(1380),message); // '%s' is not a known permission.
clif->message(fd, atcmd_output);
@@ -8743,13 +8679,13 @@ ACMD_FUNC(addperm) {
sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
clif->message(fd, atcmd_output);
}
- return -1;
+ return false;
}
-
+
if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
sprintf(atcmd_output, msg_txt(1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
clif->message(fd, atcmd_output);
- return -1;
+ return false;
} else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
sprintf(atcmd_output, msg_txt(1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
clif->message(fd, atcmd_output);
@@ -8761,106 +8697,106 @@ ACMD_FUNC(addperm) {
clif->message(fd, atcmd_output);
}
}
-
- return -1;
+
+ return false;
}
-
+
if( add )
sd->permissions |= pc_g_permission_name[i].permission;
else
sd->permissions &=~ pc_g_permission_name[i].permission;
-
-
+
+
sprintf(atcmd_output, msg_txt(1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
clif->message(fd, atcmd_output);
-
- return 0;
+
+ return true;
}
-ACMD_FUNC(unloadnpcfile) {
-
+ACMD(unloadnpcfile) {
+
if( !message || !*message ) {
clif->message(fd, msg_txt(1385)); // Usage: @unloadnpcfile <file name>
- return -1;
+ return false;
}
-
+
if( npc_unloadfile(message) )
clif->message(fd, msg_txt(1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
else {
clif->message(fd, msg_txt(1387)); // File not found.
- return -1;
+ return false;
}
- return 0;
+ return true;
}
-ACMD_FUNC(cart) {
+ACMD(cart) {
#define MC_CART_MDFY(x) \
- sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
- sd->status.skill[MC_PUSHCART].lv = x?1:0; \
- sd->status.skill[MC_PUSHCART].flag = x?1:0;
-
+sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
+sd->status.skill[MC_PUSHCART].lv = x?1:0; \
+sd->status.skill[MC_PUSHCART].flag = x?1:0;
+
int val = atoi(message);
bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true;
-
+
if( !message || !*message || val < 0 || val > MAX_CARTS ) {
sprintf(atcmd_output, msg_txt(1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
-
+
if( val == 0 && !pc_iscarton(sd) ) {
clif->message(fd, msg_txt(1391)); // You do not possess a cart to be removed
- return -1;
+ return false;
}
-
+
if( need_skill ) {
MC_CART_MDFY(1);
}
-
+
if( pc_setcart(sd, val) ) {
if( need_skill ) {
MC_CART_MDFY(0);
}
- return -1;/* @cart failed */
+ return false;/* @cart failed */
}
-
+
if( need_skill ) {
MC_CART_MDFY(0);
}
-
+
clif->message(fd, msg_txt(1392)); // Cart Added
-
- return 0;
- #undef MC_CART_MDFY
+
+ return true;
+#undef MC_CART_MDFY
}
/* [Ind/Hercules] */
-ACMD_FUNC(join) {
+ACMD(join) {
struct hChSysCh *channel;
char name[HCHSYS_NAME_LENGTH], pass[HCHSYS_NAME_LENGTH];
if( !message || !*message || sscanf(message, "%s %s", name, pass) < 1 ) {
sprintf(atcmd_output, msg_txt(1399),command); // Unknown Channel (usage: %s <#channel_name>)
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
if( hChSys.local && strcmpi(name + 1, hChSys.local_name) == 0 ) {
if( !map[sd->bl.m].channel ) {
clif->chsys_mjoin(sd);
- return 0;
+ return true;
} else
channel = map[sd->bl.m].channel;
} else if( hChSys.ally && sd->status.guild_id && strcmpi(name + 1, hChSys.ally_name) == 0 ) {
struct guild *g = sd->guild;
- if( !g ) return -1;/* unlikely, but we wont let it crash anyway. */
+ if( !g ) return false;/* unlikely, but we wont let it crash anyway. */
channel = (struct hChSysCh *)g->channel;
} else if( !( channel = strdb_get(clif->channel_db, name + 1) ) ) {
sprintf(atcmd_output, msg_txt(1400),name,command); // Unknown Channel '%s' (usage: %s <#channel_name>)
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
if( idb_exists(channel->users, sd->status.char_id) ) {
sprintf(atcmd_output, msg_txt(1434),name); // You're already in the '%s' channel
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
if( channel->pass[0] != '\0' && strcmp(channel->pass,pass) != 0 ) {
if( pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
@@ -8868,10 +8804,16 @@ ACMD_FUNC(join) {
} else {
sprintf(atcmd_output, msg_txt(1401),name,command); // '%s' Channel is password protected (usage: %s <#channel_name> <password>)
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
}
+ if( channel->banned && idb_exists(channel->banned, sd->status.account_id) ) {
+ sprintf(atcmd_output, msg_txt(1438),name); // You cannot join the '%s' channel because you've been banned from it
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
if( !( channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) {
sprintf(atcmd_output, msg_txt(1403),name); // You're now in the '%s' channel
clif->message(fd, atcmd_output);
@@ -8879,7 +8821,7 @@ ACMD_FUNC(join) {
clif->chsys_join(channel,sd);
- return 0;
+ return true;
}
/* [Ind/Hercules] */
static inline void atcmd_channel_help(int fd, const char *command, bool can_create) {
@@ -8911,10 +8853,29 @@ static inline void atcmd_channel_help(int fd, const char *command, bool can_crea
sprintf(atcmd_output, msg_txt(1429),command);// -- %s unbind
clif->message(fd, atcmd_output);
clif->message(fd, msg_txt(1430));// - unbinds your global chat from its attached channel (if binded)
-
+ sprintf(atcmd_output, msg_txt(1429),command);// -- %s unbind
+ clif->message(fd, atcmd_output);
+ if( can_create ) {
+ sprintf(atcmd_output, msg_txt(1456),command);// -- %s ban <channel name> <character name>
+ clif->message(fd, atcmd_output);
+ clif->message(fd, msg_txt(1457));// - bans <character name> from <channel name> channel
+ sprintf(atcmd_output, msg_txt(1458),command);// -- %s banlist <channel name>
+ clif->message(fd, atcmd_output);
+ clif->message(fd, msg_txt(1459));// - lists all banned characters from <channel name> channel
+ sprintf(atcmd_output, msg_txt(1460),command);// -- %s unban <channel name> <character name>
+ clif->message(fd, atcmd_output);
+ clif->message(fd, msg_txt(1461));// - unbans <character name> from <channel name> channel
+ sprintf(atcmd_output, msg_txt(1467),command);// -- %s unbanall <channel name>
+ clif->message(fd, atcmd_output);
+ clif->message(fd, msg_txt(1468));// - unbans everyone from <channel name>
+ sprintf(atcmd_output, msg_txt(1462),command);// -- %s setopt <channel name> <option name> <option value>
+ clif->message(fd, atcmd_output);
+ clif->message(fd, msg_txt(1463));// - adds or removes <option name> with <option value> to <channel name> channel
+ }
+
}
/* [Ind/Hercules] */
-ACMD_FUNC(channel) {
+ACMD(channel) {
struct hChSysCh *channel;
char key[HCHSYS_NAME_LENGTH], sub1[HCHSYS_NAME_LENGTH], sub2[HCHSYS_NAME_LENGTH], sub3[HCHSYS_NAME_LENGTH];
unsigned char k = 0;
@@ -8922,29 +8883,29 @@ ACMD_FUNC(channel) {
if( !message || !*message || sscanf(message, "%s %s %s %s", key, sub1, sub2, sub3) < 1 ) {
atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ));
- return 0;
+ return true;
}
if( strcmpi(key,"create") == 0 && ( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) ) {
if( sub1[0] != '#' ) {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
- return -1;
+ return false;
} else if ( strlen(sub1) < 3 || strlen(sub1) > HCHSYS_NAME_LENGTH ) {
sprintf(atcmd_output, msg_txt(1406), HCHSYS_NAME_LENGTH);// Channel length must be between 3 and %d
clif->message(fd, atcmd_output);
- return -1;
+ return false;
} else if ( sub3[0] != '\0' ) {
clif->message(fd, msg_txt(1408)); // Channel password may not contain spaces
- return -1;
+ return false;
}
if( strcmpi(sub1 + 1,hChSys.local_name) == 0 || strcmpi(sub1 + 1,hChSys.ally_name) == 0 || strdb_exists(clif->channel_db, sub1 + 1) ) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
CREATE( channel, struct hChSysCh, 1 );
-
+
clif->chsys_create(channel,sub1 + 1,sub2,0);
channel->owner = sd->status.char_id;
@@ -8982,12 +8943,12 @@ ACMD_FUNC(channel) {
}
if( hChSys.ally && sd->status.guild_id ) {
struct guild *g = sd->guild;
- if( !g ) return -1;
+ if( !g ) { dbi_destroy(iter); return false; }
sprintf(atcmd_output, msg_txt(1409), hChSys.ally_name, db_size(((struct hChSysCh *)g->channel)->users));// - #%s ( %d users )
clif->message(fd, atcmd_output);
}
for(channel = dbi_first(iter); dbi_exists(iter); channel = dbi_next(iter)) {
- if( show_all || channel->type == hChSys_PUBLIC ) {
+ if( show_all || channel->type == hChSys_PUBLIC || channel->type == hChSys_IRC ) {
sprintf(atcmd_output, msg_txt(1409), channel->name, db_size(channel->users));// - #%s ( %d users )
clif->message(fd, atcmd_output);
}
@@ -8998,19 +8959,19 @@ ACMD_FUNC(channel) {
if( sub1[0] != '#' ) {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
- return -1;
+ return false;
}
if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
for( k = 0; k < hChSys.colors_count; k++ ) {
@@ -9020,7 +8981,7 @@ ACMD_FUNC(channel) {
if( k == hChSys.colors_count ) {
sprintf(atcmd_output, msg_txt(1411), sub2);// Unknown color '%s'
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
channel->color = k;
sprintf(atcmd_output, msg_txt(1413),sub1,hChSys.colors_name[k]);// '%s' channel color updated to '%s'
@@ -9029,7 +8990,7 @@ ACMD_FUNC(channel) {
if( sub1[0] != '#' ) {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
- return -1;
+ return false;
}
for(k = 0; k < sd->channel_count; k++) {
@@ -9039,7 +9000,7 @@ ACMD_FUNC(channel) {
if( k == sd->channel_count ) {
sprintf(atcmd_output, msg_txt(1425),sub1);// You're not part of the '%s' channel
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
clif->chsys_left(sd->channels[k],sd);
sprintf(atcmd_output, msg_txt(1425),sub1); // You've left the '%s' channel
@@ -9048,7 +9009,7 @@ ACMD_FUNC(channel) {
if( sub1[0] != '#' ) {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
- return -1;
+ return false;
}
for(k = 0; k < sd->channel_count; k++) {
@@ -9058,7 +9019,7 @@ ACMD_FUNC(channel) {
if( k == sd->channel_count ) {
sprintf(atcmd_output, msg_txt(1425),sub1);// You're not part of the '%s' channel
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
sd->gcbind = sd->channels[k];
@@ -9068,21 +9029,301 @@ ACMD_FUNC(channel) {
if( sd->gcbind == NULL ) {
clif->message(fd, msg_txt(1432));// Your global chat is not binded to any channel
- return -1;
+ return false;
}
sprintf(atcmd_output, msg_txt(1433),sd->gcbind->name); // Your global chat is now unbinded from the '#%s' channel
clif->message(fd, atcmd_output);
-
+
sd->gcbind = NULL;
+ } else if ( strcmpi(key,"ban") == 0 ) {
+ struct map_session_data *pl_sd = NULL;
+ struct hChSysBanEntry *entry = NULL;
+
+ if( sub1[0] != '#' ) {
+ clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
+ return false;
+ }
+
+ if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) {
+ sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( sub2[0] == '\0' || ( pl_sd = map_nick2sd(sub2) ) == NULL ) {
+ sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( pc_has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN) ) {
+ clif->message(fd, msg_txt(1464)); // Ban failed, not possible to ban this user.
+ return false;
+ }
+
+ if( channel->banned && idb_exists(channel->banned,pl_sd->status.account_id) ) {
+ sprintf(atcmd_output, msg_txt(1465), pl_sd->status.name);// Player '%s' is already banned from this channel
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( !channel->banned )
+ channel->banned = idb_alloc(DB_OPT_BASE|DB_OPT_ALLOW_NULL_DATA|DB_OPT_RELEASE_DATA);
+
+ CREATE(entry, struct hChSysBanEntry, 1);
+
+ safestrncpy(entry->name, pl_sd->status.name, NAME_LENGTH);
+
+ idb_put(channel->banned, pl_sd->status.account_id, entry);
+
+ clif->chsys_left(channel,pl_sd);
+
+ sprintf(atcmd_output, msg_txt(1437),pl_sd->status.name,sub1); // Player '%s' has now been banned from '%s' channel
+ clif->message(fd, atcmd_output);
+ } else if ( strcmpi(key,"unban") == 0 ) {
+ struct map_session_data *pl_sd = NULL;
+
+ if( sub1[0] != '#' ) {
+ clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
+ return false;
+ }
+
+ if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) {
+ sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( !channel->banned ) {
+ sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( sub2[0] == '\0' || ( pl_sd = map_nick2sd(sub2) ) == NULL ) {
+ sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( !idb_exists(channel->banned,pl_sd->status.account_id) ) {
+ sprintf(atcmd_output, msg_txt(1440), pl_sd->status.name);// Player '%s' is not banned from this channel
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ idb_remove(channel->banned, pl_sd->status.account_id);
+
+ if( !db_size(channel->banned) ) {
+ db_destroy(channel->banned);
+ channel->banned = NULL;
+ }
+
+ sprintf(atcmd_output, msg_txt(1441),pl_sd->status.name,sub1); // Player '%s' has now been unbanned from the '%s' channel
+ clif->message(fd, atcmd_output);
+ } else if ( strcmpi(key,"unbanall") == 0 ) {
+ if( sub1[0] != '#' ) {
+ clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
+ return false;
+ }
+
+ if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) {
+ sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( !channel->banned ) {
+ sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ db_destroy(channel->banned);
+ channel->banned = NULL;
+
+ sprintf(atcmd_output, msg_txt(1442),sub1); // Removed all bans from '%s' channel
+ clif->message(fd, atcmd_output);
+ } else if ( strcmpi(key,"banlist") == 0 ) {
+ DBIterator *iter = NULL;
+ DBKey key;
+ DBData *data;
+ bool isA = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)?true:false;
+ if( sub1[0] != '#' ) {
+ clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
+ return false;
+ }
+
+ if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) {
+ sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( channel->owner != sd->status.char_id && !isA ) {
+ sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( !channel->banned ) {
+ sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+ sprintf(atcmd_output, msg_txt(1443), channel->name);// -- '%s' ban list
+ clif->message(fd, atcmd_output);
+
+ iter = db_iterator(channel->banned);
+
+ for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
+ struct hChSysBanEntry * entry = db_data2ptr(data);
+
+ if( !isA )
+ sprintf(atcmd_output, msg_txt(1444), entry->name);// - %s %s
+ else
+ sprintf(atcmd_output, msg_txt(1445), entry->name, key.i);// - %s (%d)
+
+ clif->message(fd, atcmd_output);
+ }
+
+ dbi_destroy(iter);
+
+ } else if ( strcmpi(key,"setopt") == 0 ) {
+ const char* opt_str[3] = {
+ "None",
+ "JoinAnnounce",
+ "MessageDelay",
+ };
+
+ if( sub1[0] != '#' ) {
+ clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
+ return false;
+ }
+
+ if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) {
+ sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if( sub2[0] == '\0' ) {
+ clif->message(fd, msg_txt(1446));// You need to input a option
+ return false;
+ }
+
+ for( k = 1; k < 3; k++ ) {
+ if( strcmpi(sub2,opt_str[k]) == 0 )
+ break;
+ }
+
+ if( k == 3 ) {
+ sprintf(atcmd_output, msg_txt(1447), sub2);// '%s' is not a known channel option
+ clif->message(fd, atcmd_output);
+ clif->message(fd, msg_txt(1448)); // -- Available options
+ for( k = 1; k < 3; k++ ) {
+ sprintf(atcmd_output, msg_txt(1444), opt_str[k]);// - '%s'
+ clif->message(fd, atcmd_output);
+ }
+ return false;
+ }
+
+ if( sub3[0] == '\0' ) {
+ if ( k == hChSys_OPT_MSG_DELAY ) {
+ sprintf(atcmd_output, msg_txt(1466), opt_str[k]);// For '%s' you need the amount of seconds (from 0 to 10)
+ clif->message(fd, atcmd_output);
+ return false;
+ } else if( channel->opt & k ) {
+ sprintf(atcmd_output, msg_txt(1449), opt_str[k],opt_str[k]); // option '%s' is already enabled, if you'd like to disable it type '@channel setopt %s 0'
+ clif->message(fd, atcmd_output);
+ return false;
+ } else {
+ channel->opt |= k;
+ sprintf(atcmd_output, msg_txt(1450), opt_str[k],channel->name);//option '%s' is now enabled for channel '%s'
+ clif->message(fd, atcmd_output);
+ return true;
+ }
+ } else {
+ int v = atoi(sub3);
+ if( k == hChSys_OPT_MSG_DELAY ) {
+ if( v < 0 || v > 10 ) {
+ sprintf(atcmd_output, msg_txt(1451), v, opt_str[k]);// value '%d' for option '%s' is out of range (limit is 0-10)
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+ if( v == 0 ) {
+ channel->opt &=~ k;
+ channel->msg_delay = 0;
+ sprintf(atcmd_output, msg_txt(1453), opt_str[k],channel->name,v);// option '%s' is now disabled for channel '%s'
+ clif->message(fd, atcmd_output);
+ return true;
+ } else {
+ channel->opt |= k;
+ channel->msg_delay = v;
+ sprintf(atcmd_output, msg_txt(1452), opt_str[k],channel->name,v);// option '%s' is now enabled for channel '%s' with %d seconds
+ clif->message(fd, atcmd_output);
+ return true;
+ }
+ } else {
+ if( v ) {
+ if( channel->opt & k ) {
+ sprintf(atcmd_output, msg_txt(1449), opt_str[k],opt_str[k]); // option '%s' is already enabled, if you'd like to disable it type '@channel opt %s 0'
+ clif->message(fd, atcmd_output);
+ return false;
+ } else {
+ channel->opt |= k;
+ sprintf(atcmd_output, msg_txt(1454), opt_str[k],channel->name);//option '%s' is now enabled for channel '%s'
+ clif->message(fd, atcmd_output);
+ }
+ } else {
+ if( !(channel->opt & k) ) {
+ sprintf(atcmd_output, msg_txt(1454), opt_str[k],channel->name); // option '%s' is not enabled on channel '%s'
+ clif->message(fd, atcmd_output);
+ return false;
+ } else {
+ channel->opt &=~ k;
+ sprintf(atcmd_output, msg_txt(1453), opt_str[k],channel->name);// option '%s' is now disabled for channel '%s'
+ clif->message(fd, atcmd_output);
+ return true;
+ }
+ }
+ }
+
+ }
+
} else {
atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ));
}
- return 0;
+ return true;
}
/* debug only, delete after */
-ACMD_FUNC(fontcolor) {
+ACMD(fontcolor) {
unsigned char k;
if( !message || !*message ) {
@@ -9099,13 +9340,13 @@ ACMD_FUNC(fontcolor) {
safestrncpy((char*)WFIFOP(fd,12), mout, msg_len);
WFIFOSET(fd, msg_len + 12);
}
- return -1;
+ return false;
}
if( message[0] == '0' ) {
sd->fontcolor = 0;
pc_disguise(sd,0);
- return 0;
+ return true;
}
for( k = 0; k < hChSys.colors_count; k++ ) {
@@ -9115,19 +9356,35 @@ ACMD_FUNC(fontcolor) {
if( k == hChSys.colors_count ) {
sprintf(atcmd_output, msg_txt(1411), message);// Unknown color '%s'
clif->message(fd, atcmd_output);
- return -1;
+ return false;
}
sd->fontcolor = k + 1;
pc_disguise(sd,sd->status.class_);
+
+ return true;
+}
+ACMD(searchstore){
+ int val = atoi(message);
+
+ switch( val ) {
+ case 0://EFFECTTYPE_NORMAL
+ case 1://EFFECTTYPE_CASH
+ break;
+ default:
+ val = 0;
+ break;
+ }
- return 0;
+ searchstore->open(sd, 99, val);
+
+ return true;
}
/**
* Fills the reference of available commands in atcommand DBMap
**/
-#define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL }
-#define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL }
+#define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, NULL, true }
+#define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, NULL, true }
void atcommand_basecommands(void) {
/**
* Command reference list, place the base of your commands here
@@ -9385,20 +9642,22 @@ void atcommand_basecommands(void) {
ACMD_DEF(mount2),
ACMD_DEF(join),
ACMD_DEF(channel),
- ACMD_DEF(fontcolor)
+ ACMD_DEF(fontcolor),
+ ACMD_DEF(searchstore),
};
- AtCommandInfo* atcommand;
+ AtCommandInfo* cmd;
int i;
for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
- if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
+ if(atcommand->exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
continue;
}
- CREATE(atcommand, AtCommandInfo, 1);
- safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
- atcommand->func = atcommand_base[i].func;
- strdb_put(atcommand_db, atcommand->command, atcommand);
+ CREATE(cmd, AtCommandInfo, 1);
+ safestrncpy(cmd->command, atcommand_base[i].command, sizeof(cmd->command));
+ cmd->func = atcommand_base[i].func;
+ cmd->help = NULL;/* start as null dear */
+ strdb_put(atcommand_db, cmd->command, cmd);
}
return;
}
@@ -9406,9 +9665,8 @@ void atcommand_basecommands(void) {
/*==========================================
* Command lookup functions
*------------------------------------------*/
-bool atcommand_exists(const char* name)
-{
- return strdb_exists(atcommand_db, name);
+AtCommandInfo* atcommand_exists(const char* name) {
+ return strdb_get(atcommand_db, name);
}
static AtCommandInfo* get_atcommandinfo_byname(const char *name)
@@ -9427,12 +9685,12 @@ static const char* atcommand_checkalias(const char *aliasname)
}
/// AtCommand suggestion
-static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
+static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool is_atcmd_cmd) {
DBIterator* atcommand_iter;
DBIterator* alias_iter;
AtCommandInfo* command_info = NULL;
AliasInfo* alias_info = NULL;
- AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
+ AtCommandType type = is_atcmd_cmd ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
char* full_match[MAX_SUGGESTIONS];
char* suggestions[MAX_SUGGESTIONS];
char* match;
@@ -9448,7 +9706,7 @@ static void atcommand_get_suggestions(struct map_session_data* sd, const char *n
// Build the matches
for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
match = strstr(command_info->command, name);
- can_use = pc_can_use_command(sd, command_info->command, type);
+ can_use = atcommand->can_use2(sd, command_info->command, type);
if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
suggestions[prefix_count] = command_info->command;
++prefix_count;
@@ -9461,7 +9719,7 @@ static void atcommand_get_suggestions(struct map_session_data* sd, const char *n
for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
match = strstr(alias_info->alias, name);
- can_use = pc_can_use_command(sd, alias_info->command->command, type);
+ can_use = atcommand->can_use2(sd, alias_info->command->command,type);
if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
suggestions[prefix_count] = alias_info->alias;
++prefix_count;
@@ -9523,11 +9781,11 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
return true;
// skip 10/11-langtype's codepage indicator, if detected
- if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
+ if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand->at_symbol || message[3] == atcommand->char_symbol) )
message += 3;
//Should display as a normal message
- if ( *message != atcommand_symbol && *message != charcommand_symbol )
+ if ( *message != atcommand->at_symbol && *message != atcommand->char_symbol )
return false;
// type value 0 = server invoked: bypass restrictions
@@ -9540,7 +9798,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
}
}
- if (*message == charcommand_symbol) {
+ if (*message == atcommand->char_symbol) {
do {
int x, y, z;
@@ -9578,12 +9836,12 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
return false;/* display as normal message */
}
- sprintf(output, msg_txt(1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
+ sprintf(output, msg_txt(1388), atcommand->char_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
clif->message(fd, output);
return true;
} while(0);
}
- else if (*message == atcommand_symbol) {
+ else if (*message == atcommand->at_symbol) {
//atcmd_msg is constructed above differently for charcommands
//it's copied from message if not a charcommand so it can
//pass through the rest of the code compatible with both symbols
@@ -9599,27 +9857,31 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
params[0] = '\0';
// @commands (script based)
- if(type == 1 && atcmd_binding_count > 0) {
+ if(type == 1 && atcommand->binding_count > 0) {
struct atcmd_binding_data * binding;
- // Check if the command initiated is a character command
- if (*message == charcommand_symbol &&
- (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
- sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
- clif->message(fd, output);
- return true;
- }
-
// Get atcommand binding
- binding = get_atcommandbind_byname(command);
+ binding = atcommand->get_bind_byname(command);
// Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
if( binding != NULL && binding->npc_event[0] &&
- ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
- (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
+ ((*atcmd_msg == atcommand->at_symbol && pc_get_group_level(sd) >= binding->group_lv) ||
+ (*atcmd_msg == atcommand->char_symbol && pc_get_group_level(sd) >= binding->group_lv_char)))
{
// Check if self or character invoking; if self == character invoked, then self invoke.
- bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
+ bool invokeFlag = ((*atcmd_msg == atcommand->at_symbol) ? 1 : 0);
+
+ // Check if the command initiated is a character command
+ if (*message == atcommand->char_symbol &&
+ (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
+ sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
+ clif->message(fd, output);
+ return true;
+ }
+
+ if( binding->log ) /* log only if this command should be logged [Ind/Hercules] */
+ logs->atcommand(sd, atcmd_msg);
+
npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
return true;
}
@@ -9631,7 +9893,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
clif->message(fd, output);
- atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
+ atcommand_get_suggestions(sd, command + 1, *message == atcommand->at_symbol);
return true;
} else
return false;
@@ -9639,18 +9901,28 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
// type == 1 : player invoked
if (type == 1) {
- if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
- (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
+ int i;
+ if ((*command == atcommand->at_symbol && info->at_groups[sd->group_pos] == 0) ||
+ (*command == atcommand->char_symbol && info->char_groups[sd->group_pos] == 0) ) {
return false;
}
if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
clif->message(fd, msg_txt(1393)); // You can't use commands while dead
return true;
}
+ for(i = 0; i < map[sd->bl.m].zone->disabled_commands_count; i++) {
+ if( info->func == map[sd->bl.m].zone->disabled_commands[i]->cmd ) {
+ if( sd->group_level < map[sd->bl.m].zone->disabled_commands[i]->group_lv ) {
+ clif->colormes(sd->fd,COLOR_RED,"This command is disabled in this area");
+ return true;
+ } else
+ break;/* already found the matching command, no need to keep checking -- just go on */
+ }
+ }
}
-
+
// Check if target is valid only if confirmed that player can use command.
- if (*message == charcommand_symbol &&
+ if (*message == atcommand->char_symbol &&
(ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
clif->message(fd, output);
@@ -9658,18 +9930,14 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
}
//Attempt to use the command
- if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
- {
+ if ( (info->func(fd, (*atcmd_msg == atcommand->at_symbol) ? sd : ssd, command, params,info) != true) ) {
sprintf(output,msg_txt(154), command); // %s failed.
clif->message(fd, output);
return true;
}
- //Log only if successful.
- if ( *atcmd_msg == atcommand_symbol )
- log_atcommand(sd, atcmd_msg);
- else if ( *atcmd_msg == charcommand_symbol )
- log_atcommand(sd, message);
+ if( info->log ) /* log only if this command should be logged [Ind/Hercules] */
+ logs->atcommand(sd, *atcmd_msg == atcommand->at_symbol ? atcmd_msg : message);
return true;
}
@@ -9677,9 +9945,9 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
/*==========================================
*
*------------------------------------------*/
-static void atcommand_config_read(const char* config_filename)
-{
- config_setting_t *aliases = NULL, *help = NULL;
+static void atcommand_config_read(const char* config_filename) {
+ config_t atcommand_config;
+ config_setting_t *aliases = NULL, *help = NULL, *nolog = NULL;
const char *symbol = NULL;
int num_aliases = 0;
@@ -9692,8 +9960,8 @@ static void atcommand_config_read(const char* config_filename)
*symbol != '/' && // symbol of client commands
*symbol != '%' && // symbol of party chat
*symbol != '$' && // symbol of guild chat
- *symbol != charcommand_symbol)
- atcommand_symbol = *symbol;
+ *symbol != atcommand->char_symbol)
+ atcommand->at_symbol = *symbol;
}
if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
@@ -9701,8 +9969,8 @@ static void atcommand_config_read(const char* config_filename)
*symbol != '/' && // symbol of client commands
*symbol != '%' && // symbol of party chat
*symbol != '$' && // symbol of guild chat
- *symbol != atcommand_symbol)
- charcommand_symbol = *symbol;
+ *symbol != atcommand->at_symbol)
+ atcommand->char_symbol = *symbol;
}
// Command aliases
@@ -9721,11 +9989,10 @@ static void atcommand_config_read(const char* config_filename)
if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
continue;
commandname = config_setting_name(command);
- if (!atcommand_exists(commandname)) {
+ if ( !( commandinfo = atcommand_exists(commandname) ) ) {
ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
continue;
}
- commandinfo = get_atcommandinfo_byname(commandname);
alias_count = config_setting_length(command);
for (j = 0; j < alias_count; ++j) {
const char *alias = config_setting_get_string_elem(command, j);
@@ -9745,6 +10012,26 @@ static void atcommand_config_read(const char* config_filename)
}
}
+ nolog = config_lookup(&atcommand_config, "nolog");
+ if (nolog != NULL) {
+ int i = 0;
+ int count = config_setting_length(nolog);
+
+ for (i = 0; i < count; ++i) {
+ config_setting_t *command;
+ const char *commandname = NULL;
+ AtCommandInfo *commandinfo = NULL;
+
+ command = config_setting_get_elem(nolog, i);
+ commandname = config_setting_name(command);
+ if ( !( commandinfo = atcommand_exists(commandname) ) ) {
+ ShowConfigWarning(command, "atcommand_config_read: can not disable logging for non-existent command %s", commandname);
+ continue;
+ }
+ commandinfo->log = false;
+ }
+ }
+
// Commands help
// We only check if all commands exist
help = config_lookup(&atcommand_config, "help");
@@ -9755,15 +10042,26 @@ static void atcommand_config_read(const char* config_filename)
for (i = 0; i < count; ++i) {
config_setting_t *command;
const char *commandname;
+ AtCommandInfo *commandinfo = NULL;
command = config_setting_get_elem(help, i);
commandname = config_setting_name(command);
- if (!atcommand_exists(commandname))
+ if ( !( commandinfo = atcommand_exists(commandname) ) )
ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
+ else {
+ if( commandinfo->help == NULL ) {
+ const char *str = config_setting_get_string(command);
+ int len = strlen(str);
+ commandinfo->help = aMalloc( len * sizeof(char) );
+ safestrncpy(commandinfo->help, str, len);
+ }
+ }
}
}
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
+
+ config_destroy(&atcommand_config);
return;
}
void atcommand_db_load_groups(int* group_ids) {
@@ -9790,6 +10088,33 @@ void atcommand_db_load_groups(int* group_ids) {
return;
}
+bool atcommand_can_use(struct map_session_data *sd, const char *command) {
+ AtCommandInfo *info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
+
+ if (info == NULL)
+ return false;
+
+ if ((*command == atcommand->at_symbol && info->at_groups[sd->group_pos] != 0) ||
+ (*command == atcommand->char_symbol && info->char_groups[sd->group_pos] != 0) ) {
+ return true;
+ }
+
+ return false;
+}
+bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtCommandType type) {
+ AtCommandInfo *info = get_atcommandinfo_byname(atcommand_checkalias(command));
+
+ if (info == NULL)
+ return false;
+
+ if ((type == COMMAND_ATCOMMAND && info->at_groups[sd->group_pos] != 0) ||
+ (type == COMMAND_CHARCOMMAND && info->char_groups[sd->group_pos] != 0) ) {
+ return true;
+ }
+
+ return false;
+}
+
void atcommand_db_clear(void) {
if (atcommand_db != NULL) {
@@ -9799,6 +10124,8 @@ void atcommand_db_clear(void) {
for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
aFree(cmd->at_groups);
aFree(cmd->char_groups);
+ if( cmd->help != NULL )
+ aFree(cmd->help);
}
dbi_destroy(iter);
@@ -9807,8 +10134,6 @@ void atcommand_db_clear(void) {
}
if (atcommand_alias_db != NULL)
db_destroy(atcommand_alias_db);
-
- config_destroy(&atcommand_config);
}
void atcommand_doload(void) {
@@ -9820,9 +10145,29 @@ void atcommand_doload(void) {
}
void do_init_atcommand(void) {
+ atcommand->at_symbol = '@';
+ atcommand->char_symbol = '#';
+ atcommand->binding_count = 0;
+
atcommand_doload();
}
void do_final_atcommand(void) {
atcommand_db_clear();
}
+
+void atcommand_defaults(void) {
+ atcommand = &atcommand_s;
+
+ atcommand->init = do_init_atcommand;
+ atcommand->final = do_final_atcommand;
+
+ atcommand->parse = is_atcommand;
+ atcommand->can_use = atcommand_can_use;
+ atcommand->can_use2 = atcommand_can_use2;
+ atcommand->load_groups = atcommand_db_load_groups;
+ atcommand->exists = atcommand_exists;
+ atcommand->msg_read = msg_config_read;
+ atcommand->final_msg = do_final_msg;
+ atcommand->get_bind_byname = get_atcommandbind_byname;
+}
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index 8affa4c26..cea59a416 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -1,51 +1,89 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _ATCOMMAND_H_
#define _ATCOMMAND_H_
+/**
+ * Declarations
+ **/
struct map_session_data;
+struct AtCommandInfo;
-//This is the distance at which @autoloot works,
-//if the item drops farther from the player than this,
-//it will not be autolooted. [Skotlex]
-//Note: The range is unlimited unless this define is set.
-//#define AUTOLOOT_DISTANCE AREA_SIZE
-
-extern char atcommand_symbol;
-extern char charcommand_symbol;
+/**
+ * Defines
+ **/
+#define ATCOMMAND_LENGTH 50
+#define MAX_MSG 1500
+/**
+ * Enumerations
+ **/
typedef enum {
COMMAND_ATCOMMAND = 1,
COMMAND_CHARCOMMAND = 2,
} AtCommandType;
-typedef int (*AtCommandFunc)(const int fd, struct map_session_data* sd, const char* command, const char* message);
-
-bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type);
-
-void do_init_atcommand(void);
-void do_final_atcommand(void);
-void atcommand_db_load_groups(int* group_ids);
+/**
+ * Typedef
+ **/
+typedef bool (*AtCommandFunc)(const int fd, struct map_session_data* sd, const char* command, const char* message,struct AtCommandInfo *info);
+typedef struct AtCommandInfo AtCommandInfo;
+typedef struct AliasInfo AliasInfo;
-bool atcommand_exists(const char* name);
-
-const char* msg_txt(int msg_number);
-int msg_config_read(const char* cfgName);
-void do_final_msg(void);
+/**
+ * Structures
+ **/
+struct AliasInfo {
+ AtCommandInfo *command;
+ char alias[ATCOMMAND_LENGTH];
+};
-extern int atcmd_binding_count;
+struct AtCommandInfo {
+ char command[ATCOMMAND_LENGTH];
+ AtCommandFunc func;
+ char *at_groups;/* quick @commands "can-use" lookup */
+ char *char_groups;/* quick @charcommands "can-use" lookup */
+ char *help;/* quick access to this @command's help string */
+ bool log;/* whether to log this command or not, regardless of group settings */
+};
-// @commands (script based)
struct atcmd_binding_data {
- char command[50];
- char npc_event[50];
- int level;
- int level2;
+ char command[ATCOMMAND_LENGTH];
+ char npc_event[ATCOMMAND_LENGTH];
+ int group_lv;
+ int group_lv_char;
+ bool log;
};
-struct atcmd_binding_data** atcmd_binding;
+/**
+ * Interface
+ **/
+struct atcommand_interface {
+ unsigned char at_symbol;
+ unsigned char char_symbol;
+ /* atcommand binding */
+ struct atcmd_binding_data** binding;
+ int binding_count;
+ /* */
+ void (*init) (void);
+ void (*final) (void);
+ /* */
+ bool (*parse) (const int fd, struct map_session_data* sd, const char* message, int type);
+ bool (*can_use) (struct map_session_data *sd, const char *command);
+ bool (*can_use2) (struct map_session_data *sd, const char *command, AtCommandType type);
+ void (*load_groups) (int* group_ids);
+ AtCommandInfo* (*exists) (const char* name);
+ int (*msg_read) (const char* cfgName);
+ void (*final_msg) (void);
+ /* atcommand binding */
+ struct atcmd_binding_data* (*get_bind_byname) (const char* name);
+} atcommand_s;
-struct atcmd_binding_data* get_atcommandbind_byname(const char* name);
+struct atcommand_interface *atcommand;
+
+const char* msg_txt(int msg_number);
+void atcommand_defaults(void);
#endif /* _ATCOMMAND_H_ */
diff --git a/src/map/battle.c b/src/map/battle.c
index d06e02f6c..372616f83 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -988,7 +988,6 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
status_change_end(bl,SC_VOICEOFSIREN,INVALID_TIMER);
}
-
//Finally damage reductions....
// Assumptio doubles the def & mdef on RE mode, otherwise gives a reduction on the final damage. [Igniz]
#ifndef RENEWAL
@@ -1039,7 +1038,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
#ifdef RENEWAL
if(sc->data[SC_ENERGYCOAT] && (flag&BF_WEAPON || flag&BF_MAGIC) && skill_id != WS_CARTTERMINATION)
#else
- if(sc->data[SC_ENERGYCOAT] && flag&BF_WEAPON && skill_id != WS_CARTTERMINATION)
+ if(sc->data[SC_ENERGYCOAT] && (flag&BF_WEAPON && skill_id != WS_CARTTERMINATION))
#endif
{
struct status_data *status = status_get_status_data(bl);
@@ -1143,7 +1142,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
if( sc && sc->data[SC__SHADOWFORM] ) {
struct block_list *s_bl = map_id2bl(sc->data[SC__SHADOWFORM]->val2);
- if( !s_bl ) { // If the shadow form target is not present remove the sc.
+ if( !s_bl || s_bl->m != bl->m ) { // If the shadow form target is not present remove the sc.
status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER);
} else if( status_isdead(s_bl) || !battle->check_target(src,s_bl,BCT_ENEMY)) { // If the shadow form target is dead or not your enemy remove the sc in both.
status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER);
@@ -1833,7 +1832,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
wd.div_ = skill->get_num(GS_CHAINACTION,skill_lv);
wd.type = 0x08;
}
- else if(sc && sc->data[SC_FEARBREEZE] && sd->weapontype1==W_BOW
+ else if(sc && sc->data[SC_FEARBREEZE] && sd->weapontype1==W_BOW
&& (i = sd->equip_index[EQI_AMMO]) >= 0 && sd->inventory_data[i] && sd->status.inventory[i].amount > 1){
int chance = rand()%100;
wd.type = 0x08;
@@ -1909,10 +1908,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if (rnd()%1000 < cri)
flag.cri = 1;
}
- if (flag.cri)
- {
+ if (flag.cri) {
wd.type = 0x0a;
+#ifdef RENEWAL
+ flag.hit = 1;
+#else
flag.idef = flag.idef2 = flag.hit = 1;
+#endif
} else { //Check for Perfect Hit
if(sd && sd->bonus.perfect_hit > 0 && rnd()%100 < sd->bonus.perfect_hit)
flag.hit = 1;
@@ -3041,7 +3043,9 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if( sc->data[SC_EDP] ){
switch(skill_id){
case AS_SPLASHER: case AS_VENOMKNIFE:
+#ifndef RENEWAL_EDP
case AS_GRIMTOOTH:
+#endif
break;
#ifndef RENEWAL_EDP
case ASC_BREAKER: case ASC_METEORASSAULT: break;
@@ -3372,9 +3376,26 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if(skill_id == CR_GRANDCROSS || skill_id == NPC_GRANDDARKNESS)
return wd; //Enough, rest is not needed.
-
- if (sd)
- {
+#ifndef HMAP_ZONE_DAMAGE_CAP_TYPE
+ if( src && skill_id ) {
+ for(i = 0; i < map[src->m].zone->capped_skills_count; i++) {
+ if( skill_id == map[src->m].zone->capped_skills[i]->nameid && (map[src->m].zone->capped_skills[i]->type & src->type) ) {
+ if( src->type == BL_MOB && map[src->m].zone->capped_skills[i]->subtype != MZS_NONE ) {
+ if( (((TBL_MOB*)src)->status.mode&MD_BOSS) && !(map[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) )
+ continue;
+ if( ((TBL_MOB*)src)->special_state.clone && !(map[src->m].zone->disabled_skills[i]->subtype&MZS_CLONE) )
+ continue;
+ }
+ if( wd.damage > map[src->m].zone->capped_skills[i]->cap )
+ wd.damage = map[src->m].zone->capped_skills[i]->cap;
+ if( wd.damage2 > map[src->m].zone->capped_skills[i]->cap )
+ wd.damage2 = map[src->m].zone->capped_skills[i]->cap;
+ break;
+ }
+ }
+ }
+#endif
+ if (sd) {
if (skill_id != CR_SHIELDBOOMERANG) //Only Shield boomerang doesn't takes the Star Crumbs bonus.
ATK_ADD2(wd.div_*sd->right_weapon.star, wd.div_*sd->left_weapon.star);
if (skill_id==MO_FINGEROFFENSIVE) { //The finger offensive spheres on moment of attack do count. [Skotlex]
@@ -3387,21 +3408,23 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 2, wd.flag);
if( flag.lh )
wd.damage2 = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage2, 3, wd.flag);
-
+#ifdef RENEWAL
+ if( flag.cri )
+ ATK_ADDRATE(sd->bonus.crit_atk_rate>=100?sd->bonus.crit_atk_rate-60:40);
+#endif
if( skill_id == CR_SHIELDBOOMERANG || skill_id == PA_SHIELDCHAIN )
{ //Refine bonus applies after cards and elements.
short index= sd->equip_index[EQI_HAND_L];
if( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_ARMOR )
ATK_ADD(10*sd->status.inventory[index].refine);
}
- } //if (sd)
+ }
//Card Fix, tsd side
- if(tsd)
+ if(tsd) //if player on player then it was already measured above
wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, flag.lh, wd.flag);
- if( flag.infdef )
- { //Plants receive 1 damage when hit
+ if( flag.infdef ) { //Plants receive 1 damage when hit
short class_ = status_get_class(target);
if( flag.hit || wd.damage > 0 )
wd.damage = wd.div_; // In some cases, right hand no need to have a weapon to increase damage
@@ -4063,6 +4086,25 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
MATK_ADD(50);
}
}
+#ifndef HMAP_ZONE_DAMAGE_CAP_TYPE
+ if( src && skill_id ) {
+ for(i = 0; i < map[src->m].zone->capped_skills_count; i++) {
+ if( skill_id == map[src->m].zone->capped_skills[i]->nameid && (map[src->m].zone->capped_skills[i]->type & src->type) ) {
+ if( src->type == BL_MOB && map[src->m].zone->capped_skills[i]->subtype != MZS_NONE ) {
+ if( (((TBL_MOB*)src)->status.mode&MD_BOSS) && !(map[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) )
+ continue;
+ if( ((TBL_MOB*)src)->special_state.clone && !(map[src->m].zone->disabled_skills[i]->subtype&MZS_CLONE) )
+ continue;
+ }
+ if( ad.damage > map[src->m].zone->capped_skills[i]->cap )
+ ad.damage = map[src->m].zone->capped_skills[i]->cap;
+ if( ad.damage2 > map[src->m].zone->capped_skills[i]->cap )
+ ad.damage2 = map[src->m].zone->capped_skills[i]->cap;
+ break;
+ }
+ }
+ }
+#endif
#ifdef RENEWAL
ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag);
#endif
@@ -4446,8 +4488,26 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
md.dmg_lv=ATK_FLEE;
}
}
-
- md.damage = battle->calc_cardfix(BF_MISC, src, target, nk, s_ele, 0, md.damage, 0, md.flag);
+#ifndef HMAP_ZONE_DAMAGE_CAP_TYPE
+ if( src && skill_id ) {
+ for(i = 0; i < map[src->m].zone->capped_skills_count; i++) {
+ if( skill_id == map[src->m].zone->capped_skills[i]->nameid && (map[src->m].zone->capped_skills[i]->type & src->type) ) {
+ if( src->type == BL_MOB && map[src->m].zone->capped_skills[i]->subtype != MZS_NONE ) {
+ if( (((TBL_MOB*)src)->status.mode&MD_BOSS) && !(map[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) )
+ continue;
+ if( ((TBL_MOB*)src)->special_state.clone && !(map[src->m].zone->disabled_skills[i]->subtype&MZS_CLONE) )
+ continue;
+ }
+ if( md.damage > map[src->m].zone->capped_skills[i]->cap )
+ md.damage = map[src->m].zone->capped_skills[i]->cap;
+ if( md.damage2 > map[src->m].zone->capped_skills[i]->cap )
+ md.damage2 = map[src->m].zone->capped_skills[i]->cap;
+ break;
+ }
+ }
+ }
+#endif
+ md.damage = battle->calc_cardfix(BF_MISC, src, target, nk, s_ele, 0, md.damage, 0, md.flag);
if (sd && (i = pc_skillatk_bonus(sd, skill_id)))
md.damage += md.damage*i/100;
@@ -4522,6 +4582,28 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl
memset(&d,0,sizeof(d));
break;
}
+
+#ifdef HMAP_ZONE_DAMAGE_CAP_TYPE
+ if( bl && skill_id ) {
+ int i;
+ for(i = 0; i < map[bl->m].zone->capped_skills_count; i++) {
+ if( skill_id == map[bl->m].zone->capped_skills[i]->nameid && (map[bl->m].zone->capped_skills[i]->type & bl->type) ) {
+ if( bl->type == BL_MOB && map[bl->m].zone->capped_skills[i]->subtype != MZS_NONE ) {
+ if( (((TBL_MOB*)bl)->status.mode&MD_BOSS) && !(map[bl->m].zone->disabled_skills[i]->subtype&MZS_BOSS) )
+ continue;
+ if( ((TBL_MOB*)bl)->special_state.clone && !(map[bl->m].zone->disabled_skills[i]->subtype&MZS_CLONE) )
+ continue;
+ }
+ if( d.damage > map[bl->m].zone->capped_skills[i]->cap )
+ d.damage = map[bl->m].zone->capped_skills[i]->cap;
+ if( d.damage2 > map[bl->m].zone->capped_skills[i]->cap )
+ d.damage2 = map[bl->m].zone->capped_skills[i]->cap;
+ break;
+ }
+ }
+ }
+#endif
+
if( d.damage + d.damage2 < 1 ) { //Miss/Absorbed
//Weapon attacks should go through to cause additional effects.
if (d.dmg_lv == ATK_DEF /*&& attack_type&(BF_MAGIC|BF_MISC)*/) // Isn't it that additional effects don't apply if miss?
@@ -5782,8 +5864,6 @@ static const struct _battle_data {
{ "status_cast_cancel", &battle_config.sc_castcancel, BL_NUL, BL_NUL, BL_ALL, },
{ "pc_status_def_rate", &battle_config.pc_sc_def_rate, 100, 0, INT_MAX, },
{ "mob_status_def_rate", &battle_config.mob_sc_def_rate, 100, 0, INT_MAX, },
- { "pc_luk_status_def", &battle_config.pc_luk_sc_def, 300, 1, INT_MAX, },
- { "mob_luk_status_def", &battle_config.mob_luk_sc_def, 300, 1, INT_MAX, },
{ "pc_max_status_def", &battle_config.pc_max_sc_def, 100, 0, INT_MAX, },
{ "mob_max_status_def", &battle_config.mob_max_sc_def, 100, 0, INT_MAX, },
{ "sg_miracle_skill_ratio", &battle_config.sg_miracle_skill_ratio, 1, 0, 10000, },
@@ -5869,7 +5949,7 @@ void Hercules_report(char* date, char *time_c) {
enum config_table {
C_CIRCULAR_AREA = 0x0001,
C_CELLNOSTACK = 0x0002,
- C_BETA_THREAD_TEST = 0x0004,
+ //C_BETA_THREAD_TEST = 0x0004, (free slot)
C_SCRIPT_CALLFUNC_CHECK = 0x0008,
C_OFFICIAL_WALKPATH = 0x0010,
C_RENEWAL = 0x0020,
@@ -5900,10 +5980,6 @@ void Hercules_report(char* date, char *time_c) {
config |= C_CELLNOSTACK;
#endif
-#ifdef BETA_THREAD_TEST
- config |= C_BETA_THREAD_TEST;
-#endif
-
#ifdef SCRIPT_CALLFUNC_CHECK
config |= C_SCRIPT_CALLFUNC_CHECK;
#endif
@@ -5940,15 +6016,15 @@ void Hercules_report(char* date, char *time_c) {
config |= C_RENEWAL_ASPD;
#endif
-/* not a ifdef because SECURE_NPCTIMEOUT is always defined, but either as 0 or higher */
-#if SECURE_NPCTIMEOUT
+#ifdef SECURE_NPCTIMEOUT
config |= C_SECURE_NPCTIMEOUT;
#endif
+
/* non-define part */
if( db_use_sqldbs )
config |= C_SQL_DBS;
- if( log_config.sql_logs )
+ if( logs->config.sql_logs )
config |= C_SQL_LOGS;
#define BFLAG_LENGTH 35
@@ -6100,8 +6176,10 @@ int battle_config_read(const char* cfgName)
count--;
- if (count == 0)
+ if (count == 0) {
battle->config_adjust();
+ clif->bc_ready();
+ }
return 0;
}
@@ -6166,4 +6244,4 @@ void battle_defaults(void) {
battle->config_adjust = battle_adjust_conf;
battle->get_enemy_area = battle_getenemyarea;
battle->damage_area = battle_damage_area;
-} \ No newline at end of file
+}
diff --git a/src/map/battle.h b/src/map/battle.h
index 54f941de8..8b1f757f5 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -381,8 +381,6 @@ struct Battle_Config {
int sc_castcancel; // [Skotlex]
int pc_sc_def_rate; // [Skotlex]
int mob_sc_def_rate;
- int pc_luk_sc_def;
- int mob_luk_sc_def;
int pc_max_sc_def;
int mob_max_sc_def;
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c
index fb186917b..0b59e8f1e 100644
--- a/src/map/buyingstore.c
+++ b/src/map/buyingstore.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/cbasetypes.h"
#include "../common/db.h" // ARR_FIND
@@ -12,6 +13,7 @@
#include "clif.h" // clif->buyingstore_*
#include "log.h" // log_pick_pc, log_zeny
#include "pc.h" // struct map_session_data
+#include "chrif.h"
/// constants (client-side restrictions)
@@ -230,7 +232,7 @@ void buyingstore_open(struct map_session_data* sd, int account_id)
return;
}
- if( !searchstore_queryremote(sd, account_id) && ( sd->bl.m != pl_sd->bl.m || !check_distance_bl(&sd->bl, &pl_sd->bl, AREA_SIZE) ) )
+ if( !searchstore->queryremote(sd, account_id) && ( sd->bl.m != pl_sd->bl.m || !check_distance_bl(&sd->bl, &pl_sd->bl, AREA_SIZE) ) )
{// out of view range
return;
}
@@ -270,13 +272,13 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
return;
}
- if( !searchstore_queryremote(sd, account_id) && ( sd->bl.m != pl_sd->bl.m || !check_distance_bl(&sd->bl, &pl_sd->bl, AREA_SIZE) ) )
+ if( !searchstore->queryremote(sd, account_id) && ( sd->bl.m != pl_sd->bl.m || !check_distance_bl(&sd->bl, &pl_sd->bl, AREA_SIZE) ) )
{// out of view range
clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0);
return;
}
- searchstore_clearremote(sd);
+ searchstore->clearremote(sd);
if( pl_sd->status.zeny < pl_sd->buyingstore.zenylimit )
{// buyer lost zeny in the mean time? fix the limit
@@ -381,6 +383,11 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
clif->buyingstore_update_item(pl_sd, nameid, amount);
}
+ if( save_settings&128 ) {
+ chrif_save(sd, 0);
+ chrif_save(pl_sd, 0);
+ }
+
// check whether or not there is still something to buy
ARR_FIND( 0, pl_sd->buyingstore.slots, i, pl_sd->buyingstore.items[i].amount != 0 );
if( i == pl_sd->buyingstore.slots )
@@ -463,7 +470,7 @@ bool buyingstore_searchall(struct map_session_data* sd, const struct s_search_st
;
}
- if( !searchstore_result(s->search_sd, sd->buyer_id, sd->status.account_id, sd->message, it->nameid, it->amount, it->price, buyingstore_blankslots, 0) )
+ if( !searchstore->result(s->search_sd, sd->buyer_id, sd->status.account_id, sd->message, it->nameid, it->amount, it->price, buyingstore_blankslots, 0) )
{// result set full
return false;
}
@@ -471,3 +478,15 @@ bool buyingstore_searchall(struct map_session_data* sd, const struct s_search_st
return true;
}
+void buyingstore_defaults(void) {
+ buyingstore = &buyingstore_s;
+
+ buyingstore->setup = buyingstore_setup;
+ buyingstore->create = buyingstore_create;
+ buyingstore->close = buyingstore_close;
+ buyingstore->open = buyingstore_open;
+ buyingstore->trade = buyingstore_trade;
+ buyingstore->search = buyingstore_search;
+ buyingstore->searchall = buyingstore_searchall;
+
+}
diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h
index 0ed6e5457..a416317be 100644
--- a/src/map/buyingstore.h
+++ b/src/map/buyingstore.h
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _BUYINGSTORE_H_
#define _BUYINGSTORE_H_
@@ -8,26 +9,30 @@ struct s_search_store_search;
#define MAX_BUYINGSTORE_SLOTS 5
-struct s_buyingstore_item
-{
+struct s_buyingstore_item {
int price;
unsigned short amount;
unsigned short nameid;
};
-struct s_buyingstore
-{
+struct s_buyingstore {
struct s_buyingstore_item items[MAX_BUYINGSTORE_SLOTS];
int zenylimit;
unsigned char slots;
};
-bool buyingstore_setup(struct map_session_data* sd, unsigned char slots);
-void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const uint8* itemlist, unsigned int count);
-void buyingstore_close(struct map_session_data* sd);
-void buyingstore_open(struct map_session_data* sd, int account_id);
-void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int buyer_id, const uint8* itemlist, unsigned int count);
-bool buyingstore_search(struct map_session_data* sd, unsigned short nameid);
-bool buyingstore_searchall(struct map_session_data* sd, const struct s_search_store_search* s);
+struct buyingstore_interface {
+ bool (*setup) (struct map_session_data* sd, unsigned char slots);
+ void (*create) (struct map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const uint8* itemlist, unsigned int count);
+ void (*close) (struct map_session_data* sd);
+ void (*open) (struct map_session_data* sd, int account_id);
+ void (*trade) (struct map_session_data* sd, int account_id, unsigned int buyer_id, const uint8* itemlist, unsigned int count);
+ bool (*search) (struct map_session_data* sd, unsigned short nameid);
+ bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s);
+} buyingstore_s;
+
+struct buyingstore_interface *buyingstore;
+
+void buyingstore_defaults (void);
#endif // _BUYINGSTORE_H_
diff --git a/src/map/chat.c b/src/map/chat.c
index f908e94ef..a18e87eef 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -96,15 +96,14 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char
pc_stop_walking(sd,1);
cd = chat_createchat(&sd->bl, title, pass, limit, pub, 0, "", 0, 1, MAX_LEVEL);
- if( cd )
- {
+ if( cd ) {
cd->users = 1;
cd->usersd[0] = sd;
pc_setchatid(sd,cd->bl.id);
+ pc_stop_attack(sd);
clif->createchat(sd,0);
clif->dispchat(cd,0);
- }
- else
+ } else
clif->createchat(sd,1);
return 0;
diff --git a/src/map/clif.c b/src/map/clif.c
index 56fdb4193..7ada310e2 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -44,6 +44,8 @@
#include "clif.h"
#include "mail.h"
#include "quest.h"
+#include "packets_struct.h"
+#include "irc-bot.h"
#include <stdio.h>
#include <stdlib.h>
@@ -256,7 +258,7 @@ static inline unsigned char clif_bl_type(struct block_list *bl) {
int clif_send_sub(struct block_list *bl, va_list ap) {
struct block_list *src_bl;
struct map_session_data *sd;
- unsigned char *buf;
+ void *buf;
int len, type, fd;
nullpo_ret(bl);
@@ -266,7 +268,7 @@ int clif_send_sub(struct block_list *bl, va_list ap) {
if (!fd) //Don't send to disconnected clients.
return 0;
- buf = va_arg(ap,unsigned char*);
+ buf = va_arg(ap,void*);
len = va_arg(ap,int);
nullpo_ret(src_bl = va_arg(ap,struct block_list*));
type = va_arg(ap,int);
@@ -319,7 +321,7 @@ int clif_send_sub(struct block_list *bl, va_list ap) {
* Packet Delegation (called on all packets that require data to be sent to more than one client)
* functions that are sent solely to one use whose ID it posses use WFIFOSET
*------------------------------------------*/
-int clif_send(const uint8* buf, int len, struct block_list* bl, enum send_target type) {
+int clif_send(const void* buf, int len, struct block_list* bl, enum send_target type) {
int i;
struct map_session_data *sd, *tsd;
struct party_data *p = NULL;
@@ -555,29 +557,23 @@ int clif_send(const uint8* buf, int len, struct block_list* bl, enum send_target
return 0;
}
-
/// Notifies the client, that it's connection attempt was accepted.
/// 0073 <start time>.L <position>.3B <x size>.B <y size>.B (ZC_ACCEPT_ENTER)
/// 02eb <start time>.L <position>.3B <x size>.B <y size>.B <font>.W (ZC_ACCEPT_ENTER2)
void clif_authok(struct map_session_data *sd)
{
-#if PACKETVER < 20080102
- const int cmd = 0x73;
-#else
- const int cmd = 0x2eb;
-#endif
- int fd = sd->fd;
-
- WFIFOHEAD(fd,packet_len(cmd));
- WFIFOW(fd, 0) = cmd;
- WFIFOL(fd, 2) = gettick();
- WFIFOPOS(fd, 6, sd->bl.x, sd->bl.y, sd->ud.dir);
- WFIFOB(fd, 9) = 5; // ignored
- WFIFOB(fd,10) = 5; // ignored
+ struct packet_authok p;
+
+ p.PacketType = authokType;
+ p.startTime = gettick();
+ WBUFPOS(&p.PosDir[0],0,sd->bl.x,sd->bl.y,sd->ud.dir); /* do the stupid client math */
+ p.xSize = p.ySize = 5; /* not-used */
+
#if PACKETVER >= 20080102
- WFIFOW(fd,11) = sd->user_font; // FIXME: Font is currently not saved.
+ p.font = sd->user_font; // FIXME: Font is currently not saved.
#endif
- WFIFOSET(fd,packet_len(cmd));
+
+ clif->send(&p,sizeof(p),&sd->bl,SELF);
}
@@ -666,27 +662,29 @@ void clif_charselectok(int id, uint8 ok)
/// Makes an item appear on the ground.
/// 009e <id>.L <name id>.W <identified>.B <x>.W <y>.W <subX>.B <subY>.B <amount>.W (ZC_ITEM_FALL_ENTRY)
/// 084b (ZC_ITEM_FALL_ENTRY4)
-void clif_dropflooritem(struct flooritem_data* fitem)
-{
- uint8 buf[17];
+void clif_dropflooritem(struct flooritem_data* fitem) {
+ struct packet_dropflooritem p;
int view;
nullpo_retv(fitem);
if (fitem->item_data.nameid <= 0)
return;
-
- WBUFW(buf, 0) = 0x9e;
- WBUFL(buf, 2) = fitem->bl.id;
- WBUFW(buf, 6) = ((view = itemdb_viewid(fitem->item_data.nameid)) > 0) ? view : fitem->item_data.nameid;
- WBUFB(buf, 8) = fitem->item_data.identify;
- WBUFW(buf, 9) = fitem->bl.x;
- WBUFW(buf,11) = fitem->bl.y;
- WBUFB(buf,13) = fitem->subx;
- WBUFB(buf,14) = fitem->suby;
- WBUFW(buf,15) = fitem->item_data.amount;
-
- clif->send(buf, packet_len(0x9e), &fitem->bl, AREA);
+
+ p.PacketType = dropflooritemType;
+ p.ITAID = fitem->bl.id;
+ p.ITID = ((view = itemdb_viewid(fitem->item_data.nameid)) > 0) ? view : fitem->item_data.nameid;
+#if PACKETVER >= 20130000 /* not sure date */
+ p.type = itemtype(itemdb_type(fitem->item_data.nameid));
+#endif
+ p.IsIdentified = fitem->item_data.identify;
+ p.xPos = fitem->bl.x;
+ p.yPos = fitem->bl.y;
+ p.subX = fitem->subx;
+ p.subY = fitem->suby;
+ p.count = fitem->item_data.amount;
+
+ clif->send(&p, sizeof(p), &fitem->bl, AREA);
}
@@ -836,12 +834,91 @@ static int clif_setlevel(struct block_list* bl) {
}
/*==========================================
- * Prepares 'unit standing/spawning' packet
+ * Prepares 'unit standing' packet
*------------------------------------------*/
-int clif_set_unit_idle(struct block_list* bl, unsigned char* buffer, bool spawn) {
+void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enum send_target target) {
struct map_session_data* sd;
struct status_change* sc = status_get_sc(bl);
struct view_data* vd = status_get_viewdata(bl);
+ struct packet_idle_unit p;
+ int g_id = status_get_emblem_id(bl);
+
+ sd = BL_CAST(BL_PC, bl);
+
+ p.PacketType = idle_unitType;
+#if PACKETVER >= 20091103
+ p.PacketLength = sizeof(p);
+ p.objecttype = clif_bl_type(bl);
+#endif
+ p.GID = bl->id;
+ p.speed = status_get_speed(bl);
+ p.bodypalette = (sc) ? sc->opt1 : 0;
+ p.healthState = (sc) ? sc->opt2 : 0;
+ p.effectState = (sc) ? sc->option : 0;
+ p.job = vd->class_;
+ p.head = vd->hair_style;
+ p.weapon = vd->weapon;
+ p.accessory = vd->head_bottom;
+#if PACKETVER < 7
+ p.shield = vd->shield;
+#endif
+ p.accessory2 = vd->head_top;
+ p.accessory3 = vd->head_mid;
+ if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this?
+ p.accessory = g_id;
+ p.accessory2 = GetWord(g_id, 1);
+ p.accessory3 = GetWord(g_id, 0);
+ }
+ p.headpalette = vd->hair_color;
+ p.bodypalette = vd->cloth_color;
+ p.headDir = (sd)? sd->head_dir : 0;
+#if PACKETVER >= 20101124
+ p.robe = vd->robe;
+#endif
+ p.GUID = g_id;
+ p.GEmblemVer = status_get_emblem_id(bl);
+ p.honor = (sd) ? sd->status.manner : 0;
+ p.virtue = (sc) ? sc->opt3 : 0;
+ p.isPKModeON = (sd) ? sd->status.karma : 0;
+ p.sex = vd->sex;
+ WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl));
+ p.xSize = p.ySize = (sd) ? 5 : 0;
+ p.state = vd->dead_sit;
+ p.clevel = clif_setlevel(bl);
+#if PACKETVER >= 20080102
+ p.font = (sd) ? sd->user_font : 0;
+#endif
+#if PACKETVER >= 20120712
+ if( bl->type == BL_MOB ) {
+ p.maxHP = status_get_max_hp(bl);
+ p.HP = status_get_hp(bl);
+ p.isBoss = ( ((TBL_MOB*)bl)->spawn && ((TBL_MOB*)bl)->spawn->state.boss ) ? 1 : 0;
+ } else {
+ p.maxHP = -1;
+ p.HP = -1;
+ p.isBoss = 0;
+ }
+#endif
+
+ clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,target);
+
+ if( disguised(bl) ) {
+#if PACKETVER >= 20071106
+ p.objecttype = pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
+ p.GID = -bl->id;
+#else
+ p.GID = -bl->id;
+#endif
+ clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,SELF);
+ }
+
+}
+/* todo for packetver 20091103 0x7c non-pc-looking unit handling */
+int clif_spawn_unit2(struct block_list* bl, enum send_target target) {
+ return 0;
+ /*struct map_session_data* sd;
+ struct status_change* sc = status_get_sc(bl);
+ struct view_data* vd = status_get_viewdata(bl);
unsigned char *buf = WBUFP(buffer,0);
#if PACKETVER < 20091103
bool type = !pcdb_checkid(vd->class_);
@@ -851,26 +928,26 @@ int clif_set_unit_idle(struct block_list* bl, unsigned char* buffer, bool spawn)
const char *name;
#endif
sd = BL_CAST(BL_PC, bl);
-
+
#if PACKETVER < 20091103
if(type)
- WBUFW(buf,0) = spawn?0x7c:0x78;
+ WBUFW(buf,0) = 0x7c;
else
#endif
#if PACKETVER < 4
- WBUFW(buf,0) = spawn?0x79:0x78;
+ WBUFW(buf,0) = 0x79;
#elif PACKETVER < 7
- WBUFW(buf,0) = spawn?0x1d9:0x1d8;
+ WBUFW(buf,0) = 0x1d9;
#elif PACKETVER < 20080102
- WBUFW(buf,0) = spawn?0x22b:0x22a;
+ WBUFW(buf,0) = 0x22b;
#elif PACKETVER < 20091103
- WBUFW(buf,0) = spawn?0x2ed:0x2ee;
+ WBUFW(buf,0) = 0x2ed;
#elif PACKETVER < 20101124
- WBUFW(buf,0) = spawn?0x7f8:0x7f9;
+ WBUFW(buf,0) = 0x7f8;
#else
- WBUFW(buf,0) = spawn?0x858:0x857;
+ WBUFW(buf,0) = 0x858;
#endif
-
+
#if PACKETVER >= 20091103
name = status_get_name(bl);
#if PACKETVER < 20110111
@@ -931,14 +1008,14 @@ int clif_set_unit_idle(struct block_list* bl, unsigned char* buffer, bool spawn)
#endif
WBUFW(buf,24) = vd->head_top;
WBUFW(buf,26) = vd->head_mid;
-
+
if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS )
{ //The hell, why flags work like this?
WBUFW(buf,22) = status_get_emblem_id(bl);
WBUFW(buf,24) = GetWord(status_get_guild_id(bl), 1);
WBUFW(buf,26) = GetWord(status_get_guild_id(bl), 0);
}
-
+
WBUFW(buf,28) = vd->hair_color;
WBUFW(buf,30) = vd->cloth_color;
WBUFW(buf,32) = (sd)? sd->head_dir : 0;
@@ -998,130 +1075,160 @@ int clif_set_unit_idle(struct block_list* bl, unsigned char* buffer, bool spawn)
#else
return packet_len(WBUFW(buffer,0));
#endif
+ */
}
-/*==========================================
- * Prepares 'unit walking' packet
- *------------------------------------------*/
-int clif_set_unit_walking(struct block_list* bl, struct unit_data* ud, unsigned char* buffer) {
+void clif_spawn_unit(struct block_list* bl, enum send_target target) {
struct map_session_data* sd;
struct status_change* sc = status_get_sc(bl);
struct view_data* vd = status_get_viewdata(bl);
- unsigned char* buf = WBUFP(buffer,0);
-#if PACKETVER >= 7
- unsigned short offset = 0;
-#endif
-#if PACKETVER >= 20091103
- const char *name;
-#endif
+ struct packet_spawn_unit p;
+ int g_id = status_get_emblem_id(bl);
sd = BL_CAST(BL_PC, bl);
-
-#if PACKETVER < 4
- WBUFW(buf, 0) = 0x7b;
-#elif PACKETVER < 7
- WBUFW(buf, 0) = 0x1da;
-#elif PACKETVER < 20080102
- WBUFW(buf, 0) = 0x22c;
-#elif PACKETVER < 20091103
- WBUFW(buf, 0) = 0x2ec;
-#elif PACKETVER < 20101124
- WBUFW(buf, 0) = 0x7f7;
-#else
- WBUFW(buf, 0) = 0x856;
-#endif
-
+
+ p.PacketType = spawn_unitType;
#if PACKETVER >= 20091103
- name = status_get_name(bl);
-#if PACKETVER < 20110111
- WBUFW(buf, 2) = 69+strlen(name);
-#else
- WBUFW(buf, 2) = 71+strlen(name);
+ p.PacketLength = sizeof(p);
+ p.objecttype = clif_bl_type(bl);
#endif
- offset+=2;
- buf = WBUFP(buffer,offset);
+ p.GID = bl->id;
+ p.speed = status_get_speed(bl);
+ p.bodypalette = (sc) ? sc->opt1 : 0;
+ p.healthState = (sc) ? sc->opt2 : 0;
+ p.effectState = (sc) ? sc->option : 0;
+ p.job = vd->class_;
+ p.head = vd->hair_style;
+ p.weapon = vd->weapon;
+ p.accessory = vd->head_bottom;
+#if PACKETVER < 7
+ p.shield = vd->shield;
#endif
-#if PACKETVER >= 20071106
- WBUFB(buf, 2) = clif_bl_type(bl);
- offset++;
- buf = WBUFP(buffer,offset);
+ p.accessory2 = vd->head_top;
+ p.accessory3 = vd->head_mid;
+ if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this?
+ p.accessory = g_id;
+ p.accessory2 = GetWord(g_id, 1);
+ p.accessory3 = GetWord(g_id, 0);
+ }
+ p.headpalette = vd->hair_color;
+ p.bodypalette = vd->cloth_color;
+ p.headDir = (sd)? sd->head_dir : 0;
+#if PACKETVER >= 20101124
+ p.robe = vd->robe;
#endif
- WBUFL(buf, 2) = bl->id;
- WBUFW(buf, 6) = status_get_speed(bl);
- WBUFW(buf, 8) = (sc)? sc->opt1 : 0;
- WBUFW(buf,10) = (sc)? sc->opt2 : 0;
-#if PACKETVER < 7
- WBUFW(buf,12) = (sc)? sc->option : 0;
-#else
- WBUFL(buf,12) = (sc)? sc->option : 0;
- offset+=2; //Shift the rest of elements by 2 bytes.
- buf = WBUFP(buffer,offset);
+ p.GUID = g_id;
+ p.GEmblemVer = status_get_emblem_id(bl);
+ p.honor = (sd) ? sd->status.manner : 0;
+ p.virtue = (sc) ? sc->opt3 : 0;
+ p.isPKModeON = (sd) ? sd->status.karma : 0;
+ p.sex = vd->sex;
+ WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl));
+ p.xSize = p.ySize = (sd) ? 5 : 0;
+ p.clevel = clif_setlevel(bl);
+#if PACKETVER >= 20080102
+ p.font = (sd) ? sd->user_font : 0;
#endif
- WBUFW(buf,14) = vd->class_;
- WBUFW(buf,16) = vd->hair_style;
- WBUFW(buf,18) = vd->weapon;
-#if PACKETVER < 4
- WBUFW(buf,20) = vd->head_bottom;
- WBUFL(buf,22) = gettick();
- WBUFW(buf,26) = vd->shield;
+#if PACKETVER >= 20120712
+ if( bl->type == BL_MOB ) {
+ p.maxHP = status_get_max_hp(bl);
+ p.HP = status_get_hp(bl);
+ p.isBoss = ( ((TBL_MOB*)bl)->spawn && ((TBL_MOB*)bl)->spawn->state.boss ) ? 1 : 0;
+ } else {
+ p.maxHP = -1;
+ p.HP = -1;
+ p.isBoss = 0;
+ }
+#endif
+ clif->send(&p,sizeof(p),bl,target);
+
+ if( disguised(bl) ) {
+#if PACKETVER >= 20071106
+ p.objecttype = pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
+ p.GID = -bl->id;
#else
- WBUFW(buf,20) = vd->shield;
- WBUFW(buf,22) = vd->head_bottom;
- WBUFL(buf,24) = gettick();
+ p.GID = -bl->id;
#endif
- WBUFW(buf,28) = vd->head_top;
- WBUFW(buf,30) = vd->head_mid;
- WBUFW(buf,32) = vd->hair_color;
- WBUFW(buf,34) = vd->cloth_color;
- WBUFW(buf,36) = (sd)? sd->head_dir : 0;
-#if PACKETVER >= 20110111
- WBUFW(buf,38) = vd->robe;
- offset+= 2;
- buf = WBUFP(buffer,offset);
+ clif->send(&p,sizeof(p),bl,SELF);
+ }
+
+}
+
+/*==========================================
+ * Prepares 'unit walking' packet
+ *------------------------------------------*/
+void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, struct unit_data* ud, enum send_target target) {
+ struct map_session_data* sd;
+ struct status_change* sc = status_get_sc(bl);
+ struct view_data* vd = status_get_viewdata(bl);
+ struct packet_unit_walking p;
+ int g_id = status_get_emblem_id(bl);
+
+ sd = BL_CAST(BL_PC, bl);
+
+ p.PacketType = unit_walkingType;
+#if PACKETVER >= 20091103
+ p.PacketLength = sizeof(p);
+ p.objecttype = clif_bl_type(bl);
#endif
- WBUFL(buf,38) = status_get_guild_id(bl);
- WBUFW(buf,42) = status_get_emblem_id(bl);
- WBUFW(buf,44) = (sd)? sd->status.manner : 0;
+ p.GID = bl->id;
+ p.speed = status_get_speed(bl);
+ p.bodypalette = (sc) ? sc->opt1 : 0;
+ p.healthState = (sc) ? sc->opt2 : 0;
+ p.effectState = (sc) ? sc->option : 0;
+ p.job = vd->class_;
+ p.head = vd->hair_style;
+ p.weapon = vd->weapon;
+ p.accessory = vd->head_bottom;
+ p.moveStartTime = gettick();
#if PACKETVER < 7
- WBUFW(buf,46) = (sc)? sc->opt3 : 0;
-#else
- WBUFL(buf,46) = (sc)? sc->opt3 : 0;
- offset+=2; //Shift the rest of elements by 2 bytes.
- buf = WBUFP(buffer,offset);
+ p.shield = vd->shield;
+#endif
+ p.accessory2 = vd->head_top;
+ p.accessory3 = vd->head_mid;
+ p.headpalette = vd->hair_color;
+ p.bodypalette = vd->cloth_color;
+ p.headDir = (sd)? sd->head_dir : 0;
+#if PACKETVER >= 20101124
+ p.robe = vd->robe;
#endif
- WBUFB(buf,48) = (sd)? sd->status.karma : 0;
- WBUFB(buf,49) = vd->sex;
- WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y,8,8);
- WBUFB(buf,56) = (sd)? 5 : 0;
- WBUFB(buf,57) = (sd)? 5 : 0;
- WBUFW(buf,58) = clif_setlevel(bl);
+ p.GUID = g_id;
+ p.GEmblemVer = status_get_emblem_id(bl);
+ p.honor = (sd) ? sd->status.manner : 0;
+ p.virtue = (sc) ? sc->opt3 : 0;
+ p.isPKModeON = (sd) ? sd->status.karma : 0;
+ p.sex = vd->sex;
+ WBUFPOS2(&p.MoveData[0],0,bl->x,bl->y,ud->to_x,ud->to_y,8,8);
+ p.xSize = p.ySize = (sd) ? 5 : 0;
+ p.clevel = clif_setlevel(bl);
#if PACKETVER >= 20080102
- WBUFW(buf,60) = sd?sd->user_font:0;
+ p.font = (sd) ? sd->user_font : 0;
#endif
-#if PACKETVER >= 20091103
- memcpy((char*)WBUFP(buf,62), name, NAME_LENGTH);
- return WBUFW(buffer,2);
-#else
- return packet_len(WBUFW(buffer,0));
+#if PACKETVER >= 20120712
+ if( bl->type == BL_MOB ) {
+ p.maxHP = status_get_max_hp(bl);
+ p.HP = status_get_hp(bl);
+ p.isBoss = ( ((TBL_MOB*)bl)->spawn && ((TBL_MOB*)bl)->spawn->state.boss ) ? 1 : 0;
+ } else {
+ p.maxHP = -1;
+ p.HP = -1;
+ p.isBoss = 0;
+ }
#endif
-}
+
+ clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,target);
-//Modifies the buffer for disguise characters and sends it to self.
-//Used for spawn/walk packets, where the ID offset changes for packetver >=9
-void clif_setdisguise(struct block_list *bl, unsigned char *buf,int len) {
-#if PACKETVER >= 20091103
- WBUFB(buf,4)= pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
- WBUFL(buf,5)=-bl->id;
-#elif PACKETVER >= 20071106
- WBUFB(buf,2)= pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
- WBUFL(buf,3)=-bl->id;
+ if( disguised(bl) ) {
+#if PACKETVER >= 20071106
+ p.objecttype = pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
+ p.GID = -bl->id;
#else
- WBUFL(buf,2)=-bl->id;
-#endif
- clif->send(buf, len, bl, SELF);
+ p.GID = -bl->id;
+#endif
+ clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,SELF);
+ }
}
-
/// Changes sprite of an NPC object (ZC_NPCSPRITE_CHANGE).
/// 01b0 <id>.L <type>.B <value>.L
/// type:
@@ -1220,9 +1327,7 @@ void clif_weather(int16 m)
**/
int clif_spawn(struct block_list *bl)
{
- unsigned char buf[128];
struct view_data *vd;
- int len;
vd = status_get_viewdata(bl);
if( !vd || vd->class_ == INVISIBLE_CLASS )
@@ -1234,67 +1339,63 @@ int clif_spawn(struct block_list *bl)
if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
return 0;
- len = clif->set_unit_idle(bl, buf,true);
- clif->send(buf, len, bl, AREA_WOS);
- if (disguised(bl))
- clif->setdisguise(bl, buf, len);
+ clif->spawn_unit(bl,AREA_WOS);
if (vd->cloth_color)
clif->refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
- switch (bl->type)
- {
- case BL_PC:
- {
- TBL_PC *sd = ((TBL_PC*)bl);
- int i;
- if (sd->spiritball > 0)
- clif->spiritball(&sd->bl);
- if(sd->state.size==SZ_BIG) // tiny/big players [Valaris]
- clif->specialeffect(bl,423,AREA);
- else if(sd->state.size==SZ_MEDIUM)
- clif->specialeffect(bl,421,AREA);
- if( sd->bg_id && map[sd->bl.m].flag.battleground )
- clif->sendbgemblem_area(sd);
- if( sd->sc.option&OPTION_MOUNTING ) {
- //New Mounts are not complaint to the original method, so we gotta tell this guy that he is mounting.
- clif->sc_notick(&sd->bl,SI_ALL_RIDING,2,1,0,0);
+ switch (bl->type) {
+ case BL_PC:
+ {
+ TBL_PC *sd = ((TBL_PC*)bl);
+ int i;
+ if (sd->spiritball > 0)
+ clif->spiritball(&sd->bl);
+ if(sd->state.size==SZ_BIG) // tiny/big players [Valaris]
+ clif->specialeffect(bl,423,AREA);
+ else if(sd->state.size==SZ_MEDIUM)
+ clif->specialeffect(bl,421,AREA);
+ if( sd->bg_id && map[sd->bl.m].flag.battleground )
+ clif->sendbgemblem_area(sd);
+ if( sd->sc.option&OPTION_MOUNTING ) {
+ //New Mounts are not complaint to the original method, so we gotta tell this guy that he is mounting.
+ clif->sc_notick(&sd->bl,SI_ALL_RIDING,2,1,0,0);
+ }
+ for(i = 1; i < 5; i++){
+ if( sd->talisman[i] > 0 )
+ clif->talisman(sd, i);
+ }
+ #ifdef NEW_CARTS
+ if( sd->sc.data[SC_PUSH_CART] )
+ clif->sc_notick(&sd->bl, SI_ON_PUSH_CART, 2, sd->sc.data[SC_PUSH_CART]->val1, 0, 0);
+ #endif
+ if (sd->status.robe)
+ clif->refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA);
+ }
+ break;
+ case BL_MOB:
+ {
+ TBL_MOB *md = ((TBL_MOB*)bl);
+ if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
+ clif->specialeffect(&md->bl,423,AREA);
+ else if(md->special_state.size==SZ_MEDIUM)
+ clif->specialeffect(&md->bl,421,AREA);
}
- for(i = 1; i < 5; i++){
- if( sd->talisman[i] > 0 )
- clif->talisman(sd, i);
+ break;
+ case BL_NPC:
+ {
+ TBL_NPC *nd = ((TBL_NPC*)bl);
+ if( nd->size == SZ_BIG )
+ clif->specialeffect(&nd->bl,423,AREA);
+ else if( nd->size == SZ_MEDIUM )
+ clif->specialeffect(&nd->bl,421,AREA);
}
- #ifdef NEW_CARTS
- if( sd->sc.data[SC_PUSH_CART] )
- clif->sc_notick(&sd->bl, SI_ON_PUSH_CART, 2, sd->sc.data[SC_PUSH_CART]->val1, 0, 0);
- #endif
- if (sd->status.robe)
- clif->refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA);
- }
- break;
- case BL_MOB:
- {
- TBL_MOB *md = ((TBL_MOB*)bl);
- if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
- clif->specialeffect(&md->bl,423,AREA);
- else if(md->special_state.size==SZ_MEDIUM)
- clif->specialeffect(&md->bl,421,AREA);
- }
- break;
- case BL_NPC:
- {
- TBL_NPC *nd = ((TBL_NPC*)bl);
- if( nd->size == SZ_BIG )
- clif->specialeffect(&nd->bl,423,AREA);
- else if( nd->size == SZ_MEDIUM )
- clif->specialeffect(&nd->bl,421,AREA);
- }
- break;
- case BL_PET:
- if (vd->head_bottom)
- clif->send_petdata(NULL, (TBL_PET*)bl, 3, vd->head_bottom); // needed to display pet equip properly
- break;
+ break;
+ case BL_PET:
+ if (vd->head_bottom)
+ clif->send_petdata(NULL, (TBL_PET*)bl, 3, vd->head_bottom); // needed to display pet equip properly
+ break;
}
return 0;
}
@@ -1464,13 +1565,8 @@ void clif_walkok(struct map_session_data *sd)
void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *ud) {
- uint8 buf[128];
- int len;
- len = clif->set_unit_walking(bl,ud,buf);
- clif->send(buf,len,bl,AREA_WOS);
- if (disguised(bl))
- clif->setdisguise(bl, buf, len);
+ clif->set_unit_walking(bl,NULL,ud,AREA_WOS);
if(vd->cloth_color)
clif->refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
@@ -1694,6 +1790,9 @@ void clif_hercules_chsys_create(struct hChSysCh *channel, char *name, char *pass
safestrncpy(channel->pass, pass, HCHSYS_NAME_LENGTH);
channel->opt = hChSys_OPT_BASE;
+ channel->banned = NULL;
+
+ channel->msg_delay = 0;
if( channel->type != hChSys_MAP && channel->type != hChSys_ALLY )
strdb_put(clif->channel_db, channel->name, channel);
@@ -2057,79 +2156,99 @@ void clif_addcards(unsigned char* buf, struct item* item) {
WBUFW(buf,6) = item->card[i];
}
+void clif_addcards2(unsigned short *cards, struct item* item) {
+ int i=0,j;
+ if( item == NULL ) { //Blank data
+ cards[0] = 0;
+ cards[1] = 0;
+ cards[2] = 0;
+ cards[3] = 0;
+ return;
+ }
+ if( item->card[0] == CARD0_PET ) { //pet eggs
+ cards[0] = 0;
+ cards[1] = 0;
+ cards[2] = 0;
+ cards[3] = item->card[3]; //Pet renamed flag.
+ return;
+ }
+ if( item->card[0] == CARD0_FORGE || item->card[0] == CARD0_CREATE ) { //Forged/created items
+ cards[0] = item->card[0];
+ cards[1] = item->card[1];
+ cards[2] = item->card[2];
+ cards[3] = item->card[3];
+ return;
+ }
+ //Client only receives four cards.. so randomly send them a set of cards. [Skotlex]
+ if( MAX_SLOTS > 4 && (j = itemdb_slot(item->nameid)) > 4 )
+ i = rnd()%(j-3); //eg: 6 slots, possible i values: 0->3, 1->4, 2->5 => i = rnd()%3;
+
+ //Normal items.
+ if( item->card[i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 )
+ cards[0] = j;
+ else
+ cards[0] = item->card[i];
+
+ if( item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 )
+ cards[1] = j;
+ else
+ cards[1] = item->card[i];
+
+ if( item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 )
+ cards[2] = j;
+ else
+ cards[2] = item->card[i];
+
+ if( item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 )
+ cards[3] = j;
+ else
+ cards[3] = item->card[i];
+}
+
/// Notifies the client, about a received inventory item or the result of a pick-up request.
/// 00a0 <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.W <item type>.B <result>.B (ZC_ITEM_PICKUP_ACK)
/// 029a <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.W <item type>.B <result>.B <expire time>.L (ZC_ITEM_PICKUP_ACK2)
/// 02d4 <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.W <item type>.B <result>.B <expire time>.L <bindOnEquipType>.W (ZC_ITEM_PICKUP_ACK3)
-void clif_additem(struct map_session_data *sd, int n, int amount, int fail)
-{
- int fd;
-#if PACKETVER < 20061218
- const int cmd = 0xa0;
-#elif PACKETVER < 20071002
- const int cmd = 0x29a;
-#else
- const int cmd = 0x2d4;
-#endif
+void clif_additem(struct map_session_data *sd, int n, int amount, int fail) {
+ struct packet_additem p;
nullpo_retv(sd);
- fd = sd->fd;
- if( !session_isActive(fd) ) //Sasuke-
+ if( !session_isActive(sd->fd) ) //Sasuke-
return;
- WFIFOHEAD(fd,packet_len(cmd));
if( fail )
- {
- WFIFOW(fd,0)=cmd;
- WFIFOW(fd,2)=n+2;
- WFIFOW(fd,4)=amount;
- WFIFOW(fd,6)=0;
- WFIFOB(fd,8)=0;
- WFIFOB(fd,9)=0;
- WFIFOB(fd,10)=0;
- WFIFOW(fd,11)=0;
- WFIFOW(fd,13)=0;
- WFIFOW(fd,15)=0;
- WFIFOW(fd,17)=0;
- WFIFOW(fd,19)=0;
- WFIFOB(fd,21)=0;
- WFIFOB(fd,22)=fail;
-#if PACKETVER >= 20061218
- WFIFOL(fd,23)=0;
-#endif
-#if PACKETVER >= 20071002
- WFIFOW(fd,27)=0; // unknown
-#endif
- }
- else
- {
+ memset(&p, 0, sizeof(p));
+
+ p.PacketType = additemType;
+ p.Index = n+2;
+ p.count = amount;
+
+ if( !fail ) {
if( n < 0 || n >= MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL )
return;
-
- WFIFOW(fd,0)=cmd;
- WFIFOW(fd,2)=n+2;
- WFIFOW(fd,4)=amount;
+
if (sd->inventory_data[n]->view_id > 0)
- WFIFOW(fd,6)=sd->inventory_data[n]->view_id;
+ p.nameid = sd->inventory_data[n]->view_id;
else
- WFIFOW(fd,6)=sd->status.inventory[n].nameid;
- WFIFOB(fd,8)=sd->status.inventory[n].identify;
- WFIFOB(fd,9)=sd->status.inventory[n].attribute;
- WFIFOB(fd,10)=sd->status.inventory[n].refine;
- clif->addcards(WFIFOP(fd,11), &sd->status.inventory[n]);
- WFIFOW(fd,19)=pc_equippoint(sd,n);
- WFIFOB(fd,21)=itemtype(sd->inventory_data[n]->type);
- WFIFOB(fd,22)=fail;
+ p.nameid = sd->status.inventory[n].nameid;
+
+ p.IsIdentified = sd->status.inventory[n].identify;
+ p.IsDamaged = sd->status.inventory[n].attribute;
+ p.refiningLevel =sd->status.inventory[n].refine;
+ clif->addcards2(&p.slot.card[0], &sd->status.inventory[n]);
+ p.location = pc_equippoint(sd,n);
+ p.type = itemtype(sd->inventory_data[n]->type);
#if PACKETVER >= 20061218
- WFIFOL(fd,23)=sd->status.inventory[n].expire_time;
+ p.HireExpireDate = sd->status.inventory[n].expire_time;
#endif
#if PACKETVER >= 20071002
- WFIFOW(fd,27)=0; // unknown
+ p.bindOnEquipType = 0; // unused
#endif
}
+ p.result = (unsigned char)fail;
- WFIFOSET(fd,packet_len(cmd));
+ clif->send(&p,sizeof(p),&sd->bl,SELF);
}
@@ -2588,10 +2707,12 @@ void read_channels_config(void) {
config_setting_t *colors;
int i,k;
const char *local_name, *ally_name,
- *local_color, *ally_color;
+ *local_color, *ally_color,
+ *irc_name, *irc_color;
int ally_enabled = 0, local_enabled = 0,
local_autojoin = 0, ally_autojoin = 0,
- allow_user_channel_creation = 0;
+ allow_user_channel_creation = 0,
+ irc_enabled = 0;
if( !config_setting_lookup_string(settings, "map_local_channel_name", &local_name) )
local_name = "map";
@@ -2601,13 +2722,66 @@ void read_channels_config(void) {
ally_name = "ally";
safestrncpy(hChSys.ally_name, ally_name, HCHSYS_NAME_LENGTH);
+ if( !config_setting_lookup_string(settings, "irc_channel_name", &irc_name) )
+ irc_name = "irc";
+ safestrncpy(hChSys.irc_name, irc_name, HCHSYS_NAME_LENGTH);
+
config_setting_lookup_bool(settings, "map_local_channel", &local_enabled);
config_setting_lookup_bool(settings, "ally_channel_enabled", &ally_enabled);
+ config_setting_lookup_bool(settings, "irc_channel_enabled", &irc_enabled);
if( local_enabled )
hChSys.local = true;
if( ally_enabled )
hChSys.ally = true;
+ if( irc_enabled )
+ hChSys.irc = true;
+
+ hChSys.irc_server[0] = hChSys.irc_channel[0] = hChSys.irc_nick[0] = hChSys.irc_nick_pw[0] = '\0';
+
+ if( hChSys.irc ) {
+ const char *irc_server, *irc_channel,
+ *irc_nick, *irc_nick_pw;
+ if( config_setting_lookup_string(settings, "irc_channel_network", &irc_server) ) {
+ if( !strstr(irc_server,":") ) {
+ hChSys.irc = false;
+ ShowWarning("channels.conf : network port wasn't found in 'irc_channel_network', disabling irc channel...\n");
+ } else {
+ unsigned char d = 0, dlen = strlen(irc_server);
+ char server[40];
+ for(d = 0; d < dlen; d++) {
+ if(irc_server[d] == ':') {
+ memcpy(server, irc_server, d);
+ safestrncpy(hChSys.irc_server, server, 40);
+ memcpy(server, &irc_server[d+1], dlen);
+ hChSys.irc_server_port = atoi(server);
+ break;
+ }
+ }
+ }
+ } else {
+ hChSys.irc = false;
+ ShowWarning("channels.conf : irc channel enabled but irc_channel_network wasn't found, disabling irc channel...\n");
+ }
+ if( config_setting_lookup_string(settings, "irc_channel_channel", &irc_channel) )
+ safestrncpy(hChSys.irc_channel, irc_channel, 20);
+ else {
+ hChSys.irc = false;
+ ShowWarning("channels.conf : irc channel enabled but irc_channel_channel wasn't found, disabling irc channel...\n");
+ }
+ if( config_setting_lookup_string(settings, "irc_channel_nick", &irc_nick) ) {
+ if( strcmpi(irc_nick,"Hercules_chSysBot") == 0 ) {
+ sprintf(hChSys.irc_nick, "Hercules_chSysBot%d",rand()%777);
+ } else
+ safestrncpy(hChSys.irc_nick, irc_nick, 30);
+ } else {
+ hChSys.irc = false;
+ ShowWarning("channels.conf : irc channel enabled but irc_channel_nick wasn't found, disabling irc channel...\n");
+ }
+ if( config_setting_lookup_string(settings, "irc_channel_nick_pw", &irc_nick_pw) )
+ safestrncpy(hChSys.irc_nick_pw, irc_nick_pw, 30);
+
+ }
config_setting_lookup_bool(settings, "map_local_channel_autojoin", &local_autojoin);
config_setting_lookup_bool(settings, "ally_channel_autojoin", &ally_autojoin);
@@ -2649,7 +2823,7 @@ void read_channels_config(void) {
if( k < hChSys.colors_count ) {
hChSys.local_color = k;
} else {
- ShowError("channels.conf: unknown color '%s' for channel 'map_local_channel_color', disabling '#%s'...\n",local_color,local_name);
+ ShowError("channels.conf: unknown color '%s' for 'map_local_channel_color', disabling '#%s'...\n",local_color,local_name);
hChSys.local = false;
}
@@ -2663,10 +2837,35 @@ void read_channels_config(void) {
if( k < hChSys.colors_count ) {
hChSys.ally_color = k;
} else {
- ShowError("channels.conf: unknown color '%s' for channel 'ally_channel_color', disabling '#%s'...\n",local_color,ally_name);
+ ShowError("channels.conf: unknown color '%s' for 'ally_channel_color', disabling '#%s'...\n",ally_color,ally_name);
hChSys.ally = false;
}
+ config_setting_lookup_string(settings, "irc_channel_color", &irc_color);
+
+ for (k = 0; k < hChSys.colors_count; k++) {
+ if( strcmpi(hChSys.colors_name[k],irc_color) == 0 )
+ break;
+ }
+
+ if( k < hChSys.colors_count ) {
+ hChSys.irc_color = k;
+ } else {
+ ShowError("channels.conf: unknown color '%s' for 'irc_channel_color', disabling '#%s'...\n",irc_color,irc_name);
+ hChSys.irc = false;
+ }
+
+ if( hChSys.irc ) {
+ struct hChSysCh *chd;
+ CREATE( chd, struct hChSysCh, 1 );
+
+ safestrncpy(chd->name, hChSys.irc_name, HCHSYS_NAME_LENGTH);
+ chd->type = hChSys_IRC;
+
+ clif->chsys_create(chd,NULL,NULL,hChSys.irc_color);
+ ircbot->channel = chd;
+ }
+
if( (channels = config_setting_get_member(settings, "default_channels")) != NULL ) {
int channel_count = config_setting_length(channels);
@@ -2684,7 +2883,7 @@ void read_channels_config(void) {
ShowError("channels.conf: unknown color '%s' for channel '%s', skipping channel...\n",color,name);
continue;
}
- if( strcmpi(name,hChSys.local_name) == 0 || strcmpi(name,hChSys.ally_name) == 0 || strdb_exists(clif->channel_db, name) ) {
+ if( strcmpi(name,hChSys.local_name) == 0 || strcmpi(name,hChSys.ally_name) == 0 || strcmpi(name,hChSys.irc_name) == 0 || strdb_exists(clif->channel_db, name) ) {
ShowError("channels.conf: duplicate channel '%s', skipping channel...\n",name);
continue;
@@ -3534,9 +3733,18 @@ void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok)
}
void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data *sd, char *msg) {
- char message[150];
- snprintf(message, 150, "[ #%s ] %s : %s",channel->name,sd->status.name, msg);
- clif->chsys_msg(channel,sd,message);
+ if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), gettick()) > 0 && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ clif->colormes(sd->fd,COLOR_RED,msg_txt(1455));
+ return;
+ } else {
+ char message[150];
+ snprintf(message, 150, "[ #%s ] %s : %s",channel->name,sd->status.name, msg);
+ clif->chsys_msg(channel,sd,message);
+ if( channel->type == hChSys_IRC )
+ ircbot->relay(sd->status.name,msg);
+ if( channel->msg_delay != 0 )
+ sd->hchsysch_tick = gettick();
+ }
}
/// Inform client whether chatroom creation was successful or not (ZC_ACK_CREATE_CHATROOM).
@@ -4115,10 +4323,8 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds
}
void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
- uint8 buf[128];
struct unit_data *ud;
struct view_data *vd;
- int len;
vd = status_get_viewdata(bl);
if (!vd || vd->class_ == INVISIBLE_CLASS)
@@ -4130,66 +4336,64 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
return;
- ud = unit_bl2ud(bl);
- len = ( ud && ud->walktimer != INVALID_TIMER ) ? clif->set_unit_walking(bl,ud,buf) : clif->set_unit_idle(bl,buf,false);
- clif->send(buf,len,&sd->bl,SELF);
+ if ( ( ud = unit_bl2ud(bl) ) && ud->walktimer != INVALID_TIMER )
+ clif->set_unit_walking(bl,sd,ud,SELF);
+ else
+ clif->set_unit_idle(bl,sd,SELF);
if (vd->cloth_color)
clif->refreshlook(&sd->bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,SELF);
- switch (bl->type)
- {
- case BL_PC:
- {
- TBL_PC* tsd = (TBL_PC*)bl;
- clif->getareachar_pc(sd, tsd);
- if(tsd->state.size==SZ_BIG) // tiny/big players [Valaris]
- clif->specialeffect_single(bl,423,sd->fd);
- else if(tsd->state.size==SZ_MEDIUM)
- clif->specialeffect_single(bl,421,sd->fd);
- if( tsd->bg_id && map[tsd->bl.m].flag.battleground )
- clif->sendbgemblem_single(sd->fd,tsd);
- if( tsd->sc.data[SC_CAMOUFLAGE] )
- clif->status_change(bl, SI_CAMOUFLAGE, 1, 0, 0, 0, 0);
- if ( tsd->status.robe )
- clif->refreshlook(&sd->bl,bl->id,LOOK_ROBE,tsd->status.robe,SELF);
- }
- break;
- case BL_MER: // Devotion Effects
- if( ((TBL_MER*)bl)->devotion_flag )
- clif->devotion(bl, sd);
- break;
- case BL_NPC:
- {
- TBL_NPC* nd = (TBL_NPC*)bl;
- if( nd->chat_id )
- clif->dispchat((struct chat_data*)map_id2bl(nd->chat_id),sd->fd);
- if( nd->size == SZ_BIG )
- clif->specialeffect_single(bl,423,sd->fd);
- else if( nd->size == SZ_MEDIUM )
- clif->specialeffect_single(bl,421,sd->fd);
- }
- break;
- case BL_MOB:
- {
- TBL_MOB* md = (TBL_MOB*)bl;
- if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
- clif->specialeffect_single(bl,423,sd->fd);
- else if(md->special_state.size==SZ_MEDIUM)
- clif->specialeffect_single(bl,421,sd->fd);
-#if PACKETVER >= 20120404
- if( !(md->status.mode&MD_BOSS) ){
- int i;
- for(i = 0; i < DAMAGELOG_SIZE; i++)// must show hp bar to all char who already hit the mob.
- if( md->dmglog[i].id == sd->status.char_id )
- clif->monster_hp_bar(md, sd->fd);
+ switch (bl->type) {
+ case BL_PC:
+ {
+ TBL_PC* tsd = (TBL_PC*)bl;
+ clif->getareachar_pc(sd, tsd);
+ if(tsd->state.size==SZ_BIG) // tiny/big players [Valaris]
+ clif->specialeffect_single(bl,423,sd->fd);
+ else if(tsd->state.size==SZ_MEDIUM)
+ clif->specialeffect_single(bl,421,sd->fd);
+ if( tsd->bg_id && map[tsd->bl.m].flag.battleground )
+ clif->sendbgemblem_single(sd->fd,tsd);
+ if( tsd->sc.data[SC_CAMOUFLAGE] )
+ clif->status_change(bl, SI_CAMOUFLAGE, 1, 0, 0, 0, 0);
+ if ( tsd->status.robe )
+ clif->refreshlook(&sd->bl,bl->id,LOOK_ROBE,tsd->status.robe,SELF);
}
-#endif
- }
- break;
- case BL_PET:
- if (vd->head_bottom)
- clif->send_petdata(NULL, (TBL_PET*)bl, 3, vd->head_bottom); // needed to display pet equip properly
- break;
+ break;
+ case BL_MER: // Devotion Effects
+ if( ((TBL_MER*)bl)->devotion_flag )
+ clif->devotion(bl, sd);
+ break;
+ case BL_NPC:
+ {
+ TBL_NPC* nd = (TBL_NPC*)bl;
+ if( nd->chat_id )
+ clif->dispchat((struct chat_data*)map_id2bl(nd->chat_id),sd->fd);
+ if( nd->size == SZ_BIG )
+ clif->specialeffect_single(bl,423,sd->fd);
+ else if( nd->size == SZ_MEDIUM )
+ clif->specialeffect_single(bl,421,sd->fd);
+ }
+ break;
+ case BL_MOB:
+ {
+ TBL_MOB* md = (TBL_MOB*)bl;
+ if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
+ clif->specialeffect_single(bl,423,sd->fd);
+ else if(md->special_state.size==SZ_MEDIUM)
+ clif->specialeffect_single(bl,421,sd->fd);
+ /* only between 04-04 and 07-12 (afterwards its bundled on the other packet) */
+ #if PACKETVER >= 20120404
+ #if PACKETVER <= 20120712
+ clif->monster_hp_bar(md);
+ #endif
+ #endif
+ }
+ break;
+ case BL_PET:
+ if (vd->head_bottom)
+ clif->send_petdata(NULL, (TBL_PET*)bl, 3, vd->head_bottom); // needed to display pet equip properly
+ break;
}
}
@@ -5369,6 +5573,27 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id
}
}
+void clif_status_change_notick(struct block_list *bl,int type,int flag,int tick,int val1, int val2, int val3) {
+ struct packet_sc_notick p;
+ struct map_session_data *sd;
+
+ nullpo_retv(bl);
+
+ if (!(status_type2relevant_bl_types(type)&bl->type)) // only send status changes that actually matter to the client
+ return;
+
+ if (type == SI_BLANK) //It shows nothing on the client...
+ return;
+
+ sd = BL_CAST(BL_PC, bl);
+
+ p.PacketType = sc_notickType;
+ p.index = type;
+ p.AID = bl->id;
+ p.state = (unsigned char)flag;
+
+ clif->send(&p,packet_len(p.PacketType), bl, (sd && sd->status.option&OPTION_INVISIBLE) ? SELF : AREA);
+}
/// Notifies clients of a status change.
/// 0196 <index>.W <id>.L <state>.B (ZC_MSG_STATE_CHANGE) [used for ending status changes and starting them on non-pc units (when needed)]
@@ -5376,9 +5601,8 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id
/// 08ff <id>.L <index>.W <remain msec>.L { <val>.L }*3 (PACKETVER >= 20111108)
/// 0983 <index>.W <id>.L <state>.B <total msec>.L <remain msec>.L { <val>.L }*3 (PACKETVER >= 20120618)
/// 0984 <id>.L <index>.W <total msec>.L <remain msec>.L { <val>.L }*3 (PACKETVER >= 20120618)
-void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val1, int val2, int val3)
-{
- unsigned char buf[32];
+void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val1, int val2, int val3) {
+ struct packet_status_change p;
struct map_session_data *sd;
if (type == SI_BLANK) //It shows nothing on the client...
@@ -5386,46 +5610,26 @@ void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val
nullpo_retv(bl);
- sd = BL_CAST(BL_PC, bl);
-
if (!(status_type2relevant_bl_types(type)&bl->type)) // only send status changes that actually matter to the client
return;
+
+ sd = BL_CAST(BL_PC, bl);
+
+ p.PacketType = status_changeType;
+ p.index = type;
+ p.AID = bl->id;
+ p.state = (unsigned char)flag;
#if PACKETVER >= 20120618
- if(flag && battle_config.display_status_timers && sd)
- WBUFW(buf,0)=0x983;
- else
-#elif PACKETVER >= 20090121
- if(flag && battle_config.display_status_timers && sd)
- WBUFW(buf,0)=0x43f;
- else
+ p.Total = tick; /* at this stage remain and total are the same value I believe */
#endif
- WBUFW(buf,0)=0x196;
- WBUFW(buf,2)=type;
- WBUFL(buf,4)=bl->id;
- WBUFB(buf,8)=flag;
-#if PACKETVER >= 20120618
- WBUFL(buf,9)=tick;/* at this stage remain and total are the same value I believe */
- WBUFL(buf,13)=tick;
- if(flag && battle_config.display_status_timers && sd) {
- if (tick <= 0)
- tick = 9999; // this is indeed what official servers do
-
- WBUFL(buf,17) = val1;
- WBUFL(buf,21) = val2;
- WBUFL(buf,25) = val3;
- }
-#elif PACKETVER >= 20090121
- if(flag && battle_config.display_status_timers && sd) {
- if (tick <= 0)
- tick = 9999; // this is indeed what official servers do
-
- WBUFL(buf,9) = tick;
- WBUFL(buf,13) = val1;
- WBUFL(buf,17) = val2;
- WBUFL(buf,21) = val3;
- }
+#if PACKETVER >= 20090121
+ p.Left = tick;
+ p.val1 = val1;
+ p.val2 = val2;
+ p.val3 = val3;
#endif
- clif->send(buf,packet_len(WBUFW(buf,0)),bl, (sd && sd->status.option&OPTION_INVISIBLE) ? SELF : AREA);
+
+ clif->send(&p,sizeof(p), bl, (sd && sd->status.option&OPTION_INVISIBLE) ? SELF : AREA);
}
/// Send message (modified by [Yor]) (ZC_NOTIFY_PLAYERCHAT).
@@ -5570,7 +5774,7 @@ void clif_map_property(struct map_session_data* sd, enum map_property property)
int fd;
nullpo_retv(sd);
-
+
fd=sd->fd;
WFIFOHEAD(fd,packet_len(0x199));
WFIFOW(fd,0)=0x199;
@@ -5632,7 +5836,7 @@ void clif_map_property_mapall(int map, enum map_property property)
{
struct block_list bl;
unsigned char buf[16];
-
+
bl.id = 0;
bl.type = BL_NUL;
bl.m = map;
@@ -6113,7 +6317,7 @@ void clif_closevendingboard(struct block_list* bl, int fd)
/// Sends a list of items in a shop.
/// R 0133 <packet len>.W <owner id>.L { <price>.L <amount>.W <index>.W <type>.B <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W }* (ZC_PC_PURCHASE_ITEMLIST_FROMMC)
/// R 0800 <packet len>.W <owner id>.L <unique id>.L { <price>.L <amount>.W <index>.W <type>.B <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W }* (ZC_PC_PURCHASE_ITEMLIST_FROMMC2)
-void clif_vendinglist(struct map_session_data* sd, int id, struct s_vending* vending)
+void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_vending* vending)
{
int i,fd;
int count;
@@ -6349,7 +6553,7 @@ void clif_partyinvitationstate(struct map_session_data* sd)
WFIFOHEAD(fd, packet_len(0x2c9));
WFIFOW(fd, 0) = 0x2c9;
- WFIFOB(fd, 2) = 0; // not implemented
+ WFIFOB(fd, 2) = sd->status.allow_party ? 1 : 0;
WFIFOSET(fd, packet_len(0x2c9));
}
@@ -8181,16 +8385,16 @@ void clif_specialeffect_value(struct block_list* bl, int effect_id, int num, sen
}
// Modification of clif_messagecolor to send colored messages to players to chat log only (doesn't display overhead)
/// 02c1 <packet len>.W <id>.L <color>.L <message>.?B
-int clif_colormes(struct map_session_data * sd, enum clif_colors color, const char* msg) {
+int clif_colormes(int fd, enum clif_colors color, const char* msg) {
unsigned short msg_len = strlen(msg) + 1;
- WFIFOHEAD(sd->fd,msg_len + 12);
- WFIFOW(sd->fd,0) = 0x2C1;
- WFIFOW(sd->fd,2) = msg_len + 12;
- WFIFOL(sd->fd,4) = 0;
- WFIFOL(sd->fd,8) = color_table[color];
- safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len);
- WFIFOSET(sd->fd, msg_len + 12);
+ WFIFOHEAD(fd,msg_len + 12);
+ WFIFOW(fd,0) = 0x2C1;
+ WFIFOW(fd,2) = msg_len + 12;
+ WFIFOL(fd,4) = 0;
+ WFIFOL(fd,8) = color_table[color];
+ safestrncpy((char*)WFIFOP(fd,12), msg, msg_len);
+ WFIFOSET(fd, msg_len + 12);
return 0;
}
@@ -8288,7 +8492,7 @@ void clif_refresh(struct map_session_data *sd)
clif->changed_dir(&sd->bl, SELF);
// unlike vending, resuming buyingstore crashes the client.
- buyingstore_close(sd);
+ buyingstore->close(sd);
mail_clear(sd);
@@ -8954,6 +9158,27 @@ void clif_hercules_chsys_msg(struct hChSysCh *channel, struct map_session_data *
dbi_destroy(iter);
}
+void clif_hercules_chsys_msg2(struct hChSysCh *channel, char *msg) {
+ DBIterator *iter = db_iterator(channel->users);
+ struct map_session_data *user;
+ unsigned char buf[210];
+ unsigned short msg_len = strlen(msg) + 1;
+
+ WBUFW(buf,0) = 0x2C1;
+ WBUFW(buf,2) = msg_len + 12;
+ WBUFL(buf,4) = 0;
+ WBUFL(buf,8) = hChSys.colors[channel->color];
+ safestrncpy((char*)WBUFP(buf,12), msg, msg_len);
+
+ for( user = dbi_first(iter); dbi_exists(iter); user = dbi_next(iter) ) {
+ WFIFOHEAD(user->fd,msg_len + 12);
+ memcpy(WFIFOP(user->fd,0), WBUFP(buf,0), msg_len + 12);
+ WFIFOSET(user->fd, msg_len + 12);
+ }
+
+ dbi_destroy(iter);
+}
+
// ------------
// clif_parse_*
// ------------
@@ -9037,12 +9262,17 @@ void clif_hercules_chsys_mjoin(struct map_session_data *sd) {
clif->chsys_create(map[sd->bl.m].channel,NULL,NULL,hChSys.local_color);
}
+
+ if( map[sd->bl.m].channel->banned && idb_exists(map[sd->bl.m].channel->banned, sd->status.account_id) ) {
+ return;
+ }
+
clif->chsys_join(map[sd->bl.m].channel,sd);
if( !( map[sd->bl.m].channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) {
char mout[60];
sprintf(mout, msg_txt(1435),hChSys.local_name,map[sd->bl.m].name); // You're now in the '#%s' channel for '%s'
- clif->message(sd->fd, mout);
+ clif->colormes(sd->fd, COLOR_DEFAULT, mout);
}
}
@@ -9147,7 +9377,6 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
if( map_flag_gvg(sd->bl.m) )
clif->map_property(sd, MAPPROPERTY_AGITZONE);
-
// info about nearby objects
// must use foreachinarea (CIRCULAR_AREA interferes with foreachinrange)
map_foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd);
@@ -9305,6 +9534,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
mail_clear(sd);
+ clif->maptypeproperty2(&sd->bl,SELF);
+
/* Guild Aura Init */
if( sd->state.gmaster_flag ) {
guild_guildaura_refresh(sd,GD_LEADERSHIP,guild_checkskill(sd->state.gmaster_flag,GD_LEADERSHIP));
@@ -9587,7 +9818,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
- if( is_atcommand(fd, sd, message, 1) )
+ if( atcommand->parse(fd, sd, message, 1) )
return;
if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
@@ -9656,7 +9887,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
#endif
// Chat logging type 'O' / Global Chat
- log_chat(LOG_CHAT_GLOBAL, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
+ logs->chat(LOG_CHAT_GLOBAL, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
}
@@ -9670,8 +9901,8 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd)
map_name = (char*)RFIFOP(fd,2);
map_name[MAP_NAME_LENGTH_EXT-1]='\0';
- sprintf(command, "%cmapmove %s %d %d", atcommand_symbol, map_name, RFIFOW(fd,18), RFIFOW(fd,20));
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%cmapmove %s %d %d", atcommand->at_symbol, map_name, RFIFOW(fd,18), RFIFOW(fd,20));
+ atcommand->parse(fd, sd, command, 1);
}
@@ -9901,6 +10132,74 @@ void clif_hercules_chsys_left(struct hChSysCh *channel, struct map_session_data
}
+void clif_hercules_chsys_quitg(struct map_session_data *sd) {
+ unsigned char i;
+ struct hChSysCh *channel = NULL;
+
+ for( i = 0; i < sd->channel_count; i++ ) {
+ if( (channel = sd->channels[i] ) != NULL && channel->type == hChSys_ALLY ) {
+ idb_remove(channel->users,sd->status.char_id);
+
+ if( channel == sd->gcbind )
+ sd->gcbind = NULL;
+
+ if( !db_size(channel->users) && channel->type == hChSys_PRIVATE ) {
+ clif->chsys_delete(channel);
+ } else if( !hChSys.closing && (channel->opt & hChSys_OPT_ANNOUNCE_JOIN) ) {
+ char message[60];
+ sprintf(message, "#%s '%s' left",channel->name,sd->status.name);
+ clif->chsys_msg(channel,sd,message);
+ }
+ sd->channels[i] = NULL;
+ }
+ }
+
+ if( i < sd->channel_count ) {
+ unsigned char cursor = 0;
+ for( i = 0; i < sd->channel_count; i++ ) {
+ if( sd->channels[i] == NULL )
+ continue;
+ if( cursor != i ) {
+ sd->channels[cursor] = sd->channels[i];
+ }
+ cursor++;
+ }
+ if ( !(sd->channel_count = cursor) ) {
+ aFree(sd->channels);
+ sd->channels = NULL;
+ }
+ }
+
+}
+
+
+void clif_hercules_chsys_quit(struct map_session_data *sd) {
+ unsigned char i;
+ struct hChSysCh *channel = NULL;
+
+ for( i = 0; i < sd->channel_count; i++ ) {
+ if( (channel = sd->channels[i] ) != NULL ) {
+ idb_remove(channel->users,sd->status.char_id);
+
+ if( channel == sd->gcbind )
+ sd->gcbind = NULL;
+
+ if( !db_size(channel->users) && channel->type == hChSys_PRIVATE ) {
+ clif->chsys_delete(channel);
+ } else if( !hChSys.closing && (channel->opt & hChSys_OPT_ANNOUNCE_JOIN) ) {
+ char message[60];
+ sprintf(message, "#%s '%s' left",channel->name,sd->status.name);
+ clif->chsys_msg(channel,sd,message);
+ }
+
+ }
+ }
+
+ sd->channel_count = 0;
+ aFree(sd->channels);
+ sd->channels = NULL;
+}
+
/// Request for an action.
/// 0089 <target id>.L <action>.B (CZ_REQUEST_ACT)
/// 0437 <target id>.L <action>.B (CZ_REQUEST_ACT2)
@@ -9960,7 +10259,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
if( !clif->process_message(sd, 1, &target, &namelen, &message, &messagelen) )
return;
- if ( is_atcommand(fd, sd, message, 1) )
+ if ( atcommand->parse(fd, sd, message, 1) )
return;
if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT))
@@ -9974,7 +10273,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
}
// Chat logging type 'W' / Whisper
- log_chat(LOG_CHAT_WHISPER, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, target, message);
+ logs->chat(LOG_CHAT_WHISPER, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, target, message);
//-------------------------------------------------------//
// Lordalfa - Paperboy - To whisper NPC commands //
@@ -10038,7 +10337,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
}
if( k < sd->channel_count ) {
clif->chsys_send(channel,sd,message);
- } else if( channel->pass[0] == '\0' ) {
+ } else if( channel->pass[0] == '\0' && !(channel->banned && idb_exists(channel->banned, sd->status.account_id)) ) {
clif->chsys_join(channel,sd);
clif->chsys_send(channel,sd,message);
} else {
@@ -10104,8 +10403,8 @@ void clif_parse_Broadcast(int fd, struct map_session_data* sd) {
// as the length varies depending on the command used, just block unreasonably long strings
mes_len_check(msg, len, CHAT_SIZE_MAX);
- sprintf(command, "%ckami %s", atcommand_symbol, msg);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%ckami %s", atcommand->at_symbol, msg);
+ atcommand->parse(fd, sd, command, 1);
}
@@ -10288,6 +10587,10 @@ void clif_hercules_chsys_delete(struct hChSysCh *channel) {
}
dbi_destroy(iter);
}
+ if( channel->banned ) {
+ db_destroy(channel->banned);
+ channel->banned = NULL;
+ }
db_destroy(channel->users);
if( channel->m ) {
map[channel->m].channel = NULL;
@@ -11172,13 +11475,13 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
uint8 select = RFIFOB(fd,6);
if( (select > sd->npc_menu && select != 0xff) || select == 0 ) {
-#if SECURE_NPCTIMEOUT
+#ifdef SECURE_NPCTIMEOUT
if( sd->npc_idle_timer != INVALID_TIMER ) {
#endif
TBL_NPC* nd = map_id2nd(npc_id);
ShowWarning("Invalid menu selection on npc %d:'%s' - got %d, valid range is [%d..%d] (player AID:%d, CID:%d, name:'%s')!\n", npc_id, (nd)?nd->name:"invalid npc id", select, 1, sd->npc_menu, sd->bl.id, sd->status.char_id, sd->status.name);
clif->GM_kick(NULL,sd);
-#if SECURE_NPCTIMEOUT
+#ifdef SECURE_NPCTIMEOUT
}
#endif
return;
@@ -11340,11 +11643,11 @@ void clif_parse_ResetChar(int fd, struct map_session_data *sd) {
char cmd[15];
if( RFIFOW(fd,2) )
- sprintf(cmd,"%cresetskill",atcommand_symbol);
+ sprintf(cmd,"%cresetskill",atcommand->at_symbol);
else
- sprintf(cmd,"%cresetstat",atcommand_symbol);
+ sprintf(cmd,"%cresetstat",atcommand->at_symbol);
- is_atcommand(fd, sd, cmd, 1);
+ atcommand->parse(fd, sd, cmd, 1);
}
@@ -11360,8 +11663,8 @@ void clif_parse_LocalBroadcast(int fd, struct map_session_data* sd)
// as the length varies depending on the command used, just block unreasonably long strings
mes_len_check(msg, len, CHAT_SIZE_MAX);
- sprintf(command, "%clkami %s", atcommand_symbol, msg);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%clkami %s", atcommand->at_symbol, msg);
+ atcommand->parse(fd, sd, command, 1);
}
@@ -11675,7 +11978,7 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
- if( is_atcommand(fd, sd, message, 1) )
+ if( atcommand->parse(fd, sd, message, 1) )
return;
if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
@@ -11876,7 +12179,7 @@ void clif_PartyBookingDeleteNotify(struct map_session_data* sd, int index)
/// 012e
void clif_parse_CloseVending(int fd, struct map_session_data* sd)
{
- vending_closevending(sd);
+ vending->close(sd);
}
@@ -11887,7 +12190,7 @@ void clif_parse_VendingListReq(int fd, struct map_session_data* sd)
if( sd->npc_id ) {// using an NPC
return;
}
- vending_vendinglistreq(sd,RFIFOL(fd,2));
+ vending->list(sd,RFIFOL(fd,2));
}
@@ -11899,7 +12202,7 @@ void clif_parse_PurchaseReq(int fd, struct map_session_data* sd)
int id = (int)RFIFOL(fd,4);
const uint8* data = (uint8*)RFIFOP(fd,8);
- vending_purchasereq(sd, id, sd->vended_id, data, len/4);
+ vending->purchase(sd, id, sd->vended_id, data, len/4);
// whether it fails or not, the buy window is closed
sd->vended_id = 0;
@@ -11915,7 +12218,7 @@ void clif_parse_PurchaseReq2(int fd, struct map_session_data* sd)
int uid = (int)RFIFOL(fd,8);
const uint8* data = (uint8*)RFIFOP(fd,12);
- vending_purchasereq(sd, aid, uid, data, len/4);
+ vending->purchase(sd, aid, uid, data, len/4);
// whether it fails or not, the buy window is closed
sd->vended_id = 0;
@@ -11952,7 +12255,7 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd)
if( message[0] == '\0' ) // invalid input
return;
- vending_openvending(sd, message, data, len/8);
+ vending->open(sd, message, data, len/8);
}
/// Guild creation request (CZ_REQ_MAKE_GUILD).
@@ -12195,7 +12498,7 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
- if( is_atcommand(fd, sd, message, 1) )
+ if( atcommand->parse(fd, sd, message, 1) )
return;
if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
@@ -12409,8 +12712,8 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
case BL_PC:
{
char command[NAME_LENGTH+6];
- sprintf(command, "%ckick %s", atcommand_symbol, status_get_name(target));
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%ckick %s", atcommand->at_symbol, status_get_name(target));
+ atcommand->parse(fd, sd, command, 1);
}
break;
@@ -12420,12 +12723,12 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
case BL_MOB:
{
char command[100];
- if( !pc_can_use_command(sd, "killmonster", COMMAND_ATCOMMAND)) {
+ if( !pc_can_use_command(sd, "@killmonster")) {
clif->GM_kickack(sd, 0);
return;
}
sprintf(command, "/kick %s (%d)", status_get_name(target), status_get_class(target));
- log_atcommand(sd, command);
+ logs->atcommand(sd, command);
status_percent_damage(&sd->bl, target, 100, 0, true); // can invalidate 'target'
}
break;
@@ -12433,8 +12736,8 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
case BL_NPC:
{
char command[NAME_LENGTH+11];
- sprintf(command, "%cunloadnpc %s", atcommand_symbol, status_get_name(target));
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%cunloadnpc %s", atcommand->at_symbol, status_get_name(target));
+ atcommand->parse(fd, sd, command, 1);
}
break;
@@ -12449,8 +12752,8 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
/// 00ce
void clif_parse_GMKickAll(int fd, struct map_session_data* sd) {
char cmd[15];
- sprintf(cmd,"%ckickall",atcommand_symbol);
- is_atcommand(fd, sd, cmd, 1);
+ sprintf(cmd,"%ckickall",atcommand->at_symbol);
+ atcommand->parse(fd, sd, cmd, 1);
}
@@ -12469,8 +12772,8 @@ void clif_parse_GMShift(int fd, struct map_session_data *sd)
player_name = (char*)RFIFOP(fd,2);
player_name[NAME_LENGTH-1] = '\0';
- sprintf(command, "%cjumpto %s", atcommand_symbol, player_name);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%cjumpto %s", atcommand->at_symbol, player_name);
+ atcommand->parse(fd, sd, command, 1);
}
@@ -12485,8 +12788,8 @@ void clif_parse_GMRemove2(int fd, struct map_session_data* sd)
account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
if( (pl_sd = map_id2sd(account_id)) != NULL ) {
char command[NAME_LENGTH+8];
- sprintf(command, "%cjumpto %s", atcommand_symbol, pl_sd->status.name);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%cjumpto %s", atcommand->at_symbol, pl_sd->status.name);
+ atcommand->parse(fd, sd, command, 1);
}
}
@@ -12506,8 +12809,8 @@ void clif_parse_GMRecall(int fd, struct map_session_data *sd)
player_name = (char*)RFIFOP(fd,2);
player_name[NAME_LENGTH-1] = '\0';
- sprintf(command, "%crecall %s", atcommand_symbol, player_name);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%crecall %s", atcommand->at_symbol, player_name);
+ atcommand->parse(fd, sd, command, 1);
}
@@ -12522,8 +12825,8 @@ void clif_parse_GMRecall2(int fd, struct map_session_data* sd)
account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
if( (pl_sd = map_id2sd(account_id)) != NULL ) {
char command[NAME_LENGTH+8];
- sprintf(command, "%crecall %s", atcommand_symbol, pl_sd->status.name);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%crecall %s", atcommand->at_symbol, pl_sd->status.name);
+ atcommand->parse(fd, sd, command, 1);
}
}
@@ -12542,16 +12845,16 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd)
// FIXME: Should look for item first, then for monster.
// FIXME: /monster takes mob_db Sprite_Name as argument
if( mobdb_searchname(monster_item_name) ) {
- snprintf(command, sizeof(command)-1, "%cmonster %s", atcommand_symbol, monster_item_name);
- is_atcommand(fd, sd, command, 1);
+ snprintf(command, sizeof(command)-1, "%cmonster %s", atcommand->at_symbol, monster_item_name);
+ atcommand->parse(fd, sd, command, 1);
return;
}
// FIXME: Stackables have a quantity of 20.
// FIXME: Equips are supposed to be unidentified.
if( itemdb_searchname(monster_item_name) ) {
- snprintf(command, sizeof(command)-1, "%citem %s", atcommand_symbol, monster_item_name);
- is_atcommand(fd, sd, command, 1);
+ snprintf(command, sizeof(command)-1, "%citem %s", atcommand->at_symbol, monster_item_name);
+ atcommand->parse(fd, sd, command, 1);
return;
}
}
@@ -12564,9 +12867,9 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd)
void clif_parse_GMHide(int fd, struct map_session_data *sd) {
char cmd[6];
- sprintf(cmd,"%chide",atcommand_symbol);
+ sprintf(cmd,"%chide",atcommand->at_symbol);
- is_atcommand(fd, sd, cmd, 1);
+ atcommand->parse(fd, sd, cmd, 1);
}
@@ -12598,8 +12901,8 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd)
if( dstsd == NULL )
return;
- sprintf(command, "%cmute %d %s", atcommand_symbol, value, dstsd->status.name);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%cmute %d %s", atcommand->at_symbol, value, dstsd->status.name);
+ atcommand->parse(fd, sd, command, 1);
}
@@ -12612,8 +12915,8 @@ void clif_parse_GMRc(int fd, struct map_session_data* sd)
char *name = (char*)RFIFOP(fd,2);
name[NAME_LENGTH-1] = '\0';
- sprintf(command, "%cmute %d %s", atcommand_symbol, 60, name);
- is_atcommand(fd, sd, command, 1);
+ sprintf(command, "%cmute %d %s", atcommand->at_symbol, 60, name);
+ atcommand->parse(fd, sd, command, 1);
}
@@ -14558,6 +14861,16 @@ void clif_parse_EquipTick(int fd, struct map_session_data* sd)
clif->equiptickack(sd, flag);
}
+/// Request to change party invitation tick.
+/// value:
+/// 0 = disabled
+/// 1 = enabled
+void clif_parse_PartyTick(int fd, struct map_session_data* sd)
+{
+ bool flag = RFIFOB(fd,6)?true:false;
+ sd->status.allow_party = flag;
+ clif->partytickack(sd, flag);
+}
/// Questlog System [Kevin] [Inkfish]
///
@@ -15040,7 +15353,7 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd)
if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
- if( is_atcommand(fd, sd, message, 1) )
+ if( atcommand->parse(fd, sd, message, 1) )
return;
if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
@@ -15451,7 +15764,7 @@ void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data* sd) {
}
count = packet_len/blocksize;
- buyingstore_create(sd, zenylimit, result, storename, itemlist, count);
+ buyingstore->create(sd, zenylimit, result, storename, itemlist, count);
}
@@ -15526,7 +15839,7 @@ void clif_buyingstore_entry_single(struct map_session_data* sd, struct map_sessi
/// Request to close own buying store (CZ_REQ_CLOSE_BUYING_STORE).
/// 0815
void clif_parse_ReqCloseBuyingStore(int fd, struct map_session_data* sd) {
- buyingstore_close(sd);
+ buyingstore->close(sd);
}
@@ -15560,7 +15873,7 @@ void clif_parse_ReqClickBuyingStore(int fd, struct map_session_data* sd)
account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
- buyingstore_open(sd, account_id);
+ buyingstore->open(sd, account_id);
}
@@ -15616,12 +15929,12 @@ void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data* sd) {
if( packet_len%blocksize )
{
- ShowError("clif_parse_ReqTradeBuyingStore: Unexpected item list size %u (account_id=%d, buyer_id=%d, block size=%u)\n", packet_len, sd->bl.id, account_id, blocksize);
+ ShowError("clif_parse_ReqTradeBuyingStore: Unexpected item list size %u (account_id=%d, buyer_id=%u, block size=%u)\n", packet_len, sd->bl.id, account_id, blocksize);
return;
}
count = packet_len/blocksize;
- buyingstore_trade(sd, account_id, buyer_id, itemlist, count);
+ buyingstore->trade(sd, account_id, buyer_id, itemlist, count);
}
@@ -15747,7 +16060,7 @@ void clif_parse_SearchStoreInfo(int fd, struct map_session_data* sd) {
return;
}
- searchstore_query(sd, type, min_price, max_price, (const unsigned short*)itemlist, item_count, (const unsigned short*)cardlist, card_count);
+ searchstore->query(sd, type, min_price, max_price, (const unsigned short*)itemlist, item_count, (const unsigned short*)cardlist, card_count);
}
@@ -15772,7 +16085,7 @@ void clif_search_store_info_ack(struct map_session_data* sd)
WFIFOW(fd,0) = 0x836;
WFIFOW(fd,2) = 7+(end-start)*blocksize;
WFIFOB(fd,4) = !sd->searchstore.pages;
- WFIFOB(fd,5) = searchstore_querynext(sd);
+ WFIFOB(fd,5) = searchstore->querynext(sd);
WFIFOB(fd,6) = (unsigned char)min(sd->searchstore.uses, UINT8_MAX);
for( i = start; i < end; i++ ) {
@@ -15824,7 +16137,7 @@ void clif_search_store_info_failed(struct map_session_data* sd, unsigned char re
/// 0838
void clif_parse_SearchStoreInfoNextPage(int fd, struct map_session_data* sd)
{
- searchstore_next(sd);
+ searchstore->next(sd);
}
@@ -15851,7 +16164,7 @@ void clif_open_search_store_info(struct map_session_data* sd)
/// 083b
void clif_parse_CloseSearchStoreInfo(int fd, struct map_session_data* sd)
{
- searchstore_close(sd);
+ searchstore->close(sd);
}
@@ -15867,7 +16180,7 @@ void clif_parse_SearchStoreInfoListItemClick(int fd, struct map_session_data* sd
store_id = RFIFOL(fd,info->pos[1]);
nameid = RFIFOW(fd,info->pos[2]);
- searchstore_click(sd, account_id, store_id, nameid);
+ searchstore->click(sd, account_id, store_id, nameid);
}
@@ -16245,99 +16558,74 @@ void clif_parse_MoveItem(int fd, struct map_session_data *sd) {
}
/* [Ind/Hercules] */
void clif_cashshop_db(void) {
- FILE *fp;
- char line[254];
- int ln = 0;/* line num */
- char *str[3], *p;
- struct item_data * data;
- int val, type, j;
-
- for( j = 0; j < CASHSHOP_TAB_MAX; j++ ) {
- CREATE(clif->cs.data[j], struct hCSData *, 1);
- clif->cs.item_count[j] = 0;
+ config_t cashshop_conf;
+ config_setting_t *cashshop = NULL;
+ const char *config_filename = "db/cashshop_db.conf"; // FIXME hardcoded name
+ int i;
+ for( i = 0; i < CASHSHOP_TAB_MAX; i++ ) {
+ CREATE(clif->cs.data[i], struct hCSData *, 1);
+ clif->cs.item_count[i] = 0;
}
- if( (fp=fopen("db/cashshop_db.txt","r"))==NULL ){
- ShowError("can't read %s\n", "db/cashshop_db.txt");
+ if (conf_read_file(&cashshop_conf, config_filename)) {
+ ShowError("can't read %s\n", config_filename);
return;
}
- while(fgets(line, sizeof(line), fp)) {
- ln++;
- if( line[0]=='/' && line[1]=='/' )
- continue;
-
- memset(str,0,sizeof(str));
- data = NULL;
-
- for(j=0,p=line;j<3 && p;j++){
- str[j]=p;
- p=strchr(p,',');
- if(p) *p++=0;
- }
+ cashshop = config_lookup(&cashshop_conf, "cash_shop");
+
+ if (cashshop != NULL) {
+ config_setting_t *cats = config_setting_get_elem(cashshop, 0);
+ config_setting_t *cat;
+ int k, item_count_t = 0;
- if(str[0]==NULL)
- continue;
+ for(i = 0; i < CASHSHOP_TAB_MAX; i++) {
+ char entry_name[10];
+
+ sprintf(entry_name,"cat_%d",i);
+
+ if( (cat = config_setting_get_member(cats, entry_name)) != NULL ) {
+ int item_count = config_setting_length(cat);
- if ( j < 3 ) {
- if ( j > 1 )
- ShowWarning("cashshop_db: insufficient fields for entry at %s:%d\n", "db/cashshop_db.txt", ln);
- continue;
- }
- if( ISALPHA(str[0][0]) ) {
- if( strcmpi(str[0],"new") == 0 )
- type = CASHSHOP_TAB_NEW;
- else if( strcmpi(str[0],"popular") == 0 )
- type = CASHSHOP_TAB_POPULAR;
- else if( strcmpi(str[0],"limited") == 0 )
- type = CASHSHOP_TAB_LIMITED;
- else if( strcmpi(str[0],"rental") == 0 )
- type = CASHSHOP_TAB_RENTAL;
- else if( strcmpi(str[0],"permanent") == 0 )
- type = CASHSHOP_TAB_PERPETUITY;
- else if( strcmpi(str[0],"scroll") == 0 )
- type = CASHSHOP_TAB_BUFF;
- else if( strcmpi(str[0],"usable") == 0 )
- type = CASHSHOP_TAB_RECOVERY;
- else if( strcmpi(str[0],"other") == 0 )
- type = CASHSHOP_TAB_ETC;
- else {
- ShowWarning("cashshop_db: unknown type %s for entry at %s:%d\n", str[0], "db/cashshop_db.txt", ln);
- continue;
- }
- } else {
- type = atoi(str[0]);
- if( type < 0 || type > CASHSHOP_TAB_MAX ) {
- ShowWarning("cashshop_db: unknown type %d for entry at %s:%d\n", type, "db/cashshop_db.txt", ln);
- continue;
- }
- }
-
- if( ISALPHA(str[1][0]) ) {
- if( !( data = itemdb_searchname(str[1]) ) ) {
- ShowWarning("cashshop_db: unknown item name %s for entry at %s:%d\n", str[1], "db/cashshop_db.txt", ln);
- continue;
- }
- } else {
- if( !( data = itemdb_exists(atoi(str[1]))) ) {
- ShowWarning("cashshop_db: unknown item id %s for entry at %s:%d\n", str[1], "db/cashshop_db.txt", ln);
- continue;
+ for(k = 0; k < item_count; k++) {
+ config_setting_t *entry = config_setting_get_elem(cat,k);
+ const char *name = config_setting_name(entry);
+ int price = config_setting_get_int(entry);
+ struct item_data * data = NULL;
+
+ if( price < 1 ) {
+ ShowWarning("cashshop_db: unsupported price '%d' for entry named '%s' in category '%s'\n", price, name, entry_name);
+ continue;
+ }
+
+ if( name[0] == 'I' && name[1] == 'D' && strlen(name) <= 7 ) {
+ if( !( data = itemdb_exists(atoi(name+2))) ) {
+ ShowWarning("cashshop_db: unknown item id '%s' in category '%s'\n", name+2, entry_name);
+ continue;
+ }
+ } else {
+ if( !( data = itemdb_searchname(name) ) ) {
+ ShowWarning("cashshop_db: unknown item name '%s' in category '%s'\n", name, entry_name);
+ continue;
+ }
+ }
+
+
+ RECREATE(clif->cs.data[i], struct hCSData *, ++clif->cs.item_count[i]);
+ CREATE(clif->cs.data[i][ clif->cs.item_count[i] - 1 ], struct hCSData , 1);
+
+ clif->cs.data[i][ clif->cs.item_count[i] - 1 ]->id = data->nameid;
+ clif->cs.data[i][ clif->cs.item_count[i] - 1 ]->price = price;
+ item_count_t++;
+ }
+ } else {
+ ShowError("cashshop_db: category '%s' (%d) not found!!\n",entry_name,i);
}
}
- if( ( val = atoi(str[2]) ) < 1 ) {
- ShowWarning("cashshop_db: unsupported price '%d' for entry at %s:%d\n", val, "db/cashshop_db.txt", ln);
- continue;
- }
-
- RECREATE(clif->cs.data[type], struct hCSData *, ++clif->cs.item_count[type]);
- CREATE(clif->cs.data[type][ clif->cs.item_count[type] - 1 ], struct hCSData , 1);
-
- clif->cs.data[type][ clif->cs.item_count[type] - 1 ]->id = data->nameid;
- clif->cs.data[type][ clif->cs.item_count[type] - 1 ]->price = val;
-
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", item_count_t, config_filename);
+ config_destroy(&cashshop_conf);
}
- fclose(fp);
}
/// Items that are in favorite tab of inventory (ZC_ITEM_FAVORITE).
/// 0900 <index>.W <favorite>.B
@@ -16362,17 +16650,15 @@ void clif_snap( struct block_list *bl, short x, short y ) {
clif->send(buf,packet_len(0x8d2),bl,AREA);
}
-void clif_monster_hp_bar( struct mob_data* md, int fd ) {
-#if PACKETVER >= 20120404
- WFIFOHEAD(fd,packet_len(0x977));
-
- WFIFOW(fd,0) = 0x977;
- WFIFOL(fd,2) = md->bl.id;
- WFIFOL(fd,6) = md->status.hp;
- WFIFOL(fd,10) = md->status.max_hp;
-
- WFIFOSET(fd,packet_len(0x977));
-#endif
+void clif_monster_hp_bar( struct mob_data* md ) {
+ struct packet_monster_hp p;
+
+ p.PacketType = monsterhpType;
+ p.GID = md->bl.id;
+ p.HP = md->status.hp;
+ p.MaxHP = md->status.max_hp;
+
+ clif->send(&p,sizeof(p),&md->bl,AREA_WOS);
}
/* [Ind/Hercules] placeholder for unsupported incoming packets (avoids server disconnecting client) */
void __attribute__ ((unused)) clif_parse_dull(int fd,struct map_session_data *sd) {
@@ -16382,13 +16668,13 @@ void __attribute__ ((unused)) clif_parse_dull(int fd,struct map_session_data *sd
void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) {
WFIFOHEAD(fd, 10);
WFIFOW(fd, 0) = 0x845;
- WFIFOL(fd, 2) = sd->cashPoints;/* kafra for now disabled until we know how to apply it */
- WFIFOL(fd, 6) = sd->cashPoints;
+ WFIFOL(fd, 2) = sd->cashPoints; //[Ryuuzaki] - switched positions to reflect proper values
+ WFIFOL(fd, 6) = sd->kafraPoints;
WFIFOSET(fd, 10);
}
void clif_parse_CashShopClose(int fd, struct map_session_data *sd) {
-
+ /* TODO apply some state tracking */
}
void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd) {
@@ -16411,8 +16697,7 @@ void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd) {
}
void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
unsigned short limit = RFIFOW(fd, 4), i, j;
-
- /* no idea what data is on 6-10 */
+ unsigned int kafra_pay = RFIFOL(fd, 6);// [Ryuuzaki] - These are free cash points (strangely #CASH = main cash curreny for us, confusing)
for(i = 0; i < limit; i++) {
int qty = RFIFOL(fd, 14 + ( i * 10 ));
@@ -16429,7 +16714,9 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
}
if( j < clif->cs.item_count[tab] ) {
struct item_data *data;
- if( sd->cashPoints < (clif->cs.data[tab][j]->price * qty) ) {
+ if( sd->kafraPoints < kafra_pay ) {
+ result = CSBR_SHORTTAGE_CASH;
+ } else if( (sd->cashPoints+kafra_pay) < (clif->cs.data[tab][j]->price * qty) ) {
result = CSBR_SHORTTAGE_CASH;
} else if ( !( data = itemdb_exists(clif->cs.data[tab][j]->id) ) ) {
result = CSBR_UNKONWN_ITEM;
@@ -16442,7 +16729,7 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
if (!itemdb_isstackable2(data))
get_count = 1;
- pc_paycash(sd, clif->cs.data[tab][j]->price * qty, 0);/* kafra point support is missing */
+ pc_paycash(sd, clif->cs.data[tab][j]->price * qty, kafra_pay);// [Ryuuzaki]
for (k = 0; k < qty; k += get_count) {
if (!pet_create_egg(sd, data->nameid)) {
memset(&item_tmp, 0, sizeof(item_tmp));
@@ -16471,7 +16758,7 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
}
if( result != CSBR_SUCCESS )
- pc_getcash(sd, clif->cs.data[tab][j]->price * get_count, 0);/* kafra point support is missing */
+ pc_getcash(sd, clif->cs.data[tab][j]->price * get_count,0);
}
}
}
@@ -16484,12 +16771,43 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
WFIFOL(fd, 2) = id;
WFIFOW(fd, 6) = result;/* result */
WFIFOL(fd, 8) = sd->cashPoints;/* current cash point */
- WFIFOL(fd, 12) = 0;/* no idea (kafra cash?) */
+ WFIFOL(fd, 12) = sd->kafraPoints;// [Ryuuzaki]
WFIFOSET(fd, 16);
}
}
+/* [Ind/Hercules] */
+void clif_maptypeproperty2(struct block_list *bl,enum send_target t) {
+#if PACKETVER >= 20130000 /* not entirely sure when this started */
+ struct packet_maptypeproperty2 p;
+
+ p.PacketType = maptypeproperty2Type;
+ p.type = 0x28;
+ p.flag.usecart = 1;
+ p.flag.party = 1;
+ p.flag.guild = 1;
+ p.flag.siege = map_flag_gvg2(bl->m) ? 1: 0;
+ p.flag.mineffect = 1;
+ p.flag.nolockon = 0;
+ p.flag.countpk = map[bl->m].flag.pvp ? 1 : 0;
+ p.flag.nopartyformation = 0;
+ p.flag.noitemconsumption = 0;
+ p.flag.summonstarmiracle = 0;
+ p.flag.bg = map[bl->m].flag.battleground ? 1 : 0;
+
+ clif->send(&p,sizeof(p),bl,t);
+#endif
+}
+
+void clif_partytickack(struct map_session_data* sd, bool flag) {
+
+ WFIFOHEAD(sd->fd, packet_len(0x2c9));
+ WFIFOW(sd->fd, 0) = 0x2c9;
+ WFIFOB(sd->fd, 2) = flag;
+ WFIFOSET(sd->fd, packet_len(0x2c9));
+}
+
/*==========================================
* Main client packet processing function
*------------------------------------------*/
@@ -16655,11 +16973,17 @@ void packetdb_loaddb(void) {
#include "packets.h" /* load structure data */
#undef packet
}
+void clif_bc_ready(void) {
+ if( battle_config.display_status_timers )
+ clif->status_change = clif_status_change;
+ else
+ clif->status_change = clif_status_change_notick;
+}
/*==========================================
*
*------------------------------------------*/
int do_init_clif(void) {
- const char* colors[COLOR_MAX] = { "0xFF0000" };
+ const char* colors[COLOR_MAX] = { "0xFF0000", "0x00ff00" };
int i;
/**
* Setup Color Table (saves unnecessary load of strtoul on every call)
@@ -16683,7 +17007,7 @@ int do_init_clif(void) {
clif->delay_clearunit_ers = ers_new(sizeof(struct block_list),"clif.c::delay_clearunit_ers",ERS_OPT_CLEAR);
clif->channel_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, HCHSYS_NAME_LENGTH);
- hChSys.ally = hChSys.local = hChSys.ally_autojoin = hChSys.local_autojoin = false;
+ hChSys.ally = hChSys.local = hChSys.irc = hChSys.ally_autojoin = hChSys.local_autojoin = false;
clif->chann_config_read();
return 0;
@@ -16757,6 +17081,7 @@ void clif_defaults(void) {
clif->unequipitemack = clif_unequipitemack;
clif->useitemack = clif_useitemack;
clif->addcards = clif_addcards;
+ clif->addcards2 = clif_addcards2;
clif->item_sub = clif_item_sub;
clif->getareachar_item = clif_getareachar_item;
/* unit-related */
@@ -16778,7 +17103,7 @@ void clif_defaults(void) {
clif->skillunit_update = clif_skillunit_update;
clif->clearunit_delayed_sub = clif_clearunit_delayed_sub;
clif->set_unit_idle = clif_set_unit_idle;
- clif->setdisguise = clif_setdisguise;
+ clif->spawn_unit = clif_spawn_unit;
clif->set_unit_walking = clif_set_unit_walking;
clif->calc_walkdelay = clif_calc_walkdelay;
clif->getareachar_skillunit = clif_getareachar_skillunit;
@@ -16795,6 +17120,7 @@ void clif_defaults(void) {
clif->map_property_mapall = clif_map_property_mapall;
clif->bossmapinfo = clif_bossmapinfo;
clif->map_type = clif_map_type;
+ clif->maptypeproperty2 = clif_maptypeproperty2;
/* multi-map-server */
clif->changemapserver = clif_changemapserver;
/* npc-shop-related */
@@ -16868,6 +17194,7 @@ void clif_defaults(void) {
clif->hate_info = clif_hate_info;
clif->mission_info = clif_mission_info;
clif->feel_hate_reset = clif_feel_hate_reset;
+ clif->partytickack = clif_partytickack;
clif->equiptickack = clif_equiptickack;
clif->viewequip_ack = clif_viewequip_ack;
clif->viewequip_fail = clif_viewequip_fail;
@@ -17155,12 +17482,16 @@ void clif_defaults(void) {
clif->noask_sub = clif_noask_sub;
clif->chsys_create = clif_hercules_chsys_create;
clif->chsys_msg = clif_hercules_chsys_msg;
+ clif->chsys_msg2 = clif_hercules_chsys_msg2;
clif->chsys_send = clif_hercules_chsys_send;
clif->chsys_join = clif_hercules_chsys_join;
clif->chsys_left = clif_hercules_chsys_left;
clif->chsys_delete = clif_hercules_chsys_delete;
clif->chsys_mjoin = clif_hercules_chsys_mjoin;
+ clif->chsys_quit = clif_hercules_chsys_quit;
+ clif->chsys_quitg = clif_hercules_chsys_quitg;
clif->cashshop_load = clif_cashshop_db;
+ clif->bc_ready = clif_bc_ready;
/*------------------------
*- Parse Incoming Packet
*------------------------*/
@@ -17357,10 +17688,13 @@ void clif_defaults(void) {
clif->pDebug = clif_parse_debug;
clif->pSkillSelectMenu = clif_parse_SkillSelectMenu;
clif->pMoveItem = clif_parse_MoveItem;
- clif->pDull = clif_parse_dull;
/* RagExe Cash Shop [Ind/Hercules] */
clif->pCashShopOpen = clif_parse_CashShopOpen;
clif->pCashShopClose = clif_parse_CashShopClose;
clif->pCashShopSchedule = clif_parse_CashShopSchedule;
clif->pCashShopBuy = clif_parse_CashShopBuy;
+ /* */
+ clif->pPartyTick = clif_parse_PartyTick;
+ /* dull */
+ clif->pDull = clif_parse_dull;
}
diff --git a/src/map/clif.h b/src/map/clif.h
index 90915e1c9..8c6a0628b 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -7,6 +7,7 @@
#include "../common/cbasetypes.h"
#include "../common/db.h"
+#include "../common/mmo.h"
#include <stdarg.h>
/**
@@ -322,13 +323,14 @@ enum clif_messages {
**/
enum clif_colors {
COLOR_RED,
-
+ COLOR_DEFAULT,
COLOR_MAX
};
enum hChSysChOpt {
- hChSys_OPT_BASE = 0,
- hChSys_OPT_ANNOUNCE_JOIN = 1,
+ hChSys_OPT_BASE = 0x0,
+ hChSys_OPT_ANNOUNCE_JOIN = 0x1,
+ hChSys_OPT_MSG_DELAY = 0x2,
};
enum hChSysChType {
@@ -336,6 +338,7 @@ enum hChSysChType {
hChSys_PRIVATE = 1,
hChSys_MAP = 2,
hChSys_ALLY = 3,
+ hChSys_IRC = 4,
};
enum CASH_SHOP_TABS {
@@ -375,23 +378,31 @@ struct {
unsigned long *colors;
char **colors_name;
unsigned char colors_count;
- bool local, ally;
+ bool local, ally, irc;
bool local_autojoin, ally_autojoin;
- char local_name[HCHSYS_NAME_LENGTH], ally_name[HCHSYS_NAME_LENGTH];
- unsigned char local_color, ally_color;
+ char local_name[HCHSYS_NAME_LENGTH], ally_name[HCHSYS_NAME_LENGTH], irc_name[HCHSYS_NAME_LENGTH];
+ unsigned char local_color, ally_color, irc_color;
bool closing;
bool allow_user_channel_creation;
+ char irc_server[40], irc_channel[20], irc_nick[30], irc_nick_pw[30];
+ unsigned short irc_server_port;
} hChSys;
+struct hChSysBanEntry {
+ char name[NAME_LENGTH];
+};
+
struct hChSysCh {
char name[HCHSYS_NAME_LENGTH];
char pass[HCHSYS_NAME_LENGTH];
unsigned char color;
DBMap *users;
+ DBMap *banned;
unsigned int opt;
unsigned int owner;
enum hChSysChType type;
uint16 m;
+ unsigned char msg_delay;
};
struct hCSData {
@@ -430,7 +441,7 @@ struct clif_interface {
void (*setbindip) (const char* ip);
void (*setport) (uint16 port);
uint32 (*refresh_ip) (void);
- int (*send) (const uint8* buf, int len, struct block_list* bl, enum send_target type);
+ int (*send) (const void* buf, int len, struct block_list* bl, enum send_target type);
int (*send_sub) (struct block_list *bl, va_list ap);
int (*parse) (int fd);
/* auth */
@@ -454,6 +465,7 @@ struct clif_interface {
void (*unequipitemack) (struct map_session_data *sd,int n,int pos,int ok);
void (*useitemack) (struct map_session_data *sd,int index,int amount,bool ok);
void (*addcards) (unsigned char* buf, struct item* item);
+ void (*addcards2) (unsigned short *cards, struct item* item);
void (*item_sub) (unsigned char *buf, int n, struct item *i, struct item_data *id, int equip);
void (*getareachar_item) (struct map_session_data* sd,struct flooritem_data* fitem);
void (*cashshop_load) (void);
@@ -475,9 +487,9 @@ struct clif_interface {
void (*skill_delunit) (struct skill_unit *unit);
void (*skillunit_update) (struct block_list* bl);
int (*clearunit_delayed_sub) (int tid, unsigned int tick, int id, intptr_t data);
- int (*set_unit_idle) (struct block_list* bl, unsigned char* buffer, bool spawn);
- void (*setdisguise) (struct block_list *bl, unsigned char *buf,int len);
- int (*set_unit_walking) (struct block_list* bl, struct unit_data* ud, unsigned char* buffer);
+ void (*set_unit_idle) (struct block_list* bl, struct map_session_data *tsd,enum send_target target);
+ void (*spawn_unit) (struct block_list* bl,enum send_target target);
+ void (*set_unit_walking) (struct block_list* bl, struct map_session_data *tsd,struct unit_data* ud, enum send_target target);
int (*calc_walkdelay) (struct block_list *bl,int delay, int type, int damage, int div_);
void (*getareachar_skillunit) (struct map_session_data *sd, struct skill_unit *unit);
void (*getareachar_unit) (struct map_session_data* sd,struct block_list *bl);
@@ -493,6 +505,7 @@ struct clif_interface {
void (*map_property_mapall) (int map, enum map_property property);
void (*bossmapinfo) (int fd, struct mob_data *md, short flag);
void (*map_type) (struct map_session_data* sd, enum map_type type);
+ void (*maptypeproperty2) (struct block_list *bl,enum send_target t);
/* multi-map-server */
void (*changemapserver) (struct map_session_data* sd, unsigned short map_index, int x, int y, uint32 ip, uint16 port);
/* npc-shop-related */
@@ -553,7 +566,7 @@ struct clif_interface {
void (*mvp_noitem) (struct map_session_data* sd);
void (*changed_dir) (struct block_list *bl, enum send_target target);
void (*charnameack) (int fd, struct block_list *bl);
- void (*monster_hp_bar) ( struct mob_data* md, int fd );
+ void (*monster_hp_bar) ( struct mob_data* md );
int (*hpmeter) (struct map_session_data *sd);
void (*hpmeter_single) (int fd, int id, unsigned int hp, unsigned int maxhp);
int (*hpmeter_sub) (struct block_list *bl, va_list ap);
@@ -566,6 +579,7 @@ struct clif_interface {
void (*hate_info) (struct map_session_data *sd, unsigned char hate_level,int class_, unsigned char type);
void (*mission_info) (struct map_session_data *sd, int mob_id, unsigned char progress);
void (*feel_hate_reset) (struct map_session_data *sd);
+ void (*partytickack) (struct map_session_data* sd, bool flag);
void (*equiptickack) (struct map_session_data* sd, int flag);
void (*viewequip_ack) (struct map_session_data* sd, struct map_session_data* tsd);
void (*viewequip_fail) (struct map_session_data* sd);
@@ -662,7 +676,7 @@ struct clif_interface {
void (*msgtable) (int fd, int line);
void (*msgtable_num) (int fd, int line, int num);
void (*message) (const int fd, const char* mes);
- int (*colormes) (struct map_session_data * sd, enum clif_colors color, const char* msg);
+ int (*colormes) (int fd, enum clif_colors color, const char* msg);
bool (*process_message) (struct map_session_data* sd, int format, char** name_, int* namelen_, char** message_, int* messagelen_);
void (*wisexin) (struct map_session_data *sd,int type,int flag);
void (*wisall) (struct map_session_data *sd,int type,int flag);
@@ -680,7 +694,7 @@ struct clif_interface {
void (*openvendingreq) (struct map_session_data* sd, int num);
void (*showvendingboard) (struct block_list* bl, const char* message, int fd);
void (*closevendingboard) (struct block_list* bl, int fd);
- void (*vendinglist) (struct map_session_data* sd, int id, struct s_vending* vending);
+ void (*vendinglist) (struct map_session_data* sd, unsigned int id, struct s_vending* vending);
void (*buyvending) (struct map_session_data* sd, int index, int amount, int fail);
void (*openvending) (struct map_session_data* sd, int id, struct s_vending* vending);
void (*vendingreport) (struct map_session_data* sd, int index, int amount);
@@ -853,11 +867,15 @@ struct clif_interface {
void (*noask_sub) (struct map_session_data *src, struct map_session_data *target, int type);
void (*chsys_create) (struct hChSysCh *channel, char *name, char *pass, unsigned char color);
void (*chsys_msg) (struct hChSysCh *channel, struct map_session_data *sd, char *msg);
+ void (*chsys_msg2) (struct hChSysCh *channel, char *msg);
void (*chsys_send) (struct hChSysCh *channel, struct map_session_data *sd, char *msg);
void (*chsys_join) (struct hChSysCh *channel, struct map_session_data *sd);
void (*chsys_left) (struct hChSysCh *channel, struct map_session_data *sd);
void (*chsys_delete) (struct hChSysCh *channel);
void (*chsys_mjoin) (struct map_session_data *sd);
+ void (*chsys_quit) (struct map_session_data *sd);
+ void (*chsys_quitg) (struct map_session_data *sd);
+ void (*bc_ready) (void);
/*------------------------
*- Parse Incoming Packet
*------------------------*/
@@ -1060,6 +1078,7 @@ struct clif_interface {
void (*pCashShopClose) (int fd, struct map_session_data *sd);
void (*pCashShopSchedule) (int fd, struct map_session_data *sd);
void (*pCashShopBuy) (int fd, struct map_session_data *sd);
+ void (*pPartyTick) (int fd, struct map_session_data *sd);
} clif_s;
struct clif_interface *clif;
diff --git a/src/map/duel.c b/src/map/duel.c
index 1c659bd33..7af427304 100644
--- a/src/map/duel.c
+++ b/src/map/duel.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/cbasetypes.h"
@@ -95,7 +96,7 @@ int duel_create(struct map_session_data* sd, const unsigned int maxpl)
clif->disp_onlyself(sd, output, strlen(output));
clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
- //clif->misceffect2(&sd->bl, 159);
+ clif->maptypeproperty2(&sd->bl,SELF);
return i;
}
@@ -141,6 +142,7 @@ void duel_leave(const unsigned int did, struct map_session_data* sd)
sd->duel_group = 0;
duel_savetime(sd);
clif->map_property(sd, MAPPROPERTY_NOTHING);
+ clif->maptypeproperty2(&sd->bl,SELF);
}
void duel_accept(const unsigned int did, struct map_session_data* sd)
@@ -157,7 +159,7 @@ void duel_accept(const unsigned int did, struct map_session_data* sd)
clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
- //clif->misceffect2(&sd->bl, 159);
+ clif->maptypeproperty2(&sd->bl,SELF);
}
void duel_reject(const unsigned int did, struct map_session_data* sd)
diff --git a/src/map/guild.c b/src/map/guild.c
index 9b128c4e1..cc9b3e812 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -549,6 +549,7 @@ int guild_recv_info(struct guild *sg) {
guild_block_skill(sd, 300000);
//Also set the guild master flag.
+ sd->guild = g;
sd->state.gmaster_flag = g;
clif->charnameupdate(sd); // [LuzZza]
clif->guild_masterormember(sd);
@@ -582,7 +583,7 @@ int guild_recv_info(struct guild *sg) {
sd = g->member[i].sd;
if( sd==NULL )
continue;
-
+ sd->guild = g;
if (before.guild_lv != g->guild_lv || bm != m ||
before.max_member != g->max_member) {
clif->guild_basicinfo(sd); //Submit basic information
@@ -754,12 +755,15 @@ void guild_member_joined(struct map_session_data *sd)
if( hChSys.ally && hChSys.ally_autojoin ) {
struct guild* sg = NULL;
- clif->chsys_join((struct hChSysCh*)g->channel,sd);
+ struct hChSysCh *channel = (struct hChSysCh*)g->channel;
+
+ if( !(channel->banned && idb_exists(channel->banned, sd->status.account_id) ) )
+ clif->chsys_join(channel,sd);
for (i = 0; i < MAX_GUILDALLIANCE; i++) {
if( g->alliance[i].guild_id && (sg = guild_search(g->alliance[i].guild_id) ) ) {
- clif->chsys_join((struct hChSysCh*)sg->channel,sd);
- break;
+ if( !(((struct hChSysCh*)sg->channel)->banned && idb_exists(((struct hChSysCh*)sg->channel)->banned, sd->status.account_id)))
+ clif->chsys_join((struct hChSysCh*)sg->channel,sd);
}
}
}
@@ -902,17 +906,13 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c
clif->guild_memberlist(online_member_sd);
// update char, if online
- if(sd != NULL && sd->status.guild_id == guild_id)
- {
+ if(sd != NULL && sd->status.guild_id == guild_id) {
// do stuff that needs the guild_id first, BEFORE we wipe it
if (sd->state.storage_flag == 2) //Close the guild storage.
storage_guild_storageclose(sd);
guild_send_dot_remove(sd);
if( hChSys.ally ) {
- for (i = 0; i < sd->channel_count; i++) {
- if( sd->channels[i] && sd->channels[i]->type == hChSys_ALLY )
- clif->chsys_left(sd->channels[i],sd);
- }
+ clif->chsys_quitg(sd);
}
sd->status.guild_id = 0;
sd->guild = NULL;
@@ -1033,7 +1033,7 @@ int guild_send_message(struct map_session_data *sd,const char *mes,int len)
guild_recv_message(sd->status.guild_id,sd->status.account_id,mes,len);
// Chat logging type 'G' / Guild Chat
- log_chat(LOG_CHAT_GUILD, sd->status.guild_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes);
+ logs->chat(LOG_CHAT_GUILD, sd->status.guild_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes);
return 0;
}
@@ -1955,8 +1955,8 @@ int guild_castledatasave(int castle_id, int index, int value)
void guild_castle_reconnect_sub(void *key, void *data, va_list ap)
{
- int castle_id = GetWord((int)__64BPRTSIZE(key), 0);
- int index = GetWord((int)__64BPRTSIZE(key), 1);
+ int castle_id = GetWord((int)__64BPTRSIZE(key), 0);
+ int index = GetWord((int)__64BPTRSIZE(key), 1);
intif_guild_castle_datasave(castle_id, index, *(int *)data);
aFree(data);
}
@@ -1977,7 +1977,7 @@ void guild_castle_reconnect(int castle_id, int index, int value)
int *data;
CREATE(data, int, 1);
*data = value;
- linkdb_replace(&gc_save_pending, (void*)__64BPRTSIZE((MakeDWord(castle_id, index))), data);
+ linkdb_replace(&gc_save_pending, (void*)__64BPTRSIZE((MakeDWord(castle_id, index))), data);
}
}
diff --git a/src/map/intif.c b/src/map/intif.c
index 73b828f00..102dbf84e 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -207,7 +207,7 @@ int intif_main_message(struct map_session_data* sd, const char* message)
intif_broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 );
// log the chat message
- log_chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message );
+ logs->chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message );
return 0;
}
diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c
new file mode 100644
index 000000000..3e7d7eb06
--- /dev/null
+++ b/src/map/irc-bot.c
@@ -0,0 +1,272 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Base Author: shennetsind @ http://hercules.ws
+
+#include "../common/cbasetypes.h"
+#include "../common/malloc.h"
+#include "../common/strlib.h"
+#include "../common/showmsg.h"
+#include "../common/socket.h"
+#include "../common/timer.h"
+#include "../common/random.h"
+
+#include "map.h"
+#include "pc.h"
+#include "clif.h"
+#include "irc-bot.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+char send_string[200];
+
+int irc_connect_timer(int tid, unsigned int tick, int id, intptr_t data) {
+ if( ircbot->fd != -1 || session[ircbot->fd] || ++ircbot->fails >= 3 )
+ return 0;
+
+ ircbot->last_try = gettick();
+ if( ( ircbot->fd = make_connection(ircbot->ip,hChSys.irc_server_port,true) ) > 0 ){
+ session[ircbot->fd]->func_parse = ircbot->parse;
+ session[ircbot->fd]->flag.server = 1;
+ add_timer(gettick() + 3000, ircbot->identify_timer, 0, 0);
+ }
+ return 0;
+}
+
+int irc_identify_timer(int tid, unsigned int tick, int id, intptr_t data) {
+ if( ircbot->fd == -1 )
+ return 0;
+
+ sprintf(send_string, "USER HerculesWS%d 8 * : Hercules IRC Bridge",rand()%777);
+ ircbot->send(send_string);
+ sprintf(send_string, "NICK %s", hChSys.irc_nick);
+ ircbot->send(send_string);
+
+ add_timer(gettick() + 3000, ircbot->join_timer, 0, 0);
+
+ return 0;
+}
+
+int irc_join_timer(int tid, unsigned int tick, int id, intptr_t data) {
+ if( ircbot->fd == -1 )
+ return 0;
+
+ if( hChSys.irc_nick_pw[0] != '\0' ) {
+ sprintf(send_string, "PRIVMSG NICKSERV : IDENTIFY %s", hChSys.irc_nick_pw);
+ ircbot->send(send_string);
+ }
+
+ sprintf(send_string, "JOIN %s", hChSys.irc_channel);
+ ircbot->send(send_string);
+ ircbot->isIn = true;
+
+ return 0;
+}
+
+struct irc_func* irc_func_search(char* function_name) {
+ int i;
+ for(i = 0; i < ircbot->funcs.size; i++) {
+ if( strcmpi(ircbot->funcs.list[i]->name, function_name) == 0 ) {
+ return ircbot->funcs.list[i];
+ }
+ }
+ return NULL;
+}
+
+int irc_parse(int fd) {
+ char *parse_string = NULL, *str_safe = NULL;
+
+ if (session[fd]->flag.eof) {
+ do_close(fd);
+ ircbot->fd = -1;
+ ircbot->isIn = false;
+ ircbot->fails = 0;
+ ircbot->ip = host2ip(hChSys.irc_server);
+ add_timer(gettick() + 120000, ircbot->connect_timer, 0, 0);
+ return 0;
+ }
+
+ if( !RFIFOREST(fd) )
+ return 0;
+
+ parse_string = (char*)RFIFOP(fd,0);
+ parse_string[ RFIFOREST(fd) - 1 ] = '\0';
+
+ parse_string = strtok_r(parse_string,"\r\n",&str_safe);
+
+ while (parse_string != NULL) {
+ ircbot->parse_sub(fd,parse_string);
+ parse_string = strtok_r(NULL,"\r\n",&str_safe);
+ }
+
+ RFIFOSKIP(fd, RFIFOREST(fd));
+ RFIFOFLUSH(fd);
+ return 0;
+}
+
+void irc_parse_source(char *source, char *nick, char *ident, char *host) {
+ int i, len = strlen(source), pos = 0;
+ unsigned char stage = 0;
+
+ for(i = 0; i < len; i++) {
+ if( stage == 0 && source[i] == '!' ) {
+ memcpy(nick, &source[0], len - i);
+ nick[i] = '\0';
+ pos = i+1;
+ stage = 1;
+ } else if( stage == 1 && source[i] == '@' ) {
+ memcpy(ident, &source[pos], i - pos);
+ ident[i-pos] = '\0';
+ memcpy(host, &source[i+1], len);
+ host[len] = '\0';
+ break;
+ }
+ }
+}
+void irc_parse_sub(int fd, char *str) {
+ char source[180], command[60], target[60], message[200];
+ struct irc_func *func;
+
+ source[0] = command[0] = target[0] = message[0] = '\0';
+
+ if( str[0] == ':' )
+ str++;
+
+ sscanf(str, "%179s %59s %59s :%199[^\r\n]", source, command, target, message);
+
+ if( command[0] == '\0' )
+ return;
+
+ if( !(func = ircbot->func_search(command)) && !(func = ircbot->func_search(source)) ) {
+ ShowWarning("Unknown command received %s from %s\n",command,source);
+ return;
+ }
+ func->func(fd,command,source,target,message);
+
+}
+
+void irc_send(char *str) {
+ int len = strlen(str) + 2;
+ WFIFOHEAD(ircbot->fd, len);
+ snprintf((char*)WFIFOP(ircbot->fd,0),200, "%s\r\n", str);
+ WFIFOSET(ircbot->fd, len);
+}
+
+void irc_pong(int fd, char *cmd, char *source, char *target, char *msg) {
+ sprintf(send_string, "PONG %s", cmd);
+ ircbot->send(send_string);
+}
+
+void irc_join(int fd, char *cmd, char *source, char *target, char *msg) {
+ if( ircbot->isIn )
+ return;
+ sprintf(send_string, "JOIN %s", hChSys.irc_channel);
+ ircbot->send(send_string);
+ ircbot->isIn = true;
+}
+
+void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) {
+ if( strcmpi(target,hChSys.irc_nick) == 0 ) {
+ if( strcmpi(msg,"VERSION") == 0 ) {
+ sprintf(send_string, "Hercules.ws IRC Bridge");
+ ircbot->send(send_string);
+ return;
+ }
+ } else if( strcmpi(target,hChSys.irc_channel) == 0 ) {
+ char source_nick[40], source_ident[40], source_host[100];
+
+ source_nick[0] = source_ident[0] = source_host[0] = '\0';
+
+ if( source[0] != '\0' )
+ ircbot->parse_source(source,source_nick,source_ident,source_host);
+
+ snprintf(send_string, 150, "[ #%s ] IRC.%s : %s",ircbot->channel->name,source_nick,msg);
+ clif->chsys_msg2(ircbot->channel,send_string);
+ }
+}
+
+void irc_relay (char *name, char *msg) {
+ if( !ircbot->isIn )
+ return;
+ sprintf(send_string,"PRIVMSG %s :[ %s ] : %s",hChSys.irc_channel,name,msg);
+ ircbot->send(send_string);
+}
+
+void irc_bot_init(void) {
+ const struct irc_func irc_func_base[] = {
+ { "PING" , ircbot->pong },
+ { "PRIVMSG", ircbot->privmsg },
+ };
+ struct irc_func* function;
+ int i;
+
+ if( !hChSys.irc )
+ return;
+
+ if (!(ircbot->ip = host2ip(hChSys.irc_server))) {
+ ShowError("Unable to resolve '%s' (irc server), disabling irc channel...\n", hChSys.irc_server);
+ hChSys.irc = false;
+ return;
+ }
+
+ ircbot->funcs.size = ARRAYLENGTH(irc_func_base);
+
+ CREATE(ircbot->funcs.list,struct irc_func*,ircbot->funcs.size);
+
+ for( i = 0; i < ircbot->funcs.size; i++ ) {
+
+ CREATE(function, struct irc_func, 1);
+
+ safestrncpy(function->name, irc_func_base[i].name, sizeof(function->name));
+ function->func = irc_func_base[i].func;
+
+ ircbot->funcs.list[i] = function;
+ }
+
+ ircbot->fails = 0;
+ ircbot->fd = -1;
+ ircbot->isIn = true;
+
+ add_timer_func_list(ircbot->connect_timer, "irc_connect_timer");
+ add_timer(gettick() + 7000, ircbot->connect_timer, 0, 0);
+}
+
+void irc_bot_final(void) {
+ int i;
+
+ if( !hChSys.irc )
+ return;
+ if( ircbot->fd != -1 ) {
+ ircbot->send("QUIT :Hercules is shutting down");
+ do_close(ircbot->fd);
+ }
+
+ for( i = 0; i < ircbot->funcs.size; i++ ) {
+ aFree(ircbot->funcs.list[i]);
+ }
+ aFree(ircbot->funcs.list);
+}
+
+void ircbot_defaults(void) {
+ ircbot = &irc_bot_s;
+ ircbot->init = irc_bot_init;
+ ircbot->final = irc_bot_final;
+
+ ircbot->parse = irc_parse;
+ ircbot->parse_sub = irc_parse_sub;
+ ircbot->parse_source = irc_parse_source;
+
+ ircbot->func_search = irc_func_search;
+
+ ircbot->connect_timer = irc_connect_timer;
+ ircbot->identify_timer = irc_identify_timer;
+ ircbot->join_timer = irc_join_timer;
+
+ ircbot->send = irc_send;
+ ircbot->relay = irc_relay;
+
+ ircbot->pong = irc_pong;
+ ircbot->join = irc_join;
+ ircbot->privmsg = irc_privmsg;
+}
diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h
new file mode 100644
index 000000000..d1bf0866d
--- /dev/null
+++ b/src/map/irc-bot.h
@@ -0,0 +1,58 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Base Author: shennetsind @ http://hercules.ws
+
+
+#ifndef _IRC_BOT_H_
+#define _IRC_BOT_H_
+
+#define IRC_FUNC_LENGTH 30
+
+struct hChSysCh;
+
+struct irc_func {
+ char name[IRC_FUNC_LENGTH];
+ void (*func)(int, char*, char*, char*, char*);
+};
+
+struct irc_bot_interface {
+ int fd;
+ bool isIn;
+ unsigned int last_try;
+ unsigned char fails;
+ unsigned long ip;
+ unsigned short port;
+ /* */
+ struct hChSysCh *channel;
+ /* */
+ struct {
+ struct irc_func **list;
+ unsigned int size;
+ } funcs;
+ /* */
+ void (*init) (void);
+ void (*final) (void);
+ /* */
+ int (*parse) (int fd);
+ void (*parse_sub) (int fd, char *str);
+ void (*parse_source) (char *source, char *nick, char *ident, char *host);
+ /* */
+ struct irc_func* (*func_search) (char* function_name);
+ /* */
+ int (*connect_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*identify_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*join_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ /* */
+ void (*send)(char *str);
+ void (*relay) (char *name, char *msg);
+ /* */
+ void (*pong) (int fd, char *cmd, char *source, char *target, char *msg);
+ void (*join) (int fd, char *cmd, char *source, char *target, char *msg);
+ void (*privmsg) (int fd, char *cmd, char *source, char *target, char *msg);
+} irc_bot_s;
+
+struct irc_bot_interface *ircbot;
+
+void ircbot_defaults(void);
+
+#endif /* _IRC_BOT_H_ */
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 2b7d27c8a..386f38c5a 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -20,8 +20,6 @@
static struct item_data* itemdb_array[MAX_ITEMDB];
static DBMap* itemdb_other;// int nameid -> struct item_data*
-static struct item_group itemgroup_db[MAX_ITEMGROUP];
-
struct item_data dummy_item; //This is the default dummy item used for non-existant items. [Skotlex]
/**
@@ -466,8 +464,7 @@ int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(stru
/*==========================================
* Specifies if item-type should drop unidentified.
*------------------------------------------*/
-int itemdb_isidentified(int nameid)
-{
+int itemdb_isidentified(int nameid) {
int type=itemdb_type(nameid);
switch (type) {
case IT_WEAPON:
@@ -478,6 +475,18 @@ int itemdb_isidentified(int nameid)
return 1;
}
}
+/* same as itemdb_isidentified but without a lookup */
+int itemdb_isidentified2(struct item_data *data) {
+ switch (data->type) {
+ case IT_WEAPON:
+ case IT_ARMOR:
+ case IT_PETARMOR:
+ return 0;
+ default:
+ return 1;
+ }
+}
+
/*==========================================
* Search by name for the override flags available items
@@ -514,18 +523,18 @@ static bool itemdb_read_itemavail(char* str[], int columns, int current)
/*==========================================
* read item group data
*------------------------------------------*/
-static void itemdb_read_itemgroup_sub(const char* filename)
-{
+static unsigned int itemdb_read_itemgroup_sub(const char* filename) {
FILE *fp;
char line[1024];
int ln=0;
+ unsigned int count = 0;
int groupid,j,k,nameid;
char *str[3],*p;
char w1[1024], w2[1024];
if( (fp=fopen(filename,"r"))==NULL ){
ShowError("can't read %s\n", filename);
- return;
+ return 0;
}
while(fgets(line, sizeof(line), fp))
@@ -536,7 +545,7 @@ static void itemdb_read_itemgroup_sub(const char* filename)
if(strstr(line,"import")) {
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2 &&
strcmpi(w1, "import") == 0) {
- itemdb_read_itemgroup_sub(w2);
+ count += itemdb_read_itemgroup_sub(w2);
continue;
}
}
@@ -570,18 +579,20 @@ static void itemdb_read_itemgroup_sub(const char* filename)
}
for(j=0;j<k;j++)
itemgroup_db[groupid].nameid[itemgroup_db[groupid].qty++] = nameid;
+ count++;
}
fclose(fp);
- return;
+ return count;
}
static void itemdb_read_itemgroup(void)
{
char path[256];
+ unsigned int count;
snprintf(path, 255, "%s/"DBPATH"item_group_db.txt", db_path);
memset(&itemgroup_db, 0, sizeof(itemgroup_db));
- itemdb_read_itemgroup_sub(path);
- ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n", "item_group_db.txt");
+ count = itemdb_read_itemgroup_sub(path);
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, "item_group_db.txt");
return;
}
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 06c95da8a..362b42cff 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -155,6 +155,8 @@ struct item_combo {
bool isRef;/* whether this struct is a reference or the master */
};
+struct item_group itemgroup_db[MAX_ITEMGROUP];
+
struct item_data* itemdb_searchname(const char *name);
int itemdb_searchname_array(struct item_data** data, int size, const char *str);
struct item_data* itemdb_load(int nameid);
@@ -216,6 +218,7 @@ int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(stru
int itemdb_isequip(int);
int itemdb_isequip2(struct item_data *);
int itemdb_isidentified(int);
+int itemdb_isidentified2(struct item_data *data);
int itemdb_isstackable(int);
int itemdb_isstackable2(struct item_data *);
uint64 itemdb_unique_id(int8 flag, int64 value); // Unique Item ID
diff --git a/src/map/log.c b/src/map/log.c
index ca10c97ab..1cca0a098 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/cbasetypes.h"
#include "../common/sql.h" // SQL_INNODB
@@ -19,8 +20,7 @@
/// filters for item logging
-typedef enum e_log_filter
-{
+typedef enum e_log_filter {
LOG_FILTER_NONE = 0x000,
LOG_FILTER_ALL = 0x001,
// bits
@@ -38,10 +38,6 @@ typedef enum e_log_filter
}
e_log_filter;
-
-struct Log_Config log_config;
-
-
#ifdef SQL_INNODB
// database is using an InnoDB engine so do not use DELAYED
#define LOG_QUERY "INSERT"
@@ -52,10 +48,8 @@ struct Log_Config log_config;
/// obtain log type character for item/zeny logs
-static char log_picktype2char(e_log_pick_type type)
-{
- switch( type )
- {
+static char log_picktype2char(e_log_pick_type type) {
+ switch( type ) {
case LOG_TYPE_TRADE: return 'T'; // (T)rade
case LOG_TYPE_VENDING: return 'V'; // (V)ending
case LOG_TYPE_PICKDROP_PLAYER: return 'P'; // (P)player
@@ -83,10 +77,8 @@ static char log_picktype2char(e_log_pick_type type)
/// obtain log type character for chat logs
-static char log_chattype2char(e_log_chat_type type)
-{
- switch( type )
- {
+static char log_chattype2char(e_log_chat_type type) {
+ switch( type ) {
case LOG_CHAT_GLOBAL: return 'O'; // Gl(O)bal
case LOG_CHAT_WHISPER: return 'W'; // (W)hisper
case LOG_CHAT_PARTY: return 'P'; // (P)arty
@@ -101,12 +93,10 @@ static char log_chattype2char(e_log_chat_type type)
/// check if this item should be logged according the settings
-static bool should_log_item(int nameid, int amount, int refine)
-{
- int filter = log_config.filter;
- struct item_data* id;
+static bool should_log_item(int nameid, int amount, int refine, struct item_data *id) {
+ int filter = logs->config.filter;
- if( ( id = itemdb_exists(nameid) ) == NULL )
+ if( id == NULL )
return false;
if( ( filter&LOG_FILTER_ALL ) ||
@@ -117,360 +107,289 @@ static bool should_log_item(int nameid, int amount, int refine)
( filter&LOG_FILTER_ARMOR && id->type == IT_ARMOR ) ||
( filter&LOG_FILTER_CARD && id->type == IT_CARD ) ||
( filter&LOG_FILTER_PETITEM && ( id->type == IT_PETEGG || id->type == IT_PETARMOR ) ) ||
- ( filter&LOG_FILTER_PRICE && id->value_buy >= log_config.price_items_log ) ||
- ( filter&LOG_FILTER_AMOUNT && abs(amount) >= log_config.amount_items_log ) ||
- ( filter&LOG_FILTER_REFINE && refine >= log_config.refine_items_log ) ||
- ( filter&LOG_FILTER_CHANCE && ( ( id->maxchance != -1 && id->maxchance <= log_config.rare_items_log ) || id->nameid == ITEMID_EMPERIUM ) )
+ ( filter&LOG_FILTER_PRICE && id->value_buy >= logs->config.price_items_log ) ||
+ ( filter&LOG_FILTER_AMOUNT && abs(amount) >= logs->config.amount_items_log ) ||
+ ( filter&LOG_FILTER_REFINE && refine >= logs->config.refine_items_log ) ||
+ ( filter&LOG_FILTER_CHANCE && ( ( id->maxchance != -1 && id->maxchance <= logs->config.rare_items_log ) || id->nameid == ITEMID_EMPERIUM ) )
)
return true;
return false;
}
-
+void log_branch_sub_sql(struct map_session_data* sd) {
+ SqlStmt* stmt;
+ stmt = SqlStmt_Malloc(logmysql_handle);
+ if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', ?, '%s')", logs->config.log_branch, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
+ || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
+ || SQL_SUCCESS != SqlStmt_Execute(stmt) )
+ {
+ SqlStmt_ShowDebug(stmt);
+ SqlStmt_Free(stmt);
+ return;
+ }
+ SqlStmt_Free(stmt);
+}
+void log_branch_sub_txt(struct map_session_data* sd) {
+ char timestring[255];
+ time_t curtime;
+ FILE* logfp;
+
+ if( ( logfp = fopen(logs->config.log_branch, "a") ) == NULL )
+ return;
+ time(&curtime);
+ strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d:%d]\t%s\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex));
+ fclose(logfp);
+}
/// logs items, that summon monsters
-void log_branch(struct map_session_data* sd)
-{
+void log_branch(struct map_session_data* sd) {
nullpo_retv(sd);
- if( !log_config.branch )
+ if( !logs->config.branch )
return;
- if( log_config.sql_logs ) {
-#ifdef BETA_THREAD_TEST
- char entry[512];
- int e_length = 0;
- e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%s')", log_config.log_branch, sd->status.account_id, sd->status.char_id, sd->status.name, mapindex_id2name(sd->mapindex));
- queryThread_log(entry,e_length);
-#else
- SqlStmt* stmt;
- stmt = SqlStmt_Malloc(logmysql_handle);
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', ?, '%s')", log_config.log_branch, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_Execute(stmt) )
- {
- SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
- return;
- }
- SqlStmt_Free(stmt);
-#endif
- }
- else
+ logs->branch_sub(sd);
+}
+void log_pick_sub_sql(int id, int16 m, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) {
+ if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `unique_id`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%"PRIu64"')",
+ logs->config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id) )
{
- char timestring[255];
- time_t curtime;
- FILE* logfp;
-
- if( ( logfp = fopen(log_config.log_branch, "a") ) == NULL )
- return;
- time(&curtime);
- strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
- fprintf(logfp,"%s - %s[%d:%d]\t%s\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex));
- fclose(logfp);
+ Sql_ShowDebug(logmysql_handle);
+ return;
}
}
-
+void log_pick_sub_txt(int id, int16 m, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) {
+ char timestring[255];
+ time_t curtime;
+ FILE* logfp;
+
+ if( ( logfp = fopen(logs->config.log_pick, "a") ) == NULL )
+ return;
+ time(&curtime);
+ strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %d\t%c\t%d,%d,%d,%d,%d,%d,%d,%s,'%"PRIu64"'\n", timestring, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id);
+ fclose(logfp);
+}
/// logs item transactions (generic)
-void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* itm)
-{
+void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) {
nullpo_retv(itm);
- if( ( log_config.enable_logs&type ) == 0 )
- {// disabled
+ if( ( logs->config.enable_logs&type ) == 0 ) {// disabled
return;
}
- if( !should_log_item(itm->nameid, amount, itm->refine) )
+ if( !should_log_item(itm->nameid, amount, itm->refine, data) )
return; //we skip logging this item set - it doesn't meet our logging conditions [Lupus]
- if( log_config.sql_logs )
- {
-#ifdef BETA_THREAD_TEST
- char entry[512];
- int e_length = 0;
- e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `unique_id`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%"PRIu64"')",
- log_config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id);
- queryThread_log(entry,e_length);
-#else
- if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `unique_id`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%"PRIu64"')",
- log_config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id) )
- {
- Sql_ShowDebug(logmysql_handle);
- return;
- }
-#endif
- }
- else
- {
- char timestring[255];
- time_t curtime;
- FILE* logfp;
-
- if( ( logfp = fopen(log_config.log_pick, "a") ) == NULL )
- return;
- time(&curtime);
- strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
- fprintf(logfp,"%s - %d\t%c\t%d,%d,%d,%d,%d,%d,%d,%s,'%"PRIu64"'\n", timestring, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id);
- fclose(logfp);
- }
+ logs->pick_sub(id,m,type,amount,itm,data);
}
/// logs item transactions (players)
-void log_pick_pc(struct map_session_data* sd, e_log_pick_type type, int amount, struct item* itm)
-{
+void log_pick_pc(struct map_session_data* sd, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) {
nullpo_retv(sd);
- log_pick(sd->status.char_id, sd->bl.m, type, amount, itm);
+ log_pick(sd->status.char_id, sd->bl.m, type, amount, itm, data ? data : itemdb_exists(itm->nameid));
}
/// logs item transactions (monsters)
-void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct item* itm)
-{
+void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) {
nullpo_retv(md);
- log_pick(md->class_, md->bl.m, type, amount, itm);
+ log_pick(md->class_, md->bl.m, type, amount, itm, data ? data : itemdb_exists(itm->nameid));
+}
+void log_zeny_sub_sql(struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount) {
+ if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')",
+ logs->config.log_zeny, sd->status.char_id, src_sd->status.char_id, log_picktype2char(type), amount, mapindex_id2name(sd->mapindex)) )
+ {
+ Sql_ShowDebug(logmysql_handle);
+ return;
+ }
+}
+void log_zeny_sub_txt(struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount) {
+ char timestring[255];
+ time_t curtime;
+ FILE* logfp;
+
+ if( ( logfp = fopen(logs->config.log_zeny, "a") ) == NULL )
+ return;
+ time(&curtime);
+ strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp, "%s - %s[%d]\t%s[%d]\t%d\t\n", timestring, src_sd->status.name, src_sd->status.account_id, sd->status.name, sd->status.account_id, amount);
+ fclose(logfp);
}
-
/// logs zeny transactions
void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount)
{
nullpo_retv(sd);
- if( !log_config.zeny || ( log_config.zeny != 1 && abs(amount) < log_config.zeny ) )
+ if( !logs->config.zeny || ( logs->config.zeny != 1 && abs(amount) < logs->config.zeny ) )
return;
- if( log_config.sql_logs )
- {
-#ifdef BETA_THREAD_TEST
- char entry[512];
- int e_length = 0;
- e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')",
- log_config.log_zeny, sd->status.char_id, src_sd->status.char_id, log_picktype2char(type), amount, mapindex_id2name(sd->mapindex));
- queryThread_log(entry,e_length);
-#else
- if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')",
- log_config.log_zeny, sd->status.char_id, src_sd->status.char_id, log_picktype2char(type), amount, mapindex_id2name(sd->mapindex)) )
- {
- Sql_ShowDebug(logmysql_handle);
- return;
- }
-#endif
- }
- else
+ logs->zeny_sub(sd,type,src_sd,amount);
+}
+void log_mvpdrop_sub_sql(struct map_session_data* sd, int monster_id, int* log_mvp) {
+ if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ",
+ logs->config.log_mvpdrop, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)) )
{
- char timestring[255];
- time_t curtime;
- FILE* logfp;
-
- if( ( logfp = fopen(log_config.log_zeny, "a") ) == NULL )
- return;
- time(&curtime);
- strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
- fprintf(logfp, "%s - %s[%d]\t%s[%d]\t%d\t\n", timestring, src_sd->status.name, src_sd->status.account_id, sd->status.name, sd->status.account_id, amount);
- fclose(logfp);
+ Sql_ShowDebug(logmysql_handle);
+ return;
}
}
-
-
+void log_mvpdrop_sub_txt(struct map_session_data* sd, int monster_id, int* log_mvp) {
+ char timestring[255];
+ time_t curtime;
+ FILE* logfp;
+
+ if( ( logfp = fopen(logs->config.log_mvpdrop,"a") ) == NULL )
+ return;
+ time(&curtime);
+ strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1]);
+ fclose(logfp);
+}
/// logs MVP monster rewards
void log_mvpdrop(struct map_session_data* sd, int monster_id, int* log_mvp)
{
nullpo_retv(sd);
- if( !log_config.mvpdrop )
+ if( !logs->config.mvpdrop )
return;
- if( log_config.sql_logs )
- {
-#ifdef BETA_THREAD_TEST
- char entry[512];
- int e_length = 0;
- e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ",
- log_config.log_mvpdrop, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex));
- queryThread_log(entry,e_length);
-#else
- if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ",
- log_config.log_mvpdrop, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)) )
- {
- Sql_ShowDebug(logmysql_handle);
- return;
- }
-#endif
- }
- else
+ logs->mvpdrop_sub(sd,monster_id,log_mvp);
+}
+
+void log_atcommand_sub_sql(struct map_session_data* sd, const char* message) {
+ SqlStmt* stmt;
+
+ stmt = SqlStmt_Malloc(logmysql_handle);
+ if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", logs->config.log_gm, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
+ || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
+ || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
+ || SQL_SUCCESS != SqlStmt_Execute(stmt) )
{
- char timestring[255];
- time_t curtime;
- FILE* logfp;
-
- if( ( logfp = fopen(log_config.log_mvpdrop,"a") ) == NULL )
- return;
- time(&curtime);
- strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
- fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1]);
- fclose(logfp);
+ SqlStmt_ShowDebug(stmt);
+ SqlStmt_Free(stmt);
+ return;
}
+ SqlStmt_Free(stmt);
+}
+void log_atcommand_sub_txt(struct map_session_data* sd, const char* message) {
+ char timestring[255];
+ time_t curtime;
+ FILE* logfp;
+
+ if( ( logfp = fopen(logs->config.log_gm, "a") ) == NULL )
+ return;
+ time(&curtime);
+ strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message);
+ fclose(logfp);
}
-
-
/// logs used atcommands
void log_atcommand(struct map_session_data* sd, const char* message)
{
nullpo_retv(sd);
- if( !log_config.commands ||
+ if( !logs->config.commands ||
!pc_should_log_commands(sd) )
return;
- if( log_config.sql_logs )
+ logs->atcommand_sub(sd,message);
+}
+
+void log_npc_sub_sql(struct map_session_data *sd, const char *message) {
+ SqlStmt* stmt;
+ stmt = SqlStmt_Malloc(logmysql_handle);
+ if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", logs->config.log_npc, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
+ || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
+ || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
+ || SQL_SUCCESS != SqlStmt_Execute(stmt) )
{
-#ifdef BETA_THREAD_TEST
- char entry[512];
- int e_length = 0;
- e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', '%s', '%s', '%s')", log_config.log_gm, sd->status.account_id, sd->status.char_id, sd->status.name ,mapindex_id2name(sd->mapindex), message);
- queryThread_log(entry,e_length);
-#else
- SqlStmt* stmt;
-
- stmt = SqlStmt_Malloc(logmysql_handle);
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_gm, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
- || SQL_SUCCESS != SqlStmt_Execute(stmt) )
- {
- SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
- return;
- }
+ SqlStmt_ShowDebug(stmt);
SqlStmt_Free(stmt);
-#endif
- }
- else
- {
- char timestring[255];
- time_t curtime;
- FILE* logfp;
-
- if( ( logfp = fopen(log_config.log_gm, "a") ) == NULL )
- return;
- time(&curtime);
- strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
- fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message);
- fclose(logfp);
+ return;
}
+ SqlStmt_Free(stmt);
+}
+void log_npc_sub_txt(struct map_session_data *sd, const char *message) {
+ char timestring[255];
+ time_t curtime;
+ FILE* logfp;
+
+ if( ( logfp = fopen(logs->config.log_npc, "a") ) == NULL )
+ return;
+ time(&curtime);
+ strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message);
+ fclose(logfp);
}
-
-
/// logs messages passed to script command 'logmes'
void log_npc(struct map_session_data* sd, const char* message)
{
nullpo_retv(sd);
- if( !log_config.npc )
+ if( !logs->config.npc )
return;
- if( log_config.sql_logs )
+ logs->npc_sub(sd,message);
+}
+
+void log_chat_sub_sql(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message) {
+ SqlStmt* stmt;
+
+ stmt = SqlStmt_Malloc(logmysql_handle);
+ if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", logs->config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y)
+ || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH))
+ || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX))
+ || SQL_SUCCESS != SqlStmt_Execute(stmt) )
{
-#ifdef BETA_THREAD_TEST
- char entry[512];
- int e_length = 0;
- e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', '%s', '%s', '%s')", log_config.log_npc, sd->status.account_id, sd->status.char_id, sd->status.name, mapindex_id2name(sd->mapindex), message );
- queryThread_log(entry,e_length);
-#else
- SqlStmt* stmt;
- stmt = SqlStmt_Malloc(logmysql_handle);
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_npc, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
- || SQL_SUCCESS != SqlStmt_Execute(stmt) )
- {
- SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
- return;
- }
+ SqlStmt_ShowDebug(stmt);
SqlStmt_Free(stmt);
-#endif
- }
- else
- {
- char timestring[255];
- time_t curtime;
- FILE* logfp;
-
- if( ( logfp = fopen(log_config.log_npc, "a") ) == NULL )
- return;
- time(&curtime);
- strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
- fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message);
- fclose(logfp);
+ return;
}
+ SqlStmt_Free(stmt);
+}
+void log_chat_sub_txt(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message) {
+ char timestring[255];
+ time_t curtime;
+ FILE* logfp;
+
+ if( ( logfp = fopen(logs->config.log_chat, "a") ) == NULL )
+ return;
+ time(&curtime);
+ strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y, dst_charname, message);
+ fclose(logfp);
}
-
/// logs chat
void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message)
{
- if( ( log_config.chat&type ) == 0 )
+ if( ( logs->config.chat&type ) == 0 )
{// disabled
return;
}
- if( log_config.log_chat_woe_disable && ( agit_flag || agit2_flag ) )
+ if( logs->config.log_chat_woe_disable && ( agit_flag || agit2_flag ) )
{// no chat logging during woe
return;
}
- if( log_config.sql_logs ) {
-#ifdef BETA_THREAD_TEST
- char entry[512];
- int e_length = 0;
- e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', '%s', '%s')", log_config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y, dst_charname, message );
- queryThread_log(entry,e_length);
-#else
- SqlStmt* stmt;
-
- stmt = SqlStmt_Malloc(logmysql_handle);
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", log_config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y)
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX))
- || SQL_SUCCESS != SqlStmt_Execute(stmt) )
- {
- SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
- return;
- }
- SqlStmt_Free(stmt);
-#endif
- }
- else
- {
- char timestring[255];
- time_t curtime;
- FILE* logfp;
-
- if( ( logfp = fopen(log_config.log_chat, "a") ) == NULL )
- return;
- time(&curtime);
- strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
- fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y, dst_charname, message);
- fclose(logfp);
- }
+ logs->chat_sub(type,type_id,src_charid,src_accid,map,x,y,dst_charname,message);
}
-void log_set_defaults(void)
-{
- memset(&log_config, 0, sizeof(log_config));
+void log_set_defaults(void) {
+ memset(&logs->config, 0, sizeof(logs->config));
//LOG FILTER Default values
- log_config.refine_items_log = 5; // log refined items, with refine >= +5
- log_config.rare_items_log = 100; // log rare items. drop chance <= 1%
- log_config.price_items_log = 1000; // 1000z
- log_config.amount_items_log = 100;
+ logs->config.refine_items_log = 5; // log refined items, with refine >= +5
+ logs->config.rare_items_log = 100; // log rare items. drop chance <= 1%
+ logs->config.price_items_log = 1000; // 1000z
+ logs->config.amount_items_log = 100;
}
-int log_config_read(const char* cfgName)
-{
+int log_config_read(const char* cfgName) {
static int count = 0;
char line[1024], w1[1024], w2[1024];
FILE *fp;
@@ -478,63 +397,60 @@ int log_config_read(const char* cfgName)
if( count++ == 0 )
log_set_defaults();
- if( ( fp = fopen(cfgName, "r") ) == NULL )
- {
+ if( ( fp = fopen(cfgName, "r") ) == NULL ) {
ShowError("Log configuration file not found at: %s\n", cfgName);
return 1;
}
- while( fgets(line, sizeof(line), fp) )
- {
+ while( fgets(line, sizeof(line), fp) ) {
if( line[0] == '/' && line[1] == '/' )
continue;
- if( sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2 )
- {
+ if( sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2 ) {
if( strcmpi(w1, "enable_logs") == 0 )
- log_config.enable_logs = (e_log_pick_type)config_switch(w2);
+ logs->config.enable_logs = (e_log_pick_type)config_switch(w2);
else if( strcmpi(w1, "sql_logs") == 0 )
- log_config.sql_logs = (bool)config_switch(w2);
+ logs->config.sql_logs = (bool)config_switch(w2);
//start of common filter settings
else if( strcmpi(w1, "rare_items_log") == 0 )
- log_config.rare_items_log = atoi(w2);
+ logs->config.rare_items_log = atoi(w2);
else if( strcmpi(w1, "refine_items_log") == 0 )
- log_config.refine_items_log = atoi(w2);
+ logs->config.refine_items_log = atoi(w2);
else if( strcmpi(w1, "price_items_log") == 0 )
- log_config.price_items_log = atoi(w2);
+ logs->config.price_items_log = atoi(w2);
else if( strcmpi(w1, "amount_items_log") == 0 )
- log_config.amount_items_log = atoi(w2);
+ logs->config.amount_items_log = atoi(w2);
//end of common filter settings
else if( strcmpi(w1, "log_branch") == 0 )
- log_config.branch = config_switch(w2);
+ logs->config.branch = config_switch(w2);
else if( strcmpi(w1, "log_filter") == 0 )
- log_config.filter = config_switch(w2);
+ logs->config.filter = config_switch(w2);
else if( strcmpi(w1, "log_zeny") == 0 )
- log_config.zeny = config_switch(w2);
+ logs->config.zeny = config_switch(w2);
else if( strcmpi(w1, "log_commands") == 0 )
- log_config.commands = config_switch(w2);
+ logs->config.commands = config_switch(w2);
else if( strcmpi(w1, "log_npc") == 0 )
- log_config.npc = config_switch(w2);
+ logs->config.npc = config_switch(w2);
else if( strcmpi(w1, "log_chat") == 0 )
- log_config.chat = config_switch(w2);
+ logs->config.chat = config_switch(w2);
else if( strcmpi(w1, "log_mvpdrop") == 0 )
- log_config.mvpdrop = config_switch(w2);
+ logs->config.mvpdrop = config_switch(w2);
else if( strcmpi(w1, "log_chat_woe_disable") == 0 )
- log_config.log_chat_woe_disable = (bool)config_switch(w2);
+ logs->config.log_chat_woe_disable = (bool)config_switch(w2);
else if( strcmpi(w1, "log_branch_db") == 0 )
- safestrncpy(log_config.log_branch, w2, sizeof(log_config.log_branch));
+ safestrncpy(logs->config.log_branch, w2, sizeof(logs->config.log_branch));
else if( strcmpi(w1, "log_pick_db") == 0 )
- safestrncpy(log_config.log_pick, w2, sizeof(log_config.log_pick));
+ safestrncpy(logs->config.log_pick, w2, sizeof(logs->config.log_pick));
else if( strcmpi(w1, "log_zeny_db") == 0 )
- safestrncpy(log_config.log_zeny, w2, sizeof(log_config.log_zeny));
+ safestrncpy(logs->config.log_zeny, w2, sizeof(logs->config.log_zeny));
else if( strcmpi(w1, "log_mvpdrop_db") == 0 )
- safestrncpy(log_config.log_mvpdrop, w2, sizeof(log_config.log_mvpdrop));
+ safestrncpy(logs->config.log_mvpdrop, w2, sizeof(logs->config.log_mvpdrop));
else if( strcmpi(w1, "log_gm_db") == 0 )
- safestrncpy(log_config.log_gm, w2, sizeof(log_config.log_gm));
+ safestrncpy(logs->config.log_gm, w2, sizeof(logs->config.log_gm));
else if( strcmpi(w1, "log_npc_db") == 0 )
- safestrncpy(log_config.log_npc, w2, sizeof(log_config.log_npc));
+ safestrncpy(logs->config.log_npc, w2, sizeof(logs->config.log_npc));
else if( strcmpi(w1, "log_chat_db") == 0 )
- safestrncpy(log_config.log_chat, w2, sizeof(log_config.log_chat));
+ safestrncpy(logs->config.log_chat, w2, sizeof(logs->config.log_chat));
//support the import command, just like any other config
else if( strcmpi(w1,"import") == 0 )
log_config_read(w2);
@@ -545,39 +461,67 @@ int log_config_read(const char* cfgName)
fclose(fp);
- if( --count == 0 )
- {// report final logging state
- const char* target = log_config.sql_logs ? "table" : "file";
+ if( --count == 0 ) {// report final logging state
+ const char* target = logs->config.sql_logs ? "table" : "file";
- if( log_config.enable_logs && log_config.filter )
- {
- ShowInfo("Logging item transactions to %s '%s'.\n", target, log_config.log_pick);
+ if( logs->config.enable_logs && logs->config.filter ) {
+ ShowInfo("Logging item transactions to %s '%s'.\n", target, logs->config.log_pick);
}
- if( log_config.branch )
- {
- ShowInfo("Logging monster summon item usage to %s '%s'.\n", target, log_config.log_pick);
+ if( logs->config.branch ) {
+ ShowInfo("Logging monster summon item usage to %s '%s'.\n", target, logs->config.log_pick);
}
- if( log_config.chat )
- {
- ShowInfo("Logging chat to %s '%s'.\n", target, log_config.log_chat);
+ if( logs->config.chat ) {
+ ShowInfo("Logging chat to %s '%s'.\n", target, logs->config.log_chat);
}
- if( log_config.commands )
- {
- ShowInfo("Logging commands to %s '%s'.\n", target, log_config.log_gm);
+ if( logs->config.commands ) {
+ ShowInfo("Logging commands to %s '%s'.\n", target, logs->config.log_gm);
}
- if( log_config.mvpdrop )
- {
- ShowInfo("Logging MVP monster rewards to %s '%s'.\n", target, log_config.log_mvpdrop);
+ if( logs->config.mvpdrop ) {
+ ShowInfo("Logging MVP monster rewards to %s '%s'.\n", target, logs->config.log_mvpdrop);
}
- if( log_config.npc )
- {
- ShowInfo("Logging 'logmes' messages to %s '%s'.\n", target, log_config.log_npc);
+ if( logs->config.npc ) {
+ ShowInfo("Logging 'logmes' messages to %s '%s'.\n", target, logs->config.log_npc);
}
- if( log_config.zeny )
- {
- ShowInfo("Logging Zeny transactions to %s '%s'.\n", target, log_config.log_zeny);
+ if( logs->config.zeny ) {
+ ShowInfo("Logging Zeny transactions to %s '%s'.\n", target, logs->config.log_zeny);
}
+ logs->config_done();
}
return 0;
}
+void log_config_complete(void) {
+ if( logs->config.sql_logs ) {
+ logs->pick_sub = log_pick_sub_sql;
+ logs->zeny_sub = log_zeny_sub_sql;
+ logs->npc_sub = log_npc_sub_sql;
+ logs->chat_sub = log_chat_sub_sql;
+ logs->atcommand_sub = log_atcommand_sub_sql;
+ logs->branch_sub = log_branch_sub_sql;
+ logs->mvpdrop_sub = log_mvpdrop_sub_sql;
+ }
+}
+void log_defaults(void) {
+ logs = &log_s;
+
+ logs->pick_pc = log_pick_pc;
+ logs->pick_mob = log_pick_mob;
+ logs->zeny = log_zeny;
+ logs->npc = log_npc;
+ logs->chat = log_chat;
+ logs->atcommand = log_atcommand;
+ logs->branch = log_branch;
+ logs->mvpdrop = log_mvpdrop;
+ logs->config_read = log_config_read;
+ logs->config_done = log_config_complete;
+
+ /* will be modified in a few seconds once loading is complete. */
+ logs->pick_sub = log_pick_sub_txt;
+ logs->zeny_sub = log_zeny_sub_txt;
+ logs->npc_sub = log_npc_sub_txt;
+ logs->chat_sub = log_chat_sub_txt;
+ logs->atcommand_sub = log_atcommand_sub_txt;
+ logs->branch_sub = log_branch_sub_txt;
+ logs->mvpdrop_sub = log_mvpdrop_sub_txt;
+
+}
diff --git a/src/map/log.h b/src/map/log.h
index a40a3fcf4..462a12ff5 100644
--- a/src/map/log.h
+++ b/src/map/log.h
@@ -1,18 +1,18 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _LOG_H_
#define _LOG_H_
-//#include "map.h"
struct block_list;
struct map_session_data;
struct mob_data;
struct item;
+struct item_data;
-typedef enum e_log_chat_type
-{
+typedef enum e_log_chat_type {
LOG_CHAT_GLOBAL = 0x01,
LOG_CHAT_WHISPER = 0x02,
LOG_CHAT_PARTY = 0x04,
@@ -20,12 +20,10 @@ typedef enum e_log_chat_type
LOG_CHAT_MAINCHAT = 0x10,
// all
LOG_CHAT_ALL = 0xFF,
-}
-e_log_chat_type;
+} e_log_chat_type;
-typedef enum e_log_pick_type
-{
+typedef enum e_log_pick_type {
LOG_TYPE_NONE = 0,
LOG_TYPE_TRADE = 0x00001,
LOG_TYPE_VENDING = 0x00002,
@@ -48,42 +46,42 @@ typedef enum e_log_pick_type
LOG_TYPE_LOOT = LOG_TYPE_PICKDROP_MONSTER|LOG_TYPE_CONSUME,
// all
LOG_TYPE_ALL = 0xFFFFF,
-}
-e_log_pick_type;
+} e_log_pick_type;
+struct log_interface {
+ struct {
+ e_log_pick_type enable_logs;
+ int filter;
+ bool sql_logs;
+ bool log_chat_woe_disable;
+ int rare_items_log,refine_items_log,price_items_log,amount_items_log;
+ int branch, mvpdrop, zeny, commands, npc, chat;
+ char log_branch[64], log_pick[64], log_zeny[64], log_mvpdrop[64], log_gm[64], log_npc[64], log_chat[64];
+ } config;
+ /* */
+ void (*pick_pc) (struct map_session_data* sd, e_log_pick_type type, int amount, struct item* itm, struct item_data *data);
+ void (*pick_mob) (struct mob_data* md, e_log_pick_type type, int amount, struct item* itm, struct item_data *data);
+ void (*zeny) (struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount);
+ void (*npc) (struct map_session_data* sd, const char *message);
+ void (*chat) (e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message);
+ void (*atcommand) (struct map_session_data* sd, const char* message);
+ void (*branch) (struct map_session_data* sd);
+ void (*mvpdrop) (struct map_session_data* sd, int monster_id, int* log_mvp);
+
+ void (*pick_sub) (int id, int16 m, e_log_pick_type type, int amount, struct item* itm, struct item_data *data);
+ void (*zeny_sub) (struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount);
+ void (*npc_sub) (struct map_session_data* sd, const char *message);
+ void (*chat_sub) (e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message);
+ void (*atcommand_sub) (struct map_session_data* sd, const char* message);
+ void (*branch_sub) (struct map_session_data* sd);
+ void (*mvpdrop_sub) (struct map_session_data* sd, int monster_id, int* log_mvp);
+
+ int (*config_read) (const char* cfgName);
+ void (*config_done) (void);
+} log_s;
-/// new logs
-void log_pick_pc(struct map_session_data* sd, e_log_pick_type type, int amount, struct item* itm);
-void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct item* itm);
-void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount);
-
-void log_npc(struct map_session_data* sd, const char *message);
-void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message);
-void log_atcommand(struct map_session_data* sd, const char* message);
-
-/// old, but useful logs
-void log_branch(struct map_session_data* sd);
-void log_mvpdrop(struct map_session_data* sd, int monster_id, int* log_mvp);
-
-int log_config_read(const char* cfgName);
-
-extern struct Log_Config
-{
- e_log_pick_type enable_logs;
- int filter;
- bool sql_logs;
- bool log_chat_woe_disable;
- int rare_items_log,refine_items_log,price_items_log,amount_items_log; //for filter
- int branch, mvpdrop, zeny, commands, npc, chat;
- char log_branch[64], log_pick[64], log_zeny[64], log_mvpdrop[64], log_gm[64], log_npc[64], log_chat[64];
-}
-log_config;
+struct log_interface *logs;
-#ifdef BETA_THREAD_TEST
- struct {
- char** entry;
- int count;
- } logThreadData;
-#endif
+void log_defaults(void);
#endif /* _LOG_H_ */
diff --git a/src/map/mail.c b/src/map/mail.c
index ffb3176c1..fa842b70f 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -175,7 +175,7 @@ void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg)
// This function only check if the mail operations are valid
bool mail_invalid_operation(struct map_session_data *sd)
{
- if( !map[sd->bl.m].flag.town && !pc_can_use_command(sd, "mail", COMMAND_ATCOMMAND) )
+ if( !map[sd->bl.m].flag.town && !pc_can_use_command(sd, "@mail") )
{
ShowWarning("clif->parse_Mail: char '%s' trying to do invalid mail operations.\n", sd->status.name);
return true;
diff --git a/src/map/map.c b/src/map/map.c
index 779070f0e..c65157cb2 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -48,6 +48,8 @@
#include "atcommand.h"
#include "log.h"
#include "mail.h"
+#include "irc-bot.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -413,7 +415,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
if( bl->type == BL_PC && ((TBL_PC*)bl)->shadowform_id ) {//Shadow Form Target Moving
struct block_list *d_bl;
- if( (d_bl = map_id2bl(((TBL_PC*)bl)->shadowform_id)) == NULL || bl->m != d_bl->m || !check_distance_bl(bl,d_bl,10) ) {
+ if( (d_bl = map_id2bl(((TBL_PC*)bl)->shadowform_id)) == NULL || !check_distance_bl(bl,d_bl,10) ) {
if( d_bl )
status_change_end(d_bl,SC__SHADOWFORM,INVALID_TIMER);
((TBL_PC*)bl)->shadowform_id = 0;
@@ -438,7 +440,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
if( sc->data[SC__SHADOWFORM] ) {//Shadow Form Caster Moving
struct block_list *d_bl;
- if( (d_bl = map_id2bl(sc->data[SC__SHADOWFORM]->val2)) == NULL || bl->m != d_bl->m || !check_distance_bl(bl,d_bl,10) )
+ if( (d_bl = map_id2bl(sc->data[SC__SHADOWFORM]->val2)) == NULL || !check_distance_bl(bl,d_bl,10) )
status_change_end(bl,SC__SHADOWFORM,INVALID_TIMER);
}
@@ -1692,38 +1694,18 @@ int map_quit(struct map_session_data *sd) {
if( sd->state.storage_flag == 1 ) sd->state.storage_flag = 0; // No need to Double Save Storage on Quit.
+ if (sd->state.permanent_speed == 1) sd->state.permanent_speed = 0; // Remove lock so speed is set back to normal at login.
+
if( sd->ed ) {
elemental_clean_effect(sd->ed);
unit_remove_map(&sd->ed->bl,CLR_TELEPORT);
}
- if( hChSys.ally && sd->status.guild_id ) {
- struct guild *g = sd->guild, *sg;
- if( g ) {
- if( idb_exists(((struct hChSysCh *)g->channel)->users, sd->status.char_id) )
- clif->chsys_left((struct hChSysCh *)g->channel,sd);
- for (i = 0; i < MAX_GUILDALLIANCE; i++) {
- if( g->alliance[i].guild_id && (sg = guild_search(g->alliance[i].guild_id) ) ) {
- if( idb_exists(((struct hChSysCh *)sg->channel)->users, sd->status.char_id) )
- clif->chsys_left((struct hChSysCh *)sg->channel,sd);
- break;
- }
- }
- }
- }
-
if( hChSys.local && map[sd->bl.m].channel && idb_exists(map[sd->bl.m].channel->users, sd->status.char_id) ) {
clif->chsys_left(map[sd->bl.m].channel,sd);
}
- if( sd->channel_count ) {
- for( i = 0; i < sd->channel_count; i++ ) {
- if( sd->channels[i] != NULL )
- clif->chsys_left(sd->channels[i],sd);
- }
- if( hChSys.closing )
- aFree(sd->channels);
- }
+ clif->chsys_quit(sd);
unit_remove_map_pc(sd,CLR_TELEPORT);
@@ -2924,6 +2906,14 @@ void map_zone_db_clear(void) {
aFree(zone->mapflags[i]);
}
aFree(zone->mapflags);
+ for(i = 0; i < zone->disabled_commands_count; i++) {
+ aFree(zone->disabled_commands[i]);
+ }
+ aFree(zone->disabled_commands);
+ for(i = 0; i < zone->capped_skills_count; i++) {
+ aFree(zone->capped_skills[i]);
+ }
+ aFree(zone->capped_skills);
}
dbi_destroy(iter);
@@ -2939,6 +2929,14 @@ void map_zone_db_clear(void) {
aFree(map_zone_pk.mapflags[i]);
}
aFree(map_zone_pk.mapflags);
+ for(i = 0; i < map_zone_pk.disabled_commands_count; i++) {
+ aFree(map_zone_pk.disabled_commands[i]);
+ }
+ aFree(map_zone_pk.disabled_commands);
+ for(i = 0; i < map_zone_pk.capped_skills_count; i++) {
+ aFree(map_zone_pk.capped_skills[i]);
+ }
+ aFree(map_zone_pk.capped_skills);
/* clear the main zone stuff */
for(i = 0; i < map_zone_all.disabled_skills_count; i++) {
aFree(map_zone_all.disabled_skills[i]);
@@ -2949,6 +2947,14 @@ void map_zone_db_clear(void) {
aFree(map_zone_all.mapflags[i]);
}
aFree(map_zone_all.mapflags);
+ for(i = 0; i < map_zone_all.disabled_commands_count; i++) {
+ aFree(map_zone_all.disabled_commands[i]);
+ }
+ aFree(map_zone_all.disabled_commands);
+ for(i = 0; i < map_zone_all.capped_skills_count; i++) {
+ aFree(map_zone_all.capped_skills[i]);
+ }
+ aFree(map_zone_all.capped_skills);
}
void do_final_maps(void) {
@@ -3308,22 +3314,16 @@ int parse_console(const char* buf)
ShowNotice("Type of command: '%s' || Command: '%s' || Map: '%s' Coords: %d %d\n", type, command, map, x, y);
- if( n == 5 && strcmpi("admin",type) == 0 )
- {
- if( !is_atcommand(sd.fd, &sd, command, 0) )
+ if( n == 5 && strcmpi("admin",type) == 0 ) {
+ if( !atcommand->parse(sd.fd, &sd, command, 0) )
ShowInfo("Console: not atcommand\n");
- }
- else if( n == 2 && strcmpi("server", type) == 0 )
- {
- if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 )
- {
+ } else if( n == 2 && strcmpi("server", type) == 0 ) {
+ if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 ) {
runflag = 0;
}
- }
- else if( strcmpi("ers_report", type) == 0 )
+ } else if( strcmpi("ers_report", type) == 0 )
ers_report();
- else if( strcmpi("help", type) == 0 )
- {
+ else if( strcmpi("help", type) == 0 ) {
ShowInfo("To use GM commands:\n");
ShowInfo(" admin:<gm command>:<map of \"gm\"> <x> <y>\n");
ShowInfo("You can use any GM command that doesn't require the GM.\n");
@@ -3597,20 +3597,16 @@ int map_sql_close(void)
ShowStatus("Close Map DB Connection....\n");
Sql_Free(mmysql_handle);
mmysql_handle = NULL;
-#ifndef BETA_THREAD_TEST
- if (log_config.sql_logs)
- {
+ if (logs->config.sql_logs) {
ShowStatus("Close Log DB Connection....\n");
Sql_Free(logmysql_handle);
logmysql_handle = NULL;
}
-#endif
return 0;
}
int log_sql_init(void)
{
-#ifndef BETA_THREAD_TEST
// log db connection
logmysql_handle = Sql_Malloc();
@@ -3622,7 +3618,6 @@ int log_sql_init(void)
if( strlen(default_codepage) > 0 )
if ( SQL_ERROR == Sql_SetEncoding(logmysql_handle, default_codepage) )
Sql_ShowDebug(logmysql_handle);
-#endif
return 0;
}
void map_zone_change2(int m, struct map_zone_data *zone) {
@@ -4063,15 +4058,6 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
else if( map[m].flag.nightenabled )
map_zone_mf_cache_add(m,"nightenabled");
}
- } else if (!strcmpi(flag,"nogo")) {
- if( state && map[m].flag.nogo )
- ;/* nothing to do */
- else {
- if( state )
- map_zone_mf_cache_add(m,"nogo off");
- else if( map[m].flag.nogo )
- map_zone_mf_cache_add(m,"nogo");
- }
} else if (!strcmpi(flag,"noexp")) {
if( state && map[m].flag.nobaseexp )
;/* nothing to do */
@@ -4450,9 +4436,46 @@ void map_zone_init(void) {
}
}
-enum bl_type map_zone_bl_type(const char *entry) {
+unsigned short map_zone_str2itemid(const char *name) {
+ struct item_data *data;
+
+ if( !name )
+ return 0;
+ if( name[0] == 'I' && name[1] == 'D' && strlen(name) <= 7 ) {
+ if( !( data = itemdb_exists(atoi(name+2))) ) {
+ return 0;
+ }
+ } else {
+ if( !( data = itemdb_searchname(name) ) ) {
+ return 0;
+ }
+ }
+ return data->nameid;
+}
+unsigned short map_zone_str2skillid(const char *name) {
+ unsigned short nameid = 0;
+
+ if( !name )
+ return 0;
+
+ if( name[0] == 'I' && name[1] == 'D' && strlen(name) <= 7 ) {
+ if( !skill->get_index((nameid = atoi(name+2))) )
+ return 0;
+ } else {
+ if( !( nameid = strdb_iget(skilldb_name2id, name) ) ) {
+ return 0;
+ }
+ }
+ return nameid;
+}
+enum bl_type map_zone_bl_type(const char *entry, enum map_zone_skill_subtype *subtype) {
char temp[200], *parse;
enum bl_type bl = BL_NUL;
+ *subtype = MZS_NONE;
+
+ if( !entry )
+ return BL_NUL;
+
safestrncpy(temp, entry, 200);
parse = strtok(temp,"|");
@@ -4467,8 +4490,16 @@ enum bl_type map_zone_bl_type(const char *entry) {
bl |= BL_MER;
else if( strcmpi(parse,"monster") == 0 )
bl |= BL_MOB;
- else if( strcmpi(parse,"elemental") == 0 )
+ else if( strcmpi(parse,"clone") == 0 ) {
+ bl |= BL_MOB;
+ *subtype |= MZS_CLONE;
+ } else if( strcmpi(parse,"mob_boss") == 0 ) {
+ bl |= BL_MOB;
+ *subtype |= MZS_BOSS;
+ } else if( strcmpi(parse,"elemental") == 0 )
bl |= BL_ELEM;
+ else if( strcmpi(parse,"pet") == 0 )
+ bl |= BL_PET;
else if( strcmpi(parse,"all") == 0 )
bl |= BL_ALL;
else if( strcmpi(parse,"none") == 0 ) {
@@ -4480,6 +4511,7 @@ enum bl_type map_zone_bl_type(const char *entry) {
}
return bl;
}
+/* [Ind/Hercules] */
void read_map_zone_db(void) {
config_t map_zone_db;
config_setting_t *zones = NULL;
@@ -4496,15 +4528,18 @@ void read_map_zone_db(void) {
if (zones != NULL) {
struct map_zone_data *zone;
- struct item_data *data;
config_setting_t *zone_e;
config_setting_t *skills;
config_setting_t *items;
config_setting_t *mapflags;
+ config_setting_t *commands;
+ config_setting_t *caps;
const char *name;
const char *zonename;
int i,h,v;
- int zone_count = 0, disabled_skills_count = 0, disabled_items_count = 0, mapflags_count = 0;
+ int zone_count = 0, disabled_skills_count = 0, disabled_items_count = 0, mapflags_count = 0,
+ disabled_commands_count = 0, capped_skills_count = 0;
+ enum map_zone_skill_subtype subtype;
zone_count = config_setting_length(zones);
for (i = 0; i < zone_count; ++i) {
@@ -4530,7 +4565,7 @@ void read_map_zone_db(void) {
}
/* is this the global template? */
- if( strncmpi(zonename,MAP_ZONE_ALL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
+ if( strncmpi(zonename,MAP_ZONE_NORMAL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
zone = &map_zone_all;
is_all = true;
} else if( strncmpi(zonename,MAP_ZONE_PK_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
@@ -4549,14 +4584,14 @@ void read_map_zone_db(void) {
for(h = 0; h < config_setting_length(skills); h++) {
config_setting_t *skill = config_setting_get_elem(skills, h);
name = config_setting_name(skill);
- if( !strdb_exists(skilldb_name2id,name) ) {
+ if( !map_zone_str2skillid(name) ) {
ShowError("map_zone_db: unknown skill (%s) in disabled_skills for zone '%s', skipping skill...\n",name,zone->name);
config_setting_remove_elem(skills,h);
--disabled_skills_count;
--h;
continue;
}
- if( !map_zone_bl_type(config_setting_get_string_elem(skills,h)) )/* we dont remove it from the three due to inheritance */
+ if( !map_zone_bl_type(config_setting_get_string_elem(skills,h),&subtype) )/* we dont remove it from the three due to inheritance */
--disabled_skills_count;
}
/* all ok, process */
@@ -4567,11 +4602,12 @@ void read_map_zone_db(void) {
enum bl_type type;
name = config_setting_name(skill);
- if( (type = map_zone_bl_type(config_setting_get_string_elem(skills,h))) ) { /* only add if enabled */
+ if( (type = map_zone_bl_type(config_setting_get_string_elem(skills,h),&subtype)) ) { /* only add if enabled */
CREATE( entry, struct map_zone_disabled_skill_entry, 1 );
- entry->nameid = strdb_iget(skilldb_name2id, name);
+ entry->nameid = map_zone_str2skillid(name);
entry->type = type;
+ entry->subtype = subtype;
zone->disabled_skills[v++] = entry;
}
@@ -4586,8 +4622,7 @@ void read_map_zone_db(void) {
for(h = 0; h < config_setting_length(items); h++) {
config_setting_t *item = config_setting_get_elem(items, h);
name = config_setting_name(item);
- data = itemdb_searchname(name);
- if( data == NULL ) {
+ if( !map_zone_str2itemid(name) ) {
ShowError("map_zone_db: unknown item (%s) in disabled_items for zone '%s', skipping item...\n",name,zone->name);
config_setting_remove_elem(items,h);
--disabled_items_count;
@@ -4604,8 +4639,7 @@ void read_map_zone_db(void) {
if( config_setting_get_bool(item) ) { /* only add if enabled */
name = config_setting_name(item);
- data = itemdb_searchname(name);
- zone->disabled_items[v++] = data->nameid;
+ zone->disabled_items[v++] = map_zone_str2itemid(name);
}
}
@@ -4627,105 +4661,256 @@ void read_map_zone_db(void) {
zone->mapflags_count = mapflags_count;
}
+ if( (commands = config_setting_get_member(zone_e, "disabled_commands")) != NULL ) {
+ disabled_commands_count = config_setting_length(commands);
+ /* validate */
+ for(h = 0; h < config_setting_length(commands); h++) {
+ config_setting_t *command = config_setting_get_elem(commands, h);
+ name = config_setting_name(command);
+ if( !atcommand->exists(name) ) {
+ ShowError("map_zone_db: unknown command '%s' in disabled_commands for zone '%s', skipping entry...\n",name,zone->name);
+ config_setting_remove_elem(commands,h);
+ --disabled_commands_count;
+ --h;
+ continue;
+ }
+ if( !config_setting_get_int(command) )/* we dont remove it from the three due to inheritance */
+ --disabled_commands_count;
+ }
+ /* all ok, process */
+ CREATE( zone->disabled_commands, struct map_zone_disabled_command_entry *, disabled_commands_count );
+ for(h = 0, v = 0; h < config_setting_length(commands); h++) {
+ config_setting_t *command = config_setting_get_elem(commands, h);
+ struct map_zone_disabled_command_entry * entry;
+ int group_lv;
+ name = config_setting_name(command);
+
+ if( (group_lv = config_setting_get_int(command)) ) { /* only add if enabled */
+ CREATE( entry, struct map_zone_disabled_command_entry, 1 );
+
+ entry->cmd = atcommand->exists(name)->func;
+ entry->group_lv = group_lv;
+
+ zone->disabled_commands[v++] = entry;
+ }
+ }
+ zone->disabled_commands_count = disabled_commands_count;
+ }
+
+ if( (caps = config_setting_get_member(zone_e, "skill_damage_cap")) != NULL ) {
+ capped_skills_count = config_setting_length(caps);
+ /* validate */
+ for(h = 0; h < config_setting_length(caps); h++) {
+ config_setting_t *cap = config_setting_get_elem(caps, h);
+ name = config_setting_name(cap);
+ if( !map_zone_str2skillid(name) ) {
+ ShowError("map_zone_db: unknown skill (%s) in skill_damage_cap for zone '%s', skipping skill...\n",name,zone->name);
+ config_setting_remove_elem(caps,h);
+ --capped_skills_count;
+ --h;
+ continue;
+ }
+ if( !map_zone_bl_type(config_setting_get_string_elem(cap,1),&subtype) )/* we dont remove it from the three due to inheritance */
+ --capped_skills_count;
+ }
+ /* all ok, process */
+ CREATE( zone->capped_skills, struct map_zone_skill_damage_cap_entry *, capped_skills_count );
+ for(h = 0, v = 0; h < config_setting_length(caps); h++) {
+ config_setting_t *cap = config_setting_get_elem(caps, h);
+ struct map_zone_skill_damage_cap_entry * entry;
+ enum bl_type type;
+ name = config_setting_name(cap);
+
+ if( (type = map_zone_bl_type(config_setting_get_string_elem(cap,1),&subtype)) ) { /* only add if enabled */
+ CREATE( entry, struct map_zone_skill_damage_cap_entry, 1 );
+
+ entry->nameid = map_zone_str2skillid(name);
+ entry->cap = config_setting_get_int_elem(cap,0);
+ entry->type = type;
+ entry->subtype = subtype;
+ zone->capped_skills[v++] = entry;
+ }
+ }
+ zone->capped_skills_count = capped_skills_count;
+ }
if( !is_all ) /* global template doesn't go into db -- since it isn't a alloc'd piece of data */
strdb_put(zone_db, zonename, zone);
}
-
+
/* process inheritance, aka loop through the whole thing again :P */
for (i = 0; i < zone_count; ++i) {
config_setting_t *inherit_tree = NULL;
+ config_setting_t *new_entry = NULL;
+ int inherit_count;
zone_e = config_setting_get_elem(zones, i);
+ config_setting_lookup_string(zone_e, "name", &zonename);
+
+ if( strncmpi(zonename,MAP_ZONE_ALL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
+ continue;/* all zone doesn't inherit anything (if it did, everything would link to each other and boom endless loop) */
+ }
if( (inherit_tree = config_setting_get_member(zone_e, "inherit")) != NULL ) {
- int inherit_count = config_setting_length(inherit_tree);
- for(h = 0; h < inherit_count; h++) {
- struct map_zone_data *izone; /* inherit zone */
- int disabled_skills_count_i = 0; /* disabled skill count from inherit zone */
- int disabled_items_count_i = 0; /* disabled item count from inherit zone */
- int mapflags_count_i = 0; /* mapflag count from inherit zone */
- int j;
-
- name = config_setting_get_string_elem(inherit_tree, h);
- config_setting_lookup_string(zone_e, "name", &zonename);/* will succeed for we validated it earlier */
-
- if( !(izone = strdb_get(zone_db, name)) ) {
- ShowError("map_zone_db: Unknown zone '%s' being inherit by zone '%s', skipping...\n",name,zonename);
- continue;
- }
-
+ /* append global zone to this */
+ new_entry = config_setting_add(inherit_tree,MAP_ZONE_ALL_NAME,CONFIG_TYPE_STRING);
+ config_setting_set_string(new_entry,MAP_ZONE_ALL_NAME);
+ } else {
+ /* create inherit member and add global zone to it */
+ inherit_tree = config_setting_add(zone_e, "inherit",CONFIG_TYPE_ARRAY);
+ new_entry = config_setting_add(inherit_tree,MAP_ZONE_ALL_NAME,CONFIG_TYPE_STRING);
+ config_setting_set_string(new_entry,MAP_ZONE_ALL_NAME);
+ }
+ inherit_count = config_setting_length(inherit_tree);
+ for(h = 0; h < inherit_count; h++) {
+ struct map_zone_data *izone; /* inherit zone */
+ int disabled_skills_count_i = 0; /* disabled skill count from inherit zone */
+ int disabled_items_count_i = 0; /* disabled item count from inherit zone */
+ int mapflags_count_i = 0; /* mapflag count from inherit zone */
+ int disabled_commands_count_i = 0; /* commands count from inherit zone */
+ int capped_skills_count_i = 0; /* skill capped count from inherit zone */
+ int j;
+
+ name = config_setting_get_string_elem(inherit_tree, h);
+ config_setting_lookup_string(zone_e, "name", &zonename);/* will succeed for we validated it earlier */
+
+ if( !(izone = strdb_get(zone_db, name)) ) {
+ ShowError("map_zone_db: Unknown zone '%s' being inherit by zone '%s', skipping...\n",name,zonename);
+ continue;
+ }
+
+ if( strncmpi(zonename,MAP_ZONE_NORMAL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
+ zone = &map_zone_all;
+ } else if( strncmpi(zonename,MAP_ZONE_PK_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
+ zone = &map_zone_pk;
+ } else
zone = strdb_get(zone_db, zonename);/* will succeed for we just put it in here */
-
- disabled_skills_count_i = izone->disabled_skills_count;
- disabled_items_count_i = izone->disabled_items_count;
- mapflags_count_i = izone->mapflags_count;
-
- /* process everything to override, paying attention to config_setting_get_bool */
- if( (skills = config_setting_get_member(zone_e, "disabled_skills")) != NULL ) {
- disabled_skills_count = config_setting_length(skills);
- for(j = 0; j < disabled_skills_count_i; j++) {
- int k;
- for(k = 0; k < disabled_skills_count; k++) {
- config_setting_t *skill = config_setting_get_elem(skills, k);
- if( strdb_iget(skilldb_name2id, config_setting_name(skill)) == izone->disabled_skills[j]->nameid ) {
- break;
- }
+
+ disabled_skills_count_i = izone->disabled_skills_count;
+ disabled_items_count_i = izone->disabled_items_count;
+ mapflags_count_i = izone->mapflags_count;
+ disabled_commands_count_i = izone->disabled_commands_count;
+ capped_skills_count_i = izone->capped_skills_count;
+
+ /* process everything to override, paying attention to config_setting_get_bool */
+ if( disabled_skills_count_i ) {
+ if( (skills = config_setting_get_member(zone_e, "disabled_skills")) == NULL )
+ skills = config_setting_add(zone_e, "disabled_skills",CONFIG_TYPE_GROUP);
+ disabled_skills_count = config_setting_length(skills);
+ for(j = 0; j < disabled_skills_count_i; j++) {
+ int k;
+ for(k = 0; k < disabled_skills_count; k++) {
+ config_setting_t *skill = config_setting_get_elem(skills, k);
+ if( map_zone_str2skillid(config_setting_name(skill)) == izone->disabled_skills[j]->nameid ) {
+ break;
}
- if( k == disabled_skills_count ) {/* we didn't find it */
- struct map_zone_disabled_skill_entry *entry;
- RECREATE( zone->disabled_skills, struct map_zone_disabled_skill_entry *, ++zone->disabled_skills_count );
- CREATE( entry, struct map_zone_disabled_skill_entry, 1 );
- entry->nameid = izone->disabled_skills[j]->nameid;
- entry->type = izone->disabled_skills[j]->type;
- zone->disabled_skills[zone->disabled_skills_count-1] = entry;
+ }
+ if( k == disabled_skills_count ) {/* we didn't find it */
+ struct map_zone_disabled_skill_entry *entry;
+ RECREATE( zone->disabled_skills, struct map_zone_disabled_skill_entry *, ++zone->disabled_skills_count );
+ CREATE( entry, struct map_zone_disabled_skill_entry, 1 );
+ entry->nameid = izone->disabled_skills[j]->nameid;
+ entry->type = izone->disabled_skills[j]->type;
+ zone->disabled_skills[zone->disabled_skills_count-1] = entry;
+ }
+ }
+ }
+
+ if( disabled_items_count_i ) {
+ if( (items = config_setting_get_member(zone_e, "disabled_items")) == NULL )
+ items = config_setting_add(zone_e, "disabled_items",CONFIG_TYPE_GROUP);
+ disabled_items_count = config_setting_length(items);
+ for(j = 0; j < disabled_items_count_i; j++) {
+ int k;
+ for(k = 0; k < disabled_items_count; k++) {
+ config_setting_t *item = config_setting_get_elem(items, k);
+
+ name = config_setting_name(item);
+
+ if( map_zone_str2itemid(name) == izone->disabled_items[j] ) {
+ if( config_setting_get_bool(item) )
+ continue;
+ break;
}
}
+ if( k == disabled_items_count ) {/* we didn't find it */
+ RECREATE( zone->disabled_items, int, ++zone->disabled_items_count );
+ zone->disabled_items[zone->disabled_items_count-1] = izone->disabled_items[j];
+ }
}
-
- if( (items = config_setting_get_member(zone_e, "disabled_items")) != NULL ) {
- disabled_items_count = config_setting_length(items);
- for(j = 0; j < disabled_items_count_i; j++) {
- int k;
- for(k = 0; k < disabled_items_count; k++) {
- config_setting_t *item = config_setting_get_elem(items, k);
-
- name = config_setting_name(item);
- data = itemdb_searchname(name);
-
- if( data->nameid == izone->disabled_items[j] ) {
- if( config_setting_get_bool(item) )
- continue;
- break;
- }
+ }
+
+ if( mapflags_count_i ) {
+ if( (mapflags = config_setting_get_member(zone_e, "mapflags")) == NULL )
+ mapflags = config_setting_add(zone_e, "mapflags",CONFIG_TYPE_ARRAY);
+ mapflags_count = config_setting_length(mapflags);
+ for(j = 0; j < mapflags_count_i; j++) {
+ int k;
+ for(k = 0; k < mapflags_count; k++) {
+ name = config_setting_get_string_elem(mapflags, k);
+
+ if( strcmpi(name,izone->mapflags[j]) == 0 ) {
+ break;
}
- if( k == disabled_items_count ) {/* we didn't find it */
- RECREATE( zone->disabled_items, int, ++zone->disabled_items_count );
- zone->disabled_items[zone->disabled_items_count-1] = izone->disabled_items[j];
+ }
+ if( k == mapflags_count ) {/* we didn't find it */
+ RECREATE( zone->mapflags, char*, ++zone->mapflags_count );
+ CREATE( zone->mapflags[zone->mapflags_count-1], char, MAP_ZONE_MAPFLAG_LENGTH );
+ safestrncpy(zone->mapflags[zone->mapflags_count-1], izone->mapflags[j], MAP_ZONE_MAPFLAG_LENGTH);
+ }
+ }
+ }
+
+ if( disabled_commands_count_i ) {
+ if( (commands = config_setting_get_member(zone_e, "disabled_commands")) == NULL )
+ commands = config_setting_add(zone_e, "disabled_commands",CONFIG_TYPE_GROUP);
+
+ disabled_commands_count = config_setting_length(commands);
+ for(j = 0; j < disabled_commands_count_i; j++) {
+ int k;
+ for(k = 0; k < disabled_commands_count; k++) {
+ config_setting_t *command = config_setting_get_elem(commands, k);
+ if( atcommand->exists(config_setting_name(command))->func == izone->disabled_commands[j]->cmd ) {
+ break;
}
}
+ if( k == disabled_commands_count ) {/* we didn't find it */
+ struct map_zone_disabled_command_entry *entry;
+ RECREATE( zone->disabled_commands, struct map_zone_disabled_command_entry *, ++zone->disabled_commands_count );
+ CREATE( entry, struct map_zone_disabled_command_entry, 1 );
+ entry->cmd = izone->disabled_commands[j]->cmd;
+ entry->group_lv = izone->disabled_commands[j]->group_lv;
+ zone->disabled_commands[zone->disabled_commands_count-1] = entry;
+ }
}
+ }
+
+ if( capped_skills_count_i ) {
+ if( (caps = config_setting_get_member(zone_e, "skill_damage_cap")) == NULL )
+ caps = config_setting_add(zone_e, "skill_damage_cap",CONFIG_TYPE_GROUP);
- if( (mapflags = config_setting_get_member(zone_e, "mapflags")) != NULL ) {
- mapflags_count = config_setting_length(mapflags);
- for(j = 0; j < mapflags_count_i; j++) {
- int k;
- for(k = 0; k < mapflags_count; k++) {
- name = config_setting_get_string_elem(mapflags, k);
-
- if( strcmpi(name,izone->mapflags[j]) == 0 ) {
- break;
- }
- }
- if( k == mapflags_count ) {/* we didn't find it */
- RECREATE( zone->mapflags, char*, ++zone->mapflags_count );
- CREATE( zone->mapflags[zone->mapflags_count-1], char, MAP_ZONE_MAPFLAG_LENGTH );
- safestrncpy(zone->mapflags[zone->mapflags_count-1], izone->mapflags[j], MAP_ZONE_MAPFLAG_LENGTH);
+ capped_skills_count = config_setting_length(caps);
+ for(j = 0; j < capped_skills_count_i; j++) {
+ int k;
+ for(k = 0; k < capped_skills_count; k++) {
+ config_setting_t *cap = config_setting_get_elem(caps, k);
+ if( map_zone_str2skillid(config_setting_name(cap)) == izone->capped_skills[j]->nameid ) {
+ break;
}
}
+ if( k == capped_skills_count ) {/* we didn't find it */
+ struct map_zone_skill_damage_cap_entry *entry;
+ RECREATE( zone->capped_skills, struct map_zone_skill_damage_cap_entry *, ++zone->capped_skills_count );
+ CREATE( entry, struct map_zone_skill_damage_cap_entry, 1 );
+ entry->nameid = izone->capped_skills[j]->nameid;
+ entry->cap = izone->capped_skills[j]->cap;
+ entry->type = izone->capped_skills[j]->type;
+ zone->capped_skills[zone->capped_skills_count-1] = entry;
+ }
}
}
+
}
}
@@ -4835,9 +5020,10 @@ void do_final(void)
chrif_char_reset_offline();
chrif_flush_fifo();
- do_final_atcommand();
+ atcommand->final();
battle->final();
do_final_chrif();
+ ircbot->final();/* before clif. */
clif->final();
do_final_npc();
do_final_script();
@@ -4849,7 +5035,7 @@ void do_final(void)
do_final_pc();
do_final_pet();
do_final_mob();
- do_final_msg();
+ atcommand->final_msg();
skill->final();
do_final_status();
do_final_unit();
@@ -4857,6 +5043,7 @@ void do_final(void)
do_final_duel();
do_final_elemental();
do_final_maps();
+ vending->final();
map_db->destroy(map_db, map_db_final);
@@ -4983,7 +5170,17 @@ static bool map_arg_next_value(const char* option, int i, int argc)
return true;
}
-
+void load_defaults(void) {
+ atcommand_defaults();
+ battle_defaults();
+ buyingstore_defaults();
+ clif_defaults();
+ ircbot_defaults();
+ log_defaults();
+ searchstore_defaults();
+ skill_defaults();
+ vending_defaults();
+}
int do_init(int argc, char *argv[])
{
int i;
@@ -5088,10 +5285,8 @@ int do_init(int argc, char *argv[])
exit(EXIT_FAILURE);
}
}
-
- battle_defaults();
- clif_defaults();
- skill_defaults();
+
+ load_defaults();
map_config_read(MAP_CONF_NAME);
// loads npcs
@@ -5119,10 +5314,10 @@ int do_init(int argc, char *argv[])
}
battle->config_read(BATTLE_CONF_FILENAME);
- msg_config_read(MSG_CONF_NAME);
+ atcommand->msg_read(MSG_CONF_NAME);
script_config_read(SCRIPT_CONF_NAME);
inter_config_read(INTER_CONF_NAME);
- log_config_read(LOG_CONF_NAME);
+ logs->config_read(LOG_CONF_NAME);
id_db = idb_alloc(DB_OPT_BASE);
pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable map_id2sd() use. [Skotlex]
@@ -5138,7 +5333,7 @@ int do_init(int argc, char *argv[])
map_sql_init();
- if (log_config.sql_logs)
+ if (logs->config.sql_logs)
log_sql_init();
mapindex_init();
@@ -5152,11 +5347,12 @@ int do_init(int argc, char *argv[])
add_timer_func_list(map_removemobs_timer, "map_removemobs_timer");
add_timer_interval(gettick()+1000, map_freeblock_timer, 0, 0, 60*1000);
- do_init_atcommand();
+ atcommand->init();
battle->init();
do_init_instance();
do_init_chrif();
clif->init();
+ ircbot->init();
do_init_script();
do_init_itemdb();
skill->init();
@@ -5176,6 +5372,7 @@ int do_init(int argc, char *argv[])
do_init_unit();
do_init_battleground();
do_init_duel();
+ vending->init();
npc_event_do_oninit(); // Init npcs (OnInit)
diff --git a/src/map/map.h b/src/map/map.h
index dd0a47aaf..ae60b810c 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -13,6 +13,8 @@
#include "../config/core.h"
+#include "atcommand.h"
+
#include <stdarg.h>
struct npc_data;
@@ -106,7 +108,7 @@ enum {
MAPID_ASSASSIN,
MAPID_STAR_GLADIATOR,
MAPID_KAGEROUOBORO = JOBL_2_1|0x0A,
- MAPID_DEATH_KNIGHT = JOBL_2_1|0x0D,
+ MAPID_DEATH_KNIGHT = JOBL_2_1|0x0E,
//2-2 Jobs
MAPID_CRUSADER = JOBL_2_2|0x1,
MAPID_SAGE,
@@ -497,13 +499,35 @@ struct mapflag_skill_adjust {
unsigned short skill_id;
unsigned short modifier;
};
+
+enum map_zone_skill_subtype {
+ MZS_NONE = 0x0,
+ MZS_CLONE = 0x01,
+ MZS_BOSS = 0x02,
+
+ MZS_ALL = 0xFFF,
+};
+
struct map_zone_disabled_skill_entry {
unsigned short nameid;
enum bl_type type;
+ enum map_zone_skill_subtype subtype;
+};
+struct map_zone_disabled_command_entry {
+ AtCommandFunc cmd;
+ int group_lv;
+};
+
+struct map_zone_skill_damage_cap_entry {
+ unsigned short nameid;
+ unsigned int cap;
+ enum bl_type type;
+ enum map_zone_skill_subtype subtype;
};
#define MAP_ZONE_NAME_LENGTH 30
-#define MAP_ZONE_ALL_NAME "Normal"
+#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"
@@ -518,6 +542,10 @@ struct map_zone_data {
int disabled_items_count;
char **mapflags;
int mapflags_count;
+ struct map_zone_disabled_command_entry **disabled_commands;
+ int disabled_commands_count;
+ struct map_zone_skill_damage_cap_entry **capped_skills;
+ int capped_skills_count;
};
void map_zone_init(void);
void map_zone_remove(int m);
@@ -577,7 +605,6 @@ struct map_data {
unsigned fireworks : 1;
unsigned sakura : 1; // [Valaris]
unsigned leaves : 1; // [Valaris]
- unsigned nogo : 1; // [Valaris]
unsigned nobaseexp : 1; // [Lorky] added by Lupus
unsigned nojobexp : 1; // [Lorky]
unsigned nomobloot : 1; // [Lorky]
@@ -823,24 +850,6 @@ typedef struct elemental_data TBL_ELEM;
#define BL_CAST(type_, bl) \
( ((bl) == (struct block_list*)NULL || (bl)->type != (type_)) ? (T ## type_ *)NULL : (T ## type_ *)(bl) )
-
-#ifdef BETA_THREAD_TEST
-
-extern char default_codepage[32];
-extern int map_server_port;
-extern char map_server_ip[32];
-extern char map_server_id[32];
-extern char map_server_pw[32];
-extern char map_server_db[32];
-
-extern char log_db_ip[32];
-extern int log_db_port;
-extern char log_db_id[32];
-extern char log_db_pw[32];
-extern char log_db_db[32];
-
-#endif
-
#include "../common/sql.h"
extern int db_use_sqldbs;
diff --git a/src/map/mob.c b/src/map/mob.c
index 6a507a099..f68f85455 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -875,8 +875,8 @@ int mob_setdelayspawn(struct mob_data *md)
spawntime = spawntime/100*battle_config.mob_spawn_delay;
}
- if (spawntime < 500) //Min respawn time (is it needed?)
- spawntime = 500;
+ if (spawntime < 5000) //Monsters should never respawn faster than within 5 seconds
+ spawntime = 5000;
if( md->spawn_timer != INVALID_TIMER )
delete_timer(md->spawn_timer, mob_delayspawn);
@@ -1602,7 +1602,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
fitem = (struct flooritem_data *)tbl;
//Logs items, taken by (L)ooter Mobs [Lupus]
- log_pick_mob(md, LOG_TYPE_LOOT, fitem->item_data.amount, &fitem->item_data);
+ logs->pick_mob(md, LOG_TYPE_LOOT, fitem->item_data.amount, &fitem->item_data, NULL);
if (md->lootitem_count < LOOTITEM_SIZE) {
memcpy (&md->lootitem[md->lootitem_count++], &fitem->item_data, sizeof(md->lootitem[0]));
@@ -1789,13 +1789,12 @@ static int mob_ai_hard(int tid, unsigned int tick, int id, intptr_t data)
/*==========================================
* Initializes the delay drop structure for mob-dropped items.
*------------------------------------------*/
-static struct item_drop* mob_setdropitem(int nameid, int qty)
-{
+static struct item_drop* mob_setdropitem(int nameid, int qty, struct item_data *data) {
struct item_drop *drop = ers_alloc(item_drop_ers, struct item_drop);
memset(&drop->item_data, 0, sizeof(struct item));
drop->item_data.nameid = nameid;
drop->item_data.amount = qty;
- drop->item_data.identify = itemdb_isidentified(nameid);
+ drop->item_data.identify = data ? itemdb_isidentified2(data) : itemdb_isidentified(nameid);
drop->next = NULL;
return drop;
}
@@ -1843,7 +1842,7 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str
TBL_PC* sd;
//Logs items, dropped by mobs [Lupus]
- log_pick_mob(md, loot?LOG_TYPE_LOOT:LOG_TYPE_PICKDROP_MONSTER, -ditem->item_data.amount, &ditem->item_data);
+ logs->pick_mob(md, loot?LOG_TYPE_LOOT:LOG_TYPE_PICKDROP_MONSTER, -ditem->item_data.amount, &ditem->item_data, NULL);
sd = map_charid2sd(dlist->first_charid);
if( sd == NULL ) sd = map_charid2sd(dlist->second_charid);
@@ -2038,8 +2037,7 @@ void mob_log_damage(struct mob_data *md, struct block_list *src, int damage)
return;
}
//Call when a mob has received damage.
-void mob_damage(struct mob_data *md, struct block_list *src, int damage)
-{
+void mob_damage(struct mob_data *md, struct block_list *src, int damage) {
if (damage > 0) { //Store total damage...
if (UINT_MAX - (unsigned int)damage > md->tdmg)
md->tdmg+=damage;
@@ -2069,14 +2067,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage)
return;
#if PACKETVER >= 20120404
- if( !(md->status.mode&MD_BOSS) ){
- int i;
- for(i = 0; i < DAMAGELOG_SIZE; i++){ // must show hp bar to all char who already hit the mob.
- struct map_session_data *sd = map_charid2sd(md->dmglog[i].id);
- if( sd && check_distance_bl(&md->bl, &sd->bl, AREA_SIZE) ) // check if in range
- clif->monster_hp_bar(md, sd->fd);
- }
- }
+ clif->monster_hp_bar(md);
#endif
if( md->special_state.ai == 2 ) {//LOne WOlf explained that ANYONE can trigger the marine countdown skill. [Skotlex]
@@ -2383,7 +2374,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
continue;
}
- ditem = mob_setdropitem(md->db->dropitem[i].nameid, 1);
+ ditem = mob_setdropitem(md->db->dropitem[i].nameid, 1, it);
//A Rare Drop Global Announce by Lupus
if( mvp_sd && drop_rate <= battle_config.rare_drop_announce ) {
@@ -2399,7 +2390,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
// Ore Discovery [Celest]
if (sd == mvp_sd && pc_checkskill(sd,BS_FINDINGORE)>0 && battle_config.finding_ore_rate/10 >= rnd()%10000) {
- ditem = mob_setdropitem(itemdb_searchrandomid(IG_FINDINGORE), 1);
+ ditem = mob_setdropitem(itemdb_searchrandomid(IG_FINDINGORE), 1, NULL);
mob_item_drop(md, dlist, ditem, 0, battle_config.finding_ore_rate/10, homkillonly);
}
@@ -2429,7 +2420,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if (rnd()%10000 >= drop_rate)
continue;
itemid = (sd->add_drop[i].id > 0) ? sd->add_drop[i].id : itemdb_searchrandomid(sd->add_drop[i].group);
- mob_item_drop(md, dlist, mob_setdropitem(itemid,1), 0, drop_rate, homkillonly);
+ mob_item_drop(md, dlist, mob_setdropitem(itemid,1,NULL), 0, drop_rate, homkillonly);
}
}
@@ -2505,9 +2496,10 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
}
for(i = 0; i < MAX_MVP_DROP; i++) {
+ struct item_data *data;
if(mdrop_id[i] <= 0)
continue;
- if(!itemdb_exists(mdrop_id[i]))
+ if(! (data = itemdb_exists(mdrop_id[i])) )
continue;
temp = mdrop_p[i];
@@ -2518,16 +2510,14 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
memset(&item,0,sizeof(item));
item.nameid=mdrop_id[i];
- item.identify= itemdb_isidentified(item.nameid);
+ item.identify= itemdb_isidentified2(data);
clif->mvp_item(mvp_sd,item.nameid);
log_mvp[0] = item.nameid;
//A Rare MVP Drop Global Announce by Lupus
if(temp<=battle_config.rare_drop_announce) {
- struct item_data *i_data;
char message[128];
- i_data = itemdb_exists(item.nameid);
- sprintf (message, msg_txt(541), mvp_sd->status.name, md->name, i_data->jname, temp/100.);
+ sprintf (message, msg_txt(541), mvp_sd->status.name, md->name, data->jname, temp/100.);
//MSG: "'%s' won %s's %s (chance: %0.02f%%)"
intif_broadcast(message,strlen(message)+1,0);
}
@@ -2538,12 +2528,12 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
}
//Logs items, MVP prizes [Lupus]
- log_pick_mob(md, LOG_TYPE_MVP, -1, &item);
+ logs->pick_mob(md, LOG_TYPE_MVP, -1, &item, data);
break;
}
}
- log_mvpdrop(mvp_sd, md->class_, log_mvp);
+ logs->mvpdrop(mvp_sd, md->class_, log_mvp);
}
if (type&2 && !sd && md->class_ == MOBID_EMPERIUM)
@@ -2634,8 +2624,10 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if (battle_config.mvp_tomb_enabled && md->spawn->state.boss)
mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL));
- if( !rebirth )
+ if( !rebirth ) {
+ status_change_clear(&md->bl,1);
mob_setdelayspawn(md); //Set respawning.
+ }
return 3; //Remove from map.
}
@@ -3335,7 +3327,7 @@ int mob_is_clone(int class_)
int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, const char *event, int master_id, int mode, int flag, unsigned int duration)
{
int class_;
- int i,j,inf,skill_id, fd;
+ int i,j,h,inf,skill_id, fd;
struct mob_data *md;
struct mob_skill *ms;
struct mob_db* db;
@@ -3389,9 +3381,16 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons
for (i=0,j = MAX_SKILL_TREE-1;j>=0 && i< MAX_MOBSKILL ;j--) {
skill_id = skill_tree[pc_class2idx(sd->status.class_)][j].id;
if (!skill_id || sd->status.skill[skill_id].lv < 1 ||
- (skill->get_inf2(skill_id)&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL|INF2_CLONE_NOCOPY))
+ (skill->get_inf2(skill_id)&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL))
)
continue;
+ for(h = 0; h < map[sd->bl.m].zone->disabled_skills_count; h++) {
+ if( skill_id == map[sd->bl.m].zone->disabled_skills[h]->nameid && map[sd->bl.m].zone->disabled_skills[h]->subtype == MZS_CLONE ) {
+ break;
+ }
+ }
+ if( h < map[sd->bl.m].zone->disabled_skills_count )
+ continue;
//Normal aggressive mob, disable skills that cannot help them fight
//against players (those with flags UF_NOMOB and UF_NOPC are specific
//to always aid players!) [Skotlex]
@@ -4013,8 +4012,8 @@ static int mob_read_randommonster(void)
memset(&summon, 0, sizeof(summon));
- for( i = 0; i < ARRAYLENGTH(mobfile) && i < MAX_RANDOMMONSTER; i++ )
- {
+ for( i = 0; i < ARRAYLENGTH(mobfile) && i < MAX_RANDOMMONSTER; i++ ) {
+ unsigned int count = 0;
mob_db_data[0]->summonper[i] = 1002; // Default fallback value, in case the database does not provide one
sprintf(line, "%s/%s", db_path, mobfile[i]);
fp=fopen(line,"r");
@@ -4040,6 +4039,7 @@ static int mob_read_randommonster(void)
class_ = atoi(str[0]);
if(mob_db(class_) == mob_dummy)
continue;
+ count++;
mob_db_data[class_]->summonper[i]=atoi(str[2]);
if (i) {
if( summon[i].qty < ARRAYLENGTH(summon[i].class_) ) //MvPs
@@ -4050,13 +4050,12 @@ static int mob_read_randommonster(void)
}
}
}
- if (i && !summon[i].qty)
- { //At least have the default here.
+ if (i && !summon[i].qty) { //At least have the default here.
summon[i].class_[0] = mob_db_data[0]->summonper[i];
summon[i].qty = 1;
}
fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n",mobfile[i]);
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",count,mobfile[i]);
}
return 0;
}
@@ -4173,7 +4172,7 @@ static void mob_readchatdb(void)
count++;
}
fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n", arc);
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, arc);
}
/*==========================================
diff --git a/src/map/npc.c b/src/map/npc.c
index aa44d8840..dee5f4f50 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -96,6 +96,7 @@ static DBMap *npc_path_db;
//For holding the view data of npc classes. [Skotlex]
static struct view_data npc_viewdb[MAX_NPC_CLASS];
+static struct view_data npc_viewdb2[MAX_NPC_CLASS2_END-MAX_NPC_CLASS2_START];
static struct script_event_s
{ //Holds pointers to the commonly executed scripts for speedup. [Skotlex]
@@ -108,8 +109,13 @@ struct view_data* npc_get_viewdata(int class_)
{ //Returns the viewdata for normal npc classes.
if( class_ == INVISIBLE_CLASS )
return &npc_viewdb[0];
- if (npcdb_checkid(class_) || class_ == WARP_CLASS)
- return &npc_viewdb[class_];
+ if (npcdb_checkid(class_) || class_ == WARP_CLASS){
+ if( class_ > MAX_NPC_CLASS2_START ){
+ return &npc_viewdb2[class_-MAX_NPC_CLASS2_START];
+ }else{
+ return &npc_viewdb[class_];
+ }
+ }
return NULL;
}
@@ -234,17 +240,29 @@ struct npc_data* npc_name2id(const char* name)
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
**/
-#if SECURE_NPCTIMEOUT
+#ifdef SECURE_NPCTIMEOUT
/**
* Timer to check for idle time and timeout the dialog if necessary
**/
int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t data) {
struct map_session_data* sd = NULL;
+ unsigned int timeout = NPC_SECURE_TIMEOUT_NEXT;
if( (sd = map_id2sd(id)) == NULL || !sd->npc_id ) {
if( sd ) sd->npc_idle_timer = INVALID_TIMER;
return 0;//Not logged in anymore OR no longer attached to a npc
}
- if( DIFF_TICK(tick,sd->npc_idle_tick) > (SECURE_NPCTIMEOUT*1000) ) {
+
+ switch( sd->npc_idle_type ) {
+ case NPCT_INPUT:
+ timeout = NPC_SECURE_TIMEOUT_INPUT;
+ break;
+ case NPCT_MENU:
+ timeout = NPC_SECURE_TIMEOUT_MENU;
+ break;
+ //case NPCT_WAIT: var starts with this value
+ }
+
+ if( DIFF_TICK(tick,sd->npc_idle_tick) > (timeout*1000) ) {
/**
* If we still have the NPC script attached, tell it to stop.
**/
@@ -1234,7 +1252,7 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing)
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
**/
-#if SECURE_NPCTIMEOUT
+#ifdef SECURE_NPCTIMEOUT
/**
* Update the last NPC iteration
**/
@@ -2133,6 +2151,11 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
return strchr(start,'\n');// skip and continue
}
+ if( m != -1 && ( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) ) {
+ ShowError("npc_parse_warp: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map[m].name, x, y, map[m].xs, map[m].ys,filepath,strline(buffer,start-buffer));
+ return strchr(start,'\n');;//try next
+ }
+
CREATE(nd, struct npc_data, 1);
nd->bl.id = npc_get_new_npc_id();
@@ -2180,13 +2203,10 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
struct npc_data *nd;
enum npc_subtype type;
- if( strcmp(w1,"-") == 0 )
- {// 'floating' shop?
+ if( strcmp(w1,"-") == 0 ) {// 'floating' shop?
x = y = dir = 0;
m = -1;
- }
- else
- {// w1=<map name>,<x>,<y>,<facing>
+ } else {// w1=<map name>,<x>,<y>,<facing>
char mapname[32];
if( sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4
|| strchr(w4, ',') == NULL )
@@ -2198,6 +2218,11 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
m = map_mapname2mapid(mapname);
}
+ if( m != -1 && ( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) ) {
+ ShowError("npc_parse_shop: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map[m].name, x, y, map[m].xs, map[m].ys,filepath,strline(buffer,start-buffer));
+ return strchr(start,'\n');;//try next
+ }
+
if( !strcasecmp(w2,"cashshop") )
type = CASHSHOP;
else
@@ -2583,6 +2608,11 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
m = map_mapname2mapid(mapname);
}
+ if( m != -1 && ( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) ) {
+ ShowError("npc_parse_duplicate: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map[m].name, x, y, map[m].xs, map[m].ys,filepath,strline(buffer,start-buffer));
+ return end;//try next
+ }
+
if( type == WARP && sscanf(w4, "%d,%d", &xs, &ys) == 2 );// <spanx>,<spany>
else if( type == SCRIPT && sscanf(w4, "%d,%d,%d", &class_, &xs, &ys) == 3);// <sprite id>,<triggerX>,<triggerY>
else if( type != WARP ) class_ = atoi(w4);// <sprite id>
@@ -2911,18 +2941,20 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
for( i = 0; i < ( strlen( message ) + 1 ) && k < 127; i ++ ) {
if( message[i] == ' ' || message[i] == '\0' ) {
if( message[ ( i - 1 ) ] == ' ' ) {
- continue; // To prevent "@atcmd [space][space][space]..."
+ continue; // To prevent "@atcmd [space][space]" and .@atcmd_numparameters return 1 without any parameter.
}
temp[k] = '\0';
k = 0;
- setd_sub( st, NULL, ".@atcmd_parameters$", j++, (void *)temp, NULL );
+ if( temp[0] != '\0' ) {
+ setd_sub( st, NULL, ".@atcmd_parameters$", j++, (void *)temp, NULL );
+ }
} else {
temp[k] = message[i];
k++;
}
}
- setd_sub(st, NULL, ".@atcmd_numparameters", 0, (void *)__64BPRTSIZE(j), NULL);
+ setd_sub(st, NULL, ".@atcmd_numparameters", 0, (void *)__64BPTRSIZE(j), NULL);
aFree(temp);
run_script_main(st);
@@ -3365,8 +3397,6 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
map[m].flag.leaves=state;
else if (!strcmpi(w3,"nightenabled"))
map[m].flag.nightenabled=state;
- else if (!strcmpi(w3,"nogo"))
- map[m].flag.nogo=state;
else if (!strcmpi(w3,"noexp")) {
map[m].flag.nobaseexp=state;
map[m].flag.nojobexp=state;
@@ -3992,6 +4022,8 @@ int do_init_npc(void)
npc_viewdb[0].class_ = INVISIBLE_CLASS; //Invisible class is stored here.
for( i = 1; i < MAX_NPC_CLASS; i++ )
npc_viewdb[i].class_ = i;
+ for( i = MAX_NPC_CLASS2_START; i < MAX_NPC_CLASS2_END; i++ )
+ npc_viewdb2[i - MAX_NPC_CLASS2_START].class_ = i;
ev_db = strdb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA),2*NAME_LENGTH+2+1);
npcname_db = strdb_alloc(DB_OPT_BASE,NAME_LENGTH);
diff --git a/src/map/npc.h b/src/map/npc.h
index c2351a836..8800b4e5b 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -88,7 +88,12 @@ enum actor_classes
INVISIBLE_CLASS = 32767,
};
+// Old NPC range
#define MAX_NPC_CLASS 1000
+// New NPC range
+#define MAX_NPC_CLASS2_START 10000
+#define MAX_NPC_CLASS2_END 10049
+
//Checks if a given id is a valid npc id. [Skotlex]
//Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001)
#define npcdb_checkid(id) ( ( (id) >= 46 && (id) <= 125) || (id) == HIDDEN_WARP_CLASS || ( (id) > 400 && (id) < MAX_NPC_CLASS ) || (id) == INVISIBLE_CLASS || ( (id) > 10000 && (id) < 10049 ) )
@@ -174,7 +179,7 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
**/
-#if SECURE_NPCTIMEOUT
+#ifdef SECURE_NPCTIMEOUT
int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t data);
#endif
diff --git a/src/map/packets.h b/src/map/packets.h
index 29181d392..3c204c978 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -1116,7 +1116,7 @@ packet(0x020d,-1);
packet(0x02c5,30);
packet(0x02c6,30);
packet(0x02c7,7,clif->pReplyPartyInvite2,2,6);
- packet(0x02c8,3);
+ packet(0x02c8,3,clif->pPartyTick,2);
packet(0x02c9,3);
packet(0x02ca,3);
packet(0x02cb,20);
@@ -2045,9 +2045,7 @@ packet(0x020d,-1);
packet(0x094C,6,clif->pSolveCharName,2);
packet(0x0907,5,clif->pMoveItem,2,4);
packet(0x0908,5);
- packet(0x08CF,10); //Amulet spirits
packet(0x08d2,10);
- packet(0x0977,14); //Monster HP Bar
packet(0x0998,8,clif->pEquipItem,2,4);
//packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8);
packet(0x0938,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
@@ -2061,6 +2059,7 @@ packet(0x020d,-1);
packet(0x084a,2,clif->pCashShopClose,0);/* tell server cashshop window is being closed */
packet(0x08c9,4,clif->pCashShopSchedule,0);
packet(0x0848,-1,clif->pCashShopBuy,0);
+ packet(0x0447,2);
#endif
#endif /* _PACKETS_H_ */
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
new file mode 100644
index 000000000..17c6777e8
--- /dev/null
+++ b/src/map/packets_struct.h
@@ -0,0 +1,376 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+
+/* Hercules Renewal: Phase Two http://hercules.ws/board/topic/383-hercules-renewal-phase-two/ */
+
+#ifndef _PACKETS_STRUCT_H_
+#define _PACKETS_STRUCT_H_
+
+#include "../common/mmo.h"
+
+/**
+ * structs for data
+ */
+struct EQUIPSLOTINFO {
+ unsigned short card[4];
+};
+/**
+ *
+ **/
+enum packet_headers {
+ sc_notickType = 0x196,
+#if PACKETVER < 20061218
+ additemType = 0xa0,
+#elif PACKETVER < 20071002
+ additemType = 0x29a,
+#elif PACKETVER < 2013000 /* not sure date */
+ additemType = 0x2d4,
+#else
+ additemType = 0x990,
+#endif
+#if PACKETVER < 4
+ idle_unitType = 0x78,
+#elif PACKETVER < 7
+ idle_unitType = 0x1d8,
+#elif PACKETVER < 20080102
+ idle_unitType = 0x22a,
+#elif PACKETVER < 20091103
+ idle_unitType = 0x2ee,
+#elif PACKETVER < 20101124
+ idle_unitType = 0x7f9,
+#elif PACKETVER < 20120712
+ idle_unitType = 0x857,
+#else
+ idle_unitType = 0x915,
+#endif
+#if PACKETVER >= 20120618
+ status_changeType = 0x983,
+#elif PACKETVER >= 20090121
+ status_changeType = 0x43f,
+#else
+ status_changeType = sc_notickType,/* 0x196 */
+#endif
+#if PACKETVER < 4
+ spawn_unitType = 0x79,
+#elif PACKETVER < 7
+ spawn_unitType = 0x1d9,
+#elif PACKETVER < 20080102
+ spawn_unitType = 0x22b,
+#elif PACKETVER < 20091103
+ spawn_unitType = 0x2ed,
+#elif PACKETVER < 20101124
+ spawn_unitType = 0x7f8,
+#elif PACKETVER < 20120712
+ spawn_unitType = 0x858,
+#else
+ spawn_unitType = 0x90f,
+#endif
+#if PACKETVER < 20080102
+ authokType = 0x73,
+#else
+ authokType = 0x2eb,
+#endif
+#if PACKETVER < 4
+ unit_walkingType = 0x7b,
+#elif PACKETVER < 7
+ unit_walkingType = 0x1da,
+#elif PACKETVER < 20080102
+ unit_walkingType = 0x22c,
+#elif PACKETVER < 20091103
+ unit_walkingType = 0x2ec,
+#elif PACKETVER < 20101124
+ unit_walkingType = 0x7f7,
+#elif PACKETVER < 20120712
+ unit_walkingType = 0x856,
+#else
+ unit_walkingType = 0x914,
+#endif
+#if PACKETVER > 2013000 /* not sure date */
+ dropflooritemType = 0x84b,
+#else
+ dropflooritemType = 0x9e,
+#endif
+ monsterhpType = 0x977,
+ maptypeproperty2Type = 0x99b,
+};
+
+#pragma pack(push, 1)
+
+struct packet_authok {
+ short PacketType;
+ unsigned int startTime;
+ char PosDir[3];
+ unsigned char xSize;
+ unsigned char ySize;
+#if PACKETVER >= 20080102
+ short font;
+#endif
+} __attribute__((packed));
+
+struct packet_monster_hp {
+ short PacketType;
+ unsigned int GID;
+ int HP;
+ int MaxHP;
+} __attribute__((packed));
+
+struct packet_sc_notick {
+ short PacketType;
+ short index;
+ unsigned int AID;
+ unsigned char state;
+} __attribute__((packed));
+
+struct packet_additem {
+ short PacketType;
+ unsigned short Index;
+ unsigned short count;
+ unsigned short nameid;
+ bool IsIdentified;
+ bool IsDamaged;
+ unsigned char refiningLevel;
+ struct EQUIPSLOTINFO slot;
+#if PACKETVER >= 20130000 /* not sure */
+ unsigned int location;
+#else
+ unsigned short location;
+#endif
+ unsigned char type;
+ unsigned char result;
+#if PACKETVER >= 20061218
+ int HireExpireDate;
+#endif
+#if PACKETVER >= 20071002
+ unsigned short bindOnEquipType;
+#endif
+} __attribute__((packed));
+
+struct packet_dropflooritem {
+ short PacketType;
+ unsigned int ITAID;
+ unsigned short ITID;
+#if PACKETVER >= 20130000 /* not sure date */
+ unsigned short type;
+#endif
+ bool IsIdentified;
+ short xPos;
+ short yPos;
+ unsigned char subX;
+ unsigned char subY;
+ short count;
+} __attribute__((packed));
+
+struct packet_spawn_unit {
+ short PacketType;
+#if PACKETVER >= 20091103
+ short PacketLength;
+ unsigned char objecttype;
+#endif
+ unsigned int GID;
+ short speed;
+ short bodyState;
+ short healthState;
+#if PACKETVER < 20080102
+ short effectState;
+#else
+ int effectState;
+#endif
+ short job;
+ short head;
+#if PACKETVER < 7
+ short weapon;
+#else
+ int weapon;
+#endif
+ short accessory;
+#if PACKETVER < 7
+ short shield;
+#endif
+ short accessory2;
+ short accessory3;
+ short headpalette;
+ short bodypalette;
+ short headDir;
+#if PACKETVER >= 20101124
+ short robe;
+#endif
+ unsigned int GUID;
+ short GEmblemVer;
+ short honor;
+#if PACKETVER >= 20091103
+ int virtue;
+#else
+ short virtue;
+#endif
+ bool isPKModeON;
+ unsigned char sex;
+ char PosDir[3];
+ unsigned char xSize;
+ unsigned char ySize;
+ short clevel;
+#if PACKETVER >= 20080102
+ short font;
+#endif
+#if PACKETVER >= 20120712
+ int maxHP;
+ int HP;
+ unsigned char isBoss;
+#endif
+} __attribute__((packed));
+
+struct packet_unit_walking {
+ short PacketType;
+#if PACKETVER >= 20091103
+ short PacketLength;
+ unsigned char objecttype;
+#endif
+ unsigned int GID;
+ short speed;
+ short bodyState;
+ short healthState;
+#if PACKETVER < 20080102
+ short effectState;
+#else
+ int effectState;
+#endif
+ short job;
+ short head;
+#if PACKETVER < 7
+ short weapon;
+#else
+ int weapon;
+#endif
+ short accessory;
+ unsigned int moveStartTime;
+#if PACKETVER < 7
+ short shield;
+#endif
+ short accessory2;
+ short accessory3;
+ short headpalette;
+ short bodypalette;
+ short headDir;
+#if PACKETVER >= 20101124
+ short robe;
+#endif
+ unsigned int GUID;
+ short GEmblemVer;
+ short honor;
+#if PACKETVER >= 20091103
+ int virtue;
+#else
+ short virtue;
+#endif
+ bool isPKModeON;
+ unsigned char sex;
+ char MoveData[6];
+ unsigned char xSize;
+ unsigned char ySize;
+ short clevel;
+#if PACKETVER >= 20080102
+ short font;
+#endif
+#if PACKETVER >= 20120712
+ int maxHP;
+ int HP;
+ unsigned char isBoss;
+#endif
+} __attribute__((packed));
+
+struct packet_idle_unit {
+ short PacketType;
+#if PACKETVER >= 20091103
+ short PacketLength;
+ unsigned char objecttype;
+#endif
+ unsigned int GID;
+ short speed;
+ short bodyState;
+ short healthState;
+#if PACKETVER < 20080102
+ short effectState;
+#else
+ int effectState;
+#endif
+ short job;
+ short head;
+#if PACKETVER < 7
+ short weapon;
+#else
+ int weapon;
+#endif
+ short accessory;
+#if PACKETVER < 7
+ short shield;
+#endif
+ short accessory2;
+ short accessory3;
+ short headpalette;
+ short bodypalette;
+ short headDir;
+#if PACKETVER >= 20101124
+ short robe;
+#endif
+ unsigned int GUID;
+ short GEmblemVer;
+ short honor;
+#if PACKETVER >= 20091103
+ int virtue;
+#else
+ short virtue;
+#endif
+ bool isPKModeON;
+ unsigned char sex;
+ char PosDir[3];
+ unsigned char xSize;
+ unsigned char ySize;
+ unsigned char state;
+ short clevel;
+#if PACKETVER >= 20080102
+ short font;
+#endif
+#if PACKETVER >= 20120712
+ int maxHP;
+ int HP;
+ unsigned char isBoss;
+#endif
+} __attribute__((packed));
+
+struct packet_status_change {
+ short PacketType;
+ short index;
+ unsigned int AID;
+ unsigned char state;
+#if PACKETVER >= 20120618
+ unsigned int Total;
+#endif
+#if PACKETVER >= 20090121
+ unsigned int Left;
+ int val1;
+ int val2;
+ int val3;
+#endif
+} __attribute__((packed));
+
+struct packet_maptypeproperty2 {
+ short PacketType;
+ short type;
+ struct {
+ unsigned int party : 1;
+ unsigned int guild : 1;
+ unsigned int siege : 1;
+ unsigned int mineffect : 1;
+ unsigned int nolockon : 1;
+ unsigned int countpk : 1;
+ unsigned int nopartyformation : 1;
+ unsigned int bg : 1;
+ unsigned int noitemconsumption : 1;
+ unsigned int usecart : 1;
+ unsigned int summonstarmiracle : 1;
+ unsigned int SpareBits : 15;
+ } flag;
+} __attribute__((packed));
+
+#pragma pack(pop)
+
+#endif /* _PACKETS_STRUCT_H_ */
diff --git a/src/map/party.c b/src/map/party.c
index f69a843fc..d8bb321f1 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -786,7 +786,7 @@ int party_send_message(struct map_session_data *sd,const char *mes,int len)
party_recv_message(sd->status.party_id,sd->status.account_id,mes,len);
// Chat logging type 'P' / Party Chat
- log_chat(LOG_CHAT_PARTY, sd->status.party_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes);
+ logs->chat(LOG_CHAT_PARTY, sd->status.party_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes);
return 0;
}
@@ -910,6 +910,9 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b
{
struct map_session_data* sd[MAX_PARTY];
unsigned int i, c;
+#ifdef RENEWAL_EXP
+ unsigned int job_exp_bonus, base_exp_bonus;
+#endif
nullpo_ret(p);
@@ -926,8 +929,7 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b
job_exp/=c;
zeny/=c;
- if (battle_config.party_even_share_bonus && c > 1)
- {
+ if (battle_config.party_even_share_bonus && c > 1) {
double bonus = 100 + battle_config.party_even_share_bonus*(c-1);
if (base_exp)
base_exp = (unsigned int) cap_value(base_exp * bonus/100, 0, UINT_MAX);
@@ -937,12 +939,17 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b
zeny = (unsigned int) cap_value(zeny * bonus/100, INT_MIN, INT_MAX);
}
+#ifdef RENEWAL_EXP
+ base_exp_bonus = base_exp;
+ job_exp_bonus = job_exp;
+#endif
+
for (i = 0; i < c; i++) {
#ifdef RENEWAL_EXP
if( !(src && src->type == BL_MOB && ((TBL_MOB*)src)->db->mexp) ){
int rate = pc_level_penalty_mod(sd[i], (TBL_MOB*)src, 1);
- base_exp = (unsigned int)cap_value(base_exp * rate / 100, 1, UINT_MAX);
- job_exp = (unsigned int)cap_value(job_exp * rate / 100, 1, UINT_MAX);
+ base_exp = (unsigned int)cap_value(base_exp_bonus * rate / 100, 1, UINT_MAX);
+ job_exp = (unsigned int)cap_value(job_exp_bonus * rate / 100, 1, UINT_MAX);
}
#endif
pc_gainexp(sd[i], src, base_exp, job_exp, false);
diff --git a/src/map/pc.c b/src/map/pc.c
index 796280308..7427348fe 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -99,10 +99,6 @@ int pc_class2idx(int class_) {
return class_;
}
-inline int pc_get_group_id(struct map_session_data *sd) {
- return sd->group_id;
-}
-
inline int pc_get_group_level(struct map_session_data *sd) {
return sd->group_level;
}
@@ -522,9 +518,9 @@ int pc_makesavestatus(struct map_session_data *sd)
//Only copy the Cart/Peco/Falcon options, the rest are handled via
//status change load/saving. [Skotlex]
#ifdef NEW_CARTS
- sd->status.option = sd->sc.option&(OPTION_FALCON|OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_MOUNTING);
+ sd->status.option = sd->sc.option&(OPTION_INVISIBLE|OPTION_FALCON|OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_MOUNTING);
#else
- sd->status.option = sd->sc.option&(OPTION_CART|OPTION_FALCON|OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_MOUNTING);
+ sd->status.option = sd->sc.option&(OPTION_INVISIBLE|OPTION_CART|OPTION_FALCON|OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_MOUNTING);
#endif
if (sd->sc.data[SC_JAILED])
{ //When Jailed, do not move last point.
@@ -968,12 +964,13 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
**/
-#if SECURE_NPCTIMEOUT
+#ifdef SECURE_NPCTIMEOUT
/**
* Initialize to defaults/expected
**/
sd->npc_idle_timer = INVALID_TIMER;
sd->npc_idle_tick = tick;
+ sd->npc_idle_type = NPCT_INPUT;
#endif
sd->canuseitem_tick = tick;
@@ -982,6 +979,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
sd->cantalk_tick = tick;
sd->canskill_tick = tick;
sd->cansendmail_tick = tick;
+ sd->hchsysch_tick = tick;
for(i = 0; i < MAX_SKILL_LEVEL; i++)
sd->spirit_timer[i] = INVALID_TIMER;
@@ -1006,14 +1004,13 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
pc_setinventorydata(sd);
pc_setequipindex(sd);
+ if( sd->status.option & OPTION_INVISIBLE && !pc_can_use_command(sd, "@hide") )
+ sd->status.option &=~ OPTION_INVISIBLE;
+
status_change_init(&sd->bl);
-
- if (pc_can_use_command(sd, "hide", COMMAND_ATCOMMAND))
- sd->status.option &= (OPTION_MASK | OPTION_INVISIBLE);
- else
- sd->status.option &= OPTION_MASK;
-
+
sd->sc.option = sd->status.option; //This is the actual option used in battle.
+
//Set here because we need the inventory data for weapon sprite parsing.
status_set_viewdata(&sd->bl, sd->status.class_);
unit_dataset(&sd->bl);
@@ -1242,6 +1239,20 @@ int pc_reg_received(struct map_session_data *sd)
pc_inventory_rentals(sd);
+ if( sd->sc.option & OPTION_INVISIBLE ) {
+ sd->vd.class_ = INVISIBLE_CLASS;
+ clif->message(sd->fd, msg_txt(11)); // Invisible: On
+ // decrement the number of pvp players on the map
+ map[sd->bl.m].users_pvp--;
+
+ if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking
+ delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
+ sd->pvp_timer = INVALID_TIMER;
+ }
+ clif->changeoption(&sd->bl);
+ }
+
+
return 1;
}
@@ -3435,11 +3446,11 @@ int pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4
}
/*==========================================
- * Grants a player a given skill. Flag values are:
- * 0 - Grant skill unconditionally and forever (only this one invokes status_calc_pc,
- * as the other two are assumed to be invoked from within it)
- * 1 - Grant an item skill (temporary)
- * 2 - Like 1, except the level granted can stack with previously learned level.
+ * Grants a player a given skill. Flag values are:
+ * 0 - Grant permanent skill to be bound to skill tree
+ * 1 - Grant an item skill (temporary)
+ * 2 - Like 1, except the level granted can stack with previously learned level.
+ * 3 - Grant skill unconditionally and forever (persistent to job changes and skill resets)
*------------------------------------------*/
int pc_skill(TBL_PC* sd, int id, int level, int flag)
{
@@ -3459,42 +3470,52 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag)
}
switch( flag ){
- case 0: //Set skill data overwriting whatever was there before.
- sd->status.skill[id].id = id;
- sd->status.skill[id].lv = level;
- sd->status.skill[id].flag = SKILL_FLAG_PERM_GRANTED;
- if( level == 0 ) //Remove skill.
- {
- sd->status.skill[id].id = 0;
- clif->deleteskill(sd,id);
- }
- else
- clif->addskill(sd,id);
- if( !skill->get_inf(id) ) //Only recalculate for passive skills.
- status_calc_pc(sd, 0);
- break;
- case 1: //Item bonus skill.
- if( sd->status.skill[id].id == id ){
- if( sd->status.skill[id].lv >= level )
- return 0;
- if( sd->status.skill[id].flag == SKILL_FLAG_PERMANENT ) //Non-granted skill, store it's level.
- sd->status.skill[id].flag = SKILL_FLAG_REPLACED_LV_0 + sd->status.skill[id].lv;
- } else {
+ case 0: //Set skill data overwriting whatever was there before.
sd->status.skill[id].id = id;
- sd->status.skill[id].flag = SKILL_FLAG_TEMPORARY;
- }
- sd->status.skill[id].lv = level;
- break;
- case 2: //Add skill bonus on top of what you had.
- if( sd->status.skill[id].id == id ){
- if( sd->status.skill[id].flag == SKILL_FLAG_PERMANENT )
- sd->status.skill[id].flag = SKILL_FLAG_REPLACED_LV_0 + sd->status.skill[id].lv; // Store previous level.
- } else {
+ sd->status.skill[id].lv = level;
+ sd->status.skill[id].flag = SKILL_FLAG_PERMANENT;
+ if( level == 0 ) { //Remove skill.
+ sd->status.skill[id].id = 0;
+ clif->deleteskill(sd,id);
+ } else
+ clif->addskill(sd,id);
+ if( !skill->get_inf(id) ) //Only recalculate for passive skills.
+ status_calc_pc(sd, 0);
+ break;
+ case 1: //Item bonus skill.
+ if( sd->status.skill[id].id == id ) {
+ if( sd->status.skill[id].lv >= level )
+ return 0;
+ if( sd->status.skill[id].flag == SKILL_FLAG_PERMANENT ) //Non-granted skill, store it's level.
+ sd->status.skill[id].flag = SKILL_FLAG_REPLACED_LV_0 + sd->status.skill[id].lv;
+ } else {
+ sd->status.skill[id].id = id;
+ sd->status.skill[id].flag = SKILL_FLAG_TEMPORARY;
+ }
+ sd->status.skill[id].lv = level;
+ break;
+ case 2: //Add skill bonus on top of what you had.
+ if( sd->status.skill[id].id == id ) {
+ if( sd->status.skill[id].flag == SKILL_FLAG_PERMANENT )
+ sd->status.skill[id].flag = SKILL_FLAG_REPLACED_LV_0 + sd->status.skill[id].lv; // Store previous level.
+ } else {
+ sd->status.skill[id].id = id;
+ sd->status.skill[id].flag = SKILL_FLAG_TEMPORARY; //Set that this is a bonus skill.
+ }
+ sd->status.skill[id].lv += level;
+ break;
+ case 3:
sd->status.skill[id].id = id;
- sd->status.skill[id].flag = SKILL_FLAG_TEMPORARY; //Set that this is a bonus skill.
- }
- sd->status.skill[id].lv += level;
- break;
+ sd->status.skill[id].lv = level;
+ sd->status.skill[id].flag = SKILL_FLAG_PERM_GRANTED;
+ if( level == 0 ) { //Remove skill.
+ sd->status.skill[id].id = 0;
+ clif->deleteskill(sd,id);
+ } else
+ clif->addskill(sd,id);
+ if( !skill->get_inf(id) ) //Only recalculate for passive skills.
+ status_calc_pc(sd, 0);
+ break;
default: //Unknown flag?
return 0;
}
@@ -3546,9 +3567,9 @@ int pc_insert_card(struct map_session_data* sd, int idx_card, int idx_equip)
}
else
{// success
- log_pick_pc(sd, LOG_TYPE_OTHER, -1, &sd->status.inventory[idx_equip]);
+ logs->pick_pc(sd, LOG_TYPE_OTHER, -1, &sd->status.inventory[idx_equip],sd->inventory_data[idx_equip]);
sd->status.inventory[idx_equip].card[i] = nameid;
- log_pick_pc(sd, LOG_TYPE_OTHER, 1, &sd->status.inventory[idx_equip]);
+ logs->pick_pc(sd, LOG_TYPE_OTHER, 1, &sd->status.inventory[idx_equip],sd->inventory_data[idx_equip]);
clif->insert_card(sd,idx_equip,idx_card,0);
}
@@ -3667,7 +3688,7 @@ int pc_payzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type,
clif->updatestatus(sd,SP_ZENY);
if(!tsd) tsd = sd;
- log_zeny(sd, type, tsd, -zeny);
+ logs->zeny(sd, type, tsd, -zeny);
if( zeny > 0 && sd->state.showzeny ) {
char output[255];
sprintf(output, "Removed %dz.", zeny);
@@ -3795,7 +3816,7 @@ int pc_getzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type,
clif->updatestatus(sd,SP_ZENY);
if(!tsd) tsd = sd;
- log_zeny(sd, type, tsd, zeny);
+ logs->zeny(sd, type, tsd, zeny);
if( zeny > 0 && sd->state.showzeny ) {
char output[255];
sprintf(output, "Gained %dz.", zeny);
@@ -3890,7 +3911,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
if( !itemdb_isstackable2(data) && !item_data->unique_id )
sd->status.inventory[i].unique_id = itemdb_unique_id(0,0);
#endif
- log_pick_pc(sd, log_type, amount, &sd->status.inventory[i]);
+ logs->pick_pc(sd, log_type, amount, &sd->status.inventory[i],sd->inventory_data[i]);
sd->weight += w;
clif->updatestatus(sd,SP_WEIGHT);
@@ -3930,7 +3951,7 @@ int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reas
if(sd->status.inventory[n].nameid==0 || amount <= 0 || sd->status.inventory[n].amount<amount || sd->inventory_data[n] == NULL)
return 1;
- log_pick_pc(sd, log_type, -amount, &sd->status.inventory[n]);
+ logs->pick_pc(sd, log_type, -amount, &sd->status.inventory[n],sd->inventory_data[n]);
sd->status.inventory[n].amount -= amount;
sd->weight -= sd->inventory_data[n]->weight*amount ;
@@ -4213,7 +4234,7 @@ int pc_isUseitem(struct map_session_data *sd,int n)
//Dead Branch & Bloody Branch & Porings Box
// FIXME: outdated, use constants or database
if( nameid == 604 || nameid == 12103 || nameid == 12109 )
- log_branch(sd);
+ logs->branch(sd);
return 1;
}
@@ -4302,7 +4323,7 @@ int pc_useitem(struct map_session_data *sd,int n)
sprintf(e_msg,"Item Failed. [%s] is cooling down. wait %d seconds.",
itemdb_jname(sd->status.inventory[n].nameid),
e_tick+1);
- clif->colormes(sd,COLOR_RED,e_msg);
+ clif->colormes(sd->fd,COLOR_RED,e_msg);
return 0; // Delay has not expired yet
}
} else {// not yet used item (all slots are initially empty)
@@ -4428,7 +4449,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
clif->cart_additem(sd,i,amount,0);
}
sd->status.cart[i].favorite = 0;/* clear */
- log_pick_pc(sd, log_type, amount, &sd->status.cart[i]);
+ logs->pick_pc(sd, log_type, amount, &sd->status.cart[i],data);
sd->cart_weight += w;
clif->updatestatus(sd,SP_CARTINFO);
@@ -4442,18 +4463,17 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
* 0 = success
* 1 = fail
*------------------------------------------*/
-int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type)
-{
+int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type) {
+ struct item_data * data;
nullpo_retr(1, sd);
- if(sd->status.cart[n].nameid==0 ||
- sd->status.cart[n].amount<amount)
+ if( sd->status.cart[n].nameid == 0 || sd->status.cart[n].amount < amount || !(data = itemdb_exists(sd->status.cart[n].nameid)) )
return 1;
- log_pick_pc(sd, log_type, -amount, &sd->status.cart[n]);
+ logs->pick_pc(sd, log_type, -amount, &sd->status.cart[n],data);
sd->status.cart[n].amount -= amount;
- sd->cart_weight -= itemdb_weight(sd->status.cart[n].nameid)*amount ;
+ sd->cart_weight -= data->weight*amount ;
if(sd->status.cart[n].amount <= 0){
memset(&sd->status.cart[n],0,sizeof(sd->status.cart[0]));
sd->cart_num--;
@@ -4573,6 +4593,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil
struct status_data *sd_status, *md_status;
struct mob_data *md;
struct item tmp_item;
+ struct item_data *data;
if(!sd || !bl || bl->type!=BL_MOB)
return 0;
@@ -4604,7 +4625,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil
// Try dropping one item, in the order from first to last possible slot.
// Droprate is affected by the skill success rate.
for( i = 0; i < MAX_STEAL_DROP; i++ )
- if( md->db->dropitem[i].nameid > 0 && itemdb_exists(md->db->dropitem[i].nameid) && rnd() % 10000 < md->db->dropitem[i].p * rate/100. )
+ if( md->db->dropitem[i].nameid > 0 && (data = itemdb_exists(md->db->dropitem[i].nameid)) && rnd() % 10000 < md->db->dropitem[i].p * rate/100. )
break;
if( i == MAX_STEAL_DROP )
return 0;
@@ -4613,7 +4634,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil
memset(&tmp_item,0,sizeof(tmp_item));
tmp_item.nameid = itemid;
tmp_item.amount = 1;
- tmp_item.identify = itemdb_isidentified(itemid);
+ tmp_item.identify = itemdb_isidentified2(data);
flag = pc_additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER);
//TODO: Should we disable stealing when the item you stole couldn't be added to your inventory? Perhaps players will figure out a way to exploit this behaviour otherwise?
@@ -4628,14 +4649,12 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil
party_foreachsamemap(pc_show_steal,sd,AREA_SIZE,sd,tmp_item.nameid);
//Logs items, Stolen from mobs [Lupus]
- log_pick_mob(md, LOG_TYPE_STEAL, -1, &tmp_item);
+ logs->pick_mob(md, LOG_TYPE_STEAL, -1, &tmp_item, data);
//A Rare Steal Global Announce by Lupus
if(md->db->dropitem[i].p<=battle_config.rare_drop_announce) {
- struct item_data *i_data;
char message[128];
- i_data = itemdb_search(itemid);
- sprintf (message, msg_txt(542), (sd->status.name != NULL)?sd->status.name :"GM", md->db->jname, i_data->jname, (float)md->db->dropitem[i].p/100);
+ sprintf (message, msg_txt(542), (sd->status.name != NULL)?sd->status.name :"GM", md->db->jname, data->jname, (float)md->db->dropitem[i].p/100);
//MSG: "'%s' stole %s's %s (chance: %0.02f%%)"
intif_broadcast(message,strlen(message)+1,0);
}
@@ -4755,7 +4774,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
// make sure vending is allowed here
if (sd->state.vending && map[m].flag.novending) {
clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map"
- vending_closevending(sd);
+ vending->close(sd);
}
if( hChSys.local && map[sd->bl.m].channel && idb_exists(map[sd->bl.m].channel->users, sd->status.char_id) ) {
@@ -4806,7 +4825,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
if (sd->state.vending && map_getcell(m,x,y,CELL_CHKNOVENDING)) {
clif->message (sd->fd, msg_txt(204)); // "You can't open a shop on this cell."
- vending_closevending(sd);
+ vending->close(sd);
}
if(sd->bl.prev != NULL){
@@ -6306,7 +6325,7 @@ int pc_resetskill(struct map_session_data* sd, int flag)
if( pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd) )
clif->status_change(&sd->bl, SI_DEVIL, 0, 0, 0, 0, 0); //Remove perma blindness due to skill-reset. [Skotlex]
i = sd->sc.option;
- if( i&OPTION_RIDING && pc_checkskill(sd, KN_RIDING) )
+ if( i&OPTION_RIDING && (!pc_checkskill(sd, KN_RIDING) || (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) )
i &= ~OPTION_RIDING;
if( i&OPTION_FALCON && pc_checkskill(sd, HT_FALCON) )
i &= ~OPTION_FALCON;
@@ -7085,7 +7104,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val)
case SP_ZENY:
if( val < 0 )
return 0;// can't set negative zeny
- log_zeny(sd, LOG_TYPE_SCRIPT, sd, -(sd->status.zeny - cap_value(val, 0, MAX_ZENY)));
+ logs->zeny(sd, LOG_TYPE_SCRIPT, sd, -(sd->status.zeny - cap_value(val, 0, MAX_ZENY)));
sd->status.zeny = cap_value(val, 0, MAX_ZENY);
break;
case SP_BASEEXP:
@@ -7444,7 +7463,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
if (sd->ed)
elemental_delete(sd->ed, 0);
if (sd->state.vending)
- vending_closevending(sd);
+ vending->close(sd);
map_foreachinmap(jobchange_killclone, sd->bl.m, BL_MOB, sd->bl.id);
@@ -7594,7 +7613,7 @@ int pc_setoption(struct map_session_data *sd,int type)
clif->status_change(&sd->bl, SI_RIDING, 1, 0, 0, 0, 0);
status_calc_pc(sd,0);
}
- else if( (!(type&OPTION_RIDING) && p_type&OPTION_RIDING) || (!(type&OPTION_DRAGON) && p_type&OPTION_DRAGON && pc_checkskill(sd,RK_DRAGONTRAINING) > 0) )
+ else if( (!(type&OPTION_RIDING) && p_type&OPTION_RIDING) || (!(type&OPTION_DRAGON) && p_type&OPTION_DRAGON) )
{ // Dismount
clif->status_change(&sd->bl, SI_RIDING, 0, 0, 0, 0, 0);
status_calc_pc(sd,0);
@@ -9243,22 +9262,10 @@ bool pc_isautolooting(struct map_session_data *sd, int nameid)
/**
* Checks if player can use @/#command
* @param sd Player map session data
- * @param command Command name without @/# and params
- * @param type is it atcommand or charcommand
+ * @param command Command name with @/# and without params
*/
-bool pc_can_use_command(struct map_session_data *sd, const char *command, AtCommandType type)
-{
- return pc_group_can_use_command(pc_get_group_id(sd), command, type);
-}
-
-/**
- * Checks if commands used by a player should be logged
- * according to their group setting.
- * @param sd Player map session data
- */
-bool pc_should_log_commands(struct map_session_data *sd)
-{
- return pc_group_should_log_commands(pc_get_group_id(sd));
+bool pc_can_use_command(struct map_session_data *sd, const char *command) {
+ return atcommand->can_use(sd,command);
}
static int pc_talisman_timer(int tid, unsigned int tick, int id, intptr_t data)
@@ -9542,7 +9549,8 @@ static bool pc_readdb_levelpenalty(char* fields[], int columns, int current)
*------------------------------------------*/
int pc_readdb(void)
{
- int i,j,k,tmp=0;
+ int i,j,k;
+ unsigned int count = 0;
FILE *fp;
char line[24000],*p;
@@ -9586,7 +9594,7 @@ int pc_readdb(void)
ShowWarning("pc_readdb: Specified max level %u for job %d is beyond server's limit (%u).\n ", maxlv, job_id, MAX_LEVEL);
maxlv = MAX_LEVEL;
}
-
+ count++;
job = jobs[0] = pc_class2idx(job_id);
//We send one less and then one more because the last entry in the exp array should hold 0.
max_level[job][type] = pc_split_atoui(split[3], exp_table[job][type],',',maxlv-1)+1;
@@ -9629,8 +9637,8 @@ int pc_readdb(void)
if (!max_level[j][1])
ShowWarning("Class %s (%d) does not has a job exp table.\n", job_name(i), i);
}
- ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n","exp.txt");
-
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,db_path,"exp.txt");
+ count = 0;
// Reset and read skilltree
memset(skill_tree,0,sizeof(skill_tree));
sv_readdb(db_path, DBPATH"skill_tree.txt", ',', 3+MAX_PC_SKILL_REQUIRE*2, 4+MAX_PC_SKILL_REQUIRE*2, -1, &pc_readdb_skilltree);
@@ -9639,7 +9647,7 @@ int pc_readdb(void)
sv_readdb(db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty);
for( k=1; k < 3; k++ ){ // fill in the blanks
for( j = 0; j < RC_MAX; j++ ){
- tmp = 0;
+ int tmp = 0;
for( i = 0; i < MAX_LEVEL*2; i++ ){
if( i == MAX_LEVEL+1 )
tmp = level_penalty[k][j][0];// reset
@@ -9681,7 +9689,7 @@ int pc_readdb(void)
lv=atoi(split[0]);
n=atoi(split[1]);
-
+ count++;
for(i=0;i<n && i<ELE_MAX;){
if( !fgets(line, sizeof(line), fp) )
break;
@@ -9702,8 +9710,8 @@ int pc_readdb(void)
}
}
fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n","attr_fix.txt");
-
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,db_path,"attr_fix.txt");
+ count = 0;
// reset then read statspoint
memset(statp,0,sizeof(statp));
i=1;
@@ -9723,12 +9731,13 @@ int pc_readdb(void)
stat=0;
if (i > MAX_LEVEL)
break;
+ count++;
statp[i]=stat;
i++;
}
fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n","statpoint.txt");
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,db_path,"statpoint.txt");
}
// generate the remaining parts of the db if necessary
k = battle_config.use_statpoint_table; //save setting
diff --git a/src/map/pc.h b/src/map/pc.h
index 809822e78..ff65d9824 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -109,6 +109,12 @@ struct s_autobonus {
unsigned short pos;
};
+enum npc_timeout_type {
+ NPCT_INPUT = 0,
+ NPCT_MENU = 1,
+ NPCT_WAIT = 2,
+};
+
struct map_session_data {
struct block_list bl;
struct unit_data ud;
@@ -165,6 +171,7 @@ struct map_session_data {
struct guild *gmaster_flag;
unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
unsigned int warping : 1;//states whether you're in the middle of a warp processing
+ unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
} state;
struct {
unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
@@ -182,7 +189,8 @@ struct map_session_data {
unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex]
int group_id, group_pos, group_level;
unsigned int permissions;/* group permissions */
-
+ bool group_log_command;
+
struct mmo_charstatus status;
struct registry save_reg;
@@ -391,8 +399,8 @@ struct map_session_data {
int guildspy; // [Syrus22]
int partyspy; // [Syrus22]
- int vended_id;
- int vender_id;
+ unsigned int vended_id;
+ unsigned int vender_id;
int vend_num;
char message[MESSAGE_SIZE];
struct s_vending vending[MAX_VENDING];
@@ -466,7 +474,7 @@ struct map_session_data {
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
**/
-#if SECURE_NPCTIMEOUT
+#ifdef SECURE_NPCTIMEOUT
/**
* ID of the timer
* @info
@@ -480,6 +488,8 @@ struct map_session_data {
* - It is updated on every NPC iteration as mentioned above
**/
unsigned int npc_idle_tick;
+ /* */
+ enum npc_timeout_type npc_idle_type;
#endif
struct {
@@ -500,7 +510,8 @@ struct map_session_data {
unsigned char channel_count;
struct hChSysCh *gcbind;
bool stealth;
- unsigned char fontcolor; /* debug-only */
+ unsigned char fontcolor;
+ unsigned int hchsysch_tick;
// temporary debugging of bug #3504
const char* delunit_prevfile;
@@ -685,13 +696,13 @@ enum equip_pos {
int pc_class2idx(int class_);
int pc_get_group_level(struct map_session_data *sd);
-int pc_get_group_id(struct map_session_data *sd);
+#define pc_get_group_id(sd) ( (sd)->group_id )
int pc_getrefinebonus(int lv,int type);
bool pc_can_give_items(struct map_session_data *sd);
-bool pc_can_use_command(struct map_session_data *sd, const char *command, AtCommandType type);
+bool pc_can_use_command(struct map_session_data *sd, const char *command);
#define pc_has_permission(sd, permission) ( ((sd)->permissions&permission) != 0 )
-bool pc_should_log_commands(struct map_session_data *sd);
+#define pc_should_log_commands(sd) ( (sd)->group_log_command != false )
int pc_setrestartvalue(struct map_session_data *sd,int type);
int pc_makesavestatus(struct map_session_data *);
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index 31ae03e2a..2fd143b53 100644
--- a/src/map/pc_groups.c
+++ b/src/map/pc_groups.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/conf.h"
#include "../common/db.h"
@@ -20,21 +21,20 @@ typedef struct GroupSettings GroupSettings;
struct GroupSettings {
unsigned int id; // groups.[].id
int level; // groups.[].level
- const char *name; // groups.[].name
- config_setting_t *commands; // groups.[].commands
+ char name[60]; // copy of groups.[].name
unsigned int e_permissions; // packed groups.[].permissions
bool log_commands; // groups.[].log_commands
- /// Following are used only during config reading
+ int group_pos;/* pos on load [Ind] */
+ /// Following are used/avaialble only during config reading
+ config_setting_t *commands; // groups.[].commands
config_setting_t *permissions; // groups.[].permissions
config_setting_t *inherit; // groups.[].inherit
bool inheritance_done; // have all inheritance rules been evaluated?
config_setting_t *root; // groups.[]
- int group_pos;/* pos on load */
};
int pc_group_max; /* known number of groups */
-static config_t pc_group_config;
static DBMap* pc_group_db; // id -> GroupSettings
static DBMap* pc_groupname_db; // name -> GroupSettings
@@ -60,8 +60,8 @@ static inline GroupSettings* name2group(const char* group_name)
* Loads group configuration from config file into memory.
* @private
*/
-static void read_config(void)
-{
+static void read_config(void) {
+ config_t pc_group_config;
config_setting_t *groups = NULL;
const char *config_filename = "conf/groups.conf"; // FIXME hardcoded name
int group_count = 0;
@@ -126,7 +126,7 @@ static void read_config(void)
CREATE(group_settings, GroupSettings, 1);
group_settings->id = id;
group_settings->level = level;
- group_settings->name = groupname;
+ safestrncpy(group_settings->name, groupname, 60);
group_settings->log_commands = (bool)log_commands;
group_settings->inherit = config_setting_get_member(group, "inherit");
group_settings->commands = config_setting_get_member(group, "commands");
@@ -155,7 +155,7 @@ static void read_config(void)
for (i = 0; i < count; ++i) {
config_setting_t *command = config_setting_get_elem(commands, i);
const char *name = config_setting_name(command);
- if (!atcommand_exists(name)) {
+ if (!atcommand->exists(name)) {
ShowConfigWarning(command, "pc_groups:read_config: non-existent command name '%s', removing...", name);
config_setting_remove(commands, name);
--i;
@@ -284,20 +284,13 @@ static void read_config(void)
group_ids[i++] = group_settings->id;
}
- atcommand_db_load_groups(group_ids);
+ atcommand->load_groups(group_ids);
aFree(group_ids);
dbi_destroy(iter);
}
-}
-
-/**
- * Removes group configuration from memory.
- * @private
- */
-static void destroy_config(void)
-{
+
config_destroy(&pc_group_config);
}
@@ -312,13 +305,12 @@ static void destroy_config(void)
static inline int AtCommandType2idx(AtCommandType type) { return (type-1); }
/**
- * Checks if player group can use @/#command
+ * Checks if player group can use @/#command, used only during parse (only available during parse)
* @param group_id ID of the group
* @param command Command name without @/# and params
* @param type enum AtCommanndType { COMMAND_ATCOMMAND = 1, COMMAND_CHARCOMMAND = 2 }
*/
-bool pc_group_can_use_command(int group_id, const char *command, AtCommandType type)
-{
+bool pc_group_can_use_command(int group_id, const char *command, AtCommandType type) {
int result = 0;
config_setting_t *commands = NULL;
GroupSettings *group = NULL;
@@ -357,6 +349,7 @@ void pc_group_pc_load(struct map_session_data * sd) {
sd->permissions = group->e_permissions;
sd->group_pos = group->group_pos;
sd->group_level = group->level;
+ sd->group_log_command = group->log_commands;
}
/**
* Checks if player group has a permission
@@ -442,7 +435,6 @@ void do_final_pc_groups(void)
db_destroy(pc_group_db);
if (pc_groupname_db != NULL )
db_destroy(pc_groupname_db);
- destroy_config();
}
/**
diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h
index dea689ebd..26cd8f39f 100644
--- a/src/map/pc_groups.h
+++ b/src/map/pc_groups.h
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _PC_GROUPS_H_
#define _PC_GROUPS_H_
diff --git a/src/map/pet.c b/src/map/pet.c
index 28f841809..c85092a01 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -76,6 +76,7 @@ int pet_create_egg(struct map_session_data *sd, int item_id)
{
int pet_id = search_petDB_index(item_id, PET_EGG);
if (pet_id < 0) return 0; //No pet egg here.
+ if (!pc_inventoryblank(sd)) return 0; // Inventory full
sd->catch_target_class = pet_db[pet_id].class_;
intif_create_pet(sd->status.account_id, sd->status.char_id,
(short)pet_db[pet_id].class_,
@@ -582,6 +583,7 @@ static int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap);
int pet_menu(struct map_session_data *sd,int menunum)
{
+ struct item_data *egg_id;
nullpo_ret(sd);
if (sd->pd == NULL)
return 1;
@@ -589,6 +591,14 @@ int pet_menu(struct map_session_data *sd,int menunum)
//You lost the pet already.
if(!sd->status.pet_id || sd->pd->pet.intimate <= 0 || sd->pd->pet.incuvate)
return 1;
+
+ egg_id = itemdb_exists(sd->pd->petDB->EggID);
+ if (egg_id) {
+ if ((egg_id->flag.trade_restriction&0x01) && !pc_inventoryblank(sd)) {
+ clif->message(sd->fd, msg_txt(451)); // You can't return your pet because your inventory is full.
+ return 1;
+ }
+ }
switch(menunum) {
case 0:
@@ -875,7 +885,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
}
}
- if(!target && pd->loot && pd->loot->count < pd->loot->max && DIFF_TICK(tick,pd->ud.canact_tick)>0) {
+ if(!target && pd->loot && pd->msd && pc_has_permission(pd->msd, PC_PERM_TRADE) && pd->loot->count < pd->loot->max && DIFF_TICK(tick,pd->ud.canact_tick)>0) {
//Use half the pet's range of sight.
map_foreachinrange(pet_ai_sub_hard_lootsearch,&pd->bl,
pd->db->range2/2, BL_ITEM,pd,&target);
diff --git a/src/map/script.c b/src/map/script.c
index 3e51859d1..a061fcdd1 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -50,6 +50,7 @@
#include "script.h"
#include "quest.h"
#include "elemental.h"
+#include "../config/core.h"
#include <stdio.h>
#include <stdlib.h>
@@ -62,13 +63,6 @@
#include <setjmp.h>
#include <errno.h>
-#ifdef BETA_THREAD_TEST
- #include "../common/atomic.h"
- #include "../common/spinlock.h"
- #include "../common/thread.h"
- #include "../common/mutex.h"
-#endif
-
///////////////////////////////////////////////////////////////////////////////
//## TODO possible enhancements: [FlavioJS]
@@ -199,7 +193,7 @@ static struct str_data_struct {
int str;
int backpatch;
int label;
- int (*func)(struct script_state *st);
+ bool (*func)(struct script_state *st);
int val;
int next;
} *str_data = NULL;
@@ -305,39 +299,15 @@ c_op get_com(unsigned char *script,int *pos);
int get_num(unsigned char *script,int *pos);
typedef struct script_function {
- int (*func)(struct script_state *st);
+ bool (*func)(struct script_state *st);
const char *name;
const char *arg;
} script_function;
-extern script_function buildin_func[];
+extern script_function BUILDIN[];
static struct linkdb_node* sleep_db;// int oid -> struct script_state*
-#ifdef BETA_THREAD_TEST
-/**
- * MySQL Query Slave
- **/
-static SPIN_LOCK queryThreadLock;
-static rAthread queryThread = NULL;
-static ramutex queryThreadMutex = NULL;
-static racond queryThreadCond = NULL;
-static volatile int32 queryThreadTerminate = 0;
-
-struct queryThreadEntry {
- bool ok;
- bool type; /* main db or log db? */
- struct script_state *st;
-};
-
-/* Ladies and Gentleman the Manager! */
-struct {
- struct queryThreadEntry **entry;/* array of structs */
- int count;
- int timer;/* used to receive processed entries */
-} queryThreadData;
-#endif
-
/*==========================================
* (Only those needed) local declaration prototype
*------------------------------------------*/
@@ -365,13 +335,8 @@ enum {
MF_FOG,
MF_SAKURA,
MF_LEAVES,
- /**
- * No longer available, keeping here just in case it's back someday. [Ind]
- **/
- //MF_RAIN, //20
- // 21 free
- MF_NOGO = 22,
- MF_CLOUDS,
+ /* 21 - 22 free */
+ MF_CLOUDS = 23,
MF_CLOUDS2,
MF_FIREWORKS,
MF_GVG_CASTLE,
@@ -971,13 +936,13 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom)
// buildin function
add_scriptl(func);
add_scriptc(C_ARG);
- arg = buildin_func[str_data[func].val].arg;
+ arg = BUILDIN[str_data[func].val].arg;
} else if( str_data[func].type == C_USERFUNC || str_data[func].type == C_USERFUNC_POS ){
// script defined function
add_scriptl(buildin_callsub_ref);
add_scriptc(C_ARG);
add_scriptl(func);
- arg = buildin_func[str_data[buildin_callsub_ref].val].arg;
+ arg = BUILDIN[str_data[buildin_callsub_ref].val].arg;
if( *arg == 0 )
disp_error_message("parse_callfunc: callsub has no arguments, please review it's definition",p);
if( *arg != '*' )
@@ -995,7 +960,7 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom)
add_scriptc(C_STR);
while( *name ) add_scriptb(*name ++);
add_scriptb(0);
- arg = buildin_func[str_data[buildin_callfunc_ref].val].arg;
+ arg = BUILDIN[str_data[buildin_callfunc_ref].val].arg;
if( *arg != '*' ) ++ arg;
}
#endif
@@ -1610,9 +1575,9 @@ const char* parse_syntax(const char* p)
set_label(l,script_pos,p);
}
// check duplication of case label [Rayce]
- if(linkdb_search(&syntax.curly[pos].case_label, (void*)__64BPRTSIZE(v)) != NULL)
+ if(linkdb_search(&syntax.curly[pos].case_label, (void*)__64BPTRSIZE(v)) != NULL)
disp_error_message("parse_syntax: dup 'case'",p);
- linkdb_insert(&syntax.curly[pos].case_label, (void*)__64BPRTSIZE(v), (void*)1);
+ linkdb_insert(&syntax.curly[pos].case_label, (void*)__64BPTRSIZE(v), (void*)1);
sprintf(label,"set $@__SW%x_VAL,0;",syntax.curly[pos].index);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
@@ -2125,11 +2090,11 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
/*==========================================
* Added built-in functions
*------------------------------------------*/
-static void add_buildin_func(void)
+static void add_BUILDIN(void)
{
int i,n;
const char* p;
- for( i = 0; buildin_func[i].func; i++ )
+ for( i = 0; BUILDIN[i].func; i++ )
{
// arg must follow the pattern: (v|s|i|r|l)*\?*\*?
// 'v' - value (either string or int or reference)
@@ -2139,24 +2104,24 @@ static void add_buildin_func(void)
// 'l' - label
// '?' - one optional parameter
// '*' - unknown number of optional parameters
- p = buildin_func[i].arg;
+ p = BUILDIN[i].arg;
while( *p == 'v' || *p == 's' || *p == 'i' || *p == 'r' || *p == 'l' ) ++p;
while( *p == '?' ) ++p;
if( *p == '*' ) ++p;
if( *p != 0){
- ShowWarning("add_buildin_func: ignoring function \"%s\" with invalid arg \"%s\".\n", buildin_func[i].name, buildin_func[i].arg);
- } else if( *skip_word(buildin_func[i].name) != 0 ){
- ShowWarning("add_buildin_func: ignoring function with invalid name \"%s\" (must be a word).\n", buildin_func[i].name);
+ ShowWarning("add_BUILDIN: ignoring function \"%s\" with invalid arg \"%s\".\n", BUILDIN[i].name, BUILDIN[i].arg);
+ } else if( *skip_word(BUILDIN[i].name) != 0 ){
+ ShowWarning("add_BUILDIN: ignoring function with invalid name \"%s\" (must be a word).\n", BUILDIN[i].name);
} else {
- n = add_str(buildin_func[i].name);
+ n = add_str(BUILDIN[i].name);
str_data[n].type = C_FUNC;
str_data[n].val = i;
- str_data[n].func = buildin_func[i].func;
+ str_data[n].func = BUILDIN[i].func;
- if (!strcmp(buildin_func[i].name, "set")) buildin_set_ref = n;
- else if (!strcmp(buildin_func[i].name, "callsub")) buildin_callsub_ref = n;
- else if (!strcmp(buildin_func[i].name, "callfunc")) buildin_callfunc_ref = n;
- else if( !strcmp(buildin_func[i].name, "getelementofarray") ) buildin_getelementofarray_ref = n;
+ if (!strcmp(BUILDIN[i].name, "set")) buildin_set_ref = n;
+ else if (!strcmp(BUILDIN[i].name, "callsub")) buildin_callsub_ref = n;
+ else if (!strcmp(BUILDIN[i].name, "callfunc")) buildin_callfunc_ref = n;
+ else if( !strcmp(BUILDIN[i].name, "getelementofarray") ) buildin_getelementofarray_ref = n;
}
}
}
@@ -2298,7 +2263,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
memset(&syntax,0,sizeof(syntax));
if(first){
- add_buildin_func();
+ add_BUILDIN();
read_constdb();
first=0;
}
@@ -2650,7 +2615,7 @@ void* get_val2(struct script_state* st, int uid, struct DBMap** ref)
push_val2(st->stack, C_NAME, uid, ref);
data = script_getdatatop(st, -1);
get_val(st, data);
- return (data->type == C_INT ? (void*)__64BPRTSIZE(data->u.num) : (void*)__64BPRTSIZE(data->u.str));
+ return (data->type == C_INT ? (void*)__64BPTRSIZE(data->u.num) : (void*)__64BPTRSIZE(data->u.str));
}
/*==========================================
@@ -2695,7 +2660,7 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
}
else
{// integer variable
- int val = (int)__64BPRTSIZE(value);
+ int val = (int)__64BPTRSIZE(value);
if(str_data[num&0x00ffffff].type == C_PARAM)
{
if( pc_setparam(sd, str_data[num&0x00ffffff].val, val) == 0 )
@@ -3341,7 +3306,7 @@ static void script_check_buildin_argtype(struct script_state* st, int func)
{
char type;
int idx, invalid = 0;
- script_function* sf = &buildin_func[str_data[func].val];
+ script_function* sf = &BUILDIN[str_data[func].val];
for( idx = 2; script_hasdata(st, idx); idx++ )
{
@@ -3462,7 +3427,7 @@ int run_func(struct script_state *st)
}
if(str_data[func].func){
- if (str_data[func].func(st)) //Report error
+ if (!(str_data[func].func(st))) //Report error
script_reportsrc(st);
} else {
ShowError("script:run_func: '%s' (id=%d type=%s) has no C function. please report this!!!\n", get_str(func), func, script_op2name(str_data[func].type));
@@ -3529,7 +3494,7 @@ void script_stop_sleeptimers(int id)
struct script_state* st;
for(;;)
{
- st = (struct script_state*)linkdb_erase(&sleep_db,(void*)__64BPRTSIZE(id));
+ st = (struct script_state*)linkdb_erase(&sleep_db,(void*)__64BPTRSIZE(id));
if( st == NULL )
break; // no more sleep timers
script_free_state(st);
@@ -3571,7 +3536,7 @@ int run_script_timer(int tid, unsigned int tick, int id, intptr_t data)
st->state = END;
}
while( node && st->sleep.timer != INVALID_TIMER ) {
- if( (int)__64BPRTSIZE(node->key) == st->oid && ((struct script_state *)node->data)->sleep.timer == st->sleep.timer ) {
+ if( (int)__64BPTRSIZE(node->key) == st->oid && ((struct script_state *)node->data)->sleep.timer == st->sleep.timer ) {
script_erase_sleepdb(node);
st->sleep.timer = INVALID_TIMER;
break;
@@ -3603,7 +3568,7 @@ static void script_detach_state(struct script_state* st, bool dequeue_event)
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
**/
-#if SECURE_NPCTIMEOUT
+#ifdef SECURE_NPCTIMEOUT
/**
* We're done with this NPC session, so we cancel the timer (if existent) and move on
**/
@@ -3649,7 +3614,7 @@ static void script_attach_state(struct script_state* st)
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
**/
-#if SECURE_NPCTIMEOUT
+#ifdef SECURE_NPCTIMEOUT
if( sd->npc_idle_timer == INVALID_TIMER )
sd->npc_idle_timer = add_timer(gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0);
sd->npc_idle_tick = gettick();
@@ -3777,7 +3742,7 @@ void run_script_main(struct script_state *st)
st->sleep.charid = sd?sd->status.char_id:0;
st->sleep.timer = add_timer(gettick()+st->sleep.tick,
run_script_timer, st->sleep.charid, (intptr_t)st);
- linkdb_insert(&sleep_db, (void*)__64BPRTSIZE(st->oid), st);
+ linkdb_insert(&sleep_db, (void*)__64BPTRSIZE(st->oid), st);
}
else if(st->state != END && st->rid){
//Resume later (st is already attached to player).
@@ -3921,7 +3886,7 @@ void script_cleararray_pc(struct map_session_data* sd, const char* varname, void
{
for( idx = 0; idx < SCRIPT_MAX_ARRAYSIZE; idx++ )
{
- pc_setreg(sd, reference_uid(key, idx), (int)__64BPRTSIZE(value));
+ pc_setreg(sd, reference_uid(key, idx), (int)__64BPTRSIZE(value));
}
}
}
@@ -3953,7 +3918,7 @@ void script_setarray_pc(struct map_session_data* sd, const char* varname, uint8
}
else
{
- pc_setreg(sd, reference_uid(key, idx), (int)__64BPRTSIZE(value));
+ pc_setreg(sd, reference_uid(key, idx), (int)__64BPTRSIZE(value));
}
if( refcache )
@@ -3961,175 +3926,6 @@ void script_setarray_pc(struct map_session_data* sd, const char* varname, uint8
refcache[0] = key;
}
}
-#ifdef BETA_THREAD_TEST
-int buildin_query_sql_sub(struct script_state* st, Sql* handle);
-
-/* used to receive items the queryThread has already processed */
-int queryThread_timer(int tid, unsigned int tick, int id, intptr_t data) {
- int i, cursor = 0;
- bool allOk = true;
-
- EnterSpinLock(&queryThreadLock);
-
- for( i = 0; i < queryThreadData.count; i++ ) {
- struct queryThreadEntry *entry = queryThreadData.entry[i];
-
- if( !entry->ok ) {
- allOk = false;
- continue;
- }
-
- run_script_main(entry->st);
-
- entry->st = NULL;/* empty entries */
- aFree(entry);
- queryThreadData.entry[i] = NULL;
- }
-
-
- if( allOk ) {
- /* cancel the repeating timer -- it'll re-create itself when necessary, dont need to remain looping */
- delete_timer(queryThreadData.timer, queryThread_timer);
- queryThreadData.timer = INVALID_TIMER;
- }
-
- /* now lets clear the mess. */
- for( i = 0; i < queryThreadData.count; i++ ) {
- struct queryThreadEntry *entry = queryThreadData.entry[i];
- if( entry == NULL )
- continue;/* entry on hold */
-
- /* move */
- memmove(&queryThreadData.entry[cursor], &queryThreadData.entry[i], sizeof(struct queryThreadEntry*));
-
- cursor++;
- }
-
- queryThreadData.count = cursor;
-
- LeaveSpinLock(&queryThreadLock);
-
- return 0;
-}
-
-void queryThread_add(struct script_state *st, bool type) {
- int idx = 0;
- struct queryThreadEntry* entry = NULL;
-
- EnterSpinLock(&queryThreadLock);
-
- if( queryThreadData.count++ != 0 )
- RECREATE(queryThreadData.entry, struct queryThreadEntry* , queryThreadData.count);
-
- idx = queryThreadData.count-1;
-
- CREATE(queryThreadData.entry[idx],struct queryThreadEntry,1);
-
- entry = queryThreadData.entry[idx];
-
- entry->st = st;
- entry->ok = false;
- entry->type = type;
- if( queryThreadData.timer == INVALID_TIMER ) { /* start the receiver timer */
- queryThreadData.timer = add_timer_interval(gettick() + 100, queryThread_timer, 0, 0, 100);
- }
-
- LeaveSpinLock(&queryThreadLock);
-
- /* unlock the queryThread */
- racond_signal(queryThreadCond);
-}
-/* adds a new log to the queue */
-void queryThread_log(char * entry, int length) {
- int idx = logThreadData.count;
-
- EnterSpinLock(&queryThreadLock);
-
- if( logThreadData.count++ != 0 )
- RECREATE(logThreadData.entry, char* , logThreadData.count);
-
- CREATE(logThreadData.entry[idx], char, length + 1 );
- safestrncpy(logThreadData.entry[idx], entry, length + 1 );
-
- LeaveSpinLock(&queryThreadLock);
-
- /* unlock the queryThread */
- racond_signal(queryThreadCond);
-}
-
-/* queryThread_main */
-static void *queryThread_main(void *x) {
- Sql *queryThread_handle = Sql_Malloc();
- int i;
-
- if ( SQL_ERROR == Sql_Connect(queryThread_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) )
- exit(EXIT_FAILURE);
-
- if( strlen(default_codepage) > 0 )
- if ( SQL_ERROR == Sql_SetEncoding(queryThread_handle, default_codepage) )
- Sql_ShowDebug(queryThread_handle);
-
- if( log_config.sql_logs ) {
- logmysql_handle = Sql_Malloc();
-
- if ( SQL_ERROR == Sql_Connect(logmysql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db) )
- exit(EXIT_FAILURE);
-
- if( strlen(default_codepage) > 0 )
- if ( SQL_ERROR == Sql_SetEncoding(logmysql_handle, default_codepage) )
- Sql_ShowDebug(logmysql_handle);
- }
-
- while( 1 ) {
-
- if(queryThreadTerminate > 0)
- break;
-
- EnterSpinLock(&queryThreadLock);
-
- /* mess with queryThreadData within the lock */
- for( i = 0; i < queryThreadData.count; i++ ) {
- struct queryThreadEntry *entry = queryThreadData.entry[i];
-
- if( entry->ok )
- continue;
- else if ( !entry->st || !entry->st->stack ) {
- entry->ok = true;/* dispose */
- continue;
- }
-
- buildin_query_sql_sub(entry->st, entry->type ? logmysql_handle : queryThread_handle);
-
- entry->ok = true;/* we're done with this */
- }
-
- /* also check for any logs in need to be sent */
- if( log_config.sql_logs ) {
- for( i = 0; i < logThreadData.count; i++ ) {
- if( SQL_ERROR == Sql_Query(logmysql_handle, logThreadData.entry[i]) )
- Sql_ShowDebug(logmysql_handle);
- aFree(logThreadData.entry[i]);
- }
- logThreadData.count = 0;
- }
-
- LeaveSpinLock(&queryThreadLock);
-
- ramutex_lock( queryThreadMutex );
- racond_wait( queryThreadCond, queryThreadMutex, -1 );
- ramutex_unlock( queryThreadMutex );
-
- }
-
- Sql_Free(queryThread_handle);
-
- if( log_config.sql_logs ) {
- Sql_Free(logmysql_handle);
- }
-
- return NULL;
-}
-#endif
/*==========================================
* Destructor
*------------------------------------------*/
@@ -4210,35 +4006,12 @@ int do_final_script() {
if (str_buf)
aFree(str_buf);
- for( i = 0; i < atcmd_binding_count; i++ ) {
- aFree(atcmd_binding[i]);
+ for( i = 0; i < atcommand->binding_count; i++ ) {
+ aFree(atcommand->binding[i]);
}
- if( atcmd_binding_count != 0 )
- aFree(atcmd_binding);
-#ifdef BETA_THREAD_TEST
- /* QueryThread */
- InterlockedIncrement(&queryThreadTerminate);
- racond_signal(queryThreadCond);
- rathread_wait(queryThread, NULL);
-
- // Destroy cond var and mutex.
- racond_destroy( queryThreadCond );
- ramutex_destroy( queryThreadMutex );
-
- /* Clear missing vars */
- for( i = 0; i < queryThreadData.count; i++ ) {
- aFree(queryThreadData.entry[i]);
- }
-
- aFree(queryThreadData.entry);
-
- for( i = 0; i < logThreadData.count; i++ ) {
- aFree(logThreadData.entry[i]);
- }
-
- aFree(logThreadData.entry);
-#endif
+ if( atcommand->binding_count != 0 )
+ aFree(atcommand->binding);
return 0;
}
@@ -4251,66 +4024,23 @@ int do_init_script() {
autobonus_db = strdb_alloc(DB_OPT_DUP_KEY,0);
mapreg_init();
-#ifdef BETA_THREAD_TEST
- CREATE(queryThreadData.entry, struct queryThreadEntry*, 1);
- queryThreadData.count = 0;
- CREATE(logThreadData.entry, char *, 1);
- logThreadData.count = 0;
- /* QueryThread Start */
-
- InitializeSpinLock(&queryThreadLock);
-
- queryThreadData.timer = INVALID_TIMER;
- queryThreadTerminate = 0;
- queryThreadMutex = ramutex_create();
- queryThreadCond = racond_create();
-
- queryThread = rathread_create(queryThread_main, NULL);
-
- if(queryThread == NULL){
- ShowFatalError("do_init_script: cannot spawn Query Thread.\n");
- exit(EXIT_FAILURE);
- }
-
- add_timer_func_list(queryThread_timer, "queryThread_timer");
-#endif
return 0;
}
int script_reload() {
int i;
-#ifdef BETA_THREAD_TEST
- /* we're reloading so any queries undergoing should be...exterminated. */
- EnterSpinLock(&queryThreadLock);
-
- for( i = 0; i < queryThreadData.count; i++ ) {
- aFree(queryThreadData.entry[i]);
- }
- queryThreadData.count = 0;
-
- if( queryThreadData.timer != INVALID_TIMER ) {
- delete_timer(queryThreadData.timer, queryThread_timer);
- queryThreadData.timer = INVALID_TIMER;
- }
-
- LeaveSpinLock(&queryThreadLock);
-#endif
-
-
userfunc_db->clear(userfunc_db, db_script_free_code_sub);
db_clear(scriptlabel_db);
- // @commands (script based)
- // Clear bindings
- for( i = 0; i < atcmd_binding_count; i++ ) {
- aFree(atcmd_binding[i]);
+ for( i = 0; i < atcommand->binding_count; i++ ) {
+ aFree(atcommand->binding[i]);
}
- if( atcmd_binding_count != 0 )
- aFree(atcmd_binding);
+ if( atcommand->binding_count != 0 )
+ aFree(atcommand->binding);
- atcmd_binding_count = 0;
+ atcommand->binding_count = 0;
if(sleep_db) {
struct linkdb_node *n = (struct linkdb_node *)sleep_db;
@@ -4331,7 +4061,7 @@ int script_reload() {
#define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args }
#define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args }
-#define BUILDIN_FUNC(x) int buildin_ ## x (struct script_state* st)
+#define BUILDIN(x) bool buildin_ ## x (struct script_state* st)
/////////////////////////////////////////////////////////////////////
// NPC interaction
@@ -4341,12 +4071,12 @@ int script_reload() {
/// If a dialog doesn't exist yet, one is created.
///
/// mes "<message>";
-BUILDIN_FUNC(mes)
+BUILDIN(mes)
{
TBL_PC* sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if( !script_hasdata(st, 3) )
{// only a single line detected in the script
clif->scriptmes(sd, st->oid, script_getstr(st, 2));
@@ -4354,66 +4084,68 @@ BUILDIN_FUNC(mes)
else
{// parse multiple lines as they exist
int i;
-
+
for( i = 2; script_hasdata(st, i); i++ )
{
// send the message to the client
clif->scriptmes(sd, st->oid, script_getstr(st, i));
}
}
-
- return 0;
+
+ return true;
}
/// Displays the button 'next' in the npc dialog.
/// The dialog text is cleared and the script continues when the button is pressed.
///
/// next;
-BUILDIN_FUNC(next)
+BUILDIN(next)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+#ifdef SECURE_NPCTIMEOUT
+ sd->npc_idle_type = NPCT_WAIT;
+#endif
st->state = STOP;
clif->scriptnext(sd, st->oid);
- return 0;
+ return true;
}
/// Ends the script and displays the button 'close' on the npc dialog.
/// The dialog is closed when the button is pressed.
///
/// close;
-BUILDIN_FUNC(close)
+BUILDIN(close)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
st->state = CLOSE;
clif->scriptclose(sd, st->oid);
- return 0;
+ return true;
}
/// Displays the button 'close' on the npc dialog.
/// The dialog is closed and the script continues when the button is pressed.
///
/// close2;
-BUILDIN_FUNC(close2)
+BUILDIN(close2)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
st->state = STOP;
clif->scriptclose(sd, st->oid);
- return 0;
+ return true;
}
/// Counts the number of valid and total number of options in 'str'
@@ -4423,11 +4155,11 @@ static int menu_countoptions(const char* str, int max_count, int* total)
{
int count = 0;
int bogus_total;
-
+
if( total == NULL )
total = &bogus_total;
++(*total);
-
+
// initial empty options
while( *str == ':' )
{
@@ -4468,36 +4200,40 @@ static int menu_countoptions(const char* str, int max_count, int* total)
/// NOTE: the client closes the npc dialog when cancel is pressed
///
/// menu "<option_text>",<target_label>{,"<option_text>",<target_label>,...};
-BUILDIN_FUNC(menu)
+BUILDIN(menu)
{
int i;
const char* text;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
+#ifdef SECURE_NPCTIMEOUT
+ sd->npc_idle_type = NPCT_MENU;
+#endif
+
// TODO detect multiple scripts waiting for input at the same time, and what to do when that happens
if( sd->state.menu_or_input == 0 )
{
struct StringBuf buf;
struct script_data* data;
-
+
if( script_lastdata(st) % 2 == 0 )
{// argument count is not even (1st argument is at index 2)
ShowError("script:menu: illegal number of arguments (%d).\n", (script_lastdata(st) - 1));
st->state = END;
- return 1;
+ return false;
}
-
+
StringBuf_Init(&buf);
sd->npc_menu = 0;
for( i = 2; i < script_lastdata(st); i += 2 )
{
// menu options
text = script_getstr(st, i);
-
+
// target label
data = script_getdata(st, i+1);
if( !data_islabel(data) )
@@ -4506,9 +4242,9 @@ BUILDIN_FUNC(menu)
ShowError("script:menu: argument #%d (from 1) is not a label or label not found.\n", i);
script_reportdata(data);
st->state = END;
- return 1;
+ return false;
}
-
+
// append option(s)
if( text[0] == '\0' )
continue;// empty string, ignore
@@ -4519,7 +4255,7 @@ BUILDIN_FUNC(menu)
}
st->state = RERUNLINE;
sd->state.menu_or_input = 1;
-
+
/**
* menus beyond this length crash the client (see bugreport:6402)
**/
@@ -4533,9 +4269,9 @@ BUILDIN_FUNC(menu)
aFree(menu);
} else
clif->scriptmenu(sd, st->oid, StringBuf_Value(&buf));
-
+
StringBuf_Destroy(&buf);
-
+
if( sd->npc_menu >= 0xff )
{// client supports only up to 254 entries; 0 is not used and 255 is reserved for cancel; excess entries are displayed but cause 'uint8' overflow
ShowWarning("buildin_menu: Too many options specified (current=%d, max=254).\n", sd->npc_menu);
@@ -4550,15 +4286,15 @@ BUILDIN_FUNC(menu)
else
{// goto target label
int menu = 0;
-
+
sd->state.menu_or_input = 0;
if( sd->npc_menu <= 0 )
{
ShowDebug("script:menu: unexpected selection (%d)\n", sd->npc_menu);
st->state = END;
- return 1;
+ return false;
}
-
+
// get target label
for( i = 2; i < script_lastdata(st); i += 2 )
{
@@ -4571,20 +4307,20 @@ BUILDIN_FUNC(menu)
{// Invalid selection
ShowDebug("script:menu: selection is out of range (%d pairs are missing?) - please report this\n", sd->npc_menu);
st->state = END;
- return 1;
+ return false;
}
if( !data_islabel(script_getdata(st, i + 1)) )
{// TODO remove this temporary crash-prevention code (fallback for multiple scripts requesting user input)
ShowError("script:menu: unexpected data in label argument\n");
script_reportdata(script_getdata(st, i + 1));
st->state = END;
- return 1;
+ return false;
}
pc_setreg(sd, add_str("@menu"), menu);
st->pos = script_getnum(st, i + 1);
st->state = GOTO;
}
- return 0;
+ return true;
}
/// Displays a menu with options and returns the selected option.
@@ -4593,34 +4329,38 @@ BUILDIN_FUNC(menu)
/// select(<option_text>{,<option_text>,...}) -> <selected_option>
///
/// @see menu
-BUILDIN_FUNC(select)
+BUILDIN(select)
{
int i;
const char* text;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
+#ifdef SECURE_NPCTIMEOUT
+ sd->npc_idle_type = NPCT_MENU;
+#endif
+
if( sd->state.menu_or_input == 0 ) {
struct StringBuf buf;
-
+
StringBuf_Init(&buf);
sd->npc_menu = 0;
for( i = 2; i <= script_lastdata(st); ++i ) {
text = script_getstr(st, i);
-
+
if( sd->npc_menu > 0 )
StringBuf_AppendStr(&buf, ":");
-
+
StringBuf_AppendStr(&buf, text);
sd->npc_menu += menu_countoptions(text, 0, NULL);
}
-
+
st->state = RERUNLINE;
sd->state.menu_or_input = 1;
-
+
/**
* menus beyond this length crash the client (see bugreport:6402)
**/
@@ -4635,7 +4375,7 @@ BUILDIN_FUNC(select)
} else
clif->scriptmenu(sd, st->oid, StringBuf_Value(&buf));
StringBuf_Destroy(&buf);
-
+
if( sd->npc_menu >= 0xff ) {
ShowWarning("buildin_select: Too many options specified (current=%d, max=254).\n", sd->npc_menu);
script_reportsrc(st);
@@ -4645,7 +4385,7 @@ BUILDIN_FUNC(select)
st->state = END;
} else {// return selected option
int menu = 0;
-
+
sd->state.menu_or_input = 0;
for( i = 2; i <= script_lastdata(st); ++i ) {
text = script_getstr(st, i);
@@ -4657,7 +4397,7 @@ BUILDIN_FUNC(select)
script_pushint(st, menu);
st->state = RUN;
}
- return 0;
+ return true;
}
/// Displays a menu with options and returns the selected option.
@@ -4668,20 +4408,24 @@ BUILDIN_FUNC(select)
/// prompt(<option_text>{,<option_text>,...}) -> <selected_option>
///
/// @see menu
-BUILDIN_FUNC(prompt)
+BUILDIN(prompt)
{
int i;
const char *text;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
+#ifdef SECURE_NPCTIMEOUT
+ sd->npc_idle_type = NPCT_MENU;
+#endif
+
if( sd->state.menu_or_input == 0 )
{
struct StringBuf buf;
-
+
StringBuf_Init(&buf);
sd->npc_menu = 0;
for( i = 2; i <= script_lastdata(st); ++i )
@@ -4692,10 +4436,10 @@ BUILDIN_FUNC(prompt)
StringBuf_AppendStr(&buf, text);
sd->npc_menu += menu_countoptions(text, 0, NULL);
}
-
+
st->state = RERUNLINE;
sd->state.menu_or_input = 1;
-
+
/**
* menus beyond this length crash the client (see bugreport:6402)
**/
@@ -4710,7 +4454,7 @@ BUILDIN_FUNC(prompt)
} else
clif->scriptmenu(sd, st->oid, StringBuf_Value(&buf));
StringBuf_Destroy(&buf);
-
+
if( sd->npc_menu >= 0xff )
{
ShowWarning("buildin_prompt: Too many options specified (current=%d, max=254).\n", sd->npc_menu);
@@ -4727,7 +4471,7 @@ BUILDIN_FUNC(prompt)
else
{// return selected option
int menu = 0;
-
+
sd->state.menu_or_input = 0;
for( i = 2; i <= script_lastdata(st); ++i )
{
@@ -4740,7 +4484,7 @@ BUILDIN_FUNC(prompt)
script_pushint(st, menu);
st->state = RUN;
}
- return 0;
+ return true;
}
/////////////////////////////////////////////////////////////////////
@@ -4750,40 +4494,40 @@ BUILDIN_FUNC(prompt)
/// Jumps to the target script label.
///
/// goto <label>;
-BUILDIN_FUNC(goto)
+BUILDIN(goto)
{
if( !data_islabel(script_getdata(st,2)) )
{
ShowError("script:goto: not a label\n");
script_reportdata(script_getdata(st,2));
st->state = END;
- return 1;
+ return false;
}
-
+
st->pos = script_getnum(st,2);
st->state = GOTO;
- return 0;
+ return true;
}
/*==========================================
* user-defined function call
*------------------------------------------*/
-BUILDIN_FUNC(callfunc)
+BUILDIN(callfunc)
{
int i, j;
struct script_retinfo* ri;
struct script_code* scr;
const char* str = script_getstr(st,2);
DBMap **ref = NULL;
-
+
scr = (struct script_code*)strdb_get(userfunc_db, str);
if( !scr )
{
ShowError("script:callfunc: function not found! [%s]\n", str);
st->state = END;
- return 1;
+ return false;
}
-
+
for( i = st->start+3, j = 0; i < st->end; i++, j++ )
{
struct script_data* data = push_copy(st->stack,i);
@@ -4791,15 +4535,13 @@ BUILDIN_FUNC(callfunc)
{
const char* name = reference_getname(data);
if( name[0] == '.' ) {
- if ( !ref ) {
- ref = (struct DBMap**)aCalloc(sizeof(struct DBMap*), 1);
- ref[0] = (name[1] == '@' ? st->stack->var_function : st->script->script_vars);
- }
+ ref = (struct DBMap**)aCalloc(sizeof(struct DBMap*), 1);
+ ref[0] = (name[1] == '@' ? st->stack->var_function : st->script->script_vars);
data->ref = ref;
}
}
}
-
+
CREATE(ri, struct script_retinfo, 1);
ri->script = st->script;// script code
ri->var_function = st->stack->var_function;// scope variables
@@ -4807,33 +4549,33 @@ BUILDIN_FUNC(callfunc)
ri->nargs = j;// argument count
ri->defsp = st->stack->defsp;// default stack pointer
push_retinfo(st->stack, ri, ref);
-
+
st->pos = 0;
st->script = scr;
st->stack->defsp = st->stack->sp;
st->state = GOTO;
st->stack->var_function = idb_alloc(DB_OPT_RELEASE_DATA);
-
- return 0;
+
+ return true;
}
/*==========================================
* subroutine call
*------------------------------------------*/
-BUILDIN_FUNC(callsub)
+BUILDIN(callsub)
{
int i,j;
struct script_retinfo* ri;
int pos = script_getnum(st,2);
DBMap **ref = NULL;
-
+
if( !data_islabel(script_getdata(st,2)) && !data_isfunclabel(script_getdata(st,2)) )
{
ShowError("script:callsub: argument is not a label\n");
script_reportdata(script_getdata(st,2));
st->state = END;
- return 1;
+ return false;
}
-
+
for( i = st->start+3, j = 0; i < st->end; i++, j++ )
{
struct script_data* data = push_copy(st->stack,i);
@@ -4849,7 +4591,7 @@ BUILDIN_FUNC(callsub)
}
}
}
-
+
CREATE(ri, struct script_retinfo, 1);
ri->script = st->script;// script code
ri->var_function = st->stack->var_function;// scope variables
@@ -4857,34 +4599,34 @@ BUILDIN_FUNC(callsub)
ri->nargs = j;// argument count
ri->defsp = st->stack->defsp;// default stack pointer
push_retinfo(st->stack, ri, ref);
-
+
st->pos = pos;
st->stack->defsp = st->stack->sp;
st->state = GOTO;
st->stack->var_function = idb_alloc(DB_OPT_RELEASE_DATA);
-
- return 0;
+
+ return true;
}
/// Retrieves an argument provided to callfunc/callsub.
/// If the argument doesn't exist
///
/// getarg(<index>{,<default_value>}) -> <value>
-BUILDIN_FUNC(getarg)
+BUILDIN(getarg)
{
struct script_retinfo* ri;
int idx;
-
+
if( st->stack->defsp < 1 || st->stack->stack_data[st->stack->defsp - 1].type != C_RETINFO )
{
ShowError("script:getarg: no callfunc or callsub!\n");
st->state = END;
- return 1;
+ return false;
}
ri = st->stack->stack_data[st->stack->defsp - 1].u.ri;
-
+
idx = script_getnum(st,2);
-
+
if( idx >= 0 && idx < ri->nargs )
push_copy(st->stack, st->stack->defsp - 1 - ri->nargs + idx);
else if( script_hasdata(st,3) )
@@ -4893,10 +4635,10 @@ BUILDIN_FUNC(getarg)
{
ShowError("script:getarg: index (idx=%d) out of range (nargs=%d) and no default value found\n", idx, ri->nargs);
st->state = END;
- return 1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/// Returns from the current function, optionaly returning a value from the functions.
@@ -4904,7 +4646,7 @@ BUILDIN_FUNC(getarg)
///
/// return;
/// return <value>;
-BUILDIN_FUNC(return)
+BUILDIN(return)
{
if( script_hasdata(st,2) )
{// return value
@@ -4930,7 +4672,7 @@ BUILDIN_FUNC(return)
script_pushnil(st);
}
st->state = RETFUNC;
- return 0;
+ return true;
}
/// Returns a random number from 0 to <range>-1.
@@ -4938,12 +4680,12 @@ BUILDIN_FUNC(return)
/// If <min> is greater than <max>, their numbers are switched.
/// rand(<range>) -> <int>
/// rand(<min>,<max>) -> <int>
-BUILDIN_FUNC(rand)
+BUILDIN(rand)
{
int range;
int min;
int max;
-
+
if( script_hasdata(st,3) )
{// min,max
min = script_getnum(st,2);
@@ -4961,41 +4703,41 @@ BUILDIN_FUNC(rand)
script_pushint(st, min);
else
script_pushint(st, rnd()%range + min);
-
- return 0;
+
+ return true;
}
/*==========================================
* Warp sd to str,x,y or Random or SavePoint/Save
*------------------------------------------*/
-BUILDIN_FUNC(warp)
+BUILDIN(warp)
{
int ret;
int x,y;
const char* str;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
str = script_getstr(st,2);
x = script_getnum(st,3);
y = script_getnum(st,4);
-
+
if(strcmp(str,"Random")==0)
ret = pc_randomwarp(sd,CLR_TELEPORT);
else if(strcmp(str,"SavePoint")==0 || strcmp(str,"Save")==0)
ret = pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
else
ret = pc_setpos(sd,mapindex_name2id(str),x,y,CLR_OUTSIGHT);
-
+
if( ret ) {
ShowError("buildin_warp: moving player '%s' to \"%s\",%d,%d failed.\n", sd->status.name, str, x, y);
script_reportsrc(st);
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Warp a specified area
@@ -5004,42 +4746,42 @@ static int buildin_areawarp_sub(struct block_list *bl,va_list ap)
{
int x2,y2,x3,y3;
unsigned int index;
-
+
index = va_arg(ap,unsigned int);
x2 = va_arg(ap,int);
y2 = va_arg(ap,int);
x3 = va_arg(ap,int);
y3 = va_arg(ap,int);
-
+
if(index == 0)
pc_randomwarp((TBL_PC *)bl,CLR_TELEPORT);
else if(x3 && y3) {
int max, tx, ty, j = 0;
-
+
// choose a suitable max number of attempts
if( (max = (y3-y2+1)*(x3-x2+1)*3) > 1000 )
max = 1000;
-
+
// find a suitable map cell
do {
tx = rnd()%(x3-x2+1)+x2;
ty = rnd()%(y3-y2+1)+y2;
j++;
} while( map_getcell(index,tx,ty,CELL_CHKNOPASS) && j < max );
-
+
pc_setpos((TBL_PC *)bl,index,tx,ty,CLR_OUTSIGHT);
}
else
pc_setpos((TBL_PC *)bl,index,x2,y2,CLR_OUTSIGHT);
return 0;
}
-BUILDIN_FUNC(areawarp)
+BUILDIN(areawarp)
{
int16 m, x0,y0,x1,y1, x2,y2,x3=0,y3=0;
unsigned int index;
const char *str;
const char *mapname;
-
+
mapname = script_getstr(st,2);
x0 = script_getnum(st,3);
y0 = script_getnum(st,4);
@@ -5048,7 +4790,7 @@ BUILDIN_FUNC(areawarp)
str = script_getstr(st,7);
x2 = script_getnum(st,8);
y2 = script_getnum(st,9);
-
+
if( script_hasdata(st,10) && script_hasdata(st,11) ) { // Warp area to area
if( (x3 = script_getnum(st,10)) < 0 || (y3 = script_getnum(st,11)) < 0 ){
x3 = 0;
@@ -5059,17 +4801,17 @@ BUILDIN_FUNC(areawarp)
if( y3 < y2 ) swap(y3,y2);
}
}
-
+
if( (m = map_mapname2mapid(mapname)) < 0 )
- return 0;
-
+ return true;
+
if( strcmp(str,"Random") == 0 )
index = 0;
else if( !(index=mapindex_name2id(str)) )
- return 0;
-
+ return true;
+
map_foreachinarea(buildin_areawarp_sub, m,x0,y0,x1,y1, BL_PC, index,x2,y2,x3,y3);
- return 0;
+ return true;
}
/*==========================================
@@ -5083,12 +4825,12 @@ static int buildin_areapercentheal_sub(struct block_list *bl,va_list ap)
pc_percentheal((TBL_PC *)bl,hp,sp);
return 0;
}
-BUILDIN_FUNC(areapercentheal)
+BUILDIN(areapercentheal)
{
int hp,sp,m;
const char *mapname;
int x0,y0,x1,y1;
-
+
mapname=script_getstr(st,2);
x0=script_getnum(st,3);
y0=script_getnum(st,4);
@@ -5096,12 +4838,12 @@ BUILDIN_FUNC(areapercentheal)
y1=script_getnum(st,6);
hp=script_getnum(st,7);
sp=script_getnum(st,8);
-
+
if( (m=map_mapname2mapid(mapname))< 0)
- return 0;
-
+ return true;
+
map_foreachinarea(buildin_areapercentheal_sub,m,x0,y0,x1,y1,BL_PC,hp,sp);
- return 0;
+ return true;
}
/*==========================================
@@ -5110,37 +4852,37 @@ BUILDIN_FUNC(areapercentheal)
* another player npc-session.
* Using: warpchar "mapname",x,y,Char_ID;
*------------------------------------------*/
-BUILDIN_FUNC(warpchar)
+BUILDIN(warpchar)
{
int x,y,a;
const char *str;
TBL_PC *sd;
-
+
str=script_getstr(st,2);
x=script_getnum(st,3);
y=script_getnum(st,4);
a=script_getnum(st,5);
-
+
sd = map_charid2sd(a);
if( sd == NULL )
- return 0;
-
+ return true;
+
if(strcmp(str, "Random") == 0)
pc_randomwarp(sd, CLR_TELEPORT);
else
- if(strcmp(str, "SavePoint") == 0)
- pc_setpos(sd, sd->status.save_point.map,sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
- else
- pc_setpos(sd, mapindex_name2id(str), x, y, CLR_TELEPORT);
-
- return 0;
+ if(strcmp(str, "SavePoint") == 0)
+ pc_setpos(sd, sd->status.save_point.map,sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
+ else
+ pc_setpos(sd, mapindex_name2id(str), x, y, CLR_TELEPORT);
+
+ return true;
}
/*==========================================
* Warpparty - [Fredzilla] [Paradox924X]
* Syntax: warpparty "to_mapname",x,y,Party_ID,{"from_mapname"};
* If 'from_mapname' is specified, only the party members on that map will be warped
*------------------------------------------*/
-BUILDIN_FUNC(warpparty)
+BUILDIN(warpparty)
{
TBL_PC *sd = NULL;
TBL_PC *pl_sd;
@@ -5148,7 +4890,7 @@ BUILDIN_FUNC(warpparty)
int type;
int mapindex;
int i;
-
+
const char* str = script_getstr(st,2);
int x = script_getnum(st,3);
int y = script_getnum(st,4);
@@ -5156,235 +4898,235 @@ BUILDIN_FUNC(warpparty)
const char* str2 = NULL;
if ( script_hasdata(st,6) )
str2 = script_getstr(st,6);
-
+
p = party_search(p_id);
if(!p)
- return 0;
-
+ return true;
+
type = ( strcmp(str,"Random")==0 ) ? 0
- : ( strcmp(str,"SavePointAll")==0 ) ? 1
- : ( strcmp(str,"SavePoint")==0 ) ? 2
- : ( strcmp(str,"Leader")==0 ) ? 3
- : 4;
-
+ : ( strcmp(str,"SavePointAll")==0 ) ? 1
+ : ( strcmp(str,"SavePoint")==0 ) ? 2
+ : ( strcmp(str,"Leader")==0 ) ? 3
+ : 4;
+
switch (type)
{
- case 3:
- for(i = 0; i < MAX_PARTY && !p->party.member[i].leader; i++);
- if (i == MAX_PARTY || !p->data[i].sd) //Leader not found / not online
- return 0;
- pl_sd = p->data[i].sd;
- mapindex = pl_sd->mapindex;
- x = pl_sd->bl.x;
- y = pl_sd->bl.y;
- break;
- case 4:
- mapindex = mapindex_name2id(str);
- break;
- case 2:
- //"SavePoint" uses save point of the currently attached player
- if (( sd = script_rid2sd(st) ) == NULL )
- return 0;
- default:
- mapindex = 0;
- break;
+ case 3:
+ for(i = 0; i < MAX_PARTY && !p->party.member[i].leader; i++);
+ if (i == MAX_PARTY || !p->data[i].sd) //Leader not found / not online
+ return true;
+ pl_sd = p->data[i].sd;
+ mapindex = pl_sd->mapindex;
+ x = pl_sd->bl.x;
+ y = pl_sd->bl.y;
+ break;
+ case 4:
+ mapindex = mapindex_name2id(str);
+ break;
+ case 2:
+ //"SavePoint" uses save point of the currently attached player
+ if (( sd = script_rid2sd(st) ) == NULL )
+ return true;
+ default:
+ mapindex = 0;
+ break;
}
-
+
for (i = 0; i < MAX_PARTY; i++)
{
if( !(pl_sd = p->data[i].sd) || pl_sd->status.party_id != p_id )
continue;
-
+
if( str2 && strcmp(str2, map[pl_sd->bl.m].name) != 0 )
continue;
-
+
if( pc_isdead(pl_sd) )
continue;
-
+
switch( type )
{
- case 0: // Random
- if(!map[pl_sd->bl.m].flag.nowarp)
- pc_randomwarp(pl_sd,CLR_TELEPORT);
- break;
- case 1: // SavePointAll
- if(!map[pl_sd->bl.m].flag.noreturn)
- pc_setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
- break;
- case 2: // SavePoint
- if(!map[pl_sd->bl.m].flag.noreturn)
- pc_setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
- break;
- case 3: // Leader
- case 4: // m,x,y
- if(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp)
- pc_setpos(pl_sd,mapindex,x,y,CLR_TELEPORT);
- break;
+ case 0: // Random
+ if(!map[pl_sd->bl.m].flag.nowarp)
+ pc_randomwarp(pl_sd,CLR_TELEPORT);
+ break;
+ case 1: // SavePointAll
+ if(!map[pl_sd->bl.m].flag.noreturn)
+ pc_setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
+ break;
+ case 2: // SavePoint
+ if(!map[pl_sd->bl.m].flag.noreturn)
+ pc_setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
+ break;
+ case 3: // Leader
+ case 4: // m,x,y
+ if(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp)
+ pc_setpos(pl_sd,mapindex,x,y,CLR_TELEPORT);
+ break;
}
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Warpguild - [Fredzilla]
* Syntax: warpguild "mapname",x,y,Guild_ID;
*------------------------------------------*/
-BUILDIN_FUNC(warpguild)
+BUILDIN(warpguild)
{
TBL_PC *sd = NULL;
TBL_PC *pl_sd;
struct guild* g;
struct s_mapiterator* iter;
int type;
-
+
const char* str = script_getstr(st,2);
int x = script_getnum(st,3);
int y = script_getnum(st,4);
int gid = script_getnum(st,5);
-
+
g = guild_search(gid);
if( g == NULL )
- return 0;
-
+ return true;
+
type = ( strcmp(str,"Random")==0 ) ? 0
- : ( strcmp(str,"SavePointAll")==0 ) ? 1
- : ( strcmp(str,"SavePoint")==0 ) ? 2
- : 3;
-
+ : ( strcmp(str,"SavePointAll")==0 ) ? 1
+ : ( strcmp(str,"SavePoint")==0 ) ? 2
+ : 3;
+
if( type == 2 && ( sd = script_rid2sd(st) ) == NULL )
{// "SavePoint" uses save point of the currently attached player
- return 0;
+ return true;
}
-
+
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
if( pl_sd->status.guild_id != gid )
continue;
-
+
switch( type )
{
- case 0: // Random
- if(!map[pl_sd->bl.m].flag.nowarp)
- pc_randomwarp(pl_sd,CLR_TELEPORT);
- break;
- case 1: // SavePointAll
- if(!map[pl_sd->bl.m].flag.noreturn)
- pc_setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
- break;
- case 2: // SavePoint
- if(!map[pl_sd->bl.m].flag.noreturn)
- pc_setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
- break;
- case 3: // m,x,y
- if(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp)
- pc_setpos(pl_sd,mapindex_name2id(str),x,y,CLR_TELEPORT);
- break;
+ case 0: // Random
+ if(!map[pl_sd->bl.m].flag.nowarp)
+ pc_randomwarp(pl_sd,CLR_TELEPORT);
+ break;
+ case 1: // SavePointAll
+ if(!map[pl_sd->bl.m].flag.noreturn)
+ pc_setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
+ break;
+ case 2: // SavePoint
+ if(!map[pl_sd->bl.m].flag.noreturn)
+ pc_setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
+ break;
+ case 3: // m,x,y
+ if(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp)
+ pc_setpos(pl_sd,mapindex_name2id(str),x,y,CLR_TELEPORT);
+ break;
}
}
mapit_free(iter);
-
- return 0;
+
+ return true;
}
/*==========================================
* Force Heal a player (hp and sp)
*------------------------------------------*/
-BUILDIN_FUNC(heal)
+BUILDIN(heal)
{
TBL_PC *sd;
int hp,sp;
-
+
sd = script_rid2sd(st);
- if (!sd) return 0;
-
+ if (!sd) return true;
+
hp=script_getnum(st,2);
sp=script_getnum(st,3);
status_heal(&sd->bl, hp, sp, 1);
- return 0;
+ return true;
}
/*==========================================
* Heal a player by item (get vit bonus etc)
*------------------------------------------*/
-BUILDIN_FUNC(itemheal)
+BUILDIN(itemheal)
{
TBL_PC *sd;
int hp,sp;
-
+
hp=script_getnum(st,2);
sp=script_getnum(st,3);
-
+
if(potion_flag==1) {
potion_hp = hp;
potion_sp = sp;
- return 0;
+ return true;
}
-
+
sd = script_rid2sd(st);
- if (!sd) return 0;
+ if (!sd) return true;
pc_itemheal(sd,sd->itemid,hp,sp);
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(percentheal)
+BUILDIN(percentheal)
{
int hp,sp;
TBL_PC* sd;
-
+
hp=script_getnum(st,2);
sp=script_getnum(st,3);
-
+
if(potion_flag==1) {
potion_per_hp = hp;
potion_per_sp = sp;
- return 0;
+ return true;
}
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
+ return true;
#ifdef RENEWAL
if( sd->sc.data[SC_EXTREMITYFIST2] )
sp = 0;
#endif
pc_percentheal(sd,hp,sp);
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(jobchange)
+BUILDIN(jobchange)
{
int job, upper=-1;
-
+
job=script_getnum(st,2);
if( script_hasdata(st,3) )
upper=script_getnum(st,3);
-
+
if (pcdb_checkid(job))
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
pc_jobchange(sd, job, upper);
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(jobname)
+BUILDIN(jobname)
{
int class_=script_getnum(st,2);
script_pushconststr(st, (char*)job_name(class_));
- return 0;
+ return true;
}
/// Get input from the player.
@@ -5394,7 +5136,7 @@ BUILDIN_FUNC(jobname)
/// shorter than 'min' and 0 otherwise.
///
/// input(<var>{,<min>{,<max>}}) -> <int>
-BUILDIN_FUNC(input)
+BUILDIN(input)
{
TBL_PC* sd;
struct script_data* data;
@@ -5402,23 +5144,27 @@ BUILDIN_FUNC(input)
const char* name;
int min;
int max;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
data = script_getdata(st,2);
if( !data_isreference(data) ){
ShowError("script:input: not a variable\n");
script_reportdata(data);
st->state = END;
- return 1;
+ return false;
}
uid = reference_getuid(data);
name = reference_getname(data);
min = (script_hasdata(st,3) ? script_getnum(st,3) : script_config.input_min_value);
max = (script_hasdata(st,4) ? script_getnum(st,4) : script_config.input_max_value);
-
+
+#ifdef SECURE_NPCTIMEOUT
+ sd->npc_idle_type = NPCT_WAIT;
+#endif
+
if( !sd->state.menu_or_input )
{ // first invocation, display npc input box
sd->state.menu_or_input = 1;
@@ -5440,22 +5186,22 @@ BUILDIN_FUNC(input)
else
{
int amount = sd->npc_amount;
- set_reg(st, sd, uid, name, (void*)__64BPRTSIZE(cap_value(amount,min,max)), script_getref(st,2));
+ set_reg(st, sd, uid, name, (void*)__64BPTRSIZE(cap_value(amount,min,max)), script_getref(st,2));
script_pushint(st, (amount > max ? 1 : amount < min ? -1 : 0));
}
st->state = RUN;
}
- return 0;
+ return true;
}
// declare the copyarray method here for future reference
-BUILDIN_FUNC(copyarray);
+BUILDIN(copyarray);
/// Sets the value of a variable.
/// The value is converted to the type of the variable.
///
/// set(<variable>,<value>) -> <variable>
-BUILDIN_FUNC(set)
+BUILDIN(set)
{
TBL_PC* sd = NULL;
struct script_data* data;
@@ -5463,7 +5209,7 @@ BUILDIN_FUNC(set)
int num;
const char* name;
char prefix;
-
+
data = script_getdata(st,2);
//datavalue = script_getdata(st,3);
if( !data_isreference(data) )
@@ -5471,60 +5217,60 @@ BUILDIN_FUNC(set)
ShowError("script:set: not a variable\n");
script_reportdata(script_getdata(st,2));
st->state = END;
- return 1;
+ return false;
}
-
+
num = reference_getuid(data);
name = reference_getname(data);
prefix = *name;
-
+
if( not_server_variable(prefix) )
{
sd = script_rid2sd(st);
if( sd == NULL )
{
ShowError("script:set: no player attached for player variable '%s'\n", name);
- return 0;
+ return true;
}
}
-
+
#if 0
if( data_isreference(datavalue) )
{// the value being referenced is a variable
const char* namevalue = reference_getname(datavalue);
-
+
if( !not_array_variable(*namevalue) )
{// array variable being copied into another array variable
if( sd == NULL && not_server_variable(*namevalue) && !(sd = script_rid2sd(st)) )
{// player must be attached in order to copy a player variable
ShowError("script:set: no player attached for player variable '%s'\n", namevalue);
- return 0;
+ return true;
}
-
+
if( is_string_variable(namevalue) != is_string_variable(name) )
{// non-matching array value types
ShowWarning("script:set: two array variables do not match in type.\n");
- return 0;
+ return true;
}
-
+
// push the maximum number of array values to the stack
push_val(st->stack, C_INT, SCRIPT_MAX_ARRAYSIZE);
-
+
// call the copy array method directly
return buildin_copyarray(st);
}
}
#endif
-
+
if( is_string_variable(name) )
set_reg(st,sd,num,name,(void*)script_getstr(st,3),script_getref(st,2));
else
- set_reg(st,sd,num,name,(void*)__64BPRTSIZE(script_getnum(st,3)),script_getref(st,2));
-
+ set_reg(st,sd,num,name,(void*)__64BPTRSIZE(script_getnum(st,3)),script_getref(st,2));
+
// return a copy of the variable reference
script_pushcopy(st,2);
-
- return 0;
+
+ return true;
}
/////////////////////////////////////////////////////////////////////
@@ -5535,7 +5281,7 @@ BUILDIN_FUNC(set)
static int32 getarraysize(struct script_state* st, int32 id, int32 idx, int isstring, struct DBMap** ref)
{
int32 ret = idx;
-
+
if( isstring )
{
for( ; idx < SCRIPT_MAX_ARRAYSIZE; ++idx )
@@ -5550,7 +5296,7 @@ static int32 getarraysize(struct script_state* st, int32 id, int32 idx, int isst
{
for( ; idx < SCRIPT_MAX_ARRAYSIZE; ++idx )
{
- int32 num = (int32)__64BPRTSIZE(get_val2(st, reference_uid(id, idx), ref));
+ int32 num = (int32)__64BPTRSIZE(get_val2(st, reference_uid(id, idx), ref));
if( num )
ret = idx + 1;
script_removetop(st, -1, 0);
@@ -5563,7 +5309,7 @@ static int32 getarraysize(struct script_state* st, int32 id, int32 idx, int isst
/// ex: setarray arr[1],1,2,3;
///
/// setarray <array variable>,<value1>{,<value2>...};
-BUILDIN_FUNC(setarray)
+BUILDIN(setarray)
{
struct script_data* data;
const char* name;
@@ -5572,16 +5318,16 @@ BUILDIN_FUNC(setarray)
int32 id;
int32 i;
TBL_PC* sd = NULL;
-
+
data = script_getdata(st, 2);
if( !data_isreference(data) )
{
ShowError("script:setarray: not a variable\n");
script_reportdata(data);
st->state = END;
- return 1;// not a variable
+ return false;// not a variable
}
-
+
id = reference_getid(data);
start = reference_getindex(data);
name = reference_getname(data);
@@ -5590,20 +5336,20 @@ BUILDIN_FUNC(setarray)
ShowError("script:setarray: illegal scope\n");
script_reportdata(data);
st->state = END;
- return 1;// not supported
+ return false;// not supported
}
-
+
if( not_server_variable(*name) )
{
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached
+ return true;// no player attached
}
-
+
end = start + script_lastdata(st) - 2;
if( end > SCRIPT_MAX_ARRAYSIZE )
end = SCRIPT_MAX_ARRAYSIZE;
-
+
if( is_string_variable(name) )
{// string array
for( i = 3; start < end; ++start, ++i )
@@ -5612,16 +5358,16 @@ BUILDIN_FUNC(setarray)
else
{// int array
for( i = 3; start < end; ++start, ++i )
- set_reg(st, sd, reference_uid(id, start), name, (void*)__64BPRTSIZE(script_getnum(st,i)), reference_getref(data));
+ set_reg(st, sd, reference_uid(id, start), name, (void*)__64BPTRSIZE(script_getnum(st,i)), reference_getref(data));
}
- return 0;
+ return true;
}
/// Sets count values of an array, from the starting index.
/// ex: cleararray arr[0],0,1;
///
/// cleararray <array variable>,<value>,<count>;
-BUILDIN_FUNC(cleararray)
+BUILDIN(cleararray)
{
struct script_data* data;
const char* name;
@@ -5630,16 +5376,16 @@ BUILDIN_FUNC(cleararray)
int32 id;
void* v;
TBL_PC* sd = NULL;
-
+
data = script_getdata(st, 2);
if( !data_isreference(data) )
{
ShowError("script:cleararray: not a variable\n");
script_reportdata(data);
st->state = END;
- return 1;// not a variable
+ return false;// not a variable
}
-
+
id = reference_getid(data);
start = reference_getindex(data);
name = reference_getname(data);
@@ -5648,35 +5394,35 @@ BUILDIN_FUNC(cleararray)
ShowError("script:cleararray: illegal scope\n");
script_reportdata(data);
st->state = END;
- return 1;// not supported
+ return false;// not supported
}
-
+
if( not_server_variable(*name) )
{
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached
+ return true;// no player attached
}
-
+
if( is_string_variable(name) )
v = (void*)script_getstr(st, 3);
else
- v = (void*)__64BPRTSIZE(script_getnum(st, 3));
-
+ v = (void*)__64BPTRSIZE(script_getnum(st, 3));
+
end = start + script_getnum(st, 4);
if( end > SCRIPT_MAX_ARRAYSIZE )
end = SCRIPT_MAX_ARRAYSIZE;
-
+
for( ; start < end; ++start )
set_reg(st, sd, reference_uid(id, start), name, v, script_getref(st,2));
- return 0;
+ return true;
}
/// Copies data from one array to another.
/// ex: copyarray arr[0],arr[2],2;
///
/// copyarray <destination array variable>,<source array variable>,<count>;
-BUILDIN_FUNC(copyarray)
+BUILDIN(copyarray)
{
struct script_data* data1;
struct script_data* data2;
@@ -5690,7 +5436,7 @@ BUILDIN_FUNC(copyarray)
int32 i;
int32 count;
TBL_PC* sd = NULL;
-
+
data1 = script_getdata(st, 2);
data2 = script_getdata(st, 3);
if( !data_isreference(data1) || !data_isreference(data2) )
@@ -5699,9 +5445,9 @@ BUILDIN_FUNC(copyarray)
script_reportdata(data1);
script_reportdata(data2);
st->state = END;
- return 1;// not a variable
+ return false;// not a variable
}
-
+
id1 = reference_getid(data1);
id2 = reference_getid(data2);
idx1 = reference_getindex(data1);
@@ -5714,31 +5460,31 @@ BUILDIN_FUNC(copyarray)
script_reportdata(data1);
script_reportdata(data2);
st->state = END;
- return 1;// not supported
+ return false;// not supported
}
-
+
if( is_string_variable(name1) != is_string_variable(name2) )
{
ShowError("script:copyarray: type mismatch\n");
script_reportdata(data1);
script_reportdata(data2);
st->state = END;
- return 1;// data type mismatch
+ return false;// data type mismatch
}
-
+
if( not_server_variable(*name1) || not_server_variable(*name2) )
{
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached
+ return true;// no player attached
}
-
+
count = script_getnum(st, 4);
if( count > SCRIPT_MAX_ARRAYSIZE - idx1 )
count = SCRIPT_MAX_ARRAYSIZE - idx1;
if( count <= 0 || (id1 == id2 && idx1 == idx2) )
- return 0;// nothing to copy
-
+ return true;// nothing to copy
+
if( id1 == id2 && idx1 > idx2 )
{// destination might be overlapping the source - copy in reverse order
for( i = count - 1; i >= 0; --i )
@@ -5762,7 +5508,7 @@ BUILDIN_FUNC(copyarray)
set_reg(st, sd, reference_uid(id1, idx1 + i), name1, (is_string_variable(name1)?(void*)"":(void*)0), reference_getref(data1));
}
}
- return 0;
+ return true;
}
/// Returns the size of the array.
@@ -5770,11 +5516,11 @@ BUILDIN_FUNC(copyarray)
/// ex: getarraysize(arr[3])
///
/// getarraysize(<array variable>) -> <int>
-BUILDIN_FUNC(getarraysize)
+BUILDIN(getarraysize)
{
struct script_data* data;
const char* name;
-
+
data = script_getdata(st, 2);
if( !data_isreference(data) )
{
@@ -5782,9 +5528,9 @@ BUILDIN_FUNC(getarraysize)
script_reportdata(data);
script_pushnil(st);
st->state = END;
- return 1;// not a variable
+ return false;// not a variable
}
-
+
name = reference_getname(data);
if( not_array_variable(*name) )
{
@@ -5792,11 +5538,11 @@ BUILDIN_FUNC(getarraysize)
script_reportdata(data);
script_pushnil(st);
st->state = END;
- return 1;// not supported
+ return false;// not supported
}
-
+
script_pushint(st, getarraysize(st, reference_getid(data), reference_getindex(data), is_string_variable(name), reference_getref(data)));
- return 0;
+ return true;
}
/// Deletes count or all the elements in an array, from the starting index.
@@ -5804,7 +5550,7 @@ BUILDIN_FUNC(getarraysize)
///
/// deletearray <array variable>;
/// deletearray <array variable>,<count>;
-BUILDIN_FUNC(deletearray)
+BUILDIN(deletearray)
{
struct script_data* data;
const char* name;
@@ -5812,16 +5558,16 @@ BUILDIN_FUNC(deletearray)
int end;
int id;
TBL_PC *sd = NULL;
-
+
data = script_getdata(st, 2);
if( !data_isreference(data) )
{
ShowError("script:deletearray: not a variable\n");
script_reportdata(data);
st->state = END;
- return 1;// not a variable
+ return false;// not a variable
}
-
+
id = reference_getid(data);
start = reference_getindex(data);
name = reference_getname(data);
@@ -5830,29 +5576,29 @@ BUILDIN_FUNC(deletearray)
ShowError("script:deletearray: illegal scope\n");
script_reportdata(data);
st->state = END;
- return 1;// not supported
+ return false;// not supported
}
-
+
if( not_server_variable(*name) )
{
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached
+ return true;// no player attached
}
-
+
end = SCRIPT_MAX_ARRAYSIZE;
-
+
if( start >= end )
- return 0;// nothing to free
-
+ return true;// nothing to free
+
if( script_hasdata(st,3) )
{
int count = script_getnum(st, 3);
if( count > end - start )
count = end - start;
if( count <= 0 )
- return 0;// nothing to free
-
+ return true;// nothing to free
+
// move rest of the elements backward
for( ; start + count < end; ++start )
{
@@ -5861,7 +5607,7 @@ BUILDIN_FUNC(deletearray)
script_removetop(st, -1, 0);
}
}
-
+
// clear the rest of the array
if( is_string_variable(name) )
{
@@ -5873,20 +5619,20 @@ BUILDIN_FUNC(deletearray)
for( ; start < end; ++start )
set_reg(st, sd, reference_uid(id, start), name, (void*)0, reference_getref(data));
}
- return 0;
+ return true;
}
/// Returns a reference to the target index of the array variable.
/// Equivalent to var[index].
///
/// getelementofarray(<array variable>,<index>) -> <variable reference>
-BUILDIN_FUNC(getelementofarray)
+BUILDIN(getelementofarray)
{
struct script_data* data;
const char* name;
int32 id;
int i;
-
+
data = script_getdata(st, 2);
if( !data_isreference(data) )
{
@@ -5894,9 +5640,9 @@ BUILDIN_FUNC(getelementofarray)
script_reportdata(data);
script_pushnil(st);
st->state = END;
- return 1;// not a variable
+ return false;// not a variable
}
-
+
id = reference_getid(data);
name = reference_getname(data);
if( not_array_variable(*name) )
@@ -5905,9 +5651,9 @@ BUILDIN_FUNC(getelementofarray)
script_reportdata(data);
script_pushnil(st);
st->state = END;
- return 1;// not supported
+ return false;// not supported
}
-
+
i = script_getnum(st, 3);
if( i < 0 || i >= SCRIPT_MAX_ARRAYSIZE )
{
@@ -5915,11 +5661,11 @@ BUILDIN_FUNC(getelementofarray)
script_reportdata(data);
script_pushnil(st);
st->state = END;
- return 1;// out of range
+ return false;// out of range
}
-
+
push_val2(st->stack, C_NAME, reference_uid(id, i), reference_getref(data));
- return 0;
+ return true;
}
/////////////////////////////////////////////////////////////////////
@@ -5929,97 +5675,97 @@ BUILDIN_FUNC(getelementofarray)
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(setlook)
+BUILDIN(setlook)
{
int type,val;
TBL_PC* sd;
-
+
type=script_getnum(st,2);
val=script_getnum(st,3);
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
pc_changelook(sd,type,val);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(changelook)
+BUILDIN(changelook)
{ // As setlook but only client side
int type,val;
TBL_PC* sd;
-
+
type=script_getnum(st,2);
val=script_getnum(st,3);
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
clif->changelook(&sd->bl,type,val);
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(cutin)
+BUILDIN(cutin)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
clif->cutin(sd,script_getstr(st,2),script_getnum(st,3));
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(viewpoint)
+BUILDIN(viewpoint)
{
int type,x,y,id,color;
TBL_PC* sd;
-
+
type=script_getnum(st,2);
x=script_getnum(st,3);
y=script_getnum(st,4);
id=script_getnum(st,5);
color=script_getnum(st,6);
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
clif->viewpoint(sd,st->oid,type,x,y,id,color);
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(countitem)
+BUILDIN(countitem)
{
int nameid, i;
int count = 0;
struct item_data* id = NULL;
struct script_data* data;
-
+
TBL_PC* sd = script_rid2sd(st);
if (!sd) {
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
data = script_getdata(st,2);
get_val(st, data); // convert into value in case of a variable
-
+
if( data_isstring(data) )
{// item name
id = itemdb_searchname(conv_str(st, data));
@@ -6028,45 +5774,45 @@ BUILDIN_FUNC(countitem)
{// item id
id = itemdb_exists(conv_num(st, data));
}
-
+
if( id == NULL )
{
ShowError("buildin_countitem: Invalid item '%s'.\n", script_getstr(st,2)); // returns string, regardless of what it was
script_pushint(st,0);
- return 1;
+ return false;
}
-
+
nameid = id->nameid;
-
+
for(i = 0; i < MAX_INVENTORY; i++)
if(sd->status.inventory[i].nameid == nameid)
count += sd->status.inventory[i].amount;
-
+
script_pushint(st,count);
- return 0;
+ return true;
}
/*==========================================
* countitem2(nameID,Identified,Refine,Attribute,Card0,Card1,Card2,Card3) [Lupus]
* returns number of items that meet the conditions
*------------------------------------------*/
-BUILDIN_FUNC(countitem2)
+BUILDIN(countitem2)
{
int nameid, iden, ref, attr, c1, c2, c3, c4;
int count = 0;
int i;
struct item_data* id = NULL;
struct script_data* data;
-
+
TBL_PC* sd = script_rid2sd(st);
if (!sd) {
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
data = script_getdata(st,2);
get_val(st, data); // convert into value in case of a variable
-
+
if( data_isstring(data) )
{// item name
id = itemdb_searchname(conv_str(st, data));
@@ -6075,14 +5821,14 @@ BUILDIN_FUNC(countitem2)
{// item id
id = itemdb_exists(conv_num(st, data));
}
-
+
if( id == NULL )
{
ShowError("buildin_countitem2: Invalid item '%s'.\n", script_getstr(st,2)); // returns string, regardless of what it was
script_pushint(st,0);
- return 1;
+ return false;
}
-
+
nameid = id->nameid;
iden = script_getnum(st,3);
ref = script_getnum(st,4);
@@ -6091,7 +5837,7 @@ BUILDIN_FUNC(countitem2)
c2 = (short)script_getnum(st,7);
c3 = (short)script_getnum(st,8);
c4 = (short)script_getnum(st,9);
-
+
for(i = 0; i < MAX_INVENTORY; i++)
if (sd->status.inventory[i].nameid > 0 && sd->inventory_data[i] != NULL &&
sd->status.inventory[i].amount > 0 && sd->status.inventory[i].nameid == nameid &&
@@ -6099,11 +5845,11 @@ BUILDIN_FUNC(countitem2)
sd->status.inventory[i].attribute == attr && sd->status.inventory[i].card[0] == c1 &&
sd->status.inventory[i].card[1] == c2 && sd->status.inventory[i].card[2] == c3 &&
sd->status.inventory[i].card[3] == c4
- )
+ )
count += sd->status.inventory[i].amount;
-
+
script_pushint(st,count);
- return 0;
+ return true;
}
/*==========================================
@@ -6113,25 +5859,25 @@ BUILDIN_FUNC(countitem2)
* 0 : fail
* 1 : success (npc side only)
*------------------------------------------*/
-BUILDIN_FUNC(checkweight)
+BUILDIN(checkweight)
{
int nameid, amount, slots, amount2=0;
unsigned int weight=0, i, nbargs;
struct item_data* id = NULL;
struct map_session_data* sd;
struct script_data* data;
-
+
if( ( sd = script_rid2sd(st) ) == NULL ){
- return 0;
+ return true;
}
nbargs = script_lastdata(st)+1;
if(nbargs%2){
ShowError("buildin_checkweight: Invalid nb of args should be a multiple of 2.\n");
script_pushint(st,0);
- return 1;
+ return false;
}
slots = pc_inventoryblank(sd); //nb of empty slot
-
+
for(i=2; i<nbargs; i=i+2){
data = script_getdata(st,i);
get_val(st, data); // convert into value in case of a variable
@@ -6143,24 +5889,24 @@ BUILDIN_FUNC(checkweight)
if( id == NULL ) {
ShowError("buildin_checkweight: Invalid item '%s'.\n", script_getstr(st,i)); // returns string, regardless of what it was
script_pushint(st,0);
- return 1;
+ return false;
}
nameid = id->nameid;
-
+
amount = script_getnum(st,i+1);
if( amount < 1 ) {
ShowError("buildin_checkweight: Invalid amount '%d'.\n", amount);
script_pushint(st,0);
- return 1;
+ return false;
}
-
+
weight += itemdb_weight(nameid)*amount; //total weight for all chk
if( weight + sd->weight > sd->max_weight )
{// too heavy
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
switch( pc_checkadditem(sd, nameid, amount) )
{
case ADDITEM_EXIST:
@@ -6171,105 +5917,105 @@ BUILDIN_FUNC(checkweight)
amount2++;
if( slots < amount2 ) {
script_pushint(st,0);
- return 0;
+ return true;
}
}
else {// non-stackable
amount2 += amount;
if( slots < amount2){
script_pushint(st,0);
- return 0;
+ return true;
}
}
break;
case ADDITEM_OVERAMOUNT:
script_pushint(st,0);
- return 0;
+ return true;
}
}
script_pushint(st,1);
- return 0;
+ return true;
}
-BUILDIN_FUNC(checkweight2)
+BUILDIN(checkweight2)
{
- //variable sub checkweight
- int32 nameid=-1, amount=-1;
- int i=0, amount2=0, slots=0, weight=0;
+ //variable sub checkweight
+ int32 nameid=-1, amount=-1;
+ int i=0, amount2=0, slots=0, weight=0;
short fail=0;
-
- //variable for array parsing
- struct script_data* data_it;
- struct script_data* data_nb;
- const char* name_it;
- const char* name_nb;
- int32 id_it, id_nb;
- int32 idx_it, idx_nb;
- int nb_it, nb_nb; //array size
-
- TBL_PC *sd = script_rid2sd(st);
- nullpo_retr(1,sd);
-
- data_it = script_getdata(st, 2);
- data_nb = script_getdata(st, 3);
-
- if( !data_isreference(data_it) || !data_isreference(data_nb))
- {
- ShowError("script:checkweight2: parameter not a variable\n");
- script_pushint(st,0);
- return 1;// not a variable
- }
- id_it = reference_getid(data_it);
- id_nb = reference_getid(data_nb);
- idx_it = reference_getindex(data_it);
- idx_nb = reference_getindex(data_nb);
- name_it = reference_getname(data_it);
- name_nb = reference_getname(data_nb);
-
- if( not_array_variable(*name_it) || not_array_variable(*name_nb))
- {
- ShowError("script:checkweight2: illegal scope\n");
- script_pushint(st,0);
- return 1;// not supported
- }
- if(is_string_variable(name_it) || is_string_variable(name_nb)){
- ShowError("script:checkweight2: illegal type, need int\n");
- script_pushint(st,0);
- return 1;// not supported
- }
- nb_it = getarraysize(st, id_it, idx_it, 0, reference_getref(data_it));
- nb_nb = getarraysize(st, id_nb, idx_nb, 0, reference_getref(data_nb));
- if(nb_it != nb_nb){
- ShowError("Size mistmatch: nb_it=%d, nb_nb=%d\n",nb_it,nb_nb);
+
+ //variable for array parsing
+ struct script_data* data_it;
+ struct script_data* data_nb;
+ const char* name_it;
+ const char* name_nb;
+ int32 id_it, id_nb;
+ int32 idx_it, idx_nb;
+ int nb_it, nb_nb; //array size
+
+ TBL_PC *sd = script_rid2sd(st);
+ nullpo_retr(1,sd);
+
+ data_it = script_getdata(st, 2);
+ data_nb = script_getdata(st, 3);
+
+ if( !data_isreference(data_it) || !data_isreference(data_nb))
+ {
+ ShowError("script:checkweight2: parameter not a variable\n");
+ script_pushint(st,0);
+ return false;// not a variable
+ }
+ id_it = reference_getid(data_it);
+ id_nb = reference_getid(data_nb);
+ idx_it = reference_getindex(data_it);
+ idx_nb = reference_getindex(data_nb);
+ name_it = reference_getname(data_it);
+ name_nb = reference_getname(data_nb);
+
+ if( not_array_variable(*name_it) || not_array_variable(*name_nb))
+ {
+ ShowError("script:checkweight2: illegal scope\n");
+ script_pushint(st,0);
+ return false;// not supported
+ }
+ if(is_string_variable(name_it) || is_string_variable(name_nb)){
+ ShowError("script:checkweight2: illegal type, need int\n");
+ script_pushint(st,0);
+ return false;// not supported
+ }
+ nb_it = getarraysize(st, id_it, idx_it, 0, reference_getref(data_it));
+ nb_nb = getarraysize(st, id_nb, idx_nb, 0, reference_getref(data_nb));
+ if(nb_it != nb_nb){
+ ShowError("Size mistmatch: nb_it=%d, nb_nb=%d\n",nb_it,nb_nb);
fail = 1;
- }
-
- slots = pc_inventoryblank(sd);
- for(i=0; i<nb_it; i++){
- nameid = (int32)__64BPRTSIZE(get_val2(st,reference_uid(id_it,idx_it+i),reference_getref(data_it)));
+ }
+
+ slots = pc_inventoryblank(sd);
+ for(i=0; i<nb_it; i++){
+ nameid = (int32)__64BPTRSIZE(get_val2(st,reference_uid(id_it,idx_it+i),reference_getref(data_it)));
script_removetop(st, -1, 0);
- amount = (int32)__64BPRTSIZE(get_val2(st,reference_uid(id_nb,idx_nb+i),reference_getref(data_nb)));
+ amount = (int32)__64BPTRSIZE(get_val2(st,reference_uid(id_nb,idx_nb+i),reference_getref(data_nb)));
script_removetop(st, -1, 0);
if(fail) continue; //cpntonie to depop rest
-
- if(itemdb_exists(nameid) == NULL ){
- ShowError("buildin_checkweight2: Invalid item '%d'.\n", nameid);
- fail=1;
- continue;
- }
- if(amount < 0 ){
- ShowError("buildin_checkweight2: Invalid amount '%d'.\n", amount);
- fail = 1;
- continue;
- }
+
+ if(itemdb_exists(nameid) == NULL ){
+ ShowError("buildin_checkweight2: Invalid item '%d'.\n", nameid);
+ fail=1;
+ continue;
+ }
+ if(amount < 0 ){
+ ShowError("buildin_checkweight2: Invalid amount '%d'.\n", amount);
+ fail = 1;
+ continue;
+ }
weight += itemdb_weight(nameid)*amount;
if( weight + sd->weight > sd->max_weight ){
- fail = 1;
- continue;
+ fail = 1;
+ continue;
}
switch( pc_checkadditem(sd, nameid, amount) ) {
case ADDITEM_EXIST:
- // item is already in inventory, but there is still space for the requested amount
+ // item is already in inventory, but there is still space for the requested amount
break;
case ADDITEM_NEW:
if( itemdb_isstackable(nameid) ){// stackable
@@ -6288,75 +6034,74 @@ BUILDIN_FUNC(checkweight2)
fail = 1;
} //end switch
} //end loop DO NOT break it prematurly we need to depop all stack
-
- fail?script_pushint(st,0):script_pushint(st,1);
- return 0;
+
+ fail?script_pushint(st,0):script_pushint(st,1);
+ return true;
}
/*==========================================
* getitem <item id>,<amount>{,<account ID>};
* getitem "<item name>",<amount>{,<account ID>};
*------------------------------------------*/
-BUILDIN_FUNC(getitem)
+BUILDIN(getitem)
{
int nameid,amount,get_count,i,flag = 0;
struct item it;
TBL_PC *sd;
struct script_data *data;
-
+ struct item_data *item_data;
+
data=script_getdata(st,2);
get_val(st,data);
if( data_isstring(data) )
{// "<item name>"
const char *name=conv_str(st,data);
- struct item_data *item_data = itemdb_searchname(name);
- if( item_data == NULL ){
+ if( (item_data = itemdb_searchname(name)) == NULL ){
ShowError("buildin_getitem: Nonexistant item %s requested.\n", name);
- return 1; //No item created.
+ return false; //No item created.
}
nameid=item_data->nameid;
- } else if( data_isint(data) )
- {// <item id>
+ } else if( data_isint(data) ) {// <item id>
nameid=conv_num(st,data);
//Violet Box, Blue Box, etc - random item pick
if( nameid < 0 ) {
nameid = -nameid;
flag = 1;
}
- if( nameid <= 0 || !itemdb_exists(nameid) ){
+ if( nameid <= 0 || !(item_data = itemdb_exists(nameid)) ){
ShowError("buildin_getitem: Nonexistant item %d requested.\n", nameid);
- return 1; //No item created.
+ return false; //No item created.
}
} else {
ShowError("buildin_getitem: invalid data type for argument #1 (%d).", data->type);
- return 1;
+ return false;
}
-
+
// <amount>
if( (amount=script_getnum(st,3)) <= 0)
- return 0; //return if amount <=0, skip the useles iteration
-
+ return true; //return if amount <=0, skip the useles iteration
+
memset(&it,0,sizeof(it));
it.nameid=nameid;
if(!flag)
it.identify=1;
else
- it.identify=itemdb_isidentified(nameid);
-
+ it.identify=itemdb_isidentified2(item_data);
+
if( script_hasdata(st,4) )
sd=map_id2sd(script_getnum(st,4)); // <Account ID>
else
sd=script_rid2sd(st); // Attached player
-
+
if( sd == NULL ) // no target
- return 0;
-
+ return true;
+
//Check if it's stackable.
if (!itemdb_isstackable(nameid))
get_count = 1;
else
get_count = amount;
-
+
for (i = 0; i < amount; i += get_count)
{
// if not pet egg
@@ -6370,14 +6115,14 @@ BUILDIN_FUNC(getitem)
}
}
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(getitem2)
+BUILDIN(getitem2)
{
int nameid,amount,get_count,i,flag = 0;
int iden,ref,attr,c1,c2,c3,c4;
@@ -6385,15 +6130,15 @@ BUILDIN_FUNC(getitem2)
struct item item_tmp;
TBL_PC *sd;
struct script_data *data;
-
+
if( script_hasdata(st,11) )
sd=map_id2sd(script_getnum(st,11)); // <Account ID>
else
sd=script_rid2sd(st); // Attached player
-
+
if( sd == NULL ) // no target
- return 0;
-
+ return true;
+
data=script_getdata(st,2);
get_val(st,data);
if( data_isstring(data) ){
@@ -6405,7 +6150,7 @@ BUILDIN_FUNC(getitem2)
nameid=UNKNOWN_ITEM_ID;
}else
nameid=conv_num(st,data);
-
+
amount=script_getnum(st,3);
iden=script_getnum(st,4);
ref=script_getnum(st,5);
@@ -6414,12 +6159,12 @@ BUILDIN_FUNC(getitem2)
c2=(short)script_getnum(st,8);
c3=(short)script_getnum(st,9);
c4=(short)script_getnum(st,10);
-
+
if(nameid<0) { // Invalide nameid
nameid = -nameid;
flag = 1;
}
-
+
if(nameid > 0) {
memset(&item_tmp,0,sizeof(item_tmp));
item_data=itemdb_exists(nameid);
@@ -6436,7 +6181,7 @@ BUILDIN_FUNC(getitem2)
iden = 1;
ref = attr = 0;
}
-
+
item_tmp.nameid=nameid;
if(!flag)
item_tmp.identify=iden;
@@ -6448,13 +6193,13 @@ BUILDIN_FUNC(getitem2)
item_tmp.card[1]=(short)c2;
item_tmp.card[2]=(short)c3;
item_tmp.card[3]=(short)c4;
-
+
//Check if it's stackable.
if (!itemdb_isstackable(nameid))
get_count = 1;
else
get_count = amount;
-
+
for (i = 0; i < amount; i += get_count)
{
// if not pet egg
@@ -6469,28 +6214,28 @@ BUILDIN_FUNC(getitem2)
}
}
}
-
- return 0;
+
+ return true;
}
/*==========================================
* rentitem <item id>,<seconds>
* rentitem "<item name>",<seconds>
*------------------------------------------*/
-BUILDIN_FUNC(rentitem)
+BUILDIN(rentitem)
{
struct map_session_data *sd;
struct script_data *data;
struct item it;
int seconds;
int nameid = 0, flag;
-
+
data = script_getdata(st,2);
get_val(st,data);
-
+
if( (sd = script_rid2sd(st)) == NULL )
- return 0;
-
+ return true;
+
if( data_isstring(data) )
{
const char *name = conv_str(st,data);
@@ -6498,7 +6243,7 @@ BUILDIN_FUNC(rentitem)
if( itd == NULL )
{
ShowError("buildin_rentitem: Nonexistant item %s requested.\n", name);
- return 1;
+ return false;
}
nameid = itd->nameid;
}
@@ -6508,28 +6253,28 @@ BUILDIN_FUNC(rentitem)
if( nameid <= 0 || !itemdb_exists(nameid) )
{
ShowError("buildin_rentitem: Nonexistant item %d requested.\n", nameid);
- return 1;
+ return false;
}
}
else
{
ShowError("buildin_rentitem: invalid data type for argument #1 (%d).\n", data->type);
- return 1;
+ return false;
}
-
+
seconds = script_getnum(st,3);
memset(&it, 0, sizeof(it));
it.nameid = nameid;
it.identify = 1;
it.expire_time = (unsigned int)(time(NULL) + seconds);
-
+
if( (flag = pc_additem(sd, &it, 1, LOG_TYPE_SCRIPT)) )
{
clif->additem(sd, 0, 0, flag);
- return 1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -6538,20 +6283,20 @@ BUILDIN_FUNC(rentitem)
* Returned Qty is always 1, only works on equip-able
* equipment
*------------------------------------------*/
-BUILDIN_FUNC(getnameditem)
+BUILDIN(getnameditem)
{
int nameid;
struct item item_tmp;
TBL_PC *sd, *tsd;
struct script_data *data;
-
+
sd = script_rid2sd(st);
if (sd == NULL)
{ //Player not attached!
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
data=script_getdata(st,2);
get_val(st,data);
if( data_isstring(data) ){
@@ -6560,31 +6305,31 @@ BUILDIN_FUNC(getnameditem)
if( item_data == NULL)
{ //Failed
script_pushint(st,0);
- return 0;
+ return true;
}
nameid = item_data->nameid;
}else
nameid = conv_num(st,data);
-
+
if(!itemdb_exists(nameid)/* || itemdb_isstackable(nameid)*/)
{ //Even though named stackable items "could" be risky, they are required for certain quests.
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
data=script_getdata(st,3);
get_val(st,data);
if( data_isstring(data) ) //Char Name
tsd=map_nick2sd(conv_str(st,data));
else //Char Id was given
tsd=map_charid2sd(conv_num(st,data));
-
+
if( tsd == NULL )
{ //Failed
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
memset(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid=nameid;
item_tmp.amount=1;
@@ -6594,80 +6339,77 @@ BUILDIN_FUNC(getnameditem)
item_tmp.card[3]=tsd->status.char_id >> 16;
if(pc_additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT)) {
script_pushint(st,0);
- return 0; //Failed to add item, we will not drop if they don't fit
+ return true; //Failed to add item, we will not drop if they don't fit
}
-
+
script_pushint(st,1);
- return 0;
+ return true;
}
/*==========================================
* gets a random item ID from an item group [Skotlex]
* groupranditem group_num
*------------------------------------------*/
-BUILDIN_FUNC(grouprandomitem)
+BUILDIN(grouprandomitem)
{
int group;
-
+
group = script_getnum(st,2);
script_pushint(st,itemdb_searchrandomid(group));
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(makeitem)
+BUILDIN(makeitem)
{
int nameid,amount,flag = 0;
int x,y,m;
const char *mapname;
struct item item_tmp;
struct script_data *data;
+ struct item_data *item_data;
data=script_getdata(st,2);
get_val(st,data);
if( data_isstring(data) ){
const char *name=conv_str(st,data);
- struct item_data *item_data = itemdb_searchname(name);
- if( item_data )
+ if( (item_data = itemdb_searchname(name)) )
nameid=item_data->nameid;
else
nameid=UNKNOWN_ITEM_ID;
- }else
+ } else {
nameid=conv_num(st,data);
-
+ if( nameid <= 0 || !(item_data = itemdb_exists(nameid)) ){
+ ShowError("makeitem: Nonexistant item %d requested.\n", nameid);
+ return false; //No item created.
+ }
+ }
amount=script_getnum(st,3);
mapname =script_getstr(st,4);
x =script_getnum(st,5);
y =script_getnum(st,6);
-
+
if(strcmp(mapname,"this")==0)
{
TBL_PC *sd;
sd = script_rid2sd(st);
- if (!sd) return 0; //Failed...
+ if (!sd) return true; //Failed...
m=sd->bl.m;
} else
m=map_mapname2mapid(mapname);
-
- if(nameid<0) {
- nameid = -nameid;
- flag = 1;
- }
-
- if(nameid > 0) {
- memset(&item_tmp,0,sizeof(item_tmp));
- item_tmp.nameid=nameid;
- if(!flag)
- item_tmp.identify=1;
- else
- item_tmp.identify=itemdb_isidentified(nameid);
-
- map_addflooritem(&item_tmp,amount,m,x,y,0,0,0,0);
- }
-
- return 0;
+
+ memset(&item_tmp,0,sizeof(item_tmp));
+ item_tmp.nameid=nameid;
+ if(!flag)
+ item_tmp.identify=1;
+ else
+ item_tmp.identify=itemdb_isidentified2(item_data);
+
+ map_addflooritem(&item_tmp,amount,m,x,y,0,0,0,0);
+
+ return true;
}
@@ -6678,9 +6420,9 @@ static void buildin_delitem_delete(struct map_session_data* sd, int idx, int* am
{
int delamount;
struct item* inv = &sd->status.inventory[idx];
-
+
delamount = ( amount[0] < inv->amount ) ? amount[0] : inv->amount;
-
+
if( delete_items )
{
if( sd->inventory_data[idx]->type == IT_PETEGG && inv->card[0] == CARD0_PET )
@@ -6689,7 +6431,7 @@ static void buildin_delitem_delete(struct map_session_data* sd, int idx, int* am
}
pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_SCRIPT);
}
-
+
amount[0]-= delamount;
}
@@ -6704,10 +6446,10 @@ static bool buildin_delitem_search(struct map_session_data* sd, struct item* it,
bool delete_items = false;
int i, amount, important;
struct item* inv;
-
+
// prefer always non-equipped items
it->equip = 0;
-
+
// when searching for nameid only, prefer additionally
if( !exact_match )
{
@@ -6716,28 +6458,28 @@ static bool buildin_delitem_search(struct map_session_data* sd, struct item* it,
// card-less items
memset(it->card, 0, sizeof(it->card));
}
-
+
for(;;)
{
amount = it->amount;
important = 0;
-
+
// 1st pass -- less important items / exact match
for( i = 0; amount && i < ARRAYLENGTH(sd->status.inventory); i++ )
{
inv = &sd->status.inventory[i];
-
+
if( !inv->nameid || !sd->inventory_data[i] || inv->nameid != it->nameid )
{// wrong/invalid item
continue;
}
-
+
if( inv->equip != it->equip || inv->refine != it->refine )
{// not matching attributes
important++;
continue;
}
-
+
if( exact_match )
{
if( inv->identify != it->identify || inv->attribute != it->attribute || memcmp(inv->card, it->card, sizeof(inv->card)) )
@@ -6760,11 +6502,11 @@ static bool buildin_delitem_search(struct map_session_data* sd, struct item* it,
continue;
}
}
-
+
// count / delete item
buildin_delitem_delete(sd, i, &amount, delete_items);
}
-
+
// 2nd pass -- any matching item
if( amount == 0 || important == 0 )
{// either everything was already consumed or no items were skipped
@@ -6773,17 +6515,17 @@ static bool buildin_delitem_search(struct map_session_data* sd, struct item* it,
else for( i = 0; amount && i < ARRAYLENGTH(sd->status.inventory); i++ )
{
inv = &sd->status.inventory[i];
-
+
if( !inv->nameid || !sd->inventory_data[i] || inv->nameid != it->nameid )
{// wrong/invalid item
continue;
}
-
+
if( sd->inventory_data[i]->type == IT_PETEGG && inv->card[0] == CARD0_PET && CheckForCharServer() )
{// pet which cannot be deleted
continue;
}
-
+
if( exact_match )
{
if( inv->refine != it->refine || inv->identify != it->identify || inv->attribute != it->attribute || memcmp(inv->card, it->card, sizeof(inv->card)) )
@@ -6791,18 +6533,18 @@ static bool buildin_delitem_search(struct map_session_data* sd, struct item* it,
continue;
}
}
-
+
// count / delete item
buildin_delitem_delete(sd, i, &amount, delete_items);
}
-
+
if( amount )
{// not enough items
- return false;
+ return true;
}
else if( delete_items )
{// we are done with the work
- return true;
+ return false;
}
else
{// get rid of the items now
@@ -6817,12 +6559,12 @@ static bool buildin_delitem_search(struct map_session_data* sd, struct item* it,
///
/// delitem <item id>,<amount>{,<account id>}
/// delitem "<item name>",<amount>{,<account id>}
-BUILDIN_FUNC(delitem)
+BUILDIN(delitem)
{
TBL_PC *sd;
struct item it;
struct script_data *data;
-
+
if( script_hasdata(st,4) )
{
int account_id = script_getnum(st,4);
@@ -6831,16 +6573,16 @@ BUILDIN_FUNC(delitem)
{
ShowError("script:delitem: player not found (AID=%d).\n", account_id);
st->state = END;
- return 1;
+ return false;
}
}
else
{
sd = script_rid2sd(st);// attached player
if( sd == NULL )
- return 0;
+ return true;
}
-
+
data = script_getdata(st,2);
get_val(st,data);
if( data_isstring(data) )
@@ -6851,7 +6593,7 @@ BUILDIN_FUNC(delitem)
{
ShowError("script:delitem: unknown item \"%s\".\n", item_name);
st->state = END;
- return 1;
+ return false;
}
it.nameid = id->nameid;// "<item name>"
}
@@ -6862,36 +6604,36 @@ BUILDIN_FUNC(delitem)
{
ShowError("script:delitem: unknown item \"%d\".\n", it.nameid);
st->state = END;
- return 1;
+ return false;
}
}
-
+
it.amount=script_getnum(st,3);
-
+
if( it.amount <= 0 )
- return 0;// nothing to do
-
+ return true;// nothing to do
+
if( buildin_delitem_search(sd, &it, false) )
{// success
- return 0;
+ return true;
}
-
+
ShowError("script:delitem: failed to delete %d items (AID=%d item_id=%d).\n", it.amount, sd->status.account_id, it.nameid);
st->state = END;
clif->scriptclose(sd, st->oid);
- return 1;
+ return false;
}
/// Deletes items from the target/attached player.
///
/// delitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>}
/// delitem2 "<Item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>}
-BUILDIN_FUNC(delitem2)
+BUILDIN(delitem2)
{
TBL_PC *sd;
struct item it;
struct script_data *data;
-
+
if( script_hasdata(st,11) )
{
int account_id = script_getnum(st,11);
@@ -6900,16 +6642,16 @@ BUILDIN_FUNC(delitem2)
{
ShowError("script:delitem2: player not found (AID=%d).\n", account_id);
st->state = END;
- return 1;
+ return false;
}
}
else
{
sd = script_rid2sd(st);// attached player
if( sd == NULL )
- return 0;
+ return true;
}
-
+
data = script_getdata(st,2);
get_val(st,data);
if( data_isstring(data) )
@@ -6920,7 +6662,7 @@ BUILDIN_FUNC(delitem2)
{
ShowError("script:delitem2: unknown item \"%s\".\n", item_name);
st->state = END;
- return 1;
+ return false;
}
it.nameid = id->nameid;// "<item name>"
}
@@ -6931,10 +6673,10 @@ BUILDIN_FUNC(delitem2)
{
ShowError("script:delitem: unknown item \"%d\".\n", it.nameid);
st->state = END;
- return 1;
+ return false;
}
}
-
+
it.amount=script_getnum(st,3);
it.identify=script_getnum(st,4);
it.refine=script_getnum(st,5);
@@ -6943,65 +6685,65 @@ BUILDIN_FUNC(delitem2)
it.card[1]=(short)script_getnum(st,8);
it.card[2]=(short)script_getnum(st,9);
it.card[3]=(short)script_getnum(st,10);
-
+
if( it.amount <= 0 )
- return 0;// nothing to do
-
+ return true;// nothing to do
+
if( buildin_delitem_search(sd, &it, true) )
{// success
- return 0;
+ return true;
}
-
+
ShowError("script:delitem2: failed to delete %d items (AID=%d item_id=%d).\n", it.amount, sd->status.account_id, it.nameid);
st->state = END;
clif->scriptclose(sd, st->oid);
- return 1;
+ return false;
}
/*==========================================
* Enables/Disables use of items while in an NPC [Skotlex]
*------------------------------------------*/
-BUILDIN_FUNC(enableitemuse)
+BUILDIN(enableitemuse)
{
TBL_PC *sd;
sd=script_rid2sd(st);
if (sd)
st->npc_item_flag = sd->npc_item_flag = 1;
- return 0;
+ return true;
}
-BUILDIN_FUNC(disableitemuse)
+BUILDIN(disableitemuse)
{
TBL_PC *sd;
sd=script_rid2sd(st);
if (sd)
st->npc_item_flag = sd->npc_item_flag = 0;
- return 0;
+ return true;
}
/*==========================================
* return the basic stats of sd
* chk pc_readparam for available type
*------------------------------------------*/
-BUILDIN_FUNC(readparam)
+BUILDIN(readparam)
{
int type;
TBL_PC *sd;
-
+
type=script_getnum(st,2);
if( script_hasdata(st,3) )
sd=map_nick2sd(script_getstr(st,3));
else
sd=script_rid2sd(st);
-
+
if(sd==NULL){
script_pushint(st,-1);
- return 0;
+ return true;
}
-
+
script_pushint(st,pc_readparam(sd,type));
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -7013,54 +6755,54 @@ BUILDIN_FUNC(readparam)
* 3 : account_id
* 4 : bg_id
*------------------------------------------*/
-BUILDIN_FUNC(getcharid)
+BUILDIN(getcharid)
{
int num;
TBL_PC *sd;
-
+
num = script_getnum(st,2);
if( script_hasdata(st,3) )
sd=map_nick2sd(script_getstr(st,3));
else
sd=script_rid2sd(st);
-
+
if(sd==NULL){
script_pushint(st,0); //return 0, according docs
- return 0;
+ return true;
}
-
+
switch( num ) {
- case 0: script_pushint(st,sd->status.char_id); break;
- case 1: script_pushint(st,sd->status.party_id); break;
- case 2: script_pushint(st,sd->status.guild_id); break;
- case 3: script_pushint(st,sd->status.account_id); break;
- case 4: script_pushint(st,sd->bg_id); break;
- default:
- ShowError("buildin_getcharid: invalid parameter (%d).\n", num);
- script_pushint(st,0);
- break;
+ case 0: script_pushint(st,sd->status.char_id); break;
+ case 1: script_pushint(st,sd->status.party_id); break;
+ case 2: script_pushint(st,sd->status.guild_id); break;
+ case 3: script_pushint(st,sd->status.account_id); break;
+ case 4: script_pushint(st,sd->bg_id); break;
+ default:
+ ShowError("buildin_getcharid: invalid parameter (%d).\n", num);
+ script_pushint(st,0);
+ break;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* returns the GID of an NPC
*------------------------------------------*/
-BUILDIN_FUNC(getnpcid)
+BUILDIN(getnpcid)
{
int num = script_getnum(st,2);
struct npc_data* nd = NULL;
-
+
if( script_hasdata(st,3) )
{// unique npc name
if( ( nd = npc_name2id(script_getstr(st,3)) ) == NULL )
{
ShowError("buildin_getnpcid: No such NPC '%s'.\n", script_getstr(st,3));
script_pushint(st,0);
- return 1;
+ return false;
}
}
-
+
switch (num) {
case 0:
script_pushint(st,nd ? nd->bl.id : st->oid);
@@ -7068,23 +6810,23 @@ BUILDIN_FUNC(getnpcid)
default:
ShowError("buildin_getnpcid: invalid parameter (%d).\n", num);
script_pushint(st,0);
- return 1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Return the name of the party_id
* null if not found
*------------------------------------------*/
-BUILDIN_FUNC(getpartyname)
+BUILDIN(getpartyname)
{
int party_id;
struct party_data* p;
-
+
party_id = script_getnum(st,2);
-
+
if( ( p = party_search(party_id) ) != NULL )
{
script_pushstrcopy(st,p->party.name);
@@ -7093,7 +6835,7 @@ BUILDIN_FUNC(getpartyname)
{
script_pushconststr(st,"null");
}
- return 0;
+ return true;
}
/*==========================================
@@ -7104,64 +6846,64 @@ BUILDIN_FUNC(getpartyname)
* 1 : char_id des membres
* 2 : account_id des membres
*------------------------------------------*/
-BUILDIN_FUNC(getpartymember)
+BUILDIN(getpartymember)
{
struct party_data *p;
int i,j=0,type=0;
-
+
p=party_search(script_getnum(st,2));
-
+
if( script_hasdata(st,3) )
type=script_getnum(st,3);
-
+
if(p!=NULL){
for(i=0;i<MAX_PARTY;i++){
if(p->party.member[i].account_id){
switch (type) {
- case 2:
- mapreg_setreg(reference_uid(add_str("$@partymemberaid"), j),p->party.member[i].account_id);
- break;
- case 1:
- mapreg_setreg(reference_uid(add_str("$@partymembercid"), j),p->party.member[i].char_id);
- break;
- default:
- mapreg_setregstr(reference_uid(add_str("$@partymembername$"), j),p->party.member[i].name);
+ case 2:
+ mapreg_setreg(reference_uid(add_str("$@partymemberaid"), j),p->party.member[i].account_id);
+ break;
+ case 1:
+ mapreg_setreg(reference_uid(add_str("$@partymembercid"), j),p->party.member[i].char_id);
+ break;
+ default:
+ mapreg_setregstr(reference_uid(add_str("$@partymembername$"), j),p->party.member[i].name);
}
j++;
}
}
}
mapreg_setreg(add_str("$@partymembercount"),j);
-
- return 0;
+
+ return true;
}
/*==========================================
* Retrieves party leader. if flag is specified,
* return some of the leader data. Otherwise, return name.
*------------------------------------------*/
-BUILDIN_FUNC(getpartyleader)
+BUILDIN(getpartyleader)
{
int party_id, type = 0, i=0;
struct party_data *p;
-
+
party_id=script_getnum(st,2);
if( script_hasdata(st,3) )
type=script_getnum(st,3);
-
+
p=party_search(party_id);
-
+
if (p) //Search leader
- for(i = 0; i < MAX_PARTY && !p->party.member[i].leader; i++);
-
+ for(i = 0; i < MAX_PARTY && !p->party.member[i].leader; i++);
+
if (!p || i == MAX_PARTY) { //leader not found
if (type)
script_pushint(st,-1);
else
script_pushconststr(st,"null");
- return 0;
+ return true;
}
-
+
switch (type) {
case 1: script_pushint(st,p->party.member[i].account_id); break;
case 2: script_pushint(st,p->party.member[i].char_id); break;
@@ -7170,20 +6912,20 @@ BUILDIN_FUNC(getpartyleader)
case 5: script_pushint(st,p->party.member[i].lv); break;
default: script_pushstrcopy(st,p->party.member[i].name); break;
}
- return 0;
+ return true;
}
/*==========================================
* Return the name of the @guild_id
* null if not found
*------------------------------------------*/
-BUILDIN_FUNC(getguildname)
+BUILDIN(getguildname)
{
int guild_id;
struct guild* g;
-
+
guild_id = script_getnum(st,2);
-
+
if( ( g = guild_search(guild_id) ) != NULL )
{
script_pushstrcopy(st,g->name);
@@ -7192,20 +6934,20 @@ BUILDIN_FUNC(getguildname)
{
script_pushconststr(st,"null");
}
- return 0;
+ return true;
}
/*==========================================
* Return the name of the guild master of @guild_id
* null if not found
*------------------------------------------*/
-BUILDIN_FUNC(getguildmaster)
+BUILDIN(getguildmaster)
{
int guild_id;
struct guild* g;
-
+
guild_id = script_getnum(st,2);
-
+
if( ( g = guild_search(guild_id) ) != NULL )
{
script_pushstrcopy(st,g->member[0].name);
@@ -7214,16 +6956,16 @@ BUILDIN_FUNC(getguildmaster)
{
script_pushconststr(st,"null");
}
- return 0;
+ return true;
}
-BUILDIN_FUNC(getguildmasterid)
+BUILDIN(getguildmasterid)
{
int guild_id;
struct guild* g;
-
+
guild_id = script_getnum(st,2);
-
+
if( ( g = guild_search(guild_id) ) != NULL )
{
script_pushint(st,g->member[0].char_id);
@@ -7232,7 +6974,7 @@ BUILDIN_FUNC(getguildmasterid)
{
script_pushint(st,0);
}
- return 0;
+ return true;
}
/*==========================================
@@ -7244,17 +6986,17 @@ BUILDIN_FUNC(getguildmasterid)
* 3 : map_name
* - : ""
*------------------------------------------*/
-BUILDIN_FUNC(strcharinfo)
+BUILDIN(strcharinfo)
{
TBL_PC *sd;
int num;
struct guild* g;
struct party_data* p;
-
+
sd=script_rid2sd(st);
if (!sd) { //Avoid crashing....
script_pushconststr(st,"");
- return 0;
+ return true;
}
num=script_getnum(st,2);
switch(num){
@@ -7283,8 +7025,8 @@ BUILDIN_FUNC(strcharinfo)
script_pushconststr(st,"");
break;
}
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -7296,18 +7038,18 @@ BUILDIN_FUNC(strcharinfo)
* 3 : ::str
* 4 : map name
*------------------------------------------*/
-BUILDIN_FUNC(strnpcinfo)
+BUILDIN(strnpcinfo)
{
TBL_NPC* nd;
int num;
char *buf,*name=NULL;
-
+
nd = map_id2nd(st->oid);
if (!nd) {
script_pushconststr(st, "");
- return 0;
+ return true;
}
-
+
num = script_getnum(st,2);
switch(num){
case 0: // display name
@@ -7332,13 +7074,13 @@ BUILDIN_FUNC(strnpcinfo)
name = aStrdup(map[nd->bl.m].name);
break;
}
-
+
if(name)
script_pushstr(st, name);
else
script_pushconststr(st, "");
-
- return 0;
+
+ return true;
}
@@ -7348,148 +7090,148 @@ static unsigned int equip[] = {EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_
/*==========================================
* GetEquipID(Pos); Pos: 1-10
*------------------------------------------*/
-BUILDIN_FUNC(getequipid)
+BUILDIN(getequipid)
{
int i, num;
TBL_PC* sd;
struct item_data* item;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
num = script_getnum(st,2) - 1;
if( num < 0 || num >= ARRAYLENGTH(equip) )
{
script_pushint(st,-1);
- return 0;
+ return true;
}
-
+
// get inventory position of item
i = pc_checkequip(sd,equip[num]);
if( i < 0 )
{
script_pushint(st,-1);
- return 0;
+ return true;
}
-
+
item = sd->inventory_data[i];
if( item != 0 )
script_pushint(st,item->nameid);
else
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
/*==========================================
* Get the equipement name at pos
* return item jname or ""
*------------------------------------------*/
-BUILDIN_FUNC(getequipname)
+BUILDIN(getequipname)
{
int i, num;
TBL_PC* sd;
struct item_data* item;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
num = script_getnum(st,2) - 1;
if( num < 0 || num >= ARRAYLENGTH(equip) )
{
script_pushconststr(st,"");
- return 0;
+ return true;
}
-
+
// get inventory position of item
i = pc_checkequip(sd,equip[num]);
if( i < 0 )
{
script_pushconststr(st,"");
- return 0;
+ return true;
}
-
+
item = sd->inventory_data[i];
if( item != 0 )
script_pushstrcopy(st,item->jname);
else
script_pushconststr(st,"");
-
- return 0;
+
+ return true;
}
/*==========================================
* getbrokenid [Valaris]
*------------------------------------------*/
-BUILDIN_FUNC(getbrokenid)
+BUILDIN(getbrokenid)
{
int i,num,id=0,brokencounter=0;
TBL_PC *sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
num=script_getnum(st,2);
for(i=0; i<MAX_INVENTORY; i++) {
if(sd->status.inventory[i].attribute){
- brokencounter++;
- if(num==brokencounter){
- id=sd->status.inventory[i].nameid;
- break;
- }
+ brokencounter++;
+ if(num==brokencounter){
+ id=sd->status.inventory[i].nameid;
+ break;
+ }
}
}
-
+
script_pushint(st,id);
-
- return 0;
+
+ return true;
}
/*==========================================
* repair [Valaris]
*------------------------------------------*/
-BUILDIN_FUNC(repair)
+BUILDIN(repair)
{
int i,num;
int repaircounter=0;
TBL_PC *sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
num=script_getnum(st,2);
for(i=0; i<MAX_INVENTORY; i++) {
if(sd->status.inventory[i].attribute){
- repaircounter++;
- if(num==repaircounter){
- sd->status.inventory[i].attribute=0;
- clif->equiplist(sd);
- clif->produce_effect(sd, 0, sd->status.inventory[i].nameid);
- clif->misceffect(&sd->bl, 3);
- break;
- }
+ repaircounter++;
+ if(num==repaircounter){
+ sd->status.inventory[i].attribute=0;
+ clif->equiplist(sd);
+ clif->produce_effect(sd, 0, sd->status.inventory[i].nameid);
+ clif->misceffect(&sd->bl, 3);
+ break;
+ }
}
}
-
- return 0;
+
+ return true;
}
/*==========================================
* repairall
*------------------------------------------*/
-BUILDIN_FUNC(repairall)
+BUILDIN(repairall)
{
int i, repaircounter = 0;
TBL_PC *sd;
-
+
sd = script_rid2sd(st);
if(sd == NULL)
- return 0;
-
+ return true;
+
for(i = 0; i < MAX_INVENTORY; i++)
{
if(sd->status.inventory[i].nameid && sd->status.inventory[i].attribute)
@@ -7499,37 +7241,37 @@ BUILDIN_FUNC(repairall)
repaircounter++;
}
}
-
+
if(repaircounter)
{
clif->misceffect(&sd->bl, 3);
clif->equiplist(sd);
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Chk if player have something equiped at pos
*------------------------------------------*/
-BUILDIN_FUNC(getequipisequiped)
+BUILDIN(getequipisequiped)
{
int i = -1,num;
TBL_PC *sd;
-
+
num = script_getnum(st,2);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
-
+
if(i >= 0)
script_pushint(st,1);
else
- script_pushint(st,0);
- return 0;
+ script_pushint(st,0);
+ return true;
}
/*==========================================
@@ -7539,24 +7281,24 @@ BUILDIN_FUNC(getequipisequiped)
* 1 : true
* 0 : false
*------------------------------------------*/
-BUILDIN_FUNC(getequipisenableref)
+BUILDIN(getequipisenableref)
{
int i = -1,num;
TBL_PC *sd;
-
+
num = script_getnum(st,2);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if( num > 0 && num <= ARRAYLENGTH(equip) )
i = pc_checkequip(sd,equip[num-1]);
if( i >= 0 && sd->inventory_data[i] && !sd->inventory_data[i]->flag.no_refine && !sd->status.inventory[i].expire_time )
script_pushint(st,1);
else
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -7565,24 +7307,24 @@ BUILDIN_FUNC(getequipisenableref)
* 1 : true
* 0 : false
*------------------------------------------*/
-BUILDIN_FUNC(getequipisidentify)
+BUILDIN(getequipisidentify)
{
int i = -1,num;
TBL_PC *sd;
-
+
num = script_getnum(st,2);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
if(i >= 0)
script_pushint(st,sd->status.inventory[i].identify);
else
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -7591,24 +7333,24 @@ BUILDIN_FUNC(getequipisidentify)
* x : refine amount
* 0 : false (not refined)
*------------------------------------------*/
-BUILDIN_FUNC(getequiprefinerycnt)
+BUILDIN(getequiprefinerycnt)
{
int i = -1,num;
TBL_PC *sd;
-
+
num = script_getnum(st,2);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
if(i >= 0)
script_pushint(st,sd->status.inventory[i].refine);
else
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -7618,24 +7360,24 @@ BUILDIN_FUNC(getequiprefinerycnt)
* x : weapon level
* 0 : false
*------------------------------------------*/
-BUILDIN_FUNC(getequipweaponlv)
+BUILDIN(getequipweaponlv)
{
int i = -1,num;
TBL_PC *sd;
-
+
num = script_getnum(st,2);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
if(i >= 0 && sd->inventory_data[i])
script_pushint(st,sd->inventory_data[i]->wlv);
else
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -7644,63 +7386,63 @@ BUILDIN_FUNC(getequipweaponlv)
* x : refine chance
* 0 : false (max refine level or unequip..)
*------------------------------------------*/
-BUILDIN_FUNC(getequippercentrefinery)
+BUILDIN(getequippercentrefinery)
{
int i = -1,num;
TBL_PC *sd;
-
+
num = script_getnum(st,2);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
if(i >= 0 && sd->status.inventory[i].nameid && sd->status.inventory[i].refine < MAX_REFINE)
script_pushint(st,status_get_refine_chance(itemdb_wlv(sd->status.inventory[i].nameid), (int)sd->status.inventory[i].refine));
else
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
/*==========================================
* Refine +1 item at pos and log and display refine
*------------------------------------------*/
-BUILDIN_FUNC(successrefitem)
+BUILDIN(successrefitem)
{
int i=-1,num,ep;
TBL_PC *sd;
-
+
num = script_getnum(st,2);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
if(i >= 0) {
ep=sd->status.inventory[i].equip;
-
+
//Logs items, got from (N)PC scripts [Lupus]
- log_pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i]);
-
+ logs->pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i],sd->inventory_data[i]);
+
sd->status.inventory[i].refine++;
pc_unequipitem(sd,i,2); // status calc will happen in pc_equipitem() below
-
+
clif->refine(sd->fd,0,i,sd->status.inventory[i].refine);
clif->delitem(sd,i,1,3);
-
+
//Logs items, got from (N)PC scripts [Lupus]
- log_pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i]);
-
+ logs->pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i],sd->inventory_data[i]);
+
clif->additem(sd,i,1,0);
pc_equipitem(sd,i,ep);
clif->misceffect(&sd->bl,3);
if(sd->status.inventory[i].refine == MAX_REFINE &&
- sd->status.inventory[i].card[0] == CARD0_FORGE &&
- sd->status.char_id == (int)MakeDWord(sd->status.inventory[i].card[2],sd->status.inventory[i].card[3])
- ){ // Fame point system [DracoRPG]
+ sd->status.inventory[i].card[0] == CARD0_FORGE &&
+ sd->status.char_id == (int)MakeDWord(sd->status.inventory[i].card[2],sd->status.inventory[i].card[3])
+ ){ // Fame point system [DracoRPG]
switch (sd->inventory_data[i]->wlv){
case 1:
pc_addfame(sd,1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point
@@ -7711,113 +7453,136 @@ BUILDIN_FUNC(successrefitem)
case 3:
pc_addfame(sd,1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point
break;
- }
+ }
}
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Show a failed Refine +1 attempt
*------------------------------------------*/
-BUILDIN_FUNC(failedrefitem)
+BUILDIN(failedrefitem)
{
int i=-1,num;
TBL_PC *sd;
-
+
num = script_getnum(st,2);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
if(i >= 0) {
sd->status.inventory[i].refine = 0;
pc_unequipitem(sd,i,3); //recalculate bonus
clif->refine(sd->fd,1,i,sd->status.inventory[i].refine); //notify client of failure
-
+
pc_delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
-
+
clif->misceffect(&sd->bl,2); // display failure effect
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Downgrades an Equipment Part by -1 . [Masao]
*------------------------------------------*/
-BUILDIN_FUNC(downrefitem)
+BUILDIN(downrefitem)
{
int i = -1,num,ep;
TBL_PC *sd;
-
+
num = script_getnum(st,2);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i = pc_checkequip(sd,equip[num-1]);
if(i >= 0) {
ep = sd->status.inventory[i].equip;
-
+
//Logs items, got from (N)PC scripts [Lupus]
- log_pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i]);
-
+ logs->pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i],sd->inventory_data[i]);
+
sd->status.inventory[i].refine++;
pc_unequipitem(sd,i,2); // status calc will happen in pc_equipitem() below
-
+
clif->refine(sd->fd,2,i,sd->status.inventory[i].refine = sd->status.inventory[i].refine - 2);
clif->delitem(sd,i,1,3);
-
+
//Logs items, got from (N)PC scripts [Lupus]
- log_pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i]);
-
+ logs->pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i],sd->inventory_data[i]);
+
clif->additem(sd,i,1,0);
pc_equipitem(sd,i,ep);
clif->misceffect(&sd->bl,2);
}
+
+ return true;
+}
- return 0;
+/*==========================================
+ * Delete the item equipped at pos.
+ *------------------------------------------*/
+BUILDIN(delequip)
+{
+ int i=-1,num;
+ TBL_PC *sd;
+
+ num = script_getnum(st,2);
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return true;
+
+ if (num > 0 && num <= ARRAYLENGTH(equip))
+ i=pc_checkequip(sd,equip[num-1]);
+ if(i >= 0) {
+ pc_unequipitem(sd,i,3); //recalculate bonus
+ pc_delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ }
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(statusup)
+BUILDIN(statusup)
{
int type;
TBL_PC *sd;
-
+
type=script_getnum(st,2);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
pc_statusup(sd,type);
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(statusup2)
+BUILDIN(statusup2)
{
int type,val;
TBL_PC *sd;
-
+
type=script_getnum(st,2);
val=script_getnum(st,3);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
pc_statusup2(sd,type,val);
-
- return 0;
+
+ return true;
}
/// See 'doc/item_bonus.txt'
@@ -7827,7 +7592,7 @@ BUILDIN_FUNC(statusup2)
/// bonus3 <bonus type>,<val1>,<val2>,<val3>;
/// bonus4 <bonus type>,<val1>,<val2>,<val3>,<val4>;
/// bonus5 <bonus type>,<val1>,<val2>,<val3>,<val4>,<val5>;
-BUILDIN_FUNC(bonus)
+BUILDIN(bonus)
{
int type;
int val1;
@@ -7836,11 +7601,11 @@ BUILDIN_FUNC(bonus)
int val4 = 0;
int val5 = 0;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0; // no player attached
-
+ return true; // no player attached
+
type = script_getnum(st,2);
switch( type ) {
case SP_AUTOSPELL:
@@ -7866,7 +7631,7 @@ BUILDIN_FUNC(bonus)
val1 = script_getnum(st,3);
break;
}
-
+
switch( script_lastdata(st)-2 ) {
case 1:
pc_bonus(sd, type, val1);
@@ -7885,7 +7650,7 @@ BUILDIN_FUNC(bonus)
val2 = skill->name2id(script_getstr(st,4)); // 2nd value can be skill name
else
val2 = script_getnum(st,4);
-
+
val3 = script_getnum(st,5);
val4 = script_getnum(st,6);
pc_bonus4(sd, type, val1, val2, val3, val4);
@@ -7895,7 +7660,7 @@ BUILDIN_FUNC(bonus)
val2 = skill->name2id(script_getstr(st,4)); // 2nd value can be skill name
else
val2 = script_getnum(st,4);
-
+
val3 = script_getnum(st,5);
val4 = script_getnum(st,6);
val5 = script_getnum(st,7);
@@ -7905,117 +7670,117 @@ BUILDIN_FUNC(bonus)
ShowDebug("buildin_bonus: unexpected number of arguments (%d)\n", (script_lastdata(st) - 1));
break;
}
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(autobonus)
+BUILDIN(autobonus)
{
unsigned int dur;
short rate;
short atk_type = 0;
TBL_PC* sd;
const char *bonus_script, *other_script = NULL;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0; // no player attached
-
+ return true; // no player attached
+
if( sd->state.autobonus&sd->status.inventory[current_equip_item_index].equip )
- return 0;
-
+ return true;
+
rate = script_getnum(st,3);
dur = script_getnum(st,4);
bonus_script = script_getstr(st,2);
if( !rate || !dur || !bonus_script )
- return 0;
-
+ return true;
+
if( script_hasdata(st,5) )
atk_type = script_getnum(st,5);
if( script_hasdata(st,6) )
other_script = script_getstr(st,6);
-
+
if( pc_addautobonus(sd->autobonus,ARRAYLENGTH(sd->autobonus),
- bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,false) )
+ bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,false) )
{
script_add_autobonus(bonus_script);
if( other_script )
script_add_autobonus(other_script);
}
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(autobonus2)
+BUILDIN(autobonus2)
{
unsigned int dur;
short rate;
short atk_type = 0;
TBL_PC* sd;
const char *bonus_script, *other_script = NULL;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0; // no player attached
-
+ return true; // no player attached
+
if( sd->state.autobonus&sd->status.inventory[current_equip_item_index].equip )
- return 0;
-
+ return true;
+
rate = script_getnum(st,3);
dur = script_getnum(st,4);
bonus_script = script_getstr(st,2);
if( !rate || !dur || !bonus_script )
- return 0;
-
+ return true;
+
if( script_hasdata(st,5) )
atk_type = script_getnum(st,5);
if( script_hasdata(st,6) )
other_script = script_getstr(st,6);
-
+
if( pc_addautobonus(sd->autobonus2,ARRAYLENGTH(sd->autobonus2),
- bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,false) )
+ bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,false) )
{
script_add_autobonus(bonus_script);
if( other_script )
script_add_autobonus(other_script);
}
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(autobonus3)
+BUILDIN(autobonus3)
{
unsigned int dur;
short rate,atk_type;
TBL_PC* sd;
const char *bonus_script, *other_script = NULL;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0; // no player attached
-
+ return true; // no player attached
+
if( sd->state.autobonus&sd->status.inventory[current_equip_item_index].equip )
- return 0;
-
+ return true;
+
rate = script_getnum(st,3);
dur = script_getnum(st,4);
atk_type = ( script_isstring(st,5) ? skill->name2id(script_getstr(st,5)) : script_getnum(st,5) );
bonus_script = script_getstr(st,2);
if( !rate || !dur || !atk_type || !bonus_script )
- return 0;
-
+ return true;
+
if( script_hasdata(st,6) )
other_script = script_getstr(st,6);
-
+
if( pc_addautobonus(sd->autobonus3,ARRAYLENGTH(sd->autobonus3),
- bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,true) )
+ bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,true) )
{
script_add_autobonus(bonus_script);
if( other_script )
script_add_autobonus(other_script);
}
-
- return 0;
+
+ return true;
}
/// Changes the level of a player skill.
@@ -8028,24 +7793,24 @@ BUILDIN_FUNC(autobonus3)
/// skill <skill id>,<level>
/// skill "<skill name>",<level>,<flag>
/// skill "<skill name>",<level>
-BUILDIN_FUNC(skill)
+BUILDIN(skill)
{
int id;
int level;
int flag = 1;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
id = ( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
level = script_getnum(st,3);
if( script_hasdata(st,4) )
flag = script_getnum(st,4);
pc_skill(sd, id, level, flag);
-
- return 0;
+
+ return true;
}
/// Changes the level of a player skill.
@@ -8057,78 +7822,78 @@ BUILDIN_FUNC(skill)
/// addtoskill "<skill name>",<amount>
///
/// @see skill
-BUILDIN_FUNC(addtoskill)
+BUILDIN(addtoskill)
{
int id;
int level;
int flag = 2;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
id = ( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
level = script_getnum(st,3);
if( script_hasdata(st,4) )
flag = script_getnum(st,4);
pc_skill(sd, id, level, flag);
-
- return 0;
+
+ return true;
}
/// Increases the level of a guild skill.
///
/// guildskill <skill id>,<amount>;
/// guildskill "<skill name>",<amount>;
-BUILDIN_FUNC(guildskill)
+BUILDIN(guildskill)
{
int id;
int level;
TBL_PC* sd;
int i;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
id = ( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
level = script_getnum(st,3);
for( i=0; i < level; i++ )
guild_skillup(sd, id);
-
- return 0;
+
+ return true;
}
/// Returns the level of the player skill.
///
/// getskilllv(<skill id>) -> <level>
/// getskilllv("<skill name>") -> <level>
-BUILDIN_FUNC(getskilllv)
+BUILDIN(getskilllv)
{
int id;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
id = ( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
script_pushint(st, pc_checkskill(sd,id));
-
- return 0;
+
+ return true;
}
/// Returns the level of the guild skill.
///
/// getgdskilllv(<guild id>,<skill id>) -> <level>
/// getgdskilllv(<guild id>,"<skill name>") -> <level>
-BUILDIN_FUNC(getgdskilllv)
+BUILDIN(getgdskilllv)
{
int guild_id;
uint16 skill_id;
struct guild* g;
-
+
guild_id = script_getnum(st,2);
skill_id = ( script_isstring(st,3) ? skill->name2id(script_getstr(st,3)) : script_getnum(st,3) );
g = guild_search(guild_id);
@@ -8136,8 +7901,8 @@ BUILDIN_FUNC(getgdskilllv)
script_pushint(st, -1);
else
script_pushint(st, guild_checkskill(g,skill_id));
-
- return 0;
+
+ return true;
}
/// Returns the 'basic_skill_check' setting.
@@ -8145,113 +7910,113 @@ BUILDIN_FUNC(getgdskilllv)
/// before allowing the basic actions.
///
/// basicskillcheck() -> <bool>
-BUILDIN_FUNC(basicskillcheck)
+BUILDIN(basicskillcheck)
{
script_pushint(st, battle_config.basic_skill_check);
- return 0;
+ return true;
}
/// Returns the GM level of the player.
///
/// getgmlevel() -> <level>
-BUILDIN_FUNC(getgmlevel)
+BUILDIN(getgmlevel)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
script_pushint(st, pc_get_group_level(sd));
-
- return 0;
+
+ return true;
}
/// Returns the group ID of the player.
///
/// getgroupid() -> <int>
-BUILDIN_FUNC(getgroupid)
+BUILDIN(getgroupid)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if (sd == NULL)
- return 1; // no player attached, report source
+ return false; // no player attached, report source
script_pushint(st, pc_get_group_id(sd));
-
- return 0;
+
+ return true;
}
/// Terminates the execution of this script instance.
///
/// end
-BUILDIN_FUNC(end)
+BUILDIN(end)
{
st->state = END;
- return 0;
+ return true;
}
/// Checks if the player has that effect state (option).
///
/// checkoption(<option>) -> <bool>
-BUILDIN_FUNC(checkoption)
+BUILDIN(checkoption)
{
int option;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
option = script_getnum(st,2);
if( sd->sc.option&option )
script_pushint(st, 1);
else
script_pushint(st, 0);
-
- return 0;
+
+ return true;
}
/// Checks if the player is in that body state (opt1).
///
/// checkoption1(<opt1>) -> <bool>
-BUILDIN_FUNC(checkoption1)
+BUILDIN(checkoption1)
{
int opt1;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
opt1 = script_getnum(st,2);
if( sd->sc.opt1 == opt1 )
script_pushint(st, 1);
else
script_pushint(st, 0);
-
- return 0;
+
+ return true;
}
/// Checks if the player has that health state (opt2).
///
/// checkoption2(<opt2>) -> <bool>
-BUILDIN_FUNC(checkoption2)
+BUILDIN(checkoption2)
{
int opt2;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
opt2 = script_getnum(st,2);
if( sd->sc.opt2&opt2 )
script_pushint(st, 1);
else
script_pushint(st, 0);
-
- return 0;
+
+ return true;
}
/// Changes the effect state (option) of the player.
@@ -8261,16 +8026,16 @@ BUILDIN_FUNC(checkoption2)
///
/// setoption <option>,<flag>;
/// setoption <option>;
-BUILDIN_FUNC(setoption)
+BUILDIN(setoption)
{
int option;
int flag = 1;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
option = script_getnum(st,2);
if( script_hasdata(st,3) )
flag = script_getnum(st,3);
@@ -8287,8 +8052,8 @@ BUILDIN_FUNC(setoption)
pc_setoption(sd, sd->sc.option|option);
} else// Remove option
pc_setoption(sd, sd->sc.option&~option);
-
- return 0;
+
+ return true;
}
/// Returns if the player has a cart.
@@ -8296,20 +8061,20 @@ BUILDIN_FUNC(setoption)
/// checkcart() -> <bool>
///
/// @author Valaris
-BUILDIN_FUNC(checkcart)
+BUILDIN(checkcart)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
if( pc_iscarton(sd) )
script_pushint(st, 1);
else
script_pushint(st, 0);
-
- return 0;
+
+ return true;
}
/// Sets the cart of the player.
@@ -8323,20 +8088,20 @@ BUILDIN_FUNC(checkcart)
///
/// setcart <type>;
/// setcart;
-BUILDIN_FUNC(setcart)
+BUILDIN(setcart)
{
int type = 1;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
if( script_hasdata(st,2) )
type = script_getnum(st,2);
pc_setcart(sd, type);
-
- return 0;
+
+ return true;
}
/// Returns if the player has a falcon.
@@ -8344,20 +8109,20 @@ BUILDIN_FUNC(setcart)
/// checkfalcon() -> <bool>
///
/// @author Valaris
-BUILDIN_FUNC(checkfalcon)
+BUILDIN(checkfalcon)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
if( pc_isfalcon(sd) )
script_pushint(st, 1);
else
script_pushint(st, 0);
-
- return 0;
+
+ return true;
}
/// Sets if the player has a falcon or not.
@@ -8365,21 +8130,21 @@ BUILDIN_FUNC(checkfalcon)
///
/// setfalcon <flag>;
/// setfalcon;
-BUILDIN_FUNC(setfalcon)
+BUILDIN(setfalcon)
{
int flag = 1;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
if( script_hasdata(st,2) )
flag = script_getnum(st,2);
-
+
pc_setfalcon(sd, flag);
-
- return 0;
+
+ return true;
}
/// Returns if the player is riding.
@@ -8387,20 +8152,20 @@ BUILDIN_FUNC(setfalcon)
/// checkriding() -> <bool>
///
/// @author Valaris
-BUILDIN_FUNC(checkriding)
+BUILDIN(checkriding)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
if( pc_isriding(sd) || pc_isridingwug(sd) || pc_isridingdragon(sd) )
script_pushint(st, 1);
else
script_pushint(st, 0);
-
- return 0;
+
+ return true;
}
/// Sets if the player is riding.
@@ -8408,60 +8173,60 @@ BUILDIN_FUNC(checkriding)
///
/// setriding <flag>;
/// setriding;
-BUILDIN_FUNC(setriding)
+BUILDIN(setriding)
{
int flag = 1;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
if( script_hasdata(st,2) )
flag = script_getnum(st,2);
pc_setriding(sd, flag);
-
- return 0;
+
+ return true;
}
/// Returns if the player has a warg.
///
/// checkwug() -> <bool>
///
-BUILDIN_FUNC(checkwug)
+BUILDIN(checkwug)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
if( pc_iswug(sd) || pc_isridingwug(sd) )
script_pushint(st, 1);
else
script_pushint(st, 0);
-
- return 0;
+
+ return true;
}
/// Returns if the player is wearing MADO Gear.
///
/// checkmadogear() -> <bool>
///
-BUILDIN_FUNC(checkmadogear)
+BUILDIN(checkmadogear)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
if( pc_ismadogear(sd) )
script_pushint(st, 1);
else
script_pushint(st, 0);
-
- return 0;
+
+ return true;
}
/// Sets if the player is riding MADO Gear.
@@ -8469,78 +8234,78 @@ BUILDIN_FUNC(checkmadogear)
///
/// setmadogear <flag>;
/// setmadogear;
-BUILDIN_FUNC(setmadogear)
+BUILDIN(setmadogear)
{
int flag = 1;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
if( script_hasdata(st,2) )
flag = script_getnum(st,2);
pc_setmadogear(sd, flag);
-
- return 0;
+
+ return true;
}
/// Sets the save point of the player.
///
/// save "<map name>",<x>,<y>
/// savepoint "<map name>",<x>,<y>
-BUILDIN_FUNC(savepoint)
+BUILDIN(savepoint)
{
int x;
int y;
short map;
const char* str;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached, report source
-
+ return true;// no player attached, report source
+
str = script_getstr(st, 2);
x = script_getnum(st,3);
y = script_getnum(st,4);
map = mapindex_name2id(str);
if( map )
pc_setsavepoint(sd, map, x, y);
-
- return 0;
+
+ return true;
}
/*==========================================
* GetTimeTick(0: System Tick, 1: Time Second Tick)
*------------------------------------------*/
-BUILDIN_FUNC(gettimetick) /* Asgard Version */
+BUILDIN(gettimetick) /* Asgard Version */
{
int type;
time_t timer;
struct tm *t;
-
+
type=script_getnum(st,2);
-
+
switch(type){
- case 2:
- //type 2:(Get the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC
- // from the system clock.)
- script_pushint(st,(int)time(NULL));
- break;
- case 1:
- //type 1:(Second Ticks: 0-86399, 00:00:00-23:59:59)
- time(&timer);
- t=localtime(&timer);
- script_pushint(st,((t->tm_hour)*3600+(t->tm_min)*60+t->tm_sec));
- break;
- case 0:
- default:
- //type 0:(System Ticks)
- script_pushint(st,gettick());
- break;
+ case 2:
+ //type 2:(Get the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC
+ // from the system clock.)
+ script_pushint(st,(int)time(NULL));
+ break;
+ case 1:
+ //type 1:(Second Ticks: 0-86399, 00:00:00-23:59:59)
+ time(&timer);
+ t=localtime(&timer);
+ script_pushint(st,((t->tm_hour)*3600+(t->tm_min)*60+t->tm_sec));
+ break;
+ case 0:
+ default:
+ //type 0:(System Ticks)
+ script_pushint(st,gettick());
+ break;
}
- return 0;
+ return true;
}
/*==========================================
@@ -8549,97 +8314,97 @@ BUILDIN_FUNC(gettimetick) /* Asgard Version */
* 4: WeekDay 5: MonthDay 6: Month
* 7: Year
*------------------------------------------*/
-BUILDIN_FUNC(gettime) /* Asgard Version */
+BUILDIN(gettime) /* Asgard Version */
{
int type;
time_t timer;
struct tm *t;
-
+
type=script_getnum(st,2);
-
+
time(&timer);
t=localtime(&timer);
-
+
switch(type){
- case 1://Sec(0~59)
- script_pushint(st,t->tm_sec);
- break;
- case 2://Min(0~59)
- script_pushint(st,t->tm_min);
- break;
- case 3://Hour(0~23)
- script_pushint(st,t->tm_hour);
- break;
- case 4://WeekDay(0~6)
- script_pushint(st,t->tm_wday);
- break;
- case 5://MonthDay(01~31)
- script_pushint(st,t->tm_mday);
- break;
- case 6://Month(01~12)
- script_pushint(st,t->tm_mon+1);
- break;
- case 7://Year(20xx)
- script_pushint(st,t->tm_year+1900);
- break;
- case 8://Year Day(01~366)
- script_pushint(st,t->tm_yday+1);
- break;
- default://(format error)
- script_pushint(st,-1);
- break;
+ case 1://Sec(0~59)
+ script_pushint(st,t->tm_sec);
+ break;
+ case 2://Min(0~59)
+ script_pushint(st,t->tm_min);
+ break;
+ case 3://Hour(0~23)
+ script_pushint(st,t->tm_hour);
+ break;
+ case 4://WeekDay(0~6)
+ script_pushint(st,t->tm_wday);
+ break;
+ case 5://MonthDay(01~31)
+ script_pushint(st,t->tm_mday);
+ break;
+ case 6://Month(01~12)
+ script_pushint(st,t->tm_mon+1);
+ break;
+ case 7://Year(20xx)
+ script_pushint(st,t->tm_year+1900);
+ break;
+ case 8://Year Day(01~366)
+ script_pushint(st,t->tm_yday+1);
+ break;
+ default://(format error)
+ script_pushint(st,-1);
+ break;
}
- return 0;
+ return true;
}
/*==========================================
* GetTimeStr("TimeFMT", Length);
*------------------------------------------*/
-BUILDIN_FUNC(gettimestr)
+BUILDIN(gettimestr)
{
char *tmpstr;
const char *fmtstr;
int maxlen;
time_t now = time(NULL);
-
+
fmtstr=script_getstr(st,2);
maxlen=script_getnum(st,3);
-
+
tmpstr=(char *)aMalloc((maxlen+1)*sizeof(char));
strftime(tmpstr,maxlen,fmtstr,localtime(&now));
tmpstr[maxlen]='\0';
-
+
script_pushstr(st,tmpstr);
- return 0;
+ return true;
}
/*==========================================
* Open player storage
*------------------------------------------*/
-BUILDIN_FUNC(openstorage)
+BUILDIN(openstorage)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
storage_storageopen(sd);
- return 0;
+ return true;
}
-BUILDIN_FUNC(guildopenstorage)
+BUILDIN(guildopenstorage)
{
TBL_PC* sd;
int ret;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
ret = storage_guild_storageopen(sd);
script_pushint(st,ret);
- return 0;
+ return true;
}
/*==========================================
@@ -8647,152 +8412,152 @@ BUILDIN_FUNC(guildopenstorage)
*------------------------------------------*/
/// itemskill <skill id>,<level>
/// itemskill "<skill name>",<level>
-BUILDIN_FUNC(itemskill)
+BUILDIN(itemskill)
{
int id;
int lv;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL || sd->ud.skilltimer != INVALID_TIMER )
- return 0;
-
+ return true;
+
id = ( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
lv = script_getnum(st,3);
-
+
sd->skillitem=id;
sd->skillitemlv=lv;
clif->item_skill(sd,id,lv);
- return 0;
+ return true;
}
/*==========================================
* Attempt to create an item
*------------------------------------------*/
-BUILDIN_FUNC(produce)
+BUILDIN(produce)
{
int trigger;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
trigger=script_getnum(st,2);
clif->skill_produce_mix_list(sd, -1, trigger);
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(cooking)
+BUILDIN(cooking)
{
int trigger;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
trigger=script_getnum(st,2);
clif->cooking_list(sd, trigger, AM_PHARMACY, 1, 1);
- return 0;
+ return true;
}
/*==========================================
* Create a pet
*------------------------------------------*/
-BUILDIN_FUNC(makepet)
+BUILDIN(makepet)
{
TBL_PC* sd;
int id,pet_id;
-
+
id=script_getnum(st,2);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
pet_id = search_petDB_index(id, PET_CLASS);
-
+
if (pet_id < 0)
pet_id = search_petDB_index(id, PET_EGG);
if (pet_id >= 0 && sd) {
sd->catch_target_class = pet_db[pet_id].class_;
intif_create_pet(
- sd->status.account_id, sd->status.char_id,
- (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
- (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
- 100, 0, 1, pet_db[pet_id].jname);
+ sd->status.account_id, sd->status.char_id,
+ (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
+ (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
+ 100, 0, 1, pet_db[pet_id].jname);
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Give player exp base,job * quest_exp_rate/100
*------------------------------------------*/
-BUILDIN_FUNC(getexp)
+BUILDIN(getexp)
{
TBL_PC* sd;
int base=0,job=0;
double bonus;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
base=script_getnum(st,2);
job =script_getnum(st,3);
if(base<0 || job<0)
- return 0;
-
+ return true;
+
// bonus for npc-given exp
bonus = battle_config.quest_exp_rate / 100.;
base = (int) cap_value(base * bonus, 0, INT_MAX);
job = (int) cap_value(job * bonus, 0, INT_MAX);
-
+
pc_gainexp(sd, NULL, base, job, true);
-
- return 0;
+
+ return true;
}
/*==========================================
* Gain guild exp [Celest]
*------------------------------------------*/
-BUILDIN_FUNC(guildgetexp)
+BUILDIN(guildgetexp)
{
TBL_PC* sd;
int exp;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
exp = script_getnum(st,2);
if(exp < 0)
- return 0;
+ return true;
if(sd && sd->status.guild_id > 0)
guild_getexp (sd, exp);
-
- return 0;
+
+ return true;
}
/*==========================================
* Changes the guild master of a guild [Skotlex]
*------------------------------------------*/
-BUILDIN_FUNC(guildchangegm)
+BUILDIN(guildchangegm)
{
TBL_PC *sd;
int guild_id;
const char *name;
-
+
guild_id = script_getnum(st,2);
name = script_getstr(st,3);
sd=map_nick2sd(name);
-
+
if (!sd)
script_pushint(st,0);
else
script_pushint(st,guild_gm_change(guild_id, sd));
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -8803,7 +8568,7 @@ BUILDIN_FUNC(guildchangegm)
@amount : nb to spawn
@event : event to attach to mob
*------------------------------------------*/
-BUILDIN_FUNC(monster)
+BUILDIN(monster)
{
const char* mapn = script_getstr(st,2);
int x = script_getnum(st,3);
@@ -8814,44 +8579,44 @@ BUILDIN_FUNC(monster)
const char* event = "";
unsigned int size = SZ_SMALL;
unsigned int ai = AI_NONE;
-
+
struct map_session_data* sd;
int16 m;
-
+
if (script_hasdata(st, 8))
{
event = script_getstr(st, 8);
check_event(st, event);
}
-
+
if (script_hasdata(st, 9))
{
size = script_getnum(st, 9);
if (size > 3)
{
ShowWarning("buildin_monster: Attempted to spawn non-existing size %d for monster class %d\n", size, class_);
- return 1;
+ return false;
}
}
-
+
if (script_hasdata(st, 10))
{
ai = script_getnum(st, 10);
if (ai > 4)
{
ShowWarning("buildin_monster: Attempted to spawn non-existing ai %d for monster class %d\n", ai, class_);
- return 1;
+ return false;
}
}
-
+
if (class_ >= 0 && !mobdb_checkid(class_))
{
ShowWarning("buildin_monster: Attempted to spawn non-existing monster class %d\n", class_);
- return 1;
+ return false;
}
-
+
sd = map_id2sd(st->rid);
-
+
if (sd && strcmp(mapn, "this") == 0)
m = sd->bl.m;
else
@@ -8862,53 +8627,53 @@ BUILDIN_FUNC(monster)
if ((m = instance_mapid2imapid(m, st->instance_id)) < 0)
{
ShowError("buildin_monster: Trying to spawn monster (%d) on instance map (%s) without instance attached.\n", class_, mapn);
- return 1;
+ return false;
}
}
}
-
+
mob_once_spawn(sd, m, x, y, str, class_, amount, event, size, ai);
- return 0;
+ return true;
}
/*==========================================
* Request List of Monster Drops
*------------------------------------------*/
-BUILDIN_FUNC(getmobdrops)
+BUILDIN(getmobdrops)
{
int class_ = script_getnum(st,2);
int i, j = 0;
struct mob_db *mob;
-
+
if( !mobdb_checkid(class_) )
{
script_pushint(st, 0);
- return 0;
+ return true;
}
-
+
mob = mob_db(class_);
-
+
for( i = 0; i < MAX_MOB_DROP; i++ )
{
if( mob->dropitem[i].nameid < 1 )
continue;
if( itemdb_exists(mob->dropitem[i].nameid) == NULL )
continue;
-
+
mapreg_setreg(reference_uid(add_str("$@MobDrop_item"), j), mob->dropitem[i].nameid);
mapreg_setreg(reference_uid(add_str("$@MobDrop_rate"), j), mob->dropitem[i].p);
-
+
j++;
}
-
+
mapreg_setreg(add_str("$@MobDrop_count"), j);
script_pushint(st, 1);
-
- return 0;
+
+ return true;
}
/*==========================================
* Same as monster but randomize location in x0,x1,y0,y1 area
*------------------------------------------*/
-BUILDIN_FUNC(areamonster)
+BUILDIN(areamonster)
{
const char* mapn = script_getstr(st,2);
int x0 = script_getnum(st,3);
@@ -8921,38 +8686,38 @@ BUILDIN_FUNC(areamonster)
const char* event = "";
unsigned int size = SZ_SMALL;
unsigned int ai = AI_NONE;
-
+
struct map_session_data* sd;
int16 m;
-
+
if (script_hasdata(st,10))
{
event = script_getstr(st, 10);
check_event(st, event);
}
-
+
if (script_hasdata(st, 11))
{
size = script_getnum(st, 11);
if (size > 3)
{
ShowWarning("buildin_monster: Attempted to spawn non-existing size %d for monster class %d\n", size, class_);
- return 1;
+ return false;
}
}
-
+
if (script_hasdata(st, 12))
{
ai = script_getnum(st, 12);
if (ai > 4)
{
ShowWarning("buildin_monster: Attempted to spawn non-existing ai %d for monster class %d\n", ai, class_);
- return 1;
+ return false;
}
}
-
+
sd = map_id2sd(st->rid);
-
+
if (sd && strcmp(mapn, "this") == 0)
m = sd->bl.m;
else
@@ -8963,25 +8728,25 @@ BUILDIN_FUNC(areamonster)
if ((m = instance_mapid2imapid(m, st->instance_id)) < 0)
{
ShowError("buildin_areamonster: Trying to spawn monster (%d) on instance map (%s) without instance attached.\n", class_, mapn);
- return 1;
+ return false;
}
}
}
-
+
mob_once_spawn_area(sd, m, x0, y0, x1, y1, str, class_, amount, event, size, ai);
- return 0;
+ return true;
}
/*==========================================
* KillMonster subcheck, verify if mob to kill ain't got an even to handle, could be force kill by allflag
*------------------------------------------*/
- static int buildin_killmonster_sub_strip(struct block_list *bl,va_list ap)
+static int buildin_killmonster_sub_strip(struct block_list *bl,va_list ap)
{ //same fix but with killmonster instead - stripping events from mobs.
TBL_MOB* md = (TBL_MOB*)bl;
char *event=va_arg(ap,char *);
int allflag=va_arg(ap,int);
-
+
md->state.npc_killmonster = 1;
-
+
if(!allflag){
if(strcmp(event,md->npc_event)==0)
status_kill(bl);
@@ -8997,7 +8762,7 @@ static int buildin_killmonster_sub(struct block_list *bl,va_list ap)
TBL_MOB* md = (TBL_MOB*)bl;
char *event=va_arg(ap,char *);
int allflag=va_arg(ap,int);
-
+
if(!allflag){
if(strcmp(event,md->npc_event)==0)
status_kill(bl);
@@ -9007,7 +8772,7 @@ static int buildin_killmonster_sub(struct block_list *bl,va_list ap)
}
return 0;
}
-BUILDIN_FUNC(killmonster)
+BUILDIN(killmonster)
{
const char *mapname,*event;
int16 m,allflag=0;
@@ -9017,34 +8782,34 @@ BUILDIN_FUNC(killmonster)
allflag = 1;
else
check_event(st, event);
-
+
if( (m=map_mapname2mapid(mapname))<0 )
- return 0;
-
+ return true;
+
if( map[m].flag.src4instance && st->instance_id && (m = instance_mapid2imapid(m, st->instance_id)) < 0 )
- return 0;
-
+ return true;
+
if( script_hasdata(st,4) ) {
if ( script_getnum(st,4) == 1 ) {
map_foreachinmap(buildin_killmonster_sub, m, BL_MOB, event ,allflag);
- return 0;
+ return true;
}
}
-
+
map_freeblock_lock();
map_foreachinmap(buildin_killmonster_sub_strip, m, BL_MOB, event ,allflag);
map_freeblock_unlock();
- return 0;
+ return true;
}
static int buildin_killmonsterall_sub_strip(struct block_list *bl,va_list ap)
{ //Strips the event from the mob if it's killed the old method.
struct mob_data *md;
-
+
md = BL_CAST(BL_MOB, bl);
if (md->npc_event[0])
md->npc_event[0] = 0;
-
+
status_kill(bl);
return 0;
}
@@ -9053,65 +8818,65 @@ static int buildin_killmonsterall_sub(struct block_list *bl,va_list ap)
status_kill(bl);
return 0;
}
-BUILDIN_FUNC(killmonsterall)
+BUILDIN(killmonsterall)
{
const char *mapname;
int16 m;
mapname=script_getstr(st,2);
-
+
if( (m = map_mapname2mapid(mapname))<0 )
- return 0;
-
+ return true;
+
if( map[m].flag.src4instance && st->instance_id && (m = instance_mapid2imapid(m, st->instance_id)) < 0 )
- return 0;
-
+ return true;
+
if( script_hasdata(st,3) ) {
if ( script_getnum(st,3) == 1 ) {
map_foreachinmap(buildin_killmonsterall_sub,m,BL_MOB);
- return 0;
+ return true;
}
}
-
+
map_foreachinmap(buildin_killmonsterall_sub_strip,m,BL_MOB);
- return 0;
+ return true;
}
/*==========================================
* Creates a clone of a player.
* clone map, x, y, event, char_id, master_id, mode, flag, duration
*------------------------------------------*/
-BUILDIN_FUNC(clone)
+BUILDIN(clone)
{
TBL_PC *sd, *msd=NULL;
int char_id,master_id=0,x,y, mode = 0, flag = 0, m;
unsigned int duration = 0;
const char *map,*event="";
-
+
map=script_getstr(st,2);
x=script_getnum(st,3);
y=script_getnum(st,4);
event=script_getstr(st,5);
char_id=script_getnum(st,6);
-
+
if( script_hasdata(st,7) )
master_id=script_getnum(st,7);
-
+
if( script_hasdata(st,8) )
mode=script_getnum(st,8);
-
+
if( script_hasdata(st,9) )
flag=script_getnum(st,9);
-
+
if( script_hasdata(st,10) )
duration=script_getnum(st,10);
-
+
check_event(st, event);
-
+
m = map_mapname2mapid(map);
- if (m < 0) return 0;
-
+ if (m < 0) return true;
+
sd = map_charid2sd(char_id);
-
+
if (master_id) {
msd = map_charid2sd(master_id);
if (msd)
@@ -9123,28 +8888,28 @@ BUILDIN_FUNC(clone)
script_pushint(st,mob_clone_spawn(sd, m, x, y, event, master_id, mode, flag, 1000*duration));
else //Failed to create clone.
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(doevent)
+BUILDIN(doevent)
{
const char* event = script_getstr(st,2);
struct map_session_data* sd;
-
+
if( ( sd = script_rid2sd(st) ) == NULL )
{
- return 0;
+ return true;
}
-
+
check_event(st, event);
npc_event(sd, event, 0);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(donpcevent)
+BUILDIN(donpcevent)
{
const char* event = script_getstr(st,2);
check_event(st, event);
@@ -9154,12 +8919,12 @@ BUILDIN_FUNC(donpcevent)
script_pushint(st, 0);
} else
script_pushint(st, 1);
- return 0;
+ return true;
}
/// for Aegis compatibility
/// basically a specialized 'donpcevent', with the event specified as two arguments instead of one
-BUILDIN_FUNC(cmdothernpc) // Added by RoVeRT
+BUILDIN(cmdothernpc) // Added by RoVeRT
{
const char* npc = script_getstr(st,2);
const char* command = script_getstr(st,3);
@@ -9167,67 +8932,67 @@ BUILDIN_FUNC(cmdothernpc) // Added by RoVeRT
snprintf(event, sizeof(event), "%s::OnCommand%s", npc, command);
check_event(st, event);
npc_event_do(event);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(addtimer)
+BUILDIN(addtimer)
{
int tick = script_getnum(st,2);
const char* event = script_getstr(st, 3);
TBL_PC* sd;
-
+
check_event(st, event);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
pc_addeventtimer(sd,tick,event);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(deltimer)
+BUILDIN(deltimer)
{
const char *event;
TBL_PC* sd;
-
+
event=script_getstr(st, 2);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
check_event(st, event);
pc_deleventtimer(sd,event);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(addtimercount)
+BUILDIN(addtimercount)
{
const char *event;
int tick;
TBL_PC* sd;
-
+
event=script_getstr(st, 2);
tick=script_getnum(st,3);
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
check_event(st, event);
pc_addeventtimercount(sd,event,tick);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(initnpctimer)
+BUILDIN(initnpctimer)
{
struct npc_data *nd;
int flag = 0;
-
+
if( script_hasdata(st,3) )
{ //Two arguments: NPC name and attach flag.
nd = npc_name2id(script_getstr(st, 2));
@@ -9248,34 +9013,34 @@ BUILDIN_FUNC(initnpctimer)
else
{
ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n");
- return 1;
+ return false;
}
}
else
nd = (struct npc_data *)map_id2bl(st->oid);
-
+
if( !nd )
- return 0;
+ return true;
if( flag ) //Attach
{
TBL_PC* sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
+ return true;
nd->u.scr.rid = sd->bl.id;
}
-
+
nd->u.scr.timertick = 0;
npc_settimerevent_tick(nd,0);
npc_timerevent_start(nd, st->rid);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(startnpctimer)
+BUILDIN(startnpctimer)
{
struct npc_data *nd;
int flag = 0;
-
+
if( script_hasdata(st,3) )
{ //Two arguments: NPC name and attach flag.
nd = npc_name2id(script_getstr(st, 2));
@@ -9296,32 +9061,32 @@ BUILDIN_FUNC(startnpctimer)
else
{
ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n");
- return 1;
+ return false;
}
}
else
nd=(struct npc_data *)map_id2bl(st->oid);
-
+
if( !nd )
- return 0;
+ return true;
if( flag ) //Attach
{
TBL_PC* sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
+ return true;
nd->u.scr.rid = sd->bl.id;
}
-
+
npc_timerevent_start(nd, st->rid);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(stopnpctimer)
+BUILDIN(stopnpctimer)
{
struct npc_data *nd;
int flag = 0;
-
+
if( script_hasdata(st,3) )
{ //Two arguments: NPC name and attach flag.
nd = npc_name2id(script_getstr(st, 2));
@@ -9342,143 +9107,143 @@ BUILDIN_FUNC(stopnpctimer)
else
{
ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n");
- return 1;
+ return false;
}
}
else
nd=(struct npc_data *)map_id2bl(st->oid);
-
+
if( !nd )
- return 0;
+ return true;
if( flag ) //Detach
nd->u.scr.rid = 0;
-
+
npc_timerevent_stop(nd);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(getnpctimer)
+BUILDIN(getnpctimer)
{
struct npc_data *nd;
TBL_PC *sd;
int type = script_getnum(st,2);
int val = 0;
-
+
if( script_hasdata(st,3) )
nd = npc_name2id(script_getstr(st,3));
else
nd = (struct npc_data *)map_id2bl(st->oid);
-
+
if( !nd || nd->bl.type != BL_NPC )
{
script_pushint(st,0);
ShowError("getnpctimer: Invalid NPC.\n");
- return 1;
+ return false;
}
-
+
switch( type )
{
- case 0: val = npc_gettimerevent_tick(nd); break;
- case 1:
- if( nd->u.scr.rid )
- {
- sd = map_id2sd(nd->u.scr.rid);
- if( !sd )
+ case 0: val = npc_gettimerevent_tick(nd); break;
+ case 1:
+ if( nd->u.scr.rid )
{
- ShowError("buildin_getnpctimer: Attached player not found!\n");
- break;
+ sd = map_id2sd(nd->u.scr.rid);
+ if( !sd )
+ {
+ ShowError("buildin_getnpctimer: Attached player not found!\n");
+ break;
+ }
+ val = (sd->npc_timer_id != INVALID_TIMER);
}
- val = (sd->npc_timer_id != INVALID_TIMER);
- }
- else
- val = (nd->u.scr.timerid != INVALID_TIMER);
- break;
- case 2: val = nd->u.scr.timeramount; break;
+ else
+ val = (nd->u.scr.timerid != INVALID_TIMER);
+ break;
+ case 2: val = nd->u.scr.timeramount; break;
}
-
+
script_pushint(st,val);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(setnpctimer)
+BUILDIN(setnpctimer)
{
int tick;
struct npc_data *nd;
-
+
tick = script_getnum(st,2);
if( script_hasdata(st,3) )
nd = npc_name2id(script_getstr(st,3));
else
nd = (struct npc_data *)map_id2bl(st->oid);
-
+
if( !nd || nd->bl.type != BL_NPC )
{
script_pushint(st,1);
ShowError("setnpctimer: Invalid NPC.\n");
- return 1;
+ return false;
}
-
+
npc_settimerevent_tick(nd,tick);
script_pushint(st,0);
- return 0;
+ return true;
}
/*==========================================
* attaches the player rid to the timer [Celest]
*------------------------------------------*/
-BUILDIN_FUNC(attachnpctimer)
+BUILDIN(attachnpctimer)
{
TBL_PC *sd;
struct npc_data *nd = (struct npc_data *)map_id2bl(st->oid);
-
+
if( !nd || nd->bl.type != BL_NPC )
{
script_pushint(st,1);
ShowError("setnpctimer: Invalid NPC.\n");
- return 1;
+ return false;
}
-
+
if( script_hasdata(st,2) )
sd = map_nick2sd(script_getstr(st,2));
else
sd = script_rid2sd(st);
-
+
if( !sd )
{
script_pushint(st,1);
ShowWarning("attachnpctimer: Invalid player.\n");
- return 1;
+ return false;
}
-
+
nd->u.scr.rid = sd->bl.id;
script_pushint(st,0);
- return 0;
+ return true;
}
/*==========================================
* detaches a player rid from the timer [Celest]
*------------------------------------------*/
-BUILDIN_FUNC(detachnpctimer)
+BUILDIN(detachnpctimer)
{
struct npc_data *nd;
-
+
if( script_hasdata(st,2) )
nd = npc_name2id(script_getstr(st,2));
else
nd = (struct npc_data *)map_id2bl(st->oid);
-
+
if( !nd || nd->bl.type != BL_NPC )
{
script_pushint(st,1);
ShowError("detachnpctimer: Invalid NPC.\n");
- return 1;
+ return false;
}
-
+
nd->u.scr.rid = 0;
script_pushint(st,0);
- return 0;
+ return true;
}
/*==========================================
@@ -9486,18 +9251,18 @@ BUILDIN_FUNC(detachnpctimer)
* it checks if there is a player attached to the current script. [Skotlex]
* If no, returns 0, if yes, returns the account_id of the attached player.
*------------------------------------------*/
-BUILDIN_FUNC(playerattached)
+BUILDIN(playerattached)
{
if(st->rid == 0 || map_id2sd(st->rid) == NULL)
script_pushint(st,0);
else
script_pushint(st,st->rid);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(announce)
+BUILDIN(announce)
{
const char *mes = script_getstr(st,2);
int flag = script_getnum(st,3);
@@ -9506,19 +9271,19 @@ BUILDIN_FUNC(announce)
int fontSize = script_hasdata(st,6) ? script_getnum(st,6) : 12; // default fontSize
int fontAlign = script_hasdata(st,7) ? script_getnum(st,7) : 0; // default fontAlign
int fontY = script_hasdata(st,8) ? script_getnum(st,8) : 0; // default fontY
-
+
if (flag&0x0f) // Broadcast source or broadcast region defined
{
send_target target;
struct block_list *bl = (flag&0x08) ? map_id2bl(st->oid) : (struct block_list *)script_rid2sd(st); // If bc_npc flag is set, use NPC as broadcast source
if (bl == NULL)
- return 0;
-
+ return true;
+
flag &= 0x07;
target = (flag == 1) ? ALL_SAMEMAP :
- (flag == 2) ? AREA :
- (flag == 3) ? SELF :
- ALL_CLIENT;
+ (flag == 2) ? AREA :
+ (flag == 3) ? SELF :
+ ALL_CLIENT;
if (fontColor)
clif->broadcast2(bl, mes, (int)strlen(mes)+1, strtol(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY, target);
else
@@ -9531,7 +9296,7 @@ BUILDIN_FUNC(announce)
else
intif_broadcast(mes, (int)strlen(mes)+1, flag&0xf0);
}
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
@@ -9554,7 +9319,7 @@ static int buildin_announce_sub(struct block_list *bl, va_list ap)
/* Runs item effect on attached character.
* itemeffect <item id>;
* itemeffect "<item name>"; */
-BUILDIN_FUNC(itemeffect) {
+BUILDIN(itemeffect) {
TBL_NPC *nd;
TBL_PC *sd;
struct script_data *data;
@@ -9571,26 +9336,26 @@ BUILDIN_FUNC(itemeffect) {
if( ( item_data = itemdb_searchname( name ) ) == NULL ){
ShowError( "buildin_itemeffect: Nonexistant item %s requested.\n", name );
- return 1;
+ return false;
}
} else if( data_isint( data ) ){
int nameid = conv_num( st, data );
if( ( item_data = itemdb_exists( nameid ) ) == NULL ){
ShowError("buildin_itemeffect: Nonexistant item %d requested.\n", nameid );
- return 1;
+ return false;
}
} else {
ShowError("buildin_itemeffect: invalid data type for argument #1 (%d).", data->type );
- return 1;
+ return false;
}
run_script( item_data->script, 0, sd->bl.id, nd->bl.id );
- return 0;
+ return true;
}
-BUILDIN_FUNC(mapannounce)
+BUILDIN(mapannounce)
{
const char *mapname = script_getstr(st,2);
const char *mes = script_getstr(st,3);
@@ -9601,17 +9366,17 @@ BUILDIN_FUNC(mapannounce)
int fontAlign = script_hasdata(st,8) ? script_getnum(st,8) : 0; // default fontAlign
int fontY = script_hasdata(st,9) ? script_getnum(st,9) : 0; // default fontY
int16 m;
-
+
if ((m = map_mapname2mapid(mapname)) < 0)
- return 0;
-
+ return true;
+
map_foreachinmap(buildin_announce_sub, m, BL_PC,
- mes, strlen(mes)+1, flag&0xf0, fontColor, fontType, fontSize, fontAlign, fontY);
- return 0;
+ mes, strlen(mes)+1, flag&0xf0, fontColor, fontType, fontSize, fontAlign, fontY);
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(areaannounce)
+BUILDIN(areaannounce)
{
const char *mapname = script_getstr(st,2);
int x0 = script_getnum(st,3);
@@ -9626,25 +9391,25 @@ BUILDIN_FUNC(areaannounce)
int fontAlign = script_hasdata(st,12) ? script_getnum(st,12) : 0; // default fontAlign
int fontY = script_hasdata(st,13) ? script_getnum(st,13) : 0; // default fontY
int16 m;
-
+
if ((m = map_mapname2mapid(mapname)) < 0)
- return 0;
-
+ return true;
+
map_foreachinarea(buildin_announce_sub, m, x0, y0, x1, y1, BL_PC,
- mes, strlen(mes)+1, flag&0xf0, fontColor, fontType, fontSize, fontAlign, fontY);
- return 0;
+ mes, strlen(mes)+1, flag&0xf0, fontColor, fontType, fontSize, fontAlign, fontY);
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(getusers)
+BUILDIN(getusers)
{
int flag, val = 0;
struct map_session_data* sd;
struct block_list* bl = NULL;
-
+
flag = script_getnum(st,2);
-
+
switch(flag&0x07)
{
case 0:
@@ -9656,7 +9421,7 @@ BUILDIN_FUNC(getusers)
{// pc
bl = &sd->bl;
}
-
+
if(bl)
{
val = map[bl->m].users;
@@ -9668,45 +9433,45 @@ BUILDIN_FUNC(getusers)
default:
ShowWarning("buildin_getusers: Unknown type %d.\n", flag);
script_pushint(st,0);
- return 1;
+ return false;
}
-
+
script_pushint(st,val);
- return 0;
+ return true;
}
/*==========================================
* Works like @WHO - displays all online users names in window
*------------------------------------------*/
-BUILDIN_FUNC(getusersname)
+BUILDIN(getusersname)
{
TBL_PC *sd, *pl_sd;
int /*disp_num=1,*/ group_level = 0;
struct s_mapiterator* iter;
-
+
sd = script_rid2sd(st);
- if (!sd) return 0;
-
+ if (!sd) return true;
+
group_level = pc_get_group_level(sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
if (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > group_level)
continue; // skip hidden sessions
-
+
/* Temporary fix for bugreport:1023.
* Do not uncomment unless you want thousands of 'next' buttons.
- if((disp_num++)%10==0)
- clif->scriptnext(sd,st->oid);*/
+ if((disp_num++)%10==0)
+ clif->scriptnext(sd,st->oid);*/
clif->scriptmes(sd,st->oid,pl_sd->status.name);
}
mapit_free(iter);
-
- return 0;
+
+ return true;
}
/*==========================================
* getmapguildusers("mapname",guild ID) Returns the number guild members present on a map [Reddozen]
*------------------------------------------*/
-BUILDIN_FUNC(getmapguildusers)
+BUILDIN(getmapguildusers)
{
const char *str;
int16 m;
@@ -9717,10 +9482,10 @@ BUILDIN_FUNC(getmapguildusers)
gid=script_getnum(st,3);
if ((m = map_mapname2mapid(str)) < 0) { // map id on this server (m == -1 if not in actual map-server)
script_pushint(st,-1);
- return 0;
+ return true;
}
g = guild_search(gid);
-
+
if (g){
for(i = 0; i < g->max_member; i++)
{
@@ -9728,23 +9493,23 @@ BUILDIN_FUNC(getmapguildusers)
c++;
}
}
-
+
script_pushint(st,c);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(getmapusers)
+BUILDIN(getmapusers)
{
const char *str;
int16 m;
str=script_getstr(st,2);
if( (m=map_mapname2mapid(str))< 0){
script_pushint(st,-1);
- return 0;
+ return true;
}
script_pushint(st,map[m].users);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
@@ -9754,7 +9519,7 @@ static int buildin_getareausers_sub(struct block_list *bl,va_list ap)
(*users)++;
return 0;
}
-BUILDIN_FUNC(getareausers)
+BUILDIN(getareausers)
{
const char *str;
int16 m,x0,y0,x1,y1,users=0; //doubt we can have more then 32k users on
@@ -9765,12 +9530,12 @@ BUILDIN_FUNC(getareausers)
y1=script_getnum(st,6);
if( (m=map_mapname2mapid(str))< 0){
script_pushint(st,-1);
- return 0;
+ return true;
}
map_foreachinarea(buildin_getareausers_sub,
- m,x0,y0,x1,y1,BL_PC,&users);
+ m,x0,y0,x1,y1,BL_PC,&users);
script_pushint(st,users);
- return 0;
+ return true;
}
/*==========================================
@@ -9780,25 +9545,25 @@ static int buildin_getareadropitem_sub(struct block_list *bl,va_list ap)
int item=va_arg(ap,int);
int *amount=va_arg(ap,int *);
struct flooritem_data *drop=(struct flooritem_data *)bl;
-
+
if(drop->item_data.nameid==item)
(*amount)+=drop->item_data.amount;
-
+
return 0;
}
-BUILDIN_FUNC(getareadropitem)
+BUILDIN(getareadropitem)
{
const char *str;
int16 m,x0,y0,x1,y1;
int item,amount=0;
struct script_data *data;
-
+
str=script_getstr(st,2);
x0=script_getnum(st,3);
y0=script_getnum(st,4);
x1=script_getnum(st,5);
y1=script_getnum(st,6);
-
+
data=script_getdata(st,7);
get_val(st,data);
if( data_isstring(data) ){
@@ -9809,65 +9574,65 @@ BUILDIN_FUNC(getareadropitem)
item=item_data->nameid;
}else
item=conv_num(st,data);
-
+
if( (m=map_mapname2mapid(str))< 0){
script_pushint(st,-1);
- return 0;
+ return true;
}
map_foreachinarea(buildin_getareadropitem_sub,
- m,x0,y0,x1,y1,BL_ITEM,item,&amount);
+ m,x0,y0,x1,y1,BL_ITEM,item,&amount);
script_pushint(st,amount);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(enablenpc)
+BUILDIN(enablenpc)
{
const char *str;
str=script_getstr(st,2);
npc_enable(str,1);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(disablenpc)
+BUILDIN(disablenpc)
{
const char *str;
str=script_getstr(st,2);
npc_enable(str,0);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(hideoffnpc)
+BUILDIN(hideoffnpc)
{
const char *str;
str=script_getstr(st,2);
npc_enable(str,2);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(hideonnpc)
+BUILDIN(hideonnpc)
{
const char *str;
str=script_getstr(st,2);
npc_enable(str,4);
- return 0;
+ return true;
}
/// Starts a status effect on the target unit or on the attached player.
///
/// sc_start <effect_id>,<duration>,<val1>{,<unit_id>};
-BUILDIN_FUNC(sc_start)
+BUILDIN(sc_start)
{
struct block_list* bl;
enum sc_type type;
int tick;
int val1;
int val4 = 0;
-
+
type = (sc_type)script_getnum(st,2);
tick = script_getnum(st,3);
val1 = script_getnum(st,4);
@@ -9875,29 +9640,29 @@ BUILDIN_FUNC(sc_start)
bl = map_id2bl(script_getnum(st,5));
else
bl = map_id2bl(st->rid);
-
+
if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0 )
{// When there isn't a duration specified, try to get it from the skill_db
tick = skill->get_time(status_sc2skill(type), val1);
}
-
+
if( potion_flag == 1 && potion_target )
{ //skill.c set the flags before running the script, this must be a potion-pitched effect.
bl = map_id2bl(potion_target);
tick /= 2;// Thrown potions only last half.
val4 = 1;// Mark that this was a thrown sc_effect
}
-
+
if( bl )
status_change_start(bl, type, 10000, val1, 0, 0, val4, tick, 2);
-
- return 0;
+
+ return true;
}
/// Starts a status effect on the target unit or on the attached player.
///
/// sc_start2 <effect_id>,<duration>,<val1>,<percent chance>{,<unit_id>};
-BUILDIN_FUNC(sc_start2)
+BUILDIN(sc_start2)
{
struct block_list* bl;
enum sc_type type;
@@ -9905,7 +9670,7 @@ BUILDIN_FUNC(sc_start2)
int val1;
int val4 = 0;
int rate;
-
+
type = (sc_type)script_getnum(st,2);
tick = script_getnum(st,3);
val1 = script_getnum(st,4);
@@ -9914,29 +9679,29 @@ BUILDIN_FUNC(sc_start2)
bl = map_id2bl(script_getnum(st,6));
else
bl = map_id2bl(st->rid);
-
+
if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0 )
{// When there isn't a duration specified, try to get it from the skill_db
tick = skill->get_time(status_sc2skill(type), val1);
}
-
+
if( potion_flag == 1 && potion_target )
{ //skill.c set the flags before running the script, this must be a potion-pitched effect.
bl = map_id2bl(potion_target);
tick /= 2;// Thrown potions only last half.
val4 = 1;// Mark that this was a thrown sc_effect
}
-
+
if( bl )
status_change_start(bl, type, rate, val1, 0, 0, val4, tick, 2);
-
- return 0;
+
+ return true;
}
/// Starts a status effect on the target unit or on the attached player.
///
/// sc_start4 <effect_id>,<duration>,<val1>,<val2>,<val3>,<val4>{,<unit_id>};
-BUILDIN_FUNC(sc_start4)
+BUILDIN(sc_start4)
{
struct block_list* bl;
enum sc_type type;
@@ -9945,7 +9710,7 @@ BUILDIN_FUNC(sc_start4)
int val2;
int val3;
int val4;
-
+
type = (sc_type)script_getnum(st,2);
tick = script_getnum(st,3);
val1 = script_getnum(st,4);
@@ -9956,125 +9721,125 @@ BUILDIN_FUNC(sc_start4)
bl = map_id2bl(script_getnum(st,8));
else
bl = map_id2bl(st->rid);
-
+
if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0 )
{// When there isn't a duration specified, try to get it from the skill_db
tick = skill->get_time(status_sc2skill(type), val1);
}
-
+
if( potion_flag == 1 && potion_target )
{ //skill.c set the flags before running the script, this must be a potion-pitched effect.
bl = map_id2bl(potion_target);
tick /= 2;// Thrown potions only last half.
}
-
+
if( bl )
status_change_start(bl, type, 10000, val1, val2, val3, val4, tick, 2);
-
- return 0;
+
+ return true;
}
/// Ends one or all status effects on the target unit or on the attached player.
///
/// sc_end <effect_id>{,<unit_id>};
-BUILDIN_FUNC(sc_end)
+BUILDIN(sc_end)
{
struct block_list* bl;
int type;
-
+
type = script_getnum(st, 2);
if (script_hasdata(st, 3))
bl = map_id2bl(script_getnum(st, 3));
else
bl = map_id2bl(st->rid);
-
+
if (potion_flag == 1 && potion_target) //##TODO how does this work [FlavioJS]
bl = map_id2bl(potion_target);
-
+
if (!bl)
- return 0;
-
+ return true;
+
if (type >= 0 && type < SC_MAX)
{
struct status_change *sc = status_get_sc(bl);
struct status_change_entry *sce = sc ? sc->data[type] : NULL;
-
+
if (!sce)
- return 0;
-
-
+ return true;
+
+
switch (type)
{
case SC_WEIGHT50:
case SC_WEIGHT90:
case SC_NOCHAT:
case SC_PUSH_CART:
- return 0;
-
+ return true;
+
default:
break;
}
-
+
//This should help status_change_end force disabling the SC in case it has no limit.
sce->val1 = sce->val2 = sce->val3 = sce->val4 = 0;
status_change_end(bl, (sc_type)type, INVALID_TIMER);
}
else
status_change_clear(bl, 3); // remove all effects
-
- return 0;
+
+ return true;
}
/*==========================================
* @FIXME atm will return reduced tick, 0 immune, 1 no tick
*------------------------------------------*/
-BUILDIN_FUNC(getscrate)
+BUILDIN(getscrate)
{
struct block_list *bl;
int type,rate;
-
+
type=script_getnum(st,2);
rate=script_getnum(st,3);
if( script_hasdata(st,4) ) //get for the bl assigned
bl = map_id2bl(script_getnum(st,4));
else
bl = map_id2bl(st->rid);
-
+
if (bl)
rate = status_get_sc_def(bl, (sc_type)type, 10000, 10000, 0);
-
+
script_pushint(st,rate);
- return 0;
+ return true;
}
/*==========================================
* getstatus <type>{, <info>};
*------------------------------------------*/
-BUILDIN_FUNC(getstatus)
+BUILDIN(getstatus)
{
int id, type;
struct map_session_data* sd = script_rid2sd(st);
-
+
if( sd == NULL )
{// no player attached
- return 0;
+ return true;
}
-
+
id = script_getnum(st, 2);
type = script_hasdata(st, 3) ? script_getnum(st, 3) : 0;
-
+
if( id <= SC_NONE || id >= SC_MAX )
{// invalid status type given
ShowWarning("script.c:getstatus: Invalid status type given (%d).\n", id);
- return 0;
+ return true;
}
-
+
if( sd->sc.count == 0 || !sd->sc.data[id] )
{// no status is active
script_pushint(st, 0);
- return 0;
+ return true;
}
-
+
switch( type )
{
case 1: script_pushint(st, sd->sc.data[id]->val1); break;
@@ -10082,59 +9847,59 @@ BUILDIN_FUNC(getstatus)
case 3: script_pushint(st, sd->sc.data[id]->val3); break;
case 4: script_pushint(st, sd->sc.data[id]->val4); break;
case 5:
- {
- struct TimerData* timer = (struct TimerData*)get_timer(sd->sc.data[id]->timer);
-
- if( timer )
- {// return the amount of time remaining
- script_pushint(st, timer->tick - gettick());
- }
+ {
+ struct TimerData* timer = (struct TimerData*)get_timer(sd->sc.data[id]->timer);
+
+ if( timer )
+ {// return the amount of time remaining
+ script_pushint(st, timer->tick - gettick());
}
+ }
break;
default: script_pushint(st, 1); break;
}
-
- return 0;
+
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(debugmes)
+BUILDIN(debugmes)
{
const char *str;
str=script_getstr(st,2);
ShowDebug("script debug : %d %d : %s\n",st->rid,st->oid,str);
- return 0;
+ return true;
}
/*==========================================
*------------------------------------------*/
-BUILDIN_FUNC(catchpet)
+BUILDIN(catchpet)
{
int pet_id;
TBL_PC *sd;
-
+
pet_id= script_getnum(st,2);
sd=script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
pet_catch_process1(sd,pet_id);
- return 0;
+ return true;
}
/*==========================================
* [orn]
*------------------------------------------*/
-BUILDIN_FUNC(homunculus_evolution)
+BUILDIN(homunculus_evolution)
{
TBL_PC *sd;
-
+
sd=script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if(merc_is_hom_active(sd->hd))
{
if (sd->hd->homunculus.intimacy > 91000)
@@ -10142,55 +9907,55 @@ BUILDIN_FUNC(homunculus_evolution)
else
clif->emotion(&sd->hd->bl, E_SWT);
}
- return 0;
+ return true;
}
/*==========================================
* [Xantara]
*------------------------------------------*/
-BUILDIN_FUNC(homunculus_mutate)
+BUILDIN(homunculus_mutate)
{
int homun_id, m_class, m_id;
TBL_PC *sd;
-
+
sd = script_rid2sd(st);
- if( sd == NULL )
- return 0;
-
+ if( sd == NULL || sd->hd == NULL )
+ return true;
+
if(script_hasdata(st,2))
homun_id = script_getnum(st,2);
else
homun_id = 6048 + (rnd() % 4);
-
+
if(merc_is_hom_active(sd->hd)) {
m_class = hom_class2mapid(sd->hd->homunculus.class_);
m_id = hom_class2mapid(homun_id);
-
+
if ( m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99 )
hom_mutate(sd->hd, homun_id);
else
clif->emotion(&sd->hd->bl, E_SWT);
}
- return 0;
+ return true;
}
// [Zephyrus]
-BUILDIN_FUNC(homunculus_shuffle)
+BUILDIN(homunculus_shuffle)
{
TBL_PC *sd;
-
+
sd=script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if(merc_is_hom_active(sd->hd))
merc_hom_shuffle(sd->hd);
-
- return 0;
+
+ return true;
}
//These two functions bring the eA MAPID_* class functionality to scripts.
-BUILDIN_FUNC(eaclass)
+BUILDIN(eaclass)
{
int class_;
if( script_hasdata(st,2) )
@@ -10200,15 +9965,15 @@ BUILDIN_FUNC(eaclass)
sd=script_rid2sd(st);
if (!sd) {
script_pushint(st,-1);
- return 0;
+ return true;
}
class_ = sd->status.class_;
}
script_pushint(st,pc_jobid2mapid(class_));
- return 0;
+ return true;
}
-BUILDIN_FUNC(roclass)
+BUILDIN(roclass)
{
int class_ =script_getnum(st,2);
int sex;
@@ -10222,26 +9987,26 @@ BUILDIN_FUNC(roclass)
sex = 1; //Just use male when not found.
}
script_pushint(st,pc_mapid2jobid(class_, sex));
- return 0;
+ return true;
}
/*==========================================
* Tells client to open a hatching window, used for pet incubator
*------------------------------------------*/
-BUILDIN_FUNC(birthpet)
+BUILDIN(birthpet)
{
TBL_PC *sd;
sd=script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
if( sd->status.pet_id )
{// do not send egg list, when you already have a pet
- return 0;
+ return true;
}
-
+
clif->sendegg(sd);
- return 0;
+ return true;
}
/*==========================================
@@ -10252,77 +10017,77 @@ BUILDIN_FUNC(birthpet)
* 3 : don't reset skill, blvl=1
* 4 : jlvl=0
*------------------------------------------*/
-BUILDIN_FUNC(resetlvl)
+BUILDIN(resetlvl)
{
TBL_PC *sd;
-
+
int type=script_getnum(st,2);
-
+
sd=script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
pc_resetlvl(sd,type);
- return 0;
+ return true;
}
/*==========================================
* Reset a player status point
*------------------------------------------*/
-BUILDIN_FUNC(resetstatus)
+BUILDIN(resetstatus)
{
TBL_PC *sd;
sd=script_rid2sd(st);
pc_resetstate(sd);
- return 0;
+ return true;
}
/*==========================================
* script command resetskill
*------------------------------------------*/
-BUILDIN_FUNC(resetskill)
+BUILDIN(resetskill)
{
TBL_PC *sd;
sd=script_rid2sd(st);
pc_resetskill(sd,1);
- return 0;
+ return true;
}
/*==========================================
* Counts total amount of skill points.
*------------------------------------------*/
-BUILDIN_FUNC(skillpointcount)
+BUILDIN(skillpointcount)
{
TBL_PC *sd;
sd=script_rid2sd(st);
script_pushint(st,sd->status.skill_point + pc_resetskill(sd,2));
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(changebase)
+BUILDIN(changebase)
{
TBL_PC *sd=NULL;
int vclass;
-
+
if( script_hasdata(st,3) )
sd=map_id2sd(script_getnum(st,3));
else
- sd=script_rid2sd(st);
-
+ sd=script_rid2sd(st);
+
if(sd == NULL)
- return 0;
-
+ return true;
+
vclass = script_getnum(st,2);
if(vclass == JOB_WEDDING)
{
if (!battle_config.wedding_modifydisplay || //Do not show the wedding sprites
sd->class_&JOBL_BABY //Baby classes screw up when showing wedding sprites. [Skotlex] They don't seem to anymore.
)
- return 0;
+ return true;
}
-
+
if(!sd->disguise && vclass != sd->vd.class_) {
status_set_viewdata(&sd->bl, vclass);
//Updated client view. Base, Weapon and Cloth Colors.
@@ -10332,48 +10097,48 @@ BUILDIN_FUNC(changebase)
clif->changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color);
clif->skillinfoblock(sd);
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Unequip all item and request for a changesex to char-serv
*------------------------------------------*/
-BUILDIN_FUNC(changesex)
+BUILDIN(changesex)
{
int i;
TBL_PC *sd = NULL;
sd = script_rid2sd(st);
-
+
pc_resetskill(sd,4);
// to avoid any problem with equipment and invalid sex, equipment is unequiped.
for( i=0; i<EQI_MAX; i++ )
if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
chrif_changesex(sd);
- return 0;
+ return true;
}
/*==========================================
* Works like 'announce' but outputs in the common chat window
*------------------------------------------*/
-BUILDIN_FUNC(globalmes)
+BUILDIN(globalmes)
{
struct block_list *bl = map_id2bl(st->oid);
struct npc_data *nd = (struct npc_data *)bl;
const char *name=NULL,*mes;
-
+
mes=script_getstr(st,2);
- if(mes==NULL) return 0;
-
+ if(mes==NULL) return true;
+
if(script_hasdata(st,3)){ // npc name to display
name=script_getstr(st,3);
} else {
name=nd->name; //use current npc name
}
-
+
npc_globalmessage(name,mes); // broadcast to all players connected
-
- return 0;
+
+ return true;
}
/////////////////////////////////////////////////////////////////////
@@ -10383,7 +10148,7 @@ BUILDIN_FUNC(globalmes)
/// Creates a waiting room (chat room) for this npc.
///
/// waitingroom "<title>",<limit>{,"<event>"{,<trigger>{,<zeny>{,<minlvl>{,<maxlvl>}}}}};
-BUILDIN_FUNC(waitingroom)
+BUILDIN(waitingroom)
{
struct npc_data* nd;
int pub = 1;
@@ -10394,19 +10159,19 @@ BUILDIN_FUNC(waitingroom)
int zeny = script_hasdata(st,6) ? script_getnum(st,6) : 0;
int minLvl = script_hasdata(st,7) ? script_getnum(st,7) : 1;
int maxLvl = script_hasdata(st,8) ? script_getnum(st,8) : MAX_LEVEL;
-
+
nd = (struct npc_data *)map_id2bl(st->oid);
if( nd != NULL )
chat_createnpcchat(nd, title, limit, pub, trigger, ev, zeny, minLvl, maxLvl);
-
- return 0;
+
+ return true;
}
/// Removes the waiting room of the current or target npc.
///
/// delwaitingroom "<npc_name>";
/// delwaitingroom;
-BUILDIN_FUNC(delwaitingroom)
+BUILDIN(delwaitingroom)
{
struct npc_data* nd;
if( script_hasdata(st,2) )
@@ -10415,64 +10180,64 @@ BUILDIN_FUNC(delwaitingroom)
nd = (struct npc_data *)map_id2bl(st->oid);
if( nd != NULL )
chat_deletenpcchat(nd);
- return 0;
+ return true;
}
/// Kicks all the players from the waiting room of the current or target npc.
///
/// kickwaitingroomall "<npc_name>";
/// kickwaitingroomall;
-BUILDIN_FUNC(waitingroomkickall)
+BUILDIN(waitingroomkickall)
{
struct npc_data* nd;
struct chat_data* cd;
-
+
if( script_hasdata(st,2) )
nd = npc_name2id(script_getstr(st,2));
else
nd = (struct npc_data *)map_id2bl(st->oid);
-
+
if( nd != NULL && (cd=(struct chat_data *)map_id2bl(nd->chat_id)) != NULL )
chat_npckickall(cd);
- return 0;
+ return true;
}
/// Enables the waiting room event of the current or target npc.
///
/// enablewaitingroomevent "<npc_name>";
/// enablewaitingroomevent;
-BUILDIN_FUNC(enablewaitingroomevent)
+BUILDIN(enablewaitingroomevent)
{
struct npc_data* nd;
struct chat_data* cd;
-
+
if( script_hasdata(st,2) )
nd = npc_name2id(script_getstr(st, 2));
else
nd = (struct npc_data *)map_id2bl(st->oid);
-
+
if( nd != NULL && (cd=(struct chat_data *)map_id2bl(nd->chat_id)) != NULL )
chat_enableevent(cd);
- return 0;
+ return true;
}
/// Disables the waiting room event of the current or target npc.
///
/// disablewaitingroomevent "<npc_name>";
/// disablewaitingroomevent;
-BUILDIN_FUNC(disablewaitingroomevent)
+BUILDIN(disablewaitingroomevent)
{
struct npc_data *nd;
struct chat_data *cd;
-
+
if( script_hasdata(st,2) )
nd = npc_name2id(script_getstr(st, 2));
else
nd = (struct npc_data *)map_id2bl(st->oid);
-
+
if( nd != NULL && (cd=(struct chat_data *)map_id2bl(nd->chat_id)) != NULL )
chat_disableevent(cd);
- return 0;
+ return true;
}
/// Returns info on the waiting room of the current or target npc.
@@ -10489,38 +10254,38 @@ BUILDIN_FUNC(disablewaitingroomevent)
///
/// getwaitingroomstate(<type>,"<npc_name>") -> <info>
/// getwaitingroomstate(<type>) -> <info>
-BUILDIN_FUNC(getwaitingroomstate)
+BUILDIN(getwaitingroomstate)
{
struct npc_data *nd;
struct chat_data *cd;
int type;
-
+
type = script_getnum(st,2);
if( script_hasdata(st,3) )
nd = npc_name2id(script_getstr(st, 3));
else
nd = (struct npc_data *)map_id2bl(st->oid);
-
+
if( nd == NULL || (cd=(struct chat_data *)map_id2bl(nd->chat_id)) == NULL )
{
script_pushint(st, -1);
- return 0;
+ return true;
}
-
+
switch(type)
{
- case 0: script_pushint(st, cd->users); break;
- case 1: script_pushint(st, cd->limit); break;
- case 2: script_pushint(st, cd->trigger&0x7f); break;
- case 3: script_pushint(st, ((cd->trigger&0x80)!=0)); break;
- case 4: script_pushstrcopy(st, cd->title); break;
- case 5: script_pushstrcopy(st, cd->pass); break;
- case 16: script_pushstrcopy(st, cd->npc_event);break;
- case 32: script_pushint(st, (cd->users >= cd->limit)); break;
- case 33: script_pushint(st, (cd->users >= cd->trigger)); break;
- default: script_pushint(st, -1); break;
+ case 0: script_pushint(st, cd->users); break;
+ case 1: script_pushint(st, cd->limit); break;
+ case 2: script_pushint(st, cd->trigger&0x7f); break;
+ case 3: script_pushint(st, ((cd->trigger&0x80)!=0)); break;
+ case 4: script_pushstrcopy(st, cd->title); break;
+ case 5: script_pushstrcopy(st, cd->pass); break;
+ case 16: script_pushstrcopy(st, cd->npc_event);break;
+ case 32: script_pushint(st, (cd->users >= cd->limit)); break;
+ case 33: script_pushint(st, (cd->users >= cd->trigger)); break;
+ default: script_pushint(st, -1); break;
}
- return 0;
+ return true;
}
/// Warps the trigger or target amount of players to the target map and position.
@@ -10535,7 +10300,7 @@ BUILDIN_FUNC(getwaitingroomstate)
///
/// warpwaitingpc "<map name>",<x>,<y>,<number of players>;
/// warpwaitingpc "<map name>",<x>,<y>;
-BUILDIN_FUNC(warpwaitingpc)
+BUILDIN(warpwaitingpc)
{
int x;
int y;
@@ -10545,28 +10310,28 @@ BUILDIN_FUNC(warpwaitingpc)
struct npc_data* nd;
struct chat_data* cd;
TBL_PC* sd;
-
+
nd = (struct npc_data *)map_id2bl(st->oid);
if( nd == NULL || (cd=(struct chat_data *)map_id2bl(nd->chat_id)) == NULL )
- return 0;
-
+ return true;
+
map_name = script_getstr(st,2);
x = script_getnum(st,3);
y = script_getnum(st,4);
n = cd->trigger&0x7f;
-
+
if( script_hasdata(st,5) )
n = script_getnum(st,5);
-
+
for( i = 0; i < n && cd->users > 0; i++ )
{
sd = cd->usersd[0];
-
+
if( strcmp(map_name,"SavePoint") == 0 && map[sd->bl.m].flag.noteleport )
{// can't teleport on this map
break;
}
-
+
if( cd->zeny )
{// fee set
if( (uint32)sd->status.zeny < cd->zeny )
@@ -10575,9 +10340,9 @@ BUILDIN_FUNC(warpwaitingpc)
}
pc_payzeny(sd, cd->zeny, LOG_TYPE_NPC, NULL);
}
-
+
mapreg_setreg(reference_uid(add_str("$@warpwaitingpc"), i), sd->bl.id);
-
+
if( strcmp(map_name,"Random") == 0 )
pc_randomwarp(sd,CLR_TELEPORT);
else if( strcmp(map_name,"SavePoint") == 0 )
@@ -10586,7 +10351,7 @@ BUILDIN_FUNC(warpwaitingpc)
pc_setpos(sd, mapindex_name2id(map_name), x, y, CLR_OUTSIGHT);
}
mapreg_setreg(add_str("$@warpwaitingpcnum"), i);
- return 0;
+ return true;
}
/////////////////////////////////////////////////////////////////////
@@ -10608,76 +10373,76 @@ static void script_detach_rid(struct script_state* st)
/*==========================================
* Attach sd char id to script and detach current one if any
*------------------------------------------*/
-BUILDIN_FUNC(attachrid)
+BUILDIN(attachrid)
{
int rid = script_getnum(st,2);
-
+
if (map_id2sd(rid) != NULL) {
script_detach_rid(st);
-
+
st->rid = rid;
script_attach_state(st);
script_pushint(st,1);
} else
script_pushint(st,0);
- return 0;
+ return true;
}
/*==========================================
* Detach script to rid
*------------------------------------------*/
-BUILDIN_FUNC(detachrid)
+BUILDIN(detachrid)
{
script_detach_rid(st);
- return 0;
+ return true;
}
/*==========================================
* Chk if account connected, (and charid from account if specified)
*------------------------------------------*/
-BUILDIN_FUNC(isloggedin)
+BUILDIN(isloggedin)
{
TBL_PC* sd = map_id2sd(script_getnum(st,2));
if (script_hasdata(st,3) && sd &&
sd->status.char_id != script_getnum(st,3))
sd = NULL;
push_val(st->stack,C_INT,sd!=NULL);
- return 0;
+ return true;
}
/*==========================================
*
*------------------------------------------*/
-BUILDIN_FUNC(setmapflagnosave)
+BUILDIN(setmapflagnosave)
{
int16 m,x,y;
unsigned short mapindex;
const char *str,*str2;
-
+
str=script_getstr(st,2);
str2=script_getstr(st,3);
x=script_getnum(st,4);
y=script_getnum(st,5);
m = map_mapname2mapid(str);
mapindex = mapindex_name2id(str2);
-
+
if(m >= 0 && mapindex) {
map[m].flag.nosave=1;
map[m].save.map=mapindex;
map[m].save.x=x;
map[m].save.y=y;
}
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(getmapflag)
+BUILDIN(getmapflag)
{
int16 m,i;
const char *str;
-
+
str=script_getstr(st,2);
i=script_getnum(st,3);
-
+
m = map_mapname2mapid(str);
if(m >= 0) {
switch(i) {
@@ -10701,7 +10466,6 @@ BUILDIN_FUNC(getmapflag)
case MF_FOG: script_pushint(st,map[m].flag.fog); break;
case MF_SAKURA: script_pushint(st,map[m].flag.sakura); break;
case MF_LEAVES: script_pushint(st,map[m].flag.leaves); break;
- case MF_NOGO: script_pushint(st,map[m].flag.nogo); break;
case MF_CLOUDS: script_pushint(st,map[m].flag.clouds); break;
case MF_CLOUDS2: script_pushint(st,map[m].flag.clouds2); break;
case MF_FIREWORKS: script_pushint(st,map[m].flag.fireworks); break;
@@ -10733,8 +10497,8 @@ BUILDIN_FUNC(getmapflag)
case MF_RESET: script_pushint(st,map[m].flag.reset); break;
}
}
-
- return 0;
+
+ return true;
}
/* pvp timer handling */
static int script_mapflag_pvp_sub(struct block_list *bl,va_list ap) {
@@ -10748,15 +10512,16 @@ static int script_mapflag_pvp_sub(struct block_list *bl,va_list ap) {
sd->pvp_lost = 0;
}
clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
+ clif->maptypeproperty2(&sd->bl,SELF);
return 0;
}
-BUILDIN_FUNC(setmapflag)
+BUILDIN(setmapflag)
{
int16 m,i;
const char *str, *val2 = NULL;
struct script_data* data;
int val=0;
-
+
str=script_getstr(st,2);
i = script_getnum(st, 3);
@@ -10770,7 +10535,7 @@ BUILDIN_FUNC(setmapflag)
val2 = script_getstr(st, 4);
else
val = script_getnum(st, 4);
-
+
}
m = map_mapname2mapid(str);
@@ -10790,9 +10555,14 @@ BUILDIN_FUNC(setmapflag)
break;
case MF_PVP_NOPARTY: map[m].flag.pvp_noparty = 1; break;
case MF_PVP_NOGUILD: map[m].flag.pvp_noguild = 1; break;
- case MF_GVG:
+ case MF_GVG: {
+ struct block_list bl;
map[m].flag.gvg = 1;
clif->map_property_mapall(m, MAPPROPERTY_AGITZONE);
+ bl.type = BL_NUL;
+ bl.m = m;
+ clif->maptypeproperty2(&bl,ALL_SAMEMAP);
+ }
break;
case MF_GVG_NOPARTY: map[m].flag.gvg_noparty = 1; break;
case MF_NOTRADE: map[m].flag.notrade = 1; break;
@@ -10804,11 +10574,6 @@ BUILDIN_FUNC(setmapflag)
case MF_FOG: map[m].flag.fog = 1; break;
case MF_SAKURA: map[m].flag.sakura = 1; break;
case MF_LEAVES: map[m].flag.leaves = 1; break;
- /**
- * No longer available, keeping here just in case it's back someday. [Ind]
- **/
- //case MF_RAIN: map[m].flag.rain = 1; break;
- case MF_NOGO: map[m].flag.nogo = 1; break;
case MF_CLOUDS: map[m].flag.clouds = 1; break;
case MF_CLOUDS2: map[m].flag.clouds2 = 1; break;
case MF_FIREWORKS: map[m].flag.fireworks = 1; break;
@@ -10828,7 +10593,7 @@ BUILDIN_FUNC(setmapflag)
char params[MAP_ZONE_MAPFLAG_LENGTH];
memcpy(params, val2, MAP_ZONE_MAPFLAG_LENGTH);
npc_parse_mapflag(map[m].name, empty, zone, params, empty, empty, empty);
- }
+ }
break;
case MF_NOCOMMAND: map[m].nocommand = (val <= 0) ? 100 : val; break;
case MF_NODROP: map[m].flag.nodrop = 1; break;
@@ -10848,16 +10613,16 @@ BUILDIN_FUNC(setmapflag)
case MF_RESET: map[m].flag.reset = 1; break;
}
}
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(removemapflag)
+BUILDIN(removemapflag)
{
int16 m,i;
const char *str;
int val=0;
-
+
str=script_getstr(st,2);
i=script_getnum(st,3);
if(script_hasdata(st,4)){
@@ -10872,15 +10637,25 @@ BUILDIN_FUNC(removemapflag)
case MF_NOBRANCH: map[m].flag.nobranch = 0; break;
case MF_NOPENALTY: map[m].flag.noexppenalty = 0; map[m].flag.nozenypenalty = 0; break;
case MF_NOZENYPENALTY: map[m].flag.nozenypenalty = 0; break;
- case MF_PVP:
+ case MF_PVP: {
+ struct block_list bl;
+ bl.type = BL_NUL;
+ bl.m = m;
map[m].flag.pvp = 0;
clif->map_property_mapall(m, MAPPROPERTY_NOTHING);
+ clif->maptypeproperty2(&bl,ALL_SAMEMAP);
+ }
break;
case MF_PVP_NOPARTY: map[m].flag.pvp_noparty = 0; break;
case MF_PVP_NOGUILD: map[m].flag.pvp_noguild = 0; break;
- case MF_GVG:
+ case MF_GVG: {
+ struct block_list bl;
+ bl.type = BL_NUL;
+ bl.m = m;
map[m].flag.gvg = 0;
clif->map_property_mapall(m, MAPPROPERTY_NOTHING);
+ clif->maptypeproperty2(&bl,ALL_SAMEMAP);
+ }
break;
case MF_GVG_NOPARTY: map[m].flag.gvg_noparty = 0; break;
case MF_NOTRADE: map[m].flag.notrade = 0; break;
@@ -10892,7 +10667,6 @@ BUILDIN_FUNC(removemapflag)
case MF_FOG: map[m].flag.fog = 0; break;
case MF_SAKURA: map[m].flag.sakura = 0; break;
case MF_LEAVES: map[m].flag.leaves = 0; break;
- case MF_NOGO: map[m].flag.nogo = 0; break;
case MF_CLOUDS: map[m].flag.clouds = 0; break;
case MF_CLOUDS2: map[m].flag.clouds2 = 0; break;
case MF_FIREWORKS: map[m].flag.fireworks = 0; break;
@@ -10927,35 +10701,40 @@ BUILDIN_FUNC(removemapflag)
case MF_RESET: map[m].flag.reset = 0; break;
}
}
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(pvpon)
+BUILDIN(pvpon)
{
int16 m;
const char *str;
TBL_PC* sd = NULL;
struct s_mapiterator* iter;
-
+ struct block_list bl;
+
str = script_getstr(st,2);
m = map_mapname2mapid(str);
if( m < 0 || map[m].flag.pvp )
- return 0; // nothing to do
-
+ return true; // nothing to do
+
map_zone_change2(m, strdb_get(zone_db, MAP_ZONE_PVP_NAME));
map[m].flag.pvp = 1;
clif->map_property_mapall(m, MAPPROPERTY_FREEPVPZONE);
-
+ bl.type = BL_NUL;
+ bl.m = m;
+ clif->maptypeproperty2(&bl,ALL_SAMEMAP);
+
+
if(battle_config.pk_mode) // disable ranking functions if pk_mode is on [Valaris]
- return 0;
-
+ return true;
+
iter = mapit_getallusers();
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
{
if( sd->bl.m != m || sd->pvp_timer != INVALID_TIMER )
continue; // not applicable
-
+
sd->pvp_timer = add_timer(gettick()+200,pc_calc_pvprank_timer,sd->bl.id,0);
sd->pvp_rank = 0;
sd->pvp_lastusers = 0;
@@ -10964,8 +10743,8 @@ BUILDIN_FUNC(pvpon)
sd->pvp_lost = 0;
}
mapit_free(iter);
-
- return 0;
+
+ return true;
}
static int buildin_pvpoff_sub(struct block_list *bl,va_list ap)
@@ -10979,74 +10758,86 @@ static int buildin_pvpoff_sub(struct block_list *bl,va_list ap)
return 0;
}
-BUILDIN_FUNC(pvpoff)
+BUILDIN(pvpoff)
{
int16 m;
const char *str;
-
+ struct block_list bl;
+
str=script_getstr(st,2);
m = map_mapname2mapid(str);
if(m < 0 || !map[m].flag.pvp)
- return 0; //fixed Lupus
+ return true; //fixed Lupus
map_zone_change2(m, map[m].prev_zone);
map[m].flag.pvp = 0;
clif->map_property_mapall(m, MAPPROPERTY_NOTHING);
-
+ bl.type = BL_NUL;
+ bl.m = m;
+ clif->maptypeproperty2(&bl,ALL_SAMEMAP);
+
if(battle_config.pk_mode) // disable ranking options if pk_mode is on [Valaris]
- return 0;
-
+ return true;
+
map_foreachinmap(buildin_pvpoff_sub, m, BL_PC);
- return 0;
+ return true;
}
-BUILDIN_FUNC(gvgon)
+BUILDIN(gvgon)
{
int16 m;
const char *str;
-
+
str=script_getstr(st,2);
m = map_mapname2mapid(str);
if(m >= 0 && !map[m].flag.gvg) {
+ struct block_list bl;
map_zone_change2(m, strdb_get(zone_db, MAP_ZONE_GVG_NAME));
map[m].flag.gvg = 1;
clif->map_property_mapall(m, MAPPROPERTY_AGITZONE);
+ bl.type = BL_NUL;
+ bl.m = m;
+ clif->maptypeproperty2(&bl,ALL_SAMEMAP);
}
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(gvgoff)
+BUILDIN(gvgoff)
{
int16 m;
const char *str;
-
+
str=script_getstr(st,2);
m = map_mapname2mapid(str);
if(m >= 0 && map[m].flag.gvg) {
+ struct block_list bl;
map_zone_change2(m, map[m].prev_zone);
map[m].flag.gvg = 0;
clif->map_property_mapall(m, MAPPROPERTY_NOTHING);
+ bl.type = BL_NUL;
+ bl.m = m;
+ clif->maptypeproperty2(&bl,ALL_SAMEMAP);
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Shows an emoticon on top of the player/npc
* emotion emotion#, <target: 0 - NPC, 1 - PC>, <NPC/PC name>
*------------------------------------------*/
//Optional second parameter added by [Skotlex]
-BUILDIN_FUNC(emotion)
+BUILDIN(emotion)
{
int type;
int player=0;
-
+
type=script_getnum(st,2);
if(type < 0 || type > 100)
- return 0;
-
+ return true;
+
if( script_hasdata(st,3) )
player=script_getnum(st,3);
-
+
if (player) {
TBL_PC *sd = NULL;
if( script_hasdata(st,4) )
@@ -11064,7 +10855,7 @@ BUILDIN_FUNC(emotion)
}
else
clif->emotion(map_id2bl(st->oid),type);
- return 0;
+ return true;
}
static int buildin_maprespawnguildid_sub_pc(struct map_session_data* sd, va_list ap)
@@ -11072,14 +10863,14 @@ static int buildin_maprespawnguildid_sub_pc(struct map_session_data* sd, va_list
int16 m=va_arg(ap,int);
int g_id=va_arg(ap,int);
int flag=va_arg(ap,int);
-
+
if(!sd || sd->bl.m != m)
return 0;
if(
- (sd->status.guild_id == g_id && flag&1) || //Warp out owners
- (sd->status.guild_id != g_id && flag&2) || //Warp out outsiders
- (sd->status.guild_id == 0) // Warp out players not in guild [Valaris]
- )
+ (sd->status.guild_id == g_id && flag&1) || //Warp out owners
+ (sd->status.guild_id != g_id && flag&2) || //Warp out outsiders
+ (sd->status.guild_id == 0) // Warp out players not in guild [Valaris]
+ )
pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
return 1;
}
@@ -11087,91 +10878,91 @@ static int buildin_maprespawnguildid_sub_pc(struct map_session_data* sd, va_list
static int buildin_maprespawnguildid_sub_mob(struct block_list *bl,va_list ap)
{
struct mob_data *md=(struct mob_data *)bl;
-
+
if(!md->guardian_data && md->class_ != MOBID_EMPERIUM)
status_kill(bl);
-
+
return 0;
}
-BUILDIN_FUNC(maprespawnguildid)
+BUILDIN(maprespawnguildid)
{
const char *mapname=script_getstr(st,2);
int g_id=script_getnum(st,3);
int flag=script_getnum(st,4);
-
+
int16 m=map_mapname2mapid(mapname);
-
+
if(m == -1)
- return 0;
-
+ return true;
+
//Catch ALL players (in case some are 'between maps' on execution time)
map_foreachpc(buildin_maprespawnguildid_sub_pc,m,g_id,flag);
if (flag&4) //Remove script mobs.
map_foreachinmap(buildin_maprespawnguildid_sub_mob,m,BL_MOB);
- return 0;
+ return true;
}
-BUILDIN_FUNC(agitstart)
+BUILDIN(agitstart)
{
- if(agit_flag==1) return 0; // Agit already Start.
+ if(agit_flag==1) return true; // Agit already Start.
agit_flag=1;
guild_agit_start();
- return 0;
+ return true;
}
-BUILDIN_FUNC(agitend)
+BUILDIN(agitend)
{
- if(agit_flag==0) return 0; // Agit already End.
+ if(agit_flag==0) return true; // Agit already End.
agit_flag=0;
guild_agit_end();
- return 0;
+ return true;
}
-BUILDIN_FUNC(agitstart2)
+BUILDIN(agitstart2)
{
- if(agit2_flag==1) return 0; // Agit2 already Start.
+ if(agit2_flag==1) return true; // Agit2 already Start.
agit2_flag=1;
guild_agit2_start();
- return 0;
+ return true;
}
-BUILDIN_FUNC(agitend2)
+BUILDIN(agitend2)
{
- if(agit2_flag==0) return 0; // Agit2 already End.
+ if(agit2_flag==0) return true; // Agit2 already End.
agit2_flag=0;
guild_agit2_end();
- return 0;
+ return true;
}
/*==========================================
* Returns whether woe is on or off. // choice script
*------------------------------------------*/
-BUILDIN_FUNC(agitcheck)
+BUILDIN(agitcheck)
{
script_pushint(st,agit_flag);
- return 0;
+ return true;
}
/*==========================================
* Returns whether woese is on or off. // choice script
*------------------------------------------*/
-BUILDIN_FUNC(agitcheck2)
+BUILDIN(agitcheck2)
{
script_pushint(st,agit2_flag);
- return 0;
+ return true;
}
/// Sets the guild_id of this npc.
///
/// flagemblem <guild_id>;
-BUILDIN_FUNC(flagemblem)
+BUILDIN(flagemblem)
{
TBL_NPC* nd;
int g_id = script_getnum(st,2);
-
- if(g_id < 0) return 0;
-
+
+ if(g_id < 0) return true;
+
nd = (TBL_NPC*)map_id2nd(st->oid);
if( nd == NULL ) {
ShowError("script:flagemblem: npc %d not found\n", st->oid);
@@ -11187,30 +10978,30 @@ BUILDIN_FUNC(flagemblem)
else if( changed ) /* removing a flag */
guild_flag_remove(nd);
}
- return 0;
+ return true;
}
-BUILDIN_FUNC(getcastlename)
+BUILDIN(getcastlename)
{
const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL);
struct guild_castle* gc = guild_mapname2gc(mapname);
const char* name = (gc) ? gc->castle_name : "";
script_pushstrcopy(st,name);
- return 0;
+ return true;
}
-BUILDIN_FUNC(getcastledata)
+BUILDIN(getcastledata)
{
const char *mapname = mapindex_getmapname(script_getstr(st,2),NULL);
int index = script_getnum(st,3);
struct guild_castle *gc = guild_mapname2gc(mapname);
-
+
if (gc == NULL) {
script_pushint(st,0);
ShowWarning("buildin_setcastledata: guild castle for map '%s' not found\n", mapname);
- return 1;
+ return false;
}
-
+
switch (index) {
case 1:
script_pushint(st,gc->guild_id); break;
@@ -11237,101 +11028,101 @@ BUILDIN_FUNC(getcastledata)
}
script_pushint(st,0);
ShowWarning("buildin_setcastledata: index = '%d' is out of allowed range\n", index);
- return 1;
+ return false;
}
- return 0;
+ return true;
}
-BUILDIN_FUNC(setcastledata)
+BUILDIN(setcastledata)
{
const char *mapname = mapindex_getmapname(script_getstr(st,2),NULL);
int index = script_getnum(st,3);
int value = script_getnum(st,4);
struct guild_castle *gc = guild_mapname2gc(mapname);
-
+
if (gc == NULL) {
ShowWarning("buildin_setcastledata: guild castle for map '%s' not found\n", mapname);
- return 1;
+ return false;
}
-
+
if (index <= 0 || index > 9+MAX_GUARDIANS) {
ShowWarning("buildin_setcastledata: index = '%d' is out of allowed range\n", index);
- return 1;
+ return false;
}
-
+
guild_castledatasave(gc->castle_id, index, value);
- return 0;
+ return true;
}
/* =====================================================================
* ---------------------------------------------------------------------*/
-BUILDIN_FUNC(requestguildinfo)
+BUILDIN(requestguildinfo)
{
int guild_id=script_getnum(st,2);
const char *event=NULL;
-
+
if( script_hasdata(st,3) ){
event=script_getstr(st,3);
check_event(st, event);
}
-
+
if(guild_id>0)
guild_npc_request_info(guild_id,event);
- return 0;
+ return true;
}
/// Returns the number of cards that have been compounded onto the specified equipped item.
/// getequipcardcnt(<equipment slot>);
-BUILDIN_FUNC(getequipcardcnt)
+BUILDIN(getequipcardcnt)
{
int i=-1,j,num;
TBL_PC *sd;
int count;
-
+
num=script_getnum(st,2);
sd=script_rid2sd(st);
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
-
+
if (i < 0 || !sd->inventory_data[i]) {
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
if(itemdb_isspecial(sd->status.inventory[i].card[0]))
{
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
count = 0;
for( j = 0; j < sd->inventory_data[i]->slot; j++ )
if( sd->status.inventory[i].card[j] && itemdb_type(sd->status.inventory[i].card[j]) == IT_CARD )
count++;
-
+
script_pushint(st,count);
- return 0;
+ return true;
}
/// Removes all cards from the item found in the specified equipment slot of the invoking character,
/// and give them to the character. If any cards were removed in this manner, it will also show a success effect.
/// successremovecards <slot>;
-BUILDIN_FUNC(successremovecards) {
+BUILDIN(successremovecards) {
int i=-1,j,c,cardflag=0;
-
+
TBL_PC* sd = script_rid2sd(st);
int num = script_getnum(st,2);
-
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
-
+
if (i < 0 || !sd->inventory_data[i]) {
- return 0;
+ return true;
}
-
+
if(itemdb_isspecial(sd->status.inventory[i].card[0]))
- return 0;
-
+ return true;
+
for( c = sd->inventory_data[i]->slot - 1; c >= 0; --c ) {
if( sd->status.inventory[i].card[c] && itemdb_type(sd->status.inventory[i].card[c]) == IT_CARD ) {// extract this card from the item
int flag;
@@ -11340,37 +11131,37 @@ BUILDIN_FUNC(successremovecards) {
cardflag = 1;
item_tmp.nameid = sd->status.inventory[i].card[c];
item_tmp.identify = 1;
-
+
if((flag=pc_additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ // get back the cart in inventory
clif->additem(sd,0,0,flag);
map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
}
-
+
if(cardflag == 1) {//if card was remove remplace item with no card
int flag;
struct item item_tmp;
memset(&item_tmp,0,sizeof(item_tmp));
-
+
item_tmp.nameid = sd->status.inventory[i].nameid;
item_tmp.identify = 1;
item_tmp.refine = sd->status.inventory[i].refine;
item_tmp.attribute = sd->status.inventory[i].attribute;
item_tmp.expire_time = sd->status.inventory[i].expire_time;
-
+
for (j = sd->inventory_data[i]->slot; j < MAX_SLOTS; j++)
item_tmp.card[j]=sd->status.inventory[i].card[j];
-
+
pc_delitem(sd,i,1,0,3,LOG_TYPE_SCRIPT);
if((flag=pc_additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ //chk if can be spawn in inventory otherwise put on floor
clif->additem(sd,0,0,flag);
map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
-
+
clif->misceffect(&sd->bl,3);
}
- return 0;
+ return true;
}
/// Removes all cards from the item found in the specified equipment slot of the invoking character.
@@ -11379,35 +11170,35 @@ BUILDIN_FUNC(successremovecards) {
/// <type>=1 : will keep the item, but destroy the cards.
/// <type>=2 : will keep the cards, but destroy the item.
/// <type>=? : will just display the failure effect.
-BUILDIN_FUNC(failedremovecards) {
+BUILDIN(failedremovecards) {
int i=-1,j,c,cardflag=0;
-
+
TBL_PC* sd = script_rid2sd(st);
int num = script_getnum(st,2);
int typefail = script_getnum(st,3);
-
+
if (num > 0 && num <= ARRAYLENGTH(equip))
i=pc_checkequip(sd,equip[num-1]);
-
+
if (i < 0 || !sd->inventory_data[i])
- return 0;
-
+ return true;
+
if(itemdb_isspecial(sd->status.inventory[i].card[0]))
- return 0;
-
+ return true;
+
for( c = sd->inventory_data[i]->slot - 1; c >= 0; --c ) {
if( sd->status.inventory[i].card[c] && itemdb_type(sd->status.inventory[i].card[c]) == IT_CARD ) {
cardflag = 1;
-
+
if(typefail == 2) {// add cards to inventory, clear
int flag;
struct item item_tmp;
-
+
memset(&item_tmp,0,sizeof(item_tmp));
-
+
item_tmp.nameid = sd->status.inventory[i].card[c];
item_tmp.identify = 1;
-
+
if((flag=pc_additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){
clif->additem(sd,0,0,flag);
map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
@@ -11415,7 +11206,7 @@ BUILDIN_FUNC(failedremovecards) {
}
}
}
-
+
if(cardflag == 1) {
if(typefail == 0 || typefail == 2){ // destroy the item
pc_delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
@@ -11423,20 +11214,20 @@ BUILDIN_FUNC(failedremovecards) {
if(typefail == 1){ // destroy the card
int flag;
struct item item_tmp;
-
+
memset(&item_tmp,0,sizeof(item_tmp));
-
+
item_tmp.nameid = sd->status.inventory[i].nameid;
item_tmp.identify = 1;
item_tmp.refine = sd->status.inventory[i].refine;
item_tmp.attribute = sd->status.inventory[i].attribute;
item_tmp.expire_time = sd->status.inventory[i].expire_time;
-
+
for (j = sd->inventory_data[i]->slot; j < MAX_SLOTS; j++)
item_tmp.card[j]=sd->status.inventory[i].card[j];
-
+
pc_delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
-
+
if((flag=pc_additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){
clif->additem(sd,0,0,flag);
map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
@@ -11444,8 +11235,8 @@ BUILDIN_FUNC(failedremovecards) {
}
clif->misceffect(&sd->bl,2);
}
-
- return 0;
+
+ return true;
}
/* ================================================================
@@ -11453,7 +11244,7 @@ BUILDIN_FUNC(failedremovecards) {
* type: 0=everyone, 1=guild, 2=party; [Reddozen]
* improved by [Lance]
* ================================================================*/
-BUILDIN_FUNC(mapwarp) // Added by RoVeRT
+BUILDIN(mapwarp) // Added by RoVeRT
{
int x,y,m,check_val=0,check_ID=0,i=0;
struct guild *g = NULL;
@@ -11469,13 +11260,13 @@ BUILDIN_FUNC(mapwarp) // Added by RoVeRT
check_val=script_getnum(st,6);
check_ID=script_getnum(st,7);
}
-
+
if((m=map_mapname2mapid(mapname))< 0)
- return 0;
-
+ return true;
+
if(!(index=mapindex_name2id(str)))
- return 0;
-
+ return true;
+
switch(check_val){
case 1:
g = guild_search(check_ID);
@@ -11502,8 +11293,8 @@ BUILDIN_FUNC(mapwarp) // Added by RoVeRT
map_foreachinmap(buildin_areawarp_sub,m,BL_PC,index,x,y,0,0);
break;
}
-
- return 0;
+
+ return true;
}
static int buildin_mobcount_sub(struct block_list *bl,va_list ap) // Added by RoVeRT
@@ -11515,218 +11306,218 @@ static int buildin_mobcount_sub(struct block_list *bl,va_list ap) // Added by Ro
return 0;
}
-BUILDIN_FUNC(mobcount) // Added by RoVeRT
+BUILDIN(mobcount) // Added by RoVeRT
{
const char *mapname,*event;
int16 m;
mapname=script_getstr(st,2);
event=script_getstr(st,3);
-
+
if( strcmp(event, "all") == 0 )
event = NULL;
else
check_event(st, event);
-
+
if( strcmp(mapname, "this") == 0 ) {
struct map_session_data *sd = script_rid2sd(st);
if( sd )
m = sd->bl.m;
else {
script_pushint(st,-1);
- return 0;
+ return true;
}
}
else if( (m = map_mapname2mapid(mapname)) < 0 ) {
script_pushint(st,-1);
- return 0;
+ return true;
}
-
+
if( map[m].flag.src4instance && map[m].instance_id == 0 && st->instance_id && (m = instance_mapid2imapid(m, st->instance_id)) < 0 )
{
script_pushint(st,-1);
- return 0;
+ return true;
}
-
+
script_pushint(st,map_foreachinmap(buildin_mobcount_sub, m, BL_MOB, event));
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(marriage)
+BUILDIN(marriage)
{
const char *partner=script_getstr(st,2);
TBL_PC *sd=script_rid2sd(st);
TBL_PC *p_sd=map_nick2sd(partner);
-
+
if(sd==NULL || p_sd==NULL || pc_marriage(sd,p_sd) < 0){
script_pushint(st,0);
- return 0;
+ return true;
}
script_pushint(st,1);
- return 0;
+ return true;
}
-BUILDIN_FUNC(wedding_effect)
+BUILDIN(wedding_effect)
{
TBL_PC *sd=script_rid2sd(st);
struct block_list *bl;
-
+
if(sd==NULL) {
bl=map_id2bl(st->oid);
} else
bl=&sd->bl;
clif->wedding_effect(bl);
- return 0;
+ return true;
}
-BUILDIN_FUNC(divorce)
+BUILDIN(divorce)
{
TBL_PC *sd=script_rid2sd(st);
if(sd==NULL || pc_divorce(sd) < 0){
script_pushint(st,0);
- return 0;
+ return true;
}
script_pushint(st,1);
- return 0;
+ return true;
}
-BUILDIN_FUNC(ispartneron)
+BUILDIN(ispartneron)
{
TBL_PC *sd=script_rid2sd(st);
-
+
if(sd==NULL || !pc_ismarried(sd) ||
- map_charid2sd(sd->status.partner_id) == NULL) {
+ map_charid2sd(sd->status.partner_id) == NULL) {
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
script_pushint(st,1);
- return 0;
+ return true;
}
-BUILDIN_FUNC(getpartnerid)
+BUILDIN(getpartnerid)
{
TBL_PC *sd=script_rid2sd(st);
if (sd == NULL) {
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
script_pushint(st,sd->status.partner_id);
- return 0;
+ return true;
}
-BUILDIN_FUNC(getchildid)
+BUILDIN(getchildid)
{
TBL_PC *sd=script_rid2sd(st);
if (sd == NULL) {
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
script_pushint(st,sd->status.child);
- return 0;
+ return true;
}
-BUILDIN_FUNC(getmotherid)
+BUILDIN(getmotherid)
{
TBL_PC *sd=script_rid2sd(st);
if (sd == NULL) {
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
script_pushint(st,sd->status.mother);
- return 0;
+ return true;
}
-BUILDIN_FUNC(getfatherid)
+BUILDIN(getfatherid)
{
TBL_PC *sd=script_rid2sd(st);
if (sd == NULL) {
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
script_pushint(st,sd->status.father);
- return 0;
+ return true;
}
-BUILDIN_FUNC(warppartner)
+BUILDIN(warppartner)
{
int x,y;
unsigned short mapindex;
const char *str;
TBL_PC *sd=script_rid2sd(st);
TBL_PC *p_sd=NULL;
-
+
if(sd==NULL || !pc_ismarried(sd) ||
- (p_sd=map_charid2sd(sd->status.partner_id)) == NULL) {
+ (p_sd=map_charid2sd(sd->status.partner_id)) == NULL) {
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
str=script_getstr(st,2);
x=script_getnum(st,3);
y=script_getnum(st,4);
-
+
mapindex = mapindex_name2id(str);
if (mapindex) {
pc_setpos(p_sd,mapindex,x,y,CLR_OUTSIGHT);
script_pushint(st,1);
} else
script_pushint(st,0);
- return 0;
+ return true;
}
/*================================================
* Script for Displaying MOB Information [Valaris]
*------------------------------------------------*/
-BUILDIN_FUNC(strmobinfo)
+BUILDIN(strmobinfo)
{
-
+
int num=script_getnum(st,2);
int class_=script_getnum(st,3);
-
+
if(!mobdb_checkid(class_))
{
if (num < 3) //requested a string
script_pushconststr(st,"");
else
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
switch (num) {
- case 1: script_pushstrcopy(st,mob_db(class_)->name); break;
- case 2: script_pushstrcopy(st,mob_db(class_)->jname); break;
- case 3: script_pushint(st,mob_db(class_)->lv); break;
- case 4: script_pushint(st,mob_db(class_)->status.max_hp); break;
- case 5: script_pushint(st,mob_db(class_)->status.max_sp); break;
- case 6: script_pushint(st,mob_db(class_)->base_exp); break;
- case 7: script_pushint(st,mob_db(class_)->job_exp); break;
- default:
- script_pushint(st,0);
- break;
+ case 1: script_pushstrcopy(st,mob_db(class_)->name); break;
+ case 2: script_pushstrcopy(st,mob_db(class_)->jname); break;
+ case 3: script_pushint(st,mob_db(class_)->lv); break;
+ case 4: script_pushint(st,mob_db(class_)->status.max_hp); break;
+ case 5: script_pushint(st,mob_db(class_)->status.max_sp); break;
+ case 6: script_pushint(st,mob_db(class_)->base_exp); break;
+ case 7: script_pushint(st,mob_db(class_)->job_exp); break;
+ default:
+ script_pushint(st,0);
+ break;
}
- return 0;
+ return true;
}
/*==========================================
* Summon guardians [Valaris]
* guardian("<map name>",<x>,<y>,"<name to show>",<mob id>{,"<event label>"}{,<guardian index>}) -> <id>
*------------------------------------------*/
-BUILDIN_FUNC(guardian)
+BUILDIN(guardian)
{
int class_=0,x=0,y=0,guardian=0;
const char *str,*map,*evt="";
struct script_data *data;
bool has_index = false;
-
+
map =script_getstr(st,2);
x =script_getnum(st,3);
y =script_getnum(st,4);
str =script_getstr(st,5);
class_=script_getnum(st,6);
-
+
if( script_hasdata(st,8) )
{// "<event label>",<guardian index>
evt=script_getstr(st,7);
@@ -11745,24 +11536,24 @@ BUILDIN_FUNC(guardian)
} else {
ShowError("script:guardian: invalid data type for argument #6 (from 1)\n");
script_reportdata(data);
- return 1;
+ return false;
}
}
-
+
check_event(st, evt);
script_pushint(st, mob_spawn_guardian(map,x,y,str,class_,evt,guardian,has_index));
-
- return 0;
+
+ return true;
}
/*==========================================
* Invisible Walls [Zephyrus]
*------------------------------------------*/
-BUILDIN_FUNC(setwall)
+BUILDIN(setwall)
{
const char *map, *name;
int x, y, m, size, dir;
bool shootable;
-
+
map = script_getstr(st,2);
x = script_getnum(st,3);
y = script_getnum(st,4);
@@ -11770,19 +11561,19 @@ BUILDIN_FUNC(setwall)
dir = script_getnum(st,6);
shootable = script_getnum(st,7);
name = script_getstr(st,8);
-
+
if( (m = map_mapname2mapid(map)) < 0 )
- return 0; // Invalid Map
-
+ return true; // Invalid Map
+
map_iwall_set(m, x, y, size, dir, shootable, name);
- return 0;
+ return true;
}
-BUILDIN_FUNC(delwall)
+BUILDIN(delwall)
{
const char *name = script_getstr(st,2);
map_iwall_remove(name);
-
- return 0;
+
+ return true;
}
/// Retrieves various information about the specified guardian.
@@ -11792,53 +11583,53 @@ BUILDIN_FUNC(delwall)
/// 1 - maximum hp
/// 2 - current hp
///
-BUILDIN_FUNC(guardianinfo)
+BUILDIN(guardianinfo)
{
const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL);
int id = script_getnum(st,3);
int type = script_getnum(st,4);
-
+
struct guild_castle* gc = guild_mapname2gc(mapname);
struct mob_data* gd;
-
+
if( gc == NULL || id < 0 || id >= MAX_GUARDIANS )
{
script_pushint(st,-1);
- return 0;
+ return true;
}
-
+
if( type == 0 )
script_pushint(st, gc->guardian[id].visible);
else
- if( !gc->guardian[id].visible )
- script_pushint(st,-1);
- else
- if( (gd = map_id2md(gc->guardian[id].id)) == NULL )
- script_pushint(st,-1);
- else
- {
- if ( type == 1 ) script_pushint(st,gd->status.max_hp);
- else if( type == 2 ) script_pushint(st,gd->status.hp);
- else
+ if( !gc->guardian[id].visible )
script_pushint(st,-1);
- }
-
- return 0;
+ else
+ if( (gd = map_id2md(gc->guardian[id].id)) == NULL )
+ script_pushint(st,-1);
+ else
+ {
+ if ( type == 1 ) script_pushint(st,gd->status.max_hp);
+ else if( type == 2 ) script_pushint(st,gd->status.hp);
+ else
+ script_pushint(st,-1);
+ }
+
+ return true;
}
/*==========================================
* Get the item name by item_id or null
*------------------------------------------*/
-BUILDIN_FUNC(getitemname)
+BUILDIN(getitemname)
{
int item_id=0;
struct item_data *i_data;
char *item_name;
struct script_data *data;
-
+
data=script_getdata(st,2);
get_val(st,data);
-
+
if( data_isstring(data) ){
const char *name=conv_str(st,data);
struct item_data *item_data = itemdb_searchname(name);
@@ -11846,36 +11637,36 @@ BUILDIN_FUNC(getitemname)
item_id=item_data->nameid;
}else
item_id=conv_num(st,data);
-
+
i_data = itemdb_exists(item_id);
if (i_data == NULL)
{
script_pushconststr(st,"null");
- return 0;
+ return true;
}
item_name=(char *)aMalloc(ITEM_NAME_LENGTH*sizeof(char));
-
+
memcpy(item_name, i_data->jname, ITEM_NAME_LENGTH);
script_pushstr(st,item_name);
- return 0;
+ return true;
}
/*==========================================
* Returns number of slots an item has. [Skotlex]
*------------------------------------------*/
-BUILDIN_FUNC(getitemslots)
+BUILDIN(getitemslots)
{
int item_id;
struct item_data *i_data;
-
+
item_id=script_getnum(st,2);
-
+
i_data = itemdb_exists(item_id);
-
+
if (i_data)
script_pushint(st,i_data->slot);
else
script_pushint(st,-1);
- return 0;
+ return true;
}
// TODO: add matk here if needed/once we get rid of RENEWAL
@@ -11883,103 +11674,103 @@ BUILDIN_FUNC(getitemslots)
/*==========================================
* Returns some values of an item [Lupus]
* Price, Weight, etc...
- getiteminfo(itemID,n), where n
- 0 value_buy;
- 1 value_sell;
- 2 type;
- 3 maxchance = Max drop chance of this item e.g. 1 = 0.01% , etc..
- if = 0, then monsters don't drop it at all (rare or a quest item)
- if = -1, then this item is sold in NPC shops only
- 4 sex;
- 5 equip;
- 6 weight;
- 7 atk;
- 8 def;
- 9 range;
- 10 slot;
- 11 look;
- 12 elv;
- 13 wlv;
- 14 view id
+ getiteminfo(itemID,n), where n
+ 0 value_buy;
+ 1 value_sell;
+ 2 type;
+ 3 maxchance = Max drop chance of this item e.g. 1 = 0.01% , etc..
+ if = 0, then monsters don't drop it at all (rare or a quest item)
+ if = -1, then this item is sold in NPC shops only
+ 4 sex;
+ 5 equip;
+ 6 weight;
+ 7 atk;
+ 8 def;
+ 9 range;
+ 10 slot;
+ 11 look;
+ 12 elv;
+ 13 wlv;
+ 14 view id
*------------------------------------------*/
-BUILDIN_FUNC(getiteminfo)
+BUILDIN(getiteminfo)
{
int item_id,n;
int *item_arr;
struct item_data *i_data;
-
+
item_id = script_getnum(st,2);
n = script_getnum(st,3);
i_data = itemdb_exists(item_id);
-
+
if (i_data && n>=0 && n<=14) {
item_arr = (int*)&i_data->value_buy;
script_pushint(st,item_arr[n]);
} else
script_pushint(st,-1);
- return 0;
+ return true;
}
/*==========================================
* Set some values of an item [Lupus]
* Price, Weight, etc...
- setiteminfo(itemID,n,Value), where n
- 0 value_buy;
- 1 value_sell;
- 2 type;
- 3 maxchance = Max drop chance of this item e.g. 1 = 0.01% , etc..
- if = 0, then monsters don't drop it at all (rare or a quest item)
- if = -1, then this item is sold in NPC shops only
- 4 sex;
- 5 equip;
- 6 weight;
- 7 atk;
- 8 def;
- 9 range;
- 10 slot;
- 11 look;
- 12 elv;
- 13 wlv;
- 14 view id
- * Returns Value or -1 if the wrong field's been set
+ setiteminfo(itemID,n,Value), where n
+ 0 value_buy;
+ 1 value_sell;
+ 2 type;
+ 3 maxchance = Max drop chance of this item e.g. 1 = 0.01% , etc..
+ if = 0, then monsters don't drop it at all (rare or a quest item)
+ if = -1, then this item is sold in NPC shops only
+ 4 sex;
+ 5 equip;
+ 6 weight;
+ 7 atk;
+ 8 def;
+ 9 range;
+ 10 slot;
+ 11 look;
+ 12 elv;
+ 13 wlv;
+ 14 view id
+ * Returns Value or -1 if the wrong field's been set
*------------------------------------------*/
-BUILDIN_FUNC(setiteminfo)
+BUILDIN(setiteminfo)
{
int item_id,n,value;
int *item_arr;
struct item_data *i_data;
-
+
item_id = script_getnum(st,2);
n = script_getnum(st,3);
value = script_getnum(st,4);
i_data = itemdb_exists(item_id);
-
+
if (i_data && n>=0 && n<=14) {
item_arr = (int*)&i_data->value_buy;
item_arr[n] = value;
script_pushint(st,value);
} else
script_pushint(st,-1);
- return 0;
+ return true;
}
/*==========================================
* Returns value from equipped item slot n [Lupus]
- getequipcardid(num,slot)
- where
- num = eqip position slot
- slot = 0,1,2,3 (Card Slot N)
-
- This func returns CARD ID, 255,254,-255 (for card 0, if the item is produced)
- it's useful when you want to check item cards or if it's signed
- Useful for such quests as "Sign this refined item with players name" etc
- Hat[0] +4 -> Player's Hat[0] +4
+ getequipcardid(num,slot)
+ where
+ num = eqip position slot
+ slot = 0,1,2,3 (Card Slot N)
+
+ This func returns CARD ID, 255,254,-255 (for card 0, if the item is produced)
+ it's useful when you want to check item cards or if it's signed
+ Useful for such quests as "Sign this refined item with players name" etc
+ Hat[0] +4 -> Player's Hat[0] +4
*------------------------------------------*/
-BUILDIN_FUNC(getequipcardid)
+BUILDIN(getequipcardid)
{
int i=-1,num,slot;
TBL_PC *sd;
-
+
num=script_getnum(st,2);
slot=script_getnum(st,3);
sd=script_rid2sd(st);
@@ -11989,22 +11780,22 @@ BUILDIN_FUNC(getequipcardid)
script_pushint(st,sd->status.inventory[i].card[slot]);
else
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
/*==========================================
* petskillbonus [Valaris] //Rewritten by [Skotlex]
*------------------------------------------*/
-BUILDIN_FUNC(petskillbonus)
+BUILDIN(petskillbonus)
{
struct pet_data *pd;
-
+
TBL_PC *sd=script_rid2sd(st);
-
+
if(sd==NULL || sd->pd==NULL)
- return 0;
-
+ return true;
+
pd=sd->pd;
if (pd->bonus)
{ //Clear previous bonus
@@ -12012,43 +11803,43 @@ BUILDIN_FUNC(petskillbonus)
delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
} else //init
pd->bonus = (struct pet_bonus *) aMalloc(sizeof(struct pet_bonus));
-
+
pd->bonus->type=script_getnum(st,2);
pd->bonus->val=script_getnum(st,3);
pd->bonus->duration=script_getnum(st,4);
pd->bonus->delay=script_getnum(st,5);
-
+
if (pd->state.skillbonus == 1)
pd->state.skillbonus=0; // waiting state
-
+
// wait for timer to start
if (battle_config.pet_equip_required && pd->pet.equip == 0)
pd->bonus->timer = INVALID_TIMER;
else
pd->bonus->timer = add_timer(gettick()+pd->bonus->delay*1000, pet_skill_bonus_timer, sd->bl.id, 0);
-
- return 0;
+
+ return true;
}
/*==========================================
* pet looting [Valaris] //Rewritten by [Skotlex]
*------------------------------------------*/
-BUILDIN_FUNC(petloot)
+BUILDIN(petloot)
{
int max;
struct pet_data *pd;
TBL_PC *sd=script_rid2sd(st);
-
+
if(sd==NULL || sd->pd==NULL)
- return 0;
-
+ return true;
+
max=script_getnum(st,2);
-
+
if(max < 1)
max = 1; //Let'em loot at least 1 item.
else if (max > MAX_PETLOOT_SIZE)
max = MAX_PETLOOT_SIZE;
-
+
pd = sd->pd;
if (pd->loot != NULL)
{ //Release whatever was there already and reallocate memory
@@ -12057,14 +11848,14 @@ BUILDIN_FUNC(petloot)
}
else
pd->loot = (struct pet_loot *)aMalloc(sizeof(struct pet_loot));
-
+
pd->loot->item = (struct item *)aCalloc(max,sizeof(struct item));
-
+
pd->loot->max=max;
pd->loot->count = 0;
pd->loot->weight = 0;
-
- return 0;
+
+ return true;
}
/*==========================================
* Set arrays with info of all sd inventory :
@@ -12073,13 +11864,13 @@ BUILDIN_FUNC(petloot)
* @inventorylist_card(0..3), @inventorylist_expire
* @inventorylist_count = scalar
*------------------------------------------*/
-BUILDIN_FUNC(getinventorylist)
+BUILDIN(getinventorylist)
{
TBL_PC *sd=script_rid2sd(st);
char card_var[NAME_LENGTH];
-
+
int i,j=0,k;
- if(!sd) return 0;
+ if(!sd) return true;
for(i=0;i<MAX_INVENTORY;i++){
if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].amount > 0){
pc_setreg(sd,reference_uid(add_str("@inventorylist_id"), j),sd->status.inventory[i].nameid);
@@ -12098,14 +11889,14 @@ BUILDIN_FUNC(getinventorylist)
}
}
pc_setreg(sd,add_str("@inventorylist_count"),j);
- return 0;
+ return true;
}
-BUILDIN_FUNC(getskilllist)
+BUILDIN(getskilllist)
{
TBL_PC *sd=script_rid2sd(st);
int i,j=0;
- if(!sd) return 0;
+ if(!sd) return true;
for(i=0;i<MAX_SKILL;i++){
if(sd->status.skill[i].id > 0 && sd->status.skill[i].lv > 0){
pc_setreg(sd,reference_uid(add_str("@skilllist_id"), j),sd->status.skill[i].id);
@@ -12115,83 +11906,83 @@ BUILDIN_FUNC(getskilllist)
}
}
pc_setreg(sd,add_str("@skilllist_count"),j);
- return 0;
+ return true;
}
-BUILDIN_FUNC(clearitem)
+BUILDIN(clearitem)
{
TBL_PC *sd=script_rid2sd(st);
int i;
- if(sd==NULL) return 0;
+ if(sd==NULL) return true;
for (i=0; i<MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount) {
pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_SCRIPT);
}
}
- return 0;
+ return true;
}
/*==========================================
* Disguise Player (returns Mob/NPC ID if success, 0 on fail)
*------------------------------------------*/
-BUILDIN_FUNC(disguise)
+BUILDIN(disguise)
{
int id;
TBL_PC* sd = script_rid2sd(st);
- if (sd == NULL) return 0;
-
+ if (sd == NULL) return true;
+
id = script_getnum(st,2);
-
+
if (mobdb_checkid(id) || npcdb_checkid(id)) {
pc_disguise(sd, id);
script_pushint(st,id);
} else
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
/*==========================================
* Undisguise Player (returns 1 if success, 0 on fail)
*------------------------------------------*/
-BUILDIN_FUNC(undisguise)
+BUILDIN(undisguise)
{
TBL_PC* sd = script_rid2sd(st);
- if (sd == NULL) return 0;
-
+ if (sd == NULL) return true;
+
if (sd->disguise) {
pc_disguise(sd, 0);
script_pushint(st,0);
} else {
script_pushint(st,1);
}
- return 0;
+ return true;
}
/*==========================================
* Transform a bl to another _class,
* @type unused
*------------------------------------------*/
-BUILDIN_FUNC(classchange)
+BUILDIN(classchange)
{
int _class,type;
struct block_list *bl=map_id2bl(st->oid);
-
- if(bl==NULL) return 0;
-
+
+ if(bl==NULL) return true;
+
_class=script_getnum(st,2);
type=script_getnum(st,3);
clif->class_change(bl,_class,type);
- return 0;
+ return true;
}
/*==========================================
* Display an effect
*------------------------------------------*/
-BUILDIN_FUNC(misceffect)
+BUILDIN(misceffect)
{
int type;
-
+
type=script_getnum(st,2);
if(st->oid && st->oid != fake_nd->bl.id) {
struct block_list *bl = map_id2bl(st->oid);
@@ -12202,39 +11993,39 @@ BUILDIN_FUNC(misceffect)
if(sd)
clif->specialeffect(&sd->bl,type,AREA);
}
- return 0;
+ return true;
}
/*==========================================
* Play a BGM on a single client [Rikter/Yommy]
*------------------------------------------*/
-BUILDIN_FUNC(playBGM)
+BUILDIN(playBGM)
{
const char* name;
struct map_session_data* sd;
-
+
if( ( sd = script_rid2sd(st) ) != NULL )
{
name = script_getstr(st,2);
-
+
clif->playBGM(sd, name);
}
-
- return 0;
+
+ return true;
}
static int playBGM_sub(struct block_list* bl,va_list ap)
{
const char* name = va_arg(ap,const char*);
-
+
clif->playBGM(BL_CAST(BL_PC, bl), name);
-
+
return 0;
}
static int playBGM_foreachpc_sub(struct map_session_data* sd, va_list args)
{
const char* name = va_arg(args, const char*);
-
+
clif->playBGM(sd, name);
return 0;
}
@@ -12242,12 +12033,12 @@ static int playBGM_foreachpc_sub(struct map_session_data* sd, va_list args)
/*==========================================
* Play a BGM on multiple client [Rikter/Yommy]
*------------------------------------------*/
-BUILDIN_FUNC(playBGMall)
+BUILDIN(playBGMall)
{
const char* name;
-
+
name = script_getstr(st,2);
-
+
if( script_hasdata(st,7) )
{// specified part of map
const char* map = script_getstr(st,3);
@@ -12255,133 +12046,133 @@ BUILDIN_FUNC(playBGMall)
int y0 = script_getnum(st,5);
int x1 = script_getnum(st,6);
int y1 = script_getnum(st,7);
-
+
map_foreachinarea(playBGM_sub, map_mapname2mapid(map), x0, y0, x1, y1, BL_PC, name);
}
else if( script_hasdata(st,3) )
{// entire map
const char* map = script_getstr(st,3);
-
+
map_foreachinmap(playBGM_sub, map_mapname2mapid(map), BL_PC, name);
}
else
{// entire server
map_foreachpc(&playBGM_foreachpc_sub, name);
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Play a .wav sound for sd
*------------------------------------------*/
-BUILDIN_FUNC(soundeffect)
+BUILDIN(soundeffect)
{
TBL_PC* sd = script_rid2sd(st);
const char* name = script_getstr(st,2);
int type = script_getnum(st,3);
-
+
if(sd)
{
clif->soundeffect(sd,&sd->bl,name,type);
}
- return 0;
+ return true;
}
int soundeffect_sub(struct block_list* bl,va_list ap)
{
char* name = va_arg(ap,char*);
int type = va_arg(ap,int);
-
+
clif->soundeffect((TBL_PC *)bl, bl, name, type);
-
- return 0;
+
+ return true;
}
/*==========================================
* Play a sound effect (.wav) on multiple clients
* soundeffectall "<filepath>",<type>{,"<map name>"}{,<x0>,<y0>,<x1>,<y1>};
*------------------------------------------*/
-BUILDIN_FUNC(soundeffectall)
+BUILDIN(soundeffectall)
{
struct block_list* bl;
const char* name;
int type;
-
+
bl = (st->rid) ? &(script_rid2sd(st)->bl) : map_id2bl(st->oid);
if (!bl)
- return 0;
-
+ return true;
+
name = script_getstr(st,2);
type = script_getnum(st,3);
-
+
//FIXME: enumerating map squares (map_foreach) is slower than enumerating the list of online players (map_foreachpc?) [ultramage]
-
+
if(!script_hasdata(st,4))
{ // area around
clif->soundeffectall(bl, name, type, AREA);
}
else
- if(!script_hasdata(st,5))
- { // entire map
- const char* map = script_getstr(st,4);
- map_foreachinmap(soundeffect_sub, map_mapname2mapid(map), BL_PC, name, type);
- }
- else
- if(script_hasdata(st,8))
- { // specified part of map
- const char* map = script_getstr(st,4);
- int x0 = script_getnum(st,5);
- int y0 = script_getnum(st,6);
- int x1 = script_getnum(st,7);
- int y1 = script_getnum(st,8);
- map_foreachinarea(soundeffect_sub, map_mapname2mapid(map), x0, y0, x1, y1, BL_PC, name, type);
- }
- else
- {
- ShowError("buildin_soundeffectall: insufficient arguments for specific area broadcast.\n");
- }
-
- return 0;
+ if(!script_hasdata(st,5))
+ { // entire map
+ const char* map = script_getstr(st,4);
+ map_foreachinmap(soundeffect_sub, map_mapname2mapid(map), BL_PC, name, type);
+ }
+ else
+ if(script_hasdata(st,8))
+ { // specified part of map
+ const char* map = script_getstr(st,4);
+ int x0 = script_getnum(st,5);
+ int y0 = script_getnum(st,6);
+ int x1 = script_getnum(st,7);
+ int y1 = script_getnum(st,8);
+ map_foreachinarea(soundeffect_sub, map_mapname2mapid(map), x0, y0, x1, y1, BL_PC, name, type);
+ }
+ else
+ {
+ ShowError("buildin_soundeffectall: insufficient arguments for specific area broadcast.\n");
+ }
+
+ return true;
}
/*==========================================
* pet status recovery [Valaris] / Rewritten by [Skotlex]
*------------------------------------------*/
-BUILDIN_FUNC(petrecovery)
+BUILDIN(petrecovery)
{
struct pet_data *pd;
TBL_PC *sd=script_rid2sd(st);
-
+
if(sd==NULL || sd->pd==NULL)
- return 0;
-
+ return true;
+
pd=sd->pd;
-
+
if (pd->recovery)
{ //Halt previous bonus
if (pd->recovery->timer != INVALID_TIMER)
delete_timer(pd->recovery->timer, pet_recovery_timer);
} else //Init
pd->recovery = (struct pet_recovery *)aMalloc(sizeof(struct pet_recovery));
-
+
pd->recovery->type = (sc_type)script_getnum(st,2);
pd->recovery->delay = script_getnum(st,3);
pd->recovery->timer = INVALID_TIMER;
-
- return 0;
+
+ return true;
}
/*==========================================
* pet healing [Valaris] //Rewritten by [Skotlex]
*------------------------------------------*/
-BUILDIN_FUNC(petheal)
+BUILDIN(petheal)
{
struct pet_data *pd;
TBL_PC *sd=script_rid2sd(st);
-
+
if(sd==NULL || sd->pd==NULL)
- return 0;
-
+ return true;
+
pd=sd->pd;
if (pd->s_skill)
{ //Clear previous skill
@@ -12394,21 +12185,21 @@ BUILDIN_FUNC(petheal)
}
} else //init memory
pd->s_skill = (struct pet_skill_support *) aMalloc(sizeof(struct pet_skill_support));
-
+
pd->s_skill->id=0; //This id identifies that it IS petheal rather than pet_skillsupport
//Use the lv as the amount to heal
pd->s_skill->lv=script_getnum(st,2);
pd->s_skill->delay=script_getnum(st,3);
pd->s_skill->hp=script_getnum(st,4);
pd->s_skill->sp=script_getnum(st,5);
-
+
//Use delay as initial offset to avoid skill/heal exploits
if (battle_config.pet_equip_required && pd->pet.equip == 0)
pd->s_skill->timer = INVALID_TIMER;
else
pd->s_skill->timer = add_timer(gettick()+pd->s_skill->delay*1000,pet_heal_timer,sd->bl.id,0);
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -12416,25 +12207,25 @@ BUILDIN_FUNC(petheal)
*------------------------------------------*/
/// petskillattack <skill id>,<level>,<rate>,<bonusrate>
/// petskillattack "<skill name>",<level>,<rate>,<bonusrate>
-BUILDIN_FUNC(petskillattack)
+BUILDIN(petskillattack)
{
struct pet_data *pd;
TBL_PC *sd=script_rid2sd(st);
-
+
if(sd==NULL || sd->pd==NULL)
- return 0;
-
+ return true;
+
pd=sd->pd;
if (pd->a_skill == NULL)
pd->a_skill = (struct pet_skill_attack *)aMalloc(sizeof(struct pet_skill_attack));
-
+
pd->a_skill->id=( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
pd->a_skill->lv=script_getnum(st,3);
pd->a_skill->div_ = 0;
pd->a_skill->rate=script_getnum(st,4);
pd->a_skill->bonusrate=script_getnum(st,5);
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -12442,25 +12233,25 @@ BUILDIN_FUNC(petskillattack)
*------------------------------------------*/
/// petskillattack2 <skill id>,<level>,<div>,<rate>,<bonusrate>
/// petskillattack2 "<skill name>",<level>,<div>,<rate>,<bonusrate>
-BUILDIN_FUNC(petskillattack2)
+BUILDIN(petskillattack2)
{
struct pet_data *pd;
TBL_PC *sd=script_rid2sd(st);
-
+
if(sd==NULL || sd->pd==NULL)
- return 0;
-
+ return true;
+
pd=sd->pd;
if (pd->a_skill == NULL)
pd->a_skill = (struct pet_skill_attack *)aMalloc(sizeof(struct pet_skill_attack));
-
+
pd->a_skill->id=( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
pd->a_skill->lv=script_getnum(st,3);
pd->a_skill->div_ = script_getnum(st,4);
pd->a_skill->rate=script_getnum(st,5);
pd->a_skill->bonusrate=script_getnum(st,6);
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -12468,14 +12259,14 @@ BUILDIN_FUNC(petskillattack2)
*------------------------------------------*/
/// petskillsupport <skill id>,<level>,<delay>,<hp>,<sp>
/// petskillsupport "<skill name>",<level>,<delay>,<hp>,<sp>
-BUILDIN_FUNC(petskillsupport)
+BUILDIN(petskillsupport)
{
struct pet_data *pd;
TBL_PC *sd=script_rid2sd(st);
-
+
if(sd==NULL || sd->pd==NULL)
- return 0;
-
+ return true;
+
pd=sd->pd;
if (pd->s_skill)
{ //Clear previous skill
@@ -12488,20 +12279,20 @@ BUILDIN_FUNC(petskillsupport)
}
} else //init memory
pd->s_skill = (struct pet_skill_support *) aMalloc(sizeof(struct pet_skill_support));
-
+
pd->s_skill->id=( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
pd->s_skill->lv=script_getnum(st,3);
pd->s_skill->delay=script_getnum(st,4);
pd->s_skill->hp=script_getnum(st,5);
pd->s_skill->sp=script_getnum(st,6);
-
+
//Use delay as initial offset to avoid skill/heal exploits
if (battle_config.pet_equip_required && pd->pet.equip == 0)
pd->s_skill->timer = INVALID_TIMER;
else
pd->s_skill->timer = add_timer(gettick()+pd->s_skill->delay*1000,pet_skill_support_timer,sd->bl.id,0);
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -12509,17 +12300,17 @@ BUILDIN_FUNC(petskillsupport)
*------------------------------------------*/
/// skilleffect <skill id>,<level>
/// skilleffect "<skill name>",<level>
-BUILDIN_FUNC(skilleffect)
+BUILDIN(skilleffect)
{
TBL_PC *sd;
-
+
uint16 skill_id=( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
uint16 skill_lv=script_getnum(st,3);
sd=script_rid2sd(st);
-
+
clif->skill_nodamage(&sd->bl,&sd->bl,skill_id,skill_lv,1);
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -12527,33 +12318,33 @@ BUILDIN_FUNC(skilleffect)
*------------------------------------------*/
/// npcskilleffect <skill id>,<level>,<x>,<y>
/// npcskilleffect "<skill name>",<level>,<x>,<y>
-BUILDIN_FUNC(npcskilleffect)
+BUILDIN(npcskilleffect)
{
struct block_list *bl= map_id2bl(st->oid);
-
+
uint16 skill_id=( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
uint16 skill_lv=script_getnum(st,3);
int x=script_getnum(st,4);
int y=script_getnum(st,5);
-
+
if (bl)
clif->skill_poseffect(bl,skill_id,skill_lv,x,y,gettick());
-
- return 0;
+
+ return true;
}
/*==========================================
* Special effects [Valaris]
*------------------------------------------*/
-BUILDIN_FUNC(specialeffect)
+BUILDIN(specialeffect)
{
struct block_list *bl=map_id2bl(st->oid);
int type = script_getnum(st,2);
enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA;
-
+
if(bl==NULL)
- return 0;
-
+ return true;
+
if( script_hasdata(st,4) )
{
TBL_NPC *nd = npc_name2id(script_getstr(st,4));
@@ -12570,36 +12361,36 @@ BUILDIN_FUNC(specialeffect)
clif->specialeffect(bl, type, target);
}
}
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(specialeffect2)
+BUILDIN(specialeffect2)
{
TBL_PC *sd=script_rid2sd(st);
int type = script_getnum(st,2);
enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA;
-
+
if( script_hasdata(st,4) )
sd = map_nick2sd(script_getstr(st,4));
-
+
if (sd)
clif->specialeffect(&sd->bl, type, target);
-
- return 0;
+
+ return true;
}
/*==========================================
* Nude [Valaris]
*------------------------------------------*/
-BUILDIN_FUNC(nude)
+BUILDIN(nude)
{
TBL_PC *sd = script_rid2sd(st);
int i, calcflag = 0;
-
+
if( sd == NULL )
- return 0;
-
+ return true;
+
for( i = 0 ; i < EQI_MAX; i++ ) {
if( sd->equip_index[ i ] >= 0 ) {
if( !calcflag )
@@ -12607,32 +12398,32 @@ BUILDIN_FUNC(nude)
pc_unequipitem( sd , sd->equip_index[ i ] , 2);
}
}
-
+
if( calcflag )
status_calc_pc(sd,0);
-
- return 0;
+
+ return true;
}
/*==========================================
* gmcommand [MouseJstr]
*------------------------------------------*/
-BUILDIN_FUNC(atcommand)
+BUILDIN(atcommand)
{
TBL_PC dummy_sd;
TBL_PC* sd;
int fd;
const char* cmd;
-
+
cmd = script_getstr(st,2);
-
+
if (st->rid) {
sd = script_rid2sd(st);
fd = sd->fd;
} else { //Use a dummy character.
sd = &dummy_sd;
fd = 0;
-
+
memset(&dummy_sd, 0, sizeof(TBL_PC));
if (st->oid)
{
@@ -12642,38 +12433,38 @@ BUILDIN_FUNC(atcommand)
safestrncpy(dummy_sd.status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH);
}
}
-
- if (!is_atcommand(fd, sd, cmd, 0)) {
+
+ if (!atcommand->parse(fd, sd, cmd, 0)) {
ShowWarning("script: buildin_atcommand: failed to execute command '%s'\n", cmd);
script_reportsrc(st);
- return 1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Displays a message for the player only (like system messages like "you got an apple" )
*------------------------------------------*/
-BUILDIN_FUNC(dispbottom)
+BUILDIN(dispbottom)
{
TBL_PC *sd=script_rid2sd(st);
const char *message;
message=script_getstr(st,2);
if(sd)
clif->disp_onlyself(sd,message,(int)strlen(message));
- return 0;
+ return true;
}
/*==========================================
* All The Players Full Recovery
* (HP/SP full restore and resurrect if need)
*------------------------------------------*/
-BUILDIN_FUNC(recovery)
+BUILDIN(recovery)
{
TBL_PC* sd;
struct s_mapiterator* iter;
-
+
iter = mapit_getallusers();
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
{
@@ -12684,25 +12475,25 @@ BUILDIN_FUNC(recovery)
clif->message(sd->fd,msg_txt(680));
}
mapit_free(iter);
- return 0;
+ return true;
}
/*==========================================
* Get your pet info: getpetinfo(n)
* n -> 0:pet_id 1:pet_class 2:pet_name
* 3:friendly 4:hungry, 5: rename flag.
*------------------------------------------*/
-BUILDIN_FUNC(getpetinfo)
+BUILDIN(getpetinfo)
{
TBL_PC *sd=script_rid2sd(st);
TBL_PET *pd;
int type=script_getnum(st,2);
-
+
if(!sd || !sd->pd) {
if (type == 2)
script_pushconststr(st,"null");
else
script_pushint(st,0);
- return 0;
+ return true;
}
pd = sd->pd;
switch(type){
@@ -12716,7 +12507,7 @@ BUILDIN_FUNC(getpetinfo)
script_pushint(st,0);
break;
}
- return 0;
+ return true;
}
/*==========================================
@@ -12725,12 +12516,12 @@ BUILDIN_FUNC(getpetinfo)
* 3:friendly 4:hungry, 5: rename flag.
* 6: level
*------------------------------------------*/
-BUILDIN_FUNC(gethominfo)
+BUILDIN(gethominfo)
{
TBL_PC *sd=script_rid2sd(st);
TBL_HOM *hd;
int type=script_getnum(st,2);
-
+
hd = sd?sd->hd:NULL;
if(!merc_is_hom_active(hd))
{
@@ -12738,9 +12529,9 @@ BUILDIN_FUNC(gethominfo)
script_pushconststr(st,"null");
else
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
switch(type){
case 0: script_pushint(st,hd->homunculus.hom_id); break;
case 1: script_pushint(st,hd->homunculus.class_); break;
@@ -12753,28 +12544,28 @@ BUILDIN_FUNC(gethominfo)
script_pushint(st,0);
break;
}
- return 0;
+ return true;
}
/// Retrieves information about character's mercenary
/// getmercinfo <type>[,<char id>];
-BUILDIN_FUNC(getmercinfo)
+BUILDIN(getmercinfo)
{
int type, char_id;
struct map_session_data* sd;
struct mercenary_data* md;
-
+
type = script_getnum(st,2);
-
+
if( script_hasdata(st,3) )
{
char_id = script_getnum(st,3);
-
+
if( ( sd = map_charid2sd(char_id) ) == NULL )
{
ShowError("buildin_getmercinfo: No such character (char_id=%d).\n", char_id);
script_pushnil(st);
- return 1;
+ return false;
}
}
else
@@ -12782,12 +12573,12 @@ BUILDIN_FUNC(getmercinfo)
if( ( sd = script_rid2sd(st) ) == NULL )
{
script_pushnil(st);
- return 0;
+ return true;
}
}
-
+
md = ( sd->status.mer_id && sd->md ) ? sd->md : NULL;
-
+
switch( type )
{
case 0: script_pushint(st,md ? md->mercenary.mercenary_id : 0); break;
@@ -12806,25 +12597,25 @@ BUILDIN_FUNC(getmercinfo)
default:
ShowError("buildin_getmercinfo: Invalid type %d (char_id=%d).\n", type, sd->status.char_id);
script_pushnil(st);
- return 1;
+ return false;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Shows wether your inventory(and equips) contain
- selected card or not.
- checkequipedcard(4001);
+ selected card or not.
+ checkequipedcard(4001);
*------------------------------------------*/
-BUILDIN_FUNC(checkequipedcard)
+BUILDIN(checkequipedcard)
{
TBL_PC *sd=script_rid2sd(st);
-
+
if(sd){
int n,i,c=0;
c=script_getnum(st,2);
-
+
for(i=0;i<MAX_INVENTORY;i++){
if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].amount && sd->inventory_data[i]){
if (itemdb_isspecial(sd->status.inventory[i].card[0]))
@@ -12832,17 +12623,17 @@ BUILDIN_FUNC(checkequipedcard)
for(n=0;n<sd->inventory_data[i]->slot;n++){
if(sd->status.inventory[i].card[n]==c){
script_pushint(st,1);
- return 0;
+ return true;
}
}
}
}
}
script_pushint(st,0);
- return 0;
+ return true;
}
-BUILDIN_FUNC(jump_zero)
+BUILDIN(jump_zero)
{
int sel;
sel=script_getnum(st,2);
@@ -12851,67 +12642,67 @@ BUILDIN_FUNC(jump_zero)
if( !data_islabel(script_getdata(st,3)) ){
ShowError("script: jump_zero: not label !\n");
st->state=END;
- return 1;
+ return false;
}
-
+
pos=script_getnum(st,3);
st->pos=pos;
st->state=GOTO;
}
- return 0;
+ return true;
}
/*==========================================
* movenpc [MouseJstr]
*------------------------------------------*/
-BUILDIN_FUNC(movenpc)
+BUILDIN(movenpc)
{
TBL_NPC *nd = NULL;
const char *npc;
int x,y;
-
+
npc = script_getstr(st,2);
x = script_getnum(st,3);
y = script_getnum(st,4);
-
+
if ((nd = npc_name2id(npc)) == NULL)
return -1;
-
+
if (script_hasdata(st,5))
nd->ud.dir = script_getnum(st,5) % 8;
npc_movenpc(nd, x, y);
- return 0;
+ return true;
}
/*==========================================
* message [MouseJstr]
*------------------------------------------*/
-BUILDIN_FUNC(message)
+BUILDIN(message)
{
const char *msg,*player;
TBL_PC *pl_sd = NULL;
-
+
player = script_getstr(st,2);
msg = script_getstr(st,3);
-
+
if((pl_sd=map_nick2sd((char *) player)) == NULL)
- return 0;
+ return true;
clif->message(pl_sd->fd, msg);
-
- return 0;
+
+ return true;
}
/*==========================================
* npctalk (sends message to surrounding area)
*------------------------------------------*/
-BUILDIN_FUNC(npctalk)
+BUILDIN(npctalk)
{
const char* str;
char name[NAME_LENGTH], message[256];
-
+
struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
str = script_getstr(st,2);
-
+
if(nd)
{
safestrncpy(name, nd->name, sizeof(name));
@@ -12919,36 +12710,36 @@ BUILDIN_FUNC(npctalk)
safesnprintf(message, sizeof(message), "%s : %s", name, str);
clif->disp_overhead(&nd->bl, message);
}
-
- return 0;
+
+ return true;
}
// change npc walkspeed [Valaris]
-BUILDIN_FUNC(npcspeed)
+BUILDIN(npcspeed)
{
struct npc_data* nd;
int speed;
-
+
speed = script_getnum(st,2);
nd =(struct npc_data *)map_id2bl(st->oid);
-
+
if( nd )
{
nd->speed = speed;
nd->ud.state.speed_changed = 1;
}
-
- return 0;
+
+ return true;
}
// make an npc walk to a position [Valaris]
-BUILDIN_FUNC(npcwalkto)
+BUILDIN(npcwalkto)
{
struct npc_data *nd=(struct npc_data *)map_id2bl(st->oid);
int x=0,y=0;
-
+
x=script_getnum(st,2);
y=script_getnum(st,3);
-
+
if(nd) {
if (!nd->status.hp) {
status_calc_npc(nd, true);
@@ -12957,66 +12748,66 @@ BUILDIN_FUNC(npcwalkto)
}
unit_walktoxy(&nd->bl,x,y,0);
}
-
- return 0;
+
+ return true;
}
// stop an npc's movement [Valaris]
-BUILDIN_FUNC(npcstop)
+BUILDIN(npcstop)
{
struct npc_data *nd=(struct npc_data *)map_id2bl(st->oid);
-
+
if(nd) {
unit_stop_walking(&nd->bl,1|4);
}
-
- return 0;
+
+ return true;
}
/*==========================================
* getlook char info. getlook(arg)
*------------------------------------------*/
-BUILDIN_FUNC(getlook)
-{
- int type,val;
- TBL_PC *sd;
- sd=script_rid2sd(st);
-
- type=script_getnum(st,2);
- val=-1;
- switch(type) {
- case LOOK_HAIR: val=sd->status.hair; break; //1
- case LOOK_WEAPON: val=sd->status.weapon; break; //2
- case LOOK_HEAD_BOTTOM: val=sd->status.head_bottom; break; //3
- case LOOK_HEAD_TOP: val=sd->status.head_top; break; //4
- case LOOK_HEAD_MID: val=sd->status.head_mid; break; //5
- case LOOK_HAIR_COLOR: val=sd->status.hair_color; break; //6
- case LOOK_CLOTHES_COLOR:val=sd->status.clothes_color; break; //7
- case LOOK_SHIELD: val=sd->status.shield; break; //8
- case LOOK_SHOES: break; //9
- case LOOK_ROBE: val=sd->status.robe; break; //12
- }
-
- script_pushint(st,val);
- return 0;
+BUILDIN(getlook)
+{
+ int type,val;
+ TBL_PC *sd;
+ sd=script_rid2sd(st);
+
+ type=script_getnum(st,2);
+ val=-1;
+ switch(type) {
+ case LOOK_HAIR: val=sd->status.hair; break; //1
+ case LOOK_WEAPON: val=sd->status.weapon; break; //2
+ case LOOK_HEAD_BOTTOM: val=sd->status.head_bottom; break; //3
+ case LOOK_HEAD_TOP: val=sd->status.head_top; break; //4
+ case LOOK_HEAD_MID: val=sd->status.head_mid; break; //5
+ case LOOK_HAIR_COLOR: val=sd->status.hair_color; break; //6
+ case LOOK_CLOTHES_COLOR:val=sd->status.clothes_color; break; //7
+ case LOOK_SHIELD: val=sd->status.shield; break; //8
+ case LOOK_SHOES: break; //9
+ case LOOK_ROBE: val=sd->status.robe; break; //12
+ }
+
+ script_pushint(st,val);
+ return true;
}
/*==========================================
* get char save point. argument: 0- map name, 1- x, 2- y
*------------------------------------------*/
-BUILDIN_FUNC(getsavepoint)
+BUILDIN(getsavepoint)
{
TBL_PC* sd;
int type;
-
+
sd = script_rid2sd(st);
if (sd == NULL) {
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
type = script_getnum(st,2);
-
+
switch(type) {
case 0: script_pushstrcopy(st,mapindex_id2name(sd->status.save_point.map)); break;
case 1: script_pushint(st,sd->status.save_point.x); break;
@@ -13025,69 +12816,69 @@ BUILDIN_FUNC(getsavepoint)
script_pushint(st,0);
break;
}
- return 0;
+ return true;
}
/*==========================================
- * Get position for char/npc/pet/mob objects. Added by Lorky
- *
- * int getMapXY(MapName$,MapX,MapY,type,[CharName$]);
- * where type:
- * MapName$ - String variable for output map name
- * MapX - Integer variable for output coord X
- * MapY - Integer variable for output coord Y
- * type - type of object
- * 0 - Character coord
- * 1 - NPC coord
- * 2 - Pet coord
- * 3 - Mob coord (not released)
- * 4 - Homun coord
- * 5 - Mercenary coord
- * 6 - Elemental coord
- * CharName$ - Name object. If miss or "this" the current object
- *
- * Return:
- * 0 - success
- * -1 - some error, MapName$,MapX,MapY contains unknown value.
- *------------------------------------------*/
-BUILDIN_FUNC(getmapxy)
+ * Get position for char/npc/pet/mob objects. Added by Lorky
+ *
+ * int getMapXY(MapName$,MapX,MapY,type,[CharName$]);
+ * where type:
+ * MapName$ - String variable for output map name
+ * MapX - Integer variable for output coord X
+ * MapY - Integer variable for output coord Y
+ * type - type of object
+ * 0 - Character coord
+ * 1 - NPC coord
+ * 2 - Pet coord
+ * 3 - Mob coord (not released)
+ * 4 - Homun coord
+ * 5 - Mercenary coord
+ * 6 - Elemental coord
+ * CharName$ - Name object. If miss or "this" the current object
+ *
+ * Return:
+ * 0 - success
+ * -1 - some error, MapName$,MapX,MapY contains unknown value.
+ *------------------------------------------*/
+BUILDIN(getmapxy)
{
struct block_list *bl = NULL;
TBL_PC *sd=NULL;
-
+
int num;
const char *name;
char prefix;
-
+
int x,y,type;
char mapname[MAP_NAME_LENGTH];
-
+
if( !data_isreference(script_getdata(st,2)) ){
ShowWarning("script: buildin_getmapxy: not mapname variable\n");
script_pushint(st,-1);
- return 1;
+ return false;
}
if( !data_isreference(script_getdata(st,3)) ){
ShowWarning("script: buildin_getmapxy: not mapx variable\n");
script_pushint(st,-1);
- return 1;
+ return false;
}
if( !data_isreference(script_getdata(st,4)) ){
ShowWarning("script: buildin_getmapxy: not mapy variable\n");
script_pushint(st,-1);
- return 1;
+ return false;
}
-
+
// Possible needly check function parameters on C_STR,C_INT,C_INT
type=script_getnum(st,5);
-
+
switch (type){
case 0: //Get Character Position
if( script_hasdata(st,6) )
sd=map_nick2sd(script_getstr(st,6));
else
sd=script_rid2sd(st);
-
+
if (sd)
bl = &sd->bl;
break;
@@ -13106,7 +12897,7 @@ BUILDIN_FUNC(getmapxy)
sd=map_nick2sd(script_getstr(st,6));
else
sd=script_rid2sd(st);
-
+
if (sd && sd->pd)
bl = &sd->pd->bl;
break;
@@ -13117,7 +12908,7 @@ BUILDIN_FUNC(getmapxy)
sd=map_nick2sd(script_getstr(st,6));
else
sd=script_rid2sd(st);
-
+
if (sd && sd->hd)
bl = &sd->hd->bl;
break;
@@ -13126,7 +12917,7 @@ BUILDIN_FUNC(getmapxy)
sd=map_nick2sd(script_getstr(st,6));
else
sd=script_rid2sd(st);
-
+
if (sd && sd->md)
bl = &sd->md->bl;
break;
@@ -13135,90 +12926,90 @@ BUILDIN_FUNC(getmapxy)
sd=map_nick2sd(script_getstr(st,6));
else
sd=script_rid2sd(st);
-
+
if (sd && sd->ed)
bl = &sd->ed->bl;
break;
default:
ShowWarning("script: buildin_getmapxy: Invalid type %d\n", type);
script_pushint(st,-1);
- return 1;
+ return false;
}
if (!bl) { //No object found.
script_pushint(st,-1);
- return 0;
+ return true;
}
-
+
x= bl->x;
y= bl->y;
safestrncpy(mapname, map[bl->m].name, MAP_NAME_LENGTH);
-
+
//Set MapName$
num=st->stack->stack_data[st->start+2].u.num;
name=get_str(num&0x00ffffff);
prefix=*name;
-
+
if(not_server_variable(prefix))
sd=script_rid2sd(st);
else
sd=NULL;
set_reg(st,sd,num,name,(void*)mapname,script_getref(st,2));
-
+
//Set MapX
num=st->stack->stack_data[st->start+3].u.num;
name=get_str(num&0x00ffffff);
prefix=*name;
-
+
if(not_server_variable(prefix))
sd=script_rid2sd(st);
else
sd=NULL;
- set_reg(st,sd,num,name,(void*)__64BPRTSIZE(x),script_getref(st,3));
-
+ set_reg(st,sd,num,name,(void*)__64BPTRSIZE(x),script_getref(st,3));
+
//Set MapY
num=st->stack->stack_data[st->start+4].u.num;
name=get_str(num&0x00ffffff);
prefix=*name;
-
+
if(not_server_variable(prefix))
sd=script_rid2sd(st);
else
sd=NULL;
- set_reg(st,sd,num,name,(void*)__64BPRTSIZE(y),script_getref(st,4));
-
+ set_reg(st,sd,num,name,(void*)__64BPTRSIZE(y),script_getref(st,4));
+
//Return Success value
script_pushint(st,0);
- return 0;
+ return true;
}
/*==========================================
* Allows player to write NPC logs (i.e. Bank NPC, etc) [Lupus]
*------------------------------------------*/
-BUILDIN_FUNC(logmes)
+BUILDIN(logmes)
{
const char *str;
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 1;
-
+ return false;
+
str = script_getstr(st,2);
- log_npc(sd,str);
- return 0;
+ logs->npc(sd,str);
+ return true;
}
-BUILDIN_FUNC(summon)
+BUILDIN(summon)
{
int _class, timeout=0;
const char *str,*event="";
TBL_PC *sd;
struct mob_data *md;
int tick = gettick();
-
+
sd=script_rid2sd(st);
- if (!sd) return 0;
-
+ if (!sd) return true;
+
str =script_getstr(st,2);
_class=script_getnum(st,3);
if( script_hasdata(st,4) )
@@ -13227,9 +13018,9 @@ BUILDIN_FUNC(summon)
event=script_getstr(st,5);
check_event(st, event);
}
-
+
clif->skill_poseffect(&sd->bl,AM_CALLHOMUN,1,sd->bl.x,sd->bl.y,tick);
-
+
md = mob_once_spawn_sub(&sd->bl, sd->bl.m, sd->bl.x, sd->bl.y, str, _class, event, SZ_SMALL, AI_NONE);
if (md) {
md->master_id=sd->bl.id;
@@ -13241,45 +13032,45 @@ BUILDIN_FUNC(summon)
clif->specialeffect(&md->bl,344,AREA);
sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
}
- return 0;
+ return true;
}
/*==========================================
* Checks whether it is daytime/nighttime
*------------------------------------------*/
-BUILDIN_FUNC(isnight)
+BUILDIN(isnight)
{
script_pushint(st,(night_flag == 1));
- return 0;
+ return true;
}
-BUILDIN_FUNC(isday)
+BUILDIN(isday)
{
script_pushint(st,(night_flag == 0));
- return 0;
+ return true;
}
/*================================================
* Check how many items/cards in the list are
* equipped - used for 2/15's cards patch [celest]
*------------------------------------------------*/
-BUILDIN_FUNC(isequippedcnt)
+BUILDIN(isequippedcnt)
{
TBL_PC *sd;
int i, j, k, id = 1;
int ret = 0;
-
+
sd = script_rid2sd(st);
if (!sd) { //If the player is not attached it is a script error anyway... but better prevent the map server from crashing...
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
for (i=0; id!=0; i++) {
FETCH (i+2, id) else id = 0;
if (id <= 0)
continue;
-
+
for (j=0; j<EQI_MAX; j++) {
int index;
index = sd->equip_index[j];
@@ -13287,10 +13078,10 @@ BUILDIN_FUNC(isequippedcnt)
if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index) continue;
if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == index) continue;
if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == index || sd->equip_index[EQI_HEAD_LOW] == index)) continue;
-
+
if(!sd->inventory_data[index])
continue;
-
+
if (itemdb_type(id) != IT_CARD) { //No card. Count amount in inventory.
if (sd->inventory_data[index]->nameid == id)
ret+= sd->status.inventory[index].amount;
@@ -13304,9 +13095,9 @@ BUILDIN_FUNC(isequippedcnt)
}
}
}
-
+
script_pushint(st,ret);
- return 0;
+ return true;
}
/*================================================
@@ -13315,7 +13106,7 @@ BUILDIN_FUNC(isequippedcnt)
* -- Items checked cannot be reused in another
* card set to prevent exploits
*------------------------------------------------*/
-BUILDIN_FUNC(isequipped)
+BUILDIN(isequipped)
{
TBL_PC *sd;
int i, j, k, id = 1;
@@ -13323,14 +13114,14 @@ BUILDIN_FUNC(isequipped)
int ret = -1;
//Original hash to reverse it when full check fails.
unsigned int setitem_hash = 0, setitem_hash2 = 0;
-
+
sd = script_rid2sd(st);
-
+
if (!sd) { //If the player is not attached it is a script error anyway... but better prevent the map server from crashing...
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
setitem_hash = sd->bonus.setitem_hash;
setitem_hash2 = sd->bonus.setitem_hash2;
for (i=0; id!=0; i++) {
@@ -13344,10 +13135,10 @@ BUILDIN_FUNC(isequipped)
if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index) continue;
if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == index) continue;
if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == index || sd->equip_index[EQI_HEAD_LOW] == index)) continue;
-
+
if(!sd->inventory_data[index])
continue;
-
+
if (itemdb_type(id) != IT_CARD) {
if (sd->inventory_data[index]->nameid != id)
continue;
@@ -13357,18 +13148,18 @@ BUILDIN_FUNC(isequipped)
if (sd->inventory_data[index]->slot == 0 ||
itemdb_isspecial(sd->status.inventory[index].card[0]))
continue;
-
+
for (k = 0; k < sd->inventory_data[index]->slot; k++)
{ //New hash system which should support up to 4 slots on any equipment. [Skotlex]
unsigned int hash = 0;
if (sd->status.inventory[index].card[k] != id)
continue;
-
+
hash = 1<<((j<5?j:j-5)*4 + k);
// check if card is already used by another set
if ( ( j < 5 ? sd->bonus.setitem_hash : sd->bonus.setitem_hash2 ) & hash)
continue;
-
+
// We have found a match
flag = 1;
// Set hash so this card cannot be used by another
@@ -13392,33 +13183,33 @@ BUILDIN_FUNC(isequipped)
sd->bonus.setitem_hash2 = setitem_hash2;
}
script_pushint(st,ret);
- return 0;
+ return true;
}
/*================================================
* Check how many given inserted cards in the CURRENT
* weapon - used for 2/15's cards patch [Lupus]
*------------------------------------------------*/
-BUILDIN_FUNC(cardscnt)
+BUILDIN(cardscnt)
{
TBL_PC *sd;
int i, k, id = 1;
int ret = 0;
int index;
-
+
sd = script_rid2sd(st);
-
+
for (i=0; id!=0; i++) {
FETCH (i+2, id) else id = 0;
if (id <= 0)
continue;
-
+
index = current_equip_item_index; //we get CURRENT WEAPON inventory index from status.c [Lupus]
if(index < 0) continue;
-
+
if(!sd->inventory_data[index])
continue;
-
+
if(itemdb_type(id) != IT_CARD) {
if (sd->inventory_data[index]->nameid == id)
ret+= sd->status.inventory[index].amount;
@@ -13432,47 +13223,47 @@ BUILDIN_FUNC(cardscnt)
}
}
script_pushint(st,ret);
-// script_pushint(st,current_equip_item_index);
- return 0;
+ // script_pushint(st,current_equip_item_index);
+ return true;
}
/*=======================================================
* Returns the refined number of the current item, or an
* item with inventory index specified
*-------------------------------------------------------*/
-BUILDIN_FUNC(getrefine)
+BUILDIN(getrefine)
{
TBL_PC *sd;
if ((sd = script_rid2sd(st))!= NULL)
script_pushint(st,sd->status.inventory[current_equip_item_index].refine);
else
script_pushint(st,0);
- return 0;
+ return true;
}
/*=======================================================
* Day/Night controls
*-------------------------------------------------------*/
-BUILDIN_FUNC(night)
+BUILDIN(night)
{
if (night_flag != 1) map_night_timer(night_timer_tid, 0, 0, 1);
- return 0;
+ return true;
}
-BUILDIN_FUNC(day)
+BUILDIN(day)
{
if (night_flag != 0) map_day_timer(day_timer_tid, 0, 0, 1);
- return 0;
+ return true;
}
//=======================================================
// Unequip [Spectre]
//-------------------------------------------------------
-BUILDIN_FUNC(unequip)
+BUILDIN(unequip)
{
int i;
size_t num;
TBL_PC *sd;
-
+
num = script_getnum(st,2);
sd = script_rid2sd(st);
if( sd != NULL && num >= 1 && num <= ARRAYLENGTH(equip) )
@@ -13481,138 +13272,138 @@ BUILDIN_FUNC(unequip)
if (i >= 0)
pc_unequipitem(sd,i,1|2);
}
- return 0;
+ return true;
}
-BUILDIN_FUNC(equip)
+BUILDIN(equip)
{
int nameid=0,i;
TBL_PC *sd;
struct item_data *item_data;
-
+
sd = script_rid2sd(st);
-
+
nameid=script_getnum(st,2);
if((item_data = itemdb_exists(nameid)) == NULL)
{
ShowError("wrong item ID : equipitem(%i)\n",nameid);
- return 1;
+ return false;
}
ARR_FIND( 0, MAX_INVENTORY, i, sd->status.inventory[i].nameid == nameid );
if( i < MAX_INVENTORY )
pc_equipitem(sd,i,item_data->equip);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(autoequip)
+BUILDIN(autoequip)
{
int nameid, flag;
struct item_data *item_data;
nameid=script_getnum(st,2);
flag=script_getnum(st,3);
-
+
if( ( item_data = itemdb_exists(nameid) ) == NULL )
{
ShowError("buildin_autoequip: Invalid item '%d'.\n", nameid);
- return 1;
+ return false;
}
-
+
if( !itemdb_isequip2(item_data) )
{
ShowError("buildin_autoequip: Item '%d' cannot be equipped.\n", nameid);
- return 1;
+ return false;
}
-
+
item_data->flag.autoequip = flag>0?1:0;
- return 0;
+ return true;
}
-BUILDIN_FUNC(setbattleflag)
+BUILDIN(setbattleflag)
{
const char *flag, *value;
-
+
flag = script_getstr(st,2);
value = script_getstr(st,3); // HACK: Retrieve number as string (auto-converted) for battle_set_value
-
+
if (battle->config_set_value(flag, value) == 0)
ShowWarning("buildin_setbattleflag: unknown battle_config flag '%s'\n",flag);
else
ShowInfo("buildin_setbattleflag: battle_config flag '%s' is now set to '%s'.\n",flag,value);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(getbattleflag)
+BUILDIN(getbattleflag)
{
const char *flag;
flag = script_getstr(st,2);
script_pushint(st,battle->config_get_value(flag));
- return 0;
+ return true;
}
//=======================================================
// strlen [Valaris]
//-------------------------------------------------------
-BUILDIN_FUNC(getstrlen)
+BUILDIN(getstrlen)
{
-
+
const char *str = script_getstr(st,2);
int len = (str) ? (int)strlen(str) : 0;
-
+
script_pushint(st,len);
- return 0;
+ return true;
}
//=======================================================
// isalpha [Valaris]
//-------------------------------------------------------
-BUILDIN_FUNC(charisalpha)
+BUILDIN(charisalpha)
{
const char *str=script_getstr(st,2);
int pos=script_getnum(st,3);
-
+
int val = ( str && pos >= 0 && (unsigned int)pos < strlen(str) ) ? ISALPHA( str[pos] ) != 0 : 0;
-
+
script_pushint(st,val);
- return 0;
+ return true;
}
//=======================================================
// charisupper <str>, <index>
//-------------------------------------------------------
-BUILDIN_FUNC(charisupper)
+BUILDIN(charisupper)
{
const char *str = script_getstr(st,2);
int pos = script_getnum(st,3);
-
+
int val = ( str && pos >= 0 && (unsigned int)pos < strlen(str) ) ? ISUPPER( str[pos] ) : 0;
-
+
script_pushint(st,val);
- return 0;
+ return true;
}
//=======================================================
// charislower <str>, <index>
//-------------------------------------------------------
-BUILDIN_FUNC(charislower)
+BUILDIN(charislower)
{
const char *str = script_getstr(st,2);
int pos = script_getnum(st,3);
-
+
int val = ( str && pos >= 0 && (unsigned int)pos < strlen(str) ) ? ISLOWER( str[pos] ) : 0;
-
+
script_pushint(st,val);
- return 0;
+ return true;
}
//=======================================================
// charat <str>, <index>
//-------------------------------------------------------
-BUILDIN_FUNC(charat) {
+BUILDIN(charat) {
const char *str = script_getstr(st,2);
int pos = script_getnum(st,3);
-
+
if( pos >= 0 && (unsigned int)pos < strlen(str) ) {
char output[2];
output[0] = str[pos];
@@ -13620,145 +13411,145 @@ BUILDIN_FUNC(charat) {
script_pushstrcopy(st, output);
} else
script_pushconststr(st, "");
- return 0;
+ return true;
}
//=======================================================
// setchar <string>, <char>, <index>
//-------------------------------------------------------
-BUILDIN_FUNC(setchar)
+BUILDIN(setchar)
{
const char *str = script_getstr(st,2);
const char *c = script_getstr(st,3);
int index = script_getnum(st,4);
char *output = aStrdup(str);
-
+
if(index >= 0 && index < strlen(output))
output[index] = *c;
-
+
script_pushstr(st, output);
- return 0;
+ return true;
}
//=======================================================
// insertchar <string>, <char>, <index>
//-------------------------------------------------------
-BUILDIN_FUNC(insertchar)
+BUILDIN(insertchar)
{
const char *str = script_getstr(st,2);
const char *c = script_getstr(st,3);
int index = script_getnum(st,4);
char *output;
size_t len = strlen(str);
-
+
if(index < 0)
index = 0;
else if(index > len)
index = len;
-
+
output = (char*)aMalloc(len + 2);
-
+
memcpy(output, str, index);
output[index] = c[0];
memcpy(&output[index+1], &str[index], len - index);
output[len+1] = '\0';
-
+
script_pushstr(st, output);
- return 0;
+ return true;
}
//=======================================================
// delchar <string>, <index>
//-------------------------------------------------------
-BUILDIN_FUNC(delchar)
+BUILDIN(delchar)
{
const char *str = script_getstr(st,2);
int index = script_getnum(st,3);
char *output;
size_t len = strlen(str);
-
+
if(index < 0 || index > len) {
//return original
output = aStrdup(str);
script_pushstr(st, output);
- return 0;
+ return true;
}
-
+
output = (char*)aMalloc(len);
-
+
memcpy(output, str, index);
memcpy(&output[index], &str[index+1], len - index);
-
+
script_pushstr(st, output);
- return 0;
+ return true;
}
//=======================================================
// strtoupper <str>
//-------------------------------------------------------
-BUILDIN_FUNC(strtoupper)
+BUILDIN(strtoupper)
{
const char *str = script_getstr(st,2);
char *output = aStrdup(str);
char *cursor = output;
-
+
while (*cursor != '\0') {
*cursor = TOUPPER(*cursor);
cursor++;
}
-
+
script_pushstr(st, output);
- return 0;
+ return true;
}
//=======================================================
// strtolower <str>
//-------------------------------------------------------
-BUILDIN_FUNC(strtolower)
+BUILDIN(strtolower)
{
const char *str = script_getstr(st,2);
char *output = aStrdup(str);
char *cursor = output;
-
+
while (*cursor != '\0') {
*cursor = TOLOWER(*cursor);
cursor++;
}
-
+
script_pushstr(st, output);
- return 0;
+ return true;
}
//=======================================================
// substr <str>, <start>, <end>
//-------------------------------------------------------
-BUILDIN_FUNC(substr)
+BUILDIN(substr)
{
const char *str = script_getstr(st,2);
char *output;
int start = script_getnum(st,3);
int end = script_getnum(st,4);
-
+
int len = 0;
-
+
if(start >= 0 && end < strlen(str) && start <= end) {
len = end - start + 1;
output = (char*)aMalloc(len + 1);
memcpy(output, &str[start], len);
} else
output = (char*)aMalloc(1);
-
+
output[len] = '\0';
-
+
script_pushstr(st, output);
- return 0;
+ return true;
}
//=======================================================
// explode <dest_string_array>, <str>, <delimiter>
// Note: delimiter is limited to 1 char
//-------------------------------------------------------
-BUILDIN_FUNC(explode)
+BUILDIN(explode)
{
struct script_data* data = script_getdata(st, 2);
const char *str = script_getstr(st,3);
@@ -13767,50 +13558,50 @@ BUILDIN_FUNC(explode)
size_t len = strlen(str);
int i = 0, j = 0;
int start;
-
-
+
+
char *temp;
const char* name;
-
+
TBL_PC* sd = NULL;
-
+
temp = (char*)aMalloc(len + 1);
-
+
if( !data_isreference(data) )
{
ShowError("script:explode: not a variable\n");
script_reportdata(data);
st->state = END;
- return 1;// not a variable
+ return false;// not a variable
}
-
+
id = reference_getid(data);
start = reference_getindex(data);
name = reference_getname(data);
-
+
if( not_array_variable(*name) )
{
ShowError("script:explode: illegal scope\n");
script_reportdata(data);
st->state = END;
- return 1;// not supported
+ return false;// not supported
}
-
+
if( !is_string_variable(name) )
{
ShowError("script:explode: not string array\n");
script_reportdata(data);
st->state = END;
- return 1;// data type mismatch
+ return false;// data type mismatch
}
-
+
if( not_server_variable(*name) )
{
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached
+ return true;// no player attached
}
-
+
while(str[i] != '\0') {
if(str[i] == delimiter && start < SCRIPT_MAX_ARRAYSIZE-1) { //break at delimiter but ignore after reaching last array index
temp[j] = '\0';
@@ -13824,64 +13615,64 @@ BUILDIN_FUNC(explode)
//set last string
temp[j] = '\0';
set_reg(st, sd, reference_uid(id, start), name, (void*)temp, reference_getref(data));
-
+
aFree(temp);
- return 0;
+ return true;
}
//=======================================================
// implode <string_array>
// implode <string_array>, <glue>
//-------------------------------------------------------
-BUILDIN_FUNC(implode)
+BUILDIN(implode)
{
struct script_data* data = script_getdata(st, 2);
const char *glue = NULL, *name, *temp;
int32 glue_len = 0, array_size, id;
size_t len = 0;
int i, k = 0;
-
+
TBL_PC* sd = NULL;
-
+
char *output;
-
+
if( !data_isreference(data) )
{
ShowError("script:implode: not a variable\n");
script_reportdata(data);
st->state = END;
- return 1;// not a variable
+ return false;// not a variable
}
-
+
id = reference_getid(data);
name = reference_getname(data);
-
+
if( not_array_variable(*name) )
{
ShowError("script:implode: illegal scope\n");
script_reportdata(data);
st->state = END;
- return 1;// not supported
+ return false;// not supported
}
-
+
if( !is_string_variable(name) )
{
ShowError("script:implode: not string array\n");
script_reportdata(data);
st->state = END;
- return 1;// data type mismatch
+ return false;// data type mismatch
}
-
+
if( not_server_variable(*name) )
{
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached
+ return true;// no player attached
}
-
+
//count chars
array_size = getarraysize(st, id, reference_getindex(data), is_string_variable(name), reference_getref(data)) - 1;
-
+
if(array_size == -1) //empty array check (AmsTaff)
{
ShowWarning("script:implode: array length = 0\n");
@@ -13893,7 +13684,7 @@ BUILDIN_FUNC(implode)
len += strlen(temp);
script_removetop(st, -1, 0);
}
-
+
//allocate mem
if( script_hasdata(st,3) ) {
glue = script_getstr(st,3);
@@ -13901,7 +13692,7 @@ BUILDIN_FUNC(implode)
len += glue_len * (array_size);
}
output = (char*)aMalloc(len + 1);
-
+
//build output
for(i = 0; i < array_size; ++i) {
temp = (char*) get_val2(st, reference_uid(id, i), reference_getref(data));
@@ -13919,12 +13710,12 @@ BUILDIN_FUNC(implode)
memcpy(&output[k], temp, len);
k += len;
script_removetop(st, -1, 0);
-
+
output[k] = '\0';
}
-
+
script_pushstr(st, output);
- return 0;
+ return true;
}
//=======================================================
@@ -13932,7 +13723,7 @@ BUILDIN_FUNC(implode)
// Implements C sprintf, except format %n. The resulting string is
// returned, instead of being saved in variable by reference.
//-------------------------------------------------------
-BUILDIN_FUNC(sprintf)
+BUILDIN(sprintf)
{
unsigned int len, argc = 0, arg = 0, buf2_len = 0;
const char* format;
@@ -13942,31 +13733,31 @@ BUILDIN_FUNC(sprintf)
char* buf2 = NULL;
struct script_data* data;
StringBuf final_buf;
-
+
// Fetch init data
format = script_getstr(st, 2);
argc = script_lastdata(st)-2;
len = strlen(format);
-
+
// Skip parsing, where no parsing is required.
if(len==0){
script_pushconststr(st,"");
- return 0;
+ return true;
}
-
+
// Pessimistic alloc
CREATE(buf, char, len+1);
-
+
// Need not be parsed, just solve stuff like %%.
if(argc==0){
memcpy(buf,format,len+1);
script_pushstrcopy(st, buf);
aFree(buf);
- return 0;
+ return true;
}
-
+
safestrncpy(buf, format, len+1);
-
+
// Issue sprintf for each parameter
StringBuf_Init(&final_buf);
q = buf;
@@ -13999,7 +13790,7 @@ BUILDIN_FUNC(sprintf)
if(buf2) aFree(buf2);
StringBuf_Destroy(&final_buf);
script_pushconststr(st,"");
- return 1;
+ return false;
}
if((p = strchr(q+1, '%'))==NULL){
p = strchr(q, 0); // EOS
@@ -14011,7 +13802,7 @@ BUILDIN_FUNC(sprintf)
}
safestrncpy(buf2, q, len);
q = p;
-
+
// Note: This assumes the passed value being the correct
// type to the current format specifier. If not, the server
// probably crashes or returns anything else, than expected,
@@ -14035,36 +13826,36 @@ BUILDIN_FUNC(sprintf)
if(buf2) aFree(buf2);
StringBuf_Destroy(&final_buf);
script_pushconststr(st,"");
- return 1;
+ return false;
}
arg++;
}
-
+
// Append anything left
if(*q){
StringBuf_AppendStr(&final_buf, q);
}
-
+
// Passed more, than needed
if(arg<argc){
ShowWarning("buildin_sprintf: Unused arguments passed.\n");
script_reportsrc(st);
}
-
+
script_pushstrcopy(st, StringBuf_Value(&final_buf));
-
+
if(buf) aFree(buf);
if(buf2) aFree(buf2);
StringBuf_Destroy(&final_buf);
-
- return 0;
+
+ return true;
}
//=======================================================
// sscanf(<str>, <format>, ...);
// Implements C sscanf.
//-------------------------------------------------------
-BUILDIN_FUNC(sscanf){
+BUILDIN(sscanf){
unsigned int argc, arg = 0, len;
struct script_data* data;
struct map_session_data* sd = NULL;
@@ -14076,15 +13867,15 @@ BUILDIN_FUNC(sscanf){
char* buf_p;
char* ref_str = NULL;
int ref_int;
-
+
// Get data
str = script_getstr(st, 2);
format = script_getstr(st, 3);
argc = script_lastdata(st)-3;
-
+
len = strlen(format);
CREATE(buf, char, len*2+1);
-
+
// Issue sscanf for each parameter
*buf = 0;
q = format;
@@ -14104,7 +13895,7 @@ BUILDIN_FUNC(sscanf){
script_pushint(st, -1);
if(buf) aFree(buf);
if(ref_str) aFree(ref_str);
- return 1;
+ return false;
}
if((p = strchr(q+1, '%'))==NULL){
p = strchr(q, 0); // EOS
@@ -14112,7 +13903,7 @@ BUILDIN_FUNC(sscanf){
len = p-q;
strncat(buf, q, len);
q = p;
-
+
// Validate output
data = script_getdata(st, arg+4);
if(!data_isreference(data) || !reference_tovariable(data)){
@@ -14120,16 +13911,16 @@ BUILDIN_FUNC(sscanf){
script_pushint(st, -1);
if(buf) aFree(buf);
if(ref_str) aFree(ref_str);
- return 1;
+ return false;
}
buf_p = reference_getname(data);
if(not_server_variable(*buf_p) && (sd = script_rid2sd(st))==NULL){
script_pushint(st, -1);
if(buf) aFree(buf);
if(ref_str) aFree(ref_str);
- return 0;
+ return true;
}
-
+
// Save value if any
if(buf_p[strlen(buf_p)-1]=='$'){ // String
if(ref_str==NULL){
@@ -14138,26 +13929,26 @@ BUILDIN_FUNC(sscanf){
if(sscanf(str, buf, ref_str)==0){
break;
}
- set_reg(st, sd, add_str(buf_p), buf_p, (void *)(ref_str), reference_getref(data));
- }else{ // Number
+ set_reg(st, sd, reference_uid( reference_getid(data), reference_getindex(data) ), buf_p, (void *)(ref_str), reference_getref(data));
+ } else { // Number
if(sscanf(str, buf, &ref_int)==0){
break;
}
- set_reg(st, sd, add_str(buf_p), buf_p, (void *)__64BPRTSIZE(ref_int), reference_getref(data));
+ set_reg(st, sd, reference_uid( reference_getid(data), reference_getindex(data) ), buf_p, (void *)__64BPTRSIZE(ref_int), reference_getref(data));
}
arg++;
-
+
// Disable used format (%... -> %*...)
buf_p = strchr(buf, 0);
memmove(buf_p-len+2, buf_p-len+1, len);
*(buf_p-len+1) = '*';
}
-
+
script_pushint(st, arg);
if(buf) aFree(buf);
if(ref_str) aFree(ref_str);
-
- return 0;
+
+ return true;
}
//=======================================================
@@ -14167,22 +13958,22 @@ BUILDIN_FUNC(sscanf){
// Implements PHP style strpos. Adapted from code from
// http://www.daniweb.com/code/snippet313.html, Dave Sinkula
//-------------------------------------------------------
-BUILDIN_FUNC(strpos) {
+BUILDIN(strpos) {
const char *haystack = script_getstr(st,2);
const char *needle = script_getstr(st,3);
int i;
size_t len;
-
+
if( script_hasdata(st,4) )
i = script_getnum(st,4);
else
i = 0;
-
+
if (needle[0] == '\0') {
script_pushint(st, -1);
- return 0;
+ return true;
}
-
+
len = strlen(haystack);
for ( ; i < len; ++i ) {
if ( haystack[i] == *needle ) {
@@ -14195,12 +13986,12 @@ BUILDIN_FUNC(strpos) {
}
if ( !*n ) { // matched all of 'needle' to null termination
script_pushint(st, i);
- return 0;
+ return true;
}
}
}
script_pushint(st, -1);
- return 0;
+ return true;
}
//===============================================================
@@ -14211,7 +14002,7 @@ BUILDIN_FUNC(strpos) {
// instances as specified in <count>. By default will be case
// sensitive.
//---------------------------------------------------------------
-BUILDIN_FUNC(replacestr)
+BUILDIN(replacestr)
{
const char *input = script_getstr(st, 2);
const char *find = script_getstr(st, 3);
@@ -14220,48 +14011,48 @@ BUILDIN_FUNC(replacestr)
size_t findlen = strlen(find);
struct StringBuf output;
bool usecase = true;
-
+
int count = 0;
int numFinds = 0;
int i = 0, f = 0;
-
+
if(findlen == 0) {
ShowError("script:replacestr: Invalid search length.\n");
st->state = END;
- return 1;
+ return false;
}
-
+
if(script_hasdata(st, 5)) {
if( !script_isstring(st,5) )
usecase = script_getnum(st, 5) != 0;
else {
ShowError("script:replacestr: Invalid usecase value. Expected int got string\n");
st->state = END;
- return 1;
+ return false;
}
}
-
+
if(script_hasdata(st, 6)) {
count = script_getnum(st, 6);
if(count == 0) {
ShowError("script:replacestr: Invalid count value. Expected int got string\n");
st->state = END;
- return 1;
+ return false;
}
}
-
+
StringBuf_Init(&output);
-
+
for(; i < inputlen; i++) {
if(count && count == numFinds) { //found enough, stop looking
break;
}
-
+
for(f = 0; f <= findlen; f++) {
if(f == findlen) { //complete match
numFinds++;
StringBuf_AppendStr(&output, replace);
-
+
i += findlen - 1;
break;
} else {
@@ -14279,14 +14070,14 @@ BUILDIN_FUNC(replacestr)
}
}
}
-
+
//append excess after enough found
if(i < inputlen)
StringBuf_AppendStr(&output, &(input[i]));
-
+
script_pushstrcopy(st, StringBuf_Value(&output));
StringBuf_Destroy(&output);
- return 0;
+ return true;
}
//========================================================
@@ -14295,33 +14086,33 @@ BUILDIN_FUNC(replacestr)
// Note: Counts the number of times <search> occurs in
// <input>. By default will be case sensitive.
//--------------------------------------------------------
-BUILDIN_FUNC(countstr)
+BUILDIN(countstr)
{
const char *input = script_getstr(st, 2);
const char *find = script_getstr(st, 3);
size_t inputlen = strlen(input);
size_t findlen = strlen(find);
bool usecase = true;
-
+
int numFinds = 0;
int i = 0, f = 0;
-
+
if(findlen == 0) {
ShowError("script:countstr: Invalid search length.\n");
st->state = END;
- return 1;
+ return false;
}
-
+
if(script_hasdata(st, 4)) {
if( !script_isstring(st,4) )
usecase = script_getnum(st, 4) != 0;
else {
ShowError("script:countstr: Invalid usecase value. Expected int got string\n");
st->state = END;
- return 1;
+ return false;
}
}
-
+
for(; i < inputlen; i++) {
for(f = 0; f <= findlen; f++) {
if(f == findlen) { //complete match
@@ -14342,7 +14133,7 @@ BUILDIN_FUNC(countstr)
}
}
script_pushint(st, numFinds);
- return 0;
+ return true;
}
@@ -14353,22 +14144,22 @@ BUILDIN_FUNC(countstr)
/// setnpcdisplay("<npc name>", "<new display name>", <new class id>) -> <int>
/// setnpcdisplay("<npc name>", "<new display name>") -> <int>
/// setnpcdisplay("<npc name>", <new class id>) -> <int>
-BUILDIN_FUNC(setnpcdisplay)
+BUILDIN(setnpcdisplay)
{
const char* name;
const char* newname = NULL;
int class_ = -1, size = -1;
struct script_data* data;
struct npc_data* nd;
-
+
name = script_getstr(st,2);
data = script_getdata(st,3);
-
+
if( script_hasdata(st,4) )
class_ = script_getnum(st,4);
if( script_hasdata(st,5) )
size = script_getnum(st,5);
-
+
get_val(st, data);
if( data_isstring(data) )
newname = conv_str(st,data);
@@ -14378,25 +14169,25 @@ BUILDIN_FUNC(setnpcdisplay)
{
ShowError("script:setnpcdisplay: expected a string or number\n");
script_reportdata(data);
- return 1;
+ return false;
}
-
+
nd = npc_name2id(name);
if( nd == NULL )
{// not found
script_pushint(st,1);
- return 0;
+ return true;
}
-
+
// update npc
if( newname )
npc_setdisplayname(nd, newname);
-
+
if( size != -1 && size != (int)nd->size )
nd->size = size;
else
size = -1;
-
+
if( class_ != -1 && nd->class_ != class_ )
npc_setclass(nd, class_);
else if( size != -1 )
@@ -14404,107 +14195,107 @@ BUILDIN_FUNC(setnpcdisplay)
clif->clearunit_area(&nd->bl, CLR_OUTSIGHT);
clif->spawn(&nd->bl);
}
-
+
script_pushint(st,0);
- return 0;
+ return true;
}
-BUILDIN_FUNC(atoi)
+BUILDIN(atoi)
{
const char *value;
value = script_getstr(st,2);
script_pushint(st,atoi(value));
- return 0;
+ return true;
}
// case-insensitive substring search [lordalfa]
-BUILDIN_FUNC(compare)
+BUILDIN(compare)
{
const char *message;
const char *cmpstring;
message = script_getstr(st,2);
cmpstring = script_getstr(st,3);
script_pushint(st,(stristr(message,cmpstring) != NULL));
- return 0;
+ return true;
}
// [zBuffer] List of mathematics commands --->
-BUILDIN_FUNC(sqrt)
+BUILDIN(sqrt)
{
double i, a;
i = script_getnum(st,2);
a = sqrt(i);
script_pushint(st,(int)a);
- return 0;
+ return true;
}
-BUILDIN_FUNC(pow)
+BUILDIN(pow)
{
double i, a, b;
a = script_getnum(st,2);
b = script_getnum(st,3);
i = pow(a,b);
script_pushint(st,(int)i);
- return 0;
+ return true;
}
-BUILDIN_FUNC(distance)
+BUILDIN(distance)
{
int x0, y0, x1, y1;
-
+
x0 = script_getnum(st,2);
y0 = script_getnum(st,3);
x1 = script_getnum(st,4);
y1 = script_getnum(st,5);
-
+
script_pushint(st,distance_xy(x0,y0,x1,y1));
- return 0;
+ return true;
}
// <--- [zBuffer] List of mathematics commands
-BUILDIN_FUNC(md5)
+BUILDIN(md5)
{
const char *tmpstr;
char *md5str;
-
+
tmpstr = script_getstr(st,2);
md5str = (char *)aMalloc((32+1)*sizeof(char));
MD5_String(tmpstr, md5str);
script_pushstr(st, md5str);
- return 0;
+ return true;
}
// [zBuffer] List of dynamic var commands --->
-BUILDIN_FUNC(setd)
+BUILDIN(setd)
{
TBL_PC *sd=NULL;
char varname[100];
const char *buffer;
int elem;
buffer = script_getstr(st, 2);
-
+
if(sscanf(buffer, "%99[^[][%d]", varname, &elem) < 2)
elem = 0;
-
+
if( not_server_variable(*varname) )
{
sd = script_rid2sd(st);
if( sd == NULL )
{
ShowError("script:setd: no player attached for player variable '%s'\n", buffer);
- return 0;
+ return true;
}
}
-
+
if( is_string_variable(varname) ) {
setd_sub(st, sd, varname, elem, (void *)script_getstr(st, 3), NULL);
} else {
- setd_sub(st, sd, varname, elem, (void *)__64BPRTSIZE(script_getnum(st, 3)), NULL);
+ setd_sub(st, sd, varname, elem, (void *)__64BPTRSIZE(script_getnum(st, 3)), NULL);
}
-
- return 0;
+
+ return true;
}
int buildin_query_sql_sub(struct script_state* st, Sql* handle)
@@ -14517,7 +14308,7 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle)
int max_rows = SCRIPT_MAX_ARRAYSIZE; // maximum number of rows
int num_vars;
int num_cols;
-
+
// check target variables
for( i = 3; script_hasdata(st,i); ++i ) {
data = script_getdata(st, i);
@@ -14528,7 +14319,7 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle)
if( sd == NULL ) { // no player attached
script_reportdata(data);
st->state = END;
- return 1;
+ return false;
}
}
if( not_array_variable(*name) )
@@ -14537,26 +14328,26 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle)
ShowError("script:query_sql: not a variable\n");
script_reportdata(data);
st->state = END;
- return 1;
+ return false;
}
}
num_vars = i - 3;
-
+
// Execute the query
query = script_getstr(st,2);
-
+
if( SQL_ERROR == Sql_QueryStr(handle, query) ) {
Sql_ShowDebug(handle);
script_pushint(st, 0);
- return 1;
+ return false;
}
-
+
if( Sql_NumRows(handle) == 0 ) { // No data received
Sql_FreeResult(handle);
script_pushint(st, 0);
- return 0;
+ return true;
}
-
+
// Count the number of columns to store
num_cols = Sql_NumColumns(handle);
if( num_vars < num_cols ) {
@@ -14566,104 +14357,82 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle)
ShowWarning("script:query_sql: Too many variables (%u extra).\n", (unsigned int)(num_vars-num_cols));
script_reportsrc(st);
}
-
+
// Store data
for( i = 0; i < max_rows && SQL_SUCCESS == Sql_NextRow(handle); ++i ) {
for( j = 0; j < num_vars; ++j ) {
char* str = NULL;
-
+
if( j < num_cols )
Sql_GetData(handle, j, &str, NULL);
-
+
data = script_getdata(st, j+3);
name = reference_getname(data);
if( is_string_variable(name) )
setd_sub(st, sd, name, i, (void *)(str?str:""), reference_getref(data));
else
- setd_sub(st, sd, name, i, (void *)__64BPRTSIZE((str?atoi(str):0)), reference_getref(data));
+ setd_sub(st, sd, name, i, (void *)__64BPTRSIZE((str?atoi(str):0)), reference_getref(data));
}
}
if( i == max_rows && max_rows < Sql_NumRows(handle) ) {
ShowWarning("script:query_sql: Only %d/%u rows have been stored.\n", max_rows, (unsigned int)Sql_NumRows(handle));
script_reportsrc(st);
}
-
+
// Free data
Sql_FreeResult(handle);
script_pushint(st, i);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(query_sql) {
-#ifdef BETA_THREAD_TEST
- if( st->state != RERUNLINE ) {
- queryThread_add(st,false);
-
- st->state = RERUNLINE;/* will continue when the query is finished running. */
- } else
- st->state = RUN;
-
- return 0;
-#else
+BUILDIN(query_sql) {
return buildin_query_sql_sub(st, mmysql_handle);
-#endif
}
-BUILDIN_FUNC(query_logsql) {
- if( !log_config.sql_logs ) {// logmysql_handle == NULL
+BUILDIN(query_logsql) {
+ if( !logs->config.sql_logs ) {// logmysql_handle == NULL
ShowWarning("buildin_query_logsql: SQL logs are disabled, query '%s' will not be executed.\n", script_getstr(st,2));
script_pushint(st,-1);
- return 1;
+ return false;
}
-#ifdef BETA_THREAD_TEST
- if( st->state != RERUNLINE ) {
- queryThread_add(st,true);
-
- st->state = RERUNLINE;/* will continue when the query is finished running. */
- } else
- st->state = RUN;
-
- return 0;
-#else
return buildin_query_sql_sub(st, logmysql_handle);
-#endif
}
//Allows escaping of a given string.
-BUILDIN_FUNC(escape_sql)
+BUILDIN(escape_sql)
{
const char *str;
char *esc_str;
size_t len;
-
+
str = script_getstr(st,2);
len = strlen(str);
esc_str = (char*)aMalloc(len*2+1);
Sql_EscapeStringLen(mmysql_handle, esc_str, str, len);
script_pushstr(st, esc_str);
- return 0;
+ return true;
}
-BUILDIN_FUNC(getd)
+BUILDIN(getd)
{
char varname[100];
const char *buffer;
int elem;
-
+
buffer = script_getstr(st, 2);
-
+
if(sscanf(buffer, "%[^[][%d]", varname, &elem) < 2)
elem = 0;
-
+
// Push the 'pointer' so it's more flexible [Lance]
push_val(st->stack, C_NAME, reference_uid(add_str(varname), elem));
-
- return 0;
+
+ return true;
}
// <--- [zBuffer] List of dynamic var commands
// Pet stat [Lance]
-BUILDIN_FUNC(petstat)
+BUILDIN(petstat)
{
TBL_PC *sd = NULL;
struct pet_data *pd;
@@ -14674,7 +14443,7 @@ BUILDIN_FUNC(petstat)
script_pushconststr(st, "");
else
script_pushint(st,0);
- return 0;
+ return true;
}
pd = sd->pd;
switch(flag){
@@ -14687,10 +14456,10 @@ BUILDIN_FUNC(petstat)
script_pushint(st,0);
break;
}
- return 0;
+ return true;
}
-BUILDIN_FUNC(callshop)
+BUILDIN(callshop)
{
TBL_PC *sd = NULL;
struct npc_data *nd;
@@ -14699,7 +14468,7 @@ BUILDIN_FUNC(callshop)
sd = script_rid2sd(st);
if (!sd) {
script_pushint(st,0);
- return 0;
+ return true;
}
shopname = script_getstr(st, 2);
if( script_hasdata(st,3) )
@@ -14709,14 +14478,14 @@ BUILDIN_FUNC(callshop)
{
ShowError("buildin_callshop: Shop [%s] not found (or NPC is not shop type)\n", shopname);
script_pushint(st,0);
- return 1;
+ return false;
}
-
+
if( nd->subtype == SHOP )
{
// flag the user as using a valid script call for opening the shop (for floating NPCs)
sd->state.callshop = 1;
-
+
switch( flag )
{
case 1: npc_buysellsel(sd,nd->bl.id,0); break; //Buy window
@@ -14726,28 +14495,28 @@ BUILDIN_FUNC(callshop)
}
else
clif->cashshop_show(sd, nd);
-
+
sd->npc_shopid = nd->bl.id;
script_pushint(st,1);
- return 0;
+ return true;
}
-BUILDIN_FUNC(npcshopitem)
+BUILDIN(npcshopitem)
{
const char* npcname = script_getstr(st, 2);
struct npc_data* nd = npc_name2id(npcname);
int n, i;
int amount;
-
+
if( !nd || ( nd->subtype != SHOP && nd->subtype != CASHSHOP ) )
{ //Not found.
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
// get the count of new entries
amount = (script_lastdata(st)-2)/2;
-
+
// generate new shop item list
RECREATE(nd->u.shop.shop_item, struct npc_item_list, amount);
for( n = 0, i = 3; n < amount; n++, i+=2 )
@@ -14756,27 +14525,27 @@ BUILDIN_FUNC(npcshopitem)
nd->u.shop.shop_item[n].value = script_getnum(st,i+1);
}
nd->u.shop.count = n;
-
+
script_pushint(st,1);
- return 0;
+ return true;
}
-BUILDIN_FUNC(npcshopadditem)
+BUILDIN(npcshopadditem)
{
const char* npcname = script_getstr(st,2);
struct npc_data* nd = npc_name2id(npcname);
int n, i;
int amount;
-
+
if( !nd || ( nd->subtype != SHOP && nd->subtype != CASHSHOP ) )
{ //Not found.
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
// get the count of new entries
amount = (script_lastdata(st)-2)/2;
-
+
// append new items to existing shop item list
RECREATE(nd->u.shop.shop_item, struct npc_item_list, nd->u.shop.count+amount);
for( n = nd->u.shop.count, i = 3; n < nd->u.shop.count+amount; n++, i+=2 )
@@ -14785,12 +14554,12 @@ BUILDIN_FUNC(npcshopadditem)
nd->u.shop.shop_item[n].value = script_getnum(st,i+1);
}
nd->u.shop.count = n;
-
+
script_pushint(st,1);
- return 0;
+ return true;
}
-BUILDIN_FUNC(npcshopdelitem)
+BUILDIN(npcshopdelitem)
{
const char* npcname = script_getstr(st,2);
struct npc_data* nd = npc_name2id(npcname);
@@ -14798,21 +14567,21 @@ BUILDIN_FUNC(npcshopdelitem)
int n, i;
int amount;
int size;
-
+
if( !nd || ( nd->subtype != SHOP && nd->subtype != CASHSHOP ) )
{ //Not found.
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
amount = script_lastdata(st)-2;
size = nd->u.shop.count;
-
+
// remove specified items from the shop item list
for( i = 3; i < 3 + amount; i++ )
{
nameid = script_getnum(st,i);
-
+
ARR_FIND( 0, size, n, nd->u.shop.shop_item[n].nameid == nameid );
if( n < size )
{
@@ -14820,121 +14589,121 @@ BUILDIN_FUNC(npcshopdelitem)
size--;
}
}
-
+
RECREATE(nd->u.shop.shop_item, struct npc_item_list, size);
nd->u.shop.count = size;
-
+
script_pushint(st,1);
- return 0;
+ return true;
}
//Sets a script to attach to a shop npc.
-BUILDIN_FUNC(npcshopattach)
+BUILDIN(npcshopattach)
{
const char* npcname = script_getstr(st,2);
struct npc_data* nd = npc_name2id(npcname);
int flag = 1;
-
+
if( script_hasdata(st,3) )
flag = script_getnum(st,3);
-
+
if( !nd || nd->subtype != SHOP )
{ //Not found.
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
if (flag)
nd->master_nd = ((struct npc_data *)map_id2bl(st->oid));
else
nd->master_nd = NULL;
-
+
script_pushint(st,1);
- return 0;
+ return true;
}
/*==========================================
* Returns some values of an item [Lupus]
* Price, Weight, etc...
- setitemscript(itemID,"{new item bonus script}",[n]);
- Where n:
- 0 - script
- 1 - Equip script
- 2 - Unequip script
+ setitemscript(itemID,"{new item bonus script}",[n]);
+ Where n:
+ 0 - script
+ 1 - Equip script
+ 2 - Unequip script
*------------------------------------------*/
-BUILDIN_FUNC(setitemscript)
+BUILDIN(setitemscript)
{
int item_id,n=0;
const char *script;
struct item_data *i_data;
struct script_code **dstscript;
-
+
item_id = script_getnum(st,2);
script = script_getstr(st,3);
if( script_hasdata(st,4) )
n=script_getnum(st,4);
i_data = itemdb_exists(item_id);
-
+
if (!i_data || script==NULL || ( script[0] && script[0]!='{' )) {
script_pushint(st,0);
- return 0;
+ return true;
}
switch (n) {
- case 2:
- dstscript = &i_data->unequip_script;
- break;
- case 1:
- dstscript = &i_data->equip_script;
- break;
- default:
- dstscript = &i_data->script;
- break;
+ case 2:
+ dstscript = &i_data->unequip_script;
+ break;
+ case 1:
+ dstscript = &i_data->equip_script;
+ break;
+ default:
+ dstscript = &i_data->script;
+ break;
}
if(*dstscript)
script_free_code(*dstscript);
-
+
*dstscript = script[0] ? parse_script(script, "script_setitemscript", 0, 0) : NULL;
script_pushint(st,1);
- return 0;
+ return true;
}
/* Work In Progress [Lupus]
-BUILDIN_FUNC(addmonsterdrop)
-{
- int class_,item_id,chance;
- class_=script_getnum(st,2);
- item_id=script_getnum(st,3);
- chance=script_getnum(st,4);
- if(class_>1000 && item_id>500 && chance>0) {
- script_pushint(st,1);
- } else {
- script_pushint(st,0);
- }
-}
-
-BUILDIN_FUNC(delmonsterdrop)
-{
- int class_,item_id;
- class_=script_getnum(st,2);
- item_id=script_getnum(st,3);
- if(class_>1000 && item_id>500) {
- script_pushint(st,1);
- } else {
- script_pushint(st,0);
- }
-}
-*/
+ BUILDIN(addmonsterdrop)
+ {
+ int class_,item_id,chance;
+ class_=script_getnum(st,2);
+ item_id=script_getnum(st,3);
+ chance=script_getnum(st,4);
+ if(class_>1000 && item_id>500 && chance>0) {
+ script_pushint(st,1);
+ } else {
+ script_pushint(st,0);
+ }
+ }
+
+ BUILDIN(delmonsterdrop)
+ {
+ int class_,item_id;
+ class_=script_getnum(st,2);
+ item_id=script_getnum(st,3);
+ if(class_>1000 && item_id>500) {
+ script_pushint(st,1);
+ } else {
+ script_pushint(st,0);
+ }
+ }
+ */
/*==========================================
* Returns some values of a monster [Lupus]
* Name, Level, race, size, etc...
- getmonsterinfo(monsterID,queryIndex);
+ getmonsterinfo(monsterID,queryIndex);
*------------------------------------------*/
-BUILDIN_FUNC(getmonsterinfo)
+BUILDIN(getmonsterinfo)
{
struct mob_db *mob;
int mob_id;
-
+
mob_id = script_getnum(st,2);
if (!mobdb_checkid(mob_id)) {
ShowError("buildin_getmonsterinfo: Wrong Monster ID: %i\n", mob_id);
@@ -14971,94 +14740,94 @@ BUILDIN_FUNC(getmonsterinfo)
case 22: script_pushint(st,mob->mexp); break;
default: script_pushint(st,-1); //wrong Index
}
- return 0;
+ return true;
}
-BUILDIN_FUNC(checkvending) // check vending [Nab4]
+BUILDIN(checkvending) // check vending [Nab4]
{
TBL_PC *sd = NULL;
-
+
if(script_hasdata(st,2))
sd = map_nick2sd(script_getstr(st,2));
else
sd = script_rid2sd(st);
-
+
if(sd)
script_pushint(st, sd->state.autotrade ? 2 : sd->state.vending);
else
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(checkchatting) // check chatting [Marka]
+BUILDIN(checkchatting) // check chatting [Marka]
{
TBL_PC *sd = NULL;
-
+
if(script_hasdata(st,2))
sd = map_nick2sd(script_getstr(st,2));
else
sd = script_rid2sd(st);
-
+
if(sd)
script_pushint(st,(sd->chatID != 0));
else
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(checkidle)
+BUILDIN(checkidle)
{
TBL_PC *sd = NULL;
-
+
if (script_hasdata(st, 2))
sd = map_nick2sd(script_getstr(st, 2));
else
sd = script_rid2sd(st);
-
+
if (sd)
script_pushint(st, DIFF_TICK(last_tick, sd->idletime));
else
script_pushint(st, 0);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(searchitem)
+BUILDIN(searchitem)
{
struct script_data* data = script_getdata(st, 2);
const char *itemname = script_getstr(st,3);
struct item_data *items[MAX_SEARCH];
int count;
-
+
char* name;
int32 start;
int32 id;
int32 i;
TBL_PC* sd = NULL;
-
+
if ((items[0] = itemdb_exists(atoi(itemname))))
count = 1;
else {
count = itemdb_searchname_array(items, ARRAYLENGTH(items), itemname);
if (count > MAX_SEARCH) count = MAX_SEARCH;
}
-
+
if (!count) {
script_pushint(st, 0);
- return 0;
+ return true;
}
-
+
if( !data_isreference(data) )
{
ShowError("script:searchitem: not a variable\n");
script_reportdata(data);
st->state = END;
- return 1;// not a variable
+ return false;// not a variable
}
-
+
id = reference_getid(data);
start = reference_getindex(data);
name = reference_getname(data);
@@ -15067,32 +14836,32 @@ BUILDIN_FUNC(searchitem)
ShowError("script:searchitem: illegal scope\n");
script_reportdata(data);
st->state = END;
- return 1;// not supported
+ return false;// not supported
}
-
+
if( not_server_variable(*name) )
{
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;// no player attached
+ return true;// no player attached
}
-
+
if( is_string_variable(name) )
{// string array
ShowError("script:searchitem: not an integer array reference\n");
script_reportdata(data);
st->state = END;
- return 1;// not supported
+ return false;// not supported
}
-
+
for( i = 0; i < count; ++start, ++i )
{// Set array
- void* v = (void*)__64BPRTSIZE((int)items[i]->nameid);
+ void* v = (void*)__64BPTRSIZE((int)items[i]->nameid);
set_reg(st, sd, reference_uid(id, start), name, v, reference_getref(data));
}
-
+
script_pushint(st, count);
- return 0;
+ return true;
}
int axtoi(const char *hexStg)
@@ -15129,15 +14898,15 @@ int axtoi(const char *hexStg)
}
// [Lance] Hex string to integer converter
-BUILDIN_FUNC(axtoi)
+BUILDIN(axtoi)
{
const char *hex = script_getstr(st,2);
script_pushint(st,axtoi(hex));
- return 0;
+ return true;
}
// [zBuffer] List of player cont commands --->
-BUILDIN_FUNC(rid2name)
+BUILDIN(rid2name)
{
struct block_list *bl = NULL;
int rid = script_getnum(st,2);
@@ -15159,65 +14928,65 @@ BUILDIN_FUNC(rid2name)
ShowError("buildin_rid2name: invalid RID\n");
script_pushconststr(st,"(null)");
}
- return 0;
+ return true;
}
-BUILDIN_FUNC(pcblockmove)
+BUILDIN(pcblockmove)
{
int id, flag;
TBL_PC *sd = NULL;
-
+
id = script_getnum(st,2);
flag = script_getnum(st,3);
-
+
if(id)
sd = map_id2sd(id);
else
sd = script_rid2sd(st);
-
+
if(sd)
sd->state.blockedmove = flag > 0;
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(pcfollow)
+BUILDIN(pcfollow)
{
int id, targetid;
TBL_PC *sd = NULL;
-
-
+
+
id = script_getnum(st,2);
targetid = script_getnum(st,3);
-
+
if(id)
sd = map_id2sd(id);
else
sd = script_rid2sd(st);
-
+
if(sd)
pc_follow(sd, targetid);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(pcstopfollow)
+BUILDIN(pcstopfollow)
{
int id;
TBL_PC *sd = NULL;
-
-
+
+
id = script_getnum(st,2);
-
+
if(id)
sd = map_id2sd(id);
else
sd = script_rid2sd(st);
-
+
if(sd)
pc_stop_following(sd);
-
- return 0;
+
+ return true;
}
// <--- [zBuffer] List of player cont commands
// [zBuffer] List of mob control commands --->
@@ -15228,10 +14997,10 @@ BUILDIN_FUNC(pcstopfollow)
///
/// unitwalk(<unit_id>,<x>,<y>) -> <bool>
/// unitwalk(<unit_id>,<map_id>) -> <bool>
-BUILDIN_FUNC(unitwalk)
+BUILDIN(unitwalk)
{
struct block_list* bl;
-
+
bl = map_id2bl(script_getnum(st,2));
if( bl == NULL )
{
@@ -15248,27 +15017,27 @@ BUILDIN_FUNC(unitwalk)
int map_id = script_getnum(st,3);
script_pushint(st, unit_walktobl(bl,map_id2bl(map_id),65025,1));
}
-
- return 0;
+
+ return true;
}
/// Kills the unit
///
/// unitkill <unit_id>;
-BUILDIN_FUNC(unitkill)
+BUILDIN(unitkill)
{
struct block_list* bl = map_id2bl(script_getnum(st,2));
if( bl != NULL )
status_kill(bl);
-
- return 0;
+
+ return true;
}
/// Warps the unit to the target position in the target map
/// Returns if it was successfull
///
/// unitwarp(<unit_id>,"<map name>",<x>,<y>) -> <bool>
-BUILDIN_FUNC(unitwarp)
+BUILDIN(unitwarp)
{
int unit_id;
int map;
@@ -15276,28 +15045,28 @@ BUILDIN_FUNC(unitwarp)
short y;
struct block_list* bl;
const char *mapname;
-
+
unit_id = script_getnum(st,2);
mapname = script_getstr(st, 3);
x = (short)script_getnum(st,4);
y = (short)script_getnum(st,5);
-
+
if (!unit_id) //Warp the script's runner
bl = map_id2bl(st->rid);
else
bl = map_id2bl(unit_id);
-
+
if( strcmp(mapname,"this") == 0 )
map = bl?bl->m:-1;
else
map = map_mapname2mapid(mapname);
-
+
if( map >= 0 && bl != NULL )
script_pushint(st, unit_warp(bl,map,x,y,CLR_OUTSIGHT));
else
script_pushint(st, 0);
-
- return 0;
+
+ return true;
}
/// Makes the unit attack the target.
@@ -15307,20 +15076,20 @@ BUILDIN_FUNC(unitwarp)
///
/// unitattack(<unit_id>,"<target name>"{,<action type>}) -> <bool>
/// unitattack(<unit_id>,<target_id>{,<action type>}) -> <bool>
-BUILDIN_FUNC(unitattack)
+BUILDIN(unitattack)
{
struct block_list* unit_bl;
struct block_list* target_bl = NULL;
struct script_data* data;
int actiontype = 0;
-
+
// get unit
unit_bl = map_id2bl(script_getnum(st,2));
if( unit_bl == NULL ) {
script_pushint(st, 0);
- return 0;
+ return true;
}
-
+
data = script_getdata(st, 3);
get_val(st, data);
if( data_isstring(data) )
@@ -15334,44 +15103,44 @@ BUILDIN_FUNC(unitattack)
if( target_bl == NULL )
{
script_pushint(st, 0);
- return 0;
+ return true;
}
-
+
// get actiontype
if( script_hasdata(st,4) )
actiontype = script_getnum(st,4);
-
+
switch( unit_bl->type )
{
- case BL_PC:
- clif->pActionRequest_sub(((TBL_PC *)unit_bl), actiontype > 0 ? 0x07 : 0x00, target_bl->id, gettick());
- script_pushint(st, 1);
- return 0;
- case BL_MOB:
- ((TBL_MOB *)unit_bl)->target_id = target_bl->id;
- break;
- case BL_PET:
- ((TBL_PET *)unit_bl)->target_id = target_bl->id;
- break;
- default:
- ShowError("script:unitattack: unsupported source unit type %d\n", unit_bl->type);
- script_pushint(st, 0);
- return 1;
+ case BL_PC:
+ clif->pActionRequest_sub(((TBL_PC *)unit_bl), actiontype > 0 ? 0x07 : 0x00, target_bl->id, gettick());
+ script_pushint(st, 1);
+ return true;
+ case BL_MOB:
+ ((TBL_MOB *)unit_bl)->target_id = target_bl->id;
+ break;
+ case BL_PET:
+ ((TBL_PET *)unit_bl)->target_id = target_bl->id;
+ break;
+ default:
+ ShowError("script:unitattack: unsupported source unit type %d\n", unit_bl->type);
+ script_pushint(st, 0);
+ return false;
}
script_pushint(st, unit_walktobl(unit_bl, target_bl, 65025, 2));
- return 0;
+ return true;
}
/// Makes the unit stop attacking and moving
///
/// unitstop <unit_id>;
-BUILDIN_FUNC(unitstop)
+BUILDIN(unitstop)
{
int unit_id;
struct block_list* bl;
-
+
unit_id = script_getnum(st,2);
-
+
bl = map_id2bl(unit_id);
if( bl != NULL )
{
@@ -15380,22 +15149,22 @@ BUILDIN_FUNC(unitstop)
if( bl->type == BL_MOB )
((TBL_MOB*)bl)->target_id = 0;
}
-
- return 0;
+
+ return true;
}
/// Makes the unit say the message
///
/// unittalk <unit_id>,"<message>";
-BUILDIN_FUNC(unittalk)
+BUILDIN(unittalk)
{
int unit_id;
const char* message;
struct block_list* bl;
-
+
unit_id = script_getnum(st,2);
message = script_getstr(st, 3);
-
+
bl = map_id2bl(unit_id);
if( bl != NULL )
{
@@ -15407,8 +15176,8 @@ BUILDIN_FUNC(unittalk)
clif->message(((TBL_PC*)bl)->fd, StringBuf_Value(&sbuf));
StringBuf_Destroy(&sbuf);
}
-
- return 0;
+
+ return true;
}
/// Makes the unit do an emotion
@@ -15416,50 +15185,50 @@ BUILDIN_FUNC(unittalk)
/// unitemote <unit_id>,<emotion>;
///
/// @see e_* in const.txt
-BUILDIN_FUNC(unitemote)
+BUILDIN(unitemote)
{
int unit_id;
int emotion;
struct block_list* bl;
-
+
unit_id = script_getnum(st,2);
emotion = script_getnum(st,3);
bl = map_id2bl(unit_id);
if( bl != NULL )
clif->emotion(bl, emotion);
-
- return 0;
+
+ return true;
}
/// Makes the unit cast the skill on the target or self if no target is specified
///
/// unitskilluseid <unit_id>,<skill_id>,<skill_lv>{,<target_id>};
/// unitskilluseid <unit_id>,"<skill name>",<skill_lv>{,<target_id>};
-BUILDIN_FUNC(unitskilluseid)
+BUILDIN(unitskilluseid)
{
int unit_id;
uint16 skill_id;
uint16 skill_lv;
int target_id;
struct block_list* bl;
-
+
unit_id = script_getnum(st,2);
skill_id = ( script_isstring(st,3) ? skill->name2id(script_getstr(st,3)) : script_getnum(st,3) );
skill_lv = script_getnum(st,4);
target_id = ( script_hasdata(st,5) ? script_getnum(st,5) : unit_id );
-
+
bl = map_id2bl(unit_id);
if( bl != NULL )
unit_skilluse_id(bl, target_id, skill_id, skill_lv);
-
- return 0;
+
+ return true;
}
/// Makes the unit cast the skill on the target position.
///
/// unitskillusepos <unit_id>,<skill_id>,<skill_lv>,<target_x>,<target_y>;
/// unitskillusepos <unit_id>,"<skill name>",<skill_lv>,<target_x>,<target_y>;
-BUILDIN_FUNC(unitskillusepos)
+BUILDIN(unitskillusepos)
{
int unit_id;
uint16 skill_id;
@@ -15467,18 +15236,18 @@ BUILDIN_FUNC(unitskillusepos)
int skill_x;
int skill_y;
struct block_list* bl;
-
+
unit_id = script_getnum(st,2);
skill_id = ( script_isstring(st,3) ? skill->name2id(script_getstr(st,3)) : script_getnum(st,3) );
skill_lv = script_getnum(st,4);
skill_x = script_getnum(st,5);
skill_y = script_getnum(st,6);
-
+
bl = map_id2bl(unit_id);
if( bl != NULL )
unit_skilluse_pos(bl, skill_x, skill_y, skill_id, skill_lv);
-
- return 0;
+
+ return true;
}
// <--- [zBuffer] List of mob control commands
@@ -15486,15 +15255,15 @@ BUILDIN_FUNC(unitskillusepos)
/// Pauses the execution of the script, detaching the player
///
/// sleep <mili seconds>;
-BUILDIN_FUNC(sleep)
+BUILDIN(sleep)
{
int ticks;
-
+
ticks = script_getnum(st,2);
-
+
// detach the player
script_detach_rid(st);
-
+
if( ticks <= 0 )
{// do nothing
}
@@ -15508,19 +15277,19 @@ BUILDIN_FUNC(sleep)
st->state = RUN;
st->sleep.tick = 0;
}
- return 0;
+ return true;
}
/// Pauses the execution of the script, keeping the player attached
/// Returns if a player is still attached
///
/// sleep2(<mili secconds>) -> <bool>
-BUILDIN_FUNC(sleep2)
+BUILDIN(sleep2)
{
int ticks;
-
+
ticks = script_getnum(st,2);
-
+
if( ticks <= 0 )
{// do nothing
script_pushint(st, (map_id2sd(st->rid)!=NULL));
@@ -15536,30 +15305,30 @@ BUILDIN_FUNC(sleep2)
st->sleep.tick = 0;
script_pushint(st, (map_id2sd(st->rid)!=NULL));
}
- return 0;
+ return true;
}
/// Awakes all the sleep timers of the target npc
///
/// awake "<npc name>";
-BUILDIN_FUNC(awake)
+BUILDIN(awake)
{
struct npc_data* nd;
struct linkdb_node *node = (struct linkdb_node *)sleep_db;
-
+
nd = npc_name2id(script_getstr(st, 2));
if( nd == NULL ) {
ShowError("awake: NPC \"%s\" not found\n", script_getstr(st, 2));
- return 1;
+ return false;
}
-
+
while( node )
{
- if( (int)__64BPRTSIZE(node->key) == nd->bl.id )
+ if( (int)__64BPTRSIZE(node->key) == nd->bl.id )
{// sleep timer for the npc
struct script_state* tst = (struct script_state*)node->data;
TBL_PC* sd = map_id2sd(tst->rid);
-
+
if( tst->sleep.timer == INVALID_TIMER )
{// already awake ???
node = node->next;
@@ -15570,7 +15339,7 @@ BUILDIN_FUNC(awake)
tst->state = END;
tst->rid = 0;
}
-
+
delete_timer(tst->sleep.timer, run_script_timer);
node = script_erase_sleepdb(node);
tst->sleep.timer = INVALID_TIMER;
@@ -15583,19 +15352,19 @@ BUILDIN_FUNC(awake)
node = node->next;
}
}
- return 0;
+ return true;
}
/// Returns a reference to a variable of the target NPC.
/// Returns 0 if an error occurs.
///
/// getvariableofnpc(<variable>, "<npc name>") -> <reference>
-BUILDIN_FUNC(getvariableofnpc)
+BUILDIN(getvariableofnpc)
{
struct script_data* data;
const char* name;
struct npc_data* nd;
-
+
data = script_getdata(st,2);
if( !data_isreference(data) )
{// Not a reference (aka varaible name)
@@ -15603,9 +15372,9 @@ BUILDIN_FUNC(getvariableofnpc)
script_reportdata(data);
script_pushnil(st);
st->state = END;
- return 1;
+ return false;
}
-
+
name = reference_getname(data);
if( *name != '.' || name[1] == '@' )
{// not a npc variable
@@ -15613,20 +15382,20 @@ BUILDIN_FUNC(getvariableofnpc)
script_reportdata(data);
script_pushnil(st);
st->state = END;
- return 1;
+ return false;
}
-
+
nd = npc_name2id(script_getstr(st,3));
if( nd == NULL || nd->subtype != SCRIPT || nd->u.scr.script == NULL )
{// NPC not found or has no script
ShowError("script:getvariableofnpc: can't find npc %s\n", script_getstr(st,3));
script_pushnil(st);
st->state = END;
- return 1;
+ return false;
}
-
+
push_val2(st->stack, C_NAME, reference_getuid(data), &nd->u.scr.script->script_vars );
- return 0;
+ return true;
}
/// Opens a warp portal.
@@ -15635,7 +15404,7 @@ BUILDIN_FUNC(getvariableofnpc)
/// warpportal <source x>,<source y>,"<target map>",<target x>,<target y>;
///
/// @author blackhole89
-BUILDIN_FUNC(warpportal)
+BUILDIN(warpportal)
{
int spx;
int spy;
@@ -15644,56 +15413,57 @@ BUILDIN_FUNC(warpportal)
int tpy;
struct skill_unit_group* group;
struct block_list* bl;
-
+
bl = map_id2bl(st->oid);
if( bl == NULL )
{
ShowError("script:warpportal: npc is needed\n");
- return 1;
+ return false;
}
-
+
spx = script_getnum(st,2);
spy = script_getnum(st,3);
mapindex = mapindex_name2id(script_getstr(st, 4));
tpx = script_getnum(st,5);
tpy = script_getnum(st,6);
-
+
if( mapindex == 0 )
- return 0;// map not found
-
+ return true;// map not found
+
group = skill->unitsetting(bl, AL_WARP, 4, spx, spy, 0);
if( group == NULL )
- return 0;// failed
+ return true;// failed
+ group->val1 = (group->val1<<16)|(short)0;
group->val2 = (tpx<<16) | tpy;
group->val3 = mapindex;
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(openmail)
+BUILDIN(openmail)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
mail_openmail(sd);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(openauction)
+BUILDIN(openauction)
{
TBL_PC* sd;
-
+
sd = script_rid2sd(st);
if( sd == NULL )
- return 0;
-
+ return true;
+
clif->auction_openwindow(sd);
-
- return 0;
+
+ return true;
}
/// Retrieves the value of the specified flag of the specified cell.
@@ -15701,16 +15471,16 @@ BUILDIN_FUNC(openauction)
/// checkcell("<map name>",<x>,<y>,<type>) -> <bool>
///
/// @see cell_chk* constants in const.txt for the types
-BUILDIN_FUNC(checkcell)
+BUILDIN(checkcell)
{
int16 m = map_mapname2mapid(script_getstr(st,2));
int16 x = script_getnum(st,3);
int16 y = script_getnum(st,4);
cell_chk type = (cell_chk)script_getnum(st,5);
-
+
script_pushint(st, map_getcell(m, x, y, type));
-
- return 0;
+
+ return true;
}
/// Modifies flags of cells in the specified area.
@@ -15718,7 +15488,7 @@ BUILDIN_FUNC(checkcell)
/// setcell "<map name>",<x1>,<y1>,<x2>,<y2>,<type>,<flag>;
///
/// @see cell_* constants in const.txt for the types
-BUILDIN_FUNC(setcell)
+BUILDIN(setcell)
{
int16 m = map_mapname2mapid(script_getstr(st,2));
int16 x1 = script_getnum(st,3);
@@ -15727,79 +15497,79 @@ BUILDIN_FUNC(setcell)
int16 y2 = script_getnum(st,6);
cell_t type = (cell_t)script_getnum(st,7);
bool flag = (bool)script_getnum(st,8);
-
+
int x,y;
-
+
if( x1 > x2 ) swap(x1,x2);
if( y1 > y2 ) swap(y1,y2);
-
+
for( y = y1; y <= y2; ++y )
for( x = x1; x <= x2; ++x )
map_setcell(m, x, y, type, flag);
-
- return 0;
+
+ return true;
}
/*==========================================
* Mercenary Commands
*------------------------------------------*/
-BUILDIN_FUNC(mercenary_create)
+BUILDIN(mercenary_create)
{
struct map_session_data *sd;
int class_, contract_time;
-
+
if( (sd = script_rid2sd(st)) == NULL || sd->md || sd->status.mer_id != 0 )
- return 0;
-
+ return true;
+
class_ = script_getnum(st,2);
-
+
if( !merc_class(class_) )
- return 0;
-
+ return true;
+
contract_time = script_getnum(st,3);
merc_create(sd, class_, contract_time);
- return 0;
+ return true;
}
-BUILDIN_FUNC(mercenary_heal)
+BUILDIN(mercenary_heal)
{
struct map_session_data *sd = script_rid2sd(st);
int hp, sp;
-
+
if( sd == NULL || sd->md == NULL )
- return 0;
+ return true;
hp = script_getnum(st,2);
sp = script_getnum(st,3);
-
+
status_heal(&sd->md->bl, hp, sp, 0);
- return 0;
+ return true;
}
-BUILDIN_FUNC(mercenary_sc_start)
+BUILDIN(mercenary_sc_start)
{
struct map_session_data *sd = script_rid2sd(st);
enum sc_type type;
int tick, val1;
-
+
if( sd == NULL || sd->md == NULL )
- return 0;
-
+ return true;
+
type = (sc_type)script_getnum(st,2);
tick = script_getnum(st,3);
val1 = script_getnum(st,4);
-
+
status_change_start(&sd->md->bl, type, 10000, val1, 0, 0, 0, tick, 2);
- return 0;
+ return true;
}
-BUILDIN_FUNC(mercenary_get_calls)
+BUILDIN(mercenary_get_calls)
{
struct map_session_data *sd = script_rid2sd(st);
int guild;
-
+
if( sd == NULL )
- return 0;
-
+ return true;
+
guild = script_getnum(st,2);
switch( guild )
{
@@ -15816,21 +15586,21 @@ BUILDIN_FUNC(mercenary_get_calls)
script_pushint(st,0);
break;
}
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(mercenary_set_calls)
+BUILDIN(mercenary_set_calls)
{
struct map_session_data *sd = script_rid2sd(st);
int guild, value, *calls;
-
+
if( sd == NULL )
- return 0;
-
+ return true;
+
guild = script_getnum(st,2);
value = script_getnum(st,3);
-
+
switch( guild )
{
case ARCH_MERC_GUILD:
@@ -15843,23 +15613,23 @@ BUILDIN_FUNC(mercenary_set_calls)
calls = &sd->status.sword_calls;
break;
default:
- return 0; // Invalid Guild
+ return true; // Invalid Guild
}
-
+
*calls += value;
*calls = cap_value(*calls, 0, INT_MAX);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(mercenary_get_faith)
+BUILDIN(mercenary_get_faith)
{
struct map_session_data *sd = script_rid2sd(st);
int guild;
-
+
if( sd == NULL )
- return 0;
-
+ return true;
+
guild = script_getnum(st,2);
switch( guild )
{
@@ -15876,21 +15646,21 @@ BUILDIN_FUNC(mercenary_get_faith)
script_pushint(st,0);
break;
}
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(mercenary_set_faith)
+BUILDIN(mercenary_set_faith)
{
struct map_session_data *sd = script_rid2sd(st);
int guild, value, *calls;
-
+
if( sd == NULL )
- return 0;
-
+ return true;
+
guild = script_getnum(st,2);
value = script_getnum(st,3);
-
+
switch( guild )
{
case ARCH_MERC_GUILD:
@@ -15903,130 +15673,130 @@ BUILDIN_FUNC(mercenary_set_faith)
calls = &sd->status.sword_faith;
break;
default:
- return 0; // Invalid Guild
+ return true; // Invalid Guild
}
-
+
*calls += value;
*calls = cap_value(*calls, 0, INT_MAX);
if( mercenary_get_guild(sd->md) == guild )
clif->mercenary_updatestatus(sd,SP_MERCFAITH);
-
- return 0;
+
+ return true;
}
/*------------------------------------------
* Book Reading
*------------------------------------------*/
-BUILDIN_FUNC(readbook)
+BUILDIN(readbook)
{
struct map_session_data *sd;
int book_id, page;
-
+
if( (sd = script_rid2sd(st)) == NULL )
- return 0;
-
+ return true;
+
book_id = script_getnum(st,2);
page = script_getnum(st,3);
-
+
clif->readbook(sd->fd, book_id, page);
- return 0;
+ return true;
}
/******************
-Questlog script commands
-*******************/
+ Questlog script commands
+ *******************/
-BUILDIN_FUNC(setquest)
+BUILDIN(setquest)
{
struct map_session_data *sd = script_rid2sd(st);
nullpo_ret(sd);
-
+
quest_add(sd, script_getnum(st, 2));
- return 0;
+ return true;
}
-BUILDIN_FUNC(erasequest)
+BUILDIN(erasequest)
{
struct map_session_data *sd = script_rid2sd(st);
nullpo_ret(sd);
-
+
quest_delete(sd, script_getnum(st, 2));
- return 0;
+ return true;
}
-BUILDIN_FUNC(completequest)
+BUILDIN(completequest)
{
struct map_session_data *sd = script_rid2sd(st);
nullpo_ret(sd);
-
+
quest_update_status(sd, script_getnum(st, 2), Q_COMPLETE);
- return 0;
+ return true;
}
-BUILDIN_FUNC(changequest)
+BUILDIN(changequest)
{
struct map_session_data *sd = script_rid2sd(st);
nullpo_ret(sd);
-
+
quest_change(sd, script_getnum(st, 2),script_getnum(st, 3));
- return 0;
+ return true;
}
-BUILDIN_FUNC(checkquest)
+BUILDIN(checkquest)
{
struct map_session_data *sd = script_rid2sd(st);
quest_check_type type = HAVEQUEST;
-
+
nullpo_ret(sd);
-
+
if( script_hasdata(st, 3) )
type = (quest_check_type)script_getnum(st, 3);
-
+
script_pushint(st, quest_check(sd, script_getnum(st, 2), type));
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(showevent)
+BUILDIN(showevent)
{
TBL_PC *sd = script_rid2sd(st);
struct npc_data *nd = map_id2nd(st->oid);
int state, color;
-
+
if( sd == NULL || nd == NULL )
- return 0;
+ return true;
state = script_getnum(st, 2);
color = script_getnum(st, 3);
-
+
if( color < 0 || color > 3 )
- color = 0; // set default color
-
+ color = 0; // set default color
+
clif->quest_show_event(sd, &nd->bl, state, color);
- return 0;
+ return true;
}
/*==========================================
* BattleGround System
*------------------------------------------*/
-BUILDIN_FUNC(waitingroom2bg)
+BUILDIN(waitingroom2bg)
{
struct npc_data *nd;
struct chat_data *cd;
const char *map_name, *ev = "", *dev = "";
int x, y, i, mapindex = 0, bg_id, n;
struct map_session_data *sd;
-
+
if( script_hasdata(st,7) )
nd = npc_name2id(script_getstr(st,7));
else
nd = (struct npc_data *)map_id2bl(st->oid);
-
+
if( nd == NULL || (cd = (struct chat_data *)map_id2bl(nd->chat_id)) == NULL )
{
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
map_name = script_getstr(st,2);
if( strcmp(map_name,"-") != 0 )
{
@@ -16034,21 +15804,21 @@ BUILDIN_FUNC(waitingroom2bg)
if( mapindex == 0 )
{ // Invalid Map
script_pushint(st,0);
- return 0;
+ return true;
}
}
-
+
x = script_getnum(st,3);
y = script_getnum(st,4);
ev = script_getstr(st,5); // Logout Event
dev = script_getstr(st,6); // Die Event
-
+
if( (bg_id = bg_create(mapindex, x, y, ev, dev)) == 0 )
{ // Creation failed
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
n = cd->users;
for( i = 0; i < n && i < MAX_BG_MEMBERS; i++ )
{
@@ -16057,35 +15827,35 @@ BUILDIN_FUNC(waitingroom2bg)
else
mapreg_setreg(reference_uid(add_str("$@arenamembers"), i), 0);
}
-
+
mapreg_setreg(add_str("$@arenamembersnum"), i);
script_pushint(st,bg_id);
- return 0;
+ return true;
}
-BUILDIN_FUNC(waitingroom2bg_single)
+BUILDIN(waitingroom2bg_single)
{
const char* map_name;
struct npc_data *nd;
struct chat_data *cd;
struct map_session_data *sd;
int x, y, mapindex, bg_id;
-
+
bg_id = script_getnum(st,2);
map_name = script_getstr(st,3);
if( (mapindex = mapindex_name2id(map_name)) == 0 )
- return 0; // Invalid Map
-
+ return true; // Invalid Map
+
x = script_getnum(st,4);
y = script_getnum(st,5);
nd = npc_name2id(script_getstr(st,6));
-
+
if( nd == NULL || (cd = (struct chat_data *)map_id2bl(nd->chat_id)) == NULL || cd->users <= 0 )
- return 0;
-
+ return true;
+
if( (sd = cd->usersd[0]) == NULL )
- return 0;
-
+ return true;
+
if( bg_team_join(bg_id, sd) )
{
pc_setpos(sd, mapindex, x, y, CLR_TELEPORT);
@@ -16093,44 +15863,44 @@ BUILDIN_FUNC(waitingroom2bg_single)
}
else
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(bg_team_setxy)
+BUILDIN(bg_team_setxy)
{
struct battleground_data *bg;
int bg_id;
-
+
bg_id = script_getnum(st,2);
if( (bg = bg_team_search(bg_id)) == NULL )
- return 0;
-
+ return true;
+
bg->x = script_getnum(st,3);
bg->y = script_getnum(st,4);
- return 0;
+ return true;
}
-BUILDIN_FUNC(bg_warp)
+BUILDIN(bg_warp)
{
int x, y, mapindex, bg_id;
const char* map_name;
-
+
bg_id = script_getnum(st,2);
map_name = script_getstr(st,3);
if( (mapindex = mapindex_name2id(map_name)) == 0 )
- return 0; // Invalid Map
+ return true; // Invalid Map
x = script_getnum(st,4);
y = script_getnum(st,5);
bg_team_warp(bg_id, mapindex, x, y);
- return 0;
+ return true;
}
-BUILDIN_FUNC(bg_monster)
+BUILDIN(bg_monster)
{
int class_ = 0, x = 0, y = 0, bg_id = 0;
const char *str,*map, *evt="";
-
+
bg_id = script_getnum(st,2);
map = script_getstr(st,3);
x = script_getnum(st,4);
@@ -16140,47 +15910,47 @@ BUILDIN_FUNC(bg_monster)
if( script_hasdata(st,8) ) evt = script_getstr(st,8);
check_event(st, evt);
script_pushint(st, mob_spawn_bg(map,x,y,str,class_,evt,bg_id));
- return 0;
+ return true;
}
-BUILDIN_FUNC(bg_monster_set_team)
+BUILDIN(bg_monster_set_team)
{
struct mob_data *md;
struct block_list *mbl;
int id = script_getnum(st,2),
- bg_id = script_getnum(st,3);
-
+ bg_id = script_getnum(st,3);
+
if( (mbl = map_id2bl(id)) == NULL || mbl->type != BL_MOB )
- return 0;
+ return true;
md = (TBL_MOB *)mbl;
md->bg_id = bg_id;
-
+
mob_stop_attack(md);
mob_stop_walking(md, 0);
md->target_id = md->attacked_id = 0;
clif->charnameack(0, &md->bl);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(bg_leave)
+BUILDIN(bg_leave)
{
struct map_session_data *sd = script_rid2sd(st);
if( sd == NULL || !sd->bg_id )
- return 0;
-
+ return true;
+
bg_team_leave(sd,0);
- return 0;
+ return true;
}
-BUILDIN_FUNC(bg_destroy)
+BUILDIN(bg_destroy)
{
int bg_id = script_getnum(st,2);
bg_team_delete(bg_id);
- return 0;
+ return true;
}
-BUILDIN_FUNC(bg_getareausers)
+BUILDIN(bg_getareausers)
{
const char *str;
int16 m, x0, y0, x1, y1;
@@ -16188,21 +15958,21 @@ BUILDIN_FUNC(bg_getareausers)
int i = 0, c = 0;
struct battleground_data *bg = NULL;
struct map_session_data *sd;
-
+
bg_id = script_getnum(st,2);
str = script_getstr(st,3);
-
+
if( (bg = bg_team_search(bg_id)) == NULL || (m = map_mapname2mapid(str)) < 0 )
{
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
x0 = script_getnum(st,4);
y0 = script_getnum(st,5);
x1 = script_getnum(st,6);
y1 = script_getnum(st,7);
-
+
for( i = 0; i < MAX_BG_MEMBERS; i++ )
{
if( (sd = bg->members[i].sd) == NULL )
@@ -16211,39 +15981,39 @@ BUILDIN_FUNC(bg_getareausers)
continue;
c++;
}
-
+
script_pushint(st,c);
- return 0;
+ return true;
}
-BUILDIN_FUNC(bg_updatescore)
+BUILDIN(bg_updatescore)
{
const char *str;
int16 m;
-
+
str = script_getstr(st,2);
if( (m = map_mapname2mapid(str)) < 0 )
- return 0;
-
+ return true;
+
map[m].bgscore_lion = script_getnum(st,3);
map[m].bgscore_eagle = script_getnum(st,4);
-
+
clif->bg_updatescore(m);
- return 0;
+ return true;
}
-BUILDIN_FUNC(bg_get_data)
+BUILDIN(bg_get_data)
{
struct battleground_data *bg;
int bg_id = script_getnum(st,2),
- type = script_getnum(st,3);
-
+ type = script_getnum(st,3);
+
if( (bg = bg_team_search(bg_id)) == NULL )
{
script_pushint(st,0);
- return 0;
+ return true;
}
-
+
switch( type )
{
case 0: script_pushint(st, bg->count); break;
@@ -16251,102 +16021,102 @@ BUILDIN_FUNC(bg_get_data)
ShowError("script:bg_get_data: unknown data identifier %d\n", type);
break;
}
-
- return 0;
+
+ return true;
}
/*==========================================
* Instancing Script Commands
*------------------------------------------*/
-BUILDIN_FUNC(instance_create)
+BUILDIN(instance_create)
{
const char *name;
int party_id, res;
-
+
name = script_getstr(st, 2);
party_id = script_getnum(st, 3);
-
+
res = instance_create(party_id, name);
if( res == -4 ) // Already exists
{
script_pushint(st, -1);
- return 0;
+ return true;
}
else if( res < 0 )
{
const char *err;
switch(res)
{
- case -3: err = "No free instances"; break;
- case -2: err = "Invalid party ID"; break;
- case -1: err = "Invalid type"; break;
- default: err = "Unknown"; break;
+ case -3: err = "No free instances"; break;
+ case -2: err = "Invalid party ID"; break;
+ case -1: err = "Invalid type"; break;
+ default: err = "Unknown"; break;
}
ShowError("buildin_instance_create: %s [%d].\n", err, res);
script_pushint(st, -2);
- return 0;
+ return true;
}
-
+
script_pushint(st, res);
- return 0;
+ return true;
}
-BUILDIN_FUNC(instance_destroy)
+BUILDIN(instance_destroy)
{
int instance_id;
struct map_session_data *sd;
struct party_data *p;
-
+
if( script_hasdata(st, 2) )
instance_id = script_getnum(st, 2);
else if( st->instance_id )
instance_id = st->instance_id;
else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
instance_id = p->instance_id;
- else return 0;
-
+ else return true;
+
if( instance_id <= 0 || instance_id >= MAX_INSTANCE )
{
ShowError("buildin_instance_destroy: Trying to destroy invalid instance %d.\n", instance_id);
- return 0;
+ return true;
}
-
+
instance_destroy(instance_id);
- return 0;
+ return true;
}
-BUILDIN_FUNC(instance_attachmap)
+BUILDIN(instance_attachmap)
{
const char *name;
int16 m;
int instance_id;
bool usebasename = false;
-
+
name = script_getstr(st,2);
instance_id = script_getnum(st,3);
if( script_hasdata(st,4) && script_getnum(st,4) > 0)
usebasename = true;
-
+
if( (m = instance_add_map(name, instance_id, usebasename)) < 0 ) // [Saithis]
{
ShowError("buildin_instance_attachmap: instance creation failed (%s): %d\n", name, m);
script_pushconststr(st, "");
- return 0;
+ return true;
}
script_pushconststr(st, map[m].name);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(instance_detachmap)
+BUILDIN(instance_detachmap)
{
struct map_session_data *sd;
struct party_data *p;
const char *str;
int16 m;
int instance_id;
-
+
str = script_getstr(st, 2);
if( script_hasdata(st, 3) )
instance_id = script_getnum(st, 3);
@@ -16354,34 +16124,34 @@ BUILDIN_FUNC(instance_detachmap)
instance_id = st->instance_id;
else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
instance_id = p->instance_id;
- else return 0;
-
+ else return true;
+
if( (m = map_mapname2mapid(str)) < 0 || (m = instance_map2imap(m,instance_id)) < 0 )
{
ShowError("buildin_instance_detachmap: Trying to detach invalid map %s\n", str);
- return 0;
+ return true;
}
-
+
instance_del_map(m);
- return 0;
+ return true;
}
-BUILDIN_FUNC(instance_attach)
+BUILDIN(instance_attach)
{
int instance_id;
-
+
instance_id = script_getnum(st, 2);
if( instance_id <= 0 || instance_id >= MAX_INSTANCE )
- return 0;
-
+ return true;
+
st->instance_id = instance_id;
- return 0;
+ return true;
}
-BUILDIN_FUNC(instance_id)
+BUILDIN(instance_id)
{
int instance_id;
-
+
if( script_hasdata(st, 2) )
{
struct party_data *p;
@@ -16397,50 +16167,50 @@ BUILDIN_FUNC(instance_id)
}
else
instance_id = st->instance_id;
-
+
script_pushint(st, instance_id);
- return 0;
+ return true;
}
-BUILDIN_FUNC(instance_set_timeout)
+BUILDIN(instance_set_timeout)
{
int progress_timeout, idle_timeout;
int instance_id;
struct map_session_data *sd;
struct party_data *p;
-
+
progress_timeout = script_getnum(st, 2);
idle_timeout = script_getnum(st, 3);
-
+
if( script_hasdata(st, 4) )
instance_id = script_getnum(st, 4);
else if( st->instance_id )
instance_id = st->instance_id;
else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
instance_id = p->instance_id;
- else return 0;
-
+ else return true;
+
if( instance_id > 0 )
instance_set_timeout(instance_id, progress_timeout, idle_timeout);
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(instance_init)
+BUILDIN(instance_init)
{
int instance_id = script_getnum(st, 2);
-
+
if( instance[instance_id].state != INSTANCE_IDLE )
{
ShowError("instance_init: instance already initialized.\n");
- return 0;
+ return true;
}
-
+
instance_init(instance_id);
- return 0;
+ return true;
}
-BUILDIN_FUNC(instance_announce)
+BUILDIN(instance_announce)
{
int instance_id = script_getnum(st,2);
const char *mes = script_getstr(st,3);
@@ -16450,39 +16220,39 @@ BUILDIN_FUNC(instance_announce)
int fontSize = script_hasdata(st,7) ? script_getnum(st,7) : 12; // default fontSize
int fontAlign = script_hasdata(st,8) ? script_getnum(st,8) : 0; // default fontAlign
int fontY = script_hasdata(st,9) ? script_getnum(st,9) : 0; // default fontY
-
+
int i;
struct map_session_data *sd;
struct party_data *p;
-
+
if( instance_id == 0 )
{
if( st->instance_id )
instance_id = st->instance_id;
else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
instance_id = p->instance_id;
- else return 0;
+ else return true;
}
-
+
if( instance_id <= 0 || instance_id >= MAX_INSTANCE )
- return 0;
-
+ return true;
+
for( i = 0; i < instance[instance_id].num_map; i++ )
map_foreachinmap(buildin_announce_sub, instance[instance_id].map[i], BL_PC,
- mes, strlen(mes)+1, flag&0xf0, fontColor, fontType, fontSize, fontAlign, fontY);
-
- return 0;
+ mes, strlen(mes)+1, flag&0xf0, fontColor, fontType, fontSize, fontAlign, fontY);
+
+ return true;
}
-BUILDIN_FUNC(instance_npcname)
+BUILDIN(instance_npcname)
{
const char *str;
int instance_id = 0;
-
+
struct map_session_data *sd;
struct party_data *p;
struct npc_data *nd;
-
+
str = script_getstr(st, 2);
if( script_hasdata(st, 3) )
instance_id = script_getnum(st, 3);
@@ -16490,7 +16260,7 @@ BUILDIN_FUNC(instance_npcname)
instance_id = st->instance_id;
else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
instance_id = p->instance_id;
-
+
if( instance_id && (nd = npc_name2id(str)) != NULL )
{
static char npcname[NAME_LENGTH];
@@ -16501,20 +16271,20 @@ BUILDIN_FUNC(instance_npcname)
{
ShowError("script:instance_npcname: invalid instance NPC (instance_id: %d, NPC name: \"%s\".)\n", instance_id, str);
st->state = END;
- return 1;
+ return false;
}
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(has_instance)
+BUILDIN(has_instance)
{
struct map_session_data *sd;
struct party_data *p;
const char *str;
int16 m;
int instance_id = 0;
-
+
str = script_getstr(st, 2);
if( script_hasdata(st, 3) )
instance_id = script_getnum(st, 3);
@@ -16522,18 +16292,18 @@ BUILDIN_FUNC(has_instance)
instance_id = st->instance_id;
else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
instance_id = p->instance_id;
-
+
if( !instance_id || (m = map_mapname2mapid(str)) < 0 || (m = instance_map2imap(m, instance_id)) < 0 )
{
script_pushconststr(st, "");
- return 0;
+ return true;
}
-
+
script_pushconststr(st, map[m].name);
- return 0;
+ return true;
}
-BUILDIN_FUNC(instance_warpall)
+BUILDIN(instance_warpall)
{
struct map_session_data *pl_sd;
int16 m, i;
@@ -16542,7 +16312,7 @@ BUILDIN_FUNC(instance_warpall)
int x, y;
unsigned short mapindex;
struct party_data *p = NULL;
-
+
mapn = script_getstr(st,2);
x = script_getnum(st,3);
y = script_getnum(st,4);
@@ -16552,19 +16322,19 @@ BUILDIN_FUNC(instance_warpall)
instance_id = st->instance_id;
else if( (pl_sd = script_rid2sd(st)) != NULL && pl_sd->status.party_id && (p = party_search(pl_sd->status.party_id)) != NULL && p->instance_id )
instance_id = p->instance_id;
- else return 0;
-
+ else return true;
+
if( (m = map_mapname2mapid(mapn)) < 0 || (map[m].flag.src4instance && (m = instance_mapid2imapid(m, instance_id)) < 0) )
- return 0;
-
+ return true;
+
if( !(p = party_search(instance[instance_id].party_id)) )
- return 0;
-
+ return true;
+
mapindex = map_id2index(m);
for( i = 0; i < MAX_PARTY; i++ )
if( (pl_sd = p->data[i].sd) && map[pl_sd->bl.m].instance_id == st->instance_id ) pc_setpos(pl_sd,mapindex,x,y,CLR_TELEPORT);
-
- return 0;
+
+ return true;
}
/*==========================================
@@ -16577,71 +16347,71 @@ BUILDIN_FUNC(instance_warpall)
* Example: instance_check_party (getcharid(1){,amount}{,min}{,max});
* Example 2: instance_check_party (getcharid(1),1,1,99);
*------------------------------------------*/
-BUILDIN_FUNC(instance_check_party)
+BUILDIN(instance_check_party)
{
struct map_session_data *pl_sd;
int amount, min, max, i, party_id, c = 0;
struct party_data *p = NULL;
-
+
amount = script_hasdata(st,3) ? script_getnum(st,3) : 1; // Amount of needed Partymembers for the Instance.
min = script_hasdata(st,4) ? script_getnum(st,4) : 1; // Minimum Level needed to join the Instance.
max = script_hasdata(st,5) ? script_getnum(st,5) : MAX_LEVEL; // Maxium Level allowed to join the Instance.
-
+
if( min < 1 || min > MAX_LEVEL){
ShowError("instance_check_party: Invalid min level, %d\n", min);
- return 0;
+ return true;
}else if( max < 1 || max > MAX_LEVEL){
ShowError("instance_check_party: Invalid max level, %d\n", max);
- return 0;
+ return true;
}
-
+
if( script_hasdata(st,2) )
party_id = script_getnum(st,2);
- else return 0;
-
+ else return true;
+
if( !(p = party_search(party_id)) ){
script_pushint(st, 0); // Returns false if party does not exist.
- return 0;
+ return true;
}
-
+
for( i = 0; i < MAX_PARTY; i++ )
if( (pl_sd = p->data[i].sd) )
if(map_id2bl(pl_sd->bl.id)){
if(pl_sd->status.base_level < min){
script_pushint(st, 0);
- return 0;
+ return true;
}else if(pl_sd->status.base_level > max){
script_pushint(st, 0);
- return 0;
+ return true;
}
- c++;
+ c++;
}
-
+
if(c < amount){
script_pushint(st, 0); // Not enough Members in the Party to join Instance.
}else
script_pushint(st, 1);
-
- return 0;
+
+ return true;
}
/*==========================================
* Custom Fonts
*------------------------------------------*/
-BUILDIN_FUNC(setfont)
+BUILDIN(setfont)
{
struct map_session_data *sd = script_rid2sd(st);
int font = script_getnum(st,2);
if( sd == NULL )
- return 0;
-
+ return true;
+
if( sd->user_font != font )
sd->user_font = font;
else
sd->user_font = 0;
-
+
clif->font(sd);
- return 0;
+ return true;
}
static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap)
@@ -16655,10 +16425,10 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap)
int cancel = va_arg(ap,int);
int emotion = va_arg(ap,int);
int target = va_arg(ap,int);
-
+
if( md->class_ != mobid )
return 0;
-
+
// 0:self, 1:target, 2:master, default:random
switch( target )
{
@@ -16667,40 +16437,40 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap)
case 2: tbl = map_id2bl(md->master_id); break;
default:tbl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md),skill->get_range2(&md->bl, skill_id, skill_lv)); break;
}
-
+
if( !tbl )
return 0;
-
+
if( md->ud.skilltimer != INVALID_TIMER ) // Cancel the casting skill.
unit_skillcastcancel(bl,0);
-
+
if( skill->get_casttype(skill_id) == CAST_GROUND )
unit_skilluse_pos2(&md->bl, tbl->x, tbl->y, skill_id, skill_lv, casttime, cancel);
else
unit_skilluse_id2(&md->bl, tbl->id, skill_id, skill_lv, casttime, cancel);
-
+
clif->emotion(&md->bl, emotion);
-
+
return 0;
}
/*==========================================
* areamobuseskill "Map Name",<x>,<y>,<range>,<Mob ID>,"Skill Name"/<Skill ID>,<Skill Lv>,<Cast Time>,<Cancelable>,<Emotion>,<Target Type>;
*------------------------------------------*/
-BUILDIN_FUNC(areamobuseskill)
+BUILDIN(areamobuseskill)
{
struct block_list center;
int16 m;
int range,mobid,skill_id,skill_lv,casttime,emotion,target,cancel;
-
+
if( (m = map_mapname2mapid(script_getstr(st,2))) < 0 )
{
ShowError("areamobuseskill: invalid map name.\n");
- return 0;
+ return true;
}
-
+
if( map[m].flag.src4instance && st->instance_id && (m = instance_mapid2imapid(m, st->instance_id)) < 0 )
- return 0;
-
+ return true;
+
center.m = m;
center.x = script_getnum(st,3);
center.y = script_getnum(st,4);
@@ -16709,177 +16479,176 @@ BUILDIN_FUNC(areamobuseskill)
skill_id = ( script_isstring(st,7) ? skill->name2id(script_getstr(st,7)) : script_getnum(st,7) );
if( (skill_lv = script_getnum(st,8)) > battle_config.mob_max_skilllvl )
skill_lv = battle_config.mob_max_skilllvl;
-
+
casttime = script_getnum(st,9);
cancel = script_getnum(st,10);
emotion = script_getnum(st,11);
target = script_getnum(st,12);
-
+
map_foreachinrange(buildin_mobuseskill_sub, &center, range, BL_MOB, mobid, skill_id, skill_lv, casttime, cancel, emotion, target);
- return 0;
+ return true;
}
-BUILDIN_FUNC(progressbar)
+BUILDIN(progressbar)
{
struct map_session_data * sd = script_rid2sd(st);
const char * color;
unsigned int second;
-
+
if( !st || !sd )
- return 0;
-
+ return true;
+
st->state = STOP;
-
+
color = script_getstr(st,2);
second = script_getnum(st,3);
-
+
sd->progressbar.npc_id = st->oid;
sd->progressbar.timeout = gettick() + second*1000;
-
+
clif->progressbar(sd, strtol(color, (char **)NULL, 0), second);
- return 0;
+ return true;
}
-BUILDIN_FUNC(pushpc)
+BUILDIN(pushpc)
{
uint8 dir;
int cells, dx, dy;
struct map_session_data* sd;
-
+
if((sd = script_rid2sd(st))==NULL)
{
- return 0;
+ return true;
}
-
+
dir = script_getnum(st,2);
cells = script_getnum(st,3);
-
+
if(dir>7)
{
ShowWarning("buildin_pushpc: Invalid direction %d specified.\n", dir);
script_reportsrc(st);
-
+
dir%= 8; // trim spin-over
}
-
+
if(!cells)
{// zero distance
- return 0;
+ return true;
}
else if(cells<0)
{// pushing backwards
dir = (dir+4)%8; // turn around
cells = -cells;
}
-
+
dx = dirx[dir];
dy = diry[dir];
-
+
unit_blown(&sd->bl, dx, dy, cells, 0);
- return 0;
+ return true;
}
/// Invokes buying store preparation window
/// buyingstore <slots>;
-BUILDIN_FUNC(buyingstore)
+BUILDIN(buyingstore)
{
struct map_session_data* sd;
-
- if( ( sd = script_rid2sd(st) ) == NULL )
- {
- return 0;
+
+ if( ( sd = script_rid2sd(st) ) == NULL ) {
+ return true;
}
-
- buyingstore_setup(sd, script_getnum(st,2));
- return 0;
+
+ buyingstore->setup(sd, script_getnum(st,2));
+ return true;
}
/// Invokes search store info window
/// searchstores <uses>,<effect>;
-BUILDIN_FUNC(searchstores)
+BUILDIN(searchstores)
{
unsigned short effect;
unsigned int uses;
struct map_session_data* sd;
-
+
if( ( sd = script_rid2sd(st) ) == NULL )
{
- return 0;
+ return true;
}
-
+
uses = script_getnum(st,2);
effect = script_getnum(st,3);
-
+
if( !uses )
{
ShowError("buildin_searchstores: Amount of uses cannot be zero.\n");
- return 1;
+ return false;
}
-
+
if( effect > 1 )
{
ShowError("buildin_searchstores: Invalid effect id %hu, specified.\n", effect);
- return 1;
+ return false;
}
-
- searchstore_open(sd, uses, effect);
- return 0;
+
+ searchstore->open(sd, uses, effect);
+ return true;
}
/// Displays a number as large digital clock.
/// showdigit <value>[,<type>];
-BUILDIN_FUNC(showdigit)
+BUILDIN(showdigit)
{
unsigned int type = 0;
int value;
struct map_session_data* sd;
-
+
if( ( sd = script_rid2sd(st) ) == NULL )
{
- return 0;
+ return true;
}
-
+
value = script_getnum(st,2);
-
+
if( script_hasdata(st,3) )
{
type = script_getnum(st,3);
-
+
if( type > 3 )
{
ShowError("buildin_showdigit: Invalid type %u.\n", type);
- return 1;
+ return false;
}
}
-
+
clif->showdigit(sd, (unsigned char)type, value);
- return 0;
+ return true;
}
/**
* Rune Knight
**/
-BUILDIN_FUNC(makerune) {
+BUILDIN(makerune) {
TBL_PC* sd;
if( (sd = script_rid2sd(st)) == NULL )
- return 0;
+ return true;
clif->skill_produce_mix_list(sd,RK_RUNEMASTERY,24);
sd->itemid = script_getnum(st,2);
- return 0;
+ return true;
}
/**
* checkdragon() returns 1 if mounting a dragon or 0 otherwise.
**/
-BUILDIN_FUNC(checkdragon) {
+BUILDIN(checkdragon) {
TBL_PC* sd;
if( (sd = script_rid2sd(st)) == NULL )
- return 0;
+ return true;
if( pc_isridingdragon(sd) )
script_pushint(st,1);
else
script_pushint(st,0);
- return 0;
+ return true;
}
/**
* setdragon({optional Color}) returns 1 on success or 0 otherwise
@@ -16891,12 +16660,12 @@ BUILDIN_FUNC(checkdragon) {
* - 4 : Blue Dragon
* - 5 : Red Dragon
**/
-BUILDIN_FUNC(setdragon) {
+BUILDIN(setdragon) {
TBL_PC* sd;
int color = script_hasdata(st,2) ? script_getnum(st,2) : 0;
if( (sd = script_rid2sd(st)) == NULL )
- return 0;
+ return true;
if( !pc_checkskill(sd,RK_DRAGONTRAINING) || (sd->class_&MAPID_THIRDMASK) != MAPID_RUNE_KNIGHT )
script_pushint(st,0);//Doesn't have the skill or it's not a Rune Knight
else if ( pc_isridingdragon(sd) ) {//Is mounted; release
@@ -16906,10 +16675,10 @@ BUILDIN_FUNC(setdragon) {
unsigned int option = OPTION_DRAGON1;
if( color ) {
option = ( color == 1 ? OPTION_DRAGON1 :
- color == 2 ? OPTION_DRAGON2 :
- color == 3 ? OPTION_DRAGON3 :
- color == 4 ? OPTION_DRAGON4 :
- color == 5 ? OPTION_DRAGON5 : 0);
+ color == 2 ? OPTION_DRAGON2 :
+ color == 3 ? OPTION_DRAGON3 :
+ color == 4 ? OPTION_DRAGON4 :
+ color == 5 ? OPTION_DRAGON5 : 0);
if( !option ) {
ShowWarning("script_setdragon: Unknown Color %d used; changing to green (1)\n",color);
option = OPTION_DRAGON1;
@@ -16918,21 +16687,21 @@ BUILDIN_FUNC(setdragon) {
pc_setoption(sd, sd->sc.option|option);
script_pushint(st,1);
}
- return 0;
+ return true;
}
/**
* ismounting() returns 1 if mounting a new mount or 0 otherwise
**/
-BUILDIN_FUNC(ismounting) {
+BUILDIN(ismounting) {
TBL_PC* sd;
if( (sd = script_rid2sd(st)) == NULL )
- return 0;
+ return true;
if( sd->sc.option&OPTION_MOUNTING )
script_pushint(st,1);
else
script_pushint(st,0);
- return 0;
+ return true;
}
/**
@@ -16941,10 +16710,10 @@ BUILDIN_FUNC(ismounting) {
* - Will fail if the player is mounting a non-new mount, e.g. dragon, peco, wug, etc.
* - Will unmount the player is he is already mounting
**/
-BUILDIN_FUNC(setmounting) {
+BUILDIN(setmounting) {
TBL_PC* sd;
if( (sd = script_rid2sd(st)) == NULL )
- return 0;
+ return true;
if( sd->sc.option&(OPTION_WUGRIDER|OPTION_RIDING|OPTION_DRAGON|OPTION_MADOGEAR) )
script_pushint(st,0);//can't mount with one of these
else {
@@ -16954,33 +16723,33 @@ BUILDIN_FUNC(setmounting) {
pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);//mount
script_pushint(st,1);//in both cases, return 1.
}
- return 0;
+ return true;
}
/**
* Retrieves quantity of arguments provided to callfunc/callsub.
* getargcount() -> amount of arguments received in a function
**/
-BUILDIN_FUNC(getargcount) {
+BUILDIN(getargcount) {
struct script_retinfo* ri;
-
+
if( st->stack->defsp < 1 || st->stack->stack_data[st->stack->defsp - 1].type != C_RETINFO ) {
ShowError("script:getargcount: used out of function or callsub label!\n");
st->state = END;
- return 1;
+ return false;
}
ri = st->stack->stack_data[st->stack->defsp - 1].u.ri;
-
+
script_pushint(st, ri->nargs);
-
- return 0;
+
+ return true;
}
/**
* getcharip(<account ID>/<character ID>/<character name>)
**/
-BUILDIN_FUNC(getcharip)
+BUILDIN(getcharip)
{
struct map_session_data* sd = NULL;
-
+
/* check if a character name is specified */
if( script_hasdata(st, 2) )
{
@@ -16995,169 +16764,174 @@ BUILDIN_FUNC(getcharip)
}
else
sd = script_rid2sd(st);
-
+
/* check for sd and IP */
if (!sd || !session[sd->fd]->client_addr)
{
script_pushconststr(st, "");
- return 0;
+ return true;
}
-
+
/* return the client ip_addr converted for output */
if (sd && sd->fd && session[sd->fd])
{
/* initiliaze */
const char *ip_addr = NULL;
uint32 ip;
-
+
/* set ip, ip_addr and convert to ip and push str */
ip = session[sd->fd]->client_addr;
ip_addr = ip2str(ip, NULL);
script_pushstrcopy(st, ip_addr);
}
-
- return 0;
+
+ return true;
}
/**
* is_function(<function name>) -> 1 if function exists, 0 otherwise
**/
-BUILDIN_FUNC(is_function) {
+BUILDIN(is_function) {
const char* str = script_getstr(st,2);
-
+
if( strdb_exists(userfunc_db, str) )
script_pushint(st,1);
else
script_pushint(st,0);
-
- return 0;
+
+ return true;
}
/**
* get_revision() -> retrieves the current svn revision (if available)
**/
-BUILDIN_FUNC(get_revision) {
+BUILDIN(get_revision) {
const char *svn = get_svn_revision();
-
+
if ( svn[0] != HERC_UNKNOWN_VER )
script_pushint(st,atoi(svn));
else
script_pushint(st,-1);//unknown
-
- return 0;
+
+ return true;
}
/**
* freeloop(<toggle>) -> toggles this script instance's looping-check ability
**/
-BUILDIN_FUNC(freeloop) {
-
+BUILDIN(freeloop) {
+
if( script_getnum(st,2) )
st->freeloop = 1;
else
st->freeloop = 0;
-
+
script_pushint(st, st->freeloop);
-
- return 0;
+
+ return true;
}
/**
* @commands (script based)
**/
-BUILDIN_FUNC(bindatcmd) {
+BUILDIN(bindatcmd) {
const char* atcmd;
const char* eventName;
- int i, level = 0, level2 = 0;
+ int i, group_lv = 0, group_lv_char = 99;
+ bool log = false;
bool create = false;
-
+
atcmd = script_getstr(st,2);
eventName = script_getstr(st,3);
-
- if( *atcmd == atcommand_symbol || *atcmd == charcommand_symbol )
+
+ if( *atcmd == atcommand->at_symbol || *atcmd == atcommand->char_symbol )
atcmd++;
+
+ if( script_hasdata(st,4) ) group_lv = script_getnum(st,4);
+ if( script_hasdata(st,5) ) group_lv_char = script_getnum(st,5);
+ if( script_hasdata(st,6) ) log = script_getnum(st,6) ? true : false;
- if( script_hasdata(st,4) ) level = script_getnum(st,4);
- if( script_hasdata(st,5) ) level2 = script_getnum(st,5);
-
- if( atcmd_binding_count == 0 ) {
- CREATE(atcmd_binding,struct atcmd_binding_data*,1);
-
+
+ if( atcommand->binding_count == 0 ) {
+ CREATE(atcommand->binding,struct atcmd_binding_data*,1);
+
create = true;
} else {
- ARR_FIND(0, atcmd_binding_count, i, strcmp(atcmd_binding[i]->command,atcmd) == 0);
- if( i < atcmd_binding_count ) {/* update existent entry */
- safestrncpy(atcmd_binding[i]->npc_event, eventName, 50);
- atcmd_binding[i]->level = level;
- atcmd_binding[i]->level2 = level2;
+ ARR_FIND(0, atcommand->binding_count, i, strcmp(atcommand->binding[i]->command,atcmd) == 0);
+ if( i < atcommand->binding_count ) {/* update existent entry */
+ safestrncpy(atcommand->binding[i]->npc_event, eventName, ATCOMMAND_LENGTH);
+ atcommand->binding[i]->group_lv = group_lv;
+ atcommand->binding[i]->group_lv_char = group_lv_char;
+ atcommand->binding[i]->log = log;
} else
create = true;
}
-
+
if( create ) {
- i = atcmd_binding_count;
-
- if( atcmd_binding_count++ != 0 )
- RECREATE(atcmd_binding,struct atcmd_binding_data*,atcmd_binding_count);
-
- CREATE(atcmd_binding[i],struct atcmd_binding_data,1);
-
- safestrncpy(atcmd_binding[i]->command, atcmd, 50);
- safestrncpy(atcmd_binding[i]->npc_event, eventName, 50);
- atcmd_binding[i]->level = level;
- atcmd_binding[i]->level2 = level2;
+ i = atcommand->binding_count;
+
+ if( atcommand->binding_count++ != 0 )
+ RECREATE(atcommand->binding,struct atcmd_binding_data*,atcommand->binding_count);
+
+ CREATE(atcommand->binding[i],struct atcmd_binding_data,1);
+
+ safestrncpy(atcommand->binding[i]->command, atcmd, 50);
+ safestrncpy(atcommand->binding[i]->npc_event, eventName, 50);
+ atcommand->binding[i]->group_lv = group_lv;
+ atcommand->binding[i]->group_lv_char = group_lv_char;
+ atcommand->binding[i]->log = log;
}
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(unbindatcmd) {
+BUILDIN(unbindatcmd) {
const char* atcmd;
int i = 0;
-
+
atcmd = script_getstr(st, 2);
-
- if( *atcmd == atcommand_symbol || *atcmd == charcommand_symbol )
+
+ if( *atcmd == atcommand->at_symbol || *atcmd == atcommand->char_symbol )
atcmd++;
-
- if( atcmd_binding_count == 0 ) {
+
+ if( atcommand->binding_count == 0 ) {
script_pushint(st, 0);
- return 0;
+ return true;
}
-
- ARR_FIND(0, atcmd_binding_count, i, strcmp(atcmd_binding[i]->command, atcmd) == 0);
- if( i < atcmd_binding_count ) {
+
+ ARR_FIND(0, atcommand->binding_count, i, strcmp(atcommand->binding[i]->command, atcmd) == 0);
+ if( i < atcommand->binding_count ) {
int cursor = 0;
- aFree(atcmd_binding[i]);
- atcmd_binding[i] = NULL;
+ aFree(atcommand->binding[i]);
+ atcommand->binding[i] = NULL;
/* compact the list now that we freed a slot somewhere */
- for( i = 0, cursor = 0; i < atcmd_binding_count; i++ ) {
- if( atcmd_binding[i] == NULL )
+ for( i = 0, cursor = 0; i < atcommand->binding_count; i++ ) {
+ if( atcommand->binding[i] == NULL )
continue;
-
+
if( cursor != i ) {
- memmove(&atcmd_binding[cursor], &atcmd_binding[i], sizeof(struct atcmd_binding_data*));
+ memmove(&atcommand->binding[cursor], &atcommand->binding[i], sizeof(struct atcmd_binding_data*));
}
-
+
cursor++;
}
-
- if( (atcmd_binding_count = cursor) == 0 )
- aFree(atcmd_binding);
-
+
+ if( (atcommand->binding_count = cursor) == 0 )
+ aFree(atcommand->binding);
+
script_pushint(st, 1);
} else
script_pushint(st, 0);/* not found */
-
- return 0;
+
+ return true;
}
-BUILDIN_FUNC(useatcmd)
+BUILDIN(useatcmd)
{
TBL_PC dummy_sd;
TBL_PC* sd;
int fd;
const char* cmd;
-
+
cmd = script_getstr(st,2);
-
+
if( st->rid )
{
sd = script_rid2sd(st);
@@ -17167,7 +16941,7 @@ BUILDIN_FUNC(useatcmd)
{ // Use a dummy character.
sd = &dummy_sd;
fd = 0;
-
+
memset(&dummy_sd, 0, sizeof(TBL_PC));
if( st->oid )
{
@@ -17177,109 +16951,115 @@ BUILDIN_FUNC(useatcmd)
safestrncpy(dummy_sd.status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH);
}
}
-
+
// compatibility with previous implementation (deprecated!)
- if( cmd[0] != atcommand_symbol )
- {
+ if( cmd[0] != atcommand->at_symbol ) {
cmd += strlen(sd->status.name);
- while( *cmd != atcommand_symbol && *cmd != 0 )
+ while( *cmd != atcommand->at_symbol && *cmd != 0 )
cmd++;
}
-
- is_atcommand(fd, sd, cmd, 1);
- return 0;
+
+ atcommand->parse(fd, sd, cmd, 1);
+ return true;
}
-BUILDIN_FUNC(checkre)
+BUILDIN(checkre)
{
int num;
-
+
num=script_getnum(st,2);
switch(num){
case 0:
- #ifdef RENEWAL
- script_pushint(st, 1);
- #else
- script_pushint(st, 0);
- #endif
+#ifdef RENEWAL
+ script_pushint(st, 1);
+#else
+ script_pushint(st, 0);
+#endif
break;
case 1:
- #ifdef RENEWAL_CAST
- script_pushint(st, 1);
- #else
- script_pushint(st, 0);
- #endif
+#ifdef RENEWAL_CAST
+ script_pushint(st, 1);
+#else
+ script_pushint(st, 0);
+#endif
break;
case 2:
- #ifdef RENEWAL_DROP
- script_pushint(st, 1);
- #else
- script_pushint(st, 0);
- #endif
+#ifdef RENEWAL_DROP
+ script_pushint(st, 1);
+#else
+ script_pushint(st, 0);
+#endif
break;
case 3:
- #ifdef RENEWAL_EXP
- script_pushint(st, 1);
- #else
- script_pushint(st, 0);
- #endif
+#ifdef RENEWAL_EXP
+ script_pushint(st, 1);
+#else
+ script_pushint(st, 0);
+#endif
break;
case 4:
- #ifdef RENEWAL_LVDMG
- script_pushint(st, 1);
- #else
- script_pushint(st, 0);
- #endif
+#ifdef RENEWAL_LVDMG
+ script_pushint(st, 1);
+#else
+ script_pushint(st, 0);
+#endif
break;
case 5:
- #ifdef RENEWAL_EDP
- script_pushint(st, 1);
- #else
- script_pushint(st, 0);
- #endif
+#ifdef RENEWAL_EDP
+ script_pushint(st, 1);
+#else
+ script_pushint(st, 0);
+#endif
break;
case 6:
- #ifdef RENEWAL_ASPD
- script_pushint(st, 1);
- #else
- script_pushint(st, 0);
- #endif
+#ifdef RENEWAL_ASPD
+ script_pushint(st, 1);
+#else
+ script_pushint(st, 0);
+#endif
break;
default:
ShowWarning("buildin_checkre: unknown parameter.\n");
break;
}
- return 0;
+ return true;
}
/* getrandgroupitem <group_id>,<quantity> */
-BUILDIN_FUNC(getrandgroupitem) {
+BUILDIN(getrandgroupitem) {
TBL_PC* sd;
int i, get_count = 0, flag, nameid, group = script_getnum(st, 2), qty = script_getnum(st,3);
struct item item_tmp;
-
+
if( !( sd = script_rid2sd(st) ) )
- return 0;
-
+ return true;
+
if( qty <= 0 ) {
ShowError("getrandgroupitem: qty is <= 0!\n");
- return 1;
+ return false;
}
- if( (nameid = itemdb_searchrandomid(group)) == UNKNOWN_ITEM_ID ) {
- return 1;/* itemdb_searchrandomid will already scream a error */
+
+ if(group < 1 || group >= MAX_ITEMGROUP) {
+ ShowError("getrandgroupitem: Invalid group id %d\n", group);
+ return false;
}
-
+ if (!itemgroup_db[group].qty) {
+ ShowError("getrandgroupitem: group id %d is empty!\n", group);
+ return false;
+ }
+
+ nameid = itemdb_searchrandomid(group);
memset(&item_tmp,0,sizeof(item_tmp));
-
+
item_tmp.nameid = nameid;
item_tmp.identify = itemdb_isidentified(nameid);
-
+
//Check if it's stackable.
if (!itemdb_isstackable(nameid))
get_count = 1;
else
get_count = qty;
-
+
for (i = 0; i < qty; i += get_count) {
// if not pet egg
if (!pet_create_egg(sd, nameid)) {
@@ -17290,8 +17070,8 @@ BUILDIN_FUNC(getrandgroupitem) {
}
}
}
-
- return 0;
+
+ return true;
}
/* cleanmap <map_name>;
@@ -17300,21 +17080,21 @@ static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
{
nullpo_ret(bl);
map_clearflooritem(bl);
-
+
return 0;
}
-BUILDIN_FUNC(cleanmap)
+BUILDIN(cleanmap)
{
const char *map;
int16 m = -1;
int16 x0 = 0, y0 = 0, x1 = 0, y1 = 0;
-
+
map = script_getstr(st, 2);
m = map_mapname2mapid(map);
if (!m)
- return 1;
-
+ return false;
+
if ((script_lastdata(st) - 2) < 4) {
map_foreachinmap(atcommand_cleanfloor_sub, m, BL_ITEM);
} else {
@@ -17326,16 +17106,16 @@ BUILDIN_FUNC(cleanmap)
map_foreachinarea(atcommand_cleanfloor_sub, m, x0, y0, x1, y1, BL_ITEM);
} else {
ShowError("cleanarea: invalid coordinate defined!\n");
- return 1;
+ return false;
}
}
-
- return 0;
+
+ return true;
}
/* Cast a skill on the attached player.
* npcskill <skill id>, <skill lvl>, <stat point>, <NPC level>;
* npcskill "<skill name>", <skill lvl>, <stat point>, <NPC level>; */
-BUILDIN_FUNC(npcskill)
+BUILDIN(npcskill)
{
uint16 skill_id;
unsigned short skill_level;
@@ -17343,55 +17123,55 @@ BUILDIN_FUNC(npcskill)
unsigned int npc_level;
struct npc_data *nd;
struct map_session_data *sd;
-
+
skill_id = script_isstring(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2);
skill_level = script_getnum(st, 3);
stat_point = script_getnum(st, 4);
npc_level = script_getnum(st, 5);
sd = script_rid2sd(st);
nd = (struct npc_data *)map_id2bl(sd->npc_id);
-
+
if (stat_point > battle_config.max_third_parameter) {
ShowError("npcskill: stat point exceeded maximum of %d.\n",battle_config.max_third_parameter );
- return 1;
+ return false;
}
if (npc_level > MAX_LEVEL) {
ShowError("npcskill: level exceeded maximum of %d.\n", MAX_LEVEL);
- return 1;
+ return false;
}
if (sd == NULL || nd == NULL) { //ain't possible, but I don't trust people.
- return 1;
+ return false;
}
-
+
nd->level = npc_level;
nd->stat_point = stat_point;
-
+
if (!nd->status.hp) {
status_calc_npc(nd, true);
} else {
status_calc_npc(nd, false);
}
-
+
if (skill->get_inf(skill_id)&INF_GROUND_SKILL) {
unit_skilluse_pos(&nd->bl, sd->bl.x, sd->bl.y, skill_id, skill_level);
} else {
unit_skilluse_id(&nd->bl, sd->bl.id, skill_id, skill_level);
}
-
- return 0;
+
+ return true;
}
// declarations that were supposed to be exported from npc_chat.c
#ifdef PCRE_SUPPORT
-BUILDIN_FUNC(defpattern);
-BUILDIN_FUNC(activatepset);
-BUILDIN_FUNC(deactivatepset);
-BUILDIN_FUNC(deletepset);
+BUILDIN(defpattern);
+BUILDIN(activatepset);
+BUILDIN(deactivatepset);
+BUILDIN(deletepset);
#endif
/// script command definitions
-/// for an explanation on args, see add_buildin_func
-struct script_function buildin_func[] = {
+/// for an explanation on args, see add_BUILDIN
+struct script_function BUILDIN[] = {
// NPC interaction
BUILDIN_DEF(mes,"s*"),
BUILDIN_DEF(next,""),
@@ -17826,10 +17606,11 @@ struct script_function buildin_func[] = {
BUILDIN_DEF2(cleanmap,"cleanarea","siiii"),
BUILDIN_DEF(npcskill,"viii"),
BUILDIN_DEF(itemeffect,"v"),
+ BUILDIN_DEF(delequip,"i"),
/**
* @commands (script based)
**/
- BUILDIN_DEF(bindatcmd, "ss??"),
+ BUILDIN_DEF(bindatcmd, "ss???"),
BUILDIN_DEF(unbindatcmd, "s"),
BUILDIN_DEF(useatcmd, "s"),
diff --git a/src/map/script.h b/src/map/script.h
index 3e7f3087f..4a12a3f7f 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -191,8 +191,4 @@ int script_reload(void);
// @commands (script based)
void setd_sub(struct script_state *st, TBL_PC *sd, const char *varname, int elem, void *value, struct DBMap **ref);
-#ifdef BETA_THREAD_TEST
-void queryThread_log(char * entry, int length);
-#endif
-
#endif /* _SCRIPT_H_ */
diff --git a/src/map/searchstore.c b/src/map/searchstore.c
index cac79a242..7e1ee3e84 100644
--- a/src/map/searchstore.c
+++ b/src/map/searchstore.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/cbasetypes.h"
#include "../common/malloc.h" // aMalloc, aRealloc, aFree
@@ -12,8 +13,7 @@
/// failure constants for clif functions
-enum e_searchstore_failure
-{
+enum e_searchstore_failure {
SSI_FAILED_NOTHING_SEARCH_ITEM = 0, // "No matching stores were found."
SSI_FAILED_OVER_MAXCOUNT = 1, // "There are too many results. Please enter more detailed search term."
SSI_FAILED_SEARCH_CNT = 2, // "You cannot search anymore."
@@ -22,15 +22,13 @@ enum e_searchstore_failure
};
-enum e_searchstore_searchtype
-{
+enum e_searchstore_searchtype {
SEARCHTYPE_VENDING = 0,
SEARCHTYPE_BUYING_STORE = 1,
};
-enum e_searchstore_effecttype
-{
+enum e_searchstore_effecttype {
EFFECTTYPE_NORMAL = 0,
EFFECTTYPE_CASH = 1,
EFFECTTYPE_MAX
@@ -43,34 +41,28 @@ typedef bool (*searchstore_searchall_t)(struct map_session_data* sd, const struc
/// retrieves search function by type
-static searchstore_search_t searchstore_getsearchfunc(unsigned char type)
-{
- switch( type )
- {
- case SEARCHTYPE_VENDING: return &vending_search;
- case SEARCHTYPE_BUYING_STORE: return &buyingstore_search;
+static inline searchstore_search_t searchstore_getsearchfunc(unsigned char type) {
+ switch( type ) {
+ case SEARCHTYPE_VENDING: return vending->search;
+ case SEARCHTYPE_BUYING_STORE: return buyingstore->search;
}
return NULL;
}
/// retrieves search-all function by type
-static searchstore_searchall_t searchstore_getsearchallfunc(unsigned char type)
-{
- switch( type )
- {
- case SEARCHTYPE_VENDING: return &vending_searchall;
- case SEARCHTYPE_BUYING_STORE: return &buyingstore_searchall;
+static inline searchstore_searchall_t searchstore_getsearchallfunc(unsigned char type) {
+ switch( type ) {
+ case SEARCHTYPE_VENDING: return vending->searchall;
+ case SEARCHTYPE_BUYING_STORE: return buyingstore->searchall;
}
return NULL;
}
/// checks if the player has a store by type
-static bool searchstore_hasstore(struct map_session_data* sd, unsigned char type)
-{
- switch( type )
- {
+static inline bool searchstore_hasstore(struct map_session_data* sd, unsigned char type) {
+ switch( type ) {
case SEARCHTYPE_VENDING: return sd->state.vending;
case SEARCHTYPE_BUYING_STORE: return sd->state.buyingstore;
}
@@ -79,10 +71,8 @@ static bool searchstore_hasstore(struct map_session_data* sd, unsigned char type
/// returns player's store id by type
-static int searchstore_getstoreid(struct map_session_data* sd, unsigned char type)
-{
- switch( type )
- {
+static inline unsigned int searchstore_getstoreid(struct map_session_data* sd, unsigned char type) {
+ switch( type ) {
case SEARCHTYPE_VENDING: return sd->vender_id;
case SEARCHTYPE_BUYING_STORE: return sd->buyer_id;
}
@@ -90,15 +80,12 @@ static int searchstore_getstoreid(struct map_session_data* sd, unsigned char typ
}
-bool searchstore_open(struct map_session_data* sd, unsigned int uses, unsigned short effect)
-{
- if( !battle_config.feature_search_stores || sd->searchstore.open )
- {
+bool searchstore_open(struct map_session_data* sd, unsigned int uses, unsigned short effect) {
+ if( !battle_config.feature_search_stores || sd->searchstore.open ) {
return false;
}
- if( !uses || effect >= EFFECTTYPE_MAX )
- {// invalid input
+ if( !uses || effect >= EFFECTTYPE_MAX ) {// invalid input
return false;
}
@@ -116,63 +103,53 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned
{
unsigned int i;
struct map_session_data* pl_sd;
- struct s_mapiterator* iter;
+ struct DBIterator *iter;
struct s_search_store_search s;
searchstore_searchall_t store_searchall;
time_t querytime;
- if( !battle_config.feature_search_stores )
- {
+ if( !battle_config.feature_search_stores ) {
return;
}
- if( !sd->searchstore.open )
- {
+ if( !sd->searchstore.open ) {
return;
}
- if( ( store_searchall = searchstore_getsearchallfunc(type) ) == NULL )
- {
+ if( ( store_searchall = searchstore_getsearchallfunc(type) ) == NULL ) {
ShowError("searchstore_query: Unknown search type %u (account_id=%d).\n", (unsigned int)type, sd->bl.id);
return;
}
time(&querytime);
- if( sd->searchstore.nextquerytime > querytime )
- {
+ if( sd->searchstore.nextquerytime > querytime ) {
clif->search_store_info_failed(sd, SSI_FAILED_LIMIT_SEARCH_TIME);
return;
}
- if( !sd->searchstore.uses )
- {
+ if( !sd->searchstore.uses ) {
clif->search_store_info_failed(sd, SSI_FAILED_SEARCH_CNT);
return;
}
// validate lists
- for( i = 0; i < item_count; i++ )
- {
- if( !itemdb_exists(itemlist[i]) )
- {
+ for( i = 0; i < item_count; i++ ) {
+ if( !itemdb_exists(itemlist[i]) ) {
ShowWarning("searchstore_query: Client resolved item %hu is not known.\n", itemlist[i]);
clif->search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
return;
}
}
- for( i = 0; i < card_count; i++ )
- {
- if( !itemdb_exists(cardlist[i]) )
- {
+ for( i = 0; i < card_count; i++ ) {
+ if( !itemdb_exists(cardlist[i]) ) {
ShowWarning("searchstore_query: Client resolved card %hu is not known.\n", cardlist[i]);
clif->search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
return;
}
}
- if( max_price < min_price )
- {
+ if( max_price < min_price ) {
swap(min_price, max_price);
}
@@ -181,7 +158,7 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned
sd->searchstore.nextquerytime = querytime+battle_config.searchstore_querydelay;
// drop previous results
- searchstore_clear(sd);
+ searchstore->clear(sd);
// allocate max. amount of results
sd->searchstore.items = (struct s_search_store_info_item*)aMalloc(sizeof(struct s_search_store_info_item)*battle_config.searchstore_maxresults);
@@ -194,26 +171,22 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned
s.card_count = card_count;
s.min_price = min_price;
s.max_price = max_price;
- iter = mapit_geteachpc();
+ iter = db_iterator(vending->db);
- for( pl_sd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); pl_sd = (struct map_session_data*)mapit_next(iter) )
- {
- if( sd == pl_sd )
- {// skip own shop, if any
+ for( pl_sd = dbi_first(iter); dbi_exists(iter); pl_sd = dbi_next(iter) ) {
+ if( sd == pl_sd ) {// skip own shop, if any
continue;
}
- if( !store_searchall(pl_sd, &s) )
- {// exceeded result size
+ if( !store_searchall(pl_sd, &s) ) {// exceeded result size
clif->search_store_info_failed(sd, SSI_FAILED_OVER_MAXCOUNT);
break;
}
}
- mapit_free(iter);
+ dbi_destroy(iter);
- if( sd->searchstore.count )
- {
+ if( sd->searchstore.count ) {
// reclaim unused memory
sd->searchstore.items = (struct s_search_store_info_item*)aRealloc(sd->searchstore.items, sizeof(struct s_search_store_info_item)*sd->searchstore.count);
@@ -222,11 +195,9 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned
// one page displayed
sd->searchstore.pages++;
- }
- else
- {
+ } else {
// cleanup
- searchstore_clear(sd);
+ searchstore->clear(sd);
// update uses
clif->search_store_info_ack(sd);
@@ -238,10 +209,8 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned
/// checks whether or not more results are available for the client
-bool searchstore_querynext(struct map_session_data* sd)
-{
- if( sd->searchstore.count && ( sd->searchstore.count-1 )/SEARCHSTORE_RESULTS_PER_PAGE < sd->searchstore.pages )
- {
+bool searchstore_querynext(struct map_session_data* sd) {
+ if( sd->searchstore.count && ( sd->searchstore.count-1 )/SEARCHSTORE_RESULTS_PER_PAGE < sd->searchstore.pages ) {
return true;
}
@@ -249,8 +218,7 @@ bool searchstore_querynext(struct map_session_data* sd)
}
-void searchstore_next(struct map_session_data* sd)
-{
+void searchstore_next(struct map_session_data* sd) {
if( !battle_config.feature_search_stores || !sd->searchstore.open || sd->searchstore.count <= sd->searchstore.pages*SEARCHSTORE_RESULTS_PER_PAGE )
{// nothing (more) to display
return;
@@ -264,12 +232,10 @@ void searchstore_next(struct map_session_data* sd)
}
-void searchstore_clear(struct map_session_data* sd)
-{
- searchstore_clearremote(sd);
+void searchstore_clear(struct map_session_data* sd) {
+ searchstore->clearremote(sd);
- if( sd->searchstore.items )
- {// release results
+ if( sd->searchstore.items ) {// release results
aFree(sd->searchstore.items);
sd->searchstore.items = NULL;
}
@@ -279,11 +245,9 @@ void searchstore_clear(struct map_session_data* sd)
}
-void searchstore_close(struct map_session_data* sd)
-{
- if( sd->searchstore.open )
- {
- searchstore_clear(sd);
+void searchstore_close(struct map_session_data* sd) {
+ if( sd->searchstore.open ) {
+ searchstore->clear(sd);
sd->searchstore.uses = 0;
sd->searchstore.open = false;
@@ -291,58 +255,49 @@ void searchstore_close(struct map_session_data* sd)
}
-void searchstore_click(struct map_session_data* sd, int account_id, int store_id, unsigned short nameid)
-{
+void searchstore_click(struct map_session_data* sd, int account_id, int store_id, unsigned short nameid) {
unsigned int i;
struct map_session_data* pl_sd;
searchstore_search_t store_search;
- if( !battle_config.feature_search_stores || !sd->searchstore.open || !sd->searchstore.count )
- {
+ if( !battle_config.feature_search_stores || !sd->searchstore.open || !sd->searchstore.count ) {
return;
}
- searchstore_clearremote(sd);
+ searchstore->clearremote(sd);
ARR_FIND( 0, sd->searchstore.count, i, sd->searchstore.items[i].store_id == store_id && sd->searchstore.items[i].account_id == account_id && sd->searchstore.items[i].nameid == nameid );
- if( i == sd->searchstore.count )
- {// no such result, crafted
+ if( i == sd->searchstore.count ) {// no such result, crafted
ShowWarning("searchstore_click: Received request with item %hu of account %d, which is not part of current result set (account_id=%d, char_id=%d).\n", nameid, account_id, sd->bl.id, sd->status.char_id);
clif->search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
return;
}
- if( ( pl_sd = map_id2sd(account_id) ) == NULL )
- {// no longer online
+ if( ( pl_sd = map_id2sd(account_id) ) == NULL ) {// no longer online
clif->search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
return;
}
- if( !searchstore_hasstore(pl_sd, sd->searchstore.type) || searchstore_getstoreid(pl_sd, sd->searchstore.type) != store_id )
- {// no longer vending/buying or not same shop
+ if( !searchstore_hasstore(pl_sd, sd->searchstore.type) || searchstore_getstoreid(pl_sd, sd->searchstore.type) != store_id ) {
+ // no longer vending/buying or not same shop
clif->search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
return;
}
store_search = searchstore_getsearchfunc(sd->searchstore.type);
- if( !store_search(pl_sd, nameid) )
- {// item no longer being sold/bought
+ if( !store_search(pl_sd, nameid) ) {// item no longer being sold/bought
clif->search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
return;
}
- switch( sd->searchstore.effect )
- {
+ switch( sd->searchstore.effect ) {
case EFFECTTYPE_NORMAL:
// display coords
- if( sd->bl.m != pl_sd->bl.m )
- {// not on same map, wipe previous marker
+ if( sd->bl.m != pl_sd->bl.m ) {// not on same map, wipe previous marker
clif->search_store_info_click_ack(sd, -1, -1);
- }
- else
- {
+ } else {
clif->search_store_info_click_ack(sd, pl_sd->bl.x, pl_sd->bl.y);
}
@@ -353,10 +308,9 @@ void searchstore_click(struct map_session_data* sd, int account_id, int store_id
// to bypass range checks
sd->searchstore.remote_id = account_id;
- switch( sd->searchstore.type )
- {
- case SEARCHTYPE_VENDING: vending_vendinglistreq(sd, account_id); break;
- case SEARCHTYPE_BUYING_STORE: buyingstore_open(sd, account_id); break;
+ switch( sd->searchstore.type ) {
+ case SEARCHTYPE_VENDING: vending->list(sd, account_id); break;
+ case SEARCHTYPE_BUYING_STORE: buyingstore->open(sd, account_id); break;
}
break;
@@ -368,26 +322,23 @@ void searchstore_click(struct map_session_data* sd, int account_id, int store_id
/// checks whether or not sd has opened account_id's shop remotely
-bool searchstore_queryremote(struct map_session_data* sd, int account_id)
-{
+bool searchstore_queryremote(struct map_session_data* sd, int account_id) {
return (bool)( sd->searchstore.open && sd->searchstore.count && sd->searchstore.remote_id == account_id );
}
/// removes range-check bypassing for remotely opened stores
-void searchstore_clearremote(struct map_session_data* sd)
-{
+void searchstore_clearremote(struct map_session_data* sd) {
sd->searchstore.remote_id = 0;
}
/// receives results from a store-specific callback
-bool searchstore_result(struct map_session_data* sd, int store_id, int account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const short* card, unsigned char refine)
+bool searchstore_result(struct map_session_data* sd, unsigned int store_id, int account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const short* card, unsigned char refine)
{
struct s_search_store_info_item* ssitem;
- if( sd->searchstore.count >= (unsigned int)battle_config.searchstore_maxresults )
- {// no more
+ if( sd->searchstore.count >= (unsigned int)battle_config.searchstore_maxresults ) {// no more
return false;
}
@@ -403,3 +354,19 @@ bool searchstore_result(struct map_session_data* sd, int store_id, int account_i
return true;
}
+
+void searchstore_defaults (void) {
+ searchstore = &searchstore_s;
+
+ searchstore->open = searchstore_open;
+ searchstore->query = searchstore_query;
+ searchstore->querynext = searchstore_querynext;
+ searchstore->next = searchstore_next;
+ searchstore->clear = searchstore_clear;
+ searchstore->close = searchstore_close;
+ searchstore->click = searchstore_click;
+ searchstore->queryremote = searchstore_queryremote;
+ searchstore->clearremote = searchstore_clearremote;
+ searchstore->result = searchstore_result;
+
+}
diff --git a/src/map/searchstore.h b/src/map/searchstore.h
index ffa8e9784..61e65c7d2 100644
--- a/src/map/searchstore.h
+++ b/src/map/searchstore.h
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _SEARCHSTORE_H_
#define _SEARCHSTORE_H_
@@ -7,8 +8,7 @@
#define SEARCHSTORE_RESULTS_PER_PAGE 10
/// information about the search being performed
-struct s_search_store_search
-{
+struct s_search_store_search {
struct map_session_data* search_sd; // sd of the searching player
const unsigned short* itemlist;
const unsigned short* cardlist;
@@ -18,9 +18,8 @@ struct s_search_store_search
unsigned int max_price;
};
-struct s_search_store_info_item
-{
- int store_id;
+struct s_search_store_info_item {
+ unsigned int store_id;
int account_id;
char store_name[MESSAGE_SIZE];
unsigned short nameid;
@@ -30,8 +29,7 @@ struct s_search_store_info_item
unsigned char refine;
};
-struct s_search_store_info
-{
+struct s_search_store_info {
unsigned int count;
struct s_search_store_info_item* items;
unsigned int pages; // amount of pages already sent to client
@@ -43,15 +41,21 @@ struct s_search_store_info
bool open;
};
-bool searchstore_open(struct map_session_data* sd, unsigned int uses, unsigned short effect);
-void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned int min_price, unsigned int max_price, const unsigned short* itemlist, unsigned int item_count, const unsigned short* cardlist, unsigned int card_count);
-bool searchstore_querynext(struct map_session_data* sd);
-void searchstore_next(struct map_session_data* sd);
-void searchstore_clear(struct map_session_data* sd);
-void searchstore_close(struct map_session_data* sd);
-void searchstore_click(struct map_session_data* sd, int account_id, int store_id, unsigned short nameid);
-bool searchstore_queryremote(struct map_session_data* sd, int account_id);
-void searchstore_clearremote(struct map_session_data* sd);
-bool searchstore_result(struct map_session_data* sd, int store_id, int account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const short* card, unsigned char refine);
+struct searchstore_interface {
+ bool (*open) (struct map_session_data* sd, unsigned int uses, unsigned short effect);
+ void (*query) (struct map_session_data* sd, unsigned char type, unsigned int min_price, unsigned int max_price, const unsigned short* itemlist, unsigned int item_count, const unsigned short* cardlist, unsigned int card_count);
+ bool (*querynext) (struct map_session_data* sd);
+ void (*next) (struct map_session_data* sd);
+ void (*clear) (struct map_session_data* sd);
+ void (*close) (struct map_session_data* sd);
+ void (*click) (struct map_session_data* sd, int account_id, int store_id, unsigned short nameid);
+ bool (*queryremote) (struct map_session_data* sd, int account_id);
+ void (*clearremote) (struct map_session_data* sd);
+ bool (*result) (struct map_session_data* sd, unsigned int store_id, int account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const short* card, unsigned char refine);
+} searchstore_s;
+
+struct searchstore_interface *searchstore;
+
+void searchstore_defaults (void);
#endif // _SEARCHSTORE_H_
diff --git a/src/map/skill.c b/src/map/skill.c
index e393e4293..874ad1a26 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -2233,8 +2233,30 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
* Official Magic Reflection Behavior : damage reflected depends on gears caster wears, not target
**/
#if MAGIC_REFLECTION_TYPE
- if( dmg.dmg_lv != ATK_MISS )//Wiz SL cancelled and consumed fragment
- dmg = battle->calc_attack(BF_MAGIC,bl,bl,skill_id,skill_lv,flag&0xFFF);
+ if( dmg.dmg_lv != ATK_MISS ){ //Wiz SL cancelled and consumed fragment
+ short s_ele = skill->get_ele(skill_id, skill_lv);
+
+ if (s_ele == -1) // the skill takes the weapon's element
+ s_ele = sstatus->rhw.ele;
+ else if (s_ele == -2) //Use status element
+ s_ele = status_get_attack_sc_element(src,status_get_sc(src));
+ else if( s_ele == -3 ) //Use random element
+ s_ele = rnd()%ELE_MAX;
+
+ dmg.damage = battle->attr_fix(bl, bl, dmg.damage, s_ele, status_get_element(bl), status_get_element_level(bl));
+
+ if( sc && sc->data[SC_ENERGYCOAT] ) {
+ struct status_data *status = status_get_status_data(bl);
+ int per = 100*status->sp / status->max_sp -1; //100% should be counted as the 80~99% interval
+ per /=20; //Uses 20% SP intervals.
+ //SP Cost: 1% + 0.5% per every 20% SP
+ if (!status_charge(bl, 0, (10+5*per)*status->max_sp/1000))
+ status_change_end(bl, SC_ENERGYCOAT, INVALID_TIMER);
+ //Reduction: 6% + 6% every 20%
+ dmg.damage -= dmg.damage * (6 * (1+per)) / 100;
+ }
+
+ }
#endif
}
if(sc && sc->data[SC_MAGICROD] && src == dsrc) {
@@ -4043,7 +4065,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
skill->blown(src,bl,distance_bl(src,bl)-1,unit_getdir(src),0);
- if( battle->check_target(src,bl,BCT_ENEMY) )
+ if( battle->check_target(src,bl,BCT_ENEMY) > 0 )
skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
break;
@@ -5223,7 +5245,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
int bonus = 25 + 10 * skill_lv;
bonus += (pc_checkskill(sd, SA_FLAMELAUNCHER)+pc_checkskill(sd, SA_FROSTWEAPON)+pc_checkskill(sd, SA_LIGHTNINGLOADER)+pc_checkskill(sd, SA_SEISMICWEAPON))*5;
clif->skill_nodamage( src, bl, skill_id, skill_lv,
- battle->check_target(src,bl,BCT_PARTY) ?
+ battle->check_target(src,bl,BCT_PARTY) > 0 ?
sc_start2(bl, type, 100, skill_lv, bonus, skill->get_time(skill_id,skill_lv)) :
0
);
@@ -6344,7 +6366,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case SC_DONTFORGETME:
case SC_FORTUNE:
case SC_SERVICE4U:
- if( tsc->data[i]->val4 ) //val4 = out-of-song-area
+ if( !tsc->data[i]->val4 ) //val4 = out-of-song-area
continue;
break;
case SC_ASSUMPTIO:
@@ -6635,18 +6657,21 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NPC_EMOTION_ON:
case NPC_EMOTION:
- //va[0] is the emotion to use.
+ //val[0] is the emotion to use.
//NPC_EMOTION & NPC_EMOTION_ON can change a mob's mode 'permanently' [Skotlex]
//val[1] 'sets' the mode
//val[2] adds to the current mode
//val[3] removes from the current mode
//val[4] if set, asks to delete the previous mode change.
- if(md && md->skill_idx >= 0 && tsc)
- {
+ if(md && md->skill_idx >= 0 && tsc) {
clif->emotion(bl, md->db->skill[md->skill_idx].val[0]);
if(md->db->skill[md->skill_idx].val[4] && tsce)
status_change_end(bl, type, INVALID_TIMER);
+ //If mode gets set by NPC_EMOTION then the target should be reset [Playtester]
+ if(skill_id == NPC_EMOTION && md->db->skill[md->skill_idx].val[1])
+ mob_unlocktarget(md,tick);
+
if(md->db->skill[md->skill_idx].val[1] || md->db->skill[md->skill_idx].val[2])
sc_start4(src, type, 100, skill_lv,
md->db->skill[md->skill_idx].val[1],
@@ -7374,7 +7399,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case ALL_BUYING_STORE:
if( sd )
{// players only, skill allows 5 buying slots
- clif->skill_nodamage(src, bl, skill_id, skill_lv, buyingstore_setup(sd, MAX_BUYINGSTORE_SLOTS));
+ clif->skill_nodamage(src, bl, skill_id, skill_lv, buyingstore->setup(sd, MAX_BUYINGSTORE_SLOTS));
}
break;
case RK_ENCHANTBLADE:
@@ -7740,7 +7765,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
case WL_WHITEIMPRISON:
- if( (src == bl || battle->check_target(src, bl, BCT_ENEMY)) && !is_boss(bl) )// Should not work with bosses.
+ if( (src == bl || battle->check_target(src, bl, BCT_ENEMY) > 0 ) && !is_boss(bl) )// Should not work with bosses.
{
int rate = ( sd? sd->status.job_level : 50 ) / 4;
@@ -11670,11 +11695,11 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
break;
case UNT_SEVERE_RAINSTORM:
- if( battle->check_target(&src->bl, bl, BCT_ENEMY) )
+ if( battle->check_target(&src->bl, bl, BCT_ENEMY) > 0 )
skill->attack(BF_WEAPON,ss,&src->bl,bl,WM_SEVERE_RAINSTORM_MELEE,sg->skill_lv,tick,0);
break;
case UNT_NETHERWORLD:
- if( !(status_get_mode(bl)&MD_BOSS) && ss != bl && battle->check_target(&src->bl, bl, BCT_PARTY) ) {
+ if( !(status_get_mode(bl)&MD_BOSS) && ss != bl && battle->check_target(&src->bl, bl, BCT_PARTY) > 0 ) {
if( !(tsc && tsc->data[type]) ){
sc_start(bl, type, 100, sg->skill_lv, skill->get_time2(sg->skill_id,sg->skill_lv));
sg->limit = DIFF_TICK(tick,sg->tick);
@@ -11811,7 +11836,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
break;
case UNT_FIRE_MANTLE:
- if( battle->check_target(&src->bl, bl, BCT_ENEMY) )
+ if( battle->check_target(&src->bl, bl, BCT_ENEMY) > 0 )
skill->attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0);
break;
@@ -12855,7 +12880,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
MOBID_EMPERIUM, MOBID_GUARIDAN_STONE1, MOBID_GUARIDAN_STONE2)) {
char output[128];
sprintf(output, "You're too close to a stone or emperium to do this skill");
- clif->colormes(sd, COLOR_RED, output);
+ clif->colormes(sd->fd, COLOR_RED, output);
return 0;
}
}
@@ -13236,7 +13261,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id,
skill->get_desc(skill_id),
require.ammo_qty,
itemdb_jname(sd->status.inventory[i].nameid));
- clif->colormes(sd,COLOR_RED,e_msg);
+ clif->colormes(sd->fd,COLOR_RED,e_msg);
return 0;
}
if (!(require.ammo&1<<sd->inventory_data[i]->look)) { //Ammo type check. Send the "wrong weapon type" message
@@ -14160,9 +14185,9 @@ void skill_weaponrefine (struct map_session_data *sd, int idx)
pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
if (per > rnd() % 100) {
- log_pick_pc(sd, LOG_TYPE_OTHER, -1, item);
+ logs->pick_pc(sd, LOG_TYPE_OTHER, -1, item, ditem);
item->refine++;
- log_pick_pc(sd, LOG_TYPE_OTHER, 1, item);
+ logs->pick_pc(sd, LOG_TYPE_OTHER, 1, item, ditem);
if(item->equip) {
ep = item->equip;
pc_unequipitem(sd,idx,3);
diff --git a/src/map/skill.h b/src/map/skill.h
index d1d7d1894..3e2fc7936 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -95,7 +95,6 @@ enum e_skill_inf2 {
INF2_NO_ENEMY = 0x1000,
INF2_NOLP = 0x2000, // Spells that can ignore Land Protector
INF2_CHORUS_SKILL = 0x4000, // Chorus skill
- INF2_CLONE_NOCOPY = 0x8000, // Clones will not copy this skill
};
diff --git a/src/map/sql/CMakeLists.txt b/src/map/sql/CMakeLists.txt
index 2efeabd02..1b2c19979 100644
--- a/src/map/sql/CMakeLists.txt
+++ b/src/map/sql/CMakeLists.txt
@@ -17,8 +17,9 @@ set( SQL_MAP_HEADERS
"${SQL_MAP_SOURCE_DIR}/elemental.h"
"${SQL_MAP_SOURCE_DIR}/guild.h"
"${SQL_MAP_SOURCE_DIR}/homunculus.h"
- "${SQL_MAP_SOURCE_DIR}/instance.h"
+ "${SQL_MAP_SOURCE_DIR}/instance.h"
"${SQL_MAP_SOURCE_DIR}/intif.h"
+ "${SQL_MAP_SOURCE_DIR}/irc-bot.h"
"${SQL_MAP_SOURCE_DIR}/itemdb.h"
"${SQL_MAP_SOURCE_DIR}/log.h"
"${SQL_MAP_SOURCE_DIR}/mail.h"
@@ -28,6 +29,7 @@ set( SQL_MAP_HEADERS
"${SQL_MAP_SOURCE_DIR}/mob.h"
"${SQL_MAP_SOURCE_DIR}/npc.h"
"${SQL_MAP_SOURCE_DIR}/packets.h"
+ "${SQL_MAP_SOURCE_DIR}/packets_struct.h"
"${SQL_MAP_SOURCE_DIR}/party.h"
"${SQL_MAP_SOURCE_DIR}/path.h"
"${SQL_MAP_SOURCE_DIR}/pc.h"
@@ -58,6 +60,7 @@ set( SQL_MAP_SOURCES
"${SQL_MAP_SOURCE_DIR}/homunculus.c"
"${SQL_MAP_SOURCE_DIR}/instance.c"
"${SQL_MAP_SOURCE_DIR}/intif.c"
+ "${SQL_MAP_SOURCE_DIR}/irc-bot.c"
"${SQL_MAP_SOURCE_DIR}/itemdb.c"
"${SQL_MAP_SOURCE_DIR}/log.c"
"${SQL_MAP_SOURCE_DIR}/mail.c"
diff --git a/src/map/status.c b/src/map/status.c
index 5d41acbe0..3892d94cc 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -1503,6 +1503,10 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
if( skill_id == map[src->m].zone->disabled_skills[i]->nameid && (map[src->m].zone->disabled_skills[i]->type&src->type) ) {
if( src->type == BL_PC )
clif->msg((TBL_PC*)src, SKILL_CANT_USE_AREA); // This skill cannot be used within this area
+ else if( src->type == BL_MOB && map[src->m].zone->disabled_skills[i]->subtype != MZS_NONE ) {
+ if( (status->mode&MD_BOSS) && !(map[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) )
+ break;
+ }
return 0;
}
}
@@ -2335,7 +2339,8 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
memset(&status->max_hp, 0, sizeof(struct status_data)-(sizeof(status->hp)+sizeof(status->sp)));
//FIXME: Most of these stuff should be calculated once, but how do I fix the memset above to do that? [Skotlex]
- status->speed = DEFAULT_WALK_SPEED;
+ if (!sd->state.permanent_speed)
+ status->speed = DEFAULT_WALK_SPEED;
//Give them all modes except these (useful for clones)
status->mode = MD_MASK&~(MD_BOSS|MD_PLANT|MD_DETECTOR|MD_ANGRY|MD_TARGETWEAK);
@@ -4988,6 +4993,9 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
if( sc == NULL )
return cap_value(speed,10,USHRT_MAX);
+ if (sd && sd->state.permanent_speed)
+ return (short)cap_value(speed,10,USHRT_MAX);
+
if( sd && sd->ud.skilltimer != INVALID_TIMER && (pc_checkskill(sd,SA_FREECAST) > 0 || sd->ud.skill_id == LG_EXEEDBREAK) )
{
if( sd->ud.skill_id == LG_EXEEDBREAK )
@@ -6078,7 +6086,12 @@ void status_change_init(struct block_list *bl)
//the flag values are the same as in status_change_start.
int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int tick, int flag)
{
- int sc_def = 0, tick_def = 0;
+ //Percentual resistance: 10000 = 100% Resist
+ //Example: 50% -> sc_def=5000 -> 25%; 5000ms -> tick_def=5000 -> 2500ms
+ int sc_def = 0, tick_def = -1; //-1 = use sc_def
+ //Linear resistance substracted from rate and tick after percentual resistance was applied
+ //Example: 25% -> sc_def2=2000 -> 5%; 2500ms -> tick_def2=2000 -> 500ms
+ int sc_def2 = 0, tick_def2 = -1; //-1 = use sc_def2
struct status_data* status;
struct status_change* sc;
struct map_session_data *sd;
@@ -6127,67 +6140,72 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
if( sc && !sc->count )
sc = NULL;
switch (type) {
- case SC_STUN:
- case SC_POISON:
- if( sc && sc->data[SC__UNLUCKY] )
- return tick;
- case SC_DPOISON:
- case SC_SILENCE:
- case SC_BLEEDING:
- sc_def = 3 +status->vit;
- break;
- case SC_SLEEP:
- sc_def = 3 +status->int_;
- break;
- case SC_DEEPSLEEP:
- tick_def = status->int_ / 10 + status_get_lv(bl) * 65 / 1000; // Seems to be -1 sec every 10 int and -5% chance every 10 int.
- sc_def = 5 * status->int_ /10;
- break;
- case SC_DECREASEAGI:
- case SC_ADORAMUS://Arch Bishop
- if (sd) tick>>=1; //Half duration for players.
- case SC_STONE:
- case SC_FREEZE:
- sc_def = 3 +status->mdef;
- break;
- case SC_CURSE:
- //Special property: inmunity when luk is greater than level or zero
- if (status->luk > status_get_lv(bl) || status->luk == 0)
- return 0;
- else
- sc_def = 3 +status->luk;
- tick_def = status->vit;
- break;
- case SC_BLIND:
- if( sc && sc->data[SC__UNLUCKY] )
- return tick;
- sc_def = 3 +(status->vit + status->int_)/2;
- break;
- case SC_CONFUSION:
- sc_def = 3 +(status->str + status->int_)/2;
- break;
- case SC_ANKLE:
- if(status->mode&MD_BOSS) // Lasts 5 times less on bosses
- tick /= 5;
- sc_def = status->agi / 2;
- break;
- case SC_MAGICMIRROR:
- case SC_ARMORCHANGE:
- if (sd) //Duration greatly reduced for players.
- tick /= 15;
- //No defense against it (buff).
- rate -= (status_get_lv(bl) / 5 + status->vit / 4 + status->agi / 10)*100; // Lineal Reduction of Rate
- break;
+ case SC_STUN:
+ case SC_POISON:
+ if( sc && sc->data[SC__UNLUCKY] )
+ return tick;
+ case SC_DPOISON:
+ case SC_SILENCE:
+ case SC_BLEEDING:
+ sc_def = status->vit*100;
+ sc_def2 = status->luk*10;
+ break;
+ case SC_SLEEP:
+ sc_def = status->int_*100;
+ sc_def2 = status->luk*10;
+ break;
+ case SC_DEEPSLEEP:
+ sc_def = status->int_*50;
+ tick_def = status->int_*10 + status_get_lv(bl) * 65 / 10; //Seems to be -1 sec every 10 int and -5% chance every 10 int.
+ break;
+ case SC_DECREASEAGI:
+ case SC_ADORAMUS: //Arch Bishop
+ if (sd) tick>>=1; //Half duration for players.
+ case SC_STONE:
+ //Impossible to reduce duration with stats
+ tick_def = 0;
+ tick_def2 = 0;
+ case SC_FREEZE:
+ sc_def = status->mdef*100;
+ sc_def2 = status->luk*10;
+ break;
+ case SC_CURSE:
+ //Special property: inmunity when luk is greater than level or zero
+ if (status->luk > status_get_lv(bl) || status->luk == 0)
+ return 0;
+ sc_def = status->luk*100;
+ sc_def2 = status->luk*10;
+ tick_def = status->vit*100;
+ break;
+ case SC_BLIND:
+ if( sc && sc->data[SC__UNLUCKY] )
+ return tick;
+ sc_def = (status->vit + status->int_)*50;
+ sc_def2 = status->luk*10;
+ break;
+ case SC_CONFUSION:
+ sc_def = (status->str + status->int_)*50;
+ sc_def2 = status->luk*10;
+ break;
+ case SC_ANKLE:
+ if(status->mode&MD_BOSS) // Lasts 5 times less on bosses
+ tick /= 5;
+ sc_def = status->agi*50;
+ break;
+ case SC_MAGICMIRROR:
+ case SC_ARMORCHANGE:
+ if (sd) //Duration greatly reduced for players.
+ tick /= 15;
+ sc_def2 = status_get_lv(bl)*20 + status->vit*25 + status->agi*10; // Lineal Reduction of Rate
+ tick_def2 = 0; //No duration reduction
+ break;
case SC_MARSHOFABYSS:
//5 second (Fixed) + 25 second - {( INT + LUK ) / 20 second }
- tick -= (status->int_ + status->luk) / 20 * 1000;
+ tick_def2 = (status->int_ + status->luk)*50;
break;
case SC_STASIS:
//5 second (fixed) + { Stasis Skill level * 5 - (Target's VIT + DEX) / 20 }
- tick -= (status->vit + status->dex) / 20 * 1000;
- break;
- case SC_WHITEIMPRISON:
- if( tick == 5000 ) // 100% on caster
+ tick_def2 = (status->vit + status->dex)*50;
break;
if( bl->type == BL_PC )
tick -= (status_get_lv(bl) / 5 + status->vit / 4 + status->agi / 10)*100;
@@ -6236,51 +6254,58 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
if (sd) {
- if (battle_config.pc_sc_def_rate != 100)
+ if (battle_config.pc_sc_def_rate != 100) {
sc_def = sc_def*battle_config.pc_sc_def_rate/100;
+ sc_def2 = sc_def2*battle_config.pc_sc_def_rate/100;
+ }
- if (sc_def < battle_config.pc_max_sc_def)
- sc_def += (battle_config.pc_max_sc_def - sc_def)*
- status->luk/battle_config.pc_luk_sc_def;
- else
- sc_def = battle_config.pc_max_sc_def;
+ sc_def = min(sc_def, battle_config.pc_max_sc_def*100);
+ sc_def2 = min(sc_def2, battle_config.pc_max_sc_def*100);
- if (tick_def) {
- if (battle_config.pc_sc_def_rate != 100)
- tick_def = tick_def*battle_config.pc_sc_def_rate/100;
+ if (tick_def > 0 && battle_config.pc_sc_def_rate != 100) {
+ tick_def = tick_def*battle_config.pc_sc_def_rate/100;
+ tick_def2 = tick_def2*battle_config.pc_sc_def_rate/100;
}
-
} else {
- if (battle_config.mob_sc_def_rate != 100)
+ if (battle_config.mob_sc_def_rate != 100) {
sc_def = sc_def*battle_config.mob_sc_def_rate/100;
+ sc_def2 = sc_def2*battle_config.mob_sc_def_rate/100;
+ }
- if (sc_def < battle_config.mob_max_sc_def)
- sc_def += (battle_config.mob_max_sc_def - sc_def)*
- status->luk/battle_config.mob_luk_sc_def;
- else
- sc_def = battle_config.mob_max_sc_def;
+ sc_def = min(sc_def, battle_config.mob_max_sc_def*100);
+ sc_def2 = min(sc_def2, battle_config.mob_max_sc_def*100);
- if (tick_def) {
- if (battle_config.mob_sc_def_rate != 100)
- tick_def = tick_def*battle_config.mob_sc_def_rate/100;
+ if (tick_def > 0 && battle_config.mob_sc_def_rate != 100) {
+ tick_def = tick_def*battle_config.mob_sc_def_rate/100;
+ tick_def2 = tick_def2*battle_config.mob_sc_def_rate/100;
}
}
if (sc) {
if (sc->data[SC_SCRESIST])
- sc_def += sc->data[SC_SCRESIST]->val1; //Status resist
+ sc_def += sc->data[SC_SCRESIST]->val1*100; //Status resist
else if (sc->data[SC_SIEGFRIED])
- sc_def += sc->data[SC_SIEGFRIED]->val3; //Status resistance.
+ sc_def += sc->data[SC_SIEGFRIED]->val3*100; //Status resistance.
}
//When no tick def, reduction is the same for both.
- if( !tick_def && type != SC_STONE ) //Recent tests show duration of petrify isn't reduced by MDEF. [Inkfish]
+ if(tick_def < 0)
tick_def = sc_def;
+ if(tick_def2 < 0)
+ tick_def2 = sc_def2;
//Natural resistance
if (!(flag&8)) {
- rate -= rate*sc_def/100;
+ rate -= rate*sc_def/10000;
+ rate -= sc_def2;
+
+ //Minimum chances
+ switch (type) {
+ case SC_BITE:
+ rate = max(rate, 5000); //Minimum of 50%
+ break;
+ }
//Item resistance (only applies to rate%)
if(sd && SC_COMMON_MIN <= type && type <= SC_COMMON_MAX)
@@ -6291,22 +6316,38 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
rate -= rate*sd->sc.data[SC_COMMONSC_RESIST]->val1/100;
}
}
+
if (!(rnd()%10000 < rate))
return 0;
- //Why would a status start with no duration? Presume it has
- //duration defined elsewhere.
- if (!tick) return 1;
+ //Even if a status change doesn't have a duration, it should still trigger
+ if (tick < 1) return 1;
//Rate reduction
- if (flag&2)
+ if (flag&2)
return tick;
- tick -= tick*tick_def/100;
- // Changed to 5 seconds according to recent tests [Playtester]
- if (type == SC_ANKLE && tick < 5000)
- tick = 5000;
- return tick<=0?0:tick;
+ tick -= tick*tick_def/10000;
+ tick -= tick_def2;
+
+ //Minimum durations
+ switch (type) {
+ case SC_ANKLE:
+ case SC_MARSHOFABYSS:
+ case SC_STASIS:
+ tick = max(tick, 5000); //Minimum duration 5s
+ break;
+ case SC_BURNING:
+ case SC_FREEZING:
+ tick = max(tick, 10000); //Minimum duration 10s
+ break;
+ default:
+ //Skills need to trigger even if the duration is reduced below 1ms
+ tick = max(tick, 1);
+ break;
+ }
+
+ return tick;
}
/*==========================================
@@ -6552,11 +6593,6 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
opt_flag = 0; //Reuse to check success condition.
if(sd->bonus.unstripable_equip&EQP_WEAPON)
return 0;
- i = sd->equip_index[EQI_HAND_L];
- if (i>=0 && sd->inventory_data[i] && sd->inventory_data[i]->type == IT_WEAPON) {
- opt_flag|=1;
- pc_unequipitem(sd,i,3); //L-hand weapon
- }
i = sd->equip_index[EQI_HAND_R];
if (i>=0 && sd->inventory_data[i] && sd->inventory_data[i]->type == IT_WEAPON) {
@@ -7258,7 +7294,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_MERC_QUICKEN:
val2 = 300;
break;
-#ifndef RENEWAL
+#ifndef RENEWAL_ASPD
case SC_SPEARQUICKEN:
val2 = 200+10*val1;
break;
@@ -8966,7 +9002,6 @@ int status_change_clear(struct block_list* bl, int type) {
sc->opt1 = 0;
sc->opt2 = 0;
sc->opt3 = 0;
- sc->option &= OPTION_MASK;
if( type == 0 || type == 2 )
clif->changeoption(bl);
@@ -9853,6 +9888,9 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if (--(sce->val4) >= 0) {
int hp = rnd()%600 + 200;
struct block_list* src = map_id2bl(sce->val2);
+ if( src && bl && bl->type == BL_MOB ) {
+ mob_log_damage((TBL_MOB*)bl,src,sd||hp<status->hp?hp:status->hp-1);
+ }
map_freeblock_lock();
status_fix_damage(src, bl, sd||hp<status->hp?hp:status->hp-1, 1);
if( sc->data[type] ) {
diff --git a/src/map/status.h b/src/map/status.h
index 4535b1aed..3c02b9d6c 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -1488,7 +1488,6 @@ enum {
// compound constants
OPTION_DRAGON = OPTION_DRAGON1|OPTION_DRAGON2|OPTION_DRAGON3|OPTION_DRAGON4|OPTION_DRAGON5,
- OPTION_MASK = ~OPTION_INVISIBLE,
};
//Defines for the manner system [Skotlex]
diff --git a/src/map/trade.c b/src/map/trade.c
index 0b9609322..1417426e9 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -77,7 +77,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta
}
// Players can not request trade from far away, unless they are allowed to use @trade.
- if (!pc_can_use_command(sd, "trade", COMMAND_ATCOMMAND) &&
+ if (!pc_can_use_command(sd, "@trade") &&
(sd->bl.m != target_sd->bl.m || !check_distance_bl(&sd->bl, &target_sd->bl, TRADE_DISTANCE))) {
clif->tradestart(sd, 0); // too far
return ;
@@ -135,7 +135,7 @@ void trade_tradeack(struct map_session_data *sd, int type)
// Players can not request trade from far away, unless they are allowed to use @trade.
// Check here as well since the original character could had warped.
- if (!pc_can_use_command(sd, "trade", COMMAND_ATCOMMAND) &&
+ if (!pc_can_use_command(sd, "@trade") &&
(sd->bl.m != tsd->bl.m || !check_distance_bl(&sd->bl, &tsd->bl, TRADE_DISTANCE))) {
clif->tradestart(sd, 0); // too far
sd->trade_partner=0;
@@ -178,8 +178,7 @@ int impossible_trade_check(struct map_session_data *sd)
nullpo_retr(1, sd);
- if(sd->deal.zeny > sd->status.zeny)
- {
+ if(sd->deal.zeny > sd->status.zeny) {
pc_setglobalreg(sd,"ZENY_HACKER",1);
return -1;
}
diff --git a/src/map/unit.c b/src/map/unit.c
index 4732b89dd..952b1a20e 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -330,7 +330,7 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
&& wpd.path_len > 14 ) // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett]
return 0;
#endif
- if( battle_config.max_walk_path < wpd.path_len )
+ if( (battle_config.max_walk_path < wpd.path_len) && (bl->type != BL_NPC) )
return 0;
if (flag&4 && DIFF_TICK(ud->canmove_tick, gettick()) > 0 &&
@@ -406,7 +406,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
ud = unit_bl2ud(bl);
if( ud == NULL) return 0;
-
+
if (!(status_get_mode(bl)&MD_CANMOVE))
return 0;
@@ -416,13 +416,13 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
ud->target_to = 0;
return 0;
}
-
+
ud->state.walk_easy = flag&1;
ud->target_to = tbl->id;
ud->chaserange = range; //Note that if flag&2, this SHOULD be attack-range
ud->state.attack_continue = flag&2?1:0; //Chase to attack.
unit_set_target(ud, 0);
-
+
sc = status_get_sc(bl);
if (sc && sc->data[SC_CONFUSION]) //Randomize the target position
map_random_dir(bl, &ud->to_x, &ud->to_y);
@@ -432,7 +432,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
set_mobstate(bl, flag&2);
return 1;
}
-
+
if(DIFF_TICK(ud->canmove_tick, gettick()) > 0)
{ //Can't move, wait a bit before invoking the movement.
add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->target);
@@ -1149,40 +1149,40 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
if(sd) {
if( (skill->get_inf2(skill_id)&INF2_ENSEMBLE_SKILL) && skill->check_pc_partner(sd, skill_id, &skill_lv, 1, 0) < 1 ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
- }
-
+ }
+
switch(skill_id){
- case SA_CASTCANCEL:
- if(ud->skill_id != skill_id){
- sd->skill_id_old = ud->skill_id;
- sd->skill_lv_old = ud->skill_lv;
- }
- break;
- case BD_ENCORE:
- //Prevent using the dance skill if you no longer have the skill in your tree.
- if(!sd->skill_id_dance || pc_checkskill(sd,sd->skill_id_dance)<=0){
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- return 0;
+ case SA_CASTCANCEL:
+ if(ud->skill_id != skill_id){
+ sd->skill_id_old = ud->skill_id;
+ sd->skill_lv_old = ud->skill_lv;
+ }
+ break;
+ case BD_ENCORE:
+ //Prevent using the dance skill if you no longer have the skill in your tree.
+ if(!sd->skill_id_dance || pc_checkskill(sd,sd->skill_id_dance)<=0){
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ return 0;
+ }
+ sd->skill_id_old = skill_id;
+ break;
+ case WL_WHITEIMPRISON:
+ if( battle->check_target(src,target,BCT_SELF|BCT_ENEMY) < 0 ) {
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_TOTARGET,0);
+ return 0;
+ }
+ break;
+ case MG_FIREBOLT:
+ case MG_LIGHTNINGBOLT:
+ case MG_COLDBOLT:
+ sd->skill_id_old = skill_id;
+ sd->skill_lv_old = skill_lv;
+ break;
}
- sd->skill_id_old = skill_id;
- break;
- case WL_WHITEIMPRISON:
- if( battle->check_target(src,target,BCT_SELF|BCT_ENEMY) < 0 ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_TOTARGET,0);
+ if (!skill->check_condition_castbegin(sd, skill_id, skill_lv))
return 0;
- }
- break;
- case MG_FIREBOLT:
- case MG_LIGHTNINGBOLT:
- case MG_COLDBOLT:
- sd->skill_id_old = skill_id;
- sd->skill_lv_old = skill_lv;
- break;
- }
- if (!skill->check_condition_castbegin(sd, skill_id, skill_lv))
- return 0;
}
if( src->type == BL_MOB )
@@ -2089,13 +2089,18 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
case BL_PC: {
struct map_session_data *sd = (struct map_session_data*)bl;
+ if(sd->shadowform_id){
+ struct block_list *d_bl = map_id2bl(sd->shadowform_id);
+ if( d_bl )
+ status_change_end(d_bl,SC__SHADOWFORM,INVALID_TIMER);
+ }
//Leave/reject all invitations.
if(sd->chatID)
chat_leavechat(sd,0);
if(sd->trade_partner)
trade_tradecancel(sd);
- buyingstore_close(sd);
- searchstore_close(sd);
+ buyingstore->close(sd);
+ searchstore->close(sd);
if(sd->state.storage_flag == 1)
storage_storage_quit(sd,0);
else if (sd->state.storage_flag == 2)
diff --git a/src/map/vending.c b/src/map/vending.c
index 1f96672f4..1576b684e 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/nullpo.h"
#include "../common/strlib.h"
@@ -20,33 +21,28 @@
#include <stdio.h>
#include <string.h>
-static int vending_nextid = 0;
-
/// Returns an unique vending shop id.
-static int vending_getuid(void)
-{
- return vending_nextid++;
+static inline unsigned int getid(void) {
+ return vending->next_id++;
}
/*==========================================
* Close shop
*------------------------------------------*/
-void vending_closevending(struct map_session_data* sd)
-{
+void vending_closevending(struct map_session_data* sd) {
nullpo_retv(sd);
- if( sd->state.vending )
- {
+ if( sd->state.vending ) {
sd->state.vending = false;
clif->closevendingboard(&sd->bl, 0);
+ idb_remove(vending->db, sd->status.char_id);
}
}
/*==========================================
* Request a shop's item list
*------------------------------------------*/
-void vending_vendinglistreq(struct map_session_data* sd, int id)
-{
+void vending_vendinglistreq(struct map_session_data* sd, unsigned int id) {
struct map_session_data* vsd;
nullpo_retv(sd);
@@ -55,8 +51,8 @@ void vending_vendinglistreq(struct map_session_data* sd, int id)
if( !vsd->state.vending )
return; // not vending
- if (!pc_can_give_items(sd) || !pc_can_give_items(vsd)) //check if both GMs are allowed to trade
- { // GM is not allowed to trade
+ if (!pc_can_give_items(sd) || !pc_can_give_items(vsd)) { //check if both GMs are allowed to trade
+ // GM is not allowed to trade
clif->message(sd->fd, msg_txt(246));
return;
}
@@ -69,27 +65,25 @@ void vending_vendinglistreq(struct map_session_data* sd, int id)
/*==========================================
* Purchase item(s) from a shop
*------------------------------------------*/
-void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const uint8* data, int count)
-{
+void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, const uint8* data, int count) {
int i, j, cursor, w, new_ = 0, blank, vend_list[MAX_VENDING];
double z;
- struct s_vending vending[MAX_VENDING]; // against duplicate packets
+ struct s_vending vend[MAX_VENDING]; // against duplicate packets
struct map_session_data* vsd = map_id2sd(aid);
nullpo_retv(sd);
if( vsd == NULL || !vsd->state.vending || vsd->bl.id == sd->bl.id )
return; // invalid shop
- if( vsd->vender_id != uid )
- {// shop has changed
+ if( vsd->vender_id != uid ) { // shop has changed
clif->buyvending(sd, 0, 0, 6); // store information was incorrect
return;
}
- if( !searchstore_queryremote(sd, aid) && ( sd->bl.m != vsd->bl.m || !check_distance_bl(&sd->bl, &vsd->bl, AREA_SIZE) ) )
+ if( !searchstore->queryremote(sd, aid) && ( sd->bl.m != vsd->bl.m || !check_distance_bl(&sd->bl, &vsd->bl, AREA_SIZE) ) )
return; // shop too far away
- searchstore_clearremote(sd);
+ searchstore->clearremote(sd);
if( count < 1 || count > MAX_VENDING || count > vsd->vend_num )
return; // invalid amount of purchased items
@@ -97,13 +91,12 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
blank = pc_inventoryblank(sd); //number of free cells in the buyer's inventory
// duplicate item in vending to check hacker with multiple packets
- memcpy(&vending, &vsd->vending, sizeof(vsd->vending)); // copy vending list
+ memcpy(&vend, &vsd->vending, sizeof(vsd->vending)); // copy vending list
// some checks
z = 0.; // zeny counter
w = 0; // weight counter
- for( i = 0; i < count; i++ )
- {
+ for( i = 0; i < count; i++ ) {
short amount = *(uint16*)(data + 4*i + 0);
short idx = *(uint16*)(data + 4*i + 2);
idx -= 2;
@@ -122,49 +115,45 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
vend_list[i] = j;
z += ((double)vsd->vending[j].value * (double)amount);
- if( z > (double)sd->status.zeny || z < 0. || z > (double)MAX_ZENY )
- {
+ if( z > (double)sd->status.zeny || z < 0. || z > (double)MAX_ZENY ) {
clif->buyvending(sd, idx, amount, 1); // you don't have enough zeny
return;
}
- if( z + (double)vsd->status.zeny > (double)MAX_ZENY && !battle_config.vending_over_max )
- {
+ if( z + (double)vsd->status.zeny > (double)MAX_ZENY && !battle_config.vending_over_max ) {
clif->buyvending(sd, idx, vsd->vending[j].amount, 4); // too much zeny = overflow
return;
}
w += itemdb_weight(vsd->status.cart[idx].nameid) * amount;
- if( w + sd->weight > sd->max_weight )
- {
+ if( w + sd->weight > sd->max_weight ) {
clif->buyvending(sd, idx, amount, 2); // you can not buy, because overweight
return;
}
//Check to see if cart/vend info is in sync.
- if( vending[j].amount > vsd->status.cart[idx].amount )
- vending[j].amount = vsd->status.cart[idx].amount;
+ if( vend[j].amount > vsd->status.cart[idx].amount )
+ vend[j].amount = vsd->status.cart[idx].amount;
// if they try to add packets (example: get twice or more 2 apples if marchand has only 3 apples).
// here, we check cumulative amounts
- if( vending[j].amount < amount )
- {
+ if( vend[j].amount < amount ) {
// send more quantity is not a hack (an other player can have buy items just before)
clif->buyvending(sd, idx, vsd->vending[j].amount, 4); // not enough quantity
return;
}
- vending[j].amount -= amount;
+ vend[j].amount -= amount;
switch( pc_checkadditem(sd, vsd->status.cart[idx].nameid, amount) ) {
- case ADDITEM_EXIST:
- break; //We'd add this item to the existing one (in buyers inventory)
- case ADDITEM_NEW:
- new_++;
- if (new_ > blank)
- return; //Buyer has no space in his inventory
- break;
- case ADDITEM_OVERAMOUNT:
- return; //too many items
+ case ADDITEM_EXIST:
+ break; //We'd add this item to the existing one (in buyers inventory)
+ case ADDITEM_NEW:
+ new_++;
+ if (new_ > blank)
+ return; //Buyer has no space in his inventory
+ break;
+ case ADDITEM_OVERAMOUNT:
+ return; //too many items
}
}
@@ -173,8 +162,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
z -= z * (battle_config.vending_tax/10000.);
pc_getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd);
- for( i = 0; i < count; i++ )
- {
+ for( i = 0; i < count; i++ ) {
short amount = *(uint16*)(data + 4*i + 0);
short idx = *(uint16*)(data + 4*i + 2);
idx -= 2;
@@ -186,8 +174,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
clif->vendingreport(vsd, idx, amount);
//print buyer's name
- if( battle_config.buyer_name )
- {
+ if( battle_config.buyer_name ) {
char temp[256];
sprintf(temp, msg_txt(265), sd->status.name);
clif->disp_onlyself(vsd,temp,strlen(temp));
@@ -195,13 +182,11 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
}
// compact the vending list
- for( i = 0, cursor = 0; i < vsd->vend_num; i++ )
- {
+ for( i = 0, cursor = 0; i < vsd->vend_num; i++ ) {
if( vsd->vending[i].amount == 0 )
continue;
- if( cursor != i ) // speedup
- {
+ if( cursor != i ) { // speedup
vsd->vending[cursor].index = vsd->vending[i].index;
vsd->vending[cursor].amount = vsd->vending[i].amount;
vsd->vending[cursor].value = vsd->vending[i].value;
@@ -212,21 +197,18 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
vsd->vend_num = cursor;
//Always save BOTH: buyer and customer
- if( save_settings&2 )
- {
+ if( save_settings&2 ) {
chrif_save(sd,0);
chrif_save(vsd,0);
}
//check for @AUTOTRADE users [durf]
- if( vsd->state.autotrade )
- {
+ if( vsd->state.autotrade ) {
//see if there is anything left in the shop
ARR_FIND( 0, vsd->vend_num, i, vsd->vending[i].amount > 0 );
- if( i == vsd->vend_num )
- {
+ if( i == vsd->vend_num ) {
//Close Vending (this was automatically done by the client, we have to do it manually for autovenders) [Skotlex]
- vending_closevending(vsd);
+ vending->close(vsd);
map_quit(vsd); //They have no reason to stay around anymore, do they?
}
}
@@ -246,23 +228,21 @@ void vending_openvending(struct map_session_data* sd, const char* message, const
vending_skill_lvl = pc_checkskill(sd, MC_VENDING);
// skill level and cart check
- if( !vending_skill_lvl || !pc_iscarton(sd) )
- {
+ if( !vending_skill_lvl || !pc_iscarton(sd) ) {
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return;
}
// check number of items in shop
- if( count < 1 || count > MAX_VENDING || count > 2 + vending_skill_lvl )
- { // invalid item count
+ if( count < 1 || count > MAX_VENDING || count > 2 + vending_skill_lvl ) {
+ // invalid item count
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return;
}
// filter out invalid items
i = 0;
- for( j = 0; j < count; j++ )
- {
+ for( j = 0; j < count; j++ ) {
short index = *(uint16*)(data + 8*j + 0);
short amount = *(uint16*)(data + 8*j + 2);
unsigned int value = *(uint32*)(data + 8*j + 4);
@@ -288,35 +268,33 @@ void vending_openvending(struct map_session_data* sd, const char* message, const
if( i != j )
clif->message (sd->fd, msg_txt(266)); //"Some of your items cannot be vended and were removed from the shop."
- if( i == 0 )
- { // no valid item found
+ if( i == 0 ) { // no valid item found
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0); // custom reply packet
return;
}
sd->state.prevend = 0;
sd->state.vending = true;
- sd->vender_id = vending_getuid();
+ sd->vender_id = getid();
sd->vend_num = i;
safestrncpy(sd->message, message, MESSAGE_SIZE);
clif->openvending(sd,sd->bl.id,sd->vending);
clif->showvendingboard(&sd->bl,message,0);
+
+ idb_put(vending->db, sd->vender_id, sd);
}
/// Checks if an item is being sold in given player's vending.
-bool vending_search(struct map_session_data* sd, unsigned short nameid)
-{
+bool vending_search(struct map_session_data* sd, unsigned short nameid) {
int i;
- if( !sd->state.vending )
- {// not vending
+ if( !sd->state.vending ) { // not vending
return false;
}
ARR_FIND( 0, sd->vend_num, i, sd->status.cart[sd->vending[i].index].nameid == (short)nameid );
- if( i == sd->vend_num )
- {// not found
+ if( i == sd->vend_num ) { // not found
return false;
}
@@ -326,46 +304,36 @@ bool vending_search(struct map_session_data* sd, unsigned short nameid)
/// Searches for all items in a vending, that match given ids, price and possible cards.
/// @return Whether or not the search should be continued.
-bool vending_searchall(struct map_session_data* sd, const struct s_search_store_search* s)
-{
+bool vending_searchall(struct map_session_data* sd, const struct s_search_store_search* s) {
int i, c, slot;
unsigned int idx, cidx;
struct item* it;
- if( !sd->state.vending )
- {// not vending
+ if( !sd->state.vending ) // not vending
return true;
- }
- for( idx = 0; idx < s->item_count; idx++ )
- {
+ for( idx = 0; idx < s->item_count; idx++ ) {
ARR_FIND( 0, sd->vend_num, i, sd->status.cart[sd->vending[i].index].nameid == (short)s->itemlist[idx] );
- if( i == sd->vend_num )
- {// not found
+ if( i == sd->vend_num ) {// not found
continue;
}
it = &sd->status.cart[sd->vending[i].index];
- if( s->min_price && s->min_price > sd->vending[i].value )
- {// too low price
+ if( s->min_price && s->min_price > sd->vending[i].value ) {// too low price
continue;
}
- if( s->max_price && s->max_price < sd->vending[i].value )
- {// too high price
+ if( s->max_price && s->max_price < sd->vending[i].value ) {// too high price
continue;
}
- if( s->card_count )
- {// check cards
- if( itemdb_isspecial(it->card[0]) )
- {// something, that is not a carded
+ if( s->card_count ) {// check cards
+ if( itemdb_isspecial(it->card[0]) ) {// something, that is not a carded
continue;
}
slot = itemdb_slot(it->nameid);
- for( c = 0; c < slot && it->card[c]; c ++ )
- {
+ for( c = 0; c < slot && it->card[c]; c ++ ) {
ARR_FIND( 0, s->card_count, cidx, s->cardlist[cidx] == it->card[c] );
if( cidx != s->card_count )
{// found
@@ -373,13 +341,12 @@ bool vending_searchall(struct map_session_data* sd, const struct s_search_store_
}
}
- if( c == slot || !it->card[c] )
- {// no card match
+ if( c == slot || !it->card[c] ) {// no card match
continue;
}
}
- if( !searchstore_result(s->search_sd, sd->vender_id, sd->status.account_id, sd->message, it->nameid, sd->vending[i].amount, sd->vending[i].value, it->card, it->refine) )
+ if( !searchstore->result(s->search_sd, sd->vender_id, sd->status.account_id, sd->message, it->nameid, sd->vending[i].amount, sd->vending[i].value, it->card, it->refine) )
{// result set full
return false;
}
@@ -387,3 +354,25 @@ bool vending_searchall(struct map_session_data* sd, const struct s_search_store_
return true;
}
+void final(void) {
+ db_destroy(vending->db);
+}
+
+void init(void) {
+ vending->db = idb_alloc(DB_OPT_BASE);
+ vending->next_id = 0;
+}
+
+void vending_defaults(void) {
+ vending = &vending_s;
+
+ vending->init = init;
+ vending->final = final;
+
+ vending->close = vending_closevending;
+ vending->open = vending_openvending;
+ vending->list = vending_vendinglistreq;
+ vending->purchase = vending_purchasereq;
+ vending->search = vending_search;
+ vending->searchall = vending_searchall;
+}
diff --git a/src/map/vending.h b/src/map/vending.h
index 402df5579..0148deb71 100644
--- a/src/map/vending.h
+++ b/src/map/vending.h
@@ -1,11 +1,12 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _VENDING_H_
#define _VENDING_H_
#include "../common/cbasetypes.h"
-//#include "map.h"
+#include "../common/db.h"
struct map_session_data;
struct s_search_store_search;
@@ -15,11 +16,23 @@ struct s_vending {
unsigned int value; //at wich price
};
-void vending_closevending(struct map_session_data* sd);
-void vending_openvending(struct map_session_data* sd, const char* message, const uint8* data, int count);
-void vending_vendinglistreq(struct map_session_data* sd, int id);
-void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const uint8* data, int count);
-bool vending_search(struct map_session_data* sd, unsigned short nameid);
-bool vending_searchall(struct map_session_data* sd, const struct s_search_store_search* s);
+struct vending_interface {
+ unsigned int next_id;/* next vender id */
+ DBMap *db;
+ /* */
+ void (*init) (void);
+ void (*final) (void);
+ /* */
+ void (*close) (struct map_session_data* sd);
+ void (*open) (struct map_session_data* sd, const char* message, const uint8* data, int count);
+ void (*list) (struct map_session_data* sd, unsigned int id);
+ void (*purchase) (struct map_session_data* sd, int aid, unsigned int uid, const uint8* data, int count);
+ bool (*search) (struct map_session_data* sd, unsigned short nameid);
+ bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s);
+} vending_s;
+
+struct vending_interface * vending;
+
+void vending_defaults(void);
#endif /* _VENDING_H_ */