void NFCProxyServerToWorldModule::OnSocketWSEvent(const int nSockIndex, const NF_NET_EVENT eEvent, NFINet* pNet)
{
    if (eEvent & NF_NET_EVENT_EOF)
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFGUID(0, nSockIndex), "NF_NET_EVENT_EOF", "Connection closed", __FUNCTION__, __LINE__);
    }
    else if (eEvent & NF_NET_EVENT_ERROR)
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFGUID(0, nSockIndex), "NF_NET_EVENT_ERROR", "Got an error on the connection", __FUNCTION__, __LINE__);
    }
    else if (eEvent & NF_NET_EVENT_TIMEOUT)
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFGUID(0, nSockIndex), "NF_NET_EVENT_TIMEOUT", "read timeout", __FUNCTION__, __LINE__);
    }
    else  if (eEvent == NF_NET_EVENT_CONNECTED)
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFGUID(0, nSockIndex), "NF_NET_EVENT_CONNECTED", "connectioned success", __FUNCTION__, __LINE__);
        Register(pNet);
    }
}
MI_Result RegistrationManager_HandleRequest(
    _In_ RegistrationManager* self,
    _In_ RegistrationRequest *request,
    _Outptr_result_maybenull_ MI_Instance **cimErrorDetails)
{
    MI_Result result = MI_RESULT_OK;

    if (cimErrorDetails)
    {
        *cimErrorDetails = NULL;
    }
    
    if (ShouldDoRegistration(self, request, cimErrorDetails))
    {
        return Register(self, request, cimErrorDetails);
    }

    *cimErrorDetails = NULL;       
    return result;
}
bool CActiveBanknode::RegisterByPubKey(std::string strService, std::string strKeyBanknode, std::string collateralAddress, std::string& errorMessage) {
	CTxIn vin;
    CPubKey pubKeyCollateralAddress;
    CKey keyCollateralAddress;
    CPubKey pubKeyBanknode;
    CKey keyBanknode;

    if(!darkSendSigner.SetKey(strKeyBanknode, errorMessage, keyBanknode, pubKeyBanknode))
    {
    	LogPrintf("CActiveBanknode::RegisterByPubKey() - Error upon calling SetKey: %s\n", errorMessage.c_str());
    	return false;
    }

    if(!GetBankNodeVinForPubKey(collateralAddress, vin, pubKeyCollateralAddress, keyCollateralAddress)) {
		errorMessage = "could not allocate vin for collateralAddress";
    	LogPrintf("Register::Register() - Error: %s\n", errorMessage.c_str());
		return false;
	}
	return Register(vin, CService(strService), keyCollateralAddress, pubKeyCollateralAddress, keyBanknode, pubKeyBanknode, errorMessage);
}
Example #4
0
void CUIMpTradeWnd::FillUpSubLevelButtons()
{
	u32 root_cnt						= m_store_hierarchy->CurrentLevel().ChildCount();

	Fvector2							pos;
	pos.set								(40.0f,90.0f);

	for(u32 i=0; i<root_cnt; ++i)
	{
		const CStoreHierarchy::item& it	= m_store_hierarchy->CurrentLevel().ChildAt(i);
		CUITabButtonMP* btn				= it.m_button;
		btn->m_temp_index				= i;
		Register						(btn);
		btn->SetWndPos					(pos);
		pos.add							(btn->GetWndSize().y);
		pos.y							+= 40.0f;
		pos.x							= 40.0f;
		m_shop_wnd->AttachChild			(btn);
	}
}
bool CActiveMasternode::Register(std::string strService, std::string strKeyMasternode, std::string txHash, std::string strOutputIndex, std::string& errorMessage) {
	CTxIn vin;
    CPubKey pubKeyCollateralAddress;
    CKey keyCollateralAddress;
    CPubKey pubKeyMasternode;
    CKey keyMasternode;

    if(!darkSendSigner.SetKey(strKeyMasternode, errorMessage, keyMasternode, pubKeyMasternode))
    {
    	LogPrintf("CActiveMasternode::Register() - Error upon calling SetKey: %s\n", errorMessage.c_str());
    	return false;
    }

    if(!GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress, txHash, strOutputIndex)) {
		errorMessage = "could not allocate vin";
    	LogPrintf("Register::Register() - Error: %s\n", errorMessage.c_str());
		return false;
	}
	return Register(vin, CService(strService), keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage);
}
Example #6
0
C4ValueMapNames *C4ValueMapData::CreateTempNameList()
{
	// create new list
	C4ValueMapNames *pTempNames = new C4ValueMapNames();

	// register (this func will unreg if necessary, too)
	Register(pTempNames);

	// error?
	if(pNames != pTempNames)
	{
		delete pTempNames;
		return 0;
	}

	// set flag
	bTempNameList = true;

	return pTempNames;
}
Example #7
0
bool CFileAssoc::Register(const CMediaFormatCategory& mfc, bool bRegister, bool bRegisterContextMenuEntries, bool bAssociatedWithIcon)
{
    if (!mfc.IsAssociable()) {
        ASSERT(FALSE);
        return false;
    }

    CAtlList<CString> exts;
    ExplodeMin(mfc.GetExtsWithPeriod(), exts, ' ');

    CString strLabel = mfc.GetDescription();
    bool res = true;

    POSITION pos = exts.GetHeadPosition();
    while (pos) {
        res &= Register(exts.GetNext(pos), strLabel, bRegister, bRegisterContextMenuEntries, bAssociatedWithIcon);
    }

    return res;
}
QTSS_Error  QTSSAdminModuleDispatch(QTSS_Role inRole, QTSS_RoleParamPtr inParams)
{
    switch (inRole)
    {
        case QTSS_Register_Role:
            return Register(&inParams->regParams);
        case QTSS_Initialize_Role:
            return Initialize(&inParams->initParams);
        case QTSS_RTSPFilter_Role:
        {   if (!sEnableRemoteAdmin) 
                break;
            return FilterRequest(&inParams->rtspFilterParams);
        }
        case QTSS_RTSPAuthorize_Role:
                return AuthorizeAdminRequest(inParams->rtspRequestParams.inRTSPRequest);
        case QTSS_RereadPrefs_Role:
            return RereadPrefs();
    }
    return QTSS_NoErr;
}
QTSS_Error  EasyHLSModuleDispatch(QTSS_Role inRole, QTSS_RoleParamPtr inParams)
{
    switch (inRole)
    {
        case QTSS_Register_Role:
            return Register(&inParams->regParams);
        case QTSS_Initialize_Role:
            return Initialize(&inParams->initParams);
        case QTSS_RereadPrefs_Role:
            return RereadPrefs();
		case Easy_RecordOpen_Role:		//Start HLS Streaming
			return EasyHLSOpen(&inParams->easyRecordOpenParams);
		case Easy_RecordClose_Role:	//Stop HLS Streaming
			return EasyHLSClose(&inParams->easyRecordCloseParams);
		case Easy_RecordList_Role:	//list record files
			return EasyRecordList(&inParams->easyRecordListParams);

    }
    return QTSS_NoErr;
}
Example #10
0
ISharedParamsConstPtr CSharedParamsManager::Register(const char* pName, const ISharedParams &sharedParams)
{
	// Check lock.

	if (VerifyUnlocked())
	{
		// Generate 32 bit crc.

		uint32 crc32 = GenerateCRC32(pName);

		if (crc32)
		{
			// Register shared parameters.

			return Register(crc32, sharedParams);
		}
	}

	return ISharedParamsConstPtr();
}
Example #11
0
/**
 * Construct a shader from shader compiler output.
 */
