コード例 #1
0
ファイル: npcutil.c プロジェクト: darciusal/stoneagecode
static char *NPC_Util_MargeStrFromArgFile( char *filename, char *buf, int len)
{
	FILE	*fp;
	char	*cret = NULL;
	char	line[NPC_UTIL_GETARGSTR_LINEMAX];
	char	opfile[256];

	sprintf( opfile, "%s/", getNpcdir( ) );
	strcat( opfile, filename);
	*buf = '\0';
	fp = fopen( opfile, "r");
	if( fp != NULL ) {
		while( fgets( line, sizeof( line), fp)) {
			if( strlen(buf) != 0 ) {
				if( buf[strlen(buf) -1] != '|' ) {
					strcatsafe( buf, len, "|");
				}
			}
			chompex( line);
			strcatsafe( buf,len,  line);
		}
		fclose( fp);
		cret=buf;
	}
	return cret;
}
コード例 #2
0
ファイル: readnpc.c プロジェクト: darciusal/stoneagecode
BOOL NPC_reloadNPC(void)
{
	int i;
	int charnum = getFdnum()+ getPetcharnum()+getOtherscharnum();
	for(i=0;i<charnum;i++){
		if(!CHAR_CHECKINDEX(i)) continue;
		if(CHAR_getWorkInt(i,CHAR_WORKNPCTYPE)==1){
			NPC_Util_NPCDelete(i);
		}
	}
	if(NPC_readNPCSettingFiles( getNpcdir(), getNpctemplatenum(),
                                  getNpccreatenum() )==TRUE)
  	NPC_generateLoop( 1 );
  if(getReloadNpcType()==1){
  	int j;
  	int playernum = CHAR_getPlayerMaxNum();
  	for(j=0;j<playernum;j++){
  		if( CHAR_getCharUse(j) != FALSE ) {
  			if(CHAR_getWorkInt(j,CHAR_WORK_OFFLINE)==0 && CHAR_getWorkInt(j,CHAR_WORKBATTLEMODE)==BATTLE_CHARMODE_NONE){
  				CHAR_warpToSpecificPoint(j,CHAR_getInt(j,CHAR_FLOOR),CHAR_getInt(j,CHAR_X),CHAR_getInt(j,CHAR_Y));
  			}
  		}
  	}
  }
  return TRUE;
}
コード例 #3
0
ファイル: init.c プロジェクト: beijunyi/custom-sa
int init(int argc, char **argv, char **env) {
#ifdef _ITEM_QUITPARTY
  FILE *f;
  int i;
  char line[256];
#endif
  srand(getpid());
  print("This Program is compiled at %s %s by gcc %s\n",
        __DATE__, __TIME__, __VERSION__);

  defaultConfig(argv[0]);
  signalset();

  GOTORETURNFALSEIFFALSE(parseCommandLine(argc, argv));
  GOTORETURNFALSEIFFALSE(parseEnvironment(env));

  {
    Char aho;
    debug(sizeof(aho), d);
    debug(sizeof(aho.data), d);
    debug(sizeof(aho.string), d);
    debug(sizeof(aho.flg), d);
    debug(sizeof(aho.indexOfExistItems), d);
    debug(sizeof(aho.haveSkill), d);
    debug(sizeof(aho.indexOfHaveTitle), d);
    debug(sizeof(aho.addressBook), d);
    debug(sizeof(aho.workint), d);
    debug(sizeof(aho.workchar), d);
  }

  print("配置文件: %s\n", getConfigfilename());

  GOTORETURNFALSEIFFALSE(readconfigfile(getConfigfilename()));

  nice(getrunlevel());
  {
    int iWork = setAcWBSize();
    if(iWork == 0) {
      printf("----------------------------------------\n");
      printf("-------------[AC缓冲] 无法设置 %s\n", getConfigfilename());
      printf("----------------------------------------\n");
      exit(1);
    } else {
      printf("AC缓冲 = %d\n", iWork);
    }
  }

  if(getDebuglevel() >= 1) {
    print("调试等级: %d\n", getDebuglevel());
    print("运行等级: %d\n", getrunlevel());
    print("接收缓冲: %d\n", getrecvbuffer() * 1024);
    print("发送缓冲: %d\n", getsendbuffer() * 1024);
    print("接收缓冲下限: %d\n", getrecvlowatbuffer());
    print("内存单元大小: %d\n", getMemoryunit());
    print("内存单元数量: %d\n", getMemoryunitnum());

    print("账号服务器地址: %s\n", getAccountservername());
    print("账号服务器端口: %d\n", getAccountserverport());
    print("登陆服务器名称: %s\n", getGameservername());
    print("登陆服务器密码: %s\n", getAccountserverpasswd());

    print("等待连接端口: %d\n", getPortnumber());

    print("服务端序列号: %d\n", getServernumber());

    print("重复地址使用: %d\n", getReuseaddr());


    print("最大在线人数: %d\n", getFdnum());
    print("最大在线宠数: %d\n", getPetcharnum());
    print("最大其他数目: %d\n", getOtherscharnum());
    print("最大对象数目: %d\n", getObjnum());
    print("最大物品数目: %d\n", getItemnum());
    print("最大战斗数目: %d\n", getBattlenum());
    print("顶层文件目录: %s\n", getTopdir());
    print("地图文件目录: %s\n", getMapdir());
    print("地图标识文件: %s\n", getMaptilefile());
    print("物品配置文件: %s\n", getItemfile());
    print("不可战斗文件: %s\n", getInvfile());
    print("显示位置文件: %s\n", getAppearfile());
    print("头衔名称文件: %s\n", getTitleNamefile());
    print("头衔配置文件: %s\n", getTitleConfigfile());
    print("遇敌坐标文件: %s\n", getEncountfile());
    print("遇敌组群文件: %s\n", getGroupfile());
    print("宠物基本文件: %s\n", getEnemyBasefile());
    print("创建宠物文件: %s\n", getEnemyfile());
    print("精灵魔法文件: %s\n", getMagicfile());

#ifdef _ATTACK_MAGIC
    print("攻击魔法文件: %s\n", getAttMagicfileName());
#endif

    print("宠物技能文件: %s\n", getPetskillfile());
    print("物品成份文件: %s\n", getItematomfile());
    print("猜迷问题文件: %s\n", getQuizfile());
#ifdef _GMRELOAD
    print("G M 配置文件: %s\n", getGMSetfile());
#endif
    print("日志记录文件: %s\n", getLsgenlogfilename());
    print("还原资料目录: %s\n", getStoredir());
    print("NPC 配置目录: %s\n", getNpcdir());
    print("日志记载文件: %s\n", getLogdir());
    print("日志配置文件: %s\n", getLogconffile());
    print("GM的指命密码: %s\n", getChatMagicPasswd());
    print("使用GM的权限: %d\n", getChatMagicCDKeyCheck());

    print("NPC 模板数目: %d\n", getNpctemplatenum());
    print("NPC 最大数目: %d\n", getNpccreatenum());

    print("走路时间间隔: %d\n", getWalksendinterval());
    print("清除所有间隔: %d\n", getCAsendinterval_ms());
    print("清除目标间隔: %d\n", getCDsendinterval_ms());
    print("执行一次时间: %d\n", getOnelooptime_ms());
    print("宠物清除时间: %d\n", getPetdeletetime());
    print("道具清除时间: %d\n", getItemdeletetime());
#ifdef _DEL_DROP_GOLD
    print("石器清除时间: %d\n", getGolddeletetime());
#endif
    print("数据保存间隔: %d\n", getCharSavesendinterval());

    print("名片最大数目: %d\n", getAddressbookoffmsgnum());
    print("读取频率协议: %d\n", getProtocolreadfrequency());

    print("连接错误上限: %d\n", getAllowerrornum());
#ifdef _GET_BATTLE_EXP
    print("战斗经验倍数: %d倍\n", getBattleexp() );
#endif
#ifdef _NEW_PLAYER_CF
    print("出生人物转数: %d转\n", getNewplayertrans());
    print("出生人物等级: %d级\n", getNewplayerlv());
    print("出生人物金钱: %d S\n", getNewplayergivegold());
    print("出生宠物等级: %d级\n", getNewplayerpetlv());
#ifdef _VIP_SERVER
    print("出生拥有点数: %d点\n", getNewplayergivevip());
#endif
    print("出生能骑等级: %d\n", getRidePetLevel());
#ifdef _NEW_PLAYER_RIDE
    print("出生配套骑宠: %s\n", getPlayerRide());
#endif
    print("出生拥有宠物: NO1:%d NO2:%d NO3:%d NO4:%d NO5:%d\n", getNewplayergivepet(0),
          getNewplayergivepet(1),
          getNewplayergivepet(2),
          getNewplayergivepet(3),
          getNewplayergivepet(4));
    print("出生拥有物品: ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n"
              "       ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n"
              "       ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n", getNewplayergiveitem(0), getNewplayergiveitem(1),
          getNewplayergiveitem(2), getNewplayergiveitem(3), getNewplayergiveitem(4), getNewplayergiveitem(5),
          getNewplayergiveitem(6), getNewplayergiveitem(7), getNewplayergiveitem(8), getNewplayergiveitem(9),
          getNewplayergiveitem(10), getNewplayergiveitem(11), getNewplayergiveitem(12), getNewplayergiveitem(13),
          getNewplayergiveitem(14));
#endif
#ifdef _UNREG_NEMA
    print("禁止人物名称: 名字1:%s 名字2:%s 名字3:%s 名字4:%s 名字5:%s\n", getUnregname(0),
          getUnregname(1),
          getUnregname(2),
          getUnregname(3),
          getUnregname(4));
#endif
#ifdef _UNLAW_WARP_FLOOR
    print("禁止传送地图: 地图1:%d 地图2:%d 地图3:%d 地图4:%d 地图5:%d\n"
              "              地图1:%d 地图2:%d 地图3:%d 地图4:%d 地图5:%d\n", getUnlawwarpfloor(0),
          getUnlawwarpfloor(1),
          getUnlawwarpfloor(2),
          getUnlawwarpfloor(3),
          getUnlawwarpfloor(4),
          getUnlawwarpfloor(5),
          getUnlawwarpfloor(6),
          getUnlawwarpfloor(7),
          getUnlawwarpfloor(8),
          getUnlawwarpfloor(9));
#endif
#ifdef _WATCH_FLOOR
    print("是否全图观战: %s\n",getWatchFloorCF());
    if(strcmp(getWatchFloorCF(),"是"))
      print("允许观战地图: 地图1:%d 地图2:%d 地图3:%d 地图4:%d 地图5:%d\n",getWatchFloor(1),
                                                                    getWatchFloor(2),
                                                                    getWatchFloor(3),
                                                                    getWatchFloor(4),
                                                                    getWatchFloor(5));
#endif

#ifdef _BATTLE_FLOOR
    print("是否强制战斗: %s\n",getBattleFloorCF());
    if(strcmp(getBattleFloorCF(),"是"))
      print("强制战斗地图: 地图1:%d 地图2:%d 地图3:%d 地图4:%d 地图5:%d\n",getBattleFloor(1),
                                                                    getBattleFloor(2),
                                                                    getBattleFloor(3),
                                                                    getBattleFloor(4),
                                                                    getBattleFloor(5));
#endif

#ifdef _TRANS_LEVEL_CF
    print("人物等级转数: %d级\n", getChartrans());
    print("宠物等级转数: %d级\n", getPettrans());
#endif

#ifdef _POINT
    print("禁止点数上限: %s\n", getPoint());
    if(strcmp(getPoint(), "是"))
      print("每转点数上限: 0转:%d 1转:%d 2转:%d 3转:%d 4转:%d 5转:%d 6转:%d\n", getTransPoint(0),
            getTransPoint(1),
            getTransPoint(2),
            getTransPoint(3),
            getTransPoint(4),
            getTransPoint(5),
            getTransPoint(6));
#endif
#ifdef _PET_UP
    print("宠物能否捡获: %s\n", getPetup());
#endif
#ifdef _LOOP_ANNOUNCE
    print("循环公告路径: %s\n",getLoopAnnouncePath());
    print("循环时间间隔: %d分钟\n",getLoopAnnounceTime());
#endif
#ifdef _SKILLUPPOINT_CF
    print("每级升级点数: %d\n",getSkup());
#endif

#ifdef _RIDELEVEL
    print("骑宠等级相差: %d级\n",getRideLevel());
#endif
#ifdef _REVLEVEL
    print("还原上限等级: %s级\n",getRevLevel());
#endif
#ifdef _TRANS_LEVEL_CF
    print("一般等级上限: %d级\n", getYBLevel());
    print("最高等级上限: %d级\n", getMaxLevel());
#endif
#ifdef _FIX_CHARLOOPS
    print("恶魔时间倍数: %d倍\n", getCharloops());
#endif
#ifdef _PLAYER_ANNOUNCE
    if(getPAnnounce() == -1)
      print("喇叭消耗点数: 关闭使用\n");
    else
      print("喇叭消耗点数: %d点\n", getPAnnounce());
#endif
#ifdef _PLAYER_MOVE
    if(getPMove() == -1)
      print("顺移消耗点数: 关闭使用\n");
    else
      print("顺移消耗点数: %d点\n", getPMove());
#endif
#ifdef _BATTLE_GOLD
    print("战斗获得金钱: %d%\n", getBattleGold());
#endif
#ifdef _ANGEL_TIME
    print("精灵召唤时间: (%d人/在线人数)分\n", getAngelPlayerTime());
    print("精灵召唤人数: %d人\n", getAngelPlayerMun());
#endif
#ifdef _RIDEMODE_20
    print("2.0 骑宠模式: %d\n", getRideMode());
#endif
#ifdef _FM_POINT_PK
    print("庄园互抢模式: %s\n", getFmPointPK());
#endif
  }

  {  //andy_add 2003/05/05 check GameServer Name
    char *GameServerName;
    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");

  print("始终化连接空间...");
  if(!initConnect(getFdnum()))
    goto MEMEND;
  print("完成\n");
  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("建立物品...");
  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");

  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(!QUIZ_initQuiz(getQuizfile()))
    goto CLOSEBIND;
  print("完成\n");
#ifdef _GMRELOAD
  print("读取GM配置文件...");
  if(!LoadGMSet(getGMSetfile()))
    goto CLOSEBIND;
  print("完成\n");
#endif

#ifdef _USER_EXP_CF
  print( "读取经验配置文件..." );
  if ( !LoadEXP( getEXPfile() ) )
    goto CLOSEBIND;
  print("最高等级: %d...",getMaxLevel());
  print("一般等级: %d...",getYBLevel());
  print( "完成\n" );
#endif

#ifdef _LOOP_ANNOUNCE
  print("读取循环公告文件...");
  if(!loadLoopAnnounce())
    print("...失败\n");
  else
   print("完成\n");
#endif
#ifdef _RIDE_CF
  print("读取自定义骑宠文件...");
  if(!CHAR_Ride_CF_init())
    print("...失败\n");
  print("完成\n");
#endif
#ifdef _FM_LEADER_RIDE
  print("读取庄园族长专用骑宠文件...");
  if(!CHAR_FmLeaderRide_init())
    print("...失败\n");
  print("完成\n");
#endif
#ifdef _NEED_ITEM_ENEMY
  print("读取融合宠配置文件...");
  if(!need_item_eneny_init())
    print("...失败\n");
  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;

  print("完成\n");
  initConnectOne(acfd, NULL, 0);
  if(!CONNECT_acfdInitRB(acfd)) goto CLOSEAC;
  if(!CONNECT_acfdInitWB(acfd)) goto CLOSEAC;
  CONNECT_setCtype(acfd, AC);

  print("初始化 NPC 客户端 ... ");
  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");

  print("开始记始日志\n");
  {
    if(!initLog(getLogconffile()))
      goto CLOSEAC;
  }
#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;
  return TRUE;

  CLOSEAC:
  close(acfd);
  CLOSEBIND:
  close(bindedfd);
  endConnect();
  MEMEND:
  memEnd();
  RETURNFALSE:
  return FALSE;
}
コード例 #4
0
ファイル: npc_riderman.c プロジェクト: darciusal/stoneagecode
/*
 *
 * 娄醒“
 *		meindex		int		仇及NPC及charaindex
 *
 */
static BOOL NPC_Riderman_readData( int meindex, int windowno, BOOL chkflg)
{

    int		i;
    int		linenum = 0;
    int		endflg = FALSE;
    int		buttonendflg;
    int		winno = -1;
    int		buttonconfmode;
    int		b_mode;
    int		selectnum ;
    int		messagepos;
    BOOL	errflg = FALSE;
    BOOL	readflg = TRUE;
    FILE	*fp;
    char	argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
    char	filename[64];
    char	opfile[128];
    char	line[1024];
    char	firstToken[1024];
    char	secondToken[1024];


    NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr));
    NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename));

    sprintf( opfile, "%s/", getNpcdir( ) );
    strcat( opfile, filename);

    fp = fopen( opfile, "r");
    if( fp == NULL ) {
        print( "riderman:file open error [%s]\n", opfile);
        return FALSE;
    }

    while( readflg == TRUE ) {
        endflg = FALSE;
        buttonendflg = TRUE;
        buttonconfmode = FALSE;
        selectnum = 0;
        messagepos = 0;
        winno = -1;
        b_mode = -1;
        errflg = FALSE;

        /* 赓渝祭 */
        w.windowno = -1;
        w.windowtype = -1;
        w.buttontype = -1;
        w.takeitem = -1;
        w.giveitem = -1;
        w.takegold = 0;
        w.message[0] = '\0';

        for( i = 0; i < arraysizeof( buttonproc); i ++ ) {
            buttonproc[i].use = FALSE;
            buttonproc[i].checkhaveitem = -1;
            buttonproc[i].checkhaveitemgotowin = -1;
            buttonproc[i].checkdonthaveitem = -1;
            buttonproc[i].checkdonthaveitemgotowin = -1;
            buttonproc[i].warp = -1;
            buttonproc[i].battle = -1;
            buttonproc[i].gotowin = -1;
        }

        while( 1) {
            char    buf[256];
            int		ret;
            if( !fgets( line, sizeof( line), fp)) {
                readflg = FALSE;
                break;
            }

            linenum ++;

            if( line[0] == '#' || line[0] == '\n') continue;
            /* 荼垫潸月 */
            chomp( line );

            /*  垫毛帮溥允月    */
            replaceString( line, '\t' , ' ' );
            for( i = 0; i < strlen( line); i ++) {
                if( line[i] != ' ' ) {
                    break;
                }
                strcpy( buf, &line[i]);
            }
            if( i != 0 ) strcpy( line, buf);

            ret = getStringFromIndexWithDelim( line, "=",  1, firstToken,
                                               sizeof( firstToken ) );
            if( ret == FALSE ) {
                print( "Find error at %s in line %d. Ignore\n",
                       filename , linenum);
                continue;
            }
            ret = getStringFromIndexWithDelim( line, "=", 2, secondToken,
                                               sizeof( secondToken ) );
            if( ret == FALSE ) {
                print( "Find error at %s in line %d. Ignore\n",
                       filename , linenum);
                continue;
            }

            if( strcasecmp( firstToken, "winno") == 0 ) {
                if( winno != -1 ) {
                    print( "riderman:已有winno却重新定义winno\n");
                    print( "filename:[%s] line[%d]\n", filename, linenum);
                    errflg = TRUE;
                    readflg = FALSE;
                    break;
                }
                /* 它奴件玉它No毛忡绣 */
                winno = atoi( secondToken);
                continue;
            }

            if( winno == -1 ) {
                print( "riderman:winno 尚未定义,资料却已设定。\n");
                print( "filename:[%s] line[%d]\n", filename, linenum);
                readflg = FALSE;
                errflg = FALSE;
                break;
            }
            if( (chkflg == FALSE && winno == windowno )||
                    chkflg == TRUE)
            {
                if( buttonconfmode == TRUE ) {
                    if( strcasecmp( firstToken, "gotowin") == 0 ) {
                        buttonproc[b_mode].gotowin = atoi( secondToken);
                    }
                    else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) {
                        buttonproc[b_mode].checkhaveitem = atoi( secondToken);
                    }
                    else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) {
                        buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken);
                    }
                    else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) {
                        buttonproc[b_mode].checkdonthaveitem = atoi( secondToken);
                    }
                    else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) {
                        buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken);
                    }
                    else if( strcasecmp( firstToken, "endbutton") == 0 ) {
                        if( buttonproc[b_mode].gotowin == - 1 ) {
                            if( buttonproc[b_mode].checkhaveitem == -1 &&
                                    buttonproc[b_mode].checkdonthaveitem == -1)
                            {
                                errflg = TRUE;
                            }
                            else {
                                if( !((buttonproc[b_mode].checkhaveitem != -1 &&
                                        buttonproc[b_mode].checkhaveitemgotowin != -1)
                                        || (buttonproc[b_mode].checkdonthaveitem != -1 &&
                                            buttonproc[b_mode].checkdonthaveitemgotowin != -1)))
                                {
                                    errflg = TRUE;
                                }
                            }
                        }

                        if( errflg == TRUE) {
                            print( "riderman: 找不到gotowin\n");
                            print( "filename:[%s] line[%d]\n", filename, linenum);
                            readflg = FALSE;
                            errflg = TRUE;
                            break;
                        }
                        buttonproc[b_mode].use = TRUE;
                        buttonconfmode = FALSE;
                        buttonendflg = TRUE;
                    }
                }
                else {

                    w.windowno = winno;
                    /* 它奴件玉它正奶皿及涩烂 */
                    if( strcasecmp( firstToken, "wintype") == 0 ) {
                        w.windowtype = atoi( secondToken);
                    }
                    /* 示正件正奶皿及涩烂 */
                    else if( strcasecmp( firstToken, "buttontype") == 0 ) {
                        w.buttontype = NPC_Riderman_restoreButtontype( secondToken);
                    }
                    /* getitem及涩烂 */
                    else if( strcasecmp( firstToken, "takeitem") == 0 ) {
                        w.takeitem = atoi( secondToken);
                    }
                    /* giveitem及涩烂 */
                    else if( strcasecmp( firstToken, "giveitem") == 0 ) {
                        w.giveitem = atoi( secondToken);
                    }

                    /* takegold 学费 */
                    else if( strcasecmp( firstToken, "takegold") == 0 ) {
                        w.takegold = atoi( secondToken);
                    }

                    // Robin
                    else if( strcasecmp( firstToken, "letter1") == 0 ) {
                        w.letter[0] = atoi( secondToken);
                    }
                    else if( strcasecmp( firstToken, "letter2") == 0 ) {
                        w.letter[1] = atoi( secondToken);
                    }
                    else if( strcasecmp( firstToken, "letter3") == 0 ) {
                        w.letter[2] = atoi( secondToken);
                    }
                    else if( strcasecmp( firstToken, "letter4") == 0 ) {
                        w.letter[3] = atoi( secondToken);
                    }

                    /* message及涩烂 */
                    else if( strcasecmp( firstToken, "message") == 0 ) {
                        if( messagepos == 0 ) {
                            strcpy(  w.message, secondToken);
                            messagepos = strlen( w.message);
                        }
                        else {
                            w.message[messagepos]='\n';
                            messagepos++;
                            strcpy( &w.message[messagepos], secondToken);
                            messagepos+=strlen(secondToken);
                        }
                    }
                    /* 示正件毛瓷仄凶凛及涩烂 */
                    else if( strcasecmp( firstToken, "okpressed") == 0 ) {
                        buttonconfmode = TRUE;
                        b_mode = 0;
                        buttonendflg = FALSE;
                    }
                    else if( strcasecmp( firstToken, "cancelpressed") == 0 ) {
                        buttonconfmode = TRUE;
                        b_mode = 1;
                        buttonendflg = FALSE;
                    }
                    else if( strcasecmp( firstToken, "yespressed") == 0 ) {
                        buttonconfmode = TRUE;
                        b_mode = 2;
                        buttonendflg = FALSE;
                    }
                    else if( strcasecmp( firstToken, "nopressed") == 0 ) {
                        buttonconfmode = TRUE;
                        b_mode = 3;
                        buttonendflg = FALSE;
                    }
                    else if( strcasecmp( firstToken, "prevpressed") == 0 ) {
                        buttonconfmode = TRUE;
                        b_mode = 4;
                        buttonendflg = FALSE;
                    }
                    else if( strcasecmp( firstToken, "nextpressed") == 0 ) {
                        buttonconfmode = TRUE;
                        b_mode = 5;
                        buttonendflg = FALSE;
                    }
                    else if( strcasecmp( firstToken, "selected") == 0 ) {
                        buttonconfmode = TRUE;
                        b_mode = 6 + selectnum;
                        buttonendflg = FALSE;
                        selectnum ++;
                    }
                    /* 涩烂蔽歹曰 */
                    else if( strcasecmp( firstToken, "endwin") == 0 ) {
                        endflg = TRUE;
                        if( chkflg == FALSE) {
                            readflg = FALSE;
                        }
                        break;
                    }
                    else {
                        print( "riderman:设定是不可能的参数\n");
                        print( "filename:[%s] line[%d]\n", filename, linenum);
                    }
                }
            }
            else {
                if( strcasecmp( firstToken, "endwin") == 0 ) {
                    winno = -1;
                }
            }
        }
        if( buttonendflg == FALSE) {
            print( "riderman: 找不到endbutton\n");
            print( "filename:[%s] line[%d]\n", filename, linenum);
            errflg = TRUE;
            break;
        }
        if( winno != -1 ) {
            if( w.windowtype == -1 ) {
                print( "riderman: 找不到wintype\n");
                print( "filename:[%s] line[%d]\n", filename, linenum);
                errflg = TRUE;
                break;
            }
            if( w.buttontype == -1 ) {
                print( "riderman: 找不到button\n");
                print( "filename:[%s] line[%d]\n", filename, linenum);
                errflg = TRUE;
                break;
            }
            if( strlen( w.message) == 0 ) {
                print( "riderman: 找不到message\n");
                print( "filename:[%s] line[%d]\n", filename, linenum);
                errflg = TRUE;
                break;
            }
        }
    }
    fclose( fp);

    if( chkflg == FALSE && w.windowno == -1 ) {
        print( "riderman: 找不到所指定的windowno\n");
        print( "filename:[%s] line[%d]\n", filename, linenum);
        return FALSE;
    }
    if( winno != -1 && endflg == FALSE) {
        print( "riderman: 找不到endwin\n");
        print( "filename:[%s] line[%d]\n", filename, linenum);
        return FALSE;
    }
    if( errflg == TRUE) return FALSE;

    return TRUE;
}
コード例 #5
0
ファイル: npc_bankman.c プロジェクト: ChowZenki/SMO-Sa-Source
static BOOL NPC_Bankman_readData( int meindex, int windowno, BOOL chkflg)
{
	
	int		i;
	int		linenum = 0;
	int		endflg = FALSE;
	int		buttonendflg;
	int		winno = -1;
	int		buttonconfmode;
	int		b_mode;
	int		selectnum ;
	int		messagepos;
	BOOL	errflg = FALSE;
	BOOL	readflg = TRUE;
	FILE	*fp;
	char	argstr1[NPC_UTIL_GETARGSTR_BUFSIZE];
	char *argstr;
	char	filename[64];
	char	opfile[128];
	char	line[1024];
	char	firstToken[1024];
	char	secondToken[1024];

	argstr = NPC_Util_GetArgStr( meindex, argstr1, sizeof( argstr1));
	NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename));
	sprintf( opfile, "%s/", getNpcdir( ) );
	strcat( opfile, filename);
	fp = fopen( opfile, "r");
	if( fp == NULL ) {
		print( "familyman:file open error [%s]\n", opfile);
		return FALSE;
	}
	
	while( readflg == TRUE ) {
		endflg = FALSE;
		buttonendflg = TRUE;
		buttonconfmode = FALSE;
		selectnum = 0;
		messagepos = 0;
		winno = -1;
		b_mode = -1;
		errflg = FALSE;

		/* ½é´ü²½ */
		w.windowno = -1;
		w.windowtype = -1;
		w.buttontype = -1;
		w.takeitem = -1;
		w.giveitem = -1;
		w.message[0] = '\0';
	
		for( i = 0; i < arraysizeof( buttonproc); i ++ ) {
			buttonproc[i].use = FALSE;
			buttonproc[i].checkhaveitem = -1;
			buttonproc[i].checkhaveitemgotowin = -1;
			buttonproc[i].checkdonthaveitem = -1;
			buttonproc[i].checkdonthaveitemgotowin = -1;
			buttonproc[i].warp = -1;
			buttonproc[i].battle = -1;
			buttonproc[i].gotowin = -1;
		}

		while( 1) {
			char    buf[256];
			int		ret;
			if( !fgets( line, sizeof( line), fp)){
				readflg = FALSE;
				break;
			}
			
			linenum ++;
			
			/* ¥³¥á¥ó¥È¤Ï  »ë */
			if( line[0] == '#' || line[0] == '\n') continue;
			/* ²þ¹Ô¼è¤ë */
			chomp( line );
			
			/*  ¹Ô¤òÀ°·Á¤¹¤ë    */
			/*  ¤Þ¤º tab ¤ò " " ¤Ë  ¤­´¹¤¨¤ë    */
			replaceString( line, '\t' , ' ' );
			/* Àè  ¤Î¥¹¥Ú¡¼¥¹¤ò¼è¤ë¡e*/
			for( i = 0; i < strlen( line); i ++) {
				if( line[i] != ' ' ) {
					break;
				}
				strcpy( buf, &line[i]);
			}
			if( i != 0 ) strcpy( line, buf);

			/* delim "=" ¤Ç  ½é(1)¤Î¥È¡¼¥¯¥ó¤ò  ¤ë*/
			ret = getStringFromIndexWithDelim( line, "=",  1, firstToken,
											   sizeof( firstToken ) );
			if( ret == FALSE ){
				print( "Find error at %s in line %d. Ignore\n",
					   filename , linenum);
				continue;
			}
			/* delim "=" ¤Ç2    ¤Î¥È¡¼¥¯¥ó¤ò  ¤ë*/
			ret = getStringFromIndexWithDelim( line, "=", 2, secondToken,
											   sizeof( secondToken ) );
			if( ret == FALSE ){
				print( "Find error at %s in line %d. Ignore\n",
					   filename , linenum);
				continue;
			}
			
			if( strcasecmp( firstToken, "winno") == 0 ) {
				if( winno != -1 ) {
					print( "familyman:¤w¦³winno«o­«·s©w¸qwinno\n");
					print( "filename:[%s] line[%d]\n", filename, linenum);
					errflg = TRUE;
					readflg = FALSE;
					break;
				}
				/* ¥¦¥£¥ó¥É¥¦No¤òÊݸ */
				winno = atoi( secondToken);
				continue;
			}
			/* ¥¦¥£¥ó¥É¥¦No ¤¬·è¤Þ¤Ã¤Æ¤¤¤Ê¤¤»þ¤Î¹Ô¤Ï  »ë¤¹¤ë */
			if( winno == -1 ) {
				print( "familyman:winno ©|¥¼©w¸q¡A¸ê®Æ«o¤w³]©w¡C\n");
				print( "filename:[%s] line[%d]\n", filename, linenum);
				readflg = FALSE;
				errflg = FALSE;
				break;
			}
			/* ¥¦¥£¥ó¥É¥¦No ¤¬°ìÃפ·¤¿»þ¤Ï¾ò·ï¤ò  ¤à¡e
			 * ¤½¤ì°Ê³°¤Ï  »ë¤¹¤ë */
			if( (chkflg == FALSE && winno == windowno )||
				chkflg == TRUE) 
			{
				if( buttonconfmode == TRUE ) {
					if( strcasecmp( firstToken, "gotowin") == 0 ) {
						buttonproc[b_mode].gotowin = atoi( secondToken);
					}
					else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) {
						buttonproc[b_mode].checkhaveitem = atoi( secondToken);
					}
					else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) {
						buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken);
					}
					else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) {
						buttonproc[b_mode].checkdonthaveitem = atoi( secondToken);
					}
					else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) {
						buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken);
					}
					else if( strcasecmp( firstToken, "endbutton") == 0 ) {
						if( buttonproc[b_mode].gotowin == - 1 ) {
							if( buttonproc[b_mode].checkhaveitem == -1 && 
								buttonproc[b_mode].checkdonthaveitem == -1)
							{
								errflg = TRUE;
							}
							else {
								/* ¤É¤Ã¤Á¤«¤«¤¿¤Ã¦Q¤À¤±¤Ç¤âÀßÄꤵ¤ì¤Æ¤¤¤ì¤Ð     */
								if( !((buttonproc[b_mode].checkhaveitem != -1 && 
									   buttonproc[b_mode].checkhaveitemgotowin != -1)
									 || (buttonproc[b_mode].checkdonthaveitem != -1 && 
									     buttonproc[b_mode].checkdonthaveitemgotowin != -1)))
								{
									errflg = TRUE;
								}
							}
						}
						
						if( errflg == TRUE) {
							print( "familyman: §ä¤£¨ìgotowin\n");
							print( "filename:[%s] line[%d]\n", filename, linenum);
							readflg = FALSE;
							errflg = TRUE;
							break;
						}
						buttonproc[b_mode].use = TRUE;
						buttonconfmode = FALSE;
						buttonendflg = TRUE;
					}
				}
				else {
					
					w.windowno = winno;
					/* ¥¦¥£¥ó¥É¥¦¥¿¥¤¥×¤ÎÀßÄê */
					if( strcasecmp( firstToken, "wintype") == 0 ) {
						w.windowtype = atoi( secondToken);
					}
					/* ¥Ü¥¿¥ó¥¿¥¤¥×¤ÎÀßÄê */
					else if( strcasecmp( firstToken, "buttontype") == 0 ) {
						w.buttontype = NPC_Bankman_restoreButtontype( secondToken);
					}
					/* getitem¤ÎÀßÄê */
					else if( strcasecmp( firstToken, "takeitem") == 0 ) {
						w.takeitem = atoi( secondToken);
					}
					/* giveitem¤ÎÀßÄê */
					else if( strcasecmp( firstToken, "giveitem") == 0 ) {
						w.giveitem = atoi( secondToken);
					}
					/* message¤ÎÀßÄê */
					else if( strcasecmp( firstToken, "message") == 0 ) {
						if( messagepos == 0 ) {
							strcpy(  w.message, secondToken);
							messagepos = strlen( w.message);
						}
						else {
							w.message[messagepos]='\n';
							messagepos++;
							strcpy( &w.message[messagepos], secondToken);
							messagepos+=strlen(secondToken);
						}
					}
					/* ¥Ü¥¿¥ó¤ò²¡¤·¤¿»þ¤ÎÀßÄê */
					else if( strcasecmp( firstToken, "okpressed") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 0;
						buttonendflg = FALSE;
					}
					else if( strcasecmp( firstToken, "cancelpressed") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 1;
						buttonendflg = FALSE;
					}
					else if( strcasecmp( firstToken, "yespressed") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 2;
						buttonendflg = FALSE;
					}
					else if( strcasecmp( firstToken, "nopressed") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 3;
						buttonendflg = FALSE;
					}
					else if( strcasecmp( firstToken, "prevpressed") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 4;
						buttonendflg = FALSE;
					}
					else if( strcasecmp( firstToken, "nextpressed") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 5;
						buttonendflg = FALSE;
					}
					else if( strcasecmp( firstToken, "selected") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 6 + selectnum;
						buttonendflg = FALSE;
						selectnum ++;
					}
					/* ÀßÄ꽪¤ï¤ê */
					else if( strcasecmp( firstToken, "endwin") == 0 ) {
						endflg = TRUE;
						if( chkflg == FALSE) {
							readflg = FALSE;
						}
						break;
					}
					else {
						print( "familyman:³]©w¬O¤£¥i¯àªº°Ñ¼Æ\n");
						print( "filename:[%s] line[%d]\n", filename, linenum);
					}
				}
			}
			else {
				if( strcasecmp( firstToken, "endwin") == 0 ) {
					winno = -1;
				}
			}
		}
		if( buttonendflg == FALSE) {
			print( "familyman: §ä¤£¨ìendbutton\n");
			print( "filename:[%s] line[%d]\n", filename, linenum);
			errflg = TRUE;
			break;
		}
		if( winno != -1 ) {
			if( w.windowtype == -1 ) {
				print( "familyman: §ä¤£¨ìwintype\n");
				print( "filename:[%s] line[%d]\n", filename, linenum);
				errflg = TRUE;
				break;
			}
			if( w.buttontype == -1 ) {
				print( "familyman: §ä¤£¨ìbutton\n");
				print( "filename:[%s] line[%d]\n", filename, linenum);
				errflg = TRUE;
				break;
			}
			if( strlen( w.message) == 0 ) {
				print( "familyman: §ä¤£¨ìmessage\n");
				print( "filename:[%s] line[%d]\n", filename, linenum);
				errflg = TRUE;
				break;
			}
		}
	}
	fclose( fp);
	
	if( chkflg == FALSE && w.windowno == -1 ) {
		print( "familyman: §ä¤£¨ì©Ò«ü©wªºwindowno\n");
		print( "filename:[%s] line[%d]\n", filename, linenum);
		return FALSE;
	}
	if( winno != -1 && endflg == FALSE) {
		print( "familyman: §ä¤£¨ìendwin\n");
		print( "filename:[%s] line[%d]\n", filename, linenum);
		return FALSE;
	}
	if( errflg == TRUE) return FALSE;
	
	return TRUE;
}
コード例 #6
0
ファイル: npc_fmletter.c プロジェクト: Nurarihyo/smo-sa
/* 
 * 澀爛白央奶伙毛  氏匹隙爛今木凶windowno及犯□正毛本永玄允月
 * 
 * 婁醒「
 *		meindex		int		仇及NPC及charaindex
 *		windowno	int		它奴件玉它  寞
 *		
 */
