Beispiel #1
0
void CBigMap::InitMapData( const TCHAR* szMapFile)
{
	ClearUp();

	m_SceneName = szMapFile;
	
	//读取区域名字和文件名对应关系
	if(!LoadConfig(m_SceneName))
		return;

	//创建m_MapTextureClose
	//创建m_MapTextureOpen
	CPkgFile::EnableAsyncRead(false);
	string FileName = "";
	format(FileName,"%s/BigMap/open.dds",m_SceneName.c_str());
	if(m_bOpen)
		GetGraphic()->CreateTexture(PATH_ALIAS_RES.c_str(), FileName.c_str(),&m_MapTextureOpen);
	else
	{
		m_MapTextureOpen = NULL;
		return;
	}
	FileName.clear();
	format(FileName,"%s/BigMap/close.dds",m_SceneName.c_str());
	if(m_bClose)
		GetGraphic()->CreateTexture(PATH_ALIAS_RES.c_str(), FileName.c_str(),&m_MapTextureClose);
	else
	{
		m_MapTextureClose = NULL;
		return;
	}

	SafeRelease(m_pAlphaTexture);
	m_pAlphaTexture = GetGraphic()->CreateRenderTarget();
	m_pAlphaTexture->SetWidth(uint32(GetWndWidth()));
	m_pAlphaTexture->SetHeight(uint32(GetWndHeight()));
	m_pAlphaTexture->SetUseDepthBuffer(false);
	m_pAlphaTexture->SetFormat(TFMT_A8R8G8B8);
	m_pAlphaTexture->Create();

	m_BackTexUV[2] = CVector2f(	0.0f , float(m_pAlphaTexture->GetHeight()));
	m_BackTexUV[0] = CVector2f( 0.0f , 0.0f );
	m_BackTexUV[3] = CVector2f( float(m_pAlphaTexture->GetWidth()) , float(m_pAlphaTexture->GetHeight()) );
	m_BackTexUV[1] = CVector2f( float(m_pAlphaTexture->GetWidth())   , 0.0f);
	m_fRTWidth = float(m_pAlphaTexture->GetWidth());
	m_fRTHeight = float(m_pAlphaTexture->GetHeight());

	if(m_pAlphaTexture==NULL)
		return;
	//string testdir = szMapFile;
	//testdir+= "yhl.dds";
	//m_pAlphaTexture->SaveToFile(testdir);
}
Beispiel #2
0
/**
 * @brief 评测函数
 * 通过对比输出文件进行评测
 *
 * @param exe 已编译好的可执行文件名
 * @param stdinput 标准输入文件名
 * @param stdoutput 标准输出文件名
 * @param cs 用于接收代码状态的引用
 * @return 若评测结果为ACCEPTED则返回true,其它一律返回false
 */
