Example #1
0
void OSInterface::DeleteFilesFromDirectory(const STRING& aRootDir,const STRING& aExtension)                    
	{
	STRING			patternOfString;
	WIN32_FIND_DATA fileInfo;
    patternOfString = aRootDir + _T("\\*.*") ;
	
	HANDLE hToFile = ::FindFirstFile(patternOfString.c_str(), &fileInfo);	
	
	if(hToFile != INVALID_HANDLE_VALUE)
		{
		do
			{
			if(fileInfo.cFileName[0] != '.')
				{
				
				STRING file = fileInfo.cFileName;
				
				STRING extOfString = file.substr(file.rfind(_T(".")) + 1);

				if(extOfString == aExtension)
					{
					::DeleteFile(file.c_str());
					}
				}		
			}while(::FindNextFile(hToFile , &fileInfo));

		::FindClose(hToFile);
	  	}
	}
Example #2
0
/*
 * Constructor.
 */
CAnimation::CAnimation(const STRING file):
m_users(1) 
{
	extern STRING g_projectPath;

	renderFrame = &CAnimation::renderAnmFrame;

	if (!file.empty())
	{
		const STRING ext = getExtension(file);
	    
		if (_ftcsicmp(ext.c_str(), _T("anm")) == 0)
		{
			m_data.open(g_projectPath + MISC_PATH + file);
		}
		else if (_ftcsicmp(ext.c_str(), _T("gif")) == 0)
		{
			m_data.loadFromGif(resolve(g_projectPath + MISC_PATH + file));
			renderFrame = &CAnimation::renderFileFrame;
			m_data.filename = file;
		}
	}

	freeCanvases();
	m_canvases.resize(m_data.frameCount, NULL);
}
Example #3
0
// 得到宝石属性信息
LPCTSTR	CObject_Item_Gem::GetGemArribInfo()
{
	
	static TCHAR szAttribInfo[1024];
	TCHAR	szInfo[512];

	memset(szAttribInfo, 0, sizeof(szAttribInfo));
	STRING strAttrib = _T("");

	STRING strTemp = "";
		
	if(m_theBaseDef)
	{
		for(int i = 0; i < 60; i++)
		{
			memset(szInfo, 0, sizeof(szInfo));
			if(-1 != m_theBaseDef->nAttr[i])
			{
				strTemp = NOCOLORMSGFUNC(g_szGemAttName[i]);
				_stprintf(szInfo, _T("%s+%d\n"), strTemp.c_str(), m_theBaseDef->nAttr[i]);
				//_stprintf(szInfo, _T("%s:%d\n"), g_szGemAttName[i], m_theBaseDef->nAttr[i]);
				strAttrib += szInfo;
			}
		}

		_stprintf(szAttribInfo, _T("%s"), strAttrib.c_str());
		return szAttribInfo;
	}

	return szAttribInfo;


}
	/* ------------------------------------------------
	// 放生
	参数1	GUID m_uHighSection
	参数2	GUID m_uLowSection
	------------------------------------------------ */
	INT Mount::FreeMount(LuaPlus::LuaState* state)
	{
		LuaStack args(state);
		if (!(args[2].IsString()))
		{
			KLThrow("Mount::FreeMount[2] param parameter error");
		}
		STRING szHighSection = args[2].GetString();

		if (!(args[3].IsString()))
		{
			KLThrow("Mount::FreeMount[3] param parameter error");
		}
		STRING szLowSection = args[3].GetString();

		PET_GUID_t GUID;
		GUID.m_uHighSection = atol(szHighSection.c_str());
		GUID.m_uLowSection	= atol(szLowSection.c_str());

		const SDATA_PET* pPet = CDataPool::GetMe()->Pet_GetPet(GUID); 
		if (pPet && FALSE == pPet->m_GUID.IsNull())
		{
			//向服务器发送
			CGManipulatePet Msg;

			Msg.SetGUID(pPet->m_GUID);
			Msg.SetManipulateType( MANIPULATE_FREEHORSE );
			CNetManager::GetMe()->SendPacket(&Msg);
		}

		return 0;
	}