FShader::FShader(const CompiledShaderInitializerType& Initializer):
	MaterialShaderMapHash(Initializer.MaterialShaderMapHash),
	VFType(Initializer.VertexFactoryType),
	Type(Initializer.Type),
	Target(Initializer.Target),
	NumRefs(0),
	SetParametersId(0),
	Canary(ShaderMagic_Initialized)
{
	OutputHash = Initializer.OutputHash;
	checkSlow(OutputHash != FSHAHash());

	check(Type);

	// Store off the source hash that this shader was compiled with
	// This will be used as part of the shader key in order to identify when shader files have been changed and a recompile is needed
	SourceHash = Type->GetSourceHash();

	if (VFType)
	{
		// Store off the VF source hash that this shader was compiled with
		VFSourceHash = VFType->GetSourceHash();
	}

	// Bind uniform buffer parameters automatically 
	for (TLinkedList<FUniformBufferStruct*>::TIterator StructIt(FUniformBufferStruct::GetStructList()); StructIt; StructIt.Next())
	{
		if (Initializer.ParameterMap.ContainsParameterAllocation(StructIt->GetShaderVariableName()))
		{
			UniformBufferParameterStructs.Add(*StructIt);
			UniformBufferParameters.Add(StructIt->ConstructTypedParameter());
			FShaderUniformBufferParameter* Parameter = UniformBufferParameters.Last();
			Parameter->Bind(Initializer.ParameterMap, StructIt->GetShaderVariableName(), SPF_Mandatory);
		}
	}

	SetResource(Initializer.Resource);

	// Register the shader now that it is valid, so that it can be reused
	Register();
}
QTSS_Error QTSSAccessLogModuleDispatch(QTSS_Role inRole, QTSS_RoleParamPtr inParamBlock)
{
	switch (inRole)
	{
	case QTSS_Register_Role:
		return Register(&inParamBlock->regParams);
	case QTSS_StateChange_Role:
		return StateChange(&inParamBlock->stateChangeParams);
	case QTSS_Initialize_Role:
		return Initialize(&inParamBlock->initParams);
	case QTSS_RereadPrefs_Role:
		return RereadPrefs();
	case QTSS_RTSPPostProcessor_Role:
		return PostProcess(&inParamBlock->rtspPostProcessorParams);
	case QTSS_ClientSessionClosing_Role:
		return ClientSessionClosing(&inParamBlock->clientSessionClosingParams);
	case QTSS_Shutdown_Role:
		return Shutdown();
	}
	return QTSS_NoErr;
}
QTSS_Error  QTSSPosixFileSysModuleDispatch(QTSS_Role inRole, QTSS_RoleParamPtr inParams)
{
    switch (inRole)
    {
        case QTSS_Register_Role:
            return Register(&inParams->regParams);
        case QTSS_Initialize_Role:
            return Initialize(&inParams->initParams);
        case QTSS_OpenFile_Role:
            return OpenFile(&inParams->openFileParams);
        case QTSS_AdviseFile_Role:
            return AdviseFile(&inParams->adviseFileParams);
        case QTSS_ReadFile_Role:
            return ReadFile(&inParams->readFileParams);
        case QTSS_CloseFile_Role:
            return CloseFile(&inParams->closeFileParams);
        case QTSS_RequestEventFile_Role:
            return RequestEventFile(&inParams->reqEventFileParams);
    }
    return QTSS_NoErr;
}
Example #14
0
//ringFile rfc = "child.txt";
//char cc[80];
HWND RingMDIChildWnd::Create(LPCTSTR szTitle,LPCTSTR szClass,
									  DWORD dwStyle,DWORD dwExStyle,
									  int x,int y,int width,int height,
									  HWND hParentWnd/*=NULL*/,HMENU hMenu/*=NULL*/,
									  LPARAM lParam/*=0*/)
{
   if(!Register(szClass,
		(HBRUSH)(COLOR_WINDOW + 1),
		m_windowInfo.lpszMenu,
		m_windowInfo.hIconBig,
		m_windowInfo.hCursor,
		m_windowInfo.hIconSmall,
		ITIS_MDICHILD))
		return NULL;
	
   if(m_parent->GetWindowType() == ITIS_MDIFRAME)
		((RingMDIFrameWnd*)m_parent)->CreateChild(szTitle,this,FALSE,dwStyle | WS_CHILD,
																lParam,(LPSTR)szClass);

   return m_hWnd;
}
Example #15
0
QTSS_Error  QTSSDSAuthModuleDispatch(QTSS_Role inRole, QTSS_RoleParamPtr inParams)
{
   switch (inRole)
    {  
       case QTSS_Register_Role:
            return Register();
        case QTSS_Initialize_Role:
            return Initialize(&inParams->initParams);
        case QTSS_RereadPrefs_Role:
            return RereadPrefs();
        case QTSS_RTSPAuthenticate_Role:
             if (sAuthenticationEnabled)
                 return AuthenticateRTSPRequest(&inParams->rtspAthnParams);
        case QTSS_RTSPAuthorize_Role:
             if (sAuthenticationEnabled)
                 return Authorize(&inParams->rtspRequestParams);
        case QTSS_Shutdown_Role:
            return Shutdown();
    }
    return QTSS_NoErr;
}
Example #16
0
void observerChat::Init ( const char* commandLine )
{
  variableName = "_observerChat";
  defaultValue = "game";
  permName = "OBSERVERCHAT";

  int mode = (int)atoi(commandLine);
  const char* variableValue = "game";

  if (mode == 0 && commandLine != NULL && strlen(commandLine) != 0) variableValue = "off";
  else if (mode == 1) variableValue = "game";
  else if (mode == 2) variableValue = "alwaysOn";
  else if (bz_BZDBItemExists(variableName))
    variableValue = bz_getBZDBString(variableName).c_str();
  
  bz_setBZDBString(variableName, variableValue);

  bz_debugMessage(4,"observerChat plugin loaded");

  Register(bz_eRawChatMessageEvent);
}
Example #17
0
/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: WinMain
--
-- DATE: November 12, 2013
--
-- REVISIONS:
-- November 25, 2013 - Vincent Lau: Added Semaphore creation and error checking
--
-- DESIGNER: Mat Siwoski
--
-- PROGRAMMER: Mat Siwoski
--
-- INTERFACE: int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lspszCmdParam, int nCmdShow)
--				HINSTANCE hInst: Handle to the current instance of the program.
--				HINSTANCE hPrevInstance: Handle to the previous instance of the program.
--				LPSTR lspszCmdParam: Command line for the application.
--				int nCmdShow: Control for how the window should be shown.
--
-- RETURNS: Returns the exit value upon exit.
--
-- NOTES:
-- This function is the entry point for a graphical Windows-based application.
------------------------------------------------------------------------------------------------------------------*/
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lspszCmdParam, int nCmdShow)
{
    MSG Msg;


    if (!hPrevInstance) {
        if (!Register(hInst)) {
            return FALSE;
        }
    }
    MainWindow = Create (hInst, nCmdShow);
    if (!MainWindow) {
        return FALSE;
    }
    ShowWindow (MainWindow, nCmdShow);
    UpdateWindow (MainWindow);
    cc.dwSize			= sizeof(COMMCONFIG);
    cc.wVersion			= 0x100;

    // Non-Window related inits
    hComm = 0;
    hWaitForLineSemaphore = CreateSemaphore(NULL, 0, 1, NULL);
    hACKWaitSemaphore	= CreateSemaphore(NULL, 0, 1, NULL);
    hFileWaitSemaphore	= CreateSemaphore(NULL, 0, 1, NULL);

    if (hWaitForLineSemaphore == NULL || hWaitForLineSemaphore == INVALID_HANDLE_VALUE ||
            hACKWaitSemaphore == NULL || hACKWaitSemaphore == INVALID_HANDLE_VALUE ||
            hFileWaitSemaphore == NULL || hFileWaitSemaphore == INVALID_HANDLE_VALUE)
    {
        MessageBox(MainWindow, TEXT("Couldn't acquire semaphores"), TEXT("Creation error"), MB_OK);
        return EXIT_FAILURE;
    }

    while (GetMessage (&Msg, NULL, 0, 0))
    {
        TranslateMessage (&Msg);
        DispatchMessage (&Msg);
    }
    return Msg.wParam;
}
Example #18
0
// Log a Win32 error
BOOL CEventLog::LogWin32Error(DWORD dwEventID,
                                           LPCTSTR szString, DWORD dwErrorNum)
{
   LPVOID lpvMsgBuf;
   TCHAR szErrorDesc[1024];
   if(!FormatMessage(
                  FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                  0, dwErrorNum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                  (LPTSTR)&lpvMsgBuf, 0, 0))
   {
      if(szString != NULL)
         wsprintf(szErrorDesc,
                  NTEXT("Function: %s returned Win32 Error: %d, Unknown Error"),
                  szString, dwErrorNum);
      else
         wsprintf(szErrorDesc,
                  NTEXT("Win32 Error: %d, Unknown Error"),
                  dwErrorNum);
   }
   else
   {
      if(szString != NULL)
         wsprintf(szErrorDesc,
                  NTEXT("Function: %s returned Win32 Error: %d Description: %s"),
                  szString, dwErrorNum, lpvMsgBuf);
      else
         wsprintf(szErrorDesc,
                  NTEXT("Win32 Error: %d Description: %s"),
                  dwErrorNum, lpvMsgBuf);
      LocalFree(lpvMsgBuf);
   }

   const TCHAR* rgsz[] = { szErrorDesc };

   Register();
   BOOL b = ReportEvent(m_hes, EVENTLOG_ERROR_TYPE, NULL, dwEventID,
                                                      NULL, 1, 0, rgsz, NULL);
   Deregister();
   return b;
}
bool Test()
{
	asIScriptEngine*        pSE;
	pSE=asCreateScriptEngine(ANGELSCRIPT_VERSION);
	Register(pSE);
	pSE->RegisterGlobalFunction("Float& Get(int32)",asFUNCTION(Get),asCALL_CDECL);
	pSE->RegisterGlobalFunction("void Print(float)",asFUNCTION(Print),asCALL_CDECL);

	const char script[]="\
						   float ret=10;\n\
						   Get(0)=10.0f;\n\
						   Get(1)=10.0f;\n\
						   Get(2)=10.0f;\n\
						   ret=Get(0)+(Get(1)*2.0f);\n\
						   Print(ret);\n\
						   \n";
	pSE->ExecuteString("",script);

	pSE->Release();

	return false;
}
Example #20
0
QTSS_Error EasyRedisModuleDispatch(QTSS_Role inRole, QTSS_RoleParamPtr inParamBlock)
{
	switch (inRole)
	{
	case QTSS_Register_Role:
		return Register(&inParamBlock->regParams);
	case QTSS_Initialize_Role:
		return Initialize(&inParamBlock->initParams);
	case QTSS_RereadPrefs_Role:
		return RereadPrefs();
	case Easy_RedisSetDevice_Role:
		return RedisSetDevice(&inParamBlock->DeviceInfoParams);
	case Easy_RedisDelDevice_Role:
		return RedisDelDevice(&inParamBlock->DeviceInfoParams);
	case Easy_RedisTTL_Role:
		return RedisTTL();
	case Easy_RedisGetEasyDarwin_Role:
		return RedisGetAssociatedDarwin(&inParamBlock->GetAssociatedDarwinParams);
	default: break;
	}
	return QTSS_NoErr;
}
Example #21
0
void CUITalkDialogWnd::AddQuestion(LPCSTR str, LPCSTR value, int number, bool b_finalizer)
{
	CUIQuestionItem* itm			= xr_new<CUIQuestionItem>(m_uiXml,"question_item");
	itm->Init						(value, str);
	++number; //zero-based index
	if(number<=10)
	{
		string16 buff;
		xr_sprintf						(buff, "%d.", (number==10)?0:number);
		itm->m_num_text->SetText		(buff);
		itm->m_text->SetAccelerator		(DIK_ESCAPE+number, 0);
	}
	if(b_finalizer)
	{
		itm->m_text->SetAccelerator		(kQUIT, 2);
		itm->m_text->SetAccelerator		(kUSE, 3);
	}

	itm->SetWindowName				("question_item");
	UIQuestionsList->AddWindow		(itm, true);
	Register						(itm);
}
Example #22
0
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInstance,
 						  LPSTR lspszCmdParam, int nCmdShow)
{
   MSG Msg;

   if (!hPrevInstance)
   	if (!Register(hInst))
      	return FALSE;

   MainWindow = Create (hInst, nCmdShow);
   	if (!MainWindow)
      	return FALSE;


  	while (GetMessage (&Msg, NULL, 0, 0))
   {
   	TranslateMessage (&Msg);
      DispatchMessage (&Msg);
   }

	return Msg.wParam;
}
Example #23
0
//本函数必须由父窗口的CreateDockSite调用
HWND RingDockSite::Create()
{
/*	WNDCLASSEX wndclsex =
   {
		sizeof(WNDCLASSEX),
			CS_DBLCLKS,
			InitWndProc,
			0,
			0,
			GetInstance(),
			NULL,
			NULL,
			NULL,//(HBRUSH)(COLOR_BTNFACE + 1),
			NULL,
			"RingDockSite",
			NULL
   };
	
   RegRingdowClass(&wndclsex);
*/
	if(!Register("RingDockSite",
		(HBRUSH)NULL,
		NULL,
		NULL,
		m_windowInfo.hCursor,
		NULL))
		return NULL;

	if(m_Background.hBrush == NULL)
	{
		//m_Background.cx = m_Background.cy = 0;
		m_Background.hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
		m_Background.bNeedDelete = TRUE;
	}
	
   CreateEx("","RingDockSite",WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);// | WS_VISIBLE);
	Show();
   return m_hWnd;
}
Example #24
0
 int SIPMediaServer::RegisterMediaServer(uint32_t task_id, char** rtmsg, 
         size_t *rtlen,
         string remote_name,
         string remote_ip,
         string remote_port)
 {
     /*父类已经将_ua_task_ 作为sip tid传入下层*/
     int rt = Register( rtmsg, rtlen, remote_name, remote_ip, 
             remote_port);
     if( rt == SIP_SUCCESS)
     {
         struct MediaServerState mds_state;
         mds_state.sip_tid = _ua_task_id_;
         mds_state.fsm_state = MEDIA_SERVER_FSM_REGISTER;
         _task_state_machine_.insert( make_pair( task_id, mds_state));
         _siptid_taskid_.insert( make_pair( _ua_task_id_, task_id));
         _ua_task_id_++;
         return SIP_SUCCESS;
     }
     else 
         return SIP_REGISTER_ERR;
 }
