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. 31
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  7. 6
      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())
{

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

@ -952,7 +952,7 @@ public:
static plFileName GetInitPath();
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* GetAIAvatarsByModelName(const char* name);
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")
{
PyObject* emailObj;
PyObject* toNameObj = nil;
if (!PyArg_ParseTuple(args, "O|O", &emailObj, &toNameObj))
char* emailIn = nullptr;
char* nameIn = nullptr;
if (!PyArg_ParseTuple(args, "es|es", "utf8", &emailIn, "utf8", &nameIn))
{
PyErr_SetString(PyExc_TypeError, "PtSendFriendInvite expects a string and optionally another string");
PYTHON_RETURN_ERROR;
}
wchar_t emailAddr[kMaxEmailAddressLength];
memset(emailAddr, 0, sizeof(emailAddr));
plString email = emailIn;
plString name = nameIn ? nameIn : "Friend";
PyMem_Free(emailIn);
PyMem_Free(nameIn);
wchar_t toName[kMaxPlayerNameLength];
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)
if (email.GetSize() >= kMaxEmailAddressLength)
{
PyErr_SetString(PyExc_TypeError, "PtSendFriendInvite: Email address too long");
PYTHON_RETURN_ERROR;
}
// Check if the "to name" field is ok
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);
cyMisc::SendFriendInvite(email, name);
PYTHON_RETURN_NONE;
}

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

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

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

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

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

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

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

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

Loading…
Cancel
Save