Example #5
0
BOOL CSoundBufferFMod::ReadWavBuffer(const STRING &name)
{
	Release();

	char* lpAddress = NULL;
	DWORD dwSize = CGameProcedure::s_pResourceProvider->loadResource(name.c_str(), lpAddress, "General");
	if(dwSize > 0)
	{
		m_pFModSample = FSOUND_Sample_Load(FSOUND_FREE, 
				lpAddress, 
				FSOUND_HW3D | FSOUND_LOADMEMORY, 0, dwSize);
		CGameProcedure::s_pResourceProvider->unloadResource( lpAddress, dwSize );
	}
	
	if(!m_pFModSample) 
	{
		KLThrow("Invalid sound file:%s", name.c_str());
		return FALSE;
	}

	//缺省所有声音都是不循环的
    FSOUND_Sample_SetMode(m_pFModSample, FSOUND_LOOP_OFF);

	return TRUE;
}
	// 询问是否删除角色
	INT CGameProduce_Login::DelRole_YesNo(LuaPlus::LuaState* state)
	{

		LuaStack args(state);
		if (!(args[2].IsInteger()))
		{
			KLThrow("LUA:GetBuffIconNameByIndex param parameter error");
		}

		int iRoleIndex = args[2].GetInteger();
		CGameProcedure::s_pProcCharSel->m_iCurSelRoleDel = iRoleIndex;
		std::vector< STRING > strParamInfo;

		if(CGameProcedure::s_pProcCharSel->IsValidIndex(iRoleIndex))
		{
			// 
			std::string strInfo = ""; 
			// 通过索引得到角色的信息
			const DB_CHAR_BASE_INFO* pInfo = CGameProcedure::s_pProcCharSel->GetRoleInfo(iRoleIndex);
			if(pInfo)
			{
				//if(pInfo->m_Level < 9)
				{
					TCHAR szBuf[128];
					STRING strTemp = "";
					strTemp = NOPARAMMSGFUNC("GMGameInterface_Script_GameLogin_Info_Del_Role_YesNo");
					_stprintf(szBuf, strTemp.c_str(), pInfo->m_Level, pInfo->m_Name);
					//_stprintf(szBuf, _T("你确定要将 %d级 的角色#c00ff00 %s #cffffff删除吗?"), pInfo->m_Level, pInfo->m_Name);
					strParamInfo.push_back(szBuf);
					strParamInfo.push_back("1");

					((CEventSystem*)CGameProcedure::s_pEventSystem)->PushEvent( GE_GAMELOGIN_SYSTEM_INFO_YESNO, strParamInfo);
				}
				//else
				//{
				//	STRING strTemp = "";
				//	strTemp = NOCOLORMSGFUNC("CGameProduce_Login_Can_Not_Del_Level_Over_9");
				//	CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_SHOW_SYSTEM_INFO, strTemp.c_str());
				//}//
			}
			else
			{
				STRING strTemp = "";
				strTemp = NOCOLORMSGFUNC("GMGameInterface_Script_GameLogin_Info_Sel_Del_Role");
				CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_SHOW_SYSTEM_INFO, strTemp.c_str());
				//CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_SHOW_SYSTEM_INFO, "请选择一个要删除的角色.");
			}//
		}
		else
		{
			STRING strTemp = "";
			strTemp = NOCOLORMSGFUNC("GMGameInterface_Script_GameLogin_Info_Sel_Del_Role");
			CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_SHOW_SYSTEM_INFO, strTemp.c_str());
			//CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_SHOW_SYSTEM_INFO, "请选择一个要删除的角色.");
		}
		
		return 0;
	}
