Пример #1
0
int CNssCreature::SummonAssociate(CGameObject *oObject, char *Params) {
	CNWSCreature *cre = oObject->AsNWSCreature();
	if (!cre) {
		_log(2, "o Error SummonAssociate used on non-creature object.\n");
		sprintf(Params, "-1");
		return 0;
	}

	uint16_t Type=0;
	char Name[250];
	char ResRef[16];

	if (sscanf(Params, "%s %s %d", ResRef, Name, &Type) != 3) {
		sprintf(Params, "-1");
		return -1;
	}

	CResRef sResRef;
	strcpy(sResRef.resref, ResRef);
	CExoString sName(Name);
	_log(3, "ResRef: %s\tName: %s\tType %d\n", sResRef.resref, sName.text, Type);
	cre->SummonAssociate(sResRef, sName, Type);

	return 1;
}
Пример #2
0
int CItems::New(LPCTSTR szName, LPCTSTR szContent, int nParentId, BOOL bFolder, int nModuleId/* =-1*/)
{
	if (bFolder == FALSE || nModuleId == -1) // new item is not folder, to get module id from parent folder
	{
		Assist::IItemIteratorPtr pParent = GetItem(nParentId);
		nModuleId = pParent->GetModuleId();
		if (nModuleId == ID_TRASH)
			ThrowError(RESSTR(IDS_CAN_NOT_ADD_TO_TRASH));
	}

	IStatementPtr st = CApplicationImpl::Get().GetStatement();

	CStringBuf sName(szName);
	CStringBuf sContent(szContent);
	time_t t = dateutils::GetCurrentDate();
	st->sql(_T("insert into adx_items (created, name, content, module, parent, folder) values (:created, :name, :content, :module, :parent, :folder)"));
	st->use(t, _T(":created"));
	st->use(sName, _T(":name"));
	st->use(sContent, _T(":content"));
	st->use(nModuleId, _T(":module"));
	st->use(nParentId, _T(":parent"));
	st->use((int&)bFolder, _T(":folder"));
	st->exec();
	return st->last_insert_rowid();
}
Пример #3
0
void Event::Create(const TCHAR* const pszName)
{
   if(NULL == pszName)
      THROW_STD_EXCEPTION(L"The name of the event may not be null");

   CString sName(pszName);
   sName.Trim();
   if(0 >= sName.GetLength())
      THROW_STD_EXCEPTION(L"The name of the event is invalid. It is either empty, or contains only spaces.");

   m_hEvent = CreateEvent(NULL, TRUE, FALSE, sName);
   if(NULL == m_hEvent)
   {
      DWORD dwLastError = ::GetLastError();
      CString sMessage;
      sMessage.Format(_T("Failed to create the event, \"%s\"."), (LPCTSTR)sName);
      THROW_STD_EXCEPTION(sMessage);
   }

   DWORD dwLastError = GetLastError();
   if(ERROR_ALREADY_EXISTS == dwLastError)
   {
      CloseHandle(m_hEvent);
      m_hEvent = 0;   
      CString sMessage;
      sMessage.Format(_T("Failed to create the event, \"%s\" as the event already exists."), (LPCTSTR)sName);
      THROW_STD_EXCEPTION(sMessage);
   }

   CString sMessage;
   sMessage.Format(_T("The event \"%s\" has been created."), (LPCTSTR)sName);
   LOG_WS_INFO(std::wstring(sMessage).c_str());
}
Пример #4
0
irr::scene::ISceneNode *CIrrOdeSceneNodeFactory::addSceneNode (irr::scene::ESCENE_NODE_TYPE type, irr::scene::ISceneNode *parent) {
  CIrrOdeSceneNode *pRet=NULL;
  if (!parent) parent=m_pManager->getRootSceneNode();
  switch (type) {
    case IRR_ODE_BODY_ID             : pRet=new CIrrOdeBody           (parent,m_pManager); break;
    case IRR_ODE_GEOM_BOX_ID         : pRet=new CIrrOdeGeomBox        (parent,m_pManager); break;
    case IRR_ODE_GEOM_CAPSULE_ID     : pRet=new CIrrOdeGeomCapsule    (parent,m_pManager); break;
    case IRR_ODE_GEOM_CYLINDER_ID    : pRet=new CIrrOdeGeomCylinder   (parent,m_pManager); break;
    case IRR_ODE_GEOM_HEIGHTFIELD_ID : pRet=new CIrrOdeGeomHeightfield(parent,m_pManager); break;
    case IRR_ODE_GEOM_PLANE_ID       : pRet=new CIrrOdeGeomPlane      (parent,m_pManager); break;
    case IRR_ODE_GEOM_RAY_ID         : pRet=new CIrrOdeGeomRay        (parent,m_pManager); break;
    case IRR_ODE_GEOM_SPHERE_ID      : pRet=new CIrrOdeGeomSphere     (parent,m_pManager); break;
    case IRR_ODE_GEOM_TRIMESH_ID     : pRet=new CIrrOdeGeomTrimesh    (parent,m_pManager); break;
    case IRR_ODE_JOINT_FIXED_ID      : pRet=new CIrrOdeJointFixed     (parent,m_pManager); break;
    case IRR_ODE_JOINT_HINGE_ID      : pRet=new CIrrOdeJointHinge     (parent,m_pManager); break;
    case IRR_ODE_JOINT_HINGE2_ID     : pRet=new CIrrOdeJointHinge2    (parent,m_pManager); break;
    case IRR_ODE_JOINT_SLIDER_ID     : pRet=new CIrrOdeJointSlider    (parent,m_pManager); break;
    case IRR_ODE_SPACE_ID            : pRet=new CIrrOdeSpace          (parent,m_pManager); break;
    case IRR_ODE_WORLD_ID            : pRet=new CIrrOdeWorld          (parent,m_pManager); break;
    case IRR_ODE_MOTOR_ID            : pRet=new CIrrOdeMotor          (parent,m_pManager); break;
    case IRR_ODE_SERVO_ID            : pRet=new CIrrOdeServo          (parent,m_pManager); break;
    case IRR_ODE_IMPULSE_MOTOR_ID    : pRet=new CIrrOdeImpulseMotor   (parent,m_pManager); break;
    case IRR_ODE_TORQUE_MOTOR_ID     : pRet=new CIrrOdeTorqueMotor    (parent,m_pManager); break;
    case IRR_ODE_AERO_DRAG_ID        : pRet=new CIrrOdeAeroDrag       (parent,m_pManager); break;

    default: break;
  }

  #ifdef _TRACE_FACTORY
    irr::core::stringc sName(pRet->getTypeName());
    printf("CIrrOdeSceneNodeFactory::addSceneNode(%i): \"%s\"\n",(int)type,sName.c_str());
  #endif

  return pRet;
}
Пример #5
0
void CSystemDeviceEnumerator::EnumerateDMOs(const IID clsidDMOCategory)
{
	IEnumDMO* pEnum = NULL; 
	HRESULT hr = DMOEnum(
		clsidDMOCategory,			// Category
		DMO_ENUMF_INCLUDE_KEYED,	// Included keyed DMOs
		0, NULL,					// Input types (don't care)
		0, NULL,					// Output types (don't care)
		&pEnum);

	if (SUCCEEDED(hr)) 
	{
		CLSID clsidDMO;
		WCHAR* wszName;
		do
		{
			hr = pEnum->Next(1, &clsidDMO, &wszName, NULL);
			if (hr == S_OK) 
			{  
				// Now wszName holds the friendly name of the DMO, 
				// and clsidDMO holds the CLSID. 
				CString sName(wszName);
				m_listDMOs.push_back(sName);
				CoTaskMemFree(wszName);
			}
		} while (hr == S_OK);
		pEnum->Release();
	}
}
Пример #6
0
void CMLogin::Login(const char* sEid, const char* sUserName, const char* sPassWord,const char* sUserId, BOOL bAutoLogin)
{
	if(m_bLogin) return;
		m_bLogin = TRUE;

	CMGlobal::TheOne().SetOffline(FALSE);

	SETTING.SetCustomer(sEid);
	SETTING.SetUserName(sUserName);
	SETTING.SetUserPass(sPassWord);
    SETTING.SetUserId(sUserId);
	SETTING.SetAutoLogin(bAutoLogin);
	SETTING.Save();
	CMString sEID(sEid), sName(sUserName), sPass(sPassWord), sUid(sUserId);
	
	const char* sNewName = (const char *)sName;
		
	if(sNewName == SETTING.GetUserName())
		CMGlobal::TheOne().SetUserStatus(FALSE);
	else
		CMGlobal::TheOne().SetUserStatus(TRUE);	

	if(m_pSession == NULL)
		m_pSession = new CMSession(this);
	if(m_pSession)
		m_pSession->LogIn(sEID, sName, sPass, sUid,FALSE, 1);
}
Пример #7
0
    bool OnWebRequest(CWebSock& WebSock, const CString& sPageName,
                      CTemplate& Tmpl) override {
        if (sPageName != "index") {
            // only accept requests to index
            return false;
        }

        if (WebSock.IsPost()) {
            SetNV("username", WebSock.GetParam("username"));
            CString sPassword = WebSock.GetParam("password");
            if (!sPassword.empty()) {
                SetNV("password", sPassword);
            }
            SetNV(NV_REQUIRE_AUTH, WebSock.GetParam("require_auth"));
            SetNV(NV_MECHANISMS, WebSock.GetParam("mechanisms"));
        }

        Tmpl["Username"] = GetNV("username");
        Tmpl["Password"] = GetNV("password");
        Tmpl["RequireAuth"] = GetNV(NV_REQUIRE_AUTH);
        Tmpl["Mechanisms"] = GetMechanismsString();

        for (const auto& it : SupportedMechanisms) {
            CTemplate& Row = Tmpl.AddRow("MechanismLoop");
            CString sName(it.szName);
            Row["Name"] = sName;
            Row["Description"] = CString(it.szDescription);
        }

        return true;
    }
