📄 init.c
字号:
GameServerName = getGameserverID(); if( GameServerName == NULL || strlen( GameServerName) <= 0 ) return FALSE; print("\n游戏服务器ID: %s\n", GameServerName ); } print("开始初始化\n" );//#define DEBUG1( arg... ) if( getDebuglevel()>1 ){##arg} print( "建立内存空间..." ); GOTORETURNFALSEIFFALSE(configmem( getMemoryunit(), getMemoryunitnum() ) ); GOTORETURNFALSEIFFALSE(memInit()); print( "完成\n" ); if( !initConnect(getFdnum()) ) goto MEMEND; while( 1 ){ print( "尝试绑定本地端口 %d... " , getPortnumber()); bindedfd = bindlocalhost( getPortnumber() ); if( bindedfd == -1 ) sleep( 10 ); else break; } print( "完成\n" ); print( "建立对象..." ); if( !initObjectArray( getObjnum()) ) goto CLOSEBIND; print( "完成\n" ); print( "建立人物..." ); if(!CHAR_initCharArray( getFdnum(), getPetcharnum(),getOtherscharnum()) ) goto CLOSEBIND; print( "完成\n" ); print( "建立物品:%s...", getItemfile()); if(!ITEM_readItemConfFile( getItemfile()) ) goto CLOSEBIND; if(!ITEM_initExistItemsArray( getItemnum() ) ) goto CLOSEBIND; print( "完成\n" ); print( "建立战斗..." ); if(!BATTLE_initBattleArray( getBattlenum() ) ) goto CLOSEBIND; print( "完成\n" ); print( "建立功能模块..." ); if( !initFunctionTable() ) goto CLOSEBIND; print( "完成\n" ); print( "初始化邮件..." ); if( !PETMAIL_initOffmsgBuffer( getAddressbookoffmsgnum() )) goto CLOSEBIND; print( "完成\n" ); print( "读取不可战斗文件..." ); if( !CHAR_initInvinciblePlace( getInvfile() ) ) goto CLOSEBIND; print( "完成\n" ); print( "读取显示位置文件..." ); if( !CHAR_initAppearPosition( getAppearfile() ) ) goto CLOSEBIND; print( "完成\n" ); print( "读取头衔名称文件..." ); if( !TITLE_initTitleName( getTitleNamefile() ) ) goto CLOSEBIND; print( "完成\n" ); print( "读取头衔配置文件..." ); if( !TITLE_initTitleConfig( getTitleConfigfile() ) ) goto CLOSEBIND; print( "完成\n" ); print( "读取遇敌坐标文件..." ); if( !ENCOUNT_initEncount( getEncountfile() ) ) goto CLOSEBIND; print( "完成\n" ); print( "读取宠物基本文件..." ); if( !ENEMYTEMP_initEnemy( getEnemyBasefile() ) ) goto CLOSEBIND; print( "完成\n" ); print( "读取创建宠物文件..." ); if( !ENEMY_initEnemy( getEnemyfile() ) ) goto CLOSEBIND; print( "完成\n" ); print( "读取遇敌组群文件..." ); if( !GROUP_initGroup( getGroupfile() ) ) goto CLOSEBIND; print( "完成\n" ); print( "读取魔法文件..." ); if( !MAGIC_initMagic( getMagicfile() ) ) goto CLOSEBIND; print( "完成\n" ); #ifdef __ATTACK_MAGIC print( "读取魔法攻击文件..." ); if( !ATTMAGIC_initMagic( getAttMagicfileName() ) )// if( !ATTMAGIC_initMagic( getMagicfile() ) ) goto CLOSEBIND; print( "魔法攻击文件 -->%s..." , getAttMagicfileName()); print( "完成\n" ); #endif print( "读取宠物技能文件..." ); if( !PETSKILL_initPetskill( getPetskillfile() ) ) goto CLOSEBIND; print( "完成\n" );#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 print( "读取职业技能文件..." ); if( !PROFESSION_initSkill( getProfession() ) ){ goto CLOSEBIND; } print( "完成\n" );#endif /* 失奶 丞及笺 毛 戈 */ print( "读取物品成份文件..." ); if( !ITEM_initItemAtom( getItematomfile()) ) goto CLOSEBIND; print("完成\n" ); print( "初始化物品高速缓冲..." ); if( !ITEM_initItemIngCache() ) goto CLOSEBIND; print("完成\n" ); print( "初始化物品名称..." ); if( !ITEM_initRandTable() ) goto CLOSEBIND; print("完成\n" ); print( "读取遇敌配置文件..." ); if( !CHAR_initEffectSetting( getEffectfile() ) ) goto CLOSEBIND; print( "完成\n" ); print( "读取猜迷问题文件..." ); if( !QUIZ_initQuiz( getQuizfile() ) ) goto CLOSEBIND; print( "完成\n" );#ifdef _BLACK_MARKET print( "地下市场文件..." ); if ( !LoadBMItem(getBMItemFile()) ) goto CLOSEBIND; print( "完成\n" );#endif#ifdef _GMRELOAD print( "读取GM配置文件..." ); if ( !LoadGMSet( getGMSetfile() ) ) goto CLOSEBIND; print( "完成\n" );#endif#ifdef _GMRELOAD print( "读取经验配置文件..." ); if ( !LoadEXP( getEXPfile() ) ) goto CLOSEBIND; print("最高等级: %d...",getMaxLevel()); print("一般等级: %d...",getYBLevel()); print( "完成\n" );#endif#ifdef _ANGEL_SUMMON print("读取任务列表文件..."); if( !LoadMissionList( ) ) goto CLOSEBIND; print("完成\n");#endif#ifdef _CONTRACT print("读取契约文件..."); //if( !LoadMissionList( ) ) // goto CLOSEBIND; if( !ITEM_initContractTable() ) goto CLOSEBIND; print("完成\n");#endif#ifdef _JOBDAILY print("读取任务日志文件..."); if(!LoadJobdailyfile()) goto CLOSEBIND; print("完成\n");#endif#ifdef _RACEMAN print("读取宠物赛跑文件..."); if(!LoadRacepetfile()) goto CLOSEBIND; print("完成\n");#endif#ifdef _LOCK_IP print("读取锁定IP文件..."); if(!loadLockip( getLockipPath())) goto CLOSEBIND; print("完成\n");#endif print( "建立地图..." ); if( !MAP_initReadMap( getMaptilefile() , getMapdir() )) goto CLOSEBIND; print( "完成\n" ); print( "读取NPC文件..." ); if( !NPC_readNPCSettingFiles( getNpcdir(), getNpctemplatenum(), getNpccreatenum() ) ) goto CLOSEBIND; print( "完成\n" ); print( "初始化 NPC 服务器... " ); if( lssproto_InitServer( lsrpcClientWriteFunc, LSGENWORKINGBUFFER ) < 0 ) goto CLOSEBIND; print( "完成\n" ); print( "尝试连接账号服务器... " ); acfd = connectHost( getAccountservername(), getAccountserverport()); if(acfd == -1) goto CLOSEBIND;/* { int errorcode; int errorcodelen; int qs; errorcodelen = sizeof(errorcode); qs = getsockopt( acfd, SOL_SOCKET, SO_RCVBUF , &errorcode, &errorcodelen); //andy_log print("\n\n GETSOCKOPT SO_RCVBUF: [ %d, %d, %d] \n", qs, errorcode, errorcodelen); }*/ print( "完成\n" ); initConnectOne( acfd, NULL , 0 ); if( !CONNECT_acfdInitRB( acfd)) goto CLOSEAC; if( !CONNECT_acfdInitWB( acfd)) goto CLOSEAC; CONNECT_setCtype( acfd, AC ); print( "初始化 NPC 客户端 ... " ); /* rpc(client)及赓渝祭 */ if( saacproto_InitClient( lsrpcClientWriteFunc,LSGENWORKINGBUFFER, acfd) < 0 ) goto CLOSEAC; print( "完成\n" ); print( "向账号服务器发送登陆请求... " ); /* 夫弘奶件邰菲毛请允 */ saacproto_ACServerLogin_send(acfd, getGameservername(), getAccountserverpasswd()); print( "完成\n" ); if( isExistFile( getLsgenlogfilename() ) ){ lssproto_SetServerLogFiles( getLsgenlogfilename(), getLsgenlogfilename() ); saacproto_SetClientLogFiles( getLsgenlogfilename(), getLsgenlogfilename() ); } print( "初始化已完成\n" );#ifdef _MUSEUM if( getMuseum() ) print("\n这是石器博物馆!!\n"); else print("\n这是普通星球!!\n");#endif print( "开始记始日志\n" ); { char logconffile[512]; snprintf( logconffile, sizeof( logconffile), "%s/%s" , getLogdir(), getLogconffile() ); if( !initLog( logconffile ) ) goto CLOSEAC; }#ifdef _M_SERVER print( "尝试连接GM服务器... " ); mfd = connectmServer( getmservername(), getmserverport()); if (mfd ==-1 ){ print( "连接GM服务器失败... " ); }else{ initConnectOne( mfd, NULL , 0 ); print( "成败连接GM服务器... " ); }#endif#ifdef _NPCSERVER_NEW npcfd = connectNpcServer( getnpcserveraddr(), getnpcserverport()); if( npcfd == -1 ){ print( "连接NPC服务器失败... " ); }else{ initConnectOne( npcfd, NULL , 0 ); print( "成败连接NPC服务器... " ); NPCS_NpcSLogin_send( npcfd); }#endif #ifdef _ITEM_QUITPARTY print( "读取队伍解散物品消失文件..." ); //读取档案 f = fopen( getitemquitparty(), "r" ); if( f != NULL ){ while( fgets( line, sizeof( line ), f ) ){ if( line[0] == '#' )continue; if( line[0] == '\n' )continue; chomp( line ); itemquitparty_num++; } if( fseek( f, 0, SEEK_SET ) == -1 ){ print( "物品录找错误\n" ); fclose(f); goto CLOSEAC; } //配记忆体 Disappear_Item = allocateMemory( sizeof(struct tagDisappearItem) * itemquitparty_num ); if( Disappear_Item == NULL ){ print( "无法分配内存 %d\n", sizeof(struct tagDisappearItem) * itemquitparty_num ); fclose( f ); goto CLOSEAC; } i = 0; //将道具编号存入 Disappear_Item.string while( fgets( line, sizeof( line ), f ) ){ if( line[0] == '#' )continue; if( line[0] == '\n' )continue; chomp( line ); sprintf( Disappear_Item[i].string,"%s",line ); print("\n道具编号:%s", Disappear_Item[i].string ); i++; } fclose(f); }#endif DEBUG_ADJUSTTIME = 0; print( "\n" ); return TRUE;CLOSEAC: close( acfd );CLOSEBIND: close( bindedfd ); endConnect();MEMEND: memEnd();RETURNFALSE: return FALSE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -