aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Orbis/Orbis_PlayerUID.h
blob: 422a23348c103e0aff5a8283a1faa7e2f71ff7b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once


// Note - there are now 3 types of PlayerUID
// (1) A full online ID - either the primary login, or a sub-signin through to PSN. This has m_onlineID set up as a normal SceNpOnlineId, with dummy[0] set to 0
// (2) An offline ID, where there is also a primary login on the system. This has m_onlineID set up to copy the primary SceNpOnlineId, except with dummy[0] set to the controller ID of this other player
// (3) An offline ID, where there isn't a primary PSN login on the system. This has SceNpOnlineId fully zeroed.


class PlayerUID
{
	char m_onlineID[SCE_NP_ONLINEID_MAX_LENGTH];
	char term;
	bool m_bSignedIntoPSN : 1;
	unsigned char m_quadrant : 2;
	uint8_t m_macAddress[SCE_NET_ETHER_ADDR_LEN];
	SceUserServiceUserId m_userID;

public:

	class Hash 
	{
	public:		
		std::size_t operator()(const PlayerUID& k) const;
	};

	PlayerUID();
	PlayerUID(SceUserServiceUserId userID, SceNpOnlineId& onlineID, bool bSignedInPSN, int quadrant);
	PlayerUID(std::wstring fromString);

	bool operator==(const PlayerUID& rhs) const;
	bool operator!=(const PlayerUID& rhs);
	void setCurrentMacAddress();
	std::wstring macAddressStr() const;
	std::wstring userIDStr() const;
	std::wstring toString() const;
	void setOnlineID(SceNpOnlineId& id, bool bSignedIntoPSN);
	void setUserID(unsigned int id);


	const char*			getOnlineID() const		{ return m_onlineID; }
	SceUserServiceUserId getUserID() const		{ return m_userID; }
	int					getQuadrant() const		{ return m_quadrant;  }
	bool				isPrimaryUser() const;	// only true if we're on the local machine and signed into the first quadrant;
	bool				isSignedIntoPSN() const	{ return m_bSignedIntoPSN; }
private:
};

namespace std 
{
	template <> 
	struct hash<PlayerUID> 
	{
		size_t operator()(const PlayerUID& v) const
		{
			return PlayerUID::Hash()(v);///* my hash algorithm */;
			
		}
	};
}




class GameSessionUID
{
	char m_onlineID[SCE_NP_ONLINEID_MAX_LENGTH];
	char term;
	bool m_bSignedIntoPSN : 1;
	unsigned char m_quadrant : 2;
public:
	GameSessionUID();
	GameSessionUID(int nullVal);

	bool operator==(const GameSessionUID& rhs) const;
	bool operator!=(const GameSessionUID& rhs);
	GameSessionUID& operator=(const PlayerUID& rhs);

	const char*			getOnlineID() const		{ return m_onlineID; }
	int					getQuadrant() const		{ return m_quadrant;  }
	bool				isSignedIntoPSN() const	{ return m_bSignedIntoPSN; }
};