Skip to content

Commit

Permalink
Hercules Renewal: Phase Two: Starting~!
Browse files Browse the repository at this point in the history
  • Loading branch information
shennetsind committed Apr 12, 2013
1 parent 57b5943 commit 4d89aa6
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/map/Makefile.in
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion src/map/atcommand.c
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}

Expand All @@ -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.

Expand All @@ -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;
Expand Down
66 changes: 44 additions & 22 deletions src/map/clif.c
Expand Up @@ -44,6 +44,7 @@
#include "clif.h"
#include "mail.h"
#include "quest.h"
#include "packets_struct.h"

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 <start time>.L <position>.3B <x size>.B <y size>.B (ZC_ACCEPT_ENTER)
/// 02eb <start time>.L <position>.3B <x size>.B <y size>.B <font>.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);
}


Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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
*------------------------------------------*/
Expand Down Expand Up @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion src/map/clif.h
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
10 changes: 6 additions & 4 deletions 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"

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/map/packets.h
Expand Up @@ -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);
Expand All @@ -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_ */
52 changes: 52 additions & 0 deletions 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_ */

0 comments on commit 4d89aa6

Please sign in to comment.