void DGameTree::RebuildTree()
{
	GameFile* currentGame = SelectedGame();

	int count = topLevelItemCount();
	for (int a = 0; a < count; a++)
		takeTopLevelItem(0);

	for (QTreeWidgetItem* i : m_path_nodes.values())
	{
		count = i->childCount();
		for (int a = 0; a < count; a++)
			i->takeChild(0);
	}

	if (m_current_style == STYLE_TREE)
	{
		for (QTreeWidgetItem* i : m_path_nodes.values())
			addTopLevelItem(i);
		for (QTreeWidgetItem* i : m_items.keys())
			m_path_nodes.value(m_items.value(i)->GetFolderName())->addChild(i);
	}
	else
	{
		for (QTreeWidgetItem* i : m_items.keys())
			addTopLevelItem(i);
	}

	expandAll();
	ResizeAllCols();
	SelectGame(currentGame);
}
Beispiel #2
0
//--------------------------------------
bool CGameServer::OnUdpDispatch(const PacketPtr& PktPtr, PUDP_PARAM pUdp)
{
	// PUDP_PARAM->pCache == nullptr, 上层可以保存从底层申请的缓存数据
	// PUDP_PARAM->pCache, PUDP_PARAM->index是底层申请的缓存数据的起始地址和索引号
	// 如果上层保存缓存, 设置PUDP_PARAM->pData为nullptr通知网络底层
	// 释放缓存使用MObject::sMCFree(index, pCache)
	assert(PktPtr->GetEvent() == PAK_EVENT_LOGIN_SELECT_GAME);
	CPAKLoginSelectGame* pSelect = static_cast<CPAKLoginSelectGame*>(PktPtr.Get());
	if (SelectGame(pSelect) == false) {
		pSelect->SetAck(LOGIN_ERROR_NONE_GATE);
		m_NetworkPtr->SendTo(pUdp->krSocket, *pSelect, pUdp->NetAddr);
		LOG_INFO(m_FileLog, TF("[游戏服务器]游戏服务器收到客户端选择游戏服务器请求, 但是没有网关服务器"));
	}
	return true;
}
Beispiel #3
0
//--------------------------------------
bool CGameServer::OnShareRoutine(Int nEvent, CEventBase& EventRef, LLong llParam, CEventQueue::EVENT_TYPE)
{
	assert((m_pConfig->GetLoadServers() & (CServerConfig::CFG_DEFAULT_CENTER|CServerConfig::CFG_DEFAULT_GAMEDB|CServerConfig::CFG_DEFAULT_ZONE|CServerConfig::CFG_DEFAULT_GATE)) != 0);
	switch (nEvent) {
	case PAK_EVENT_LINK:
		{
			return OnShareLink(EventRef, llParam);
		}
		break;
	case PAK_EVENT_UPDATE:
		{
			return OnShareUpdate(EventRef, llParam);
		}
		break;
	//case PAK_EVENT_UNLINK: // 同进程服务器注销, 说明服务停止, 不需要处理
	//	break;
	case PAK_EVENT_GAME_ID:
		{
			PInt pId = reinterpret_cast<PInt>(llParam);
			*pId = (Int)m_ServerInfo.usId;
		}
		break;
	case PAK_EVENT_LOGIN_SELECT_GAME:
		{
			CPAKLoginSelectGame* pSelect = static_cast<CPAKLoginSelectGame*>(&EventRef);
			if (SelectGame(pSelect, llParam) == false) {
				pSelect->SetAck(LOGIN_ERROR_NONE_GATE);
				reinterpret_cast<ICommonServer*>(llParam)->OnShareRoutine(PAK_EVENT_LOGIN_SELECT_GAME, *pSelect);
				DEV_INFO(TF("[游戏服务器]同进程游戏服务器收到客户端选择游戏服务器请求, 但是没有网关服务器"));
			}
		}
		break;
	default:
		{
			LOGV_WARN(m_FileLog, TF("[游戏服务器]同进程服务器无法识别的信令包数据[event=%d]"), nEvent);
			assert(0);
		}
	}
	return true;
}
Beispiel #4
0
u16 ReadZodKeys()
{
	u16 pad_status = 0xffff;
	u32 keys = gp2x_joystick_read();

/* DEBUG */
#ifdef WITH_REG_STATS
	if( keys & GP2X_PUSH )
	{
		int regcounter=0;
		for(regcounter = 0; regcounter < 32; regcounter++)
		{
			reg_count[regcounter] = 0; 
			reg_mapped_count[regcounter] = 0;
		}
	}
#endif

	//Read key state
#ifndef IPHONE	
	if (
		keys & GP2X_L && keys & GP2X_R &&
		keys & GP2X_A && keys & GP2X_B &&
		keys & GP2X_X && keys & GP2X_Y )
	{
		psx4all_prof_show();
		psxShutdown();
		CloseComponents();
		
		gp2x_deinit();
		exit(0);
	}
#endif
#if 0
	if( keys & GP2X_SELECT )
	{
		SkipReset = !SkipReset;
		gp2x_printf(NULL, 0, 0, "SkipReset %s           ", SkipReset == 0 ? "OFF" : "ON" );
		gp2x_video_flip();
		gp2x_timer_delay(1000);		
	}
	if( keys & GP2X_L )
	{
		if( skipCount > 0 ) skipCount--;
		gp2x_printf(NULL, 0, 0, "skipCount %d            ", skipCount);
		gp2x_video_flip();
		gp2x_timer_delay(250);
	}
	if( keys & GP2X_R )
	{
		skipCount++;
		gp2x_printf(NULL, 0, 0, "skipCount %d            ", skipCount);
		gp2x_video_flip();
		gp2x_timer_delay(250);
	}
	if( keys & GP2X_VOL_DOWN )
	{
		if( skipRate > 0 ) skipRate--;
		gp2x_printf(NULL, 0, 0, "skipRate %d            ", skipRate);
		gp2x_video_flip();
		gp2x_timer_delay(250);
	}
	if( keys & GP2X_VOL_UP )
	{
		skipRate++;
		gp2x_printf(NULL, 0, 0, "skipRate %d            ", skipRate);
		gp2x_video_flip();
		gp2x_timer_delay(250);
	}
#endif
	if( keys & GP2X_VOL_DOWN && keys & GP2X_VOL_UP )
	{
#ifdef GP2X_SDL
		// Menu system
		u32 w = sdlscreen->w;
		u32 h = sdlscreen->h;

		gp2x_change_res(320, 240);
#endif

		if( 0 != SelectGame() )
		{
			psx4all_emulating=1;
			psx4all_prof_start(PROFILER_TOTAL);
			psxCpu->Execute();
			psx4all_prof_end(PROFILER_TOTAL);
			psx4all_emulating=0;

			psx4all_prof_show();
		}
#ifdef GP2X_SDL
		gp2x_change_res(w, h);	
#endif
	}

/*
	if( keys & GP2X_PUSH && displayVideoMemory)
    primitiveDebugMode = true;
  else
    primitiveDebugMode = false;
*/
	if(	keys & GP2X_R &&
		keys & GP2X_VOL_DOWN )
	{
		// Underclock
    u32 newClock = (PsxClockMult>2) ? (PsxClockMult-1) : PsxClockMult;
    UpdateClock (newClock);
    gp2x_printf(NULL, 0, 0, "PSX CLOCK %d %%            ", newClock);
		gp2x_video_flip();
		gp2x_timer_delay(250);
	}


	if( 	keys & GP2X_R &&
		keys & GP2X_VOL_UP )
	{
		// Overclock
    u32 newClock = (PsxClockMult<200) ? (PsxClockMult+1) : PsxClockMult;
    UpdateClock (newClock);
    gp2x_printf(NULL, 0, 0, "PSX CLOCK %d %%            ", newClock);
		gp2x_video_flip();
		gp2x_timer_delay(250);
	}

	if(	keys & GP2X_L &&
		keys & GP2X_VOL_DOWN )
	{
		// Underclock
		PsxCycleMult = (PsxCycleMult>0.2) ? (PsxCycleMult-0.1) : PsxCycleMult;
		gp2x_printf(NULL, 0, 0, "PSX CYCLE %f               ", PsxCycleMult);
#ifdef DYNAREC
		psxCpu->Reset();
#endif
		gp2x_video_flip();
		gp2x_timer_delay(250);
	}


	if( 	keys & GP2X_L &&
		keys & GP2X_VOL_UP )
	{
		// Overclock
    		PsxCycleMult = (PsxCycleMult<10.0) ? (PsxCycleMult+0.1) : PsxCycleMult;
    		gp2x_printf(NULL, 0, 0, "PSX CYCLE %f               ", PsxCycleMult);
#ifdef DYNAREC
		psxCpu->Reset();
#endif
		gp2x_video_flip();
		gp2x_timer_delay(250);
	}

	if(	keys & GP2X_VOL_DOWN ) // L2
	{
		pad_status &= ~(1<<8);
	}
	
	if( keys & GP2X_VOL_UP ) // R2
	{
		pad_status &= ~(1<<9);
	}

	if (keys & GP2X_UP)
	{
		pad_status &= ~(1<<4); 
	}
	if (keys & GP2X_DOWN)
	{
		pad_status &= ~(1<<6);
	}
	if (keys & GP2X_LEFT)
	{
		pad_status &= ~(1<<7);
	}
	if (keys & GP2X_RIGHT)
	{
		pad_status &= ~(1<<5);
	}
	if (keys & GP2X_START)
	{
		pad_status &= ~(1<<3);
	}
	if (keys & GP2X_SELECT)
	{			
		pad_status &= ~(1);
	}
	if (keys & GP2X_L)
	{
		pad_status &= ~(1<<10); // L ?
	}
	if (keys & GP2X_R)
	{
		pad_status &= ~(1<<11); // R ?
	}
		
	if (keys & GP2X_X)
	{
		pad_status &= ~(1<<14);
	}
	if (keys & GP2X_B)
	{
		pad_status &= ~(1<<13);
	}
	if (keys & GP2X_A)
	{
		pad_status &= ~(1<<15);
	}
	if (keys & GP2X_Y)
	{
		pad_status &= ~(1<<12);
	}

	return pad_status;
}
Beispiel #5
0
int main(int argc, char *argv[])
#endif
{
#ifndef IPHONE
#if defined(ARM_ARCH)
	ChangeWorkingDirectory(argv[0]);
	getcwd(gamepath, 256);
#else
#if defined(__WIN32__)
	if(argc == 1)
		strncpy(gamepath,"E:\\ps1",256);
	else
		strncpy(gamepath,argv[1],256);
#else
	strncpy(gamepath,ROM_PREFIX,256);
#endif
#endif
#endif

#ifdef PSP
	sprintf(gamepath,"");
#endif

#ifdef IPHONE
	sprintf(gamepath,"");
#endif

	memset(&Config, 0, sizeof(PsxConfig));
	Config.PsxAuto = 1;
	Config.Cdda = 1;
	Config.Xa = 0;
#ifdef DYNAREC
	Config.Cpu = 0;
#else
	Config.Cpu = 1;
#endif

#ifdef WITH_HLE
	Config.HLE = 1;
#else
	Config.HLE = 0;
#endif

	Config.Mdec = 0;
	Config.PsxOut = 0;
	Config.PsxType = 0;
	Config.QKeys = 0;
	Config.RCntFix = 0;
	Config.Sio = 0;
	Config.SpuIrq = 1;
	Config.VSyncWA = 0;

#if defined(PSP) || defined(SDL) || defined(IPHONE)
    	sprintf(Config.BiosDir, "%s/Media/ROMs/PSX/", appworkdir);
	sprintf(Config.Bios, "scph1001.bin");
	sprintf(Config.Mcd1, "mcd001.mcr");
	sprintf(Config.Mcd2, "mcd002.mcr");
#else
	sprintf(Config.BiosDir, PSX4ALL_STR, gamepath);
	sprintf(Config.Bios, "/bios/scph1000.bin");
	sprintf(Config.Mcd1, "%s/memory_card/mcd001.mcr", gamepath);
	sprintf(Config.Mcd2, "%s/memory_card/mcd002.mcr", gamepath);
	
#endif
	gp2x_init(900, 16, 11025, 16, 1, 60, 1);
#ifndef GP2X
	gp2x_video_flip_single();
#endif

#ifdef IPHONE
	u32 loadsvs = 0;
	linesInterlace_user = preferences.interlace;
	skipCount = skipCountTablePhone[preferences.frameSkip];
	skipRate = skipRateTablePhone[preferences.frameSkip];   
	iSoundMuted = preferences.muted;
	Config.Cdda = preferences.muted;
	Config.Xa = preferences.muted;
#ifdef WITH_HLE
	Config.HLE = !preferences.bios;
#else
	Config.HLE = 0;
#endif
	if( (!strcasecmp(filename + (strlen(filename)-4), FORMAT_SV )) )
	{
		u32 pos;
		loadsvs = 1;
		sprintf(svsfilename, PSX4ALL_STR, filename);
		sprintf(iphonefile, PSX4ALL_STR, filename);
		pos = strlen(iphonefile)-18;
		iphonefile[pos] = '\0';
		packfile = iphonefile;
	}
	else
	{
		loadsvs = 0;
		sprintf(iphonefile, PSX4ALL_STR, filename);
		packfile = iphonefile;
	}

	gp2x_video_RGB_clearscreen16();
	LoadCdBios = 0;

	if (SysInit() == -1)
	{
		gp2x_deinit();
		return 0;
	}

	if (InitComponents() == -1)
	{
		gp2x_deinit();
		return 0;
	}

	SysReset();
	CheckCdrom();

	if( Config.HLE )
	{
		LoadCdBios = 0;
		if( LoadCdrom() == -1 )
		{
			gp2x_printf(NULL, 120, 120, PSX4ALL_LDD);
			gp2x_video_flip();
			gp2x_timer_delay(2000);
			gp2x_video_RGB_clearscreen16();
			return 0;
		}
	}
	
	if (loadsvs) {
		if( LoadState(svsfilename) == -1 )
		{
			gp2x_printf(NULL, 120, 120,  PSX4ALL_LSF);
			gp2x_video_flip();
			gp2x_timer_delay(2000);
			gp2x_video_RGB_clearscreen16();

			psxShutdown();
			CloseComponents();
			
			gp2x_deinit();
			pthread_exit(NULL);
		}
	}

	psx4all_emulating=1;
	psx4all_prof_start(PROFILER_TOTAL);
	psxCpu->Execute();
	psx4all_prof_end(PROFILER_TOTAL);
	psx4all_emulating=0;

	psx4all_prof_show();
#else
	if( 0 != SelectGame() )
	{
		psx4all_emulating=1;
		psx4all_prof_start(PROFILER_TOTAL);
		psxCpu->Execute();
		psx4all_prof_end(PROFILER_TOTAL);
		psx4all_emulating=0;

		psx4all_prof_show();
	}
#endif
	gp2x_deinit();

	return 0;
}
Beispiel #6
0
    void LootState::Init(const std::string& cmdLineGame) {
        // Do some preliminary locale / UTF-8 support setup here, in case the settings file reading requires it.
        //Boost.Locale initialisation: Specify location of language dictionaries.
        boost::locale::generator gen;
        gen.add_messages_path(g_path_l10n.string());
        gen.add_messages_domain("loot");

        //Boost.Locale initialisation: Generate and imbue locales.
        locale::global(gen(Language(Language::english).Locale() + ".UTF-8"));
        boost::filesystem::path::imbue(locale());

        // Check if the LOOT local app data folder exists, and create it if not.
        if (!fs::exists(g_path_local)) {
            BOOST_LOG_TRIVIAL(info) << "Local app data LOOT folder doesn't exist, creating it.";
            try {
                fs::create_directory(g_path_local);
            }
            catch (exception& e) {
                _initErrors.push_back((format(translate("Error: Could not create LOOT settings file. %1%")) % e.what()).str());
            }
        }
        if (fs::exists(g_path_settings)) {
            try {
                loot::ifstream in(g_path_settings);
                _settings = YAML::Load(in);
                in.close();
            }
            catch (exception& e) {
                _initErrors.push_back((format(translate("Error: Settings parsing failed. %1%")) % e.what()).str());
            }
        }
        // Check if the settings are valid (or if they don't exist).
        if (!AreSettingsValid()) {
            _settings = GetDefaultSettings();
        }

        //Set up logging.
        boost::log::add_file_log(
            boost::log::keywords::file_name = g_path_log.string().c_str(),
            boost::log::keywords::auto_flush = true,
            boost::log::keywords::format = (
            boost::log::expressions::stream
            << "[" << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%H:%M:%S") << "]"
            << " [" << boost::log::trivial::severity << "]: "
            << boost::log::expressions::smessage
            )
            );
        boost::log::add_common_attributes();
        bool enableDebugLogging = false;
        if (_settings["enableDebugLogging"]) {
            enableDebugLogging = _settings["enableDebugLogging"].as<bool>();
        }
        if (enableDebugLogging)
            boost::log::core::get()->set_logging_enabled(true);
        else
            boost::log::core::get()->set_logging_enabled(false);

        // Log some useful info.
        BOOST_LOG_TRIVIAL(info) << "LOOT Version: " << g_version_major << "." << g_version_minor << "." << g_version_patch;
        BOOST_LOG_TRIVIAL(info) << "LOOT Build Revision: " << g_build_revision;
