示例#1
0
void PCPointShop::BuyItem(DWORD PlayerID,int Position)
{
	int ID=PlayerID-MIN_PLAYERID;
	LPGOBJSTRUCT pObj = (LPGOBJSTRUCT)(PlayerID*gObjSize + gObjBaseAddr);
	char sBuf[255]		= {0};
	int i=SearchIndex(Position);
	BOOL IfBuy=FALSE;

	if(i!=(-1))
	{
		if(Items[i].Cost<pObjGS[ID].PCPlayerPoints)
		{
			int RewardItem=Items[i].ItemIndex*512+Items[i].ItemID;
			ItemSerialCreateSend(PlayerID,235,0,0,(DWORD)RewardItem,Items[i].Level,Items[i].Dur,Items[i].Skill,Items[i].Luck,(Items[i].Opt/4),-1,Items[i].Exc,0);
			DecreasePoints(PlayerID,Items[i].Cost);
			IfBuy=TRUE;
		}
	}
	//Log
	if((IfBuy==TRUE) && (i!=(-1)))
	{
		wsprintf(sBuf, "[PCPointShop] BuyItem [%s][%s] Item {%d %d} Cost: %d",pObj->AccountID,pObj->Name,Items[i].ItemIndex,Items[i].ItemID,Items[i].Cost);
		Log.outNormal(sBuf);
	} else {
		wsprintf(sBuf, "[PCPointShop] Attempt to BuyItem [%s][%s] Item {%d %d} Cost: %d",pObj->AccountID,pObj->Name,Items[i].ItemIndex,Items[i].ItemID,Items[i].Cost);
		Log.outError(sBuf,14);
	}
}
	int main(int argc, char **argv) {
		std::map<std::string, int> map_word;
		std::vector<std::string> lib_vec; 
		std::ofstream ofs_lib;
		std::ofstream ofs_index;
		char* source_name = strdup("./language_lib");
		std::string lib_file_name("/home/markwoo/Documents/my_project/0515_0516_mini_search/lib_page/ripepage.lib"); //build_lib file name
		std::string index_file_name("/home/markwoo/Documents/my_project/0515_0516_mini_search/index/ripepage.index"); //index file file name
		
		/* 扫描语料库 */
		ScanFile(source_name, lib_vec);
		
		/* 写入文件,同时制作索引 */
		OpenOutFile(ofs_lib, lib_file_name);
		OpenOutFile(ofs_index, index_file_name);
		size_t vec_index = 1; //存储页面的容器vector下标

		for (auto &i : lib_vec) {
			ofs_index << vec_index << " " << ofs_lib.tellp(); //取得当前文件指针的位置
			ofs_lib << i;
			ofs_index << " " << i.size() << std::endl; //Doc文件的大小
			++vec_index;
		}

		ofs_index.close();
		ofs_lib.close();
		log_file.close();
		std::cout << "language lib and index builded" << std::endl;

		SearchIndex(index_file_name, lib_file_name);

		return 0;
	}
示例#3
0
/**********************************************************************
 *                          main()
 *
 * This program is used to dump binary files (default behavior), and to
 * test some parts of the lib. during the development process. 
 **********************************************************************/