Example #25
0
int main(int argc, char** argv) {
    try{
        auto lua = std::make_shared<Lunar::Lua>();

        lua->LoadChunk("print('\\tHello from Lua!')");
        std::cout << "Lua says: " << lua->Exec<std::string>() << std::endl;

        lua->LoadChunk("return string.upper('Hello!')");
        std::cout << "Lua says: " << lua->Exec<std::string>() << std::endl;

        lua->LoadChunk("function dots(x) return string.rep('.', x) end");
        std::cout << "Lua says: " << lua->Exec<std::string>("dots", [&lua]() {
            lua->Push(42);
            return 1;
        })
        << std::endl;

        lua->LoadChunk("function mul(a, b) return a * b end");
        std::cout << "Lua says: " << lua->Exec<std::string>("mul", [&lua]() {
            lua->Push(3.0);
            lua->Push(5.0);
            return 2;
        })
        << std::endl;

        lua->Register("cmul", Lunar::LunarExports::Cmul);

        lua->LoadFile("bootstraper.lua");
        std::cout << "Lua says: " << lua->Exec<std::string>("l_bootstrap")
        << std::endl;
    }

    catch(std::exception & e) {
        std::cout << "Exception: " << e.what() << std::endl;
    }

    return EXIT_SUCCESS;
}
Example #26
0
template <> void LuaObject<SystemPath>::PushToLua(const SystemPath &o) {
	lua_State *l = Lua::manager->GetLuaState();

	// get the system path object cache
	if (!luaL_getsubtable(l, LUA_REGISTRYINDEX, "SystemPaths")) {
		lua_createtable(l, 0, 1);
		lua_pushliteral(l, "v");
		lua_setfield(l, -2, "__mode");
		lua_setmetatable(l, -2);
	}

	// stack: [SystemPaths]

	// push the system path as a blob to use as a key to look up the actual SystemPath object
	char key_blob[SystemPath::SizeAsBlob];
	o.SerializeToBlob(key_blob);

	lua_pushlstring(l, key_blob, sizeof(key_blob)); // [SystemPaths key]
	lua_pushvalue(l, -1); // [SystemPaths key key]
	lua_rawget(l, -3); // [SystemPaths key value/nil]
	if (lua_isnil(l, -1)) {
		// [SystemPaths key nil]
		lua_pop(l, 1);

		// push a new Lua SystemPath object
		Register(new (LuaObjectBase::Allocate(sizeof(LuaCopyObject<SystemPath>))) LuaCopyObject<SystemPath>(o));

		// store it in the SystemPaths cache, but keep a copy on the stack
		lua_pushvalue(l, -1); // [SystemPaths  key  value  value]
		lua_insert(l, -4); // [value SystemPaths key value]
		lua_rawset(l, -3); // [value SystemPaths]
		lua_pop(l, 1); // [value]
	} else {
		// [SystemPaths key value]
		lua_insert(l, -3); // [value SystemPaths key]
		lua_pop(l, 2); // [value]
	}
}
Example #27
0
int main () {

  int lock0 = -1;
  int mv0 = -1;
  int mv0value = -1;

  Print("Registering with network thread.\n",0,0,0);
  Register();
  Print("Done Registering with network thread.\n",0,0,0);

  Print("Creating lock with name \"lockOne\"\n",0,0,0);
  lock0 = CreateLock("lockOne");
  Print("Created lock with name \"lockOne\"\n",0,0,0);
  
  Print("Acquiring lock0\n",0,0,0);
  Acquire(lock0);
  Print("Acquired lock0\n",0,0,0);

  Print("Creating MV with name \"mvOne\"\n",0,0,0);
  mv0 = CreateMV("mvOne");
  Print("Created MV with name \"mvOne\" and ID=%d\n",mv0,0,0);

  
  mv0value = GetMV(mv0);
  Print("Current value of \"mvOne\" =%d\n",mv0value,0,0);

  mv0value++;

  Print("Setting value of \"mvOne\" to %d\n",mv0value,0,0);
  SetMV(mv0,mv0value);

  mv0value = GetMV(mv0);
  Print("New value of \"mvOne\" =%d\n",mv0value,0,0);
  
  Print("Releasing lock0\n",0,0,0);
  Release(lock0);

}
void CParticleGroupManager::Read(CTStream *pIS)
{
	ASSERT(pIS);
	CTStream &is = *pIS;

	is.ExpectID_t("PGMG");
	UBYTE ubVer;
	is >> ubVer;

	if(ubVer == CURRENT_VERSION)
	{
		DWORD dwSize;
		is >> dwSize;
		for(DWORD i=0; i<dwSize; ++i)
		{
			CParticleGroup* pg = new CParticleGroup;
			pg->Read(&is);
			if (!Register(pg))
			{
				if (pg) delete pg;
			}
		}
	}
Example #29
0
CConsole::CConsole(int FlagMask)
{
	m_FlagMask = FlagMask;
	m_AccessLevel = ACCESS_LEVEL_ADMIN;
	m_pRecycleList = 0;
	m_TempCommands.Reset();
	m_StoreCommands = true;
	m_paStrokeStr[0] = "0";
	m_paStrokeStr[1] = "1";
	m_ExecutionQueue.Reset();
	m_pFirstCommand = 0;
	m_pFirstExec = 0;
	mem_zero(m_aPrintCB, sizeof(m_aPrintCB));
	m_NumPrintCB = 0;

	m_pStorage = 0;

	// register some basic commands
	Register("echo", "r", CFGFLAG_SERVER|CFGFLAG_CLIENT, Con_Echo, this, "Echo the text");
	Register("exec", "r", CFGFLAG_SERVER|CFGFLAG_CLIENT, Con_Exec, this, "Execute the specified file");

	Register("toggle", "sii", CFGFLAG_SERVER|CFGFLAG_CLIENT, ConToggle, this, "Toggle config value");
	Register("+toggle", "sii", CFGFLAG_CLIENT, ConToggleStroke, this, "Toggle config value via keypress");

	Register("mod_command", "s?i", CFGFLAG_SERVER, ConModCommandAccess, this, "Specify command accessibility for moderators");
	Register("mod_status", "", CFGFLAG_SERVER, ConModCommandStatus, this, "List all commands which are accessible for moderators");

	// TODO: this should disappear
	#define MACRO_CONFIG_INT(Name,ScriptName,Def,Min,Max,Flags,Desc) \
	{ \
		static CIntVariableData Data = { this, &g_Config.m_##Name, Min, Max }; \
		Register(#ScriptName, "?i", Flags, IntVariableCommand, &Data, Desc); \
	}

	#define MACRO_CONFIG_STR(Name,ScriptName,Len,Def,Flags,Desc) \
	{ \
		static CStrVariableData Data = { this, g_Config.m_##Name, Len }; \
		Register(#ScriptName, "?r", Flags, StrVariableCommand, &Data, Desc); \
	}

	#include "config_variables.h"

	#undef MACRO_CONFIG_INT
	#undef MACRO_CONFIG_STR
}
Example #30
0
void CMainMenu::OnNewPatchFound(LPCSTR VersionName, LPCSTR URL)
{
	if (m_sPDProgress.IsInProgress) return;
	
	if (m_pMB_ErrDlgs[NewPatchFound])	
	{
		delete_data(m_pMB_ErrDlgs[NewPatchFound]);
		m_pMB_ErrDlgs[NewPatchFound] = NULL;
	}
	if (!m_pMB_ErrDlgs[NewPatchFound])
	{
		INIT_MSGBOX(m_pMB_ErrDlgs[NewPatchFound], "msg_box_new_patch");

		shared_str tmpText;
		tmpText.printf(m_pMB_ErrDlgs[NewPatchFound]->GetText(), VersionName, URL);
		m_pMB_ErrDlgs[NewPatchFound]->SetText(*tmpText);		
	}
	m_sPatchURL = URL;
	
	Register						(m_pMB_ErrDlgs[NewPatchFound]);
	m_pMB_ErrDlgs[NewPatchFound]->AddCallbackStr	("button_yes", MESSAGE_BOX_YES_CLICKED, CUIWndCallback::void_function(this, &CMainMenu::OnDownloadPatch));
	m_pMB_ErrDlgs[NewPatchFound]->ShowDialog(false);
};