summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.cpp721
-rw-r--r--src/map/atcommand.hpp9
-rw-r--r--src/map/battle.cpp112
-rw-r--r--src/map/battle.hpp4
-rw-r--r--src/map/chat.cpp19
-rw-r--r--src/map/chat.hpp3
-rw-r--r--src/map/chrif.cpp67
-rw-r--r--src/map/chrif.hpp3
-rw-r--r--src/map/clif.cpp318
-rw-r--r--src/map/clif.hpp23
-rw-r--r--src/map/intif.cpp37
-rw-r--r--src/map/intif.hpp3
-rw-r--r--src/map/itemdb.cpp113
-rw-r--r--src/map/itemdb.hpp3
-rw-r--r--src/map/magic-expr-eval.hpp19
-rw-r--r--src/map/magic-expr.cpp312
-rw-r--r--src/map/magic-expr.hpp23
-rw-r--r--src/map/magic-interpreter-aux.hpp2
-rw-r--r--src/map/magic-interpreter-base.cpp86
-rw-r--r--src/map/magic-interpreter-lexer.lpp4
-rw-r--r--src/map/magic-interpreter-parser.ypp138
-rw-r--r--src/map/magic-interpreter.hpp39
-rw-r--r--src/map/magic-stmt.cpp214
-rw-r--r--src/map/magic.cpp16
-rw-r--r--src/map/magic.hpp11
-rw-r--r--src/map/map.cpp193
-rw-r--r--src/map/map.hpp45
-rw-r--r--src/map/mob.cpp435
-rw-r--r--src/map/mob.hpp6
-rw-r--r--src/map/mob.t.hpp4
-rw-r--r--src/map/npc.cpp282
-rw-r--r--src/map/npc.hpp5
-rw-r--r--src/map/party.cpp80
-rw-r--r--src/map/party.hpp11
-rw-r--r--src/map/path.cpp38
-rw-r--r--src/map/pc.cpp334
-rw-r--r--src/map/pc.hpp4
-rw-r--r--src/map/script.cpp282
-rw-r--r--src/map/script.hpp7
-rw-r--r--src/map/skill-pools.cpp23
-rw-r--r--src/map/skill.cpp742
-rw-r--r--src/map/skill.hpp9
-rw-r--r--src/map/skill.t.hpp3
-rw-r--r--src/map/storage.cpp32
-rw-r--r--src/map/storage.hpp2
-rw-r--r--src/map/tmw.cpp14
-rw-r--r--src/map/tmw.hpp3
-rw-r--r--src/map/trade.cpp14
-rw-r--r--src/map/trade.hpp2
49 files changed, 2147 insertions, 2722 deletions
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index b01c801..67cc51d 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -1,45 +1,49 @@
-// $Id: atcommand.c 148 2004-09-30 14:05:37Z MouseJstr $
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <math.h>
-#include <sys/types.h>
+#include "atcommand.hpp"
+
#include <sys/stat.h>
+#include <sys/types.h>
+
#include <fcntl.h>
-#include <time.h>
#include <unistd.h>
+#include <cctype>
+#include <cmath>
+#include <cstdarg> // exception to "no va_list" rule
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+
#include <array>
+#include "../common/core.hpp"
+#include "../common/mt_rand.hpp"
+#include "../common/nullpo.hpp"
#include "../common/socket.hpp"
#include "../common/timer.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/mt_rand.hpp"
-#include "atcommand.hpp"
#include "battle.hpp"
-#include "clif.hpp"
#include "chrif.hpp"
+#include "clif.hpp"
#include "intif.hpp"
#include "itemdb.hpp"
#include "map.hpp"
#include "mob.hpp"
#include "npc.hpp"
-#include "pc.hpp"
#include "party.hpp"
+#include "pc.hpp"
#include "script.hpp"
#include "skill.hpp"
-#include "trade.hpp"
-
-#include "../common/core.hpp"
#include "tmw.hpp"
+#include "trade.hpp"
#define STATE_BLIND 0x10
-static char command_symbol = '@'; // first char of the commands (by [Yor])
+static
+char command_symbol = '@'; // first char of the commands (by [Yor])
-#define ATCOMMAND_FUNC(x) int atcommand_ ## x(const int fd, struct map_session_data* sd, const char* command, const char* message)
+#define ATCOMMAND_FUNC(x) static \
+int atcommand_##x(const int fd, struct map_session_data* sd, const char* command, const char* message)
ATCOMMAND_FUNC(setup);
ATCOMMAND_FUNC(broadcast);
ATCOMMAND_FUNC(localbroadcast);
@@ -78,7 +82,6 @@ ATCOMMAND_FUNC(go);
//ATCOMMAND_FUNC (spawn);
ATCOMMAND_FUNC(killmonster);
ATCOMMAND_FUNC(killmonster2);
-ATCOMMAND_FUNC(refine);
ATCOMMAND_FUNC(produce);
ATCOMMAND_FUNC(memo);
ATCOMMAND_FUNC(gat);
@@ -158,7 +161,6 @@ ATCOMMAND_FUNC(character_item_list); // by Yor
ATCOMMAND_FUNC(character_storage_list); // by Yor
ATCOMMAND_FUNC(character_cart_list); // by Yor
ATCOMMAND_FUNC(addwarp); // by MouseJstr
-ATCOMMAND_FUNC(follow); // by MouseJstr
ATCOMMAND_FUNC(skillon); // by MouseJstr
ATCOMMAND_FUNC(skilloff); // by MouseJstr
ATCOMMAND_FUNC(killer); // by MouseJstr
@@ -166,9 +168,6 @@ ATCOMMAND_FUNC(npcmove); // by MouseJstr
ATCOMMAND_FUNC(killable); // by MouseJstr
ATCOMMAND_FUNC(charkillable); // by MouseJstr
ATCOMMAND_FUNC(chareffect); // by MouseJstr
-ATCOMMAND_FUNC(chardye); // by MouseJstr
-ATCOMMAND_FUNC(charhairstyle); // by MouseJstr
-ATCOMMAND_FUNC(charhaircolor); // by MouseJstr
ATCOMMAND_FUNC(dropall); // by MouseJstr
ATCOMMAND_FUNC(chardropall); // by MouseJstr
ATCOMMAND_FUNC(storeall); // by MouseJstr
@@ -210,7 +209,8 @@ ATCOMMAND_FUNC(doomspot);
// First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
// to set default level, read atcommand_athena.conf first please.
-static AtCommandInfo atcommand_info[] = {
+static
+AtCommandInfo atcommand_info[] = {
{AtCommand_Setup, "@setup", 40, atcommand_setup},
{AtCommand_CharWarp, "@charwarp", 60, atcommand_charwarp},
{AtCommand_Warp, "@warp", 40, atcommand_warp},
@@ -341,7 +341,6 @@ static AtCommandInfo atcommand_info[] = {
{AtCommand_Char_Item_List, "@charitemlist", 40, atcommand_character_item_list}, // by Yor
{AtCommand_Char_Storage_List, "@charstoragelist", 40, atcommand_character_storage_list}, // by Yor
{AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list}, // by Yor
- {AtCommand_Follow, "@follow", 10, atcommand_follow}, // by MouseJstr
{AtCommand_AddWarp, "@addwarp", 20, atcommand_addwarp}, // by MouseJstr
{AtCommand_SkillOn, "@skillon", 20, atcommand_skillon}, // by MouseJstr
{AtCommand_SkillOff, "@skilloff", 20, atcommand_skilloff}, // by MouseJstr
@@ -350,9 +349,6 @@ static AtCommandInfo atcommand_info[] = {
{AtCommand_Killable, "@killable", 40, atcommand_killable}, // by MouseJstr
{AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable}, // by MouseJstr
{AtCommand_Chareffect, "@chareffect", 40, atcommand_chareffect}, // MouseJstr
- //{ AtCommand_Chardye, "@chardye", 40, atcommand_chardye }, // MouseJstr
- //{ AtCommand_Charhairstyle, "@charhairstyle", 40, atcommand_charhairstyle }, // MouseJstr
- //{ AtCommand_Charhaircolor, "@charhaircolor", 40, atcommand_charhaircolor }, // MouseJstr
{AtCommand_Dropall, "@dropall", 40, atcommand_dropall}, // MouseJstr
{AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall}, // MouseJstr
{AtCommand_Storeall, "@storeall", 40, atcommand_storeall}, // MouseJstr
@@ -561,6 +557,8 @@ int get_atcommand_level(const AtCommandType type)
return 100; // 100: command can not be used
}
+// TODO: remove the hard limit of 512
+
/*========================================
* At-command logging
*/
@@ -636,8 +634,7 @@ void gm_log(const char *fmt, ...)
*is_atcommand @コマンドに存在するかどうか確認する
*------------------------------------------
*/
-AtCommandType
-is_atcommand(const int fd, struct map_session_data *sd, const char *message,
+AtCommandType is_atcommand(const int fd, struct map_session_data *sd, const char *message,
int gmlvl)
{
AtCommandInfo info;
@@ -754,10 +751,8 @@ AtCommandType atcommand(const int level, const char *message,
*------------------------------------------
*/
static
-void atkillmonster_sub(struct block_list *bl, va_list ap)
+void atkillmonster_sub(struct block_list *bl, int flag)
{
- int flag = va_arg(ap, int);
-
nullpo_retv(bl);
if (flag)
@@ -771,7 +766,8 @@ void atkillmonster_sub(struct block_list *bl, va_list ap)
*
*------------------------------------------
*/
-static AtCommandInfo *get_atcommandinfo_byname(const char *name)
+static
+AtCommandInfo *get_atcommandinfo_byname(const char *name)
{
int i;
@@ -837,7 +833,7 @@ int atcommand_config_read(const char *cfgName)
*------------------------------------------
*/
int atcommand_setup(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char buf[256];
char character[100];
@@ -883,7 +879,7 @@ int atcommand_setup(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_charwarp(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char map_name[100];
char character[100];
@@ -968,7 +964,7 @@ int atcommand_charwarp(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_warp(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char map_name[100];
int x = 0, y = 0;
@@ -1031,7 +1027,7 @@ int atcommand_warp(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_where(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
char output[200];
@@ -1066,7 +1062,7 @@ int atcommand_where(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_goto(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
char output[200];
@@ -1116,7 +1112,7 @@ int atcommand_goto(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_jump(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char output[200];
int x = 0, y = 0;
@@ -1163,7 +1159,7 @@ int atcommand_jump(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_who(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char output[200];
struct map_session_data *pl_sd;
@@ -1233,7 +1229,7 @@ int atcommand_who(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_whogroup(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char temp0[100];
char temp1[100];
@@ -1312,7 +1308,7 @@ int atcommand_whogroup(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_whomap(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char output[200];
struct map_session_data *pl_sd;
@@ -1384,7 +1380,7 @@ int atcommand_whomap(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_whomapgroup(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char temp0[100];
char output[200];
@@ -1464,7 +1460,7 @@ int atcommand_whomapgroup(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_whogm(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char temp0[100];
char output[200];
@@ -1549,7 +1545,7 @@ int atcommand_whogm(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_save(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
nullpo_retr(-1, sd);
@@ -1566,7 +1562,7 @@ int atcommand_save(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_load(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
int m;
@@ -1598,7 +1594,7 @@ int atcommand_load(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_speed(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char output[200];
int speed;
@@ -1640,7 +1636,7 @@ int atcommand_speed(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_storage(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
struct storage *stor; //changes from Freya/Yor
nullpo_retr(-1, sd);
@@ -1668,7 +1664,7 @@ int atcommand_storage(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_option(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int param1 = 0, param2 = 0, param3 = 0;
nullpo_retr(-1, sd);
@@ -1743,7 +1739,7 @@ int atcommand_option(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_hide(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
if (sd->status.option & OPTION_HIDE)
{
@@ -1765,7 +1761,7 @@ int atcommand_hide(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_die(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
pc_damage(NULL, sd, sd->status.hp + 1);
clif_displaymessage(fd, "A pity! You've died.");
@@ -1778,7 +1774,7 @@ int atcommand_die(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_kill(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
struct map_session_data *pl_sd;
@@ -1819,7 +1815,7 @@ int atcommand_kill(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_alive(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
sd->status.hp = sd->status.max_hp;
sd->status.sp = sd->status.max_sp;
@@ -1838,8 +1834,8 @@ int atcommand_alive(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_kami(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_kami(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char output[200];
@@ -1863,7 +1859,7 @@ int atcommand_kami(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_heal(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int hp = 0, sp = 0; // [Valaris] thanks to fov
@@ -1915,7 +1911,7 @@ int atcommand_heal(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_item(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char item_name[100];
int number = 0, item_id, flag;
@@ -1975,7 +1971,7 @@ int atcommand_item(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_itemreset(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
int i;
@@ -1994,8 +1990,8 @@ int atcommand_itemreset(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_itemcheck(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_itemcheck(const int, struct map_session_data *sd,
+ const char *, const char *)
{
pc_checkitem(sd);
@@ -2007,7 +2003,7 @@ int atcommand_itemcheck(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_baselevelup(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int level, i;
@@ -2071,7 +2067,7 @@ int atcommand_baselevelup(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_joblevelup(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int up_level = 50, level;
@@ -2137,7 +2133,7 @@ int atcommand_joblevelup(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_help(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
char buf[2048], w1[2048], w2[2048];
int i, gm_level;
@@ -2182,7 +2178,7 @@ int atcommand_help(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_gm(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char password[100];
@@ -2212,7 +2208,7 @@ int atcommand_gm(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_pvpoff(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
struct map_session_data *pl_sd;
int i;
@@ -2260,7 +2256,7 @@ int atcommand_pvpoff(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_pvpon(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
struct map_session_data *pl_sd;
int i;
@@ -2307,7 +2303,7 @@ int atcommand_pvpon(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_model(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int hair_style = 0, hair_color = 0, cloth_color = 0;
char output[200];
@@ -2360,7 +2356,7 @@ int atcommand_model(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_dye(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int cloth_color = 0;
char output[200];
@@ -2400,22 +2396,11 @@ int atcommand_dye(const int fd, struct map_session_data *sd,
}
/*==========================================
- * @chardye by [MouseJstr]
- *------------------------------------------
- */
-int
-atcommand_chardye(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
-{
- return 0;
-}
-
-/*==========================================
* @hairstyle && @hstyle
*------------------------------------------
*/
int atcommand_hair_style(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int hair_style = 0;
char output[200];
@@ -2455,22 +2440,11 @@ int atcommand_hair_style(const int fd, struct map_session_data *sd,
}
/*==========================================
- * @charhairstyle by [MouseJstr]
- *------------------------------------------
- */
-int
-atcommand_charhairstyle(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
-{
- return 0;
-}
-
-/*==========================================
* @haircolor && @hcolor
*------------------------------------------
*/
int atcommand_hair_color(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int hair_color = 0;
char output[200];
@@ -2510,22 +2484,11 @@ int atcommand_hair_color(const int fd, struct map_session_data *sd,
}
/*==========================================
- * @charhaircolor by [MouseJstr]
- *------------------------------------------
- */
-int
-atcommand_charhaircolor(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
-{
- return 0;
-}
-
-/*==========================================
* @go [city_number/city_name]: improved by [yor] to add city names and help
*------------------------------------------
*/
int atcommand_go(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int i;
int town;
@@ -2884,8 +2847,8 @@ void atcommand_killmonster_sub(const int fd, struct map_session_data *sd,
map_id = sd->bl.m;
}
- map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs,
- map[map_id].ys, BL_MOB, drop);
+ map_foreachinarea(std::bind(atkillmonster_sub, ph::_1, drop), map_id, 0, 0, map[map_id].xs,
+ map[map_id].ys, BL_MOB);
clif_displaymessage(fd, "All monsters killed!");
@@ -2897,7 +2860,7 @@ void atcommand_killmonster_sub(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_killmonster(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
atcommand_killmonster_sub(fd, sd, message, 1);
@@ -2909,10 +2872,9 @@ int atcommand_killmonster(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
static
-void atlist_nearby_sub(struct block_list *bl, va_list ap)
+void atlist_nearby_sub(struct block_list *bl, int fd)
{
char buf[32];
- int fd = va_arg(ap, int);
nullpo_retv(bl);
sprintf(buf, " - \"%s\"", ((struct map_session_data *) bl)->status.name);
@@ -2924,11 +2886,12 @@ void atlist_nearby_sub(struct block_list *bl, va_list ap)
*------------------------------------------
*/
int atcommand_list_nearby(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
clif_displaymessage(fd, "Nearby players:");
- map_foreachinarea(atlist_nearby_sub, sd->bl.m, sd->bl.x - 1,
- sd->bl.y - 1, sd->bl.x + 1, sd->bl.x + 1, BL_PC, fd);
+ map_foreachinarea(std::bind(atlist_nearby_sub, ph::_1, fd),
+ sd->bl.m, sd->bl.x - 1, sd->bl.y - 1,
+ sd->bl.x + 1, sd->bl.x + 1, BL_PC);
return 0;
}
@@ -2938,7 +2901,7 @@ int atcommand_list_nearby(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_killmonster2(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
atcommand_killmonster_sub(fd, sd, message, 0);
@@ -2950,7 +2913,7 @@ int atcommand_killmonster2(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_produce(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char item_name[100];
int item_id, attribute = 0, star = 0;
@@ -3044,7 +3007,7 @@ void atcommand_memo_sub(struct map_session_data *sd)
*------------------------------------------
*/
int atcommand_memo(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int position = 0;
char output[200];
@@ -3097,7 +3060,7 @@ int atcommand_memo(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_gat(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
char output[200];
int y;
@@ -3124,7 +3087,7 @@ int atcommand_gat(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_packet(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int type = 0, flag = 0;
@@ -3145,7 +3108,7 @@ int atcommand_packet(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_statuspoint(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int point, new_status_point;
@@ -3185,7 +3148,7 @@ int atcommand_statuspoint(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_skillpoint(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int point, new_skill_point;
@@ -3225,7 +3188,7 @@ int atcommand_skillpoint(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_zeny(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int zeny, new_zeny;
@@ -3336,7 +3299,7 @@ int atcommand_param(const int fd, struct map_session_data *sd,
*/
//** Stat all by fritz (rewritten by [Yor])
int atcommand_all_stats(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int index, count, value = 0, new_value;
short *status[] = {
@@ -3388,7 +3351,7 @@ int atcommand_all_stats(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_recall(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
char output[200];
@@ -3446,7 +3409,7 @@ int atcommand_recall(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_revive(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
struct map_session_data *pl_sd;
@@ -3484,17 +3447,14 @@ int atcommand_revive(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_character_stats(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_character_stats(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char character[100];
- char job_jobname[100];
char output[200];
struct map_session_data *pl_sd;
- int i;
memset(character, '\0', sizeof(character));
- memset(job_jobname, '\0', sizeof(job_jobname));
memset(output, '\0', sizeof(output));
if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1)
@@ -3506,50 +3466,35 @@ int atcommand_character_stats(const int fd, struct map_session_data *sd,
if ((pl_sd = map_nick2sd(character)) != NULL)
{
- struct
- {
- const char *format;
- int value;
- } output_table[] =
- {
- {
- "Base Level - %d", pl_sd->status.base_level},
- {
- job_jobname, pl_sd->status.job_level},
- {
- "Hp - %d", pl_sd->status.hp},
- {
- "MaxHp - %d", pl_sd->status.max_hp},
- {
- "Sp - %d", pl_sd->status.sp},
- {
- "MaxSp - %d", pl_sd->status.max_sp},
- {
- "Str - %3d", pl_sd->status.str},
- {
- "Agi - %3d", pl_sd->status.agi},
- {
- "Vit - %3d", pl_sd->status.vit},
- {
- "Int - %3d", pl_sd->status.int_},
- {
- "Dex - %3d", pl_sd->status.dex},
- {
- "Luk - %3d", pl_sd->status.luk},
- {
- "Zeny - %d", pl_sd->status.zeny},
- {
- NULL, 0}
- };
- sprintf(job_jobname, "Job - %s %s", job_name(pl_sd->status.pc_class),
- "(level %d)");
sprintf(output, "'%s' stats:", pl_sd->status.name);
clif_displaymessage(fd, output);
- for (i = 0; output_table[i].format != NULL; i++)
- {
- sprintf(output, output_table[i].format, output_table[i].value);
- clif_displaymessage(fd, output);
- }
+ sprintf(output, "Base Level - %d", pl_sd->status.base_level),
+ clif_displaymessage(fd, output);
+ sprintf(output, "Job - %s (level %d)",
+ job_name(pl_sd->status.pc_class), pl_sd->status.job_level);
+ clif_displaymessage(fd, output);
+ sprintf(output, "Hp - %d", pl_sd->status.hp);
+ clif_displaymessage(fd, output);
+ sprintf(output, "MaxHp - %d", pl_sd->status.max_hp);
+ clif_displaymessage(fd, output);
+ sprintf(output, "Sp - %d", pl_sd->status.sp);
+ clif_displaymessage(fd, output);
+ sprintf(output, "MaxSp - %d", pl_sd->status.max_sp);
+ clif_displaymessage(fd, output);
+ sprintf(output, "Str - %3d", pl_sd->status.str);
+ clif_displaymessage(fd, output);
+ sprintf(output, "Agi - %3d", pl_sd->status.agi);
+ clif_displaymessage(fd, output);
+ sprintf(output, "Vit - %3d", pl_sd->status.vit);
+ clif_displaymessage(fd, output);
+ sprintf(output, "Int - %3d", pl_sd->status.int_);
+ clif_displaymessage(fd, output);
+ sprintf(output, "Dex - %3d", pl_sd->status.dex);
+ clif_displaymessage(fd, output);
+ sprintf(output, "Luk - %3d", pl_sd->status.luk);
+ clif_displaymessage(fd, output);
+ sprintf(output, "Zeny - %d", pl_sd->status.zeny);
+ clif_displaymessage(fd, output);
}
else
{
@@ -3565,8 +3510,8 @@ int atcommand_character_stats(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
//** Character Stats All by fritz
-int atcommand_character_stats_all(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_character_stats_all(const int fd, struct map_session_data *,
+ const char *, const char *)
{
char output[1024], gmlevel[1024];
int i;
@@ -3624,7 +3569,7 @@ int atcommand_character_stats_all(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_character_option(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
int opt1 = 0, opt2 = 0, opt3 = 0;
@@ -3711,7 +3656,7 @@ int atcommand_character_option(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_char_change_sex(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
@@ -3750,7 +3695,7 @@ int atcommand_char_change_sex(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_char_block(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
@@ -3800,7 +3745,7 @@ int atcommand_char_block(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_char_ban(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char modif[100], character[100];
char *modif_p;
@@ -3901,7 +3846,7 @@ int atcommand_char_ban(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_char_unblock(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
@@ -3940,7 +3885,7 @@ int atcommand_char_unblock(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_char_unban(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
@@ -3979,7 +3924,7 @@ int atcommand_char_unban(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_character_save(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char map_name[100];
char character[100];
@@ -4044,8 +3989,8 @@ int atcommand_character_save(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_night(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_night(const int fd, struct map_session_data *,
+ const char *, const char *)
{
struct map_session_data *pl_sd;
int i;
@@ -4077,8 +4022,8 @@ int atcommand_night(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_day(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_day(const int fd, struct map_session_data *,
+ const char *, const char *)
{
struct map_session_data *pl_sd;
int i;
@@ -4111,7 +4056,7 @@ int atcommand_day(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_doom(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
struct map_session_data *pl_sd;
int i;
@@ -4136,7 +4081,7 @@ int atcommand_doom(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_doommap(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
struct map_session_data *pl_sd;
int i;
@@ -4160,7 +4105,8 @@ int atcommand_doommap(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-static void atcommand_raise_sub(struct map_session_data *sd)
+static
+void atcommand_raise_sub(struct map_session_data *sd)
{
if (sd && sd->state.auth && pc_isdead(sd))
{
@@ -4178,8 +4124,8 @@ static void atcommand_raise_sub(struct map_session_data *sd)
*
*------------------------------------------
*/
-int atcommand_raise(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_raise(const int fd, struct map_session_data *,
+ const char *, const char *)
{
int i;
@@ -4198,7 +4144,7 @@ int atcommand_raise(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_raisemap(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
struct map_session_data *pl_sd;
int i;
@@ -4219,7 +4165,7 @@ int atcommand_raisemap(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_character_baselevel(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
struct map_session_data *pl_sd;
char character[100];
@@ -4313,7 +4259,7 @@ int atcommand_character_baselevel(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_character_joblevel(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
struct map_session_data *pl_sd;
char character[100];
@@ -4403,7 +4349,7 @@ int atcommand_character_joblevel(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_kick(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
struct map_session_data *pl_sd;
char character[100];
@@ -4441,7 +4387,7 @@ int atcommand_kick(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_kickall(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
struct map_session_data *pl_sd;
int i;
@@ -4466,7 +4412,7 @@ int atcommand_kickall(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_allskills(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
pc_allskillup(sd); // all skills
sd->status.skill_point = 0; // 0 skill points
@@ -4481,7 +4427,7 @@ int atcommand_allskills(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_questskill(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int skill_id_;
@@ -4494,7 +4440,7 @@ int atcommand_questskill(const int fd, struct map_session_data *sd,
SkillID skill_id = SkillID(skill_id_);
- if (skill_id >= SkillID() && skill_id < MAX_SKILL_DB)
+ if (/*skill_id >= SkillID() &&*/ skill_id < MAX_SKILL_DB)
{
if (skill_get_inf2(skill_id) & 0x01)
{
@@ -4528,8 +4474,8 @@ int atcommand_questskill(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_charquestskill(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_charquestskill(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char character[100];
struct map_session_data *pl_sd;
@@ -4548,7 +4494,7 @@ int atcommand_charquestskill(const int fd, struct map_session_data *sd,
SkillID skill_id = SkillID(skill_id_);
- if (skill_id >= SkillID() && skill_id < MAX_SKILL_DB)
+ if (/*skill_id >= SkillID() &&*/ skill_id < MAX_SKILL_DB)
{
if (skill_get_inf2(skill_id) & 0x01)
{
@@ -4591,7 +4537,7 @@ int atcommand_charquestskill(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_lostskill(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int skill_id_;
@@ -4604,7 +4550,7 @@ int atcommand_lostskill(const int fd, struct map_session_data *sd,
SkillID skill_id = SkillID(skill_id_);
- if (skill_id >= SkillID() && skill_id < MAX_SKILL)
+ if (/*skill_id >= SkillID() &&*/ skill_id < MAX_SKILL)
{
if (skill_get_inf2(skill_id) & 0x01)
{
@@ -4640,8 +4586,8 @@ int atcommand_lostskill(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_charlostskill(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_charlostskill(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char character[100];
struct map_session_data *pl_sd;
@@ -4660,7 +4606,7 @@ int atcommand_charlostskill(const int fd, struct map_session_data *sd,
SkillID skill_id = SkillID(skill_id_);
- if (skill_id >= SkillID() && skill_id < MAX_SKILL)
+ if (/*skill_id >= SkillID() &&*/ skill_id < MAX_SKILL)
{
if (skill_get_inf2(skill_id) & 0x01)
{
@@ -4705,7 +4651,7 @@ int atcommand_charlostskill(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_party(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char party[100];
@@ -4727,8 +4673,8 @@ int atcommand_party(const int fd, struct map_session_data *sd,
* @mapexitでマップサーバーを終了させる
*------------------------------------------
*/
-int atcommand_mapexit(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_mapexit(const int, struct map_session_data *sd,
+ const char *, const char *)
{
struct map_session_data *pl_sd;
int i;
@@ -4753,8 +4699,8 @@ int atcommand_mapexit(const int fd, struct map_session_data *sd,
* idsearch <part_of_name>: revrited by [Yor]
*------------------------------------------
*/
-int atcommand_idsearch(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_idsearch(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char item_name[100];
char output[200];
@@ -4795,7 +4741,7 @@ int atcommand_idsearch(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_charskreset(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
char output[200];
@@ -4839,7 +4785,7 @@ int atcommand_charskreset(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_charstreset(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
char output[200];
@@ -4883,7 +4829,7 @@ int atcommand_charstreset(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_charreset(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
char output[200];
@@ -4930,7 +4876,7 @@ int atcommand_charreset(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_char_wipe(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
char output[200];
@@ -5019,8 +4965,8 @@ int atcommand_char_wipe(const int fd, struct map_session_data *sd,
* Character Model by chbrules
*------------------------------------------
*/
-int atcommand_charmodel(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_charmodel(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
int hair_style = 0, hair_color = 0, cloth_color = 0;
struct map_session_data *pl_sd;
@@ -5084,8 +5030,8 @@ int atcommand_charmodel(const int fd, struct map_session_data *sd,
* Character Skill Point (Rewritten by [Yor])
*------------------------------------------
*/
-int atcommand_charskpoint(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_charskpoint(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
struct map_session_data *pl_sd;
char character[100];
@@ -5138,8 +5084,8 @@ int atcommand_charskpoint(const int fd, struct map_session_data *sd,
* Character Status Point (rewritten by [Yor])
*------------------------------------------
*/
-int atcommand_charstpoint(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_charstpoint(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
struct map_session_data *pl_sd;
char character[100];
@@ -5192,8 +5138,8 @@ int atcommand_charstpoint(const int fd, struct map_session_data *sd,
* Character Zeny Point (Rewritten by [Yor])
*------------------------------------------
*/
-int atcommand_charzeny(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_charzeny(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
struct map_session_data *pl_sd;
char character[100];
@@ -5245,7 +5191,7 @@ int atcommand_charzeny(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_recallall(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
struct map_session_data *pl_sd;
int i;
@@ -5295,7 +5241,7 @@ int atcommand_recallall(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_partyrecall(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int i;
struct map_session_data *pl_sd;
@@ -5363,8 +5309,8 @@ int atcommand_partyrecall(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_reloaditemdb(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_reloaditemdb(const int fd, struct map_session_data *,
+ const char *, const char *)
{
itemdb_reload();
clif_displaymessage(fd, "Item database reloaded.");
@@ -5376,8 +5322,8 @@ int atcommand_reloaditemdb(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_reloadmobdb(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_reloadmobdb(const int fd, struct map_session_data *,
+ const char *, const char *)
{
mob_reload();
clif_displaymessage(fd, "Monster database reloaded.");
@@ -5389,8 +5335,8 @@ int atcommand_reloadmobdb(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_reloadskilldb(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_reloadskilldb(const int fd, struct map_session_data *,
+ const char *, const char *)
{
skill_reload();
clif_displaymessage(fd, "Skill database reloaded.");
@@ -5402,8 +5348,8 @@ int atcommand_reloadskilldb(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_reloadscript(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_reloadscript(const int fd, struct map_session_data *,
+ const char *, const char *)
{
do_init_npc();
do_init_script();
@@ -5419,9 +5365,8 @@ int atcommand_reloadscript(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_reloadgmdb( // by [Yor]
- const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_reloadgmdb(const int fd, struct map_session_data *,
+ const char *, const char *)
{
chrif_reloadGMdb();
@@ -5440,7 +5385,7 @@ int atcommand_reloadgmdb( // by [Yor]
*------------------------------------------
*/
int atcommand_mapinfo(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
struct map_session_data *pl_sd;
struct npc_data *nd = NULL;
@@ -5625,7 +5570,7 @@ int atcommand_mapinfo(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_mount_peco(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
if (sd->disguise > 0)
{ // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
@@ -5676,8 +5621,8 @@ int atcommand_mount_peco(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_char_mount_peco(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_char_mount_peco(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char character[100];
struct map_session_data *pl_sd;
@@ -5749,7 +5694,7 @@ int atcommand_char_mount_peco(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_partyspy(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char party_name[100];
char output[200];
@@ -5794,8 +5739,8 @@ int atcommand_partyspy(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_enablenpc(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_enablenpc(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char NPCname[100];
@@ -5826,8 +5771,8 @@ int atcommand_enablenpc(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_disablenpc(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_disablenpc(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char NPCname[100];
@@ -5900,8 +5845,8 @@ const char *txt_time(unsigned int duration)
* Calculation management of GM modification (@day/@night GM commands) is done
*------------------------------------------
*/
-int atcommand_servertime(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_servertime(const int fd, struct map_session_data *,
+ const char *, const char *)
{
struct TimerData *timer_data;
struct TimerData *timer_data2;
@@ -5987,7 +5932,7 @@ int atcommand_servertime(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_chardelitem(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
struct map_session_data *pl_sd;
char character[100];
@@ -6071,7 +6016,7 @@ int atcommand_chardelitem(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_jail(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
struct map_session_data *pl_sd;
@@ -6134,7 +6079,7 @@ int atcommand_jail(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_unjail(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
struct map_session_data *pl_sd;
@@ -6189,7 +6134,7 @@ int atcommand_unjail(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_disguise(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int mob_id;
@@ -6232,7 +6177,7 @@ int atcommand_disguise(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_undisguise(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
if (sd->disguise)
{
@@ -6255,7 +6200,7 @@ int atcommand_undisguise(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_broadcast(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char output[200];
@@ -6279,7 +6224,7 @@ int atcommand_broadcast(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_localbroadcast(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char output[200];
@@ -6304,7 +6249,7 @@ int atcommand_localbroadcast(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_ignorelist(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
char output[200];
int count;
@@ -6346,8 +6291,8 @@ int atcommand_ignorelist(const int fd, struct map_session_data *sd,
* @charignorelist <player_name> by [Yor]
*------------------------------------------
*/
-int atcommand_charignorelist(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_charignorelist(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char character[100];
struct map_session_data *pl_sd;
@@ -6419,7 +6364,7 @@ int atcommand_charignorelist(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_inall(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
char output[200];
@@ -6478,7 +6423,7 @@ int atcommand_inall(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_exall(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
char output[200];
@@ -6537,7 +6482,7 @@ int atcommand_exall(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_chardisguise(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
int mob_id;
char character[100];
@@ -6604,7 +6549,7 @@ int atcommand_chardisguise(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_charundisguise(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char character[100];
struct map_session_data *pl_sd;
@@ -6656,7 +6601,7 @@ int atcommand_charundisguise(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_email(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
char actual_email[100];
char new_email[100];
@@ -6706,7 +6651,7 @@ int atcommand_email(const int fd, struct map_session_data *sd,
*------------------------------------------
*/
int atcommand_effect(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
struct map_session_data *pl_sd;
int type = 0, flag = 0, i;
@@ -6742,9 +6687,8 @@ int atcommand_effect(const int fd, struct map_session_data *sd,
* @charitemlist <character>: Displays the list of a player's items.
*------------------------------------------
*/
-int
-atcommand_character_item_list(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_character_item_list(const int fd, struct map_session_data *sd,
+ const char *, const char *message)
{
struct map_session_data *pl_sd;
struct item_data *item_data, *item_temp;
@@ -6894,9 +6838,8 @@ atcommand_character_item_list(const int fd, struct map_session_data *sd,
* @charstoragelist <character>: Displays the items list of a player's storage.
*------------------------------------------
*/
-int
-atcommand_character_storage_list(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_character_storage_list(const int fd, struct map_session_data *sd,
+ const char *, const char *message)
{
struct storage *stor;
struct map_session_data *pl_sd;
@@ -7020,9 +6963,8 @@ atcommand_character_storage_list(const int fd, struct map_session_data *sd,
* @charcartlist <character>: Displays the items list of a player's cart.
*------------------------------------------
*/
-int
-atcommand_character_cart_list(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_character_cart_list(const int fd, struct map_session_data *sd,
+ const char *, const char *message)
{
struct map_session_data *pl_sd;
struct item_data *item_data, *item_temp;
@@ -7136,9 +7078,8 @@ atcommand_character_cart_list(const int fd, struct map_session_data *sd,
* enable killing players even when not in pvp
*------------------------------------------
*/
-int
-atcommand_killer(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_killer(const int fd, struct map_session_data *sd,
+ const char *, const char *)
{
sd->special_state.killer = !sd->special_state.killer;
@@ -7155,9 +7096,8 @@ atcommand_killer(const int fd, struct map_session_data *sd,
* enable other people killing you
*------------------------------------------
*/
-int
-atcommand_killable(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_killable(const int fd, struct map_session_data *sd,
+ const char *, const char *)
{
sd->special_state.killable = !sd->special_state.killable;
@@ -7174,9 +7114,8 @@ atcommand_killable(const int fd, struct map_session_data *sd,
* enable another player to be killed
*------------------------------------------
*/
-int
-atcommand_charkillable(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_charkillable(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
struct map_session_data *pl_sd = NULL;
@@ -7201,9 +7140,8 @@ atcommand_charkillable(const int fd, struct map_session_data *sd,
* turn skills on for the map
*------------------------------------------
*/
-int
-atcommand_skillon(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_skillon(const int fd, struct map_session_data *sd,
+ const char *, const char *)
{
map[sd->bl.m].flag.noskill = 0;
clif_displaymessage(fd, "Map skills are on.");
@@ -7215,9 +7153,8 @@ atcommand_skillon(const int fd, struct map_session_data *sd,
* Turn skills off on the map
*------------------------------------------
*/
-int
-atcommand_skilloff(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_skilloff(const int fd, struct map_session_data *sd,
+ const char *, const char *)
{
map[sd->bl.m].flag.noskill = 1;
clif_displaymessage(fd, "Map skills are off.");
@@ -7230,9 +7167,8 @@ atcommand_skilloff(const int fd, struct map_session_data *sd,
* move a npc
*------------------------------------------
*/
-int
-atcommand_npcmove(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_npcmove(const int, struct map_session_data *sd,
+ const char *, const char *message)
{
char character[100];
int x = 0, y = 0;
@@ -7267,23 +7203,22 @@ atcommand_npcmove(const int fd, struct map_session_data *sd,
* Create a new static warp point.
*------------------------------------------
*/
-int
-atcommand_addwarp(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_addwarp(const int fd, struct map_session_data *sd,
+ const char *, const char *message)
{
char w1[64], w3[64], w4[64];
- char map[30], output[200];
+ char mapname[30], output[200];
int x, y, ret;
if (!message || !*message)
return -1;
- if (sscanf(message, "%99s %d %d[^\n]", map, &x, &y) < 3)
+ if (sscanf(message, "%99s %d %d[^\n]", mapname, &x, &y) < 3)
return -1;
sprintf(w1, "%s,%d,%d", sd->mapname, sd->bl.x, sd->bl.y);
- sprintf(w3, "%s%d%d%d%d", map, sd->bl.x, sd->bl.y, x, y);
- sprintf(w4, "1,1,%s.gat,%d,%d", map, x, y);
+ sprintf(w3, "%s%d%d%d%d", mapname, sd->bl.x, sd->bl.y, x, y);
+ sprintf(w4, "1,1,%s.gat,%d,%d", mapname, x, y);
ret = npc_parse_warp(w1, "warp", w3, w4);
@@ -7295,45 +7230,13 @@ atcommand_addwarp(const int fd, struct map_session_data *sd,
}
/*==========================================
- * @follow by [MouseJstr]
- *
- * Follow a player .. staying no more then 5 spaces away
- *------------------------------------------
- */
-int
-atcommand_follow(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
-{
-#if 0
- struct map_session_data *pl_sd = NULL;
-
- if (!message || !*message)
- return -1;
- if ((pl_sd = map_nick2sd((char *) message)) != NULL)
- pc_follow(sd, pl_sd->bl.id);
- else
- return 1;
-#endif
-
- /*
- * Command disabled - it's incompatible with the TMW
- * client.
- */
- clif_displaymessage(fd, "@follow command not available");
-
- return 0;
-
-}
-
-/*==========================================
* @chareffect by [MouseJstr]
*
* Create a effect localized on another character
*------------------------------------------
*/
-int
-atcommand_chareffect(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_chareffect(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
struct map_session_data *pl_sd = NULL;
char target[255];
@@ -7361,9 +7264,8 @@ atcommand_chareffect(const int fd, struct map_session_data *sd,
* Drop all your possession on the ground
*------------------------------------------
*/
-int
-atcommand_dropall(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_dropall(const int, struct map_session_data *sd,
+ const char *, const char *)
{
int i;
for (i = 0; i < MAX_INVENTORY; i++)
@@ -7385,9 +7287,8 @@ atcommand_dropall(const int fd, struct map_session_data *sd,
* done in response to them being disrespectful of a GM
*------------------------------------------
*/
-int
-atcommand_chardropall(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_chardropall(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
int i;
struct map_session_data *pl_sd = NULL;
@@ -7420,9 +7321,8 @@ atcommand_chardropall(const int fd, struct map_session_data *sd,
* debugging easie
*------------------------------------------
*/
-int
-atcommand_storeall(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_storeall(const int fd, struct map_session_data *sd,
+ const char *, const char *)
{
int i;
nullpo_retr(-1, sd);
@@ -7461,9 +7361,8 @@ atcommand_storeall(const int fd, struct map_session_data *sd,
* A way to screw with players who piss you off
*------------------------------------------
*/
-int
-atcommand_charstoreall(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_charstoreall(const int fd, struct map_session_data *sd,
+ const char *, const char *message)
{
int i;
struct map_session_data *pl_sd = NULL;
@@ -7508,9 +7407,8 @@ atcommand_charstoreall(const int fd, struct map_session_data *sd,
* lookup a skill by name
*------------------------------------------
*/
-int
-atcommand_skillid(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_skillid(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
int skillen = 0, idx = 0;
if (!message || !*message)
@@ -7537,9 +7435,8 @@ atcommand_skillid(const int fd, struct map_session_data *sd,
* A way of using skills without having to find them in the skills menu
*------------------------------------------
*/
-int
-atcommand_useskill(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_useskill(const int fd, struct map_session_data *sd,
+ const char *, const char *message)
{
struct map_session_data *pl_sd = NULL;
int skillnum_;
@@ -7575,9 +7472,8 @@ atcommand_useskill(const int fd, struct map_session_data *sd,
* It is made to rain.
*------------------------------------------
*/
-int
-atcommand_rain(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_rain(const int, struct map_session_data *sd,
+ const char *, const char *)
{
int effno = 0;
effno = 161;
@@ -7594,9 +7490,8 @@ atcommand_rain(const int fd, struct map_session_data *sd,
* It is made to snow.
*------------------------------------------
*/
-int
-atcommand_snow(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_snow(const int, struct map_session_data *sd,
+ const char *, const char *)
{
int effno = 0;
effno = 162;
@@ -7613,9 +7508,8 @@ atcommand_snow(const int fd, struct map_session_data *sd,
* Cherry tree snowstorm is made to fall. (Sakura)
*------------------------------------------
*/
-int
-atcommand_sakura(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_sakura(const int, struct map_session_data *sd,
+ const char *, const char *)
{
int effno = 0;
effno = 163;
@@ -7632,9 +7526,8 @@ atcommand_sakura(const int fd, struct map_session_data *sd,
* Fog hangs over.
*------------------------------------------
*/
-int
-atcommand_fog(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_fog(const int, struct map_session_data *sd,
+ const char *, const char *)
{
int effno = 0;
effno = 233;
@@ -7652,9 +7545,8 @@ atcommand_fog(const int fd, struct map_session_data *sd,
* Fallen leaves fall.
*------------------------------------------
*/
-int
-atcommand_leaves(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_leaves(const int, struct map_session_data *sd,
+ const char *, const char *)
{
int effno = 0;
effno = 333;
@@ -7671,8 +7563,8 @@ atcommand_leaves(const int fd, struct map_session_data *sd,
*
*------------------------------------------
*/
-int atcommand_summon(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_summon(const int, struct map_session_data *sd,
+ const char *, const char *message)
{
char name[100];
int mob_id = 0;
@@ -7720,9 +7612,8 @@ int atcommand_summon(const int fd, struct map_session_data *sd,
* for short periods of time
*------------------------------------------
*/
-int
-atcommand_adjcmdlvl(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_adjcmdlvl(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
int i, newlev;
char cmd[100];
@@ -7754,9 +7645,8 @@ atcommand_adjcmdlvl(const int fd, struct map_session_data *sd,
* for short periods of time
*------------------------------------------
*/
-int
-atcommand_adjgmlvl(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_adjgmlvl(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
int newlev;
char user[100];
@@ -7786,9 +7676,8 @@ atcommand_adjgmlvl(const int fd, struct map_session_data *sd,
* gonna scream!
*------------------------------------------
*/
-int
-atcommand_trade(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_trade(const int, struct map_session_data *sd,
+ const char *, const char *message)
{
struct map_session_data *pl_sd = NULL;
@@ -7806,8 +7695,8 @@ atcommand_trade(const int fd, struct map_session_data *sd,
* @unmute [Valaris]
*===========================
*/
-int atcommand_unmute(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_unmute(const int, struct map_session_data *sd,
+ const char *, const char *message)
{
struct map_session_data *pl_sd = NULL;
if (!message || !*message)
@@ -7829,7 +7718,8 @@ int atcommand_unmute(const int fd, struct map_session_data *sd,
/* Magic atcommands by Fate */
-static SkillID magic_skills[] =
+static
+SkillID magic_skills[] =
{
TMW_MAGIC,
TMW_MAGIC_LIFE,
@@ -7842,7 +7732,8 @@ static SkillID magic_skills[] =
constexpr
size_t magic_skills_nr = sizeof(magic_skills) / sizeof(magic_skills[0]);
-static const char *magic_skill_names[magic_skills_nr] =
+static
+const char *magic_skill_names[magic_skills_nr] =
{
"magic",
"life",
@@ -7852,9 +7743,8 @@ static const char *magic_skill_names[magic_skills_nr] =
"astral"
};
-int
-atcommand_magic_info(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_magic_info(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char character[100];
char buf[200];
@@ -7890,15 +7780,15 @@ atcommand_magic_info(const int fd, struct map_session_data *sd,
return -1;
}
-static void set_skill(struct map_session_data *sd, SkillID i, int level)
+static
+void set_skill(struct map_session_data *sd, SkillID i, int level)
{
sd->status.skill[i].id = level ? i : SkillID();
sd->status.skill[i].lv = level;
}
-int
-atcommand_set_magic(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_set_magic(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char character[100];
char magic_type[20];
@@ -7955,16 +7845,15 @@ atcommand_set_magic(const int fd, struct map_session_data *sd,
return -1;
}
-int
-atcommand_log(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_log(const int, struct map_session_data *,
+ const char *, const char *)
{
- return 0; // only used for (implicit) logging
+ return 0;
+ // only used for (implicit) logging
}
-int
-atcommand_tee(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_tee(const int, struct map_session_data *sd,
+ const char *, const char *message)
{
char *data = (char *)malloc(strlen(message) + 28);
strcpy(data, sd->status.name);
@@ -7974,17 +7863,15 @@ atcommand_tee(const int fd, struct map_session_data *sd,
return 0;
}
-int
-atcommand_invisible(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_invisible(const int, struct map_session_data *sd,
+ const char *, const char *)
{
pc_invisibility(sd, 1);
return 0;
}
-int
-atcommand_visible(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_visible(const int, struct map_session_data *sd,
+ const char *, const char *)
{
pc_invisibility(sd, 0);
return 0;
@@ -7992,11 +7879,9 @@ atcommand_visible(const int fd, struct map_session_data *sd,
static
int atcommand_jump_iterate(const int fd, struct map_session_data *sd,
- const char *command, const char *message,
- struct map_session_data *(*get_start)(void),
- struct map_session_data *(*get_next)(struct
- map_session_data
- * current))
+ const char *, const char *,
+ struct map_session_data *(*get_start)(void),
+ struct map_session_data *(*get_next)(struct map_session_data*))
{
char output[200];
struct map_session_data *pl_sd;
@@ -8041,8 +7926,7 @@ int atcommand_jump_iterate(const int fd, struct map_session_data *sd,
return 0;
}
-int
-atcommand_iterate_forward_over_players(const int fd,
+int atcommand_iterate_forward_over_players(const int fd,
struct map_session_data *sd,
const char *command,
const char *message)
@@ -8052,8 +7936,7 @@ atcommand_iterate_forward_over_players(const int fd,
map_get_next_session);
}
-int
-atcommand_iterate_backwards_over_players(const int fd,
+int atcommand_iterate_backwards_over_players(const int fd,
struct map_session_data *sd,
const char *command,
const char *message)
@@ -8064,7 +7947,7 @@ atcommand_iterate_backwards_over_players(const int fd,
}
int atcommand_wgm(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *message)
{
if (tmw_CheckChatSpam(sd, message))
return 0;
@@ -8076,8 +7959,8 @@ int atcommand_wgm(const int fd, struct map_session_data *sd,
}
-int atcommand_skillpool_info(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_skillpool_info(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char character[100];
struct map_session_data *pl_sd;
@@ -8131,8 +8014,8 @@ int atcommand_skillpool_info(const int fd, struct map_session_data *sd,
return 0;
}
-int atcommand_skillpool_focus(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_skillpool_focus(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char character[100];
int skill_;
@@ -8160,8 +8043,8 @@ int atcommand_skillpool_focus(const int fd, struct map_session_data *sd,
return 0;
}
-int atcommand_skillpool_unfocus(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_skillpool_unfocus(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char character[100];
int skill_;
@@ -8189,8 +8072,8 @@ int atcommand_skillpool_unfocus(const int fd, struct map_session_data *sd,
return 0;
}
-int atcommand_skill_learn(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_skill_learn(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
char character[100];
int skill_, level;
@@ -8217,8 +8100,8 @@ int atcommand_skill_learn(const int fd, struct map_session_data *sd,
return 0;
}
-int atcommand_ipcheck(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+int atcommand_ipcheck(const int fd, struct map_session_data *,
+ const char *, const char *message)
{
struct map_session_data *pl_sd;
struct sockaddr_in sai;
@@ -8279,7 +8162,7 @@ int atcommand_ipcheck(const int fd, struct map_session_data *sd,
}
int atcommand_doomspot(const int fd, struct map_session_data *sd,
- const char *command, const char *message)
+ const char *, const char *)
{
struct map_session_data *pl_sd;
int i;
diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp
index d22b71a..86db2a5 100644
--- a/src/map/atcommand.hpp
+++ b/src/map/atcommand.hpp
@@ -1,4 +1,3 @@
-// $Id: atcommand.h 148 2004-09-30 14:05:37Z MouseJstr $
#ifndef ATCOMMAND_HPP
#define ATCOMMAND_HPP
@@ -139,7 +138,6 @@ enum AtCommandType
AtCommand_Char_Storage_List, // by Yor
AtCommand_Char_Cart_List, // by Yor
AtCommand_AddWarp, // by MouseJstr
- AtCommand_Follow, // by MouseJstr
AtCommand_SkillOn, // by MouseJstr
AtCommand_SkillOff, // by MouseJstr
AtCommand_Killer, // by MouseJstr
@@ -147,9 +145,6 @@ enum AtCommandType
AtCommand_Killable, // by MouseJstr
AtCommand_CharKillable, // by MouseJstr
AtCommand_Chareffect, // by MouseJstr
- AtCommand_Chardye, // by MouseJstr
- AtCommand_Charhairstyle, // by MouseJstr
- AtCommand_Charhaircolor, // by MouseJstr
AtCommand_Dropall, // by MouseJstr
AtCommand_Chardropall, // by MouseJstr
AtCommand_Storeall, // by MouseJstr
@@ -181,7 +176,7 @@ enum AtCommandType
AtCommand_DoomSpot,
// end
AtCommand_Unknown,
- AtCommand_MAX
+ AtCommand_MAX,
};
typedef enum AtCommandType AtCommandType;
@@ -215,4 +210,4 @@ void log_atcommand(struct map_session_data *sd, const char *fmt, ...);
__attribute__((format(printf, 1, 2)))
void gm_log(const char *fmt, ...);
-#endif
+#endif // ATCOMMAND_HPP
diff --git a/src/map/battle.cpp b/src/map/battle.cpp
index 126b752..14ef933 100644
--- a/src/map/battle.cpp
+++ b/src/map/battle.cpp
@@ -1,13 +1,14 @@
-// $Id: battle.c,v 1.10 2004/09/29 21:08:17 Akitasha Exp $
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
#include "battle.hpp"
-#include "../common/timer.hpp"
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include "../common/mt_rand.hpp"
#include "../common/nullpo.hpp"
+#include "../common/socket.hpp"
+#include "../common/timer.hpp"
#include "clif.hpp"
#include "itemdb.hpp"
@@ -15,12 +16,6 @@
#include "mob.hpp"
#include "pc.hpp"
#include "skill.hpp"
-#include "../common/socket.hpp"
-#include "../common/mt_rand.hpp"
-
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
int attr_fix_table[4][10][10];
@@ -31,7 +26,8 @@ struct Battle_Config battle_config;
* 戻りは整数で0以上
*------------------------------------------
*/
-static int distance(int x0, int y0, int x1, int y1)
+static
+int distance(int x0, int y0, int x1, int y1)
{
int dx, dy;
@@ -1005,7 +1001,7 @@ int battle_get_adelay(struct block_list *bl)
else
{
eptr<struct status_change, StatusChange> sc_data = battle_get_sc_data(bl);
- int adelay = 4000, aspd_rate = 100, i;
+ int adelay = 4000, aspd_rate = 100;
if (bl->type == BL_MOB && (struct mob_data *) bl)
adelay = ((struct mob_data *) bl)->stats[MOB_ADELAY];
@@ -1081,7 +1077,7 @@ int battle_get_amotion(struct block_list *bl)
else
{
eptr<struct status_change, StatusChange> sc_data = battle_get_sc_data(bl);
- int amotion = 2000, aspd_rate = 100, i;
+ int amotion = 2000, aspd_rate = 100;
if (bl->type == BL_MOB && (struct mob_data *) bl)
amotion = mob_db[((struct mob_data *) bl)->mob_class].amotion;
@@ -1423,7 +1419,7 @@ struct battle_delay_damage_
int flag;
};
static
-void battle_delay_damage_sub(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void battle_delay_damage_sub(timer_id, tick_t, custom_id_t id, custom_data_t data)
{
struct battle_delay_damage_ *dat = (struct battle_delay_damage_ *) data;
if (dat && map_id2bl(id) == dat->src && dat->target->prev != NULL)
@@ -1452,7 +1448,6 @@ int battle_delay_damage(unsigned int tick, struct block_list *src,
int battle_damage(struct block_list *bl, struct block_list *target,
int damage, int flag)
{
- struct map_session_data *sd = NULL;
eptr<struct status_change, StatusChange> sc_data = battle_get_sc_data(target);
short *sc_count;
int i;
@@ -1469,9 +1464,6 @@ int battle_damage(struct block_list *bl, struct block_list *target,
{
if (bl->prev == NULL)
return 0;
-
- if (bl->type == BL_PC)
- sd = (struct map_session_data *) bl;
}
if (damage < 0)
@@ -1608,17 +1600,15 @@ int battle_attr_fix(int damage, int atk_elem, int def_elem)
*/
int battle_calc_damage(struct block_list *src, struct block_list *bl,
int damage, int div_,
- SkillID skill_num, int skill_lv, int flag)
+ SkillID skill_num, int, int flag)
{
struct map_session_data *sd = NULL;
struct mob_data *md = NULL;
eptr<struct status_change, StatusChange> sc_data;
short *sc_count;
- int class_;
nullpo_retr(0, bl);
- class_ = battle_get_class(bl);
if (bl->type == BL_MOB)
md = (struct mob_data *) bl;
else
@@ -1961,7 +1951,8 @@ int battle_addmastery(struct map_session_data *sd, struct block_list *target,
return (damage);
}
-static struct Damage battle_calc_mob_weapon_attack(struct block_list *src,
+static
+struct Damage battle_calc_mob_weapon_attack(struct block_list *src,
struct block_list *target,
SkillID skill_num,
int skill_lv, int wflag)
@@ -1969,7 +1960,7 @@ static struct Damage battle_calc_mob_weapon_attack(struct block_list *src,
struct map_session_data *tsd = NULL;
struct mob_data *md = (struct mob_data *) src, *tmd = NULL;
int hitrate, flee, cri = 0, atkmin, atkmax;
- int luk, target_count = 1;
+ int target_count = 1;
int def1 = battle_get_def(target);
int def2 = battle_get_def2(target);
int t_vit = battle_get_vit(target);
@@ -1977,10 +1968,8 @@ static struct Damage battle_calc_mob_weapon_attack(struct block_list *src,
int damage, damage2 = 0, type, div_, blewcount =
skill_get_blewcount(skill_num, skill_lv);
int flag, skill, ac_flag = 0, dmg_lv = 0;
- int t_mode = 0, t_race = 0, t_size = 1, s_race = 0, s_ele = 0;
+ int t_mode = 0, t_size = 1, s_race = 0, s_ele = 0;
eptr<struct status_change, StatusChange> sc_data, t_sc_data;
- short *sc_count;
- short *option, *opt1, *opt2;
//return前の処理があるので情報出力部のみ変更
if (src == NULL || target == NULL || md == NULL)
@@ -1993,17 +1982,12 @@ static struct Damage battle_calc_mob_weapon_attack(struct block_list *src,
s_race = battle_get_race(src);
s_ele = battle_get_attack_element(src);
sc_data = battle_get_sc_data(src);
- sc_count = battle_get_sc_count(src);
- option = battle_get_option(src);
- opt1 = battle_get_opt1(src);
- opt2 = battle_get_opt2(src);
// ターゲット
if (target->type == BL_PC)
tsd = (struct map_session_data *) target;
else if (target->type == BL_MOB)
tmd = (struct mob_data *) target;
- t_race = battle_get_race(target);
t_size = battle_get_size(target);
t_mode = battle_get_mode(target);
t_sc_data = battle_get_sc_data(target);
@@ -2075,8 +2059,6 @@ static struct Damage battle_calc_mob_weapon_attack(struct block_list *src,
type = 0; // normal
div_ = 1; // single attack
- luk = battle_get_luk(src);
-
if (battle_config.enemy_str)
damage = battle_get_baseatk(src);
else
@@ -2621,7 +2603,8 @@ int battle_is_unarmed(struct block_list *bl)
* PCの武器による攻撃
*-------------------------------------------------------------------------
*/
-static struct Damage battle_calc_pc_weapon_attack(struct block_list *src,
+static
+struct Damage battle_calc_pc_weapon_attack(struct block_list *src,
struct block_list *target,
SkillID skill_num,
int skill_lv, int wflag)
@@ -2630,21 +2613,19 @@ static struct Damage battle_calc_pc_weapon_attack(struct block_list *src,
NULL;
struct mob_data *tmd = NULL;
int hitrate, flee, cri = 0, atkmin, atkmax;
- int dex, luk, target_count = 1;
+ int dex, target_count = 1;
int def1 = battle_get_def(target);
int def2 = battle_get_def2(target);
int t_vit = battle_get_vit(target);
struct Damage wd;
- int damage, damage2, damage3 = 0, damage4 = 0, type, div_, blewcount =
+ int damage, damage2, damage4 = 0, type, div_, blewcount =
skill_get_blewcount(skill_num, skill_lv);
int flag, skill, dmg_lv = 0;
int t_mode = 0, t_race = 0, t_size = 1, s_race = 7, s_ele = 0;
eptr<struct status_change, StatusChange> sc_data, t_sc_data;
- short *sc_count;
- short *option, *opt1, *opt2;
int atkmax_ = 0, atkmin_ = 0, s_ele_; //二刀流用
int watk, watk_, cardfix, t_ele;
- int da = 0, i, t_class, ac_flag = 0;
+ int da = 0, t_class, ac_flag = 0;
int idef_flag = 0, idef_flag_ = 0;
int target_distance;
@@ -2661,10 +2642,6 @@ static struct Damage battle_calc_pc_weapon_attack(struct block_list *src,
s_ele = battle_get_attack_element(src); //属性
s_ele_ = battle_get_attack_element2(src); //左手属性
sc_data = battle_get_sc_data(src); //ステータス異常
- sc_count = battle_get_sc_count(src); //ステータス異常の数
- option = battle_get_option(src); //鷹とかペコとかカートとか
- opt1 = battle_get_opt1(src); //石化、凍結、スタン、睡眠、暗闇
- opt2 = battle_get_opt2(src); //毒、呪い、沈黙、暗闇?
if (skill_num != CR_GRANDCROSS) //グランドクロスでないなら
sd->state.attack_type = BF_WEAPON; //攻撃タイプは武器攻撃
@@ -2753,7 +2730,6 @@ static struct Damage battle_calc_pc_weapon_attack(struct block_list *src,
}
dex = battle_get_dex(src); //DEX
- luk = battle_get_luk(src); //LUK
watk = battle_get_atk(src); //ATK
watk_ = battle_get_atk_(src); //ATK左手
@@ -3127,19 +3103,22 @@ static struct Damage battle_calc_pc_weapon_attack(struct block_list *src,
case KN_BRANDISHSPEAR: // ブランディッシュスピア
damage = damage * (100 + 20 * skill_lv) / 100;
damage2 = damage2 * (100 + 20 * skill_lv) / 100;
- if (skill_lv > 3 && wflag == 1)
- damage3 += damage / 2;
- if (skill_lv > 6 && wflag == 1)
- damage3 += damage / 4;
- if (skill_lv > 9 && wflag == 1)
- damage3 += damage / 8;
- if (skill_lv > 6 && wflag == 2)
- damage3 += damage / 2;
- if (skill_lv > 9 && wflag == 2)
- damage3 += damage / 4;
- if (skill_lv > 9 && wflag == 3)
- damage3 += damage / 2;
- damage += damage3;
+ {
+ int damage3 = 0;
+ if (skill_lv > 3 && wflag == 1)
+ damage3 += damage / 2;
+ if (skill_lv > 6 && wflag == 1)
+ damage3 += damage / 4;
+ if (skill_lv > 9 && wflag == 1)
+ damage3 += damage / 8;
+ if (skill_lv > 6 && wflag == 2)
+ damage3 += damage / 2;
+ if (skill_lv > 9 && wflag == 2)
+ damage3 += damage / 4;
+ if (skill_lv > 9 && wflag == 3)
+ damage3 += damage / 2;
+ damage += damage3;
+ }
if (skill_lv > 3 && wflag == 1)
damage4 += damage2 / 2;
if (skill_lv > 6 && wflag == 1)
@@ -3426,8 +3405,7 @@ static struct Damage battle_calc_pc_weapon_attack(struct block_list *src,
case PA_SACRIFICE:
if (sd)
{
- int hp, mhp, damage3;
- hp = battle_get_hp(src);
+ int mhp, damage3;
mhp = battle_get_max_hp(src);
damage3 = mhp * ((skill_lv / 2) + (50 / 100)) / 100;
damage =
@@ -3772,7 +3750,7 @@ static struct Damage battle_calc_pc_weapon_attack(struct block_list *src,
}
//特定Class用補正処理(少女の日記→ボンゴン用?)
t_class = battle_get_class(target);
- for (i = 0; i < sd->add_damage_class_count; i++)
+ for (int i = 0; i < sd->add_damage_class_count; i++)
{
if (sd->add_damage_classid[i] == t_class)
{
@@ -3797,7 +3775,7 @@ static struct Damage battle_calc_pc_weapon_attack(struct block_list *src,
cardfix = cardfix * (100 + sd->addrace_[11]) / 100; //ボス以外モンスターに追加ダメージ左手
}
//特定Class用補正処理左手(少女の日記→ボンゴン用?)
- for (i = 0; i < sd->add_damage_class_count_; i++)
+ for (int i = 0; i < sd->add_damage_class_count_; i++)
{
if (sd->add_damage_classid_[i] == t_class)
{
@@ -3810,6 +3788,7 @@ static struct Damage battle_calc_pc_weapon_attack(struct block_list *src,
//カードによるダメージ増加処理(左手)ここまで
// -- moonsoul (cardfix for magic damage portion of ASC_BREAKER)
+ int damage3 = 0;
if (skill_num == ASC_BREAKER)
damage3 = damage3 * cardfix / 100;
@@ -3824,7 +3803,7 @@ static struct Damage battle_calc_pc_weapon_attack(struct block_list *src,
else
cardfix = cardfix * (100 - tsd->subrace[11]) / 100; //ボス以外からの攻撃はダメージ減少
//特定Class用補正処理左手(少女の日記→ボンゴン用?)
- for (i = 0; i < tsd->add_def_class_count; i++)
+ for (int i = 0; i < tsd->add_def_class_count; i++)
{
if (tsd->add_def_classid[i] == sd->status.pc_class)
{
@@ -4144,7 +4123,6 @@ struct Damage battle_calc_magic_attack(struct block_list *bl,
int ele = 0, race = 7, t_ele = 0, t_race = 7, t_mode =
0, cardfix, t_class, i;
struct map_session_data *sd = NULL, *tsd = NULL;
- struct mob_data *tmd = NULL;
//return前の処理があるので情報出力部のみ変更
if (bl == NULL || target == NULL)
@@ -4173,8 +4151,6 @@ struct Damage battle_calc_magic_attack(struct block_list *bl,
}
if (target->type == BL_PC)
tsd = (struct map_session_data *) target;
- else if (target->type == BL_MOB)
- tmd = (struct mob_data *) target;
aflag = BF_MAGIC | BF_LONG | BF_SKILL;
diff --git a/src/map/battle.hpp b/src/map/battle.hpp
index 50c3195..aa4dd91 100644
--- a/src/map/battle.hpp
+++ b/src/map/battle.hpp
@@ -1,8 +1,8 @@
-// $Id: battle.h,v 1.6 2004/09/29 21:08:17 Akitasha Exp $
#ifndef BATTLE_HPP
#define BATTLE_HPP
#include "../common/utils.hpp"
+
#include "skill.t.hpp"
// ダメージ
@@ -343,4 +343,4 @@ extern struct Battle_Config
int battle_config_read(const char *cfgName);
-#endif
+#endif // BATTLE_HPP
diff --git a/src/map/chat.cpp b/src/map/chat.cpp
index 9078ea0..89ee992 100644
--- a/src/map/chat.cpp
+++ b/src/map/chat.cpp
@@ -1,19 +1,16 @@
-// $Id: chat.c,v 1.2 2004/09/22 02:59:47 Akitasha Exp $
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "chat.hpp"
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include "../common/db.hpp"
#include "../common/nullpo.hpp"
-#include "map.hpp"
+
#include "clif.hpp"
-#include "pc.hpp"
-#include "chat.hpp"
+#include "map.hpp"
#include "npc.hpp"
-
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
+#include "pc.hpp"
int chat_triggerevent(struct chat_data *cd);
diff --git a/src/map/chat.hpp b/src/map/chat.hpp
index 5ffff36..9768343 100644
--- a/src/map/chat.hpp
+++ b/src/map/chat.hpp
@@ -1,4 +1,3 @@
-// $Id: chat.h,v 1.3 2004/09/25 05:32:18 MouseJstr Exp $
#ifndef CHAT_HPP
#define CHAT_HPP
@@ -22,4 +21,4 @@ int chat_npckickall(struct chat_data *cd);
int do_final_chat(void);
-#endif
+#endif // CHAT_HPP
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index af5e1e1..6f5278e 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -1,35 +1,31 @@
-// $Id: chrif.c,v 1.6 2004/09/25 11:39:17 MouseJstr Exp $
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef LCCWIN32
-#include <winsock.h>
-#else
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
+#include "chrif.hpp"
+
#include <arpa/inet.h>
-#endif
+#include <netinet/in.h>
+#include <sys/socket.h>
#include <sys/types.h>
-#include <time.h>
+#include <unistd.h>
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+
+#include "../common/nullpo.hpp"
#include "../common/socket.hpp"
#include "../common/timer.hpp"
-#include "map.hpp"
+
#include "battle.hpp"
-#include "chrif.hpp"
#include "clif.hpp"
#include "intif.hpp"
+#include "itemdb.hpp"
+#include "map.hpp"
#include "npc.hpp"
#include "pc.hpp"
-#include "../common/nullpo.hpp"
-#include "itemdb.hpp"
-
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
-static const int packet_len_table[0x20] = {
+static
+const int packet_len_table[0x20] = {
60, 3, 10, 27, 22, -1, 6, -1, // 2af8-2aff
6, -1, 18, 7, -1, 49, 44, 0, // 2b00-2b07
6, 30, -1, 10, 86, 7, 44, 34, // 2b08-2b0f
@@ -38,11 +34,16 @@ static const int packet_len_table[0x20] = {
int char_fd;
int srvinfo;
-static char char_ip_str[16];
-static int char_ip;
-static int char_port = 6121;
-static char userid[24], passwd[24];
-static int chrif_state;
+static
+char char_ip_str[16];
+static
+int char_ip;
+static
+int char_port = 6121;
+static
+char userid[24], passwd[24];
+static
+int chrif_state;
// 設定ファイル読み込み関係
/*==========================================
@@ -1024,7 +1025,8 @@ int chrif_char_offline(struct map_session_data *sd)
*----------------------------------------
*/
-static void ladmin_itemfrob_fix_item(int source, int dest, struct item *item)
+static
+void ladmin_itemfrob_fix_item(int source, int dest, struct item *item)
{
if (item && item->nameid == source)
{
@@ -1100,10 +1102,8 @@ void ladmin_itemfrob_c2(struct block_list *bl, int source_id, int dest_id)
}
static
-void ladmin_itemfrob_c(struct block_list *bl, va_list va_args)
+void ladmin_itemfrob_c(struct block_list *bl, int source_id, int dest_id)
{
- int source_id = va_arg(va_args, int);
- int dest_id = va_arg(va_args, int);
ladmin_itemfrob_c2(bl, source_id, dest_id);
}
@@ -1115,8 +1115,7 @@ void ladmin_itemfrob(int fd)
struct block_list *bl = (struct block_list *) map_get_first_session();
// flooritems
- map_foreachobject(ladmin_itemfrob_c, 0 /* any object */ , source_id,
- dest_id);
+ map_foreachobject(std::bind(ladmin_itemfrob_c, ph::_1, source_id, dest_id), 0 /* any object */);
// player characters (and, hopefully, mobs)
while (bl->next)
@@ -1256,7 +1255,7 @@ void chrif_parse(int fd)
*------------------------------------------
*/
static
-void send_users_tochar(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void send_users_tochar(timer_id, tick_t, custom_id_t, custom_data_t)
{
int users = 0, i;
struct map_session_data *sd;
@@ -1287,7 +1286,7 @@ void send_users_tochar(timer_id tid, tick_t tick, custom_id_t id, custom_data_t
*------------------------------------------
*/
static
-void check_connect_char_server(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void check_connect_char_server(timer_id, tick_t, custom_id_t, custom_data_t)
{
if (char_fd <= 0 || session[char_fd] == NULL)
{
diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp
index 93f3e00..97debb8 100644
--- a/src/map/chrif.hpp
+++ b/src/map/chrif.hpp
@@ -1,4 +1,3 @@
-// $Id: chrif.h,v 1.3 2004/09/25 11:39:17 MouseJstr Exp $
#ifndef CHRIF_HPP
#define CHRIF_HPP
@@ -33,4 +32,4 @@ int chrif_send_divorce(int char_id);
int do_init_chrif (void);
-#endif
+#endif // CHRIF_HPP
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index 0b95208..a5d756a 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -1,35 +1,30 @@
-// $Id: clif.c 164 2004-10-01 16:46:58Z $
-
-#define DUMP_UNKNOWN_PACKET 1
+#include "clif.hpp"
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
#include <sys/types.h>
-#ifdef LCCWIN32
-#include <winsock.h>
-#else
+
#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#endif
-#include <time.h>
+#include <cctype>
+#include <stdarg.h> // needs justification for <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+
+#include "../common/md5calc.hpp"
+#include "../common/mt_rand.hpp"
+#include "../common/nullpo.hpp"
#include "../common/socket.hpp"
#include "../common/timer.hpp"
#include "../common/version.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/md5calc.hpp"
-#include "../common/mt_rand.hpp"
#include "atcommand.hpp"
#include "battle.hpp"
#include "chat.hpp"
#include "chrif.hpp"
-#include "clif.hpp"
#include "intif.hpp"
#include "itemdb.hpp"
#include "magic.hpp"
@@ -44,14 +39,13 @@
#include "tmw.hpp"
#include "trade.hpp"
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
+#define DUMP_UNKNOWN_PACKET 1
#define STATE_BLIND 0x10
#define EMOTE_IGNORED 0x0e
-static const int packet_len_table[0x220] = {
+static
+const int packet_len_table[0x220] = {
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -115,7 +109,7 @@ enum
PARTY_SAMEMAP_WOS,
PARTY_AREA,
PARTY_AREA_WOS,
- SELF
+ SELF,
};
#define WBUFPOS(p,pos,x,y) { unsigned char *__p = (p); __p+= (pos); __p[0] = (x)>>2; __p[1] = ((x)<<6) | (((y)>>4)&0x3f); __p[2] = (y)<<4; }
@@ -124,9 +118,12 @@ enum
#define WFIFOPOS(fd,pos,x,y) { WBUFPOS(WFIFOP(fd,pos),0,x,y); }
#define WFIFOPOS2(fd,pos,x0,y0,x1,y1) { WBUFPOS2(WFIFOP(fd,pos),0,x0,y0,x1,y1); }
-static char map_ip_str[16];
-static struct in_addr map_ip;
-static int map_port = 5121;
+static
+char map_ip_str[16];
+static
+struct in_addr map_ip;
+static
+int map_port = 5121;
int map_fd;
char talkie_mes[80];
@@ -190,24 +187,22 @@ int clif_countusers(void)
* 全てのclientに対してfunc()実行
*------------------------------------------
*/
-int clif_foreachclient(int(*func)(struct map_session_data *, va_list), ...)
+int clif_foreachclient(std::function<void(struct map_session_data *)> func)
{
int i;
- va_list ap;
struct map_session_data *sd;
- va_start(ap, func);
for (i = 0; i < fd_max; i++)
{
if (session[i] && (sd = (struct map_session_data *)session[i]->session_data) && sd
&& sd->state.auth)
- func(sd, ap);
+ func(sd);
}
- va_end(ap);
return 0;
}
-static int is_deaf(struct block_list *bl)
+static
+int is_deaf(struct block_list *bl)
{
struct map_session_data *sd = (struct map_session_data *) bl;
if (!bl || bl->type != BL_PC)
@@ -215,10 +210,12 @@ static int is_deaf(struct block_list *bl)
return sd->special_state.deaf;
}
-static void clif_emotion_towards(struct block_list *bl,
+static
+void clif_emotion_towards(struct block_list *bl,
struct block_list *target, int type);
-static char *clif_validate_chat(struct map_session_data *sd, int type,
+static
+char *clif_validate_chat(struct map_session_data *sd, int type,
char **message, size_t *message_len);
/*==========================================
@@ -226,22 +223,11 @@ static char *clif_validate_chat(struct map_session_data *sd, int type,
*------------------------------------------
*/
static
-void clif_send_sub(struct block_list *bl, va_list ap)
+void clif_send_sub(struct block_list *bl, const unsigned char *buf, int len,
+ struct block_list *src_bl, int type)
{
- unsigned char *buf;
- int len;
- struct block_list *src_bl;
- int type;
- struct map_session_data *sd;
-
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(sd = (struct map_session_data *) bl);
-
- buf = va_arg(ap, unsigned char *);
- len = va_arg(ap, int);
- nullpo_retv(src_bl = va_arg(ap, struct block_list *));
- type = va_arg(ap, int);
+ struct map_session_data *sd = (struct map_session_data *) bl;
switch (type)
{
@@ -368,16 +354,14 @@ int clif_send(const uint8_t *buf, int len, struct block_list *bl, int type)
case AREA_WOS:
case AREA_WOC:
case AREA_WOSC:
- map_foreachinarea(clif_send_sub, bl->m, bl->x - AREA_SIZE,
- bl->y - AREA_SIZE, bl->x + AREA_SIZE,
- bl->y + AREA_SIZE, BL_PC, buf, len, bl, type);
+ map_foreachinarea(std::bind(clif_send_sub, ph::_1, buf, len, bl, type),
+ bl->m, bl->x - AREA_SIZE, bl->y - AREA_SIZE,
+ bl->x + AREA_SIZE, bl->y + AREA_SIZE, BL_PC);
break;
case AREA_CHAT_WOC:
- map_foreachinarea(clif_send_sub, bl->m, bl->x - (AREA_SIZE),
- bl->y - (AREA_SIZE),
- bl->x + (AREA_SIZE),
- bl->y + (AREA_SIZE), BL_PC, buf, len, bl,
- AREA_CHAT_WOC);
+ map_foreachinarea(std::bind(clif_send_sub, ph::_1, buf, len, bl, AREA_CHAT_WOC),
+ bl->m, bl->x - (AREA_SIZE), bl->y - (AREA_SIZE),
+ bl->x + (AREA_SIZE), bl->y + (AREA_SIZE), BL_PC);
break;
case CHAT:
case CHAT_WOS:
@@ -562,7 +546,8 @@ int clif_charselectok(int id)
*
*------------------------------------------
*/
-static int clif_set009e(struct flooritem_data *fitem, uint8_t *buf)
+static
+int clif_set009e(struct flooritem_data *fitem, uint8_t *buf)
{
int view;
@@ -656,7 +641,8 @@ int clif_clearchar(struct block_list *bl, int type)
return 0;
}
-static void clif_clearchar_delay_sub(timer_id tid, tick_t tick, custom_id_t id,
+static
+void clif_clearchar_delay_sub(timer_id, tick_t, custom_id_t id,
custom_data_t data)
{
struct block_list *bl = (struct block_list *) id;
@@ -694,7 +680,8 @@ int clif_clearchar_id(int id, int type, int fd)
}
/*
-static int current_weapon(struct map_session_data *sd)
+static
+int current_weapon(struct map_session_data *sd)
{
if (sd->attack_spell_override)
return sd->attack_spell_look_override;
@@ -708,7 +695,8 @@ static int current_weapon(struct map_session_data *sd)
*
*------------------------------------------
*/
-static int clif_set0078(struct map_session_data *sd, unsigned char *buf)
+static
+int clif_set0078(struct map_session_data *sd, unsigned char *buf)
{
int level = 0;
@@ -798,7 +786,8 @@ static int clif_set0078(struct map_session_data *sd, unsigned char *buf)
*
*------------------------------------------
*/
-static int clif_set007b(struct map_session_data *sd, unsigned char *buf)
+static
+int clif_set007b(struct map_session_data *sd, unsigned char *buf)
{
int level = 0;
nullpo_retr(0, sd);
@@ -945,7 +934,8 @@ int clif_mob_equip(struct mob_data *md, int nameid)
* MOB表示1
*------------------------------------------
*/
-static int clif_mob0078(struct mob_data *md, unsigned char *buf)
+static
+int clif_mob0078(struct mob_data *md, unsigned char *buf)
{
int level;
@@ -992,7 +982,8 @@ static int clif_mob0078(struct mob_data *md, unsigned char *buf)
* MOB表示2
*------------------------------------------
*/
-static int clif_mob007b(struct mob_data *md, unsigned char *buf)
+static
+int clif_mob007b(struct mob_data *md, unsigned char *buf)
{
int level;
@@ -1040,7 +1031,8 @@ static int clif_mob007b(struct mob_data *md, unsigned char *buf)
*
*------------------------------------------
*/
-static int clif_npc0078(struct npc_data *nd, unsigned char *buf)
+static
+int clif_npc0078(struct npc_data *nd, unsigned char *buf)
{
nullpo_retr(0, nd);
@@ -1062,7 +1054,8 @@ static int clif_npc0078(struct npc_data *nd, unsigned char *buf)
*
*------------------------------------------
*/
-static int clif_set01e1(struct map_session_data *sd, unsigned char *buf)
+static
+int clif_set01e1(struct map_session_data *sd, unsigned char *buf)
{
nullpo_retr(0, sd);
@@ -1077,7 +1070,8 @@ static int clif_set01e1(struct map_session_data *sd, unsigned char *buf)
*
*------------------------------------------
*/
-static int clif_set0192(int fd, int m, int x, int y, int type)
+static
+int clif_set0192(int fd, int m, int x, int y, int type)
{
WFIFOW(fd, 0) = 0x192;
WFIFOW(fd, 2) = x;
@@ -1090,7 +1084,8 @@ static int clif_set0192(int fd, int m, int x, int y, int type)
}
/* These indices are derived from equip_pos in pc.c and some guesswork */
-static int equip_points[LOOK_LAST + 1] = {
+static
+int equip_points[LOOK_LAST + 1] = {
-1, /* 0: base */
-1, /* 1: hair */
9, /* 2: weapon */
@@ -1209,8 +1204,7 @@ int clif_spawnnpc(struct npc_data *nd)
return 0;
}
-int
-clif_spawn_fake_npc_for_player(struct map_session_data *sd, int fake_npc_id)
+int clif_spawn_fake_npc_for_player(struct map_session_data *sd, int fake_npc_id)
{
int fd;
@@ -1327,14 +1321,11 @@ int clif_walkok(struct map_session_data *sd)
*/
int clif_movechar(struct map_session_data *sd)
{
- int fd;
int len;
unsigned char buf[256];
nullpo_retr(0, sd);
- fd = sd->fd;
-
len = clif_set007b(sd, buf);
if (sd->disguise > 23 && sd->disguise < 4001)
@@ -1357,7 +1348,7 @@ int clif_movechar(struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_quitsave(int fd, struct map_session_data *sd)
+void clif_quitsave(int, struct map_session_data *sd)
{
map_quit(sd);
}
@@ -1366,7 +1357,8 @@ void clif_quitsave(int fd, struct map_session_data *sd)
*
*------------------------------------------
*/
-static void clif_waitclose(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+static
+void clif_waitclose(timer_id, tick_t, custom_id_t id, custom_data_t)
{
if (session[id])
session[id]->eof = 1;
@@ -3203,8 +3195,7 @@ int clif_storageclose(struct map_session_data *sd)
return 0;
}
-void
-clif_changelook_accessories(struct block_list *bl,
+void clif_changelook_accessories(struct block_list *bl,
struct map_session_data *dest)
{
int i;
@@ -3572,14 +3563,9 @@ int clif_01ac(struct block_list *bl)
*------------------------------------------
*/
static
-void clif_getareachar(struct block_list *bl, va_list ap)
+void clif_getareachar(struct block_list *bl, struct map_session_data *sd)
{
- struct map_session_data *sd;
-
nullpo_retv(bl);
- nullpo_retv(ap);
-
- sd = va_arg(ap, struct map_session_data *);
switch (bl->type)
{
@@ -3611,13 +3597,12 @@ void clif_getareachar(struct block_list *bl, va_list ap)
*
*------------------------------------------
*/
-void clif_pcoutsight(struct block_list *bl, va_list ap)
+void clif_pcoutsight(struct block_list *bl, struct map_session_data *sd)
{
- struct map_session_data *sd, *dstsd;
+ struct map_session_data *dstsd;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(sd = va_arg(ap, struct map_session_data *));
+ nullpo_retv(sd);
switch (bl->type)
{
@@ -3656,13 +3641,12 @@ void clif_pcoutsight(struct block_list *bl, va_list ap)
*
*------------------------------------------
*/
-void clif_pcinsight(struct block_list *bl, va_list ap)
+void clif_pcinsight(struct block_list *bl, struct map_session_data *sd)
{
- struct map_session_data *sd, *dstsd;
+ struct map_session_data *dstsd;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(sd = va_arg(ap, struct map_session_data *));
+ nullpo_retv(sd);
switch (bl->type)
{
@@ -3693,14 +3677,12 @@ void clif_pcinsight(struct block_list *bl, va_list ap)
*
*------------------------------------------
*/
-void clif_moboutsight(struct block_list *bl, va_list ap)
+void clif_moboutsight(struct block_list *bl, struct mob_data *md)
{
struct map_session_data *sd;
- struct mob_data *md;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(md = va_arg(ap, struct mob_data *));
+ nullpo_retv(md);
if (bl->type == BL_PC && (sd = (struct map_session_data *) bl))
{
@@ -3712,15 +3694,13 @@ void clif_moboutsight(struct block_list *bl, va_list ap)
*
*------------------------------------------
*/
-void clif_mobinsight(struct block_list *bl, va_list ap)
+void clif_mobinsight(struct block_list *bl, struct mob_data *md)
{
struct map_session_data *sd;
- struct mob_data *md;
nullpo_retv(bl);
- nullpo_retv(ap);
+ nullpo_retv(md);
- md = va_arg(ap, struct mob_data *);
if (bl->type == BL_PC && (sd = (struct map_session_data *) bl))
{
clif_getareachar_mob(sd, md);
@@ -4389,7 +4369,7 @@ int clif_send0199(int m, int type)
* 精錬エフェクトを送信する
*------------------------------------------
*/
-int clif_refine(int fd, struct map_session_data *sd, int fail, int index,
+int clif_refine(int fd, struct map_session_data *, int fail, int index,
int val)
{
WFIFOW(fd, 0) = 0x188;
@@ -4642,7 +4622,7 @@ int clif_item_skill(struct map_session_data *sd, SkillID skillid, int skilllv,
*------------------------------------------
*/
int clif_cart_additem(struct map_session_data *sd, int n, int amount,
- int fail)
+ int)
{
int view, j, fd;
unsigned char *buf;
@@ -5073,7 +5053,7 @@ int clif_party_message(struct party *p, int account_id, const char *mes, int len
* パーティ座標通知
*------------------------------------------
*/
-int clif_party_xy(struct party *p, struct map_session_data *sd)
+int clif_party_xy(struct party *, struct map_session_data *sd)
{
unsigned char buf[16];
@@ -5093,7 +5073,7 @@ int clif_party_xy(struct party *p, struct map_session_data *sd)
* パーティHP通知
*------------------------------------------
*/
-int clif_party_hp(struct party *p, struct map_session_data *sd)
+int clif_party_hp(struct party *, struct map_session_data *sd)
{
unsigned char buf[16];
@@ -5233,7 +5213,7 @@ int clif_autospell(struct map_session_data *sd, int skilllv)
* ディボーションの青い糸
*------------------------------------------
*/
-int clif_devotion(struct map_session_data *sd, int target)
+int clif_devotion(struct map_session_data *sd, int)
{
unsigned char buf[56];
int n;
@@ -5403,7 +5383,8 @@ void clif_emotion(struct block_list *bl, int type)
clif_send(buf, packet_len_table[0xc0], bl, AREA);
}
-static void clif_emotion_towards(struct block_list *bl,
+static
+void clif_emotion_towards(struct block_list *bl,
struct block_list *target, int type)
{
unsigned char buf[8];
@@ -5485,7 +5466,7 @@ void clif_callpartner(struct map_session_data *sd)
* 座る
*------------------------------------------
*/
-void clif_sitting(int fd, struct map_session_data *sd)
+void clif_sitting(int, struct map_session_data *sd)
{
unsigned char buf[64];
@@ -5555,46 +5536,6 @@ int clif_GM_kick(struct map_session_data *sd, struct map_session_data *tsd,
}
/*==========================================
- * Wis拒否許可応答
- *------------------------------------------
- */
-static
-int clif_wisexin(struct map_session_data *sd, int type, int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xd1;
- WFIFOB(fd, 2) = type;
- WFIFOB(fd, 3) = flag;
- WFIFOSET(fd, packet_len_table[0xd1]);
-
- return 0;
-}
-
-/*==========================================
- * Wis全拒否許可応答
- *------------------------------------------
- */
-static
-int clif_wisall(struct map_session_data *sd, int type, int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xd2;
- WFIFOB(fd, 2) = type;
- WFIFOB(fd, 3) = flag;
- WFIFOSET(fd, packet_len_table[0xd2]);
-
- return 0;
-}
-
-/*==========================================
* サウンドエフェクト
*------------------------------------------
*/
@@ -5713,7 +5654,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_LoadEndAck(int fd, struct map_session_data *sd)
+void clif_parse_LoadEndAck(int, struct map_session_data *sd)
{
// struct item_data* item;
int i;
@@ -5838,9 +5779,9 @@ void clif_parse_LoadEndAck(int fd, struct map_session_data *sd)
// clif_changelook_accessories(sd, NULL);
- map_foreachinarea(clif_getareachar, sd->bl.m, sd->bl.x - AREA_SIZE,
+ map_foreachinarea(std::bind(clif_getareachar, ph::_1, sd), sd->bl.m, sd->bl.x - AREA_SIZE,
sd->bl.y - AREA_SIZE, sd->bl.x + AREA_SIZE,
- sd->bl.y + AREA_SIZE, 0, sd);
+ sd->bl.y + AREA_SIZE, 0);
}
/*==========================================
@@ -6224,7 +6165,7 @@ void clif_parse_Emotion(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_HowManyConnections(int fd, struct map_session_data *sd)
+void clif_parse_HowManyConnections(int fd, struct map_session_data *)
{
WFIFOW(fd, 0) = 0xc2;
WFIFOL(fd, 2) = map_getusers();
@@ -6764,7 +6705,7 @@ void clif_parse_KickFromChat(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_ChatLeave(int fd, struct map_session_data *sd)
+void clif_parse_ChatLeave(int, struct map_session_data *sd)
{
chat_leavechat(sd);
}
@@ -6774,7 +6715,7 @@ void clif_parse_ChatLeave(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_TradeRequest(int fd, struct map_session_data *sd)
+void clif_parse_TradeRequest(int, struct map_session_data *sd)
{
nullpo_retv(sd);
@@ -6792,7 +6733,7 @@ void clif_parse_TradeRequest(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_TradeAck(int fd, struct map_session_data *sd)
+void clif_parse_TradeAck(int, struct map_session_data *sd)
{
nullpo_retv(sd);
@@ -6804,7 +6745,7 @@ void clif_parse_TradeAck(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_TradeAddItem(int fd, struct map_session_data *sd)
+void clif_parse_TradeAddItem(int, struct map_session_data *sd)
{
nullpo_retv(sd);
@@ -6816,7 +6757,7 @@ void clif_parse_TradeAddItem(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_TradeOk(int fd, struct map_session_data *sd)
+void clif_parse_TradeOk(int, struct map_session_data *sd)
{
trade_tradeok(sd);
}
@@ -6826,7 +6767,7 @@ void clif_parse_TradeOk(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_TradeCansel(int fd, struct map_session_data *sd)
+void clif_parse_TradeCansel(int, struct map_session_data *sd)
{
trade_tradecancel(sd);
}
@@ -6836,7 +6777,7 @@ void clif_parse_TradeCansel(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_TradeCommit(int fd, struct map_session_data *sd)
+void clif_parse_TradeCommit(int, struct map_session_data *sd)
{
trade_tradecommit(sd);
}
@@ -6846,7 +6787,7 @@ void clif_parse_TradeCommit(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_StopAttack(int fd, struct map_session_data *sd)
+void clif_parse_StopAttack(int, struct map_session_data *sd)
{
pc_stopattack(sd);
}
@@ -6884,7 +6825,7 @@ void clif_parse_GetItemFromCart(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_RemoveOption(int fd, struct map_session_data *sd)
+void clif_parse_RemoveOption(int, struct map_session_data *sd)
{
if (pc_isriding(sd))
{ // jobchange when removing peco [Valaris]
@@ -7119,7 +7060,7 @@ void clif_parse_UseSkillMap(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_RequestMemo(int fd, struct map_session_data *sd)
+void clif_parse_RequestMemo(int, struct map_session_data *sd)
{
pc_memo(sd, -1);
}
@@ -7394,7 +7335,7 @@ void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_CloseKafra(int fd, struct map_session_data *sd)
+void clif_parse_CloseKafra(int, struct map_session_data *sd)
{
nullpo_retv(sd);
@@ -7485,7 +7426,7 @@ void clif_parse_ReplyPartyInvite(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_LeaveParty(int fd, struct map_session_data *sd)
+void clif_parse_LeaveParty(int, struct map_session_data *sd)
{
party_leave(sd);
}
@@ -7756,7 +7697,7 @@ void clif_parse_GMReqNoChat(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_GMReqNoChatCount(int fd, struct map_session_data *sd)
+void clif_parse_GMReqNoChatCount(int fd, struct map_session_data *)
{
int tid = RFIFOL(fd, 2);
@@ -7950,44 +7891,12 @@ void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd)
return;
}
-static
-void clif_parse_skillMessage(int fd, struct map_session_data *sd)
-{ // Added by RoVeRT
- int skillid, skilllv, x, y;
- char *mes;
-
- skilllv = RFIFOW(fd, 2);
- skillid = RFIFOW(fd, 4);
-
- y = RFIFOB(fd, 6);
- x = RFIFOB(fd, 8);
-
- mes = (char *)RFIFOP(fd, 10);
-
- // skill 220 = graffiti
-// printf("skill: %d %d location: %3d %3d message: %s\n", skillid, skilllv, x, y, (char*)mes);
-}
-
-static
-int monk(struct map_session_data *sd, struct block_list *target, int type)
-{
-//R 01d1 <Monk id>L <Target monster id>L <Bool>L
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0x1d1;
- WFIFOL(fd, 2) = sd->bl.id;
- WFIFOL(fd, 6) = target->id;
- WFIFOL(fd, 10) = type;
- WFIFOSET(fd, packet_len_table[0x1d1]);
-
- return 0;
-}
-
/*==========================================
* スパノビの/doridoriによるSPR2倍
*------------------------------------------
*/
static
-void clif_parse_sn_doridori(int fd, struct map_session_data *sd)
+void clif_parse_sn_doridori(int, struct map_session_data *sd)
{
if (sd)
sd->doridori_counter = 1;
@@ -8000,7 +7909,7 @@ void clif_parse_sn_doridori(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static
-void clif_parse_sn_explosionspirits(int fd, struct map_session_data *sd)
+void clif_parse_sn_explosionspirits(int, struct map_session_data *sd)
{
if (sd)
{
@@ -8023,10 +7932,9 @@ void clif_parse_sn_explosionspirits(int fd, struct map_session_data *sd)
{
clif_skill_nodamage(&sd->bl, &sd->bl, MO_EXPLOSIONSPIRITS, 5, 1);
skill_status_change_start(&sd->bl,
- SkillStatusChangeTable
- [MO_EXPLOSIONSPIRITS], 5, 0, 0, 0,
- skill_get_time(MO_EXPLOSIONSPIRITS,
- 5), 0);
+ SkillStatusChangeTable[MO_EXPLOSIONSPIRITS],
+ 5, 0, 0, 0,
+ skill_get_time(MO_EXPLOSIONSPIRITS, 5), 0);
}
}
return;
@@ -8686,7 +8594,8 @@ int clif_check_packet_flood(int fd, int cmd)
* @param[out] message_len the length of the actual text, excluding NUL
* @return a dynamically allocated copy of the message, or NULL upon failure
*/
-static char *clif_validate_chat(struct map_session_data *sd, int type,
+static
+char *clif_validate_chat(struct map_session_data *sd, int type,
char **message, size_t *message_len)
{
int fd;
@@ -8804,7 +8713,8 @@ static char *clif_validate_chat(struct map_session_data *sd, int type,
* socket.cのdo_parsepacketから呼び出される
*------------------------------------------
*/
-static void clif_parse(int fd)
+static
+void clif_parse(int fd)
{
int packet_len = 0, cmd = 0;
struct map_session_data *sd = (struct map_session_data *)session[fd]->session_data;
diff --git a/src/map/clif.hpp b/src/map/clif.hpp
index 2214e48..b072d3c 100644
--- a/src/map/clif.hpp
+++ b/src/map/clif.hpp
@@ -1,14 +1,13 @@
-// $Id: clif.h,v 1.4 2004/09/25 05:32:18 MouseJstr Exp $
#ifndef CLIF_HPP
#define CLIF_HPP
-#include <sys/types.h>
-
-#include <sys/socket.h>
-#include <netinet/in.h>
#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <sys/types.h>
#include "map.hpp"
+#include "storage.hpp"
void clif_setip(const char *);
void clif_setport(int);
@@ -100,7 +99,6 @@ int clif_tradecancelled(struct map_session_data *sd);
int clif_tradecompleted(struct map_session_data *sd, int fail);
// storage
-#include "storage.hpp"
int clif_storageitemlist(struct map_session_data *sd, struct storage *stor);
int clif_storageequiplist(struct map_session_data *sd,
struct storage *stor);
@@ -112,10 +110,11 @@ int clif_storageitemremoved(struct map_session_data *sd, int index,
int amount);
int clif_storageclose(struct map_session_data *sd);
-void clif_pcinsight(struct block_list *, va_list); // map_forallinmovearea callback
-void clif_pcoutsight(struct block_list *, va_list); // map_forallinmovearea callback
-void clif_mobinsight(struct block_list *, va_list); // map_forallinmovearea callback
-void clif_moboutsight(struct block_list *, va_list); // map_forallinmovearea callback
+// map_forallinmovearea callbacks
+void clif_pcinsight(struct block_list *, struct map_session_data *);
+void clif_pcoutsight(struct block_list *, struct map_session_data *);
+void clif_mobinsight(struct block_list *, struct mob_data *);
+void clif_moboutsight(struct block_list *, struct mob_data *);
int clif_npc_class_change(struct block_list *bl, int npc_class, int type);
int clif_mob_class_change(struct mob_data *md, int mob_class);
@@ -235,9 +234,9 @@ int clif_GM_kickack(struct map_session_data *sd, int id);
int clif_GM_kick(struct map_session_data *sd, struct map_session_data *tsd,
int type);
-int clif_foreachclient(int(*)(struct map_session_data *, va_list), ...);
+int clif_foreachclient(std::function<void(struct map_session_data *)>);
int do_final_clif (void);
int do_init_clif (void);
-#endif
+#endif // CLIF_HPP
diff --git a/src/map/intif.cpp b/src/map/intif.cpp
index b8d21f3..0107155 100644
--- a/src/map/intif.cpp
+++ b/src/map/intif.cpp
@@ -1,22 +1,19 @@
-// $Id: intif.c,v 1.2 2004/09/25 05:32:18 MouseJstr Exp $
-#include <sys/types.h>
-#ifdef LCCWIN32
-#include <winsock.h>
-#else
-#include <sys/socket.h>
+#include "intif.hpp"
+
+#include <arpa/inet.h>
#include <netinet/in.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#ifndef LCCWIN32
-#include <sys/time.h>
#include <sys/ioctl.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#endif
-#include <signal.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/types.h>
+
#include <fcntl.h>
-#include <string.h>
+#include <unistd.h>
+
+#include <csignal>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include "../common/nullpo.hpp"
#include "../common/socket.hpp"
@@ -25,17 +22,13 @@
#include "battle.hpp"
#include "chrif.hpp"
#include "clif.hpp"
-#include "intif.hpp"
#include "map.hpp"
#include "party.hpp"
#include "pc.hpp"
#include "storage.hpp"
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
-
-static const int packet_len_table[] = {
+static
+const int packet_len_table[] = {
-1, -1, 27, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, 7, 0, 0, 0, 0, 0, 0, -1, 11, 0, 0, 0, 0, 0, 0,
35, -1, 11, 15, 34, 29, 7, -1, 0, 0, 0, 0, 0, 0, 0, 0,
diff --git a/src/map/intif.hpp b/src/map/intif.hpp
index 185ce73..c2a4d5f 100644
--- a/src/map/intif.hpp
+++ b/src/map/intif.hpp
@@ -1,4 +1,3 @@
-// $Id: intif.h,v 1.2 2004/09/25 05:32:18 MouseJstr Exp $
#ifndef INTIF_HPP
#define INTIF_HPP
@@ -28,4 +27,4 @@ int intif_break_party(int party_id);
int intif_party_message(int party_id, int account_id, const char *mes, int len);
int intif_party_checkconflict(int party_id, int account_id, const char *nick);
-#endif
+#endif // INTIF_HPP
diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp
index 8d0eb3b..7861796 100644
--- a/src/map/itemdb.cpp
+++ b/src/map/itemdb.cpp
@@ -1,22 +1,19 @@
-// $Id: itemdb.c,v 1.3 2004/09/25 05:32:18 MouseJstr Exp $
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "itemdb.hpp"
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include "../common/db.hpp"
#include "../common/grfio.hpp"
+#include "../common/mt_rand.hpp"
#include "../common/nullpo.hpp"
-#include "map.hpp"
-#include "battle.hpp"
-#include "itemdb.hpp"
-#include "script.hpp"
-#include "pc.hpp"
#include "../common/socket.hpp"
-#include "../common/mt_rand.hpp"
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
+#include "battle.hpp"
+#include "map.hpp"
+#include "pc.hpp"
+#include "script.hpp"
#define MAX_RANDITEM 2000
@@ -24,24 +21,34 @@
// 定義すると、itemdb.txtとgrfで名前が異なる場合、表示します.
//#define ITEMDB_OVERRIDE_NAME_VERBOSE 1
-static struct dbt *item_db;
+static
+struct dbt *item_db;
-static struct random_item_data blue_box[MAX_RANDITEM],
+static
+struct random_item_data blue_box[MAX_RANDITEM],
violet_box[MAX_RANDITEM], card_album[MAX_RANDITEM],
gift_box[MAX_RANDITEM], scroll[MAX_RANDITEM];
-static int blue_box_count = 0, violet_box_count = 0, card_album_count =
+static
+int blue_box_count = 0, violet_box_count = 0, card_album_count =
0, gift_box_count = 0, scroll_count = 0;
-static int blue_box_default = 0, violet_box_default = 0, card_album_default =
+static
+int blue_box_default = 0, violet_box_default = 0, card_album_default =
0, gift_box_default = 0, scroll_default = 0;
// Function declarations
-static void itemdb_read(void);
-static int itemdb_readdb(void);
-static int itemdb_read_randomitem(void);
-static int itemdb_read_itemavail(void);
-static int itemdb_read_itemnametable(void);
-static int itemdb_read_noequip(void);
+static
+void itemdb_read(void);
+static
+int itemdb_readdb(void);
+static
+int itemdb_read_randomitem(void);
+static
+int itemdb_read_itemavail(void);
+static
+int itemdb_read_itemnametable(void);
+static
+int itemdb_read_noequip(void);
/*==========================================
* 名前で検索用
@@ -49,42 +56,21 @@ static int itemdb_read_noequip(void);
*/
// name = item alias, so we should find items aliases first. if not found then look for "jname" (full name)
static
-void itemdb_searchname_sub(db_key_t key, db_val_t data, va_list ap)
+void itemdb_searchname_sub(db_key_t, db_val_t data, const char *str, struct item_data **dst)
{
- struct item_data *item = (struct item_data *) data, **dst;
- char *str;
- str = va_arg(ap, char *);
- dst = va_arg(ap, struct item_data **);
-// if( strcasecmp(item->name,str)==0 || strcmp(item->jname,str)==0 ||
-// memcmp(item->name,str,24)==0 || memcmp(item->jname,str,24)==0 )
+ struct item_data *item = (struct item_data *) data;
if (strcasecmp(item->name, str) == 0) //by lupus
*dst = item;
}
/*==========================================
- * 名前で検索用
- *------------------------------------------
- */
-static
-int itemdb_searchjname_sub(void *key, void *data, va_list ap)
-{
- struct item_data *item = (struct item_data *) data, **dst;
- char *str;
- str = va_arg(ap, char *);
- dst = va_arg(ap, struct item_data **);
- if (strcasecmp(item->jname, str) == 0)
- *dst = item;
- return 0;
-}
-
-/*==========================================
* 名前で検索
*------------------------------------------
*/
struct item_data *itemdb_searchname(const char *str)
{
struct item_data *item = NULL;
- numdb_foreach(item_db, itemdb_searchname_sub, str, &item);
+ numdb_foreach(item_db, std::bind(itemdb_searchname_sub, ph::_1, ph::_2, str, &item));
return item;
}
@@ -257,7 +243,8 @@ int itemdb_isdropable(int nameid)
*
*------------------------------------------
*/
-static int itemdb_read_itemslottable(void)
+static
+int itemdb_read_itemslottable(void)
{
char *buf, *p;
size_t s;
@@ -289,7 +276,8 @@ static int itemdb_read_itemslottable(void)
* アイテムデータベースの読み込み
*------------------------------------------
*/
-static int itemdb_readdb(void)
+static
+int itemdb_readdb(void)
{
FILE *fp;
char line[1024];
@@ -396,7 +384,8 @@ static int itemdb_readdb(void)
* ランダムアイテム出現データの読み込み
*------------------------------------------
*/
-static int itemdb_read_randomitem(void)
+static
+int itemdb_read_randomitem(void)
{
FILE *fp;
char line[1024];
@@ -487,7 +476,8 @@ static int itemdb_read_randomitem(void)
* アイテム使用可能フラグのオーバーライド
*------------------------------------------
*/
-static int itemdb_read_itemavail(void)
+static
+int itemdb_read_itemavail(void)
{
FILE *fp;
char line[1024];
@@ -540,7 +530,8 @@ static int itemdb_read_itemavail(void)
* アイテムの名前テーブルを読み込む
*------------------------------------------
*/
-static int itemdb_read_itemnametable(void)
+static
+int itemdb_read_itemnametable(void)
{
char *buf, *p;
size_t s;
@@ -586,7 +577,8 @@ static int itemdb_read_itemnametable(void)
* カードイラストのリソース名前テーブルを読み込む
*------------------------------------------
*/
-static int itemdb_read_cardillustnametable(void)
+static
+int itemdb_read_cardillustnametable(void)
{
char *buf, *p;
size_t s;
@@ -624,7 +616,8 @@ static int itemdb_read_cardillustnametable(void)
* 装備制限ファイル読み出し
*------------------------------------------
*/
-static int itemdb_read_noequip(void)
+static
+int itemdb_read_noequip(void)
{
FILE *fp;
char line[1024];
@@ -671,7 +664,8 @@ static int itemdb_read_noequip(void)
*
*------------------------------------------
*/
-static void itemdb_final(db_key_t key, db_val_t data, va_list ap)
+static
+void itemdb_final(db_key_t, db_val_t data)
{
struct item_data *id;
@@ -710,8 +704,10 @@ void do_final_itemdb(void)
}
/*
-static FILE *dfp;
-static int itemdebug(void *key,void *data,va_list ap){
+static
+FILE *dfp;
+static
+int itemdebug(void *key,void *data,_va_list ap){
// struct item_data *id=(struct item_data *)data;
fprintf(dfp,"%6d", (int)key);
return 0;
@@ -728,7 +724,8 @@ void itemdebugtxt()
* Removed item_value_db, don't re-add
*------------------------------------
*/
-static void itemdb_read(void)
+static
+void itemdb_read(void)
{
itemdb_read_itemslottable();
itemdb_readdb();
diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp
index a132067..ffca4bd 100644
--- a/src/map/itemdb.hpp
+++ b/src/map/itemdb.hpp
@@ -1,4 +1,3 @@
-// $Id: itemdb.h,v 1.3 2004/09/25 05:32:18 MouseJstr Exp $
#ifndef ITEMDB_HPP
#define ITEMDB_HPP
@@ -80,4 +79,4 @@ void itemdb_reload(void);
void do_final_itemdb(void);
int do_init_itemdb(void);
-#endif
+#endif // ITEMDB_HPP
diff --git a/src/map/magic-expr-eval.hpp b/src/map/magic-expr-eval.hpp
index 09e6f66..f5ca6af 100644
--- a/src/map/magic-expr-eval.hpp
+++ b/src/map/magic-expr-eval.hpp
@@ -1,17 +1,18 @@
-#ifndef MAGIC_EXPR_EVAL
-#define MAGIC_EXPR_EVAL
+#ifndef MAGIC_EXPR_EVAL_HPP
+#define MAGIC_EXPR_EVAL_HPP
/* Helper definitions for dealing with functions and operations */
-static int heading_x[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
-static int heading_y[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
+static
+int heading_x[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
+static
+int heading_y[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
int magic_signature_check(const char *opname, const char *funname, const char *signature,
- int args_nr, val_t * args, int line, int column);
+ int args_nr, val_t *args, int line, int column);
-void
-magic_area_rect(int *m, int *x, int *y, int *width, int *height,
- area_t * area);
+void magic_area_rect(int *m, int *x, int *y, int *width, int *height,
+ area_t *area);
#define ARGINT(x) args[x].v.v_int
#define ARGDIR(x) args[x].v.v_int
@@ -40,4 +41,4 @@ magic_area_rect(int *m, int *x, int *y, int *width, int *height,
#define ARG_MAY_BE_AREA(x) (TY(x) == TY_AREA || TY(x) == TY_LOCATION)
-#endif /* !defined(MAGIC_EXPR_EVAL) */
+#endif // MAGIC_EXPR_EVAL_HPP
diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp
index a53f939..ef1ddb1 100644
--- a/src/map/magic-expr.cpp
+++ b/src/map/magic-expr.cpp
@@ -1,10 +1,12 @@
#include "magic-expr.hpp"
-#include "magic-expr-eval.hpp"
-#include "itemdb.hpp"
-#include <math.h>
+
+#include <cmath>
#include "../common/mt_rand.hpp"
+#include "itemdb.hpp"
+#include "magic-expr-eval.hpp"
+
#define IS_SOLID(c) ((c) == 1 || (c) == 5)
int map_is_solid(int m, int x, int y)
@@ -14,7 +16,8 @@ int map_is_solid(int m, int x, int y)
#undef IS_SOLID
-static void free_area(area_t * area)
+static
+void free_area(area_t *area)
{
if (!area)
return;
@@ -32,7 +35,8 @@ static void free_area(area_t * area)
free(area);
}
-static area_t *dup_area(area_t * area)
+static
+area_t *dup_area(area_t *area)
{
area_t *retval = (area_t *)malloc(sizeof(area_t));
*retval = *area;
@@ -50,7 +54,7 @@ static area_t *dup_area(area_t * area)
return retval;
}
-void magic_copy_var(val_t * dest, val_t * src)
+void magic_copy_var(val_t *dest, val_t *src)
{
*dest = *src;
@@ -68,7 +72,7 @@ void magic_copy_var(val_t * dest, val_t * src)
}
-void magic_clear_var(val_t * v)
+void magic_clear_var(val_t *v)
{
switch (v->ty)
{
@@ -84,7 +88,7 @@ void magic_clear_var(val_t * v)
}
static
-const char *show_entity(entity_t * entity)
+const char *show_entity(entity_t *entity)
{
switch (entity->type)
{
@@ -108,7 +112,8 @@ const char *show_entity(entity_t * entity)
}
}
-static void stringify(val_t * v, int within_op)
+static
+void stringify(val_t *v, int within_op)
{
static const char *dirs[8] =
{ "south", "south-west", "west", "north-west", "north", "north-east",
@@ -171,7 +176,8 @@ static void stringify(val_t * v, int within_op)
v->ty = TY_STRING;
}
-static void intify(val_t * v)
+static
+void intify(val_t *v)
{
if (v->ty == TY_INT)
return;
@@ -191,7 +197,7 @@ area_t *area_new(int ty)
}
static
-area_t *area_union(area_t * area, area_t * other_area)
+area_t *area_union(area_t *area, area_t *other_area)
{
area_t *retval = area_new(AREA_UNION);
retval->a.a_union[0] = area;
@@ -203,7 +209,8 @@ area_t *area_union(area_t * area, area_t * other_area)
/**
* Turns location into area, leaves other types untouched
*/
-static void make_area(val_t * v)
+static
+void make_area(val_t *v)
{
if (v->ty == TY_LOCATION)
{
@@ -215,7 +222,8 @@ static void make_area(val_t * v)
}
}
-static void make_location(val_t * v)
+static
+void make_location(val_t *v)
{
if (v->ty == TY_AREA && v->v.v_area->ty == AREA_LOCATION)
{
@@ -226,7 +234,8 @@ static void make_location(val_t * v)
}
}
-static void make_spell(val_t * v)
+static
+void make_spell(val_t *v)
{
if (v->ty == TY_INVOCATION)
{
@@ -241,7 +250,8 @@ static void make_spell(val_t * v)
}
}
-static int fun_add(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_add(env_t *, int, val_t *result, val_t *args)
{
if (TY(0) == TY_INT && TY(1) == TY_INT)
{
@@ -274,19 +284,22 @@ static int fun_add(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int fun_sub(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_sub(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = ARGINT(0) - ARGINT(1);
return 0;
}
-static int fun_mul(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_mul(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = ARGINT(0) * ARGINT(1);
return 0;
}
-static int fun_div(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_div(env_t *, int, val_t *result, val_t *args)
{
if (!ARGINT(1))
return 1; /* division by zero */
@@ -294,7 +307,8 @@ static int fun_div(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int fun_mod(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_mod(env_t *, int, val_t *result, val_t *args)
{
if (!ARGINT(1))
return 1; /* division by zero */
@@ -302,31 +316,36 @@ static int fun_mod(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int fun_or(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_or(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = ARGINT(0) || ARGINT(1);
return 0;
}
-static int fun_and(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_and(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = ARGINT(0) && ARGINT(1);
return 0;
}
-static int fun_not(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_not(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = !ARGINT(0);
return 0;
}
-static int fun_neg(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_neg(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = ~ARGINT(0);
return 0;
}
-static int fun_gte(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_gte(env_t *, int, val_t *result, val_t *args)
{
if (TY(0) == TY_STRING || TY(1) == TY_STRING)
{
@@ -343,7 +362,8 @@ static int fun_gte(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int fun_gt(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_gt(env_t *, int, val_t *result, val_t *args)
{
if (TY(0) == TY_STRING || TY(1) == TY_STRING)
{
@@ -360,7 +380,8 @@ static int fun_gt(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int fun_eq(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_eq(env_t *, int, val_t *result, val_t *args)
{
if (TY(0) == TY_STRING || TY(1) == TY_STRING)
{
@@ -391,50 +412,57 @@ static int fun_eq(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int fun_bitand(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_bitand(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = ARGINT(0) & ARGINT(1);
return 0;
}
-static int fun_bitor(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_bitor(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = ARGINT(0) | ARGINT(1);
return 0;
}
-static int fun_bitxor(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_bitxor(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = ARGINT(0) ^ ARGINT(1);
return 0;
}
-static int fun_bitshl(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_bitshl(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = ARGINT(0) << ARGINT(1);
return 0;
}
-static int fun_bitshr(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_bitshr(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = ARGINT(0) >> ARGINT(1);
return 0;
}
-static int fun_max(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_max(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = MAX(ARGINT(0), ARGINT(1));
return 0;
}
-static int fun_min(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_min(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = MIN(ARGINT(0), ARGINT(1));
return 0;
}
-static int
-fun_if_then_else(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_if_then_else(env_t *, int, val_t *result, val_t *args)
{
if (ARGINT(0))
magic_copy_var(result, &args[1]);
@@ -443,9 +471,8 @@ fun_if_then_else(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-void
-magic_area_rect(int *m, int *x, int *y, int *width, int *height,
- area_t * area)
+void magic_area_rect(int *m, int *x, int *y, int *width, int *height,
+ area_t *area)
{
switch (area->ty)
{
@@ -518,7 +545,7 @@ magic_area_rect(int *m, int *x, int *y, int *width, int *height,
}
}
-int magic_location_in_area(int m, int x, int y, area_t * area)
+int magic_location_in_area(int m, int x, int y, area_t *area)
{
switch (area->ty)
{
@@ -542,7 +569,8 @@ int magic_location_in_area(int m, int x, int y, area_t * area)
}
}
-static int fun_is_in(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_is_in(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = magic_location_in_area(ARGLOCATION(0).m,
ARGLOCATION(0).x,
@@ -550,7 +578,8 @@ static int fun_is_in(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int fun_skill(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_skill(env_t *, int, val_t *result, val_t *args)
{
if (ETY(0) != BL_PC
// don't convert to enum until after the range check
@@ -563,14 +592,20 @@ static int fun_skill(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int
-fun_has_shroud(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_has_shroud(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = (ETY(0) == BL_PC && ARGPC(0)->state.shroud_active);
return 0;
}
-#define BATTLE_GETTER(name) static int fun_get_##name(env_t *env, int args_nr, val_t *result, val_t *args) { RESULTINT = battle_get_##name(ARGENTITY(0)); return 0; }
+#define BATTLE_GETTER(name) \
+static \
+int fun_get_##name(env_t *, int, val_t *result, val_t *args) \
+{ \
+ RESULTINT = battle_get_##name(ARGENTITY(0)); \
+ return 0; \
+}
BATTLE_GETTER(str);
BATTLE_GETTER(agi);
@@ -585,18 +620,22 @@ BATTLE_GETTER(def);
BATTLE_GETTER(max_hp);
BATTLE_GETTER(dir);
-#define MMO_GETTER(name) static int fun_get_##name(env_t *env, int args_nr, val_t *result, val_t *args) { \
- if (ETY(0) == BL_PC) \
- RESULTINT = ARGPC(0)->status.name; \
- else \
- RESULTINT = 0; \
- return 0; }
+#define MMO_GETTER(name) \
+static \
+int fun_get_##name(env_t *, int, val_t *result, val_t *args) \
+{ \
+ if (ETY(0) == BL_PC) \
+ RESULTINT = ARGPC(0)->status.name; \
+ else \
+ RESULTINT = 0; \
+ return 0; \
+}
MMO_GETTER(sp);
MMO_GETTER(max_sp);
-static int
-fun_name_of(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_name_of(env_t *, int, val_t *result, val_t *args)
{
if (TY(0) == TY_ENTITY)
{
@@ -617,8 +656,8 @@ fun_name_of(env_t * env, int args_nr, val_t * result, val_t * args)
}
/* [Freeyorp] I'm putting this one in as name_of seems to have issues with summoned or spawned mobs. */
-static int
-fun_mob_id(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_mob_id(env_t *, int, val_t *result, val_t *args)
{
if (ETY(0) != BL_MOB) return 1;
RESULTINT = ((struct mob_data *)(ARGENTITY(0)))->mob_class;
@@ -627,14 +666,15 @@ fun_mob_id(env_t * env, int args_nr, val_t * result, val_t * args)
#define COPY_LOCATION(dest, src) (dest).x = (src).x;(dest).y = (src).y;(dest).m = (src).m;
-static int
-fun_location(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_location(env_t *, int, val_t *result, val_t *args)
{
COPY_LOCATION(RESULTLOCATION, *(ARGENTITY(0)));
return 0;
}
-static int fun_random(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_random(env_t *, int, val_t *result, val_t *args)
{
int delta = ARGINT(0);
if (delta < 0)
@@ -651,8 +691,8 @@ static int fun_random(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int
-fun_random_dir(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_random_dir(env_t *, int, val_t *result, val_t *args)
{
if (ARGINT(0))
RESULTDIR = mt_random() & 0x7;
@@ -661,15 +701,15 @@ fun_random_dir(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int
-fun_hash_entity(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_hash_entity(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = ARGENTITY(0)->id;
return 0;
}
int // ret -1: not a string, ret 1: no such item, ret 0: OK
-magic_find_item(val_t * args, int index, struct item *item, int *stackable)
+magic_find_item(val_t *args, int index, struct item *item, int *stackable)
{
struct item_data *item_data;
int must_add_sequentially;
@@ -696,8 +736,8 @@ magic_find_item(val_t * args, int index, struct item *item, int *stackable)
return 0;
}
-static int
-fun_count_item(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_count_item(env_t *, int, val_t *result, val_t *args)
{
character_t *chr = (ETY(0) == BL_PC) ? ARGPC(0) : NULL;
int stackable;
@@ -712,8 +752,8 @@ fun_count_item(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int
-fun_is_equipped(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_is_equipped(env_t *, int, val_t *result, val_t *args)
{
character_t *chr = (ETY(0) == BL_PC) ? ARGPC(0) : NULL;
int stackable;
@@ -739,28 +779,29 @@ fun_is_equipped(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int
-fun_is_married(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_is_married(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = (ETY(0) == BL_PC && ARGPC(0)->status.partner_id);
return 0;
}
-static int
-fun_is_dead(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_is_dead(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = (ETY(0) == BL_PC && pc_isdead(ARGPC(0)));
return 0;
}
-static int fun_is_pc(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_is_pc(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = (ETY(0) == BL_PC);
return 0;
}
-static int
-fun_partner(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_partner(env_t *, int, val_t *result, val_t *args)
{
if (ETY(0) == BL_PC && ARGPC(0)->status.partner_id)
{
@@ -773,8 +814,8 @@ fun_partner(env_t * env, int args_nr, val_t * result, val_t * args)
return 1;
}
-static int
-fun_awayfrom(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_awayfrom(env_t *, int, val_t *result, val_t *args)
{
location_t *loc = &ARGLOCATION(0);
int dx = heading_x[ARGDIR(1)];
@@ -790,26 +831,29 @@ fun_awayfrom(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int fun_failed(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_failed(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = TY(0) == TY_FAIL;
return 0;
}
-static int fun_npc(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_npc(env_t *, int, val_t *result, val_t *args)
{
RESULTENTITY = (entity_t *) npc_name2id(ARGSTR(0));
return RESULTENTITY == NULL;
}
-static int fun_pc(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_pc(env_t *, int, val_t *result, val_t *args)
{
RESULTENTITY = (entity_t *) map_nick2sd(ARGSTR(0));
return RESULTENTITY == NULL;
}
-static int
-fun_distance(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_distance(env_t *, int, val_t *result, val_t *args)
{
if (ARGLOCATION(0).m != ARGLOCATION(1).m)
RESULTINT = INT_MAX;
@@ -819,8 +863,8 @@ fun_distance(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int
-fun_rdistance(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_rdistance(env_t *, int, val_t *result, val_t *args)
{
if (ARGLOCATION(0).m != ARGLOCATION(1).m)
RESULTINT = INT_MAX;
@@ -833,7 +877,8 @@ fun_rdistance(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int fun_anchor(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_anchor(env_t *env, int, val_t *result, val_t *args)
{
teleport_anchor_t *anchor = magic_find_anchor(ARGSTR(0));
@@ -852,8 +897,8 @@ static int fun_anchor(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int
-fun_line_of_sight(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_line_of_sight(env_t *, int, val_t *result, val_t *args)
{
entity_t e1, e2;
@@ -865,7 +910,7 @@ fun_line_of_sight(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-void magic_random_location(location_t * dest, area_t * area)
+void magic_random_location(location_t *dest, area_t *area)
{
switch (area->ty)
{
@@ -933,15 +978,15 @@ void magic_random_location(location_t * dest, area_t * area)
}
}
-static int
-fun_pick_location(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_pick_location(env_t *, int, val_t *result, val_t *args)
{
magic_random_location(&result->v.v_location, ARGAREA(0));
return 0;
}
-static int
-fun_read_script_int(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_read_script_int(env_t *, int, val_t *result, val_t *args)
{
entity_t *subject_p = ARGENTITY(0);
char *var_name = ARGSTR(1);
@@ -953,7 +998,8 @@ fun_read_script_int(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int fun_rbox(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_rbox(env_t *, int, val_t *result, val_t *args)
{
location_t loc = ARGLOCATION(0);
int radius = ARGINT(1);
@@ -968,9 +1014,9 @@ static int fun_rbox(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int
-fun_running_status_update(env_t * env, int args_nr, val_t * result,
- val_t * args)
+static
+int fun_running_status_update(env_t *, int, val_t *result,
+ val_t *args)
{
if (ETY(0) != BL_PC && ETY(0) != BL_MOB)
return 1;
@@ -980,8 +1026,8 @@ fun_running_status_update(env_t * env, int args_nr, val_t * result,
return 0;
}
-static int
-fun_status_option(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_status_option(env_t *, int, val_t *result, val_t *args)
{
RESULTINT =
((((struct map_session_data *) ARGENTITY(0))->
@@ -989,54 +1035,58 @@ fun_status_option(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int
-fun_element(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_element(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = battle_get_element(ARGENTITY(0)) % 10;
return 0;
}
-static int
-fun_element_level(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_element_level(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = battle_get_element(ARGENTITY(0)) / 10;
return 0;
}
-static int fun_index(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_index(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = ARGSPELL(0)->index;
return 0;
}
-static int
-fun_is_exterior(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_is_exterior(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = map[ARGLOCATION(0).m].name[4] == '1';
return 0;
}
-static int
-fun_contains_string(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_contains_string(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = NULL != strstr(ARGSTR(0), ARGSTR(1));
return 0;
}
-static int fun_strstr(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_strstr(env_t *, int, val_t *result, val_t *args)
{
char *offset = strstr(ARGSTR(0), ARGSTR(1));
RESULTINT = offset - ARGSTR(0);
return offset == NULL;
}
-static int fun_strlen(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_strlen(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = strlen(ARGSTR(0));
return 0;
}
-static int fun_substr(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_substr(env_t *, int, val_t *result, val_t *args)
{
const char *src = ARGSTR(0);
const int slen = strlen(src);
@@ -1060,20 +1110,22 @@ static int fun_substr(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int fun_sqrt(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_sqrt(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = (int) sqrt(ARGINT(0));
return 0;
}
-static int
-fun_map_level(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_map_level(env_t *, int, val_t *result, val_t *args)
{
RESULTINT = map[ARGLOCATION(0).m].name[4] - '0';
return 0;
}
-static int fun_map_nr(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_map_nr(env_t *, int, val_t *result, val_t *args)
{
const char *mapname = map[ARGLOCATION(0).m].name;
@@ -1082,8 +1134,8 @@ static int fun_map_nr(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int
-fun_dir_towards(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_dir_towards(env_t *, int, val_t *result, val_t *args)
{
int dx;
int dy;
@@ -1148,8 +1200,8 @@ fun_dir_towards(env_t * env, int args_nr, val_t * result, val_t * args)
return 0;
}
-static int
-fun_extract_healer_xp(env_t * env, int args_nr, val_t * result, val_t * args)
+static
+int fun_extract_healer_xp(env_t *, int, val_t *result, val_t *args)
{
character_t *sd = (ETY(0) == BL_PC) ? ARGPC(0) : NULL;
@@ -1162,7 +1214,8 @@ fun_extract_healer_xp(env_t * env, int args_nr, val_t * result, val_t * args)
#define BATTLE_RECORD2(sname, name) { sname, "e", 'i', fun_get_##name }
#define BATTLE_RECORD(name) BATTLE_RECORD2(#name, name)
-static fun_t functions[] = {
+static
+fun_t functions[] = {
{"+", "..", '.', fun_add},
{"-", "ii", 'i', fun_sub},
{"*", "ii", 'i', fun_mul},
@@ -1241,7 +1294,8 @@ static fun_t functions[] = {
{NULL, NULL, '.', NULL}
};
-static int functions_are_sorted = 0;
+static
+int functions_are_sorted = 0;
static
int compare_fun(const void *lhs, const void *rhs)
@@ -1251,7 +1305,8 @@ int compare_fun(const void *lhs, const void *rhs)
fun_t *magic_get_fun(const char *name, int *index)
{
- static int functions_nr;
+ static
+int functions_nr;
fun_t *result;
fun_t key;
@@ -1277,8 +1332,9 @@ fun_t *magic_get_fun(const char *name, int *index)
return result;
}
-static int // 1 on failure
-eval_location(env_t * env, location_t * dest, e_location_t * expr)
+static
+int // 1 on failure
+eval_location(env_t *env, location_t *dest, e_location_t *expr)
{
val_t m, x, y;
magic_eval(env, &m, expr->m);
@@ -1306,7 +1362,8 @@ eval_location(env_t * env, location_t * dest, e_location_t * expr)
}
}
-static area_t *eval_area(env_t * env, e_area_t * expr)
+static
+area_t *eval_area(env_t *env, e_area_t *expr)
{
area_t *area = (area_t *)malloc(sizeof(area_t));
area->ty = expr->ty;
@@ -1417,7 +1474,8 @@ static area_t *eval_area(env_t * env, e_area_t * expr)
}
}
-static int type_key(char ty_key)
+static
+int type_key(char ty_key)
{
switch (ty_key)
{
@@ -1443,7 +1501,7 @@ static int type_key(char ty_key)
}
int magic_signature_check(const char *opname, const char *funname, const char *signature,
- int args_nr, val_t * args, int line, int column)
+ int args_nr, val_t *args, int line, int column)
{
int i;
for (i = 0; i < args_nr; i++)
@@ -1527,7 +1585,7 @@ int magic_signature_check(const char *opname, const char *funname, const char *s
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
-void magic_eval(env_t * env, val_t * dest, expr_t * expr)
+void magic_eval(env_t *env, val_t *dest, expr_t *expr)
{
#ifdef RECENT_GCC
#pragma GCC diagnostic pop
@@ -1640,7 +1698,7 @@ void magic_eval(env_t * env, val_t * dest, expr_t * expr)
#pragma GCC diagnostic pop
#endif
-int magic_eval_int(env_t * env, expr_t * expr)
+int magic_eval_int(env_t *env, expr_t *expr)
{
val_t result;
magic_eval(env, &result, expr);
@@ -1653,7 +1711,7 @@ int magic_eval_int(env_t * env, expr_t * expr)
return result.v.v_int;
}
-char *magic_eval_str(env_t * env, expr_t * expr)
+char *magic_eval_str(env_t *env, expr_t *expr)
{
val_t result;
magic_eval(env, &result, expr);
diff --git a/src/map/magic-expr.hpp b/src/map/magic-expr.hpp
index bd38ea4..2e9c5ec 100644
--- a/src/map/magic-expr.hpp
+++ b/src/map/magic-expr.hpp
@@ -1,5 +1,6 @@
#ifndef MAGIC_EXPR_HPP
#define MAGIC_EXPR_HPP
+
#include "magic-interpreter.hpp"
#include "magic-interpreter-aux.hpp"
@@ -32,14 +33,14 @@ typedef struct fun
const char *name;
const char *signature;
char ret_ty;
- int(*fun)(env_t * env, int args_nr, val_t * result, val_t * args);
+ int(*fun)(env_t *env, int args_nr, val_t *result, val_t *args);
} fun_t;
typedef struct op
{
const char *name;
const char *signature;
- int(*op)(env_t * env, int args_nr, val_t * args);
+ int(*op)(env_t *env, int args_nr, val_t *args);
} op_t;
/**
@@ -59,37 +60,37 @@ op_t *magic_get_op(char *name, int *index);
/**
* Evaluates an expression and stores the result in `dest'
*/
-void magic_eval(env_t * env, val_t * dest, expr_t * expr);
+void magic_eval(env_t *env, val_t *dest, expr_t *expr);
/**
* Evaluates an expression and coerces the result into an integer
*/
-int magic_eval_int(env_t * env, expr_t * expr);
+int magic_eval_int(env_t *env, expr_t *expr);
/**
* Evaluates an expression and coerces the result into a string
*/
-char *magic_eval_str(env_t * env, expr_t * expr);
+char *magic_eval_str(env_t *env, expr_t *expr);
int map_is_solid(int m, int x, int y);
expr_t *magic_new_expr(int ty);
-void magic_clear_var(val_t * v);
+void magic_clear_var(val_t *v);
-void magic_copy_var(val_t * dest, val_t * src);
+void magic_copy_var(val_t *dest, val_t *src);
-void magic_random_location(location_t * dest, area_t * area);
+void magic_random_location(location_t *dest, area_t *area);
int // ret -1: not a string, ret 1: no such item, ret 0: OK
- magic_find_item(val_t * args, int index, struct item *item, int *stackable);
+ magic_find_item(val_t *args, int index, struct item *item, int *stackable);
#define GET_ARG_ITEM(index, dest, stackable) switch (magic_find_item(args, index, &dest, &stackable)) { case -1 : return 1; case 1 : return 0; }
-int magic_location_in_area(int m, int x, int y, area_t * area);
+int magic_location_in_area(int m, int x, int y, area_t *area);
-#endif /* !defined(MAGIC_EXPR_H_) */
+#endif // MAGIC_EXPR_HPP
diff --git a/src/map/magic-interpreter-aux.hpp b/src/map/magic-interpreter-aux.hpp
index ea05b88..983d3d6 100644
--- a/src/map/magic-interpreter-aux.hpp
+++ b/src/map/magic-interpreter-aux.hpp
@@ -5,4 +5,4 @@
#define VAR(i) ((!env->vars || env->vars[i].ty == TY_UNDEF)? env->base_env->vars[i] : env->vars[i])
-#endif /* !defined(MAGIC_INTERPRETER_AUX_H_) */
+#endif // MAGIC_INTERPRETER_AUX_HPP
diff --git a/src/map/magic-interpreter-base.cpp b/src/map/magic-interpreter-base.cpp
index 94e0a18..229dadb 100644
--- a/src/map/magic-interpreter-base.cpp
+++ b/src/map/magic-interpreter-base.cpp
@@ -1,9 +1,10 @@
#include "magic.hpp"
-#include "magic-interpreter.hpp"
#include "magic-expr.hpp"
+#include "magic-interpreter.hpp"
#include "magic-interpreter-aux.hpp"
-static void set_int_p(val_t * v, int i, int t)
+static
+void set_int_p(val_t *v, int i, int t)
{
v->ty = t;
v->v.v_int = i;
@@ -14,21 +15,25 @@ static void set_int_p(val_t * v, int i, int t)
#define SETTER(tty, dyn_ty, field) (val_t *v, tty x) { v->ty = dyn_ty; v->v.field = x; }
-static void set_string SETTER(char *, TY_STRING, v_string);
+static
+void set_string SETTER(char *, TY_STRING, v_string);
-static void set_entity(val_t * v, entity_t * e)
+static
+void set_entity(val_t *v, entity_t *e)
{
v->ty = TY_ENTITY;
v->v.v_int = e->id;
}
-static void set_invocation(val_t * v, invocation_t * i)
+static
+void set_invocation(val_t *v, invocation_t *i)
{
v->ty = TY_INVOCATION;
v->v.v_int = i->bl.id;
}
-static void set_spell SETTER(spell_t *, TY_SPELL, v_spell);
+static
+void set_spell SETTER(spell_t *, TY_SPELL, v_spell);
#define setenv(f, v, x) f(&(env->vars[v]), x)
@@ -44,7 +49,8 @@ static void set_spell SETTER(spell_t *, TY_SPELL, v_spell);
magic_conf_t magic_conf; /* Global magic conf */
env_t magic_default_env = { &magic_conf, NULL };
-static int spells_sorted = 0;
+static
+int spells_sorted = 0;
const char *magic_find_invocation(const char *spellname)
{
@@ -57,7 +63,8 @@ const char *magic_find_invocation(const char *spellname)
return NULL;
}
-static int spell_compare(const void *lhs, const void *rhs)
+static
+int spell_compare(const void *lhs, const void *rhs)
{
return strcmp((*((spell_t **) lhs))->invocation,
(*((spell_t **) rhs))->invocation);
@@ -93,7 +100,8 @@ spell_t *magic_find_spell(char *invocation)
/* Spell anchors */
/* -------------------------------------------------------------------------------- */
-static int compare_teleport_anchor(const void *lhs, const void *rhs)
+static
+int compare_teleport_anchor(const void *lhs, const void *rhs)
{
return strcmp((*((teleport_anchor_t **) lhs))->invocation,
(*((teleport_anchor_t **) rhs))->invocation);
@@ -141,7 +149,8 @@ teleport_anchor_t *magic_find_anchor(char *name)
/* Spell guard checks */
/* -------------------------------------------------------------------------------- */
-static env_t *alloc_env(magic_conf_t * conf)
+static
+env_t *alloc_env(magic_conf_t *conf)
{
env_t *env;
CREATE(env, env_t, 1);
@@ -150,7 +159,8 @@ static env_t *alloc_env(magic_conf_t * conf)
return env;
}
-static env_t *clone_env(env_t * src)
+static
+env_t *clone_env(env_t *src)
{
env_t *retval = alloc_env(src->base_env);
int i;
@@ -161,7 +171,7 @@ static env_t *clone_env(env_t * src)
return retval;
}
-void magic_free_env(env_t * env)
+void magic_free_env(env_t *env)
{
int i;
for (i = 0; i < env->base_env->vars_nr; i++)
@@ -169,8 +179,8 @@ void magic_free_env(env_t * env)
free(env);
}
-env_t *spell_create_env(magic_conf_t * conf, spell_t * spell,
- character_t * caster, int spellpower, char *param)
+env_t *spell_create_env(magic_conf_t *conf, spell_t *spell,
+ character_t *caster, int spellpower, char *param)
{
env_t *env = alloc_env(conf);
@@ -208,7 +218,8 @@ env_t *spell_create_env(magic_conf_t * conf, spell_t * spell,
return env;
}
-static void free_components(component_t ** component_holder)
+static
+void free_components(component_t ** component_holder)
{
if (*component_holder == NULL)
return;
@@ -245,8 +256,8 @@ void magic_add_component(component_t ** component_holder, int id, int count)
}
}
-static void
-copy_components(component_t ** component_holder, component_t * component)
+static
+void copy_components(component_t ** component_holder, component_t *component)
{
if (component == NULL)
return;
@@ -262,7 +273,8 @@ typedef struct spellguard_check
int mana, casttime;
} spellguard_check_t;
-static int check_prerequisites(character_t * caster, component_t * component)
+static
+int check_prerequisites(character_t *caster, component_t *component)
{
while (component)
{
@@ -276,7 +288,8 @@ static int check_prerequisites(character_t * caster, component_t * component)
return 1;
}
-static void consume_components(character_t * caster, component_t * component)
+static
+void consume_components(character_t *caster, component_t *component)
{
while (component)
{
@@ -285,9 +298,9 @@ static void consume_components(character_t * caster, component_t * component)
}
}
-static int
-spellguard_can_satisfy(spellguard_check_t * check, character_t * caster,
- env_t * env, int *near_miss)
+static
+int spellguard_can_satisfy(spellguard_check_t *check, character_t *caster,
+ env_t *env, int *near_miss)
{
unsigned int tick = gettick();
@@ -326,9 +339,10 @@ spellguard_can_satisfy(spellguard_check_t * check, character_t * caster,
return retval;
}
-static effect_set_t *spellguard_check_sub(spellguard_check_t * check,
- spellguard_t * guard,
- character_t * caster, env_t * env,
+static
+effect_set_t *spellguard_check_sub(spellguard_check_t *check,
+ spellguard_t *guard,
+ character_t *caster, env_t *env,
int *near_miss)
{
if (guard == NULL)
@@ -394,8 +408,9 @@ static effect_set_t *spellguard_check_sub(spellguard_check_t * check,
return spellguard_check_sub(check, guard->next, caster, env, near_miss);
}
-static effect_set_t *check_spellguard(spellguard_t * guard,
- character_t * caster, env_t * env,
+static
+effect_set_t *check_spellguard(spellguard_t *guard,
+ character_t *caster, env_t *env,
int *near_miss)
{
spellguard_check_t check;
@@ -416,8 +431,8 @@ static effect_set_t *check_spellguard(spellguard_t * guard,
/* Public API */
/* -------------------------------------------------------------------------------- */
-effect_set_t *spell_trigger(spell_t * spell, character_t * caster,
- env_t * env, int *near_miss)
+effect_set_t *spell_trigger(spell_t *spell, character_t *caster,
+ env_t *env, int *near_miss)
{
int i;
spellguard_t *guard = spell->spellguard;
@@ -432,7 +447,8 @@ effect_set_t *spell_trigger(spell_t * spell, character_t * caster,
return check_spellguard(guard, caster, env, near_miss);
}
-static void spell_set_location(invocation_t * invocation, entity_t * entity)
+static
+void spell_set_location(invocation_t *invocation, entity_t *entity)
{
magic_clear_var(&invocation->env->vars[VAR_LOCATION]);
invocation->env->vars[VAR_LOCATION].ty = TY_LOCATION;
@@ -441,7 +457,7 @@ static void spell_set_location(invocation_t * invocation, entity_t * entity)
invocation->env->vars[VAR_LOCATION].v.v_location.y = entity->y;
}
-void spell_update_location(invocation_t * invocation)
+void spell_update_location(invocation_t *invocation)
{
if (invocation->spell->flags & SPELL_FLAG_LOCAL)
return;
@@ -455,7 +471,7 @@ void spell_update_location(invocation_t * invocation)
}
}
-invocation_t *spell_instantiate(effect_set_t * effect_set, env_t * env)
+invocation_t *spell_instantiate(effect_set_t *effect_set, env_t *env)
{
invocation_t *retval;
CREATE(retval, invocation_t, 1);
@@ -483,7 +499,7 @@ invocation_t *spell_instantiate(effect_set_t * effect_set, env_t * env)
return retval;
}
-invocation_t *spell_clone_effect(invocation_t * base)
+invocation_t *spell_clone_effect(invocation_t *base)
{
invocation_t *retval = (invocation_t *) malloc(sizeof(invocation_t));
env_t *env;
@@ -513,7 +529,7 @@ invocation_t *spell_clone_effect(invocation_t * base)
return retval;
}
-void spell_bind(character_t * subject, invocation_t * invocation)
+void spell_bind(character_t *subject, invocation_t *invocation)
{
/* Only bind nonlocal spells */
@@ -539,7 +555,7 @@ void spell_bind(character_t * subject, invocation_t * invocation)
spell_set_location(invocation, (entity_t *) subject);
}
-int spell_unbind(character_t * subject, invocation_t * invocation)
+int spell_unbind(character_t *subject, invocation_t *invocation)
{
invocation_t **seeker = &subject->active_spells;
diff --git a/src/map/magic-interpreter-lexer.lpp b/src/map/magic-interpreter-lexer.lpp
index 632dbab..0ae6494 100644
--- a/src/map/magic-interpreter-lexer.lpp
+++ b/src/map/magic-interpreter-lexer.lpp
@@ -10,6 +10,8 @@
#define HEADING(dir) { magic_frontend_lval.i = dir; FIXLOC; return DIR; }
+// silence compiler warnings
+#define YY_USER_INIT (void)yylval, (void)yylloc
%}
%option yylineno
@@ -133,7 +135,7 @@
"#".*$ /* Ignore comments */
"//".*$ /* Ignore comments */
-[ \n\t\r] /* ignore whitespace */
+[ \n\t\r] /* ignore whitespace */
. fprintf(stderr, "%s: Unexpected character in line %d\n", MAGIC_CONFIG_FILE, magic_frontend_lineno);
diff --git a/src/map/magic-interpreter-parser.ypp b/src/map/magic-interpreter-parser.ypp
index 274819c..09dc67e 100644
--- a/src/map/magic-interpreter-parser.ypp
+++ b/src/map/magic-interpreter-parser.ypp
@@ -2,70 +2,72 @@
#include "magic-expr.hpp"
}
%code{
+#include <cstdarg> // exception to "no va_list" rule
+
#include "magic-interpreter-parser.hpp"
#include "magic-interpreter.hpp"
-#include <stdarg.h>
#define YYLEX_PARAM 0, 0
-static int
-intern_id(const char *id_name);
+static
+int intern_id(const char *id_name);
-static expr_t *
-fun_expr(const char *name, int args_nr, expr_t **args, int line, int column);
+static
+expr_t *fun_expr(const char *name, int args_nr, expr_t **args, int line, int column);
-static expr_t *
-dot_expr(expr_t *lhs, int id);
+static
+expr_t *dot_expr(expr_t *lhs, int id);
#define BIN_EXPR(x, name, arg1, arg2, line, column) { expr_t *e[2]; e[0] = arg1; e[1] = arg2; x = fun_expr(name, 2, e, line, column); }
-static int failed_flag = 0;
+static
+int failed_flag = 0;
-static void
-magic_frontend_error(const char *msg);
+static
+void magic_frontend_error(const char *msg);
-static void
-fail(int line, int column, const char *fmt, ...);
+static
+void fail(int line, int column, const char *fmt, ...);
-static spell_t *
-new_spell(spellguard_t *guard);
+static
+spell_t *new_spell(spellguard_t *guard);
-static spellguard_t *
-spellguard_implication(spellguard_t *a, spellguard_t *b);
+static
+spellguard_t *spellguard_implication(spellguard_t *a, spellguard_t *b);
-static spellguard_t *
-new_spellguard(int ty);
+static
+spellguard_t *new_spellguard(int ty);
-static effect_t *
-new_effect(int ty);
+static
+effect_t *new_effect(int ty);
-static effect_t *
-set_effect_continuation(effect_t *src, effect_t *continuation);
+static
+effect_t *set_effect_continuation(effect_t *src, effect_t *continuation);
-static void
-add_spell(spell_t *spell, int line_nr);
+static
+void add_spell(spell_t *spell, int line_nr);
-static void
-add_teleport_anchor(teleport_anchor_t *anchor, int line_nr);
+static
+void add_teleport_anchor(teleport_anchor_t *anchor, int line_nr);
-static effect_t *
-op_effect(char *name, int args_nr, expr_t **args, int line, int column);
+static
+effect_t *op_effect(char *name, int args_nr, expr_t **args, int line, int column);
int magic_frontend_lex(YYSTYPE *, YYLTYPE *);
-static void
-install_proc(proc_t *proc);
+static
+void install_proc(proc_t *proc);
-static effect_t *
-call_proc(char *name, int args_nr, expr_t **args, int line_nr, int column);
+static
+effect_t *call_proc(char *name, int args_nr, expr_t **args, int line_nr, int column);
-static void
-bind_constant(char *name, val_t *val, int line_nr);
+static
+void bind_constant(char *name, val_t *val, int line_nr);
-static val_t *
-find_constant(char *name);
+static
+val_t *find_constant(char *name);
}
@@ -703,8 +705,8 @@ effect_list : /* empty */
/* We do incremental realloc here to store our results. Since this happens only once
* during startup for a relatively manageable set of configs, it should be fine. */
-static int
-intern_id(const char *id_name)
+static
+int intern_id(const char *id_name)
{
int i;
@@ -724,8 +726,8 @@ intern_id(const char *id_name)
return i;
}
-static void
-add_spell(spell_t *spell, int line_nr)
+static
+void add_spell(spell_t *spell, int line_nr)
{
int index = magic_conf.spells_nr;
int i;
@@ -749,8 +751,8 @@ add_spell(spell_t *spell, int line_nr)
}
-static void
-add_teleport_anchor(teleport_anchor_t *anchor, int line_nr)
+static
+void add_teleport_anchor(teleport_anchor_t *anchor, int line_nr)
{
int index = magic_conf.anchors_nr;
int i;
@@ -783,8 +785,8 @@ void fail(int line, int column, const char *fmt, ...)
failed_flag = 1;
}
-static expr_t *
-dot_expr(expr_t *expr, int id)
+static
+expr_t *dot_expr(expr_t *expr, int id)
{
expr_t *retval = magic_new_expr(EXPR_SPELLFIELD);
retval->e.e_field.id = id;
@@ -793,8 +795,8 @@ dot_expr(expr_t *expr, int id)
return retval;
}
-static expr_t *
-fun_expr(const char *name, int args_nr, expr_t **args, int line, int column)
+static
+expr_t *fun_expr(const char *name, int args_nr, expr_t **args, int line, int column)
{
int id;
expr_t *expr;
@@ -826,8 +828,8 @@ fun_expr(const char *name, int args_nr, expr_t **args, int line, int column)
return expr;
}
-static spell_t *
-new_spell(spellguard_t *guard)
+static
+spell_t *new_spell(spellguard_t *guard)
{
static int spell_counter = 0;
@@ -837,16 +839,16 @@ new_spell(spellguard_t *guard)
return retval;
}
-static spellguard_t *
-new_spellguard(int ty)
+static
+spellguard_t *new_spellguard(int ty)
{
spellguard_t *retval = (spellguard_t *)calloc(1, sizeof(spellguard_t));
retval->ty = ty;
return retval;
}
-static spellguard_t *
-spellguard_implication(spellguard_t *a, spellguard_t *b)
+static
+spellguard_t *spellguard_implication(spellguard_t *a, spellguard_t *b)
{
spellguard_t *retval = a;
@@ -875,16 +877,16 @@ spellguard_implication(spellguard_t *a, spellguard_t *b)
return retval;
}
-static effect_t *
-new_effect(int ty)
+static
+effect_t *new_effect(int ty)
{
effect_t *effect = (effect_t *) calloc(1, sizeof(effect_t));
effect->ty = ty;
return effect;
}
-static effect_t *
-set_effect_continuation(effect_t *src, effect_t *continuation)
+static
+effect_t *set_effect_continuation(effect_t *src, effect_t *continuation)
{
effect_t *retval = src;
/* This function is completely analogous to `spellguard_implication' above; read the control flow implications above first before pondering it. */
@@ -906,8 +908,8 @@ set_effect_continuation(effect_t *src, effect_t *continuation)
return retval;
}
-static effect_t *
-op_effect(char *name, int args_nr, expr_t **args, int line, int column)
+static
+effect_t *op_effect(char *name, int args_nr, expr_t **args, int line, int column)
{
int id;
effect_t *effect;
@@ -942,8 +944,8 @@ proc_t *procs = NULL;
int procs_nr = 0;
// I think this is a memory leak, or undefined behavior
-static void
-install_proc(proc_t *proc)
+static
+void install_proc(proc_t *proc)
{
if (!procs) {
procs = proc;
@@ -954,8 +956,8 @@ install_proc(proc_t *proc)
}
}
-static effect_t *
-call_proc(char *name, int args_nr, expr_t **args, int line_nr, int column)
+static
+effect_t *call_proc(char *name, int args_nr, expr_t **args, int line_nr, int column)
{
proc_t *p = NULL;
int i;
@@ -992,8 +994,8 @@ struct const_def_rec {
int const_defs_nr = 0;
-static void
-bind_constant(char *name, val_t *val, int line_nr)
+static
+void bind_constant(char *name, val_t *val, int line_nr)
{
if (find_constant(name)) {
fail(line_nr, 0, "Redefinition of constant `%s'\n", name);
@@ -1011,8 +1013,8 @@ bind_constant(char *name, val_t *val, int line_nr)
++const_defs_nr;
}
-static val_t *
-find_constant(char *name)
+static
+val_t *find_constant(char *name)
{
int i;
for (i = 0; i < const_defs_nr; i++) {
@@ -1084,8 +1086,8 @@ int magic_init(const char *conffile)
extern int magic_frontend_lineno;
-static void
-magic_frontend_error(const char *msg)
+static
+void magic_frontend_error(const char *msg)
{
fprintf(stderr, "[magic-conf] Parse error: %s at line %d\n", msg, magic_frontend_lineno);
failed_flag = 1;
diff --git a/src/map/magic-interpreter.hpp b/src/map/magic-interpreter.hpp
index 2414a7a..664c818 100644
--- a/src/map/magic-interpreter.hpp
+++ b/src/map/magic-interpreter.hpp
@@ -1,14 +1,14 @@
-/* Magic interpreter */
-
#ifndef MAGIC_INTERPRETER_HPP
#define MAGIC_INTERPRETER_HPP
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include "../common/nullpo.hpp"
+#include "../common/socket.hpp"
+#include "../common/timer.hpp"
#include "battle.hpp"
#include "chat.hpp"
@@ -20,16 +20,13 @@
#include "map.hpp"
#include "mob.hpp"
#include "npc.hpp"
-#include "pc.hpp"
#include "party.hpp"
+#include "pc.hpp"
#include "script.hpp"
#include "skill.hpp"
#include "storage.hpp"
#include "trade.hpp"
-#include "../common/timer.hpp"
-#include "../common/socket.hpp"
-
#define SPELLARG_NONE 0 /* No spell parameter */
#define SPELLARG_PC 1 /* Spell parameter describes pc (defaults to self) */
#define SPELLARG_STRING 2 /* Spell parameter describes pc (defaults to self) */
@@ -454,31 +451,31 @@ teleport_anchor_t *magic_find_anchor(char *name);
/**
* The parameter `param' must have been dynamically allocated; ownership is transferred to the resultant env_t.
*/
-env_t *spell_create_env(magic_conf_t * conf, spell_t * spell,
- character_t * caster, int spellpower, char *param);
+env_t *spell_create_env(magic_conf_t *conf, spell_t *spell,
+ character_t *caster, int spellpower, char *param);
-void magic_free_env(env_t * env);
+void magic_free_env(env_t *env);
/**
* near_miss is set to nonzero iff the spell only failed due to ephemereal issues (spell delay in effect, out of mana, out of components)
*/
-effect_set_t *spell_trigger(spell_t * spell, character_t * caster,
- env_t * env, int *near_miss);
+effect_set_t *spell_trigger(spell_t *spell, character_t *caster,
+ env_t *env, int *near_miss);
-invocation_t *spell_instantiate(effect_set_t * effect, env_t * env);
+invocation_t *spell_instantiate(effect_set_t *effect, env_t *env);
/**
* Bind a spell to a subject (this is a no-op for `local' spells).
*/
-void spell_bind(character_t * subject, invocation_t * invocation);
+void spell_bind(character_t *subject, invocation_t *invocation);
int // 1 on failure
- spell_unbind(character_t * subject, invocation_t * invocation);
+ spell_unbind(character_t *subject, invocation_t *invocation);
/**
* Clones a spell to run the at_effect field
*/
-invocation_t *spell_clone_effect(invocation_t * source);
+invocation_t *spell_clone_effect(invocation_t *source);
spell_t *magic_find_spell(char *invocation);
@@ -499,6 +496,6 @@ typedef struct
// must be called after itemdb initialisation
int magic_init(const char *);
-void spell_update_location(invocation_t * invocation);
+void spell_update_location(invocation_t *invocation);
-#endif /* !defined (MAGIC_INTERPRETER_H) */
+#endif // MAGIC_INTERPRETER_HPP
diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp
index 859d2cd..19d6636 100644
--- a/src/map/magic-stmt.cpp
+++ b/src/map/magic-stmt.cpp
@@ -1,6 +1,6 @@
-#include "magic-interpreter.hpp"
#include "magic-expr.hpp"
#include "magic-expr-eval.hpp"
+#include "magic-interpreter.hpp"
#include "magic-interpreter-aux.hpp"
#define INVISIBLE_NPC 127 /* used for local spell effects */
@@ -8,7 +8,8 @@
//#define DEBUG
#ifdef DEBUG
-static void print_val(val_t * v)
+static
+void print_val(val_t *v)
{
switch (v->ty)
{
@@ -30,7 +31,8 @@ static void print_val(val_t * v)
}
}
-static void dump_env(env_t * env)
+static
+void dump_env(env_t *env)
{
int i;
for (i = 0; i < env->base_env->vars_nr; i++)
@@ -47,7 +49,8 @@ static void dump_env(env_t * env)
}
#endif
-static void clear_activation_record(cont_activation_record_t * ar)
+static
+void clear_activation_record(cont_activation_record_t *ar)
{
switch (ar->ty)
{
@@ -60,8 +63,8 @@ static void clear_activation_record(cont_activation_record_t * ar)
}
}
-static void
-invocation_timer_callback(timer_id UNUSED, tick_t UNUSED, custom_id_t id, custom_data_t data)
+static
+void invocation_timer_callback(timer_id, tick_t, custom_id_t id, custom_data_t)
{
invocation_t *invocation = (invocation_t *) map_id2bl(id);
@@ -72,7 +75,8 @@ invocation_timer_callback(timer_id UNUSED, tick_t UNUSED, custom_id_t id, custom
}
}
-static void clear_stack(invocation_t * invocation)
+static
+void clear_stack(invocation_t *invocation)
{
int i;
@@ -82,7 +86,7 @@ static void clear_stack(invocation_t * invocation)
invocation->stack_size = 0;
}
-void spell_free_invocation(invocation_t * invocation)
+void spell_free_invocation(invocation_t *invocation)
{
if (invocation->status_change_refs)
{
@@ -111,8 +115,8 @@ void spell_free_invocation(invocation_t * invocation)
// free(invocation);
}
-static void
-char_set_weapon_icon(character_t * subject, int count,
+static
+void char_set_weapon_icon(character_t *subject, int count,
StatusChange icon, int look)
{
const StatusChange old_icon = subject->attack_spell_icon_override;
@@ -137,7 +141,8 @@ char_set_weapon_icon(character_t * subject, int count,
}
}
-static void char_set_attack_info(character_t * subject, int speed, int range)
+static
+void char_set_attack_info(character_t *subject, int speed, int range)
{
subject->attack_spell_delay = speed;
subject->attack_spell_range = range;
@@ -156,7 +161,7 @@ static void char_set_attack_info(character_t * subject, int speed, int range)
}
}
-void magic_stop_completely(character_t * c)
+void magic_stop_completely(character_t *c)
{
// Zap all status change references to spells
for (StatusChange i : erange(StatusChange(), MAX_STATUSCHANGE))
@@ -178,7 +183,8 @@ void magic_stop_completely(character_t * c)
}
/* Spell execution has finished normally or we have been notified by a finished skill timer */
-static void try_to_finish_invocation(invocation_t * invocation)
+static
+void try_to_finish_invocation(invocation_t *invocation)
{
if (invocation->status_change_refs_nr == 0 && !invocation->current_effect)
{
@@ -194,7 +200,8 @@ static void try_to_finish_invocation(invocation_t * invocation)
}
}
-static int trigger_spell(int subject, int spell)
+static
+int trigger_spell(int subject, int spell)
{
invocation_t *invocation = (invocation_t *) map_id2bl(spell);
@@ -211,28 +218,32 @@ static int trigger_spell(int subject, int spell)
return invocation->bl.id;
}
-static void entity_warp(entity_t * target, int destm, int destx, int desty);
+static
+void entity_warp(entity_t *target, int destm, int destx, int desty);
-static void char_update(character_t * character)
+static
+void char_update(character_t *character)
{
entity_warp((entity_t *) character, character->bl.m, character->bl.x,
character->bl.y);
}
-static void timer_callback_effect(timer_id UNUSED, tick_t UNUSED, custom_id_t id, custom_data_t data)
+static
+void timer_callback_effect(timer_id, tick_t, custom_id_t id, custom_data_t data)
{
entity_t *target = map_id2bl(id);
if (target)
clif_misceffect(target, data);
}
-static void entity_effect(entity_t * entity, int effect_nr, int delay)
+static
+void entity_effect(entity_t *entity, int effect_nr, int delay)
{
add_timer(gettick() + delay,
&timer_callback_effect, entity->id, effect_nr);
}
-void magic_unshroud(character_t * other_char)
+void magic_unshroud(character_t *other_char)
{
other_char->state.shroud_active = 0;
// Now warp the caster out of and back into here to refresh everyone's display
@@ -241,15 +252,16 @@ void magic_unshroud(character_t * other_char)
// entity_effect(&other_char->bl, MAGIC_EFFECT_REVEAL);
}
-static void
-timer_callback_effect_npc_delete(timer_id UNUSED, tick_t odelay,
- custom_id_t npc_id, custom_data_t UNUSED)
+static
+void timer_callback_effect_npc_delete(timer_id, tick_t,
+ custom_id_t npc_id, custom_data_t)
{
struct npc_data *effect_npc = (struct npc_data *) map_id2bl(npc_id);
npc_free(effect_npc);
}
-static struct npc_data *local_spell_effect(int m, int x, int y, int effect,
+static
+struct npc_data *local_spell_effect(int m, int x, int y, int effect,
int tdelay)
{
int delay = 30000; /* 1 minute should be enough for all interesting spell effects, I hope */
@@ -264,7 +276,8 @@ static struct npc_data *local_spell_effect(int m, int x, int y, int effect,
return effect_npc;
}
-static int op_sfx(env_t * env, int args_nr, val_t * args)
+static
+int op_sfx(env_t *, int, val_t *args)
{
int delay = ARGINT(2);
@@ -284,7 +297,8 @@ static int op_sfx(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_instaheal(env_t * env, int args_nr, val_t * args)
+static
+int op_instaheal(env_t *env, int, val_t *args)
{
entity_t *caster = (VAR(VAR_CASTER).ty == TY_ENTITY)
? map_id2bl(VAR(VAR_CASTER).v.v_int) : NULL;
@@ -304,7 +318,8 @@ static int op_instaheal(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_itemheal(env_t * env, int args_nr, val_t * args)
+static
+int op_itemheal(env_t *env, int args_nr, val_t *args)
{
entity_t *subject = ARGENTITY(0);
if (subject->type == BL_PC)
@@ -324,7 +339,8 @@ static int op_itemheal(env_t * env, int args_nr, val_t * args)
#define ARGCHAR(n) (ARGENTITY(n)->type == BL_PC) ? (character_t *)(ARGENTITY(n)) : NULL
-static int op_shroud(env_t * env, int args_nr, val_t * args)
+static
+int op_shroud(env_t *, int, val_t *args)
{
character_t *subject = ARGCHAR(0);
int arg = ARGINT(1);
@@ -342,7 +358,8 @@ static int op_shroud(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_reveal(env_t * env, int args_nr, val_t * args)
+static
+int op_reveal(env_t *, int, val_t *args)
{
character_t *subject = ARGCHAR(0);
@@ -352,7 +369,8 @@ static int op_reveal(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_message(env_t * env, int args_nr, val_t * args)
+static
+int op_message(env_t *, int, val_t *args)
{
character_t *subject = ARGCHAR(0);
@@ -362,16 +380,17 @@ static int op_message(env_t * env, int args_nr, val_t * args)
return 0;
}
-static void
-timer_callback_kill_npc(timer_id UNUSED, tick_t odelay, custom_id_t npc_id,
- custom_data_t data)
+static
+void timer_callback_kill_npc(timer_id, tick_t, custom_id_t npc_id,
+ custom_data_t)
{
struct npc_data *npc = (struct npc_data *) map_id2bl(npc_id);
if (npc)
npc_free(npc);
}
-static int op_messenger_npc(env_t * env, int args_nr, val_t * args)
+static
+int op_messenger_npc(env_t *, int, val_t *args)
{
struct npc_data *npc;
location_t *loc = &ARGLOCATION(0);
@@ -385,7 +404,8 @@ static int op_messenger_npc(env_t * env, int args_nr, val_t * args)
return 0;
}
-static void entity_warp(entity_t * target, int destm, int destx, int desty)
+static
+void entity_warp(entity_t *target, int destm, int destx, int desty)
{
if (target->type == BL_PC || target->type == BL_MOB)
{
@@ -424,7 +444,8 @@ static void entity_warp(entity_t * target, int destm, int destx, int desty)
}
}
-static int op_move(env_t * env, int args_nr, val_t * args)
+static
+int op_move(env_t *, int, val_t *args)
{
entity_t *subject = ARGENTITY(0);
int dir = ARGDIR(1);
@@ -438,7 +459,8 @@ static int op_move(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_warp(env_t * env, int args_nr, val_t * args)
+static
+int op_warp(env_t *, int, val_t *args)
{
entity_t *subject = ARGENTITY(0);
location_t *loc = &ARGLOCATION(1);
@@ -448,7 +470,8 @@ static int op_warp(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_banish(env_t * env, int args_nr, val_t * args)
+static
+int op_banish(env_t *, int, val_t *args)
{
entity_t *subject = ARGENTITY(0);
@@ -463,8 +486,8 @@ static int op_banish(env_t * env, int args_nr, val_t * args)
return 0;
}
-static void
-record_status_change(invocation_t * invocation, int bl_id,
+static
+void record_status_change(invocation_t *invocation, int bl_id,
StatusChange sc_id)
{
int index = invocation->status_change_refs_nr++;
@@ -478,7 +501,8 @@ record_status_change(invocation_t * invocation, int bl_id,
cr->bl_id = bl_id;
}
-static int op_status_change(env_t * env, int args_nr, val_t * args)
+static
+int op_status_change(env_t *env, int, val_t *args)
{
entity_t *subject = ARGENTITY(0);
int invocation_id = VAR(VAR_INVOCATION).ty == TY_INVOCATION
@@ -495,7 +519,8 @@ static int op_status_change(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_stop_status_change(env_t * env, int args_nr, val_t * args)
+static
+int op_stop_status_change(env_t *, int, val_t *args)
{
entity_t *subject = ARGENTITY(0);
@@ -505,7 +530,8 @@ static int op_stop_status_change(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_override_attack(env_t * env, int args_nr, val_t * args)
+static
+int op_override_attack(env_t *env, int, val_t *args)
{
entity_t *psubject = ARGENTITY(0);
int charges = ARGINT(1);
@@ -547,7 +573,8 @@ static int op_override_attack(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_create_item(env_t * env, int args_nr, val_t * args)
+static
+int op_create_item(env_t *, int, val_t *args)
{
struct item item;
entity_t *entity = ARGENTITY(0);
@@ -576,7 +603,8 @@ static int op_create_item(env_t * env, int args_nr, val_t * args)
#define AGGRAVATION_MODE_ATTACKS_CASTER(n) ((n) == 0 || (n) == 2)
#define AGGRAVATION_MODE_MAKES_AGGRESSIVE(n) ((n) > 0)
-static int op_aggravate(env_t * env, int args_nr, val_t * args)
+static
+int op_aggravate(env_t *, int, val_t *args)
{
entity_t *victim = ARGENTITY(2);
int mode = ARGINT(1);
@@ -607,7 +635,8 @@ static int op_aggravate(env_t * env, int args_nr, val_t * args)
#define MONSTER_ATTITUDE_SERVANT 2
#define MONSTER_ATTITUDE_FROZEN 3
-static int op_spawn(env_t * env, int args_nr, val_t * args)
+static
+int op_spawn(env_t *, int, val_t *args)
{
area_t *area = ARGAREA(0);
entity_t *owner_e = ARGENTITY(1);
@@ -682,7 +711,7 @@ static int op_spawn(env_t * env, int args_nr, val_t * args)
}
static
-const char *get_invocation_name(env_t * env)
+const char *get_invocation_name(env_t *env)
{
invocation_t *invocation;
@@ -696,7 +725,8 @@ const char *get_invocation_name(env_t * env)
return "??";
}
-static int op_injure(env_t * env, int args_nr, val_t * args)
+static
+int op_injure(env_t *env, int, val_t *args)
{
entity_t *caster = ARGENTITY(0);
entity_t *target = ARGENTITY(1);
@@ -740,7 +770,8 @@ static int op_injure(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_emote(env_t * env, int args_nr, val_t * args)
+static
+int op_emote(env_t *, int, val_t *args)
{
entity_t *victim = ARGENTITY(0);
int emotion = ARGINT(1);
@@ -749,7 +780,8 @@ static int op_emote(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_set_script_variable(env_t * env, int args_nr, val_t * args)
+static
+int op_set_script_variable(env_t *, int, val_t *args)
{
character_t *c = (ETY(0) == BL_PC) ? ARGPC(0) : NULL;
@@ -761,7 +793,8 @@ static int op_set_script_variable(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_set_hair_colour(env_t * env, int args_nr, val_t * args)
+static
+int op_set_hair_colour(env_t *, int, val_t *args)
{
character_t *c = (ETY(0) == BL_PC) ? ARGPC(0) : NULL;
@@ -773,7 +806,8 @@ static int op_set_hair_colour(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_set_hair_style(env_t * env, int args_nr, val_t * args)
+static
+int op_set_hair_style(env_t *, int, val_t *args)
{
character_t *c = (ETY(0) == BL_PC) ? ARGPC(0) : NULL;
@@ -785,7 +819,8 @@ static int op_set_hair_style(env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_drop_item_for (env_t * env, int args_nr, val_t * args)
+static
+int op_drop_item_for (env_t *, int args_nr, val_t *args)
{
struct item item;
int stackable;
@@ -810,7 +845,8 @@ static int op_drop_item_for (env_t * env, int args_nr, val_t * args)
return 0;
}
-static int op_gain_exp(env_t * env, int args_nr, val_t * args)
+static
+int op_gain_exp(env_t *, int, val_t *args)
{
character_t *c = (ETY(0) == BL_PC) ? ARGPC(0) : NULL;
@@ -821,7 +857,8 @@ static int op_gain_exp(env_t * env, int args_nr, val_t * args)
return 0;
}
-static op_t operations[] = {
+static
+op_t operations[] = {
{"sfx", ".ii", op_sfx},
{"instaheal", "eii", op_instaheal},
{"itemheal", "eii", op_itemheal},
@@ -849,8 +886,10 @@ static op_t operations[] = {
{NULL, NULL, NULL}
};
-static int operations_sorted = 0;
-static int operation_count;
+static
+int operations_sorted = 0;
+static
+int operation_count;
static
int compare_operations(const void *lhs, const void *rhs)
@@ -886,9 +925,8 @@ op_t *magic_get_op(char *name, int *index)
return op;
}
-void
-spell_effect_report_termination(int invocation_id, int bl_id,
- StatusChange sc_id, int supplanted)
+void spell_effect_report_termination(int invocation_id, int bl_id,
+ StatusChange sc_id, int)
{
int i;
int index = -1;
@@ -913,7 +951,7 @@ spell_effect_report_termination(int invocation_id, int bl_id,
if (entity->type == BL_PC)
fprintf(stderr,
"[magic] INTERNAL ERROR: spell-effect-report-termination: tried to terminate on unexpected bl %d, sc %d\n",
- bl_id, sc_id);
+ bl_id, uint16_t(sc_id));
return;
}
@@ -927,7 +965,8 @@ spell_effect_report_termination(int invocation_id, int bl_id,
try_to_finish_invocation(invocation);
}
-static effect_t *return_to_stack(invocation_t * invocation)
+static
+effect_t *return_to_stack(invocation_t *invocation)
{
if (!invocation->stack_size)
return NULL;
@@ -1009,9 +1048,10 @@ static effect_t *return_to_stack(invocation_t * invocation)
}
}
-static cont_activation_record_t *add_stack_entry(invocation_t * invocation,
+static
+cont_activation_record_t *add_stack_entry(invocation_t *invocation,
int ty,
- effect_t * return_location)
+ effect_t *return_location)
{
cont_activation_record_t *ar =
invocation->stack + invocation->stack_size++;
@@ -1030,13 +1070,12 @@ static cont_activation_record_t *add_stack_entry(invocation_t * invocation,
}
static
-void find_entities_in_area_c(entity_t * target, va_list va)
+void find_entities_in_area_c(entity_t *target,
+ int *entities_allocd_p,
+ int *entities_nr_p,
+ int **entities_p,
+ int filter)
{
- int *entities_allocd_p = va_arg(va, int *);
- int *entities_nr_p = va_arg(va, int *);
- int **entities_p = va_arg(va, int **);
- int filter = va_arg(va, int);
-
/* The following macro adds an entity to the result list: */
#define ADD_ENTITY(e) \
if (*entities_nr_p == *entities_allocd_p) { \
@@ -1104,8 +1143,8 @@ void find_entities_in_area_c(entity_t * target, va_list va)
#undef ADD_ENTITY
}
-static void
-find_entities_in_area(area_t * area, int *entities_allocd_p,
+static
+void find_entities_in_area(area_t *area, int *entities_allocd_p,
int *entities_nr_p, int **entities_p, int filter)
{
switch (area->ty)
@@ -1121,17 +1160,16 @@ find_entities_in_area(area_t * area, int *entities_allocd_p,
{
int m, x, y, width, height;
magic_area_rect(&m, &x, &y, &width, &height, area);
- map_foreachinarea(find_entities_in_area_c,
+ map_foreachinarea(std::bind(find_entities_in_area_c, ph::_1, entities_allocd_p, entities_nr_p, entities_p, filter),
m, x, y, x + width, y + height,
- 0 /* filter elsewhere */ ,
- entities_allocd_p, entities_nr_p, entities_p,
- filter);
+ 0 /* filter elsewhere */);
}
}
}
-static effect_t *run_foreach(invocation_t * invocation, effect_t * foreach,
- effect_t * return_location)
+static
+effect_t *run_foreach(invocation_t *invocation, effect_t *foreach,
+ effect_t *return_location)
{
val_t area;
int filter = foreach->e.e_foreach.filter;
@@ -1198,8 +1236,9 @@ static effect_t *run_foreach(invocation_t * invocation, effect_t * foreach,
}
}
-static effect_t *run_for (invocation_t * invocation, effect_t * for_,
- effect_t * return_location)
+static
+effect_t *run_for (invocation_t *invocation, effect_t *for_,
+ effect_t *return_location)
{
cont_activation_record_t *ar;
int id = for_->e.e_for.id;
@@ -1232,8 +1271,9 @@ static effect_t *run_for (invocation_t * invocation, effect_t * for_,
return return_to_stack(invocation);
}
-static effect_t *run_call(invocation_t * invocation,
- effect_t * return_location)
+static
+effect_t *run_call(invocation_t *invocation,
+ effect_t *return_location)
{
effect_t *current = invocation->current_effect;
cont_activation_record_t *ar;
@@ -1260,7 +1300,8 @@ static effect_t *run_call(invocation_t * invocation,
}
#ifdef DEBUG
-static void print_cfg(int i, effect_t * e)
+static
+void print_cfg(int i, effect_t *e)
{
int j;
for (j = 0; j < i; j++)
@@ -1333,7 +1374,8 @@ static void print_cfg(int i, effect_t * e)
* >1 if we hit `sleep'; the result is the number of ticks we should sleep for.
* -1 if we paused to wait for a user action (via script interaction)
*/
-static int spell_run(invocation_t * invocation, int allow_delete)
+static
+int spell_run(invocation_t *invocation, int allow_delete)
{
const int invocation_id = invocation->bl.id;
#define REFRESH_INVOCATION invocation = (invocation_t *) map_id2bl(invocation_id); if (!invocation) return 0;
@@ -1500,7 +1542,7 @@ static int spell_run(invocation_t * invocation, int allow_delete)
}
static
-void spell_execute_d(invocation_t * invocation, int allow_deletion)
+void spell_execute_d(invocation_t *invocation, int allow_deletion)
{
int delta;
@@ -1524,12 +1566,12 @@ void spell_execute_d(invocation_t * invocation, int allow_deletion)
/* If 0, the script cleaned itself. If -1(wait-for-script), we must wait for the user. */
}
-void spell_execute(invocation_t * invocation)
+void spell_execute(invocation_t *invocation)
{
spell_execute_d(invocation, 1);
}
-void spell_execute_script(invocation_t * invocation)
+void spell_execute_script(invocation_t *invocation)
{
if (invocation->script_pos)
spell_execute_d(invocation, 1);
diff --git a/src/map/magic.cpp b/src/map/magic.cpp
index 48010e6..a310273 100644
--- a/src/map/magic.cpp
+++ b/src/map/magic.cpp
@@ -1,13 +1,14 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include "magic-interpreter.hpp"
#undef DEBUG
-static char *magic_preprocess_message(character_t * character, char *start,
+static
+char *magic_preprocess_message(character_t *character, char *start,
char *end)
{
if (character->state.shroud_active
@@ -30,7 +31,8 @@ static char *magic_preprocess_message(character_t * character, char *start,
/* Returns a dynamically allocated copy of `src'.
* `*parameter' may point within that copy or be NULL. */
-static char *magic_tokenise(char *src, char **parameter)
+static
+char *magic_tokenise(char *src, char **parameter)
{
char *retval = strdup(src);
char *seeker = retval;
@@ -54,7 +56,7 @@ static char *magic_tokenise(char *src, char **parameter)
return retval;
}
-int magic_message(character_t * caster, char *spell_, size_t spell_len)
+int magic_message(character_t *caster, char *spell_, size_t)
{
if (pc_isdead(caster))
return 0;
diff --git a/src/map/magic.hpp b/src/map/magic.hpp
index fecb975..4cdce18 100644
--- a/src/map/magic.hpp
+++ b/src/map/magic.hpp
@@ -22,14 +22,14 @@ struct invocation; /* Spell invocation */
* \return 1 or -1 if the input message was magic and was handled by this function, 0 otherwise. -1 is returned when the
* message should not be repeated.
*/
-int magic_message(character_t * caster, char *spell, size_t spell_len);
+int magic_message(character_t *caster, char *spell, size_t spell_len);
/**
* Removes the shroud from a character
*
* \param character The character to remove the shroud from
*/
-void magic_unshroud(character_t * character);
+void magic_unshroud(character_t *character);
/**
* Notifies a running spell that a status_change timer triggered by the spell has expired
@@ -39,8 +39,7 @@ void magic_unshroud(character_t * character);
* \param type sc_id ID of the status change entry that finished
* \param supplanted Whether the status_change finished normally (0) or was supplanted by a new status_change (1)
*/
-void
-spell_effect_report_termination(int invocation, int bl_id,
+void spell_effect_report_termination(int invocation, int bl_id,
StatusChange sc_id, int supplanted);
/**
@@ -76,7 +75,7 @@ void spell_execute_script(struct invocation *invocation);
* Stops all magic bound to the specified character
*
*/
-void magic_stop_completely(character_t * c);
+void magic_stop_completely(character_t *c);
/**
* Attacks with a magical spell charged to the character
@@ -87,4 +86,4 @@ int spell_attack(int caster, int target);
void spell_free_invocation(struct invocation *invocation);
-#endif /* !defined(MAGIC_H_) */
+#endif // MAGIC_HPP
diff --git a/src/map/map.cpp b/src/map/map.cpp
index dbdafdc..3bbfa9f 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -1,60 +1,65 @@
-// $Id: map.c,v 1.6 2004/09/25 17:37:01 MouseJstr Exp $
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#ifdef LCCWIN32
-#include <winsock.h>
-#else
+#include "map.hpp"
+
#include <netdb.h>
-#endif
+
+#include <cstdarg> // exception to "no va_list" rule
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include "../common/core.hpp"
-#include "../common/timer.hpp"
#include "../common/db.hpp"
#include "../common/grfio.hpp"
#include "../common/mt_rand.hpp"
-#include "map.hpp"
+#include "../common/nullpo.hpp"
+#include "../common/socket.hpp"
+#include "../common/timer.hpp"
+
+#include "atcommand.hpp"
+#include "battle.hpp"
+#include "chat.hpp"
#include "chrif.hpp"
#include "clif.hpp"
#include "intif.hpp"
+#include "itemdb.hpp"
+#include "magic.hpp"
+#include "mob.hpp"
#include "npc.hpp"
+#include "party.hpp"
#include "pc.hpp"
-#include "mob.hpp"
-#include "chat.hpp"
-#include "itemdb.hpp"
-#include "storage.hpp"
+#include "script.hpp"
#include "skill.hpp"
+#include "storage.hpp"
#include "trade.hpp"
-#include "party.hpp"
-#include "battle.hpp"
-#include "script.hpp"
-#include "atcommand.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/socket.hpp"
-#include "magic.hpp"
-
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
// 極力 staticでローカルに収める
-static struct dbt *id_db = NULL;
-static struct dbt *map_db = NULL;
-static struct dbt *nick_db = NULL;
-static struct dbt *charid_db = NULL;
+static
+struct dbt *id_db = NULL;
+static
+struct dbt *map_db = NULL;
+static
+struct dbt *nick_db = NULL;
+static
+struct dbt *charid_db = NULL;
-static int users = 0;
-static struct block_list *object[MAX_FLOORITEM];
-static int first_free_object_id = 0, last_object_id = 0;
+static
+int users = 0;
+static
+struct block_list *object[MAX_FLOORITEM];
+static
+int first_free_object_id = 0, last_object_id = 0;
#define block_free_max 1048576
-static void *block_free[block_free_max];
-static int block_free_count = 0, block_free_lock = 0;
+static
+void *block_free[block_free_max];
+static
+int block_free_count = 0, block_free_lock = 0;
#define BL_LIST_MAX 1048576
-static struct block_list *bl_list[BL_LIST_MAX];
-static int bl_list_count = 0;
+static
+struct block_list *bl_list[BL_LIST_MAX];
+static
+int bl_list_count = 0;
struct map_data map[MAX_MAP_PER_SERVER];
int map_num = 0;
@@ -172,7 +177,8 @@ int map_freeblock_unlock(void)
* bl->prevにbl_headのアドレスを入れておく
*------------------------------------------
*/
-static struct block_list bl_head;
+static
+struct block_list bl_head;
/*==========================================
* map[]のblock_listに追加
@@ -356,17 +362,17 @@ int map_count_oncell(int m, int x, int y)
* type!=0 ならその種類のみ
*------------------------------------------
*/
-void map_foreachinarea(void(*func)(struct block_list *, va_list), int m,
- int x0, int y0, int x1, int y1, int type, ...)
+void map_foreachinarea(std::function<void(struct block_list *)> func,
+ int m,
+ int x0, int y0, int x1, int y1,
+ int type)
{
int bx, by;
struct block_list *bl = NULL;
- va_list ap = NULL;
int blockcount = bl_list_count, i, c;
if (m < 0)
return;
- va_start(ap, type);
if (x0 < 0)
x0 = 0;
if (y0 < 0)
@@ -418,11 +424,10 @@ void map_foreachinarea(void(*func)(struct block_list *, va_list), int m,
for (i = blockcount; i < bl_list_count; i++)
if (bl_list[i]->prev) // 有効かどうかチェック
- func(bl_list[i], ap);
+ func(bl_list[i]);
map_freeblock_unlock(); // 解放を許可する
- va_end(ap);
bl_list_count = blockcount;
}
@@ -434,16 +439,16 @@ void map_foreachinarea(void(*func)(struct block_list *, va_list), int m,
* dx,dyは-1,0,1のみとする(どんな値でもいいっぽい?)
*------------------------------------------
*/
-void map_foreachinmovearea(void(*func)(struct block_list *, va_list), int m,
- int x0, int y0, int x1, int y1, int dx, int dy,
- int type, ...)
+void map_foreachinmovearea(std::function<void(struct block_list *)> func,
+ int m,
+ int x0, int y0, int x1, int y1,
+ int dx, int dy,
+ int type)
{
int bx, by;
struct block_list *bl = NULL;
- va_list ap = NULL;
int blockcount = bl_list_count, i, c;
- va_start(ap, type);
if (dx == 0 || dy == 0)
{
// 矩形領域の場合
@@ -573,11 +578,10 @@ void map_foreachinmovearea(void(*func)(struct block_list *, va_list), int m,
for (i = blockcount; i < bl_list_count; i++)
if (bl_list[i]->prev) // 有効かどうかチェック
- func(bl_list[i], ap);
+ func(bl_list[i]);
map_freeblock_unlock(); // 解放を許可する
- va_end(ap);
bl_list_count = blockcount;
}
@@ -585,16 +589,15 @@ void map_foreachinmovearea(void(*func)(struct block_list *, va_list), int m,
// which only checks the exact single x/y passed to it rather than an
// area radius - may be more useful in some instances)
//
-void map_foreachincell(void(*func)(struct block_list *, va_list), int m,
- int x, int y, int type, ...)
+void map_foreachincell(std::function<void(struct block_list *)> func,
+ int m,
+ int x, int y,
+ int type)
{
int bx, by;
struct block_list *bl = NULL;
- va_list ap = NULL;
int blockcount = bl_list_count, i, c;
- va_start(ap, type);
-
by = y / BLOCK_SIZE;
bx = x / BLOCK_SIZE;
@@ -632,11 +635,10 @@ void map_foreachincell(void(*func)(struct block_list *, va_list), int m,
for (i = blockcount; i < bl_list_count; i++)
if (bl_list[i]->prev) // 有効かどうかチェック
- func(bl_list[i], ap);
+ func(bl_list[i]);
map_freeblock_unlock(); // 解放を許可する
- va_end(ap);
bl_list_count = blockcount;
}
@@ -734,14 +736,11 @@ int map_delobject(int id, int type)
*
*------------------------------------------
*/
-void map_foreachobject(void(*func)(struct block_list *, va_list), int type,
- ...)
+void map_foreachobject(std::function<void(struct block_list *)> func,
+ int type)
{
int i;
int blockcount = bl_list_count;
- va_list ap = NULL;
-
- va_start(ap, type);
for (i = 2; i <= last_object_id; i++)
{
@@ -763,11 +762,10 @@ void map_foreachobject(void(*func)(struct block_list *, va_list), int type,
for (i = blockcount; i < bl_list_count; i++)
if (bl_list[i]->prev || bl_list[i]->next)
- func(bl_list[i], ap);
+ func(bl_list[i]);
map_freeblock_unlock();
- va_end(ap);
bl_list_count = blockcount;
}
@@ -781,7 +779,7 @@ void map_foreachobject(void(*func)(struct block_list *, va_list), int type,
* map.h内で#defineしてある
*------------------------------------------
*/
-void map_clearflooritem_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void map_clearflooritem_timer(timer_id tid, tick_t, custom_id_t id, custom_data_t data)
{
struct flooritem_data *fitem = NULL;
@@ -1202,7 +1200,8 @@ char *map_charid2nick(int id)
/*========================================*/
/* [Fate] Operations to iterate over active map sessions */
-static struct map_session_data *map_get_session(int i)
+static
+struct map_session_data *map_get_session(int i)
{
struct map_session_data *d;
@@ -1213,7 +1212,8 @@ static struct map_session_data *map_get_session(int i)
return NULL;
}
-static struct map_session_data *map_get_session_forward(int start)
+static
+struct map_session_data *map_get_session_forward(int start)
{
int i;
for (i = start; i < fd_max; i++)
@@ -1226,7 +1226,8 @@ static struct map_session_data *map_get_session_forward(int start)
return NULL;
}
-static struct map_session_data *map_get_session_backward(int start)
+static
+struct map_session_data *map_get_session_backward(int start)
{
int i;
for (i = start; i >= 0; i--)
@@ -1321,14 +1322,9 @@ struct block_list *map_id2bl(int id)
* id_db内の全てにfuncを実行
*------------------------------------------
*/
-int map_foreachiddb(db_func_t func, ...)
+void map_foreachiddb(db_func_t func)
{
- va_list ap = NULL;
-
- va_start(ap, func);
- numdb_foreach(id_db, func, ap);
- va_end(ap);
- return 0;
+ numdb_foreach(id_db, func);
}
/*==========================================
@@ -1582,27 +1578,15 @@ int map_setipport(const char *name, struct in_addr ip, int port)
* 水場高さ設定
*------------------------------------------
*/
-static struct Waterlist
+static
+struct Waterlist
{
char mapname[24];
int waterheight;
} *waterlist = NULL;
-#define NO_WATER 1000000
-
-static int map_waterheight(char *mapname)
-{
- if (waterlist)
- {
- int i;
- for (i = 0; waterlist[i].mapname[0] && i < MAX_MAP_PER_SERVER; i++)
- if (strcmp(waterlist[i].mapname, mapname) == 0)
- return waterlist[i].waterheight;
- }
- return NO_WATER;
-}
-
-static void map_readwater(char *watertxt)
+static
+void map_readwater(char *watertxt)
{
char line[1024], w1[1024];
FILE *fp = NULL;
@@ -1641,7 +1625,8 @@ static void map_readwater(char *watertxt)
* マップ1枚読み込み
*------------------------------------------
*/
-static int map_readmap(int m, char *fn, char *alias)
+static
+int map_readmap(int m, char *fn, char *)
{
int s;
int x, y, xs, ys;
@@ -1649,7 +1634,6 @@ static int map_readmap(int m, char *fn, char *alias)
{
char type;
} *p;
- int wh;
size_t size;
// read & convert fn
@@ -1676,7 +1660,6 @@ static int map_readmap(int m, char *fn, char *alias)
memset(&map[m].flag, 0, sizeof(map[m].flag));
if (battle_config.pk_mode)
map[m].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris]
- wh = map_waterheight(map[m].name);
for (y = 0; y < ys; y++)
{
p = (struct gat_1cell *)(gat + y * xs + 4);
@@ -1827,9 +1810,11 @@ extern char *gm_logfile_name;
FILE *map_logfile = NULL;
char *map_logfile_name = NULL;
-static long map_logfile_index;
+static
+long map_logfile_index;
-static void map_close_logfile(void)
+static
+void map_close_logfile(void)
{
if (map_logfile)
{
@@ -1846,7 +1831,8 @@ static void map_close_logfile(void)
}
}
-static void map_start_logfile(long suffix)
+static
+void map_start_logfile(long suffix)
{
char *filename_buf = (char*)malloc(strlen(map_logfile_name) + 50);
map_logfile_index = suffix >> LOGFILE_SECONDS_PER_CHUNK_SHIFT;
@@ -1859,7 +1845,8 @@ static void map_start_logfile(long suffix)
free(filename_buf);
}
-static void map_set_logfile(const char *filename)
+static
+void map_set_logfile(const char *filename)
{
struct timeval tv;
@@ -2022,7 +2009,7 @@ int map_config_read(const char *cfgName)
}
static
-void cleanup_sub(struct block_list *bl, va_list ap)
+void cleanup_sub(struct block_list *bl)
{
nullpo_retv(bl);
@@ -2063,7 +2050,7 @@ void term_func(void)
{
if (map[map_id].m)
map_foreachinarea(cleanup_sub, map_id, 0, 0, map[map_id].xs,
- map[map_id].ys, 0, 0);
+ map[map_id].ys, 0);
}
for (i = 0; i < fd_max; i++)
@@ -2096,6 +2083,7 @@ void term_func(void)
/// --help was passed
// FIXME this should produce output
+static __attribute__((noreturn))
void map_helpscreen(void)
{
exit(1);
@@ -2124,7 +2112,6 @@ int do_init(int argc, char *argv[])
const char *BATTLE_CONF_FILENAME = "conf/battle_athena.conf";
const char *ATCOMMAND_CONF_FILENAME = "conf/atcommand_athena.conf";
const char *SCRIPT_CONF_NAME = "conf/script_athena.conf";
- const char *MSG_CONF_NAME = "conf/msg_athena.conf";
for (i = 1; i < argc; i++)
{
@@ -2140,8 +2127,6 @@ int do_init(int argc, char *argv[])
ATCOMMAND_CONF_FILENAME = argv[i + 1];
else if (strcmp(argv[i], "--script_config") == 0)
SCRIPT_CONF_NAME = argv[i + 1];
- else if (strcmp(argv[i], "--msg_config") == 0)
- MSG_CONF_NAME = argv[i + 1];
}
map_config_read(MAP_CONF_NAME);
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 18b1e8d..27e574a 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -1,18 +1,18 @@
-// $Id: map.h,v 1.8 2004/09/25 11:39:17 MouseJstr Exp $
#ifndef MAP_HPP
#define MAP_HPP
-#include <stdio.h>
-#include <stdarg.h>
-#include <time.h>
-#include <sys/time.h>
#include <netinet/in.h>
+#include <sys/time.h>
+#include <cstdio>
+#include <ctime>
+
+#include "../common/db.hpp"
#include "../common/mmo.hpp"
#include "../common/timer.hpp"
-#include "../common/db.hpp"
-#include "script.hpp"
+
#include "mob.t.hpp"
+#include "script.hpp" // change to script.t.hpp
#include "skill.t.hpp"
#ifndef MAX
@@ -481,7 +481,7 @@ enum mob_stat
MOB_SPEED,
// These must come last:
MOB_XP_BONUS, /* [Fate] Encoded as base to 1024: 1024 means 100% */
- MOB_LAST
+ MOB_LAST,
};
#define MOB_XP_BONUS_BASE 1024
@@ -687,7 +687,7 @@ enum
LOOK_GLOVES,
LOOK_CAPE,
LOOK_MISC1,
- LOOK_MISC2
+ LOOK_MISC2,
};
enum
@@ -737,13 +737,20 @@ int map_freeblock_unlock(void);
// block関連
int map_addblock(struct block_list *);
int map_delblock(struct block_list *);
-void map_foreachinarea(void(*)(struct block_list *, va_list), int, int, int,
- int, int, int, ...);
+void map_foreachinarea(std::function<void(struct block_list *)>,
+ int,
+ int, int, int, int,
+ int);
// -- moonsoul (added map_foreachincell)
-void map_foreachincell(void(*)(struct block_list *, va_list), int, int, int,
- int, ...);
-void map_foreachinmovearea(void(*)(struct block_list *, va_list), int, int,
- int, int, int, int, int, int, ...);
+void map_foreachincell(std::function<void(struct block_list *)>,
+ int,
+ int, int,
+ int);
+void map_foreachinmovearea(std::function<void(struct block_list *)>,
+ int,
+ int, int, int, int,
+ int, int,
+ int);
int map_countnearpc(int, int, int);
//block関連に追加
int map_count_oncell(int m, int x, int y);
@@ -751,7 +758,8 @@ int map_count_oncell(int m, int x, int y);
int map_addobject(struct block_list *);
int map_delobject(int, int type);
int map_delobjectnofree(int id, int type);
-void map_foreachobject(void(*)(struct block_list *, va_list), int, ...);
+void map_foreachobject(std::function<void(struct block_list *)>,
+ int);
//
int map_quit(struct map_session_data *);
// npc
@@ -790,7 +798,7 @@ int map_setipport(const char *name, struct in_addr ip, int port);
int map_eraseipport(const char *name, struct in_addr ip, int port);
void map_addiddb(struct block_list *);
void map_deliddb(struct block_list *bl);
-int map_foreachiddb(db_func_t, ...);
+void map_foreachiddb(db_func_t);
void map_addnickdb(struct map_session_data *);
int map_scriptcont(struct map_session_data *sd, int id); /* Continues a script either on a spell or on an NPC */
struct map_session_data *map_nick2sd(const char *);
@@ -817,7 +825,6 @@ int path_blownpos(int m, int x0, int y0, int dx, int dy, int count);
int map_who(int fd);
-void map_helpscreen(void); // [Valaris]
int map_delmap(char *mapname);
-#endif
+#endif // MAP_HPP
diff --git a/src/map/mob.cpp b/src/map/mob.cpp
index d1f431f..cb7ef89 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -1,29 +1,26 @@
-// $Id: mob.c,v 1.7 2004/09/25 05:32:18 MouseJstr Exp $
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
+#include "mob.hpp"
+
+#include <cmath>
+#include <stdarg.h> // requires justification for <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
-#include "../common/timer.hpp"
-#include "../common/socket.hpp"
#include "../common/db.hpp"
-#include "../common/nullpo.hpp"
#include "../common/mt_rand.hpp"
-#include "map.hpp"
+#include "../common/nullpo.hpp"
+#include "../common/socket.hpp"
+#include "../common/timer.hpp"
+
+#include "battle.hpp"
#include "clif.hpp"
#include "intif.hpp"
-#include "pc.hpp"
-#include "mob.hpp"
#include "itemdb.hpp"
-#include "skill.hpp"
-#include "battle.hpp"
-#include "party.hpp"
+#include "map.hpp"
#include "npc.hpp"
-
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
+#include "party.hpp"
+#include "pc.hpp"
+#include "skill.hpp"
#ifndef max
#define max( a, b ) (((a) > (b)) ? (a) : (b) )
@@ -47,8 +44,6 @@ int mob_makedummymobdb(int);
static
void mob_timer(timer_id, tick_t, custom_id_t, custom_data_t);
static
-int mobskill_deltimer(struct mob_data *md);
-static
int mob_skillid2skillidx(int mob_class, SkillID skillid);
static
int mobskill_use_id(struct mob_data *md, struct block_list *target,
@@ -89,7 +84,8 @@ int mobdb_checkid(const int id)
return id;
}
-static void mob_init(struct mob_data *md);
+static
+void mob_init(struct mob_data *md);
/*==========================================
* The minimum data set for MOB spawning
@@ -126,7 +122,8 @@ int mob_spawn_dataset(struct mob_data *md, const char *mobname, int mob_class)
// Mutation values indicate how `valuable' a change to each stat is, XP wise.
// For one 256th of change, we give out that many 1024th fractions of XP change
// (i.e., 1024 means a 100% XP increase for a single point of adjustment, 4 means 100% XP bonus for doubling the value)
-static int mutation_value[MOB_XP_BONUS] = {
+static
+int mutation_value[MOB_XP_BONUS] = {
2, // MOB_LV
3, // MOB_MAX_HP
1, // MOB_STR
@@ -145,7 +142,8 @@ static int mutation_value[MOB_XP_BONUS] = {
// The mutation scale indicates how far `up' we can go, with 256 indicating 100% Note that this may stack with multiple
// calls to `mutate'.
-static int mutation_scale[MOB_XP_BONUS] = {
+static
+int mutation_scale[MOB_XP_BONUS] = {
16, // MOB_LV
256, // MOB_MAX_HP
32, // MOB_STR
@@ -169,7 +167,8 @@ static int mutation_scale[MOB_XP_BONUS] = {
// (2) second, determine the absolute stat change
// (3) third, compute the percentage stat change relative to mutation_base (p1)
// (4) fourth, compute the XP mofication based on the smaller of (p0, p1).
-static int mutation_base[MOB_XP_BONUS] = {
+static
+int mutation_base[MOB_XP_BONUS] = {
30, // MOB_LV
-1, // MOB_MAX_HP
20, // MOB_STR
@@ -190,7 +189,8 @@ static int mutation_base[MOB_XP_BONUS] = {
* Mutates a MOB. For large `direction' values, calling this multiple times will give bigger XP boni.
*----------------------------------------
*/
-static void mob_mutate(struct mob_data *md, int stat, int intensity) // intensity: positive: strengthen, negative: weaken. 256 = 100%.
+static
+void mob_mutate(struct mob_data *md, int stat, int intensity) // intensity: positive: strengthen, negative: weaken. 256 = 100%.
{
int old_stat;
int new_stat;
@@ -296,7 +296,8 @@ int mob_gen_exp(struct mob_db *mob)
return xp;
}
-static void mob_init(struct mob_data *md)
+static
+void mob_init(struct mob_data *md)
{
int i;
const int mob_class = md->mob_class;
@@ -492,13 +493,10 @@ int mob_once_spawn_area(struct map_session_data *sd, const char *mapname,
*/
int mob_spawn_guardian(struct map_session_data *sd, const char *mapname,
int x, int y, const char *mobname, int mob_class,
- int amount, const char *event, int guardian)
+ int amount, const char *event, int)
{
struct mob_data *md = NULL;
- int m, count = 1, lv = 255;
-
- if (sd)
- lv = sd->status.base_level;
+ int m, count = 1;
if (sd && strcmp(mapname, "this") == 0)
m = sd->bl.m;
@@ -634,7 +632,8 @@ int mob_can_move(struct mob_data *md)
* Time calculation concerning one step next to mob
*------------------------------------------
*/
-static int calc_next_walk_step(struct mob_data *md)
+static
+int calc_next_walk_step(struct mob_data *md)
{
nullpo_retr(0, md);
@@ -645,13 +644,15 @@ static int calc_next_walk_step(struct mob_data *md)
return battle_get_speed(&md->bl);
}
-static int mob_walktoxy_sub(struct mob_data *md);
+static
+int mob_walktoxy_sub(struct mob_data *md);
/*==========================================
* Mob Walk processing
*------------------------------------------
*/
-static int mob_walk(struct mob_data *md, unsigned int tick, int data)
+static
+int mob_walk(struct mob_data *md, unsigned int tick, int data)
{
int moveblock;
int i, ctype;
@@ -704,9 +705,10 @@ static int mob_walk(struct mob_data *md, unsigned int tick, int data)
|| y / BLOCK_SIZE != (y + dy) / BLOCK_SIZE);
md->state.state = MS_WALK;
- map_foreachinmovearea(clif_moboutsight, md->bl.m, x - AREA_SIZE,
- y - AREA_SIZE, x + AREA_SIZE, y + AREA_SIZE,
- dx, dy, BL_PC, md);
+ map_foreachinmovearea(std::bind(clif_moboutsight, ph::_1, md),
+ md->bl.m, x - AREA_SIZE, y - AREA_SIZE,
+ x + AREA_SIZE, y + AREA_SIZE,
+ dx, dy, BL_PC);
x += dx;
y += dy;
@@ -720,9 +722,10 @@ static int mob_walk(struct mob_data *md, unsigned int tick, int data)
if (moveblock)
map_addblock(&md->bl);
- map_foreachinmovearea(clif_mobinsight, md->bl.m, x - AREA_SIZE,
- y - AREA_SIZE, x + AREA_SIZE, y + AREA_SIZE,
- -dx, -dy, BL_PC, md);
+ map_foreachinmovearea(std::bind(clif_mobinsight, ph::_1, md),
+ md->bl.m, x - AREA_SIZE, y - AREA_SIZE,
+ x + AREA_SIZE, y + AREA_SIZE,
+ -dx, -dy, BL_PC);
md->state.state = MS_IDLE;
if (md->option & 4)
@@ -749,7 +752,8 @@ static int mob_walk(struct mob_data *md, unsigned int tick, int data)
* Check if mob should be attempting to attack
*------------------------------------------
*/
-static int mob_check_attack(struct mob_data *md)
+static
+int mob_check_attack(struct mob_data *md)
{
struct block_list *tbl = NULL;
struct map_session_data *tsd = NULL;
@@ -843,11 +847,9 @@ static int mob_check_attack(struct mob_data *md)
}
static
-void mob_ancillary_attack(struct block_list *bl, va_list ap)
+void mob_ancillary_attack(struct block_list *bl,
+ struct block_list *mdbl, struct block_list *tbl, unsigned int tick)
{
- struct block_list *mdbl = va_arg(ap, struct block_list *);
- struct block_list *tbl = va_arg(ap, struct block_list *);
- unsigned int tick = va_arg(ap, unsigned int);
if (bl != tbl)
battle_weapon_attack(mdbl, bl, tick, 0);
}
@@ -856,7 +858,8 @@ void mob_ancillary_attack(struct block_list *bl, va_list ap)
* Attack processing of mob
*------------------------------------------
*/
-static int mob_attack(struct mob_data *md, unsigned int tick, int data)
+static
+int mob_attack(struct mob_data *md, unsigned int tick, int)
{
struct block_list *tbl = NULL;
@@ -882,10 +885,9 @@ static int mob_attack(struct mob_data *md, unsigned int tick, int data)
// it is highly platform-specific that this even works at all.
int radius = battle_config.mob_splash_radius;
if (radius >= 0 && tbl->type == BL_PC && !map[tbl->m].flag.town)
- map_foreachinarea(mob_ancillary_attack,
- tbl->m, tbl->x - radius, tbl->y - radius, tbl->x + radius, tbl->y + radius,
- BL_PC,
- &md->bl, tbl, tick);
+ map_foreachinarea(std::bind(mob_ancillary_attack, ph::_1, &md->bl, tbl, tick),
+ tbl->m, tbl->x - radius, tbl->y - radius,
+ tbl->x + radius, tbl->y + radius, BL_PC);
if (!(battle_config.monster_cloak_check_type & 2)
&& md->sc_data[SC_CLOAKING].timer != -1)
@@ -905,17 +907,12 @@ static int mob_attack(struct mob_data *md, unsigned int tick, int data)
*------------------------------------------
*/
static
-int mob_stopattacked(struct map_session_data *sd, va_list ap)
+void mob_stopattacked(struct map_session_data *sd, int id)
{
- int id;
+ nullpo_retv(sd);
- nullpo_retr(0, sd);
- nullpo_retr(0, ap);
-
- id = va_arg(ap, int);
if (sd->attacktarget == id)
pc_stopattack(sd);
- return 0;
}
/*==========================================
@@ -975,7 +972,7 @@ int mob_changestate(struct mob_data *md, int state, int type)
md->state.skillstate = MSS_DEAD;
md->last_deadtime = gettick();
// Since it died, all aggressors' attack to this mob is stopped.
- clif_foreachclient(mob_stopattacked, md->bl.id);
+ clif_foreachclient(std::bind(mob_stopattacked, ph::_1, md->bl.id));
skill_unit_out_all(&md->bl, gettick(), 1);
skill_status_change_clear(&md->bl, 2); // The abnormalities in status are canceled.
skill_clear_unitgroup(&md->bl); // All skill unit groups are deleted.
@@ -996,7 +993,8 @@ int mob_changestate(struct mob_data *md, int state, int type)
* It branches to a walk and an attack.
*------------------------------------------
*/
-static void mob_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+static
+void mob_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
{
struct mob_data *md;
struct block_list *bl;
@@ -1050,7 +1048,8 @@ static void mob_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t d
*
*------------------------------------------
*/
-static int mob_walktoxy_sub(struct mob_data *md)
+static
+int mob_walktoxy_sub(struct mob_data *md)
{
struct walkpath_data wpd;
@@ -1101,7 +1100,8 @@ int mob_walktoxy(struct mob_data *md, int x, int y, int easy)
* mob spawn with delay (timer function)
*------------------------------------------
*/
-static void mob_delayspawn(timer_id tid, tick_t tick, custom_id_t m, custom_data_t n)
+static
+void mob_delayspawn(timer_id, tick_t, custom_id_t m, custom_data_t)
{
mob_spawn(m);
}
@@ -1168,7 +1168,7 @@ int mob_setdelayspawn(int id)
*/
int mob_spawn(int id)
{
- int x = 0, y = 0, i = 0, c;
+ int x = 0, y = 0, c;
unsigned int tick = gettick();
struct mob_data *md;
struct block_list *bl;
@@ -1194,28 +1194,31 @@ int mob_spawn(int id)
md->mob_class = md->base_class;
md->bl.m = md->m;
- do
{
- if (md->x0 == 0 && md->y0 == 0)
+ int i = 0;
+ do
{
- x = MPRAND(1, (map[md->bl.m].xs - 2));
- y = MPRAND(1, (map[md->bl.m].ys - 2));
+ if (md->x0 == 0 && md->y0 == 0)
+ {
+ x = MPRAND(1, (map[md->bl.m].xs - 2));
+ y = MPRAND(1, (map[md->bl.m].ys - 2));
+ }
+ else
+ {
+ x = MPRAND(md->x0, (md->xs + 1)) - md->xs / 2;
+ y = MPRAND(md->y0, (md->ys + 1)) - md->ys / 2;
+ }
+ i++;
}
- else
+ while (((c = map_getcell(md->bl.m, x, y)) == 1 || c == 5) && i < 50);
+
+ if (i >= 50)
{
- x = MPRAND(md->x0, (md->xs + 1)) - md->xs / 2;
- y = MPRAND(md->y0, (md->ys + 1)) - md->ys / 2;
+ // if(battle_config.error_log==1)
+ // printf("MOB spawn error %d @ %s\n",id,map[md->bl.m].name);
+ add_timer(tick + 5000, mob_delayspawn, id, 0);
+ return 1;
}
- i++;
- }
- while (((c = map_getcell(md->bl.m, x, y)) == 1 || c == 5) && i < 50);
-
- if (i >= 50)
- {
-// if(battle_config.error_log==1)
-// printf("MOB spawn error %d @ %s\n",id,map[md->bl.m].name);
- add_timer(tick + 5000, mob_delayspawn, id, 0);
- return 1;
}
md->to_x = md->bl.x = x;
@@ -1248,8 +1251,8 @@ int mob_spawn(int id)
md->deletetimer = -1;
md->skilltimer = -1;
- for (i = 0, c = tick - 1000 * 3600 * 10; i < MAX_MOBSKILL; i++)
- md->skilldelay[i] = c;
+ for (int i = 0; i < MAX_MOBSKILL; i++)
+ md->skilldelay[i] = tick - 1000 * 3600 * 10;
md->skillid = SkillID();
md->skilllv = 0;
@@ -1258,7 +1261,7 @@ int mob_spawn(int id)
memset(md->lootitem, 0, sizeof(*md->lootitem));
md->lootitem_count = 0;
- for (i = 0; i < MAX_MOBSKILLTIMERSKILL; i++)
+ for (int i = 0; i < MAX_MOBSKILLTIMERSKILL; i++)
md->skilltimerskill[i].timer = -1;
for (StatusChange i : erange(StatusChange(), MAX_STATUSCHANGE))
@@ -1289,7 +1292,8 @@ int mob_spawn(int id)
* Distance calculation between two points
*------------------------------------------
*/
-static int distance(int x0, int y0, int x1, int y1)
+static
+int distance(int x0, int y0, int x1, int y1)
{
int dx, dy;
@@ -1483,16 +1487,16 @@ int mob_target(struct mob_data *md, struct block_list *bl, int dist)
*------------------------------------------
*/
static
-void mob_ai_sub_hard_activesearch(struct block_list *bl, va_list ap)
+void mob_ai_sub_hard_activesearch(struct block_list *bl,
+ struct mob_data *smd, int *pcc)
{
struct map_session_data *tsd = NULL;
- struct mob_data *smd, *tmd = NULL;
- int mode, race, dist, *pcc;
+ struct mob_data *tmd = NULL;
+ int mode, race, dist;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(smd = va_arg(ap, struct mob_data *));
- nullpo_retv(pcc = va_arg(ap, int *));
+ nullpo_retv(smd);
+ nullpo_retv(pcc);
if (bl->type == BL_PC)
tsd = (struct map_session_data *) bl;
@@ -1559,15 +1563,11 @@ void mob_ai_sub_hard_activesearch(struct block_list *bl, va_list ap)
*------------------------------------------
*/
static
-void mob_ai_sub_hard_lootsearch(struct block_list *bl, va_list ap)
+void mob_ai_sub_hard_lootsearch(struct block_list *bl, struct mob_data *md, int *itc)
{
- struct mob_data *md;
- int mode, dist, *itc;
+ int mode, dist;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(md = va_arg(ap, struct mob_data *));
- nullpo_retv(itc = va_arg(ap, int *));
if (!md->mode)
{
@@ -1603,17 +1603,14 @@ void mob_ai_sub_hard_lootsearch(struct block_list *bl, va_list ap)
*------------------------------------------
*/
static
-void mob_ai_sub_hard_linksearch(struct block_list *bl, va_list ap)
+void mob_ai_sub_hard_linksearch(struct block_list *bl, struct mob_data *md, struct block_list *target)
{
struct mob_data *tmd;
- struct mob_data *md;
- struct block_list *target;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(tmd = (struct mob_data *) bl);
- nullpo_retv(md = va_arg(ap, struct mob_data *));
- nullpo_retv(target = va_arg(ap, struct block_list *));
+ tmd = (struct mob_data *) bl;
+ nullpo_retv(md);
+ nullpo_retv(target);
// same family free in a range at a link monster -- it will be made to lock if MOB is
/* if ((md->target_id > 0 && md->state.targettype == ATTACKABLE) && mob_db[md->mob_class].mode&0x08){
@@ -1644,7 +1641,8 @@ void mob_ai_sub_hard_linksearch(struct block_list *bl, va_list ap)
* Processing of slave monsters
*------------------------------------------
*/
-static int mob_ai_sub_hard_slavemob(struct mob_data *md, unsigned int tick)
+static
+int mob_ai_sub_hard_slavemob(struct mob_data *md, unsigned int tick)
{
struct mob_data *mmd = NULL;
struct block_list *bl;
@@ -1790,7 +1788,8 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md, unsigned int tick)
* A lock of target is stopped and mob moves to a standby state.
*------------------------------------------
*/
-static int mob_unlocktarget(struct mob_data *md, int tick)
+static
+int mob_unlocktarget(struct mob_data *md, int tick)
{
nullpo_retr(0, md);
@@ -1805,7 +1804,8 @@ static int mob_unlocktarget(struct mob_data *md, int tick)
* Random walk
*------------------------------------------
*/
-static int mob_randomwalk(struct mob_data *md, int tick)
+static
+int mob_randomwalk(struct mob_data *md, int tick)
{
const int retrycount = 20;
int speed;
@@ -1861,22 +1861,18 @@ static int mob_randomwalk(struct mob_data *md, int tick)
*------------------------------------------
*/
static
-void mob_ai_sub_hard(struct block_list *bl, va_list ap)
+void mob_ai_sub_hard(struct block_list *bl, unsigned int tick)
{
struct mob_data *md, *tmd = NULL;
struct map_session_data *tsd = NULL;
struct block_list *tbl = NULL;
struct flooritem_data *fitem;
- unsigned int tick;
int i, dx, dy, ret, dist;
int attack_type = 0;
int mode, race;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(md = (struct mob_data *) bl);
-
- tick = va_arg(ap, unsigned int);
+ md = (struct mob_data *) bl;
if (DIFF_TICK(tick, md->last_thinktime) < MIN_MOBTHINKTIME)
return;
@@ -1911,10 +1907,9 @@ void mob_ai_sub_hard(struct block_list *bl, va_list ap)
{
if (asd->invincible_timer == -1 && !pc_isinvisible(asd))
{
- map_foreachinarea(mob_ai_sub_hard_linksearch, md->bl.m,
- md->bl.x - 13, md->bl.y - 13,
- md->bl.x + 13, md->bl.y + 13,
- BL_MOB, md, &asd->bl);
+ map_foreachinarea(std::bind(mob_ai_sub_hard_linksearch, ph::_1, md, &asd->bl),
+ md->bl.m, md->bl.x - 13, md->bl.y - 13,
+ md->bl.x + 13, md->bl.y + 13, BL_MOB);
}
}
}
@@ -1962,19 +1957,15 @@ void mob_ai_sub_hard(struct block_list *bl, va_list ap)
i = 0;
if (md->state.special_mob_ai)
{
- map_foreachinarea(mob_ai_sub_hard_activesearch, md->bl.m,
- md->bl.x - AREA_SIZE * 2,
- md->bl.y - AREA_SIZE * 2,
- md->bl.x + AREA_SIZE * 2,
- md->bl.y + AREA_SIZE * 2, 0, md, &i);
+ map_foreachinarea(std::bind(mob_ai_sub_hard_activesearch, ph::_1, md, &i),
+ md->bl.m, md->bl.x - AREA_SIZE * 2, md->bl.y - AREA_SIZE * 2,
+ md->bl.x + AREA_SIZE * 2, md->bl.y + AREA_SIZE * 2, 0);
}
else
{
- map_foreachinarea(mob_ai_sub_hard_activesearch, md->bl.m,
- md->bl.x - AREA_SIZE * 2,
- md->bl.y - AREA_SIZE * 2,
- md->bl.x + AREA_SIZE * 2,
- md->bl.y + AREA_SIZE * 2, BL_PC, md, &i);
+ map_foreachinarea(std::bind(mob_ai_sub_hard_activesearch, ph::_1, md, &i),
+ md->bl.m, md->bl.x - AREA_SIZE * 2, md->bl.y - AREA_SIZE * 2,
+ md->bl.x + AREA_SIZE * 2, md->bl.y + AREA_SIZE * 2, BL_PC);
}
}
@@ -1982,10 +1973,9 @@ void mob_ai_sub_hard(struct block_list *bl, va_list ap)
if (!md->target_id && mode & 0x02 && !md->state.master_check)
{
i = 0;
- map_foreachinarea(mob_ai_sub_hard_lootsearch, md->bl.m,
- md->bl.x - AREA_SIZE * 2, md->bl.y - AREA_SIZE * 2,
- md->bl.x + AREA_SIZE * 2, md->bl.y + AREA_SIZE * 2,
- BL_ITEM, md, &i);
+ map_foreachinarea(std::bind(mob_ai_sub_hard_lootsearch, ph::_1, md, &i),
+ md->bl.m, md->bl.x - AREA_SIZE * 2, md->bl.y - AREA_SIZE * 2,
+ md->bl.x + AREA_SIZE * 2, md->bl.y + AREA_SIZE * 2, BL_ITEM);
}
// It will attack, if the candidate for an attack is.
@@ -2215,43 +2205,36 @@ void mob_ai_sub_hard(struct block_list *bl, va_list ap)
* Serious processing for mob in PC field of view (foreachclient)
*------------------------------------------
*/
-static int mob_ai_sub_foreachclient(struct map_session_data *sd, va_list ap)
+static
+void mob_ai_sub_foreachclient(struct map_session_data *sd, unsigned int tick)
{
- unsigned int tick;
- nullpo_retr(0, sd);
- nullpo_retr(0, ap);
-
- tick = va_arg(ap, unsigned int);
- map_foreachinarea(mob_ai_sub_hard, 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_MOB, tick);
+ nullpo_retv(sd);
- return 0;
+ map_foreachinarea(std::bind(mob_ai_sub_hard, ph::_1, tick),
+ 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_MOB);
}
/*==========================================
* Serious processing for mob in PC field of view (interval timer function)
*------------------------------------------
*/
-static void mob_ai_hard(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+static
+void mob_ai_hard(timer_id, tick_t tick, custom_id_t, custom_data_t)
{
- clif_foreachclient(mob_ai_sub_foreachclient, tick);
+ clif_foreachclient(std::bind(mob_ai_sub_foreachclient, ph::_1, tick));
}
/*==========================================
* Negligent mode MOB AI (PC is not in near)
*------------------------------------------
*/
-static void mob_ai_sub_lazy(db_key_t key, db_val_t data, va_list app)
+static
+void mob_ai_sub_lazy(db_key_t, db_val_t data, unsigned int tick)
{
struct mob_data *md = (struct mob_data *)data;
- unsigned int tick;
- va_list ap;
nullpo_retv(md);
- nullpo_retv(app);
- nullpo_retv(ap = va_arg(app, va_list));
if (md == NULL)
return;
@@ -2259,8 +2242,6 @@ static void mob_ai_sub_lazy(db_key_t key, db_val_t data, va_list app)
if (!md->bl.type || md->bl.type != BL_MOB)
return;
- tick = va_arg(ap, unsigned int);
-
if (DIFF_TICK(tick, md->last_thinktime) < MIN_MOBTHINKTIME * 10)
return;
md->last_thinktime = tick;
@@ -2310,9 +2291,10 @@ static void mob_ai_sub_lazy(db_key_t key, db_val_t data, va_list app)
* Negligent processing for mob outside PC field of view (interval timer function)
*------------------------------------------
*/
-static void mob_ai_lazy(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+static
+void mob_ai_lazy(timer_id, tick_t tick, custom_id_t, custom_data_t)
{
- map_foreachiddb(mob_ai_sub_lazy, tick);
+ map_foreachiddb(std::bind(mob_ai_sub_lazy, ph::_1, ph::_2, tick));
}
/*==========================================
@@ -2339,7 +2321,8 @@ struct delay_item_drop2
* item drop with delay (timer function)
*------------------------------------------
*/
-static void mob_delay_item_drop(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+static
+void mob_delay_item_drop(timer_id, tick_t, custom_id_t id, custom_data_t)
{
struct delay_item_drop *ditem;
struct item temp_item;
@@ -2377,7 +2360,8 @@ static void mob_delay_item_drop(timer_id tid, tick_t tick, custom_id_t id, custo
* item drop (timer function)-lootitem with delay
*------------------------------------------
*/
-static void mob_delay_item_drop2(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+static
+void mob_delay_item_drop2(timer_id, tick_t, custom_id_t id, custom_data_t)
{
struct delay_item_drop2 *ditem;
int flag;
@@ -2440,7 +2424,7 @@ int mob_catch_delete(struct mob_data *md, int type)
return 0;
}
-void mob_timer_delete(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void mob_timer_delete(timer_id, tick_t, custom_id_t id, custom_data_t)
{
struct block_list *bl = map_id2bl(id);
struct mob_data *md;
@@ -2456,16 +2440,13 @@ void mob_timer_delete(timer_id tid, tick_t tick, custom_id_t id, custom_data_t d
*------------------------------------------
*/
static
-void mob_deleteslave_sub(struct block_list *bl, va_list ap)
+void mob_deleteslave_sub(struct block_list *bl, int id)
{
struct mob_data *md;
- int id;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(md = (struct mob_data *) bl);
+ md = (struct mob_data *) bl;
- id = va_arg(ap, int);
if (md->master_id > 0 && md->master_id == id)
mob_damage(NULL, md, md->hp, 1);
}
@@ -2478,9 +2459,9 @@ int mob_deleteslave(struct mob_data *md)
{
nullpo_retr(0, md);
- map_foreachinarea(mob_deleteslave_sub, md->bl.m,
- 0, 0, map[md->bl.m].xs, map[md->bl.m].ys,
- BL_MOB, md->bl.id);
+ map_foreachinarea(std::bind(mob_deleteslave_sub, ph::_1, md->bl.id),
+ md->bl.m, 0, 0,
+ map[md->bl.m].xs, map[md->bl.m].ys, BL_MOB);
return 0;
}
@@ -2508,7 +2489,7 @@ int mob_damage(struct block_list *src, struct mob_data *md, int damage,
unsigned int tick = gettick();
struct map_session_data *mvp_sd = NULL, *second_sd = NULL, *third_sd =
NULL;
- double dmg_rate, tdmg, temp;
+ double tdmg, temp;
struct item item;
int ret;
int skill, sp;
@@ -2729,12 +2710,6 @@ int mob_damage(struct block_list *src, struct mob_data *md, int damage,
// [MouseJstr]
if ((map[md->bl.m].flag.pvp == 0) || (battle_config.pvp_exp == 1))
{
-
- if ((double) max_hp < tdmg)
- dmg_rate = ((double) max_hp) / tdmg;
- else
- dmg_rate = 1;
-
// 経験値の分配
for (int i = 0; i < DAMAGELOG_SIZE; i++)
{
@@ -3107,13 +3082,10 @@ int mob_heal(struct mob_data *md, int heal)
*------------------------------------------
*/
static
-void mob_warpslave_sub(struct block_list *bl, va_list ap)
+void mob_warpslave_sub(struct block_list *bl, int id, int x, int y)
{
struct mob_data *md = (struct mob_data *) bl;
- int id, x, y;
- id = va_arg(ap, int);
- x = va_arg(ap, int);
- y = va_arg(ap, int);
+
if (md->master_id == id)
{
mob_warp(md, -1, x, y, 2);
@@ -3128,10 +3100,9 @@ static
int mob_warpslave(struct mob_data *md, int x, int y)
{
//printf("warp slave\n");
- map_foreachinarea(mob_warpslave_sub, md->bl.m,
- x - AREA_SIZE, y - AREA_SIZE,
- x + AREA_SIZE, y + AREA_SIZE, BL_MOB,
- md->bl.id, md->bl.x, md->bl.y);
+ map_foreachinarea(std::bind(mob_warpslave_sub, ph::_1, md->bl.id, md->bl.x, md->bl.y),
+ md->bl.m, x - AREA_SIZE, y - AREA_SIZE,
+ x + AREA_SIZE, y + AREA_SIZE, BL_MOB);
return 0;
}
@@ -3221,17 +3192,12 @@ int mob_warp(struct mob_data *md, int m, int x, int y, int type)
*------------------------------------------
*/
static
-void mob_countslave_sub(struct block_list *bl, va_list ap)
+void mob_countslave_sub(struct block_list *bl, int id, int *c)
{
- int id, *c;
struct mob_data *md;
- id = va_arg(ap, int);
-
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(c = va_arg(ap, int *));
- nullpo_retv(md = (struct mob_data *) bl);
+ md = (struct mob_data *) bl;
if (md->master_id == id)
(*c)++;
@@ -3248,9 +3214,9 @@ int mob_countslave(struct mob_data *md)
nullpo_retr(0, md);
- map_foreachinarea(mob_countslave_sub, md->bl.m,
- 0, 0, map[md->bl.m].xs - 1, map[md->bl.m].ys - 1,
- BL_MOB, md->bl.id, &c);
+ map_foreachinarea(std::bind(mob_countslave_sub, ph::_1, md->bl.id, &c),
+ md->bl.m, 0, 0,
+ map[md->bl.m].xs - 1, map[md->bl.m].ys - 1, BL_MOB);
return c;
}
@@ -3341,18 +3307,11 @@ int mob_summonslave(struct mob_data *md2, int *value, int amount, int flag)
*------------------------------------------
*/
static
-void mob_counttargeted_sub(struct block_list *bl, va_list ap)
+void mob_counttargeted_sub(struct block_list *bl, int id, int *c, struct block_list *src, int target_lv)
{
- int id, *c, target_lv;
- struct block_list *src;
-
- id = va_arg(ap, int);
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(c = va_arg(ap, int *));
+ nullpo_retv(c);
- src = va_arg(ap, struct block_list *);
- target_lv = va_arg(ap, int);
if (id == bl->id || (src && id == src->id))
return;
if (bl->type == BL_PC)
@@ -3382,10 +3341,9 @@ int mob_counttargeted(struct mob_data *md, struct block_list *src,
nullpo_retr(0, md);
- map_foreachinarea(mob_counttargeted_sub, md->bl.m,
- md->bl.x - AREA_SIZE, md->bl.y - AREA_SIZE,
- md->bl.x + AREA_SIZE, md->bl.y + AREA_SIZE, 0,
- md->bl.id, &c, src, target_lv);
+ map_foreachinarea(std::bind(mob_counttargeted_sub, ph::_1, md->bl.id, &c, src, target_lv),
+ md->bl.m, md->bl.x - AREA_SIZE, md->bl.y - AREA_SIZE,
+ md->bl.x + AREA_SIZE, md->bl.y + AREA_SIZE, 0);
return c;
}
@@ -3418,7 +3376,7 @@ int mob_skillid2skillidx(int mob_class, SkillID skillid)
* スキル使用(詠唱完了、ID指定)
*------------------------------------------
*/
-void mobskill_castend_id(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void mobskill_castend_id(timer_id tid, tick_t tick, custom_id_t id, custom_data_t)
{
struct mob_data *md = NULL;
struct block_list *bl;
@@ -3522,7 +3480,7 @@ void mobskill_castend_id(timer_id tid, tick_t tick, custom_id_t id, custom_data_
* スキル使用(詠唱完了、場所指定)
*------------------------------------------
*/
-void mobskill_castend_pos(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void mobskill_castend_pos(timer_id tid, tick_t tick, custom_id_t id, custom_data_t)
{
struct mob_data *md = NULL;
struct block_list *bl;
@@ -3870,21 +3828,18 @@ int mobskill_use_pos(struct mob_data *md,
*------------------------------------------
*/
static
-void mob_getfriendhpltmaxrate_sub(struct block_list *bl, va_list ap)
+void mob_getfriendhpltmaxrate_sub(struct block_list *bl, struct mob_data *mmd, int rate, struct mob_data **fr)
{
- int rate;
- struct mob_data **fr, *md, *mmd;
+ struct mob_data *md;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(mmd = va_arg(ap, struct mob_data *));
+ nullpo_retv(mmd);
md = (struct mob_data *) bl;
if (mmd->bl.id == bl->id)
return;
- rate = va_arg(ap, int);
- fr = va_arg(ap, struct mob_data **);
+
if (md->hp < mob_db[md->mob_class].max_hp * rate / 100)
(*fr) = md;
}
@@ -3897,9 +3852,9 @@ struct mob_data *mob_getfriendhpltmaxrate(struct mob_data *md, int rate)
nullpo_retr(NULL, md);
- map_foreachinarea(mob_getfriendhpltmaxrate_sub, md->bl.m,
- md->bl.x - r, md->bl.y - r, md->bl.x + r, md->bl.y + r,
- BL_MOB, md, rate, &fr);
+ map_foreachinarea(std::bind(mob_getfriendhpltmaxrate_sub, ph::_1, md, rate, &fr),
+ md->bl.m, md->bl.x - r, md->bl.y - r,
+ md->bl.x + r, md->bl.y + r, BL_MOB);
return fr;
}
@@ -3908,21 +3863,17 @@ struct mob_data *mob_getfriendhpltmaxrate(struct mob_data *md, int rate)
*------------------------------------------
*/
static
-void mob_getfriendstatus_sub(struct block_list *bl, va_list ap)
+void mob_getfriendstatus_sub(struct block_list *bl, struct mob_data *mmd, MSC cond1, StatusChange cond2, struct mob_data **fr)
{
- struct mob_data **fr, *md, *mmd;
+ struct mob_data *md;
int flag = 0;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(md = (struct mob_data *) bl);
- nullpo_retv(mmd = va_arg(ap, struct mob_data *));
+ md = (struct mob_data *) bl;
if (mmd->bl.id == bl->id)
return;
- MSC cond1 = va_arg(ap, MSC);
- StatusChange cond2 = va_arg(ap, StatusChange);
- fr = va_arg(ap, struct mob_data **);
+
if (cond2 == StatusChange::ANY_BAD)
{
for (StatusChange j : MAJOR_STATUS_EFFECTS)
@@ -3947,9 +3898,9 @@ struct mob_data *mob_getfriendstatus(struct mob_data *md,
nullpo_retr(0, md);
- map_foreachinarea(mob_getfriendstatus_sub, md->bl.m,
- md->bl.x - r, md->bl.y - r, md->bl.x + r, md->bl.y + r,
- BL_MOB, md, cond1, cond2, &fr);
+ map_foreachinarea(std::bind(mob_getfriendstatus_sub, ph::_1, md, cond1, cond2, &fr),
+ md->bl.m, md->bl.x - r, md->bl.y - r,
+ md->bl.x + r, md->bl.y + r, BL_MOB);
return fr;
}
@@ -4187,25 +4138,6 @@ int mobskill_event(struct mob_data *md, int flag)
return 0;
}
-/*==========================================
- * スキル用タイマー削除
- *------------------------------------------
- */
-int mobskill_deltimer(struct mob_data *md)
-{
- nullpo_retr(0, md);
-
- if (md->skilltimer != -1)
- {
- if (skill_get_inf(md->skillid) & 2)
- delete_timer(md->skilltimer, mobskill_castend_pos);
- else
- delete_timer(md->skilltimer, mobskill_castend_id);
- md->skilltimer = -1;
- }
- return 0;
-}
-
//
// 初期化
//
@@ -4213,7 +4145,8 @@ int mobskill_deltimer(struct mob_data *md)
* Since un-setting [ mob ] up was used, it is an initial provisional value setup.
*------------------------------------------
*/
-static int mob_makedummymobdb(int mob_class)
+static
+int mob_makedummymobdb(int mob_class)
{
int i;
@@ -4269,7 +4202,8 @@ static int mob_makedummymobdb(int mob_class)
* db/mob_db.txt reading
*------------------------------------------
*/
-static int mob_readdb(void)
+static
+int mob_readdb(void)
{
FILE *fp;
char line[1024];
@@ -4449,7 +4383,8 @@ static int mob_readdb(void)
* MOB display graphic change data reading
*------------------------------------------
*/
-static int mob_readdb_mobavail(void)
+static
+int mob_readdb_mobavail(void)
{
FILE *fp;
char line[1024];
@@ -4521,7 +4456,8 @@ static int mob_readdb_mobavail(void)
* Reading of random monster data
*------------------------------------------
*/
-static int mob_read_randommonster(void)
+static
+int mob_read_randommonster(void)
{
FILE *fp;
char line[1024];
@@ -4575,7 +4511,8 @@ static int mob_read_randommonster(void)
* db/mob_skill_db.txt reading
*------------------------------------------
*/
-static int mob_readskilldb(void)
+static
+int mob_readskilldb(void)
{
FILE *fp;
char line[1024];
diff --git a/src/map/mob.hpp b/src/map/mob.hpp
index 02197cf..e3bb0d6 100644
--- a/src/map/mob.hpp
+++ b/src/map/mob.hpp
@@ -1,9 +1,11 @@
-// $Id: mob.h,v 1.4 2004/09/25 05:32:18 MouseJstr Exp $
#ifndef MOB_HPP
#define MOB_HPP
#include "mob.t.hpp"
+
#include "../common/timer.hpp"
+
+#include "map.hpp"
#include "skill.t.hpp"
#define MAX_RANDOMMONSTER 3
@@ -111,4 +113,4 @@ int mob_summonslave(struct mob_data *md2, int *value, int amount, int flag);
void mob_reload(void);
-#endif
+#endif // MOB_HPP
diff --git a/src/map/mob.t.hpp b/src/map/mob.t.hpp
index edbbf40..3c20e07 100644
--- a/src/map/mob.t.hpp
+++ b/src/map/mob.t.hpp
@@ -1,6 +1,8 @@
#ifndef MOB_T_HPP
#define MOB_T_HPP
+#include <cstdint>
+
enum class MST
{
MST_TARGET = 0,
@@ -90,4 +92,4 @@ enum class MSS : uint8_t
#define MSS_CHASE MSS::MSS_CHASE
};
-#endif
+#endif // MOB_T_HPP
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index 87d8aba..2f84951 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -1,30 +1,26 @@
-// $Id: npc.c,v 1.5 2004/09/25 05:32:18 MouseJstr Exp $
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <math.h>
-#include <time.h>
+#include "npc.hpp"
+
+#include <cctype>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+#include "../common/db.hpp"
#include "../common/nullpo.hpp"
+#include "../common/socket.hpp"
#include "../common/timer.hpp"
#include "battle.hpp"
#include "clif.hpp"
-#include "../common/db.hpp"
#include "intif.hpp"
#include "itemdb.hpp"
#include "map.hpp"
#include "mob.hpp"
-#include "npc.hpp"
#include "pc.hpp"
#include "script.hpp"
#include "skill.hpp"
-#include "../common/socket.hpp"
-
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
struct npc_src_list
{
@@ -33,24 +29,30 @@ struct npc_src_list
char name[4];
};
-static struct npc_src_list *npc_src_first, *npc_src_last;
-static int npc_id = START_NPC_NUM;
-static int npc_warp, npc_shop, npc_script, npc_mob;
+static
+struct npc_src_list *npc_src_first, *npc_src_last;
+static
+int npc_id = START_NPC_NUM;
+static
+int npc_warp, npc_shop, npc_script, npc_mob;
int npc_get_new_npc_id(void)
{
return npc_id++;
}
-static struct dbt *ev_db;
-static struct dbt *npcname_db;
+static
+struct dbt *ev_db;
+static
+struct dbt *npcname_db;
struct event_data
{
struct npc_data *nd;
int pos;
};
-static struct tm ev_tm_b; // 時計イベント用
+static
+struct tm ev_tm_b; // 時計イベント用
/*==========================================
* NPCの無効化/有効化
@@ -59,15 +61,13 @@ static struct tm ev_tm_b; // 時計イベント用
*------------------------------------------
*/
static
-void npc_enable_sub(struct block_list *bl, va_list ap)
+void npc_enable_sub(struct block_list *bl, struct npc_data *nd)
{
struct map_session_data *sd;
- struct npc_data *nd;
char *name = (char *) calloc(50, sizeof(char));
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(nd = va_arg(ap, struct npc_data *));
+
if (bl->type == BL_PC && (sd = (struct map_session_data *) bl))
{
@@ -112,9 +112,9 @@ int npc_enable(const char *name, int flag)
clif_clearchar(&nd->bl, 0);
}
if (flag & 3 && (nd->u.scr.xs > 0 || nd->u.scr.ys > 0))
- map_foreachinarea(npc_enable_sub, nd->bl.m, nd->bl.x - nd->u.scr.xs,
- nd->bl.y - nd->u.scr.ys, nd->bl.x + nd->u.scr.xs,
- nd->bl.y + nd->u.scr.ys, BL_PC, nd);
+ map_foreachinarea(std::bind(npc_enable_sub, ph::_1, nd),
+ nd->bl.m, nd->bl.x - nd->u.scr.xs, nd->bl.y - nd->u.scr.ys,
+ nd->bl.x + nd->u.scr.xs, nd->bl.y + nd->u.scr.ys, BL_PC);
return 0;
}
@@ -172,7 +172,7 @@ int npc_delete(struct npc_data *nd)
* イベントの遅延実行
*------------------------------------------
*/
-void npc_event_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void npc_event_timer(timer_id, tick_t, custom_id_t id, custom_data_t data)
{
struct map_session_data *sd = map_id2sd(id);
if (sd == NULL)
@@ -199,113 +199,18 @@ int npc_timer_event(const char *eventname) // Added by RoVeRT
return 0;
}
-/*
-int npc_timer_sub_sub(void *key,void *data,va_list ap) // Added by RoVeRT
-{
- char *p= (char *)key;
- struct event_data *ev= (struct event_data *)data;
- int *c=va_arg(ap,int *);
- int tick=0,ctick=gettick();
- char temp[10];
- char event[100];
-
- if (ev->nd->bl.id== (int)*c && (p=strchr(p,':')) && p && strncasecmp("::OnTimer",p,8)==0 ){
- sscanf(&p[9],"%s",temp);
- tick=atoi(temp);
-
- strcpy( event, ev->nd->name);
- strcat( event, p);
-
- if (ctick >= ev->nd->lastaction && ctick - ev->nd->timer >= tick) {
- npc_timer_event(event);
- ev->nd->lastaction = ctick;
- }
- }
- return 0;
-}
-
-int npc_timer_sub(void *key,void *data,va_list ap) // Added by RoVeRT
-{
- struct npc_data *nd= (struct npc_data*)data;
-
- if (nd->timer == -1)
- return 0;
-
- strdb_foreach(ev_db,npc_timer_sub_sub,&nd->bl.id);
-
- return 0;
-}
-
-int npc_timer(int tid,unsigned int tick,int id,int data) // Added by RoVeRT
-{
- strdb_foreach(npcname_db,npc_timer_sub);
-
- free((void*)data);
- return 0;
-}*/
-/*==========================================
- * イベント用ラベルのエクスポート
- * npc_parse_script->strdb_foreachから呼ばれる
- *------------------------------------------
- */
-static
-int npc_event_export(void *key, void *data, va_list ap)
-{
- char *lname = (char *) key;
- int pos = (int) data;
- struct npc_data *nd = va_arg(ap, struct npc_data *);
-
- if ((lname[0] == 'O' || lname[0] == 'o')
- && (lname[1] == 'N' || lname[1] == 'n'))
- {
- struct event_data *ev;
- char *buf;
- char *p = strchr(lname, ':');
- // エクスポートされる
- CREATE(ev, struct event_data, 1);
- CREATE(buf, char, 50);
- if (p == NULL || (p - lname) > 24)
- {
- printf("npc_event_export: label name error !\n");
- exit(1);
- }
- else
- {
- ev->nd = nd;
- ev->pos = pos;
- *p = '\0';
- sprintf(buf, "%s::%s", nd->exname, lname);
- *p = ':';
- strdb_insert(ev_db, buf, ev);
-// if (battle_config.etc_log)
-// printf("npc_event_export: export [%s]\n",buf);
- }
- }
- return 0;
-}
-
/*==========================================
* 全てのNPCのOn*イベント実行
*------------------------------------------
*/
static
-void npc_event_doall_sub(db_key_t key, db_val_t data, va_list ap)
+void npc_event_doall_sub(db_key_t key, db_val_t data,
+ int *c, const char *name, int rid, int argc, argrec_t *argv)
{
const char *p = key.s;
- int rid, argc;
- argrec_t *argv;
struct event_data *ev;
- int *c;
- const char *name;
nullpo_retv(ev = (struct event_data *) data);
- nullpo_retv(ap);
- nullpo_retv(c = va_arg(ap, int *));
-
- name = va_arg(ap, const char *);
- rid = va_arg(ap, int);
- argc = va_arg(ap, int);
- argv = va_arg(ap, argrec_t *);
if ((p = strchr(p, ':')) && p && strcasecmp(name, p) == 0)
{
@@ -315,35 +220,25 @@ void npc_event_doall_sub(db_key_t key, db_val_t data, va_list ap)
}
}
-int npc_event_doall_l(const char *name, int rid, int argc, argrec_t * args)
+int npc_event_doall_l(const char *name, int rid, int argc, argrec_t *args)
{
int c = 0;
char buf[64] = "::";
strncpy(buf + 2, name, sizeof(buf)-3);
buf[sizeof(buf)-1] = '\0';
- strdb_foreach(ev_db, npc_event_doall_sub, &c, buf, rid, argc, args);
+ strdb_foreach(ev_db, std::bind(npc_event_doall_sub, ph::_1, ph::_2, &c, buf, rid, argc, args));
return c;
}
static
-void npc_event_do_sub(db_key_t key, db_val_t data, va_list ap)
+void npc_event_do_sub(db_key_t key, db_val_t data,
+ int *c, const char *name, int rid, int argc, argrec_t *argv)
{
const char *p = key.s;
struct event_data *ev;
- int *c;
- const char *name;
- int rid, argc;
- argrec_t *argv;
nullpo_retv(ev = (struct event_data *) data);
- nullpo_retv(ap);
- nullpo_retv(c = va_arg(ap, int *));
-
- name = va_arg(ap, const char *);
- rid = va_arg(ap, int);
- argc = va_arg(ap, int);
- argv = va_arg(ap, argrec_t *);
if (p && strcasecmp(name, p) == 0)
{
@@ -353,7 +248,7 @@ void npc_event_do_sub(db_key_t key, db_val_t data, va_list ap)
}
}
-int npc_event_do_l(const char *name, int rid, int argc, argrec_t * args)
+int npc_event_do_l(const char *name, int rid, int argc, argrec_t *args)
{
int c = 0;
@@ -362,7 +257,7 @@ int npc_event_do_l(const char *name, int rid, int argc, argrec_t * args)
return npc_event_doall_l(name + 2, rid, argc, args);
}
- strdb_foreach(ev_db, npc_event_do_sub, &c, name, rid, argc, args);
+ strdb_foreach(ev_db, std::bind(npc_event_do_sub, ph::_1, ph::_2, &c, name, rid, argc, args));
return c;
}
@@ -371,7 +266,7 @@ int npc_event_do_l(const char *name, int rid, int argc, argrec_t * args)
*------------------------------------------
*/
static
-void npc_event_do_clock(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void npc_event_do_clock(timer_id, tick_t, custom_id_t, custom_data_t)
{
time_t timer;
struct tm *t;
@@ -459,28 +354,12 @@ int npc_deleventtimer(struct npc_data *nd, const char *name)
return 0;
}
-static
-int npc_cleareventtimer(struct npc_data *nd)
-{
- int i;
- for (i = 0; i < MAX_EVENTTIMER; i++)
- if (nd->eventtimer[i] != -1)
- {
- delete_timer(nd->eventtimer[i], npc_event_timer);
- nd->eventtimer[i] = -1;
- }
-
- return 0;
-}
static
-void npc_do_ontimer_sub(db_key_t key, db_val_t data, va_list ap)
+void npc_do_ontimer_sub(db_key_t key, db_val_t data, int *c, int option)
{
const char *p = key.s;
struct event_data *ev = (struct event_data *) data;
- int *c = va_arg(ap, int *);
-// struct map_session_data *sd=va_arg(ap,struct map_session_data *);
- int option = va_arg(ap, int);
int tick = 0;
char temp[10];
char event[50];
@@ -505,55 +384,19 @@ void npc_do_ontimer_sub(db_key_t key, db_val_t data, va_list ap)
}
}
-int npc_do_ontimer(int id, struct map_session_data *sd, int option)
+int npc_do_ontimer(int id, struct map_session_data *, int option)
{
- strdb_foreach(ev_db, npc_do_ontimer_sub, &id, sd, option);
+ strdb_foreach(ev_db, std::bind(npc_do_ontimer_sub, ph::_1, ph::_2, &id, option));
return 0;
}
-/*==========================================
- * タイマーイベント用ラベルの取り込み
- * npc_parse_script->strdb_foreachから呼ばれる
- *------------------------------------------
- */
-static
-int npc_timerevent_import(void *key, void *data, va_list ap)
-{
- char *lname = (char *) key;
- int pos = (int) data;
- struct npc_data *nd = va_arg(ap, struct npc_data *);
- int t = 0, i = 0;
-
- if (sscanf(lname, "OnTimer%d%n", &t, &i) == 1 && lname[i] == ':')
- {
- // タイマーイベント
- struct npc_timerevent_list *te = nd->u.scr.timer_event;
- int j;
- i = nd->u.scr.timeramount;
- RECREATE(te, struct npc_timerevent_list, i+1);
- for (j = 0; j < i; j++)
- {
- if (te[j].timer > t)
- {
- memmove(te + j + 1, te + j,
- sizeof(struct npc_timerevent_list) * (i - j));
- break;
- }
- }
- te[j].timer = t;
- te[j].pos = pos;
- nd->u.scr.timer_event = te;
- nd->u.scr.timeramount = i + 1;
- }
- return 0;
-}
/*==========================================
* タイマーイベント実行
*------------------------------------------
*/
static
-void npc_timerevent(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void npc_timerevent(timer_id, tick_t tick, custom_id_t id, custom_data_t data)
{
int next, t;
struct npc_data *nd = (struct npc_data *) map_id2bl(id);
@@ -756,12 +599,10 @@ int npc_event(struct map_session_data *sd, const char *eventname,
}
static
-void npc_command_sub(db_key_t key, db_val_t data, va_list ap)
+void npc_command_sub(db_key_t key, db_val_t data, const char *npcname, const char *command)
{
const char *p = key.s;
struct event_data *ev = (struct event_data *) data;
- char *npcname = va_arg(ap, char *);
- char *command = va_arg(ap, char *);
char temp[100];
if (strcmp(ev->nd->name, npcname) == 0 && (p = strchr(p, ':')) && p
@@ -774,9 +615,9 @@ void npc_command_sub(db_key_t key, db_val_t data, va_list ap)
}
}
-int npc_command(struct map_session_data *sd, const char *npcname, const char *command)
+int npc_command(struct map_session_data *, const char *npcname, const char *command)
{
- strdb_foreach(ev_db, npc_command_sub, npcname, command);
+ strdb_foreach(ev_db, std::bind(npc_command_sub, ph::_1, ph::_2, npcname, command));
return 0;
}
@@ -1269,7 +1110,7 @@ void npc_delsrcfile(char *name)
* warp行解析
*------------------------------------------
*/
-int npc_parse_warp(const char *w1, const char *w2, const char *w3, const char *w4)
+int npc_parse_warp(const char *w1, const char *, const char *w3, const char *w4)
{
int x, y, xs, ys, to_x, to_y, m;
int i, j;
@@ -1345,7 +1186,8 @@ int npc_parse_warp(const char *w1, const char *w2, const char *w3, const char *w
* shop行解析
*------------------------------------------
*/
-static int npc_parse_shop(char *w1, char *w2, char *w3, char *w4)
+static
+int npc_parse_shop(char *w1, char *, char *w3, char *w4)
{
char *p;
int x, y, dir, m;
@@ -1445,18 +1287,16 @@ static int npc_parse_shop(char *w1, char *w2, char *w3, char *w4)
*------------------------------------------
*/
static
-void npc_convertlabel_db(db_key_t key, db_val_t data, va_list ap)
+void npc_convertlabel_db(db_key_t key, db_val_t data, struct npc_data *nd)
{
const char *lname = key.s;
int pos = (int) data;
- struct npc_data *nd;
struct npc_label_list *lst;
int num;
// this exists for evil purposes
char *p = const_cast<char *>(strchr(lname, ':'));
- nullpo_retv(ap);
- nullpo_retv(nd = va_arg(ap, struct npc_data *));
+ nullpo_retv(nd);
lst = nd->u.scr.label_list;
num = nd->u.scr.label_list_num;
@@ -1704,7 +1544,7 @@ int npc_parse_script(char *w1, char *w2, char *w3, char *w4,
// ラベルデータのコンバート
label_db = script_get_label_db();
- strdb_foreach(label_db, npc_convertlabel_db, nd);
+ strdb_foreach(label_db, std::bind(npc_convertlabel_db, ph::_1, ph::_2, nd));
// もう使わないのでバッファ解放
free(srcbuf);
@@ -1798,7 +1638,8 @@ int npc_parse_script(char *w1, char *w2, char *w3, char *w4,
* function行解析
*------------------------------------------
*/
-static int npc_parse_function(char *w1, char *w2, char *w3, char *w4,
+static
+int npc_parse_function(char *, char *, char *w3, char *,
char *first_line, FILE * fp, int *lines)
{
char *srcbuf = NULL;
@@ -1873,7 +1714,7 @@ static int npc_parse_function(char *w1, char *w2, char *w3, char *w4,
* mob行解析
*------------------------------------------
*/
-int npc_parse_mob(const char *w1, const char *w2, const char *w3, const char *w4)
+int npc_parse_mob(const char *w1, const char *, const char *w3, const char *w4)
{
int m, x, y, xs, ys, mob_class, num, delay1, delay2;
int i;
@@ -1960,7 +1801,8 @@ int npc_parse_mob(const char *w1, const char *w2, const char *w3, const char *w4
* マップフラグ行の解析
*------------------------------------------
*/
-static int npc_parse_mapflag(char *w1, char *w2, char *w3, char *w4)
+static
+int npc_parse_mapflag(char *w1, char *, char *w3, char *w4)
{
int m;
char mapname[24], savemap[16];
@@ -2124,7 +1966,8 @@ static int npc_parse_mapflag(char *w1, char *w2, char *w3, char *w4)
return 0;
}
-static void ev_db_final(db_key_t key, db_val_t data, va_list ap)
+static
+void ev_db_final(db_key_t key, db_val_t data)
{
free(data);
if (strstr(key.s, "::") != NULL)
@@ -2161,7 +2004,8 @@ struct npc_data *npc_spawn_text(int m, int x, int y,
return retval;
}
-static void npc_free_internal(struct npc_data *nd)
+static
+void npc_free_internal(struct npc_data *nd)
{
struct chat_data *cd;
@@ -2198,11 +2042,9 @@ static void npc_free_internal(struct npc_data *nd)
static
void npc_propagate_update(struct npc_data *nd)
{
- map_foreachinarea(npc_enable_sub,
- nd->bl.m,
- nd->bl.x - nd->u.scr.xs, nd->bl.y - nd->u.scr.ys,
- nd->bl.x + nd->u.scr.xs, nd->bl.y + nd->u.scr.ys,
- BL_PC, nd);
+ map_foreachinarea(std::bind(npc_enable_sub, ph::_1, nd),
+ nd->bl.m, nd->bl.x - nd->u.scr.xs, nd->bl.y - nd->u.scr.ys,
+ nd->bl.x + nd->u.scr.xs, nd->bl.y + nd->u.scr.ys, BL_PC);
}
void npc_free(struct npc_data *nd)
diff --git a/src/map/npc.hpp b/src/map/npc.hpp
index cea585b..f6d0adc 100644
--- a/src/map/npc.hpp
+++ b/src/map/npc.hpp
@@ -1,7 +1,8 @@
-// $Id: npc.h,v 1.5 2004/09/25 11:39:17 MouseJstr Exp $
#ifndef NPC_HPP
#define NPC_HPP
+#include "../common/timer.hpp"
+
#define START_NPC_NUM 110000000
#define WARP_CLASS 45
@@ -61,4 +62,4 @@ int npc_gettimerevent_tick(struct npc_data *nd);
int npc_settimerevent_tick(struct npc_data *nd, int newtimer);
int npc_delete(struct npc_data *nd);
-#endif
+#endif // NPC_HPP
diff --git a/src/map/party.cpp b/src/map/party.cpp
index c08c9fc..0c6e20e 100644
--- a/src/map/party.cpp
+++ b/src/map/party.cpp
@@ -1,35 +1,34 @@
-// $Id: party.c,v 1.2 2004/09/22 02:59:47 Akitasha Exp $
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "party.hpp"
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
#include "../common/db.hpp"
-#include "../common/timer.hpp"
-#include "../common/socket.hpp"
#include "../common/nullpo.hpp"
-#include "pc.hpp"
-#include "map.hpp"
+#include "../common/socket.hpp"
+#include "../common/timer.hpp"
+
#include "battle.hpp"
-#include "intif.hpp"
#include "clif.hpp"
+#include "intif.hpp"
+#include "map.hpp"
+#include "pc.hpp"
#include "skill.hpp"
#include "tmw.hpp"
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
-
#define PARTY_SEND_XYHP_INVERVAL 1000 // 座標やHP送信の間隔
-static struct dbt *party_db;
+static
+struct dbt *party_db;
void party_send_xyhp_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data);
/*==========================================
* 終了
*------------------------------------------
*/
-static void party_db_final(db_key_t key, db_val_t data, va_list ap)
+static
+void party_db_final(db_key_t, db_val_t data)
{
free(data);
}
@@ -56,12 +55,9 @@ struct party *party_search(int party_id)
}
static
-void party_searchname_sub(db_key_t key, db_val_t data, va_list ap)
+void party_searchname_sub(db_key_t, db_val_t data, const char *str, struct party **dst)
{
- struct party *p = (struct party *) data, **dst;
- const char *str;
- str = va_arg(ap, const char *);
- dst = va_arg(ap, struct party **);
+ struct party *p = (struct party *) data;
if (strcasecmp(p->name, str) == 0)
*dst = p;
}
@@ -70,7 +66,7 @@ void party_searchname_sub(db_key_t key, db_val_t data, va_list ap)
struct party *party_searchname(const char *str)
{
struct party *p = NULL;
- numdb_foreach(party_db, party_searchname_sub, str, &p);
+ numdb_foreach(party_db, std::bind(party_searchname_sub, ph::_1, ph::_2, str, &p));
return p;
}
@@ -383,8 +379,7 @@ int party_member_added(int party_id, int account_id, int flag)
}
// パーティ除名要求
-int party_removemember(struct map_session_data *sd, int account_id,
- const char *name)
+int party_removemember(struct map_session_data *sd, int account_id, const char *)
{
struct party *p;
int i;
@@ -514,7 +509,7 @@ int party_optionchanged(int party_id, int account_id, int exp, int item,
}
// パーティメンバの移動通知
-int party_recv_movemap(int party_id, int account_id, const char *map, int online,
+int party_recv_movemap(int party_id, int account_id, const char *mapname, int online,
int lv)
{
struct party *p;
@@ -531,7 +526,7 @@ int party_recv_movemap(int party_id, int account_id, const char *map, int online
}
if (m->account_id == account_id)
{
- memcpy(m->map, map, 16);
+ memcpy(m->map, mapname, 16);
m->online = online;
m->lv = lv;
break;
@@ -644,7 +639,7 @@ int party_check_conflict(struct map_session_data *sd)
// 位置やHP通知用
static
-void party_send_xyhp_timer_sub(db_key_t key, db_val_t data, va_list ap)
+void party_send_xyhp_timer_sub(db_key_t, db_val_t data)
{
struct party *p = (struct party *) data;
int i;
@@ -675,9 +670,9 @@ void party_send_xyhp_timer_sub(db_key_t key, db_val_t data, va_list ap)
}
// 位置やHP通知
-void party_send_xyhp_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void party_send_xyhp_timer(timer_id, tick_t, custom_id_t, custom_data_t)
{
- numdb_foreach(party_db, party_send_xyhp_timer_sub, tick);
+ numdb_foreach(party_db, party_send_xyhp_timer_sub);
}
// 位置通知クリア
@@ -701,18 +696,12 @@ int party_send_xy_clear(struct party *p)
}
// HP通知の必要性検査用(map_foreachinmoveareaから呼ばれる)
-void party_send_hp_check(struct block_list *bl, va_list ap)
+void party_send_hp_check(struct block_list *bl, int party_id, int *flag)
{
- int party_id;
- int *flag;
struct map_session_data *sd;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(sd = (struct map_session_data *) bl);
-
- party_id = va_arg(ap, int);
- flag = va_arg(ap, int *);
+ sd = (struct map_session_data *) bl;
if (sd->status.party_id == party_id)
{
@@ -722,7 +711,7 @@ void party_send_hp_check(struct block_list *bl, va_list ap)
}
// 経験値公平分配
-int party_exp_share(struct party *p, int map, int base_exp, int job_exp)
+int party_exp_share(struct party *p, int mapid, int base_exp, int job_exp)
{
struct map_session_data *sd;
int i, c;
@@ -730,12 +719,12 @@ int party_exp_share(struct party *p, int map, int base_exp, int job_exp)
nullpo_retr(0, p);
for (i = c = 0; i < MAX_PARTY; i++)
- if ((sd = p->member[i].sd) != NULL && sd->bl.m == map)
+ if ((sd = p->member[i].sd) != NULL && sd->bl.m == mapid)
c++;
if (c == 0)
return 0;
for (i = 0; i < MAX_PARTY; i++)
- if ((sd = p->member[i].sd) != NULL && sd->bl.m == map)
+ if ((sd = p->member[i].sd) != NULL && sd->bl.m == mapid)
pc_gainexp(sd, base_exp / c + 1, job_exp / c + 1);
return 0;
}
@@ -743,11 +732,10 @@ int party_exp_share(struct party *p, int map, int base_exp, int job_exp)
// 同じマップのパーティメンバー全体に処理をかける
// type==0 同じマップ
// !=0 画面内
-void party_foreachsamemap(void(*func)(struct block_list *, va_list),
- struct map_session_data *sd, int type, ...)
+void party_foreachsamemap(std::function<void(struct block_list *)> func,
+ struct map_session_data *sd, int type)
{
struct party *p;
- va_list ap;
int i;
int x0, y0, x1, y1;
struct block_list *list[MAX_PARTY];
@@ -763,8 +751,6 @@ void party_foreachsamemap(void(*func)(struct block_list *, va_list),
x1 = sd->bl.x + AREA_SIZE;
y1 = sd->bl.y + AREA_SIZE;
- va_start(ap, type);
-
for (i = 0; i < MAX_PARTY; i++)
{
struct party_member *m = &p->member[i];
@@ -784,9 +770,7 @@ void party_foreachsamemap(void(*func)(struct block_list *, va_list),
for (i = 0; i < blockcount; i++)
if (list[i]->prev) // 有効かどうかチェック
- func(list[i], ap);
+ func(list[i]);
map_freeblock_unlock(); // 解放を許可する
-
- va_end(ap);
}
diff --git a/src/map/party.hpp b/src/map/party.hpp
index 6ab5979..853087e 100644
--- a/src/map/party.hpp
+++ b/src/map/party.hpp
@@ -1,8 +1,7 @@
-// $Id: party.h,v 1.3 2004/09/25 05:32:18 MouseJstr Exp $
#ifndef PARTY_HPP
#define PARTY_HPP
-#include <stdarg.h>
+#include <functional>
struct party;
struct map_session_data;
@@ -42,11 +41,11 @@ int party_recv_message(int party_id, int account_id, const char *mes, int len);
int party_check_conflict(struct map_session_data *sd);
int party_send_xy_clear(struct party *p);
-void party_send_hp_check(struct block_list *bl, va_list ap);
+void party_send_hp_check(struct block_list *bl, int party_id, int *flag);
int party_exp_share(struct party *p, int map, int base_exp, int job_exp);
-void party_foreachsamemap(void(*func)(struct block_list *, va_list),
- struct map_session_data *sd, int type, ...);
+void party_foreachsamemap(std::function<void(struct block_list *)> func,
+ struct map_session_data *sd, int type);
-#endif
+#endif // PARTY_HPP
diff --git a/src/map/path.cpp b/src/map/path.cpp
index a5662c6..fb5eedf 100644
--- a/src/map/path.cpp
+++ b/src/map/path.cpp
@@ -1,15 +1,11 @@
-// $Id: path.c,v 1.1.1.1 2004/09/10 17:27:00 MagicalTux Exp $
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
-#include "map.hpp"
-#include "battle.hpp"
#include "../common/nullpo.hpp"
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
+#include "battle.hpp"
+#include "map.hpp"
//#define PATH_STANDALONETEST
@@ -25,7 +21,8 @@ struct tmp_path
* 経路探索補助heap push
*------------------------------------------
*/
-static void push_heap_path(int *heap, struct tmp_path *tp, int index)
+static
+void push_heap_path(int *heap, struct tmp_path *tp, int index)
{
int i, h;
@@ -48,7 +45,8 @@ static void push_heap_path(int *heap, struct tmp_path *tp, int index)
* costが減ったので根の方へ移動
*------------------------------------------
*/
-static void update_heap_path(int *heap, struct tmp_path *tp, int index)
+static
+void update_heap_path(int *heap, struct tmp_path *tp, int index)
{
int i, h;
@@ -73,7 +71,8 @@ static void update_heap_path(int *heap, struct tmp_path *tp, int index)
* 経路探索補助heap pop
*------------------------------------------
*/
-static int pop_heap_path(int *heap, struct tmp_path *tp)
+static
+int pop_heap_path(int *heap, struct tmp_path *tp)
{
int i, h, k;
int ret, last;
@@ -108,7 +107,8 @@ static int pop_heap_path(int *heap, struct tmp_path *tp)
* 現在の点のcost計算
*------------------------------------------
*/
-static int calc_cost(struct tmp_path *p, int x1, int y1)
+static
+int calc_cost(struct tmp_path *p, int x1, int y1)
{
int xd, yd;
@@ -127,7 +127,8 @@ static int calc_cost(struct tmp_path *p, int x1, int y1)
* 必要ならpathを追加/修正する
*------------------------------------------
*/
-static int add_path(int *heap, struct tmp_path *tp, int x, int y, int dist,
+static
+int add_path(int *heap, struct tmp_path *tp, int x, int y, int dist,
int dir, int before, int x1, int y1)
{
int i;
@@ -174,7 +175,8 @@ static int add_path(int *heap, struct tmp_path *tp, int x, int y, int dist,
* flag 0x10000 遠距離攻撃判定
*------------------------------------------
*/
-static int can_place(struct map_data *m, int x, int y, int flag)
+static
+int can_place(struct map_data *m, int x, int y, int flag)
{
int c;
@@ -193,7 +195,8 @@ static int can_place(struct map_data *m, int x, int y, int flag)
* (x0,y0)から(x1,y1)へ1歩で移動可能か計算
*------------------------------------------
*/
-static int can_move(struct map_data *m, int x0, int y0, int x1, int y1,
+static
+int can_move(struct map_data *m, int x0, int y0, int x1, int y1,
int flag)
{
nullpo_retr(0, m);
@@ -341,7 +344,7 @@ int path_search(struct walkpath_data *wpd, int m, int x0, int y0, int x1,
push_heap_path(heap, tp, calc_index(x0, y0));
while (1)
{
- int e = 0, fromdir;
+ int e = 0;
if (heap[0] == 0)
return -1;
@@ -364,7 +367,6 @@ int path_search(struct walkpath_data *wpd, int m, int x0, int y0, int x1,
return 0;
}
- fromdir = tp[rp].dir;
if (can_move(md, x, y, x + 1, y - 1, flag))
e += add_path(heap, tp, x + 1, y - 1, tp[rp].dist + 14, 5, rp,
x1, y1);
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 6446044..258af27 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -1,16 +1,16 @@
-// $Id: pc.c 101 2004-09-25 17:57:22Z Valaris $
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <time.h>
-
-#include "../common/socket.hpp" // [Valaris]
-#include "../common/timer.hpp"
-#include "../common/db.hpp"
+#include "pc.hpp"
-#include "../common/nullpo.hpp"
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+
+#include "../common/db.hpp"
#include "../common/mt_rand.hpp"
+#include "../common/nullpo.hpp"
+#include "../common/socket.hpp"
+#include "../common/timer.hpp"
#include "atcommand.hpp"
#include "battle.hpp"
@@ -23,16 +23,11 @@
#include "mob.hpp"
#include "npc.hpp"
#include "party.hpp"
-#include "pc.hpp"
#include "script.hpp"
#include "skill.hpp"
#include "storage.hpp"
#include "trade.hpp"
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
-
#define PVP_CALCRANK_INTERVAL 1000 // PVP順位計算の間隔
//define it here, since the ifdef only occurs in this file
@@ -66,16 +61,26 @@
timer_id day_timer_tid;
timer_id night_timer_tid;
-static int max_weight_base[MAX_PC_CLASS];
-static int hp_coefficient[MAX_PC_CLASS];
-static int hp_coefficient2[MAX_PC_CLASS];
-static int hp_sigma_val[MAX_PC_CLASS][MAX_LEVEL];
-static int sp_coefficient[MAX_PC_CLASS];
-static int aspd_base[MAX_PC_CLASS][20];
-static char job_bonus[3][MAX_PC_CLASS][MAX_LEVEL];
-static int exp_table[14][MAX_LEVEL];
-static char statp[255][7];
-static struct
+static
+int max_weight_base[MAX_PC_CLASS];
+static
+int hp_coefficient[MAX_PC_CLASS];
+static
+int hp_coefficient2[MAX_PC_CLASS];
+static
+int hp_sigma_val[MAX_PC_CLASS][MAX_LEVEL];
+static
+int sp_coefficient[MAX_PC_CLASS];
+static
+int aspd_base[MAX_PC_CLASS][20];
+static
+char job_bonus[3][MAX_PC_CLASS][MAX_LEVEL];
+static
+int exp_table[14][MAX_LEVEL];
+static
+char statp[255][7];
+static
+struct
{
SkillID id;
int max;
@@ -86,21 +91,29 @@ static struct
} need[6];
} skill_tree[3][MAX_PC_CLASS][100];
-static int atkmods[3][20]; // 武器ATKサイズ修正(size_fix.txt)
-static int refinebonus[5][3]; // 精錬ボーナステーブル(refine_db.txt)
-static int percentrefinery[5][10]; // 精錬成功率(refine_db.txt)
+static
+int atkmods[3][20]; // 武器ATKサイズ修正(size_fix.txt)
+static
+int refinebonus[5][3]; // 精錬ボーナステーブル(refine_db.txt)
+static
+int percentrefinery[5][10]; // 精錬成功率(refine_db.txt)
-static int dirx[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
-static int diry[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
+static
+int dirx[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
+static
+int diry[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
-static unsigned int equip_pos[11] =
+static
+unsigned int equip_pos[11] =
{ 0x0080, 0x0008, 0x0040, 0x0004, 0x0001, 0x0200, 0x0100, 0x0010, 0x0020,
0x0002, 0x8000
};
//static struct dbt *gm_account_db;
-static struct gm_account *gm_account = NULL;
-static int GM_num = 0;
+static
+struct gm_account *gm_account = NULL;
+static
+int GM_num = 0;
int pc_isGM(struct map_session_data *sd)
{
@@ -165,7 +178,8 @@ int pc_getrefinebonus(int lv, int type)
return 0;
}
-static int distance(int x0, int y0, int x1, int y1)
+static
+int distance(int x0, int y0, int x1, int y1)
{
int dx, dy;
@@ -174,7 +188,8 @@ static int distance(int x0, int y0, int x1, int y1)
return dx > dy ? dx : dy;
}
-static void pc_invincible_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+static
+void pc_invincible_timer(timer_id tid, tick_t, custom_id_t id, custom_data_t)
{
struct map_session_data *sd;
@@ -214,7 +229,8 @@ int pc_delinvincibletimer(struct map_session_data *sd)
return 0;
}
-static void pc_spiritball_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+static
+void pc_spiritball_timer(timer_id tid, tick_t, custom_id_t id, custom_data_t)
{
struct map_session_data *sd;
int i;
@@ -384,20 +400,10 @@ int pc_setrestartvalue(struct map_session_data *sd, int type)
*------------------------------------------
*/
static
-void pc_counttargeted_sub(struct block_list *bl, va_list ap)
+void pc_counttargeted_sub(struct block_list *bl, int id, int *c, struct block_list *src, int target_lv)
{
- int id, *c, target_lv;
- struct block_list *src;
-
nullpo_retv(bl);
- nullpo_retv(ap);
-
- id = va_arg(ap, int);
-
- nullpo_retv(c = va_arg(ap, int *));
- src = va_arg(ap, struct block_list *);
- target_lv = va_arg(ap, int);
if (id == bl->id || (src && id == src->id))
return;
if (bl->type == BL_PC)
@@ -422,10 +428,9 @@ int pc_counttargeted(struct map_session_data *sd, struct block_list *src,
int target_lv)
{
int c = 0;
- map_foreachinarea(pc_counttargeted_sub, sd->bl.m,
- sd->bl.x - AREA_SIZE, sd->bl.y - AREA_SIZE,
- sd->bl.x + AREA_SIZE, sd->bl.y + AREA_SIZE, 0,
- sd->bl.id, &c, src, target_lv);
+ map_foreachinarea(std::bind(pc_counttargeted_sub, ph::_1, sd->bl.id, &c, src, target_lv),
+ sd->bl.m, sd->bl.x - AREA_SIZE, sd->bl.y - AREA_SIZE,
+ sd->bl.x + AREA_SIZE, sd->bl.y + AREA_SIZE, 0);
return c;
}
@@ -433,7 +438,8 @@ int pc_counttargeted(struct map_session_data *sd, struct block_list *src,
* ローカルプロトタイプ宣言 (必要な物のみ)
*------------------------------------------
*/
-static int pc_walktoxy_sub(struct map_session_data *);
+static
+int pc_walktoxy_sub(struct map_session_data *);
/*==========================================
* saveに必要なステータス修正を行なう
@@ -484,7 +490,7 @@ int pc_makesavestatus(struct map_session_data *sd)
*------------------------------------------
*/
int pc_setnewpc(struct map_session_data *sd, int account_id, int char_id,
- int login_id1, int client_tick, int sex, int fd)
+ int login_id1, int client_tick, int sex, int)
{
nullpo_retr(0, sd);
@@ -992,7 +998,8 @@ int pc_authfail(int id)
return 0;
}
-static int pc_calc_skillpoint(struct map_session_data *sd)
+static
+int pc_calc_skillpoint(struct map_session_data *sd)
{
int i, skill_points = 0;
@@ -1014,7 +1021,7 @@ static int pc_calc_skillpoint(struct map_session_data *sd)
static
int pc_calc_skilltree(struct map_session_data *sd)
{
- int i, id = 0, flag;
+ int flag;
int c = 0, s = 0;
//転生や養子の場合の元の職業を算出する
struct pc_base_job s_class;
@@ -1158,7 +1165,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
{
flag = 0;
SkillID id;
- for (i = 0;
+ for (int i = 0;
(id = skill_tree[s][c][i].id) != SkillID::ZERO
&& id != SkillID::NEGATIVE;
i++)
@@ -1253,7 +1260,7 @@ int pc_calcstatus(struct map_session_data *sd, int first)
b_attackrange, b_matk1, b_matk2, b_mdef, b_mdef2, b_class;
int b_base_atk;
earray<struct skill, SkillID, MAX_SKILL> b_skill;
- int i, bl, index;
+ int bl, index;
int skill, aspd_rate, wele, wele_, def_ele, refinedef = 0;
int str, dstr, dex;
struct pc_base_job s_class;
@@ -1298,7 +1305,7 @@ int pc_calcstatus(struct map_session_data *sd, int first)
if (first & 1)
{
sd->weight = 0;
- for (i = 0; i < MAX_INVENTORY; i++)
+ for (int i = 0; i < MAX_INVENTORY; i++)
{
if (sd->status.inventory[i].nameid == 0
|| sd->inventory_data[i] == NULL)
@@ -1311,7 +1318,7 @@ int pc_calcstatus(struct map_session_data *sd, int first)
sd->cart_weight = 0;
sd->cart_max_num = MAX_CART;
sd->cart_num = 0;
- for (i = 0; i < MAX_CART; i++)
+ for (int i = 0; i < MAX_CART; i++)
{
if (sd->status.cart[i].nameid == 0)
continue;
@@ -1449,7 +1456,7 @@ int pc_calcstatus(struct map_session_data *sd, int first)
sd->spellpower_bonus_target = 0;
- for (i = 0; i < 10; i++)
+ for (int i = 0; i < 10; i++)
{
index = sd->equip_index[i];
if (index < 0)
@@ -1535,7 +1542,7 @@ int pc_calcstatus(struct map_session_data *sd, int first)
memcpy(sd->paramcard, sd->parame, sizeof(sd->paramcard));
// 装備品によるステータス変化はここで実行
- for (i = 0; i < 10; i++)
+ for (int i = 0; i < 10; i++)
{
index = sd->equip_index[i];
if (index < 0)
@@ -1634,7 +1641,7 @@ int pc_calcstatus(struct map_session_data *sd, int first)
{ //まだ属性が入っていない
argrec_t arg[2];
arg[0].name = "@slotId";
- arg[0].v.i = i;
+ arg[0].v.i = 10;
arg[1].name = "@itemId";
arg[1].v.i = sd->inventory_data[index]->nameid;
sd->state.lr_flag = 2;
@@ -1767,7 +1774,7 @@ int pc_calcstatus(struct map_session_data *sd, int first)
sd->paramc[3] = sd->status.int_ + sd->paramb[3] + sd->parame[3];
sd->paramc[4] = sd->status.dex + sd->paramb[4] + sd->parame[4];
sd->paramc[5] = sd->status.luk + sd->paramb[5] + sd->parame[5];
- for (i = 0; i < 6; i++)
+ for (int i = 0; i < 6; i++)
if (sd->paramc[i] < 0)
sd->paramc[i] = 0;
@@ -2424,7 +2431,7 @@ int pc_calcstatus(struct map_session_data *sd, int first)
clif_updatestatus(sd, SP_MAXWEIGHT);
pc_checkweighticon(sd);
}
- for (i = 0; i < 6; i++)
+ for (int i = 0; i < 6; i++)
if (b_paramb[i] + b_parame[i] != sd->paramb[i] + sd->parame[i])
clif_updatestatus(sd, SP_STR + i);
if (b_hit != sd->hit)
@@ -3569,7 +3576,8 @@ int pc_dropitem(struct map_session_data *sd, int n, int amount)
*------------------------------------------
*/
-static int can_pick_item_up_from(struct map_session_data *self, int other_id)
+static
+int can_pick_item_up_from(struct map_session_data *self, int other_id)
{
struct party *p = party_search(self->status.party_id);
@@ -3705,13 +3713,12 @@ int pc_isUseitem(struct map_session_data *sd, int n)
*/
int pc_useitem(struct map_session_data *sd, int n)
{
- int nameid, amount;
+ int amount;
nullpo_retr(1, sd);
if (n >= 0 && n < MAX_INVENTORY && sd->inventory_data[n])
{
- nameid = sd->status.inventory[n].nameid;
amount = sd->status.inventory[n].amount;
if (sd->status.inventory[n].nameid <= 0
|| sd->status.inventory[n].amount <= 0
@@ -3927,21 +3934,14 @@ int pc_item_identify(struct map_session_data *sd, int idx)
*------------------------------------------
*/
static
-void pc_show_steal(struct block_list *bl, va_list ap)
+void pc_show_steal(struct block_list *bl,
+ struct map_session_data *sd, int itemid, int type)
{
- struct map_session_data *sd;
- int itemid;
- int type;
-
struct item_data *item = NULL;
char output[100];
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(sd = va_arg(ap, struct map_session_data *));
-
- itemid = va_arg(ap, int);
- type = va_arg(ap, int);
+ nullpo_retv(sd);
if (!type)
{
@@ -4005,17 +4005,16 @@ int pc_steal_item(struct map_session_data *sd, struct block_list *bl)
flag = pc_additem(sd, &tmp_item, 1);
if (battle_config.show_steal_in_same_party)
{
- party_foreachsamemap(pc_show_steal, sd, 1,
- sd, tmp_item.nameid, 0);
+ party_foreachsamemap(
+ std::bind(pc_show_steal, ph::_1, sd, tmp_item.nameid, 0), sd, 1);
}
if (flag)
{
if (battle_config.show_steal_in_same_party)
{
- party_foreachsamemap(pc_show_steal, sd,
- 1, sd,
- tmp_item.nameid, 1);
+ party_foreachsamemap(
+ std::bind(pc_show_steal, ph::_1, sd, tmp_item.nameid, 1), sd, 1);
}
clif_additem(sd, 0, 0, flag);
@@ -4322,7 +4321,8 @@ int pc_can_reach(struct map_session_data *sd, int x, int y)
* 次の1歩にかかる時間を計算
*------------------------------------------
*/
-static int calc_next_walk_step(struct map_session_data *sd)
+static
+int calc_next_walk_step(struct map_session_data *sd)
{
nullpo_retr(0, sd);
@@ -4338,7 +4338,8 @@ static int calc_next_walk_step(struct map_session_data *sd)
* 半歩進む(timer関数)
*------------------------------------------
*/
-static void pc_walk(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+static
+void pc_walk(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
{
struct map_session_data *sd;
int i, ctype;
@@ -4401,9 +4402,11 @@ static void pc_walk(timer_id tid, tick_t tick, custom_id_t id, custom_data_t dat
|| y / BLOCK_SIZE != (y + dy) / BLOCK_SIZE);
sd->walktimer = 1;
- map_foreachinmovearea(clif_pcoutsight, sd->bl.m, x - AREA_SIZE,
- y - AREA_SIZE, x + AREA_SIZE, y + AREA_SIZE,
- dx, dy, 0, sd);
+ map_foreachinmovearea(std::bind(clif_pcoutsight, ph::_1, sd),
+ sd->bl.m, x - AREA_SIZE, y - AREA_SIZE,
+ x + AREA_SIZE, y + AREA_SIZE,
+ dx, dy,
+ 0);
x += dx;
y += dy;
@@ -4420,9 +4423,11 @@ static void pc_walk(timer_id tid, tick_t tick, custom_id_t id, custom_data_t dat
sd->sc_data[SC_DANCING].val2,
sd->bl.m, dx, dy);
- map_foreachinmovearea(clif_pcinsight, sd->bl.m, x - AREA_SIZE,
- y - AREA_SIZE, x + AREA_SIZE, y + AREA_SIZE,
- -dx, -dy, 0, sd);
+ map_foreachinmovearea(std::bind(clif_pcinsight, ph::_1, sd),
+ sd->bl.m, x - AREA_SIZE, y - AREA_SIZE,
+ x + AREA_SIZE, y + AREA_SIZE,
+ -dx, -dy,
+ 0);
sd->walktimer = -1;
if (sd->status.party_id > 0)
@@ -4431,10 +4436,11 @@ static void pc_walk(timer_id tid, tick_t tick, custom_id_t id, custom_data_t dat
if (p != NULL)
{
int p_flag = 0;
- map_foreachinmovearea(party_send_hp_check, sd->bl.m,
- x - AREA_SIZE, y - AREA_SIZE,
- x + AREA_SIZE, y + AREA_SIZE, -dx, -dy,
- BL_PC, sd->status.party_id, &p_flag);
+ map_foreachinmovearea(std::bind(party_send_hp_check, ph::_1, sd->status.party_id, &p_flag),
+ sd->bl.m, x - AREA_SIZE, y - AREA_SIZE,
+ x + AREA_SIZE, y + AREA_SIZE,
+ -dx, -dy,
+ BL_PC);
if (p_flag)
sd->party_hp = -1;
}
@@ -4475,7 +4481,8 @@ static void pc_walk(timer_id tid, tick_t tick, custom_id_t id, custom_data_t dat
* 移動可能か確認して、可能なら歩行開始
*------------------------------------------
*/
-static int pc_walktoxy_sub(struct map_session_data *sd)
+static
+int pc_walktoxy_sub(struct map_session_data *sd)
{
struct walkpath_data wpd;
int i;
@@ -4590,9 +4597,11 @@ int pc_movepos(struct map_session_data *sd, int dst_x, int dst_y)
moveblock = (sd->bl.x / BLOCK_SIZE != dst_x / BLOCK_SIZE
|| sd->bl.y / BLOCK_SIZE != dst_y / BLOCK_SIZE);
- map_foreachinmovearea(clif_pcoutsight, sd->bl.m, sd->bl.x - AREA_SIZE,
- sd->bl.y - AREA_SIZE, sd->bl.x + AREA_SIZE,
- sd->bl.y + AREA_SIZE, dx, dy, 0, sd);
+ map_foreachinmovearea(std::bind(clif_pcoutsight, ph::_1, sd),
+ sd->bl.m, sd->bl.x - AREA_SIZE, sd->bl.y - AREA_SIZE,
+ sd->bl.x + AREA_SIZE, sd->bl.y + AREA_SIZE,
+ dx, dy,
+ 0);
if (moveblock)
map_delblock(&sd->bl);
@@ -4601,9 +4610,11 @@ int pc_movepos(struct map_session_data *sd, int dst_x, int dst_y)
if (moveblock)
map_addblock(&sd->bl);
- map_foreachinmovearea(clif_pcinsight, sd->bl.m, sd->bl.x - AREA_SIZE,
- sd->bl.y - AREA_SIZE, sd->bl.x + AREA_SIZE,
- sd->bl.y + AREA_SIZE, -dx, -dy, 0, sd);
+ map_foreachinmovearea(std::bind(clif_pcinsight, ph::_1, sd),
+ sd->bl.m, sd->bl.x - AREA_SIZE, sd->bl.y - AREA_SIZE,
+ sd->bl.x + AREA_SIZE, sd->bl.y + AREA_SIZE,
+ -dx, -dy,
+ 0);
if (sd->status.party_id > 0)
{ // パーティのHP情報通知検査
@@ -4611,11 +4622,11 @@ int pc_movepos(struct map_session_data *sd, int dst_x, int dst_y)
if (p != NULL)
{
int flag = 0;
- map_foreachinmovearea(party_send_hp_check, sd->bl.m,
- sd->bl.x - AREA_SIZE, sd->bl.y - AREA_SIZE,
- sd->bl.x + AREA_SIZE, sd->bl.y + AREA_SIZE,
- -dx, -dy, BL_PC, sd->status.party_id,
- &flag);
+ map_foreachinmovearea(std::bind(party_send_hp_check, ph::_1, sd->status.party_id, &flag),
+ sd->bl.m, sd->bl.x - AREA_SIZE, sd->bl.y - AREA_SIZE,
+ sd->bl.x + AREA_SIZE, sd->bl.y + AREA_SIZE,
+ -dx, -dy,
+ BL_PC);
if (flag)
sd->party_hp = -1;
}
@@ -4795,7 +4806,7 @@ struct pc_base_job pc_calc_base_job(int b_class)
*------------------------------------------
*/
static
-void pc_attack_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void pc_attack_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t)
{
struct map_session_data *sd;
struct block_list *bl;
@@ -5001,7 +5012,7 @@ int pc_stopattack(struct map_session_data *sd)
}
static
-void pc_follow_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void pc_follow_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t)
{
struct map_session_data *sd, *bl;
@@ -5602,7 +5613,6 @@ int pc_skillup(struct map_session_data *sd, SkillID skill_num)
*/
int pc_allskillup(struct map_session_data *sd)
{
- int i, id;
int c = 0, s = 0;
//転生や養子の場合の元の職業を算出する
struct pc_base_job s_class;
@@ -5635,7 +5645,7 @@ int pc_allskillup(struct map_session_data *sd)
else
{
SkillID id;
- for (i = 0;
+ for (int i = 0;
(id = skill_tree[s][c][i].id) != SkillID::ZERO
&& id != SkillID::NEGATIVE;
i++)
@@ -6393,9 +6403,11 @@ int pc_heal(struct map_session_data *sd, int hp, int sp)
* HP/SP回復
*------------------------------------------
*/
-static int pc_itemheal_effect(struct map_session_data *sd, int hp, int sp);
+static
+int pc_itemheal_effect(struct map_session_data *sd, int hp, int sp);
-static int // Compute how quickly we regenerate (less is faster) for that amount
+static
+int // Compute how quickly we regenerate (less is faster) for that amount
pc_heal_quick_speed(int amount)
{
if (amount >= 100)
@@ -6416,8 +6428,8 @@ pc_heal_quick_speed(int amount)
}
}
-static void
-pc_heal_quick_accumulate(int new_amount,
+static
+void pc_heal_quick_accumulate(int new_amount,
struct quick_regeneration *quick_regen, int max)
{
int current_amount = quick_regen->amount;
@@ -6461,7 +6473,8 @@ int pc_itemheal(struct map_session_data *sd, int hp, int sp)
/* pc_itemheal_effect is invoked once every 0.5s whenever the pc
* has health recovery queued up (cf. pc_natural_heal_sub).
*/
-static int pc_itemheal_effect(struct map_session_data *sd, int hp, int sp)
+static
+int pc_itemheal_effect(struct map_session_data *sd, int hp, int sp)
{
int bonus;
// if(battle_config.battle_log)
@@ -7179,7 +7192,7 @@ int pc_percentrefinery(struct map_session_data *sd, struct item *item)
*------------------------------------------
*/
static
-void pc_eventtimer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void pc_eventtimer(timer_id tid, tick_t, custom_id_t id, custom_data_t data)
{
struct map_session_data *sd = map_id2sd(id);
int i;
@@ -7306,8 +7319,8 @@ int pc_cleareventtimer(struct map_session_data *sd)
* アイテムを装備する
*------------------------------------------
*/
-static int
-pc_signal_advanced_equipment_change(struct map_session_data *sd, int n)
+static
+int pc_signal_advanced_equipment_change(struct map_session_data *sd, int n)
{
if (sd->status.inventory[n].equip & 0x0040)
clif_changelook(&sd->bl, LOOK_SHOES, 0);
@@ -7728,14 +7741,13 @@ int pc_checkoversp(struct map_session_data *sd)
*------------------------------------------
*/
static
-void pc_calc_pvprank_sub(struct block_list *bl, va_list ap)
+void pc_calc_pvprank_sub(struct block_list *bl, struct map_session_data *sd2)
{
- struct map_session_data *sd1, *sd2 = NULL;
+ struct map_session_data *sd1;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(sd1 = (struct map_session_data *) bl);
- nullpo_retv(sd2 = va_arg(ap, struct map_session_data *));
+ sd1 = (struct map_session_data *) bl;
+ nullpo_retv(sd2);
if (sd1->pvp_point > sd2->pvp_point)
sd2->pvp_rank++;
@@ -7758,8 +7770,9 @@ int pc_calc_pvprank(struct map_session_data *sd)
if (!(m->flag.pvp))
return 0;
sd->pvp_rank = 1;
- map_foreachinarea(pc_calc_pvprank_sub, sd->bl.m, 0, 0, m->xs, m->ys,
- BL_PC, sd);
+ map_foreachinarea(std::bind(pc_calc_pvprank_sub, ph::_1, sd),
+ sd->bl.m, 0, 0, m->xs, m->ys,
+ BL_PC);
if (old != sd->pvp_rank || sd->pvp_lastusers != m->users)
clif_pvpset(sd, sd->pvp_rank, sd->pvp_lastusers = m->users, 0);
return sd->pvp_rank;
@@ -7769,7 +7782,7 @@ int pc_calc_pvprank(struct map_session_data *sd)
* PVP順位計算(timer)
*------------------------------------------
*/
-void pc_calc_pvprank_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void pc_calc_pvprank_timer(timer_id, tick_t, custom_id_t id, custom_data_t data)
{
struct map_session_data *sd = NULL;
if (battle_config.pk_mode) // disable pvp ranking if pk_mode on [Valaris]
@@ -7877,8 +7890,10 @@ struct map_session_data *pc_get_partner(struct map_session_data *sd)
* SP回復量計算
*------------------------------------------
*/
-static int natural_heal_tick, natural_heal_prev_tick, natural_heal_diff_tick;
-static int pc_spheal(struct map_session_data *sd)
+static
+int natural_heal_tick, natural_heal_prev_tick, natural_heal_diff_tick;
+static
+int pc_spheal(struct map_session_data *sd)
{
int a;
@@ -7897,7 +7912,8 @@ static int pc_spheal(struct map_session_data *sd)
* HP回復量計算
*------------------------------------------
*/
-static int pc_hpheal(struct map_session_data *sd)
+static
+int pc_hpheal(struct map_session_data *sd)
{
int a;
@@ -7912,7 +7928,8 @@ static int pc_hpheal(struct map_session_data *sd)
return a;
}
-static int pc_natural_heal_hp(struct map_session_data *sd)
+static
+int pc_natural_heal_hp(struct map_session_data *sd)
{
int bhp;
int inc_num, bonus, skill, hp_flag;
@@ -8036,7 +8053,8 @@ static int pc_natural_heal_hp(struct map_session_data *sd)
return 0;
}
-static int pc_natural_heal_sp(struct map_session_data *sd)
+static
+int pc_natural_heal_sp(struct map_session_data *sd)
{
int bsp;
int inc_num, bonus;
@@ -8115,7 +8133,8 @@ static int pc_natural_heal_sp(struct map_session_data *sd)
return 0;
}
-static int pc_spirit_heal_hp(struct map_session_data *sd, int level)
+static
+int pc_spirit_heal_hp(struct map_session_data *sd, int)
{
int bonus_hp, interval = battle_config.natural_heal_skill_interval;
eptr<struct status_change, StatusChange> sc_data = battle_get_sc_data(&sd->bl);
@@ -8167,7 +8186,8 @@ static int pc_spirit_heal_hp(struct map_session_data *sd, int level)
return 0;
}
-static int pc_spirit_heal_sp(struct map_session_data *sd, int level)
+static
+int pc_spirit_heal_sp(struct map_session_data *sd, int)
{
int bonus_sp, interval = battle_config.natural_heal_skill_interval;
@@ -8222,8 +8242,8 @@ static int pc_spirit_heal_sp(struct map_session_data *sd, int level)
*------------------------------------------
*/
-static int
-pc_quickregenerate_effect(struct quick_regeneration *quick_regen,
+static
+int pc_quickregenerate_effect(struct quick_regeneration *quick_regen,
int heal_speed)
{
if (!(quick_regen->tickdelay--))
@@ -8242,11 +8262,12 @@ pc_quickregenerate_effect(struct quick_regeneration *quick_regen,
return 0;
}
-static int pc_natural_heal_sub(struct map_session_data *sd, va_list ap)
+static
+void pc_natural_heal_sub(struct map_session_data *sd)
{
int skill;
- nullpo_retr(0, sd);
+ nullpo_retv(sd);
if (sd->heal_xp > 0)
{
@@ -8272,7 +8293,7 @@ static int pc_natural_heal_sub(struct map_session_data *sd, va_list ap)
}
if (sd->sc_data[SC_HALT_REGENERATE].timer != -1)
- return 0;
+ return;
if (sd->quick_regeneration_hp.amount || sd->quick_regeneration_sp.amount)
{
@@ -8316,7 +8337,6 @@ static int pc_natural_heal_sub(struct map_session_data *sd, va_list ap)
sd->inchealspirithptick = 0;
sd->inchealspiritsptick = 0;
}
- return 0;
}
/*==========================================
@@ -8324,7 +8344,7 @@ static int pc_natural_heal_sub(struct map_session_data *sd, va_list ap)
*------------------------------------------
*/
static
-void pc_natural_heal(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void pc_natural_heal(timer_id, tick_t tick, custom_id_t, custom_data_t)
{
natural_heal_tick = tick;
natural_heal_diff_tick =
@@ -8354,23 +8374,21 @@ int pc_setsavepoint(struct map_session_data *sd, const char *mapname, int x, int
* 自動セーブ 各クライアント
*------------------------------------------
*/
-static int last_save_fd, save_flag;
-static int pc_autosave_sub(struct map_session_data *sd, va_list ap)
+static
+int last_save_fd, save_flag;
+static
+void pc_autosave_sub(struct map_session_data *sd)
{
- nullpo_retr(0, sd);
+ nullpo_retv(sd);
if (save_flag == 0 && sd->fd > last_save_fd)
{
- int i;
-
pc_makesavestatus(sd);
chrif_save(sd);
save_flag = 1;
last_save_fd = sd->fd;
}
-
- return 0;
}
/*==========================================
@@ -8378,7 +8396,7 @@ static int pc_autosave_sub(struct map_session_data *sd, va_list ap)
*------------------------------------------
*/
static
-void pc_autosave(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void pc_autosave(timer_id, tick_t, custom_id_t, custom_data_t)
{
int interval;
@@ -8415,8 +8433,9 @@ int pc_read_gm_account(int fd)
* timer to do the day
*------------------------------------------
*/
-void map_day_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
-{ // by [yor]
+void map_day_timer(timer_id, tick_t, custom_id_t, custom_data_t)
+{
+ // by [yor]
struct map_session_data *pl_sd = NULL;
int i;
char tmpstr[1024];
@@ -8446,8 +8465,9 @@ void map_day_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data
* timer to do the night
*------------------------------------------
*/
-void map_night_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
-{ // by [yor]
+void map_night_timer(timer_id, tick_t, custom_id_t, custom_data_t)
+{
+ // by [yor]
struct map_session_data *pl_sd = NULL;
int i;
char tmpstr[1024];
@@ -8810,7 +8830,8 @@ int pc_readdb(void)
return 0;
}
-static int pc_calc_sigma(void)
+static
+int pc_calc_sigma(void)
{
int i, j, k;
@@ -8827,7 +8848,8 @@ static int pc_calc_sigma(void)
return 0;
}
-static void pc_statpointdb(void)
+static
+void pc_statpointdb(void)
{
char *buf_stat;
int i = 0, j = 0, k = 0, l = 0, end = 0;
@@ -8943,8 +8965,6 @@ void pc_invisibility(struct map_session_data *sd, int enabled)
int pc_logout(struct map_session_data *sd) // [fate] Player logs out
{
- unsigned int tick = gettick();
-
if (!sd)
return 0;
diff --git a/src/map/pc.hpp b/src/map/pc.hpp
index 2f53f8e..505cf78 100644
--- a/src/map/pc.hpp
+++ b/src/map/pc.hpp
@@ -1,5 +1,3 @@
-// $Id: pc.h,v 1.4 2004/09/25 05:32:18 MouseJstr Exp $
-
#ifndef PC_HPP
#define PC_HPP
@@ -206,4 +204,4 @@ extern timer_id night_timer_tid;
void map_day_timer(timer_id, tick_t, custom_id_t, custom_data_t); // by [yor]
void map_night_timer(timer_id, tick_t, custom_id_t, custom_data_t); // by [yor]
-#endif
+#endif // PC_HPP
diff --git a/src/map/script.cpp b/src/map/script.cpp
index 6ed0863..bf633aa 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -1,58 +1,52 @@
-// $Id: script.c 148 2004-09-30 14:05:37Z MouseJstr $
-//#define DEBUG_FUNCIN
-//#define DEBUG_DISP
-//#define DEBUG_RUN
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
+#include "script.hpp"
-#ifndef LCCWIN32
#include <sys/time.h>
-#endif
-
-#include <time.h>
-#include <math.h>
#include <cassert>
+#include <cctype>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
+#include "../common/db.hpp"
#include "../common/lock.hpp"
#include "../common/mt_rand.hpp"
+#include "../common/socket.hpp"
+#include "../common/timer.hpp"
#include "atcommand.hpp"
#include "battle.hpp"
#include "chat.hpp"
#include "chrif.hpp"
#include "clif.hpp"
-#include "../common/db.hpp"
#include "intif.hpp"
#include "itemdb.hpp"
-#include "../common/lock.hpp"
#include "map.hpp"
#include "mob.hpp"
#include "npc.hpp"
#include "party.hpp"
#include "pc.hpp"
-#include "script.hpp"
#include "skill.hpp"
#include "storage.hpp"
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
+//#define DEBUG_FUNCIN
+//#define DEBUG_DISP
+//#define DEBUG_RUN
#define SCRIPT_BLOCK_SIZE 256
enum
{ LABEL_NEXTLINE = 1, LABEL_START };
-static ScriptCode *script_buf;
-static int script_pos, script_size;
+static
+ScriptCode *script_buf;
+static
+int script_pos, script_size;
char *str_buf;
int str_pos, str_size;
-static struct str_data_t
+static
+struct str_data_t
{
ScriptCode type;
int str;
@@ -65,14 +59,19 @@ static struct str_data_t
int str_num = LABEL_START, str_data_size;
int str_hash[16];
-static struct dbt *mapreg_db = NULL;
-static struct dbt *mapregstr_db = NULL;
-static int mapreg_dirty = -1;
+static
+struct dbt *mapreg_db = NULL;
+static
+struct dbt *mapregstr_db = NULL;
+static
+int mapreg_dirty = -1;
char mapreg_txt[256] = "save/mapreg.txt";
#define MAPREG_AUTOSAVE_INTERVAL (10*1000)
-static struct dbt *scriptlabel_db = NULL;
-static struct dbt *userfunc_db = NULL;
+static
+struct dbt *scriptlabel_db = NULL;
+static
+struct dbt *userfunc_db = NULL;
struct dbt *script_get_label_db(void)
{
@@ -86,12 +85,14 @@ struct dbt *script_get_userfunc_db(void)
return userfunc_db;
}
-static char pos[11][100] =
+static
+char pos[11][100] =
{ "頭", "体", "左手", "右手", "ローブ", "靴", "アクセサリー1",
"アクセサリー2", "頭2", "頭3", "装着していない"
};
-static struct Script_Config
+static
+struct Script_Config
{
int warn_func_no_comma;
int warn_cmd_no_comma;
@@ -100,8 +101,10 @@ static struct Script_Config
int check_cmdcount;
int check_gotocount;
} script_config;
-static int parse_cmd_if = 0;
-static int parse_cmd;
+static
+int parse_cmd_if = 0;
+static
+int parse_cmd;
/*==========================================
* ローカルプロトタイプ宣言 (必要な物のみ)
@@ -277,7 +280,6 @@ void builtin_specialeffect(ScriptState *st); // special effect script [Valaris
void builtin_specialeffect2(ScriptState *st); // special effect script [Valaris]
void builtin_nude(ScriptState *st); // nude [Valaris]
void builtin_gmcommand(ScriptState *st); // [MouseJstr]
-void builtin_movenpc(ScriptState *st); // [MouseJstr]
void builtin_npcwarp(ScriptState *st); // [remoitnane]
void builtin_message(ScriptState *st); // [MouseJstr]
void builtin_npctalk(ScriptState *st); // [Valaris]
@@ -481,7 +483,6 @@ struct
{builtin_stoptimer, "stoptimer", ""},
{builtin_cmdothernpc, "cmdothernpc", "ss"},
{builtin_gmcommand, "gmcommand", "s"}, // [MouseJstr]
-// {builtin_movenpc,"movenpc","siis"}, // [MouseJstr]
{builtin_npcwarp, "npcwarp", "xys"}, // [remoitnane]
{builtin_message, "message", "Ps"}, // [MouseJstr]
{builtin_npctalk, "npctalk", "s"}, // [Valaris]
@@ -520,7 +521,8 @@ enum class ScriptCode : uint8_t
* 文字列のハッシュを計算
*------------------------------------------
*/
-static int calc_hash(const char *s)
+static
+int calc_hash(const char *s)
{
const unsigned char *p = (const unsigned char *)s;
int h = 0;
@@ -537,7 +539,8 @@ static int calc_hash(const char *s)
*------------------------------------------
*/
// 既存のであれば番号、無ければ-1
-static int search_str(const char *p)
+static
+int search_str(const char *p)
{
int i;
i = str_hash[calc_hash(p)];
@@ -557,7 +560,8 @@ static int search_str(const char *p)
*------------------------------------------
*/
// 既存のであれば番号、無ければ登録して新規番号
-static int add_str(const char *p)
+static
+int add_str(const char *p)
{
int i;
char *lowcase;
@@ -619,7 +623,8 @@ static int add_str(const char *p)
* スクリプトバッファサイズの確認と拡張
*------------------------------------------
*/
-static void check_script_buf(int size)
+static
+void check_script_buf(int size)
{
if (script_pos + size >= script_size)
{
@@ -655,7 +660,8 @@ void add_scriptb(uint8_t a)
* スクリプトバッファに整数を書き込む
*------------------------------------------
*/
-static void add_scripti(unsigned int a)
+static
+void add_scripti(unsigned int a)
{
while (a >= 0x40)
{
@@ -670,7 +676,8 @@ static void add_scripti(unsigned int a)
*------------------------------------------
*/
// 最大16Mまで
-static void add_scriptl(int l)
+static
+void add_scriptl(int l)
{
int backpatch = str_data[l].backpatch;
@@ -729,7 +736,8 @@ void set_label(int l, int pos_)
* スペース/コメント読み飛ばし
*------------------------------------------
*/
-static const char *skip_space(const char *p)
+static
+const char *skip_space(const char *p)
{
while (1)
{
@@ -783,14 +791,17 @@ const char *skip_word(const char *p)
return p;
}
-static const char *startptr;
-static int startline;
+static
+const char *startptr;
+static
+int startline;
/*==========================================
* エラーメッセージ出力
*------------------------------------------
*/
-static void disp_error_message(const char *mes, const char *pos_)
+static
+void disp_error_message(const char *mes, const char *pos_)
{
int line;
const char *p;
@@ -1168,7 +1179,8 @@ const char *parse_line(const char *p)
* 組み込み関数の追加
*------------------------------------------
*/
-static void add_builtin_functions(void)
+static
+void add_builtin_functions(void)
{
int i, n;
for (i = 0; builtin_functions[i].func; i++)
@@ -1184,7 +1196,8 @@ static void add_builtin_functions(void)
* 定数データベースの読み込み
*------------------------------------------
*/
-static void read_constdb(void)
+static
+void read_constdb(void)
{
FILE *fp;
char line[1024], name[1024];
@@ -1998,12 +2011,8 @@ void builtin_warp(ScriptState *st)
*------------------------------------------
*/
static
-void builtin_areawarp_sub(struct block_list *bl, va_list ap)
+void builtin_areawarp_sub(struct block_list *bl, const char *mapname, int x, int y)
{
- int x, y;
- const char *mapname = va_arg(ap, const char *);
- x = va_arg(ap, int);
- y = va_arg(ap, int);
if (strcmp(mapname, "Random") == 0)
pc_randomwarp((struct map_session_data *) bl, 3);
else
@@ -2027,8 +2036,8 @@ void builtin_areawarp(ScriptState *st)
if ((m = map_mapname2mapid(mapname)) < 0)
return;
- map_foreachinarea(builtin_areawarp_sub,
- m, x0, y0, x1, y1, BL_PC, str, x, y);
+ map_foreachinarea(std::bind(builtin_areawarp_sub, ph::_1, str, x, y),
+ m, x0, y0, x1, y1, BL_PC);
}
/*==========================================
@@ -2257,7 +2266,6 @@ void builtin_cleararray(ScriptState *st)
char postfix = name[strlen(name) - 1];
int sz = conv_num(st, &(st->stack->stack_data[st->start + 4]));
int i;
- void *v;
if (prefix != '$' && prefix != '@')
{
@@ -2315,7 +2323,8 @@ void builtin_copyarray(ScriptState *st)
* 配列変数のサイズ所得
*------------------------------------------
*/
-static int getarraysize(ScriptState *st, int num, int postfix)
+static
+int getarraysize(ScriptState *st, int num, int postfix)
{
int i = (num >> 24), c = i;
for (; i < 128; i++)
@@ -2982,8 +2991,17 @@ void builtin_strcharinfo(ScriptState *st)
}
unsigned int equip[10] =
- { 0x0100, 0x0010, 0x0020, 0x0002, 0x0004, 0x0040, 0x0008, 0x0080, 0x0200,
- 0x0001
+{
+ 0x0100,
+ 0x0010,
+ 0x0020,
+ 0x0002,
+ 0x0004,
+ 0x0040,
+ 0x0008,
+ 0x0080,
+ 0x0200,
+ 0x0001,
};
/*==========================================
@@ -3854,11 +3872,8 @@ void builtin_areamonster(ScriptState *st)
*------------------------------------------
*/
static
-void builtin_killmonster_sub(struct block_list *bl, va_list ap)
+void builtin_killmonster_sub(struct block_list *bl, const char *event, int allflag)
{
- char *event = va_arg(ap, char *);
- int allflag = va_arg(ap, int);
-
if (!allflag)
{
if (strcmp(event, ((struct mob_data *) bl)->npc_event) == 0)
@@ -3884,12 +3899,12 @@ void builtin_killmonster(ScriptState *st)
if ((m = map_mapname2mapid(mapname)) < 0)
return;
- map_foreachinarea(builtin_killmonster_sub,
- m, 0, 0, map[m].xs, map[m].ys, BL_MOB, event, allflag);
+ map_foreachinarea(std::bind(builtin_killmonster_sub, ph::_1, event, allflag),
+ m, 0, 0, map[m].xs, map[m].ys, BL_MOB);
}
static
-void builtin_killmonsterall_sub(struct block_list *bl, va_list ap)
+void builtin_killmonsterall_sub(struct block_list *bl)
{
mob_delete((struct mob_data *) bl);
}
@@ -4076,13 +4091,8 @@ void builtin_announce(ScriptState *st)
*------------------------------------------
*/
static
-void builtin_mapannounce_sub(struct block_list *bl, va_list ap)
+void builtin_mapannounce_sub(struct block_list *bl, const char *str, int len, int flag)
{
- char *str;
- int len, flag;
- str = va_arg(ap, char *);
- len = va_arg(ap, int);
- flag = va_arg(ap, int);
clif_GMmessage(bl, str, len, flag | 3);
}
@@ -4096,9 +4106,8 @@ void builtin_mapannounce(ScriptState *st)
if ((m = map_mapname2mapid(mapname)) < 0)
return;
- map_foreachinarea(builtin_mapannounce_sub,
- m, 0, 0, map[m].xs, map[m].ys, BL_PC, str,
- strlen(str) + 1, flag & 0x10);
+ map_foreachinarea(std::bind(builtin_mapannounce_sub, ph::_1, str, strlen(str) + 1, flag & 0x10),
+ m, 0, 0, map[m].xs, map[m].ys, BL_PC);
}
/*==========================================
@@ -4121,9 +4130,8 @@ void builtin_areaannounce(ScriptState *st)
if ((m = map_mapname2mapid(mapname)) < 0)
return;
- map_foreachinarea(builtin_mapannounce_sub,
- m, x0, y0, x1, y1, BL_PC, str, strlen(str) + 1,
- flag & 0x10);
+ map_foreachinarea(std::bind(builtin_mapannounce_sub, ph::_1, str, strlen(str) + 1, flag & 0x10),
+ m, x0, y0, x1, y1, BL_PC);
}
/*==========================================
@@ -4168,16 +4176,14 @@ void builtin_getmapusers(ScriptState *st)
*------------------------------------------
*/
static
-void builtin_getareausers_sub(struct block_list *bl, va_list ap)
+void builtin_getareausers_sub(struct block_list *, int *users)
{
- int *users = va_arg(ap, int *);
(*users)++;
}
static
-void builtin_getareausers_living_sub(struct block_list *bl, va_list ap)
+void builtin_getareausers_living_sub(struct block_list *bl, int *users)
{
- int *users = va_arg(ap, int *);
if (!pc_isdead((struct map_session_data *)bl))
(*users)++;
}
@@ -4201,8 +4207,8 @@ void builtin_getareausers(ScriptState *st)
push_val(st->stack, ScriptCode::INT, -1);
return;
}
- map_foreachinarea(living ? builtin_getareausers_living_sub: builtin_getareausers_sub,
- m, x0, y0, x1, y1, BL_PC, &users);
+ map_foreachinarea(std::bind(living ? builtin_getareausers_living_sub: builtin_getareausers_sub, ph::_1, &users),
+ m, x0, y0, x1, y1, BL_PC);
push_val(st->stack, ScriptCode::INT, users);
}
@@ -4211,10 +4217,8 @@ void builtin_getareausers(ScriptState *st)
*------------------------------------------
*/
static
-void builtin_getareadropitem_sub(struct block_list *bl, va_list ap)
+void builtin_getareadropitem_sub(struct block_list *bl, int item, int *amount)
{
- 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)
@@ -4223,10 +4227,8 @@ void builtin_getareadropitem_sub(struct block_list *bl, va_list ap)
}
static
-void builtin_getareadropitem_sub_anddelete(struct block_list *bl, va_list ap)
+void builtin_getareadropitem_sub_anddelete(struct block_list *bl, int item, int *amount)
{
- 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) {
@@ -4269,11 +4271,11 @@ void builtin_getareadropitem(ScriptState *st)
return;
}
if (delitems)
- map_foreachinarea(builtin_getareadropitem_sub_anddelete,
- m, x0, y0, x1, y1, BL_ITEM, item, &amount);
+ map_foreachinarea(std::bind(builtin_getareadropitem_sub_anddelete, ph::_1, item, &amount),
+ m, x0, y0, x1, y1, BL_ITEM);
else
- map_foreachinarea(builtin_getareadropitem_sub,
- m, x0, y0, x1, y1, BL_ITEM, item, &amount);
+ map_foreachinarea(std::bind(builtin_getareadropitem_sub, ph::_1, item, &amount),
+ m, x0, y0, x1, y1, BL_ITEM);
push_val(st->stack, ScriptCode::INT, amount);
}
@@ -4613,27 +4615,6 @@ void builtin_delwaitingroom(ScriptState *st)
}
/*==========================================
- * npcチャット全員蹴り出す
- *------------------------------------------
- */
-static
-void builtin_waitingroomkickall(ScriptState *st)
-{
- struct npc_data *nd;
- struct chat_data *cd;
-
- if (st->end > st->start + 2)
- nd = npc_name2id(conv_str(st, &(st->stack->stack_data[st->start + 2])));
- else
- nd = (struct npc_data *) map_id2bl(st->oid);
-
- if (nd == NULL
- || (cd = (struct chat_data *) map_id2bl(nd->chat_id)) == NULL)
- return;
- chat_npckickall(cd);
-}
-
-/*==========================================
* npcチャットイベント有効化
*------------------------------------------
*/
@@ -4982,7 +4963,7 @@ void builtin_removemapflag(ScriptState *st)
void builtin_getmapflag(ScriptState *st)
{
- int m, i, r;
+ int m, i, r = -1;
const char *str = conv_str(st, &(st->stack->stack_data[st->start + 2]));
i = conv_num(st, &(st->stack->stack_data[st->start + 3]));
@@ -5039,7 +5020,6 @@ void builtin_getmapflag(ScriptState *st)
case MF_RAIN: // [Valaris]
r = map[m].flag.rain;
break;
-
}
}
@@ -5322,8 +5302,8 @@ void builtin_mapwarp(ScriptState *st) // Added by RoVeRT
if ((m = map_mapname2mapid(mapname)) < 0)
return;
- map_foreachinarea(builtin_areawarp_sub,
- m, x0, y0, x1, y1, BL_PC, str, x, y);
+ map_foreachinarea(std::bind(builtin_areawarp_sub, ph::_1, str, x, y),
+ m, x0, y0, x1, y1, BL_PC);
}
void builtin_cmdothernpc(ScriptState *st) // Added by RoVeRT
@@ -5353,11 +5333,8 @@ void builtin_stoptimer(ScriptState *st) // Added by RoVeRT
}
static
-void builtin_mobcount_sub(struct block_list *bl, va_list ap) // Added by RoVeRT
+void builtin_mobcount_sub(struct block_list *bl, const char *event, int *c)
{
- char *event = va_arg(ap, char *);
- int *c = va_arg(ap, int *);
-
if (strcmp(event, ((struct mob_data *) bl)->npc_event) == 0)
(*c)++;
}
@@ -5373,8 +5350,8 @@ void builtin_mobcount(ScriptState *st) // Added by RoVeRT
push_val(st->stack, ScriptCode::INT, -1);
return;
}
- map_foreachinarea(builtin_mobcount_sub,
- m, 0, 0, map[m].xs, map[m].ys, BL_MOB, event, &c);
+ map_foreachinarea(std::bind(builtin_mobcount_sub, ph::_1, event, &c),
+ m, 0, 0, map[m].xs, map[m].ys, BL_MOB);
push_val(st->stack, ScriptCode::INT, (c - 1));
@@ -5920,25 +5897,6 @@ void builtin_gmcommand(ScriptState *st)
}
/*==========================================
- * movenpc [MouseJstr]
- *------------------------------------------
- */
-
-void builtin_movenpc(ScriptState *st)
-{
- struct map_session_data *sd;
- int x, y;
-
- sd = script_rid2sd(st);
-
- const char *mapname = conv_str(st, &(st->stack->stack_data[st->start + 2]));
- x = conv_num(st, &(st->stack->stack_data[st->start + 3]));
- y = conv_num(st, &(st->stack->stack_data[st->start + 4]));
- const char *npc = conv_str(st, &(st->stack->stack_data[st->start + 5]));
-
-}
-
-/*==========================================
* npcwarp [remoitnane]
* Move NPC to a new position on the same map.
*------------------------------------------
@@ -6123,12 +6081,8 @@ void builtin_getsavepoint(ScriptState *st)
*------------------------------------------
*/
static
-void builtin_areatimer_sub(struct block_list *bl, va_list ap)
+void builtin_areatimer_sub(struct block_list *bl, int tick, const char *event)
{
- int tick;
- char *event;
- tick = va_arg(ap, int);
- event = va_arg(ap, char *);
pc_addeventtimer((struct map_session_data *) bl, tick, event);
}
@@ -6148,8 +6102,8 @@ void builtin_areatimer(ScriptState *st)
if ((m = map_mapname2mapid(mapname)) < 0)
return;
- map_foreachinarea(builtin_areatimer_sub,
- m, x0, y0, x1, y1, BL_PC, tick, event);
+ map_foreachinarea(std::bind(builtin_areatimer_sub, ph::_1, tick, event),
+ m, x0, y0, x1, y1, BL_PC);
}
/*==========================================
@@ -6633,7 +6587,7 @@ void run_func(ScriptState *st)
*------------------------------------------
*/
static
-void run_script_main(const ScriptCode *script, int pos_, int rid, int oid,
+void run_script_main(const ScriptCode *script, int pos_, int, int,
ScriptState *st, const ScriptCode *rootscript)
{
int rerun_pos;
@@ -6785,7 +6739,7 @@ int run_script(const ScriptCode *script, int pos_, int rid, int oid)
}
int run_script_l(const ScriptCode *script, int pos_, int rid, int oid,
- int args_nr, argrec_t * args)
+ int args_nr, argrec_t *args)
{
struct script_stack stack;
ScriptState st;
@@ -6922,9 +6876,9 @@ void script_load_mapreg(void)
* 永続的マップ変数の書き込み
*------------------------------------------
*/
-static void script_save_mapreg_intsub(db_key_t key, db_val_t data, va_list ap)
+static
+void script_save_mapreg_intsub(db_key_t key, db_val_t data, FILE *fp)
{
- FILE *fp = va_arg(ap, FILE *);
int num = key.i & 0x00ffffff, i = key.i >> 24;
char *name = str_buf + str_data[num].str;
if (name[1] != '@')
@@ -6936,9 +6890,9 @@ static void script_save_mapreg_intsub(db_key_t key, db_val_t data, va_list ap)
}
}
-static void script_save_mapreg_strsub(db_key_t key, db_val_t data, va_list ap)
+static
+void script_save_mapreg_strsub(db_key_t key, db_val_t data, FILE *fp)
{
- FILE *fp = va_arg(ap, FILE *);
int num = key.i & 0x00ffffff, i = key.i >> 24;
char *name = str_buf + str_data[num].str;
if (name[1] != '@')
@@ -6958,14 +6912,14 @@ void script_save_mapreg(void)
if ((fp = lock_fopen(mapreg_txt, &lock)) == NULL)
return;
- numdb_foreach(mapreg_db, script_save_mapreg_intsub, fp);
- numdb_foreach(mapregstr_db, script_save_mapreg_strsub, fp);
+ numdb_foreach(mapreg_db, std::bind(script_save_mapreg_intsub, ph::_1, ph::_2, fp));
+ numdb_foreach(mapregstr_db, std::bind(script_save_mapreg_strsub, ph::_1, ph::_2, fp));
lock_fclose(fp, mapreg_txt, &lock);
mapreg_dirty = 0;
}
-static void script_autosave_mapreg(timer_id tid, tick_t tick, custom_id_t id,
- custom_data_t data)
+static
+void script_autosave_mapreg(timer_id, tick_t, custom_id_t, custom_data_t)
{
if (mapreg_dirty)
script_save_mapreg();
@@ -7041,12 +6995,14 @@ void script_config_read(const char *cfgName)
*------------------------------------------
*/
-static void mapregstr_db_final(db_key_t key, db_val_t data, va_list ap)
+static
+void mapregstr_db_final(db_key_t, db_val_t data)
{
free(data);
}
-static void userfunc_db_final(db_key_t key, db_val_t data, va_list ap)
+static
+void userfunc_db_final(db_key_t key, db_val_t data)
{
free((char*)key.s);
free(data);
diff --git a/src/map/script.hpp b/src/map/script.hpp
index 6f6c910..03ff950 100644
--- a/src/map/script.hpp
+++ b/src/map/script.hpp
@@ -1,7 +1,8 @@
-// $Id: script.h,v 1.2 2004/09/25 05:32:19 MouseJstr Exp $
#ifndef SCRIPT_HPP
#define SCRIPT_HPP
+#include <cstdint>
+
// values are private, but gcc < 4.6 doesn't
// support forward-declared enums
enum class ScriptCode : uint8_t
@@ -79,7 +80,7 @@ typedef struct argrec
_aru(const char *z) : s(z) {}
} v;
} argrec_t;
-int run_script_l(const ScriptCode *, int, int, int, int, argrec_t * args);
+int run_script_l(const ScriptCode *, int, int, int, int, argrec_t *args);
int run_script(const ScriptCode *, int, int, int);
struct dbt *script_get_label_db(void);
@@ -91,4 +92,4 @@ void do_final_script(void);
extern char mapreg_txt[];
-#endif
+#endif // SCRIPT_HPP
diff --git a/src/map/skill-pools.cpp b/src/map/skill-pools.cpp
index f363262..5f9351b 100644
--- a/src/map/skill-pools.cpp
+++ b/src/map/skill-pools.cpp
@@ -1,28 +1,25 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
+#include "skill.hpp"
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
-#include "../common/timer.hpp"
-#include "../common/nullpo.hpp"
#include "../common/mt_rand.hpp"
-#include "magic.hpp"
+#include "../common/nullpo.hpp"
+#include "../common/socket.hpp"
+#include "../common/timer.hpp"
#include "battle.hpp"
#include "clif.hpp"
#include "intif.hpp"
#include "itemdb.hpp"
+#include "magic.hpp"
#include "map.hpp"
#include "mob.hpp"
#include "party.hpp"
#include "pc.hpp"
#include "script.hpp"
-#include "skill.hpp"
-#include "../common/socket.hpp"
-
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
SkillID skill_pool_skills[MAX_POOL_SKILLS];
int skill_pool_skills_size = 0;
diff --git a/src/map/skill.cpp b/src/map/skill.cpp
index 5f0336f..c090102 100644
--- a/src/map/skill.cpp
+++ b/src/map/skill.cpp
@@ -1,31 +1,25 @@
-// $Id: skill.c,v 1.8 2004/09/25 05:32:19 MouseJstr Exp $
-/* スキル関係 */
+#include "skill.hpp"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
-#include "../common/timer.hpp"
-#include "../common/nullpo.hpp"
#include "../common/mt_rand.hpp"
-#include "magic.hpp"
+#include "../common/nullpo.hpp"
+#include "../common/socket.hpp"
+#include "../common/timer.hpp"
#include "battle.hpp"
#include "clif.hpp"
#include "intif.hpp"
#include "itemdb.hpp"
+#include "magic.hpp"
#include "map.hpp"
#include "mob.hpp"
#include "party.hpp"
#include "pc.hpp"
#include "script.hpp"
-#include "skill.hpp"
-#include "../common/socket.hpp"
-
-#ifdef MEMWATCH
-#include "memwatch.hpp"
-#endif
#define SKILLUNITTIMER_INVERVAL 100
@@ -956,10 +950,13 @@ struct skill_name_db skill_names[] =
{SkillID::ZERO, nullptr, nullptr}
};
-static const int dirx[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
-static const int diry[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
+static
+const int dirx[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
+static
+const int diry[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
-static int rdamage;
+static
+int rdamage;
earray<struct skill_db, SkillID, MAX_SKILL_DB> skill_db;
@@ -1085,22 +1082,25 @@ struct skill_unit_group *skill_unitsetting(struct block_list *src,
static
int skill_check_condition(struct map_session_data *sd, int type);
static
-void skill_frostjoke_scream(struct block_list *bl, va_list ap);
-static
-void skill_status_change_timer_sub(struct block_list *bl, va_list ap);
+void skill_frostjoke_scream(struct block_list *bl,
+ struct block_list *src, SkillID skillnum, int skilllv, unsigned int tick);
static
-void skill_attack_area(struct block_list *bl, va_list ap);
+void skill_status_change_timer_sub(struct block_list *bl,
+ struct block_list *src, StatusChange type, unsigned int tick);
static
void skill_clear_element_field(struct block_list *bl);
static
-void skill_landprotector(struct block_list *bl, va_list ap);
+void skill_landprotector(struct block_list *bl, SkillID skillid, int *alive);
static
-void skill_trap_splash(struct block_list *bl, va_list ap);
+void skill_trap_splash(struct block_list *bl,
+ struct block_list *src, int tick, int splash_count);
static
-void skill_count_target(struct block_list *bl, va_list ap);
+void skill_count_target(struct block_list *bl,
+ struct block_list *src, int *c);
// [MouseJstr] - skill ok to cast? and when?
-static int skillnotok(SkillID skillid, struct map_session_data *sd)
+static
+int skillnotok(SkillID skillid, struct map_session_data *sd)
{
if (sd == 0)
return 0;
@@ -1117,7 +1117,8 @@ static int skillnotok(SkillID skillid, struct map_session_data *sd)
}
}
-static int distance(int x0, int y0, int x1, int y1)
+static
+int distance(int x0, int y0, int x1, int y1)
{
int dx, dy;
@@ -1279,7 +1280,6 @@ int skill_additional_effect(struct block_list *src, struct block_list *bl,
struct map_session_data *sd = NULL;
struct map_session_data *dstsd = NULL;
struct mob_data *md = NULL;
- struct mob_data *dstmd = NULL;
int skill, skill2;
int rate, luk;
@@ -1324,7 +1324,6 @@ int skill_additional_effect(struct block_list *src, struct block_list *bl,
dstsd = (struct map_session_data *) bl;
else if (bl->type == BL_MOB)
{
- dstmd = (struct mob_data *) bl; //未使用?
if (sc_def_mdef > 50)
sc_def_mdef = 50;
if (sc_def_vit > 50)
@@ -1834,13 +1833,15 @@ int skill_blown(struct block_list *src, struct block_list *target, int count)
dy = ny - y;
if (sd) /* 画面外に出たので消去 */
- map_foreachinmovearea(clif_pcoutsight, target->m, x - AREA_SIZE,
- y - AREA_SIZE, x + AREA_SIZE, y + AREA_SIZE,
- dx, dy, 0, sd);
+ map_foreachinmovearea(std::bind(clif_pcoutsight, ph::_1, sd),
+ target->m, x - AREA_SIZE, y - AREA_SIZE,
+ x + AREA_SIZE, y + AREA_SIZE,
+ dx, dy, 0);
else if (md)
- map_foreachinmovearea(clif_moboutsight, target->m, x - AREA_SIZE,
- y - AREA_SIZE, x + AREA_SIZE, y + AREA_SIZE,
- dx, dy, BL_PC, md);
+ map_foreachinmovearea(std::bind(clif_moboutsight, ph::_1, md),
+ target->m, x - AREA_SIZE, y - AREA_SIZE,
+ x + AREA_SIZE, y + AREA_SIZE,
+ dx, dy, BL_PC);
if (su)
{
@@ -1866,17 +1867,19 @@ int skill_blown(struct block_list *src, struct block_list *target, int count)
if (sd)
{ /* 画面内に入ってきたので表示 */
- map_foreachinmovearea(clif_pcinsight, target->m, nx - AREA_SIZE,
- ny - AREA_SIZE, nx + AREA_SIZE, ny + AREA_SIZE,
- -dx, -dy, 0, sd);
+ map_foreachinmovearea(std::bind(clif_pcinsight, ph::_1, sd),
+ target->m, nx - AREA_SIZE, ny - AREA_SIZE,
+ nx + AREA_SIZE, ny + AREA_SIZE,
+ -dx, -dy, 0);
if (count & 0x20000)
sd->walktimer = -1;
}
else if (md)
{
- map_foreachinmovearea(clif_mobinsight, target->m, nx - AREA_SIZE,
- ny - AREA_SIZE, nx + AREA_SIZE, ny + AREA_SIZE,
- -dx, -dy, BL_PC, md);
+ map_foreachinmovearea(std::bind(clif_mobinsight, ph::_1, md),
+ target->m, nx - AREA_SIZE, ny - AREA_SIZE,
+ nx + AREA_SIZE, ny + AREA_SIZE,
+ -dx, -dy, BL_PC);
if (count & 0x20000)
md->state.state = prev_state;
}
@@ -2300,46 +2303,35 @@ int skill_attack(int attack_type, struct block_list *src,
* 0 =予約。0に固定
*------------------------------------------
*/
-static int skill_area_temp[8]; /* 一時変数。必要なら使う。 */
-typedef int(*SkillFunc)(struct block_list *, struct block_list *, int, int,
- unsigned int, int);
static
-void skill_area_sub(struct block_list *bl, va_list ap)
+int skill_area_temp[8]; /* 一時変数。必要なら使う。 */
+typedef int(*SkillFunc)(struct block_list *, struct block_list *,
+ SkillID, int,
+ unsigned int, int);
+static
+void skill_area_sub(struct block_list *bl,
+ struct block_list *src, SkillID skill_id, int skill_lv,
+ unsigned int tick, int flag, SkillFunc func)
{
- struct block_list *src;
- int skill_id, skill_lv, flag;
- unsigned int tick;
- SkillFunc func;
-
nullpo_retv(bl);
- nullpo_retv(ap);
if (bl->type != BL_PC && bl->type != BL_MOB && bl->type != BL_SKILL)
return;
- src = va_arg(ap, struct block_list *); //ここではsrcの値を参照していないのでNULLチェックはしない
- skill_id = va_arg(ap, int);
- skill_lv = va_arg(ap, int);
- tick = va_arg(ap, unsigned int);
- flag = va_arg(ap, int);
- func = va_arg(ap, SkillFunc);
-
if (battle_check_target(src, bl, flag) > 0)
func(src, bl, skill_id, skill_lv, tick, flag);
}
static
-void skill_check_unit_range_sub(struct block_list *bl, va_list ap)
+void skill_check_unit_range_sub(struct block_list *bl, int *c, int x, int y, int range, SkillID skillid)
{
struct skill_unit *unit;
- int *c, x, y, range, sx[4], sy[4];
+ int sx[4], sy[4];
int t_range, tx[4], ty[4];
int i, r_flag;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(unit = (struct skill_unit *) bl);
- nullpo_retv(c = va_arg(ap, int *));
+ unit = (struct skill_unit *) bl;
if (bl->prev == NULL || bl->type != BL_SKILL)
return;
@@ -2347,11 +2339,6 @@ void skill_check_unit_range_sub(struct block_list *bl, va_list ap)
if (!unit->alive)
return;
- x = va_arg(ap, int);
- y = va_arg(ap, int);
- range = va_arg(ap, int);
- SkillID skillid = va_arg(ap, SkillID);
-
if (skillid == MG_SAFETYWALL || skillid == AL_PNEUMA)
{
if (unit->group->unit_id != 0x7e && unit->group->unit_id != 0x85)
@@ -2409,20 +2396,18 @@ int skill_check_unit_range(int m, int x, int y, int range, SkillID skillid)
{
int c = 0;
- map_foreachinarea(skill_check_unit_range_sub, m, x - 10, y - 10, x + 10,
- y + 10, BL_SKILL, &c, x, y, range, skillid);
+ map_foreachinarea(std::bind(skill_check_unit_range_sub, ph::_1, &c, x, y, range, skillid),
+ m, x - 10, y - 10,
+ x + 10, y + 10, BL_SKILL);
return c;
}
static
-void skill_check_unit_range2_sub(struct block_list *bl, va_list ap)
+void skill_check_unit_range2_sub(struct block_list *bl, int *c)
{
- int *c;
-
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(c = va_arg(ap, int *));
+ nullpo_retv(c);
if (bl->prev == NULL || (bl->type != BL_PC && bl->type != BL_MOB))
return;
@@ -2437,8 +2422,9 @@ int skill_check_unit_range2(int m, int x, int y, int range)
{
int c = 0;
- map_foreachinarea(skill_check_unit_range2_sub, m, x - range, y - range,
- x + range, y + range, 0, &c);
+ map_foreachinarea(std::bind(skill_check_unit_range2_sub, ph::_1, &c),
+ m, x - range, y - range,
+ x + range, y + range, 0);
return c;
}
@@ -2448,9 +2434,8 @@ int skill_check_unit_range2(int m, int x, int y, int range)
*/
/* 対象の数をカウントする。(skill_area_temp[0]を初期化しておくこと) */
static
-int skill_area_sub_count(struct block_list *src, struct block_list *target,
- int skillid, int skilllv, unsigned int tick,
- int flag)
+int skill_area_sub_count(struct block_list *, struct block_list *,
+ SkillID, int, unsigned int, int)
{
if (skill_area_temp[0] < 0xffff)
skill_area_temp[0]++;
@@ -2461,7 +2446,8 @@ int skill_area_sub_count(struct block_list *src, struct block_list *target,
*
*------------------------------------------
*/
-static void skill_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+static
+void skill_timer(timer_id, tick_t tick, custom_id_t id, custom_data_t data)
{
struct map_session_data *sd = NULL;
struct mob_data *md = NULL;
@@ -2588,10 +2574,9 @@ static void skill_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t
case BA_FROSTJOKE: /* 寒いジョーク */
case DC_SCREAM: /* スクリーム */
range = 15; //視界全体
- map_foreachinarea(skill_frostjoke_scream, src->m,
- src->x - range, src->y - range,
- src->x + range, src->y + range, 0, src,
- skl->skill_id, skl->skill_lv, tick);
+ map_foreachinarea(std::bind(skill_frostjoke_scream, ph::_1, src, skl->skill_id, skl->skill_lv, tick),
+ src->m, src->x - range, src->y - range,
+ src->x + range, src->y + range, 0);
break;
default:
@@ -3029,11 +3014,9 @@ int skill_castend_damage_id(struct block_list *src, struct block_list *bl,
skill_attack(BF_WEAPON, src, src, bl, skillid, skilllv, tick,
0);
/* その後ターゲット以外の範囲内の敵全体に処理を行う */
- map_foreachinarea(skill_area_sub,
- bl->m, x - ar, y - ar, x + ar, y + ar, 0,
- src, skillid, skilllv, tick,
- flag | BCT_ENEMY | 1,
- skill_castend_damage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | 1, skill_castend_damage_id),
+ bl->m, x - ar, y - ar,
+ x + ar, y + ar, 0);
}
break;
@@ -3064,12 +3047,9 @@ int skill_castend_damage_id(struct block_list *src, struct block_list *bl,
else
clif_fixpos(bl);
skill_area_temp[0] = 0;
- map_foreachinarea(skill_area_sub,
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY, skill_area_sub_count),
bl->m, bl->x - 1, bl->y - 1,
- bl->x + 1, bl->y + 1, 0, src,
- skillid, skilllv, tick,
- flag | BCT_ENEMY,
- skill_area_sub_count);
+ bl->x + 1, bl->y + 1, 0);
if (skill_area_temp[0] > 1)
break;
}
@@ -3077,11 +3057,9 @@ int skill_castend_damage_id(struct block_list *src, struct block_list *bl,
skill_area_temp[2] = bl->x;
skill_area_temp[3] = bl->y;
/* その後ターゲット以外の範囲内の敵全体に処理を行う */
- map_foreachinarea(skill_area_sub,
- bl->m, bl->x - 1, bl->y - 1, bl->x + 1,
- bl->y + 1, 0, src, skillid, skilllv,
- tick, flag | BCT_ENEMY | 1,
- skill_castend_damage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | 1, skill_castend_damage_id),
+ bl->m, bl->x - 1, bl->y - 1,
+ bl->x + 1, bl->y + 1, 0);
battle_damage(src, bl, damage, 1);
if (rdamage > 0)
battle_damage(bl, src, rdamage, 0);
@@ -3159,11 +3137,9 @@ int skill_castend_damage_id(struct block_list *src, struct block_list *bl,
if (skillid == MG_NAPALMBEAT)
{ /* ナパームでは先に数える */
skill_area_temp[0] = 0;
- map_foreachinarea(skill_area_sub,
- bl->m, bl->x - 1, bl->y - 1, bl->x + 1,
- bl->y + 1, 0, src, skillid, skilllv,
- tick, flag | BCT_ENEMY,
- skill_area_sub_count);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY, skill_area_sub_count),
+ bl->m, bl->x - 1, bl->y - 1,
+ bl->x + 1, bl->y + 1, 0);
}
else
{
@@ -3175,11 +3151,9 @@ int skill_castend_damage_id(struct block_list *src, struct block_list *bl,
skill_attack(BF_MAGIC, src, src, bl, skillid, skilllv, tick,
skill_area_temp[0]);
/* その後ターゲット以外の範囲内の敵全体に処理を行う */
- map_foreachinarea(skill_area_sub,
- bl->m, bl->x - ar, bl->y - ar, bl->x + ar,
- bl->y + ar, 0, src, skillid, skilllv, tick,
- flag | BCT_ENEMY | 1,
- skill_castend_damage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | 1, skill_castend_damage_id),
+ bl->m, bl->x - ar, bl->y - ar,
+ bl->x + ar, bl->y + ar, 0);
}
break;
@@ -3199,11 +3173,9 @@ int skill_castend_damage_id(struct block_list *src, struct block_list *bl,
if (skillid == HW_NAPALMVULCAN)
{
skill_area_temp[0] = 0;
- map_foreachinarea(skill_area_sub,
- bl->m, bl->x - 1, bl->y - 1, bl->x + 1,
- bl->y + 1, 0, src, skillid, skilllv,
- tick, flag | BCT_ENEMY,
- skill_area_sub_count);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY, skill_area_sub_count),
+ bl->m, bl->x - 1, bl->y - 1,
+ bl->x + 1, bl->y + 1, 0);
}
else
{
@@ -3213,11 +3185,9 @@ int skill_castend_damage_id(struct block_list *src, struct block_list *bl,
}
skill_attack(BF_MAGIC, src, src, bl, skillid, skilllv, tick,
skill_area_temp[0]);
- map_foreachinarea(skill_area_sub,
- bl->m, bl->x - ar, bl->y - ar, bl->x + ar,
- bl->y + ar, 0, src, skillid, skilllv, tick,
- flag | BCT_ENEMY | 1,
- skill_castend_damage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | 1, skill_castend_damage_id),
+ bl->m, bl->x - ar, bl->y - ar,
+ bl->x + ar, bl->y + ar, 0);
}
break;
@@ -3248,20 +3218,16 @@ int skill_castend_damage_id(struct block_list *src, struct block_list *bl,
skill_area_temp[0] = 0;
skill_area_temp[1] = bl->id;
if (flag & 0xf00000)
- map_foreachinarea(skill_area_sub, bl->m, bl->x - 1,
- bl->y - 1, bl->x + 1, bl->y + 1, 0,
- src, skillid, skilllv, tick,
- flag | BCT_ENEMY,
- skill_area_sub_count);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY, skill_area_sub_count),
+ bl->m, bl->x - 1, bl->y - 1,
+ bl->x + 1, bl->y + 1, 0);
/* まずターゲットに攻撃を加える */
skill_attack(BF_MISC, src, src, bl, skillid, skilllv, tick,
skill_area_temp[0] | (flag & 0xf00000));
/* その後ターゲット以外の範囲内の敵全体に処理を行う */
- map_foreachinarea(skill_area_sub,
- bl->m, bl->x - 1, bl->y - 1, bl->x + 1,
- bl->y + 1, 0, src, skillid, skilllv, tick,
- flag | BCT_ENEMY | 1,
- skill_castend_damage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | 1, skill_castend_damage_id),
+ bl->m, bl->x - 1, bl->y - 1,
+ bl->x + 1, bl->y + 1, 0);
}
break;
@@ -3305,11 +3271,9 @@ int skill_castend_damage_id(struct block_list *src, struct block_list *bl,
skill_area_temp[2] = battle_get_hp(src);
clif_skill_nodamage(src, src, NPC_SELFDESTRUCTION, -1,
1);
- map_foreachinarea(skill_area_sub, bl->m, bl->x - 5,
- bl->y - 5, bl->x + 5, bl->y + 5, 0,
- src, skillid, skilllv, tick,
- flag | BCT_ENEMY | 1,
- skill_castend_damage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | 1, skill_castend_damage_id),
+ bl->m, bl->x - 5, bl->y - 5,
+ bl->x + 5, bl->y + 5, 0);
battle_damage(src, src, md->hp, 0);
}
}
@@ -3349,12 +3313,9 @@ int skill_castend_damage_id(struct block_list *src, struct block_list *bl,
{
int ar = sd->splash_range;
skill_area_temp[1] = bl->id;
- map_foreachinarea(skill_area_sub,
- bl->m, bl->x - ar, bl->y - ar,
- bl->x + ar, bl->y + ar, 0, src,
- skillid, skilllv, tick,
- flag | BCT_ENEMY | 1,
- skill_castend_damage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | 1, skill_castend_damage_id),
+ bl->m, bl->x - ar, bl->y - ar,
+ bl->x + ar, bl->y + ar, 0);
}
}
break;
@@ -3381,7 +3342,6 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl,
struct mob_data *md = NULL;
struct mob_data *dstmd = NULL;
int sc_def_vit, sc_def_mdef, strip_fix, strip_time, strip_per;
- int sc_dex, sc_luk;
//クラスチェンジ用ボスモンスターID
int changeclass[] =
{ 1038, 1039, 1046, 1059, 1086, 1087, 1112, 1115, 1157, 1159, 1190,
@@ -3397,8 +3357,6 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl,
else if (src->type == BL_MOB)
md = (struct mob_data *) src;
- sc_dex = battle_get_mdef(bl);
- sc_luk = battle_get_luk(bl);
sc_def_vit = 100 - (3 + battle_get_vit(bl) + battle_get_luk(bl) / 3);
sc_def_vit = 100 - (3 + battle_get_vit(bl) + battle_get_luk(bl) / 3);
sc_def_mdef = 100 - (3 + battle_get_mdef(bl) + battle_get_luk(bl) / 3);
@@ -3579,21 +3537,17 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl,
rate = 25 + skilllv * 2 + slv - tlv;
if (MRAND(100) < rate)
skill_status_change_start(bl,
- SkillStatusChangeTable
- [skillid], skilllv, 0, 0,
- 0, 0, 0);
+ SkillStatusChangeTable[skillid], skilllv,
+ 0, 0, 0, 0, 0);
}
}
else
{
int range = 15;
clif_skill_nodamage(src, bl, skillid, skilllv, 1);
- map_foreachinarea(skill_area_sub,
- src->m, src->x - range, src->y - range,
- src->x + range, src->y + range, 0, src,
- skillid, skilllv, tick,
- flag | BCT_ENEMY | 1,
- skill_castend_nodamage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | 1, skill_castend_nodamage_id),
+ src->m, src->x - range, src->y - range,
+ src->x + range, src->y + range, 0);
}
break;
@@ -3861,10 +3815,9 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl,
skill_status_change_start(bl, SkillStatusChangeTable[skillid],
skilllv, 0, 0, 0,
skill_get_time(skillid, skilllv), 0);
- map_foreachinarea(skill_status_change_timer_sub, src->m,
- src->x - range, src->y - range, src->x + range,
- src->y + range, 0, src,
- SkillStatusChangeTable[skillid], tick);
+ map_foreachinarea(std::bind(skill_status_change_timer_sub, ph::_1, src, SkillStatusChangeTable[skillid], tick),
+ src->m, src->x - range, src->y - range,
+ src->x + range, src->y + range, 0);
}
break;
case SM_PROVOKE: /* プロボック */
@@ -4065,22 +4018,19 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl,
skill_area_temp[1] = bl->id;
skill_area_temp[2] = x;
skill_area_temp[3] = y;
- map_foreachinarea(skill_area_sub,
- bl->m, x - 1, y - 1, x + 1, y + 1, 0,
- src, skillid, skilllv, tick,
- flag | BCT_ENEMY | 1,
- skill_castend_damage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | 1, skill_castend_damage_id),
+ bl->m, x - 1, y - 1,
+ x + 1, y + 1, 0);
}
skill_status_change_end(src, SC_HIDING, -1); // ハイディング解除
break;
case KN_BRANDISHSPEAR: /*ブランディッシュスピア */
{
- int c, n = 4, ar;
+ int c, n = 4;
int dir = map_calc_dir(src, bl->x, bl->y);
struct square tc;
int x = bl->x, y = bl->y;
- ar = skilllv / 3;
skill_brandishspear_first(&tc, dir, x, y);
skill_brandishspear_dir(&tc, dir, 4);
/* 範囲C */
@@ -4088,12 +4038,9 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl,
{
for (c = 1; c < 4; c++)
{
- map_foreachinarea(skill_area_sub,
- bl->m, tc.val1[c], tc.val2[c],
- tc.val1[c], tc.val2[c], 0, src,
- skillid, skilllv, tick,
- flag | BCT_ENEMY | n,
- skill_castend_damage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | n, skill_castend_damage_id),
+ bl->m, tc.val1[c], tc.val2[c],
+ tc.val1[c], tc.val2[c], 0);
}
}
/* 範囲BA */
@@ -4112,12 +4059,9 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl,
{
for (c = 0; c < 5; c++)
{
- map_foreachinarea(skill_area_sub,
- bl->m, tc.val1[c], tc.val2[c],
- tc.val1[c], tc.val2[c], 0, src,
- skillid, skilllv, tick,
- flag | BCT_ENEMY | n,
- skill_castend_damage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | n, skill_castend_damage_id),
+ bl->m, tc.val1[c], tc.val2[c],
+ tc.val1[c], tc.val2[c], 0);
if (skilllv > 6 && n == 3 && c == 4)
{
skill_brandishspear_dir(&tc, dir, -1);
@@ -4131,12 +4075,9 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl,
{
if (c == 0 || c == 5)
skill_brandishspear_dir(&tc, dir, -1);
- map_foreachinarea(skill_area_sub,
- bl->m, tc.val1[c % 5], tc.val2[c % 5],
- tc.val1[c % 5], tc.val2[c % 5], 0, src,
- skillid, skilllv, tick,
- flag | BCT_ENEMY | 1,
- skill_castend_damage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | 1, skill_castend_damage_id),
+ bl->m, tc.val1[c % 5], tc.val2[c % 5],
+ tc.val1[c % 5], tc.val2[c % 5], 0);
}
}
break;
@@ -4163,11 +4104,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl,
else
{
/* パーティ全体への処理 */
- party_foreachsamemap(skill_area_sub,
- sd, 1,
- src, skillid, skilllv, tick,
- flag | BCT_PARTY | 1,
- skill_castend_nodamage_id);
+ party_foreachsamemap(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_PARTY | 1, skill_castend_nodamage_id),
+ sd, 1);
}
break;
case BS_ADRENALINE: /* アドレナリンラッシュ */
@@ -4186,11 +4124,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl,
else
{
/* パーティ全体への処理 */
- party_foreachsamemap(skill_area_sub,
- sd, 1,
- src, skillid, skilllv, tick,
- flag | BCT_PARTY | 1,
- skill_castend_nodamage_id);
+ party_foreachsamemap(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_PARTY | 1, skill_castend_nodamage_id),
+ sd, 1);
}
break;
@@ -5354,7 +5289,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl,
*------------------------------------------
*/
static
-void skill_castend_id(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void skill_castend_id(timer_id tid, tick_t tick, custom_id_t id, custom_data_t)
{
struct map_session_data *sd = map_id2sd(id) /*,*target_sd=NULL */ ;
struct block_list *bl;
@@ -5555,34 +5490,27 @@ int skill_castend_pos2(struct block_list *src, int x, int y,
{
case PR_BENEDICTIO: /* 聖体降福 */
skill_area_temp[1] = src->id;
- map_foreachinarea(skill_area_sub,
- src->m, x - 1, y - 1, x + 1, y + 1, 0,
- src, skillid, skilllv, tick,
- flag | BCT_NOENEMY | 1,
- skill_castend_nodamage_id);
- map_foreachinarea(skill_area_sub, src->m, x - 1, y - 1, x + 1,
- y + 1, 0, src, skillid, skilllv, tick,
- flag | BCT_ENEMY | 1, skill_castend_damage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_NOENEMY | 1, skill_castend_nodamage_id),
+ src->m, x - 1, y - 1, x + 1, y + 1, 0);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | 1, skill_castend_damage_id),
+ src->m, x - 1, y - 1,
+ x + 1, y + 1, 0);
break;
case BS_HAMMERFALL: /* ハンマーフォール */
skill_area_temp[1] = src->id;
skill_area_temp[2] = x;
skill_area_temp[3] = y;
- map_foreachinarea(skill_area_sub,
- src->m, x - 2, y - 2, x + 2, y + 2, 0,
- src, skillid, skilllv, tick,
- flag | BCT_ENEMY | 2,
- skill_castend_nodamage_id);
+ map_foreachinarea(std::bind(skill_area_sub, ph::_1, src, skillid, skilllv, tick, flag | BCT_ENEMY | 2, skill_castend_nodamage_id),
+ src->m, x - 2, y - 2, x + 2, y + 2, 0);
break;
case HT_DETECTING: /* ディテクティング */
{
const int range = 7;
- map_foreachinarea(skill_status_change_timer_sub,
- src->m, src->x - range, src->y - range,
- src->x + range, src->y + range, 0, src,
- SC_SIGHT, tick);
+ map_foreachinarea(std::bind(skill_status_change_timer_sub, ph::_1, src, SC_SIGHT, tick),
+ src->m, src->x - range, src->y - range,
+ src->x + range, src->y + range, 0);
}
break;
@@ -6438,8 +6366,9 @@ struct skill_unit_group *skill_unitsetting(struct block_list *src,
}
//直上スキルの場合設置座標上にランドプロテクターがないかチェック
if (range <= 0)
- map_foreachinarea(skill_landprotector, src->m, ux, uy, ux, uy,
- BL_SKILL, skillid, &alive);
+ map_foreachinarea(std::bind(skill_landprotector, ph::_1, skillid, &alive),
+ src->m, ux, uy,
+ ux, uy, BL_SKILL);
if (skillid == WZ_ICEWALL && alive)
{
@@ -6504,8 +6433,9 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl,
|| diff < 0);
//対象がLP上に居る場合は無効
- map_foreachinarea(skill_landprotector, bl->m, bl->x, bl->y, bl->x, bl->y,
- BL_SKILL, 0, &goflag);
+ map_foreachinarea(std::bind(skill_landprotector, ph::_1, SkillID::ZERO, &goflag),
+ bl->m, bl->x, bl->y,
+ bl->x, bl->y, BL_SKILL);
if (!goflag)
return 0;
@@ -6646,14 +6576,12 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl,
case 0x96: /* フラッシャー */
case 0x97: /* フリージングトラップ */
case 0x98: /* クレイモアートラップ */
- map_foreachinarea(skill_count_target, src->bl.m,
- src->bl.x - src->range, src->bl.y - src->range,
- src->bl.x + src->range, src->bl.y + src->range,
- 0, &src->bl, &splash_count);
- map_foreachinarea(skill_trap_splash, src->bl.m,
- src->bl.x - src->range, src->bl.y - src->range,
- src->bl.x + src->range, src->bl.y + src->range,
- 0, &src->bl, tick, splash_count);
+ map_foreachinarea(std::bind(skill_count_target, ph::_1, &src->bl, &splash_count),
+ src->bl.m, src->bl.x - src->range, src->bl.y - src->range,
+ src->bl.x + src->range, src->bl.y + src->range, 0);
+ map_foreachinarea(std::bind(skill_trap_splash, ph::_1, &src->bl, tick, splash_count),
+ src->bl.m, src->bl.x - src->range, src->bl.y - src->range,
+ src->bl.x + src->range, src->bl.y + src->range, 0);
sg->unit_id = 0x8c;
clif_changelook(&src->bl, LOOK_BASE, sg->unit_id);
sg->limit = DIFF_TICK(tick, sg->tick) + 1500;
@@ -6721,8 +6649,6 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl,
else if (bl->type == BL_MOB && battle_config.mob_warpportal)
{
int m = map_mapname2mapid(sg->valstr);
- struct mob_data *md;
- md = (struct mob_data *) bl;
mob_warp((struct mob_data *) bl, m, sg->val2 >> 16,
sg->val2 & 0xffff, 3);
}
@@ -7117,7 +7043,7 @@ int skill_unit_ondelete(struct skill_unit *src, struct block_list *bl,
*------------------------------------------
*/
static
-int skill_unit_onlimit(struct skill_unit *src, unsigned int tick)
+int skill_unit_onlimit(struct skill_unit *src, unsigned int)
{
struct skill_unit_group *sg;
@@ -7168,7 +7094,7 @@ int skill_unit_onlimit(struct skill_unit *src, unsigned int tick)
*------------------------------------------
*/
int skill_unit_ondamaged(struct skill_unit *src, struct block_list *bl,
- int damage, unsigned int tick)
+ int damage, unsigned int)
{
struct skill_unit_group *sg;
@@ -7198,7 +7124,7 @@ int skill_unit_ondamaged(struct skill_unit *src, struct block_list *bl,
*------------------------------------------
*/
static
-void skill_castend_pos(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void skill_castend_pos(timer_id tid, tick_t tick, custom_id_t id, custom_data_t)
{
struct map_session_data *sd = map_id2sd(id) /*,*target_sd=NULL */ ;
int range, maxcount;
@@ -7377,21 +7303,18 @@ void skill_castend_pos(timer_id tid, tick_t tick, custom_id_t id, custom_data_t
*/
static
-void skill_check_condition_char_sub(struct block_list *bl, va_list ap)
+void skill_check_condition_char_sub(struct block_list *bl, struct block_list *src, int *c)
{
- int *c;
- struct block_list *src;
struct map_session_data *sd;
struct map_session_data *ssd;
struct pc_base_job s_class;
struct pc_base_job ss_class;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(sd = (struct map_session_data *) bl);
- nullpo_retv(src = va_arg(ap, struct block_list *));
- nullpo_retv(c = va_arg(ap, int *));
- nullpo_retv(ssd = (struct map_session_data *) src);
+ sd = (struct map_session_data *) bl;
+ nullpo_retv(src);
+ nullpo_retv(c);
+ ssd = (struct map_session_data *) src;
s_class = pc_calc_base_job(sd->status.pc_class);
//チェックしない設定ならcにありえない大きな数字を返して終了
@@ -7448,10 +7371,8 @@ void skill_check_condition_char_sub(struct block_list *bl, va_list ap)
*/
static
-void skill_check_condition_use_sub(struct block_list *bl, va_list ap)
+void skill_check_condition_use_sub(struct block_list *bl, struct block_list *src, int *c)
{
- int *c;
- struct block_list *src;
struct map_session_data *sd;
struct map_session_data *ssd;
struct pc_base_job s_class;
@@ -7459,11 +7380,10 @@ void skill_check_condition_use_sub(struct block_list *bl, va_list ap)
int skilllv;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(sd = (struct map_session_data *) bl);
- nullpo_retv(src = va_arg(ap, struct block_list *));
- nullpo_retv(c = va_arg(ap, int *));
- nullpo_retv(ssd = (struct map_session_data *) src);
+ sd = (struct map_session_data *) bl;
+ nullpo_retv(src);
+ nullpo_retv(c);
+ ssd = (struct map_session_data *) src;
s_class = pc_calc_base_job(sd->status.pc_class);
@@ -7537,20 +7457,18 @@ void skill_check_condition_use_sub(struct block_list *bl, va_list ap)
*/
static
-void skill_check_condition_mob_master_sub(struct block_list *bl, va_list ap)
+void skill_check_condition_mob_master_sub(struct block_list *bl, int src_id, int mob_class, int *c)
{
- int *c, src_id = 0, mob_class = 0;
struct mob_data *md;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(md = (struct mob_data *) bl);
+ md = (struct mob_data *) bl;
- if (!(src_id = va_arg(ap, int)))
+ if (!src_id)
return;
- if (!(mob_class = va_arg(ap, int)))
+ if (!mob_class)
return;
- nullpo_retv(c = va_arg(ap, int *));
+ nullpo_retv(c);
if (md->mob_class == mob_class && md->master_id == src_id)
(*c)++;
@@ -7762,10 +7680,9 @@ int skill_check_condition(struct map_session_data *sd, int type)
int c = 0;
if (!(type & 1))
{
- map_foreachinarea(skill_check_condition_char_sub, sd->bl.m,
- sd->bl.x - range, sd->bl.y - range,
- sd->bl.x + range, sd->bl.y + range, BL_PC,
- &sd->bl, &c);
+ map_foreachinarea(std::bind(skill_check_condition_char_sub, ph::_1, &sd->bl, &c),
+ sd->bl.m, sd->bl.x - range, sd->bl.y - range,
+ sd->bl.x + range, sd->bl.y + range, BL_PC);
if (c < 2)
{
clif_skill_fail(sd, skill, 0, 0);
@@ -7774,10 +7691,9 @@ int skill_check_condition(struct map_session_data *sd, int type)
}
else
{
- map_foreachinarea(skill_check_condition_use_sub, sd->bl.m,
- sd->bl.x - range, sd->bl.y - range,
- sd->bl.x + range, sd->bl.y + range, BL_PC,
- &sd->bl, &c);
+ map_foreachinarea(std::bind(skill_check_condition_use_sub, ph::_1, &sd->bl, &c),
+ sd->bl.m, sd->bl.x - range, sd->bl.y - range,
+ sd->bl.x + range, sd->bl.y + range, BL_PC);
}
}
break;
@@ -7797,10 +7713,10 @@ int skill_check_condition(struct map_session_data *sd, int type)
int mob_class = (skill == AM_CANNIBALIZE) ? 1118 : 1142;
if (battle_config.pc_land_skill_limit && maxcount > 0)
{
- map_foreachinarea(skill_check_condition_mob_master_sub,
- sd->bl.m, 0, 0, map[sd->bl.m].xs,
- map[sd->bl.m].ys, BL_MOB, sd->bl.id,
- mob_class, &c);
+ map_foreachinarea(std::bind(skill_check_condition_mob_master_sub, ph::_1, sd->bl.id, mob_class, &c),
+
+ sd->bl.m, 0, 0,
+ map[sd->bl.m].xs, map[sd->bl.m].ys, BL_MOB);
if (c >= maxcount)
{
clif_skill_fail(sd, skill, 0, 0);
@@ -8051,7 +7967,7 @@ int skill_castfix(struct block_list *bl, int time)
sc_data = battle_get_sc_data(bl);
dex = battle_get_dex(bl);
- if (skill > MAX_SKILL_DB || skill < SkillID::ZERO)
+ if (skill > MAX_SKILL_DB /*|| skill < SkillID()*/)
return 0;
castnodex = skill_get_castnodex(skill, lv);
@@ -8270,10 +8186,9 @@ int skill_use_id(struct map_session_data *sd, int target_id,
{
int range = 1;
int c = 0;
- map_foreachinarea(skill_check_condition_char_sub, sd->bl.m,
- sd->bl.x - range, sd->bl.y - range,
- sd->bl.x + range, sd->bl.y + range, BL_PC,
- &sd->bl, &c);
+ map_foreachinarea(std::bind(skill_check_condition_char_sub, ph::_1, &sd->bl, &c),
+ sd->bl.m, sd->bl.x - range, sd->bl.y - range,
+ sd->bl.x + range, sd->bl.y + range, BL_PC);
if (c < 1)
{
clif_skill_fail(sd, skill_num, 0, 0);
@@ -8823,7 +8738,7 @@ void skill_brandishspear_dir(struct square *tc, int dir, int are)
* ディボーション 有効確認
*------------------------------------------
*/
-void skill_devotion(struct map_session_data *md, int target)
+void skill_devotion(struct map_session_data *md, int)
{
// 総確認
int n;
@@ -8962,44 +8877,42 @@ int skill_autospell(struct map_session_data *sd, SkillID skillid)
*/
static
-void skill_gangster_count(struct block_list *bl, va_list ap)
+void skill_gangster_count(struct block_list *bl, int *c)
{
- int *c;
struct map_session_data *sd;
nullpo_retv(bl);
- nullpo_retv(ap);
+ nullpo_retv(c);
sd = (struct map_session_data *) bl;
- c = va_arg(ap, int *);
- if (sd && c && pc_issit(sd) && pc_checkskill(sd, RG_GANGSTER) > 0)
+ if (pc_issit(sd) && pc_checkskill(sd, RG_GANGSTER) > 0)
(*c)++;
}
static
-void skill_gangster_in(struct block_list *bl, va_list ap)
+void skill_gangster_in(struct block_list *bl)
{
struct map_session_data *sd;
nullpo_retv(bl);
- nullpo_retv(ap);
sd = (struct map_session_data *) bl;
- if (sd && pc_issit(sd) && pc_checkskill(sd, RG_GANGSTER) > 0)
+
+ if (pc_issit(sd) && pc_checkskill(sd, RG_GANGSTER) > 0)
sd->state.gangsterparadise = 1;
}
static
-void skill_gangster_out(struct block_list *bl, va_list ap)
+void skill_gangster_out(struct block_list *bl)
{
struct map_session_data *sd;
nullpo_retv(bl);
- nullpo_retv(ap);
sd = (struct map_session_data *) bl;
- if (sd && sd->state.gangsterparadise)
+
+ if (sd->state.gangsterparadise)
sd->state.gangsterparadise = 0;
}
@@ -9015,9 +8928,9 @@ int skill_gangsterparadise(struct map_session_data *sd, int type)
if (type == 1)
{ /* 座った時の処理 */
- map_foreachinarea(skill_gangster_count, sd->bl.m,
- sd->bl.x - range, sd->bl.y - range,
- sd->bl.x + range, sd->bl.y + range, BL_PC, &c);
+ map_foreachinarea(std::bind(skill_gangster_count, ph::_1, &c),
+ sd->bl.m, sd->bl.x - range, sd->bl.y - range,
+ sd->bl.x + range, sd->bl.y + range, BL_PC);
if (c > 0)
{ /*ギャングスター成功したら自分にもギャングスター属性付与 */
map_foreachinarea(skill_gangster_in, sd->bl.m,
@@ -9029,9 +8942,9 @@ int skill_gangsterparadise(struct map_session_data *sd, int type)
}
else if (type == 0)
{ /* 立ち上がったときの処理 */
- map_foreachinarea(skill_gangster_count, sd->bl.m,
- sd->bl.x - range, sd->bl.y - range,
- sd->bl.x + range, sd->bl.y + range, BL_PC, &c);
+ map_foreachinarea(std::bind(skill_gangster_count, ph::_1, &c),
+ sd->bl.m, sd->bl.x - range, sd->bl.y - range,
+ sd->bl.x + range, sd->bl.y + range, BL_PC);
if (c < 1)
map_foreachinarea(skill_gangster_out, sd->bl.m,
sd->bl.x - range, sd->bl.y - range,
@@ -9046,19 +8959,11 @@ int skill_gangsterparadise(struct map_session_data *sd, int type)
* 寒いジョーク・スクリーム判定処理(foreachinarea)
*------------------------------------------
*/
-void skill_frostjoke_scream(struct block_list *bl, va_list ap)
+void skill_frostjoke_scream(struct block_list *bl,
+ struct block_list *src, SkillID skillnum, int skilllv, unsigned int tick)
{
- struct block_list *src;
- int skilllv;
- unsigned int tick;
-
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(src = va_arg(ap, struct block_list *));
-
- SkillID skillnum = va_arg(ap, SkillID);
- skilllv = va_arg(ap, int);
- tick = va_arg(ap, unsigned int);
+ nullpo_retv(src);
if (src == bl) //自分には効かない
return;
@@ -9077,34 +8982,6 @@ void skill_frostjoke_scream(struct block_list *bl, va_list ap)
*
*------------------------------------------
*/
-void skill_attack_area(struct block_list *bl, va_list ap)
-{
- struct block_list *src, *dsrc;
- int atk_type, skilllv, flag, type;
- unsigned int tick;
-
- nullpo_retv(bl);
- nullpo_retv(ap);
-
- atk_type = va_arg(ap, int);
- if ((src = va_arg(ap, struct block_list *)) == NULL)
- return;
- if ((dsrc = va_arg(ap, struct block_list *)) == NULL)
- return;
- SkillID skillid = va_arg(ap, SkillID);
- skilllv = va_arg(ap, int);
- tick = va_arg(ap, unsigned int);
- flag = va_arg(ap, int);
- type = va_arg(ap, int);
-
- if (battle_check_target(dsrc, bl, type) > 0)
- skill_attack(atk_type, src, dsrc, bl, skillid, skilllv, tick, flag);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
void skill_clear_element_field(struct block_list *bl)
{
struct mob_data *md = NULL;
@@ -9141,18 +9018,13 @@ void skill_clear_element_field(struct block_list *bl)
* ランドプロテクターチェック(foreachinarea)
*------------------------------------------
*/
-void skill_landprotector(struct block_list *bl, va_list ap)
+void skill_landprotector(struct block_list *bl, SkillID skillid, int *alive)
{
- int *alive;
struct skill_unit *unit;
nullpo_retv(bl);
- nullpo_retv(ap);
- SkillID skillid = va_arg(ap, SkillID);
- alive = va_arg(ap, int *);
- if ((unit = (struct skill_unit *) bl) == NULL)
- return;
+ unit = (struct skill_unit *) bl;
if (skillid == SA_LANDPROTECTOR)
{
@@ -9170,15 +9042,13 @@ void skill_landprotector(struct block_list *bl, va_list ap)
*------------------------------------------
*/
static
-void skill_idun_heal(struct block_list *bl, va_list ap)
+void skill_idun_heal(struct block_list *bl, struct skill_unit *unit)
{
- struct skill_unit *unit;
struct skill_unit_group *sg;
int heal;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(unit = va_arg(ap, struct skill_unit *));
+ nullpo_retv(unit);
nullpo_retv(sg = unit->group);
heal =
@@ -9199,17 +9069,14 @@ void skill_idun_heal(struct block_list *bl, va_list ap)
* 指定範囲内でsrcに対して有効なターゲットのblの数を数える(foreachinarea)
*------------------------------------------
*/
-void skill_count_target(struct block_list *bl, va_list ap)
+void skill_count_target(struct block_list *bl,
+ struct block_list *src, int *c)
{
- struct block_list *src;
- int *c;
-
nullpo_retv(bl);
- nullpo_retv(ap);
- if ((src = va_arg(ap, struct block_list *)) == NULL)
+ if (src == NULL)
return;
- if ((c = va_arg(ap, int *)) == NULL)
+ if (c == NULL)
return;
if (battle_check_target(src, bl, BCT_ENEMY) > 0)
(*c)++;
@@ -9219,26 +9086,20 @@ void skill_count_target(struct block_list *bl, va_list ap)
* トラップ範囲処理(foreachinarea)
*------------------------------------------
*/
-void skill_trap_splash(struct block_list *bl, va_list ap)
+void skill_trap_splash(struct block_list *bl,
+ struct block_list *src, int tick, int splash_count)
{
- struct block_list *src;
- int tick;
- int splash_count;
struct skill_unit *unit;
struct skill_unit_group *sg;
struct block_list *ss;
int i;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(src = va_arg(ap, struct block_list *));
- nullpo_retv(unit = (struct skill_unit *) src);
+ nullpo_retv(src);
+ unit = (struct skill_unit *) src;
nullpo_retv(sg = unit->group);
nullpo_retv(ss = map_id2bl(sg->src_id));
- tick = va_arg(ap, int);
- splash_count = va_arg(ap, int);
-
if (battle_check_target(src, bl, BCT_ENEMY) > 0)
{
switch (sg->unit_id)
@@ -9276,16 +9137,11 @@ void skill_trap_splash(struct block_list *bl, va_list ap)
* ステータス異常タイマー範囲処理
*------------------------------------------
*/
-void skill_status_change_timer_sub(struct block_list *bl, va_list ap)
+void skill_status_change_timer_sub(struct block_list *bl,
+ struct block_list *src, StatusChange type, unsigned int tick)
{
- struct block_list *src;
- unsigned int tick;
-
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(src = va_arg(ap, struct block_list *));
- StatusChange type = va_arg(ap, StatusChange);
- tick = va_arg(ap, unsigned int);
+ nullpo_retv(src);
if (bl->type != BL_PC && bl->type != BL_MOB)
return;
@@ -9758,10 +9614,9 @@ void skill_status_change_timer(timer_id tid, tick_t tick, custom_id_t id, custom
case SC_SIGHT: /* サイト */
{
const int range = 7;
- map_foreachinarea(skill_status_change_timer_sub,
- bl->m, bl->x - range, bl->y - range,
- bl->x + range, bl->y + range, 0, bl, type,
- tick);
+ map_foreachinarea(std::bind(skill_status_change_timer_sub, ph::_1, bl, type, tick),
+ bl->m, bl->x - range, bl->y - range,
+ bl->x + range, bl->y + range, 0);
if ((--sc_data[type].val2) > 0)
{
@@ -9776,10 +9631,9 @@ void skill_status_change_timer(timer_id tid, tick_t tick, custom_id_t id, custom
case SC_RUWACH: /* ルアフ */
{
const int range = 5;
- map_foreachinarea(skill_status_change_timer_sub,
- bl->m, bl->x - range, bl->y - range,
- bl->x + range, bl->y + range, 0, bl, type,
- tick);
+ map_foreachinarea(std::bind(skill_status_change_timer_sub, ph::_1, bl, type, tick),
+ bl->m, bl->x - range, bl->y - range,
+ bl->x + range, bl->y + range, 0);
if ((--sc_data[type].val2) > 0)
{
@@ -11253,7 +11107,8 @@ struct skill_unit *skill_initunit(struct skill_unit_group *group, int idx,
return unit;
}
-void skill_unit_timer_sub_ondelete(struct block_list *bl, va_list ap);
+void skill_unit_timer_sub_ondelete(struct block_list *bl,
+ struct block_list *src, unsigned int tick);
/*==========================================
* スキルユニット削除
*------------------------------------------
@@ -11273,10 +11128,9 @@ int skill_delunit(struct skill_unit *unit)
/* ondeleteイベント呼び出し */
range = group->range;
- map_foreachinarea(skill_unit_timer_sub_ondelete, unit->bl.m,
- unit->bl.x - range, unit->bl.y - range,
- unit->bl.x + range, unit->bl.y + range, 0, &unit->bl,
- gettick());
+ map_foreachinarea(std::bind(skill_unit_timer_sub_ondelete, ph::_1, &unit->bl, gettick()),
+ unit->bl.m, unit->bl.x - range, unit->bl.y - range,
+ unit->bl.x + range, unit->bl.y + range, 0);
clif_skill_delunit(unit);
@@ -11293,7 +11147,8 @@ int skill_delunit(struct skill_unit *unit)
* スキルユニットグループ初期化
*------------------------------------------
*/
-static int skill_unit_group_newid = 10;
+static
+int skill_unit_group_newid = 10;
struct skill_unit_group *skill_initunitgroup(struct block_list *src,
int count, SkillID skillid, int skilllv, int unit_id)
{
@@ -11389,10 +11244,9 @@ struct skill_unit_group *skill_initunitgroup(struct block_list *src,
int c = 0;
if (sd)
{
- map_foreachinarea(skill_check_condition_use_sub,
- sd->bl.m, sd->bl.x - range,
- sd->bl.y - range, sd->bl.x + range,
- sd->bl.y + range, BL_PC, &sd->bl, &c);
+ map_foreachinarea(std::bind(skill_check_condition_use_sub, ph::_1, &sd->bl, &c),
+ sd->bl.m, sd->bl.x - range, sd->bl.y - range,
+ sd->bl.x + range, sd->bl.y + range, BL_PC);
}
}
}
@@ -11476,10 +11330,8 @@ int skill_clear_unitgroup(struct block_list *src)
* スキルユニットグループの被影響tick検索
*------------------------------------------
*/
-struct skill_unit_group_tickset *skill_unitgrouptickset_search(struct
- block_list
- *bl,
- int group_id)
+struct skill_unit_group_tickset *skill_unitgrouptickset_search(
+ struct block_list *bl, int group_id)
{
int i, j = 0, k, s = group_id % MAX_SKILLUNITGROUPTICKSET;
struct skill_unit_group_tickset *set = NULL;
@@ -11544,17 +11396,13 @@ int skill_unitgrouptickset_delete(struct block_list *bl, int group_id)
*------------------------------------------
*/
static
-void skill_unit_timer_sub_onplace(struct block_list *bl, va_list ap)
+void skill_unit_timer_sub_onplace(struct block_list *bl,
+ struct block_list *src, unsigned int tick)
{
- struct block_list *src;
struct skill_unit *su;
- unsigned int tick;
nullpo_retv(bl);
- nullpo_retv(ap);
- src = va_arg(ap, struct block_list *);
- tick = va_arg(ap, unsigned int);
su = (struct skill_unit *) src;
if (su && su->alive)
@@ -11570,17 +11418,13 @@ void skill_unit_timer_sub_onplace(struct block_list *bl, va_list ap)
* スキルユニットタイマー削除処理用(foreachinarea)
*------------------------------------------
*/
-void skill_unit_timer_sub_ondelete(struct block_list *bl, va_list ap)
+void skill_unit_timer_sub_ondelete(struct block_list *bl,
+ struct block_list *src, unsigned int tick)
{
- struct block_list *src;
struct skill_unit *su;
- unsigned int tick;
nullpo_retv(bl);
- nullpo_retv(ap);
- src = va_arg(ap, struct block_list *);
- tick = va_arg(ap, unsigned int);
su = (struct skill_unit *) src;
if (su && su->alive)
@@ -11597,18 +11441,15 @@ void skill_unit_timer_sub_ondelete(struct block_list *bl, va_list ap)
*------------------------------------------
*/
static
-void skill_unit_timer_sub(struct block_list *bl, va_list ap)
+void skill_unit_timer_sub(struct block_list *bl, unsigned int tick)
{
struct skill_unit *unit;
struct skill_unit_group *group;
int range;
- unsigned int tick;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(unit = (struct skill_unit *) bl);
+ unit = (struct skill_unit *) bl;
nullpo_retv(group = unit->group);
- tick = va_arg(ap, unsigned int);
if (!unit->alive)
return;
@@ -11618,15 +11459,15 @@ void skill_unit_timer_sub(struct block_list *bl, va_list ap)
/* onplaceイベント呼び出し */
if (unit->alive && unit->range >= 0)
{
- map_foreachinarea(skill_unit_timer_sub_onplace, bl->m,
- bl->x - range, bl->y - range, bl->x + range,
- bl->y + range, 0, bl, tick);
+ map_foreachinarea(std::bind(skill_unit_timer_sub_onplace, ph::_1, bl, tick),
+ bl->m, bl->x - range, bl->y - range,
+ bl->x + range, bl->y + range, 0);
if (group->unit_id == 0xaa
&& DIFF_TICK(tick, group->tick) >= 6000 * group->val2)
{
- map_foreachinarea(skill_idun_heal, bl->m,
- bl->x - range, bl->y - range, bl->x + range,
- bl->y + range, 0, unit);
+ map_foreachinarea(std::bind(skill_idun_heal, ph::_1, unit),
+ bl->m, bl->x - range, bl->y - range,
+ bl->x + range, bl->y + range, 0);
group->val2++;
}
}
@@ -11686,11 +11527,11 @@ void skill_unit_timer_sub(struct block_list *bl, va_list ap)
*------------------------------------------
*/
static
-void skill_unit_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t data)
+void skill_unit_timer(timer_id, tick_t tick, custom_id_t, custom_data_t)
{
map_freeblock_lock();
- map_foreachobject(skill_unit_timer_sub, BL_SKILL, tick);
+ map_foreachobject(std::bind(skill_unit_timer_sub, ph::_1, tick), BL_SKILL);
map_freeblock_unlock();
}
@@ -11700,22 +11541,18 @@ void skill_unit_timer(timer_id tid, tick_t tick, custom_id_t id, custom_data_t d
*------------------------------------------
*/
static
-void skill_unit_out_all_sub(struct block_list *bl, va_list ap)
+void skill_unit_out_all_sub(struct block_list *bl,
+ struct block_list *src, unsigned int tick)
{
struct skill_unit *unit;
struct skill_unit_group *group;
- struct block_list *src;
int range;
- unsigned int tick;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(src = va_arg(ap, struct block_list *));
- nullpo_retv(unit = (struct skill_unit *) bl);
+ nullpo_retv(src);
+ unit = (struct skill_unit *) bl;
nullpo_retv(group = unit->group);
- tick = va_arg(ap, unsigned int);
-
if (!unit->alive || src->prev == NULL)
return;
@@ -11742,9 +11579,9 @@ int skill_unit_out_all(struct block_list *bl, unsigned int tick, int range)
if (range < 7)
range = 7;
- map_foreachinarea(skill_unit_out_all_sub,
- bl->m, bl->x - range, bl->y - range, bl->x + range,
- bl->y + range, BL_SKILL, bl, tick);
+ map_foreachinarea(std::bind(skill_unit_out_all_sub, ph::_1, bl, tick),
+ bl->m, bl->x - range, bl->y - range,
+ bl->x + range, bl->y + range, BL_SKILL);
return 0;
}
@@ -11754,20 +11591,16 @@ int skill_unit_out_all(struct block_list *bl, unsigned int tick, int range)
*------------------------------------------
*/
static
-void skill_unit_move_sub(struct block_list *bl, va_list ap)
+void skill_unit_move_sub(struct block_list *bl,
+ struct block_list *src, unsigned int tick)
{
struct skill_unit *unit;
struct skill_unit_group *group;
- struct block_list *src;
int range;
- unsigned int tick;
nullpo_retv(bl);
- nullpo_retv(ap);
nullpo_retv(unit = (struct skill_unit *) bl);
- nullpo_retv(src = va_arg(ap, struct block_list *));
-
- tick = va_arg(ap, unsigned int);
+ nullpo_retv(src);
if (!unit->alive || src->prev == NULL)
return;
@@ -11799,9 +11632,9 @@ int skill_unit_move(struct block_list *bl, unsigned int tick, int range)
if (range < 7)
range = 7;
- map_foreachinarea(skill_unit_move_sub,
- bl->m, bl->x - range, bl->y - range, bl->x + range,
- bl->y + range, BL_SKILL, bl, tick);
+ map_foreachinarea(std::bind(skill_unit_move_sub, ph::_1, bl, tick),
+ bl->m, bl->x - range, bl->y - range,
+ bl->x + range, bl->y + range, BL_SKILL);
return 0;
}
@@ -11811,22 +11644,18 @@ int skill_unit_move(struct block_list *bl, unsigned int tick, int range)
*------------------------------------------
*/
static
-void skill_unit_move_unit_group_sub(struct block_list *bl, va_list ap)
+void skill_unit_move_unit_group_sub(struct block_list *bl,
+ struct block_list *src, unsigned int tick)
{
struct skill_unit *unit;
struct skill_unit_group *group;
- struct block_list *src;
int range;
- unsigned int tick;
nullpo_retv(bl);
- nullpo_retv(ap);
- nullpo_retv(src = va_arg(ap, struct block_list *));
- nullpo_retv(unit = (struct skill_unit *) src);
+ nullpo_retv(src);
+ unit = (struct skill_unit *) src;
nullpo_retv(group = unit->group);
- tick = va_arg(ap, unsigned int);
-
if (!unit->alive || bl->prev == NULL)
return;
@@ -11875,12 +11704,9 @@ int skill_unit_move_unit_group(struct skill_unit_group *group, int m, int dx,
{
if (range < 7)
range = 7;
- map_foreachinarea(skill_unit_move_unit_group_sub,
- unit->bl.m, unit->bl.x - range,
- unit->bl.y - range,
- unit->bl.x + range,
- unit->bl.y + range, 0, &unit->bl,
- gettick());
+ map_foreachinarea(std::bind(skill_unit_move_unit_group_sub, ph::_1, &unit->bl, gettick()),
+ unit->bl.m, unit->bl.x - range, unit->bl.y - range,
+ unit->bl.x + range, unit->bl.y + range, 0);
}
}
}
@@ -11939,13 +11765,10 @@ int skill_unit_move_unit_group(struct skill_unit_group *group, int m, int dx,
{
if (range < 7)
range = 7;
- map_foreachinarea(skill_unit_move_unit_group_sub,
- unit1->bl.m,
- unit1->bl.x - range,
- unit1->bl.y - range,
- unit1->bl.x + range,
- unit1->bl.y + range, 0,
- &unit1->bl, gettick());
+ map_foreachinarea(std::bind(skill_unit_move_unit_group_sub, ph::_1, &unit1->bl, gettick()),
+
+ unit1->bl.m, unit1->bl.x - range, unit1->bl.y - range,
+ unit1->bl.x + range, unit1->bl.y + range, 0);
}
}
else
@@ -11969,12 +11792,10 @@ int skill_unit_move_unit_group(struct skill_unit_group *group, int m, int dx,
{
if (range < 7)
range = 7;
- map_foreachinarea(skill_unit_move_unit_group_sub,
- unit2->bl.m, unit2->bl.x - range,
- unit2->bl.y - range,
- unit2->bl.x + range,
- unit2->bl.y + range, 0, &unit2->bl,
- gettick());
+ map_foreachinarea(std::bind(skill_unit_move_unit_group_sub, ph::_1, &unit2->bl, gettick()),
+
+ unit2->bl.m, unit2->bl.x - range, unit2->bl.y - range,
+ unit2->bl.x + range, unit2->bl.y + range, 0);
}
s_flag[j] = 0; // 継承完了したのでoff
break;
@@ -12000,7 +11821,8 @@ int skill_unit_move_unit_group(struct skill_unit_group *group, int m, int dx,
* 初期化系
*/
-static int scan_stat(char *statname)
+static
+int scan_stat(char *statname)
{
if (!strcasecmp(statname, "str"))
return SP_STR;
@@ -12065,7 +11887,7 @@ int skill_readdb(void)
}
SkillID i = SkillID(atoi(split[0]));
- if (i < SkillID() || i > MAX_SKILL_DB)
+ if (/*i < SkillID() ||*/ i > MAX_SKILL_DB)
continue;
memset(split2, 0, sizeof(split2));
@@ -12180,7 +12002,7 @@ int skill_readdb(void)
continue;
SkillID i = SkillID(atoi(split[0]));
- if (i < SkillID() || i > MAX_SKILL_DB)
+ if (/*i < SkillID() ||*/ i > MAX_SKILL_DB)
continue;
memset(split2, 0, sizeof(split2));
@@ -12363,7 +12185,7 @@ int skill_readdb(void)
continue;
SkillID i = SkillID(atoi(split[0]));
- if (i < SkillID() || i > MAX_SKILL_DB)
+ if (/*i < SkillID() ||*/ i > MAX_SKILL_DB)
continue;
memset(split2, 0, sizeof(split2));
@@ -12440,7 +12262,7 @@ int skill_readdb(void)
}
SkillID i = SkillID(atoi(split[0]));
- if (i < SkillID() || i > MAX_SKILL_DB)
+ if (/*i < SkillID() ||*/ i > MAX_SKILL_DB)
continue;
memset(split2, 0, sizeof(split2));
diff --git a/src/map/skill.hpp b/src/map/skill.hpp
index 5452bd2..3e45c8b 100644
--- a/src/map/skill.hpp
+++ b/src/map/skill.hpp
@@ -1,4 +1,3 @@
-// $Id: skill.h,v 1.5 2004/09/25 05:32:19 MouseJstr Exp $
#ifndef SKILL_HPP
#define SKILL_HPP
@@ -109,10 +108,8 @@ struct skill_unit_group *skill_initunitgroup(struct block_list *src,
int count, SkillID skillid,
int skilllv, int unit_id);
int skill_delunitgroup(struct skill_unit_group *group);
-struct skill_unit_group_tickset *skill_unitgrouptickset_search(struct
- block_list
- *bl,
- int group_id);
+struct skill_unit_group_tickset *skill_unitgrouptickset_search(
+ struct block_list *bl, int group_id);
int skill_unitgrouptickset_delete(struct block_list *bl, int group_id);
int skill_clear_unitgroup(struct block_list *src);
@@ -224,4 +221,4 @@ int skill_power_bl(struct block_list *bl, SkillID skill);
// [Fate] Remember that a certain skill ID belongs to a pool skill
void skill_pool_register(SkillID id);
-#endif
+#endif // SKILL_HPP
diff --git a/src/map/skill.t.hpp b/src/map/skill.t.hpp
index 0175985..fe10699 100644
--- a/src/map/skill.t.hpp
+++ b/src/map/skill.t.hpp
@@ -1,6 +1,8 @@
#ifndef SKILL_T_HPP
#define SKILL_T_HPP
+#include <cstdint>
+
// only ST_NONE is actually used - TODO remove
enum class SkillState
{
@@ -1410,6 +1412,7 @@ enum class SkillID : uint16_t
SL_SKA = 473,
#define SL_SKA SkillID::SL_SKA
+ // Note: this value is also hard-coded in common/mmo.hpp
MAX_SKILL_DB = 474, // not 450
#define MAX_SKILL_DB SkillID::MAX_SKILL_DB
};
diff --git a/src/map/storage.cpp b/src/map/storage.cpp
index 6426cb1..09b8893 100644
--- a/src/map/storage.cpp
+++ b/src/map/storage.cpp
@@ -1,23 +1,25 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "storage.hpp"
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include "../common/db.hpp"
#include "../common/nullpo.hpp"
-#include "storage.hpp"
+#include "atcommand.hpp"
+#include "battle.hpp"
#include "chrif.hpp"
-#include "itemdb.hpp"
#include "clif.hpp"
#include "intif.hpp"
+#include "itemdb.hpp"
#include "pc.hpp"
-#include "battle.hpp"
-#include "atcommand.hpp"
-static struct dbt *storage_db;
+static
+struct dbt *storage_db;
/*==========================================
* 倉庫内アイテムソート
@@ -37,7 +39,8 @@ int storage_comp_item(const void *_i1, const void *_i2)
return i1->nameid - i2->nameid;
}
-static void storage_db_final(db_key_t key, db_val_t data, va_list ap)
+static
+void storage_db_final(db_key_t, db_val_t data)
{
struct storage *stor = (struct storage *) data;
free(stor);
@@ -66,7 +69,8 @@ void do_final_storage(void) // by [MC Cameri]
numdb_final(storage_db, storage_db_final);
}
-static void storage_reconnect_sub(db_key_t key, db_val_t data, va_list ap)
+static
+void storage_reconnect_sub(db_key_t, db_val_t data)
{
//Parses storage and saves 'dirty' ones upon reconnect. [Skotlex]
struct storage *stor = (struct storage *) data;
@@ -146,7 +150,8 @@ int storage_storageopen(struct map_session_data *sd)
* Internal add-item function.
*------------------------------------------
*/
-static int storage_additem(struct map_session_data *sd, struct storage *stor,
+static
+int storage_additem(struct map_session_data *sd, struct storage *stor,
struct item *item_data, int amount)
{
struct item_data *data;
@@ -191,7 +196,8 @@ static int storage_additem(struct map_session_data *sd, struct storage *stor,
* Internal del-item function
*------------------------------------------
*/
-static int storage_delitem(struct map_session_data *sd, struct storage *stor,
+static
+int storage_delitem(struct map_session_data *sd, struct storage *stor,
int n, int amount)
{
@@ -438,4 +444,4 @@ int storage_storage_saved(int account_id)
return 1;
}
return 0;
-} \ No newline at end of file
+}
diff --git a/src/map/storage.hpp b/src/map/storage.hpp
index 171a21b..0345c0b 100644
--- a/src/map/storage.hpp
+++ b/src/map/storage.hpp
@@ -29,4 +29,4 @@ int storage_comp_item(const void *_i1, const void *_i2);
//int storage_comp_item(const struct item* i1, const struct item* i2);
void sortage_sortitem(struct storage *stor);
-#endif
+#endif // STORAGE_HPP
diff --git a/src/map/tmw.cpp b/src/map/tmw.cpp
index d648490..93ab37f 100644
--- a/src/map/tmw.cpp
+++ b/src/map/tmw.cpp
@@ -1,15 +1,13 @@
-//
-
-#include <string.h>
-#include <ctype.h>
-#include <stdarg.h>
-
#include "tmw.hpp"
+#include <cctype>
+#include <cstdarg> // exception to "no va_list" rule
+#include <cstring>
+
+#include "../common/nullpo.hpp"
#include "../common/socket.hpp"
#include "../common/timer.hpp"
#include "../common/version.hpp"
-#include "../common/nullpo.hpp"
#include "atcommand.hpp"
#include "battle.hpp"
@@ -124,7 +122,7 @@ int tmw_ShorterStrlen(const char *s1, const char *s2)
}
// Returns true if more than 50% of input message is caps or punctuation
-int tmw_CheckChatLameness(struct map_session_data *sd, const char *message)
+int tmw_CheckChatLameness(struct map_session_data *, const char *message)
{
int count, lame;
diff --git a/src/map/tmw.hpp b/src/map/tmw.hpp
index bbdba89..6a3131a 100644
--- a/src/map/tmw.hpp
+++ b/src/map/tmw.hpp
@@ -1,4 +1,3 @@
-//
#ifndef TMW_HPP
#define TMW_HPP
@@ -12,4 +11,4 @@ void tmw_GmHackMsg(const char *fmt, ...);
void tmw_AutoBan(struct map_session_data *sd, const char *reason, int length);
void tmw_TrimStr(char *str);
-#endif /* TMW_H_ */
+#endif // TMW_HPP
diff --git a/src/map/trade.cpp b/src/map/trade.cpp
index fc4c822..4c0ad99 100644
--- a/src/map/trade.cpp
+++ b/src/map/trade.cpp
@@ -1,15 +1,17 @@
-#include <stdio.h>
-#include <string.h>
+#include "trade.hpp"
+
+#include <cstdio>
+#include <cstring>
+#include "../common/nullpo.hpp"
+
+#include "battle.hpp"
#include "clif.hpp"
#include "itemdb.hpp"
#include "map.hpp"
-#include "trade.hpp"
-#include "pc.hpp"
#include "npc.hpp"
-#include "battle.hpp"
+#include "pc.hpp"
#include "storage.hpp"
-#include "../common/nullpo.hpp"
/*==========================================
* 取引要請を相手に送る
diff --git a/src/map/trade.hpp b/src/map/trade.hpp
index 3fc8f07..a05981f 100644
--- a/src/map/trade.hpp
+++ b/src/map/trade.hpp
@@ -1,8 +1,8 @@
-// $Id: trade.h,v 1.2 2004/09/25 05:32:19 MouseJstr Exp $
#ifndef TRADE_HPP
#define TRADE_HPP
#include "map.hpp"
+
void trade_traderequest(struct map_session_data *sd, int target_id);
void trade_tradeack(struct map_session_data *sd, int type);
void trade_tradeadditem(struct map_session_data *sd, int index, int amount);