Phantasy Star Portable 2 port offset fix

This commit is contained in:
Ade Novan 2016-11-22 19:57:11 +08:00
parent 01481da449
commit 55de66b5ef
2 changed files with 6 additions and 1 deletions

View File

@ -54,6 +54,7 @@ std::thread friendFinderThread;
recursive_mutex peerlock;
SceNetAdhocPdpStat * pdp[255];
SceNetAdhocPtpStat * ptp[255];
uint32_t localip;
int isLocalMAC(const SceNetEtherAddr * addr) {
SceNetEtherAddr saddr;
@ -1302,7 +1303,7 @@ int getLocalIp(sockaddr_in * SocketAddress){
}
return -1;
#else
SocketAddress->sin_addr.s_addr = inet_addr("192.168.12.1");
memcpy(&SocketAddress->sin_addr, &localip, sizeof(uint32_t));
return 0;
#endif
}
@ -1445,6 +1446,8 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
host->NotifyUserMessage(buffer, 8.0f);
return iResult;
}
//grab local ip for later use better than constant ip on non windows platform
localip = getLocalIp(metasocket);
// Prepare Login Packet
SceNetAdhocctlLoginPacketC2S packet;

View File

@ -1640,6 +1640,8 @@ static int sceNetAdhocPtpOpen(const char *srcmac, int sport, const char *dstmac,
// Valid Ports
if (!isPTPPortInUse(sport) /*&& dport != 0*/) {
//sport 0 should be shifted back to 0 when using offset Phantasy Star Portable 2 use this
if (sport == 0) sport = -(int)portOffset;
// Valid Arguments
if (bufsize > 0 && rexmt_int > 0 && rexmt_cnt > 0) {
// Create Infrastructure Socket