bool CNBUTOJCore::Judge(const char *exe, const char *stdinput, const char *stdoutput, const __int64 lim_time, const SIZE_T lim_memo, CodeState &cs, bool bPause)
{
    cs.exe_time = RUN_NO_TIME;
    cs.exe_memory = RUN_NO_MEMO;

    /** 几个文件路径 */
    string newexe = string(TEMP_PATH) + exe;
    string exeoutput = string(TEMP_PATH) + string(".output");

    /** 检测标准输出文件 */
    if(!FileExists(stdoutput))
    {
        cs.state = SYSTEM_ERROR;
        strcpy(cs.err_code, "Wrong std output file.");

        return false;
    }

    /** 最大文件大小 */
    struct _stat stdoutputinfo;
    _stat(stdoutput, &stdoutputinfo);
    DWORD maxSize = stdoutputinfo.st_size * 2;

    /** 运行代码 */
    PROCESS_INFORMATION ProcInfo;
    HANDLE hInput, hOutput;
    HANDLE hProcess = RunCode(newexe.c_str(), stdinput, exeoutput.c_str(), cs, hInput, hOutput, ProcInfo);
    ReleaseIOHandle(hInput, hOutput);
    
    /** 若代码运行不成功 */
    if(NULL == hProcess) 
    {
        if(bPause) system("pause");
        //ReleaseIOHandle(hInput, hOutput);
        ClearUp(newexe.c_str(), exeoutput.c_str(), ProcInfo);
        return false;
    }

    /** 监视若有异常 */
    if(!WatchCode(hProcess, lim_time, lim_memo, maxSize, exeoutput.c_str(), cs, ProcInfo)) 
    {
        if(cs.state == NState::TIME_LIMIT_EXCEEDED_1 || cs.state == NState::TIME_LIMIT_EXCEEDED_2)
        {
            cs.exe_time = lim_time;
        }

        if(bPause) system("pause");
        //ReleaseIOHandle(hInput, hOutput);
        ClearUp(newexe.c_str(), exeoutput.c_str(), ProcInfo);
        return false;
    }

    /** 释放输入输出文件句柄 */
    //ReleaseIOHandle(hInput, hOutput);

    /** 判断代码正误 */
    int t = 10;
    while(!_IsRight(stdoutput, exeoutput.c_str(), cs) && t--)
    {
        /** SYSTEM错误的话 */
        if(cs.state == SYSTEM_ERROR)
        {
            Sleep(10);
            continue;
        }

        if(bPause) system("pause");
        //ReleaseIOHandle(hInput, hOutput);
        ClearUp(newexe.c_str(), exeoutput.c_str(), ProcInfo);
        return false;
    }

    ClearUp(newexe.c_str(), exeoutput.c_str(), ProcInfo);
    //cs.state = ACCEPTED;

    return true;
}
Beispiel #3
0
int32 CBigMap::DestroyWnd()
{
	ClearUp();
	AdvDelRef(m_pWnd);
	return SQRWnd::DestroyWnd();
}
Beispiel #4
0
CBigMap::~CBigMap(void)
{
	ClearUp();
	SafeRelease(m_pAlphaTexture);
}
Beispiel #5
0
bool IniConfig::Load(const std::string strFilePath)
{
    ClearUp();
    if (!strFilePath.empty())
    {
        m_strFilePath = strFilePath;
    }
    if (m_strFilePath.empty())
    {
        return false;
    }
    

    FILE* pFile  = fopen(strFilePath.c_str(), "r");

    if (pFile == 0)
    {
        return false;
    }

    char szLine[INI_MAXLINE] = "";

    const char* pTmp = 0;

    Section* pCurSec = 0;

    while(feof(pFile) != EOF)
    {
        szLine[0] = '\0';

        if (fgets(szLine, INI_MAXLINE - 1, pFile) == 0)
        {
            break;
        }
        std::string strTrim = StdString::Trim(szLine, " \r\n");
        pTmp = strTrim.c_str();

//        int n = StringLenth(pTmp);
        if (StdString::StringLenth(pTmp) <= 0){
            continue;
        }
        if (*pTmp == '#' || *pTmp == ';')
        {
            continue;
        }
        // Start section
        if (*pTmp == '[')
        {
            const char* pNameDel = ++pTmp;
            while(*pTmp != '\0' && *pTmp != ']')
            {
                pTmp++;
            }
            if (*pTmp == '\0')
            {
                fclose(pFile);
                return false;
            }
            pCurSec = new Section(std::string(pNameDel, pTmp - pNameDel));
            m_lstSections.push_back(pCurSec);
            continue;
        }
        if (pCurSec != 0)
        {
            std::list<std::string> lstKV;
            int nCount = StdString::Split(pTmp, "=", lstKV);
            if (nCount != 2)
            {
                fclose(pFile);
                return false;
            }
            std::string strKey = lstKV.front();
            std::string strVal = lstKV.back();
            pCurSec->Insert(strKey, strVal);
            
        }
    }

    fclose(pFile);

    return true;
}
Beispiel #6
0
IniConfig::~IniConfig()
{
    ClearUp();
}
GFilter::~GFilter()
{
	ClearUp();
}