uint GCManualAttrResultHandler::Execute(GCManualAttrResult* pPacket,Player* pPlayer)
{
	__ENTER_FUNCTION
		
		ATTR_RESUlT res = pPacket->GetResult();
		switch(res)
		{
		case ATTR_RESUlT_SUCCESS:
			{
				CGameProcedure::s_pEventSystem->PushEvent( GE_MANUAL_ATTR_SUCCESS_EQUIP );

				STRING strTemp = "";
				strTemp = NOCOLORMSGFUNC("GCManualAttriResultHandler_Info_Addjust_Attr_Success");
				CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, strTemp.c_str());
				//CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, "调整属性成功." );
				break;
			}
		case ATTR_RESULT_NOT_ENOUGH_REMAIN_POINT:
			{

				STRING strTemp = "";
				strTemp = NOCOLORMSGFUNC("GCManualAttriResultHandler_Info_Addjust_Attr_Fail_No_Enough_point");
				CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, strTemp.c_str());
				//CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, "调整属性失败,没有足够的点数." );
				break;
			}
		case ATTR_RESULT_NO_SUCH_ATTR:
			{
				
				STRING strTemp = "";
				strTemp = NOCOLORMSGFUNC("GCManualAttriResultHandler_Info_Addjust_Attr_Fail_No_This_Attri");
				CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, strTemp.c_str());
				//CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, "调整属性失败, 没有这个属性." );
				break;
			}
		case ATTR_RESUlT_NO_POINT:
			{

				STRING strTemp = "";
				strTemp = NOCOLORMSGFUNC("GCManualAttriResultHandler_Info_Addjust_Attr_Fail_No_Enough_point");
				CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, strTemp.c_str());
				//CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, "调整属性失败,没有足够的点数." );
				break;
			}

		default:
			{
				break;
			}
		}

		
		return PACKET_EXE_CONTINUE;

	__LEAVE_FUNCTION	

		return PACKET_EXE_ERROR;
}
Example #8
0
CKT::CVersion::CVersion(STRING version)
{
	int iPoint = version.find('.');
	STRING sTemp = version.substr(0, iPoint);
	m_byMajor = (BYTE)toInt(sTemp.c_str());

	sTemp = version.substr(iPoint + 1, version.length() - iPoint);
	m_byMinor = (BYTE)toInt(sTemp.c_str());
}
Example #9
0
void HttpSocket::SendGetInet(const STRING &url, const STRING &host, const int &port, std::vector<char> *data)
{
	char d[4096];
	DWORD len;
	stringstream lss;
	INTERNET_BUFFERS BufferIn = {0};

	BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS );

	HINTERNET hNet = InternetOpen(_T("peelClient"), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, NULL);
	if(!hNet)
		throw SocketException(_T("Could not open internet"), GetError());
	
	HINTERNET hCon = InternetConnect(hNet, host.c_str(), port , 0, 0, INTERNET_SERVICE_HTTP, 0, 0);
	if(!hCon)
	{
		InternetCloseHandle(hNet);
		throw SocketException(_T("Could not connect to server"), GetError());
	}

	HINTERNET hReq = HttpOpenRequest(hCon, _T("GET"), url.c_str(), 0, 0, 0, INTERNET_FLAG_RELOAD, 0);
	if(!hReq)
	{
		InternetCloseHandle(hNet);
		InternetCloseHandle(hCon);
		throw SocketException(_T("Could not open request to server"), GetError());
	}

	if(!HttpSendRequest(hReq, NULL, NULL, NULL, NULL))
	{
		InternetCloseHandle(hNet);
		InternetCloseHandle(hCon);
		throw SocketException(_T("Could not send request to server"), GetError());
	}



	if(data != NULL)
	{
		lss.str("");

		while(1)
		{
			if(!InternetReadFile(hReq, d, 4095, &len))
				break;
			if(len==0) break;
			d[len]='\0';
            std::copy( d, d+len, (*data).begin());
		}
	}

	InternetCloseHandle(hNet);
	InternetCloseHandle(hCon);

}
Example #10
0
void JustRenderIt::NotImplemented(bool halt, STRING msg)
{
  STRING str = msg + " Not implemented!";

  if(!halt)
    LOG_WARNING1(str.c_str());
  else
  {
    LOG_FATAL1(str.c_str());
  }
}
Example #11
0
bool XmlTagEntity::getArg(STRING name, int &ivalue)
{
	STRING tmp;
	if(!getArg(name, tmp)) return false;
#ifdef _WIN32
	ivalue = _tstoi(tmp.c_str());
#else
	ivalue = atoi(tmp.c_str());
#endif
	return true;
}
Example #12
0
//从文件中读取变量
VOID CVariableSystem::LoadVariable(LPCTSTR szFileName, VARIABLE_MAP& mapBuf)
{
	KLAssert(szFileName);
	//	mapBuf.clear();

	//-----------------------------------------------------------
	//取得配置文件的大小
	HANDLE hFile = CreateFile(szFileName,
		GENERIC_READ,
		FILE_SHARE_READ | FILE_SHARE_WRITE,
		NULL,
		OPEN_EXISTING,
		FILE_ATTRIBUTE_NORMAL,
		NULL);

	if(INVALID_HANDLE_VALUE == hFile) return;

	DWORD dwHigh;
	DWORD dwFileSize = GetFileSize(hFile, &dwHigh);
	CloseHandle(hFile); hFile = NULL;
	if(0==dwFileSize) return;

	//-----------------------------------------------------------
	//分配足够的内存
	CHAR* pTempBuf = new CHAR[dwFileSize+32];
	if(!pTempBuf) return;

	//-----------------------------------------------------------
	//从配置文件中读取"Variable"节
	::GetPrivateProfileSection("Variable", pTempBuf, dwFileSize, szFileName);
	//分解
	std::vector< STRING > vRet;
	ConvertSectionInVector(pTempBuf, dwFileSize, vRet);

	delete[] pTempBuf; pTempBuf=NULL;

	//加入变量定义
	for(INT i=0; i<(INT)vRet.size(); i++)
	{
		STRING& strLine = vRet[i];

		STRING::size_type tEqu = strLine.find_first_of("= \t");
		if(tEqu == STRING::npos) continue;

		STRING strName = strLine.substr(0, tEqu);

		CHAR szTemp[1024];
		::GetPrivateProfileString("Variable", strName.c_str(), "", szTemp, 1024, szFileName);

		SetVariable(strName.c_str(), szTemp, FALSE);
	}

}
Example #13
0
BOOL EditDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
    COMBOBOXEXITEMW Item;
    ZeroMemory(&Item, sizeof(Item));
    Item.mask = CBEIF_TEXT;

    FONTNAMESET::iterator it, end = g_Names.end();
    for (it = g_Names.begin(); it != end; ++it)
    {
        Item.pszText = const_cast<LPWSTR>(it->c_str());
        Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb2));
        SendDlgItemMessageW(hwnd, cmb2, CBEM_INSERTITEM, 0, (LPARAM)&Item);
    }
    SetDlgItemTextW(hwnd, edt1, g_strFontName.c_str());
    SetDlgItemTextW(hwnd, cmb2, g_strSubstitute.c_str());

    const INT Count = _countof(g_CharSetList);
    for (INT i = 0; i < Count; ++i)
    {
        Item.pszText = const_cast<LPWSTR>(g_CharSetList[i].DisplayName);
        Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb3));
        SendDlgItemMessageW(hwnd, cmb3, CBEM_INSERTITEM, 0, (LPARAM)&Item);
        Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb4));
        SendDlgItemMessageW(hwnd, cmb4, CBEM_INSERTITEM, 0, (LPARAM)&Item);
    }

    SendDlgItemMessageW(hwnd, cmb3, CB_SETCURSEL, 0, 0);
    SendDlgItemMessageW(hwnd, cmb4, CB_SETCURSEL, 0, 0);
    for (INT i = 0; i < Count; ++i)
    {
        if (g_CharSet1 == g_CharSetList[i].CharSet)
        {
            SendDlgItemMessageW(hwnd, cmb3, CB_SETCURSEL, i, 0);
        }
        if (g_CharSet2 == g_CharSetList[i].CharSet)
        {
            SendDlgItemMessageW(hwnd, cmb4, CB_SETCURSEL, i, 0);
        }
    }

    SIZE siz;
    HDC hDC = CreateCompatibleDC(NULL);
    SelectObject(hDC, GetStockObject(DEFAULT_GUI_FONT));
    GetTextExtentPoint32W(hDC, g_LongestName, lstrlenW(g_LongestName), &siz);
    DeleteDC(hDC);

    SendDlgItemMessageW(hwnd, cmb3, CB_SETHORIZONTALEXTENT, siz.cx + 16, 0);
    SendDlgItemMessageW(hwnd, cmb4, CB_SETHORIZONTALEXTENT, siz.cx + 16, 0);

    EnableWindow(GetDlgItem(hwnd, cmb3), FALSE);

    return TRUE;
}
	//宠物改名字
	INT	Pet::Change_Name(LuaPlus::LuaState* state)
	{
		LuaStack args(state);

		if ( !(args[2].IsInteger()) || !(args[3].IsString()) )
		{
			KLThrow("LUA:Pet Change_Name parameter error");
		}

		INT nPetNum = args[2].GetInteger();
		LPCTSTR szName = args[3].GetString();
		STRING szTemp="";

		SDATA_PET* My_Pet= CDataPool::GetMe()->Pet_GetPet(nPetNum);
		if( (!My_Pet) || ( !My_Pet->m_pModelData ) ) 
		{
			KLThrow("LUA:Pet Change_Name parameter error");
			return 0;
		}
		if(CGameProcedure::s_pUISystem->CheckStringFilter(szName, FT_NAME) == FALSE)
		{
			
			STRING strTemp = "";
			strTemp = NOCOLORMSGFUNC("GMGameInterface_Script_Talk_Info_InvalidContent");
			CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE,strTemp.c_str());
			return 0;

		}
		else if(CGameProcedure::s_pUISystem->CheckStringCode(szName,szTemp) == FALSE)
		{

			return 0;

		}
		else if(KLU_CheckStringValid(szName) == FALSE)
		{
			STRING strTemp = "";
			strTemp = NOCOLORMSGFUNC("ERRORSpecialString");
			CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE,strTemp.c_str());
			return 0;
		}
		//向服务器发送
		CGSetPetAttrib Msg;
		if(strcmp(szName, My_Pet->m_szName.c_str()) != 0)
		{
			Msg.SetGUID(My_Pet->m_GUID);
//			Msg.SetIndex(nPetNum);		
			Msg.SetName((CHAR*)szName);
			CNetManager::GetMe()->SendPacket(&Msg);
		}
		return 0;
	}
