void XmlReader::readFriend() { while(!reader.atEnd()) { reader.readNext(); if(reader.isStartElement()) { if("id" == reader.name()) { readId(); } else if("nickName" == reader.name()) { readNickName(); } else if("mood" == reader.name()) { readMood(); } else if("mail" == reader.name()) { readMail(); } else if("sex" == reader.name()) { readSex(); } else if("birthday" == reader.name()) { readBirthday(); } else if("imagePath" == reader.name()) { readImage(); } } } }
int main( int argc , char **argv ) { parseOpts( argc, argv ); // Nuke +1 1012: Loop counter int counter1 = 0; int counter2 = 0; int counter3 = 0; int counter4 = 0; signal(SIGUSR1, sigusr1); log_rotate_interval = 3600 * 24 * 7; Lock_Init(); // Arminius 7.17 memory lock UNlockM_Init(); if(readConfig( "acserv.cf" )<0){ log( "ÎÞ·¨ÔÚµ±Ç°Ä¿Â¼Àï¶ÁÈ¡ acserv.cf .\n" ); exit(1); } #ifdef _SASQL sasql_init(); #endif log( "¶ÁÈ¡Êý¾ÝĿ¼\n" ); dbRead( dbdir ); #ifdef _FAMILY log("¶ÁÈ¡ ¼Ò×åׯ԰\n"); readFMSMemo(fmsmemodir); log("¶ÁÈ¡ ¼Ò×åÁôÑÔ\n"); readFMPoint(fmpointdir); log("¶ÁÈ¡ ¼Ò×åĿ¼\n"); readFamily(familydir); #endif log( "×¼±¸ µµ°¸Ä¿Â¼\n" ); prepareDirectories( chardir ); log( "×¼±¸ ÈÕ־Ŀ¼\n" ); prepareDirectories( logdir ); log( "×¼±¸ ÓʼþĿ¼\n" ); prepareDirectories( maildir ); #ifdef _SLEEP_CHAR prepareDirectories( sleepchardir ); log( "×¼±¸ ˯Ãßµµ°¸Ä¿Â¼\n" ); #endif /* Ð×ÒýÔÈ»¯Ô¶ª¡õ»ïë Ðijð¸ê */ if( readMail(maildir) < 0 ){ log( "²»Äܳõʼ»¯Óʼþ\n" ); exit(1); } /* TCPSTRUCT ëâÙÓå¼À */ { int tcpr; if( ( tcpr = tcpstruct_init( NULL , port , 0 , CHARDATASIZE * 16 * MAXCONNECTION , 1 /* DEBUG */ ) ) < 0 ){ log( "²»ÄÜ¿ªÆôTCP: %d\n", tcpr ); return 1; } } saacproto_InitServer( netWrite , CHARDATASIZE ); { struct sigaction s,os; bzero( &s, sizeof(s)); s.sa_handler = sighandle; s.sa_flags = SA_NOMASK; sigaction( SIGTERM, &s, &os ); bzero( &s, sizeof(s)); s.sa_handler = sighandle; s.sa_flags = SA_NOMASK; sigaction( SIGINT, &s, &os ); bzero( &s, sizeof( s )); s.sa_handler = SIG_IGN; s.sa_flags = SA_NOMASK; sigaction( SIGPIPE, &s, &os ); } #ifdef _AC_SEND_FM_PK // WON ADD ׯ԰¶ÔÕ½ÁÐ±í´¢´æÔÚAC load_fm_pk_list(); #endif #ifdef _ACFMPK_LIST FMPK_LoadList(); #endif #ifdef _ALLDOMAN LOAD_herolist(); // Syu ADD ÅÅÐаñNPC #endif #ifdef _ANGEL_SUMMON initMissionTable(); #endif #ifdef _VIP log( "\n·þÎñ¶Ë°æ±¾: <%s »áÔ±°æ>\n" , SERVER_VERSION ); #else log( "\n·þÎñ¶Ë°æ±¾: <%s ÆÕͨ°æ>\n" , SERVER_VERSION ); #endif log( "\n·þÎñ¶Ë±àÒëÍê³Éʱ¼ä:%s %s by 17CSA¹¤×÷ÊÒ\n" , __DATE__ , __TIME__ ); log( "\n¿ªÊ¼¹¤×÷...\n" ); signal(SIGUSR1,sigusr1); // Arminius 7.20 memory lock int itime=0; while(1){ itime++; if(itime>cpuuse){ itime=0; usleep(1); } int newti,i; static time_t main_loop_time; sys_time = time(NULL); if( main_loop_time != sys_time){ main_loop_time = time(NULL); counter1++; counter2++; counter3++; counter4++; //andy add 2002/06/20 UNlockM_UnlockPlayer(); #ifdef _ANGEL_SUMMON checkMissionTimelimit(); #endif // Nuke *1 1012 if( counter1 > Total_Charlist ){ counter1=0; char *c = ctime( &main_loop_time ); if( c ){ struct timeval st,et; log( "\nTIME:%s\n",c ); gettimeofday( &st,NULL); dbFlush(dbdir); gettimeofday( &et,NULL); log( "Flushed db(%fsec)\n", time_diff(et,st) ); log( "µµ°¸±íÁÐ×ÜÊý:%d NG:%d\n", total_ok_charlist, total_ng_charlist ); } } // Nuke **1 1012 //if( ( counter % 600 ) == 0 ){ if( counter2 > Expired_mail ){ counter2=0; struct timeval st,et; gettimeofday( &st,NULL); expireMail(); gettimeofday( &et,NULL); log( "¹ýÆÚÓʼþ(%fsec)\n", time_diff(et,st) ); } #ifdef _FAMILY //if ((counter % 300) == 0) // 300( -> 60) if( counter4 > Write_Family ) // 300( -> 60) { counter4=0; struct timeval st, et; gettimeofday(&st, NULL); writeFamily(familydir); writeFMPoint(fmpointdir); writeFMSMemo(fmsmemodir); gettimeofday(&et, NULL); log("¼Ç¼¼Ò×å(%fsec)\n", time_diff(et, st)); } #endif } newti = tcpstruct_accept1(); if( newti >= 0 ){ log( "ͬÒâ: %d\n" , newti ); gs[newti].use = 1; } for(i=0;i<MAXCONNECTION;i++){ // char buf[CHARDATASIZE * 16; char buf[CHARDATASIZE]; int l; l = tcpstruct_readline_chop( i , buf , sizeof( buf )- 1); { if( !gs[i].use )continue; if( l > 0 ){ char debugfun[256]; buf[l]=0; if( saacproto_ServerDispatchMessage( i , buf, debugfun)<0){ // Nuke start //tcpstruct_close(i);// avoid the shutdown the gmsv ttom log( "GMSV(%s) ÏûÏ¢:%s\n", gs[i].name, debugfun); FILE *fp; if( (fp=fopen( "badgmsv.txt", "a+")) != NULL ){ fprintf( fp, "GMSV(%s) ÏûÏ¢:%s\n", gs[i].name, debugfun); fclose( fp); } } } else if( l == TCPSTRUCT_ETOOLONG ){ log( "ºÜ³¤:%d ·þÎñÆ÷Ãû::%s\n", i , gs[i].name ); FILE *fp; if( (fp=fopen( "badgmsv.txt", "a+")) != NULL ){ fprintf( fp, "ºÜ³¤:%d ·þÎñÆ÷Ãû::%s\n", i , gs[i].name); fclose( fp); } logout_game_server( i ); } else if( l < 0 ){ log( "¹Ø±Õ:%d ·þÎñÆ÷Ãû:%s\n", i , gs[i].name ); FILE *fp; if( (fp=fopen( "badgmsv.txt", "a+")) != NULL ){ fprintf( fp, "¹Ø±Õ:%d ·þÎñÆ÷Ãû:%s\n", i , gs[i].name); fclose( fp); } logout_game_server(i); } else if( l == 0 ){ ; } } } { static struct timeval tv_loop_store ; struct timeval now; double dif; gettimeofday( &now , NULL ); dif = time_diff( now, tv_loop_store ); if( dif > 0.5 ){ // CoolFish 0.1 -> 0.5 2001/5/19 //log( "Sl:%f" , dif ); } tv_loop_store = now; } /* ·¥¡õÊСõ¼°ÕýÄÌةʧËüÐþëƩÍÍÔÂ£Û ÕýÄÌةʧËüÐþØÆÐ×ÈÕ·òºëë·ÖØÆ»¯·¥¡õÊСõëڽØÆ»¯ØÆÒýµ¤£Û Æ¥±Ø¡õØ©ÈÓ¡õÌï¡õ±å ±Î¶Á±å·´É§ôÅÔÊÔ */ } return 0; }
void AiEntity::update() { Physics& physics = *mGameModel->physics; // this has to be non-NULL since AiManager::update() checks before calling this. // all the same... mPhysicsEntity = physics.getEntityByHandle(mPhysicsHandle); if (mPhysicsEntity == NULL) { // this is bad! printf("AiEntity::update(): error: NULL physics entity\n"); mActive = false; return; } mWorldPosition = physics.getCenter(mPhysicsHandle); // won't know this until we read the mail mWasAttacked = false; readMail(); // handle death // FIXME: the other half of this exists in AiManager... // ever get the urge to merge? if (mCurrentHealth <= 0.0) { // turn inventory items into phys entities for (int i = 0; i < AI_INVENTORY_SIZE; i++) { if (mInventory[i] > 0) { item_t item = mGameModel->itemManager->getItem(mInventory[i]); if (item.type == ITEMTYPE_GUN_ONE_HANDED && r_numi(0, 10) < 3) { mGameModel->itemManager->destroyItem(mInventory[i]); } else { v3d_t itemForce = v3d_random(20.0); itemForce.y = 10.0; PhysicsEntity* itemPhysicsEntity = physics.createEntity(OBJTYPE_ITEM, mWorldPosition, itemForce, true); if (itemPhysicsEntity != NULL) { physics.setItemHandleAndType(itemPhysicsEntity->handle, mInventory[i], mGameModel->itemManager->getItemType(mInventory[i])); } } mInventory[i] = 0; } } return; } double time = mGameModel->physics->getLastUpdateTime(); // is it time to think yet? if (mNextUpdateTime < time) { updateTarget(); // updateState(time, worldMap, physics, aiEntities, itemManager); mNextUpdateTime = time + 0.3; } if (mTargetPhysicsHandle > 0) { mTargetPhysicsEntity = physics.getEntityByHandle(mTargetPhysicsHandle); } bool couldHaveFiredGun = false; bool didFireGun = false; if (mTargetPhysicsEntity == NULL) { mTargetPhysicsHandle = 0; } else { // now shoot'm if you got'm! v3d_t targetPosition = mTargetPhysicsEntity->boundingBox.getCenterPosition(); bool hasLineOfSight = mGameModel->location->getWorldMap()->lineOfSight(mWorldPosition, targetPosition); if (mTargetPhysicsEntity->type != OBJTYPE_TIGER_BAIT && hasLineOfSight) { if (mInventory[0] > 0 && mGameModel->itemManager->getItem(mInventory[0]).type == ITEMTYPE_GUN_ONE_HANDED) { couldHaveFiredGun = true; } didFireGun = useWeapon(); } } // now for movement switch (mType) { case AITYPE_BALLOON: updateBalloon(); break; case AITYPE_SHOOTER: if (!couldHaveFiredGun || (couldHaveFiredGun && !didFireGun && mNextShotTime <= time)) { updateHopper(); } break; case AITYPE_HOPPER: updateHopper(); break; case AITYPE_HUMAN: if (!couldHaveFiredGun || (couldHaveFiredGun && !didFireGun && mNextShotTime <= time)) { updateHopper(); } break; case AITYPE_DUMMY: updateDummy(); break; default: break; } }
int main( int argc , char **argv ) { parseOpts( argc, argv ); // Nuke +1 1012: Loop counter int counter1 = 0; int counter2 = 0; int counter3 = 0; int counter4 = 0; signal(SIGUSR1, sigusr1); log_rotate_interval = 3600 * 24 * 7; Lock_Init(); // Arminius 7.17 memory lock UNlockM_Init(); if(readConfig( "acserv.cf" )<0){ log( "���ڵ�ǰĿ¼���ȡ acserv.cf .\n" ); exit(1); } #ifdef _SASQL sasql_init(); #endif log( "��ȡ����Ŀ¼\n" ); dbRead( dbdir ); #ifdef _FAMILY log("��ȡ ����ׯ\n"); readFMSMemo(fmsmemodir); log("��ȡ ��������\n"); readFMPoint(fmpointdir); log("��ȡ ����Ŀ¼\n"); readFamily(familydir); #endif log( "�� ����Ŀ¼\n" ); prepareDirectories( chardir ); log( "�� ��־Ŀ¼\n" ); prepareDirectories( logdir ); log( "�� �ʼ�Ŀ¼\n" ); prepareDirectories( maildir ); #ifdef _SLEEP_CHAR prepareDirectories( sleepchardir ); log( "�� ˯�ߵ���Ŀ¼\n" ); #endif /* �����Ȼ��¶�����ë �ij�� */ if( readMail(maildir) < 0 ){ log( "���ܳ�ʼ���ʼ�\n" ); exit(1); } /* TCPSTRUCT ë����� */ { int tcpr; if( ( tcpr = tcpstruct_init( NULL , port , 0 , CHARDATASIZE * 16 * MAXCONNECTION , 1 /* DEBUG */ ) ) < 0 ){ log( "���ܿ���TCP: %d\n", tcpr ); return 1; } } saacproto_InitServer( netWrite , CHARDATASIZE ); { struct sigaction s,os; bzero( &s, sizeof(s)); s.sa_handler = sighandle; s.sa_flags = SA_NOMASK; sigaction( SIGTERM, &s, &os ); bzero( &s, sizeof(s)); s.sa_handler = sighandle; s.sa_flags = SA_NOMASK; sigaction( SIGINT, &s, &os ); bzero( &s, sizeof( s )); s.sa_handler = SIG_IGN; s.sa_flags = SA_NOMASK; sigaction( SIGPIPE, &s, &os ); } #ifdef _AC_SEND_FM_PK // WON ADD ׯ��ս�б�����AC load_fm_pk_list(); #endif #ifdef _ACFMPK_LIST FMPK_LoadList(); #endif #ifdef _ALLDOMAN LOAD_herolist(); // Syu ADD ���а�NPC #endif #ifdef _VIP log( "\n����˰汾: <%s ��Ա��>\n" , SERVER_VERSION ); #else log( "\n����˰汾: <%s ��ͨ��>\n" , SERVER_VERSION ); #endif log( "\n����˱������ʱ��:%s %s by ��zoro������\n" , __DATE__ , __TIME__ ); log( "\n��ʼ����...\n" ); signal(SIGUSR1,sigusr1); // Arminius 7.20 memory lock int itime=0; while(1){ itime++; if(itime>cpuuse){ itime=0; usleep(1); } int newti,i; static time_t main_loop_time; sys_time = time(NULL); if( main_loop_time != sys_time){ main_loop_time = time(NULL); counter1++; counter2++; counter3++; counter4++; //andy add 2002/06/20 UNlockM_UnlockPlayer(); #ifdef _ANGEL_SUMMON checkMissionTimelimit(); #endif // Nuke *1 1012 if( counter1 > Total_Charlist ){ counter1=0; char *c = ctime( &main_loop_time ); if( c ){ struct timeval st,et; log( "\nTIME:%s\n",c ); gettimeofday( &st,NULL); dbFlush(dbdir); gettimeofday( &et,NULL); log( "Flushed db(%fsec)\n", time_diff(et,st) ); log( "������������:%d NG:%d\n", total_ok_charlist, total_ng_charlist ); } } // Nuke **1 1012 //if( ( counter % 600 ) == 0 ){ if( counter2 > Expired_mail ){ counter2=0; struct timeval st,et; gettimeofday( &st,NULL); expireMail(); gettimeofday( &et,NULL); log( "�����ʼ�(%fsec)\n", time_diff(et,st) ); } #ifdef _FAMILY //if ((counter % 300) == 0) // 300( -> 60) if( counter4 > Write_Family ) // 300( -> 60) { counter4=0; struct timeval st, et; gettimeofday(&st, NULL); writeFamily(familydir); writeFMPoint(fmpointdir); writeFMSMemo(fmsmemodir); gettimeofday(&et, NULL); log("��¼����(%fsec)\n", time_diff(et, st)); } #endif } newti = tcpstruct_accept1(); if( newti >= 0 ){ log( "ͬ��: %d\n" , newti ); gs[newti].use = 1; } for(i=0;i<MAXCONNECTION;i++){ // char buf[CHARDATASIZE * 16; char buf[CHARDATASIZE]; int l; l = tcpstruct_readline_chop( i , buf , sizeof( buf )- 1); { if( !gs[i].use )continue; if( l > 0 ){ char debugfun[256]; buf[l]=0; if( saacproto_ServerDispatchMessage( i , buf, debugfun)<0){ // Nuke start tcpstruct_close(i);// avoid the shutdown the gmsv ttom log( "GMSV(%s) ��Ϣ:%s\n", gs[i].name, debugfun); } } else if( l == TCPSTRUCT_ETOOLONG ){ log( "�ܳ�:%d ��������::%s\n", i , gs[i].name ); logout_game_server( i ); } else if( l < 0 ){ log( "�ر�:%d ��������:%s\n", i , gs[i].name ); logout_game_server(i); } else if( l == 0 ){ ; } } } { static struct timeval tv_loop_store ; struct timeval now; double dif; gettimeofday( &now , NULL ); dif = time_diff( now, tv_loop_store ); if( dif > 0.5 ){ // CoolFish 0.1 -> 0.5 2001/5/19 //log( "Sl:%f" , dif ); } tv_loop_store = now; } /* �����С�������ةʧ����ëƩ���£� ����ةʧ���������շ��ë���ƻ������С�ëڽ�ƻ��������� ƥ�ء�ة�ӡ������ �ζ��巴ɧ������ */ } return 0; }