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( static void OnScoreCreate(
ENetError result, ENetError result,
void * param, void * param,
uint32_t scoreId, uint32_t scoreId,
uint32_t createdTime, // ignored uint32_t createdTime, // ignored
uint32_t ownerId, uint32_t ownerId,
const char* gameName, const plString& gameName,
uint32_t gameType, uint32_t gameType,
int32_t value int32_t value
) { ) {
ScoreUpdateParam* p = (ScoreUpdateParam*)param; ScoreUpdateParam* p = (ScoreUpdateParam*)param;
pfGameScore* score = new pfGameScore(scoreId, ownerId, gameName, gameType, value); 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) 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) for (uint32_t i = 0; i < scoreCount; ++i)
{ {
const NetGameScore ngs = scores[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; 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); IReadValue(&value, &buffer, &bufsz);
IReadString(&tempstr, &buffer, &bufsz); IReadString(&tempstr, &buffer, &bufsz);
StrCopy(gameName, tempstr, arrsize(gameName)); gameName = plString::FromWchar(tempstr);
delete tempstr; free(tempstr);
if (end) if (end)
*end = buffer; *end = buffer;
@ -226,7 +226,7 @@ unsigned NetGameScore::Write(ARRAY(uint8_t) * buffer) const {
IWriteValue(createdTime, buffer); IWriteValue(createdTime, buffer);
IWriteValue(gameType, buffer); IWriteValue(gameType, buffer);
IWriteValue(value, buffer); IWriteValue(value, buffer);
IWriteString(gameName, buffer); IWriteString(gameName.ToWchar().GetData(), buffer);
return buffer->Count() - pos; return buffer->Count() - pos;
} }
@ -238,7 +238,7 @@ void NetGameScore::CopyFrom(const NetGameScore & score) {
createdTime = score.createdTime; createdTime = score.createdTime;
gameType = score.gameType; gameType = score.gameType;
value = score.value; 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 { struct NetGameScore {
unsigned scoreId; unsigned scoreId;
unsigned ownerId; unsigned ownerId;
uint32_t createdTime; uint32_t createdTime;
wchar_t gameName[kMaxGameScoreNameLength]; plString gameName;
unsigned gameType; unsigned gameType;
int value; int value;

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

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

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

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

Loading…
Cancel
Save