Example #15
0
// Resolve a file name
STRING resolvePakFile(const STRING path)
{
	if(path.find("Saved\\",0) ==0){ return path;}
	const STRING file = g_pakTempPath + path;
	resolve = resolveNonPakFile;
	if (!CFile::fileExists(file))
	{
		// Extract the file from the pak file or this executable.
		// (Assume the zip is open!)
		ZIPExtract(const_cast<char *>(path.c_str()), const_cast<char *>(file.c_str()));
	}
	resolve = resolvePakFile;
	return file;
}
	/* ------------------------------------------------
	// 申请改变坐骑的名字
	参数1	MountIndex
	参数2	MountName
	------------------------------------------------ */
	INT Mount::ChangeMountName(LuaPlus::LuaState* state)
	{
		LuaStack args(state);
		if (!(args[2].IsInteger()))
		{
			KLThrow("Mount::ChangeMountName[2] param parameter error");
		}
		INT nMountIndex = args[2].GetInteger();

		if (!(args[3].IsString()))
		{
			KLThrow("Mount::ChangeMountName[3] param parameter error");
		}
		STRING szNickName = args[3].GetString();

		INT nNum = strlen(szNickName.c_str());
		// 
		if (nNum <= 0)
		{
			CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE, "名字不能为空");
			return 0;
		}

		// 名字最大长度
		if (nNum >= MAX_NICK_NAME-1)
		{
			CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE, "名字字数过长");
			return 0;
		}

		SDATA_PET* pPet = CDataPool::GetMe()->Pet_GetPet(nMountIndex);
		if (pPet && FALSE == pPet->m_GUID.IsNull())
		{
			// 和当前名不一样
			if (0 != strcmp(szNickName.c_str(), pPet->m_szNickname.c_str()))
			{
				// 发送改名消息
				CGManipulatePet Msg;

				Msg.SetGUID( pPet->m_GUID );
				Msg.SetNickName(szNickName.c_str());
				Msg.SetManipulateType( MANIPULATE_HORSE_NICKNAME );

				CNetManager::GetMe()->SendPacket(&Msg);
			}			
		}

		return 0;
	}