Пример #8
0
TYPE_File* ToppyFramework::Hdd_Fopen(char *name )
{
	CString sName(name);
	if ((sName.Find("/")!=-1) || (sName.Find("\\")!=-1))
	{
		LogError("Tried to open a file with a path in the name - %s", name);
        return 0;
	}

	FILE* handle = fopen(MakePath(name), "rb+"); // open for update
	if (handle == NULL)
	{
		LogError("Failed to open file %s", (LPCSTR) MakePath(name));
		return 0;
	}

	TYPE_File* pToppyHandle = new TYPE_File();
	ZeroMemory(pToppyHandle, sizeof(TYPE_File));
	strncpy(pToppyHandle->name, name, 100);

	m_mapOpenFiles[pToppyHandle] = handle;
	pToppyHandle->size = Hdd_Flen(pToppyHandle);

	LogInfo("Opened %s - handle 0x%x, TYPE_File 0x%x", (LPCSTR) MakePath(name), handle, pToppyHandle);

	pToppyHandle->startCluster = GetStartClusterHash(name);
	pToppyHandle->totalCluster = 0;
	// TODO: more initialization?
	return pToppyHandle;
}
Пример #9
0
void TestDocFileFontInfo::TestConvertUnicodeFontName()
{
	RTFFileContext context;
	DocFileFontinfo dffi(&context);
	dffi.m_iCharSet = 0;	// 
	CWideString sName("Fishies");
	assertTest(sName == dffi.ConvertUnicodeFontName(sName));

	// HG 20024 65402 65438 65404 65391 65400 M-PRO
	// HG\'8a\'db\'ba\'de\'bc\'af\'b8M-PRO
	sName = "HG??????m-pro";
	sName[2] = 20024;
	sName[3] = 65402;
	sName[4] = 65438;
	sName[5] = 65404;
	sName[6] = 65391;
	sName[7] = 65400;
	CWideString sNameOut = "HG???????m-pro";
	sNameOut[2] = 0x8a;
	sNameOut[3] = 0xdb;
	sNameOut[4] = 0xba;
	sNameOut[5] = 0xde;
	sNameOut[6] = 0xbc;
	sNameOut[7] = 0xaf;
	sNameOut[8] = 0xb8;

	dffi.m_iCharSet = 128;
	assertTest(dffi.ConvertUnicodeFontName(sName) == sNameOut);
}
Пример #10
0
ret_ CXMLLoaderActions::LoadEnable(CProgram &Program,
								   const DOMElement *pElement)
{
#ifdef _DEBUG_
	if (!pElement)
		return (PARAMETER_NULL | PARAMETER_2);
#endif
	auto_xerces_str wsName("name");
	auto_xerces_str sName(pElement->getAttribute(wsName));
	
	// Check if there is the container
	if (!m_pTmpContainer)
		return XML_LOADER_ERROR;

	// Check if there is the button identified by the attribute
	CWindow *pWindow = m_pTmpContainer->GetChild(sName);

	if (!pWindow || WINDOW_BUTTON != pWindow->Type())
		return XML_LOADER_ERROR;

	auto_xerces_str wsEnable("enable");
	auto_xerces_str sEnable(pElement->getAttribute(wsEnable));
	bool_ bEnble = (0 == strcmp(sEnable, "true")) ? true_v : false_v;
	
	COptEnable *pOpt = new COptEnable(sName, bEnble);

	if (false_v == Program.AddOperator(pOpt))
		return XML_LOADER_ERROR;

	return SUCCESS;
}
Пример #11
0
void CItems::Rename(LPCTSTR szFolderName, int nId)
{
	CStringBuf sName(szFolderName);
	IStatementPtr st = CApplicationImpl::Get().GetStatement();
	st->sql(_T("update adx_items set name = :name where id = :id"));
	st->use(sName, _T(":name"));
	st->use((int&)nId, _T(":id"));
	st->exec();
}
Пример #12
0
CVolume *CVolumes::Create(
  const wxString &sCopyFrom, const wxString &_sName)
{
  wxString sPath;
  wxString sName(_sName);
  MapVolume::iterator itrm;
  CVolume *pRtn(NULL);
  CVolume *pCopyFrom;

  nwxString::Trim(&sName);
  if(sName.IsEmpty())
  {
    m_sLastError = VOLUME_STRING " name has not been specified.";
  }
  else if(Find(sName) != NULL)
  {
    _SetErrorNameExists(sName);
  }
  else if( (pCopyFrom = Find(sCopyFrom)) == NULL )
  {
    m_sLastError = "Cannot create new " Volume_string " from ";
    m_sLastError.Append(sCopyFrom);
    m_sLastError.Append(".\nThe " Volume_string " was not found.");
    wxASSERT_MSG(0,m_sLastError);
  }
  else if( pCopyFrom->IsLocked() && !pCopyFrom->HasLock() )
  {
    m_sLastError = "Cannot create new " Volume_string " from ";
    m_sLastError.Append(sCopyFrom);
    m_sLastError.Append("\nbecause it is locked by ");
    m_sLastError.Append(pCopyFrom->GetLockUser());
    wxASSERT_MSG(0,m_sLastError);
  }
  else if(_BuildNewPath(pCopyFrom,&sPath))
  {
    auto_ptr<CVolume> apRtn(new CVolume(sPath));

    if(!(apRtn->IsOK() && apRtn->InitNewVolume(sName)))
    {
        m_sLastError = 
          "Could not create new " Volume_string ".\n"
          "Please check space on disk drive";
    }
    else if((itrm = m_mapVol.insert(MapVolume::value_type(sName,apRtn.get()))) == m_mapVol.end())
    {
      m_sLastError =
        "Could not add new " Volume_string " to the set.\n"
        "System may not have sufficient memory.";
    }
    else
    {
      _SetModified();
      pRtn = apRtn.release();
    }
  }
  return pRtn;
}
Пример #13
0
void icqAccount::setStatusFromPlugin(accountStatus status, const QString &status_text)
{

	
	if ( status > -1)
	{
	
		if ((status != online) && (status != offline) && (status != ffc)
		&& (status != invisible))
	{
		QString sName(StatusNames[static_cast<int>(status)]);
                QSettings settings(QSettings::NativeFormat, QSettings::UserScope, "qutim/qutim."+m_profile_name, "icqsettings");
                QSettings account_settings(QSettings::NativeFormat, QSettings::UserScope, "qutim/qutim."+m_profile_name+"/ICQ."+icqUin , "accountsettings");
			if ( m_restore_status == restoreAccount )
				m_restore_status_text = account_settings.value("autoreply/" + sName
					+ "msg", "").toString();	
		account_settings.setValue("autoreply/" + sName
					+ "msg", status_text.left(1000));	
		thisIcqProtocol->setStatus(status);


	}
	// Disconnecting
	else
	{
		if (status == offline)
			thisIcqProtocol->userDisconnected = true;

		// Apply new status
		thisIcqProtocol->setStatus(status);
	}
			if ( m_restore_status == restoreAccount )
		m_restore_status = thisIcqProtocol->getStatus();
	} else
	{
		QString sName(StatusNames[static_cast<int>(m_restore_status)]);
                QSettings settings(QSettings::NativeFormat, QSettings::UserScope, "qutim/qutim."+m_profile_name, "icqsettings");
                QSettings account_settings(QSettings::NativeFormat, QSettings::UserScope, "qutim/qutim."+m_profile_name+"/ICQ."+icqUin , "accountsettings");
		m_restore_status_text = account_settings.value("autoreply/" + sName
				+ "msg", "").toString();	
		account_settings.setValue("autoreply/" + sName
					+ "msg", status_text.left(1000));	
	}
}
Пример #14
0
std::string Quotes_MakeIconName(const char* name)
{
	assert(name);
	//char szSettingName[100];
	//mir_snprintf(szSettingName,SIZEOF(szSettingName),"%s_%s",QUOTES_PROTOCOL_NAME,name);
	std::string sName(QUOTES_PROTOCOL_NAME);
	sName += "_";
	sName += name;
	return sName;
}
Пример #15
0
void C4ScenarioParameters::CompileFunc(StdCompiler *pComp)
{
	// Unfortunately, StdCompiler cannot save std::map yet
	if (pComp->isDeserializer())
	{
		Parameters.clear();
		if (pComp->hasNaming())
		{
			// load from INI
			size_t name_count = pComp->NameCount();
			for (size_t i=0; i<name_count; ++i)
			{
				int32_t v=0;
				const char *name = pComp->GetNameByIndex(0); // always get name index 0, because names are removed after values have been extracted for them
				StdCopyStrBuf sName(name);
				if (!name) continue;
				pComp->Value(mkNamingAdapt(v, sName.getData(), 0));
				Parameters[sName] = v;
			}
		}
		else
		{
			// load from binary
			int32_t name_count=0;
			pComp->Value(name_count);
			for (int32_t i=0; i<name_count; ++i)
			{
				StdCopyStrBuf name; int32_t v;
				pComp->Value(name);
				pComp->Value(v);
				Parameters[name] = v;
			}
		}
	}
	else
	{
		if (pComp->hasNaming())
		{
			// save to INI
			for (auto & Parameter : Parameters)
				pComp->Value(mkNamingAdapt(Parameter.second, Parameter.first.getData()));
		}
		else
		{
			// save to binary
			int32_t name_count=Parameters.size();
			pComp->Value(name_count);
			for (auto & Parameter : Parameters)
			{
				pComp->Value(const_cast<StdCopyStrBuf &>(Parameter.first));
				pComp->Value(Parameter.second);
			}
		}
	}
}
Пример #16
0
static int GetFileIcon( CHotlineFileBase* pFile )
	{
	if ( !pFile->IsFolder( ) )
		return ICON_FILE;

	CString sName( pFile->GetItemName( ) );
	sName.MakeLower( );
	if ( ( -1 == sName.Find( "upload" ) ) && ( -1 == sName.Find( "drop box" ) ) )
		return ICON_FOLDER;
	return ICON_UPLOAD;
	}
