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 Jan 23, 2020
2 parents d985582 + 604ac65 commit 611ea1f
Show file tree
Hide file tree
Showing 21 changed files with 474 additions and 237 deletions.
2 changes: 1 addition & 1 deletion cmake/compiler/msvc.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_definitions ( "-wd4996" "-D_CRT_SECURE_NO_WARNINGS" "-D_ITERATOR_DEBUG_LEVEL=0" )
add_definitions ( "-wd4996" "-D_CRT_SECURE_NO_WARNINGS" )
add_definitions ( "-D_UNICODE" "-DUNICODE" "/utf-8" )

include (MSVCMultipleProcessCompile)
Expand Down
6 changes: 6 additions & 0 deletions gframe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ else ()
target_link_libraries (ygopro ${CMAKE_THREAD_LIBS_INIT} ${DL_LIBRARIES})
endif ()

if (APPLE)
find_library(COCOA_LIBRARY Cocoa)
find_library(IOKIT_LIBRARY IOKit)
target_link_libraries(ygopro ${COCOA_LIBRARY} ${IOKIT_LIBRARY})
endif ()

if (USE_IRRKLANG)
add_definitions ( "-DYGOPRO_USE_IRRKLANG" )
if (MSVC)
Expand Down
15 changes: 9 additions & 6 deletions gframe/client_card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,17 @@ bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) {
else return c1->sequence < c2->sequence;
else {
if(c1->location & (LOCATION_DECK | LOCATION_GRAVE | LOCATION_REMOVED | LOCATION_EXTRA)) {
for(size_t i = 0; i < mainGame->dField.chains.size(); ++i) {
auto chit = mainGame->dField.chains[i];
if(c1 == chit.chain_card || chit.target.find(c1) != chit.target.end())
return true;
auto it1 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c1](const auto& ch) {
return c1 == ch.chain_card || ch.target.find(c1) != ch.target.end();
});
auto it2 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c2](const auto& ch) {
return c2 == ch.chain_card || ch.target.find(c2) != ch.target.end();
});
if(it1 != mainGame->dField.chains.rend() || it2 != mainGame->dField.chains.rend()) {
return it1 < it2;
}
return c1->sequence > c2->sequence;
}
else
} else
return c1->sequence < c2->sequence;
}
}
Expand Down
4 changes: 3 additions & 1 deletion gframe/client_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ ClientField::ClientField() {
hovered_controler = 0;
hovered_location = 0;
hovered_sequence = 0;
selectable_field = 0;
selected_field = 0;
deck_act = false;
grave_act = false;
remove_act = false;
Expand Down Expand Up @@ -403,7 +405,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225));
mainGame->btnCardSelect[i]->setPressed(false);
mainGame->btnCardSelect[i]->setVisible(true);
if(mainGame->dInfo.curMsg != MSG_SORT_CHAIN && mainGame->dInfo.curMsg != MSG_SORT_CARD) {
if(mainGame->dInfo.curMsg != MSG_SORT_CARD) {
// text
wchar_t formatBuffer[2048];
if(conti_selecting)
Expand Down
5 changes: 3 additions & 2 deletions gframe/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#else //__APPLE__
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#endif //__APPLE__
#include "CGUITTFont.h"
#include "CGUIImageButton.h"
#include <iostream>
Expand All @@ -72,6 +72,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <time.h>
#include <thread>
#include <mutex>
#include <algorithm>
#include "bufferio.h"
#include "myfilesystem.h"
#include "mysignal.h"
Expand Down
1 change: 0 additions & 1 deletion gframe/deck_con.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "sound_manager.h"
#include "game.h"
#include "duelclient.h"
#include <algorithm>

namespace ygo {

Expand Down
5 changes: 3 additions & 2 deletions gframe/deck_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "data_manager.h"
#include "network.h"
#include "game.h"
#include <algorithm>

namespace ygo {

Expand Down Expand Up @@ -147,7 +146,9 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec) {
}
if(cd.type & TYPE_TOKEN)
continue;
else if(cd.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK) && deck.extra.size() < 15) {
else if(cd.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) {
if(deck.extra.size() >= 15)
continue;
deck.extra.push_back(dataManager.GetCodePointer(code)); //verified by GetData()
} else if(deck.main.size() < 60) {
deck.main.push_back(dataManager.GetCodePointer(code));
Expand Down
8 changes: 7 additions & 1 deletion gframe/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void Game::DrawBackGround() {
driver->drawVertexPrimitiveList(matManager.vField, 4, matManager.iRectangle, 2);
driver->setMaterial(matManager.mBackLine);
//select field
if(dInfo.curMsg == MSG_SELECT_PLACE || dInfo.curMsg == MSG_SELECT_DISFIELD) {
if(dInfo.curMsg == MSG_SELECT_PLACE || dInfo.curMsg == MSG_SELECT_DISFIELD || dInfo.curMsg == MSG_HINT) {
float cv[4] = {0.0f, 0.0f, 1.0f, 1.0f};
unsigned int filter = 0x1;
for (int i = 0; i < 7; ++i, filter <<= 1) {
Expand Down Expand Up @@ -1015,10 +1015,16 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
for(int i = 0; i < 5; ++i)
btnCardSelect[i]->setDrawImage(false);
dField.conti_selecting = false;
stCardListTip->setVisible(false);
for(auto& pcard : dField.selectable_cards)
dField.SetShowMark(pcard, false);
}
if(win == wCardDisplay) {
for(int i = 0; i < 5; ++i)
btnCardDisplay[i]->setDrawImage(false);
stCardListTip->setVisible(false);
for(auto& pcard : dField.display_cards)
dField.SetShowMark(pcard, false);
}
fadingList.push_back(fu);
}
Expand Down
63 changes: 47 additions & 16 deletions gframe/duelclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "game.h"
#include "replay.h"
#include "replay_mode.h"
#include <algorithm>

namespace ygo {

Expand Down Expand Up @@ -982,7 +981,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
case MSG_HINT: {
int type = BufferIO::ReadInt8(pbuf);
/*int player = */BufferIO::ReadInt8(pbuf);
int player = BufferIO::ReadInt8(pbuf);
int data = BufferIO::ReadInt32(pbuf);
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true;
Expand Down Expand Up @@ -1069,6 +1068,48 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->WaitFrameSignal(30);
break;
}
case HINT_ZONE: {
if(mainGame->LocalPlayer(player) == 1)
data = (data >> 16) | (data << 16);
for(unsigned filter = 0x1; filter != 0; filter <<= 1) {
std::wstring str;
if(unsigned s = filter & data) {
if(s & 0x60) {
str += dataManager.GetSysString(1081);
data &= ~0x600000;
} else if(s & 0xffff)
str += dataManager.GetSysString(102);
else if(s & 0xffff0000) {
str += dataManager.GetSysString(103);
s >>= 16;
}
if(s & 0x1f)
str += dataManager.GetSysString(1002);
else if(s & 0xff00) {
s >>= 8;
if(s & 0x1f)
str += dataManager.GetSysString(1003);
else if(s & 0x20)
str += dataManager.GetSysString(1008);
else if(s & 0xc0)
str += dataManager.GetSysString(1009);
}
int seq = 1;
for(int i = 0x1; i < 0x100; i <<= 1) {
if(s & i)
break;
++seq;
}
str += L"(" + std::to_wstring(seq) + L")";
myswprintf(textBuffer, dataManager.GetSysString(1510), str.c_str());
mainGame->AddLog(textBuffer);
}
}
mainGame->dField.selectable_field = data;
mainGame->WaitFrameSignal(40);
mainGame->dField.selectable_field = 0;
break;
}
}
break;
}
Expand All @@ -1085,7 +1126,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
else if(mainGame->LocalPlayer(player) == 0) {
mainGame->showcardcode = 1;
if(match_kill)
myswprintf(vic_buf, dataManager.GetVictoryString(0x20), dataManager.GetName(match_kill));
myswprintf(vic_buf, dataManager.GetVictoryString(0xffff), dataManager.GetName(match_kill));
else if(type < 0x10)
myswprintf(vic_buf, L"[%ls] %ls", mainGame->dInfo.clientname, dataManager.GetVictoryString(type));
else
Expand All @@ -1094,7 +1135,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} else {
mainGame->showcardcode = 2;
if(match_kill)
myswprintf(vic_buf, dataManager.GetVictoryString(0x20), dataManager.GetName(match_kill));
myswprintf(vic_buf, dataManager.GetVictoryString(0xffff), dataManager.GetName(match_kill));
else if(type < 0x10)
myswprintf(vic_buf, L"[%ls] %ls", mainGame->dInfo.hostname, dataManager.GetVictoryString(type));
else
Expand Down Expand Up @@ -1885,8 +1926,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
return mainGame->dField.ShowSelectSum(mainGame->dField.select_panalmode);
}
case MSG_SORT_CARD:
case MSG_SORT_CHAIN: {
case MSG_SORT_CARD: {
/*int player = */BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
mainGame->dField.selectable_cards.clear();
Expand All @@ -1906,16 +1946,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.selectable_cards.push_back(pcard);
mainGame->dField.sort_list.push_back(0);
}
if (mainGame->chkAutoChain->isChecked() && mainGame->dInfo.curMsg == MSG_SORT_CHAIN) {
mainGame->dField.sort_list.clear();
SetResponseI(-1);
DuelClient::SendResponse();
return true;
}
if(mainGame->dInfo.curMsg == MSG_SORT_CHAIN)
mainGame->wCardSelect->setText(dataManager.GetSysString(206));
else
mainGame->wCardSelect->setText(dataManager.GetSysString(205));
mainGame->wCardSelect->setText(dataManager.GetSysString(205));
mainGame->dField.select_min = 0;
mainGame->dField.select_max = count;
mainGame->dField.ShowSelectCard();
Expand Down
12 changes: 4 additions & 8 deletions gframe/event_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "single_mode.h"
#include "materials.h"
#include "../ocgcore/common.h"
#include <algorithm>

namespace ygo {

Expand Down Expand Up @@ -639,7 +638,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_CARD_4: {
if(mainGame->dInfo.isReplay)
break;
mainGame->stCardListTip->setVisible(false);
switch(mainGame->dInfo.curMsg) {
case MSG_SELECT_IDLECMD:
case MSG_SELECT_BATTLECMD:
Expand Down Expand Up @@ -736,7 +734,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if (selected_cards.size() > 0) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wCardSelect, true);}
mainGame->HideElement(mainGame->wCardSelect, true);
}
break;
}
case MSG_SELECT_SUM: {
Expand All @@ -745,7 +744,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
ShowSelectSum(true);
break;
}
case MSG_SORT_CHAIN:
case MSG_SORT_CARD: {
int offset = mainGame->scrCardList->getPos() / 10;
int sel_seq = id - BUTTON_CARD_0 + offset;
Expand Down Expand Up @@ -785,7 +783,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_CARD_SEL_OK: {
mainGame->stCardListTip->setVisible(false);
if(mainGame->dInfo.isReplay) {
mainGame->HideElement(mainGame->wCardSelect);
break;
Expand Down Expand Up @@ -1032,13 +1029,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case irr::gui::EGET_ELEMENT_LEFT: {
if(id >= BUTTON_CARD_0 && id <= BUTTON_CARD_4) {
if(id >= BUTTON_CARD_0 && id <= BUTTON_CARD_4 && mainGame->stCardListTip->isVisible()) {
int pos = mainGame->scrCardList->getPos() / 10;
ClientCard* mcard = selectable_cards[id - BUTTON_CARD_0 + pos];
SetShowMark(mcard, false);
mainGame->stCardListTip->setVisible(false);
}
if(id >= BUTTON_DISPLAY_0 && id <= BUTTON_DISPLAY_4) {
if(id >= BUTTON_DISPLAY_0 && id <= BUTTON_DISPLAY_4 && mainGame->stCardListTip->isVisible()) {
int pos = mainGame->scrDisplayList->getPos() / 10;
ClientCard* mcard = display_cards[id - BUTTON_DISPLAY_0 + pos];
SetShowMark(mcard, false);
Expand Down Expand Up @@ -2503,7 +2500,6 @@ void ClientField::CancelOrFinish() {
}
break;
}
case MSG_SORT_CHAIN:
case MSG_SORT_CARD: {
if(mainGame->wCardSelect->isVisible()) {
DuelClient::SetResponseI(-1);
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 = 0x134B;
const unsigned short PRO_VERSION = 0x1350;

namespace ygo {

Expand Down
1 change: 0 additions & 1 deletion gframe/replay.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "replay.h"
#include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h"
#include <algorithm>
#include "lzma/LzmaLib.h"

namespace ygo {
Expand Down
3 changes: 1 addition & 2 deletions gframe/replay_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
pbuf += count * 11;
return ReadReplayResponse();
}
case MSG_SORT_CARD:
case MSG_SORT_CHAIN: {
case MSG_SORT_CARD: {
player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 7;
Expand Down
6 changes: 3 additions & 3 deletions gframe/single_duel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
case 6:
case 7:
case 8:
case 9: {
case 9:
case 11: {
NetServer::SendBufferToPlayer(players[1 - player], STOC_GAME_MSG, offset, pbuf - offset);
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
Expand Down Expand Up @@ -778,8 +779,7 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1;
}
case MSG_SORT_CARD:
case MSG_SORT_CHAIN: {
case MSG_SORT_CARD: {
player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 7;
Expand Down
3 changes: 1 addition & 2 deletions gframe/single_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
}
break;
}
case MSG_SORT_CARD:
case MSG_SORT_CHAIN: {
case MSG_SORT_CARD: {
player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 7;
Expand Down
6 changes: 3 additions & 3 deletions gframe/tag_duel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,8 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
case 6:
case 7:
case 8:
case 9: {
case 9:
case 11: {
for(int i = 0; i < 4; ++i)
if(players[i] != cur_player[player])
NetServer::SendBufferToPlayer(players[i], STOC_GAME_MSG, offset, pbuf - offset);
Expand Down Expand Up @@ -719,8 +720,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1;
}
case MSG_SORT_CARD:
case MSG_SORT_CHAIN: {
case MSG_SORT_CARD: {
player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 7;
Expand Down
Loading

0 comments on commit 611ea1f

Please sign in to comment.