Commit 61972cb8 authored by nanahira's avatar nanahira

revert changes from duplicate

parent 3fe83039
...@@ -106,6 +106,4 @@ extern bool open_file; ...@@ -106,6 +106,4 @@ extern bool open_file;
extern wchar_t open_file_name[256]; extern wchar_t open_file_name[256];
extern bool bot_mode; extern bool bot_mode;
#define IMATATOR_CODE 4392470
#endif #endif
...@@ -118,7 +118,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r ...@@ -118,7 +118,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r
int code = cit->second.alias ? cit->second.alias : cit->first; int code = cit->second.alias ? cit->second.alias : cit->first;
ccount[code]++; ccount[code]++;
int dc = ccount[code]; int dc = ccount[code];
if(dc > 1) if(dc > 3)
return (DECKERROR_CARDCOUNT << 28) | cit->first; return (DECKERROR_CARDCOUNT << 28) | cit->first;
auto it = list.find(code); auto it = list.find(code);
if(it != list.end() && dc > it->second) if(it != list.end() && dc > it->second)
...@@ -133,7 +133,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r ...@@ -133,7 +133,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r
int code = cit->second.alias ? cit->second.alias : cit->first; int code = cit->second.alias ? cit->second.alias : cit->first;
ccount[code]++; ccount[code]++;
int dc = ccount[code]; int dc = ccount[code];
if(dc > 1) if(dc > 3)
return (DECKERROR_CARDCOUNT << 28) | cit->first; return (DECKERROR_CARDCOUNT << 28) | cit->first;
auto it = list.find(code); auto it = list.find(code);
if(it != list.end() && dc > it->second) if(it != list.end() && dc > it->second)
...@@ -148,7 +148,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r ...@@ -148,7 +148,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r
int code = cit->second.alias ? cit->second.alias : cit->first; int code = cit->second.alias ? cit->second.alias : cit->first;
ccount[code]++; ccount[code]++;
int dc = ccount[code]; int dc = ccount[code];
if(dc > 1) if(dc > 3)
return (DECKERROR_CARDCOUNT << 28) | cit->first; return (DECKERROR_CARDCOUNT << 28) | cit->first;
auto it = list.find(code); auto it = list.find(code);
if(it != list.end() && dc > it->second) if(it != list.end() && dc > it->second)
......
...@@ -7,21 +7,23 @@ ...@@ -7,21 +7,23 @@
#include "data_manager.h" #include "data_manager.h"
#ifndef YGOPRO_MAX_DECK #ifndef YGOPRO_MAX_DECK
#define YGOPRO_MAX_DECK 6 #define YGOPRO_MAX_DECK 60
#endif #endif
#ifndef YGOPRO_MIN_DECK #ifndef YGOPRO_MIN_DECK
#define YGOPRO_MIN_DECK 4 #define YGOPRO_MIN_DECK 40
#endif #endif
#ifndef YGOPRO_MAX_EXTRA #ifndef YGOPRO_MAX_EXTRA
#define YGOPRO_MAX_EXTRA 3 #define YGOPRO_MAX_EXTRA 15
#endif #endif
#ifndef YGOPRO_MAX_SIDE #ifndef YGOPRO_MAX_SIDE
#define YGOPRO_MAX_SIDE 3 #define YGOPRO_MAX_SIDE 15
#endif #endif
#define IMITATOR_CODE 4392470
namespace ygo { namespace ygo {
constexpr int DECK_MAX_SIZE = YGOPRO_MAX_DECK; constexpr int DECK_MAX_SIZE = YGOPRO_MAX_DECK;
constexpr int DECK_MIN_SIZE = YGOPRO_MIN_DECK; constexpr int DECK_MIN_SIZE = YGOPRO_MIN_DECK;
...@@ -80,20 +82,22 @@ public: ...@@ -80,20 +82,22 @@ public:
int SaveDeckToCode(Deck &deck, unsigned char *code); int SaveDeckToCode(Deck &deck, unsigned char *code);
#endif // YGOPRO_SERVER_MODE #endif // YGOPRO_SERVER_MODE
template <typename T>
std::vector<T> MutateVector(std::vector<T> vector, int32_t count) {
std::vector<T> result;
for(auto it : vector)
for(int32_t i = 0; i < count; ++i)
result.push_back(it);
return result;
}
Deck MutateDeck(Deck deck) { Deck MutateDeck(Deck deck) {
Deck result; Deck result;
result.main = MutateVector(deck.main, 10); uint32_t imitating_code = 0;
result.extra = MutateVector(deck.extra, 5); for(auto card : deck.main) {
result.side = MutateVector(deck.side, 5); auto use_card = card;
auto code = card->first;
if(code == IMITATOR_CODE) {
if(imitating_code)
use_card = dataManager.GetCodePointer(imitating_code);
} else
imitating_code = code;
result.main.push_back(use_card);
}
result.extra = deck.extra;
result.side = deck.side;
return result; return result;
} }
......
...@@ -469,18 +469,18 @@ void SingleDuel::StartDuel(DuelPlayer* dp) { ...@@ -469,18 +469,18 @@ void SingleDuel::StartDuel(DuelPlayer* dp) {
if (cit->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) if (cit->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK))
++extra_size[i]; ++extra_size[i];
} }
BufferIO::WriteInt16(pbuf, (short)pdeck[0].main.size() * 10); BufferIO::WriteInt16(pbuf, (short)pdeck[0].main.size());
BufferIO::WriteInt16(pbuf, extra_size[0] * 5); BufferIO::WriteInt16(pbuf, extra_size[0]);
BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[1].main.size() * 10); BufferIO::WriteInt16(pbuf, (short)pdeck[1].main.size());
BufferIO::WriteInt16(pbuf, extra_size[1] * 5); BufferIO::WriteInt16(pbuf, extra_size[1]);
BufferIO::WriteInt16(pbuf, (short)pdeck[1].side.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[1].side.size());
#else #else
BufferIO::WriteInt16(pbuf, (short)pdeck[0].main.size() * 10); BufferIO::WriteInt16(pbuf, (short)pdeck[0].main.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[0].extra.size() * 5); BufferIO::WriteInt16(pbuf, (short)pdeck[0].extra.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[1].main.size() * 10); BufferIO::WriteInt16(pbuf, (short)pdeck[1].main.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[1].extra.size() * 5); BufferIO::WriteInt16(pbuf, (short)pdeck[1].extra.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[1].side.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[1].side.size());
#endif #endif
NetServer::SendBufferToPlayer(players[0], STOC_DECK_COUNT, deckbuff, 12); NetServer::SendBufferToPlayer(players[0], STOC_DECK_COUNT, deckbuff, 12);
......
...@@ -438,18 +438,18 @@ void TagDuel::StartDuel(DuelPlayer* dp) { ...@@ -438,18 +438,18 @@ void TagDuel::StartDuel(DuelPlayer* dp) {
if (cit->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) if (cit->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK))
++extra_size[i]; ++extra_size[i];
} }
BufferIO::WriteInt16(pbuf, (short)pdeck[0].main.size() * 10); BufferIO::WriteInt16(pbuf, (short)pdeck[0].main.size());
BufferIO::WriteInt16(pbuf, extra_size[0] * 5); BufferIO::WriteInt16(pbuf, extra_size[0]);
BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[2].main.size() * 10); BufferIO::WriteInt16(pbuf, (short)pdeck[2].main.size());
BufferIO::WriteInt16(pbuf, extra_size[1] * 5); BufferIO::WriteInt16(pbuf, extra_size[1]);
BufferIO::WriteInt16(pbuf, (short)pdeck[2].side.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[2].side.size());
#else #else
BufferIO::WriteInt16(pbuf, (short)pdeck[0].main.size() * 10); BufferIO::WriteInt16(pbuf, (short)pdeck[0].main.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[0].extra.size() * 5); BufferIO::WriteInt16(pbuf, (short)pdeck[0].extra.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[2].main.size() * 10); BufferIO::WriteInt16(pbuf, (short)pdeck[2].main.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[2].extra.size() * 5); BufferIO::WriteInt16(pbuf, (short)pdeck[2].extra.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[2].side.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[2].side.size());
#endif #endif
NetServer::SendBufferToPlayer(players[0], STOC_DECK_COUNT, deckbuff, 12); NetServer::SendBufferToPlayer(players[0], STOC_DECK_COUNT, deckbuff, 12);
......
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