Commit 8c917ebe authored by nanahira's avatar nanahira

Merge branch 'master' of ../ygopro/ygopro-222DIY

parents 0a54d8d3 25f827d6
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
/single /single
/sound /sound
/update /update
/update*
# ygopro main program # ygopro main program
/ygopro /ygopro
......
...@@ -60,9 +60,6 @@ after_build: ...@@ -60,9 +60,6 @@ after_build:
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/Smile-DK/ygopro-scripts/archive/master.zip ; exit 0" - bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/Smile-DK/ygopro-scripts/archive/master.zip ; exit 0"
- 7z x -y ygopro-scripts-master.zip - 7z x -y ygopro-scripts-master.zip
- rm -rf ygopro-scripts-master.zip
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/Fluorohydride/ygopro-scripts/archive/master.zip ; exit 0"
- 7z x -y ygopro-scripts-master.zip
- mv -f ygopro-scripts-master script - mv -f ygopro-scripts-master script
- mkdir replay - mkdir replay
...@@ -91,7 +88,7 @@ after_build: ...@@ -91,7 +88,7 @@ after_build:
- cd .. - cd ..
- cp -rf ygopro/cards.cdb windbot - cp -rf ygopro/cards.cdb windbot
- cp -rf config.json config.user.json - cp -rf config_build config
- cp -rf ../node-v9.1.0-win-x64.zip . - cp -rf ../node-v9.1.0-win-x64.zip .
- 7z x node-v9.1.0-win-x64.zip - 7z x node-v9.1.0-win-x64.zip
- rm -rf node-v9.1.0-win-x64.zip - rm -rf node-v9.1.0-win-x64.zip
......
No preview for this file type
...@@ -39,9 +39,9 @@ struct CardDataC { ...@@ -39,9 +39,9 @@ struct CardDataC {
unsigned int category; unsigned int category;
}; };
struct CardString { struct CardString {
wchar_t* name; std::wstring name;
wchar_t* text; std::wstring text;
wchar_t* desc[16]; std::wstring desc[16];
}; };
typedef std::unordered_map<unsigned int, CardDataC>::const_iterator code_pointer; typedef std::unordered_map<unsigned int, CardDataC>::const_iterator code_pointer;
......
...@@ -1374,7 +1374,7 @@ void ClientField::UpdateDeclarableCodeType(bool enter) { ...@@ -1374,7 +1374,7 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd) && is_declarable(cd, declarable_type)) { if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd) && is_declarable(cd, declarable_type)) {
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
mainGame->lstANCard->addItem(cstr.name); mainGame->lstANCard->addItem(cstr.name.c_str());
ancard.push_back(trycode); ancard.push_back(trycode);
return; return;
} }
...@@ -1383,15 +1383,15 @@ void ClientField::UpdateDeclarableCodeType(bool enter) { ...@@ -1383,15 +1383,15 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) { for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
if(wcsstr(cit->second.name, pname) != 0) { if(cit->second.name.find(pname) != std::wstring::npos) {
auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings
//datas.alias can be double card names or alias //datas.alias can be double card names or alias
if(is_declarable(cp->second, declarable_type)) { if(is_declarable(cp->second, declarable_type)) {
if(wcscmp(pname, cit->second.name) == 0) { //exact match if(pname == cit->second.name) { //exact match
mainGame->lstANCard->insertItem(0, cit->second.name, -1); mainGame->lstANCard->insertItem(0, cit->second.name.c_str(), -1);
ancard.insert(ancard.begin(), cit->first); ancard.insert(ancard.begin(), cit->first);
} else { } else {
mainGame->lstANCard->addItem(cit->second.name); mainGame->lstANCard->addItem(cit->second.name.c_str());
ancard.push_back(cit->first); ancard.push_back(cit->first);
} }
} }
...@@ -1406,7 +1406,7 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) { ...@@ -1406,7 +1406,7 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd) && is_declarable(cd, opcode)) { if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd) && is_declarable(cd, opcode)) {
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
mainGame->lstANCard->addItem(cstr.name); mainGame->lstANCard->addItem(cstr.name.c_str());
ancard.push_back(trycode); ancard.push_back(trycode);
return; return;
} }
...@@ -1415,15 +1415,15 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) { ...@@ -1415,15 +1415,15 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) { for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
if(wcsstr(cit->second.name, pname) != 0) { if(cit->second.name.find(pname) != std::wstring::npos) {
auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings
//datas.alias can be double card names or alias //datas.alias can be double card names or alias
if(is_declarable(cp->second, opcode)) { if(is_declarable(cp->second, opcode)) {
if(wcscmp(pname, cit->second.name) == 0) { //exact match if(pname == cit->second.name) { //exact match
mainGame->lstANCard->insertItem(0, cit->second.name, -1); mainGame->lstANCard->insertItem(0, cit->second.name.c_str(), -1);
ancard.insert(ancard.begin(), cit->first); ancard.insert(ancard.begin(), cit->first);
} else { } else {
mainGame->lstANCard->addItem(cit->second.name); mainGame->lstANCard->addItem(cit->second.name.c_str());
ancard.push_back(cit->first); ancard.push_back(cit->first);
} }
} }
......
...@@ -138,6 +138,7 @@ public: ...@@ -138,6 +138,7 @@ public:
void ShowCancelOrFinishButton(int buttonOp); void ShowCancelOrFinishButton(int buttonOp);
void SetShowMark(ClientCard* pcard, bool enable); void SetShowMark(ClientCard* pcard, bool enable);
void SetResponseSelectedCards() const; void SetResponseSelectedCards() const;
void CancelOrFinish();
}; };
} }
......
...@@ -21,8 +21,7 @@ bool DataManager::LoadDB(const char* file) { ...@@ -21,8 +21,7 @@ bool DataManager::LoadDB(const char* file) {
return Error(pDB); return Error(pDB);
CardDataC cd; CardDataC cd;
CardString cs; CardString cs;
for(int i = 0; i < 16; ++i) cs.desc[i] = 0; int step = 0;
int step = 0, len = 0;
do { do {
step = sqlite3_step(pStmt); step = sqlite3_step(pStmt);
if(step == SQLITE_BUSY || step == SQLITE_ERROR || step == SQLITE_MISUSE) if(step == SQLITE_BUSY || step == SQLITE_ERROR || step == SQLITE_MISUSE)
...@@ -49,27 +48,21 @@ bool DataManager::LoadDB(const char* file) { ...@@ -49,27 +48,21 @@ bool DataManager::LoadDB(const char* file) {
cd.category = sqlite3_column_int(pStmt, 10); cd.category = sqlite3_column_int(pStmt, 10);
_datas.insert(std::make_pair(cd.code, cd)); _datas.insert(std::make_pair(cd.code, cd));
#ifndef YGOPRO_SERVER_MODE #ifndef YGOPRO_SERVER_MODE
len = BufferIO::DecodeUTF8((const char*)sqlite3_column_text(pStmt, 12), strBuffer); if(const char* text = (const char*)sqlite3_column_text(pStmt, 12)) {
if(len) { BufferIO::DecodeUTF8(text, strBuffer);
cs.name = new wchar_t[len + 1]; cs.name = strBuffer;
memcpy(cs.name, strBuffer, (len + 1)*sizeof(wchar_t));
} else cs.name = 0;
len = BufferIO::DecodeUTF8((const char*)sqlite3_column_text(pStmt, 13), strBuffer);
if(len) {
cs.text = new wchar_t[len + 1];
memcpy(cs.text, strBuffer, (len + 1)*sizeof(wchar_t));
} else {
cs.text = new wchar_t[1];
cs.text[0] = 0;
} }
for(int i = 14; i < 30; ++i) { if(const char* text = (const char*)sqlite3_column_text(pStmt, 13)) {
len = BufferIO::DecodeUTF8((const char*)sqlite3_column_text(pStmt, i), strBuffer); BufferIO::DecodeUTF8(text, strBuffer);
if(len) { cs.text = strBuffer;
cs.desc[i - 14] = new wchar_t[len + 1];
memcpy(cs.desc[i - 14], strBuffer, (len + 1)*sizeof(wchar_t));
} else cs.desc[i - 14] = 0;
} }
_strings.insert(std::make_pair(cd.code, cs)); for(int i = 0; i < 16; ++i) {
if(const char* text = (const char*)sqlite3_column_text(pStmt, i + 14)) {
BufferIO::DecodeUTF8(text, strBuffer);
cs.desc[i] = strBuffer;
}
}
_strings.emplace(cd.code, cs);
#endif //YGOPRO_SERVER_MODE #endif //YGOPRO_SERVER_MODE
} }
} while(step != SQLITE_DONE); } while(step != SQLITE_DONE);
...@@ -132,8 +125,8 @@ code_pointer DataManager::GetCodePointer(int code) { ...@@ -132,8 +125,8 @@ code_pointer DataManager::GetCodePointer(int code) {
bool DataManager::GetString(int code, CardString* pStr) { bool DataManager::GetString(int code, CardString* pStr) {
auto csit = _strings.find(code); auto csit = _strings.find(code);
if(csit == _strings.end()) { if(csit == _strings.end()) {
pStr->name = (wchar_t*)unknown_string; pStr->name = unknown_string;
pStr->text = (wchar_t*)unknown_string; pStr->text = unknown_string;
return false; return false;
} }
*pStr = csit->second; *pStr = csit->second;
...@@ -143,16 +136,16 @@ const wchar_t* DataManager::GetName(int code) { ...@@ -143,16 +136,16 @@ const wchar_t* DataManager::GetName(int code) {
auto csit = _strings.find(code); auto csit = _strings.find(code);
if(csit == _strings.end()) if(csit == _strings.end())
return unknown_string; return unknown_string;
if(csit->second.name) if(!csit->second.name.empty())
return csit->second.name; return csit->second.name.c_str();
return unknown_string; return unknown_string;
} }
const wchar_t* DataManager::GetText(int code) { const wchar_t* DataManager::GetText(int code) {
auto csit = _strings.find(code); auto csit = _strings.find(code);
if(csit == _strings.end()) if(csit == _strings.end())
return unknown_string; return unknown_string;
if(csit->second.text) if(!csit->second.text.empty())
return csit->second.text; return csit->second.text.c_str();
return unknown_string; return unknown_string;
} }
const wchar_t* DataManager::GetDesc(int strCode) { const wchar_t* DataManager::GetDesc(int strCode) {
...@@ -163,8 +156,8 @@ const wchar_t* DataManager::GetDesc(int strCode) { ...@@ -163,8 +156,8 @@ const wchar_t* DataManager::GetDesc(int strCode) {
auto csit = _strings.find(code); auto csit = _strings.find(code);
if(csit == _strings.end()) if(csit == _strings.end())
return unknown_string; return unknown_string;
if(csit->second.desc[offset]) if(!csit->second.desc[offset].empty())
return csit->second.desc[offset]; return csit->second.desc[offset].c_str();
return unknown_string; return unknown_string;
} }
const wchar_t* DataManager::GetSysString(int code) { const wchar_t* DataManager::GetSysString(int code) {
......
...@@ -848,12 +848,12 @@ void DeckBuilder::FilterCards() { ...@@ -848,12 +848,12 @@ void DeckBuilder::FilterCards() {
} }
if(pstr) { if(pstr) {
if(pstr[0] == L'$') { if(pstr[0] == L'$') {
if(!CardNameContains(text.name, &pstr[1])) if(!CardNameContains(text.name.c_str(), &pstr[1]))
continue; continue;
} else if(pstr[0] == L'@' && set_code) { } else if(pstr[0] == L'@' && set_code) {
if(!check_set_code(data, set_code)) continue; if(!check_set_code(data, set_code)) continue;
} else { } else {
if(!CardNameContains(text.name, pstr) && wcsstr(text.text, pstr) == 0 if(!CardNameContains(text.name.c_str(), pstr) && text.text.find(pstr) == std::wstring::npos
&& (!set_code || !check_set_code(data, set_code))) && (!set_code || !check_set_code(data, set_code)))
continue; continue;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -76,9 +76,12 @@ bool card::card_operation_sort(card* c1, card* c2) { ...@@ -76,9 +76,12 @@ bool card::card_operation_sort(card* c1, card* c2) {
} }
void card::attacker_map::addcard(card* pcard) { void card::attacker_map::addcard(card* pcard) {
uint16 fid = pcard ? pcard->fieldid_r : 0; uint16 fid = pcard ? pcard->fieldid_r : 0;
auto pr = insert(std::make_pair(fid, std::make_pair(pcard, 0))); auto pr = emplace(fid, std::make_pair(pcard, 0));
pr.first->second.second++; pr.first->second.second++;
} }
void card_data::clear() {
std::memset(this, 0, sizeof(card_data));
}
card::card(duel* pd) { card::card(duel* pd) {
scrtype = 1; scrtype = 1;
ref_handle = 0; ref_handle = 0;
...@@ -1737,21 +1740,21 @@ int32 card::add_effect(effect* peffect) { ...@@ -1737,21 +1740,21 @@ int32 card::add_effect(effect* peffect) {
remove_effect(rm->second); remove_effect(rm->second);
} }
} }
eit = single_effect.insert(std::make_pair(peffect->code, peffect)); eit = single_effect.emplace(peffect->code, peffect);
} else if (peffect->type & EFFECT_TYPE_EQUIP) { } else if (peffect->type & EFFECT_TYPE_EQUIP) {
eit = equip_effect.insert(std::make_pair(peffect->code, peffect)); eit = equip_effect.emplace(peffect->code, peffect);
if (equiping_target) if (equiping_target)
check_target = equiping_target; check_target = equiping_target;
else else
check_target = 0; check_target = 0;
} else if (peffect->type & EFFECT_TYPE_XMATERIAL) { } else if (peffect->type & EFFECT_TYPE_XMATERIAL) {
eit = xmaterial_effect.insert(std::make_pair(peffect->code, peffect)); eit = xmaterial_effect.emplace(peffect->code, peffect);
if (overlay_target) if (overlay_target)
check_target = overlay_target; check_target = overlay_target;
else else
check_target = 0; check_target = 0;
} else if (peffect->type & EFFECT_TYPE_FIELD) { } else if (peffect->type & EFFECT_TYPE_FIELD) {
eit = field_effect.insert(std::make_pair(peffect->code, peffect)); eit = field_effect.emplace(peffect->code, peffect);
} else } else
return 0; return 0;
peffect->id = pduel->game_field->infos.field_id++; peffect->id = pduel->game_field->infos.field_id++;
...@@ -1770,7 +1773,7 @@ int32 card::add_effect(effect* peffect) { ...@@ -1770,7 +1773,7 @@ int32 card::add_effect(effect* peffect) {
if(peffect->reset_count > reason_effect->reset_count) if(peffect->reset_count > reason_effect->reset_count)
peffect->reset_count = reason_effect->reset_count; peffect->reset_count = reason_effect->reset_count;
} }
indexer.insert(std::make_pair(peffect, eit)); indexer.emplace(peffect, eit);
peffect->handler = this; peffect->handler = this;
if (peffect->in_range(this) && (peffect->type & EFFECT_TYPE_FIELD)) if (peffect->in_range(this) && (peffect->type & EFFECT_TYPE_FIELD))
pduel->game_field->add_effect(peffect); pduel->game_field->add_effect(peffect);
...@@ -1779,7 +1782,7 @@ int32 card::add_effect(effect* peffect) { ...@@ -1779,7 +1782,7 @@ int32 card::add_effect(effect* peffect) {
pduel->game_field->add_to_disable_check_list(check_target); pduel->game_field->add_to_disable_check_list(check_target);
} }
if(peffect->is_flag(EFFECT_FLAG_OATH)) { if(peffect->is_flag(EFFECT_FLAG_OATH)) {
pduel->game_field->effects.oath.insert(std::make_pair(peffect, reason_effect)); pduel->game_field->effects.oath.emplace(peffect, reason_effect);
} }
if(peffect->reset_flag & RESET_PHASE) { if(peffect->reset_flag & RESET_PHASE) {
pduel->game_field->effects.pheff.insert(peffect); pduel->game_field->effects.pheff.insert(peffect);
...@@ -2124,7 +2127,7 @@ void card::release_relation(card* target) { ...@@ -2124,7 +2127,7 @@ void card::release_relation(card* target) {
relations.erase(target); relations.erase(target);
} }
void card::create_relation(const chain& ch) { void card::create_relation(const chain& ch) {
relate_effect.insert(std::make_pair(ch.triggering_effect, ch.chain_id)); relate_effect.emplace(ch.triggering_effect, ch.chain_id);
} }
int32 card::is_has_relation(const chain& ch) { int32 card::is_has_relation(const chain& ch) {
if (relate_effect.find(std::make_pair(ch.triggering_effect, ch.chain_id)) != relate_effect.end()) if (relate_effect.find(std::make_pair(ch.triggering_effect, ch.chain_id)) != relate_effect.end())
...@@ -2144,7 +2147,7 @@ void card::create_relation(effect* peffect) { ...@@ -2144,7 +2147,7 @@ void card::create_relation(effect* peffect) {
return; return;
} }
} }
relate_effect.insert(std::make_pair(peffect, (uint16)0)); relate_effect.emplace(peffect, (uint16)0);
} }
int32 card::is_has_relation(effect* peffect) { int32 card::is_has_relation(effect* peffect) {
for(auto it = relate_effect.begin(); it != relate_effect.end(); ++it) { for(auto it = relate_effect.begin(); it != relate_effect.end(); ++it) {
...@@ -2211,7 +2214,7 @@ int32 card::add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8 ...@@ -2211,7 +2214,7 @@ int32 card::add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8
if(!is_can_add_counter(playerid, countertype, count, singly, 0)) if(!is_can_add_counter(playerid, countertype, count, singly, 0))
return FALSE; return FALSE;
uint16 cttype = countertype & ~COUNTER_NEED_ENABLE; uint16 cttype = countertype & ~COUNTER_NEED_ENABLE;
auto pr = counters.insert(std::make_pair(cttype, counter_map::mapped_type())); auto pr = counters.emplace(cttype, counter_map::mapped_type());
auto cmit = pr.first; auto cmit = pr.first;
if(pr.second) { if(pr.second) {
cmit->second[0] = 0; cmit->second[0] = 0;
...@@ -2635,9 +2638,9 @@ void card::filter_spsummon_procedure(uint8 playerid, effect_set* peset, uint32 s ...@@ -2635,9 +2638,9 @@ void card::filter_spsummon_procedure(uint8 playerid, effect_set* peset, uint32 s
auto pr = field_effect.equal_range(EFFECT_SPSUMMON_PROC); auto pr = field_effect.equal_range(EFFECT_SPSUMMON_PROC);
uint8 toplayer; uint8 toplayer;
uint8 topos; uint8 topos;
effect* peffect; for(auto eit = pr.first; eit != pr.second;) {
for(; pr.first != pr.second; ++pr.first) { effect* peffect = eit->second;
peffect = pr.first->second; ++eit;
if(peffect->is_flag(EFFECT_FLAG_SPSUM_PARAM)) { if(peffect->is_flag(EFFECT_FLAG_SPSUM_PARAM)) {
topos = (uint8)peffect->s_range; topos = (uint8)peffect->s_range;
if(peffect->o_range == 0) if(peffect->o_range == 0)
...@@ -2662,8 +2665,9 @@ void card::filter_spsummon_procedure(uint8 playerid, effect_set* peset, uint32 s ...@@ -2662,8 +2665,9 @@ void card::filter_spsummon_procedure(uint8 playerid, effect_set* peset, uint32 s
} }
void card::filter_spsummon_procedure_g(uint8 playerid, effect_set* peset) { void card::filter_spsummon_procedure_g(uint8 playerid, effect_set* peset) {
auto pr = field_effect.equal_range(EFFECT_SPSUMMON_PROC_G); auto pr = field_effect.equal_range(EFFECT_SPSUMMON_PROC_G);
for(; pr.first != pr.second; ++pr.first) { for(auto eit = pr.first; eit != pr.second;) {
effect* peffect = pr.first->second; effect* peffect = eit->second;
++eit;
if(!peffect->is_available() || !peffect->check_count_limit(playerid)) if(!peffect->is_available() || !peffect->check_count_limit(playerid))
continue; continue;
if(current.controler != playerid && !peffect->is_flag(EFFECT_FLAG_BOTH_SIDE)) if(current.controler != playerid && !peffect->is_flag(EFFECT_FLAG_BOTH_SIDE))
...@@ -3201,7 +3205,7 @@ int32 card::is_setable_mzone(uint8 playerid, uint8 ignore_count, effect* peffect ...@@ -3201,7 +3205,7 @@ int32 card::is_setable_mzone(uint8 playerid, uint8 ignore_count, effect* peffect
return TRUE; return TRUE;
} }
int32 card::is_setable_szone(uint8 playerid, uint8 ignore_fd) { int32 card::is_setable_szone(uint8 playerid, uint8 ignore_fd) {
if(!(data.type & TYPE_FIELD) && !ignore_fd && pduel->game_field->get_useable_count(current.controler, LOCATION_SZONE, current.controler, LOCATION_REASON_TOFIELD) <= 0) if(!(data.type & TYPE_FIELD) && !ignore_fd && pduel->game_field->get_useable_count(this, current.controler, LOCATION_SZONE, current.controler, LOCATION_REASON_TOFIELD) <= 0)
return FALSE; return FALSE;
if(data.type & TYPE_MONSTER && !is_affected_by_effect(EFFECT_MONSTER_SSET)) if(data.type & TYPE_MONSTER && !is_affected_by_effect(EFFECT_MONSTER_SSET))
return FALSE; return FALSE;
...@@ -3291,7 +3295,7 @@ int32 card::is_destructable_by_effect(effect* peffect, uint8 playerid) { ...@@ -3291,7 +3295,7 @@ int32 card::is_destructable_by_effect(effect* peffect, uint8 playerid) {
pduel->lua->add_param(playerid, PARAM_TYPE_INT); pduel->lua->add_param(playerid, PARAM_TYPE_INT);
int32 ct; int32 ct;
if(ct = eset[i]->get_value(3)) { if(ct = eset[i]->get_value(3)) {
auto it = indestructable_effects.insert(std::make_pair(eset[i]->id, 0)); auto it = indestructable_effects.emplace(eset[i]->id, 0);
if(it.first->second + 1 <= ct) { if(it.first->second + 1 <= ct) {
return FALSE; return FALSE;
break; break;
...@@ -3350,6 +3354,17 @@ int32 card::is_releasable_by_nonsummon(uint8 playerid) { ...@@ -3350,6 +3354,17 @@ int32 card::is_releasable_by_nonsummon(uint8 playerid) {
int32 card::is_releasable_by_effect(uint8 playerid, effect* peffect) { int32 card::is_releasable_by_effect(uint8 playerid, effect* peffect) {
if(!peffect) if(!peffect)
return TRUE; return TRUE;
if(current.controler != playerid && !is_affected_by_effect(EFFECT_EXTRA_RELEASE)) {
effect_set eset;
filter_effect(EFFECT_EXTRA_RELEASE_NONSUM, &eset);
for(int32 i = 0; i < eset.size(); ++i) {
pduel->lua->add_param(peffect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(REASON_EFFECT, PARAM_TYPE_INT);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
if(!eset[i]->check_value_condition(3))
return FALSE;
}
}
effect_set eset; effect_set eset;
filter_effect(EFFECT_UNRELEASABLE_EFFECT, &eset); filter_effect(EFFECT_UNRELEASABLE_EFFECT, &eset);
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
...@@ -3562,9 +3577,9 @@ int32 card::is_control_can_be_changed(int32 ignore_mzone, uint32 zone) { ...@@ -3562,9 +3577,9 @@ int32 card::is_control_can_be_changed(int32 ignore_mzone, uint32 zone) {
return FALSE; return FALSE;
if(current.location != LOCATION_MZONE) if(current.location != LOCATION_MZONE)
return FALSE; return FALSE;
if(!ignore_mzone && pduel->game_field->get_useable_count(1 - current.controler, LOCATION_MZONE, current.controler, LOCATION_REASON_CONTROL, zone) <= 0) if(!ignore_mzone && pduel->game_field->get_useable_count(this, 1 - current.controler, LOCATION_MZONE, current.controler, LOCATION_REASON_CONTROL, zone) <= 0)
return FALSE; return FALSE;
if((get_type() & TYPE_TRAPMONSTER) && pduel->game_field->get_useable_count(1 - current.controler, LOCATION_SZONE, current.controler, LOCATION_REASON_CONTROL) <= 0) if((get_type() & TYPE_TRAPMONSTER) && pduel->game_field->get_useable_count(this, 1 - current.controler, LOCATION_SZONE, current.controler, LOCATION_REASON_CONTROL) <= 0)
return FALSE; return FALSE;
if(is_affected_by_effect(EFFECT_CANNOT_CHANGE_CONTROL)) if(is_affected_by_effect(EFFECT_CANNOT_CHANGE_CONTROL))
return FALSE; return FALSE;
......
...@@ -34,6 +34,8 @@ struct card_data { ...@@ -34,6 +34,8 @@ struct card_data {
uint32 lscale; uint32 lscale;
uint32 rscale; uint32 rscale;
uint32 link_marker; uint32 link_marker;
void clear();
}; };
struct card_state { struct card_state {
......
...@@ -55,6 +55,8 @@ card* duel::new_card(uint32 code) { ...@@ -55,6 +55,8 @@ card* duel::new_card(uint32 code) {
cards.insert(pcard); cards.insert(pcard);
if(code) if(code)
::read_card(code, &(pcard->data)); ::read_card(code, &(pcard->data));
else
pcard->data.clear();
pcard->data.code = code; pcard->data.code = code;
lua->register_card(pcard); lua->register_card(pcard);
return pcard; return pcard;
......
...@@ -25,6 +25,7 @@ effect::effect(duel* pd) { ...@@ -25,6 +25,7 @@ effect::effect(duel* pd) {
card_type = 0; card_type = 0;
active_type = 0; active_type = 0;
active_location = 0; active_location = 0;
active_sequence = 0;
active_handler = 0; active_handler = 0;
id = 0; id = 0;
code = 0; code = 0;
...@@ -200,7 +201,7 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -200,7 +201,7 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
&& !pduel->game_field->is_location_useable(playerid, LOCATION_PZONE, 1)) && !pduel->game_field->is_location_useable(playerid, LOCATION_PZONE, 1))
return FALSE; return FALSE;
} else if(!(handler->data.type & TYPE_FIELD) } else if(!(handler->data.type & TYPE_FIELD)
&& pduel->game_field->get_useable_count(playerid, LOCATION_SZONE, playerid, LOCATION_REASON_TOFIELD) <= 0) && pduel->game_field->get_useable_count(handler, playerid, LOCATION_SZONE, playerid, LOCATION_REASON_TOFIELD) <= 0)
return FALSE; return FALSE;
} else if(handler->current.location == LOCATION_SZONE) { } else if(handler->current.location == LOCATION_SZONE) {
if(handler->is_position(POS_FACEUP)) if(handler->is_position(POS_FACEUP))
......
...@@ -334,6 +334,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2) ...@@ -334,6 +334,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_EXTRA_RELEASE_SUM 155 #define EFFECT_EXTRA_RELEASE_SUM 155
//#define EFFECT_TRIPLE_TRIBUTE 156 //#define EFFECT_TRIPLE_TRIBUTE 156
#define EFFECT_ADD_EXTRA_TRIBUTE 157 #define EFFECT_ADD_EXTRA_TRIBUTE 157
#define EFFECT_EXTRA_RELEASE_NONSUM 158
#define EFFECT_PUBLIC 160 #define EFFECT_PUBLIC 160
#define EFFECT_COUNTER_PERMIT 0x10000 #define EFFECT_COUNTER_PERMIT 0x10000
#define EFFECT_COUNTER_LIMIT 0x20000 #define EFFECT_COUNTER_LIMIT 0x20000
...@@ -466,6 +467,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2) ...@@ -466,6 +467,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EVENT_CHAINING 1027 #define EVENT_CHAINING 1027
#define EVENT_BECOME_TARGET 1028 #define EVENT_BECOME_TARGET 1028
#define EVENT_DESTROYED 1029 #define EVENT_DESTROYED 1029
#define EVENT_MOVE 1030
#define EVENT_ADJUST 1040 #define EVENT_ADJUST 1040
#define EVENT_SUMMON_SUCCESS 1100 #define EVENT_SUMMON_SUCCESS 1100
#define EVENT_FLIP_SUMMON_SUCCESS 1101 #define EVENT_FLIP_SUMMON_SUCCESS 1101
......
This diff is collapsed.
...@@ -219,7 +219,7 @@ struct processor { ...@@ -219,7 +219,7 @@ struct processor {
card_set self_tograve_set; card_set self_tograve_set;
card_set release_cards; card_set release_cards;
card_set release_cards_ex; card_set release_cards_ex;
card_set release_cards_ex_sum; card_set release_cards_ex_oneof;
card_set battle_destroy_rep; card_set battle_destroy_rep;
card_set fusion_materials; card_set fusion_materials;
card_set synchro_materials; card_set synchro_materials;
...@@ -319,6 +319,7 @@ struct processor { ...@@ -319,6 +319,7 @@ struct processor {
std::unordered_map<uint32, std::pair<uint32, uint32> > attack_counter; std::unordered_map<uint32, std::pair<uint32, uint32> > attack_counter;
std::unordered_map<uint32, std::pair<uint32, uint32> > chain_counter; std::unordered_map<uint32, std::pair<uint32, uint32> > chain_counter;
processor_list recover_damage_reserve; processor_list recover_damage_reserve;
effect_vector dec_count_reserve;
}; };
class field { class field {
public: public:
...@@ -359,11 +360,13 @@ public: ...@@ -359,11 +360,13 @@ public:
card* get_field_card(uint32 playerid, uint32 location, uint32 sequence); card* get_field_card(uint32 playerid, uint32 location, uint32 sequence);
int32 is_location_useable(uint32 playerid, uint32 location, uint32 sequence); int32 is_location_useable(uint32 playerid, uint32 location, uint32 sequence);
int32 get_useable_count(card* pcard, uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone = 0xff, uint32* list = 0); int32 get_useable_count(card* pcard, uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone = 0xff, uint32* list = 0);
int32 get_spsummonable_count(card* pcard, uint8 playerid, uint32 zone = 0xff, uint32* list = 0);
int32 get_useable_count(uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone = 0xff, uint32* list = 0);
int32 get_tofield_count(uint8 playerid, uint8 location, uint32 uplayer, uint32 reason, uint32 zone = 0xff, uint32* list = 0);
int32 get_useable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone = 0xff, uint32* list = 0); int32 get_useable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone = 0xff, uint32* list = 0);
int32 get_spsummonable_count(card* pcard, uint8 playerid, uint32 zone = 0xff, uint32* list = 0);
int32 get_spsummonable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone = 0xff, uint32* list = 0); int32 get_spsummonable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone = 0xff, uint32* list = 0);
int32 get_useable_count_other(card* pcard, uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone = 0xff, uint32* list = 0);
int32 get_tofield_count(card* pcard, uint8 playerid, uint8 location, uint32 uplayer, uint32 reason, uint32 zone = 0xff, uint32* list = 0);
int32 get_useable_count_fromex_rule4(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone = 0xff, uint32* list = 0);
int32 get_spsummonable_count_fromex_rule4(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone = 0xff, uint32* list = 0);
int32 get_mzone_limit(uint8 playerid, uint8 uplayer, uint32 reason); int32 get_mzone_limit(uint8 playerid, uint8 uplayer, uint32 reason);
int32 get_szone_limit(uint8 playerid, uint8 uplayer, uint32 reason); int32 get_szone_limit(uint8 playerid, uint8 uplayer, uint32 reason);
uint32 get_linked_zone(int32 playerid); uint32 get_linked_zone(int32 playerid);
...@@ -394,9 +397,9 @@ public: ...@@ -394,9 +397,9 @@ public:
int32 filter_field_card(uint8 self, uint32 location, uint32 location2, group* pgroup); int32 filter_field_card(uint8 self, uint32 location, uint32 location2, group* pgroup);
effect* is_player_affected_by_effect(uint8 playerid, uint32 code); effect* is_player_affected_by_effect(uint8 playerid, uint32 code);
int32 get_release_list(uint8 playerid, card_set* release_list, card_set* ex_list, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exc, group* exg); int32 get_release_list(uint8 playerid, card_set* release_list, card_set* ex_list, card_set* ex_list_oneof, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exc, group* exg);
int32 check_release_list(uint8 playerid, int32 count, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exc, group* exg); int32 check_release_list(uint8 playerid, int32 count, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exc, group* exg);
int32 get_summon_release_list(card* target, card_set* release_list, card_set* ex_list, card_set* ex_list_sum, group* mg = NULL, uint32 ex = 0, uint32 releasable = 0xff00ff, uint32 pos = 0x1); int32 get_summon_release_list(card* target, card_set* release_list, card_set* ex_list, card_set* ex_list_oneof, group* mg = NULL, uint32 ex = 0, uint32 releasable = 0xff00ff, uint32 pos = 0x1);
int32 get_summon_count_limit(uint8 playerid); int32 get_summon_count_limit(uint8 playerid);
int32 get_draw_count(uint8 playerid); int32 get_draw_count(uint8 playerid);
void get_ritual_material(uint8 playerid, effect* peffect, card_set* material); void get_ritual_material(uint8 playerid, effect* peffect, card_set* material);
...@@ -537,6 +540,7 @@ public: ...@@ -537,6 +540,7 @@ public:
void change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable = FALSE); void change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable = FALSE);
void change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable = FALSE); void change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable = FALSE);
void operation_replace(int32 type, int32 step, group* targets); void operation_replace(int32 type, int32 step, group* targets);
void select_tribute_cards(card* target, uint8 playerid, uint8 cancelable, int32 min, int32 max, uint8 toplayer, uint32 zone);
int32 remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplayer, uint8 s, uint8 o, uint16 countertype, uint16 count); int32 remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplayer, uint8 s, uint8 o, uint16 countertype, uint16 count);
int32 remove_overlay_card(uint16 step, uint32 reason, card* pcard, uint8 rplayer, uint8 s, uint8 o, uint16 min, uint16 max); int32 remove_overlay_card(uint16 step, uint32 reason, card* pcard, uint8 rplayer, uint8 s, uint8 o, uint16 min, uint16 max);
...@@ -569,8 +573,8 @@ public: ...@@ -569,8 +573,8 @@ public:
int32 activate_effect(uint16 step, effect* peffect); int32 activate_effect(uint16 step, effect* peffect);
int32 select_synchro_material(int16 step, uint8 playerid, card* pcard, int32 min, int32 max, card* smat, group* mg); int32 select_synchro_material(int16 step, uint8 playerid, card* pcard, int32 min, int32 max, card* smat, group* mg);
int32 select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* pcard, int32 min, int32 max); int32 select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* pcard, int32 min, int32 max);
int32 select_release_cards(int16 step, uint8 playerid, uint8 check_field, uint8 cancelable, int32 min, int32 max); int32 select_release_cards(int16 step, uint8 playerid, uint8 cancelable, int32 min, int32 max);
int32 select_tribute_cards(int16 step, uint8 playerid, uint8 cancelable, int32 min, int32 max, uint8 toplayer, uint32 zone); int32 select_tribute_cards(int16 step, card* target, uint8 playerid, uint8 cancelable, int32 min, int32 max, uint8 toplayer, uint32 zone);
int32 toss_coin(uint16 step, effect* reason_effect, uint8 reason_player, uint8 playerid, uint8 count); int32 toss_coin(uint16 step, effect* reason_effect, uint8 reason_player, uint8 playerid, uint8 count);
int32 toss_dice(uint16 step, effect* reason_effect, uint8 reason_player, uint8 playerid, uint8 count1, uint8 count2); int32 toss_dice(uint16 step, effect* reason_effect, uint8 reason_player, uint8 playerid, uint8 count1, uint8 count2);
int32 rock_paper_scissors(uint16 step, uint8 repeat); int32 rock_paper_scissors(uint16 step, uint8 repeat);
......
...@@ -839,15 +839,15 @@ int32 interpreter::load_card_script(uint32 code) { ...@@ -839,15 +839,15 @@ int32 interpreter::load_card_script(uint32 code) {
} }
void interpreter::add_param(void *param, int32 type, bool front) { void interpreter::add_param(void *param, int32 type, bool front) {
if(front) if(front)
params.push_front(std::make_pair(param, type)); params.emplace_front(param, type);
else else
params.push_back(std::make_pair(param, type)); params.emplace_back(param, type);
} }
void interpreter::add_param(ptr param, int32 type, bool front) { void interpreter::add_param(ptr param, int32 type, bool front) {
if(front) if(front)
params.push_front(std::make_pair((void*)param, type)); params.emplace_front((void*)param, type);
else else
params.push_back(std::make_pair((void*)param, type)); params.emplace_back((void*)param, type);
} }
void interpreter::push_param(lua_State* L, bool is_coroutine) { void interpreter::push_param(lua_State* L, bool is_coroutine) {
uint32 type; uint32 type;
...@@ -1216,7 +1216,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -1216,7 +1216,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
return OPERATION_FAIL; return OPERATION_FAIL;
} }
call_depth++; call_depth++;
coroutines.insert(std::make_pair(f, rthread)); coroutines.emplace(f, rthread);
} else { } else {
rthread = it->second; rthread = it->second;
if(step == 0) { if(step == 0) {
......
...@@ -1472,8 +1472,9 @@ int32 scriptlib::card_check_activate_effect(lua_State *L) { ...@@ -1472,8 +1472,9 @@ int32 scriptlib::card_check_activate_effect(lua_State *L) {
int32 copy_info = lua_toboolean(L, 4); int32 copy_info = lua_toboolean(L, 4);
duel* pduel = pcard->pduel; duel* pduel = pcard->pduel;
tevent pe; tevent pe;
for(auto eit = pcard->field_effect.begin(); eit != pcard->field_effect.end(); ++eit) { for(auto eit = pcard->field_effect.begin(); eit != pcard->field_effect.end();) {
effect* peffect = eit->second; effect* peffect = eit->second;
++eit;
if((peffect->type & EFFECT_TYPE_ACTIVATE) if((peffect->type & EFFECT_TYPE_ACTIVATE)
&& pduel->game_field->check_event_c(peffect, pduel->game_field->core.reason_player, neglect_con, neglect_cost, copy_info, &pe)) { && pduel->game_field->check_event_c(peffect, pduel->game_field->core.reason_player, neglect_con, neglect_cost, copy_info, &pe)) {
if(!copy_info || (peffect->code == EVENT_FREE_CHAIN)) { if(!copy_info || (peffect->code == EVENT_FREE_CHAIN)) {
......
...@@ -133,7 +133,7 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) { ...@@ -133,7 +133,7 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) {
uint32 countertype = lua_tonumberint(L, 2); uint32 countertype = lua_tonumberint(L, 2);
uint32 count = lua_tonumberint(L, 3); uint32 count = lua_tonumberint(L, 3);
uint16 cttype = countertype & ~COUNTER_NEED_ENABLE; uint16 cttype = countertype & ~COUNTER_NEED_ENABLE;
auto pr = pcard->counters.insert(std::make_pair(cttype, card::counter_map::mapped_type())); auto pr = pcard->counters.emplace(cttype, card::counter_map::mapped_type());
auto cmit = pr.first; auto cmit = pr.first;
if(pr.second) { if(pr.second) {
cmit->second[0] = 0; cmit->second[0] = 0;
......
This diff is collapsed.
This diff is collapsed.
...@@ -540,10 +540,10 @@ int32 field::select_tribute(uint16 step, uint8 playerid, uint8 cancelable, uint8 ...@@ -540,10 +540,10 @@ int32 field::select_tribute(uint16 step, uint8 playerid, uint8 cancelable, uint8
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
} }
uint8 m = core.select_cards.size(), v = 0, tt = 0; uint8 m = core.select_cards.size(), tt = 0;
for(int32 i = 0; i < returns.bvalue[0]; ++i) { for(int32 i = 0; i < returns.bvalue[0]; ++i) {
v = returns.bvalue[i + 1]; int8 v = returns.bvalue[i + 1];
if(v < 0 || v >= m || v >= 6 || c[v]) { if(v < 0 || v >= m || c[v]) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
} }
......
This diff is collapsed.
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
!system 95 是否使用[%ls]的效果? !system 95 是否使用[%ls]的效果?
!system 96 是否使用[%ls]的效果代替破坏? !system 96 是否使用[%ls]的效果代替破坏?
!system 97 是否把[%ls]在魔法与陷阱区域放置? !system 97 是否把[%ls]在魔法与陷阱区域放置?
!system 98 是否要解放对方怪兽?
!system 100 先攻 !system 100 先攻
!system 101 后攻 !system 101 后攻
!system 200 是否在[%ls]发动[%ls]的效果? !system 200 是否在[%ls]发动[%ls]的效果?
...@@ -887,6 +888,6 @@ ...@@ -887,6 +888,6 @@
!setname 0x111 武装龙 アームド・ドラゴン !setname 0x111 武装龙 アームド・ドラゴン
!setname 0x112 幻崩 トロイメア !setname 0x112 幻崩 トロイメア
!setname 0x113 灵神 霊神 !setname 0x113 灵神 霊神
!setname 0x114 空牙团 !setname 0x114 空牙团 空牙団
!setname 0x115 闪刀 !setname 0x115 闪刀 閃刀
!setname 0x1115 闪刀姬 !setname 0x1115 闪刀姬 閃刀姫
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