Example #1
0
// This function restores the state (visible buttons, toolbar position, etc.)
// of the toolbar, using the registry key provided to the Create(...) function.
void CDkToolBar::RestoreState()
{
	// if there is an associated registry subkey
	//if (registrySubKey.GetLength())
	//{
	//	// restore the toolbar state from the registry
	//	GetToolBarCtrl().RestoreState(registryKey, registrySubKey, registryValue);
	//}
	CString strINI = AfxGetApp()->m_pszProfileName;
	InitProfile();
	// 1つも登録されていない場合はデフォルト表示
	if (MyGetProfileInt(L"STEP\\DefaultToolbarPosition", L"Pos00", -1) == -1) return;
	// プラグインボタンを削除
	int i;
	for (i=0;i<pluginToolBarInfo.GetSize();i++) {
		CPluginToolBarInfo* button = (CPluginToolBarInfo*)pluginToolBarInfo.GetAt(i);
		int nPos = GetToolBarCtrl().CommandToIndex(button->tbButton.idCommand);
		GetToolBarCtrl().DeleteButton(nPos);
	}
	// 標準ボタンのクリア
	for (i=GetToolBarCtrl().GetButtonCount();i>0;i--) {
		GetToolBarCtrl().DeleteButton(i-1);
	}

	// 標準ボタンのリストア
	for (i=0;;i++) {
		CString strRegName;
		strRegName.Format(L"Pos%02d", i);
		int nID = MyGetProfileInt(L"STEP\\DefaultToolbarPosition", strRegName, -1);
		if(nID == ID_TEIKEI) nID = ID_TEIKEI_TOOL;
		if (nID == -1)	break;
		if (nID == 0) {
			TBBUTTON sep;
			ZeroMemory(&sep, sizeof(TBBUTTON));
			sep.fsStyle = TBSTYLE_SEP;
			GetToolBarCtrl().InsertButton(i, &sep);
			continue;
		}
		for (int j=0;j<NButtons();j++) {
			if (toolBarInfo[j].tbButton.idCommand == nID) {
				GetToolBarCtrl().InsertButton(i, &toolBarInfo[j].tbButton);
				break;
			}
		}
	}

	// プラグインボタンのリストア
	for (i=0;i<pluginToolBarInfo.GetSize();i++) {
		CPluginToolBarInfo* button = (CPluginToolBarInfo*)pluginToolBarInfo.GetAt(i);
		button->nIndex = -1;
	}
	UpdatePluginButton();
	FreeProfile();
}
Example #2
0
void Register::SetProfile(int32_t uid)
{
	//初始化账号信息
	PReginfo reginfo;
	InitReginfo(reginfo, uid);

	string reginfo_key = REGINFOPREFIX + _req.account();
	string reginfo_value = reginfo.SerializeAsString();


	//初始化profile
	InitProfile(uid);

	PPlayerId *player_id = _p_profile->mutable_player_id();
	//string profile_key = PROFILEPREFIX + I2S(player_id->uid()) + "_" + I2S(player_id->zone_id());
	string profile_key = CommFunc::getProfileKey(player_id->uid(), player_id->zone_id());
	string profile_value = _p_profile->SerializeAsString();


	auto got_reply = [&](Command<string>& c)
	{
		if(c.ok())
		{
			_pkg_head.ret = RET_OK;
			PProfile *rsp_profile = _rsp.mutable_profile();
			*rsp_profile = *_p_profile;

			//给客户端回包,流程结束
			Send2Client(_pkg_head, _rsp);
		}
		else
		{
			PPlayerId *player_id = _p_profile->mutable_player_id();
			PlayerID id;
			id.Init(*player_id);
			PlayerDataMgr::getInstance().Del(id);

			LOG_ERROR(_ctx, "SetProfile failed. cmd:%s status:%d", c.cmd().c_str(), c.status());

			//给客户端回包,流程结束
			_pkg_head.ret = RET_REDIS_ERR_SET;
			Send2Client(_pkg_head, _rsp);
		}

	};


	ServerEnv::getInstance().getRdx().command<string>({"MSET", reginfo_key, reginfo_value, profile_key, profile_value}, got_reply);

}
Example #3
0
static bool ProcessServiceModes(range<const wchar_t* const*> const Args, int& ServiceResult)
{
	const auto& isArg = [](const wchar_t* Arg, string_view const Name)
	{
		return (*Arg == L'/' || *Arg == L'-') && equal_icase(Arg + 1, Name);
	};

	if (Args.size() == 4 && IsElevationArgument(Args[0])) // /service:elevation {GUID} PID UsePrivileges
	{
		ServiceResult = ElevationMain(Args[1], std::wcstoul(Args[2], nullptr, 10), *Args[3] == L'1');
		return true;
	}

	if (InRange(2u, Args.size(), 5u) && (isArg(Args[0], L"export"sv) || isArg(Args[0], L"import"sv)))
	{
		const auto Export = isArg(Args[0], L"export"sv);
		string strProfilePath(Args.size() > 2 ? Args[2] : L""), strLocalProfilePath(Args.size() > 3 ? Args[3] : L""), strTemplatePath(Args.size() > 4 ? Args[4] : L"");
		InitTemplateProfile(strTemplatePath);
		InitProfile(strProfilePath, strLocalProfilePath);
		Global->m_ConfigProvider = new config_provider(Export? config_provider::mode::m_export : config_provider::mode::m_import);
		ServiceResult = !ConfigProvider().ServiceMode(Args[1]);
		return true;
	}

	if (InRange(1u, Args.size(), 3u) && isArg(Args[0], L"clearcache"sv))
	{
		string strProfilePath(Args.size() > 1 ? Args[1] : L"");
		string strLocalProfilePath(Args.size() > 2 ? Args[2] : L"");
		InitProfile(strProfilePath, strLocalProfilePath);
		config_provider::ClearPluginsCache();
		ServiceResult = 0;
		return true;
	}

	return false;
}
Example #4
0
//-----------------------------------------------------------------
//
// Function:   fnStopProfilingDLL
//
// Purpose:    Stops profiling functions. Clears all profiling
//             breakpoints that are not being used by the user.
//             The data in profiling data structure is dumped out.
//
// Input:      Profile  -   pointer to profiling data structure
//
// Output:     None
//
//------------------------------------------------------------------
void fnStopProfilingDLL (PSProfile *Profile)
{
    ULONG cEntries;


    // clear all breakpoints set for profiling
    for (cEntries = 0; cEntries < (*Profile)->cUsed; cEntries++)
    {
      if ((*Profile)->ProfileRecords[cEntries].cBrkptType == BRKPT_PROFILE)
          fnChangeBpState ((*Profile)->ProfileRecords[cEntries].cBrkptNo, 'c');
    }

   DumpProfile(*Profile);
   InitProfile(*Profile);

}
Example #5
0
//-----------------------------------------------------------------
//
// Function:   ProcDump
//
// Purpose:    Called by wt profiling to dump out the information in
//             profiling data structre.  The stack is cleared of
//             functions.
//
// Input:      Profile  -   pointer to profiler data structure
//
// Output:     None
//
//------------------------------------------------------------------
void ProcDump (PSProfile *Profile )
{
   // Clear the stack of any symbols
   for ( ; iStackDepth >= 0; iStackDepth -= 1)
   {
      UpdateProfile(Profile,
                    CallStack[iStackDepth].Symbol,
                    CallStack[iStackDepth].cInstructions);
      if (iStackDepth != 0)
      {
         CallStack[iStackDepth-1].cInstructions += CallStack[iStackDepth].cInstructions;
      }
   }
   DumpProfile (*Profile);
   InitProfile (*Profile);
}
Example #6
0
// This function saves the state (visible buttons, toolbar position, etc.)
// of the toolbar, using the registry key provided to the Create(...) function.
void CDkToolBar::SaveState()
{
	// if there is an associated registry subkey
	//if (registrySubKey.GetLength())
	//{
	//	// save the toolbar state to the registry
	//	GetToolBarCtrl().SaveState(registryKey, registrySubKey, registryValue);
	//}
	CString strINI = AfxGetApp()->m_pszProfileName;
	InitProfile();
	int i;

	for (i=0;i<pluginToolBarInfo.GetSize();i++) {
		CPluginToolBarInfo* button = (CPluginToolBarInfo*)pluginToolBarInfo.GetAt(i);
		int nPos = GetToolBarCtrl().CommandToIndex(button->tbButton.idCommand);
		MyWriteProfileInt(L"STEP\\ToolbarPosition", button->strRegName, nPos);
	}
	for (i=0;i<pluginToolBarInfo.GetSize();i++) {
		CPluginToolBarInfo* button = (CPluginToolBarInfo*)pluginToolBarInfo.GetAt(i);
		int nPos = GetToolBarCtrl().CommandToIndex(button->tbButton.idCommand);
		GetToolBarCtrl().DeleteButton(nPos);
	}

	// 標準ボタンの位置を保存
	for (i=0;i<GetToolBarCtrl().GetButtonCount();i++) {
		TBBUTTON tbButton;
		CString strRegName;
		strRegName.Format(L"Pos%02d", i);
		if (GetToolBarCtrl().GetButton(i, &tbButton)) {
			MyWriteProfileInt(L"STEP\\DefaultToolbarPosition", strRegName, tbButton.idCommand);
		}
	}
	{
		CString strRegName;
		strRegName.Format(L"Pos%02d", i);
		MyWriteProfileInt(L"STEP\\DefaultToolbarPosition", strRegName, -1);
	}
	SaveProfile();
	FreeProfile();
}
Example #7
0
//-----------------------------------------------------------------
//
// Function:   Profile
//
// Purpose:    Used by wt profiling to keep track of trace information.
//             A stack is used to keep track of the call tree. The
//             function invocation count is incremented only when
//             the function is removed from the stack.  A function
//             is removed from the stack when another function of
//             a lower level is reached.
//
// Input:      Profile  -  pointer to profiling data structure
//             Symbol   -  function name to store in profiler data structure.
//             cInstructions  -  instructions executed by the function
//             cLevel         -  level in the call tree
//
// Output:     None
//
//------------------------------------------------------------------
void
Profile(
    PSProfile *pProfile,
    unsigned char *Symbol,
    unsigned long cInstructions,
    unsigned long cLevel
    )
{
   long cNewLevel = -1;
   PSProfile Profile;

   if (!*pProfile) {
      InitProfile(*pProfile);
   }
   Profile = *pProfile;

   if (iStackDepth == -1)
   {
      iStackDepth = 0;
      cNewLevel = 0;
   }
   else
   {
      // See if this is a lower level function than the current function on
      // the stack.  If so, pop the stack until at the same level
      if (CallStack[iStackDepth].cLevel > cLevel)
      {
         for ( ; CallStack[iStackDepth].cLevel > cLevel; iStackDepth -= 1)
         {
            UpdateProfile(pProfile,
                          CallStack[iStackDepth].Symbol,
                          CallStack[iStackDepth].cInstructions);
            CallStack[iStackDepth-1].cInstructions += CallStack[iStackDepth].cInstructions;
         }
      }

      if (CallStack[iStackDepth].cLevel == cLevel)
      {
         if (!strcmp(CallStack[iStackDepth].Symbol, Symbol))
         {
            // Function hasn't finished executing
            CallStack[iStackDepth].cInstructions += cInstructions;
         }
         else
         {
            // Function finished executing. Save info in Profile
            UpdateProfile(pProfile,
                          CallStack[iStackDepth].Symbol,
                          CallStack[iStackDepth].cInstructions);

            CallStack[iStackDepth-1].cInstructions += CallStack[iStackDepth].cInstructions;
            cNewLevel = iStackDepth;
         }
      }
      else if (CallStack[iStackDepth].cLevel < cLevel)
      {
         // New symbol at higher level
         iStackDepth++;
         cNewLevel = iStackDepth;
      }
   }

   if (cNewLevel != -1)
   {
      // Initialize the new stack element
      strcpy(CallStack[cNewLevel].Symbol , Symbol);
      CallStack[cNewLevel].cInstructions = cInstructions;
      CallStack[cNewLevel].cLevel = cLevel;
   }
}
Example #8
0
//-----------------------------------------------------------------
//
// Function:   UpdateProfile
//
// Purpose:    Searches the profiler data structure for the name,
//             Symbol.  If one is found, the information in the
//             corresponding entry is updated.  Otherwise, a new
//             entry is allocated and the information saved.
//
//             For wt profiling, cValue contains the instruction
//             count for the function.  For function profiling,
//             cValue contains the breakpoint number of the function.
//
// Input:      Profile    -   pointer to profiling data structure
//             Symbol     -   function name
//             cValue     -   value to update
//
// Output:     None
//
//------------------------------------------------------------------
void
UpdateProfile(
    PSProfile *pProfile,
    unsigned char Symbol[],
    unsigned long cValue
    )
{
   unsigned long iBucket;
   SProfileRecord *pProfileRecord;
   unsigned long cHashNumber;
   PSProfile Profile;

   // Initialize the Profiler if not initialized already
   if (!*pProfile) {
      InitProfile(*pProfile);
   }
   Profile = *pProfile;

   // Search data structure
   pProfileRecord = SearchStructure (Profile, Symbol);

   // If the search was unsuccessful record the new call Site.
   if (pProfileRecord == NULL)
   {
      pProfileRecord = AllocProfilerEntry(Profile);

      // Hash on the first + last letters of the symbol
      cHashNumber = (unsigned long)Symbol[0] + (unsigned long)Symbol[strlen(Symbol)-1];
      iBucket = HASH(cHashNumber);

      if (pProfileRecord != NULL)
      {
         pProfileRecord->pNext = Profile->Buckets[iBucket];
         strcpy (pProfileRecord->Symbol, Symbol);

         if (PROFILING)
         {
             pProfileRecord->cInvocations = 0;
             pProfileRecord->cBrkptType = BRKPT_PROFILE;
             pProfileRecord->cBrkptNo = cValue;
         }
         else
         {
             pProfileRecord->cInvocations = 1;
             pProfileRecord->cMinInstructions = cValue;
             pProfileRecord->cMaxInstructions = cValue;
             pProfileRecord->cCumInstructions = cValue;
         }

         Profile->Buckets[iBucket] = pProfileRecord;
      }
   }
   else
   {
      // Augment the invocation count.

      pProfileRecord->cInvocations++;

      if (!PROFILING)
      {
          if (pProfileRecord->cMinInstructions > cValue)
             pProfileRecord->cMinInstructions = cValue;

          if (pProfileRecord->cMaxInstructions < cValue)
             pProfileRecord->cMaxInstructions = cValue;

          pProfileRecord->cCumInstructions += cValue;
      }
   }
}