LPID::LPID( const STRING& aLPID ) throw( PARSE_ERROR )
{
    int offset = Parse( aLPID );

    if( offset != -1 )
    {
        THROW_PARSE_ERROR(
                _( "Illegal character found in LPID string" ),
                wxString::FromUTF8( aLPID.c_str() ),
                aLPID.c_str(),
                0,
                offset
                );
    }
}
Example #18
0
void promptAngularVelocity(Vector4d& initialAngularVelocity)
{
    BOOL validVelocity = FALSE;
    do
    {
        STRING initialVelocityString;
        cout << "Entrez la vitesse angulaire initiale comme suit Wx, Wy, Wz: ";
        getline(cin, initialVelocityString);

        CHAR* nextToken = NULL;
        INT tokenCount = 0;
        CHAR* token = strtok_s((CHAR*) initialVelocityString.c_str(), ", ", &nextToken);
        while (token != NULL && tokenCount < 3) {
            initialAngularVelocity[tokenCount++] = atof(token);
	        token = strtok_s(NULL, ", ", &nextToken);
        }

        validVelocity = tokenCount == 3;
        if ( !validVelocity )
        {
            cout << "Nombre de composants invalide" << endl;
            cout << "Vitesse angulaire initiale invalide, veuillez recommencer" << endl << endl;
        }

    } while( !validVelocity );
}
Example #19
0
// Load and decompress NBT file
bool NBT_Reader::Load(const STRING file)
{
	gzFile zload = 0;
#ifdef UNICODE
	std::string sFile(file.begin(), file.end());
	zload = gzopen(sFile.c_str(), "rb");
#else
	zload = gzopen(file.c_str(), "rb");
#endif
	BYTE buffer[BUFFER_SIZE] = {0};
	std::string load;
	int a = -1;
	do
	{
		a = gzread(zload, buffer, BUFFER_SIZE);
		if (a > 0)
			load.append(buffer, buffer+a);
	}
	while (a > 0);
	gzclose(zload);
	// Invalid
	if (load[0] != 10)
		return false;
	int size = load.size();
	data = new BYTE[size];
	memcpy(data, load.c_str(), size);
	pointer = data;
	return true;
}
Example #20
0
FdoLiteralValue* ExpressionFunctionLookup::Evaluate(FdoLiteralValueCollection *literalValues)
{
    // make sure we have 2 or more arguments, and that there are 2 plus a multiple of 2
    if (literalValues->GetCount() < 2 || (literalValues->GetCount()-2) % 2 != 0)
    {
        MgResources* resources = MgResources::GetInstance();
        assert(NULL != resources);

        STRING message = MgUtil::GetResourceMessage(MgResources::Stylization, L"MgIncorrectNumberOfArguments");
        MgStringCollection arguments;
        arguments.Add(L"LOOKUP"); // NOXLATE
        message = resources->FormatMessage(message, &arguments);

        throw FdoExpressionException::Create(message.c_str());
    }

    // the first parameter is the key we seek
    FdoPtr<FdoLiteralValue> key = literalValues->GetItem(0);

    // look for our key in remaining pairs, return matching value if found
    for (int i=2; i<literalValues->GetCount(); i += 2)
    {
        FdoPtr<FdoLiteralValue> thisKey = literalValues->GetItem(i);
        if (ExpressionHelper::Compare(key, thisKey) == 0)
            return literalValues->GetItem(i+1);
    }

    // we didn't find a match - return the default
    return literalValues->GetItem(1);
}
FdoFunctionDefinition* ExpressionFunctionArgb::GetFunctionDefinition()
{
    if (!m_functionDefinition)
    {
        STRING funcDesc = MgUtil::GetResourceMessage(MgResources::Stylization, L"MgFunctionARGB_Description");
        STRING aValDesc = MgUtil::GetResourceMessage(MgResources::Stylization, L"MgFunctionARGB_AValueDescription");
        STRING rValDesc = MgUtil::GetResourceMessage(MgResources::Stylization, L"MgFunctionARGB_RValueDescription");
        STRING gValDesc = MgUtil::GetResourceMessage(MgResources::Stylization, L"MgFunctionARGB_GValueDescription");
        STRING bValDesc = MgUtil::GetResourceMessage(MgResources::Stylization, L"MgFunctionARGB_BValueDescription");

        FdoPtr<FdoArgumentDefinition> arg1 = FdoArgumentDefinition::Create(L"aValue", aValDesc.c_str(), FdoDataType_Int32); // NOXLATE
        FdoPtr<FdoArgumentDefinition> arg2 = FdoArgumentDefinition::Create(L"rValue", rValDesc.c_str(), FdoDataType_Int32); // NOXLATE
        FdoPtr<FdoArgumentDefinition> arg3 = FdoArgumentDefinition::Create(L"gValue", gValDesc.c_str(), FdoDataType_Int32); // NOXLATE
        FdoPtr<FdoArgumentDefinition> arg4 = FdoArgumentDefinition::Create(L"bValue", bValDesc.c_str(), FdoDataType_Int32); // NOXLATE

        FdoPtr<FdoArgumentDefinitionCollection> args = FdoArgumentDefinitionCollection::Create();
        args->Add(arg1);
        args->Add(arg2);
        args->Add(arg3);
        args->Add(arg4);

        m_functionDefinition = FdoFunctionDefinition::Create(L"ARGB", // NOXLATE
                                                             funcDesc.c_str(),
                                                             FdoDataType_Int32,
                                                             args,
                                                             FdoFunctionCategoryType_String,
                                                             false);
    }

    return FDO_SAFE_ADDREF(m_functionDefinition);
}
STRING DIR_LIB_SOURCE::makeFileName( const STRING& aPartName )
{
    // create a fileName for the sweet string, using a reversible
    // partname <-> fileName conversion protocol:

    STRING  fileName = sourceURI + "/";

    const char* rev = endsWithRev( aPartName );

    if( rev )
    {
        int basePartLen = rev - aPartName.c_str() - 1;  // omit '/' separator
        fileName.append( aPartName, 0,  basePartLen );
        fileName += SWEET_EXT;
        fileName += '.';
        fileName += rev;
    }
    else
    {
        fileName += aPartName;
        fileName += SWEET_EXT;
    }

    return fileName;
}
Example #23
0
extern "C" MAIN_API bool PLUGIN_INI_FUNC_DEFAAULT_NAME(PluginSys::Plugin * p)
{
	STRING name = p->name();
	name += L".cfg";
	Config config(name);

	STRING fl = config.Get(PLUGIN_CONTAINER_CONFIG_FILE_LIST_KEY);
	STRING nl = config.Get(PLUGIN_CONTAINER_CONFIG_NAME_LIST_KEY);
	g_pc = new PluginSys::PluginContainer(fl, nl);
	g_pc->AddFather(p);

	// load fps
	STRING fps = config.Get(PLUGIN_MAIN_FPS_CONFIG_NAME);
	u32 ufps = boost::lexical_cast<u32>(fps.c_str());
	SINGLETON(God).SetFps(ufps);

	// load filefinder
	STRING filefinder_filename = config.Get(PLUGIN_MAIN_FILEFINDER_FILENAME_CONFIG_NAME);
	STRING filefinder_name = config.Get(PLUGIN_MAIN_FILEFINDER_NAME_CONFIG_NAME);
	SINGLETON(God).SetPluginName(FILE_FINDER_PLUGIN_TYPE, filefinder_filename, filefinder_name);

	// load musicengine
	STRING musicengine_filename = config.Get(PLUGIN_MAIN_MUSICENGINE_FILENAME_CONFIG_NAME);
	STRING musicengine_name = config.Get(PLUGIN_MAIN_MUSICENGINE_NAME_CONFIG_NAME);
	SINGLETON(God).SetPluginName(MUSIC_ENGINE_PLUGIN_TYPE, musicengine_filename, musicengine_name);

	g_pc->Ini();

	g_Plugin = p;

	return true;
}
Example #24
0
void GooRoomClient::InitializeCloudMap(const StageLevel stageLevel)
{
    STRING fileName = this->GetCloudMapFilePath(stageLevel);
    
    m_CloudMap.ClearCloudMap();
    m_CloudMap.InitializeCloudMapFromFile(fileName.c_str());
}
Example #25
0
void GooRoomClient::InitializeClient(GooRoomClientRPCInterface* gooroomClientRPCReceiver)
{
    ASSERT_RELEASE(m_IsInitialized == false);
    ASSERT_RELEASE(m_IsStarted == false);
    
    STRING resourceFullPath = this->GetWritableFilePath(RESOURCE_MANAGER_FILENAME);
    m_GooRoomResourceVersionManager.InitializeDataFromFile(resourceFullPath.c_str());

    m_GooRoomClientRPCInterface = gooroomClientRPCReceiver;
    
    m_ThreadController.Initialize(DEFAULT_NUMBER_OF_THREADS);
    m_ThreadController.AddWorkerRoutine(&m_ScheduledTaskWorkerRoutine);
    m_ThreadController.AddWorkerRoutine(&m_GameTaskWorkerRoutine);
    m_ThreadController.AddWorkerRoutine(&m_NetworkWorkerRoutine);
    
    // NOTE :
    // RenderingTaskWorkerRoutine is managed by Cocos2d main thread
    // DO NOT ADD this m_RenderingTaskWorkerRoutine
    
    
    // connect to server
    //m_ClientObject.InitializeClient(SERVER_CONNECT_ADDRESS, SERVER_CONNECT_PORT);
    static_cast<SCPacketHandler*>(m_CSConnection->GetPacketHandler())->SetGooRoomClientRPCReceiver(gooroomClientRPCReceiver);
    static_cast<FCPacketHandler*>(m_CFConnection->GetPacketHandler())->SetGooRoomClientRPCReceiver(gooroomClientRPCReceiver);
    
    m_CFConnectionFactory.SetGooRoomClientRPCInterface(m_GooRoomClientRPCInterface);
    
   // m_CFResponseConnectType = CFResponseConnectType_Login;
   StageInfoDictionary::Instance().Initialize();
    
    m_IsInitialized = true;
}
void DIR_LIB_SOURCE::readString( STRING* aResult, const STRING& aFileName ) throw( IO_ERROR )
{
    FILE_WRAP   fw = open( aFileName.c_str(), O_RDONLY );

    if( fw == -1 )
    {
        STRING  msg = strerror( errno );
        msg += "; cannot open(O_RDONLY) file " + aFileName;
        THROW_IO_ERROR( msg );
    }

    struct stat     fs;

    fstat( fw, &fs );

    // sanity check on file size
    if( fs.st_size > (1*1024*1024) )
    {
        STRING msg = aFileName;
        msg += " seems too big.  ( > 1 mbyte )";
        THROW_IO_ERROR( msg );
    }

#if 0
    // I read somewhere on the Internet that std::string chars are not guaranteed
    // (over time) to be contiguous in future implementations of C++, so this
    // strategy is here for that eventuality.  We buffer through readBuffer here.

    // reuse same readBuffer, which is not thread safe, but the API
    // is not advertising thread safe (yet, if ever).
    if( (int) fs.st_size > (int) readBuffer.size() )
        readBuffer.resize( fs.st_size + 1000 );

    int count = read( fw, &readBuffer[0], fs.st_size );
    if( count != (int) fs.st_size )
    {
        STRING  msg = strerror( errno );
        msg += "; cannot read file " + aFileName;
        THROW_IO_ERROR( msg );
    }

    aResult->assign( &readBuffer[0], count );
#else

    // read into the string directly
    aResult->resize( fs.st_size );

    int count = read( fw, &(*aResult)[0], fs.st_size );
    if( count != (int) fs.st_size )
    {
        STRING  msg = strerror( errno );
        msg += "; cannot read file " + aFileName;
        THROW_IO_ERROR( msg );
    }

    // test trailing nul is there, which should have been put there with resize() above
    // printf( "'%s'\n", aResult->c_str() );    // checked OK.
#endif

}
Example #27
0
/**
 * This routine parses the command line arguments that were
 * passed to the program and ses them to set relevant
 * training-related global parameters
 *
 * Globals:
 * - Config  current clustering parameters
 * @param argc number of command line arguments to parse
 * @param argv command line arguments
 * @return none
 * @note Exceptions: Illegal options terminate the program.
 */
