Commit 61477d92 authored by nanahira's avatar nanahira

Merge branch 'develop' into server-develop

parents 6f64705a 893b83b3
......@@ -14,6 +14,14 @@ using CardData = card_data;
struct CardDataC : card_data {
unsigned int ot{};
unsigned int category{};
bool is_setcodes(std::vector <uint32> values) const {
for (auto& value : values) {
if (is_setcode(value))
return true;
}
return false;
}
};
struct CardString {
std::wstring name;
......
......@@ -693,8 +693,7 @@ void ClientField::ShowSelectOption(int select_hint) {
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + newheight;
mainGame->wOptions->setRelativePosition(pos);
} else {
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->guiFont,
(wchar_t*)dataManager.GetDesc(select_options[0]));
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->guiFont, dataManager.GetDesc(select_options[0]));
mainGame->stOptions->setVisible(true);
mainGame->btnOptionp->setVisible(false);
mainGame->btnOptionn->setVisible(count > 1);
......
......@@ -308,17 +308,27 @@ const wchar_t* DataManager::GetSetName(int code) {
return NULL;
return csit->second.c_str();
}
unsigned int DataManager::GetSetCode(const wchar_t* setname) {
std::vector<unsigned int> DataManager::GetSetCodes(std::wstring setname) {
std::vector<unsigned int> matchingCodes;
for(auto csit = _setnameStrings.begin(); csit != _setnameStrings.end(); ++csit) {
auto xpos = csit->second.find_first_of(L'|');//setname|another setname or extra info
if(csit->second.compare(0, xpos, setname) == 0 || csit->second.compare(xpos + 1, csit->second.length(), setname) == 0
#ifndef YGOPRO_SERVER_MODE
|| mainGame->CheckRegEx(csit->second, setname, true)
if (mainGame->CheckRegEx(csit->second, setname, true)) {
matchingCodes.push_back(csit->first);
} else
#endif
)
return csit->first;
if(setname.size() < 2) {
if(csit->second.compare(0, xpos, setname) == 0
|| csit->second.compare(xpos + 1, csit->second.length(), setname) == 0)
matchingCodes.push_back(csit->first);
} else {
if(csit->second.substr(0, xpos).find(setname) != std::wstring::npos
|| csit->second.substr(xpos + 1).find(setname) != std::wstring::npos) {
matchingCodes.push_back(csit->first);
}
}
}
return 0;
return matchingCodes;
}
const wchar_t* DataManager::GetNumString(int num, bool bracket) {
if(!bracket)
......
......@@ -38,7 +38,7 @@ public:
const wchar_t* GetVictoryString(int code);
const wchar_t* GetCounterName(int code);
const wchar_t* GetSetName(int code);
unsigned int GetSetCode(const wchar_t* setname);
std::vector<unsigned int> GetSetCodes(std::wstring setname);
const wchar_t* GetNumString(int num, bool bracket = false);
const wchar_t* FormatLocation(int location, int sequence);
const wchar_t* FormatAttribute(int attribute);
......
......@@ -1380,14 +1380,14 @@ void DeckBuilder::FilterCards() {
results.clear();
struct element_t {
std::wstring keyword;
unsigned int setcode;
std::vector<unsigned int> setcodes;
enum class type_t {
all,
name,
setcode
} type;
bool exclude;
element_t(): setcode(0), type(type_t::all), exclude(false) {}
element_t(): type(type_t::all), exclude(false) {}
};
const wchar_t* pstr = mainGame->ebCardName->getText();
std::wstring str = std::wstring(pstr);
......@@ -1428,7 +1428,7 @@ void DeckBuilder::FilterCards() {
element.keyword = str.substr(element_start, length);
} else
element.keyword = str.substr(element_start);
element.setcode = dataManager.GetSetCode(element.keyword.c_str());
element.setcodes = dataManager.GetSetCodes(element.keyword);
query_elements.push_back(element);
if(element_end == std::wstring::npos)
break;
......@@ -1446,7 +1446,7 @@ void DeckBuilder::FilterCards() {
}
if(element_start < str.size()) {
element.keyword = str.substr(element_start);
element.setcode = dataManager.GetSetCode(element.keyword.c_str());
element.setcodes = dataManager.GetSetCodes(element.keyword);
query_elements.push_back(element);
}
}
......@@ -1533,7 +1533,7 @@ void DeckBuilder::FilterCards() {
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 && data.is_setcode(elements_iterator->setcode);
match = data.is_setcodes(elements_iterator->setcodes);
} else {
int trycode = BufferIO::GetVal(elements_iterator->keyword.c_str());
bool tryresult = dataManager.GetData(trycode, 0);
......@@ -1541,7 +1541,7 @@ void DeckBuilder::FilterCards() {
match = CardNameContains(text.name.c_str(), elements_iterator->keyword.c_str())
|| text.text.find(elements_iterator->keyword) != std::wstring::npos
|| mainGame->CheckRegEx(text.text, elements_iterator->keyword)
|| (elements_iterator->setcode && data.is_setcode(elements_iterator->setcode));
|| data.is_setcodes(elements_iterator->setcodes);
} else {
match = data.code == trycode || data.alias == trycode;
}
......
......@@ -238,7 +238,7 @@ void DeckManager::GetCategoryPath(wchar_t* ret, int index, const wchar_t* text)
void DeckManager::GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck) {
wchar_t filepath[256];
wchar_t catepath[256];
wchar_t* deckname = (wchar_t*)cbDeck->getItem(cbDeck->getSelected());
const wchar_t* deckname = cbDeck->getItem(cbDeck->getSelected());
if(deckname != NULL) {
GetCategoryPath(catepath, cbCategory->getSelected(), cbCategory->getText());
myswprintf(filepath, L"%ls/%ls.ydk", catepath, deckname);
......
......@@ -2,16 +2,12 @@
#include "lzma/LzmaLib.h"
namespace ygo {
#ifdef YGOPRO_SERVER_MODE
extern unsigned short server_port;
extern unsigned short replay_mode;
#endif
Replay::Replay()
: fp(nullptr), pheader(), pdata(nullptr), replay_size(0), comp_size(0), is_recording(false), is_replaying(false) {
#ifdef _WIN32
recording_fp = nullptr;
#endif
Replay::Replay() {
replay_data = new unsigned char[MAX_REPLAY_SIZE];
comp_data = new unsigned char[MAX_COMP_SIZE];
}
......@@ -188,8 +184,8 @@ void Replay::EndRecord() {
comp_size = MAX_COMP_SIZE;
int ret = LzmaCompress(comp_data, &comp_size, replay_data, replay_size, pheader.props, &propsize, 5, 1 << 24, 3, 0, 2, 32, 1);
if (ret != SZ_OK) {
*((int*)(comp_data)) = ret;
comp_size = sizeof(ret);
std::memcpy(comp_data, &ret, sizeof ret);
comp_size = sizeof ret;
}
is_recording = false;
}
......
......@@ -23,16 +23,13 @@ namespace ygo {
#endif // YGOPRO_SERVER_MODE
struct ReplayHeader {
unsigned int id;
unsigned int version;
unsigned int flag;
unsigned int seed;
unsigned int datasize;
unsigned int start_time;
unsigned char props[8];
ReplayHeader()
: id(0), version(0), flag(0), seed(0), datasize(0), start_time(0), props{ 0 } {}
unsigned int id{};
unsigned int version{};
unsigned int flag{};
unsigned int seed{};
unsigned int datasize{};
unsigned int start_time{};
unsigned char props[8]{};
};
class Replay {
......@@ -65,21 +62,21 @@ public:
char ReadInt8();
void Rewind();
FILE* fp;
FILE* fp{ nullptr };
#ifdef _WIN32
HANDLE recording_fp;
HANDLE recording_fp{ nullptr };
#endif
ReplayHeader pheader;
unsigned char* replay_data;
unsigned char* comp_data;
size_t replay_size;
size_t comp_size;
size_t replay_size{};
size_t comp_size{};
private:
unsigned char* pdata;
bool is_recording;
bool is_replaying;
unsigned char* pdata{ nullptr };
bool is_recording{};
bool is_replaying{};
};
}
......
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