viewing paste Unknown #6751 | C

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
struct sample_data_struct {
        struct point lastMSGPosition;
        unsigned int someNumber;
};
/* sample packet implementation */
/* cmd 0xf3 - it is a client-server existent id, for clif_parse_GlobalMessage */
/* in this sample we do nothing and simply redirect */
void sample_packet0f3(int fd) {
        struct map_session_data *sd = session[fd]->session_data;
        struct sample_data_struct *data;
       
        if( !sd ) return;/* socket didn't fully log-in? this packet shouldn't do anything then! */
       
        ShowInfo("sample_packet0f3: Hello World! received 0xf3 for '%s', redirecting!\n",sd->status.name);
       
        if( !(data = HPMi->getFromSession(session[fd],HPMi->pid,0)) ) {
                CREATE(data,struct sample_data_struct,1);
               
                data->lastMSGPosition.map = sd->status.last_point.map;
                data->lastMSGPosition.x = sd->status.last_point.x;
                data->lastMSGPosition.y = sd->status.last_point.y;
                data->someNumber = rand()%777;
               
                ShowInfo("Created Appended session[] data, %d %d %d %d\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber);
                HPMi->addToSession(session[fd],data,HPMi->pid,0,true);
        } else {
                ShowInfo("Existent Appended session[] data, %d %d %d %d\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber);
        }
       
        clif->pGlobalMessage(fd,sd);
}
 
Viewed 315 times, submitted by unknown.