From 1d0e18a186f67844ccd873eabb56ebdaa3f47f11 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 25 May 2013 13:49:50 -0700 Subject: Switch block_list and subclasses to dumb_ptr Now we're well-defined, since we're actually calling ctors and dtors. Most of this code will not survive long ... --- src/map/atcommand.cpp | 449 +++++++++++++++++------------------ src/map/atcommand.hpp | 6 +- src/map/battle.cpp | 398 +++++++++++++++---------------- src/map/battle.hpp | 82 +++---- src/map/chrif.cpp | 46 ++-- src/map/chrif.hpp | 14 +- src/map/clif.cpp | 472 +++++++++++++++++++------------------ src/map/clif.hpp | 180 +++++++------- src/map/intif.cpp | 22 +- src/map/intif.hpp | 12 +- src/map/magic-expr-eval.hpp | 8 +- src/map/magic-expr.cpp | 67 +++--- src/map/magic-interpreter-base.cpp | 91 +++---- src/map/magic-interpreter.hpp | 26 +- src/map/magic-stmt.cpp | 395 +++++++++++++++---------------- src/map/magic.cpp | 6 +- src/map/magic.hpp | 18 +- src/map/map.cpp | 188 +++++++-------- src/map/map.hpp | 260 +++++++++++++++----- src/map/map.t.hpp | 1 - src/map/mob.cpp | 279 +++++++++++----------- src/map/mob.hpp | 30 +-- src/map/npc.cpp | 388 +++++++++++++++--------------- src/map/npc.hpp | 36 +-- src/map/party.cpp | 84 ++++--- src/map/party.hpp | 26 +- src/map/pc.cpp | 277 +++++++++++----------- src/map/pc.hpp | 190 +++++++-------- src/map/script.cpp | 241 ++++++++++--------- src/map/skill-pools.cpp | 18 +- src/map/skill.cpp | 152 ++++++------ src/map/skill.hpp | 48 ++-- src/map/storage.cpp | 14 +- src/map/storage.hpp | 12 +- src/map/tmw.cpp | 10 +- src/map/tmw.hpp | 5 +- src/map/trade.cpp | 28 +-- src/map/trade.hpp | 16 +- 38 files changed, 2382 insertions(+), 2213 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 207ce25..56ff2ab 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -32,7 +32,7 @@ #include "../poison.hpp" #define ATCOMMAND_FUNC(x) static \ -int atcommand_##x(const int fd, struct map_session_data* sd, const char* command, const char* message) +int atcommand_##x(const int fd, dumb_ptr sd, const char *, const char *message) ATCOMMAND_FUNC(setup); ATCOMMAND_FUNC(broadcast); ATCOMMAND_FUNC(localbroadcast); @@ -182,14 +182,15 @@ struct AtCommandInfo { const char *command; int level; - int(*proc)(const int, struct map_session_data *, + int(*proc)(const int, dumb_ptr, const char *command, const char *message); }; // 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[] = { +AtCommandInfo atcommand_info[] = +{ {"@setup", 40, atcommand_setup}, {"@charwarp", 60, atcommand_charwarp}, {"@warp", 40, atcommand_warp}, @@ -362,7 +363,7 @@ FILE *get_gm_log(); /*======================================== * At-command logging */ -void log_atcommand(struct map_session_data *sd, const_string cmd) +void log_atcommand(dumb_ptr sd, const_string cmd) { FILE *fp = get_gm_log(); if (!fp) @@ -420,7 +421,7 @@ AtCommandInfo *atcommand(const int level, const char *message); *is_atcommand @コマンドに存在するかどうか確認する *------------------------------------------ */ -bool is_atcommand(const int fd, struct map_session_data *sd, +bool is_atcommand(const int fd, dumb_ptr sd, const char *message, int gmlvl) { nullpo_retr(false, sd); @@ -510,15 +511,15 @@ AtCommandInfo *atcommand(const int level, const char *message) *------------------------------------------ */ static -void atkillmonster_sub(struct block_list *bl, int flag) +void atkillmonster_sub(dumb_ptr bl, int flag) { nullpo_retv(bl); + dumb_ptr md = bl->as_mob(); if (flag) - mob_damage(NULL, (struct mob_data *) bl, - ((struct mob_data *) bl)->hp, 2); + mob_damage(NULL, md, md->hp, 2); else - mob_delete((struct mob_data *) bl); + mob_delete(md); } /*========================================== @@ -588,7 +589,7 @@ int atcommand_config_read(const char *cfgName) * TAW Specific *------------------------------------------ */ -int atcommand_setup(const int fd, struct map_session_data *sd, +int atcommand_setup(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; @@ -634,13 +635,13 @@ int atcommand_setup(const int fd, struct map_session_data *sd, * @rura+ *------------------------------------------ */ -int atcommand_charwarp(const int fd, struct map_session_data *sd, +int atcommand_charwarp(const int fd, dumb_ptr sd, const char *, const char *message) { char map_name[100]; char character[100]; int x = 0, y = 0; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; int m; memset(map_name, '\0', sizeof(map_name)); @@ -719,7 +720,7 @@ int atcommand_charwarp(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_warp(const int fd, struct map_session_data *sd, +int atcommand_warp(const int fd, dumb_ptr sd, const char *, const char *message) { char map_name[100]; @@ -782,11 +783,11 @@ int atcommand_warp(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_where(const int fd, struct map_session_data *sd, +int atcommand_where(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -816,11 +817,11 @@ int atcommand_where(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_goto(const int fd, struct map_session_data *sd, +int atcommand_goto(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -864,7 +865,7 @@ int atcommand_goto(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_jump(const int fd, struct map_session_data *sd, +int atcommand_jump(const int fd, dumb_ptr sd, const char *, const char *message) { int x = 0, y = 0; @@ -907,7 +908,7 @@ int atcommand_jump(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_who(const int fd, struct map_session_data *sd, +int atcommand_who(const int fd, dumb_ptr sd, const char *, const char *message) { int count; @@ -929,7 +930,7 @@ int atcommand_who(const int fd, struct map_session_data *sd, { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth) { pl_GM_level = pc_isGM(pl_sd); @@ -980,7 +981,7 @@ int atcommand_who(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_whogroup(const int fd, struct map_session_data *sd, +int atcommand_whogroup(const int fd, dumb_ptr sd, const char *, const char *message) { int count; @@ -1003,7 +1004,7 @@ int atcommand_whogroup(const int fd, struct map_session_data *sd, { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth) { pl_GM_level = pc_isGM(pl_sd); @@ -1050,7 +1051,7 @@ int atcommand_whogroup(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_whomap(const int fd, struct map_session_data *sd, +int atcommand_whomap(const int fd, dumb_ptr sd, const char *, const char *message) { int count; @@ -1077,7 +1078,7 @@ int atcommand_whomap(const int fd, struct map_session_data *sd, { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth) { pl_GM_level = pc_isGM(pl_sd); @@ -1117,7 +1118,7 @@ int atcommand_whomap(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_whomapgroup(const int fd, struct map_session_data *sd, +int atcommand_whomapgroup(const int fd, dumb_ptr sd, const char *, const char *message) { int count; @@ -1145,7 +1146,7 @@ int atcommand_whomapgroup(const int fd, struct map_session_data *sd, { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth) { pl_GM_level = pc_isGM(pl_sd); @@ -1191,7 +1192,7 @@ int atcommand_whomapgroup(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_whogm(const int fd, struct map_session_data *sd, +int atcommand_whogm(const int fd, dumb_ptr sd, const char *, const char *message) { int count; @@ -1214,7 +1215,7 @@ int atcommand_whogm(const int fd, struct map_session_data *sd, { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth) { pl_GM_level = pc_isGM(pl_sd); @@ -1274,7 +1275,7 @@ int atcommand_whogm(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_save(const int fd, struct map_session_data *sd, +int atcommand_save(const int fd, dumb_ptr sd, const char *, const char *) { nullpo_retr(-1, sd); @@ -1291,7 +1292,7 @@ int atcommand_save(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_load(const int fd, struct map_session_data *sd, +int atcommand_load(const int fd, dumb_ptr sd, const char *, const char *) { int m; @@ -1323,7 +1324,7 @@ int atcommand_load(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_speed(const int fd, struct map_session_data *sd, +int atcommand_speed(const int fd, dumb_ptr sd, const char *, const char *message) { if (!message || !*message) @@ -1362,7 +1363,7 @@ int atcommand_speed(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_storage(const int fd, struct map_session_data *sd, +int atcommand_storage(const int fd, dumb_ptr sd, const char *, const char *) { struct storage *stor; //changes from Freya/Yor @@ -1390,7 +1391,7 @@ int atcommand_storage(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_option(const int fd, struct map_session_data *sd, +int atcommand_option(const int fd, dumb_ptr sd, const char *, const char *message) { int param1_ = 0, param2_ = 0, param3_ = 0; @@ -1424,7 +1425,7 @@ int atcommand_option(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_hide(const int fd, struct map_session_data *sd, +int atcommand_hide(const int fd, dumb_ptr sd, const char *, const char *) { if (bool(sd->status.option & Option::HIDE)) @@ -1446,7 +1447,7 @@ int atcommand_hide(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_die(const int fd, struct map_session_data *sd, +int atcommand_die(const int fd, dumb_ptr sd, const char *, const char *) { pc_damage(NULL, sd, sd->status.hp + 1); @@ -1459,11 +1460,11 @@ int atcommand_die(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_kill(const int fd, struct map_session_data *sd, +int atcommand_kill(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -1500,7 +1501,7 @@ int atcommand_kill(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_alive(const int fd, struct map_session_data *sd, +int atcommand_alive(const int fd, dumb_ptr sd, const char *, const char *) { sd->status.hp = sd->status.max_hp; @@ -1520,7 +1521,7 @@ int atcommand_alive(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_kami(const int fd, struct map_session_data *, +int atcommand_kami(const int fd, dumb_ptr, const char *, const char *message) { if (!message || !*message) @@ -1539,7 +1540,7 @@ int atcommand_kami(const int fd, struct map_session_data *, * *------------------------------------------ */ -int atcommand_heal(const int fd, struct map_session_data *sd, +int atcommand_heal(const int fd, dumb_ptr sd, const char *, const char *message) { int hp = 0, sp = 0; // [Valaris] thanks to fov @@ -1587,7 +1588,7 @@ int atcommand_heal(const int fd, struct map_session_data *sd, * @item command (usage: @item ) *------------------------------------------ */ -int atcommand_item(const int fd, struct map_session_data *sd, +int atcommand_item(const int fd, dumb_ptr sd, const char *, const char *message) { char item_name[100]; @@ -1649,7 +1650,7 @@ int atcommand_item(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_itemreset(const int fd, struct map_session_data *sd, +int atcommand_itemreset(const int fd, dumb_ptr sd, const char *, const char *) { int i; @@ -1669,7 +1670,7 @@ int atcommand_itemreset(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_itemcheck(const int, struct map_session_data *sd, +int atcommand_itemcheck(const int, dumb_ptr sd, const char *, const char *) { pc_checkitem(sd); @@ -1681,7 +1682,7 @@ int atcommand_itemcheck(const int, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_baselevelup(const int fd, struct map_session_data *sd, +int atcommand_baselevelup(const int fd, dumb_ptr sd, const char *, const char *message) { int level, i; @@ -1747,7 +1748,7 @@ int atcommand_baselevelup(const int fd, struct map_session_data *sd, */ // TODO: merge this with pc_setparam(SP::JOBLEVEL) // then fix the funny 50 and/or 10 limitation. -int atcommand_joblevelup(const int fd, struct map_session_data *sd, +int atcommand_joblevelup(const int fd, dumb_ptr sd, const char *, const char *message) { int up_level = 50, level; @@ -1809,7 +1810,7 @@ int atcommand_joblevelup(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_help(const int fd, struct map_session_data *sd, +int atcommand_help(const int fd, dumb_ptr sd, const char *, const char *) { char buf[2048], w1[2048], w2[2048]; @@ -1854,7 +1855,7 @@ int atcommand_help(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_gm(const int fd, struct map_session_data *sd, +int atcommand_gm(const int fd, dumb_ptr sd, const char *, const char *message) { char password[100]; @@ -1884,7 +1885,7 @@ int atcommand_gm(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_pvpoff(const int fd, struct map_session_data *sd, +int atcommand_pvpoff(const int fd, dumb_ptr sd, const char *, const char *) { if (battle_config.pk_mode) @@ -1900,7 +1901,7 @@ int atcommand_pvpoff(const int fd, struct map_session_data *sd, { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth) { if (sd->bl_m == pl_sd->bl_m) @@ -1924,7 +1925,7 @@ int atcommand_pvpoff(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_pvpon(const int fd, struct map_session_data *sd, +int atcommand_pvpon(const int fd, dumb_ptr sd, const char *, const char *) { if (battle_config.pk_mode) @@ -1940,7 +1941,7 @@ int atcommand_pvpon(const int fd, struct map_session_data *sd, { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth) { if (sd->bl_m == pl_sd->bl_m && !pl_sd->pvp_timer) @@ -1968,7 +1969,7 @@ int atcommand_pvpon(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_model(const int fd, struct map_session_data *sd, +int atcommand_model(const int fd, dumb_ptr sd, const char *, const char *message) { int hair_style = 0, hair_color = 0, cloth_color = 0; @@ -2010,7 +2011,7 @@ int atcommand_model(const int fd, struct map_session_data *sd, * @dye && @ccolor *------------------------------------------ */ -int atcommand_dye(const int fd, struct map_session_data *sd, +int atcommand_dye(const int fd, dumb_ptr sd, const char *, const char *message) { int cloth_color = 0; @@ -2044,7 +2045,7 @@ int atcommand_dye(const int fd, struct map_session_data *sd, * @hairstyle && @hstyle *------------------------------------------ */ -int atcommand_hair_style(const int fd, struct map_session_data *sd, +int atcommand_hair_style(const int fd, dumb_ptr sd, const char *, const char *message) { int hair_style = 0; @@ -2078,7 +2079,7 @@ int atcommand_hair_style(const int fd, struct map_session_data *sd, * @haircolor && @hcolor *------------------------------------------ */ -int atcommand_hair_color(const int fd, struct map_session_data *sd, +int atcommand_hair_color(const int fd, dumb_ptr sd, const char *, const char *message) { int hair_color = 0; @@ -2112,7 +2113,7 @@ int atcommand_hair_color(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_spawn(const int fd, struct map_session_data *sd, +int atcommand_spawn(const int fd, dumb_ptr sd, const char *command, const char *message) { char monster[100]; @@ -2206,7 +2207,7 @@ int atcommand_spawn(const int fd, struct map_session_data *sd, *------------------------------------------ */ static -void atcommand_killmonster_sub(const int fd, struct map_session_data *sd, +void atcommand_killmonster_sub(const int fd, dumb_ptr sd, const char *message, const int drop) { int map_id; @@ -2236,7 +2237,7 @@ void atcommand_killmonster_sub(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_killmonster(const int fd, struct map_session_data *sd, +int atcommand_killmonster(const int fd, dumb_ptr sd, const char *, const char *message) { atcommand_killmonster_sub(fd, sd, message, 1); @@ -2249,12 +2250,12 @@ int atcommand_killmonster(const int fd, struct map_session_data *sd, *------------------------------------------ */ static -void atlist_nearby_sub(struct block_list *bl, int fd) +void atlist_nearby_sub(dumb_ptr bl, int fd) { nullpo_retv(bl); std::string buf = STRPRINTF(" - \"%s\"", - ((struct map_session_data *) bl)->status.name); + bl->as_player()->status.name); clif_displaymessage(fd, buf); } @@ -2262,7 +2263,7 @@ void atlist_nearby_sub(struct block_list *bl, int fd) * *------------------------------------------ */ -int atcommand_list_nearby(const int fd, struct map_session_data *sd, +int atcommand_list_nearby(const int fd, dumb_ptr sd, const char *, const char *) { clif_displaymessage(fd, "Nearby players:"); @@ -2277,7 +2278,7 @@ int atcommand_list_nearby(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_killmonster2(const int fd, struct map_session_data *sd, +int atcommand_killmonster2(const int fd, dumb_ptr sd, const char *, const char *message) { atcommand_killmonster_sub(fd, sd, message, 0); @@ -2289,7 +2290,7 @@ int atcommand_killmonster2(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_gat(const int fd, struct map_session_data *sd, +int atcommand_gat(const int fd, dumb_ptr sd, const char *, const char *) { int y; @@ -2314,7 +2315,7 @@ int atcommand_gat(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_packet(const int fd, struct map_session_data *sd, +int atcommand_packet(const int fd, dumb_ptr sd, const char *, const char *message) { int type = 0, flag = 0; @@ -2335,7 +2336,7 @@ int atcommand_packet(const int fd, struct map_session_data *sd, * @stpoint (Rewritten by [Yor]) *------------------------------------------ */ -int atcommand_statuspoint(const int fd, struct map_session_data *sd, +int atcommand_statuspoint(const int fd, dumb_ptr sd, const char *, const char *message) { int point, new_status_point; @@ -2375,7 +2376,7 @@ int atcommand_statuspoint(const int fd, struct map_session_data *sd, * @skpoint (Rewritten by [Yor]) *------------------------------------------ */ -int atcommand_skillpoint(const int fd, struct map_session_data *sd, +int atcommand_skillpoint(const int fd, dumb_ptr sd, const char *, const char *message) { int point, new_skill_point; @@ -2415,7 +2416,7 @@ int atcommand_skillpoint(const int fd, struct map_session_data *sd, * @zeny (Rewritten by [Yor]) *------------------------------------------ */ -int atcommand_zeny(const int fd, struct map_session_data *sd, +int atcommand_zeny(const int fd, dumb_ptr sd, const char *, const char *message) { int zeny, new_zeny; @@ -2456,7 +2457,7 @@ int atcommand_zeny(const int fd, struct map_session_data *sd, *------------------------------------------ */ template -int atcommand_param(const int fd, struct map_session_data *sd, +int atcommand_param(const int fd, dumb_ptr sd, const char *, const char *message) { int value = 0, new_value; @@ -2503,7 +2504,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, +int atcommand_all_stats(const int fd, dumb_ptr sd, const char *, const char *message) { int count, value = 0, new_value; @@ -2549,11 +2550,11 @@ int atcommand_all_stats(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_recall(const int fd, struct map_session_data *sd, +int atcommand_recall(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -2605,11 +2606,11 @@ int atcommand_recall(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_revive(const int fd, struct map_session_data *sd, +int atcommand_revive(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -2644,11 +2645,11 @@ int atcommand_revive(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_character_stats(const int fd, struct map_session_data *, +int atcommand_character_stats(const int fd, dumb_ptr, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -2705,7 +2706,7 @@ int atcommand_character_stats(const int fd, struct map_session_data *, *------------------------------------------ */ //** Character Stats All by fritz -int atcommand_character_stats_all(const int fd, struct map_session_data *, +int atcommand_character_stats_all(const int fd, dumb_ptr, const char *, const char *) { int count; @@ -2715,7 +2716,7 @@ int atcommand_character_stats_all(const int fd, struct map_session_data *, { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth) { std::string gmlevel; @@ -2764,12 +2765,12 @@ int atcommand_character_stats_all(const int fd, struct map_session_data *, * *------------------------------------------ */ -int atcommand_character_option(const int fd, struct map_session_data *sd, +int atcommand_character_option(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; int opt1_ = 0, opt2_ = 0, opt3_ = 0; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -2818,7 +2819,7 @@ int atcommand_character_option(const int fd, struct map_session_data *sd, * charchangesex command (usage: charchangesex ) *------------------------------------------ */ -int atcommand_char_change_sex(const int fd, struct map_session_data *sd, +int atcommand_char_change_sex(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; @@ -2857,7 +2858,7 @@ int atcommand_char_change_sex(const int fd, struct map_session_data *sd, * This command do a definitiv ban on a player *------------------------------------------ */ -int atcommand_char_block(const int fd, struct map_session_data *sd, +int atcommand_char_block(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; @@ -2907,7 +2908,7 @@ int atcommand_char_block(const int fd, struct map_session_data *sd, * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time. *------------------------------------------ */ -int atcommand_char_ban(const int fd, struct map_session_data *sd, +int atcommand_char_ban(const int fd, dumb_ptr sd, const char *, const char *message) { char modif[100], character[100]; @@ -3008,7 +3009,7 @@ int atcommand_char_ban(const int fd, struct map_session_data *sd, * charunblock command (usage: charunblock ) *------------------------------------------ */ -int atcommand_char_unblock(const int fd, struct map_session_data *sd, +int atcommand_char_unblock(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; @@ -3047,7 +3048,7 @@ int atcommand_char_unblock(const int fd, struct map_session_data *sd, * charunban command (usage: charunban ) *------------------------------------------ */ -int atcommand_char_unban(const int fd, struct map_session_data *sd, +int atcommand_char_unban(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; @@ -3086,12 +3087,12 @@ int atcommand_char_unban(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_character_save(const int fd, struct map_session_data *sd, +int atcommand_character_save(const int fd, dumb_ptr sd, const char *, const char *message) { char map_name[100]; char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; int x = 0, y = 0; int m; @@ -3152,14 +3153,14 @@ int atcommand_character_save(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_doom(const int fd, struct map_session_data *sd, +int atcommand_doom(const int fd, dumb_ptr sd, const char *, const char *) { for (int i = 0; i < fd_max; i++) { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth && i != fd && pc_isGM(sd) >= pc_isGM(pl_sd)) @@ -3177,14 +3178,14 @@ int atcommand_doom(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_doommap(const int fd, struct map_session_data *sd, +int atcommand_doommap(const int fd, dumb_ptr sd, const char *, const char *) { for (int i = 0; i < fd_max; i++) { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth && i != fd && sd->bl_m == pl_sd->bl_m && pc_isGM(sd) >= pc_isGM(pl_sd)) @@ -3203,7 +3204,7 @@ int atcommand_doommap(const int fd, struct map_session_data *sd, *------------------------------------------ */ static -void atcommand_raise_sub(struct map_session_data *sd) +void atcommand_raise_sub(dumb_ptr sd) { if (sd && sd->state.auth && pc_isdead(sd)) { @@ -3221,14 +3222,14 @@ void atcommand_raise_sub(struct map_session_data *sd) * *------------------------------------------ */ -int atcommand_raise(const int fd, struct map_session_data *, +int atcommand_raise(const int fd, dumb_ptr, const char *, const char *) { for (int i = 0; i < fd_max; i++) { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); atcommand_raise_sub(pl_sd); } clif_displaymessage(fd, "Mercy has been granted."); @@ -3240,14 +3241,14 @@ int atcommand_raise(const int fd, struct map_session_data *, * *------------------------------------------ */ -int atcommand_raisemap(const int fd, struct map_session_data *sd, +int atcommand_raisemap(const int fd, dumb_ptr sd, const char *, const char *) { for (int i = 0; i < fd_max; i++) { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth && sd->bl_m == pl_sd->bl_m) atcommand_raise_sub(pl_sd); @@ -3261,10 +3262,10 @@ int atcommand_raisemap(const int fd, struct map_session_data *sd, * atcommand_character_baselevel @charbaselvlで対象キャラのレベルを上げる *------------------------------------------ */ -int atcommand_character_baselevel(const int fd, struct map_session_data *sd, +int atcommand_character_baselevel(const int fd, dumb_ptr sd, const char *, const char *message) { - struct map_session_data *pl_sd; + dumb_ptr pl_sd; char character[100]; int level = 0, i; @@ -3355,10 +3356,10 @@ int atcommand_character_baselevel(const int fd, struct map_session_data *sd, * atcommand_character_joblevel @charjoblvlで対象キャラのJobレベルを上げる *------------------------------------------ */ -int atcommand_character_joblevel(const int fd, struct map_session_data *sd, +int atcommand_character_joblevel(const int fd, dumb_ptr sd, const char *, const char *message) { - struct map_session_data *pl_sd; + dumb_ptr pl_sd; char character[100]; int max_level = 50, level = 0; @@ -3440,10 +3441,10 @@ int atcommand_character_joblevel(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_kick(const int fd, struct map_session_data *sd, +int atcommand_kick(const int fd, dumb_ptr sd, const char *, const char *message) { - struct map_session_data *pl_sd; + dumb_ptr pl_sd; char character[100]; memset(character, '\0', sizeof(character)); @@ -3478,14 +3479,14 @@ int atcommand_kick(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_kickall(const int fd, struct map_session_data *sd, +int atcommand_kickall(const int fd, dumb_ptr sd, const char *, const char *) { for (int i = 0; i < fd_max; i++) { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth && pc_isGM(sd) >= pc_isGM(pl_sd)) { @@ -3504,7 +3505,7 @@ int atcommand_kickall(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_questskill(const int fd, struct map_session_data *sd, +int atcommand_questskill(const int fd, dumb_ptr sd, const char *, const char *message) { int skill_id_; @@ -3552,11 +3553,11 @@ int atcommand_questskill(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_charquestskill(const int fd, struct map_session_data *, +int atcommand_charquestskill(const int fd, dumb_ptr, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; int skill_id_ = 0; memset(character, '\0', sizeof(character)); @@ -3614,7 +3615,7 @@ int atcommand_charquestskill(const int fd, struct map_session_data *, * *------------------------------------------ */ -int atcommand_lostskill(const int fd, struct map_session_data *sd, +int atcommand_lostskill(const int fd, dumb_ptr sd, const char *, const char *message) { int skill_id_; @@ -3664,11 +3665,11 @@ int atcommand_lostskill(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_charlostskill(const int fd, struct map_session_data *, +int atcommand_charlostskill(const int fd, dumb_ptr, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; int skill_id_ = 0; memset(character, '\0', sizeof(character)); @@ -3728,7 +3729,7 @@ int atcommand_charlostskill(const int fd, struct map_session_data *, * *------------------------------------------ */ -int atcommand_party(const int fd, struct map_session_data *sd, +int atcommand_party(const int fd, dumb_ptr sd, const char *, const char *message) { char party[100]; @@ -3751,14 +3752,14 @@ int atcommand_party(const int fd, struct map_session_data *sd, * @mapexitでマップサーバーを終了させる *------------------------------------------ */ -int atcommand_mapexit(const int, struct map_session_data *sd, +int atcommand_mapexit(const int, dumb_ptr sd, const char *, const char *) { for (int i = 0; i < fd_max; i++) { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth) { if (sd->status.account_id != pl_sd->status.account_id) @@ -3776,7 +3777,7 @@ int atcommand_mapexit(const int, struct map_session_data *sd, * idsearch : revrited by [Yor] *------------------------------------------ */ -int atcommand_idsearch(const int fd, struct map_session_data *, +int atcommand_idsearch(const int fd, dumb_ptr, const char *, const char *message) { char item_name[100]; @@ -3815,11 +3816,11 @@ int atcommand_idsearch(const int fd, struct map_session_data *, * Character Skill Reset *------------------------------------------ */ -int atcommand_charskreset(const int fd, struct map_session_data *sd, +int atcommand_charskreset(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -3858,11 +3859,11 @@ int atcommand_charskreset(const int fd, struct map_session_data *sd, * Character Stat Reset *------------------------------------------ */ -int atcommand_charstreset(const int fd, struct map_session_data *sd, +int atcommand_charstreset(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -3902,11 +3903,11 @@ int atcommand_charstreset(const int fd, struct map_session_data *sd, * Character Reset *------------------------------------------ */ -int atcommand_charreset(const int fd, struct map_session_data *sd, +int atcommand_charreset(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -3948,11 +3949,11 @@ int atcommand_charreset(const int fd, struct map_session_data *sd, * Character Wipe *------------------------------------------ */ -int atcommand_char_wipe(const int fd, struct map_session_data *sd, +int atcommand_char_wipe(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -4036,11 +4037,11 @@ 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 *, +int atcommand_charmodel(const int fd, dumb_ptr, const char *, const char *message) { int hair_style = 0, hair_color = 0, cloth_color = 0; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; char character[100]; memset(character, '\0', sizeof(character)); @@ -4091,10 +4092,10 @@ int atcommand_charmodel(const int fd, struct map_session_data *, * Character Skill Point (Rewritten by [Yor]) *------------------------------------------ */ -int atcommand_charskpoint(const int fd, struct map_session_data *, +int atcommand_charskpoint(const int fd, dumb_ptr, const char *, const char *message) { - struct map_session_data *pl_sd; + dumb_ptr pl_sd; char character[100]; int new_skill_point; int point = 0; @@ -4145,10 +4146,10 @@ int atcommand_charskpoint(const int fd, struct map_session_data *, * Character Status Point (rewritten by [Yor]) *------------------------------------------ */ -int atcommand_charstpoint(const int fd, struct map_session_data *, +int atcommand_charstpoint(const int fd, dumb_ptr, const char *, const char *message) { - struct map_session_data *pl_sd; + dumb_ptr pl_sd; char character[100]; int new_status_point; int point = 0; @@ -4199,10 +4200,10 @@ int atcommand_charstpoint(const int fd, struct map_session_data *, * Character Zeny Point (Rewritten by [Yor]) *------------------------------------------ */ -int atcommand_charzeny(const int fd, struct map_session_data *, +int atcommand_charzeny(const int fd, dumb_ptr, const char *, const char *message) { - struct map_session_data *pl_sd; + dumb_ptr pl_sd; char character[100]; int zeny = 0, new_zeny; @@ -4251,7 +4252,7 @@ int atcommand_charzeny(const int fd, struct map_session_data *, * Recall All Characters Online To Your Location *------------------------------------------ */ -int atcommand_recallall(const int fd, struct map_session_data *sd, +int atcommand_recallall(const int fd, dumb_ptr sd, const char *, const char *) { int count; @@ -4269,7 +4270,7 @@ int atcommand_recallall(const int fd, struct map_session_data *sd, { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth && sd->status.account_id != pl_sd->status.account_id @@ -4300,7 +4301,7 @@ int atcommand_recallall(const int fd, struct map_session_data *sd, * Recall online characters of a party to your location *------------------------------------------ */ -int atcommand_partyrecall(const int fd, struct map_session_data *sd, +int atcommand_partyrecall(const int fd, dumb_ptr sd, const char *, const char *message) { char party_name[100]; @@ -4332,7 +4333,7 @@ int atcommand_partyrecall(const int fd, struct map_session_data *sd, { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth && sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party_id) @@ -4367,7 +4368,7 @@ int atcommand_partyrecall(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_reloaditemdb(const int fd, struct map_session_data *, +int atcommand_reloaditemdb(const int fd, dumb_ptr, const char *, const char *) { itemdb_reload(); @@ -4380,7 +4381,7 @@ int atcommand_reloaditemdb(const int fd, struct map_session_data *, * *------------------------------------------ */ -int atcommand_reloadmobdb(const int fd, struct map_session_data *, +int atcommand_reloadmobdb(const int fd, dumb_ptr, const char *, const char *) { mob_reload(); @@ -4393,7 +4394,7 @@ int atcommand_reloadmobdb(const int fd, struct map_session_data *, * *------------------------------------------ */ -int atcommand_reloadskilldb(const int fd, struct map_session_data *, +int atcommand_reloadskilldb(const int fd, dumb_ptr, const char *, const char *) { skill_reload(); @@ -4406,7 +4407,7 @@ int atcommand_reloadskilldb(const int fd, struct map_session_data *, * *------------------------------------------ */ -int atcommand_reloadscript(const int fd, struct map_session_data *, +int atcommand_reloadscript(const int fd, dumb_ptr, const char *, const char *) { do_init_npc(); @@ -4423,7 +4424,7 @@ int atcommand_reloadscript(const int fd, struct map_session_data *, * *------------------------------------------ */ -int atcommand_reloadgmdb(const int fd, struct map_session_data *, +int atcommand_reloadgmdb(const int fd, dumb_ptr, const char *, const char *) { chrif_reloadGMdb(); @@ -4441,10 +4442,10 @@ int atcommand_reloadgmdb(const int fd, struct map_session_data *, * 2 = Shows NPCs in that map *------------------------------------------ */ -int atcommand_mapinfo(const int fd, struct map_session_data *sd, +int atcommand_mapinfo(const int fd, dumb_ptr sd, const char *, const char *message) { - struct npc_data *nd = NULL; + dumb_ptr nd = NULL; char map_name[100]; const char *direction = NULL; int m_id, list = 0; @@ -4519,7 +4520,7 @@ int atcommand_mapinfo(const int fd, struct map_session_data *sd, { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth && strcmp(pl_sd->mapname, map_name) == 0) { @@ -4590,7 +4591,7 @@ int atcommand_mapinfo(const int fd, struct map_session_data *sd, *Spy Commands by Syrus22 *------------------------------------------ */ -int atcommand_partyspy(const int fd, struct map_session_data *sd, +int atcommand_partyspy(const int fd, dumb_ptr sd, const char *, const char *message) { char party_name[100]; @@ -4634,7 +4635,7 @@ int atcommand_partyspy(const int fd, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_enablenpc(const int fd, struct map_session_data *, +int atcommand_enablenpc(const int fd, dumb_ptr, const char *, const char *message) { char NPCname[100]; @@ -4666,7 +4667,7 @@ int atcommand_enablenpc(const int fd, struct map_session_data *, * *------------------------------------------ */ -int atcommand_disablenpc(const int fd, struct map_session_data *, +int atcommand_disablenpc(const int fd, dumb_ptr, const char *, const char *message) { char NPCname[100]; @@ -4699,7 +4700,7 @@ int atcommand_disablenpc(const int fd, struct map_session_data *, * Calculation management of GM modification (@day/@night GM commands) is done *------------------------------------------ */ -int atcommand_servertime(const int fd, struct map_session_data *, +int atcommand_servertime(const int fd, dumb_ptr, const char *, const char *) { timestamp_seconds_buffer tsbuf; @@ -4722,10 +4723,10 @@ int atcommand_servertime(const int fd, struct map_session_data *, * Inspired from a old command created by RoVeRT *------------------------------------------ */ -int atcommand_chardelitem(const int fd, struct map_session_data *sd, +int atcommand_chardelitem(const int fd, dumb_ptr sd, const char *, const char *message) { - struct map_session_data *pl_sd; + dumb_ptr pl_sd; char character[100]; char item_name[100]; int i, number = 0, item_id, item_position, count; @@ -4806,7 +4807,7 @@ int atcommand_chardelitem(const int fd, struct map_session_data *sd, * @broadcast by [Valaris] *------------------------------------------ */ -int atcommand_broadcast(const int fd, struct map_session_data *sd, +int atcommand_broadcast(const int fd, dumb_ptr sd, const char *, const char *message) { if (!message || !*message) @@ -4826,7 +4827,7 @@ int atcommand_broadcast(const int fd, struct map_session_data *sd, * @localbroadcast by [Valaris] *------------------------------------------ */ -int atcommand_localbroadcast(const int fd, struct map_session_data *sd, +int atcommand_localbroadcast(const int fd, dumb_ptr sd, const char *, const char *message) { if (!message || !*message) @@ -4847,7 +4848,7 @@ int atcommand_localbroadcast(const int fd, struct map_session_data *sd, * @ignorelist by [Yor] *------------------------------------------ */ -int atcommand_ignorelist(const int fd, struct map_session_data *sd, +int atcommand_ignorelist(const int fd, dumb_ptr sd, const char *, const char *) { int count; @@ -4891,11 +4892,11 @@ int atcommand_ignorelist(const int fd, struct map_session_data *sd, * @charignorelist by [Yor] *------------------------------------------ */ -int atcommand_charignorelist(const int fd, struct map_session_data *, +int atcommand_charignorelist(const int fd, dumb_ptr, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; int count; int i; @@ -4968,11 +4969,11 @@ int atcommand_charignorelist(const int fd, struct map_session_data *, * @inall by [Yor] *------------------------------------------ */ -int atcommand_inall(const int fd, struct map_session_data *sd, +int atcommand_inall(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -5029,11 +5030,11 @@ int atcommand_inall(const int fd, struct map_session_data *sd, * @exall by [Yor] *------------------------------------------ */ -int atcommand_exall(const int fd, struct map_session_data *sd, +int atcommand_exall(const int fd, dumb_ptr sd, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -5090,7 +5091,7 @@ int atcommand_exall(const int fd, struct map_session_data *sd, * @email by [Yor] *------------------------------------------ */ -int atcommand_email(const int fd, struct map_session_data *sd, +int atcommand_email(const int fd, dumb_ptr sd, const char *, const char *message) { char actual_email[100]; @@ -5140,7 +5141,7 @@ int atcommand_email(const int fd, struct map_session_data *sd, *@effect *------------------------------------------ */ -int atcommand_effect(const int fd, struct map_session_data *sd, +int atcommand_effect(const int fd, dumb_ptr sd, const char *, const char *message) { int type = 0, flag = 0; @@ -5162,7 +5163,7 @@ int atcommand_effect(const int fd, struct map_session_data *sd, { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth) { clif_specialeffect(pl_sd, type, flag); @@ -5178,10 +5179,10 @@ int atcommand_effect(const int fd, struct map_session_data *sd, * @charitemlist : Displays the list of a player's items. *------------------------------------------ */ -int atcommand_character_item_list(const int fd, struct map_session_data *sd, +int atcommand_character_item_list(const int fd, dumb_ptr sd, const char *, const char *message) { - struct map_session_data *pl_sd; + dumb_ptr pl_sd; struct item_data *item_data, *item_temp; int i, j, count, counter, counter2; char character[100], equipstr[100]; @@ -5340,11 +5341,11 @@ int atcommand_character_item_list(const int fd, struct map_session_data *sd, * @charstoragelist : Displays the items list of a player's storage. *------------------------------------------ */ -int atcommand_character_storage_list(const int fd, struct map_session_data *sd, +int atcommand_character_storage_list(const int fd, dumb_ptr sd, const char *, const char *message) { struct storage *stor; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; struct item_data *item_data, *item_temp; int i, j, count, counter, counter2; char character[100]; @@ -5472,10 +5473,10 @@ int atcommand_character_storage_list(const int fd, struct map_session_data *sd, * @charcartlist : Displays the items list of a player's cart. *------------------------------------------ */ -int atcommand_character_cart_list(const int fd, struct map_session_data *sd, +int atcommand_character_cart_list(const int fd, dumb_ptr sd, const char *, const char *message) { - struct map_session_data *pl_sd; + dumb_ptr pl_sd; struct item_data *item_data, *item_temp; int i, j, count, counter, counter2; char character[100]; @@ -5595,7 +5596,7 @@ int 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, +int atcommand_killer(const int fd, dumb_ptr sd, const char *, const char *) { sd->special_state.killer = !sd->special_state.killer; @@ -5613,7 +5614,7 @@ int 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, +int atcommand_killable(const int fd, dumb_ptr sd, const char *, const char *) { sd->special_state.killable = !sd->special_state.killable; @@ -5631,10 +5632,10 @@ int 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 *, +int atcommand_charkillable(const int fd, dumb_ptr, const char *, const char *message) { - struct map_session_data *pl_sd = NULL; + dumb_ptr pl_sd = NULL; if (!message || !*message) return -1; @@ -5658,12 +5659,12 @@ int atcommand_charkillable(const int fd, struct map_session_data *, * move a npc *------------------------------------------ */ -int atcommand_npcmove(const int, struct map_session_data *sd, +int atcommand_npcmove(const int, dumb_ptr sd, const char *, const char *message) { char character[100]; int x = 0, y = 0; - struct npc_data *nd = 0; + dumb_ptr nd = 0; if (sd == NULL) return -1; @@ -5694,7 +5695,7 @@ int atcommand_npcmove(const int, struct map_session_data *sd, * Create a new static warp point. *------------------------------------------ */ -int atcommand_addwarp(const int fd, struct map_session_data *sd, +int atcommand_addwarp(const int fd, dumb_ptr sd, const char *, const char *message) { char mapname[30]; @@ -5724,10 +5725,10 @@ int atcommand_addwarp(const int fd, struct map_session_data *sd, * Create a effect localized on another character *------------------------------------------ */ -int atcommand_chareffect(const int fd, struct map_session_data *, +int atcommand_chareffect(const int fd, dumb_ptr, const char *, const char *message) { - struct map_session_data *pl_sd = NULL; + dumb_ptr pl_sd = NULL; char target[255]; int type = 0; @@ -5753,7 +5754,7 @@ int atcommand_chareffect(const int fd, struct map_session_data *, * Drop all your possession on the ground *------------------------------------------ */ -int atcommand_dropall(const int, struct map_session_data *sd, +int atcommand_dropall(const int, dumb_ptr sd, const char *, const char *) { int i; @@ -5776,11 +5777,11 @@ int atcommand_dropall(const int, 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 *, +int atcommand_chardropall(const int fd, dumb_ptr, const char *, const char *message) { int i; - struct map_session_data *pl_sd = NULL; + dumb_ptr pl_sd = NULL; if (!message || !*message) return -1; @@ -5810,7 +5811,7 @@ int atcommand_chardropall(const int fd, struct map_session_data *, * debugging easie *------------------------------------------ */ -int atcommand_storeall(const int fd, struct map_session_data *sd, +int atcommand_storeall(const int fd, dumb_ptr sd, const char *, const char *) { int i; @@ -5850,11 +5851,11 @@ int 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, +int atcommand_charstoreall(const int fd, dumb_ptr sd, const char *, const char *message) { int i; - struct map_session_data *pl_sd = NULL; + dumb_ptr pl_sd = NULL; if (!message || !*message) return -1; @@ -5894,7 +5895,7 @@ int atcommand_charstoreall(const int fd, struct map_session_data *sd, * It is made to rain. *------------------------------------------ */ -int atcommand_rain(const int, struct map_session_data *sd, +int atcommand_rain(const int, dumb_ptr sd, const char *, const char *) { int effno = 0; @@ -5912,7 +5913,7 @@ int atcommand_rain(const int, struct map_session_data *sd, * It is made to snow. *------------------------------------------ */ -int atcommand_snow(const int, struct map_session_data *sd, +int atcommand_snow(const int, dumb_ptr sd, const char *, const char *) { int effno = 0; @@ -5930,7 +5931,7 @@ int atcommand_snow(const int, struct map_session_data *sd, * Cherry tree snowstorm is made to fall. (Sakura) *------------------------------------------ */ -int atcommand_sakura(const int, struct map_session_data *sd, +int atcommand_sakura(const int, dumb_ptr sd, const char *, const char *) { int effno = 0; @@ -5948,7 +5949,7 @@ int atcommand_sakura(const int, struct map_session_data *sd, * Fog hangs over. *------------------------------------------ */ -int atcommand_fog(const int, struct map_session_data *sd, +int atcommand_fog(const int, dumb_ptr sd, const char *, const char *) { int effno = 0; @@ -5967,7 +5968,7 @@ int atcommand_fog(const int, struct map_session_data *sd, * Fallen leaves fall. *------------------------------------------ */ -int atcommand_leaves(const int, struct map_session_data *sd, +int atcommand_leaves(const int, dumb_ptr sd, const char *, const char *) { int effno = 0; @@ -5985,7 +5986,7 @@ int atcommand_leaves(const int, struct map_session_data *sd, * *------------------------------------------ */ -int atcommand_summon(const int, struct map_session_data *sd, +int atcommand_summon(const int, dumb_ptr sd, const char *, const char *message) { char name[100]; @@ -5993,7 +5994,7 @@ int atcommand_summon(const int, struct map_session_data *sd, int x = 0; int y = 0; int id = 0; - struct mob_data *md; + dumb_ptr md; tick_t tick = gettick(); nullpo_retr(-1, sd); @@ -6012,7 +6013,7 @@ int atcommand_summon(const int, struct map_session_data *sd, y = sd->bl_y + random_::in(-5, 4); id = mob_once_spawn(sd, "this", x, y, "--ja--", mob_id, 1, ""); - if ((md = (struct mob_data *) map_id2bl(id))) + if ((md = map_id_as_mob(id))) { md->master_id = sd->bl_id; md->state.special_mob_ai = 1; @@ -6035,7 +6036,7 @@ int atcommand_summon(const int, struct map_session_data *sd, * for short periods of time *------------------------------------------ */ -int atcommand_adjcmdlvl(const int fd, struct map_session_data *, +int atcommand_adjcmdlvl(const int fd, dumb_ptr, const char *, const char *message) { int i, newlev; @@ -6068,12 +6069,12 @@ int atcommand_adjcmdlvl(const int fd, struct map_session_data *, * for short periods of time *------------------------------------------ */ -int atcommand_adjgmlvl(const int fd, struct map_session_data *, +int atcommand_adjgmlvl(const int fd, dumb_ptr, const char *, const char *message) { int newlev; char user[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; if (!message || !*message || sscanf(message, "%d %s", &newlev, user) != 2) @@ -6099,10 +6100,10 @@ int atcommand_adjgmlvl(const int fd, struct map_session_data *, * gonna scream! *------------------------------------------ */ -int atcommand_trade(const int, struct map_session_data *sd, +int atcommand_trade(const int, dumb_ptr sd, const char *, const char *message) { - struct map_session_data *pl_sd = NULL; + dumb_ptr pl_sd = NULL; if (!message || !*message) return -1; @@ -6141,11 +6142,11 @@ const char *magic_skill_names[magic_skills_nr] = "astral" }; -int atcommand_magic_info(const int fd, struct map_session_data *, +int atcommand_magic_info(const int fd, dumb_ptr, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -6182,18 +6183,18 @@ int atcommand_magic_info(const int fd, struct map_session_data *, } static -void set_skill(struct map_session_data *sd, SkillID i, int level) +void set_skill(dumb_ptr sd, SkillID i, int level) { sd->status.skill[i].lv = level; } -int atcommand_set_magic(const int fd, struct map_session_data *, +int atcommand_set_magic(const int fd, dumb_ptr, const char *, const char *message) { char character[100]; char magic_type[20]; int value; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; memset(character, '\0', sizeof(character)); @@ -6245,14 +6246,14 @@ int atcommand_set_magic(const int fd, struct map_session_data *, return -1; } -int atcommand_log(const int, struct map_session_data *, +int atcommand_log(const int, dumb_ptr, const char *, const char *) { return 0; // only used for (implicit) logging } -int atcommand_tee(const int, struct map_session_data *sd, +int atcommand_tee(const int, dumb_ptr sd, const char *, const char *message) { char data[strlen(message) + 28]; @@ -6263,14 +6264,14 @@ int atcommand_tee(const int, struct map_session_data *sd, return 0; } -int atcommand_invisible(const int, struct map_session_data *sd, +int atcommand_invisible(const int, dumb_ptr sd, const char *, const char *) { pc_invisibility(sd, 1); return 0; } -int atcommand_visible(const int, struct map_session_data *sd, +int atcommand_visible(const int, dumb_ptr sd, const char *, const char *) { pc_invisibility(sd, 0); @@ -6278,14 +6279,14 @@ int atcommand_visible(const int, struct map_session_data *sd, } static -int atcommand_jump_iterate(const int fd, struct map_session_data *sd, +int atcommand_jump_iterate(const int fd, dumb_ptr sd, const char *, const char *, - struct map_session_data *(*get_start)(void), - struct map_session_data *(*get_next)(struct map_session_data*)) + dumb_ptr (*get_start)(void), + dumb_ptr (*get_next)(dumb_ptr)) { - struct map_session_data *pl_sd; + dumb_ptr pl_sd; - pl_sd = (struct map_session_data *) map_id2bl(sd->followtarget); + pl_sd = map_id_as_player(sd->followtarget); if (pl_sd) pl_sd = get_next(pl_sd); @@ -6324,7 +6325,7 @@ int atcommand_jump_iterate(const int fd, struct map_session_data *sd, } int atcommand_iterate_forward_over_players(const int fd, - struct map_session_data *sd, + dumb_ptr sd, const char *command, const char *message) { @@ -6334,7 +6335,7 @@ int atcommand_iterate_forward_over_players(const int fd, } int atcommand_iterate_backwards_over_players(const int fd, - struct map_session_data *sd, + dumb_ptr sd, const char *command, const char *message) { @@ -6343,7 +6344,7 @@ int atcommand_iterate_backwards_over_players(const int fd, map_get_prev_session); } -int atcommand_wgm(const int fd, struct map_session_data *sd, +int atcommand_wgm(const int fd, dumb_ptr sd, const char *, const char *message) { if (tmw_CheckChatSpam(sd, message)) @@ -6357,11 +6358,11 @@ int atcommand_wgm(const int fd, struct map_session_data *sd, } -int atcommand_skillpool_info(const int fd, struct map_session_data *, +int atcommand_skillpool_info(const int fd, dumb_ptr, const char *, const char *message) { char character[100]; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) { @@ -6412,12 +6413,12 @@ int atcommand_skillpool_info(const int fd, struct map_session_data *, return 0; } -int atcommand_skillpool_focus(const int fd, struct map_session_data *, +int atcommand_skillpool_focus(const int fd, dumb_ptr, const char *, const char *message) { char character[100]; int skill_; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_, character) < 1) @@ -6441,12 +6442,12 @@ int atcommand_skillpool_focus(const int fd, struct map_session_data *, return 0; } -int atcommand_skillpool_unfocus(const int fd, struct map_session_data *, +int atcommand_skillpool_unfocus(const int fd, dumb_ptr, const char *, const char *message) { char character[100]; int skill_; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_, character) < 1) @@ -6470,12 +6471,12 @@ int atcommand_skillpool_unfocus(const int fd, struct map_session_data *, return 0; } -int atcommand_skill_learn(const int fd, struct map_session_data *, +int atcommand_skill_learn(const int fd, dumb_ptr, const char *, const char *message) { char character[100]; int skill_, level; - struct map_session_data *pl_sd; + dumb_ptr pl_sd; if (!message || !*message || sscanf(message, "%d %d %99[^\n]", &skill_, &level, character) < 1) @@ -6498,7 +6499,7 @@ int atcommand_skill_learn(const int fd, struct map_session_data *, return 0; } -int atcommand_ipcheck(const int fd, struct map_session_data *, +int atcommand_ipcheck(const int fd, dumb_ptr, const char *, const char *message) { struct sockaddr_in sai; @@ -6514,8 +6515,8 @@ int atcommand_ipcheck(const int fd, struct map_session_data *, return -1; } - map_session_data *pl_sd; - if ((pl_sd = map_nick2sd(character)) == NULL) + dumb_ptr pl_sd = map_nick2sd(character); + if (pl_sd == NULL) { clif_displaymessage(fd, "Character not found."); return -1; @@ -6537,7 +6538,7 @@ int atcommand_ipcheck(const int fd, struct map_session_data *, { if (!session[i]) continue; - pl_sd = static_cast(session[i]->session_data.get()); + pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth) { if (getpeername(pl_sd->fd, (struct sockaddr *)&sai, &sa_len)) @@ -6559,14 +6560,14 @@ int atcommand_ipcheck(const int fd, struct map_session_data *, return 0; } -int atcommand_doomspot(const int fd, struct map_session_data *sd, +int atcommand_doomspot(const int fd, dumb_ptr sd, const char *, const char *) { for (int i = 0; i < fd_max; i++) { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth && i != fd && sd->bl_m == pl_sd->bl_m && sd->bl_x == pl_sd->bl_x && sd->bl_y == pl_sd->bl_y diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp index a226b76..7033972 100644 --- a/src/map/atcommand.hpp +++ b/src/map/atcommand.hpp @@ -3,12 +3,14 @@ #include "../common/const_array.hpp" -bool is_atcommand(const int fd, struct map_session_data *sd, +#include "map.hpp" + +bool is_atcommand(const int fd, dumb_ptr sd, const char *message, int gmlvl); int atcommand_config_read(const char *cfgName); -void log_atcommand(struct map_session_data *sd, const_string cmd); +void log_atcommand(dumb_ptr sd, const_string cmd); // only used by map.cpp extern char *gm_logfile_name; diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 34d4751..8e7b174 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -25,15 +25,15 @@ struct Battle_Config battle_config; *------------------------------------------ */ static -int battle_counttargeted(struct block_list *bl, struct block_list *src, +int battle_counttargeted(dumb_ptr bl, dumb_ptr src, ATK target_lv) { nullpo_ret(bl); if (bl->bl_type == BL::PC) - return pc_counttargeted((struct map_session_data *) bl, src, + return pc_counttargeted(bl->as_player(), src, target_lv); else if (bl->bl_type == BL::MOB) - return mob_counttargeted((struct mob_data *) bl, src, target_lv); + return mob_counttargeted(bl->as_mob(), src, target_lv); return 0; } @@ -42,11 +42,11 @@ int battle_counttargeted(struct block_list *bl, struct block_list *src, * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_class(struct block_list *bl) +int battle_get_class(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::MOB) - return ((struct mob_data *) bl)->mob_class; + return bl->as_mob()->mob_class; else if (bl->bl_type == BL::PC) return 0; else @@ -58,13 +58,13 @@ int battle_get_class(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -DIR battle_get_dir(struct block_list *bl) +DIR battle_get_dir(dumb_ptr bl) { nullpo_retr(DIR::S, bl); if (bl->bl_type == BL::MOB) - return ((struct mob_data *) bl)->dir; + return bl->as_mob()->dir; else if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->dir; + return bl->as_player()->dir; else return DIR::S; } @@ -74,13 +74,13 @@ DIR battle_get_dir(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_lv(struct block_list *bl) +int battle_get_lv(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::MOB) - return ((struct mob_data *) bl)->stats[mob_stat::LV]; + return bl->as_mob()->stats[mob_stat::LV]; else if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->status.base_level; + return bl->as_player()->status.base_level; else return 0; } @@ -90,13 +90,13 @@ int battle_get_lv(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_range(struct block_list *bl) +int battle_get_range(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::MOB) - return mob_db[((struct mob_data *) bl)->mob_class].range; + return mob_db[bl->as_mob()->mob_class].range; else if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->attackrange; + return bl->as_player()->attackrange; else return 0; } @@ -106,13 +106,13 @@ int battle_get_range(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_hp(struct block_list *bl) +int battle_get_hp(dumb_ptr bl) { nullpo_retr(1, bl); if (bl->bl_type == BL::MOB) - return ((struct mob_data *) bl)->hp; + return bl->as_mob()->hp; else if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->status.hp; + return bl->as_player()->status.hp; else return 1; } @@ -122,17 +122,17 @@ int battle_get_hp(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_max_hp(struct block_list *bl) +int battle_get_max_hp(dumb_ptr bl) { nullpo_retr(1, bl); - if (bl->bl_type == BL::PC && ((struct map_session_data *) bl)) - return ((struct map_session_data *) bl)->status.max_hp; + if (bl->bl_type == BL::PC) + return bl->as_player()->status.max_hp; else { int max_hp = 1; - if (bl->bl_type == BL::MOB && ((struct mob_data *) bl)) + if (bl->bl_type == BL::MOB) { - max_hp = ((struct mob_data *) bl)->stats[mob_stat::MAX_HP]; + max_hp = bl->as_mob()->stats[mob_stat::MAX_HP]; { if (battle_config.monster_hp_rate != 100) max_hp = (max_hp * battle_config.monster_hp_rate) / 100; @@ -149,17 +149,17 @@ int battle_get_max_hp(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_str(struct block_list *bl) +int battle_get_str(dumb_ptr bl) { int str = 0; eptr sc_data; nullpo_ret(bl); sc_data = battle_get_sc_data(bl); - if (bl->bl_type == BL::MOB && ((struct mob_data *) bl)) - str = ((struct mob_data *) bl)->stats[mob_stat::STR]; - else if (bl->bl_type == BL::PC && ((struct map_session_data *) bl)) - return ((struct map_session_data *) bl)->paramc[ATTR::STR]; + if (bl->bl_type == BL::MOB) + str = bl->as_mob()->stats[mob_stat::STR]; + else if (bl->bl_type == BL::PC) + return bl->as_player()->paramc[ATTR::STR]; if (str < 0) str = 0; @@ -172,7 +172,7 @@ int battle_get_str(struct block_list *bl) *------------------------------------------ */ -int battle_get_agi(struct block_list *bl) +int battle_get_agi(dumb_ptr bl) { int agi = 0; eptr sc_data; @@ -180,9 +180,9 @@ int battle_get_agi(struct block_list *bl) nullpo_ret(bl); sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::MOB) - agi = ((struct mob_data *) bl)->stats[mob_stat::AGI]; + agi = bl->as_mob()->stats[mob_stat::AGI]; else if (bl->bl_type == BL::PC) - agi = ((struct map_session_data *) bl)->paramc[ATTR::AGI]; + agi = bl->as_player()->paramc[ATTR::AGI]; if (agi < 0) agi = 0; @@ -194,7 +194,7 @@ int battle_get_agi(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_vit(struct block_list *bl) +int battle_get_vit(dumb_ptr bl) { int vit = 0; eptr sc_data; @@ -202,9 +202,9 @@ int battle_get_vit(struct block_list *bl) nullpo_ret(bl); sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::MOB) - vit = ((struct mob_data *) bl)->stats[mob_stat::VIT]; + vit = bl->as_mob()->stats[mob_stat::VIT]; else if (bl->bl_type == BL::PC) - vit = ((struct map_session_data *) bl)->paramc[ATTR::VIT]; + vit = bl->as_player()->paramc[ATTR::VIT]; if (vit < 0) vit = 0; @@ -216,7 +216,7 @@ int battle_get_vit(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_int(struct block_list *bl) +int battle_get_int(dumb_ptr bl) { int int_ = 0; eptr sc_data; @@ -224,9 +224,9 @@ int battle_get_int(struct block_list *bl) nullpo_ret(bl); sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::MOB) - int_ = ((struct mob_data *) bl)->stats[mob_stat::INT]; + int_ = bl->as_mob()->stats[mob_stat::INT]; else if (bl->bl_type == BL::PC) - int_ = ((struct map_session_data *) bl)->paramc[ATTR::INT]; + int_ = bl->as_player()->paramc[ATTR::INT]; if (int_ < 0) int_ = 0; @@ -238,7 +238,7 @@ int battle_get_int(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_dex(struct block_list *bl) +int battle_get_dex(dumb_ptr bl) { int dex = 0; eptr sc_data; @@ -246,9 +246,9 @@ int battle_get_dex(struct block_list *bl) nullpo_ret(bl); sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::MOB) - dex = ((struct mob_data *) bl)->stats[mob_stat::DEX]; + dex = bl->as_mob()->stats[mob_stat::DEX]; else if (bl->bl_type == BL::PC) - dex = ((struct map_session_data *) bl)->paramc[ATTR::DEX]; + dex = bl->as_player()->paramc[ATTR::DEX]; if (dex < 0) dex = 0; @@ -260,7 +260,7 @@ int battle_get_dex(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_luk(struct block_list *bl) +int battle_get_luk(dumb_ptr bl) { int luk = 0; eptr sc_data; @@ -268,9 +268,9 @@ int battle_get_luk(struct block_list *bl) nullpo_ret(bl); sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::MOB) - luk = ((struct mob_data *) bl)->stats[mob_stat::LUK]; + luk = bl->as_mob()->stats[mob_stat::LUK]; else if (bl->bl_type == BL::PC) - luk = ((struct map_session_data *) bl)->paramc[ATTR::LUK]; + luk = bl->as_player()->paramc[ATTR::LUK]; if (luk < 0) luk = 0; @@ -283,7 +283,7 @@ int battle_get_luk(struct block_list *bl) *------------------------------------------ */ static -int battle_get_flee(struct block_list *bl) +int battle_get_flee(dumb_ptr bl) { int flee = 1; eptr sc_data; @@ -291,7 +291,7 @@ int battle_get_flee(struct block_list *bl) nullpo_retr(1, bl); sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::PC) - flee = ((struct map_session_data *) bl)->flee; + flee = bl->as_player()->flee; else flee = battle_get_agi(bl) + battle_get_lv(bl); @@ -312,7 +312,7 @@ int battle_get_flee(struct block_list *bl) *------------------------------------------ */ static -int battle_get_hit(struct block_list *bl) +int battle_get_hit(dumb_ptr bl) { int hit = 1; eptr sc_data; @@ -320,7 +320,7 @@ int battle_get_hit(struct block_list *bl) nullpo_retr(1, bl); sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::PC) - hit = ((struct map_session_data *) bl)->hit; + hit = bl->as_player()->hit; else hit = battle_get_dex(bl) + battle_get_lv(bl); @@ -340,7 +340,7 @@ int battle_get_hit(struct block_list *bl) *------------------------------------------ */ static -int battle_get_flee2(struct block_list *bl) +int battle_get_flee2(dumb_ptr bl) { int flee2 = 1; eptr sc_data; @@ -349,10 +349,9 @@ int battle_get_flee2(struct block_list *bl) sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::PC) { + dumb_ptr sd = bl->as_player(); flee2 = battle_get_luk(bl) + 10; - flee2 += - ((struct map_session_data *) bl)->flee2 - - (((struct map_session_data *) bl)->paramc[ATTR::LUK] + 10); + flee2 += sd->flee2 - (sd->paramc[ATTR::LUK] + 10); } else flee2 = battle_get_luk(bl) + 1; @@ -373,7 +372,7 @@ int battle_get_flee2(struct block_list *bl) *------------------------------------------ */ static -int battle_get_critical(struct block_list *bl) +int battle_get_critical(dumb_ptr bl) { int critical = 1; eptr sc_data; @@ -382,10 +381,9 @@ int battle_get_critical(struct block_list *bl) sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::PC) { + dumb_ptr sd = bl->as_player(); critical = battle_get_luk(bl) * 2 + 10; - critical += - ((struct map_session_data *) bl)->critical - - ((((struct map_session_data *) bl)->paramc[ATTR::LUK] * 3) + 10); + critical += sd->critical - ((sd->paramc[ATTR::LUK] * 3) + 10); } else critical = battle_get_luk(bl) * 3 + 1; @@ -401,7 +399,7 @@ int battle_get_critical(struct block_list *bl) *------------------------------------------ */ static -int battle_get_baseatk(struct block_list *bl) +int battle_get_baseatk(dumb_ptr bl) { eptr sc_data; int batk = 1; @@ -409,7 +407,7 @@ int battle_get_baseatk(struct block_list *bl) nullpo_retr(1, bl); sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::PC) - batk = ((struct map_session_data *) bl)->base_atk; //設定されているbase_atk + batk = bl->as_player()->base_atk; //設定されているbase_atk else { //それ以外なら int str, dstr; @@ -428,7 +426,7 @@ int battle_get_baseatk(struct block_list *bl) *------------------------------------------ */ static -int battle_get_atk(struct block_list *bl) +int battle_get_atk(dumb_ptr bl) { eptr sc_data; int atk = 0; @@ -436,9 +434,9 @@ int battle_get_atk(struct block_list *bl) nullpo_ret(bl); sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::PC) - atk = ((struct map_session_data *) bl)->watk; + atk = bl->as_player()->watk; else if (bl->bl_type == BL::MOB) - atk = ((struct mob_data *) bl)->stats[mob_stat::ATK1]; + atk = bl->as_mob()->stats[mob_stat::ATK1]; if (atk < 0) atk = 0; @@ -451,11 +449,11 @@ int battle_get_atk(struct block_list *bl) *------------------------------------------ */ static -int battle_get_atk_(struct block_list *bl) +int battle_get_atk_(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->watk_; + return bl->as_player()->watk_; else return 0; } @@ -466,16 +464,16 @@ int battle_get_atk_(struct block_list *bl) *------------------------------------------ */ static -int battle_get_atk2(struct block_list *bl) +int battle_get_atk2(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->watk2; + return bl->as_player()->watk2; else { int atk2 = 0; if (bl->bl_type == BL::MOB) - atk2 = ((struct mob_data *) bl)->stats[mob_stat::ATK2]; + atk2 = bl->as_mob()->stats[mob_stat::ATK2]; if (atk2 < 0) atk2 = 0; @@ -489,11 +487,11 @@ int battle_get_atk2(struct block_list *bl) *------------------------------------------ */ static -int battle_get_atk_2(struct block_list *bl) +int battle_get_atk_2(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->watk_2; + return bl->as_player()->watk_2; else return 0; } @@ -504,7 +502,7 @@ int battle_get_atk_2(struct block_list *bl) *------------------------------------------ */ static -int battle_get_matk1(struct block_list *bl) +int battle_get_matk1(dumb_ptr bl) { eptr sc_data; nullpo_ret(bl); @@ -517,7 +515,7 @@ int battle_get_matk1(struct block_list *bl) return matk; } else if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->matk1; + return bl->as_player()->matk1; else return 0; } @@ -528,7 +526,7 @@ int battle_get_matk1(struct block_list *bl) *------------------------------------------ */ static -int battle_get_matk2(struct block_list *bl) +int battle_get_matk2(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::MOB) @@ -539,7 +537,7 @@ int battle_get_matk2(struct block_list *bl) return matk; } else if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->matk2; + return bl->as_player()->matk2; else return 0; } @@ -549,7 +547,7 @@ int battle_get_matk2(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_def(struct block_list *bl) +int battle_get_def(dumb_ptr bl) { eptr sc_data; int def = 0; @@ -558,11 +556,11 @@ int battle_get_def(struct block_list *bl) sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::PC) { - def = ((struct map_session_data *) bl)->def; + def = bl->as_player()->def; } else if (bl->bl_type == BL::MOB) { - def = ((struct mob_data *) bl)->stats[mob_stat::DEF]; + def = bl->as_mob()->stats[mob_stat::DEF]; } if (def < 1000000) @@ -585,7 +583,7 @@ int battle_get_def(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_mdef(struct block_list *bl) +int battle_get_mdef(dumb_ptr bl) { eptr sc_data; int mdef = 0; @@ -593,9 +591,9 @@ int battle_get_mdef(struct block_list *bl) nullpo_ret(bl); sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::PC) - mdef = ((struct map_session_data *) bl)->mdef; + mdef = bl->as_player()->mdef; else if (bl->bl_type == BL::MOB) - mdef = ((struct mob_data *) bl)->stats[mob_stat::MDEF]; + mdef = bl->as_mob()->stats[mob_stat::MDEF]; if (mdef < 1000000) { @@ -620,7 +618,7 @@ int battle_get_mdef(struct block_list *bl) * 戻りは整数で1以上 *------------------------------------------ */ -int battle_get_def2(struct block_list *bl) +int battle_get_def2(dumb_ptr bl) { eptr sc_data; int def2 = 1; @@ -628,9 +626,9 @@ int battle_get_def2(struct block_list *bl) nullpo_retr(1, bl); sc_data = battle_get_sc_data(bl); if (bl->bl_type == BL::PC) - def2 = ((struct map_session_data *) bl)->def2; + def2 = bl->as_player()->def2; else if (bl->bl_type == BL::MOB) - def2 = ((struct mob_data *) bl)->stats[mob_stat::VIT]; + def2 = bl->as_mob()->stats[mob_stat::VIT]; if (sc_data) { @@ -648,19 +646,21 @@ int battle_get_def2(struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ -int battle_get_mdef2(struct block_list *bl) +int battle_get_mdef2(dumb_ptr bl) { int mdef2 = 0; nullpo_ret(bl); if (bl->bl_type == BL::MOB) - mdef2 = - ((struct mob_data *) bl)->stats[mob_stat::INT] + - (((struct mob_data *) bl)->stats[mob_stat::VIT] >> 1); + { + dumb_ptr md = bl->as_mob(); + mdef2 = md->stats[mob_stat::INT] + (md->stats[mob_stat::VIT] >> 1); + } else if (bl->bl_type == BL::PC) - mdef2 = - ((struct map_session_data *) bl)->mdef2 + - (((struct map_session_data *) bl)->paramc[ATTR::VIT] >> 1); + { + dumb_ptr sd = bl->as_player(); + mdef2 = sd->mdef2 + (sd->paramc[ATTR::VIT] >> 1); + } if (mdef2 < 0) mdef2 = 0; @@ -673,16 +673,16 @@ int battle_get_mdef2(struct block_list *bl) * Speedは小さいほうが移動速度が速い *------------------------------------------ */ -interval_t battle_get_speed(struct block_list *bl) +interval_t battle_get_speed(dumb_ptr bl) { nullpo_retr(std::chrono::seconds(1), bl); if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->speed; + return bl->as_player()->speed; else { interval_t speed = std::chrono::seconds(1); if (bl->bl_type == BL::MOB) - speed = static_cast(((struct mob_data *) bl)->stats[mob_stat::SPEED]); + speed = static_cast(bl->as_mob()->stats[mob_stat::SPEED]); return std::max(speed, std::chrono::milliseconds(1)); } @@ -694,18 +694,18 @@ interval_t battle_get_speed(struct block_list *bl) *------------------------------------------ */ // TODO figure out what all the doubling is about -interval_t battle_get_adelay(struct block_list *bl) +interval_t battle_get_adelay(dumb_ptr bl) { nullpo_retr(std::chrono::seconds(4), bl); if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->aspd * 2; + return bl->as_player()->aspd * 2; else { eptr sc_data = battle_get_sc_data(bl); interval_t adelay = std::chrono::seconds(4); int aspd_rate = 100; if (bl->bl_type == BL::MOB) - adelay = static_cast(((struct mob_data *) bl)->stats[mob_stat::ADELAY]); + adelay = static_cast(bl->as_mob()->stats[mob_stat::ADELAY]); if (sc_data) { @@ -722,18 +722,18 @@ interval_t battle_get_adelay(struct block_list *bl) } } -interval_t battle_get_amotion(struct block_list *bl) +interval_t battle_get_amotion(dumb_ptr bl) { nullpo_retr(std::chrono::seconds(2), bl); if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->amotion; + return bl->as_player()->amotion; else { eptr sc_data = battle_get_sc_data(bl); interval_t amotion = std::chrono::seconds(2); int aspd_rate = 100; if (bl->bl_type == BL::MOB) - amotion = static_cast(mob_db[((struct mob_data *) bl)->mob_class].amotion); + amotion = static_cast(mob_db[bl->as_mob()->mob_class].amotion); if (sc_data) { @@ -749,40 +749,40 @@ interval_t battle_get_amotion(struct block_list *bl) } } -interval_t battle_get_dmotion(struct block_list *bl) +interval_t battle_get_dmotion(dumb_ptr bl) { nullpo_retr(interval_t::zero(), bl); if (bl->bl_type == BL::MOB) { - return static_cast(mob_db[((struct mob_data *) bl)->mob_class].dmotion); + return static_cast(mob_db[bl->as_mob()->mob_class].dmotion); } else if (bl->bl_type == BL::PC) { - return ((struct map_session_data *) bl)->dmotion; + return bl->as_player()->dmotion; } else return std::chrono::seconds(2); } -LevelElement battle_get_element(struct block_list *bl) +LevelElement battle_get_element(dumb_ptr bl) { LevelElement ret = {2, Element::neutral}; nullpo_retr(ret, bl); if (bl->bl_type == BL::MOB) // 10の位=Lv*2、1の位=属性 - ret = ((struct mob_data *) bl)->def_ele; + ret = bl->as_mob()->def_ele; return ret; } -int battle_get_party_id(struct block_list *bl) +int battle_get_party_id(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::PC) - return ((struct map_session_data *) bl)->status.party_id; + return bl->as_player()->status.party_id; else if (bl->bl_type == BL::MOB) { - struct mob_data *md = (struct mob_data *) bl; + dumb_ptr md = bl->as_mob(); if (md->master_id > 0) return -md->master_id; return -md->bl_id; @@ -790,27 +790,27 @@ int battle_get_party_id(struct block_list *bl) return 0; } -Race battle_get_race(struct block_list *bl) +Race battle_get_race(dumb_ptr bl) { nullpo_retr(Race::formless, bl); if (bl->bl_type == BL::MOB) - return mob_db[((struct mob_data *) bl)->mob_class].race; + return mob_db[bl->as_mob()->mob_class].race; else if (bl->bl_type == BL::PC) return Race::demihuman; else return Race::formless; } -MobMode battle_get_mode(struct block_list *bl) +MobMode battle_get_mode(dumb_ptr bl) { nullpo_retr(MobMode::CAN_MOVE, bl); if (bl->bl_type == BL::MOB) - return mob_db[((struct mob_data *) bl)->mob_class].mode; + return mob_db[bl->as_mob()->mob_class].mode; // とりあえず動くということで1 return MobMode::CAN_MOVE; } -int battle_get_stat(SP stat_id, struct block_list *bl) +int battle_get_stat(SP stat_id, dumb_ptr bl) { switch (stat_id) { @@ -832,75 +832,75 @@ int battle_get_stat(SP stat_id, struct block_list *bl) } // StatusChange系の所得 -eptr battle_get_sc_data(struct block_list *bl) +eptr battle_get_sc_data(dumb_ptr bl) { nullpo_retr(nullptr, bl); switch (bl->bl_type) { case BL::MOB: - return ((struct mob_data *)(bl))->sc_data; + return bl->as_mob()->sc_data; case BL::PC: - return ((struct map_session_data *)(bl))->sc_data; + return bl->as_player()->sc_data; } return nullptr; } -short *battle_get_sc_count(struct block_list *bl) +short *battle_get_sc_count(dumb_ptr bl) { nullpo_retr(NULL, bl); if (bl->bl_type == BL::MOB) - return &((struct mob_data *) bl)->sc_count; + return &bl->as_mob()->sc_count; else if (bl->bl_type == BL::PC) - return &((struct map_session_data *) bl)->sc_count; + return &bl->as_player()->sc_count; return NULL; } -Opt1 *battle_get_opt1(struct block_list *bl) +Opt1 *battle_get_opt1(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::MOB) - return &((struct mob_data *) bl)->opt1; + return &bl->as_mob()->opt1; else if (bl->bl_type == BL::PC) - return &((struct map_session_data *) bl)->opt1; - else if (bl->bl_type == BL::NPC && (struct npc_data *) bl) - return &((struct npc_data *) bl)->opt1; + return &bl->as_player()->opt1; + else if (bl->bl_type == BL::NPC) + return &bl->as_npc()->opt1; return 0; } -Opt2 *battle_get_opt2(struct block_list *bl) +Opt2 *battle_get_opt2(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::MOB) - return &((struct mob_data *) bl)->opt2; + return &bl->as_mob()->opt2; else if (bl->bl_type == BL::PC) - return &((struct map_session_data *) bl)->opt2; - else if (bl->bl_type == BL::NPC && (struct npc_data *) bl) - return &((struct npc_data *) bl)->opt2; + return &bl->as_player()->opt2; + else if (bl->bl_type == BL::NPC) + return &bl->as_npc()->opt2; return 0; } -Opt3 *battle_get_opt3(struct block_list *bl) +Opt3 *battle_get_opt3(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::MOB) - return &((struct mob_data *) bl)->opt3; + return &bl->as_mob()->opt3; else if (bl->bl_type == BL::PC) - return &((struct map_session_data *) bl)->opt3; - else if (bl->bl_type == BL::NPC && (struct npc_data *) bl) - return &((struct npc_data *) bl)->opt3; + return &bl->as_player()->opt3; + else if (bl->bl_type == BL::NPC) + return &bl->as_npc()->opt3; return 0; } -Option *battle_get_option(struct block_list *bl) +Option *battle_get_option(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::MOB) - return &((struct mob_data *) bl)->option; + return &bl->as_mob()->option; else if (bl->bl_type == BL::PC) - return &((struct map_session_data *) bl)->status.option; - else if (bl->bl_type == BL::NPC && (struct npc_data *) bl) - return &((struct npc_data *) bl)->option; + return &bl->as_player()->status.option; + else if (bl->bl_type == BL::NPC) + return &bl->as_npc()->option; return 0; } @@ -909,13 +909,13 @@ Option *battle_get_option(struct block_list *bl) // ダメージの遅延 struct battle_delay_damage_ { - struct block_list *src, *target; + dumb_ptr src, *target; int damage; int flag; }; // 実際にHPを操作 -int battle_damage(struct block_list *bl, struct block_list *target, +int battle_damage(dumb_ptr bl, dumb_ptr target, int damage, int flag) { nullpo_ret(target); //blはNULLで呼ばれることがあるので他でチェック @@ -937,7 +937,7 @@ int battle_damage(struct block_list *bl, struct block_list *target, if (target->bl_type == BL::MOB) { // MOB - struct mob_data *md = (struct mob_data *) target; + dumb_ptr md = target->as_mob(); if (md && md->skilltimer && md->state.skillcastcancel) // 詠唱妨害 skill_castcancel(target, 0); return mob_damage(bl, md, damage, 0); @@ -945,7 +945,7 @@ int battle_damage(struct block_list *bl, struct block_list *target, else if (target->bl_type == BL::PC) { // PC - struct map_session_data *tsd = (struct map_session_data *) target; + dumb_ptr tsd = target->as_player(); return pc_damage(bl, tsd, damage); @@ -953,13 +953,13 @@ int battle_damage(struct block_list *bl, struct block_list *target, return 0; } -int battle_heal(struct block_list *bl, struct block_list *target, int hp, +int battle_heal(dumb_ptr bl, dumb_ptr target, int hp, int sp, int flag) { nullpo_ret(target); //blはNULLで呼ばれることがあるので他でチェック if (target->bl_type == BL::PC - && pc_isdead((struct map_session_data *) target)) + && pc_isdead(target->as_player())) return 0; if (hp == 0 && sp == 0) return 0; @@ -968,31 +968,31 @@ int battle_heal(struct block_list *bl, struct block_list *target, int hp, return battle_damage(bl, target, -hp, flag); if (target->bl_type == BL::MOB) - return mob_heal((struct mob_data *) target, hp); + return mob_heal(target->as_mob(), hp); else if (target->bl_type == BL::PC) - return pc_heal((struct map_session_data *) target, hp, sp); + return pc_heal(target->as_player(), hp, sp); return 0; } // 攻撃停止 -int battle_stopattack(struct block_list *bl) +int battle_stopattack(dumb_ptr bl) { nullpo_ret(bl); if (bl->bl_type == BL::MOB) - return mob_stopattack((struct mob_data *) bl); + return mob_stopattack(bl->as_mob()); else if (bl->bl_type == BL::PC) - return pc_stopattack((struct map_session_data *) bl); + return pc_stopattack(bl->as_player()); return 0; } // 移動停止 -int battle_stopwalking(struct block_list *bl, int type) +int battle_stopwalking(dumb_ptr bl, int type) { nullpo_ret(bl); if (bl->bl_type == BL::MOB) - return mob_stop_walking((struct mob_data *) bl, type); + return mob_stop_walking(bl->as_mob(), type); else if (bl->bl_type == BL::PC) - return pc_stop_walking((struct map_session_data *) bl, type); + return pc_stop_walking(bl->as_player(), type); return 0; } @@ -1001,16 +1001,16 @@ int battle_stopwalking(struct block_list *bl, int type) *------------------------------------------ */ static -int battle_calc_damage(struct block_list *, struct block_list *bl, +int battle_calc_damage(dumb_ptr, dumb_ptr bl, int damage, int div_, SkillID, int, BF flag) { - struct mob_data *md = NULL; + dumb_ptr md = NULL; nullpo_ret(bl); if (bl->bl_type == BL::MOB) - md = (struct mob_data *) bl; + md = bl->as_mob(); if (battle_config.skill_min_damage || bool(flag & BF::MISC)) @@ -1031,13 +1031,13 @@ int battle_calc_damage(struct block_list *, struct block_list *bl, } static -struct Damage battle_calc_mob_weapon_attack(struct block_list *src, - struct block_list *target, +struct Damage battle_calc_mob_weapon_attack(dumb_ptr src, + dumb_ptr target, SkillID skill_num, int skill_lv, int) { - struct map_session_data *tsd = NULL; - struct mob_data *md = (struct mob_data *) src, *tmd = NULL; + dumb_ptr tsd = NULL; + dumb_ptr md = src->as_mob(), tmd = NULL; int hitrate, flee, cri = 0, atkmin, atkmax; int target_count = 1; int def1 = battle_get_def(target); @@ -1060,9 +1060,9 @@ struct Damage battle_calc_mob_weapon_attack(struct block_list *src, // ターゲット if (target->bl_type == BL::PC) - tsd = (struct map_session_data *) target; + tsd = target->as_player(); else if (target->bl_type == BL::MOB) - tmd = (struct mob_data *) target; + tmd = target->as_mob(); MobMode t_mode = battle_get_mode(target); t_sc_data = battle_get_sc_data(target); @@ -1284,13 +1284,13 @@ struct Damage battle_calc_mob_weapon_attack(struct block_list *src, return wd; } -int battle_is_unarmed(struct block_list *bl) +int battle_is_unarmed(dumb_ptr bl) { if (!bl) return 0; if (bl->bl_type == BL::PC) { - struct map_session_data *sd = (struct map_session_data *) bl; + dumb_ptr sd = bl->as_player(); return (sd->equip_index[EQUIP::SHIELD] == -1 && sd->equip_index[EQUIP::WEAPON] == -1); @@ -1305,14 +1305,13 @@ int battle_is_unarmed(struct block_list *bl) *------------------------------------------------------------------------- */ static -struct Damage battle_calc_pc_weapon_attack(struct block_list *src, - struct block_list *target, +struct Damage battle_calc_pc_weapon_attack(dumb_ptr src, + dumb_ptr target, SkillID skill_num, int skill_lv, int) { - struct map_session_data *sd = (struct map_session_data *) src, *tsd = - NULL; - struct mob_data *tmd = NULL; + dumb_ptr sd = src->as_player(), tsd = NULL; + dumb_ptr tmd = NULL; int hitrate, flee, cri = 0, atkmin, atkmax; int dex, target_count = 1; int def1 = battle_get_def(target); @@ -1342,9 +1341,9 @@ struct Damage battle_calc_pc_weapon_attack(struct block_list *src, // ターゲット if (target->bl_type == BL::PC) //対象がPCなら - tsd = (struct map_session_data *) target; //tsdに代入(tmdはNULL) + tsd = target->as_player(); //tsdに代入(tmdはNULL) else if (target->bl_type == BL::MOB) //対象がMobなら - tmd = (struct mob_data *) target; //tmdに代入(tsdはNULL) + tmd = target->as_mob(); //tmdに代入(tsdはNULL) MobMode t_mode = battle_get_mode(target); //対象のMode t_sc_data = battle_get_sc_data(target); //対象のステータス異常 @@ -1753,8 +1752,8 @@ struct Damage battle_calc_pc_weapon_attack(struct block_list *src, *------------------------------------------ */ static -struct Damage battle_calc_weapon_attack(struct block_list *src, - struct block_list *target, +struct Damage battle_calc_weapon_attack(dumb_ptr src, + dumb_ptr target, SkillID skill_num, int skill_lv, int wflag) { @@ -1776,8 +1775,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src, *------------------------------------------ */ static -struct Damage battle_calc_magic_attack(struct block_list *bl, - struct block_list *target, +struct Damage battle_calc_magic_attack(dumb_ptr bl, + dumb_ptr target, SkillID skill_num, int skill_lv, int) { int mdef1 = battle_get_mdef(target); @@ -1785,7 +1784,7 @@ struct Damage battle_calc_magic_attack(struct block_list *bl, int matk1, matk2, damage = 0, div_ = 1; struct Damage md {}; int normalmagic_flag = 1; - struct map_session_data *sd = NULL; + dumb_ptr sd = NULL; nullpo_retr(md, bl); nullpo_retr(md, target); @@ -1794,8 +1793,9 @@ struct Damage battle_calc_magic_attack(struct block_list *bl, matk2 = battle_get_matk2(bl); MobMode t_mode = battle_get_mode(target); - if (bl->bl_type == BL::PC && (sd = (struct map_session_data *) bl)) + if (bl->bl_type == BL::PC) { + sd = bl->as_player(); sd->state.attack_type = BF::MAGIC; if (sd->matk_rate != 100) { @@ -1856,11 +1856,11 @@ struct Damage battle_calc_magic_attack(struct block_list *bl, *------------------------------------------ */ static -struct Damage battle_calc_misc_attack(struct block_list *bl, - struct block_list *target, +struct Damage battle_calc_misc_attack(dumb_ptr bl, + dumb_ptr target, SkillID skill_num, int skill_lv, int) { - struct map_session_data *sd = NULL; + dumb_ptr sd = NULL; int damage = 0, div_ = 1; struct Damage md {}; int damagefix = 1; @@ -1870,8 +1870,9 @@ struct Damage battle_calc_misc_attack(struct block_list *bl, nullpo_retr(md, bl); nullpo_retr(md, target); - if (bl->bl_type == BL::PC && (sd = (struct map_session_data *) bl)) + if (bl->bl_type == BL::PC) { + sd = bl->as_player(); sd->state.attack_type = BF::MISC; sd->state.arrow_atk = 0; } @@ -1920,8 +1921,8 @@ struct Damage battle_calc_misc_attack(struct block_list *bl, *------------------------------------------ */ struct Damage battle_calc_attack(BF attack_type, - struct block_list *bl, - struct block_list *target, SkillID skill_num, + dumb_ptr bl, + dumb_ptr target, SkillID skill_num, int skill_lv, int flag) { struct Damage d; @@ -1951,10 +1952,10 @@ struct Damage battle_calc_attack(BF attack_type, * 通常攻撃処理まとめ *------------------------------------------ */ -ATK battle_weapon_attack(struct block_list *src, struct block_list *target, +ATK battle_weapon_attack(dumb_ptr src, dumb_ptr target, tick_t tick) { - struct map_session_data *sd = NULL; + dumb_ptr sd = NULL; eptr t_sc_data = battle_get_sc_data(target); struct Damage wd; @@ -1962,14 +1963,14 @@ ATK battle_weapon_attack(struct block_list *src, struct block_list *target, nullpo_retr(ATK::ZERO, target); if (src->bl_type == BL::PC) - sd = (struct map_session_data *) src; + sd = src->as_player(); if (src->bl_prev == NULL || target->bl_prev == NULL) return ATK::ZERO; if (src->bl_type == BL::PC && pc_isdead(sd)) return ATK::ZERO; if (target->bl_type == BL::PC - && pc_isdead((struct map_session_data *) target)) + && pc_isdead(target->as_player())) return ATK::ZERO; Opt1 *opt1 = battle_get_opt1(src); @@ -2013,7 +2014,7 @@ ATK battle_weapon_attack(struct block_list *src, struct block_list *target, reduction = wd.damage; wd.damage -= reduction; - MAP_LOG_PC(((struct map_session_data *) target), + MAP_LOG_PC(target->as_player(), "MAGIC-ABSORB-DMG %d", reduction); } @@ -2041,21 +2042,21 @@ ATK battle_weapon_attack(struct block_list *src, struct block_list *target, MAP_LOG("PC%d %d:%d,%d WPNDMG %s%d %d FOR %d WPN %d", sd->status.char_id, src->bl_m, src->bl_x, src->bl_y, (target->bl_type == BL::PC) ? "PC" : "MOB", - (target->bl_type == - BL::PC) ? ((struct map_session_data *) target)-> - status.char_id : target->bl_id, + (target->bl_type == BL::PC) + ? target->as_player()-> status.char_id + : target->bl_id, battle_get_class(target), wd.damage + wd.damage2, weapon); } if (target->bl_type == BL::PC) { - struct map_session_data *sd2 = (struct map_session_data *) target; + dumb_ptr sd2 = target->as_player(); MAP_LOG("PC%d %d:%d,%d WPNINJURY %s%d %d FOR %d", sd2->status.char_id, target->bl_m, target->bl_x, target->bl_y, (src->bl_type == BL::PC) ? "PC" : "MOB", (src->bl_type == BL::PC) - ? ((struct map_session_data *) src)->status.char_id + ? src->as_player()->status.char_id : src->bl_id, battle_get_class(src), wd.damage + wd.damage2); @@ -2065,7 +2066,7 @@ ATK battle_weapon_attack(struct block_list *src, struct block_list *target, if (target->bl_prev != NULL && (target->bl_type != BL::PC || (target->bl_type == BL::PC - && !pc_isdead((struct map_session_data *) target)))) + && !pc_isdead(target->as_player())))) { if (wd.damage > 0 || wd.damage2 > 0) { @@ -2132,11 +2133,11 @@ bool battle_check_undead(Race race, Element element) * = 0x50000:パーティーじゃないか判定(ret:1=パーティでない) *------------------------------------------ */ -int battle_check_target(struct block_list *src, struct block_list *target, +int battle_check_target(dumb_ptr src, dumb_ptr target, BCT flag) { int s_p, t_p; - struct block_list *ss = src; + dumb_ptr ss = src; nullpo_ret(src); nullpo_ret(target); @@ -2158,13 +2159,13 @@ int battle_check_target(struct block_list *src, struct block_list *target, } if (target->bl_type == BL::PC - && ((struct map_session_data *) target)->invincible_timer) + && target->as_player()->invincible_timer) return -1; // Mobでmaster_idがあってspecial_mob_aiなら、召喚主を求める if (src->bl_type == BL::MOB) { - struct mob_data *md = (struct mob_data *) src; + dumb_ptr md = src->as_mob(); if (md && md->master_id > 0) { if (md->master_id == target->bl_id) // 主なら肯定 @@ -2173,7 +2174,7 @@ int battle_check_target(struct block_list *src, struct block_list *target, { if (target->bl_type == BL::MOB) { //special_mob_aiで対象がMob - struct mob_data *tmd = (struct mob_data *) target; + dumb_ptr tmd = target->as_mob(); if (tmd) { if (tmd->master_id != md->master_id) //召喚主が一緒でなければ否定 @@ -2197,11 +2198,11 @@ int battle_check_target(struct block_list *src, struct block_list *target, return 1; if (target->bl_type == BL::PC - && pc_isinvisible((struct map_session_data *) target)) + && pc_isinvisible(target->as_player())) return -1; if (src->bl_prev == NULL || // 死んでるならエラー - (src->bl_type == BL::PC && pc_isdead((struct map_session_data *) src))) + (src->bl_type == BL::PC && pc_isdead(src->as_player()))) return -1; if ((ss->bl_type == BL::PC && target->bl_type == BL::MOB) || @@ -2226,8 +2227,7 @@ int battle_check_target(struct block_list *src, struct block_list *target, if (ss->bl_type == BL::PC && target->bl_type == BL::PC) { // 両方PVPモードなら否定(敵) if (map[ss->bl_m].flag.pvp - || pc_iskiller((struct map_session_data *) ss, - (struct map_session_data *) target)) + || pc_iskiller(ss->as_player(), target->as_player())) { // [MouseJstr] if (battle_config.pk_mode) return 1; // prevent novice engagement in pk_mode [Valaris] @@ -2245,7 +2245,7 @@ int battle_check_target(struct block_list *src, struct block_list *target, * 射程判定 *------------------------------------------ */ -int battle_check_range(struct block_list *src, struct block_list *bl, +int battle_check_range(dumb_ptr src, dumb_ptr bl, int range) { diff --git a/src/map/battle.hpp b/src/map/battle.hpp index 6d9d8dd..8b7c1bd 100644 --- a/src/map/battle.hpp +++ b/src/map/battle.hpp @@ -27,66 +27,66 @@ struct block_list; // ダメージ計算 struct Damage battle_calc_attack(BF attack_type, - struct block_list *bl, struct block_list *target, + dumb_ptr bl, dumb_ptr target, SkillID skill_num, int skill_lv, int flag); // 実際にHPを増減 -int battle_damage(struct block_list *bl, struct block_list *target, +int battle_damage(dumb_ptr bl, dumb_ptr target, int damage, int flag); -int battle_heal(struct block_list *bl, struct block_list *target, int hp, +int battle_heal(dumb_ptr bl, dumb_ptr target, int hp, int sp, int flag); // 攻撃や移動を止める -int battle_stopattack(struct block_list *bl); -int battle_stopwalking(struct block_list *bl, int type); +int battle_stopattack(dumb_ptr bl); +int battle_stopwalking(dumb_ptr bl, int type); // 通常攻撃処理まとめ -ATK battle_weapon_attack(struct block_list *bl, struct block_list *target, +ATK battle_weapon_attack(dumb_ptr bl, dumb_ptr target, tick_t tick); -int battle_is_unarmed(struct block_list *bl); -int battle_get_class(struct block_list *bl); -DIR battle_get_dir(struct block_list *bl); -int battle_get_lv(struct block_list *bl); -int battle_get_range(struct block_list *bl); -int battle_get_hp(struct block_list *bl); -int battle_get_max_hp(struct block_list *bl); -int battle_get_str(struct block_list *bl); -int battle_get_agi(struct block_list *bl); -int battle_get_vit(struct block_list *bl); -int battle_get_int(struct block_list *bl); -int battle_get_dex(struct block_list *bl); -int battle_get_luk(struct block_list *bl); -int battle_get_def(struct block_list *bl); -int battle_get_mdef(struct block_list *bl); -int battle_get_def2(struct block_list *bl); -int battle_get_mdef2(struct block_list *bl); -interval_t battle_get_speed(struct block_list *bl); -interval_t battle_get_adelay(struct block_list *bl); -interval_t battle_get_amotion(struct block_list *bl); -interval_t battle_get_dmotion(struct block_list *bl); -LevelElement battle_get_element(struct block_list *bl); +int battle_is_unarmed(dumb_ptr bl); +int battle_get_class(dumb_ptr bl); +DIR battle_get_dir(dumb_ptr bl); +int battle_get_lv(dumb_ptr bl); +int battle_get_range(dumb_ptr bl); +int battle_get_hp(dumb_ptr bl); +int battle_get_max_hp(dumb_ptr bl); +int battle_get_str(dumb_ptr bl); +int battle_get_agi(dumb_ptr bl); +int battle_get_vit(dumb_ptr bl); +int battle_get_int(dumb_ptr bl); +int battle_get_dex(dumb_ptr bl); +int battle_get_luk(dumb_ptr bl); +int battle_get_def(dumb_ptr bl); +int battle_get_mdef(dumb_ptr bl); +int battle_get_def2(dumb_ptr bl); +int battle_get_mdef2(dumb_ptr bl); +interval_t battle_get_speed(dumb_ptr bl); +interval_t battle_get_adelay(dumb_ptr bl); +interval_t battle_get_amotion(dumb_ptr bl); +interval_t battle_get_dmotion(dumb_ptr bl); +LevelElement battle_get_element(dumb_ptr bl); inline -Element battle_get_elem_type(struct block_list *bl) +Element battle_get_elem_type(dumb_ptr bl) { return battle_get_element(bl).element; } -int battle_get_party_id(struct block_list *bl); -Race battle_get_race(struct block_list *bl); -MobMode battle_get_mode(struct block_list *bl); -int battle_get_stat(SP stat_id, struct block_list *bl); +int battle_get_party_id(dumb_ptr bl); +Race battle_get_race(dumb_ptr bl); +MobMode battle_get_mode(dumb_ptr bl); +int battle_get_stat(SP stat_id, dumb_ptr bl); -eptr battle_get_sc_data(struct block_list *bl); -short *battle_get_sc_count(struct block_list *bl); -Opt1 *battle_get_opt1(struct block_list *bl); -Opt2 *battle_get_opt2(struct block_list *bl); -Opt3 *battle_get_opt3(struct block_list *bl); -Option *battle_get_option(struct block_list *bl); +eptr battle_get_sc_data(dumb_ptr bl); +short *battle_get_sc_count(dumb_ptr bl); +Opt1 *battle_get_opt1(dumb_ptr bl); +Opt2 *battle_get_opt2(dumb_ptr bl); +Opt3 *battle_get_opt3(dumb_ptr bl); +Option *battle_get_option(dumb_ptr bl); bool battle_check_undead(Race race, Element element); -int battle_check_target(struct block_list *src, struct block_list *target, +int battle_check_target(dumb_ptr src, dumb_ptr target, BCT flag); -int battle_check_range(struct block_list *src, struct block_list *bl, +int battle_check_range(dumb_ptr src, dumb_ptr bl, int range); extern struct Battle_Config diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index 51736e4..aaa727e 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -97,7 +97,7 @@ int chrif_isconnect(void) * *------------------------------------------ */ -int chrif_save(struct map_session_data *sd) +int chrif_save(dumb_ptr sd) { nullpo_retr(-1, sd); @@ -190,7 +190,7 @@ int chrif_recvmap(int fd) * マップ鯖間移動のためのデータ準備要求 *------------------------------------------ */ -int chrif_changemapserver(struct map_session_data *sd, char *name, int x, +int chrif_changemapserver(dumb_ptr sd, char *name, int x, int y, struct in_addr ip, short port) { int i, s_ip; @@ -199,7 +199,7 @@ int chrif_changemapserver(struct map_session_data *sd, char *name, int x, s_ip = 0; for (i = 0; i < fd_max; i++) - if (session[i] && session[i]->session_data.get() == sd) + if (session[i] && dumb_ptr(static_cast(session[i]->session_data.get())) == sd) { s_ip = session[i]->client_addr.sin_addr.s_addr; break; @@ -229,7 +229,7 @@ int chrif_changemapserver(struct map_session_data *sd, char *name, int x, static int chrif_changemapserverack(int fd) { - struct map_session_data *sd = map_id2sd(RFIFOL(fd, 2)); + dumb_ptr sd = map_id2sd(RFIFOL(fd, 2)); if (sd == NULL || sd->status.char_id != RFIFOL(fd, 14)) return -1; @@ -300,7 +300,7 @@ int chrif_sendmapack(int fd) * *------------------------------------------ */ -int chrif_authreq(struct map_session_data *sd) +int chrif_authreq(dumb_ptr sd) { int i; @@ -310,7 +310,7 @@ int chrif_authreq(struct map_session_data *sd) return -1; for (i = 0; i < fd_max; i++) - if (session[i] && session[i]->session_data.get() == sd) + if (session[i] && dumb_ptr(static_cast(session[i]->session_data.get())) == sd) { WFIFOW(char_fd, 0) = 0x2afc; WFIFOL(char_fd, 2) = sd->bl_id; @@ -329,7 +329,7 @@ int chrif_authreq(struct map_session_data *sd) * *------------------------------------------ */ -int chrif_charselectreq(struct map_session_data *sd) +int chrif_charselectreq(dumb_ptr sd) { int i, s_ip; @@ -340,7 +340,7 @@ int chrif_charselectreq(struct map_session_data *sd) s_ip = 0; for (i = 0; i < fd_max; i++) - if (session[i] && session[i]->session_data.get() == sd) + if (session[i] && dumb_ptr(static_cast(session[i]->session_data.get())) == sd) { s_ip = session[i]->client_addr.sin_addr.s_addr; break; @@ -464,7 +464,7 @@ static int chrif_char_ask_name_answer(int fd) { int acc; - struct map_session_data *sd; + dumb_ptr sd; char player_name[24]; acc = RFIFOL(fd, 2); // account_id of who has asked (-1 if nobody) @@ -606,7 +606,7 @@ static int chrif_changedgm(int fd) { int acc, level; - struct map_session_data *sd = NULL; + dumb_ptr sd = NULL; acc = RFIFOL(fd, 2); level = RFIFOL(fd, 6); @@ -635,7 +635,7 @@ static int chrif_changedsex(int fd) { int acc, sex, i; - struct map_session_data *sd; + dumb_ptr sd; acc = RFIFOL(fd, 2); sex = RFIFOL(fd, 6); @@ -678,7 +678,7 @@ int chrif_changedsex(int fd) * アカウント変数保存要求 *------------------------------------------ */ -int chrif_saveaccountreg2(struct map_session_data *sd) +int chrif_saveaccountreg2(dumb_ptr sd) { int p, j; nullpo_retr(-1, sd); @@ -710,7 +710,7 @@ static int chrif_accountreg2(int fd) { int j, p; - struct map_session_data *sd; + dumb_ptr sd; if ((sd = map_id2sd(RFIFOL(fd, 4))) == NULL) return 1; @@ -736,7 +736,7 @@ int chrif_accountreg2(int fd) static int chrif_divorce(int char_id, int partner_id) { - struct map_session_data *sd = NULL; + dumb_ptr sd = NULL; if (!char_id || !partner_id) return 0; @@ -785,7 +785,7 @@ static int chrif_accountdeletion(int fd) { int acc; - struct map_session_data *sd; + dumb_ptr sd; acc = RFIFOL(fd, 2); if (battle_config.etc_log) @@ -818,7 +818,7 @@ static int chrif_accountban(int fd) { int acc; - struct map_session_data *sd; + dumb_ptr sd; acc = RFIFOL(fd, 2); if (battle_config.etc_log) @@ -941,7 +941,7 @@ void ladmin_itemfrob_fix_item(int source, int dest, struct item *item) } static -void ladmin_itemfrob_c2(struct block_list *bl, int source_id, int dest_id) +void ladmin_itemfrob_c2(dumb_ptr bl, int source_id, int dest_id) { #define IFIX(v) if (v == source_id) {v = dest_id; } #define FIX(item) ladmin_itemfrob_fix_item(source_id, dest_id, &item) @@ -953,7 +953,7 @@ void ladmin_itemfrob_c2(struct block_list *bl, int source_id, int dest_id) { case BL::PC: { - struct map_session_data *pc = (struct map_session_data *) bl; + dumb_ptr pc = bl->as_player(); struct storage *stor = account2storage2(pc->status.account_id); int j; @@ -988,7 +988,7 @@ void ladmin_itemfrob_c2(struct block_list *bl, int source_id, int dest_id) case BL::MOB: { - struct mob_data *mob = (struct mob_data *) bl; + dumb_ptr mob = bl->as_mob(); int i; for (i = 0; i < mob->lootitem_count; i++) FIX(mob->lootitem[i]); @@ -997,7 +997,7 @@ void ladmin_itemfrob_c2(struct block_list *bl, int source_id, int dest_id) case BL::ITEM: { - struct flooritem_data *item = (struct flooritem_data *) bl; + dumb_ptr item = bl->as_item(); FIX(item->item_data); break; } @@ -1007,7 +1007,7 @@ void ladmin_itemfrob_c2(struct block_list *bl, int source_id, int dest_id) } static -void ladmin_itemfrob_c(struct block_list *bl, int source_id, int dest_id) +void ladmin_itemfrob_c(dumb_ptr bl, int source_id, int dest_id) { ladmin_itemfrob_c2(bl, source_id, dest_id); } @@ -1017,7 +1017,7 @@ void ladmin_itemfrob(int fd) { int source_id = RFIFOL(fd, 2); int dest_id = RFIFOL(fd, 6); - struct block_list *bl = (struct block_list *) map_get_first_session(); + dumb_ptr bl = (dumb_ptr) map_get_first_session(); // flooritems map_foreachobject(std::bind(ladmin_itemfrob_c, ph::_1, source_id, dest_id), BL::NUL /* any object */); @@ -1171,7 +1171,7 @@ void send_users_tochar(TimerData *, tick_t) { if (!session[i]) continue; - map_session_data *sd = static_cast(session[i]->session_data.get()); + dumb_ptr sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (sd && sd->state.auth && !((battle_config.hide_GM_session || sd->state.shroud_active diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp index 2816e9f..6dca70c 100644 --- a/src/map/chrif.hpp +++ b/src/map/chrif.hpp @@ -1,6 +1,10 @@ #ifndef CHRIF_HPP #define CHRIF_HPP +#include "../common/dumb_ptr.hpp" + +#include "map.hpp" + void chrif_setuserid(const char *); void chrif_setpasswd(const char *); char *chrif_getpasswd(void); @@ -10,11 +14,11 @@ void chrif_setport(int); int chrif_isconnect(void); -int chrif_authreq(struct map_session_data *); -int chrif_save(struct map_session_data *); -int chrif_charselectreq(struct map_session_data *); +int chrif_authreq(dumb_ptr); +int chrif_save(dumb_ptr); +int chrif_charselectreq(dumb_ptr); -int chrif_changemapserver(struct map_session_data *sd, +int chrif_changemapserver(dumb_ptr sd, char *name, int x, int y, struct in_addr ip, short port); @@ -24,7 +28,7 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email); int chrif_char_ask_name(int id, char *character_name, short operation_type, int year, int month, int day, int hour, int minute, int second); -int chrif_saveaccountreg2(struct map_session_data *sd); +int chrif_saveaccountreg2(dumb_ptr sd); int chrif_reloadGMdb(void); int chrif_send_divorce(int char_id); diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 8419c7d..fbba044 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -40,7 +40,7 @@ constexpr int EMOTE_IGNORED = 0x0e; // map.h must be the same length as this table. rate 0 is default // rate -1 is unlimited -typedef void (*clif_func)(int fd, struct map_session_data *sd); +typedef void (*clif_func)(int fd, dumb_ptr sd); struct func_table { interval_t rate; @@ -114,8 +114,8 @@ static int map_port = 5121; static -int clif_changelook_towards(struct block_list *bl, LOOK type, int val, - struct map_session_data *dstsd); +int clif_changelook_towards(dumb_ptr bl, LOOK type, int val, + dumb_ptr dstsd); /*========================================== * map鯖のip設定 @@ -166,7 +166,7 @@ int clif_countusers(void) { if (!session[i]) continue; - map_session_data *sd = static_cast(session[i]->session_data.get()); + dumb_ptr sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (sd && sd->state.auth && !(battle_config.hide_GM_session && pc_isGM(sd))) users++; } @@ -177,13 +177,13 @@ int clif_countusers(void) * 全てのclientに対してfunc()実行 *------------------------------------------ */ -int clif_foreachclient(std::function func) +int clif_foreachclient(std::function)> func) { for (int i = 0; i < fd_max; i++) { if (!session[i]) continue; - map_session_data *sd = static_cast(session[i]->session_data.get()); + dumb_ptr sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (sd && sd->state.auth) func(sd); } @@ -191,20 +191,20 @@ int clif_foreachclient(std::function func) } static -int is_deaf(struct block_list *bl) +int is_deaf(dumb_ptr bl) { - struct map_session_data *sd = (struct map_session_data *) bl; if (!bl || bl->bl_type != BL::PC) return 0; + dumb_ptr sd = bl->as_player(); return sd->special_state.deaf; } static -void clif_emotion_towards(struct block_list *bl, - struct block_list *target, int type); +void clif_emotion_towards(dumb_ptr bl, + dumb_ptr target, int type); static -char *clif_validate_chat(struct map_session_data *sd, int type, +char *clif_validate_chat(dumb_ptr sd, int type, const char **message, size_t *message_len); /*========================================== @@ -212,11 +212,11 @@ char *clif_validate_chat(struct map_session_data *sd, int type, *------------------------------------------ */ static -void clif_send_sub(struct block_list *bl, const unsigned char *buf, int len, - struct block_list *src_bl, SendWho type) +void clif_send_sub(dumb_ptr bl, const unsigned char *buf, int len, + dumb_ptr src_bl, SendWho type) { nullpo_retv(bl); - struct map_session_data *sd = (struct map_session_data *) bl; + dumb_ptr sd = bl->as_player(); switch (type) { @@ -228,7 +228,7 @@ void clif_send_sub(struct block_list *bl, const unsigned char *buf, int len, case SendWho::AREA_CHAT_WOC: if (is_deaf(bl) && !(bl->bl_type == BL::PC - && pc_isGM((struct map_session_data *) src_bl))) + && pc_isGM(src_bl->as_player()))) { clif_emotion_towards(src_bl, bl, EMOTE_IGNORED); return; @@ -266,7 +266,7 @@ void clif_send_sub(struct block_list *bl, const unsigned char *buf, int len, *------------------------------------------ */ static -int clif_send(const uint8_t *buf, int len, struct block_list *bl, SendWho type) +int clif_send(const uint8_t *buf, int len, dumb_ptr bl, SendWho type) { struct party *p = NULL; int x0 = 0, x1 = 0, y0 = 0, y1 = 0; @@ -277,7 +277,7 @@ int clif_send(const uint8_t *buf, int len, struct block_list *bl, SendWho type) if (bl->bl_type == BL::PC) { - struct map_session_data *sd2 = (struct map_session_data *) bl; + dumb_ptr sd2 = bl->as_player(); if (bool(sd2->status.option & Option::INVISIBILITY)) { // Obscure hidden GMs @@ -305,7 +305,7 @@ int clif_send(const uint8_t *buf, int len, struct block_list *bl, SendWho type) { if (!session[i]) continue; - map_session_data *sd = static_cast(session[i]->session_data.get()); + dumb_ptr sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (sd && sd->state.auth) { if (clif_parse_func_table[RBUFW(buf, 0)].len) @@ -322,7 +322,7 @@ int clif_send(const uint8_t *buf, int len, struct block_list *bl, SendWho type) { if (!session[i]) continue; - map_session_data *sd = static_cast(session[i]->session_data.get()); + dumb_ptr sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (sd && sd->state.auth && sd->bl_m == bl->bl_m) { if (clif_parse_func_table[RBUFW(buf, 0)].len) @@ -359,7 +359,7 @@ int clif_send(const uint8_t *buf, int len, struct block_list *bl, SendWho type) case SendWho::PARTY_SAMEMAP_WOS: // 自分以外の同じマップの全パーティーメンバに送信 if (bl->bl_type == BL::PC) { - struct map_session_data *sd = (struct map_session_data *) bl; + dumb_ptr sd = bl->as_player(); if (sd->partyspy > 0) { p = party_search(sd->partyspy); @@ -374,7 +374,7 @@ int clif_send(const uint8_t *buf, int len, struct block_list *bl, SendWho type) { for (int i = 0; i < MAX_PARTY; i++) { - struct map_session_data *sd = p->member[i].sd; + dumb_ptr sd = dumb_ptr(p->member[i].sd); if (sd) { if (sd->bl_id == bl->bl_id && (type == SendWho::PARTY_WOS || @@ -399,7 +399,7 @@ int clif_send(const uint8_t *buf, int len, struct block_list *bl, SendWho type) { if (!session[i]) continue; - map_session_data *sd = static_cast(session[i]->session_data.get()); + dumb_ptr sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (sd && sd->state.auth) { if (sd->partyspy == p->party_id) @@ -417,7 +417,7 @@ int clif_send(const uint8_t *buf, int len, struct block_list *bl, SendWho type) break; case SendWho::SELF: { - map_session_data *sd = (struct map_session_data *) bl; + dumb_ptr sd = bl->as_player(); if (clif_parse_func_table[RBUFW(buf, 0)].len) { // packet must exist @@ -443,7 +443,7 @@ int clif_send(const uint8_t *buf, int len, struct block_list *bl, SendWho type) * *------------------------------------------ */ -int clif_authok(struct map_session_data *sd) +int clif_authok(dumb_ptr sd) { int fd; @@ -491,7 +491,7 @@ int clif_authfail_fd(int fd, int type) */ int clif_charselectok(int id) { - struct map_session_data *sd; + dumb_ptr sd; int fd; if ((sd = map_id2sd(id)) == NULL) @@ -513,7 +513,7 @@ int clif_charselectok(int id) *------------------------------------------ */ static -int clif_set009e(struct flooritem_data *fitem, uint8_t *buf) +int clif_set009e(dumb_ptr fitem, uint8_t *buf) { int view; @@ -540,7 +540,7 @@ int clif_set009e(struct flooritem_data *fitem, uint8_t *buf) * *------------------------------------------ */ -int clif_dropflooritem(struct flooritem_data *fitem) +int clif_dropflooritem(dumb_ptr fitem) { uint8_t buf[64]; @@ -558,7 +558,7 @@ int clif_dropflooritem(struct flooritem_data *fitem) * *------------------------------------------ */ -int clif_clearflooritem(struct flooritem_data *fitem, int fd) +int clif_clearflooritem(dumb_ptr fitem, int fd) { unsigned char buf[16]; @@ -584,7 +584,7 @@ int clif_clearflooritem(struct flooritem_data *fitem, int fd) * *------------------------------------------ */ -int clif_clearchar(struct block_list *bl, BeingRemoveWhy type) +int clif_clearchar(dumb_ptr bl, BeingRemoveWhy type) { unsigned char buf[16]; @@ -609,19 +609,27 @@ int clif_clearchar(struct block_list *bl, BeingRemoveWhy type) static void clif_clearchar_delay_sub(TimerData *, tick_t, - struct block_list *bl, BeingRemoveWhy type) + dumb_ptr bl, BeingRemoveWhy type) { clif_clearchar(bl, type); MapBlockLock::freeblock(bl); } int clif_clearchar_delay(tick_t tick, - struct block_list *bl, BeingRemoveWhy type) + dumb_ptr bl, BeingRemoveWhy type) { - struct block_list *tmpbl; - CREATE(tmpbl, struct block_list, 1); + dumb_ptr tmpbl; + tmpbl.new_(); + + // yikes! + tmpbl->bl_next = bl->bl_next; + tmpbl->bl_prev = bl->bl_prev; + tmpbl->bl_id = bl->bl_id; + tmpbl->bl_m = bl->bl_m; + tmpbl->bl_x = bl->bl_x; + tmpbl->bl_y = bl->bl_y; + tmpbl->bl_type = bl->bl_type; - memcpy(tmpbl, bl, sizeof(struct block_list)); Timer(tick, std::bind(clif_clearchar_delay_sub, ph::_1, ph::_2, tmpbl, type) @@ -652,7 +660,7 @@ int clif_clearchar_id(int id, BeingRemoveWhy type, int fd) *------------------------------------------ */ static -int clif_set0078(struct map_session_data *sd, unsigned char *buf) +int clif_set0078(dumb_ptr sd, unsigned char *buf) { nullpo_ret(sd); @@ -720,7 +728,7 @@ int clif_set0078(struct map_session_data *sd, unsigned char *buf) *------------------------------------------ */ static -int clif_set007b(struct map_session_data *sd, unsigned char *buf) +int clif_set007b(dumb_ptr sd, unsigned char *buf) { nullpo_ret(sd); @@ -779,7 +787,7 @@ int clif_set007b(struct map_session_data *sd, unsigned char *buf) *------------------------------------------ */ static -int clif_mob0078(struct mob_data *md, unsigned char *buf) +int clif_mob0078(dumb_ptr md, unsigned char *buf) { int level; @@ -814,7 +822,7 @@ int clif_mob0078(struct mob_data *md, unsigned char *buf) *------------------------------------------ */ static -int clif_mob007b(struct mob_data *md, unsigned char *buf) +int clif_mob007b(dumb_ptr md, unsigned char *buf) { int level; @@ -848,7 +856,7 @@ int clif_mob007b(struct mob_data *md, unsigned char *buf) *------------------------------------------ */ static -int clif_npc0078(struct npc_data *nd, unsigned char *buf) +int clif_npc0078(dumb_ptr nd, unsigned char *buf) { nullpo_ret(nd); @@ -892,7 +900,7 @@ earray equip_points //= * *------------------------------------------ */ -int clif_spawnpc(struct map_session_data *sd) +int clif_spawnpc(dumb_ptr sd) { unsigned char buf[128]; @@ -924,7 +932,7 @@ int clif_spawnpc(struct map_session_data *sd) * *------------------------------------------ */ -int clif_spawnnpc(struct npc_data *nd) +int clif_spawnnpc(dumb_ptr nd) { unsigned char buf[64]; int len; @@ -950,7 +958,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(dumb_ptr sd, int fake_npc_id) { int fd; @@ -991,7 +999,7 @@ int clif_spawn_fake_npc_for_player(struct map_session_data *sd, int fake_npc_id) * *------------------------------------------ */ -int clif_spawnmob(struct mob_data *md) +int clif_spawnmob(dumb_ptr md) { unsigned char buf[64]; int len; @@ -1023,7 +1031,7 @@ int clif_spawnmob(struct mob_data *md) *------------------------------------------ */ static -int clif_servertick(struct map_session_data *sd) +int clif_servertick(dumb_ptr sd) { int fd; @@ -1041,7 +1049,7 @@ int clif_servertick(struct map_session_data *sd) * *------------------------------------------ */ -int clif_walkok(struct map_session_data *sd) +int clif_walkok(dumb_ptr sd) { int fd; @@ -1061,7 +1069,7 @@ int clif_walkok(struct map_session_data *sd) * *------------------------------------------ */ -int clif_movechar(struct map_session_data *sd) +int clif_movechar(dumb_ptr sd) { int len; unsigned char buf[256]; @@ -1084,7 +1092,7 @@ int clif_movechar(struct map_session_data *sd) *------------------------------------------ */ static -void clif_quitsave(int, struct map_session_data *sd) +void clif_quitsave(int, dumb_ptr sd) { map_quit(sd); } @@ -1118,7 +1126,7 @@ void clif_setwaitclose(int fd) * *------------------------------------------ */ -int clif_changemap(struct map_session_data *sd, const char *mapname, int x, int y) +int clif_changemap(dumb_ptr sd, const char *mapname, int x, int y) { int fd; @@ -1139,7 +1147,7 @@ int clif_changemap(struct map_session_data *sd, const char *mapname, int x, int * *------------------------------------------ */ -int clif_changemapserver(struct map_session_data *sd, const char *mapname, int x, +int clif_changemapserver(dumb_ptr sd, const char *mapname, int x, int y, struct in_addr ip, int port) { int fd; @@ -1162,7 +1170,7 @@ int clif_changemapserver(struct map_session_data *sd, const char *mapname, int x * *------------------------------------------ */ -int clif_fixpos(struct block_list *bl) +int clif_fixpos(dumb_ptr bl) { uint8_t buf[16]; @@ -1182,7 +1190,7 @@ int clif_fixpos(struct block_list *bl) * *------------------------------------------ */ -int clif_npcbuysell(struct map_session_data *sd, int id) +int clif_npcbuysell(dumb_ptr sd, int id) { int fd; @@ -1200,7 +1208,7 @@ int clif_npcbuysell(struct map_session_data *sd, int id) * *------------------------------------------ */ -int clif_buylist(struct map_session_data *sd, struct npc_data *nd) +int clif_buylist(dumb_ptr sd, dumb_ptr nd) { struct item_data *id; int fd, i, val; @@ -1210,17 +1218,17 @@ int clif_buylist(struct map_session_data *sd, struct npc_data *nd) fd = sd->fd; WFIFOW(fd, 0) = 0xc6; - for (i = 0; nd->u.shop_item[i].nameid > 0; i++) + for (i = 0; i < nd->shop_items.size(); i++) { - id = itemdb_search(nd->u.shop_item[i].nameid); - val = nd->u.shop_item[i].value; + id = itemdb_search(nd->shop_items[i].nameid); + val = nd->shop_items[i].value; WFIFOL(fd, 4 + i * 11) = val; // base price WFIFOL(fd, 8 + i * 11) = val; // actual price WFIFOB(fd, 12 + i * 11) = uint8_t(id->type); if (id->view_id > 0) WFIFOW(fd, 13 + i * 11) = id->view_id; else - WFIFOW(fd, 13 + i * 11) = nd->u.shop_item[i].nameid; + WFIFOW(fd, 13 + i * 11) = nd->shop_items[i].nameid; } WFIFOW(fd, 2) = i * 11 + 4; WFIFOSET(fd, WFIFOW(fd, 2)); @@ -1232,7 +1240,7 @@ int clif_buylist(struct map_session_data *sd, struct npc_data *nd) * *------------------------------------------ */ -int clif_selllist(struct map_session_data *sd) +int clif_selllist(dumb_ptr sd) { int fd, i, c = 0, val; @@ -1263,7 +1271,7 @@ int clif_selllist(struct map_session_data *sd) * *------------------------------------------ */ -int clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) +int clif_scriptmes(dumb_ptr sd, int npcid, const char *mes) { int fd; @@ -1283,7 +1291,7 @@ int clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) * *------------------------------------------ */ -int clif_scriptnext(struct map_session_data *sd, int npcid) +int clif_scriptnext(dumb_ptr sd, int npcid) { int fd; @@ -1301,7 +1309,7 @@ int clif_scriptnext(struct map_session_data *sd, int npcid) * *------------------------------------------ */ -int clif_scriptclose(struct map_session_data *sd, int npcid) +int clif_scriptclose(dumb_ptr sd, int npcid) { int fd; @@ -1319,7 +1327,7 @@ int clif_scriptclose(struct map_session_data *sd, int npcid) * *------------------------------------------ */ -int clif_scriptmenu(struct map_session_data *sd, int npcid, const char *mes) +int clif_scriptmenu(dumb_ptr sd, int npcid, const char *mes) { int fd; @@ -1339,7 +1347,7 @@ int clif_scriptmenu(struct map_session_data *sd, int npcid, const char *mes) * *------------------------------------------ */ -int clif_scriptinput(struct map_session_data *sd, int npcid) +int clif_scriptinput(dumb_ptr sd, int npcid) { int fd; @@ -1357,7 +1365,7 @@ int clif_scriptinput(struct map_session_data *sd, int npcid) * *------------------------------------------ */ -int clif_scriptinputstr(struct map_session_data *sd, int npcid) +int clif_scriptinputstr(dumb_ptr sd, int npcid) { int fd; @@ -1375,7 +1383,7 @@ int clif_scriptinputstr(struct map_session_data *sd, int npcid) * *------------------------------------------ */ -int clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, +int clif_viewpoint(dumb_ptr sd, int npc_id, int type, int x, int y, int id, int color) { int fd; @@ -1399,7 +1407,7 @@ int clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, * *------------------------------------------ */ -int clif_cutin(struct map_session_data *sd, const char *image, int type) +int clif_cutin(dumb_ptr sd, const char *image, int type) { int fd; @@ -1418,7 +1426,7 @@ int clif_cutin(struct map_session_data *sd, const char *image, int type) * *------------------------------------------ */ -int clif_additem(struct map_session_data *sd, int n, int amount, PickupFail fail) +int clif_additem(dumb_ptr sd, int n, int amount, PickupFail fail) { nullpo_ret(sd); @@ -1507,7 +1515,7 @@ int clif_additem(struct map_session_data *sd, int n, int amount, PickupFail fail * *------------------------------------------ */ -int clif_delitem(struct map_session_data *sd, int n, int amount) +int clif_delitem(dumb_ptr sd, int n, int amount) { int fd; @@ -1527,7 +1535,7 @@ int clif_delitem(struct map_session_data *sd, int n, int amount) * *------------------------------------------ */ -int clif_itemlist(struct map_session_data *sd) +int clif_itemlist(dumb_ptr sd) { nullpo_ret(sd); @@ -1577,7 +1585,7 @@ int clif_itemlist(struct map_session_data *sd) * *------------------------------------------ */ -int clif_equiplist(struct map_session_data *sd) +int clif_equiplist(dumb_ptr sd) { nullpo_ret(sd); @@ -1654,7 +1662,7 @@ int clif_equiplist(struct map_session_data *sd) * カプラさんに預けてある消耗品&収集品リスト *------------------------------------------ */ -int clif_storageitemlist(struct map_session_data *sd, struct storage *stor) +int clif_storageitemlist(dumb_ptr sd, struct storage *stor) { nullpo_ret(sd); nullpo_ret(stor); @@ -1700,7 +1708,7 @@ int clif_storageitemlist(struct map_session_data *sd, struct storage *stor) * カプラさんに預けてある装備リスト *------------------------------------------ */ -int clif_storageequiplist(struct map_session_data *sd, struct storage *stor) +int clif_storageequiplist(dumb_ptr sd, struct storage *stor) { nullpo_ret(sd); nullpo_ret(stor); @@ -1780,7 +1788,7 @@ int clif_storageequiplist(struct map_session_data *sd, struct storage *stor) * 表示専用数字はこの中で計算して送る *------------------------------------------ */ -int clif_updatestatus(struct map_session_data *sd, SP type) +int clif_updatestatus(dumb_ptr sd, SP type) { int fd, len = 8; @@ -1951,21 +1959,21 @@ int clif_updatestatus(struct map_session_data *sd, SP type) * *------------------------------------------ */ -int clif_changelook(struct block_list *bl, LOOK type, int val) +int clif_changelook(dumb_ptr bl, LOOK type, int val) { return clif_changelook_towards(bl, type, val, NULL); } -int clif_changelook_towards(struct block_list *bl, LOOK type, int val, - struct map_session_data *dstsd) +int clif_changelook_towards(dumb_ptr bl, LOOK type, int val, + dumb_ptr dstsd) { unsigned char buf[32]; - struct map_session_data *sd = NULL; + dumb_ptr sd = NULL; nullpo_ret(bl); if (bl->bl_type == BL::PC) - sd = (struct map_session_data *) bl; + sd = bl->as_player(); if (sd && bool(sd->status.option & Option::INVISIBILITY)) return 0; @@ -2056,7 +2064,7 @@ int clif_changelook_towards(struct block_list *bl, LOOK type, int val, *------------------------------------------ */ static -int clif_initialstatus(struct map_session_data *sd) +int clif_initialstatus(dumb_ptr sd) { nullpo_ret(sd); @@ -2112,7 +2120,7 @@ int clif_initialstatus(struct map_session_data *sd) *矢装備 *------------------------------------------ */ -int clif_arrowequip(struct map_session_data *sd, int val) +int clif_arrowequip(dumb_ptr sd, int val) { int fd; @@ -2134,7 +2142,7 @@ int clif_arrowequip(struct map_session_data *sd, int val) * *------------------------------------------ */ -int clif_arrow_fail(struct map_session_data *sd, int type) +int clif_arrow_fail(dumb_ptr sd, int type) { int fd; @@ -2153,7 +2161,7 @@ int clif_arrow_fail(struct map_session_data *sd, int type) * *------------------------------------------ */ -int clif_statusupack(struct map_session_data *sd, SP type, int ok, int val) +int clif_statusupack(dumb_ptr sd, SP type, int ok, int val) { int fd; @@ -2173,7 +2181,7 @@ int clif_statusupack(struct map_session_data *sd, SP type, int ok, int val) * *------------------------------------------ */ -int clif_equipitemack(struct map_session_data *sd, int n, EPOS pos, int ok) +int clif_equipitemack(dumb_ptr sd, int n, EPOS pos, int ok) { int fd; @@ -2193,7 +2201,7 @@ int clif_equipitemack(struct map_session_data *sd, int n, EPOS pos, int ok) * *------------------------------------------ */ -int clif_unequipitemack(struct map_session_data *sd, int n, EPOS pos, int ok) +int clif_unequipitemack(dumb_ptr sd, int n, EPOS pos, int ok) { int fd; @@ -2213,7 +2221,7 @@ int clif_unequipitemack(struct map_session_data *sd, int n, EPOS pos, int ok) * *------------------------------------------ */ -int clif_misceffect(struct block_list *bl, int type) +int clif_misceffect(dumb_ptr bl, int type) { uint8_t buf[32]; @@ -2232,7 +2240,7 @@ int clif_misceffect(struct block_list *bl, int type) * 表示オプション変更 *------------------------------------------ */ -int clif_changeoption(struct block_list *bl) +int clif_changeoption(dumb_ptr bl) { uint8_t buf[32]; eptr sc_data; @@ -2258,7 +2266,7 @@ int clif_changeoption(struct block_list *bl) * *------------------------------------------ */ -int clif_useitemack(struct map_session_data *sd, int index, int amount, +int clif_useitemack(dumb_ptr sd, int index, int amount, int ok) { nullpo_ret(sd); @@ -2296,7 +2304,7 @@ int clif_useitemack(struct map_session_data *sd, int index, int amount, * 取り引き要請受け *------------------------------------------ */ -int clif_traderequest(struct map_session_data *sd, const char *name) +int clif_traderequest(dumb_ptr sd, const char *name) { int fd; @@ -2314,7 +2322,7 @@ int clif_traderequest(struct map_session_data *sd, const char *name) * 取り引き要求応答 *------------------------------------------ */ -int clif_tradestart(struct map_session_data *sd, int type) +int clif_tradestart(dumb_ptr sd, int type) { int fd; @@ -2332,8 +2340,8 @@ int clif_tradestart(struct map_session_data *sd, int type) * 相手方からのアイテム追加 *------------------------------------------ */ -int clif_tradeadditem(struct map_session_data *sd, - struct map_session_data *tsd, int index, int amount) +int clif_tradeadditem(dumb_ptr sd, + dumb_ptr tsd, int index, int amount) { int fd, j; @@ -2414,7 +2422,7 @@ int clif_tradeadditem(struct map_session_data *sd, * アイテム追加成功/失敗 *------------------------------------------ */ -int clif_tradeitemok(struct map_session_data *sd, int index, int amount, +int clif_tradeitemok(dumb_ptr sd, int index, int amount, int fail) { int fd; @@ -2435,7 +2443,7 @@ int clif_tradeitemok(struct map_session_data *sd, int index, int amount, * 取り引きok押し *------------------------------------------ */ -int clif_tradedeal_lock(struct map_session_data *sd, int fail) +int clif_tradedeal_lock(dumb_ptr sd, int fail) { int fd; @@ -2453,7 +2461,7 @@ int clif_tradedeal_lock(struct map_session_data *sd, int fail) * 取り引きがキャンセルされました *------------------------------------------ */ -int clif_tradecancelled(struct map_session_data *sd) +int clif_tradecancelled(dumb_ptr sd) { int fd; @@ -2470,7 +2478,7 @@ int clif_tradecancelled(struct map_session_data *sd) * 取り引き完了 *------------------------------------------ */ -int clif_tradecompleted(struct map_session_data *sd, int fail) +int clif_tradecompleted(dumb_ptr sd, int fail) { int fd; @@ -2488,7 +2496,7 @@ int clif_tradecompleted(struct map_session_data *sd, int fail) * カプラ倉庫のアイテム数を更新 *------------------------------------------ */ -int clif_updatestorageamount(struct map_session_data *sd, +int clif_updatestorageamount(dumb_ptr sd, struct storage *stor) { int fd; @@ -2509,7 +2517,7 @@ int clif_updatestorageamount(struct map_session_data *sd, * カプラ倉庫にアイテムを追加する *------------------------------------------ */ -int clif_storageitemadded(struct map_session_data *sd, struct storage *stor, +int clif_storageitemadded(dumb_ptr sd, struct storage *stor, int index, int amount) { int fd, j; @@ -2572,7 +2580,7 @@ int clif_storageitemadded(struct map_session_data *sd, struct storage *stor, * カプラ倉庫からアイテムを取り去る *------------------------------------------ */ -int clif_storageitemremoved(struct map_session_data *sd, int index, +int clif_storageitemremoved(dumb_ptr sd, int index, int amount) { int fd; @@ -2592,7 +2600,7 @@ int clif_storageitemremoved(struct map_session_data *sd, int index, * カプラ倉庫を閉じる *------------------------------------------ */ -int clif_storageclose(struct map_session_data *sd) +int clif_storageclose(dumb_ptr sd) { int fd; @@ -2605,8 +2613,8 @@ int clif_storageclose(struct map_session_data *sd) return 0; } -void clif_changelook_accessories(struct block_list *bl, - struct map_session_data *dest) +void clif_changelook_accessories(dumb_ptr bl, + dumb_ptr dest) { for (LOOK i = LOOK::SHOES; i < LOOK::COUNT; i = LOOK(uint8_t(i) + 1)) clif_changelook_towards(bl, i, 0, dest); @@ -2620,8 +2628,8 @@ void clif_changelook_accessories(struct block_list *bl, *------------------------------------------ */ static -void clif_getareachar_pc(struct map_session_data *sd, - struct map_session_data *dstsd) +void clif_getareachar_pc(dumb_ptr sd, + dumb_ptr dstsd) { int len; @@ -2655,7 +2663,7 @@ void clif_getareachar_pc(struct map_session_data *sd, *------------------------------------------ */ static -void clif_getareachar_npc(struct map_session_data *sd, struct npc_data *nd) +void clif_getareachar_npc(dumb_ptr sd, dumb_ptr nd) { int len; @@ -2673,7 +2681,7 @@ void clif_getareachar_npc(struct map_session_data *sd, struct npc_data *nd) * 移動停止 *------------------------------------------ */ -int clif_movemob(struct mob_data *md) +int clif_movemob(dumb_ptr md) { unsigned char buf[256]; int len; @@ -2690,7 +2698,7 @@ int clif_movemob(struct mob_data *md) * モンスターの位置修正 *------------------------------------------ */ -int clif_fixmobpos(struct mob_data *md) +int clif_fixmobpos(dumb_ptr md) { unsigned char buf[256]; int len; @@ -2715,7 +2723,7 @@ int clif_fixmobpos(struct mob_data *md) * PCの位置修正 *------------------------------------------ */ -int clif_fixpcpos(struct map_session_data *sd) +int clif_fixpcpos(dumb_ptr sd) { unsigned char buf[256]; int len; @@ -2741,7 +2749,7 @@ int clif_fixpcpos(struct map_session_data *sd) * 通常攻撃エフェクト&ダメージ *------------------------------------------ */ -int clif_damage(struct block_list *src, struct block_list *dst, +int clif_damage(dumb_ptr src, dumb_ptr dst, tick_t tick, interval_t sdelay, interval_t ddelay, int damage, int div, DamageType type, int damage2) { @@ -2773,7 +2781,7 @@ int clif_damage(struct block_list *src, struct block_list *dst, *------------------------------------------ */ static -void clif_getareachar_mob(struct map_session_data *sd, struct mob_data *md) +void clif_getareachar_mob(dumb_ptr sd, dumb_ptr md) { int len; nullpo_retv(sd); @@ -2796,8 +2804,8 @@ void clif_getareachar_mob(struct map_session_data *sd, struct mob_data *md) *------------------------------------------ */ static -void clif_getareachar_item(struct map_session_data *sd, - struct flooritem_data *fitem) +void clif_getareachar_item(dumb_ptr sd, + dumb_ptr fitem) { int view, fd; @@ -2827,25 +2835,25 @@ void clif_getareachar_item(struct map_session_data *sd, *------------------------------------------ */ static -void clif_getareachar(struct block_list *bl, struct map_session_data *sd) +void clif_getareachar(dumb_ptr bl, dumb_ptr sd) { nullpo_retv(bl); switch (bl->bl_type) { case BL::PC: - if (sd == (struct map_session_data *) bl) + if (sd == bl->as_player()) break; - clif_getareachar_pc(sd, (struct map_session_data *) bl); + clif_getareachar_pc(sd, bl->as_player()); break; case BL::NPC: - clif_getareachar_npc(sd, (struct npc_data *) bl); + clif_getareachar_npc(sd, bl->as_npc()); break; case BL::MOB: - clif_getareachar_mob(sd, (struct mob_data *) bl); + clif_getareachar_mob(sd, bl->as_mob()); break; case BL::ITEM: - clif_getareachar_item(sd, (struct flooritem_data *) bl); + clif_getareachar_item(sd, bl->as_item()); break; default: if (battle_config.error_log) @@ -2859,9 +2867,9 @@ void clif_getareachar(struct block_list *bl, struct map_session_data *sd) * *------------------------------------------ */ -void clif_pcoutsight(struct block_list *bl, struct map_session_data *sd) +void clif_pcoutsight(dumb_ptr bl, dumb_ptr sd) { - struct map_session_data *dstsd; + dumb_ptr dstsd; nullpo_retv(bl); nullpo_retv(sd); @@ -2869,7 +2877,7 @@ void clif_pcoutsight(struct block_list *bl, struct map_session_data *sd) switch (bl->bl_type) { case BL::PC: - dstsd = (struct map_session_data *) bl; + dstsd = bl->as_player(); if (sd != dstsd) { clif_clearchar_id(dstsd->bl_id, BeingRemoveWhy::GONE, sd->fd); @@ -2877,14 +2885,14 @@ void clif_pcoutsight(struct block_list *bl, struct map_session_data *sd) } break; case BL::NPC: - if (((struct npc_data *) bl)->npc_class != INVISIBLE_CLASS) + if (bl->as_npc()->npc_class != INVISIBLE_CLASS) clif_clearchar_id(bl->bl_id, BeingRemoveWhy::GONE, sd->fd); break; case BL::MOB: clif_clearchar_id(bl->bl_id, BeingRemoveWhy::GONE, sd->fd); break; case BL::ITEM: - clif_clearflooritem((struct flooritem_data *) bl, sd->fd); + clif_clearflooritem(bl->as_item(), sd->fd); break; } } @@ -2893,9 +2901,9 @@ void clif_pcoutsight(struct block_list *bl, struct map_session_data *sd) * *------------------------------------------ */ -void clif_pcinsight(struct block_list *bl, struct map_session_data *sd) +void clif_pcinsight(dumb_ptr bl, dumb_ptr sd) { - struct map_session_data *dstsd; + dumb_ptr dstsd; nullpo_retv(bl); nullpo_retv(sd); @@ -2903,7 +2911,7 @@ void clif_pcinsight(struct block_list *bl, struct map_session_data *sd) switch (bl->bl_type) { case BL::PC: - dstsd = (struct map_session_data *) bl; + dstsd = bl->as_player(); if (sd != dstsd) { clif_getareachar_pc(sd, dstsd); @@ -2911,13 +2919,13 @@ void clif_pcinsight(struct block_list *bl, struct map_session_data *sd) } break; case BL::NPC: - clif_getareachar_npc(sd, (struct npc_data *) bl); + clif_getareachar_npc(sd, bl->as_npc()); break; case BL::MOB: - clif_getareachar_mob(sd, (struct mob_data *) bl); + clif_getareachar_mob(sd, bl->as_mob()); break; case BL::ITEM: - clif_getareachar_item(sd, (struct flooritem_data *) bl); + clif_getareachar_item(sd, bl->as_item()); break; } } @@ -2926,15 +2934,16 @@ void clif_pcinsight(struct block_list *bl, struct map_session_data *sd) * *------------------------------------------ */ -void clif_moboutsight(struct block_list *bl, struct mob_data *md) +void clif_moboutsight(dumb_ptr bl, dumb_ptr md) { - struct map_session_data *sd; + dumb_ptr sd; nullpo_retv(bl); nullpo_retv(md); - if (bl->bl_type == BL::PC && (sd = (struct map_session_data *) bl)) + if (bl->bl_type == BL::PC) { + sd = bl->as_player(); clif_clearchar_id(md->bl_id, BeingRemoveWhy::GONE, sd->fd); } } @@ -2943,15 +2952,16 @@ void clif_moboutsight(struct block_list *bl, struct mob_data *md) * *------------------------------------------ */ -void clif_mobinsight(struct block_list *bl, struct mob_data *md) +void clif_mobinsight(dumb_ptr bl, dumb_ptr md) { - struct map_session_data *sd; + dumb_ptr sd; nullpo_retv(bl); nullpo_retv(md); - if (bl->bl_type == BL::PC && (sd = (struct map_session_data *) bl)) + if (bl->bl_type == BL::PC) { + sd = bl->as_player(); clif_getareachar_mob(sd, md); } } @@ -2960,7 +2970,7 @@ void clif_mobinsight(struct block_list *bl, struct mob_data *md) * *------------------------------------------ */ -int clif_skillinfo(struct map_session_data *sd, SkillID skillid, int type, +int clif_skillinfo(dumb_ptr sd, SkillID skillid, int type, int range) { int fd; @@ -2999,7 +3009,7 @@ int clif_skillinfo(struct map_session_data *sd, SkillID skillid, int type, * スキルリストを送信する *------------------------------------------ */ -int clif_skillinfoblock(struct map_session_data *sd) +int clif_skillinfoblock(dumb_ptr sd) { int fd; int len = 4, range; @@ -3039,7 +3049,7 @@ int clif_skillinfoblock(struct map_session_data *sd) * スキル割り振り通知 *------------------------------------------ */ -int clif_skillup(struct map_session_data *sd, SkillID skill_num) +int clif_skillup(dumb_ptr sd, SkillID skill_num) { int range, fd; @@ -3064,7 +3074,7 @@ int clif_skillup(struct map_session_data *sd, SkillID skill_num) * *------------------------------------------ */ -int clif_skillcastcancel(struct block_list *bl) +int clif_skillcastcancel(dumb_ptr bl) { unsigned char buf[16]; @@ -3081,7 +3091,7 @@ int clif_skillcastcancel(struct block_list *bl) * スキル詠唱失敗 *------------------------------------------ */ -int clif_skill_fail(struct map_session_data *sd, SkillID skill_id, int type, +int clif_skill_fail(dumb_ptr sd, SkillID skill_id, int type, int btype) { int fd; @@ -3110,7 +3120,7 @@ int clif_skill_fail(struct map_session_data *sd, SkillID skill_id, int type, * スキル攻撃エフェクト&ダメージ *------------------------------------------ */ -int clif_skill_damage(struct block_list *src, struct block_list *dst, +int clif_skill_damage(dumb_ptr src, dumb_ptr dst, tick_t tick, interval_t sdelay, interval_t ddelay, int damage, int div, SkillID skill_id, int skill_lv, int type) { @@ -3142,7 +3152,7 @@ int clif_skill_damage(struct block_list *src, struct block_list *dst, * 状態異常アイコン/メッセージ表示 *------------------------------------------ */ -int clif_status_change(struct block_list *bl, StatusChange type, int flag) +int clif_status_change(dumb_ptr bl, StatusChange type, int flag) { unsigned char buf[16]; @@ -3177,7 +3187,7 @@ void clif_displaymessage(int fd, const_string mes) * 天の声を送信する *------------------------------------------ */ -void clif_GMmessage(struct block_list *bl, const_string mes, int flag) +void clif_GMmessage(dumb_ptr bl, const_string mes, int flag) { unsigned char buf[mes.size() + 16]; int lp = (flag & 0x10) ? 8 : 4; @@ -3199,7 +3209,7 @@ void clif_GMmessage(struct block_list *bl, const_string mes, int flag) * 復活する *------------------------------------------ */ -int clif_resurrection(struct block_list *bl, int type) +int clif_resurrection(dumb_ptr bl, int type) { unsigned char buf[16]; @@ -3252,7 +3262,7 @@ int clif_wis_end(int fd, int flag) // R 0098 .B: 0: success to send wisper * 2 The character is already in a party. *------------------------------------------ */ -int clif_party_created(struct map_session_data *sd, int flag) +int clif_party_created(dumb_ptr sd, int flag) { int fd; @@ -3273,7 +3283,7 @@ int clif_party_info(struct party *p, int fd) { unsigned char buf[1024]; int i, c; - struct map_session_data *sd = NULL; + dumb_ptr sd = NULL; nullpo_ret(p); @@ -3285,7 +3295,7 @@ int clif_party_info(struct party *p, int fd) if (m->account_id > 0) { if (sd == NULL) - sd = m->sd; + sd = dumb_ptr(m->sd); WBUFL(buf, 28 + c * 46) = m->account_id; memcpy(WBUFP(buf, 28 + c * 46 + 4), m->name, 24); memcpy(WBUFP(buf, 28 + c * 46 + 28), m->map, 16); @@ -3313,8 +3323,8 @@ int clif_party_info(struct party *p, int fd) * (R 00fe .l .24B) *------------------------------------------ */ -int clif_party_invite(struct map_session_data *sd, - struct map_session_data *tsd) +int clif_party_invite(dumb_ptr sd, + dumb_ptr tsd) { int fd; struct party *p; @@ -3348,7 +3358,7 @@ int clif_party_invite(struct map_session_data *sd, * 4 The character is in the same party. *------------------------------------------ */ -int clif_party_inviteack(struct map_session_data *sd, const char *nick, int flag) +int clif_party_inviteack(dumb_ptr sd, const char *nick, int flag) { int fd; @@ -3369,7 +3379,7 @@ int clif_party_inviteack(struct map_session_data *sd, const char *nick, int flag * 0x100=一人にのみ送信 *------------------------------------------ */ -int clif_party_option(struct party *p, struct map_session_data *sd, int flag) +int clif_party_option(struct party *p, dumb_ptr sd, int flag) { unsigned char buf[16]; @@ -3403,7 +3413,7 @@ int clif_party_option(struct party *p, struct map_session_data *sd, int flag) * パーティ脱退(脱退前に呼ぶこと) *------------------------------------------ */ -int clif_party_leaved(struct party *p, struct map_session_data *sd, +int clif_party_leaved(struct party *p, dumb_ptr sd, int account_id, const char *name, int flag) { unsigned char buf[64]; @@ -3420,8 +3430,11 @@ int clif_party_leaved(struct party *p, struct map_session_data *sd, { if (sd == NULL) for (i = 0; i < MAX_PARTY; i++) - if ((sd = p->member[i].sd) != NULL) + { + sd = dumb_ptr(p->member[i].sd); + if (sd != NULL) break; + } if (sd != NULL) clif_send(buf, clif_parse_func_table[0x105].len, sd, SendWho::PARTY); } @@ -3440,14 +3453,15 @@ int clif_party_leaved(struct party *p, struct map_session_data *sd, int clif_party_message(struct party *p, int account_id, const char *mes, int len) { // always set, but clang is not smart enough - struct map_session_data *sd = nullptr; + dumb_ptr sd = nullptr; int i; nullpo_ret(p); for (i = 0; i < MAX_PARTY; i++) { - if ((sd = p->member[i].sd) != NULL) + sd = dumb_ptr(p->member[i].sd); + if (sd != NULL) break; } if (sd != NULL) @@ -3466,7 +3480,7 @@ int clif_party_message(struct party *p, int account_id, const char *mes, int len * パーティ座標通知 *------------------------------------------ */ -int clif_party_xy(struct party *, struct map_session_data *sd) +int clif_party_xy(struct party *, dumb_ptr sd) { unsigned char buf[16]; @@ -3486,7 +3500,7 @@ int clif_party_xy(struct party *, struct map_session_data *sd) * パーティHP通知 *------------------------------------------ */ -int clif_party_hp(struct party *, struct map_session_data *sd) +int clif_party_hp(struct party *, dumb_ptr sd) { unsigned char buf[16]; @@ -3507,7 +3521,7 @@ int clif_party_hp(struct party *, struct map_session_data *sd) * 攻撃するために移動が必要 *------------------------------------------ */ -int clif_movetoattack(struct map_session_data *sd, struct block_list *bl) +int clif_movetoattack(dumb_ptr sd, dumb_ptr bl) { int fd; @@ -3530,7 +3544,7 @@ int clif_movetoattack(struct map_session_data *sd, struct block_list *bl) * MVPエフェクト *------------------------------------------ */ -int clif_mvp_effect(struct map_session_data *sd) +int clif_mvp_effect(dumb_ptr sd) { unsigned char buf[16]; @@ -3546,7 +3560,7 @@ int clif_mvp_effect(struct map_session_data *sd) * エモーション *------------------------------------------ */ -void clif_emotion(struct block_list *bl, int type) +void clif_emotion(dumb_ptr bl, int type) { unsigned char buf[8]; @@ -3559,12 +3573,12 @@ void clif_emotion(struct block_list *bl, int type) } static -void clif_emotion_towards(struct block_list *bl, - struct block_list *target, int type) +void clif_emotion_towards(dumb_ptr bl, + dumb_ptr target, int type) { unsigned char buf[8]; int len = clif_parse_func_table[0xc0].len; - struct map_session_data *sd = (struct map_session_data *) target; + dumb_ptr sd = target->as_player(); nullpo_retv(bl); nullpo_retv(target); @@ -3584,7 +3598,7 @@ void clif_emotion_towards(struct block_list *bl, * 座る *------------------------------------------ */ -void clif_sitting(int, struct map_session_data *sd) +void clif_sitting(int, dumb_ptr sd) { unsigned char buf[64]; @@ -3601,7 +3615,7 @@ void clif_sitting(int, struct map_session_data *sd) *------------------------------------------ */ static -int clif_GM_kickack(struct map_session_data *sd, int id) +int clif_GM_kickack(dumb_ptr sd, int id) { int fd; @@ -3615,9 +3629,9 @@ int clif_GM_kickack(struct map_session_data *sd, int id) } static -void clif_parse_QuitGame(int fd, struct map_session_data *sd); +void clif_parse_QuitGame(int fd, dumb_ptr sd); -int clif_GM_kick(struct map_session_data *sd, struct map_session_data *tsd, +int clif_GM_kick(dumb_ptr sd, dumb_ptr tsd, int type) { nullpo_ret(tsd); @@ -3632,7 +3646,7 @@ int clif_GM_kick(struct map_session_data *sd, struct map_session_data *tsd, } // displaying special effects (npcs, weather, etc) [Valaris] -int clif_specialeffect(struct block_list *bl, int type, int flag) +int clif_specialeffect(dumb_ptr bl, int type, int flag) { unsigned char buf[24]; @@ -3650,7 +3664,7 @@ int clif_specialeffect(struct block_list *bl, int type, int flag) { if (!session[i]) continue; - struct map_session_data *sd = static_cast(session[i]->session_data.get()); + dumb_ptr sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (sd && sd->state.auth && sd->bl_m == bl->bl_m) clif_specialeffect(sd, type, 1); } @@ -3673,7 +3687,7 @@ int clif_specialeffect(struct block_list *bl, int type, int flag) *------------------------------------------ */ static -void clif_parse_WantToConnection(int fd, struct map_session_data *sd) +void clif_parse_WantToConnection(int fd, dumb_ptr sd) { int account_id; // account_id in the packet @@ -3695,7 +3709,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) WFIFOSET(fd, 4); // if same account already connected, we disconnect the 2 sessions - struct map_session_data *old_sd = map_id2sd(account_id); + dumb_ptr old_sd = map_id2sd(account_id); if (old_sd) { clif_authfail_fd(fd, 2); // same id @@ -3705,8 +3719,8 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) } else { - sd = new map_session_data(); - session[fd]->session_data.reset(sd); + sd.new_(); + session[fd]->session_data.reset(sd.operator->()); sd->fd = fd; pc_setnewpc(sd, account_id, RFIFOL(fd, 6), RFIFOL(fd, 10), @@ -3727,7 +3741,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_LoadEndAck(int, struct map_session_data *sd) +void clif_parse_LoadEndAck(int, dumb_ptr sd) { // struct item_data* item; int i; @@ -3828,7 +3842,7 @@ void clif_parse_LoadEndAck(int, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_TickSend(int fd, struct map_session_data *sd) +void clif_parse_TickSend(int fd, dumb_ptr sd) { nullpo_retv(sd); @@ -3842,7 +3856,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_WalkToXY(int fd, struct map_session_data *sd) +void clif_parse_WalkToXY(int fd, dumb_ptr sd) { int x, y; @@ -3879,7 +3893,7 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) * *------------------------------------------ */ -void clif_parse_QuitGame(int fd, struct map_session_data *sd) +void clif_parse_QuitGame(int fd, dumb_ptr sd) { tick_t tick = gettick(); @@ -3914,9 +3928,9 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) +void clif_parse_GetCharNameRequest(int fd, dumb_ptr sd) { - struct block_list *bl; + dumb_ptr bl; int account_id; account_id = RFIFOL(fd, 2); @@ -3931,7 +3945,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { case BL::PC: { - struct map_session_data *ssd = (struct map_session_data *) bl; + dumb_ptr ssd = bl->as_player(); nullpo_retv(ssd); @@ -3982,7 +3996,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) } break; case BL::NPC: - memcpy(WFIFOP(fd, 6), ((struct npc_data *) bl)->name, 24); + memcpy(WFIFOP(fd, 6), bl->as_npc()->name, 24); { char *start = (char *)WFIFOP(fd, 6); char *end = strchr(start, '#'); // [fate] elim hashed out/invisible names for the client @@ -3998,7 +4012,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) break; case BL::MOB: { - struct mob_data *md = (struct mob_data *) bl; + dumb_ptr md = bl->as_mob(); nullpo_retv(md); @@ -4022,7 +4036,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) +void clif_parse_GlobalMessage(int fd, dumb_ptr sd) { int msg_len = RFIFOW(fd, 2) - 4; /* Header(2) + length(2). */ size_t message_len = 0; @@ -4072,7 +4086,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) return; } -int clif_message(struct block_list *bl, const char *msg) +int clif_message(dumb_ptr bl, const char *msg) { unsigned short msg_len = strlen(msg) + 1; unsigned char buf[512]; @@ -4097,7 +4111,7 @@ int clif_message(struct block_list *bl, const char *msg) *------------------------------------------ */ static -void clif_parse_ChangeDir(int fd, struct map_session_data *sd) +void clif_parse_ChangeDir(int fd, dumb_ptr sd) { unsigned char buf[64]; @@ -4127,7 +4141,7 @@ void clif_parse_ChangeDir(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_Emotion(int fd, struct map_session_data *sd) +void clif_parse_Emotion(int fd, dumb_ptr sd) { unsigned char buf[64]; @@ -4150,7 +4164,7 @@ void clif_parse_Emotion(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_HowManyConnections(int fd, struct map_session_data *) +void clif_parse_HowManyConnections(int fd, dumb_ptr) { WFIFOW(fd, 0) = 0xc2; WFIFOL(fd, 2) = map_getusers(); @@ -4162,7 +4176,7 @@ void clif_parse_HowManyConnections(int fd, struct map_session_data *) *------------------------------------------ */ static -void clif_parse_ActionRequest(int fd, struct map_session_data *sd) +void clif_parse_ActionRequest(int fd, dumb_ptr sd) { unsigned char buf[64]; int action_type, target_id; @@ -4229,7 +4243,7 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_Restart(int fd, struct map_session_data *sd) +void clif_parse_Restart(int fd, dumb_ptr sd) { nullpo_retv(sd); @@ -4274,12 +4288,12 @@ void clif_parse_Restart(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_Wis(int fd, struct map_session_data *sd) +void clif_parse_Wis(int fd, dumb_ptr sd) { size_t message_len = 0; char *buf = NULL; const char *message = NULL; /* The message text only. */ - struct map_session_data *dstsd = NULL; + dumb_ptr dstsd = NULL; nullpo_retv(sd); @@ -4360,15 +4374,15 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_TakeItem(int fd, struct map_session_data *sd) +void clif_parse_TakeItem(int fd, dumb_ptr sd) { - struct flooritem_data *fitem; + dumb_ptr fitem; int map_object_id; nullpo_retv(sd); map_object_id = RFIFOL(fd, 2); - fitem = (struct flooritem_data *) map_id2bl(map_object_id); + fitem = map_id_is_item(map_object_id); if (pc_isdead(sd)) { @@ -4398,7 +4412,7 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_DropItem(int fd, struct map_session_data *sd) +void clif_parse_DropItem(int fd, dumb_ptr sd) { int item_index, item_amount; @@ -4432,7 +4446,7 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_UseItem(int fd, struct map_session_data *sd) +void clif_parse_UseItem(int fd, dumb_ptr sd) { nullpo_retv(sd); @@ -4456,7 +4470,7 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_EquipItem(int fd, struct map_session_data *sd) +void clif_parse_EquipItem(int fd, dumb_ptr sd) { int index; @@ -4497,7 +4511,7 @@ void clif_parse_EquipItem(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_UnequipItem(int fd, struct map_session_data *sd) +void clif_parse_UnequipItem(int fd, dumb_ptr sd) { int index; @@ -4525,7 +4539,7 @@ void clif_parse_UnequipItem(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_NpcClicked(int fd, struct map_session_data *sd) +void clif_parse_NpcClicked(int fd, dumb_ptr sd) { nullpo_retv(sd); @@ -4544,7 +4558,7 @@ void clif_parse_NpcClicked(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_NpcBuySellSelected(int fd, struct map_session_data *sd) +void clif_parse_NpcBuySellSelected(int fd, dumb_ptr sd) { npc_buysellsel(sd, RFIFOL(fd, 2), RFIFOB(fd, 6)); } @@ -4554,7 +4568,7 @@ void clif_parse_NpcBuySellSelected(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_NpcBuyListSend(int fd, struct map_session_data *sd) +void clif_parse_NpcBuyListSend(int fd, dumb_ptr sd) { int n = (RFIFOW(fd, 2) - 4) / 4; // really an array of pairs of uint16_t @@ -4572,7 +4586,7 @@ void clif_parse_NpcBuyListSend(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_NpcSellListSend(int fd, struct map_session_data *sd) +void clif_parse_NpcSellListSend(int fd, dumb_ptr sd) { int n = (RFIFOW(fd, 2) - 4) / 4; // really an array of pairs of uint16_t @@ -4590,7 +4604,7 @@ void clif_parse_NpcSellListSend(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_TradeRequest(int, struct map_session_data *sd) +void clif_parse_TradeRequest(int, dumb_ptr sd) { nullpo_retv(sd); @@ -4608,7 +4622,7 @@ void clif_parse_TradeRequest(int, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_TradeAck(int, struct map_session_data *sd) +void clif_parse_TradeAck(int, dumb_ptr sd) { nullpo_retv(sd); @@ -4620,7 +4634,7 @@ void clif_parse_TradeAck(int, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_TradeAddItem(int, struct map_session_data *sd) +void clif_parse_TradeAddItem(int, dumb_ptr sd) { nullpo_retv(sd); @@ -4632,7 +4646,7 @@ void clif_parse_TradeAddItem(int, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_TradeOk(int, struct map_session_data *sd) +void clif_parse_TradeOk(int, dumb_ptr sd) { trade_tradeok(sd); } @@ -4642,7 +4656,7 @@ void clif_parse_TradeOk(int, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_TradeCansel(int, struct map_session_data *sd) +void clif_parse_TradeCansel(int, dumb_ptr sd) { trade_tradecancel(sd); } @@ -4652,7 +4666,7 @@ void clif_parse_TradeCansel(int, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_TradeCommit(int, struct map_session_data *sd) +void clif_parse_TradeCommit(int, dumb_ptr sd) { trade_tradecommit(sd); } @@ -4662,7 +4676,7 @@ void clif_parse_TradeCommit(int, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_StopAttack(int, struct map_session_data *sd) +void clif_parse_StopAttack(int, dumb_ptr sd) { pc_stopattack(sd); } @@ -4672,7 +4686,7 @@ void clif_parse_StopAttack(int, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_StatusUp(int fd, struct map_session_data *sd) +void clif_parse_StatusUp(int fd, dumb_ptr sd) { pc_statusup(sd, SP(RFIFOW(fd, 2))); } @@ -4682,7 +4696,7 @@ void clif_parse_StatusUp(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_SkillUp(int fd, struct map_session_data *sd) +void clif_parse_SkillUp(int fd, dumb_ptr sd) { pc_skillup(sd, SkillID(RFIFOW(fd, 2))); } @@ -4692,7 +4706,7 @@ void clif_parse_SkillUp(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_NpcSelectMenu(int fd, struct map_session_data *sd) +void clif_parse_NpcSelectMenu(int fd, dumb_ptr sd) { nullpo_retv(sd); @@ -4705,7 +4719,7 @@ void clif_parse_NpcSelectMenu(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_NpcNextClicked(int fd, struct map_session_data *sd) +void clif_parse_NpcNextClicked(int fd, dumb_ptr sd) { map_scriptcont(sd, RFIFOL(fd, 2)); } @@ -4715,7 +4729,7 @@ void clif_parse_NpcNextClicked(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_NpcAmountInput(int fd, struct map_session_data *sd) +void clif_parse_NpcAmountInput(int fd, dumb_ptr sd) { nullpo_retv(sd); @@ -4730,7 +4744,7 @@ void clif_parse_NpcAmountInput(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_NpcStringInput(int fd, struct map_session_data *sd) +void clif_parse_NpcStringInput(int fd, dumb_ptr sd) { int len; nullpo_retv(sd); @@ -4762,7 +4776,7 @@ void clif_parse_NpcStringInput(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_NpcCloseClicked(int fd, struct map_session_data *sd) +void clif_parse_NpcCloseClicked(int fd, dumb_ptr sd) { map_scriptcont(sd, RFIFOL(fd, 2)); } @@ -4772,7 +4786,7 @@ void clif_parse_NpcCloseClicked(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) +void clif_parse_MoveToKafra(int fd, dumb_ptr sd) { int item_index, item_amount; @@ -4794,7 +4808,7 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_MoveFromKafra(int fd, struct map_session_data *sd) +void clif_parse_MoveFromKafra(int fd, dumb_ptr sd) { int item_index, item_amount; @@ -4816,7 +4830,7 @@ void clif_parse_MoveFromKafra(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_CloseKafra(int, struct map_session_data *sd) +void clif_parse_CloseKafra(int, dumb_ptr sd) { nullpo_retv(sd); @@ -4832,7 +4846,7 @@ void clif_parse_CloseKafra(int, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_CreateParty(int fd, struct map_session_data *sd) +void clif_parse_CreateParty(int fd, dumb_ptr sd) { if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, SkillID::NV_PARTY) >= 2) @@ -4851,7 +4865,7 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_PartyInvite(int fd, struct map_session_data *sd) +void clif_parse_PartyInvite(int fd, dumb_ptr sd) { party_invite(sd, RFIFOL(fd, 2)); } @@ -4864,7 +4878,7 @@ void clif_parse_PartyInvite(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_ReplyPartyInvite(int fd, struct map_session_data *sd) +void clif_parse_ReplyPartyInvite(int fd, dumb_ptr sd) { if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, SkillID::NV_PARTY) >= 1) @@ -4883,7 +4897,7 @@ void clif_parse_ReplyPartyInvite(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_LeaveParty(int, struct map_session_data *sd) +void clif_parse_LeaveParty(int, dumb_ptr sd) { party_leave(sd); } @@ -4893,7 +4907,7 @@ void clif_parse_LeaveParty(int, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) +void clif_parse_RemovePartyMember(int fd, dumb_ptr sd) { party_removemember(sd, RFIFOL(fd, 2), (const char *)RFIFOP(fd, 6)); } @@ -4903,7 +4917,7 @@ void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) +void clif_parse_PartyChangeOption(int fd, dumb_ptr sd) { party_changeoption(sd, RFIFOW(fd, 2), RFIFOW(fd, 4)); } @@ -4917,7 +4931,7 @@ void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) *------------------------------------------ */ static -void clif_parse_PartyMessage(int fd, struct map_session_data *sd) +void clif_parse_PartyMessage(int fd, dumb_ptr sd) { size_t message_len = 0; char *buf = NULL; @@ -4951,7 +4965,7 @@ void clif_parse_PartyMessage(int fd, struct map_session_data *sd) // 4144 wants this, but I don't like it ... static -void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd) +void clif_parse_PMIgnoreAll(int fd, dumb_ptr sd) { // Rewritten by [Yor] //PRINTF("Ignore all: state: %d\n", RFIFOB(fd,2)); if (RFIFOB(fd, 2) == 0) @@ -5548,7 +5562,7 @@ func_table clif_parse_func_table[0x0220] = static int clif_check_packet_flood(int fd, int cmd) { - map_session_data *sd = static_cast(session[fd]->session_data.get()); + dumb_ptr sd = dumb_ptr(static_cast(session[fd]->session_data.get())); tick_t tick = gettick(); // sd will not be set if the client hasn't requested @@ -5626,7 +5640,7 @@ int clif_check_packet_flood(int fd, int cmd) } inline -void WARN_MALFORMED_MSG(struct map_session_data *sd, const char *msg) +void WARN_MALFORMED_MSG(dumb_ptr sd, const char *msg) { PRINTF("clif_validate_chat(): %s (ID %d) sent a malformed message: %s.\n", sd->status.name, sd->status.account_id, msg); @@ -5644,7 +5658,7 @@ void WARN_MALFORMED_MSG(struct map_session_data *sd, const char *msg) * @return a dynamically allocated copy of the message, or NULL upon failure */ static -char *clif_validate_chat(struct map_session_data *sd, int type, +char *clif_validate_chat(dumb_ptr sd, int type, const char **message, size_t *message_len) { int fd; @@ -5765,7 +5779,7 @@ static void clif_parse(int fd) { int packet_len = 0, cmd = 0; - map_session_data *sd = static_cast(session[fd]->session_data.get()); + dumb_ptr sd = dumb_ptr(static_cast(session[fd]->session_data.get())); if (!sd || (sd && !sd->state.auth)) { diff --git a/src/map/clif.hpp b/src/map/clif.hpp index df0a48b..5240fa1 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -9,7 +9,7 @@ #include "../common/timer.t.hpp" #include "battle.t.hpp" -#include "map.t.hpp" +#include "map.hpp" #include "pc.t.hpp" #include "skill.t.hpp" @@ -21,143 +21,143 @@ int clif_getport(void); int clif_countusers(void); void clif_setwaitclose(int); -int clif_authok(struct map_session_data *); +int clif_authok(dumb_ptr); int clif_authfail_fd(int, int); int clif_charselectok(int); -int clif_dropflooritem(struct flooritem_data *); -int clif_clearflooritem(struct flooritem_data *, int); -int clif_clearchar(struct block_list *, BeingRemoveWhy); // area or fd -int clif_clearchar_delay(tick_t, struct block_list *, BeingRemoveWhy); +int clif_dropflooritem(dumb_ptr); +int clif_clearflooritem(dumb_ptr, int); +int clif_clearchar(dumb_ptr, BeingRemoveWhy); // area or fd +int clif_clearchar_delay(tick_t, dumb_ptr, BeingRemoveWhy); int clif_clearchar_id(int, BeingRemoveWhy, int); -int clif_spawnpc(struct map_session_data *); //area -int clif_spawnnpc(struct npc_data *); // area -int clif_spawn_fake_npc_for_player(struct map_session_data *sd, +int clif_spawnpc(dumb_ptr); //area +int clif_spawnnpc(dumb_ptr); // area +int clif_spawn_fake_npc_for_player(dumb_ptr sd, int fake_npc_id); -int clif_spawnmob(struct mob_data *); // area -int clif_walkok(struct map_session_data *); // self -int clif_movechar(struct map_session_data *); // area -int clif_movemob(struct mob_data *); //area -int clif_changemap(struct map_session_data *, const char *, int, int); //self -int clif_changemapserver(struct map_session_data *, const char *, int, int, struct in_addr, int); //self -int clif_fixpos(struct block_list *); // area -int clif_fixmobpos(struct mob_data *md); -int clif_fixpcpos(struct map_session_data *sd); -int clif_npcbuysell(struct map_session_data *, int); //self -int clif_buylist(struct map_session_data *, struct npc_data *); //self -int clif_selllist(struct map_session_data *); //self -int clif_scriptmes(struct map_session_data *, int, const char *); //self -int clif_scriptnext(struct map_session_data *, int); //self -int clif_scriptclose(struct map_session_data *, int); //self -int clif_scriptmenu(struct map_session_data *, int, const char *); //self -int clif_scriptinput(struct map_session_data *, int); //self -int clif_scriptinputstr(struct map_session_data *sd, int npcid); // self -int clif_cutin(struct map_session_data *, const char *, int); //self -int clif_viewpoint(struct map_session_data *, int, int, int, int, int, int); //self -int clif_additem(struct map_session_data *, int, int, PickupFail); //self -int clif_delitem(struct map_session_data *, int, int); //self -int clif_updatestatus(struct map_session_data *, SP); //self -int clif_damage(struct block_list *, struct block_list *, +int clif_spawnmob(dumb_ptr); // area +int clif_walkok(dumb_ptr); // self +int clif_movechar(dumb_ptr); // area +int clif_movemob(dumb_ptr); //area +int clif_changemap(dumb_ptr, const char *, int, int); //self +int clif_changemapserver(dumb_ptr, const char *, int, int, struct in_addr, int); //self +int clif_fixpos(dumb_ptr); // area +int clif_fixmobpos(dumb_ptr md); +int clif_fixpcpos(dumb_ptr sd); +int clif_npcbuysell(dumb_ptr, int); //self +int clif_buylist(dumb_ptr, dumb_ptr); //self +int clif_selllist(dumb_ptr); //self +int clif_scriptmes(dumb_ptr, int, const char *); //self +int clif_scriptnext(dumb_ptr, int); //self +int clif_scriptclose(dumb_ptr, int); //self +int clif_scriptmenu(dumb_ptr, int, const char *); //self +int clif_scriptinput(dumb_ptr, int); //self +int clif_scriptinputstr(dumb_ptr sd, int npcid); // self +int clif_cutin(dumb_ptr, const char *, int); //self +int clif_viewpoint(dumb_ptr, int, int, int, int, int, int); //self +int clif_additem(dumb_ptr, int, int, PickupFail); //self +int clif_delitem(dumb_ptr, int, int); //self +int clif_updatestatus(dumb_ptr, SP); //self +int clif_damage(dumb_ptr, dumb_ptr, tick_t, interval_t, interval_t, int, int, DamageType, int); // area inline -int clif_takeitem(struct block_list *src, struct block_list *dst) +int clif_takeitem(dumb_ptr src, dumb_ptr dst) { return clif_damage(src, dst, tick_t(), interval_t::zero(), interval_t::zero(), 0, 0, DamageType::TAKEITEM, 0); } -int clif_changelook(struct block_list *, LOOK, int); // area -void clif_changelook_accessories(struct block_list *bl, struct map_session_data *dst); // area or target; list gloves, boots etc. -int clif_arrowequip(struct map_session_data *sd, int val); //self -int clif_arrow_fail(struct map_session_data *sd, int type); //self -int clif_statusupack(struct map_session_data *, SP, int, int); // self -int clif_equipitemack(struct map_session_data *, int, EPOS, int); // self -int clif_unequipitemack(struct map_session_data *, int, EPOS, int); // self -int clif_misceffect(struct block_list *, int); // area -int clif_changeoption(struct block_list *); // area -int clif_useitemack(struct map_session_data *, int, int, int); // self - -void clif_emotion(struct block_list *bl, int type); -void clif_sitting(int fd, struct map_session_data *sd); +int clif_changelook(dumb_ptr, LOOK, int); // area +void clif_changelook_accessories(dumb_ptr bl, dumb_ptr dst); // area or target; list gloves, boots etc. +int clif_arrowequip(dumb_ptr sd, int val); //self +int clif_arrow_fail(dumb_ptr sd, int type); //self +int clif_statusupack(dumb_ptr, SP, int, int); // self +int clif_equipitemack(dumb_ptr, int, EPOS, int); // self +int clif_unequipitemack(dumb_ptr, int, EPOS, int); // self +int clif_misceffect(dumb_ptr, int); // area +int clif_changeoption(dumb_ptr); // area +int clif_useitemack(dumb_ptr, int, int, int); // self + +void clif_emotion(dumb_ptr bl, int type); +void clif_sitting(int fd, dumb_ptr sd); // trade -int clif_traderequest(struct map_session_data *sd, const char *name); -int clif_tradestart(struct map_session_data *sd, int type); -int clif_tradeadditem(struct map_session_data *sd, - struct map_session_data *tsd, int index, int amount); -int clif_tradeitemok(struct map_session_data *sd, int index, int amount, +int clif_traderequest(dumb_ptr sd, const char *name); +int clif_tradestart(dumb_ptr sd, int type); +int clif_tradeadditem(dumb_ptr sd, + dumb_ptr tsd, int index, int amount); +int clif_tradeitemok(dumb_ptr sd, int index, int amount, int fail); -int clif_tradedeal_lock(struct map_session_data *sd, int fail); -int clif_tradecancelled(struct map_session_data *sd); -int clif_tradecompleted(struct map_session_data *sd, int fail); +int clif_tradedeal_lock(dumb_ptr sd, int fail); +int clif_tradecancelled(dumb_ptr sd); +int clif_tradecompleted(dumb_ptr sd, int fail); // storage -int clif_storageitemlist(struct map_session_data *sd, struct storage *stor); -int clif_storageequiplist(struct map_session_data *sd, +int clif_storageitemlist(dumb_ptr sd, struct storage *stor); +int clif_storageequiplist(dumb_ptr sd, struct storage *stor); -int clif_updatestorageamount(struct map_session_data *sd, +int clif_updatestorageamount(dumb_ptr sd, struct storage *stor); -int clif_storageitemadded(struct map_session_data *sd, struct storage *stor, +int clif_storageitemadded(dumb_ptr sd, struct storage *stor, int index, int amount); -int clif_storageitemremoved(struct map_session_data *sd, int index, +int clif_storageitemremoved(dumb_ptr sd, int index, int amount); -int clif_storageclose(struct map_session_data *sd); +int clif_storageclose(dumb_ptr sd); // 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 *); +void clif_pcinsight(dumb_ptr, dumb_ptr); +void clif_pcoutsight(dumb_ptr, dumb_ptr); +void clif_mobinsight(dumb_ptr, dumb_ptr); +void clif_moboutsight(dumb_ptr, dumb_ptr); -int clif_skillinfo(struct map_session_data *sd, SkillID skillid, int type, +int clif_skillinfo(dumb_ptr sd, SkillID skillid, int type, int range); -int clif_skillinfoblock(struct map_session_data *sd); -int clif_skillup(struct map_session_data *sd, SkillID skill_num); +int clif_skillinfoblock(dumb_ptr sd); +int clif_skillup(dumb_ptr sd, SkillID skill_num); -int clif_skillcastcancel(struct block_list *bl); -int clif_skill_fail(struct map_session_data *sd, SkillID skill_id, int type, +int clif_skillcastcancel(dumb_ptr bl); +int clif_skill_fail(dumb_ptr sd, SkillID skill_id, int type, int btype); -int clif_skill_damage(struct block_list *src, struct block_list *dst, +int clif_skill_damage(dumb_ptr src, dumb_ptr dst, tick_t tick, interval_t sdelay, interval_t ddelay, int damage, int div, SkillID skill_id, int skill_lv, int type); -int clif_status_change(struct block_list *bl, +int clif_status_change(dumb_ptr bl, StatusChange type, int flag); int clif_wis_message(int fd, const char *nick, const char *mes, int mes_len); int clif_wis_end(int fd, int flag); -int clif_itemlist(struct map_session_data *sd); -int clif_equiplist(struct map_session_data *sd); +int clif_itemlist(dumb_ptr sd); +int clif_equiplist(dumb_ptr sd); -int clif_mvp_effect(struct map_session_data *sd); +int clif_mvp_effect(dumb_ptr sd); -int clif_movetoattack(struct map_session_data *sd, struct block_list *bl); +int clif_movetoattack(dumb_ptr sd, dumb_ptr bl); // party -int clif_party_created(struct map_session_data *sd, int flag); +int clif_party_created(dumb_ptr sd, int flag); int clif_party_info(struct party *p, int fd); -int clif_party_invite(struct map_session_data *sd, - struct map_session_data *tsd); -int clif_party_inviteack(struct map_session_data *sd, const char *nick, int flag); -int clif_party_option(struct party *p, struct map_session_data *sd, +int clif_party_invite(dumb_ptr sd, + dumb_ptr tsd); +int clif_party_inviteack(dumb_ptr sd, const char *nick, int flag); +int clif_party_option(struct party *p, dumb_ptr sd, int flag); -int clif_party_leaved(struct party *p, struct map_session_data *sd, +int clif_party_leaved(struct party *p, dumb_ptr sd, int account_id, const char *name, int flag); 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_hp(struct party *p, struct map_session_data *sd); +int clif_party_xy(struct party *p, dumb_ptr sd); +int clif_party_hp(struct party *p, dumb_ptr sd); // atcommand void clif_displaymessage(int fd, const_string mes); -void clif_GMmessage(struct block_list *bl, const_string mes, int flag); -int clif_resurrection(struct block_list *bl, int type); +void clif_GMmessage(dumb_ptr bl, const_string mes, int flag); +int clif_resurrection(dumb_ptr bl, int type); -int clif_specialeffect(struct block_list *bl, int type, int flag); // special effects [Valaris] -int clif_message(struct block_list *bl, const char *msg); // messages (from mobs/npcs) [Valaris] +int clif_specialeffect(dumb_ptr bl, int type, int flag); // special effects [Valaris] +int clif_message(dumb_ptr bl, const char *msg); // messages (from mobs/npcs) [Valaris] -int clif_GM_kick(struct map_session_data *sd, struct map_session_data *tsd, +int clif_GM_kick(dumb_ptr sd, dumb_ptr tsd, int type); -int clif_foreachclient(std::function); +int clif_foreachclient(std::function)>); int do_init_clif (void); diff --git a/src/map/intif.cpp b/src/map/intif.cpp index c5d3c90..53ff80e 100644 --- a/src/map/intif.cpp +++ b/src/map/intif.cpp @@ -47,7 +47,7 @@ void intif_GMmessage(const_string mes, int flag) } // The transmission of Wisp/Page to inter-server (player not found on this server) -int intif_wis_message(struct map_session_data *sd, const char *nick, const char *mes, +int intif_wis_message(dumb_ptr sd, const char *nick, const char *mes, int mes_len) { nullpo_ret(sd); @@ -100,7 +100,7 @@ int intif_wis_message_to_gm(const char *Wisp_name, int min_gm_level, const char } // アカウント変数送信 -int intif_saveaccountreg(struct map_session_data *sd) +int intif_saveaccountreg(dumb_ptr sd) { int j, p; @@ -119,7 +119,7 @@ int intif_saveaccountreg(struct map_session_data *sd) } // アカウント変数要求 -int intif_request_accountreg(struct map_session_data *sd) +int intif_request_accountreg(dumb_ptr sd) { nullpo_ret(sd); @@ -151,7 +151,7 @@ int intif_send_storage(struct storage *stor) } // パーティ作成要求 -int intif_create_party(struct map_session_data *sd, const char *name) +int intif_create_party(dumb_ptr sd, const char *name) { nullpo_ret(sd); @@ -181,7 +181,7 @@ int intif_request_partyinfo(int party_id) // パーティ追加要求 int intif_party_addmember(int party_id, int account_id) { - struct map_session_data *sd; + dumb_ptr sd; sd = map_id2sd(account_id); // if(battle_config.etc_log) // PRINTF("intif: party add member %d %d\n",party_id,account_id); @@ -223,7 +223,7 @@ int intif_party_leave(int party_id, int account_id) } // パーティ移動要求 -int intif_party_changemap(struct map_session_data *sd, int online) +int intif_party_changemap(dumb_ptr sd, int online) { if (sd != NULL) { @@ -272,7 +272,7 @@ int intif_party_checkconflict(int party_id, int account_id, const char *nick) static int intif_parse_WisMessage(int fd) { // rewritten by [Yor] - struct map_session_data *sd; + dumb_ptr sd; int i; if (battle_config.etc_log) @@ -316,7 +316,7 @@ int intif_parse_WisMessage(int fd) static int intif_parse_WisEnd(int fd) { - struct map_session_data *sd; + dumb_ptr sd; if (battle_config.etc_log) // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target @@ -354,7 +354,7 @@ int mapif_parse_WisToGM(int fd) { if (!session[i]) continue; - map_session_data *pl_sd = static_cast(session[i]->session_data.get()); + dumb_ptr pl_sd = dumb_ptr(static_cast(session[i]->session_data.get())); if (pl_sd && pl_sd->state.auth) if (pc_isGM(pl_sd) >= min_gm_level) clif_wis_message(i, Wisp_name, message, @@ -372,7 +372,7 @@ static int intif_parse_AccountReg(int fd) { int j, p; - struct map_session_data *sd; + dumb_ptr sd; if ((sd = map_id2sd(RFIFOL(fd, 4))) == NULL) return 1; @@ -393,7 +393,7 @@ static int intif_parse_LoadStorage(int fd) { struct storage *stor; - struct map_session_data *sd; + dumb_ptr sd; sd = map_id2sd(RFIFOL(fd, 4)); if (sd == NULL) diff --git a/src/map/intif.hpp b/src/map/intif.hpp index 25f69e3..766af59 100644 --- a/src/map/intif.hpp +++ b/src/map/intif.hpp @@ -3,28 +3,30 @@ #include "../common/const_array.hpp" +#include "map.hpp" + int intif_parse(int fd); void intif_GMmessage(const_string mes, int flag); -int intif_wis_message(struct map_session_data *sd, const char *nick, const char *mes, +int intif_wis_message(dumb_ptr sd, const char *nick, const char *mes, int mes_len); int intif_wis_message_to_gm(const char *Wisp_name, int min_gm_level, const char *mes, int mes_len); -int intif_saveaccountreg(struct map_session_data *sd); -int intif_request_accountreg(struct map_session_data *sd); +int intif_saveaccountreg(dumb_ptr sd); +int intif_request_accountreg(dumb_ptr sd); int intif_request_storage(int account_id); int intif_send_storage(struct storage *stor); -int intif_create_party(struct map_session_data *sd, const char *name); +int intif_create_party(dumb_ptr sd, const char *name); int intif_request_partyinfo(int party_id); int intif_party_addmember(int party_id, int account_id); int intif_party_changeoption(int party_id, int account_id, int exp, int item); int intif_party_leave(int party_id, int accound_id); -int intif_party_changemap(struct map_session_data *sd, int online); +int intif_party_changemap(dumb_ptr sd, int online); 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); diff --git a/src/map/magic-expr-eval.hpp b/src/map/magic-expr-eval.hpp index d61d397..bc5ce6e 100644 --- a/src/map/magic-expr-eval.hpp +++ b/src/map/magic-expr-eval.hpp @@ -16,7 +16,7 @@ void magic_area_rect(int *m, int *x, int *y, int *width, int *height, #define ARGINT(x) args[x].v.v_int #define ARGDIR(x) args[x].v.v_dir #define ARGSTR(x) args[x].v.v_string -#define ARGENTITY(x) args[x].v.v_entity +#define ARGENTITY(x) dumb_ptr(args[x].v.v_entity) #define ARGLOCATION(x) args[x].v.v_location #define ARGAREA(x) args[x].v.v_area #define ARGSPELL(x) args[x].v.v_spell @@ -34,9 +34,9 @@ void magic_area_rect(int *m, int *x, int *y, int *width, int *height, #define ARG_TYPE(x) args[x].ty #define ENTITY_TYPE(x) ARGENTITY(x)->bl_type -#define ARGPC(x) ((struct map_session_data *)ARGENTITY(x)) -#define ARGNPC(x) ((struct map_session_data *)ARGENTITY(x)) -#define ARGMOB(x) ((struct map_session_data *)ARGENTITY(x)) +#define ARGPC(x) (ARGENTITY(x)->as_player()) +#define ARGNPC(x) (ARGENTITY(x)->as_npc()) +#define ARGMOB(x) (ARGENTITY(x)->as_mob()) #define ARG_MAY_BE_AREA(x) (ARG_TYPE(x) == TYPE::AREA || ARG_TYPE(x) == TYPE::LOCATION) diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp index f25bf87..c0eaf9f 100644 --- a/src/map/magic-expr.cpp +++ b/src/map/magic-expr.cpp @@ -2,6 +2,7 @@ #include "magic-expr.hpp" #include "magic-interpreter-aux.hpp" +#include #include #include "../common/cxxstdio.hpp" @@ -86,21 +87,21 @@ void magic_clear_var(val_t *v) } static -const char *show_entity(entity_t *entity) +const char *show_entity(dumb_ptr entity) { switch (entity->bl_type) { case BL::PC: - return ((struct map_session_data *) entity)->status.name; + return entity->as_player()->status.name; case BL::NPC: - return ((struct npc_data *) entity)->name; + return entity->as_npc()->name; case BL::MOB: - return ((struct mob_data *) entity)->name; + return entity->as_mob()->name; case BL::ITEM: + assert (0 && "There is no way this code did what it was supposed to do!"); /* Sorry about this one... */ - return ((struct item_data - *) (&((struct flooritem_data *) entity)-> - item_data))->name; + // WTF? item_data is a struct item, not a struct item_data + // return ((struct item_data *) (&entity->as_item()->item_data))->name; case BL::SPELL: return "%invocation(ERROR:this-should-not-be-an-entity)"; default: @@ -138,7 +139,7 @@ void stringify(val_t *v, int within_op) break; case TYPE::ENTITY: - buf = show_entity(v->v.v_entity); + buf = show_entity(dumb_ptr(v->v.v_entity)); break; case TYPE::LOCATION: @@ -159,10 +160,10 @@ void stringify(val_t *v, int within_op) case TYPE::INVOCATION: { - invocation_t *invocation = within_op - ? v->v.v_invocation - : (invocation_t *) map_id2bl(v->v.v_int); - buf = invocation->spell->name; + dumb_ptr invocation_ = within_op + ? dumb_ptr(v->v.v_invocation) + : map_id2bl(v->v.v_int)->as_spell(); + buf = invocation_->spell->name; } break; @@ -239,7 +240,8 @@ void make_spell(val_t *v) { if (v->ty == TYPE::INVOCATION) { - invocation_t *invoc = v->v.v_invocation; //(invocation_t *) map_id2bl(v->v.v_int); + dumb_ptr invoc = dumb_ptr(v->v.v_invocation); + //invoc = (dumb_ptr) map_id2bl(v->v.v_int); if (!invoc) v->ty = TYPE::FAIL; else @@ -670,12 +672,12 @@ int fun_mob_id(env_t *, int, val_t *result, val_t *args) { if (ENTITY_TYPE(0) != BL::MOB) return 1; - RESULTINT = ((struct mob_data *)(ARGENTITY(0)))->mob_class; + RESULTINT = ARGMOB(0)->mob_class; return 0; } inline -void COPY_LOCATION(entity_t& dest, location_t& src) +void COPY_LOCATION(block_list& dest, location_t& src) { dest.bl_x = src.x; dest.bl_y = src.y; @@ -683,7 +685,7 @@ void COPY_LOCATION(entity_t& dest, location_t& src) } inline -void COPY_LOCATION(location_t& dest, entity_t& src) +void COPY_LOCATION(location_t& dest, block_list& src) { dest.x = src.bl_x; dest.y = src.bl_y; @@ -768,7 +770,7 @@ magic_find_item(val_t *args, int index, struct item *item, int *stackable) static int fun_count_item(env_t *, int, val_t *result, val_t *args) { - character_t *chr = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL; + dumb_ptr chr = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL; int stackable; struct item item; @@ -784,7 +786,7 @@ int fun_count_item(env_t *, int, val_t *result, val_t *args) static int fun_is_equipped(env_t *, int, val_t *result, val_t *args) { - character_t *chr = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL; + dumb_ptr chr = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL; int stackable; struct item item; bool retval = false; @@ -834,8 +836,7 @@ int fun_partner(env_t *, int, val_t *result, val_t *args) if (ENTITY_TYPE(0) == BL::PC && ARGPC(0)->status.partner_id) { RESULTENTITY = - (entity_t *) - map_nick2sd(map_charid2nick(ARGPC(0)->status.partner_id)); + map_nick2sd(map_charid2nick(ARGPC(0)->status.partner_id)).operator->(); return 0; } else @@ -871,14 +872,14 @@ int fun_failed(env_t *, int, 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)); + RESULTENTITY = npc_name2id(ARGSTR(0)).operator->(); return RESULTENTITY == NULL; } static int fun_pc(env_t *, int, val_t *result, val_t *args) { - RESULTENTITY = (entity_t *) map_nick2sd(ARGSTR(0)); + RESULTENTITY = map_nick2sd(ARGSTR(0)).operator->(); return RESULTENTITY == NULL; } @@ -930,12 +931,12 @@ int fun_anchor(env_t *env, int, 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; + block_list e1, e2; COPY_LOCATION(e1, ARGLOCATION(0)); COPY_LOCATION(e2, ARGLOCATION(1)); - RESULTINT = battle_check_range(&e1, &e2, 0); + RESULTINT = battle_check_range(dumb_ptr(&e1), dumb_ptr(&e2), 0); return 0; } @@ -992,13 +993,13 @@ int fun_pick_location(env_t *, int, 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); + dumb_ptr subject_p = ARGENTITY(0); char *var_name = ARGSTR(1); if (subject_p->bl_type != BL::PC) return 1; - RESULTINT = pc_readglobalreg((character_t *) subject_p, var_name); + RESULTINT = pc_readglobalreg(subject_p->as_player(), var_name); return 0; } @@ -1024,7 +1025,7 @@ int fun_running_status_update(env_t *, int, val_t *result, val_t *args) if (ENTITY_TYPE(0) != BL::PC && ENTITY_TYPE(0) != BL::MOB) return 1; - StatusChange sc = StatusChange(ARGINT(1)); + StatusChange sc = static_cast(ARGINT(1)); RESULTINT = bool(battle_get_sc_data(ARGENTITY(0))[sc].timer); return 0; } @@ -1032,9 +1033,7 @@ int fun_running_status_update(env_t *, int, val_t *result, val_t *args) static int fun_status_option(env_t *, int, val_t *result, val_t *args) { - RESULTINT = - (bool(((struct map_session_data *) ARGENTITY(0))-> - status.option & Option(ARGINT(0)))); + RESULTINT = (bool((ARGPC(0))->status.option & static_cast