static BOOL NPC_FmLetter_readData( int meindex, int windowno, BOOL chkflg)
{
	
	int		i;
	int		linenum = 0;
	int		endflg = FALSE;
	int		buttonendflg;
	int		winno = -1;
	int		buttonconfmode;
	int		b_mode;
	int		selectnum ;
	int		messagepos;
	BOOL	errflg = FALSE;
	BOOL	readflg = TRUE;
	FILE	*fp;
	char	argstr1[NPC_UTIL_GETARGSTR_BUFSIZE];
	char *argstr;
	char	filename[64];
	char	opfile[128];
	char	line[1024];
	char	firstToken[1024];
	char	secondToken[1024];
	
	/* 它奴件玉它及澀爛毛  曰  戈厭瞻   */
	
	argstr = NPC_Util_GetArgStr( meindex, argstr1, sizeof( argstr1));
	/* 澀爛白央奶伙  潸   */
	NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename));

	sprintf( opfile, "%s/", getNpcdir( ) );
	strcat( opfile, filename);
	
	fp = fopen( opfile, "r");
	if( fp == NULL ) {
		print( "fmletter:file open error [%s]\n", opfile);
		return FALSE;
	}
	
	while( readflg == TRUE ) {
		endflg = FALSE;
		buttonendflg = TRUE;
		buttonconfmode = FALSE;
		selectnum = 0;
		messagepos = 0;
		winno = -1;
		b_mode = -1;
		errflg = FALSE;

		/* 賡渝祭 */
		w.windowno = -1;
		w.windowtype = -1;
		w.buttontype = -1;
		w.takeitem = -1;
		w.giveitem = -1;
		w.message[0] = '\0';
	
		for( i = 0; i < arraysizeof( buttonproc); i ++ ) {
			buttonproc[i].use = FALSE;
			buttonproc[i].checkhaveitem = -1;
			buttonproc[i].checkhaveitemgotowin = -1;
			buttonproc[i].checkdonthaveitem = -1;
			buttonproc[i].checkdonthaveitemgotowin = -1;
			buttonproc[i].warp = -1;
			buttonproc[i].battle = -1;
			buttonproc[i].gotowin = -1;
		}

		while( 1) {
			char    buf[256];
			int		ret;
			if( !fgets( line, sizeof( line), fp)){
				readflg = FALSE;
				break;
			}
			
			linenum ++;
			
			/* 戊丟件玄反  骰 */
			if( line[0] == '#' || line[0] == '\n') continue;
			/* 荼墊潸月 */
			chomp( line );
			
			/*  墊毛幫溥允月    */
			/*  引內 tab 毛 " " 卞  五晶尹月    */
			replaceString( line, '\t' , ' ' );
			/* 燮  及旦矢□旦毛潸月〔*/
			for( i = 0; i < strlen( line); i ++) {
				if( line[i] != ' ' ) {
					break;
				}
				strcpy( buf, &line[i]);
			}
			if( i != 0 ) strcpy( line, buf);

			/* delim "=" 匹  賡(1)及玄□弁件毛  月*/
			ret = getStringFromIndexWithDelim( line, "=",  1, firstToken,
											   sizeof( firstToken ) );
			if( ret == FALSE ){
				print( "Find error at %s in line %d. Ignore\n",
					   filename , linenum);
				continue;
			}
			/* delim "=" 匹2    及玄□弁件毛  月*/
			ret = getStringFromIndexWithDelim( line, "=", 2, secondToken,
											   sizeof( secondToken ) );
			if( ret == FALSE ){
				print( "Find error at %s in line %d. Ignore\n",
					   filename , linenum);
				continue;
			}
			
			if( strcasecmp( firstToken, "winno") == 0 ) {
				if( winno != -1 ) {
					print( "fmletter:已有winno卻重新定義winno\n");
					print( "filename:[%s] line[%d]\n", filename, linenum);
					errflg = TRUE;
					readflg = FALSE;
					break;
				}
				/* 它奴件玉它No毛忡繡 */
				winno = atoi( secondToken);
				continue;
			}
			
			/* 它奴件玉它No 互瑁引勻化中卅中凜及墊反  骰允月 */
			if( winno == -1 ) {
				print( "fmletter:winno 尚未定義,資料卻已設定。\n");
				print( "filename:[%s] line[%d]\n", filename, linenum);
				readflg = FALSE;
				errflg = FALSE;
				break;
			}
			/* 它奴件玉它No 互域譙仄凶凜反橢瘀毛  戈〔
			 * 公木動陸反  骰允月 */
			if( (chkflg == FALSE && winno == windowno )||
				chkflg == TRUE) 
			{
				if( buttonconfmode == TRUE ) {
					if( strcasecmp( firstToken, "gotowin") == 0 ) {
						buttonproc[b_mode].gotowin = atoi( secondToken);
					}
					else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) {
						buttonproc[b_mode].checkhaveitem = atoi( secondToken);
					}
					else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) {
						buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken);
					}
					else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) {
						buttonproc[b_mode].checkdonthaveitem = atoi( secondToken);
					}
					else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) {
						buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken);
					}
					else if( strcasecmp( firstToken, "endbutton") == 0 ) {
						if( buttonproc[b_mode].gotowin == - 1 ) {
							if( buttonproc[b_mode].checkhaveitem == -1 && 
								buttonproc[b_mode].checkdonthaveitem == -1)
							{
								errflg = TRUE;
							}
							else {
								/* 升勻切井井凶勻吊分仃匹手澀爛今木化中木壬     */
								if( !((buttonproc[b_mode].checkhaveitem != -1 && 
									   buttonproc[b_mode].checkhaveitemgotowin != -1)
									 || (buttonproc[b_mode].checkdonthaveitem != -1 && 
									     buttonproc[b_mode].checkdonthaveitemgotowin != -1)))
								{
									errflg = TRUE;
								}
							}
						}
						
						if( errflg == TRUE) {
							print( "fmletter: 找不到gotowin\n");
							print( "filename:[%s] line[%d]\n", filename, linenum);
							readflg = FALSE;
							errflg = TRUE;
							break;
						}
						buttonproc[b_mode].use = TRUE;
						buttonconfmode = FALSE;
						buttonendflg = TRUE;
					}
				}
				else {
					
					w.windowno = winno;
					
					sprintf( buf, "letter%d", CHAR_getInt( meindex, CHAR_FMINDEX) );
					
					/* 它奴件玉它正奶皿及澀爛 */
					if( strcasecmp( firstToken, "wintype") == 0 ) {
						w.windowtype = atoi( secondToken);
					}
					/* 示正件正奶皿及澀爛 */
					else if( strcasecmp( firstToken, "buttontype") == 0 ) {
						w.buttontype = NPC_FmLetter_restoreButtontype( secondToken);
					}
					/* getitem及澀爛 */
					else if( strcasecmp( firstToken, "takeitem") == 0 ) {
						w.takeitem = atoi( secondToken);
					}
					/* giveitem及澀爛 */
					else if( strcasecmp( firstToken, "giveitem") == 0 ) {
						w.giveitem = atoi( secondToken);
					}
					else if( strcasecmp( firstToken, buf) == 0 ) {
						w.letter = atoi( secondToken);
					}
					
					/* message及澀爛 */
					else if( strcasecmp( firstToken, "message") == 0 ) {
						if( messagepos == 0 ) {
							strcpy(  w.message, secondToken);
							messagepos = strlen( w.message);
						}
						else {
							w.message[messagepos]='\n';
							messagepos++;
							strcpy( &w.message[messagepos], secondToken);
							messagepos+=strlen(secondToken);
						}
					}
					/* 示正件毛瓷仄凶凜及澀爛 */
					else if( strcasecmp( firstToken, "okpressed") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 0;
						buttonendflg = FALSE;
					}
					else if( strcasecmp( firstToken, "cancelpressed") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 1;
						buttonendflg = FALSE;
					}
					else if( strcasecmp( firstToken, "yespressed") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 2;
						buttonendflg = FALSE;
					}
					else if( strcasecmp( firstToken, "nopressed") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 3;
						buttonendflg = FALSE;
					}
					else if( strcasecmp( firstToken, "prevpressed") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 4;
						buttonendflg = FALSE;
					}
					else if( strcasecmp( firstToken, "nextpressed") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 5;
						buttonendflg = FALSE;
					}
					else if( strcasecmp( firstToken, "selected") == 0 ) {
						buttonconfmode = TRUE;
						b_mode = 6 + selectnum;
						buttonendflg = FALSE;
						selectnum ++;
					}
					/* 澀爛蔽歹曰 */
					else if( strcasecmp( firstToken, "endwin") == 0 ) {
						endflg = TRUE;
						if( chkflg == FALSE) {
							readflg = FALSE;
						}
						break;
					}
					else {
						//print( "fmletter:設定是不可能的參數\n");
						//print( "filename:[%s] line[%d]\n", filename, linenum);
					}
				}
			}
			else {
				if( strcasecmp( firstToken, "endwin") == 0 ) {
					winno = -1;
				}
			}
		}
		if( buttonendflg == FALSE) {
			print( "fmletter: 找不到endbutton\n");
			print( "filename:[%s] line[%d]\n", filename, linenum);
			errflg = TRUE;
			break;
		}
		if( winno != -1 ) {
			if( w.windowtype == -1 ) {
				print( "fmletter: 找不到wintype\n");
				print( "filename:[%s] line[%d]\n", filename, linenum);
				errflg = TRUE;
				break;
			}
			if( w.buttontype == -1 ) {
				print( "fmletter: 找不到button\n");
				print( "filename:[%s] line[%d]\n", filename, linenum);
				errflg = TRUE;
				break;
			}
			if( strlen( w.message) == 0 ) {
				print( "fmletter: 找不到message\n");
				print( "filename:[%s] line[%d]\n", filename, linenum);
				errflg = TRUE;
				break;
			}
		}
	}
	fclose( fp);
	
	if( chkflg == FALSE && w.windowno == -1 ) {
		print( "fmletter: 找不到所指定的windowno\n");
		print( "filename:[%s] line[%d]\n", filename, linenum);
		return FALSE;
	}
	if( winno != -1 && endflg == FALSE) {
		print( "fmletter: 找不到endwin\n");
		print( "filename:[%s] line[%d]\n", filename, linenum);
		return FALSE;
	}
	if( errflg == TRUE) return FALSE;
	
	return TRUE;
}
コード例 #7
0
ファイル: pet_event.c プロジェクト: ChowZenki/Long-Sa-Source
char *Pet_TalkGetFunStr( char *temp , char *buf, int len)
{
	char filename[56];
	char pathfile[128];
	char talkfun[ 10240];
	char buf1[256],buf2[256],buf3[256];
	FILE *petarg;
	char	*cStr=NULL; 
	int talkNo=1,mark=1;
	char	line[4096];
	BOOL find=FALSE;
	talkfun[0] ='\0';

	while( getStringFromIndexWithDelim( pettalktext,"&",talkNo, buf1, sizeof( buf1) ) != FALSE){
		talkNo++;
		if( NPC_Util_GetStrFromStrWithDelim( buf1, "PETTEMPNO", buf2, sizeof( buf2)) == NULL  )
			continue;
		mark=2;
		strcpy( filename,"\0");
		while( getStringFromIndexWithDelim( buf2,",", mark,buf3,sizeof( buf3)) != FALSE )	{
			mark ++;
			if( !strcmp( buf3, temp))	{
				print("\n buf2=%s",buf2);
				if( getStringFromIndexWithDelim( buf2,",", 1,filename,sizeof( filename)) == FALSE )
					return NULL;
				find = TRUE;
				break;
			}
		}
		if( find == TRUE )
			break;
	}
	if( !strcmp( filename, "\0") )
		return NULL;

	sprintf( pathfile, "%s/pettalk/%s", getNpcdir(), filename);
	petarg = fopen( pathfile , "r" );
	if( petarg != NULL ) {
		while( fgets( line, sizeof( line), petarg ) ) {
			if( strlen( talkfun) != 0 ) {
				if( talkfun[strlen( talkfun) -1] != '|' ) {
					strcatsafe( talkfun, sizeof( talkfun), "|");
				}
			}
			chompex( line);
			strcatsafe( talkfun, sizeof( talkfun ),  line);
		}
		fclose( petarg);
	}else	{
		return NULL;
	}
	talkNo = 1;
	while( getStringFromIndexWithDelim( talkfun,"}",talkNo, buf, len) != FALSE)	{
		talkNo++;
		if( NPC_Util_GetStrFromStrWithDelim( buf, "PETTEMPNO", buf2, sizeof( buf2)) == NULL  )
			continue;
		if( !strcmp( temp, buf2) )		{
			cStr = buf;
			break;
		}
	}
	return( cStr);
}
コード例 #8
0
ファイル: npcutil.c プロジェクト: Nurarihyo/smo-sa
/*#ifdef _JZ_NPCBUF
		CHAR_NPCBUFPOINT = CHAR_WORKEQUITFIRE,   					//NPC arg文件緩存指針
		CHAR_NPCTIMERH32 = CHAR_WORKEQUITTHUNDER,					//NPC 計時器(高32位)
		CHAR_NPCTIMERL32 = CHAR_WORKEQUITICE,							//NPC 計時器(低32位)
		CHAR_NPCFILECTIMEH32 = CHAR_WORKEQUITWEAKEN,			//讀NPC arg文件的時間(高32位)
		CHAR_NPCFILECTIMEL32 = CHAR_WORKEQUITBARRIER,			//讀NPC arg文件的時間(低32位)
		//CHAR_NPCFILECTIME_HOUR = CHAR_WORKEQUITNOCAST,		//讀NPC arg文件時的時鐘
		//CHAR_NPCFILECTIME_MIN = CHAR_WORKEQUITFALLRIDE,		//讀NPC arg文件時的分鐘
#endif*/
char *NPC_Util_GetArgStr( int index, char *argstr, int len)
{
	char	filename[128];
	Char *ch;
	char	*cret = NULL;
	struct stat buff;
	int fd;
	char	opfile[128];
	if( (ch = CHAR_getCharPointer( index)) == NULL ) {
		print("GetArgStr Not get CharPointer\n");
		return NULL;				//獲得NPC結構指針
	}
	if( NPC_Util_CheckAssignArgFile( index, filename) != NULL ) {

		sprintf( opfile, "%s/%s", getNpcdir(),filename);
		if(stat(opfile,&buff)!=0)
		{
			print("NPC緩存機制 stat error:%s\n",strerror( errno ));
			buff.st_size = NPC_UTIL_GETARGSTR_BUFSIZE;
		}else{
			buff.st_size++;
		}
		//if(buff.st_size > len)buff.st_size = len;
		cret = (char *)ch->workint[CHAR_NPCBUFPOINT];												//獲得NPC緩存指針
		if( cret == NULL ) {																								//首先判斷NPC緩存是否已經加載數據
			//未加載緩存,申請內存,並將文件內容讀到緩存中
loadarg:
			cret = allocateMemory((unsigned int)buff.st_size);															//申請內存
			memset( cret, 0,buff.st_size);
			if( cret == NULL ) {																							//判斷申請內存是否成功,如果不成功則採用舊的模式
				//舊的文件即時讀取模式
				//print("NPC BUF OLD LOAD FILE %d\n",buff.st_size);
				if( NPC_Util_MargeStrFromArgFile( opfile, argstr, len) != NULL ) {
					cret = argstr;
				}
			}else{
				//新的NPC緩存模式
				//print("NPC BUF NEW LOAD FILE %d\n",buff.st_size);
				if( NPC_Util_MargeStrFromArgFile( opfile, cret, buff.st_size) != NULL ) {
					//memcpy(cret,argstr,buff.st_size);
					ch->workint[CHAR_NPCBUFPOINT] = (int)cret;
					ch->workint[CHAR_NPCFILECTIMEH32] = (unsigned long)buff.st_mtime;
				}else{
					freeMemory(cret);
					cret = NULL;
				}
			}
		}else
		{
			//print("NPC BUF NEW %d\n",buff.st_size);
			//已加載緩存,判斷是否數據被更改,如果沒被更改直接返回緩存指針,如果更改的話則GOTO到未加載緩存的代碼
			//2個計時器暫時不用
			//if(buff.st_size > NPC_UTIL_GETARGSTR_BUFSIZE)buff.st_size = NPC_UTIL_GETARGSTR_BUFSIZE;
			if((unsigned long)ch->workint[CHAR_NPCFILECTIMEH32] != (unsigned long)buff.st_mtime)
			{
					print("npc updata:%s\n",opfile);
					freeMemory(cret);
					cret = NULL;
					goto loadarg;
			}
			//memcpy(argstr,cret,buff.st_size);
			//cret = argstr;
		}
	}else {
		if( CHAR_getChar( index, CHAR_NPCARGUMENT) != NULL ){
			strcpy( argstr, CHAR_getChar( index, CHAR_NPCARGUMENT));
			cret = argstr;
		}else{
			cret = NULL;
		}
	}
	if( cret == NULL ) print("File:%s\n", NPC_Util_CheckAssignArgFile( index, opfile));

	return( cret);

/*	if( NPC_Util_CheckAssignArgFile( index, filename) != NULL ) {
		if( NPC_Util_MargeStrFromArgFile( filename, argstr, len) != NULL ) {
			cret = argstr;
		}
	}else {
		if( CHAR_getChar( index, CHAR_NPCARGUMENT) != NULL ){
			strcpy( argstr, CHAR_getChar( index, CHAR_NPCARGUMENT));
			cret = argstr;
		}else{
			cret = NULL;
		}
	}
	if( cret == NULL ) print("File:%s\n", NPC_Util_CheckAssignArgFile( index, filename));

	return( cret);*/
}