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::
driver->setTransform(irr::video::ETS_VIEW, oldViewMat);
}
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();
return button;
}
......
......@@ -22,9 +22,8 @@ public:
}
static void VectorWriteBlock(std::vector<unsigned char>& buffer, const void* src, size_t size) {
const auto len = buffer.size();
buffer.resize(len + size);
std::memcpy(buffer.data() + len, src, size);
auto* bytes = static_cast<const unsigned char*>(src);
buffer.insert(buffer.end(), bytes, bytes + size);
}
template<typename T>
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
return false;
int 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;
++index;
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);
}
template <class T>
......
......@@ -309,7 +309,6 @@ bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) {
}
if(!reader)
return false;
std::memset(deckBuffer, 0, sizeof deckBuffer);
int size = reader->read(deckBuffer, sizeof deckBuffer);
reader->drop();
if (size >= (int)sizeof deckBuffer) {
......
......@@ -93,7 +93,8 @@ void ImageManager::ResizeTexture() {
irr::s32 bgWidth = 1024 * mainGame->xScale;
irr::s32 bgHeight = 640 * mainGame->yScale;
driver->removeTexture(tCover[0]);
driver->removeTexture(tCover[1]);
if(tCover[1] != tCover[0])
driver->removeTexture(tCover[1]);
tCover[0] = GetTextureFromFile("textures/cover.jpg", imgWidth, imgHeight);
tCover[1] = GetTextureFromFile("textures/cover2.jpg", imgWidth, imgHeight);
if(!tCover[1])
......@@ -107,12 +108,14 @@ void ImageManager::ResizeTexture() {
tUnknownFit = GetTextureFromFile("textures/unknown.jpg", imgWidthFit, imgHeightFit);
tUnknownThumb = GetTextureFromFile("textures/unknown.jpg", imgWidthThumb, imgHeightThumb);
driver->removeTexture(tBackGround);
if(tBackGround_menu != tBackGround)
driver->removeTexture(tBackGround_menu);
if(tBackGround_deck != tBackGround)
driver->removeTexture(tBackGround_deck);
tBackGround = GetTextureFromFile("textures/bg.jpg", bgWidth, bgHeight);
driver->removeTexture(tBackGround_menu);
tBackGround_menu = GetTextureFromFile("textures/bg_menu.jpg", bgWidth, bgHeight);
if(!tBackGround_menu)
tBackGround_menu = tBackGround;
driver->removeTexture(tBackGround_deck);
tBackGround_deck = GetTextureFromFile("textures/bg_deck.jpg", bgWidth, bgHeight);
if(!tBackGround_deck)
tBackGround_deck = tBackGround;
......
......@@ -356,6 +356,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
NetServer::StopServer();
break;
}
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
#else
if(fork() == 0) {
usleep(100000);
......
......@@ -239,7 +239,8 @@ public:
int len = std::snprintf(fname, sizeof(fname), "%s/%s", path, dirp->d_name);
if (len < 0 || len >= (int)(sizeof fname))
continue;
stat(fname, &fileStat);
if (stat(fname, &fileStat) != 0)
continue;
funit.filename = std::string(dirp->d_name);
funit.is_dir = S_ISDIR(fileStat.st_mode);
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) {
pplayer[0] = players[0];
pplayer[1] = players[1];
if((tp && dp->type == 1) || (!tp && dp->type == 0)) {
DuelPlayer* p = players[0];
players[0] = players[1];
players[1] = p;
std::swap(players[0], players[1]);
players[0]->type = 0;
players[1]->type = 1;
Deck d = pdeck[0];
pdeck[0] = pdeck[1];
pdeck[1] = d;
std::swap(pdeck[0], pdeck[1]);
swapped = true;
}
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