Commit c9fd3d91 authored by nanahira's avatar nanahira

Merge branch 'duplicate' into imitator

parents cf869554 348ecc21
...@@ -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 > 3) if(dc > 1)
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 > 3) if(dc > 1)
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 > 3) if(dc > 1)
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,19 +7,19 @@ ...@@ -7,19 +7,19 @@
#include "data_manager.h" #include "data_manager.h"
#ifndef YGOPRO_MAX_DECK #ifndef YGOPRO_MAX_DECK
#define YGOPRO_MAX_DECK 60 #define YGOPRO_MAX_DECK 6
#endif #endif
#ifndef YGOPRO_MIN_DECK #ifndef YGOPRO_MIN_DECK
#define YGOPRO_MIN_DECK 40 #define YGOPRO_MIN_DECK 4
#endif #endif
#ifndef YGOPRO_MAX_EXTRA #ifndef YGOPRO_MAX_EXTRA
#define YGOPRO_MAX_EXTRA 15 #define YGOPRO_MAX_EXTRA 3
#endif #endif
#ifndef YGOPRO_MAX_SIDE #ifndef YGOPRO_MAX_SIDE
#define YGOPRO_MAX_SIDE 15 #define YGOPRO_MAX_SIDE 3
#endif #endif
namespace ygo { namespace ygo {
...@@ -80,6 +80,28 @@ public: ...@@ -80,6 +80,28 @@ 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 result;
result.main = MutateVector(deck.main, 10);
result.extra = MutateVector(deck.extra, 5);
result.side = MutateVector(deck.side, 5);
return result;
}
void MutateDecks(Deck* originalDecks, Deck* result, int32_t count) {
for(int32_t i = 0; i < count; ++i)
result[i] = MutateDeck(originalDecks[i]);
}
static uint32_t LoadDeck(Deck& deck, uint32_t dbuf[], int mainc, int sidec, bool is_packlist = false); static uint32_t LoadDeck(Deck& deck, uint32_t dbuf[], int mainc, int sidec, bool is_packlist = false);
static bool LoadSide(Deck& deck, uint32_t dbuf[], int mainc, int sidec); static bool LoadSide(Deck& deck, uint32_t dbuf[], int mainc, int sidec);
#ifndef YGOPRO_SERVER_MODE #ifndef YGOPRO_SERVER_MODE
......
...@@ -931,5 +931,25 @@ extern unsigned int duel_flags; ...@@ -931,5 +931,25 @@ extern unsigned int duel_flags;
#define AVAIL_SC 0x8 #define AVAIL_SC 0x8
#define AVAIL_OCGTCG (AVAIL_OCG|AVAIL_TCG) #define AVAIL_OCGTCG (AVAIL_OCG|AVAIL_TCG)
#ifndef YGOPRO_DEFAULT_DUEL_RULE
#define YGOPRO_DEFAULT_DUEL_RULE 5
#endif
#ifndef YGOPRO_MAX_DECK
#define YGOPRO_MAX_DECK 6
#endif
#ifndef YGOPRO_MIN_DECK
#define YGOPRO_MIN_DECK 4
#endif
#ifndef YGOPRO_MAX_EXTRA
#define YGOPRO_MAX_EXTRA 3
#endif
#ifndef YGOPRO_MAX_SIDE
#define YGOPRO_MAX_SIDE 3
#endif
#define MAX_LAYER_COUNT 6 #define MAX_LAYER_COUNT 6
#endif // GAME_H #endif // GAME_H
...@@ -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()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].main.size() * 10);
BufferIO::WriteInt16(pbuf, extra_size[0]); BufferIO::WriteInt16(pbuf, extra_size[0] * 5);
BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[1].main.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[1].main.size() * 10);
BufferIO::WriteInt16(pbuf, extra_size[1]); BufferIO::WriteInt16(pbuf, extra_size[1] * 5);
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()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].main.size() * 10);
BufferIO::WriteInt16(pbuf, (short)pdeck[0].extra.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].extra.size() * 5);
BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[1].main.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[1].main.size() * 10);
BufferIO::WriteInt16(pbuf, (short)pdeck[1].extra.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[1].extra.size() * 5);
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);
...@@ -578,9 +578,11 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -578,9 +578,11 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay.WriteHeader(rh); last_replay.WriteHeader(rh);
last_replay.WriteData(players[0]->name, 40, false); last_replay.WriteData(players[0]->name, 40, false);
last_replay.WriteData(players[1]->name, 40, false); last_replay.WriteData(players[1]->name, 40, false);
Deck duplicatedDeck[2];
deckManager.MutateDecks(pdeck, duplicatedDeck, 2);
if(!host_info.no_shuffle_deck) { if(!host_info.no_shuffle_deck) {
rnd.shuffle_vector(pdeck[0].main); rnd.shuffle_vector(duplicatedDeck[0].main);
rnd.shuffle_vector(pdeck[1].main); rnd.shuffle_vector(duplicatedDeck[1].main);
} }
time_limit[0] = host_info.time_limit; time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit; time_limit[1] = host_info.time_limit;
...@@ -611,23 +613,23 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -611,23 +613,23 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
std::vector<ygo::code_pointer> extra_cards; std::vector<ygo::code_pointer> extra_cards;
auto load_extra = [&](uint8_t p) { auto load_extra = [&](uint8_t p) {
extra_cards.clear(); extra_cards.clear();
for(auto cit : pdeck[p].extra) for(auto cit : duplicatedDeck[p].extra)
extra_cards.push_back(cit); extra_cards.push_back(cit);
if(duel_flags & DUEL_FLAG_SIDEINS) if(duel_flags & DUEL_FLAG_SIDEINS)
for(auto cit : pdeck[p].side) for(auto cit : duplicatedDeck[p].side)
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_cards.push_back(cit); extra_cards.push_back(cit);
return extra_cards; return extra_cards;
}; };
load(pdeck[0].main, 0, LOCATION_DECK); load(duplicatedDeck[0].main, 0, LOCATION_DECK);
load(load_extra(0), 0, LOCATION_EXTRA); load(load_extra(0), 0, LOCATION_EXTRA);
load(pdeck[1].main, 1, LOCATION_DECK); load(duplicatedDeck[1].main, 1, LOCATION_DECK);
load(load_extra(1), 1, LOCATION_EXTRA); load(load_extra(1), 1, LOCATION_EXTRA);
#else #else
load(pdeck[0].main, 0, LOCATION_DECK); load(duplicatedDeck[0].main, 0, LOCATION_DECK);
load(pdeck[0].extra, 0, LOCATION_EXTRA); load(duplicatedDeck[0].extra, 0, LOCATION_EXTRA);
load(pdeck[1].main, 1, LOCATION_DECK); load(duplicatedDeck[1].main, 1, LOCATION_DECK);
load(pdeck[1].extra, 1, LOCATION_EXTRA); load(duplicatedDeck[1].extra, 1, LOCATION_EXTRA);
#endif #endif
last_replay.Flush(); last_replay.Flush();
unsigned char startbuf[32]{}; unsigned char startbuf[32]{};
......
...@@ -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()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].main.size() * 10);
BufferIO::WriteInt16(pbuf, extra_size[0]); BufferIO::WriteInt16(pbuf, extra_size[0] * 5);
BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[2].main.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[2].main.size() * 10);
BufferIO::WriteInt16(pbuf, extra_size[1]); BufferIO::WriteInt16(pbuf, extra_size[1] * 5);
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()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].main.size() * 10);
BufferIO::WriteInt16(pbuf, (short)pdeck[0].extra.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].extra.size() * 5);
BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[0].side.size());
BufferIO::WriteInt16(pbuf, (short)pdeck[2].main.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[2].main.size() * 10);
BufferIO::WriteInt16(pbuf, (short)pdeck[2].extra.size()); BufferIO::WriteInt16(pbuf, (short)pdeck[2].extra.size() * 5);
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);
...@@ -557,11 +557,13 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -557,11 +557,13 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay.WriteData(players[1]->name, 40, false); last_replay.WriteData(players[1]->name, 40, false);
last_replay.WriteData(players[2]->name, 40, false); last_replay.WriteData(players[2]->name, 40, false);
last_replay.WriteData(players[3]->name, 40, false); last_replay.WriteData(players[3]->name, 40, false);
Deck duplicatedDeck[4];
deckManager.MutateDecks(pdeck, duplicatedDeck, 4);
if(!host_info.no_shuffle_deck) { if(!host_info.no_shuffle_deck) {
rnd.shuffle_vector(pdeck[0].main); rnd.shuffle_vector(duplicatedDeck[0].main);
rnd.shuffle_vector(pdeck[1].main); rnd.shuffle_vector(duplicatedDeck[1].main);
rnd.shuffle_vector(pdeck[2].main); rnd.shuffle_vector(duplicatedDeck[2].main);
rnd.shuffle_vector(pdeck[3].main); rnd.shuffle_vector(duplicatedDeck[3].main);
} }
time_limit[0] = host_info.time_limit; time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit; time_limit[1] = host_info.time_limit;
...@@ -600,31 +602,31 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -600,31 +602,31 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
std::vector<ygo::code_pointer> extra_cards; std::vector<ygo::code_pointer> extra_cards;
auto load_extra = [&](uint8_t p) { auto load_extra = [&](uint8_t p) {
extra_cards.clear(); extra_cards.clear();
for(auto cit : pdeck[p].extra) for(auto cit : duplicatedDeck[p].extra)
extra_cards.push_back(cit); extra_cards.push_back(cit);
if(duel_flags & DUEL_FLAG_SIDEINS) if(duel_flags & DUEL_FLAG_SIDEINS)
for(auto cit : pdeck[p].side) for(auto cit : duplicatedDeck[p].side)
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_cards.push_back(cit); extra_cards.push_back(cit);
return extra_cards; return extra_cards;
}; };
load_single(pdeck[0].main, 0, LOCATION_DECK); load_single(duplicatedDeck[0].main, 0, LOCATION_DECK);
load_single(load_extra(0), 0, LOCATION_EXTRA); load_single(load_extra(0), 0, LOCATION_EXTRA);
load_tag(pdeck[1].main, 0, LOCATION_DECK); load_tag(duplicatedDeck[1].main, 0, LOCATION_DECK);
load_tag(load_extra(1), 0, LOCATION_EXTRA); load_tag(load_extra(1), 0, LOCATION_EXTRA);
load_single(pdeck[3].main, 1, LOCATION_DECK); load_single(duplicatedDeck[3].main, 1, LOCATION_DECK);
load_single(load_extra(3), 1, LOCATION_EXTRA); load_single(load_extra(3), 1, LOCATION_EXTRA);
load_tag(pdeck[2].main, 1, LOCATION_DECK); load_tag(duplicatedDeck[2].main, 1, LOCATION_DECK);
load_tag(load_extra(2), 1, LOCATION_EXTRA); load_tag(load_extra(2), 1, LOCATION_EXTRA);
#else #else
load_single(pdeck[0].main, 0, LOCATION_DECK); load_single(duplicatedDeck[0].main, 0, LOCATION_DECK);
load_single(pdeck[0].extra, 0, LOCATION_EXTRA); load_single(duplicatedDeck[0].extra, 0, LOCATION_EXTRA);
load_tag(pdeck[1].main, 0, LOCATION_DECK); load_tag(duplicatedDeck[1].main, 0, LOCATION_DECK);
load_tag(pdeck[1].extra, 0, LOCATION_EXTRA); load_tag(duplicatedDeck[1].extra, 0, LOCATION_EXTRA);
load_single(pdeck[3].main, 1, LOCATION_DECK); load_single(duplicatedDeck[3].main, 1, LOCATION_DECK);
load_single(pdeck[3].extra, 1, LOCATION_EXTRA); load_single(duplicatedDeck[3].extra, 1, LOCATION_EXTRA);
load_tag(pdeck[2].main, 1, LOCATION_DECK); load_tag(duplicatedDeck[2].main, 1, LOCATION_DECK);
load_tag(pdeck[2].extra, 1, LOCATION_EXTRA); load_tag(duplicatedDeck[2].extra, 1, LOCATION_EXTRA);
#endif #endif
last_replay.Flush(); last_replay.Flush();
unsigned char startbuf[32]{}; unsigned char startbuf[32]{};
......
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