Ind 945 Posted April 11, 2013 (edited) Hercules Renewal: Phase TwoHello~! - What?! "but phase one isn't complete yet!"its alright, we have been able to manage parallel projects and goals, we surely can take care of this one too and effort required on this one is pretty much less than on phase one "So whats this phase two about?"one of my favorite things: user friendliness Goal: user-friendliness This aims at rewriting all of our server-client packet building, making it much more user friendly to modify and add new ones. We'll be starting with map server <- -> client (clif.c) and then will move to char server <- -> client and later login server <- -> client Before 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 #if PACKETVER >= 20080102 WFIFOW(fd,11) = sd->user_font; #endif WFIFOSET(fd,packet_len(cmd)); } After void clif_authok(struct map_session_data *sd) { struct packet_authok pack; pack.PacketType = authokType; pack.startTime = gettick(); pack.PosDir[0] = sd->bl.x; pack.PosDir[1] = sd->bl.y; pack.PosDir[2] = sd->ud.dir; pack.xSize = 5; //not used pack.ySize = 5; //not used #if PACKETVER >= 20080102 pack.font = sd->user_font; #endif clif->send(pack,sd->fd,blabla,SELF); } Special Thanks To Yommy for bringing this up! Edited February 7, 2017 by Ridley 3 jaBote, JulioCF and rafoka reacted to this Quote Share this post Link to post Share on other sites
Ryuuzaki 9 Posted April 11, 2013 Very nice, makes screwing with packets a lot easier and faster : P 1 Judas reacted to this Quote Share this post Link to post Share on other sites
jaBote 438 Posted April 11, 2013 I'm looking forward to it. God knows I suck in source, so this could be my opportunity to learn to code some things there. Quote Share this post Link to post Share on other sites
Ind 945 Posted April 12, 2013 Let the fun begin o/ https://github.com/HerculesWS/Hercules/commit/4d89aa6e1c733618b720170a0979d895689b1d1e 1 goddameit reacted to this Quote Share this post Link to post Share on other sites
Beret 50 Posted April 13, 2013 Change is good, most still prefer the old way, why? In my view it is more easy to understand and most of those who work with the emulator is already accustomed to the old mode. Quote Share this post Link to post Share on other sites
JayPee 17 Posted April 13, 2013 Change is good, most still prefer the old way, why? In my view it is more easy to understand and most of those who work with the emulator is already accustomed to the old mode. Well it's up to them if they want to adapt changes. Quote Share this post Link to post Share on other sites
Beret 50 Posted April 13, 2013 Things aren't so they adapt to change. Ex: Have an emulator that works in the way that I know, another works differently modified, which I use, the logic is what I do know work. This does not mean that the emulator does not need to suffer modifications, on the contrary, what ind made so far look great, more my point of view about packages is different. Quote Share this post Link to post Share on other sites
JayPee 17 Posted April 14, 2013 Things aren't so they adapt to change. Ex: Have an emulator that works in the way that I know, another works differently modified, which I use, the logic is what I do know work. This does not mean that the emulator does not need to suffer modifications, on the contrary, what ind made so far look great, more my point of view about packages is different. It really depends on the user level of understanding. In some cases the old one's are easy to understand since its been there for a long time and you can find many resources or so many can explain it to you. New things have a high chance of not being easy to understand but it depends on how it is documented or explained or presented. Quote Share this post Link to post Share on other sites
Ind 945 Posted May 24, 2013 With the upcoming update we'll extend this phase to incoming packets as well, for example void clif_parse_bgqueue_battlebegin_ack(int fd, struct map_session_data *sd) { short result = RFIFOW(fd,2); char *bg_name = (char*)RFIFOP(fd,4); if ( result == 1 ) bg->queue_pc_ready(sd); else bg->queue_leave(sd, bg_name);}becomesvoid clif_parse_bgqueue_battlebegin_ack(int fd, struct map_session_data *sd) { struct packet_bgqueue_battlebegin_ack *p = P2PTR(fd, bgqueue_checkstateType); if ( p->result == 1 ) bg->queue_pc_ready(sd); else bg->queue_leave(sd, p->bg_name);}Thanks to pointer logic#define P2PTR(fd,cmd) (void*)(session[fd]->rdata + packet_len(cmd)) Quote Share this post Link to post Share on other sites