#ifdef _WIN32
        // Check if LOOT is being run through Mod Organiser.
        bool runFromMO = GetModuleHandle(ToWinWide("hook.dll").c_str()) != NULL;
        if (runFromMO) {
            BOOST_LOG_TRIVIAL(info) << "LOOT is being run through Mod Organiser.";
        }
#endif

        // The CEF debug log is appended to, not overwritten, so it gets really long.
        // Delete the current CEF debug log.
        fs::remove(g_path_local / "CEFDebugLog.txt");

        // Now that settings have been loaded, set the locale again to handle translations.
        if (_settings["language"] && _settings["language"].as<string>() != Language(Language::english).Locale()) {
            BOOST_LOG_TRIVIAL(debug) << "Initialising language settings.";
            loot::Language lang(_settings["language"].as<string>());
            BOOST_LOG_TRIVIAL(debug) << "Selected language: " << lang.Name();

            //Boost.Locale initialisation: Generate and imbue locales.
            locale::global(gen(lang.Locale() + ".UTF-8"));
            boost::filesystem::path::imbue(locale());
        }

        // Detect games & select startup game
        //-----------------------------------

        //Detect installed games.
        BOOST_LOG_TRIVIAL(debug) << "Detecting installed games.";
        try {
            _games = ToGames(GetGameSettings(_settings));
        }
        catch (YAML::Exception& e) {
            BOOST_LOG_TRIVIAL(error) << "Games' settings parsing failed. " << e.what();
            _initErrors.push_back((format(translate("Error: Games' settings parsing failed. %1%")) % e.what()).str());
            // Now redo, but with no games settings, so only the hardcoded defaults get loaded. It means the user can
            // at least still then edit them.
            _games = ToGames(GetGameSettings(YAML::Node()));
        }

        try {
            BOOST_LOG_TRIVIAL(debug) << "Selecting game.";
            SelectGame(cmdLineGame);
            BOOST_LOG_TRIVIAL(debug) << "Initialising game-specific settings.";
            _currentGame->Init(true);
            // Update game path in settings object.
            _settings["games"] = ToGameSettings(_games);
        }
        catch (loot::error &e) {
            if (e.code() == loot::error::no_game_detected) {
                _initErrors.push_back(e.what());
            }
            else {
                BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised. " << e.what();
                _initErrors.push_back((format(translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()).str());
            }
        }
        BOOST_LOG_TRIVIAL(debug) << "Game selected is " << _currentGame->Name();
    }