Hercules Renewal: Phase Two

Ind

Development Administrator
Staff member
Messages
1,655
Points
113
Hercules Renewal: Phase Two
Hello~! - 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!
 
Last edited by a moderator:
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.

 
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.

 
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. 

 
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.
 
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.

 
Last edited by a moderator:
With the upcoming update we'll extend this phase to incoming packets as well, for example

Code:
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);}
becomes
Code:
void 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
Code:
#define P2PTR(fd,cmd) (void*)(session[fd]->rdata + packet_len(cmd))
 
Back
Top