/** * Initialize the Adhoc-Control Emulator * @param stacksize Stacksize of the Internal Thread * @param prio Internal Thread Priority * @param adhoc_id Game Product Code * @return 0 on success or... ADHOCCTL_ALREADY_INITIALIZED, ADHOCCTL_STACKSIZE_TOO_SHORT, ADHOCCTL_INVALID_ARG */ int proNetAdhocctlInit(int stacksize, int prio, const SceNetAdhocctlAdhocId * adhoc_id) { // Uninitialized Library if(_init == 0) { // Minimum Stacksize (just to fake SCE behaviour) if(stacksize >= 3072) { // Read Hotspot Configuration if(_readHotspotConfig() == 0) { // Get Server IP (String) const char * ip = _readServerConfig(); // Read Server Configuration if(ip != NULL) { // Initialize Networking if(_initNetwork(adhoc_id, ip) == 0) { // Create Main Thread int update = sceKernelCreateThread("friend_finder", _friendFinder, prio, 32768, 0, NULL); // Created Main Thread if(update >= 0) { // Initialization Success _init = 1; // Start Main Thread sceKernelStartThread(update, 0, NULL); // Return Success return 0; } } } } // Generic Error return -1; } // Stack too small return ADHOCCTL_STACKSIZE_TOO_SHORT; } // Initialized Library return ADHOCCTL_ALREADY_INITIALIZED; }
void CMenu::_CheatSettings() { s32 padsState; WPADData *wd; u32 btn; WPAD_Rumble(WPAD_CHAN_0, 0); // try to load cheat file int txtavailable=0; m_cheatSettingsPage = 1; // init page txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str())); _showCheatSettings(); _textCheatSettings(); if (txtavailable) m_btnMgr.setText(m_cheatLblTitle,wfmt(L"%s",m_cheatfile.getGameName().c_str())); else m_btnMgr.setText(m_cheatLblTitle,L""); while (true) { WPAD_ScanPads(); padsState = WPAD_ButtonsDown(0); wd = WPAD_Data(0); btn = _btnRepeat(wd->btns_h); if ((padsState & (WPAD_BUTTON_HOME | WPAD_BUTTON_B)) != 0) break; if (wd->ir.valid) m_btnMgr.mouse(wd->ir.x - m_cur.width() / 2, wd->ir.y - m_cur.height() / 2); else if ((padsState & WPAD_BUTTON_UP) != 0) m_btnMgr.up(); else if ((padsState & WPAD_BUTTON_DOWN) != 0) m_btnMgr.down(); if ((padsState & WPAD_BUTTON_MINUS) != 0) { if (m_cheatSettingsPage > 1) --m_cheatSettingsPage; _hideCheatSettings(); _showCheatSettings(); m_btnMgr.click(m_cheatBtnPageM); } else if ((padsState & WPAD_BUTTON_PLUS) != 0) { _hideCheatSettings(); if (m_cheatSettingsPage < (m_cheatfile.getCnt()+CHEATSPERPAGE-1)/CHEATSPERPAGE) ++m_cheatSettingsPage; _showCheatSettings(); m_btnMgr.click(m_cheatBtnPageP); } if ((padsState & WPAD_BUTTON_A) != 0) { m_btnMgr.click(); if (m_btnMgr.selected() == m_cheatBtnBack) break; else if (m_btnMgr.selected() == m_cheatBtnPageM) { _hideCheatSettings(); if (m_cheatSettingsPage > 1) --m_cheatSettingsPage; _showCheatSettings(); } else if (m_btnMgr.selected() == m_cheatBtnPageP) { _hideCheatSettings(); if (m_cheatSettingsPage < (m_cheatfile.getCnt()+CHEATSPERPAGE-1)/CHEATSPERPAGE) ++m_cheatSettingsPage; _showCheatSettings(); } for (int i = 0; i < CHEATSPERPAGE; ++i) if (m_btnMgr.selected() == m_cheatBtnItem[i]) { // handling code for clicked cheat m_cheatfile.sCheatSelected[(m_cheatSettingsPage-1)*CHEATSPERPAGE + i] = !m_cheatfile.sCheatSelected[(m_cheatSettingsPage-1)*CHEATSPERPAGE + i]; _showCheatSettings(); } if (m_btnMgr.selected() == m_cheatBtnApply) { int operation_ok,check = 0; //checks if at least one cheat is selected for (unsigned int i=0; i < m_cheatfile.getCnt(); ++i) { if (m_cheatfile.sCheatSelected[i] == true) { check = 1; break; } } if (check) { operation_ok = m_cheatfile.createGCT(fmt("%s/%s.gct", m_cheatDir.c_str(), m_cf.getId().c_str())); operation_ok = m_cheatfile.createTXT(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str())); } m_cfg.setOptBool(m_cf.getId(), "cheat",1); if (operation_ok) break; } if (m_btnMgr.selected() == m_cheatBtnDownload) { // Download cheat code m_btnMgr.hide(m_cheatLblTitle); u32 bufferSize = 0x100000; // Maximum download size 1 MB SmartBuf buffer; block cheatfile; FILE *file; char ip[16]; if (!m_networkInit && _initNetwork(ip) < 0) { m_btnMgr.hide(m_cheatLblTitle); break; } m_networkInit = true; buffer = smartCoverAlloc(bufferSize); cheatfile = downloadfile(buffer.get(), bufferSize, sfmt(GECKOURL, m_cf.getId().c_str()).c_str(),CMenu::_downloadProgress, this); if (cheatfile.data != NULL && cheatfile.size > 65 && cheatfile.data[0] != '<') { // cheat file was downloaded and presumably no 404 file = fopen(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str()), "wb"); if (file != NULL) { fwrite(cheatfile.data, 1, cheatfile.size, file); fclose(file); break; } } else { // cheat code not found, show result m_btnMgr.setText(m_cheatLblItem[0], _t("cheat4", L"Download not found.")); m_btnMgr.setText(m_cheatLblItem[1], wfmt(L"http://www.geckocodes.org/codes/R/%s.txt",m_cf.getId().c_str())); m_btnMgr.show(m_cheatLblItem[1]); } } } _mainLoopCommon(wd); } _hideCheatSettings(); }