Jump to content
Sign in to follow this  
Ind

Hercules Renewal: Phase Two

Recommended Posts

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!
Edited by Ridley

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

 

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.