From 8d50ad7f65c46d83b44c18249566a16c6d290496 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 25 Mar 2014 18:32:46 -0700 Subject: Mapflag to override savepoint (ported from wushin) --- src/map/atcommand.cpp | 16 ++++++++++++++-- src/map/clif.cpp | 15 ++++++++++++--- src/map/map.hpp | 1 + src/map/mapflag.cpp | 1 + src/map/mapflag.hpp | 2 +- src/map/mapflag.py | 1 + src/map/npc.cpp | 9 +++++++++ src/map/pc.cpp | 9 ++++++++- 8 files changed, 47 insertions(+), 7 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 5455671..cf71ff6 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -1056,8 +1056,17 @@ ATCE atcommand_load(Session *s, dumb_ptr sd, return ATCE::PERM; } - pc_setpos(sd, sd->status.save_point.map_, sd->status.save_point.x, - sd->status.save_point.y, BeingRemoveWhy::GONE); + // TODO deduplicate with clif_parse_Restart and pc_make_savestatus + if (sd->bl_m->flag.get(MapFlag::RESAVE)) + { + pc_setpos(sd, sd->bl_m->resave.map_, sd->bl_m->resave.x, + sd->bl_m->resave.y, BeingRemoveWhy::GONE); + } + else + { + pc_setpos(sd, sd->status.save_point.map_, sd->status.save_point.x, + sd->status.save_point.y, BeingRemoveWhy::GONE); + } clif_displaymessage(s, "Warping to respawn point."); return ATCE::OKAY; @@ -3452,6 +3461,9 @@ ATCE atcommand_mapinfo(Session *s, dumb_ptr sd, output = STRPRINTF("No Save: %s", (m_id->flag.get(MapFlag::NOSAVE)) ? "True" : "False"); clif_displaymessage(s, output); + output = STRPRINTF("Re Save: %s", + (m_id->flag.get(MapFlag::RESAVE)) ? "True" : "False"); + clif_displaymessage(s, output); output = STRPRINTF("No Teleport: %s", (m_id->flag.get(MapFlag::NOTELEPORT)) ? "True" : "False"); clif_displaymessage(s, output); diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 3ec41ae..a5b02cd 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -3905,9 +3905,18 @@ void clif_parse_Restart(Session *s, dumb_ptr sd) { pc_setstand(sd); pc_setrestartvalue(sd, 3); - pc_setpos(sd, sd->status.save_point.map_, - sd->status.save_point.x, sd->status.save_point.y, - BeingRemoveWhy::QUIT); + if (sd->bl_m->flag.get(MapFlag::RESAVE)) + { + pc_setpos(sd, sd->bl_m->resave.map_, + sd->bl_m->resave.x, sd->bl_m->resave.y, + BeingRemoveWhy::QUIT); + } + else + { + pc_setpos(sd, sd->status.save_point.map_, + sd->status.save_point.x, sd->status.save_point.y, + BeingRemoveWhy::QUIT); + } } break; case 0x01: diff --git a/src/map/map.hpp b/src/map/map.hpp index d476dbc..0f9f3d1 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -516,6 +516,7 @@ struct map_local : map_abstract int users; MapFlags flag; struct point save; + struct point resave; dumb_ptr npc[MAX_NPC_PER_MAP]; struct { diff --git a/src/map/mapflag.cpp b/src/map/mapflag.cpp index 0abcaa1..097f4d1 100644 --- a/src/map/mapflag.cpp +++ b/src/map/mapflag.cpp @@ -74,6 +74,7 @@ bool extract(XString str, MapFlag *mf) {"no_player_drops", MapFlag::NO_PLAYER_DROPS}, {"town", MapFlag::TOWN}, {"outside", MapFlag::OUTSIDE}, + {"resave", MapFlag::RESAVE}, }; for (auto& pair : flags) if (str == pair.str) diff --git a/src/map/mapflag.hpp b/src/map/mapflag.hpp index f3819ff..e3a55f5 100644 --- a/src/map/mapflag.hpp +++ b/src/map/mapflag.hpp @@ -62,7 +62,7 @@ enum class MapFlag TOWN = 1 << 28, OUTSIDE = 1 << 29, - //UNUSED2 = 1 << 30, + RESAVE = 1 << 30, //UNUSED3 = 1 << 31, }; diff --git a/src/map/mapflag.py b/src/map/mapflag.py index 90d73ba..3bc9f1a 100644 --- a/src/map/mapflag.py +++ b/src/map/mapflag.py @@ -42,6 +42,7 @@ class MapFlags(object): ('NO_PLAYER_DROPS', 27), ('TOWN', 28), ('OUTSIDE', 29), + ('RESAVE', 30), ]: v = 1 << v if i & v: diff --git a/src/map/npc.cpp b/src/map/npc.cpp index bfba45f..42ec4fa 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -1554,6 +1554,15 @@ int npc_parse_mapflag(XString w1, XString, XString w3, ZString w4) m->save.y = savey; } } + if (mf == MapFlag::RESAVE) + { + if (extract(w4, record<','>(&savemap, &savex, &savey))) + { + m->resave.map_ = savemap; + m->resave.x = savex; + m->resave.y = savey; + } + } m->flag.set(mf, true); return 0; diff --git a/src/map/pc.cpp b/src/map/pc.cpp index e3dd67a..10c2b22 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -416,7 +416,14 @@ void pc_makesavestatus(dumb_ptr sd) if (pc_isdead(sd)) { pc_setrestartvalue(sd, 0); - sd->status.last_point = sd->status.save_point; + if (sd->bl_m->flag.get(MapFlag::RESAVE)) + { + sd->status.last_point = sd->bl_m->resave; + } + else + { + sd->status.last_point = sd->status.save_point; + } } else { -- cgit v1.2.3-60-g2f50