Adds adhoc support notes on readme, and option to load server address from config

This commit is contained in:
Igor Calabria 2013-10-30 00:18:06 +00:00
parent 0bc7dee02c
commit 2c484c9bee
4 changed files with 44 additions and 13 deletions

View file

@ -255,6 +255,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
pspConfig->Get("NickName", &sNickName, "PPSSPP"); pspConfig->Get("NickName", &sNickName, "PPSSPP");
pspConfig->Get("proAdhocServer", &proAdhocServer, "localhost");
pspConfig->Get("Language", &iLanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH); pspConfig->Get("Language", &iLanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
pspConfig->Get("TimeFormat", &iTimeFormat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR); pspConfig->Get("TimeFormat", &iTimeFormat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR);
pspConfig->Get("DateFormat", &iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD); pspConfig->Get("DateFormat", &iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD);
@ -451,6 +452,7 @@ void Config::Save() {
IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
pspConfig->Set("NickName", sNickName.c_str()); pspConfig->Set("NickName", sNickName.c_str());
pspConfig->Set("proAdhocServer", proAdhocServer.c_str());
pspConfig->Set("Language", iLanguage); pspConfig->Set("Language", iLanguage);
pspConfig->Set("TimeFormat", iTimeFormat); pspConfig->Set("TimeFormat", iTimeFormat);
pspConfig->Set("DateFormat", iDateFormat); pspConfig->Set("DateFormat", iDateFormat);

View file

@ -184,6 +184,7 @@ public:
// SystemParam // SystemParam
std::string sNickName; std::string sNickName;
std::string proAdhocServer;
int iLanguage; int iLanguage;
int iTimeFormat; int iTimeFormat;
int iDateFormat; int iDateFormat;

View file

@ -39,10 +39,11 @@
#else #else
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <time.h> #include <time.h>
#include <fcntl.h> #include <fcntl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h> #include <errno.h>
#endif #endif
#include <mutex> #include <mutex>
@ -660,33 +661,39 @@ int __init_network(SceNetAdhocctlAdhocId *adhoc_id){
WSADATA data; WSADATA data;
iResult = WSAStartup(MAKEWORD(2,2),&data); iResult = WSAStartup(MAKEWORD(2,2),&data);
if(iResult != NOERROR){ if(iResult != NOERROR){
printf("Wsa failed with error %d\n",iResult); ERROR_LOG(SCENET, "Wsa failed");
return iResult; return iResult;
} }
#endif #endif
metasocket = INVALID_SOCKET; metasocket = INVALID_SOCKET;
metasocket = socket(AF_INET,SOCK_STREAM, IPPROTO_TCP); metasocket = socket(AF_INET,SOCK_STREAM, IPPROTO_TCP);
if(metasocket == INVALID_SOCKET){ if(metasocket == INVALID_SOCKET){
printf("invalid socket"); ERROR_LOG(SCENET,"invalid socket");
return INVALID_SOCKET; return INVALID_SOCKET;
} }
struct sockaddr_in server_addr; struct sockaddr_in server_addr;
server_addr.sin_family = AF_INET; server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(27312); server_addr.sin_port = htons(27312); // Maybe read this from config too
server_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
iResult = connect(metasocket,(sockaddr *)&server_addr,sizeof(server_addr));
if(iResult == SOCKET_ERROR){ // Resolve dns
printf("Socket error %d", iResult); 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){
ERROR_LOG(SCENET,"Socket error");
return iResult; return iResult;
} }
memset(&parameter,0,sizeof(parameter)); memset(&parameter,0,sizeof(parameter));
strcpy((char *)&parameter.nickname.data, g_Config.sNickName.c_str()); strcpy((char *)&parameter.nickname.data, g_Config.sNickName.c_str());
parameter.channel = 1; // Fake Channel 1 parameter.channel = 1; // Fake Channel 1
// Prepare Login Packet
__getLocalMac(&parameter.bssid.mac_addr); __getLocalMac(&parameter.bssid.mac_addr);
SceNetAdhocctlLoginPacketC2S packet; SceNetAdhocctlLoginPacketC2S packet;
packet.base.opcode = OPCODE_LOGIN; packet.base.opcode = OPCODE_LOGIN;
SceNetEtherAddr addres; SceNetEtherAddr addres;

View file

@ -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 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: Official website:
http://www.ppsspp.org/ 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). For the latest source code, see [our github page](https://github.com/hrydgard/ppsspp).