Browse Source

Fix PtSendFriendInvite

Adam Johnson 10 years ago
parent
commit
0bcf45c6d5
  1. 2
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  2. 2
      Sources/Plasma/FeatureLib/pfPython/cyMisc.h
  3. 58
      Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp
  4. 4
      Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp
  5. 4
      Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h
  6. 27
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  7. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h

2
Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp

@ -2875,7 +2875,7 @@ void cyMisc::SetBehaviorNetFlags(pyKey & behKey, bool netForce, bool netProp)
} }
} }
void cyMisc::SendFriendInvite(const wchar_t email[], const wchar_t toName[]) void cyMisc::SendFriendInvite(const plString& email, const plString& toName)
{ {
if (hsRef<RelVaultNode> pNode = VaultGetPlayerNode()) if (hsRef<RelVaultNode> pNode = VaultGetPlayerNode())
{ {

2
Sources/Plasma/FeatureLib/pfPython/cyMisc.h

@ -952,7 +952,7 @@ public:
static plFileName GetInitPath(); static plFileName GetInitPath();
static void SetBehaviorNetFlags(pyKey & behKey, bool netForce, bool netProp); static void SetBehaviorNetFlags(pyKey & behKey, bool netForce, bool netProp);
static void SendFriendInvite(const wchar_t email[], const wchar_t toName[]); static void SendFriendInvite(const plString& email, const plString& toName);
static PyObject* PyGuidGenerate(); static PyObject* PyGuidGenerate();
static PyObject* GetAIAvatarsByModelName(const char* name); static PyObject* GetAIAvatarsByModelName(const char* name);
static void ForceVaultNodeUpdate(unsigned nodeId); static void ForceVaultNodeUpdate(unsigned nodeId);

58
Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp

@ -695,66 +695,26 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtSetBehaviorNetFlags, args, "Params: behKey, ne
PYTHON_GLOBAL_METHOD_DEFINITION(PtSendFriendInvite, args, "Params: emailAddress, toName = \"Friend\"\nSends an email with invite code") PYTHON_GLOBAL_METHOD_DEFINITION(PtSendFriendInvite, args, "Params: emailAddress, toName = \"Friend\"\nSends an email with invite code")
{ {
PyObject* emailObj; char* emailIn = nullptr;
PyObject* toNameObj = nil; char* nameIn = nullptr;
if (!PyArg_ParseTuple(args, "O|O", &emailObj, &toNameObj)) if (!PyArg_ParseTuple(args, "es|es", "utf8", &emailIn, "utf8", &nameIn))
{ {
PyErr_SetString(PyExc_TypeError, "PtSendFriendInvite expects a string and optionally another string"); PyErr_SetString(PyExc_TypeError, "PtSendFriendInvite expects a string and optionally another string");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
wchar_t emailAddr[kMaxEmailAddressLength]; plString email = emailIn;
memset(emailAddr, 0, sizeof(emailAddr)); plString name = nameIn ? nameIn : "Friend";
PyMem_Free(emailIn);
PyMem_Free(nameIn);
wchar_t toName[kMaxPlayerNameLength]; if (email.GetSize() >= kMaxEmailAddressLength)
memset(toName, 0, sizeof(toName));
// Check and see if the email address is ok
int origStrLen = 0;
if (PyUnicode_Check(emailObj))
{
origStrLen = PyUnicode_GET_SIZE(emailObj);
PyUnicode_AsWideChar((PyUnicodeObject*)emailObj, emailAddr, arrsize(emailAddr) - 1);
}
else if (PyString_Check(emailObj))
{
char* cAddr = PyString_AsString(emailObj);
origStrLen = StrLen(cAddr);
StrToUnicode(emailAddr, cAddr, arrsize(emailAddr));
}
else
{
PyErr_SetString(PyExc_TypeError, "PtSendFriendInvite expects a string and optionally another string");
PYTHON_RETURN_ERROR;
}
if (origStrLen >= kMaxEmailAddressLength)
{ {
PyErr_SetString(PyExc_TypeError, "PtSendFriendInvite: Email address too long"); PyErr_SetString(PyExc_TypeError, "PtSendFriendInvite: Email address too long");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
// Check if the "to name" field is ok cyMisc::SendFriendInvite(email, name);
if (toNameObj)
{
if (PyUnicode_Check(toNameObj))
{
origStrLen = PyUnicode_GET_SIZE(toNameObj);
PyUnicode_AsWideChar((PyUnicodeObject*)toNameObj, toName, arrsize(toName) - 1);
}
else if (PyString_Check(toNameObj))
{
char* cName = PyString_AsString(toNameObj);
origStrLen = StrLen(cName);
StrToUnicode(toName, cName, arrsize(toName));
}
else
StrCopy(toName, L"Friend", arrsize(toName));
}
else
StrCopy(toName, L"Friend", arrsize(toName));
cyMisc::SendFriendInvite(emailAddr, toName);
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
} }

4
Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp

@ -1325,8 +1325,8 @@ void NetCommSetCCRLevel (
//============================================================================ //============================================================================
void NetCommSendFriendInvite ( void NetCommSendFriendInvite (
const wchar_t emailAddress[], const plString& emailAddress,
const wchar_t toName[], const plString& toName,
const plUUID& inviteUuid const plUUID& inviteUuid
) { ) {
NetCliAuthSendFriendInvite( NetCliAuthSendFriendInvite(

4
Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h

@ -284,8 +284,8 @@ void NetCommSetCCRLevel (
unsigned ccrLevel unsigned ccrLevel
); );
void NetCommSendFriendInvite ( void NetCommSendFriendInvite (
const wchar_t emailAddress[], const plString& emailAddress,
const wchar_t toName[], const plString& toName,
const plUUID& inviteUuid const plUUID& inviteUuid
); );

27
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp

@ -943,13 +943,13 @@ struct SendFriendInviteTrans : NetAuthTrans {
void * m_param; void * m_param;
// send // send
wchar_t m_emailAddress[kMaxEmailAddressLength]; plString m_emailAddress;
wchar_t m_toName[kMaxPlayerNameLength]; plString m_toName;
plUUID m_inviteUuid; plUUID m_inviteUuid;
SendFriendInviteTrans( SendFriendInviteTrans(
const wchar_t emailAddr[], const plString& emailAddr,
const wchar_t toName[], const plString& toName,
const plUUID& inviteUuid, const plUUID& inviteUuid,
FNetCliAuthSendFriendInviteCallback callback, FNetCliAuthSendFriendInviteCallback callback,
void * param void * param
@ -4411,8 +4411,8 @@ bool ChangePlayerNameRequestTrans::Recv (
//============================================================================ //============================================================================
SendFriendInviteTrans::SendFriendInviteTrans ( SendFriendInviteTrans::SendFriendInviteTrans (
const wchar_t emailAddr[], const plString& emailAddr,
const wchar_t toName[], const plString& toName,
const plUUID& inviteUuid, const plUUID& inviteUuid,
FNetCliAuthSendFriendInviteCallback callback, FNetCliAuthSendFriendInviteCallback callback,
void * param void * param
@ -4420,9 +4420,9 @@ SendFriendInviteTrans::SendFriendInviteTrans (
, m_callback(callback) , m_callback(callback)
, m_param(param) , m_param(param)
, m_inviteUuid(inviteUuid) , m_inviteUuid(inviteUuid)
, m_toName(toName)
, m_emailAddress(emailAddr)
{ {
StrCopy(m_emailAddress, emailAddr, arrsize(m_emailAddress));
StrCopy(m_toName, toName, arrsize(m_toName));
} }
//============================================================================ //============================================================================
@ -4430,12 +4430,15 @@ bool SendFriendInviteTrans::Send () {
if (!AcquireConn()) if (!AcquireConn())
return false; return false;
plStringBuffer<uint16_t> emailAddress = m_emailAddress.ToUtf16();
plStringBuffer<uint16_t> toName = m_toName.ToUtf16();
const uintptr_t msg[] = { const uintptr_t msg[] = {
kCli2Auth_SendFriendInviteRequest, kCli2Auth_SendFriendInviteRequest,
m_transId, m_transId,
(uintptr_t) &m_inviteUuid, (uintptr_t) &m_inviteUuid,
(uintptr_t) m_emailAddress, (uintptr_t) emailAddress.GetData(),
(uintptr_t) m_toName, (uintptr_t) toName.GetData(),
}; };
m_conn->Send(msg, arrsize(msg)); m_conn->Send(msg, arrsize(msg));
@ -5902,8 +5905,8 @@ void NetCliAuthChangePlayerNameRequest (
//============================================================================ //============================================================================
void NetCliAuthSendFriendInvite ( void NetCliAuthSendFriendInvite (
const wchar_t emailAddress[], const plString& emailAddress,
const wchar_t toName[], const plString& toName,
const plUUID& inviteUuid, const plUUID& inviteUuid,
FNetCliAuthSendFriendInviteCallback callback, FNetCliAuthSendFriendInviteCallback callback,
void * param void * param

4
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h

@ -587,8 +587,8 @@ typedef void (*FNetCliAuthSendFriendInviteCallback)(
); );
void NetCliAuthSendFriendInvite ( void NetCliAuthSendFriendInvite (
const wchar_t emailAddress[], const plString& emailAddress,
const wchar_t toName[], const plString& toName,
const plUUID& inviteUuid, const plUUID& inviteUuid,
FNetCliAuthSendFriendInviteCallback callback, FNetCliAuthSendFriendInviteCallback callback,
void * param void * param

Loading…
Cancel
Save