Commit ad821bb4 authored by nanahira's avatar nanahira

support more premake params

parent daaec651
......@@ -1757,7 +1757,7 @@ bool DeckBuilder::push_main(code_pointer pointer, int seq) {
if(pointer->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK))
return false;
auto& container = deckManager.current_deck.main;
int maxc = mainGame->is_siding ? 64 : 60;
int maxc = mainGame->is_siding ? YGOPRO_MAX_DECK + 5 : YGOPRO_MAX_DECK;
if((int)container.size() >= maxc)
return false;
if(seq >= 0 && seq < (int)container.size())
......@@ -1772,7 +1772,7 @@ bool DeckBuilder::push_extra(code_pointer pointer, int seq) {
if(!(pointer->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)))
return false;
auto& container = deckManager.current_deck.extra;
int maxc = mainGame->is_siding ? 20 : 15;
int maxc = mainGame->is_siding ? YGOPRO_MAX_EXTRA + 5 : YGOPRO_MAX_EXTRA;
if((int)container.size() >= maxc)
return false;
if(seq >= 0 && seq < (int)container.size())
......@@ -1785,7 +1785,7 @@ bool DeckBuilder::push_extra(code_pointer pointer, int seq) {
}
bool DeckBuilder::push_side(code_pointer pointer, int seq) {
auto& container = deckManager.current_deck.side;
int maxc = mainGame->is_siding ? 20 : 15;
int maxc = mainGame->is_siding ? YGOPRO_MAX_SIDE + 5 : YGOPRO_MAX_SIDE;
if((int)container.size() >= maxc)
return false;
if(seq >= 0 && seq < (int)container.size())
......
......@@ -91,11 +91,11 @@ int DeckManager::CheckDeck(Deck& deck, int lfhash, int rule) {
if(!list)
return 0;
int dc = 0;
if(deck.main.size() < 40 || deck.main.size() > 60)
if(deck.main.size() < YGOPRO_MIN_DECK || deck.main.size() > YGOPRO_MAX_DECK)
return (DECKERROR_MAINCOUNT << 28) + deck.main.size();
if(deck.extra.size() > 15)
if(deck.extra.size() > YGOPRO_MAX_EXTRA)
return (DECKERROR_EXTRACOUNT << 28) + deck.extra.size();
if(deck.side.size() > 15)
if(deck.side.size() > YGOPRO_MAX_SIDE)
return (DECKERROR_SIDECOUNT << 28) + deck.side.size();
const int rule_map[6] = { AVAIL_OCG, AVAIL_TCG, AVAIL_SC, AVAIL_CUSTOM, AVAIL_OCGTCG, 0 };
int avail = rule_map[rule];
......@@ -163,10 +163,10 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_p
continue;
}
else if(cd.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) {
if(deck.extra.size() >= 15)
if(deck.extra.size() >= YGOPRO_MAX_EXTRA)
continue;
deck.extra.push_back(dataManager.GetCodePointer(code));
} else if(deck.main.size() < 60) {
} else if(deck.main.size() < YGOPRO_MAX_DECK) {
deck.main.push_back(dataManager.GetCodePointer(code));
}
}
......@@ -178,7 +178,7 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_p
}
if(cd.type & TYPE_TOKEN)
continue;
if(deck.side.size() < 15)
if(deck.side.size() < YGOPRO_MAX_SIDE)
deck.side.push_back(dataManager.GetCodePointer(code));
}
return errorcode;
......@@ -194,17 +194,21 @@ bool DeckManager::LoadSide(Deck& deck, int* dbuf, int mainc, int sidec) {
pcount[deck.side[i]->first]++;
Deck ndeck;
LoadDeck(ndeck, dbuf, mainc, sidec);
#ifndef YGOPRO_NO_SIDE_CHECK
if(ndeck.main.size() != deck.main.size() || ndeck.extra.size() != deck.extra.size())
return false;
#endif
for(size_t i = 0; i < ndeck.main.size(); ++i)
ncount[ndeck.main[i]->first]++;
for(size_t i = 0; i < ndeck.extra.size(); ++i)
ncount[ndeck.extra[i]->first]++;
for(size_t i = 0; i < ndeck.side.size(); ++i)
ncount[ndeck.side[i]->first]++;
#ifndef YGOPRO_NO_SIDE_CHECK
for(auto cdit = ncount.begin(); cdit != ncount.end(); ++cdit)
if(cdit->second != pcount[cdit->first])
return false;
#endif
deck = ndeck;
return true;
}
......
......@@ -13,7 +13,27 @@
#include <vector>
#include <list>
#define DEFAULT_DUEL_RULE 5
#ifndef YGOPRO_DEFAULT_DUEL_RULE
#define YGOPRO_DEFAULT_DUEL_RULE 5
#endif
#ifndef YGOPRO_MAX_DECK
#define YGOPRO_MAX_DECK 60
#endif
#ifndef YGOPRO_MIN_DECK
#define YGOPRO_MIN_DECK 40
#endif
#ifndef YGOPRO_MAX_EXTRA
#define YGOPRO_MAX_EXTRA 15
#endif
#ifndef YGOPRO_MAX_SIDE
#define YGOPRO_MAX_SIDE 15
#endif
#define DEFAULT_DUEL_RULE YGOPRO_DEFAULT_DUEL_RULE
namespace ygo {
......
......@@ -679,7 +679,7 @@ void TagDuel::Surrender(DuelPlayer* dp) {
if(dp->type > 3 || !pduel)
return;
uint32 player = dp->type;
#ifndef YGOPRO_SERVER_MODE
#if !defined(YGOPRO_SERVER_MODE) || defined(YGOPRO_TAG_SURRENDER_CONFIRM)
if(surrender[player])
return;
static const uint32 teammatemap[] = { 1, 0, 3, 2 };
......
Subproject commit bddfb7b844ea023e4eb3a85d008a4888b47f0e51
Subproject commit 4367d7a0f8ef432a1564f9c804926f9fc6af997b
......@@ -61,10 +61,46 @@ newoption { trigger = "server-mode", category = "YGOPro - server", description =
newoption { trigger = "server-zip-support", category = "YGOPro - server", description = "" }
newoption { trigger = "server-pro2-support", category = "YGOPro - server", description = "" }
boolOptions = {
"no-lua-safe",
"no-side-check",
"tag-surrender-confirm"
}
for _, boolOption in ipairs(boolOptions) do
newoption { trigger = boolOption, category = "YGOPro - options", description = "" }
end
numberOptions = {
"default-duel-rule",
"max-deck",
"min-deck",
"max-extra",
"max-side",
}
for _, numberOption in ipairs(numberOptions) do
newoption { trigger = numberOption, category = "YGOPro - options", description = "", value = "NUMBER" }
end
function GetParam(param)
return _OPTIONS[param] or os.getenv(string.upper(string.gsub(param,"-","_")))
end
function ApplyBoolean(param)
if GetParam(param) then
defines { "YGOPRO_" .. string.upper(string.gsub(param,"-","_")) }
end
end
function ApplyNumber(param)
local value = GetParam(param)
if not value then return end
local numberValue = tonumber(value)
if numberValue then
defines { "YGOPRO_" .. string.upper(string.gsub(param,"-","_")) .. "=" .. numberValue }
end
end
if GetParam("build-lua") then
BUILD_LUA = true
elseif GetParam("no-build-lua") then
......@@ -186,6 +222,14 @@ workspace "YGOPro"
configurations { "Release", "Debug" }
for _, numberOption in ipairs(numberOptions) do
ApplyNumber(numberOption)
end
for _, boolOption in ipairs(boolOptions) do
ApplyBoolean(boolOption)
end
filter "system:windows"
defines { "WIN32", "_WIN32" }
entrypoint "mainCRTStartup"
......
Subproject commit ed2712c62661c5ce9482bd4ac3079787fc26bb04
Subproject commit 1c6ce6ed259e832a860d5333fb79075ee7a8132e
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