Commit 519a0c54 authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:Fluorohydride/ygopro

parents 59307bc2 0a8a4726
......@@ -197,7 +197,7 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) {
case CTOS_UPDATE_DECK: {
if(!dp->game)
return;
duel_mode->UpdateDeck(dp, pdata);
duel_mode->UpdateDeck(dp, pdata, len - 1);
break;
}
case CTOS_HAND_RESULT: {
......
......@@ -123,7 +123,7 @@ public:
virtual void ToObserver(DuelPlayer* dp) {}
virtual void PlayerReady(DuelPlayer* dp, bool is_ready) {}
virtual void PlayerKick(DuelPlayer* dp, unsigned char pos) {}
virtual void UpdateDeck(DuelPlayer* dp, void* pdata) {}
virtual void UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len) {}
virtual void StartDuel(DuelPlayer* dp) {}
virtual void HandResult(DuelPlayer* dp, unsigned char res) {}
virtual void TPResult(DuelPlayer* dp, unsigned char tp) {}
......
......@@ -282,12 +282,20 @@ void SingleDuel::PlayerKick(DuelPlayer* dp, unsigned char pos) {
return;
LeaveGame(players[pos]);
}
void SingleDuel::UpdateDeck(DuelPlayer* dp, void* pdata) {
void SingleDuel::UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len) {
if(dp->type > 1 || ready[dp->type])
return;
char* deckbuf = (char*)pdata;
int mainc = BufferIO::ReadInt32(deckbuf);
int sidec = BufferIO::ReadInt32(deckbuf);
// verify data
if((unsigned)mainc + (unsigned)sidec > (len - 8) / 4) {
STOC_ErrorMsg scem;
scem.msg = ERRMSG_DECKERROR;
scem.code = DECKERROR_MAINCOUNT << 28;
NetServer::SendPacketToPlayer(dp, STOC_ERROR_MSG, scem);
return;
}
if(duel_count == 0) {
deck_error[dp->type] = deckManager.LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec);
} else {
......
......@@ -18,7 +18,7 @@ public:
virtual void ToObserver(DuelPlayer* dp);
virtual void PlayerReady(DuelPlayer* dp, bool ready);
virtual void PlayerKick(DuelPlayer* dp, unsigned char pos);
virtual void UpdateDeck(DuelPlayer* dp, void* pdata);
virtual void UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len);
virtual void StartDuel(DuelPlayer* dp);
virtual void HandResult(DuelPlayer* dp, unsigned char res);
virtual void TPResult(DuelPlayer* dp, unsigned char tp);
......
......@@ -258,12 +258,20 @@ void TagDuel::PlayerKick(DuelPlayer* dp, unsigned char pos) {
return;
LeaveGame(players[pos]);
}
void TagDuel::UpdateDeck(DuelPlayer* dp, void* pdata) {
void TagDuel::UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len) {
if(dp->type > 3 || ready[dp->type])
return;
char* deckbuf = (char*)pdata;
int mainc = BufferIO::ReadInt32(deckbuf);
int sidec = BufferIO::ReadInt32(deckbuf);
// verify data
if((unsigned)mainc + (unsigned)sidec > (len - 8) / 4) {
STOC_ErrorMsg scem;
scem.msg = ERRMSG_DECKERROR;
scem.code = DECKERROR_MAINCOUNT << 28;
NetServer::SendPacketToPlayer(dp, STOC_ERROR_MSG, scem);
return;
}
deck_error[dp->type] = deckManager.LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec);
}
void TagDuel::StartDuel(DuelPlayer* dp) {
......
......@@ -18,7 +18,7 @@ public:
virtual void ToObserver(DuelPlayer* dp);
virtual void PlayerReady(DuelPlayer* dp, bool ready);
virtual void PlayerKick(DuelPlayer* dp, unsigned char pos);
virtual void UpdateDeck(DuelPlayer* dp, void* pdata);
virtual void UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len);
virtual void StartDuel(DuelPlayer* dp);
virtual void HandResult(DuelPlayer* dp, unsigned char res);
virtual void TPResult(DuelPlayer* dp, unsigned char tp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment