Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Fluorohydride/ygopro
Browse files Browse the repository at this point in the history
  • Loading branch information
mercury233 committed Nov 30, 2018
2 parents 08ac0b5 + 3d2caeb commit 2f81e73
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 75 deletions.
4 changes: 2 additions & 2 deletions gframe/client_card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void ClientCard::UpdateInfo(char* buf) {
int l = BufferIO::ReadInt8(buf);
int s = BufferIO::ReadInt8(buf);
BufferIO::ReadInt8(buf);
ClientCard* ecard = mainGame->dField.GetCard(c, l, s);
ClientCard* ecard = mainGame->dField.GetCard(mainGame->LocalPlayer(c), l, s);
equipTarget = ecard;
ecard->equipped.insert(this);
}
Expand All @@ -143,7 +143,7 @@ void ClientCard::UpdateInfo(char* buf) {
int l = BufferIO::ReadInt8(buf);
int s = BufferIO::ReadInt8(buf);
BufferIO::ReadInt8(buf);
ClientCard* tcard = mainGame->dField.GetCard(c, l, s);
ClientCard* tcard = mainGame->dField.GetCard(mainGame->LocalPlayer(c), l, s);
cardTarget.insert(tcard);
tcard->ownerTarget.insert(this);
}
Expand Down
146 changes: 89 additions & 57 deletions gframe/deck_con.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,14 +676,14 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
return false;
}
void DeckBuilder::GetHoveredCard() {
int pre_code = hovered_code;
hovered_pos = 0;
hovered_code = 0;
irr::gui::IGUIElement* root = mainGame->env->getRootGUIElement();
if(root->getElementFromPoint(mouse_pos) != root)
return;
int x = mouse_pos.X;
int y = mouse_pos.Y;
int pre_code = hovered_code;
hovered_pos = 0;
hovered_code = 0;
is_lastcard = 0;
if(x >= 314 && x <= 794) {
if(y >= 164 && y <= 435) {
Expand Down Expand Up @@ -775,42 +775,78 @@ void DeckBuilder::StartFilter() {
}
void DeckBuilder::FilterCards() {
results.clear();
struct element_t {
std::wstring keyword;
int setcode;
enum class type_t {
all,
name,
setcode
} type;
bool exclude;
element_t(): setcode(0), type(type_t::all), exclude(false) {}
};
const wchar_t* pstr = mainGame->ebCardName->getText();
std::wstring str = std::wstring(pstr);
std::vector<std::wstring> query_elements;
std::vector<std::vector<std::wstring>::iterator> query_elements_track;
size_t element_start = 0;
while(mainGame->gameConf.search_multiple_keywords) {
size_t element_end = str.find_first_of(mainGame->gameConf.search_multiple_keywords == 1 ? L' ' : L'+', element_start);
if(element_end == std::wstring::npos)
break;
size_t length = element_end - element_start;
if(length > 0) {
query_elements.push_back(str.substr(element_start, length));
std::vector<element_t> query_elements;
if(mainGame->gameConf.search_multiple_keywords) {
const wchar_t separator = mainGame->gameConf.search_multiple_keywords == 1 ? L' ' : L'+';
const wchar_t minussign = L'-';
const wchar_t quotation = L'\"';
size_t element_start = 0;
for(;;) {
element_start = str.find_first_not_of(separator, element_start);
if(element_start == std::wstring::npos)
break;
element_t element;
if(str[element_start] == minussign) {
element.exclude = true;
element_start++;
}
if(element_start >= str.size())
break;
if(str[element_start] == L'$') {
element.type = element_t::type_t::name;
element_start++;
} else if(str[element_start] == L'@') {
element.type = element_t::type_t::setcode;
element_start++;
}
if(element_start >= str.size())
break;
wchar_t delimiter = separator;
if(str[element_start] == quotation) {
delimiter = quotation;
element_start++;
}
size_t element_end = str.find_first_of(delimiter, element_start);
if(element_end != std::wstring::npos) {
size_t length = element_end - element_start;
element.keyword = str.substr(element_start, length);
} else
element.keyword = str.substr(element_start);
element.setcode = dataManager.GetSetCode(element.keyword.c_str());
query_elements.push_back(element);
if(element_end == std::wstring::npos)
break;
element_start = element_end + 1;
} else
}
} else {
element_t element;
size_t element_start = 0;
if(str[element_start] == L'$') {
element.type = element_t::type_t::name;
element_start++;
} else if(str[element_start] == L'@') {
element.type = element_t::type_t::setcode;
element_start++;
}
if(element_start < str.size()) {
element.keyword = str.substr(element_start);
element.setcode = dataManager.GetSetCode(element.keyword.c_str());
query_elements.push_back(element);
}
}
query_elements.push_back(str.substr(element_start));
std::unordered_map<std::wstring, unsigned int> set_code_map;
for(auto elements_iterator = query_elements.begin(); elements_iterator != query_elements.end(); elements_iterator++) {
const wchar_t* element_pointer = elements_iterator->c_str();
if(element_pointer[0] == L'@')
set_code_map[*elements_iterator] = dataManager.GetSetCode(&element_pointer[1]);
else
set_code_map[*elements_iterator] = dataManager.GetSetCode(&element_pointer[0]);
if(element_pointer[0] == 0 || (element_pointer[0] == L'$' && element_pointer[1] == 0) || (element_pointer[0] == L'@' && element_pointer[1] == 0))
query_elements_track.push_back(elements_iterator);
}
for(auto elements_track_iterator = query_elements_track.begin(); elements_track_iterator != query_elements_track.end(); elements_track_iterator++)
query_elements.erase(*elements_track_iterator);
unsigned int set_code = 0;
if(pstr[0] == L'@')
set_code = dataManager.GetSetCode(&pstr[1]);
else
set_code = dataManager.GetSetCode(&pstr[0]);
if(pstr[0] == 0 || (pstr[0] == L'$' && pstr[1] == 0) || (pstr[0] == L'@' && pstr[1] == 0))
pstr = 0;
auto strpointer = dataManager._strings.begin();
for(code_pointer ptr = dataManager._datas.begin(); ptr != dataManager._datas.end(); ++ptr, ++strpointer) {
const CardDataC& data = ptr->second;
Expand Down Expand Up @@ -885,33 +921,29 @@ void DeckBuilder::FilterCards() {
continue;
}
bool is_target = true;
for (auto elements_iterator = query_elements.begin(); elements_iterator != query_elements.end(); elements_iterator++) {
const wchar_t* element_pointer = elements_iterator->c_str();
if (element_pointer[0] == L'$') {
if(!CardNameContains(text.name.c_str(), &element_pointer[1])){
is_target = false;
break;
}
}
else if (element_pointer[0] == L'@' && set_code_map[*elements_iterator]) {
if(!check_set_code(data, set_code_map[*elements_iterator])) {
is_target = false;
break;
}
for (auto elements_iterator = query_elements.begin(); elements_iterator != query_elements.end(); ++elements_iterator) {
bool match = false;
if (elements_iterator->type == element_t::type_t::name) {
match = CardNameContains(text.name.c_str(), elements_iterator->keyword.c_str());
} else if (elements_iterator->type == element_t::type_t::setcode) {
match = elements_iterator->setcode && check_set_code(data, elements_iterator->setcode);
} else {
int trycode = BufferIO::GetVal(elements_iterator->c_str());
int trycode = BufferIO::GetVal(elements_iterator->keyword.c_str());
bool tryresult = dataManager.GetData(trycode, 0);
if(!tryresult && !CardNameContains(text.name.c_str(), elements_iterator->c_str()) && text.text.find(elements_iterator->c_str()) == std::wstring::npos
&& (!set_code_map[*elements_iterator] || !check_set_code(data, set_code_map[*elements_iterator]))) {
is_target = false;
break;
}
if(tryresult && data.code != trycode
&& !(data.alias == trycode && (data.alias - data.code < CARD_ARTWORK_VERSIONS_OFFSET || data.code - data.alias < CARD_ARTWORK_VERSIONS_OFFSET))) {
is_target = false;
break;
if(!tryresult) {
match = CardNameContains(text.name.c_str(), elements_iterator->keyword.c_str())
|| text.text.find(elements_iterator->keyword) != std::wstring::npos
|| (elements_iterator->setcode && check_set_code(data, elements_iterator->setcode));
} else {
match = data.code == trycode || data.alias == trycode;
}
}
if(elements_iterator->exclude)
match = !match;
if(!match) {
is_target = false;
break;
}
}
if(is_target)
results.push_back(ptr);
Expand Down
5 changes: 4 additions & 1 deletion gframe/duelclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ char DuelClient::duel_client_read[0x2000];
char DuelClient::duel_client_write[0x2000];
bool DuelClient::is_closing = false;
int DuelClient::select_hint = 0;
int DuelClient::select_unselect_hint = 0;
wchar_t DuelClient::event_string[256];
mtrandom DuelClient::rnd;

Expand Down Expand Up @@ -1452,7 +1453,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
std::sort(mainGame->dField.selectable_cards.begin(), mainGame->dField.selectable_cards.end(), ClientCard::client_card_sort);
if(select_hint)
myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetDesc(select_hint),
select_unselect_hint = select_hint;
if(select_unselect_hint)
myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetDesc(select_unselect_hint),
mainGame->dField.select_min, mainGame->dField.select_max);
else myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetSysString(560), mainGame->dField.select_min, mainGame->dField.select_max);
select_hint = 0;
Expand Down
1 change: 1 addition & 0 deletions gframe/duelclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class DuelClient {
static char duel_client_write[0x2000];
static bool is_closing;
static int select_hint;
static int select_unselect_hint;
static wchar_t event_string[256];
static mtrandom rnd;
public:
Expand Down
3 changes: 2 additions & 1 deletion gframe/event_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,8 @@ void ClientField::ShowCardInfoInList(ClientCard* pcard, irr::gui::IGUIElement* e
if(pcard->code) {
str.append(dataManager.GetName(pcard->code));
}
if(pcard->status & STATUS_PROC_COMPLETE)
if((pcard->status & STATUS_PROC_COMPLETE)
&& (pcard->type & (TYPE_RITUAL | TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK | TYPE_SPSUMMON)))
str.append(L"\n").append(dataManager.GetSysString(224));
for(size_t i = 0; i < chains.size(); ++i) {
wchar_t formatBuffer[2048];
Expand Down
2 changes: 1 addition & 1 deletion gframe/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "netserver.h"
#include "single_mode.h"

const unsigned short PRO_VERSION = 0x1347;
const unsigned short PRO_VERSION = 0x1348;

namespace ygo {

Expand Down
15 changes: 6 additions & 9 deletions gframe/myfilesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
#include <functional>
#include "bufferio.h"

#ifdef _WIN32
#include <direct.h>
#include <sys/stat.h>
#else
#ifndef _WIN32
#include <dirent.h>
#include <sys/stat.h>
#endif
Expand All @@ -20,8 +17,8 @@
class FileSystem {
public:
static bool IsFileExists(const wchar_t* wfile) {
struct _stat fileStat;
return (_wstat(wfile, &fileStat) == 0) && !(fileStat.st_mode & _S_IFDIR);
DWORD attr = GetFileAttributesW(wfile);
return attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY);
}

static bool IsFileExists(const char* file) {
Expand All @@ -31,8 +28,8 @@ class FileSystem {
}

static bool IsDirExists(const wchar_t* wdir) {
struct _stat fileStat;
return (_wstat(wdir, &fileStat) == 0) && (fileStat.st_mode & _S_IFDIR);
DWORD attr = GetFileAttributesW(wdir);
return attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY);
}

static bool IsDirExists(const char* dir) {
Expand All @@ -42,7 +39,7 @@ class FileSystem {
}

static bool MakeDir(const wchar_t* wdir) {
return _wmkdir(wdir) == 0;
return CreateDirectoryW(wdir, NULL);
}

static bool MakeDir(const char* dir) {
Expand Down
2 changes: 1 addition & 1 deletion ocgcore
2 changes: 1 addition & 1 deletion script
5 changes: 3 additions & 2 deletions strings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@
!setname 0x82 怒怒怒 ドドド
!setname 0x83 机关傀儡 ギミック・パペット
!setname 0x84 燃烧拳击手 BK(バーニングナックラー)
!setname 0x85 超级防御机器人 SDロボ
!setname 0x85 超级防卫机器人 SDロボ
!setname 0x86 光天使
!setname 0x87 阴影 アンブラル
!setname 0x88 武神
Expand All @@ -752,7 +752,7 @@
#setname 0x8c 德鲁伊 ドルイド
!setname 0x8d 鬼计 ゴーストリック
!setname 0x8e 吸血鬼 ヴァンパイア
!setname 0x8f 刷啦啦 ズババ
!setname 0x8f 刷拉拉 ズババ
!setname 0x90 森罗 森羅
!setname 0x91 王家长眠之谷 ネクロバレー
!setname 0x92 纹章 メダリオン
Expand Down Expand Up @@ -819,6 +819,7 @@
!setname 0xbf 灵使 霊使い
!setname 0xc0 凭依装着 憑依装着
!setname 0xc1 PSY骨架 PSYフレーム
!setname 0x10c1 PSY骨架装备 PSYフレームギア
!setname 0xc2 动力工具 パワー・ツール
!setname 0xc3 锋利小鬼 エッジインプ
!setname 0xc4 神数 セフィラ
Expand Down

0 comments on commit 2f81e73

Please sign in to comment.