354 lines
7.5 KiB
C
354 lines
7.5 KiB
C
![]() |
|
|||
|
int main( int argc , char** argv, char** env )
|
|||
|
{
|
|||
|
|
|||
|
//if(attestation()<1)
|
|||
|
// {
|
|||
|
// print("<22><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD>\n");
|
|||
|
// exit(0);
|
|||
|
// }
|
|||
|
//if (strcmp(getlocaltime(), TimeLimitLocal)>0)exit(0);
|
|||
|
#ifdef _ONLINENUM_FIX
|
|||
|
system("ulimit -HSn 2048");
|
|||
|
#endif
|
|||
|
|
|||
|
/* <20>Ȥꤢ<C8A4><EAA4A2><EFBFBD><EFBFBD><EFBFBD>r<EFBFBD>g<EFBFBD><67><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD> */
|
|||
|
setNewTime();
|
|||
|
|
|||
|
/* if ( argc > 1 && 0==strcmp(argv[1],"-v"))
|
|||
|
{
|
|||
|
printf("%s",genver);
|
|||
|
exit(0);
|
|||
|
}
|
|||
|
else fprintf(stderr,"%s",genver);*/
|
|||
|
readconfigfile(getConfigfilename());
|
|||
|
EXITWITHEXITCODEIFFALSE( util_Init() , 1);
|
|||
|
|
|||
|
LoadAnnounce(); // Arminius 7.12 loginannounce
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD>ɬ<EFBFBD><C9AC> */
|
|||
|
memcpy( &tmOld, localtime( (time_t *)&NowTime.tv_sec), sizeof( tmNow ) );
|
|||
|
|
|||
|
sasql_init();
|
|||
|
|
|||
|
EXITWITHEXITCODEIFFALSE( init(argc , argv ,env ) , 1);
|
|||
|
sasql_online(NULL,NULL,NULL,NULL,NULL,3);
|
|||
|
LoadPetTalk(); // Arminius 8.14 pet talk
|
|||
|
|
|||
|
#ifdef _GAMBLE_BANK
|
|||
|
Load_GambleBankItems();
|
|||
|
#endif
|
|||
|
|
|||
|
#ifdef _CFREE_petskill
|
|||
|
Load_PetSkillCodes();
|
|||
|
#endif
|
|||
|
|
|||
|
#ifdef _ITEM_PILEFORTRADE
|
|||
|
TRADE_InitTradeList();
|
|||
|
#endif
|
|||
|
mainloop();
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
void mainloop( void )
|
|||
|
{
|
|||
|
print("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>NPC...");
|
|||
|
NPC_generateLoop( 1 );
|
|||
|
print("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|||
|
print("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>signal1...");
|
|||
|
signal(SIGUSR1,sigusr1);
|
|||
|
print("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|||
|
print("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>signal2...");
|
|||
|
signal(SIGUSR2,sigusr2);
|
|||
|
print("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|||
|
#ifdef _MAP_WARPPOINT
|
|||
|
print("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>...");
|
|||
|
MAPPOINT_InitMapWarpPoint();
|
|||
|
print("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|||
|
if( !MAPPOINT_loadMapWarpPoint() ){
|
|||
|
return;
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
#ifdef _ASSESS_SYSEFFICACY
|
|||
|
Assess_InitSysEfficacy();
|
|||
|
#endif
|
|||
|
#ifdef _CHATROOMPROTOCOL // (<28><><EFBFBD>ɿ<EFBFBD>) Syu ADD <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>
|
|||
|
print("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ...");
|
|||
|
InitChatRoom();
|
|||
|
print("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|||
|
#endif
|
|||
|
#ifdef _CHANNEL_MODIFY
|
|||
|
print("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ְҵƵ<EFBFBD><EFBFBD>...");
|
|||
|
if(!InitOccChannel()) return; // <20><>ʼ<EFBFBD><CABC>ְҵƵ<D2B5><C6B5>
|
|||
|
print("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|||
|
#endif
|
|||
|
#ifdef _ANGEL_SUMMON
|
|||
|
print("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۼʱ<EFBFBD><EFBFBD>...");
|
|||
|
AngelReady = 0;
|
|||
|
#ifdef _ANGEL_TIME
|
|||
|
AngelNextTime = time(NULL) + getAngelPlayerTime();
|
|||
|
#else
|
|||
|
AngelNextTime = time(NULL) + 1*60;
|
|||
|
#endif
|
|||
|
print("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|||
|
#endif
|
|||
|
#ifdef _JZ_NEWSCRIPT_LUA
|
|||
|
print("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>LNS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>...");
|
|||
|
NPC_Lua_Init(getLuaFile());
|
|||
|
print("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|||
|
#endif
|
|||
|
|
|||
|
#ifdef _ITEM_LUA
|
|||
|
print("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LUA<EFBFBD><EFBFBD><EFBFBD><EFBFBD>...");
|
|||
|
int itemluaflg=ITEM_LuaInit(getitemluafile());
|
|||
|
if(itemluaflg==TRUE){
|
|||
|
print("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|||
|
}else{
|
|||
|
print("ʧ<EFBFBD><EFBFBD>\n");
|
|||
|
}
|
|||
|
#endif
|
|||
|
#ifdef _ALLBLUES_LUA
|
|||
|
print("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>LUA<EFBFBD>ű<EFBFBD>...");
|
|||
|
LoadAllbluesLUA("data/ablua");
|
|||
|
print("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|||
|
#endif
|
|||
|
//if (strcmp(getlocaltime(), TimeLimitLocal)>0)exit(0);
|
|||
|
//#ifdef _ALLDOMAN
|
|||
|
// print("<22><>ʼ<EFBFBD><CABC>Ӣ<EFBFBD>۱<EFBFBD><DBB1><EFBFBD>...");
|
|||
|
// InitHeroList();
|
|||
|
// print("<22><><EFBFBD><EFBFBD>\n");
|
|||
|
//#endif
|
|||
|
|
|||
|
int itime=0;
|
|||
|
while(1){
|
|||
|
if(getCpuUse()!=-1){
|
|||
|
itime++;
|
|||
|
if(itime>getCpuUse()){
|
|||
|
itime=0;
|
|||
|
usleep(1);
|
|||
|
}
|
|||
|
}
|
|||
|
#ifdef _ASSESS_SYSEFFICACY
|
|||
|
Assess_SysEfficacy( 0 );
|
|||
|
#endif
|
|||
|
|
|||
|
setNewTime();
|
|||
|
memcpy(&tmNow, localtime( (time_t *)&NowTime.tv_sec),
|
|||
|
sizeof( tmNow ) );
|
|||
|
if( tmOld.tm_hour != getLogHour( ) && tmNow.tm_hour == getLogHour( ) ){
|
|||
|
#ifdef _GMSV_DEBUG
|
|||
|
DebugMainFunction="backupAllLogFile";
|
|||
|
#endif
|
|||
|
backupAllLogFile( &tmOld );
|
|||
|
}
|
|||
|
|
|||
|
setNewTime();
|
|||
|
#ifdef _ASSESS_SYSEFFICACY_SUB //<2F><>ʾLOOPʱ<50><CAB1>
|
|||
|
//Assess_SysEfficacy_sub( 0, 1);
|
|||
|
#ifdef _GMSV_DEBUG
|
|||
|
DebugMainFunction="netloop_faster";
|
|||
|
#endif
|
|||
|
netloop_faster();
|
|||
|
//Assess_SysEfficacy_sub( 1, 1);
|
|||
|
|
|||
|
//Assess_SysEfficacy_sub( 0, 2);
|
|||
|
#ifdef _GMSV_DEBUG
|
|||
|
DebugMainFunction="NPC_generateLoop";
|
|||
|
#endif
|
|||
|
NPC_generateLoop( 0 );
|
|||
|
//Assess_SysEfficacy_sub( 1, 2);
|
|||
|
|
|||
|
//Assess_SysEfficacy_sub( 0, 3);
|
|||
|
#ifdef _GMSV_DEBUG
|
|||
|
DebugMainFunction="BATTLE_Loop";
|
|||
|
#endif
|
|||
|
BATTLE_Loop();
|
|||
|
//Assess_SysEfficacy_sub( 1, 3);
|
|||
|
|
|||
|
//Assess_SysEfficacy_sub( 0, 4);
|
|||
|
#ifdef _GMSV_DEBUG
|
|||
|
DebugMainFunction="CHAR_Loop";
|
|||
|
#endif
|
|||
|
CHAR_Loop();
|
|||
|
//Assess_SysEfficacy_sub( 1, 4);
|
|||
|
|
|||
|
#ifdef _GMSV_DEBUG
|
|||
|
DebugMainFunction="PETMAIL_proc";
|
|||
|
#endif
|
|||
|
PETMAIL_proc();
|
|||
|
|
|||
|
#ifdef _GMSV_DEBUG
|
|||
|
DebugMainFunction="family_proc";
|
|||
|
#endif
|
|||
|
family_proc();
|
|||
|
|
|||
|
#ifdef _GMSV_DEBUG
|
|||
|
DebugMainFunction="chardatasavecheck";
|
|||
|
#endif
|
|||
|
chardatasavecheck();
|
|||
|
|
|||
|
#ifdef _GMSV_DEBUG
|
|||
|
DebugMainFunction="AngelReadyProc";
|
|||
|
#endif
|
|||
|
AngelReadyProc();
|
|||
|
|
|||
|
//tmOld = tmNow;
|
|||
|
if( tmOld.tm_sec != tmNow.tm_sec ) {
|
|||
|
/*#ifdef _CAX_YANZHENG
|
|||
|
if(yanzheng != 0){
|
|||
|
exit(1);
|
|||
|
}
|
|||
|
#endif*/
|
|||
|
#ifdef _GMSV_DEBUG
|
|||
|
DebugMainFunction="CHAR_checkEffectLoop";
|
|||
|
#endif
|
|||
|
CHAR_checkEffectLoop();
|
|||
|
}
|
|||
|
if( SERVSTATE_getShutdown()> 0 ) {
|
|||
|
ShutdownProc();
|
|||
|
#ifdef _GMSV_DEBUG
|
|||
|
DebugMainFunction="ShutdownProc";
|
|||
|
#endif
|
|||
|
}
|
|||
|
tmOld = tmNow;
|
|||
|
|
|||
|
#ifdef _ASSESS_SYSEFFICACY
|
|||
|
Assess_SysEfficacy( 1 );
|
|||
|
#endif
|
|||
|
#endif
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static void sendmsg_toall( char *msg )
|
|||
|
{
|
|||
|
int i;
|
|||
|
int playernum = CHAR_getPlayerMaxNum();
|
|||
|
|
|||
|
for( i = 0 ; i < playernum ; i++) {
|
|||
|
if( CHAR_getCharUse(i) != FALSE ) {
|
|||
|
CHAR_talkToCli( i, -1, msg, CHAR_COLORYELLOW);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
static void ShutdownProc( void)
|
|||
|
{
|
|||
|
#define SYSINFO_SHUTDOWN_MSG "%d <20><><EFBFBD>Ӻ<EFBFBD><D3BA><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ϵͳͣ<CDB3><CDA3>ά<EFBFBD><CEAC>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD>ʧ<EFBFBD><CAA7>"
|
|||
|
#define SYSINFO_SHUTDOWN_MSG_COMP "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹرա<D8B1>"
|
|||
|
int diff,hun;
|
|||
|
|
|||
|
diff = NowTime.tv_sec - SERVSTATE_getShutdown();
|
|||
|
hun = SERVSTATE_getLimittime() - (diff/60);
|
|||
|
if( hun != SERVSTATE_getDsptime() ){
|
|||
|
char buff[256];
|
|||
|
if( hun != 0 ) {
|
|||
|
snprintf( buff, sizeof(buff), SYSINFO_SHUTDOWN_MSG, hun);
|
|||
|
}
|
|||
|
else {
|
|||
|
strcpy( buff, SYSINFO_SHUTDOWN_MSG_COMP);
|
|||
|
}
|
|||
|
sendmsg_toall( buff);
|
|||
|
SERVSTATE_setDsptime(hun);
|
|||
|
if( hun == 1 ) {
|
|||
|
int i=0;
|
|||
|
unsigned int MAX_USER=0;
|
|||
|
|
|||
|
MAX_USER=getPlayercharnum();
|
|||
|
for(i=0;i<MAX_USER;i++){
|
|||
|
if( CHAR_getCharUse( i ) == FALSE )continue;
|
|||
|
#ifdef _OFFLINE_SYSTEM
|
|||
|
if(CHAR_getWorkInt( i, CHAR_WORK_OFFLINE )!=0){
|
|||
|
CHAR_logout(i,TRUE);
|
|||
|
}else
|
|||
|
#endif
|
|||
|
CONNECT_setCloseRequest( getfdFromCharaIndex(i) , 1 );
|
|||
|
}//for i
|
|||
|
SERVSTATE_SetAcceptMore( 0 );
|
|||
|
}
|
|||
|
}
|
|||
|
/* closesallsockets */
|
|||
|
if( hun == 0) {
|
|||
|
closeAllConnectionandSaveData();
|
|||
|
SERVSTATE_setShutdown(0);
|
|||
|
SERVSTATE_setDsptime(0);
|
|||
|
SERVSTATE_setLimittime(0);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void family_proc()
|
|||
|
{
|
|||
|
static unsigned long gettime = 0;
|
|||
|
static unsigned long checktime = 0;
|
|||
|
static unsigned long proctime = 0;
|
|||
|
|
|||
|
if( time(NULL) < proctime ) return;
|
|||
|
proctime = time(NULL)+5;
|
|||
|
|
|||
|
if( (unsigned long)NowTime.tv_sec > gettime ){
|
|||
|
getNewFMList();
|
|||
|
gettime = (unsigned long)NowTime.tv_sec + 60*10;
|
|||
|
}
|
|||
|
|
|||
|
if( (unsigned long)NowTime.tv_sec > checktime ){
|
|||
|
checkFamilyIndex();
|
|||
|
checktime = (unsigned long)NowTime.tv_sec + 60*30;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void warplog_proc()
|
|||
|
{
|
|||
|
static unsigned long checktime = 0;
|
|||
|
|
|||
|
if( (unsigned long)NowTime.tv_sec > checktime ){
|
|||
|
warplog_to_file();
|
|||
|
checktime = (unsigned long)NowTime.tv_sec + 300;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#ifdef _ANGEL_SUMMON
|
|||
|
|
|||
|
extern int player_online;
|
|||
|
|
|||
|
void AngelReadyProc()
|
|||
|
{
|
|||
|
//static time_t lastCreateTime = time(NULL);
|
|||
|
time_t nowTime;
|
|||
|
//static unsigned long AngelNextTime = 30*60;
|
|||
|
struct tm *temptime;
|
|||
|
char msg[1024];
|
|||
|
|
|||
|
nowTime = time(NULL);
|
|||
|
|
|||
|
if( nowTime < AngelNextTime )
|
|||
|
return;
|
|||
|
#ifdef _ANGEL_TIME
|
|||
|
if( player_online <= getAngelPlayerMun() )
|
|||
|
#else
|
|||
|
if( player_online <= 10 )
|
|||
|
#endif
|
|||
|
{
|
|||
|
// print("\n<><6E><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=%d\n", player_online );
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
AngelReady = 1;
|
|||
|
//AngelNextTime = min( (int)(10000/player_online), 100)*60 + (unsigned long)nowTime;
|
|||
|
#ifdef _ANGEL_TIME
|
|||
|
AngelNextTime = min( (int)(getAngelPlayerTime()/player_online) + 1, 100)*60 + (unsigned long)nowTime;//<2F><><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD>ʱ<EFBFBD><CAB1>Ϊʲôһֱ<D2BB><D6B1>ʾ<EFBFBD><CABE>
|
|||
|
#else
|
|||
|
AngelNextTime = min( (int)(5000/player_online), 100)*60 + (unsigned long)nowTime;
|
|||
|
#endif
|
|||
|
|
|||
|
temptime = localtime( &AngelNextTime );
|
|||
|
sprintf( msg, "\r<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD>:<3A><><EFBFBD><EFBFBD>һλȱ<CEBB><C8B1> <20>´β<C2B4><CEB2><EFBFBD>ʱ<EFBFBD><CAB1>=(%d/%d %d:%d) Ŀǰ<C4BF><C7B0><EFBFBD><EFBFBD>=%d",
|
|||
|
temptime->tm_mon+1, temptime->tm_mday, temptime->tm_hour, temptime->tm_min, player_online );
|
|||
|
print( msg);
|
|||
|
//LogAngel( msg);
|
|||
|
}
|
|||
|
|
|||
|
#endif
|
|||
|
|
|||
|
|