forked from metin2/server
Add project files.
This commit is contained in:
129
game/src/SpeedServer.h
Normal file
129
game/src/SpeedServer.h
Normal file
@ -0,0 +1,129 @@
|
||||
#ifndef __INC_METIN_II_GAME_SPEEDSERVER_H__
|
||||
#define __INC_METIN_II_GAME_SPEEDSERVER_H__
|
||||
|
||||
#include "../../common/length.h"
|
||||
#include <list>
|
||||
|
||||
// castle.cpp <20><> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||||
#define EMPIRE_NONE 0 // <20>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD> <20>ƴ<EFBFBD>
|
||||
#define EMPIRE_RED 1 // <20>ż<EFBFBD>
|
||||
#define EMPIRE_YELLOW 2 // õ<><C3B5>
|
||||
#define EMPIRE_BLUE 3 // <20><><EFBFBD><EFBFBD>
|
||||
|
||||
class HME
|
||||
{
|
||||
public :
|
||||
int hour;
|
||||
int min;
|
||||
int exp;
|
||||
|
||||
HME (int h=0, int m=0, int e=0){
|
||||
hour = h; min = m;
|
||||
exp = e;
|
||||
}
|
||||
|
||||
HME& operator=(const HME &rhs)
|
||||
{
|
||||
hour = rhs.hour;
|
||||
min = rhs.min;
|
||||
exp = rhs.exp;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const HME &rhs) const
|
||||
{
|
||||
return hour == rhs.hour
|
||||
&& min == rhs.min
|
||||
&& exp == rhs.exp;
|
||||
}
|
||||
|
||||
bool operator<(const HME &rhs) const
|
||||
{
|
||||
return (hour<rhs.hour)
|
||||
|| (hour==rhs.hour) && (min<rhs.min);
|
||||
}
|
||||
};
|
||||
|
||||
class Date
|
||||
{
|
||||
public :
|
||||
int year;
|
||||
int mon;
|
||||
int day;
|
||||
|
||||
Date (int y = 0, int m = 0, int d = 0)
|
||||
{
|
||||
year = y; mon = m; day = d;
|
||||
}
|
||||
|
||||
bool operator==(const Date &rhs) const
|
||||
{
|
||||
return year == rhs.year
|
||||
&& mon == rhs.mon
|
||||
&& day == rhs.day;
|
||||
}
|
||||
bool operator<(const Date &rhs) const
|
||||
{
|
||||
return (year<rhs.year)
|
||||
|| (year==rhs.year) && (mon<rhs.mon)
|
||||
|| (year==rhs.year) && (mon==rhs.mon) && (day<rhs.day);
|
||||
}
|
||||
};
|
||||
|
||||
class CSpeedServerEmpireExp
|
||||
{
|
||||
public :
|
||||
CSpeedServerEmpireExp();
|
||||
~CSpeedServerEmpireExp();
|
||||
|
||||
bool Initialize (BYTE empire);
|
||||
|
||||
std::list <HME>& GetWdayExpTable(int wday);
|
||||
void SetWdayExpTable(int wday, HME hme);
|
||||
|
||||
std::list <HME>& GetHolidayExpTable(Date date, bool &is_exist);
|
||||
void SetHolidayExpTable(Date date, HME hme);
|
||||
|
||||
void InitWdayExpTable(int wday);
|
||||
void InitHolidayExpTable(Date date);
|
||||
HME GetCurrentExpPriv (int &duration, bool &is_change);
|
||||
|
||||
bool WriteExpTable();
|
||||
|
||||
private :
|
||||
bool LoadExpTable ();
|
||||
bool LoadWdayExpTable (int wday, char *str);
|
||||
|
||||
BYTE empire;
|
||||
char file_name [256];
|
||||
HME current_hme;
|
||||
std::map <Date, std::list <HME> > holiday_map;
|
||||
std::list <HME> wday_exp_table[7];
|
||||
};
|
||||
|
||||
class CSpeedServerManager : public singleton<CSpeedServerManager>
|
||||
{
|
||||
public:
|
||||
CSpeedServerManager();
|
||||
~CSpeedServerManager();
|
||||
|
||||
bool Initialize ();
|
||||
|
||||
std::list <HME>& GetWdayExpTableOfEmpire (BYTE empire, int wday);
|
||||
void SetWdayExpTableOfEmpire (BYTE empire, int wday, HME hme);
|
||||
void InitWdayExpTableOfEmpire (BYTE empire, int wday);
|
||||
|
||||
std::list <HME>& GetHolidayExpTableOfEmpire (BYTE empire, Date date, bool &is_exist);
|
||||
void SetHolidayExpTableOfEmpire (BYTE empire, Date date, HME hme);
|
||||
void InitHolidayExpTableOfEmpire (BYTE empire, Date date);
|
||||
|
||||
bool WriteExpTableOfEmpire (BYTE empire);
|
||||
|
||||
HME GetCurrentExpPrivOfEmpire (BYTE empire, int &duration, bool &is_change);
|
||||
|
||||
private:
|
||||
CSpeedServerEmpireExp Empire[EMPIRE_MAX_NUM];
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user