summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorAsheraf <acheraf1998@gmail.com>2018-03-24 21:41:05 +0000
committerAsheraf <acheraf1998@gmail.com>2018-05-04 16:11:52 +0100
commit394e7f8752ae7c80786e202c8b859488db1af363 (patch)
tree3a329478e75881cba950165454b1f402fe38f171 /src/map
parentd6785d389cbee4f34078f6762626ca61b2d6cc25 (diff)
downloadhercules-394e7f8752ae7c80786e202c8b859488db1af363.tar.gz
hercules-394e7f8752ae7c80786e202c8b859488db1af363.tar.bz2
hercules-394e7f8752ae7c80786e202c8b859488db1af363.tar.xz
hercules-394e7f8752ae7c80786e202c8b859488db1af363.zip
Implementation of Private AirShip
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c4
-rw-r--r--src/map/clif.c45
-rw-r--r--src/map/clif.h14
-rw-r--r--src/map/map.h2
-rw-r--r--src/map/npc.c4
-rw-r--r--src/map/packets.h2
-rw-r--r--src/map/packets_struct.h11
-rw-r--r--src/map/script.c32
-rw-r--r--src/map/script.h4
9 files changed, 115 insertions, 3 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 9deed0098..017b9ddf0 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -3956,6 +3956,10 @@ ACMD(mapinfo)
strcat(atcmd_output, msg_fd(fd, 1063)); // NoAutoloot |
if (map->list[m_id].flag.noviewid != EQP_NONE)
strcat(atcmd_output, msg_fd(fd,1079)); // NoViewID |
+ if (map->list[m_id].flag.pairship_startable)
+ strcat(atcmd_output, msg_fd(fd, 1292)); // PrivateAirshipStartable |
+ if (map->list[m_id].flag.pairship_endable)
+ strcat(atcmd_output, msg_fd(fd, 1293)); // PrivateAirshipEndable |
clif->message(fd, atcmd_output);
switch (list) {
diff --git a/src/map/clif.c b/src/map/clif.c
index 47d5a1586..677a8d8b9 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -20610,6 +20610,49 @@ void clif_ui_action(struct map_session_data *sd, int32 UIType, int32 data)
clif->send(&p, sizeof(p), &sd->bl, SELF);
}
+
+void clif_parse_private_airship_request(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
+void clif_parse_private_airship_request(int fd, struct map_session_data *sd)
+{
+#if defined(PACKETVER_RE) && PACKETVER >= 20180321
+ char evname[EVENT_NAME_LENGTH];
+ struct event_data *ev = NULL;
+ const struct PACKET_CZ_PRIVATE_AIRSHIP_REQUEST *p = RP2PTR(fd);
+
+ safestrncpy(evname, "private_airship::OnAirShipRequest", EVENT_NAME_LENGTH);
+ if ((ev = strdb_get(npc->ev_db, evname))) {
+ pc->setregstr(sd, script->add_str("@mapname$"), p->mapName);
+ pc->setreg(sd, script->add_str("@itemid"), p->ItemID);
+ script->run_npc(ev->nd->u.scr.script, ev->pos, sd->bl.id, ev->nd->bl.id);
+ } else {
+ ShowError("clif_parse_private_airship_request: event '%s' not found, operation failed\n", evname);
+ }
+#else
+ ShowWarning("clif_parse_private_airship_request: private airship is not supported in this client version, possible packet manipulation.");
+#endif
+}
+
+void clif_private_airship_response(struct map_session_data *sd, uint32 flag)
+{
+#if defined(PACKETVER_RE) && PACKETVER >= 20180321
+ struct PACKET_ZC_PRIVATE_AIRSHIP_RESPONSE p;
+
+ nullpo_retv(sd);
+
+ if (flag > P_AIRSHIP_ITEM_INVALID) {
+ ShowError("clif_private_airship_response: invalid flag given '%d', defaulting to 0.\n", flag);
+ flag = 0;
+ }
+
+ p.PacketType = 0xA4A;
+ p.flag = flag;
+
+ clif->send(&p, sizeof(p), &sd->bl, SELF);
+#else
+ ShowWarning("clif_private_airship_response: private airship works only for clients >= 20180321.");
+#endif
+}
+
/*==========================================
* Main client packet processing function
*------------------------------------------*/
@@ -21715,4 +21758,6 @@ void clif_defaults(void) {
clif->open_ui = clif_open_ui;
clif->pAttendanceRewardRequest = clif_parse_attendance_reward_request;
clif->ui_action = clif_ui_action;
+ clif->pPrivateAirshipRequest = clif_parse_private_airship_request;
+ clif->PrivateAirshipResponse = clif_private_airship_response;
}
diff --git a/src/map/clif.h b/src/map/clif.h
index f0eaaf6eb..23b335376 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -589,6 +589,18 @@ enum ui_types {
ATTENDANCE_UI
};
/**
+* Private Airship Responds
+**/
+enum private_airship {
+ P_AIRSHIP_NONE,
+ P_AIRSHIP_RETRY,
+ P_AIRSHIP_INVALID_START_MAP,
+ P_AIRSHIP_INVALID_END_MAP,
+ P_AIRSHIP_ITEM_NOT_ENOUGH,
+ P_AIRSHIP_ITEM_INVALID
+};
+
+/**
* Structures
**/
typedef void (*pFunc)(int, struct map_session_data *); //cant help but put it first
@@ -1450,6 +1462,8 @@ struct clif_interface {
void (*open_ui) (struct map_session_data *sd, int8 UIType);
void (*pAttendanceRewardRequest) (int fd, struct map_session_data *sd);
void (*ui_action) (struct map_session_data *sd, int32 UIType, int32 data);
+ void (*pPrivateAirshipRequest) (int fd, struct map_session_data *sd);
+ void (*PrivateAirshipResponse) (struct map_session_data *sd, uint32 flag);
};
#ifdef HERCULES_CORE
diff --git a/src/map/map.h b/src/map/map.h
index d6afdc160..f90bdb89a 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -857,6 +857,8 @@ struct map_data {
unsigned notomb : 1;
unsigned nocashshop : 1;
unsigned noautoloot : 1;
+ unsigned pairship_startable : 1;
+ unsigned pairship_endable : 1;
uint32 noviewid; ///< noviewid (bitmask - @see enum equip_pos)
} flag;
struct point save;
diff --git a/src/map/npc.c b/src/map/npc.c
index 94ab57bd9..d361f2e90 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -4517,6 +4517,10 @@ const char *npc_parse_mapflag(const char *w1, const char *w2, const char *w3, co
map->list[m].flag.nocashshop = (state) ? 1 : 0;
} else if (!strcmpi(w3,"noviewid")) {
map->list[m].flag.noviewid = (state) ? atoi(w4) : 0;
+ } else if (!strcmpi(w3, "pairship_startable")) {
+ map->list[m].flag.pairship_startable = (state) ? 1 : 0;
+ } else if (!strcmpi(w3, "pairship_endable")) {
+ map->list[m].flag.pairship_endable = (state) ? 1 : 0;
} else {
npc->parse_unknown_mapflag(mapname, w3, w4, start, buffer, filepath, retval);
}
diff --git a/src/map/packets.h b/src/map/packets.h
index a723463b4..9e6d7161a 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -3823,7 +3823,7 @@ packet(0x96e,-1,clif->ackmergeitems);
// changed packet sizes
packet(0x006d,157); // HC_ACCEPT_MAKECHAR
packet(0x08e3,157); // HC_UPDATE_CHARINFO
- packet(0x0a49,20);
+ packet(0x0a49, 20, clif->pPrivateAirshipRequest);
#endif
// 2017-09-06cRagexeRE
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index 5b9a4344a..cae794e92 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -1729,6 +1729,17 @@ struct PACKET_ZC_UI_ACTION {
int32 data;
} __attribute__((packed));
+struct PACKET_CZ_PRIVATE_AIRSHIP_REQUEST {
+ int16 PacketType;
+ char mapName[MAP_NAME_LENGTH_EXT];
+ uint16 ItemID;
+} __attribute__((packed));
+
+struct PACKET_ZC_PRIVATE_AIRSHIP_RESPONSE {
+ int16 PacketType;
+ uint32 flag;
+} __attribute__((packed));
+
#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
#pragma pack(pop)
#endif // not NetBSD < 6 / Solaris
diff --git a/src/map/script.c b/src/map/script.c
index 93c39f2bc..67dd4214c 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -12937,7 +12937,9 @@ BUILDIN(getmapflag)
case MF_NOTOMB: script_pushint(st,map->list[m].flag.notomb); break;
case MF_NOCASHSHOP: script_pushint(st,map->list[m].flag.nocashshop); break;
case MF_NOAUTOLOOT: script_pushint(st, map->list[m].flag.noautoloot); break;
- case MF_NOVIEWID: script_pushint(st,map->list[m].flag.noviewid); break;
+ case MF_NOVIEWID: script_pushint(st, map->list[m].flag.noviewid); break;
+ case MF_PAIRSHIP_STARTABLE: script_pushint(st, map->list[m].flag.pairship_startable); break;
+ case MF_PAIRSHIP_ENDABLE: script_pushint(st, map->list[m].flag.pairship_endable); break;
}
}
@@ -13063,6 +13065,8 @@ BUILDIN(setmapflag) {
case MF_NOCASHSHOP: map->list[m].flag.nocashshop = 1; break;
case MF_NOAUTOLOOT: map->list[m].flag.noautoloot = 1; break;
case MF_NOVIEWID: map->list[m].flag.noviewid = (val <= 0) ? EQP_NONE : val; break;
+ case MF_PAIRSHIP_STARTABLE: map->list[m].flag.pairship_startable = 1; break;
+ case MF_PAIRSHIP_ENDABLE: map->list[m].flag.pairship_endable = 1; break;
}
}
@@ -23970,6 +23974,23 @@ BUILDIN(clan_master)
return true;
}
+BUILDIN(airship_respond)
+{
+ struct map_session_data *sd = map->id2sd(st->rid);
+ int32 flag = script_getnum(st, 2);
+
+ if (sd == NULL)
+ return false;
+
+ if (flag < P_AIRSHIP_NONE || flag > P_AIRSHIP_ITEM_INVALID) {
+ ShowWarning("buildin_airship_respond: invalid flag %d has been given.", flag);
+ return false;
+ }
+
+ clif->PrivateAirshipResponse(sd, flag);
+ return true;
+}
+
/**
* hateffect(EffectID, Enable_State)
*/
@@ -24719,6 +24740,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF2(rodex_sendmail, "rodex_sendmail_acc", "isss???????????"),
BUILDIN_DEF(rodex_sendmail2, "isss?????????????????????????????????????????"),
BUILDIN_DEF2(rodex_sendmail2, "rodex_sendmail_acc2", "isss?????????????????????????????????????????"),
+ BUILDIN_DEF(airship_respond, "i"),
BUILDIN_DEF(_,"s"),
BUILDIN_DEF2(_, "_$", "s"),
@@ -25094,6 +25116,14 @@ void script_hardcoded_constants(void)
script->set_constant("MST_AROUND4", MST_AROUND4, false, false);
script->set_constant("MST_AROUND", MST_AROUND , false, false);
+ script->constdb_comment("private airship responds");
+ script->set_constant("P_AIRSHIP_NONE", P_AIRSHIP_NONE, false, false);
+ script->set_constant("P_AIRSHIP_RETRY", P_AIRSHIP_RETRY, false, false);
+ script->set_constant("P_AIRSHIP_INVALID_START_MAP", P_AIRSHIP_INVALID_START_MAP, false, false);
+ script->set_constant("P_AIRSHIP_INVALID_END_MAP", P_AIRSHIP_INVALID_END_MAP, false, false);
+ script->set_constant("P_AIRSHIP_ITEM_NOT_ENOUGH", P_AIRSHIP_ITEM_NOT_ENOUGH, false, false);
+ script->set_constant("P_AIRSHIP_ITEM_INVALID", P_AIRSHIP_ITEM_INVALID, false, false);
+
script->constdb_comment("Renewal");
#ifdef RENEWAL
script->set_constant("RENEWAL", 1, false, false);
diff --git a/src/map/script.h b/src/map/script.h
index ede786481..0eaf5c539 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -337,7 +337,9 @@ enum {
MF_NOTOMB,
MF_NOCASHSHOP,
MF_NOAUTOLOOT,
- MF_NOVIEWID
+ MF_NOVIEWID,
+ MF_PAIRSHIP_STARTABLE,
+ MF_PAIRSHIP_ENDABLE
};
enum navigation_service {