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 May 1, 2020
2 parents 9db164e + 2acbb94 commit 6392ce1
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 18 deletions.
6 changes: 6 additions & 0 deletions gframe/deck_con.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
case irr::gui::EGET_EDITBOX_ENTER: {
switch(id) {
case EDITBOX_INPUTS:
case EDITBOX_KEYWORD: {
StartFilter();
break;
Expand Down Expand Up @@ -471,6 +472,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break;
}
}
mainGame->env->setFocus(0);
InstantSearch();
break;
}
Expand All @@ -488,13 +490,16 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->ebDefense->setEnabled(true);
}
}
mainGame->env->setFocus(0);
InstantSearch();
break;
}
case COMBOBOX_ATTRIBUTE:
case COMBOBOX_RACE:
case COMBOBOX_LIMIT:
mainGame->env->setFocus(0);
InstantSearch();
break;
}
}
default: break;
Expand Down Expand Up @@ -1069,6 +1074,7 @@ bool DeckBuilder::CardNameContains(const wchar_t *haystack, const wchar_t *needl
return true;
}
} else {
i -= j;
j = 0;
}
i++;
Expand Down
3 changes: 2 additions & 1 deletion gframe/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ void Game::DrawCard(ClientCard* pcard) {
matManager.mTexture.setTexture(0, imageManager.tAttack);
driver->setMaterial(matManager.mTexture);
irr::core::matrix4 atk;
atk.setTranslation(pcard->curPos + vector3df(0, -atkdy / 4.0f - 0.35f, 0.05f));
atk.setTranslation(pcard->curPos + vector3df(0, (pcard->controler == 0 ? -1 : 1) * (atkdy / 4.0f + 0.35f), 0.05f));
atk.setRotationRadians(vector3df(0, 0, pcard->controler == 0 ? 0 : 3.1415926f));
driver->setTransform(irr::video::ETS_WORLD, atk);
driver->drawVertexPrimitiveList(matManager.vSymbol, 4, matManager.iRectangle, 2);
}
Expand Down
24 changes: 23 additions & 1 deletion gframe/duelclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,19 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.unlock();
break;
}
case STOC_DECK_COUNT: {
mainGame->gMutex.lock();
int deckc = BufferIO::ReadInt16(pdata);
int extrac = BufferIO::ReadInt16(pdata);
int sidec = BufferIO::ReadInt16(pdata);
mainGame->dField.Initial(0, deckc, extrac);
deckc = BufferIO::ReadInt16(pdata);
extrac = BufferIO::ReadInt16(pdata);
sidec = BufferIO::ReadInt16(pdata);
mainGame->dField.Initial(1, deckc, extrac);
mainGame->gMutex.unlock();
break;
}
case STOC_JOIN_GAME: {
STOC_JoinGame* pkt = (STOC_JoinGame*)pdata;
std::wstring str;
Expand Down Expand Up @@ -1164,6 +1177,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->WaitFrameSignal(40);
mainGame->showcard = 0;
mainGame->gMutex.lock();
mainGame->dField.Clear();
int playertype = BufferIO::ReadInt8(pbuf);
mainGame->dInfo.isFirst = (playertype & 0xf) ? false : true;
if(playertype & 0xf0)
Expand Down Expand Up @@ -1462,6 +1476,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int c, l, s, ss;
unsigned int code;
bool panelmode = false;
int handcount = 0;
bool select_ready = mainGame->dField.select_min == 0;
mainGame->dField.select_ready = select_ready;
ClientCard* pcard;
Expand All @@ -1483,6 +1498,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->is_selected = false;
if (l & 0xf1)
panelmode = true;
if(l & LOCATION_HAND) {
handcount++;
if(handcount >= 10)
panelmode = true;
}
}
std::sort(mainGame->dField.selectable_cards.begin(), mainGame->dField.selectable_cards.end(), ClientCard::client_card_sort);
if(select_hint)
Expand Down Expand Up @@ -1689,9 +1709,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
case MSG_SELECT_PLACE:
case MSG_SELECT_DISFIELD: {
/*int selecting_player = */BufferIO::ReadInt8(pbuf);
int selecting_player = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_min = BufferIO::ReadInt8(pbuf);
mainGame->dField.selectable_field = ~BufferIO::ReadInt32(pbuf);
if(selecting_player == mainGame->LocalPlayer(1))
mainGame->dField.selectable_field = (mainGame->dField.selectable_field >> 16) | (mainGame->dField.selectable_field << 16);
mainGame->dField.selected_field = 0;
unsigned char respbuf[64];
int pzone = 0;
Expand Down
28 changes: 15 additions & 13 deletions 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 = 0x1350;
const unsigned short PRO_VERSION = 0x1351;

namespace ygo {

Expand Down Expand Up @@ -458,10 +458,10 @@ bool Game::Initialize() {
wANNumber->setVisible(false);
cbANNumber = env->addComboBox(rect<s32>(40, 30, 190, 50), wANNumber, -1);
cbANNumber->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
for(int i = 0; i < 12; ++i) {
myswprintf(strbuf, L"%d", i + 1);
btnANNumber[i] = env->addButton(rect<s32>(20 + 50 * (i % 4), 40 + 50 * (i / 4), 60 + 50 * (i % 4), 80 + 50 * (i / 4)), wANNumber, BUTTON_ANNUMBER_1 + i, strbuf);
btnANNumber[i]->setIsPushButton(true);
for(int i = 0; i < 12; ++i) {
myswprintf(strbuf, L"%d", i + 1);
btnANNumber[i] = env->addButton(rect<s32>(20 + 50 * (i % 4), 40 + 50 * (i / 4), 60 + 50 * (i % 4), 80 + 50 * (i / 4)), wANNumber, BUTTON_ANNUMBER_1 + i, strbuf);
btnANNumber[i]->setIsPushButton(true);
}
btnANNumberOK = env->addButton(rect<s32>(80, 60, 150, 85), wANNumber, BUTTON_ANNUMBER_OK, dataManager.GetSysString(1211));
//announce card
Expand Down Expand Up @@ -581,16 +581,16 @@ bool Game::Initialize() {
for(int filter = 0x1; filter != 0x2000000; filter <<= 1)
cbRace->addItem(dataManager.FormatRace(filter), filter);
stAttack = env->addStaticText(dataManager.GetSysString(1322), rect<s32>(205, 22 + 50 / 6, 280, 42 + 50 / 6), false, false, wFilter);
ebAttack = env->addEditBox(L"", rect<s32>(260, 20 + 50 / 6, 340, 40 + 50 / 6), true, wFilter);
ebAttack = env->addEditBox(L"", rect<s32>(260, 20 + 50 / 6, 340, 40 + 50 / 6), true, wFilter, EDITBOX_INPUTS);
ebAttack->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
stDefense = env->addStaticText(dataManager.GetSysString(1323), rect<s32>(205, 42 + 75 / 6, 280, 62 + 75 / 6), false, false, wFilter);
ebDefense = env->addEditBox(L"", rect<s32>(260, 40 + 75 / 6, 340, 60 + 75 / 6), true, wFilter);
ebDefense = env->addEditBox(L"", rect<s32>(260, 40 + 75 / 6, 340, 60 + 75 / 6), true, wFilter, EDITBOX_INPUTS);
ebDefense->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
stStar = env->addStaticText(dataManager.GetSysString(1324), rect<s32>(10, 62 + 100 / 6, 80, 82 + 100 / 6), false, false, wFilter);
ebStar = env->addEditBox(L"", rect<s32>(60, 60 + 100 / 6, 100, 80 + 100 / 6), true, wFilter);
ebStar = env->addEditBox(L"", rect<s32>(60, 60 + 100 / 6, 100, 80 + 100 / 6), true, wFilter, EDITBOX_INPUTS);
ebStar->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
stScale = env->addStaticText(dataManager.GetSysString(1336), rect<s32>(101, 62 + 100 / 6, 150, 82 + 100 / 6), false, false, wFilter);
ebScale = env->addEditBox(L"", rect<s32>(150, 60 + 100 / 6, 190, 80 + 100 / 6), true, wFilter);
ebScale = env->addEditBox(L"", rect<s32>(150, 60 + 100 / 6, 190, 80 + 100 / 6), true, wFilter, EDITBOX_INPUTS);
ebScale->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
stSearch = env->addStaticText(dataManager.GetSysString(1325), rect<s32>(205, 62 + 100 / 6, 280, 82 + 100 / 6), false, false, wFilter);
ebCardName = env->addEditBox(L"", rect<s32>(260, 60 + 100 / 6, 390, 80 + 100 / 6), true, wFilter, EDITBOX_KEYWORD);
Expand Down Expand Up @@ -906,7 +906,9 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
wchar_t c = text[i];
u32 w = font->getCharDimension(c).Width + font->getKerningWidth(c, prev);
prev = c;
if(text[i] == L'\n') {
if(text[i] == L'\r') {
continue;
} else if(text[i] == L'\n') {
dataManager.strBuffer[pbuffer++] = L'\n';
_width = 0;
_height++;
Expand Down Expand Up @@ -935,15 +937,15 @@ void Game::LoadExpansions() {
myswprintf(fpath, L"./expansions/%ls", name);
dataManager.LoadDB(fpath);
}
if(!isdir && wcsrchr(name, '.') && !mywcsncasecmp(wcsrchr(name, '.'), L".zip", 4)) {
if(!isdir && wcsrchr(name, '.') && (!mywcsncasecmp(wcsrchr(name, '.'), L".zip", 4) || !mywcsncasecmp(wcsrchr(name, '.'), L".ypk", 4))) {
wchar_t fpath[1024];
myswprintf(fpath, L"./expansions/%ls", name);
#ifdef _WIN32
dataManager.FileSystem->addFileArchive(fpath, true, false);
dataManager.FileSystem->addFileArchive(fpath, true, false, EFAT_ZIP);
#else
char upath[1024];
BufferIO::EncodeUTF8(fpath, upath);
dataManager.FileSystem->addFileArchive(upath, true, false);
dataManager.FileSystem->addFileArchive(upath, true, false, EFAT_ZIP);
#endif
}
});
Expand Down
9 changes: 8 additions & 1 deletion gframe/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ class Game {
return focus && focus->hasType(type);
}

void TrimText(irr::gui::IGUIElement* editbox) const {
irr::core::stringw text(editbox->getText());
text.trim();
editbox->setText(text.c_str());
}

void OnResize();
recti Resize(s32 x, s32 y, s32 x2, s32 y2);
recti Resize(s32 x, s32 y, s32 x2, s32 y2, s32 dx, s32 dy, s32 dx2, s32 dy2);
Expand Down Expand Up @@ -699,6 +705,7 @@ extern Game* mainGame;
#define BUTTON_MARKS_FILTER 322
#define BUTTON_MARKERS_OK 323
#define COMBOBOX_SORTTYPE 324
#define EDITBOX_INPUTS 325
#define BUTTON_CLEAR_LOG 350
#define LISTBOX_LOG 351
#define SCROLL_CARDTEXT 352
Expand All @@ -717,7 +724,7 @@ extern Game* mainGame;
#define CHECKBOX_MULTI_KEYWORDS 372
#define CHECKBOX_PREFER_EXPANSION 373

#define DEFAULT_DUEL_RULE 4
#define DEFAULT_DUEL_RULE 5

#define CARD_ARTWORK_VERSIONS_OFFSET 10
#endif // GAME_H
2 changes: 2 additions & 0 deletions gframe/menu_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
case BUTTON_JOIN_HOST: {
bot_mode = false;
mainGame->TrimText(mainGame->ebJoinHost);
mainGame->TrimText(mainGame->ebJoinPort);
char ip[20];
const wchar_t* pstr = mainGame->ebJoinHost->getText();
BufferIO::CopyWStr(pstr, ip, 16);
Expand Down
1 change: 1 addition & 0 deletions gframe/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class DuelMode {
#define STOC_TP_RESULT 0x6
#define STOC_CHANGE_SIDE 0x7
#define STOC_WAITING_SIDE 0x8
#define STOC_DECK_COUNT 0x9
#define STOC_CREATE_GAME 0x11
#define STOC_JOIN_GAME 0x12
#define STOC_TYPE_CHANGE 0x13
Expand Down
1 change: 1 addition & 0 deletions gframe/replay_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ void ReplayMode::EndDuel() {
mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true;
mainGame->dInfo.isReplay = false;
mainGame->dInfo.isSingleMode = false;
mainGame->gMutex.unlock();
mainGame->closeDoneSignal.Reset();
mainGame->closeSignal.Set();
Expand Down
14 changes: 14 additions & 0 deletions gframe/single_duel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,20 @@ void SingleDuel::StartDuel(DuelPlayer* dp) {
(*oit)->state = CTOS_LEAVE_GAME;
NetServer::ReSendToPlayer(*oit);
}
char deckbuff[12];
char* pbuf = deckbuff;
BufferIO::WriteInt16(pbuf, pdeck[0].main.size());
BufferIO::WriteInt16(pbuf, pdeck[0].extra.size());
BufferIO::WriteInt16(pbuf, pdeck[0].side.size());
BufferIO::WriteInt16(pbuf, pdeck[1].main.size());
BufferIO::WriteInt16(pbuf, pdeck[1].extra.size());
BufferIO::WriteInt16(pbuf, pdeck[1].side.size());
NetServer::SendBufferToPlayer(players[0], STOC_DECK_COUNT, deckbuff, 12);
char tempbuff[6];
memcpy(tempbuff, deckbuff, 6);
memcpy(deckbuff, deckbuff + 6, 6);
memcpy(deckbuff + 6, tempbuff, 6);
NetServer::SendBufferToPlayer(players[1], STOC_DECK_COUNT, deckbuff, 12);
NetServer::SendPacketToPlayer(players[0], STOC_SELECT_HAND);
NetServer::ReSendToPlayer(players[1]);
hand_result[0] = 0;
Expand Down
16 changes: 16 additions & 0 deletions gframe/tag_duel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,22 @@ void TagDuel::StartDuel(DuelPlayer* dp) {
(*oit)->state = CTOS_LEAVE_GAME;
NetServer::ReSendToPlayer(*oit);
}
char deckbuff[12];
char* pbuf = deckbuff;
BufferIO::WriteInt16(pbuf, pdeck[0].main.size());
BufferIO::WriteInt16(pbuf, pdeck[0].extra.size());
BufferIO::WriteInt16(pbuf, pdeck[0].side.size());
BufferIO::WriteInt16(pbuf, pdeck[2].main.size());
BufferIO::WriteInt16(pbuf, pdeck[2].extra.size());
BufferIO::WriteInt16(pbuf, pdeck[2].side.size());
NetServer::SendBufferToPlayer(players[0], STOC_DECK_COUNT, deckbuff, 12);
NetServer::ReSendToPlayer(players[1]);
char tempbuff[6];
memcpy(tempbuff, deckbuff, 6);
memcpy(deckbuff, deckbuff + 6, 6);
memcpy(deckbuff + 6, tempbuff, 6);
NetServer::SendBufferToPlayer(players[2], STOC_DECK_COUNT, deckbuff, 12);
NetServer::ReSendToPlayer(players[3]);
NetServer::SendPacketToPlayer(players[0], STOC_SELECT_HAND);
NetServer::ReSendToPlayer(players[2]);
hand_result[0] = 0;
Expand Down
2 changes: 1 addition & 1 deletion ocgcore
2 changes: 1 addition & 1 deletion script
4 changes: 4 additions & 0 deletions strings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1008,3 +1008,7 @@
!setname 0x2142 黄金国永生药 エルドリクシル
!setname 0x143 黄金乡 黄金郷
!setname 0x144 幻魔
!setname 0x145 教导 ドラグマ
!setname 0x146 童话动物 メルフィー
!setname 0x147 波波 ポータン
!setname 0x148 罗兰 ローラン

0 comments on commit 6392ce1

Please sign in to comment.