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) { ...@@ -197,7 +197,7 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) {
case CTOS_UPDATE_DECK: { case CTOS_UPDATE_DECK: {
if(!dp->game) if(!dp->game)
return; return;
duel_mode->UpdateDeck(dp, pdata); duel_mode->UpdateDeck(dp, pdata, len - 1);
break; break;
} }
case CTOS_HAND_RESULT: { case CTOS_HAND_RESULT: {
......
...@@ -123,7 +123,7 @@ public: ...@@ -123,7 +123,7 @@ public:
virtual void ToObserver(DuelPlayer* dp) {} virtual void ToObserver(DuelPlayer* dp) {}
virtual void PlayerReady(DuelPlayer* dp, bool is_ready) {} virtual void PlayerReady(DuelPlayer* dp, bool is_ready) {}
virtual void PlayerKick(DuelPlayer* dp, unsigned char pos) {} 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 StartDuel(DuelPlayer* dp) {}
virtual void HandResult(DuelPlayer* dp, unsigned char res) {} virtual void HandResult(DuelPlayer* dp, unsigned char res) {}
virtual void TPResult(DuelPlayer* dp, unsigned char tp) {} virtual void TPResult(DuelPlayer* dp, unsigned char tp) {}
......
...@@ -282,12 +282,20 @@ void SingleDuel::PlayerKick(DuelPlayer* dp, unsigned char pos) { ...@@ -282,12 +282,20 @@ void SingleDuel::PlayerKick(DuelPlayer* dp, unsigned char pos) {
return; return;
LeaveGame(players[pos]); 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]) if(dp->type > 1 || ready[dp->type])
return; return;
char* deckbuf = (char*)pdata; char* deckbuf = (char*)pdata;
int mainc = BufferIO::ReadInt32(deckbuf); int mainc = BufferIO::ReadInt32(deckbuf);
int sidec = 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) { if(duel_count == 0) {
deck_error[dp->type] = deckManager.LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec); deck_error[dp->type] = deckManager.LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec);
} else { } else {
......
...@@ -18,7 +18,7 @@ public: ...@@ -18,7 +18,7 @@ public:
virtual void ToObserver(DuelPlayer* dp); virtual void ToObserver(DuelPlayer* dp);
virtual void PlayerReady(DuelPlayer* dp, bool ready); virtual void PlayerReady(DuelPlayer* dp, bool ready);
virtual void PlayerKick(DuelPlayer* dp, unsigned char pos); 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 StartDuel(DuelPlayer* dp);
virtual void HandResult(DuelPlayer* dp, unsigned char res); virtual void HandResult(DuelPlayer* dp, unsigned char res);
virtual void TPResult(DuelPlayer* dp, unsigned char tp); virtual void TPResult(DuelPlayer* dp, unsigned char tp);
......
...@@ -258,12 +258,20 @@ void TagDuel::PlayerKick(DuelPlayer* dp, unsigned char pos) { ...@@ -258,12 +258,20 @@ void TagDuel::PlayerKick(DuelPlayer* dp, unsigned char pos) {
return; return;
LeaveGame(players[pos]); 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]) if(dp->type > 3 || ready[dp->type])
return; return;
char* deckbuf = (char*)pdata; char* deckbuf = (char*)pdata;
int mainc = BufferIO::ReadInt32(deckbuf); int mainc = BufferIO::ReadInt32(deckbuf);
int sidec = 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); deck_error[dp->type] = deckManager.LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec);
} }
void TagDuel::StartDuel(DuelPlayer* dp) { void TagDuel::StartDuel(DuelPlayer* dp) {
......
...@@ -18,7 +18,7 @@ public: ...@@ -18,7 +18,7 @@ public:
virtual void ToObserver(DuelPlayer* dp); virtual void ToObserver(DuelPlayer* dp);
virtual void PlayerReady(DuelPlayer* dp, bool ready); virtual void PlayerReady(DuelPlayer* dp, bool ready);
virtual void PlayerKick(DuelPlayer* dp, unsigned char pos); 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 StartDuel(DuelPlayer* dp);
virtual void HandResult(DuelPlayer* dp, unsigned char res); virtual void HandResult(DuelPlayer* dp, unsigned char res);
virtual void TPResult(DuelPlayer* dp, unsigned char tp); 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