⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 encount.c

📁 石器时代2.0完整版源代码.已经加入新功能. 在REDHAT9下GCC3.4编译成功.
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "version.h"#include <stdio.h>#include <string.h>#include <math.h>#include "common.h"#include "util.h"#include "buf.h"#include "char_base.h"#include "char.h"#include "configfile.h"#include "encount.h"#include "enemy.h"#ifdef _ADD_ENCOUNT           // WON ADD 增加敌遭遇触发修件#include "encount.h"#endif/* 巨件市它件玄楮  及末□旦 */#ifndef _ADD_ENCOUNT           // WON ADD 增加敌遭遇触发修件typedef struct tagENCOUNT_Table{    int                 index;    int                 floor;    int                 encountprob_min;                /* 巨件市它件玄割   */    int                 encountprob_max;                /* 巨件市它件玄割   */    int                 enemymaxnum;        /* 升木分仃衬毛综月井 */    int                 zorder;    int                 groupid[ENCOUNT_GROUPMAXNUM];       /* 弘伙□皿No */    int                 createprob[ENCOUNT_GROUPMAXNUM];    /* 公及弘伙□皿及请蜇   */    RECT                rect;}ENCOUNT_Table;ENCOUNT_Table           *ENCOUNT_table;#endifint                     ENCOUNT_encountnum;#define     ENCOUNT_ENEMYMAXCREATENUM   10static INLINE BOOL ENCOUNT_CHECKENCOUNTTABLEARRAY( int array){    if( array < 0 || array > ENCOUNT_encountnum-1) return FALSE;    return TRUE;}/*------------------------------------------------------------ * 巨件市它件玄涩烂及赓渝祭毛允月[ * 娄醒 *  filename        char*       涩烂白央奶伙   * 忒曰袄 *  岳      TRUE(1) *  撩      FALSE(0) *------------------------------------------------------------*/BOOL ENCOUNT_initEncount( char* filename ){    FILE*   f;    char    line[256];    int     linenum=0;    int     encount_readlen=0;    f = fopen(filename,"r");    if( f == NULL ){        errorprint;        return FALSE;    }    ENCOUNT_encountnum=0;    /*  引内  躲卅垫互窒垫丐月井升丹井譬屯月    */    while( fgets( line, sizeof( line ), f ) ){        linenum ++;        if( line[0] == '#' )continue;        /* comment */        if( line[0] == '\n' )continue;       /* none    */        chomp( line );        ENCOUNT_encountnum++;    }    if( fseek( f, 0, SEEK_SET ) == -1 ){        fprint( "寻找错误\n" );        fclose(f);        return FALSE;    }    ENCOUNT_table = allocateMemory( sizeof(struct tagENCOUNT_Table)                                   * ENCOUNT_encountnum );    if( ENCOUNT_table == NULL ){        fprint( "无法分配内存 %d\n" ,                sizeof(ENCOUNT_table)*ENCOUNT_encountnum);        fclose( f );        return FALSE;    }    /* 赓渝祭 */{    int     i,j;    for( i = 0; i < ENCOUNT_encountnum; i ++ ) {        ENCOUNT_table[i].index = -1;        ENCOUNT_table[i].floor = 0;        ENCOUNT_table[i].encountprob_min = 1;        ENCOUNT_table[i].encountprob_min = 50;        ENCOUNT_table[i].enemymaxnum = 4;        ENCOUNT_table[i].rect.x = 0;        ENCOUNT_table[i].rect.y = 0;        ENCOUNT_table[i].rect.height = 0;        ENCOUNT_table[i].rect.width = 0;        ENCOUNT_table[i].zorder = 0;        for( j = 0; j < ENCOUNT_GROUPMAXNUM; j ++ ) {            ENCOUNT_table[i].groupid[j] = -1;            ENCOUNT_table[i].createprob[j] = -1;        }#ifdef _ADD_ENCOUNT           // WON ADD 增加敌遭遇触发修件		ENCOUNT_table[i].event_now = -1;		ENCOUNT_table[i].event_end = -1;		ENCOUNT_table[i].enemy_group = -1;#endif    }}    /*  引凶  心  允    */    linenum = 0;    while( fgets( line, sizeof( line ), f ) ){        linenum ++;        if( line[0] == '#' )continue;        /* comment */        if( line[0] == '\n' )continue;       /* none    */        chomp( line );        /*  垫毛帮溥允月    */        /*  引内 tab 毛 " " 卞  五晶尹月    */        replaceString( line, '\t' , ' ' );        /* 燮  及旦矢□旦毛潸月[*/{        int     i;        char    buf[256];        for( i = 0; i < strlen( line); i ++) {            if( line[i] != ' ' ) {                break;            }            strcpy( buf, &line[i]);        }        if( i != 0 ) {            strcpy( line, buf);        }}{        char    token[256];        int     ret;        int     x1,x2,y1,y2;		int		j;                /*   蘸户及伙□皿卞  匀凶凛及啃及赓渝祭 */        ENCOUNT_table[encount_readlen].index = -1;        ENCOUNT_table[encount_readlen].floor = 0;        ENCOUNT_table[encount_readlen].encountprob_min = 1;        ENCOUNT_table[encount_readlen].encountprob_min = 50;        ENCOUNT_table[encount_readlen].enemymaxnum = 4;        ENCOUNT_table[encount_readlen].rect.x = 0;        ENCOUNT_table[encount_readlen].rect.y = 0;        ENCOUNT_table[encount_readlen].rect.height = 0;        ENCOUNT_table[encount_readlen].rect.width = 0;        ENCOUNT_table[encount_readlen].zorder = 0;        for( j = 0; j < ENCOUNT_GROUPMAXNUM; j ++ ) {            ENCOUNT_table[encount_readlen].groupid[j] = -1;            ENCOUNT_table[encount_readlen].createprob[j] = -1;        }#ifdef _ADD_ENCOUNT           // WON ADD 增加敌遭遇触发修件		ENCOUNT_table[encount_readlen].event_now = -1;		ENCOUNT_table[encount_readlen].event_end = -1;		ENCOUNT_table[encount_readlen].enemy_group = -1;#endif        /*  夫午勾户及玄□弁件毛苇月    */        ret = getStringFromIndexWithDelim( line,",",1,token,                                           sizeof(token));        if( ret==FALSE ){            fprint("文件语法错误:%s 第%d行\n",filename,linenum);            continue;        }        ENCOUNT_table[encount_readlen].index = atoi(token);                /*  2勾户及玄□弁件毛苇月    */        ret = getStringFromIndexWithDelim( line,",",2,token,                                           sizeof(token));        if( ret==FALSE ){            fprint("文件语法错误:%s 第%d行\n",filename,linenum);            continue;        }        ENCOUNT_table[encount_readlen].floor = atoi(token);        /*  3勾户及玄□弁件毛苇月    */        ret = getStringFromIndexWithDelim( line,",",3,token,                                           sizeof(token));        if( ret==FALSE ){            fprint("文件语法错误:%s 第%d行\n",filename,linenum);            continue;        }        x1 = atoi(token);        /*  4勾户及玄□弁件毛苇月    */        ret = getStringFromIndexWithDelim( line,",",4,token,                                           sizeof(token));        if( ret==FALSE ){            fprint("文件语法错误:%s 第%d行\n",filename,linenum);            continue;        }        y1= atoi(token);                /*  5勾户及玄□弁件毛苇月    */        ret = getStringFromIndexWithDelim( line,",",5,token,                                           sizeof(token));        if( ret==FALSE ){            fprint("文件语法错误:%s 第%d行\n",filename,linenum);            continue;        }                x2 = atoi(token);                /*  6勾户及玄□弁件毛苇月    */        ret = getStringFromIndexWithDelim( line,",",6,token,                                           sizeof(token));        if( ret==FALSE ){            fprint("文件语法错误:%s 第%d行\n",filename,linenum);            continue;        }        y2= atoi(token);        ENCOUNT_table[encount_readlen].rect.x      = min(x1,x2);        ENCOUNT_table[encount_readlen].rect.width  = max(x1,x2) - min(x1,x2);        ENCOUNT_table[encount_readlen].rect.y      = min(y1,y2);        ENCOUNT_table[encount_readlen].rect.height = max(y1,y2) - min(y1,y2);        /*  7户及玄□弁件毛苇月    */        ret = getStringFromIndexWithDelim( line,",",7,token,                                           sizeof(token));        if( ret==FALSE ){            fprint("文件语法错误:%s 第%d行\n",filename,linenum);            continue;        }        ENCOUNT_table[encount_readlen].encountprob_min = atoi(token);        /*  8户及玄□弁件毛苇月    */        ret = getStringFromIndexWithDelim( line,",",8,token,                                           sizeof(token));        if( ret==FALSE ){            fprint("文件语法错误:%s 第%d行\n",filename,linenum);            continue;        }        ENCOUNT_table[encount_readlen].encountprob_max = atoi(token);{		int		a,b;		a = ENCOUNT_table[encount_readlen].encountprob_min;		b = ENCOUNT_table[encount_readlen].encountprob_max;		/*   凝及譬帮 */        ENCOUNT_table[encount_readlen].encountprob_min         	= min( a,b);        ENCOUNT_table[encount_readlen].encountprob_max         	= max( a,b);}        /*  9勾户及玄□弁件毛苇月    */        ret = getStringFromIndexWithDelim( line,",",9,token,                                           sizeof(token));        if( ret==FALSE ){            fprint("文件语法错误:%s 第%d行\n",filename,linenum);            continue;        }        {            int maxnum = atoi( token);            /* 醒及恳癫岭及民尼永弁 */            if( maxnum < 1 || maxnum > ENCOUNT_ENEMYMAXCREATENUM ) {                fprint("文件语法错误:%s 第%d行\n",filename,linenum);                continue;            }            ENCOUNT_table[encount_readlen].enemymaxnum = maxnum;        }        /*  10户及玄□弁件毛苇月    */        ret = getStringFromIndexWithDelim( line,",",10,token,                                           sizeof(token));        if( ret==FALSE ){            fprint("文件语法错误:%s 第%d行\n",filename,linenum);            continue;        }        ENCOUNT_table[encount_readlen].zorder = atoi(token);        #define		CREATEPROB_TOKEN	11                /*  11  31户及玄□弁件毛苇月    */        {            int     i;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -