From 2c484c9bee71d3fa0f54f6000f73bd406bf81c9d Mon Sep 17 00:00:00 2001 From: Igor Calabria Date: Wed, 30 Oct 2013 00:18:06 +0000 Subject: [PATCH] Adds adhoc support notes on readme, and option to load server address from config --- Core/Config.cpp | 2 ++ Core/Config.h | 1 + Core/HLE/sceNetAdhoc.cpp | 29 ++++++++++++++++++----------- README.md | 23 ++++++++++++++++++++++- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 80ae8d41b0..13c905c309 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -255,6 +255,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); pspConfig->Get("NickName", &sNickName, "PPSSPP"); + pspConfig->Get("proAdhocServer", &proAdhocServer, "localhost"); pspConfig->Get("Language", &iLanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH); pspConfig->Get("TimeFormat", &iTimeFormat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR); pspConfig->Get("DateFormat", &iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD); @@ -451,6 +452,7 @@ void Config::Save() { IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); pspConfig->Set("NickName", sNickName.c_str()); + pspConfig->Set("proAdhocServer", proAdhocServer.c_str()); pspConfig->Set("Language", iLanguage); pspConfig->Set("TimeFormat", iTimeFormat); pspConfig->Set("DateFormat", iDateFormat); diff --git a/Core/Config.h b/Core/Config.h index 61163f596f..f9731f5641 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -184,6 +184,7 @@ public: // SystemParam std::string sNickName; + std::string proAdhocServer; int iLanguage; int iTimeFormat; int iDateFormat; diff --git a/Core/HLE/sceNetAdhoc.cpp b/Core/HLE/sceNetAdhoc.cpp index 577eeb6a6d..55900a12ab 100644 --- a/Core/HLE/sceNetAdhoc.cpp +++ b/Core/HLE/sceNetAdhoc.cpp @@ -39,10 +39,11 @@ #else #include #include +#include +#include +#include #include #include -#include -#include #include #endif #include @@ -660,33 +661,39 @@ int __init_network(SceNetAdhocctlAdhocId *adhoc_id){ WSADATA data; iResult = WSAStartup(MAKEWORD(2,2),&data); if(iResult != NOERROR){ - printf("Wsa failed with error %d\n",iResult); + ERROR_LOG(SCENET, "Wsa failed"); return iResult; } #endif metasocket = INVALID_SOCKET; metasocket = socket(AF_INET,SOCK_STREAM, IPPROTO_TCP); if(metasocket == INVALID_SOCKET){ - printf("invalid socket"); + ERROR_LOG(SCENET,"invalid socket"); return INVALID_SOCKET; } struct sockaddr_in server_addr; server_addr.sin_family = AF_INET; - server_addr.sin_port = htons(27312); - server_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); - iResult = connect(metasocket,(sockaddr *)&server_addr,sizeof(server_addr)); + server_addr.sin_port = htons(27312); // Maybe read this from config too + // Resolve dns + addrinfo * resultAddr; + iResult = getaddrinfo(g_Config.proAdhocServer.c_str(),0,NULL,&resultAddr); + if(iResult != 0){ + printf("Dns error\n"); + return iResult; + } + server_addr.sin_addr.s_addr = ((sockaddr_in *)resultAddr->ai_addr)->sin_addr.s_addr; + iResult = connect(metasocket,(sockaddr *)&server_addr,sizeof(server_addr)); if(iResult == SOCKET_ERROR){ - printf("Socket error %d", iResult); + ERROR_LOG(SCENET,"Socket error"); return iResult; } - memset(¶meter,0,sizeof(parameter)); strcpy((char *)¶meter.nickname.data, g_Config.sNickName.c_str()); parameter.channel = 1; // Fake Channel 1 + + // Prepare Login Packet __getLocalMac(¶meter.bssid.mac_addr); - - SceNetAdhocctlLoginPacketC2S packet; packet.base.opcode = OPCODE_LOGIN; SceNetEtherAddr addres; diff --git a/README.md b/README.md index b8b61e8815..dca4055f21 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,24 @@ +ADHOC SUPPORT +============= +This is based on coldbird code: http://code.google.com/p/aemu/ All Credit goes +to him! + +Status +------ +Code is a complete mess and it's not fully functional yet, I still need to implement +some functions and add a upnp lib(really important for people with routers). + +I did test it with some games(emulator <-> real psp with the server running locally) +and it's looking good: +* Worms Open Warfare: Ran just fine, I was able to play a whole match without problems +* Monster Hunter Freedom Unite: Runs fine too. Gathering Hall and embarking on quests Works +* Dissidia Duodecim 012: Doesn't work. It requires some functions that I haven't implemented +yet. Also, it uses a port < 1000 and thats reserved for admin apps on linux, running the emu +as sudo "solves" it, but it's far from ideal. +* Pacman World Rally: Works too. + +Oh, and it probably only compiles on linux for now. + PPSSPP - a fast and portable PSP emulator ========================================= @@ -8,7 +29,7 @@ Originally released under the GPL 2.0 (and later) in November 2012 Official website: http://www.ppsspp.org/ -To contribute, see [the development page](http://www.ppsspp.org/development.html). +To contribute, see [the development page](http://www.ppspp.org/development.html). For the latest source code, see [our github page](https://github.com/hrydgard/ppsspp).