예제 #1
0
파일: Lists.cpp 프로젝트: RJVB/QTilities
/*!
	initialise the various google::dense_hash_map "lists" that are used throughout QTils
 */
void init_QTMWlists()
{
	if( !q2nw_initialised ){
		// these two keys (variable names) should never occur:
		qtwmh2hwnd.set_empty_key( (QTMovieWindowH) 0 );
		qtwmh2hwnd.set_deleted_key( (QTMovieWindowH) -1 );
		q2nw_initialised = 1;
	}
	if( !nw2q_initialised ){
		// these two keys (variable names) should never occur:
		hwnd2qtwmh.set_empty_key( (NativeWindow) 0 );
		hwnd2qtwmh.set_deleted_key( (NativeWindow) -1 );
		nw2q_initialised = 1;
	}
	if( !m2qtmwh_initialised ){
		// these two keys (variable names) should never occur:
		m2qtmwh.set_empty_key( (Movie) 0 );
		m2qtmwh.set_deleted_key( (Movie) -1 );
		m2qtmwh_initialised = 1;
	}
#if defined(WIN32) || defined(_WINDOWS) || defined(_MSC_VER)
	if( !met_initialised ){
	  int i;
		// these two keys (variable names) should never occur:
		metMap.set_empty_key( (ErrCode) 65535 );
		metMap.set_deleted_key( (ErrCode) -65535 );
		for( i = 0 ; i < sizeof(macErrorTable) / sizeof(MacErrorTables) ; i++ ){
			metMap[macErrorTable[i].errCode] = &macErrorTable[i];
		}
		met_initialised = 1;
	}
#endif
	lastQTWMH = NULL;
}
void PatchMW2_StringList()
{
	slHashMap.set_empty_key("*DUMMYDUMMY*");
	slHashMap.set_deleted_key("*DUMMYDUMM*");

	call(0x4D2280, SL_Init, PATCH_JUMP);
	call(0x436B40, SL_GetStringOfSize, PATCH_JUMP);
	call(0x4EC1D0, SL_ConvertToString_, PATCH_JUMP);
	call(0x61BCB0, FindStringOfSize, PATCH_JUMP);
	call(0x469D80, SL_ConvertFromString, PATCH_JUMP);
	call(0x4D9B00, SL_AddRefToString, PATCH_JUMP);
	call(0x4F1500, SL_RemoveRefToStringOfSize, PATCH_JUMP);
	call(0x47CD70, SL_RemoveRefToString, PATCH_JUMP);
	call(0x417730, Scr_SetString, PATCH_JUMP);
	call(0x4401E0, SL_GetStringLen, PATCH_JUMP);
	call(0x40C050, SL_TransferRefToUser, PATCH_JUMP);
	call(0x4B4310, SL_AddUser, PATCH_JUMP);
	call(0x430510, SL_ConvertToLowercase, PATCH_JUMP);
	call(0x4F46D0, SL_ShutdownSystem, PATCH_JUMP);
	call(0x4A44A0, SL_TransferSystem, PATCH_JUMP);

	stringHeap = HeapCreate(0, 1024 * 1024, 0);

	// path_node_constant_t marking function; has some terrible string references
	*(BYTE*)0x4F74B0 = 0xC3;
}
// entry point
void PatchMW2_StringTable()
{
	stringTables.set_empty_key("");

	stringTableHook.initialize(stringTableHookLoc, StringTable_GetAsset);
	stringTableHook.installHook();
}
void PatchMW2_LocalizedStrings()
{
	_localizedStrings.set_empty_key("");
 
	loadLocalizeHook.initialize(loadLocalizeHookLoc, SEH_GetLocalizedString);
	loadLocalizeHook.installHook();
 
	call(0x4CE5EE, SetString, PATCH_CALL); //instead of calling CStringEdPackage::SetString in CStringEdPackage::ParseLine we call our SetString
	call(0x41D860, SELoadLanguageHookStub, PATCH_JUMP); //instead of the game loading str files according to loc_language we load them according to loc_modlanguage
 
	Dvar_RegisterEnum("loc_modLanguage", ModLanguageEnum, 0, DVAR_FLAG_SAVED, "Preferred language for custom localized strings.");
}
예제 #5
0
 virtual void SetUp() {
     hashMap.set_empty_key(NULL);
     hashMap["january"] = 31;
     hashMap["february"] = 29;
     hashMap["march"] = 31;
     hashMap["april"] = 30;
     hashMap["may"] = 31;
     hashMap["june"] = 30;
     hashMap["july"] = 31;
     hashMap["august"] = 31;
     hashMap["september"] = 30;
     hashMap["october"] = 31;
     hashMap["november"] = 30;
     hashMap["december"] = 31;
 }
예제 #6
0
    local_stochastic_graph_exponential(
            sparserow* G_, 
            const double t_, double eps_,
            size_t maxpush_) 
	: G(G_), t(t_), eps(eps_), maxpush(maxpush_), 
            n(G->n), N(taylordegree(t, eps)),
            pushcoeff(N+1,0.), sval(std::numeric_limits<lindex>::max()),
            nextind(0), noffset(0),
            lneigh(nstart, sval), 
            lp(nstart, std::make_pair(sval, sval)), 
            gmap(nstart, (mwIndex)-1), npush(0)
    {        
        DEBUGPRINT(("gsqres interior: t=%lf eps=%lf \n", t, eps));
        DEBUGPRINT(("gsqres: n=%i N=%i \n", n, N));
        
        // initialize the weights for the different residual partitions
        //  into the vector "pushcoeff"
        std::vector<double> psivec(N+1,0.);
        psivec[N] = 1;
        for (lindex k = 1; k <= N ; k++){
            psivec[N-k] = psivec[N-k+1]*t/(double)(N-k+1) + 1;
        } // psivec[k] = psi_k(t)

        pushcoeff[0] = ((exp(t)*eps)/(double)N)/psivec[0];
        // This is a more numerically stable way to compute
        //      pushcoeff[j] = exp(t)*eps/(n*N*psivec[j])
        for (lindex k = 1; k <= N ; k++){
            pushcoeff[k] = pushcoeff[k-1]*(psivec[k-1]/psivec[k]);
        }
        
        if (n > std::numeric_limits<lindex>::max()) {
            mexErrMsgIdAndTxt("gexpmq_mex:unimplemented", 
                    "support only up to %i elements", 
                    std::numeric_limits<lindex>::max());
        }
        
        imap.set_empty_key(sval);        
    }