int main(int argc, char *argv[])
{
    const char  *pszFname;

/*---------------------------------------------------------------------
 *      Read program arguments.
 *--------------------------------------------------------------------*/
    if (argc<3)
    {
        printf("%s", TABTEST_USAGE);
        return 1;
    }
    else
    {
        pszFname = argv[2];
    }
    
/*---------------------------------------------------------------------
 *      With option -blocks <filename>
 *      Open file, and dump each block sequentially.
 *--------------------------------------------------------------------*/
    if (EQUALN(argv[1], "-blocks", 2))
    {

        if (strstr(pszFname, ".map") != NULL ||
            strstr(pszFname, ".MAP") != NULL)
        {
            DumpMapFileBlocks(pszFname);
        }
        else if (strstr(pszFname, ".ind") != NULL ||
                 strstr(pszFname, ".IND") != NULL)
        {
            DumpIndFileObjects(pszFname);
        }
        else if (strstr(pszFname, ".otherextension") != NULL)
        {
            ;
        }
    }
/*---------------------------------------------------------------------
 *      With option -blocks <filename>
 *      Open file, and dump each block sequentially.
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-details", 2) && argc >= 4)
    {

        if (strstr(pszFname, ".map") != NULL ||
            strstr(pszFname, ".MAP") != NULL)
        {
            DumpMapFileBlockDetails(pszFname, atoi(argv[3]));
        }
        else if (strstr(pszFname, ".otherextension") != NULL)
        {
            ;
        }
    }
/*---------------------------------------------------------------------
 *      With option -objects <filename>
 *      Open file, and all geogr. objects.
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-objects", 2))
    {

        if (strstr(pszFname, ".map") != NULL ||
            strstr(pszFname, ".MAP") != NULL)
        {
            DumpMapFileObjects(pszFname);
        }
        else if (strstr(pszFname, ".tab") != NULL ||
                 strstr(pszFname, ".TAB") != NULL)
        {
            DumpTabFile(pszFname);
        }
        else if (strstr(pszFname, ".ind") != NULL ||
                 strstr(pszFname, ".IND") != NULL)
        {
            DumpIndFileObjects(pszFname);
        }
    }
/*---------------------------------------------------------------------
 *      With option -spatialindex <filename> [maxdepth]
 *      Dump Spatial Index Tree of .MAP file
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-spatialindex", 2))
    {

        if (strstr(pszFname, ".map") != NULL ||
            strstr(pszFname, ".MAP") != NULL)
        {
            if (argc >= 4)
                DumpMapFileIndexTree2MIF(pszFname, atoi(argv[3]));
            else
                DumpMapFileIndexTree2MIF(pszFname, -1);
        }
    }
/*---------------------------------------------------------------------
 *      With option -all <filename>
 *      Dump the whole TAB dataset (all supported files)
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-all", 2))
    {

        if (strstr(pszFname, ".tab") != NULL ||
            strstr(pszFname, ".TAB") != NULL ||
            strstr(pszFname, ".mif") != NULL ||
            strstr(pszFname, ".MIF") != NULL)
        {
            DumpTabFile(pszFname);
        }
    }
/*---------------------------------------------------------------------
 *      With option -coordsys <filename>
 *      Dump the dataset's projection string
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-coordsys", 2))
    {

        if (strstr(pszFname, ".tab") != NULL ||
            strstr(pszFname, ".TAB") != NULL)
        {
            DumpCoordsys(pszFname);
        }
    }
/*---------------------------------------------------------------------
 *      With option -Ccoordsys <filename>
 *      Dump the dataset's coordsys and bounds info in a C struct format
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-Ccoordsys", 3))
    {

        if (strstr(pszFname, ".tab") != NULL ||
            strstr(pszFname, ".TAB") != NULL)
        {
            DumpCoordsysStruct(pszFname);
        }
    }
/*---------------------------------------------------------------------
 *     With option -index <filename> <indexno> <value> 
 *     Search specified index for a value.
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-index", 2) && argc >=5)
    {
        SearchIndex(pszFname, atoi(argv[3]), argv[4]);
    }
/*---------------------------------------------------------------------
 *      With option -envelope <filename> <xmin> <ymin> <ymax> <ymax>
 *      Dump all objects that intersect the envelope.  Scan via spatial index.
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-envelope", 2) && argc >= 7)
    {

        if (strstr(pszFname, ".tab") != NULL ||
            strstr(pszFname, ".TAB") != NULL)
        {
            DumpViaSpatialIndex(pszFname, atof(argv[3]), atof(argv[4]), 
                                atof(argv[5]), atof(argv[6]));
        }
    }
/*---------------------------------------------------------------------
 *     With option -otheroption <filename> ... 
 *     ... do something else ...
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-otheroption", 2))
    {
        ;
    }
    else
    {
        printf("Cannot process file %s\n\n", pszFname);
        printf("%s", TABTEST_USAGE);
        
        return 1;
    }

    return 0;
}
示例#4
0
/**********************************************************************
 *                          main()
 *
 * This program is used to dump binary files (default behavior), and to
 * test some parts of the lib. during the development process. 
 **********************************************************************/
int main(int argc, char *argv[])
{
    const char  *pszFname;

/*---------------------------------------------------------------------
 *      Read program arguments.
 *--------------------------------------------------------------------*/
    if (argc<3)
    {
        printf("%s", TABTEST_USAGE);
        return 1;
    }
    else
    {
        pszFname = argv[2];
    }
    
/*---------------------------------------------------------------------
 *      With option -blocks <filename>
 *      Open file, and dump each block sequentially.
 *--------------------------------------------------------------------*/
    if (EQUALN(argv[1], "-blocks", 2))
    {

        if (strstr(pszFname, ".map") != NULL ||
            strstr(pszFname, ".MAP") != NULL)
        {
            DumpMapFileBlocks(pszFname);
        }
        else if (strstr(pszFname, ".ind") != NULL ||
                 strstr(pszFname, ".IND") != NULL)
        {
            DumpIndFileObjects(pszFname);
        }
        else if (strstr(pszFname, ".otherextension") != NULL)
        {
            ;
        }
    }
/*---------------------------------------------------------------------
 *      With option -objects <filename>
 *      Open file, and all geogr. objects.
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-objects", 2))
    {

        if (strstr(pszFname, ".map") != NULL ||
            strstr(pszFname, ".MAP") != NULL)
        {
            DumpMapFileObjects(pszFname);
        }
        else if (strstr(pszFname, ".tab") != NULL ||
                 strstr(pszFname, ".TAB") != NULL)
        {
            DumpTabFile(pszFname);
        }
        else if (strstr(pszFname, ".ind") != NULL ||
                 strstr(pszFname, ".IND") != NULL)
        {
            DumpIndFileObjects(pszFname);
        }
    }
/*---------------------------------------------------------------------
 *      With option -all <filename>
 *      Dump the whole TAB dataset (all supported files)
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-all", 2))
    {

        if (strstr(pszFname, ".tab") != NULL ||
            strstr(pszFname, ".TAB") != NULL)
        {
            DumpTabFile(pszFname);
        }
    }
/*---------------------------------------------------------------------
 *      With option -coordsys <filename>
 *      Dump the dataset's projection string
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-coordsys", 2))
    {

        if (strstr(pszFname, ".tab") != NULL ||
            strstr(pszFname, ".TAB") != NULL)
        {
            DumpCoordsys(pszFname);
        }
    }
/*---------------------------------------------------------------------
 *     With option -index <filename> <indexno> <value> 
 *     Search specified index for a value.
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-index", 2) && argc >=5)
    {
        SearchIndex(pszFname, atoi(argv[3]), argv[4]);
    }
/*---------------------------------------------------------------------
 *     With option -otheroption <filename> ... 
 *     ... do something else ...
 *--------------------------------------------------------------------*/
    else if (EQUALN(argv[1], "-otheroption", 2))
    {
        ;
    }
    else
    {
        printf("Cannot process file %s\n\n", pszFname);
        printf("%s", TABTEST_USAGE);
        
        return 1;
    }

    return 0;
}