Exemple #1
0
PGameRes WINAPI GameEnv::OpenResFiles(const tstring whichPath)
{
	tstring subPath;
	PGameRes pRes = new GameRes();
	ZeroMemory(pRes, sizeof(GameRes));
	pRes->rootPath = NewPathString(whichPath, MAX_PATH);
	//检查二进制文件
	subPath = whichPath + FP_PATH_BIN;
	pRes->pBinLib = new BinLib();
	ZeroMemory(pRes->pBinLib, sizeof(BinLib));
	if (!CheckBinLib(subPath, pRes->pBinLib))
	{
		SAFE_DELETE(pRes->pBinLib);
		SAFE_DELETE(pRes);
		return NULL;
	}
	//检查配置文件
	subPath = whichPath + FP_PATH_DAT;
	pRes->pDataSet = new DataSet();
	ZeroMemory(pRes->pDataSet, sizeof(DataSet));
	if (!CheckDataSet(subPath, pRes->pDataSet))
	{
		SAFE_DELETE(pRes);
		return NULL;
	}
	return pRes;
}
Exemple #2
0
int main (int argc, const char * argv[]) 
{
    int port = DEFAULT_PORT;    
    int bufferSize = DEFAULT_BUFFER_SIZE;
    bool isQuiet = DEFAULT_QUIET;
    bool isDebug = DEFAULT_DEBUG;
    int maxClient = DEFAULT_MAXCLIENT;

    signal(SIGINT, signalHandler);
    signal(SIGTERM, signalHandler);
    
    readArgs(argc,argv,&port,&bufferSize,&isQuiet,&isDebug,&maxClient);

    logger.setQuiet(isQuiet);
    logger.setDebug(isDebug);
    
    if(!isQuiet)
    {
        printInfo(port,bufferSize,isDebug,maxClient);
    }
    
    List<Client*> list;
    sf::Mutex listMutex;

    sf::SocketSelector selector;
    
    Buffer exchangeBuffer;
    setupExchangeBuffer(&exchangeBuffer, bufferSize);

    logger.printLog("Init'ed ...");
    
    ClientsContainer container(&list,&listMutex,&selector);
    
    
    sf::Thread answerThread(&answerToClient,AnswerDataSet(&container,port,maxClient));
    answerThread.launch();


    sf::Thread checkThread(&checkForInputs,CheckDataSet(&container,&exchangeBuffer));
    checkThread.launch();
    
    while(1) //TODO graphic stats
    {
        if(checkStopThreads())
        {
            break;
        }
        sf::sleep(sf::milliseconds(5));
    }
    
    return 0;
}