Commit eab04131 authored by mercury233's avatar mercury233 Committed by GitHub

Merge pull request #2982 from mercury233/patch-copilot-fix-2

parents df229044 631eed90
...@@ -102,7 +102,7 @@ void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core:: ...@@ -102,7 +102,7 @@ void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::
driver->setTransform(irr::video::ETS_VIEW, oldViewMat); driver->setTransform(irr::video::ETS_VIEW, oldViewMat);
} }
CGUIImageButton* CGUIImageButton::addImageButton(IGUIEnvironment *env, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id) { CGUIImageButton* CGUIImageButton::addImageButton(IGUIEnvironment *env, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id) {
CGUIImageButton* button = new CGUIImageButton(env, parent ? parent : 0, id, rectangle); CGUIImageButton* button = new CGUIImageButton(env, parent, id, rectangle);
button->drop(); button->drop();
return button; return button;
} }
......
...@@ -22,9 +22,8 @@ public: ...@@ -22,9 +22,8 @@ public:
} }
static void VectorWriteBlock(std::vector<unsigned char>& buffer, const void* src, size_t size) { static void VectorWriteBlock(std::vector<unsigned char>& buffer, const void* src, size_t size) {
const auto len = buffer.size(); auto* bytes = static_cast<const unsigned char*>(src);
buffer.resize(len + size); buffer.insert(buffer.end(), bytes, bytes + size);
std::memcpy(buffer.data() + len, src, size);
} }
template<typename T> template<typename T>
static void VectorWrite(std::vector<unsigned char>& buffer, const T& value) { static void VectorWrite(std::vector<unsigned char>& buffer, const T& value) {
......
...@@ -1392,11 +1392,11 @@ bool ClientField::check_sum_trib(std::set<ClientCard*>::const_iterator index, st ...@@ -1392,11 +1392,11 @@ bool ClientField::check_sum_trib(std::set<ClientCard*>::const_iterator index, st
return false; return false;
int l1, l2; int l1, l2;
get_sum_params((*index)->opParam, l1, l2); get_sum_params((*index)->opParam, l1, l2);
if((acc + l1 >= select_min && acc + l1 <= select_max) || (acc + l2 >= select_min && acc + l2 <= select_max)) if((acc + l1 >= select_min && acc + l1 <= select_max) || (l2 > 0 && acc + l2 >= select_min && acc + l2 <= select_max))
return true; return true;
++index; ++index;
return check_sum_trib(index, end, acc + l1) return check_sum_trib(index, end, acc + l1)
|| check_sum_trib(index, end, acc + l2) || (l2 > 0 && check_sum_trib(index, end, acc + l2))
|| check_sum_trib(index, end, acc); || check_sum_trib(index, end, acc);
} }
template <class T> template <class T>
......
...@@ -309,7 +309,6 @@ bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) { ...@@ -309,7 +309,6 @@ bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) {
} }
if(!reader) if(!reader)
return false; return false;
std::memset(deckBuffer, 0, sizeof deckBuffer);
int size = reader->read(deckBuffer, sizeof deckBuffer); int size = reader->read(deckBuffer, sizeof deckBuffer);
reader->drop(); reader->drop();
if (size >= (int)sizeof deckBuffer) { if (size >= (int)sizeof deckBuffer) {
......
...@@ -93,6 +93,7 @@ void ImageManager::ResizeTexture() { ...@@ -93,6 +93,7 @@ void ImageManager::ResizeTexture() {
irr::s32 bgWidth = 1024 * mainGame->xScale; irr::s32 bgWidth = 1024 * mainGame->xScale;
irr::s32 bgHeight = 640 * mainGame->yScale; irr::s32 bgHeight = 640 * mainGame->yScale;
driver->removeTexture(tCover[0]); driver->removeTexture(tCover[0]);
if(tCover[1] != tCover[0])
driver->removeTexture(tCover[1]); driver->removeTexture(tCover[1]);
tCover[0] = GetTextureFromFile("textures/cover.jpg", imgWidth, imgHeight); tCover[0] = GetTextureFromFile("textures/cover.jpg", imgWidth, imgHeight);
tCover[1] = GetTextureFromFile("textures/cover2.jpg", imgWidth, imgHeight); tCover[1] = GetTextureFromFile("textures/cover2.jpg", imgWidth, imgHeight);
...@@ -107,12 +108,14 @@ void ImageManager::ResizeTexture() { ...@@ -107,12 +108,14 @@ void ImageManager::ResizeTexture() {
tUnknownFit = GetTextureFromFile("textures/unknown.jpg", imgWidthFit, imgHeightFit); tUnknownFit = GetTextureFromFile("textures/unknown.jpg", imgWidthFit, imgHeightFit);
tUnknownThumb = GetTextureFromFile("textures/unknown.jpg", imgWidthThumb, imgHeightThumb); tUnknownThumb = GetTextureFromFile("textures/unknown.jpg", imgWidthThumb, imgHeightThumb);
driver->removeTexture(tBackGround); driver->removeTexture(tBackGround);
tBackGround = GetTextureFromFile("textures/bg.jpg", bgWidth, bgHeight); if(tBackGround_menu != tBackGround)
driver->removeTexture(tBackGround_menu); driver->removeTexture(tBackGround_menu);
if(tBackGround_deck != tBackGround)
driver->removeTexture(tBackGround_deck);
tBackGround = GetTextureFromFile("textures/bg.jpg", bgWidth, bgHeight);
tBackGround_menu = GetTextureFromFile("textures/bg_menu.jpg", bgWidth, bgHeight); tBackGround_menu = GetTextureFromFile("textures/bg_menu.jpg", bgWidth, bgHeight);
if(!tBackGround_menu) if(!tBackGround_menu)
tBackGround_menu = tBackGround; tBackGround_menu = tBackGround;
driver->removeTexture(tBackGround_deck);
tBackGround_deck = GetTextureFromFile("textures/bg_deck.jpg", bgWidth, bgHeight); tBackGround_deck = GetTextureFromFile("textures/bg_deck.jpg", bgWidth, bgHeight);
if(!tBackGround_deck) if(!tBackGround_deck)
tBackGround_deck = tBackGround; tBackGround_deck = tBackGround;
......
...@@ -356,6 +356,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -356,6 +356,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
NetServer::StopServer(); NetServer::StopServer();
break; break;
} }
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
#else #else
if(fork() == 0) { if(fork() == 0) {
usleep(100000); usleep(100000);
......
...@@ -239,7 +239,8 @@ public: ...@@ -239,7 +239,8 @@ public:
int len = std::snprintf(fname, sizeof(fname), "%s/%s", path, dirp->d_name); int len = std::snprintf(fname, sizeof(fname), "%s/%s", path, dirp->d_name);
if (len < 0 || len >= (int)(sizeof fname)) if (len < 0 || len >= (int)(sizeof fname))
continue; continue;
stat(fname, &fileStat); if (stat(fname, &fileStat) != 0)
continue;
funit.filename = std::string(dirp->d_name); funit.filename = std::string(dirp->d_name);
funit.is_dir = S_ISDIR(fileStat.st_mode); funit.is_dir = S_ISDIR(fileStat.st_mode);
if(funit.is_dir && (std::strcmp(dirp->d_name, ".") == 0 || std::strcmp(dirp->d_name, "..") == 0)) if(funit.is_dir && (std::strcmp(dirp->d_name, ".") == 0 || std::strcmp(dirp->d_name, "..") == 0))
......
...@@ -399,14 +399,10 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -399,14 +399,10 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
pplayer[0] = players[0]; pplayer[0] = players[0];
pplayer[1] = players[1]; pplayer[1] = players[1];
if((tp && dp->type == 1) || (!tp && dp->type == 0)) { if((tp && dp->type == 1) || (!tp && dp->type == 0)) {
DuelPlayer* p = players[0]; std::swap(players[0], players[1]);
players[0] = players[1];
players[1] = p;
players[0]->type = 0; players[0]->type = 0;
players[1]->type = 1; players[1]->type = 1;
Deck d = pdeck[0]; std::swap(pdeck[0], pdeck[1]);
pdeck[0] = pdeck[1];
pdeck[1] = d;
swapped = true; swapped = true;
} }
dp->state = CTOS_RESPONSE; dp->state = CTOS_RESPONSE;
......
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