void ParseArguments(int* argc, char ***argv) {
  STRING usage;
  if (*argc) {
    usage += (*argv)[0];
  }
  usage += " [.tr files ...]";
  tesseract::ParseCommandLineFlags(usage.c_str(), argc, argv, true);
  // Record the index of the first non-flag argument to 1, since we set
  // remove_flags to true when parsing the flags.
  tessoptind = 1;
  // Set some global values based on the flags.
  Config.MinSamples =
      MAX(0.0, MIN(1.0, double(FLAGS_clusterconfig_min_samples_fraction)));
  Config.MaxIllegal =
      MAX(0.0, MIN(1.0, double(FLAGS_clusterconfig_max_illegal)));
  Config.Independence =
      MAX(0.0, MIN(1.0, double(FLAGS_clusterconfig_independence)));
  Config.Confidence =
      MAX(0.0, MIN(1.0, double(FLAGS_clusterconfig_confidence)));
  // Set additional parameters from config file if specified.
  if (!FLAGS_configfile.empty()) {
    tesseract::ParamUtils::ReadParamsFile(
        FLAGS_configfile.c_str(),
        tesseract::SET_PARAM_CONSTRAINT_NON_INIT_ONLY,
        ccutil.params());
  }
}
Example #28
0
// Delete a tree.
// 'path' should include a trailing backslash.
void deleteTree(const STRING path)
{
	WIN32_FIND_DATA fd;

	HANDLE hSearch = FindFirstFile((path + _T("*")).c_str(), &fd);
	do
	{
		const STRING strFile = fd.cFileName;

		if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
		{
			// Delete this directory too.
			if ((strFile != _T(".")) && (strFile != _T("..")))
			{
				deleteTree(path + strFile + _T("\\"));
			}
		}
		else
		{
			// Unlink each file.
			_tunlink((path + fd.cFileName).c_str());
		}
	} while (FindNextFile(hSearch, &fd));
	FindClose(hSearch);

	// Then remove the directory.
	RemoveDirectory(path.c_str());
}
Example #29
0
void CHelperSystem::GotoAnchorHelp(const STRING& strAnchor)
{
    //-------------------------------
    //寻找目标窗口
    HWND hCmdWnd = ::FindWindow(0, m_strCmdWnd.c_str());
    if(!hCmdWnd)
    {
        CreateHelperProcess(strAnchor);
        return;
    }

    //-------------------------------
    //向目标窗口发送命令
    typedef struct
    {
        unsigned char	cCmdType;
        unsigned char	cReserve1;
        unsigned char	cReserve2;
        unsigned char	cReserve3;
        char			pContents[MAX_PATH];
    } HELPER_COMMAND, FAR *LPHELPER_COMMAND;

    static  HELPER_COMMAND cmd;
    ZeroMemory(&cmd, sizeof(HELPER_COMMAND));
    _snprintf(cmd.pContents, MAX_PATH, "%s", strAnchor.c_str());

    static COPYDATASTRUCT   cCopyData;
    ZeroMemory(&cCopyData, sizeof(COPYDATASTRUCT));

    cCopyData.dwData = 0;
    cCopyData.cbData = sizeof(unsigned char)*4 + (DWORD)strlen(cmd.pContents) + 1;
    cCopyData.lpData = &cmd;

    SendMessage(hCmdWnd, WM_COPYDATA, 0, (LPARAM)&cCopyData);
}
Example #30
0
// Constructor adapted for use as a wrapper around that other Request Parameter
// thing (the one outside of the OgcFramework) since that bad boy is case
// sensitive, and we don't want it to be.
// We adapt this from the NameValueCollection class that came from the OgcFramework.
MgHttpRequestParameters::MgHttpRequestParameters(MgHttpRequestParam* pParams)
: m_pParams(pParams)
{
    MgStringPropertyCollection* p = m_pParams->GetParameters();
    SetCount(p->GetCount());

    for(int i=0; i< Count(); i++) {
      STRING sName = p->GetName(i);
      STRING sValue = p->GetValue(i);

      VPSZ pszName = szdup(sName.c_str());
      VPSZ pszValue = szdup(sValue.c_str());
      SetName(i,pszName);
      SetValue(i,pszValue);
    }
}