Пример #17
0
//--------------------------------------------------------------------------------
CString COutputConfig::GenerateLogfileName() const
	{
	CString sName(CTime::GetCurrentTime().Format("HL7%Y%b%d.txt"));
	CString sPath(m_pLogFile);
	int i = sPath.ReverseFind('\\');
	if(i == -1)
		return sName;
	sPath.GetBufferSetLength(i + 1);
	sPath.ReleaseBuffer();
	return sPath + sName;
	}
Пример #18
0
HWND TAManager::createWindow(char *pName, DEMO_WINDOW_TYPE eWindowType)
{
	HWND windowHandle = NULL;

	CString sName(pName);  
	LPCTSTR lpszName = sName; 
	int nScreenX = GetSystemMetrics(SM_CXSCREEN);
	int nScreenY = GetSystemMetrics(SM_CYSCREEN);
	int nStartY = 0;
	unsigned int x = 0;
	unsigned int y = 0;

	int nWidth = 640, nHeight = 360, nGap = 0;


	if(nScreenY > (nHeight + 20)*2)
	{
		nGap = (nScreenY - (nHeight + 20)*2)/3;
	}

	nStartY = nGap;


	if (DEMO_WINDOW_SENDER == eWindowType)
	{
		x = 200;
		y = nStartY;
	}
	else if (DEMO_WINDOW_RECEIVER == eWindowType)
	{
		x = 200;
		y = nStartY + nHeight + 20 + nGap ;
	}
	else if(DEMO_WINDOW_PREVIEW == eWindowType)
	{
		x = 600;
		y = nStartY;	
	}

	// TODO: Add your control notification handler code here
	windowHandle = ::CreateWindow(gClassNameInterWindow,
		lpszName,
		WS_VISIBLE|WS_SYSMENU|WS_THICKFRAME ,
		x,
		y,
		nWidth,
		nHeight+20,
		NULL,
		NULL,
		AfxGetInstanceHandle(),
		0);

	return windowHandle;
}
Пример #19
0
ret_ CXMLLoaderActions::LoadAddItem(CProgram &Program,
									const DOMElement *pElement,
									const CPDUInfo *pPDU)
{
#ifdef _DEBUG_
	if (!pElement)
		return (PARAMETER_NULL | PARAMETER_2);
#endif

	auto_xerces_str wsName("name");
	auto_xerces_str sName(pElement->getAttribute(wsName));
	
	// Check if there is the container
	if (!m_pTmpContainer)
		return XML_LOADER_ERROR;

	// Check if there is the table identified by the attribute
	CWindow *pWindow = m_pTmpContainer->GetChild(sName);

	if (!pWindow || WINDOW_TABLE != pWindow->Type())
		return XML_LOADER_ERROR;

	COptAddItem *pOpt = new COptAddItem(sName);

	DOMElement *pSub = (DOMElement *)pElement->getFirstChild();

	if (!pSub)
		return XML_LOADER_ERROR;

	while (pSub)
	{
		CVariable *pV = null_v;
		ret_ Ret = LoadVariable(Program.Data(),
								pSub,
								pV,
								pPDU);

		if (SUCCESS != Ret && XML_INVALID_ELEMENT != Ret)
			return Ret;

		if (SUCCESS == Ret)
			pOpt->AddVariable(pV);
		
		pSub = (DOMElement *)pSub->getNextSibling();
	}

	if (false_v == Program.AddOperator(pOpt))
		return XML_LOADER_ERROR;

	return SUCCESS;
}
Пример #20
0
 void endElement(void *ctx, const char *name)
 {
     CC_UNUSED_PARAM(ctx);
     CCSAXState curState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top();
     std::string sName((char*)name);
     if( sName == "dict" )
     {
         m_tStateStack.pop();
         m_tDictStack.pop();
         if ( !m_tDictStack.empty())
         {
             m_pCurDict = m_tDictStack.top();
         }
     }
     else if (sName == "array")
     {
         m_tStateStack.pop();
         m_tArrayStack.pop();
         if (! m_tArrayStack.empty())
         {
             m_pArray = m_tArrayStack.top();
         }
     }
     else if (sName == "true")
     {
         CCString *str = new CCString("1");
         if (SAX_ARRAY == curState)
         {
             m_pArray->addObject(str);
         }
         else if (SAX_DICT == curState)
         {
             m_pCurDict->setObject(str, m_sCurKey);
         }
         str->release();
     }
     else if (sName == "false")
     {
         CCString *str = new CCString("0");
         if (SAX_ARRAY == curState)
         {
             m_pArray->addObject(str);
         }
         else if (SAX_DICT == curState)
         {
             m_pCurDict->setObject(str, m_sCurKey);
         }
         str->release();
     }
     m_tState = SAX_NONE;
 }
