Fimbulwinter Project  Pre-Alpha
An Ragnarok Online Emulator
ZoneServer/PlayerModules.hpp
00001 /*==================================================================*
00002 *     ___ _           _           _          _       _                          *
00003 *    / __(_)_ __ ___ | |__  _   _| |_      _(_)_ __ | |_ ___ _ __       *
00004 *   / _\ | | '_ ` _ \| '_ \| | | | \ \ /\ / / | '_ \| __/ _ \ '__|      *
00005 *  / /   | | | | | | | |_) | |_| | |\ V  V /| | | | | ||  __/ |         *
00006 *  \/    |_|_| |_| |_|_.__/ \__,_|_| \_/\_/ |_|_| |_|\__\___|_|         *
00007 *                                                                                                                                       *
00008 * ------------------------------------------------------------------*
00009 *                                                        Emulator                                       *
00010 * ------------------------------------------------------------------*
00011 *                     Licenced under GNU GPL v3                     *
00012 * ----------------------------------------------------------------- *
00013 *                    Player Manipulation Modules                        *
00014 * ==================================================================*/
00015 
00016 #pragma once
00017 
00018 #include <ragnarok.hpp>
00019 #include <packets.hpp>
00020 #include <timers.hpp>
00021 #include <iostream>
00022 #include "BlockManager.hpp"
00023 #include "PacketHandling.hpp"
00024 #include "ZoneServer.hpp"
00025 
00026 typedef enum ClearType
00027 {
00028         CLR_OUTSIGHT = 0,
00029         CLR_DEAD,
00030         CLR_RESPAWN,
00031         CLR_TELEPORT,
00032 } ClearType;
00033 
00043 struct ZoneSessionData
00044 {
00045         int login_id1;
00046         int login_id2;
00047         int gmlevel;
00048         unsigned int client_tick;
00049         time_t canlog_tick;
00050 
00051         unsigned short mapindex;
00052         struct BlockList bl;
00053         CharData status;
00054         Registry save_reg;
00055 
00056         struct
00057         {
00058                 unsigned int lesseffect : 1;
00059                 unsigned int active : 1;
00060                 unsigned int connect_new : 1;
00061         } state;
00062 
00063         tcp_connection::pointer cl;
00064 };
00065 
00066 
00075 class PC
00076 {
00077 public:
00078 
00079         static void set_new_pc(ZoneSessionData *sd, int account_id, int char_id, int login_id1, unsigned int client_tick, int sex, tcp_connection::pointer cl)
00080         {
00081                 if (!sd)
00082                         return;
00083 
00084                 sd->bl.id        = account_id;
00085                 sd->status.account_id   = account_id;
00086                 sd->status.char_id      = char_id;
00087                 sd->status.sex   = sex;
00088                 sd->login_id1    = login_id1;
00089                 sd->login_id2    = 0;
00090                 sd->client_tick  = client_tick;
00091                 sd->bl.type      = BL_PC;
00092                 sd->canlog_tick  = time(NULL);
00093                 sd->state.active = 0;
00094         }
00095 
00096         static bool auth_ok(ZoneSessionData * sd, unsigned int login_id2, time_t expiration_time, int gmlevel, struct CharData * status);
00097         static void auth_fail(ZoneSessionData * sd);
00098         static int set_pos( ZoneSessionData * sd, unsigned short m, short x, short y, ClearType clrtype );
00099         static void reg_received( struct ZoneSessionData * sd );
00100 };
 All Classes Functions