From 4d89aa6e1c733618b720170a0979d895689b1d1e Mon Sep 17 00:00:00 2001 From: shennetsind Date: Fri, 12 Apr 2013 00:14:34 -0300 Subject: Hercules Renewal: Phase Two: Starting~! http://hercules.ws/board/topic/383-hercules-renewal-phase-two/ Signed-off-by: shennetsind --- src/map/Makefile.in | 2 +- src/map/atcommand.c | 7 +++- src/map/clif.c | 66 ++++++++++++++++++++++++------------ src/map/clif.h | 3 +- src/map/duel.c | 10 +++--- src/map/packets.h | 3 +- src/map/packets_struct.h | 52 ++++++++++++++++++++++++++++ src/map/script.c | 39 +++++++++++++++++++-- src/map/sql/CMakeLists.txt | 1 + vcproj-10/map-server.vcxproj | 1 + vcproj-10/map-server.vcxproj.filters | 3 ++ vcproj-12/map-server.vcxproj | 1 + vcproj-12/map-server.vcxproj.filters | 3 ++ vcproj-9/map-server.vcproj | 6 +++- 14 files changed, 162 insertions(+), 35 deletions(-) create mode 100644 src/map/packets_struct.h diff --git a/src/map/Makefile.in b/src/map/Makefile.in index a49a6edb4..78f5c42c4 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -27,7 +27,7 @@ MAP_H = map.h chrif.h clif.h pc.h status.h npc.h \ log.h mail.h date.h unit.h homunculus.h mercenary.h quest.h instance.h mapreg.h \ buyingstore.h searchstore.h duel.h pc_groups.h \ ../config/core.h ../config/renewal.h ../config/secure.h ../config/const.h \ - ../config/classes/general.h elemental.h packets.h + ../config/classes/general.h elemental.h packets.h packets_struct.h HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index f3e69ffb7..320613be1 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1550,8 +1550,10 @@ ACMD_FUNC(pvpoff) map_zone_change2(sd->bl.m,map[sd->bl.m].prev_zone); map[sd->bl.m].flag.pvp = 0; - if (!battle_config.pk_mode) + if (!battle_config.pk_mode) { clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); + clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); + } map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC); map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0); clif->message(fd, msg_txt(31)); // PvP: Off. @@ -1589,6 +1591,7 @@ ACMD_FUNC(pvpon) if (!battle_config.pk_mode) {// display pvp circle and rank clif->map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE); + clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC); } @@ -1612,6 +1615,7 @@ ACMD_FUNC(gvgoff) map_zone_change2(sd->bl.m,map[sd->bl.m].prev_zone); map[sd->bl.m].flag.gvg = 0; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); + clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0); clif->message(fd, msg_txt(33)); // GvG: Off. @@ -1633,6 +1637,7 @@ ACMD_FUNC(gvgon) map_zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); map[sd->bl.m].flag.gvg = 1; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE); + clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); clif->message(fd, msg_txt(34)); // GvG: On. return 0; diff --git a/src/map/clif.c b/src/map/clif.c index 27223a76e..208c5829f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -44,6 +44,7 @@ #include "clif.h" #include "mail.h" #include "quest.h" +#include "packets_struct.h" #include #include @@ -256,7 +257,7 @@ static inline unsigned char clif_bl_type(struct block_list *bl) { int clif_send_sub(struct block_list *bl, va_list ap) { struct block_list *src_bl; struct map_session_data *sd; - unsigned char *buf; + void *buf; int len, type, fd; nullpo_ret(bl); @@ -266,7 +267,7 @@ int clif_send_sub(struct block_list *bl, va_list ap) { if (!fd) //Don't send to disconnected clients. return 0; - buf = va_arg(ap,unsigned char*); + buf = va_arg(ap,void*); len = va_arg(ap,int); nullpo_ret(src_bl = va_arg(ap,struct block_list*)); type = va_arg(ap,int); @@ -319,7 +320,7 @@ int clif_send_sub(struct block_list *bl, va_list ap) { * Packet Delegation (called on all packets that require data to be sent to more than one client) * functions that are sent solely to one use whose ID it posses use WFIFOSET *------------------------------------------*/ -int clif_send(const uint8* buf, int len, struct block_list* bl, enum send_target type) { +int clif_send(const void* buf, int len, struct block_list* bl, enum send_target type) { int i; struct map_session_data *sd, *tsd; struct party_data *p = NULL; @@ -555,29 +556,26 @@ int clif_send(const uint8* buf, int len, struct block_list* bl, enum send_target return 0; } - /// Notifies the client, that it's connection attempt was accepted. /// 0073 .L .3B .B .B (ZC_ACCEPT_ENTER) /// 02eb .L .3B .B .B .W (ZC_ACCEPT_ENTER2) void clif_authok(struct map_session_data *sd) { -#if PACKETVER < 20080102 - const int cmd = 0x73; -#else - const int cmd = 0x2eb; -#endif - int fd = sd->fd; - - WFIFOHEAD(fd,packet_len(cmd)); - WFIFOW(fd, 0) = cmd; - WFIFOL(fd, 2) = gettick(); - WFIFOPOS(fd, 6, sd->bl.x, sd->bl.y, sd->ud.dir); - WFIFOB(fd, 9) = 5; // ignored - WFIFOB(fd,10) = 5; // ignored + struct packet_authok p; + + p.PacketType = authokType; + p.startTime = gettick(); + p.PosDir[0] = sd->bl.x; + p.PosDir[1] = sd->bl.y; + p.PosDir[2] = sd->ud.dir; + WBUFPOS(&p.PosDir[0],0,sd->bl.x,sd->bl.y,sd->ud.dir); /* do the stupid client math */ + p.xSize = p.ySize = 5; /* not-used */ + #if PACKETVER >= 20080102 - WFIFOW(fd,11) = sd->user_font; // FIXME: Font is currently not saved. + p.font = sd->user_font; // FIXME: Font is currently not saved. #endif - WFIFOSET(fd,packet_len(cmd)); + + clif->send(&p,sizeof(p),&sd->bl,SELF); } @@ -5580,7 +5578,7 @@ void clif_map_property(struct map_session_data* sd, enum map_property property) int fd; nullpo_retv(sd); - + fd=sd->fd; WFIFOHEAD(fd,packet_len(0x199)); WFIFOW(fd,0)=0x199; @@ -5642,7 +5640,7 @@ void clif_map_property_mapall(int map, enum map_property property) { struct block_list bl; unsigned char buf[16]; - + bl.id = 0; bl.type = BL_NUL; bl.m = map; @@ -9162,7 +9160,6 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) if( map_flag_gvg(sd->bl.m) ) clif->map_property(sd, MAPPROPERTY_AGITZONE); - // info about nearby objects // must use foreachinarea (CIRCULAR_AREA interferes with foreachinrange) map_foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd); @@ -9320,6 +9317,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) mail_clear(sd); + clif->maptypeproperty2(&sd->bl,SELF); + /* Guild Aura Init */ if( sd->state.gmaster_flag ) { guild_guildaura_refresh(sd,GD_LEADERSHIP,guild_checkskill(sd->state.gmaster_flag,GD_LEADERSHIP)); @@ -16577,6 +16576,28 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) { } } +/* [Ind/Hercules] */ +void clif_maptypeproperty2(struct block_list *bl,enum send_target t) { +#if PACKETVER >= 20130000 /* not entirely sure when this started */ + struct packet_maptypeproperty2 p; + + p.PacketType = maptypeproperty2Type; + p.type = 0x28; + p.flag.usecart = 1; + p.flag.party = 1; + p.flag.guild = 1; + p.flag.siege = map_flag_gvg2(bl->m) ? 1: 0; + p.flag.mineffect = 1; + p.flag.nolockon = 0; + p.flag.countpk = map[bl->m].flag.pvp ? 1 : 0; + p.flag.nopartyformation = 0; + p.flag.noitemconsumption = 0; + p.flag.summonstarmiracle = 0; + p.flag.bg = map[bl->m].flag.battleground ? 1 : 0; + + clif->send(&p,sizeof(p),bl,t); +#endif +} /*========================================== * Main client packet processing function *------------------------------------------*/ @@ -16882,6 +16903,7 @@ void clif_defaults(void) { clif->map_property_mapall = clif_map_property_mapall; clif->bossmapinfo = clif_bossmapinfo; clif->map_type = clif_map_type; + clif->maptypeproperty2 = clif_maptypeproperty2; /* multi-map-server */ clif->changemapserver = clif_changemapserver; /* npc-shop-related */ diff --git a/src/map/clif.h b/src/map/clif.h index 616af8d7e..89a330a90 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -438,7 +438,7 @@ struct clif_interface { void (*setbindip) (const char* ip); void (*setport) (uint16 port); uint32 (*refresh_ip) (void); - int (*send) (const uint8* buf, int len, struct block_list* bl, enum send_target type); + int (*send) (const void* buf, int len, struct block_list* bl, enum send_target type); int (*send_sub) (struct block_list *bl, va_list ap); int (*parse) (int fd); /* auth */ @@ -501,6 +501,7 @@ struct clif_interface { void (*map_property_mapall) (int map, enum map_property property); void (*bossmapinfo) (int fd, struct mob_data *md, short flag); void (*map_type) (struct map_session_data* sd, enum map_type type); + void (*maptypeproperty2) (struct block_list *bl,enum send_target t); /* multi-map-server */ void (*changemapserver) (struct map_session_data* sd, unsigned short map_index, int x, int y, uint32 ip, uint16 port); /* npc-shop-related */ diff --git a/src/map/duel.c b/src/map/duel.c index 1c659bd33..7af427304 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" @@ -95,7 +96,7 @@ int duel_create(struct map_session_data* sd, const unsigned int maxpl) clif->disp_onlyself(sd, output, strlen(output)); clif->map_property(sd, MAPPROPERTY_FREEPVPZONE); - //clif->misceffect2(&sd->bl, 159); + clif->maptypeproperty2(&sd->bl,SELF); return i; } @@ -141,6 +142,7 @@ void duel_leave(const unsigned int did, struct map_session_data* sd) sd->duel_group = 0; duel_savetime(sd); clif->map_property(sd, MAPPROPERTY_NOTHING); + clif->maptypeproperty2(&sd->bl,SELF); } void duel_accept(const unsigned int did, struct map_session_data* sd) @@ -157,7 +159,7 @@ void duel_accept(const unsigned int did, struct map_session_data* sd) clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS); clif->map_property(sd, MAPPROPERTY_FREEPVPZONE); - //clif->misceffect2(&sd->bl, 159); + clif->maptypeproperty2(&sd->bl,SELF); } void duel_reject(const unsigned int did, struct map_session_data* sd) diff --git a/src/map/packets.h b/src/map/packets.h index 29181d392..09e035413 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -2045,9 +2045,7 @@ packet(0x020d,-1); packet(0x094C,6,clif->pSolveCharName,2); packet(0x0907,5,clif->pMoveItem,2,4); packet(0x0908,5); - packet(0x08CF,10); //Amulet spirits packet(0x08d2,10); - packet(0x0977,14); //Monster HP Bar packet(0x0998,8,clif->pEquipItem,2,4); //packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8); packet(0x0938,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); @@ -2061,6 +2059,7 @@ packet(0x020d,-1); packet(0x084a,2,clif->pCashShopClose,0);/* tell server cashshop window is being closed */ packet(0x08c9,4,clif->pCashShopSchedule,0); packet(0x0848,-1,clif->pCashShopBuy,0); + packet(0x0447,2); #endif #endif /* _PACKETS_H_ */ diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h new file mode 100644 index 000000000..9a872926f --- /dev/null +++ b/src/map/packets_struct.h @@ -0,0 +1,52 @@ +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file + +/* Hercules Renewal: Phase Two http://hercules.ws/board/topic/383-hercules-renewal-phase-two/ */ + +#ifndef _PACKETS_STRUCT_H_ +#define _PACKETS_STRUCT_H_ + +enum packet_headers { +#if PACKETVER < 20080102 + authokType = 0x73, +#else + authokType = 0x2eb, +#endif + maptypeproperty2Type = 0x99b, +}; + +#pragma pack(push, 1) + +struct packet_authok { + short PacketType; + unsigned int startTime; + char PosDir[3]; + unsigned char xSize; + unsigned char ySize; +#if PACKETVER >= 20080102 + short font; +#endif +} __attribute__((packed)); + +struct packet_maptypeproperty2 { + short PacketType; + short type; + struct { + unsigned int party : 1; + unsigned int guild : 1; + unsigned int siege : 1; + unsigned int mineffect : 1; + unsigned int nolockon : 1; + unsigned int countpk : 1; + unsigned int nopartyformation : 1; + unsigned int bg : 1; + unsigned int noitemconsumption : 1; + unsigned int usecart : 1; + unsigned int summonstarmiracle : 1; + unsigned int SpareBits : 15; + } flag; +} __attribute__((packed)); + +#pragma pack(pop) + +#endif /* _PACKETS_STRUCT_H_ */ diff --git a/src/map/script.c b/src/map/script.c index 4ba5cc669..648a8940f 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -10769,6 +10769,7 @@ static int script_mapflag_pvp_sub(struct block_list *bl,va_list ap) { sd->pvp_lost = 0; } clif->map_property(sd, MAPPROPERTY_FREEPVPZONE); + clif->maptypeproperty2(&sd->bl,SELF); return 0; } BUILDIN_FUNC(setmapflag) @@ -10811,9 +10812,14 @@ BUILDIN_FUNC(setmapflag) break; case MF_PVP_NOPARTY: map[m].flag.pvp_noparty = 1; break; case MF_PVP_NOGUILD: map[m].flag.pvp_noguild = 1; break; - case MF_GVG: + case MF_GVG: { + struct block_list bl; map[m].flag.gvg = 1; clif->map_property_mapall(m, MAPPROPERTY_AGITZONE); + bl.type = BL_NUL; + bl.m = m; + clif->maptypeproperty2(&bl,ALL_SAMEMAP); + } break; case MF_GVG_NOPARTY: map[m].flag.gvg_noparty = 1; break; case MF_NOTRADE: map[m].flag.notrade = 1; break; @@ -10893,15 +10899,25 @@ BUILDIN_FUNC(removemapflag) case MF_NOBRANCH: map[m].flag.nobranch = 0; break; case MF_NOPENALTY: map[m].flag.noexppenalty = 0; map[m].flag.nozenypenalty = 0; break; case MF_NOZENYPENALTY: map[m].flag.nozenypenalty = 0; break; - case MF_PVP: + case MF_PVP: { + struct block_list bl; + bl.type = BL_NUL; + bl.m = m; map[m].flag.pvp = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); + clif->maptypeproperty2(&bl,ALL_SAMEMAP); + } break; case MF_PVP_NOPARTY: map[m].flag.pvp_noparty = 0; break; case MF_PVP_NOGUILD: map[m].flag.pvp_noguild = 0; break; - case MF_GVG: + case MF_GVG: { + struct block_list bl; + bl.type = BL_NUL; + bl.m = m; map[m].flag.gvg = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); + clif->maptypeproperty2(&bl,ALL_SAMEMAP); + } break; case MF_GVG_NOPARTY: map[m].flag.gvg_noparty = 0; break; case MF_NOTRADE: map[m].flag.notrade = 0; break; @@ -10958,6 +10974,7 @@ BUILDIN_FUNC(pvpon) const char *str; TBL_PC* sd = NULL; struct s_mapiterator* iter; + struct block_list bl; str = script_getstr(st,2); m = map_mapname2mapid(str); @@ -10967,6 +10984,10 @@ BUILDIN_FUNC(pvpon) map_zone_change2(m, strdb_get(zone_db, MAP_ZONE_PVP_NAME)); map[m].flag.pvp = 1; clif->map_property_mapall(m, MAPPROPERTY_FREEPVPZONE); + bl.type = BL_NUL; + bl.m = m; + clif->maptypeproperty2(&bl,ALL_SAMEMAP); + if(battle_config.pk_mode) // disable ranking functions if pk_mode is on [Valaris] return 0; @@ -11004,6 +11025,7 @@ BUILDIN_FUNC(pvpoff) { int16 m; const char *str; + struct block_list bl; str=script_getstr(st,2); m = map_mapname2mapid(str); @@ -11013,6 +11035,9 @@ BUILDIN_FUNC(pvpoff) map_zone_change2(m, map[m].prev_zone); map[m].flag.pvp = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); + bl.type = BL_NUL; + bl.m = m; + clif->maptypeproperty2(&bl,ALL_SAMEMAP); if(battle_config.pk_mode) // disable ranking options if pk_mode is on [Valaris] return 0; @@ -11029,9 +11054,13 @@ BUILDIN_FUNC(gvgon) str=script_getstr(st,2); m = map_mapname2mapid(str); if(m >= 0 && !map[m].flag.gvg) { + struct block_list bl; map_zone_change2(m, strdb_get(zone_db, MAP_ZONE_GVG_NAME)); map[m].flag.gvg = 1; clif->map_property_mapall(m, MAPPROPERTY_AGITZONE); + bl.type = BL_NUL; + bl.m = m; + clif->maptypeproperty2(&bl,ALL_SAMEMAP); } return 0; @@ -11044,9 +11073,13 @@ BUILDIN_FUNC(gvgoff) str=script_getstr(st,2); m = map_mapname2mapid(str); if(m >= 0 && map[m].flag.gvg) { + struct block_list bl; map_zone_change2(m, map[m].prev_zone); map[m].flag.gvg = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); + bl.type = BL_NUL; + bl.m = m; + clif->maptypeproperty2(&bl,ALL_SAMEMAP); } return 0; diff --git a/src/map/sql/CMakeLists.txt b/src/map/sql/CMakeLists.txt index 2efeabd02..fc2653974 100644 --- a/src/map/sql/CMakeLists.txt +++ b/src/map/sql/CMakeLists.txt @@ -28,6 +28,7 @@ set( SQL_MAP_HEADERS "${SQL_MAP_SOURCE_DIR}/mob.h" "${SQL_MAP_SOURCE_DIR}/npc.h" "${SQL_MAP_SOURCE_DIR}/packets.h" + "${SQL_MAP_SOURCE_DIR}/packets_struct.h" "${SQL_MAP_SOURCE_DIR}/party.h" "${SQL_MAP_SOURCE_DIR}/path.h" "${SQL_MAP_SOURCE_DIR}/pc.h" diff --git a/vcproj-10/map-server.vcxproj b/vcproj-10/map-server.vcxproj index 4f51870e8..a63043a0b 100644 --- a/vcproj-10/map-server.vcxproj +++ b/vcproj-10/map-server.vcxproj @@ -182,6 +182,7 @@ + diff --git a/vcproj-10/map-server.vcxproj.filters b/vcproj-10/map-server.vcxproj.filters index 82bbcbc09..60ff487a4 100644 --- a/vcproj-10/map-server.vcxproj.filters +++ b/vcproj-10/map-server.vcxproj.filters @@ -267,6 +267,9 @@ map_sql + + map_sql + map_sql diff --git a/vcproj-12/map-server.vcxproj b/vcproj-12/map-server.vcxproj index 4acdf7d87..e0ab20202 100644 --- a/vcproj-12/map-server.vcxproj +++ b/vcproj-12/map-server.vcxproj @@ -186,6 +186,7 @@ + diff --git a/vcproj-12/map-server.vcxproj.filters b/vcproj-12/map-server.vcxproj.filters index 82bbcbc09..60ff487a4 100644 --- a/vcproj-12/map-server.vcxproj.filters +++ b/vcproj-12/map-server.vcxproj.filters @@ -267,6 +267,9 @@ map_sql + + map_sql + map_sql diff --git a/vcproj-9/map-server.vcproj b/vcproj-9/map-server.vcproj index 234908427..75562e335 100644 --- a/vcproj-9/map-server.vcproj +++ b/vcproj-9/map-server.vcproj @@ -658,7 +658,11 @@ - + + + -- cgit v1.2.3-70-g09d2