Пример #21
0
void endElement(void *ctx, const XML_Char *name)
{
	CCDictMaker * pMaker = this;
	std::string sName((char*)name);
	if( sName == "dict" )
	{
		pMaker->m_tDictStack.pop();
		if ( !pMaker->m_tDictStack.empty() )
		{
			pMaker->m_pCurDict = (CCDictionary<std::string, CCObject*>*)(pMaker->m_tDictStack.top());
		}
	}
	pMaker->m_tState = SAX_NONE;
}
void CFlashMenuObject::AddProfile(const char *profileName)
{
	if(m_pPlayerProfileManager)
	{
		CryFixedStringT<128> sName(profileName);
		sName = sName.Trim();

		// check for invalid chars
		static const char* invalidChars = "\\/:*?\"<>~|";
		if (sName.find_first_of(invalidChars) != CryFixedStringT<128>::npos)
		{
			if(m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART])
			{
				ShowMenuMessage("@ui_menu_PROFILEERROR");
			}			
			return;
		}

		const char *userName = m_pPlayerProfileManager->GetCurrentUser();
	
		IPlayerProfileManager::EProfileOperationResult result;
		bool bDone = m_pPlayerProfileManager->CreateProfile(userName,sName.c_str(), false, result);
		if(bDone)
		{
			SelectProfile(sName.c_str(), false, true);
			RestoreDefaults();

			IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
			if(!pProfile)
				return;

			//reset to default (it's a copy of the current one)
			g_pGame->GetOptions()->SaveValueToProfile("Singleplayer.LastSavedGame", "");

			UpdateProfiles();
			if(m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART])
			{
				m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART]->Invoke("Root.MainMenu.Profile.gotoProfileMenu");
				ShowMenuMessage("@ui_menu_PROFILECREATED");
			}			
		}
		else
		{
			if(m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART])
			{
				ShowMenuMessage("@ui_menu_PROFILEERROR");
			}			
		}
	}
}
Пример #23
0
void plist_endElement(void *ctx, const xmlChar *name)
{
	CCDictMaker * pMaker = (CCDictMaker*)(ctx);
	std::string sName((char*)name);
	if( sName == "dict" )
	{
		pMaker->m_tDictStack.pop();
		if ( !pMaker->m_tDictStack.empty() )
		{
			pMaker->m_pCurDict = (NSDictionary<std::string, NSObject*>*)(pMaker->m_tDictStack.top());
		}
	}
	pMaker->m_tState = SAX_NONE;
}
Пример #24
0
void CContextOSX::GetPathName(tchar* pszPathName)
{
	IFile::GetSystemDirectory(IFile::SystemDirApplications, pszPathName);

	std::string sPathName((const char*)pszPathName);

	tchar pszName[64];
	mpCallback->GetName(pszName);
	std::string sName((const char*)pszName);
	
	sPathName += sName;
	sPathName += ".kspi";

    strcpy((char*)pszPathName, sPathName.c_str());
}
Пример #25
0
void Serializer::Serialize( const QVariant &vValue, const QString &_sName )
{
    QString sName( _sName );

    if ((sName.length() > 0) && sName.at(0) == 'Q')
        sName = sName.mid( 1 );

    m_hash.reset();

    BeginSerialize( sName );

    AddProperty( sName, vValue, NULL, NULL );

    EndSerialize();
}
void startElement(void *ctx, const XML_Char *name, const XML_Char **atts)
{
	std::string sName((char*)name);
	if( sName == "dict" )
	{
		CCDictionary<std::string, CCObject*> *pNewDict = new CCDictionary<std::string, CCObject*>();
		if(! m_pRootDict)
		{
			m_pRootDict = pNewDict;
			pNewDict->autorelease();
		}
		else
		{
			CCAssert(m_pCurDict && !m_sCurKey.empty(), "");
			m_pCurDict->setObject(pNewDict, m_sCurKey);
			pNewDict->release();
			m_sCurKey.clear();
		}
		m_pCurDict = pNewDict;
		m_tDictStack.push(m_pCurDict);
		m_tState = SAX_DICT;
	}
	else if(sName == "key")
	{
		m_tState = SAX_KEY;
	}
	else if(sName == "integer")
	{
		m_tState = SAX_INT;
	}
	else if(sName == "real")
	{
		m_tState = SAX_REAL;
	}
	else if(sName == "string")
	{
		m_tState = SAX_STRING;
	}
	else
	{
        if (sName == "array")
        {
            m_bInArray = true;
            m_pArray = new CCMutableArray<CCObject*>();
        }
		m_tState = SAX_NONE;
	}	
}
Пример #27
0
void ezMaterialResource::SetParameter(const char* szName, const ezVariant& value)
{
  ezTempHashedString sName(szName);

  ezUInt32 uiIndex = ezInvalidIndex;
  for (ezUInt32 i = 0; i < m_Desc.m_Parameters.GetCount(); ++i)
  {
    if (m_Desc.m_Parameters[i].m_Name == sName)
    {
      uiIndex = i;
      break;
    }
  }

  if (value.IsValid())
  {
    if (uiIndex != ezInvalidIndex)
    {
      if (m_Desc.m_Parameters[uiIndex].m_Value == value)
      {
        return;
      }

      m_Desc.m_Parameters[uiIndex].m_Value = value;
    }
    else
    {
      auto& param = m_Desc.m_Parameters.ExpandAndGetRef();
      param.m_Name.Assign(szName);
      param.m_Value = value;
    }
  }
  else
  {
    if (uiIndex == ezInvalidIndex)
    {
      return;
    }

    m_Desc.m_Parameters.RemoveAtAndSwap(uiIndex);
  }

  m_iLastModified.Increment();
  m_iLastConstantsModified.Increment();

  m_ModifiedEvent.Broadcast(this);
}
Пример #28
0
bool CProbDistManager::loadDatabase(CAirportDatabase* pAirportDatabase)
{
	clear();

	CString strSQL(_T(""));
	strSQL.Format(_T("SELECT * FROM TB_AIRPORTDB_PRODISTMANAGER"));
	CADORecordset adoRecordset ;
	long count = 0;
	try
	{
		CDatabaseADOConnetion::ExecuteSQLStatement(strSQL,count,adoRecordset,pAirportDatabase->GetAirportConnection()) ; 
	}
	catch (CADOException& e)
	{
		e.ErrorMessage() ;
		return false;
	}
	CString sName(_T(""));
	CString sProbtype(_T(""));
	CString sProbdate(_T(""));
	int nID = -1 ;
	while (!adoRecordset.IsEOF())
	{
		adoRecordset.GetFieldValue(_T("PRODIST_NAME"),sName) ;
		adoRecordset.GetFieldValue(_T("PROBDISTDATA"),sProbdate) ;
		adoRecordset.GetFieldValue(_T("ID"),nID) ;
		ProbabilityDistribution* pProb = NULL ;
		try
		{
			pProb = ProbabilityDistribution::GetTerminalRelateProbDistributionFromDB (sProbdate);
		}
		catch (TwoStringError& e)
		{
			char string[256];
			e.getMessage (string);
			MessageBox(NULL,"Unknown Probability Distribution ","Error",MB_OK) ;
			adoRecordset.MoveNextData();
			continue ;
		}
		CProbDistEntry* pProbDist = new CProbDistEntry( sName, pProb );
		pProbDist->SetID(nID) ;
		m_vProbDist.push_back(pProbDist);

		adoRecordset.MoveNextData() ;
	}
	return true;
}
void endElement(void *ctx, const XML_Char *name)
{
	std::string sName((char*)name);
	if( sName == "dict" )
	{
		m_tDictStack.pop();
		if ( !m_tDictStack.empty() )
		{
			m_pCurDict = (CCDictionary<std::string, CCObject*>*)(m_tDictStack.top());
		}
	}
    else if (sName == "array")
    {
        CCAssert(m_bInArray, "The plist file is wrong!");
        m_pCurDict->setObject(m_pArray, m_sCurKey);
        m_pArray->release();
        m_pArray = NULL;
        m_bInArray = false;
    }
    else if (sName == "true")
    {
        CCString *str = new CCString("1");
        if (m_bInArray)
        {
            m_pArray->addObject(str);
        }
        else
        {
            m_pCurDict->setObject(str, m_sCurKey);
        }
        str->release();
    }
    else if (sName == "false")
    {
        CCString *str = new CCString("0");
        if (m_bInArray)
        {
            m_pArray->addObject(str);
        }
        else
        {
            m_pCurDict->setObject(str, m_sCurKey);
        }
        str->release();
    }
	m_tState = SAX_NONE;
}
Пример #30
0
static CMPIStatus argsAddArg(CMPIArgs* eArg, const char* name,
				 const CMPIValue* data, const CMPIType type)
{
	OpenWBEM::CIMParamValueArray* arg = (OpenWBEM::CIMParamValueArray *)eArg->hdl;
	CMPIrc rc;
	OpenWBEM::CIMValue v = value2CIMValue(data, type, &rc);
	OpenWBEM::String sName(name);

	long i = locateArg(*arg, sName);
	if (i >= 0)
	{
		arg->remove(i);
	}

	arg->append(OpenWBEM::CIMParamValue(sName, v));
	CMReturn(CMPI_RC_OK);
}