Browse Source

Convert score creation to plString

Adam Johnson 10 years ago
parent
commit
31076d65f9
  1. 20
      Sources/Plasma/FeatureLib/pfGameScoreMgr/pfGameScoreMgr.cpp
  2. 8
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp
  3. 4
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h
  4. 62
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  5. 22
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h

20
Sources/Plasma/FeatureLib/pfGameScoreMgr/pfGameScoreMgr.cpp

@ -133,14 +133,14 @@ void pfGameScore::TransferPoints(pfGameScore* to, int32_t points, plKey recvr)
//======================================
static void OnScoreCreate(
ENetError result,
void * param,
uint32_t scoreId,
uint32_t createdTime, // ignored
uint32_t ownerId,
const char* gameName,
uint32_t gameType,
int32_t value
ENetError result,
void * param,
uint32_t scoreId,
uint32_t createdTime, // ignored
uint32_t ownerId,
const plString& gameName,
uint32_t gameType,
int32_t value
) {
ScoreUpdateParam* p = (ScoreUpdateParam*)param;
pfGameScore* score = new pfGameScore(scoreId, ownerId, gameName, gameType, value);
@ -151,7 +151,7 @@ static void OnScoreCreate(
void pfGameScore::Create(uint32_t ownerId, const plString& name, uint32_t type, int32_t value, plKey rcvr)
{
NetCliAuthScoreCreate(ownerId, name.c_str(), type, value, OnScoreCreate, new ScoreUpdateParam(nil, rcvr));
NetCliAuthScoreCreate(ownerId, name, type, value, OnScoreCreate, new ScoreUpdateParam(nil, rcvr));
}
//======================================
@ -165,7 +165,7 @@ static void OnScoreFound(
for (uint32_t i = 0; i < scoreCount; ++i)
{
const NetGameScore ngs = scores[i];
vec[i] = new pfGameScore(ngs.scoreId, ngs.ownerId, plString::FromWchar(ngs.gameName), ngs.gameType, ngs.value);
vec[i] = new pfGameScore(ngs.scoreId, ngs.ownerId, ngs.gameName, ngs.gameType, ngs.value);
}
ScoreFindParam* p = (ScoreFindParam*)param;

8
Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp

@ -207,8 +207,8 @@ unsigned NetGameScore::Read(const uint8_t inbuffer[], unsigned bufsz, uint8_t**
IReadValue(&value, &buffer, &bufsz);
IReadString(&tempstr, &buffer, &bufsz);
StrCopy(gameName, tempstr, arrsize(gameName));
delete tempstr;
gameName = plString::FromWchar(tempstr);
free(tempstr);
if (end)
*end = buffer;
@ -226,7 +226,7 @@ unsigned NetGameScore::Write(ARRAY(uint8_t) * buffer) const {
IWriteValue(createdTime, buffer);
IWriteValue(gameType, buffer);
IWriteValue(value, buffer);
IWriteString(gameName, buffer);
IWriteString(gameName.ToWchar().GetData(), buffer);
return buffer->Count() - pos;
}
@ -238,7 +238,7 @@ void NetGameScore::CopyFrom(const NetGameScore & score) {
createdTime = score.createdTime;
gameType = score.gameType;
value = score.value;
StrCopy(gameName, score.gameName, arrsize(gameName));
gameName = score.gameName;
}
/*****************************************************************************

4
Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h

@ -119,8 +119,8 @@ struct NetAgeInfo {
struct NetGameScore {
unsigned scoreId;
unsigned ownerId;
uint32_t createdTime;
wchar_t gameName[kMaxGameScoreNameLength];
uint32_t createdTime;
plString gameName;
unsigned gameType;
int value;

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

@ -982,17 +982,17 @@ struct ScoreCreateTrans : NetAuthTrans {
// send
unsigned m_ownerId;
char m_gameName[kMaxGameScoreNameLength];
plString m_gameName;
unsigned m_gameType;
int m_value;
// recv
unsigned m_scoreId;
uint32_t m_createdTime;
uint32_t m_createdTime;
ScoreCreateTrans (
unsigned ownerId,
const char* gameName,
const plString& gameName,
unsigned gameType,
int value,
FNetCliAuthCreateScoreCallback callback,
@ -1038,9 +1038,9 @@ struct ScoreGetScoresTrans : NetAuthTrans {
FNetCliAuthGetScoresCallback m_callback;
void * m_param;
// send
// send
unsigned m_ownerId;
char m_gameName[kMaxGameScoreNameLength];
plString m_gameName;
// recv
NetGameScore * m_scores;
@ -1048,7 +1048,7 @@ struct ScoreGetScoresTrans : NetAuthTrans {
ScoreGetScoresTrans (
unsigned ownerId,
const char* gameName,
const plString& gameName,
FNetCliAuthGetScoresCallback callback,
void * param
);
@ -1150,11 +1150,11 @@ struct ScoreGetRanksTrans : NetAuthTrans {
FNetCliAuthGetRanksCallback m_callback;
void * m_param;
// send
// send
unsigned m_ownerId;
unsigned m_scoreGroup;
unsigned m_parentFolderId;
wchar_t m_gameName[kMaxGameScoreNameLength];
plString m_gameName;
unsigned m_timePeriod;
unsigned m_numResults;
unsigned m_pageNumber;
@ -1168,7 +1168,7 @@ struct ScoreGetRanksTrans : NetAuthTrans {
unsigned ownerId,
unsigned scoreGroup,
unsigned parentFolderId,
const char * cGameName,
const plString& gameName,
unsigned timePeriod,
unsigned numResults,
unsigned pageNumber,
@ -4494,7 +4494,7 @@ void AuthConnectedNotifyTrans::Post() {
//============================================================================
ScoreCreateTrans::ScoreCreateTrans (
unsigned ownerId,
const char* gameName,
const plString& gameName,
unsigned gameType,
int value,
FNetCliAuthCreateScoreCallback callback,
@ -4503,12 +4503,12 @@ ScoreCreateTrans::ScoreCreateTrans (
, m_callback(callback)
, m_param(param)
, m_ownerId(ownerId)
, m_gameName(gameName)
, m_gameType(gameType)
, m_value(value)
, m_scoreId(0)
, m_createdTime(0)
{
StrCopy(m_gameName, gameName, arrsize(m_gameName));
}
//============================================================================
@ -4516,16 +4516,15 @@ bool ScoreCreateTrans::Send () {
if (!AcquireConn())
return false;
wchar_t wgameName[kMaxGameScoreNameLength];
StrToUnicode(wgameName, m_gameName, arrsize(wgameName));
plStringBuffer<uint16_t> gameName = m_gameName.ToUtf16();
const uintptr_t msg[] = {
kCli2Auth_ScoreCreate,
kCli2Auth_ScoreCreate,
m_transId,
m_ownerId,
(uintptr_t) wgameName,
(uintptr_t) gameName.GetData(),
m_gameType,
(uintptr_t)m_value
(uintptr_t) m_value
};
m_conn->Send(msg, arrsize(msg));
@ -4629,17 +4628,17 @@ bool ScoreDeleteTrans::Recv (
//============================================================================
ScoreGetScoresTrans::ScoreGetScoresTrans (
unsigned ownerId,
const char* gameName,
const plString& gameName,
FNetCliAuthGetScoresCallback callback,
void * param
) : NetAuthTrans(kScoreGetScoresTrans)
, m_callback(callback)
, m_param(param)
, m_ownerId(ownerId)
, m_scores(nil)
, m_gameName(gameName)
, m_scores(nullptr)
, m_scoreCount(0)
{
StrCopy(m_gameName, gameName, arrsize(m_gameName));
}
//============================================================================
@ -4652,14 +4651,13 @@ bool ScoreGetScoresTrans::Send () {
if (!AcquireConn())
return false;
wchar_t wgameName[kMaxGameScoreNameLength];
StrToUnicode(wgameName, m_gameName, arrsize(wgameName));
plStringBuffer<uint16_t> gameName = m_gameName.ToUtf16();
const uintptr_t msg[] = {
kCli2Auth_ScoreGetScores,
m_transId,
m_ownerId,
(uintptr_t) wgameName
kCli2Auth_ScoreGetScores,
m_transId,
m_ownerId,
(uintptr_t) gameName.GetData()
};
m_conn->Send(msg, arrsize(msg));
@ -4899,7 +4897,7 @@ ScoreGetRanksTrans::ScoreGetRanksTrans (
unsigned ownerId,
unsigned scoreGroup,
unsigned parentFolderId,
const char * cGameName,
const plString& gameName,
unsigned timePeriod,
unsigned numResults,
unsigned pageNumber,
@ -4912,12 +4910,12 @@ ScoreGetRanksTrans::ScoreGetRanksTrans (
, m_ownerId(ownerId)
, m_scoreGroup(scoreGroup)
, m_parentFolderId(parentFolderId)
, m_gameName(gameName)
, m_timePeriod(timePeriod)
, m_numResults(numResults)
, m_pageNumber(pageNumber)
, m_sortDesc(sortDesc)
{
StrToUnicode(m_gameName, cGameName, arrsize(m_gameName));
}
//============================================================================
@ -4925,13 +4923,15 @@ bool ScoreGetRanksTrans::Send () {
if (!AcquireConn())
return false;
plStringBuffer<uint16_t> gameName = m_gameName.ToUtf16();
const uintptr_t msg[] = {
kCli2Auth_ScoreGetRanks,
m_transId,
m_ownerId,
m_scoreGroup,
m_parentFolderId,
(uintptr_t) m_gameName,
(uintptr_t) gameName.GetData(),
m_timePeriod,
m_numResults,
m_pageNumber,
@ -5929,7 +5929,7 @@ void NetCliAuthSendFriendInvite (
//============================================================================
void NetCliAuthScoreCreate (
unsigned ownerId,
const char* gameName,
const plString& gameName,
unsigned gameType,
int value,
FNetCliAuthCreateScoreCallback callback,
@ -5963,7 +5963,7 @@ void NetCliAuthScoreDelete(
//============================================================================
void NetCliAuthScoreGetScores(
unsigned ownerId,
const char* gameName,
const plString& gameName,
FNetCliAuthGetScoresCallback callback,
void * param
) {
@ -6031,7 +6031,7 @@ void NetCliAuthScoreGetRankList(
unsigned ownerId,
unsigned scoreGroup,
unsigned parentFolderId,
const char * gameName,
const plString& gameName,
unsigned timePeriod,
unsigned numResults,
unsigned pageNumber,

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

@ -629,18 +629,18 @@ typedef void (*FNetCliAuthScoreUpdateCallback)(
//============================================================================
typedef void (*FNetCliAuthCreateScoreCallback)(
ENetError result,
void * param,
unsigned scoreId,
uint32_t createdTime,
unsigned ownerId,
const char* gameName,
unsigned gameType,
int value
ENetError result,
void * param,
unsigned scoreId,
uint32_t createdTime,
unsigned ownerId,
const plString& gameName,
unsigned gameType,
int value
);
void NetCliAuthScoreCreate(
unsigned ownerId,
const char* gameName,
const plString& gameName,
unsigned gameType,
int value,
FNetCliAuthCreateScoreCallback callback,
@ -664,7 +664,7 @@ typedef void (*FNetCliAuthGetScoresCallback)(
void NetCliAuthScoreGetScores(
unsigned ownerId,
const char* gameName,
const plString& gameName,
FNetCliAuthGetScoresCallback callback,
void * param
);
@ -707,7 +707,7 @@ void NetCliAuthScoreGetRankList(
unsigned ownerId,
unsigned scoreGroup,
unsigned parentFolderId,
const char * gameName,
const plString& gameName,
unsigned timePeriod,
unsigned numResults,
unsigned pageNumber,

Loading…
Cancel
Save