Skip to content
This repository has been archived by the owner on Apr 6, 2018. It is now read-only.

Commit

Permalink
Merge branch 'koishibuild' of /root/7210 into local
Browse files Browse the repository at this point in the history
  • Loading branch information
Smile-DK committed Mar 10, 2018
2 parents 757349c + 7b9c850 commit 0729b27
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 47 deletions.
Binary file modified cards.cdb
Binary file not shown.
6 changes: 3 additions & 3 deletions gframe/client_card.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ struct CardDataC {
unsigned int category;
};
struct CardString {
wchar_t* name;
wchar_t* text;
wchar_t* desc[16];
std::wstring name;
std::wstring text;
std::wstring desc[16];
};
typedef std::unordered_map<unsigned int, CardDataC>::const_iterator code_pointer;

Expand Down
20 changes: 10 additions & 10 deletions gframe/client_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,7 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd) && is_declarable(cd, declarable_type)) {
mainGame->lstANCard->clear();
ancard.clear();
mainGame->lstANCard->addItem(cstr.name);
mainGame->lstANCard->addItem(cstr.name.c_str());
ancard.push_back(trycode);
return;
}
Expand All @@ -1403,15 +1403,15 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
mainGame->lstANCard->clear();
ancard.clear();
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
//datas.alias can be double card names or alias
if(is_declarable(cp->second, declarable_type)) {
if(wcscmp(pname, cit->second.name) == 0) { //exact match
mainGame->lstANCard->insertItem(0, cit->second.name, -1);
if(pname == cit->second.name) { //exact match
mainGame->lstANCard->insertItem(0, cit->second.name.c_str(), -1);
ancard.insert(ancard.begin(), cit->first);
} else {
mainGame->lstANCard->addItem(cit->second.name);
mainGame->lstANCard->addItem(cit->second.name.c_str());
ancard.push_back(cit->first);
}
}
Expand All @@ -1426,7 +1426,7 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd) && is_declarable(cd, opcode)) {
mainGame->lstANCard->clear();
ancard.clear();
mainGame->lstANCard->addItem(cstr.name);
mainGame->lstANCard->addItem(cstr.name.c_str());
ancard.push_back(trycode);
return;
}
Expand All @@ -1435,15 +1435,15 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
mainGame->lstANCard->clear();
ancard.clear();
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
//datas.alias can be double card names or alias
if(is_declarable(cp->second, opcode)) {
if(wcscmp(pname, cit->second.name) == 0) { //exact match
mainGame->lstANCard->insertItem(0, cit->second.name, -1);
if(pname == cit->second.name) { //exact match
mainGame->lstANCard->insertItem(0, cit->second.name.c_str(), -1);
ancard.insert(ancard.begin(), cit->first);
} else {
mainGame->lstANCard->addItem(cit->second.name);
mainGame->lstANCard->addItem(cit->second.name.c_str());
ancard.push_back(cit->first);
}
}
Expand Down
51 changes: 22 additions & 29 deletions gframe/data_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ bool DataManager::LoadDB(const char* file) {
return Error(pDB);
CardDataC cd;
CardString cs;
for(int i = 0; i < 16; ++i) cs.desc[i] = 0;
int step = 0, len = 0;
int step = 0;
do {
step = sqlite3_step(pStmt);
if(step == SQLITE_BUSY || step == SQLITE_ERROR || step == SQLITE_MISUSE)
Expand All @@ -44,27 +43,21 @@ bool DataManager::LoadDB(const char* file) {
cd.attribute = sqlite3_column_int(pStmt, 9);
cd.category = sqlite3_column_int(pStmt, 10);
_datas.insert(std::make_pair(cd.code, cd));
len = BufferIO::DecodeUTF8((const char*)sqlite3_column_text(pStmt, 12), strBuffer);
if(len) {
cs.name = new wchar_t[len + 1];
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;
if(const char* text = (const char*)sqlite3_column_text(pStmt, 12)) {
BufferIO::DecodeUTF8(text, strBuffer);
cs.name = strBuffer;
}
for(int i = 14; i < 30; ++i) {
len = BufferIO::DecodeUTF8((const char*)sqlite3_column_text(pStmt, i), strBuffer);
if(len) {
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;
if(const char* text = (const char*)sqlite3_column_text(pStmt, 13)) {
BufferIO::DecodeUTF8(text, strBuffer);
cs.text = strBuffer;
}
_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);
}
} while(step != SQLITE_DONE);
sqlite3_finalize(pStmt);
Expand Down Expand Up @@ -126,8 +119,8 @@ code_pointer DataManager::GetCodePointer(int code) {
bool DataManager::GetString(int code, CardString* pStr) {
auto csit = _strings.find(code);
if(csit == _strings.end()) {
pStr->name = (wchar_t*)unknown_string;
pStr->text = (wchar_t*)unknown_string;
pStr->name = unknown_string;
pStr->text = unknown_string;
return false;
}
*pStr = csit->second;
Expand All @@ -137,16 +130,16 @@ const wchar_t* DataManager::GetName(int code) {
auto csit = _strings.find(code);
if(csit == _strings.end())
return unknown_string;
if(csit->second.name)
return csit->second.name;
if(!csit->second.name.empty())
return csit->second.name.c_str();
return unknown_string;
}
const wchar_t* DataManager::GetText(int code) {
auto csit = _strings.find(code);
if(csit == _strings.end())
return unknown_string;
if(csit->second.text)
return csit->second.text;
if(!csit->second.text.empty())
return csit->second.text.c_str();
return unknown_string;
}
const wchar_t* DataManager::GetDesc(int strCode) {
Expand All @@ -157,8 +150,8 @@ const wchar_t* DataManager::GetDesc(int strCode) {
auto csit = _strings.find(code);
if(csit == _strings.end())
return unknown_string;
if(csit->second.desc[offset])
return csit->second.desc[offset];
if(!csit->second.desc[offset].empty())
return csit->second.desc[offset].c_str();
return unknown_string;
}
const wchar_t* DataManager::GetSysString(int code) {
Expand Down
4 changes: 2 additions & 2 deletions gframe/deck_con.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ void DeckBuilder::FilterCards() {
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, &element_pointer[1])){
if(!CardNameContains(text.name.c_str(), &element_pointer[1])){
is_target = false;
break;
}
Expand All @@ -890,7 +890,7 @@ void DeckBuilder::FilterCards() {
break;
}
} else {
if (!CardNameContains(text.name, elements_iterator->c_str()) && wcsstr(text.text, elements_iterator->c_str()) == 0
if (!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;
Expand Down
6 changes: 3 additions & 3 deletions strings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,6 @@
!setname 0x111 武装龙 アームド・ドラゴン
!setname 0x112 幻崩 トロイメア
!setname 0x113 灵神 霊神
!setname 0x114 空牙团
!setname 0x115 闪刀
!setname 0x1115 闪刀姬
!setname 0x114 空牙团 空牙団
!setname 0x115 闪刀 閃刀
!setname 0x1115 闪刀姬 閃刀姫

0 comments on commit 0729b27

Please sign in to comment.