Commit 79549d88 authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:Fluorohydride/ygopro into develop

parents f219906c b1cbe233
name: Automated Test Build
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build-windows:
strategy:
fail-fast: false
matrix:
os: [windows-2019, windows-2022]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository with submodules
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
- name: Update submodules
run: |
cd ocgcore
git checkout master
git pull origin master
cd ..
# cd script
# git checkout master
# git pull origin master
# cd ..
- name: Download premake
id: premake
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/premake/premake-core/releases/download/v5.0.0-beta5/premake-5.0.0-beta5-windows.zip
filename: premake5.zip
- name: Extract premake
run: |
7z x ${{ steps.premake.outputs.filepath }}
- name: Download libevent
id: libevent
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
filename: libevent.tar.gz
- name: Extract libevent
run: |
tar xf ${{ steps.libevent.outputs.filepath }}
move libevent-2.0.22-stable event
xcopy /E event\WIN32-Code event\include
- name: Download freetype
id: freetype
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: http://downloads.sourceforge.net/freetype/freetype-2.13.3.tar.gz
- name: Extract freetype
run: |
tar xf ${{ steps.freetype.outputs.filepath }}
move freetype-2.13.3 freetype
- name: Download lua
id: lua
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://www.lua.org/ftp/lua-5.4.7.tar.gz
- name: Extract lua
run: |
tar xf ${{ steps.lua.outputs.filepath }}
move lua-5.4.7 lua
- name: Download sqlite
id: sqlite
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://www.sqlite.org/2025/sqlite-amalgamation-3490100.zip
- name: Extract sqlite
run: |
7z x ${{ steps.sqlite.outputs.filepath }}
move sqlite-amalgamation-3490100 sqlite3
- name: Download irrKlang
id: irrKlang
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://www.ambiera.at/downloads/irrKlang-32bit-1.6.0.zip
- name: Extract irrKlang
run: |
7z x ${{ steps.irrKlang.outputs.filepath }}
move irrKlang-1.6.0 irrKlang
- name: Download irrlicht
run: |
git clone --depth=1 https://github.com/mercury233/irrlicht
- name: Check DirectX SDK
id: dxsdk
uses: actions/cache@v4
with:
key: dxsdk
path: DXSDK
- name: Download DirectX SDK
if: steps.dxsdk.outputs.cache-hit != 'true'
id: dxsdk-download
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://download.microsoft.com/download/a/e/7/ae743f1f-632b-4809-87a9-aa1bb3458e31/DXSDK_Jun10.exe
- name: Install DirectX SDK
if: steps.dxsdk.outputs.cache-hit != 'true'
run: |
7z x ${{ steps.dxsdk-download.outputs.filepath }} -aoa
- name: Set DirectX SDK environment variable
run: |
$dxsdkPath = Resolve-Path 'DXSDK'
"DXSDK_DIR=$($dxsdkPath.ProviderPath)\" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Copy premake files
run: |
xcopy /E premake\* .
- name: Use premake to generate Visual Studio solution (2019)
if: matrix.os == 'windows-2019'
run: |
.\premake5.exe vs2019 --winxp-support
- name: Use premake to generate Visual Studio solution (2022)
if: matrix.os == 'windows-2022'
run: |
.\premake5.exe vs2022
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Build solution
run: |
MSBuild.exe build\YGOPro.sln /m /p:Configuration=Release
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: YGOPro-${{ matrix.os }}
path: |
bin/release/YGOPro.exe
build-linux:
strategy:
fail-fast: false
matrix:
os:
# - ubuntu-20.04
- ubuntu-22.04
- ubuntu-24.04
include:
# - os: ubuntu-20.04
# premake_version: 5.0.0-beta2
- os: ubuntu-22.04
premake_version: 5.0.0-beta4
- os: ubuntu-24.04
premake_version: 5.0.0-beta5
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository with submodules
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
- name: Update submodules
run: |
cd ocgcore
git checkout master
git pull origin master
cd ..
# cd script
# git checkout master
# git pull origin master
# cd ..
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libevent-dev libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libsqlite3-dev libxxf86vm-dev
- name: Download premake
id: premake
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/premake/premake-core/releases/download/v${{ matrix.premake_version }}/premake-${{ matrix.premake_version }}-linux.tar.gz
filename: premake5.tar.gz
- name: Extract premake
run: |
tar xf ${{ steps.premake.outputs.filepath }}
chmod +x ./premake5
- name: Download lua
id: lua
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://www.lua.org/ftp/lua-5.4.7.tar.gz
- name: Extract lua
run: |
tar xf ${{ steps.lua.outputs.filepath }}
mv lua-5.4.7 lua
- name: Download irrlicht
run: |
git clone --depth=1 https://github.com/mercury233/irrlicht
- name: Copy premake files
run: |
cp -r premake/* .
- name: Use premake to generate make files
run: |
./premake5 gmake \
--no-use-irrklang \
--freetype-include-dir="/usr/include/freetype2"
- name: Make
run: |
cd build
make -j 4 config=release
cd ..
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: YGOPro-${{ matrix.os }}
path: |
bin/release/YGOPro
build-macos:
strategy:
fail-fast: false
matrix:
os:
- macos-13
- macos-15
include:
- os: macos-13
premake_version: 5.0.0-beta5
- os: macos-15
premake_version: 5.0.0-beta5
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository with submodules
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
- name: Update submodules
run: |
cd ocgcore
git checkout master
git pull origin master
cd ..
# cd script
# git checkout master
# git pull origin master
# cd ..
# - name: Install dependencies
# run: |
# brew install freetype libevent libx11 sqlite zlib
- name: Download premake
id: premake
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/premake/premake-core/releases/download/v${{ matrix.premake_version }}/premake-${{ matrix.premake_version }}-macosx.tar.gz
filename: premake5.tar.gz
- name: Extract premake
run: |
tar xf ${{ steps.premake.outputs.filepath }}
chmod +x ./premake5
- name: Download lua
id: lua
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://www.lua.org/ftp/lua-5.4.7.tar.gz
- name: Extract lua
run: |
tar xf ${{ steps.lua.outputs.filepath }}
mv lua-5.4.7 lua
- name: Download irrlicht
run: |
git clone --depth=1 https://github.com/mercury233/irrlicht
- name: Build irrlicht
run: |
cd irrlicht/source/Irrlicht/MacOSX
xcodebuild -project MacOSX.xcodeproj
cd ../../../..
- name: Copy premake files
run: |
cp -r premake/* .
- name: Use premake to generate make files (Intel)
if: runner.arch == 'X64'
run: |
./premake5 gmake \
--cc=clang \
--no-use-irrklang \
--freetype-include-dir="/usr/local/include/freetype2" \
--irrlicht-include-dir="../irrlicht/include" \
--irrlicht-lib-dir="../irrlicht/source/Irrlicht/MacOSX/build/Release"
- name: Use premake to generate make files (ARM64)
if: runner.arch == 'ARM64'
run: |
./premake5 gmake \
--cc=clang \
--no-use-irrklang \
--event-include-dir="/opt/homebrew/include" \
--event-lib-dir="/opt/homebrew/lib" \
--freetype-include-dir="/opt/homebrew/include/freetype2" \
--freetype-lib-dir="/opt/homebrew/lib" \
--sqlite-include-dir="/opt/homebrew/opt/sqlite/include" \
--sqlite-lib-dir="/opt/homebrew/opt/sqlite/lib" \
--irrlicht-include-dir="../irrlicht/include" \
--irrlicht-lib-dir="../irrlicht/source/Irrlicht/MacOSX/build/Release"
- name: Make
run: |
cd build
make -j 3 config=release
cd ..
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: YGOPro-${{ matrix.os }}
path: |
bin/*
......@@ -313,8 +313,8 @@ void CGUIImageButton::draw() {
return;
IGUISkin* skin = Environment->getSkin();
video::IVideoDriver* driver = Environment->getVideoDriver();
core::vector2di center = AbsoluteRect.getCenter();
core::vector2di pos = center;
irr::core::vector2di center = AbsoluteRect.getCenter();
irr::core::vector2di pos = center;
pos.X -= (s32)(ImageRect.getWidth() * imageScale.X * 0.5f);
pos.Y -= (s32)(ImageRect.getHeight() * imageScale.Y * 0.5f);
if(Pressed) {
......
......@@ -561,7 +561,7 @@ void CGUITTFont::drawUstring(const core::ustring& utext, const core::rect<s32>&p
// Determine rendering information.
SGUITTGlyph& glyph = Glyphs[n - 1];
CGUITTGlyphPage* const page = Glyph_Pages[glyph.glyph_page];
page->render_positions.push_back(core::vector2di(offset.X + offx, offset.Y + offy));
page->render_positions.push_back(irr::core::vector2di(offset.X + offx, offset.Y + offy));
page->render_source_rects.push_back(glyph.source_rect);
Render_Map.set(glyph.glyph_page, page);
}
......@@ -832,7 +832,7 @@ video::IImage* CGUITTFont::createTextureFromChar(const uchar32_t& ch) {
// Copy the image data out of the page texture.
core::dimension2du glyph_size(glyph.source_rect.getSize());
video::IImage* image = Driver->createImage(format, glyph_size);
pageholder->copyTo(image, core::vector2di(0, 0), glyph.source_rect);
pageholder->copyTo(image, irr::core::vector2di(0, 0), glyph.source_rect);
tex->unlock();
return image;
......@@ -854,17 +854,14 @@ void CGUITTFont::createSharedPlane() {
0---1
*/
using namespace core;
using namespace video;
using namespace scene;
S3DVertex vertices[4];
video::S3DVertex vertices[4];
u16 indices[6] = {0, 2, 3, 3, 1, 0};
vertices[0] = S3DVertex(vector3df(0, -1, 0), vector3df(0, 0, -1), SColor(255, 255, 255, 255), vector2df(0, 1));
vertices[1] = S3DVertex(vector3df(1, -1, 0), vector3df(0, 0, -1), SColor(255, 255, 255, 255), vector2df(1, 1));
vertices[2] = S3DVertex(vector3df(0, 0, 0), vector3df(0, 0, -1), SColor(255, 255, 255, 255), vector2df(0, 0));
vertices[3] = S3DVertex(vector3df(1, 0, 0), vector3df(0, 0, -1), SColor(255, 255, 255, 255), vector2df(1, 0));
vertices[0] = video::S3DVertex(core::vector3df(0, -1, 0), core::vector3df(0, 0, -1), video::SColor(255, 255, 255, 255), core::vector2df(0, 1));
vertices[1] = video::S3DVertex(core::vector3df(1, -1, 0), core::vector3df(0, 0, -1), video::SColor(255, 255, 255, 255), core::vector2df(1, 1));
vertices[2] = video::S3DVertex(core::vector3df(0, 0, 0), core::vector3df(0, 0, -1), video::SColor(255, 255, 255, 255), core::vector2df(0, 0));
vertices[3] = video::S3DVertex(core::vector3df(1, 0, 0), core::vector3df(0, 0, -1), video::SColor(255, 255, 255, 255), core::vector2df(1, 0));
SMeshBuffer* buf = new SMeshBuffer();
scene::SMeshBuffer* buf = new scene::SMeshBuffer();
buf->append(vertices, 4, indices, 6);
shared_plane_.addMeshBuffer( buf );
......@@ -882,11 +879,7 @@ core::dimension2d<u32> CGUITTFont::getDimensionUntilEndOfLine(const wchar_t* p)
}
core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text, scene::ISceneManager* smgr, scene::ISceneNode* parent, const video::SColor& color, bool center) {
using namespace core;
using namespace video;
using namespace scene;
array<scene::ISceneNode*> container;
core::array<scene::ISceneNode*> container;
if (!Driver || !smgr) return container;
if (!parent)
......@@ -897,8 +890,8 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
if (!shared_plane_ptr_) //this points to a static mesh that contains the plane
createSharedPlane(); //if it's not initialized, we create one.
dimension2d<s32> text_size(getDimension(text)); //convert from unsigned to signed.
vector3df start_point(0, 0, 0), offset;
core::dimension2d<s32> text_size(getDimension(text)); //convert from unsigned to signed.
core::vector3df start_point(0, 0, 0), offset;
/** NOTICE:
Because we are considering adding texts into 3D world, all Y axis vectors are inverted.
......@@ -912,7 +905,7 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
}
// the default font material
SMaterial mat;
video::SMaterial mat;
mat.setFlag(video::EMF_LIGHTING, true);
mat.setFlag(video::EMF_ZWRITE_ENABLE, false);
mat.setFlag(video::EMF_NORMALIZE_NORMALS, true);
......@@ -924,7 +917,7 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
wchar_t current_char = 0, previous_char = 0;
u32 n = 0;
array<u32> glyph_indices;
core::array<u32> glyph_indices;
while (*text) {
current_char = *text;
......@@ -957,23 +950,23 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
s32 offy = (font_metrics.ascender / 64) - glyph.offset.Y;
// Apply kerning.
vector2di k = getKerning(current_char, previous_char);
core::vector2di k = getKerning(current_char, previous_char);
offset.X += k.X;
offset.Y += k.Y;
vector3df current_pos(offset.X + offx, offset.Y - offy, 0);
dimension2d<u32> letter_size = dimension2d<u32>(texw, texh);
core::vector3df current_pos(offset.X + offx, offset.Y - offy, 0);
core::dimension2d<u32> letter_size = core::dimension2d<u32>(texw, texh);
// Now we copy planes corresponding to the letter size.
IMeshManipulator* mani = smgr->getMeshManipulator();
IMesh* meshcopy = mani->createMeshCopy(shared_plane_ptr_);
mani->scale(meshcopy, vector3df((f32)letter_size.Width, (f32)letter_size.Height, 1));
scene::IMeshManipulator* mani = smgr->getMeshManipulator();
scene::IMesh* meshcopy = mani->createMeshCopy(shared_plane_ptr_);
mani->scale(meshcopy, core::vector3df((f32)letter_size.Width, (f32)letter_size.Height, 1));
ISceneNode* current_node = smgr->addMeshSceneNode(meshcopy, parent, -1, current_pos);
scene::ISceneNode* current_node = smgr->addMeshSceneNode(meshcopy, parent, -1, current_pos);
meshcopy->drop();
current_node->getMaterial(0) = mat;
current_node->setAutomaticCulling(EAC_OFF);
current_node->setAutomaticCulling(scene::EAC_OFF);
current_node->setIsDebugObject(true); //so the picking won't have any effect on individual letter
//current_node->setDebugDataVisible(EDS_BBOX); //de-comment this when debugging
......@@ -991,7 +984,7 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
for (u32 i = 0; i < glyph_indices.size(); ++i) {
u32 n = glyph_indices[i];
SGUITTGlyph const& glyph = Glyphs[n - 1];
ITexture* current_tex = Glyph_Pages[glyph.glyph_page]->texture;
video::ITexture* current_tex = Glyph_Pages[glyph.glyph_page]->texture;
f32 page_texture_size = (f32)current_tex->getSize().Width;
//Now we calculate the UV position according to the texture size and the source rect.
//
......@@ -1007,15 +1000,15 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
f32 v2 = v1 + (glyph.source_rect.getHeight() / page_texture_size);
//we can be quite sure that this is IMeshSceneNode, because we just added them in the above loop.
IMeshSceneNode* node = static_cast<IMeshSceneNode*>(container[i]);
scene::IMeshSceneNode* node = static_cast<scene::IMeshSceneNode*>(container[i]);
S3DVertex* pv = static_cast<S3DVertex*>(node->getMesh()->getMeshBuffer(0)->getVertices());
video::S3DVertex* pv = static_cast<video::S3DVertex*>(node->getMesh()->getMeshBuffer(0)->getVertices());
//pv[0].TCoords.Y = pv[1].TCoords.Y = (letter_size.Height - 1) / static_cast<f32>(letter_size.Height);
//pv[1].TCoords.X = pv[3].TCoords.X = (letter_size.Width - 1) / static_cast<f32>(letter_size.Width);
pv[0].TCoords = vector2df(u1, v2);
pv[1].TCoords = vector2df(u2, v2);
pv[2].TCoords = vector2df(u1, v1);
pv[3].TCoords = vector2df(u2, v1);
pv[0].TCoords = core::vector2df(u1, v2);
pv[1].TCoords = core::vector2df(u2, v2);
pv[2].TCoords = core::vector2df(u1, v1);
pv[3].TCoords = core::vector2df(u2, v1);
container[i]->getMaterial(0).setTexture(0, current_tex);
}
......
......@@ -56,7 +56,7 @@ void ClientCard::UpdateInfo(unsigned char* buf) {
}
if(flag & QUERY_POSITION) {
int pdata = (BufferIO::ReadInt32(buf) >> 24) & 0xff;
if((location & (LOCATION_EXTRA | LOCATION_REMOVED)) && (u8)pdata != position) {
if((location & (LOCATION_EXTRA | LOCATION_REMOVED)) && pdata != position) {
position = pdata;
mainGame->dField.MoveCard(this, 1);
} else
......
......@@ -15,9 +15,9 @@ public:
irr::core::vector3df curRot;
irr::core::vector3df dPos;
irr::core::vector3df dRot;
u32 curAlpha{ 255 };
u32 dAlpha{ 0 };
u32 aniFrame{ 0 };
irr::u32 curAlpha{ 255 };
irr::u32 dAlpha{ 0 };
irr::u32 aniFrame{ 0 };
bool is_moving{ false };
bool is_fading{ false };
bool is_hovered{ false };
......
......@@ -440,7 +440,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->chain_code));
else
mainGame->btnCardSelect[i]->setImage(imageManager.tCover[selectable_cards[i]->controler + 2]);
mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225));
mainGame->btnCardSelect[i]->setRelativePosition(irr::core::rect<irr::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_CARD) {
......@@ -497,7 +497,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
mainGame->stCardPos[i]->setBackgroundColor(0xffffffff);
}
mainGame->stCardPos[i]->setVisible(true);
mainGame->stCardPos[i]->setRelativePosition(rect<s32>(startpos + i * 125, 30, startpos + 120 + i * 125, 50));
mainGame->stCardPos[i]->setRelativePosition(irr::core::rect<irr::s32>(startpos + i * 125, 30, startpos + 120 + i * 125, 50));
}
if(selectable_cards.size() <= 5) {
for(int i = selectable_cards.size(); i < 5; ++i) {
......@@ -530,7 +530,7 @@ void ClientField::ShowChainCard() {
mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->code));
else
mainGame->btnCardSelect[i]->setImage(imageManager.tCover[selectable_cards[i]->controler + 2]);
mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225));
mainGame->btnCardSelect[i]->setRelativePosition(irr::core::rect<irr::s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225));
mainGame->btnCardSelect[i]->setPressed(false);
mainGame->btnCardSelect[i]->setVisible(true);
wchar_t formatBuffer[2048];
......@@ -549,7 +549,7 @@ void ClientField::ShowChainCard() {
else mainGame->stCardPos[i]->setBackgroundColor(0xffffffff);
}
mainGame->stCardPos[i]->setVisible(true);
mainGame->stCardPos[i]->setRelativePosition(rect<s32>(startpos + i * 125, 30, startpos + 120 + i * 125, 50));
mainGame->stCardPos[i]->setRelativePosition(irr::core::rect<irr::s32>(startpos + i * 125, 30, startpos + 120 + i * 125, 50));
}
if(selectable_cards.size() <= 5) {
for(int i = selectable_cards.size(); i < 5; ++i) {
......@@ -585,7 +585,7 @@ void ClientField::ShowLocationCard() {
mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardDisplay[i], display_cards[i]->code));
else
mainGame->btnCardDisplay[i]->setImage(imageManager.tCover[display_cards[i]->controler + 2]);
mainGame->btnCardDisplay[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225));
mainGame->btnCardDisplay[i]->setRelativePosition(irr::core::rect<irr::s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225));
mainGame->btnCardDisplay[i]->setPressed(false);
mainGame->btnCardDisplay[i]->setVisible(true);
wchar_t formatBuffer[2048];
......@@ -618,7 +618,7 @@ void ClientField::ShowLocationCard() {
mainGame->stDisplayPos[i]->setBackgroundColor(0xffffffff);
}
mainGame->stDisplayPos[i]->setVisible(true);
mainGame->stDisplayPos[i]->setRelativePosition(rect<s32>(startpos + i * 125, 30, startpos + 120 + i * 125, 50));
mainGame->stDisplayPos[i]->setRelativePosition(irr::core::rect<irr::s32>(startpos + i * 125, 30, startpos + 120 + i * 125, 50));
}
if(display_cards.size() <= 5) {
for(int i = display_cards.size(); i < 5; ++i) {
......@@ -663,7 +663,7 @@ void ClientField::ShowSelectOption(int select_hint) {
mainGame->btnOptionOK->setVisible(false);
for(int i = 0; i < 5; i++)
mainGame->btnOption[i]->setVisible(i < count);
recti pos = mainGame->wOptions->getRelativePosition();
irr::core::recti pos = mainGame->wOptions->getRelativePosition();
int newheight = 30 + 40 * (scrollbar ? 5 : count);
int oldheight = pos.LowerRightCorner.Y - pos.UpperLeftCorner.Y;
pos.UpperLeftCorner.Y = pos.UpperLeftCorner.Y + (oldheight - newheight) / 2;
......@@ -678,7 +678,7 @@ void ClientField::ShowSelectOption(int select_hint) {
mainGame->btnOptionOK->setVisible(true);
for(int i = 0; i < 5; i++)
mainGame->btnOption[i]->setVisible(false);
recti pos = mainGame->wOptions->getRelativePosition();
irr::core::recti pos = mainGame->wOptions->getRelativePosition();
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + 140;
mainGame->wOptions->setRelativePosition(pos);
}
......
......@@ -53,7 +53,7 @@ inline int _wtoi(const wchar_t * str){
#endif
#include <cstdio>
#include <stdlib.h>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
......@@ -80,12 +80,6 @@ inline FILE* mywfopen(const wchar_t* filename, const char* mode) {
}
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
extern unsigned short PRO_VERSION;
extern unsigned int enable_log;
......
......@@ -13,23 +13,21 @@ DataManager::DataManager() : _datas(32768), _strings(32768) {
extra_setcode = { {8512558u, {0x8f, 0x54, 0x59, 0x82, 0x13a}}, };
}
bool DataManager::ReadDB(sqlite3* pDB) {
sqlite3_stmt* pStmt{};
sqlite3_stmt* pStmt = nullptr;
const char* sql = "select * from datas,texts where datas.id=texts.id";
if (sqlite3_prepare_v2(pDB, sql, -1, &pStmt, 0) != SQLITE_OK)
return Error(pDB);
return Error(pDB, pStmt);
wchar_t strBuffer[4096];
int step = 0;
do {
CardDataC cd;
CardString cs;
step = sqlite3_step(pStmt);
if (step == SQLITE_BUSY || step == SQLITE_ERROR || step == SQLITE_MISUSE)
return Error(pDB, pStmt);
else if (step == SQLITE_ROW) {
if (step == SQLITE_ROW) {
cd.code = sqlite3_column_int(pStmt, 0);
cd.ot = sqlite3_column_int(pStmt, 1);
cd.alias = sqlite3_column_int(pStmt, 2);
auto setcode = sqlite3_column_int64(pStmt, 3);
uint64_t setcode = static_cast<uint64_t>(sqlite3_column_int64(pStmt, 3));
if (setcode) {
auto it = extra_setcode.find(cd.code);
if (it != extra_setcode.end()) {
......@@ -42,7 +40,7 @@ bool DataManager::ReadDB(sqlite3* pDB) {
else
cd.set_setcode(setcode);
}
cd.type = sqlite3_column_int(pStmt, 4);
cd.type = static_cast<decltype(cd.type)>(sqlite3_column_int64(pStmt, 4));
cd.attack = sqlite3_column_int(pStmt, 5);
cd.defense = sqlite3_column_int(pStmt, 6);
if (cd.type & TYPE_LINK) {
......@@ -51,13 +49,13 @@ bool DataManager::ReadDB(sqlite3* pDB) {
}
else
cd.link_marker = 0;
unsigned int level = sqlite3_column_int(pStmt, 7);
uint32_t level = static_cast<uint32_t>(sqlite3_column_int(pStmt, 7));
cd.level = level & 0xff;
cd.lscale = (level >> 24) & 0xff;
cd.rscale = (level >> 16) & 0xff;
cd.race = sqlite3_column_int(pStmt, 8);
cd.attribute = sqlite3_column_int(pStmt, 9);
cd.category = sqlite3_column_int(pStmt, 10);
cd.race = static_cast<decltype(cd.race)>(sqlite3_column_int64(pStmt, 8));
cd.attribute = static_cast<decltype(cd.attribute)>(sqlite3_column_int64(pStmt, 9));
cd.category = static_cast<decltype(cd.category)>(sqlite3_column_int64(pStmt, 10));
_datas[cd.code] = cd;
if (const char* text = (const char*)sqlite3_column_text(pStmt, 12)) {
BufferIO::DecodeUTF8(text, strBuffer);
......@@ -76,7 +74,9 @@ bool DataManager::ReadDB(sqlite3* pDB) {
}
_strings[cd.code] = cs;
}
} while (step != SQLITE_DONE);
else if (step != SQLITE_DONE)
return Error(pDB, pStmt);
} while (step == SQLITE_ROW);
sqlite3_finalize(pStmt);
return true;
}
......@@ -84,17 +84,17 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
char file[256];
BufferIO::EncodeUTF8(wfile, file);
#ifdef _WIN32
IReadFile* reader = FileSystem->createAndOpenFile(wfile);
auto reader = FileSystem->createAndOpenFile(wfile);
#else
IReadFile* reader = FileSystem->createAndOpenFile(file);
auto reader = FileSystem->createAndOpenFile(file);
#endif
if(reader == nullptr)
return false;
spmemvfs_db_t db;
spmembuffer_t* mem = (spmembuffer_t*)calloc(sizeof(spmembuffer_t), 1);
spmembuffer_t* mem = (spmembuffer_t*)std::calloc(sizeof(spmembuffer_t), 1);
spmemvfs_env_init();
mem->total = mem->used = reader->getSize();
mem->data = (char*)malloc(mem->total + 1);
mem->data = (char*)std::malloc(mem->total + 1);
reader->read(mem->data, mem->total);
reader->drop();
(mem->data)[mem->total] = '\0';
......@@ -423,9 +423,9 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl
#ifdef _WIN32
wchar_t fname[256]{};
BufferIO::DecodeUTF8(script_name, fname);
IReadFile* reader = FileSystem->createAndOpenFile(fname);
auto reader = FileSystem->createAndOpenFile(fname);
#else
IReadFile* reader = FileSystem->createAndOpenFile(script_name);
auto reader = FileSystem->createAndOpenFile(script_name);
#endif
if (!reader)
return nullptr;
......
......@@ -69,7 +69,18 @@ void DeckBuilder::Initialize() {
mainGame->btnSideShuffle->setVisible(false);
mainGame->btnSideSort->setVisible(false);
mainGame->btnSideReload->setVisible(false);
filterList = &deckManager._lfList[mainGame->gameConf.use_lflist ? mainGame->gameConf.default_lflist : deckManager._lfList.size() - 1].content;
if (mainGame->gameConf.use_lflist) {
if (mainGame->gameConf.default_lflist >= 0 && mainGame->gameConf.default_lflist < (int)deckManager._lfList.size()) {
filterList = &deckManager._lfList[mainGame->gameConf.default_lflist];
}
else {
mainGame->gameConf.default_lflist = 0;
filterList = &deckManager._lfList.front();
}
}
else {
filterList = &deckManager._lfList.back();
}
ClearSearch();
rnd.reset((uint_fast32_t)std::time(nullptr));
mouse_pos.set(0, 0);
......@@ -126,7 +137,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
return false;
switch(event.EventType) {
case irr::EET_GUI_EVENT: {
s32 id = event.GUIEvent.Caller->getID();
irr::s32 id = event.GUIEvent.Caller->getID();
if(((mainGame->wCategories->isVisible() && id != BUTTON_CATEGORY_OK) ||
(mainGame->wQuery->isVisible() && id != BUTTON_YES && id != BUTTON_NO) ||
(mainGame->wLinkMarks->isVisible() && id != BUTTON_MARKERS_OK) ||
......@@ -1523,7 +1534,7 @@ void DeckBuilder::FilterCards() {
if(filter_marks && (data.link_marker & filter_marks) != filter_marks)
continue;
if(filter_lm) {
if(filter_lm <= 3 && (!filterList->count(ptr->first) || (*filterList).at(ptr->first) != filter_lm - 1))
if(filter_lm <= 3 && (!filterList->content.count(ptr->first) || filterList->content.at(ptr->first) != filter_lm - 1))
continue;
if(filter_lm == 4 && !(data.ot & AVAIL_OCG))
continue;
......@@ -1713,13 +1724,13 @@ void DeckBuilder::ShowDeckManage() {
void DeckBuilder::ShowBigCard(int code, float zoom) {
bigcard_code = code;
bigcard_zoom = zoom;
ITexture* img = imageManager.GetBigPicture(code, zoom);
auto img = imageManager.GetBigPicture(code, zoom);
mainGame->imgBigCard->setImage(img);
auto size = img->getSize();
s32 left = mainGame->window_size.Width / 2 - size.Width / 2;
s32 top = mainGame->window_size.Height / 2 - size.Height / 2;
mainGame->imgBigCard->setRelativePosition(recti(0, 0, size.Width, size.Height));
mainGame->wBigCard->setRelativePosition(recti(left, top, left + size.Width, top + size.Height));
irr::s32 left = mainGame->window_size.Width / 2 - size.Width / 2;
irr::s32 top = mainGame->window_size.Height / 2 - size.Height / 2;
mainGame->imgBigCard->setRelativePosition(irr::core::recti(0, 0, size.Width, size.Height));
mainGame->wBigCard->setRelativePosition(irr::core::recti(left, top, left + size.Width, top + size.Height));
mainGame->gMutex.lock();
mainGame->btnBigCardOriginalSize->setVisible(true);
mainGame->btnBigCardZoomIn->setVisible(true);
......@@ -1729,12 +1740,12 @@ void DeckBuilder::ShowBigCard(int code, float zoom) {
mainGame->env->getRootGUIElement()->bringToFront(mainGame->wBigCard);
mainGame->gMutex.unlock();
}
void DeckBuilder::ZoomBigCard(s32 centerx, s32 centery) {
void DeckBuilder::ZoomBigCard(irr::s32 centerx, irr::s32 centery) {
if(bigcard_zoom >= 4)
bigcard_zoom = 4;
if(bigcard_zoom <= 0.2f)
bigcard_zoom = 0.2f;
ITexture* img = imageManager.GetBigPicture(bigcard_code, bigcard_zoom);
auto img = imageManager.GetBigPicture(bigcard_code, bigcard_zoom);
mainGame->imgBigCard->setImage(img);
auto size = img->getSize();
auto pos = mainGame->wBigCard->getRelativePosition();
......@@ -1744,10 +1755,10 @@ void DeckBuilder::ZoomBigCard(s32 centerx, s32 centery) {
}
float posx = (float)(centerx - pos.UpperLeftCorner.X) / pos.getWidth();
float posy = (float)(centery - pos.UpperLeftCorner.Y) / pos.getHeight();
s32 left = centerx - size.Width * posx;
s32 top = centery - size.Height * posy;
mainGame->imgBigCard->setRelativePosition(recti(0, 0, size.Width, size.Height));
mainGame->wBigCard->setRelativePosition(recti(left, top, left + size.Width, top + size.Height));
irr::s32 left = centerx - size.Width * posx;
irr::s32 top = centery - size.Height * posy;
mainGame->imgBigCard->setRelativePosition(irr::core::recti(0, 0, size.Width, size.Height));
mainGame->wBigCard->setRelativePosition(irr::core::recti(left, top, left + size.Width, top + size.Height));
}
void DeckBuilder::CloseBigCard() {
mainGame->HideElement(mainGame->wBigCard);
......@@ -1868,8 +1879,8 @@ void DeckBuilder::pop_side(int seq) {
bool DeckBuilder::check_limit(code_pointer pointer) {
unsigned int limitcode = pointer->second.alias ? pointer->second.alias : pointer->first;
int limit = 3;
auto flit = filterList->find(limitcode);
if(flit != filterList->end())
auto flit = filterList->content.find(limitcode);
if(flit != filterList->content.end())
limit = flit->second;
for(auto it = deckManager.current_deck.main.begin(); it != deckManager.current_deck.main.end(); ++it) {
if((*it)->first == limitcode || (*it)->second.alias == limitcode)
......
......@@ -5,6 +5,7 @@
#include <vector>
#include <irrlicht.h>
#include "data_manager.h"
#include "deck_manager.h"
#include "../ocgcore/mtrandom.h"
namespace ygo {
......@@ -81,7 +82,7 @@ public:
bool showing_pack{};
mt19937 rnd;
const std::unordered_map<int, int>* filterList;
const LFList* filterList{};
std::vector<code_pointer> results;
wchar_t result_string[8]{};
std::vector<std::wstring> expansionPacks;
......
......@@ -31,17 +31,14 @@ void DeckManager::LoadLFListSingle(const char* path) {
}
if (cur == _lfList.rend())
continue;
int code = 0;
unsigned int code = 0;
int count = -1;
if (std::sscanf(linebuf, "%9d%*[ ]%9d", &code, &count) != 2)
continue;
if (code <= 0 || code > MAX_CARD_ID)
if (std::sscanf(linebuf, "%9u%*[ ]%9d", &code, &count) != 2)
continue;
if (count < 0 || count > 2)
continue;
unsigned int hcode = code;
cur->content[code] = count;
cur->hash = cur->hash ^ ((hcode << 18) | (hcode >> 14)) ^ ((hcode << (27 + count)) | (hcode >> (5 - count)));
cur->hash = cur->hash ^ ((code << 18) | (code >> 14)) ^ ((code << (27 + count)) | (code >> (5 - count)));
}
std::fclose(fp);
}
......@@ -54,7 +51,7 @@ void DeckManager::LoadLFList() {
nolimit.hash = 0;
_lfList.push_back(nolimit);
}
const wchar_t* DeckManager::GetLFListName(int lfhash) {
const wchar_t* DeckManager::GetLFListName(unsigned int lfhash) {
auto lit = std::find_if(_lfList.begin(), _lfList.end(), [lfhash](const ygo::LFList& list) {
return list.hash == lfhash;
});
......@@ -62,12 +59,12 @@ const wchar_t* DeckManager::GetLFListName(int lfhash) {
return lit->listName.c_str();
return dataManager.unknown_string;
}
const std::unordered_map<int, int>* DeckManager::GetLFListContent(int lfhash) {
const LFList* DeckManager::GetLFList(unsigned int lfhash) {
auto lit = std::find_if(_lfList.begin(), _lfList.end(), [lfhash](const ygo::LFList& list) {
return list.hash == lfhash;
});
if(lit != _lfList.end())
return &lit->content;
if (lit != _lfList.end())
return &(*lit);
return nullptr;
}
static unsigned int checkAvail(unsigned int ot, unsigned int avail) {
......@@ -90,9 +87,10 @@ unsigned int DeckManager::CheckDeck(Deck& deck, int lfhash, int rule) {
return (DECKERROR_EXTRACOUNT << 28) | (unsigned)deck.extra.size();
if(deck.side.size() > SIDE_MAX_SIZE)
return (DECKERROR_SIDECOUNT << 28) | (unsigned)deck.side.size();
auto list = GetLFListContent(lfhash);
if (!list)
auto lflist = GetLFList(lfhash);
if (!lflist)
return 0;
auto& list = lflist->content;
const unsigned int rule_map[6] = { AVAIL_OCG, AVAIL_TCG, AVAIL_SC, AVAIL_CUSTOM, AVAIL_OCGTCG, 0 };
unsigned int avail = 0;
if (rule >= 0 && rule < (int)(sizeof rule_map / sizeof rule_map[0]))
......@@ -108,8 +106,8 @@ unsigned int DeckManager::CheckDeck(Deck& deck, int lfhash, int rule) {
int dc = ccount[code];
if(dc > 3)
return (DECKERROR_CARDCOUNT << 28) | cit->first;
auto it = list->find(code);
if(it != list->end() && dc > it->second)
auto it = list.find(code);
if(it != list.end() && dc > it->second)
return (DECKERROR_LFLIST << 28) | cit->first;
}
for (auto& cit : deck.extra) {
......@@ -123,8 +121,8 @@ unsigned int DeckManager::CheckDeck(Deck& deck, int lfhash, int rule) {
int dc = ccount[code];
if(dc > 3)
return (DECKERROR_CARDCOUNT << 28) | cit->first;
auto it = list->find(code);
if(it != list->end() && dc > it->second)
auto it = list.find(code);
if(it != list.end() && dc > it->second)
return (DECKERROR_LFLIST << 28) | cit->first;
}
for (auto& cit : deck.side) {
......@@ -138,8 +136,8 @@ unsigned int DeckManager::CheckDeck(Deck& deck, int lfhash, int rule) {
int dc = ccount[code];
if(dc > 3)
return (DECKERROR_CARDCOUNT << 28) | cit->first;
auto it = list->find(code);
if(it != list->end() && dc > it->second)
auto it = list.find(code);
if(it != list.end() && dc > it->second)
return (DECKERROR_LFLIST << 28) | cit->first;
}
return 0;
......@@ -201,7 +199,7 @@ int DeckManager::LoadDeck(Deck& deck, std::istringstream& deckStream, bool is_pa
if (linebuf[0] < '0' || linebuf[0] > '9')
continue;
errno = 0;
code = strtol(linebuf.c_str(), nullptr, 10);
code = std::strtol(linebuf.c_str(), nullptr, 10);
if (errno == ERANGE)
continue;
cardlist[ct++] = code;
......@@ -288,7 +286,7 @@ irr::io::IReadFile* DeckManager::OpenDeckReader(const wchar_t* file) {
}
bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) {
current_deck.clear();
IReadFile* reader = OpenDeckReader(file);
auto reader = OpenDeckReader(file);
if(!reader) {
wchar_t localfile[256];
myswprintf(localfile, L"./deck/%ls.ydk", file);
......
......@@ -32,7 +32,7 @@ namespace ygo {
struct LFList {
unsigned int hash{};
std::wstring listName;
std::unordered_map<int, int> content;
std::unordered_map<unsigned int, int> content;
};
struct Deck {
std::vector<code_pointer> main;
......@@ -60,8 +60,8 @@ public:
void LoadLFListSingle(const char* path);
void LoadLFList();
const wchar_t* GetLFListName(int lfhash);
const std::unordered_map<int, int>* GetLFListContent(int lfhash);
const wchar_t* GetLFListName(unsigned int lfhash);
const LFList* GetLFList(unsigned int lfhash);
unsigned int CheckDeck(Deck& deck, int lfhash, int rule);
int LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_packlist = false);
int LoadDeck(Deck& deck, std::istringstream& deckStream, bool is_packlist = false);
......
This diff is collapsed.
......@@ -602,9 +602,9 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
mainGame->dInfo.time_left[0] = 0;
mainGame->dInfo.time_left[1] = 0;
mainGame->RefreshTimeDisplay();
mainGame->deckBuilder.filterList = deckManager.GetLFListContent(pkt->info.lflist);
mainGame->deckBuilder.filterList = deckManager.GetLFList(pkt->info.lflist);
if(mainGame->deckBuilder.filterList == nullptr)
mainGame->deckBuilder.filterList = &deckManager._lfList[0].content;
mainGame->deckBuilder.filterList = &deckManager._lfList[0];
mainGame->stHostPrepOB->setText(L"");
mainGame->SetStaticText(mainGame->stHostPrepRule, 180, mainGame->guiFont, str.c_str());
mainGame->RefreshCategoryDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect);
......@@ -2082,23 +2082,23 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
else startpos = 155;
if(positions & 0x1) {
mainGame->imageLoading.insert(std::make_pair(mainGame->btnPSAU, code));
mainGame->btnPSAU->setRelativePosition(rect<s32>(startpos, 45, startpos + 140, 185));
mainGame->btnPSAU->setRelativePosition(irr::core::rect<irr::s32>(startpos, 45, startpos + 140, 185));
mainGame->btnPSAU->setVisible(true);
startpos += 145;
} else mainGame->btnPSAU->setVisible(false);
if(positions & 0x2) {
mainGame->btnPSAD->setRelativePosition(rect<s32>(startpos, 45, startpos + 140, 185));
mainGame->btnPSAD->setRelativePosition(irr::core::rect<irr::s32>(startpos, 45, startpos + 140, 185));
mainGame->btnPSAD->setVisible(true);
startpos += 145;
} else mainGame->btnPSAD->setVisible(false);
if(positions & 0x4) {
mainGame->imageLoading.insert(std::make_pair(mainGame->btnPSDU, code));
mainGame->btnPSDU->setRelativePosition(rect<s32>(startpos, 45, startpos + 140, 185));
mainGame->btnPSDU->setRelativePosition(irr::core::rect<irr::s32>(startpos, 45, startpos + 140, 185));
mainGame->btnPSDU->setVisible(true);
startpos += 145;
} else mainGame->btnPSDU->setVisible(false);
if(positions & 0x8) {
mainGame->btnPSDD->setRelativePosition(rect<s32>(startpos, 45, startpos + 140, 185));
mainGame->btnPSDD->setRelativePosition(irr::core::rect<irr::s32>(startpos, 45, startpos + 140, 185));
mainGame->btnPSDD->setVisible(true);
startpos += 145;
} else mainGame->btnPSDD->setVisible(false);
......@@ -3680,11 +3680,11 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
float xd = mainGame->dField.attack_target->curPos.X;
float yd = mainGame->dField.attack_target->curPos.Y;
sy = (float)sqrt((xa - xd) * (xa - xd) + (ya - yd) * (ya - yd)) / 2;
mainGame->atk_t = vector3df((xa + xd) / 2, (ya + yd) / 2, 0);
mainGame->atk_t = irr::core::vector3df((xa + xd) / 2, (ya + yd) / 2, 0);
if (ca == 0)
mainGame->atk_r = vector3df(0, 0, -atan((xd - xa) / (yd - ya)));
mainGame->atk_r = irr::core::vector3df(0, 0, -atan((xd - xa) / (yd - ya)));
else
mainGame->atk_r = vector3df(0, 0, 3.1415926 - atan((xd - xa) / (yd - ya)));
mainGame->atk_r = irr::core::vector3df(0, 0, 3.1415926 - atan((xd - xa) / (yd - ya)));
} else {
soundManager.PlaySoundEffect(SOUND_DIRECT_ATTACK);
myswprintf(event_string, dataManager.GetSysString(1620), dataManager.GetName(mainGame->dField.attacker->code));
......@@ -3695,11 +3695,11 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
if (ca == 0)
yd = -3.5f;
sy = (float)sqrt((xa - xd) * (xa - xd) + (ya - yd) * (ya - yd)) / 2;
mainGame->atk_t = vector3df((xa + xd) / 2, (ya + yd) / 2, 0);
mainGame->atk_t = irr::core::vector3df((xa + xd) / 2, (ya + yd) / 2, 0);
if (ca == 0)
mainGame->atk_r = vector3df(0, 0, -atan((xd - xa) / (yd - ya)));
mainGame->atk_r = irr::core::vector3df(0, 0, -atan((xd - xa) / (yd - ya)));
else
mainGame->atk_r = vector3df(0, 0, 3.1415926 - atan((xd - xa) / (yd - ya)));
mainGame->atk_r = irr::core::vector3df(0, 0, 3.1415926 - atan((xd - xa) / (yd - ya)));
}
if (auto_watch_mode) {
int code = mainGame->dField.attacker->code;
......@@ -3936,9 +3936,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
mainGame->cbANNumber->setSelected(0);
if(quickmode) {
mainGame->cbANNumber->setVisible(false);
mainGame->btnANNumberOK->setRelativePosition(rect<s32>(20, 195, 210, 230));
mainGame->btnANNumberOK->setRelativePosition(irr::core::rect<irr::s32>(20, 195, 210, 230));
mainGame->btnANNumberOK->setEnabled(false);
recti pos = mainGame->wANNumber->getRelativePosition();
irr::core::recti pos = mainGame->wANNumber->getRelativePosition();
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + 250;
mainGame->wANNumber->setRelativePosition(pos);
} else {
......@@ -3946,8 +3946,8 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
mainGame->btnANNumber[i]->setVisible(false);
}
mainGame->cbANNumber->setVisible(true);
mainGame->btnANNumberOK->setRelativePosition(rect<s32>(80, 60, 150, 85));
recti pos = mainGame->wANNumber->getRelativePosition();
mainGame->btnANNumberOK->setRelativePosition(irr::core::rect<irr::s32>(80, 60, 150, 85));
irr::core::recti pos = mainGame->wANNumber->getRelativePosition();
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + 95;
mainGame->wANNumber->setRelativePosition(pos);
}
......
......@@ -103,7 +103,7 @@ public:
bufferevent_write(client_bev, duel_client_write, 3);
}
template<typename ST>
static void SendPacketToServer(unsigned char proto, ST& st) {
static void SendPacketToServer(unsigned char proto, const ST& st) {
auto p = duel_client_write;
if (sizeof(ST) > MAX_DATA_SIZE)
return;
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -163,9 +163,9 @@ public:
bool Initialize();
void MainLoop();
void RefreshTimeDisplay();
void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar);
void InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text);
std::wstring SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos = 0);
void BuildProjectionMatrix(irr::core::matrix4& mProjection, irr::f32 left, irr::f32 right, irr::f32 bottom, irr::f32 top, irr::f32 znear, irr::f32 zfar);
void InitStaticText(irr::gui::IGUIStaticText* pControl, irr::u32 cWidth, irr::u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text);
std::wstring SetStaticText(irr::gui::IGUIStaticText* pControl, irr::u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, irr::u32 pos = 0);
void LoadExpansions();
void RefreshCategoryDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck, bool selectlastused = true);
void RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck);
......@@ -191,7 +191,7 @@ public:
void HideElement(irr::gui::IGUIElement* element, bool set_action = false);
void PopupElement(irr::gui::IGUIElement* element, int hideframe = 0);
void WaitFrameSignal(int frame);
void DrawThumb(code_pointer cp, irr::core::vector2di pos, const std::unordered_map<int,int>* lflist, bool drag = false);
void DrawThumb(code_pointer cp, irr::core::vector2di pos, const LFList* lflist, bool drag = false);
void DrawDeckBd();
bool LoadConfigFromFile(const char* file);
void LoadConfig();
......@@ -217,7 +217,7 @@ public:
const wchar_t* GetLocaleDirWide(const char* dir);
bool CheckRegEx(const std::wstring& text, const std::wstring& exp, bool exact = false);
bool HasFocus(EGUI_ELEMENT_TYPE type) const {
bool HasFocus(irr::gui::EGUI_ELEMENT_TYPE type) const {
irr::gui::IGUIElement* focus = env->getFocus();
return focus && focus->hasType(type);
}
......@@ -230,27 +230,27 @@ public:
void OnResize();
void ResizeChatInputWindow();
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);
irr::core::vector2di Resize(s32 x, s32 y);
irr::core::vector2di ResizeReverse(s32 x, s32 y);
recti ResizePhaseHint(s32 x, s32 y, s32 x2, s32 y2, s32 width);
recti ResizeWin(s32 x, s32 y, s32 x2, s32 y2);
recti ResizeCardImgWin(s32 x, s32 y, s32 mx, s32 my);
recti ResizeCardHint(s32 x, s32 y, s32 x2, s32 y2);
irr::core::vector2di ResizeCardHint(s32 x, s32 y);
recti ResizeCardMid(s32 x, s32 y, s32 x2, s32 y2, s32 midx, s32 midy);
irr::core::vector2di ResizeCardMid(s32 x, s32 y, s32 midx, s32 midy);
recti ResizeFit(s32 x, s32 y, s32 x2, s32 y2);
irr::core::recti Resize(irr::s32 x, irr::s32 y, irr::s32 x2, irr::s32 y2);
irr::core::recti Resize(irr::s32 x, irr::s32 y, irr::s32 x2, irr::s32 y2, irr::s32 dx, irr::s32 dy, irr::s32 dx2, irr::s32 dy2);
irr::core::vector2di Resize(irr::s32 x, irr::s32 y);
irr::core::vector2di ResizeReverse(irr::s32 x, irr::s32 y);
irr::core::recti ResizePhaseHint(irr::s32 x, irr::s32 y, irr::s32 x2, irr::s32 y2, irr::s32 width);
irr::core::recti ResizeWin(irr::s32 x, irr::s32 y, irr::s32 x2, irr::s32 y2);
irr::core::recti ResizeCardImgWin(irr::s32 x, irr::s32 y, irr::s32 mx, irr::s32 my);
irr::core::recti ResizeCardHint(irr::s32 x, irr::s32 y, irr::s32 x2, irr::s32 y2);
irr::core::vector2di ResizeCardHint(irr::s32 x, irr::s32 y);
irr::core::recti ResizeCardMid(irr::s32 x, irr::s32 y, irr::s32 x2, irr::s32 y2, irr::s32 midx, irr::s32 midy);
irr::core::vector2di ResizeCardMid(irr::s32 x, irr::s32 y, irr::s32 midx, irr::s32 midy);
irr::core::recti ResizeFit(irr::s32 x, irr::s32 y, irr::s32 x2, irr::s32 y2);
void SetWindowsIcon();
void SetWindowsScale(float scale);
void FlashWindow();
void takeScreenshot();
void SetCursor(ECURSOR_ICON icon);
void SetCursor(irr::gui::ECURSOR_ICON icon);
template<typename T>
static void DrawShadowText(irr::gui::CGUITTFont* font, const T& text, const core::rect<s32>& position, const core::rect<s32>& padding,
video::SColor color = 0xffffffff, video::SColor shadowcolor = 0xff000000, bool hcenter = false, bool vcenter = false, const core::rect<s32>* clip = nullptr);
static void DrawShadowText(irr::gui::CGUITTFont* font, const T& text, const irr::core::rect<irr::s32>& position, const irr::core::rect<irr::s32>& padding,
irr::video::SColor color = 0xffffffff, irr::video::SColor shadowcolor = 0xff000000, bool hcenter = false, bool vcenter = false, const irr::core::rect<irr::s32>* clip = nullptr);
std::mutex gMutex;
Signal frameSignal;
......@@ -267,41 +267,41 @@ public:
std::wstring chatMsg[8];
std::vector<BotInfo> botInfo;
int hideChatTimer;
bool hideChat;
int hideChatTimer{};
bool hideChat{};
int chatTiming[8]{};
int chatType[8]{};
unsigned short linePatternD3D;
unsigned short linePatternGL;
int waitFrame;
int signalFrame;
int actionParam;
int showingcode;
const wchar_t* showingtext;
int showcard;
int showcardcode;
int showcarddif;
int showcardp;
int is_attacking;
int attack_sv;
unsigned short linePatternD3D{};
unsigned short linePatternGL{ 0x0f0f };
int waitFrame{};
int signalFrame{};
int actionParam{};
int showingcode{};
const wchar_t* showingtext{};
int showcard{};
int showcardcode{};
int showcarddif{};
int showcardp{};
int is_attacking{};
int attack_sv{};
irr::core::vector3df atk_r;
irr::core::vector3df atk_t;
float atkdy;
int lpframe;
int lpd;
int lpplayer;
int lpccolor;
float atkdy{};
int lpframe{};
int lpd{};
int lpplayer{};
int lpccolor{};
std::wstring lpcstring;
bool always_chain;
bool ignore_chain;
bool chain_when_avail;
bool always_chain{};
bool ignore_chain{};
bool chain_when_avail{};
bool is_building;
bool is_siding;
bool is_building{};
bool is_siding{};
irr::core::dimension2d<irr::u32> window_size;
float xScale;
float yScale;
float xScale{ 1.0f };
float yScale{ 1.0f };
CGUISkinSystem *skinSystem;
wchar_t locale_buf[256];
......
......@@ -2,7 +2,7 @@
#include "game.h"
#include "data_manager.h"
#include <event2/thread.h>
#include <locale.h>
#include <clocale>
#include <memory>
#ifdef __APPLE__
......@@ -26,7 +26,7 @@ void ClickButton(irr::gui::IGUIElement* btn) {
int main(int argc, char* argv[]) {
#ifndef _WIN32
setlocale(LC_CTYPE, "UTF-8");
std::setlocale(LC_CTYPE, "UTF-8");
#endif
#ifdef __APPLE__
CFURLRef bundle_url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
......
......@@ -222,7 +222,7 @@ void ImageManager::ResizeTexture() {
// function by Warr1024, from https://github.com/minetest/minetest/issues/2419 , modified
void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
double sx, sy, minsx, maxsx, minsy, maxsy, area, ra, ga, ba, aa, pw, ph, pa;
u32 dy, dx;
irr::u32 dy, dx;
irr::video::SColor pxl;
// Cache rectsngle boundaries.
......@@ -231,7 +231,7 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
// Walk each destination image pixel.
// Note: loop y around x for better cache locality.
irr::core::dimension2d<u32> dim = dest->getDimension();
irr::core::dimension2d<irr::u32> dim = dest->getDimension();
for(dy = 0; dy < dim.Height; dy++)
for(dx = 0; dx < dim.Width; dx++) {
......@@ -269,7 +269,7 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
// Get source pixel and add it to totals, weighted
// by covered area and alpha.
pxl = src->getPixel((u32)sx, (u32)sy);
pxl = src->getPixel((irr::u32)sx, (irr::u32)sy);
area += pa;
ra += pa * pxl.getRed();
ga += pa * pxl.getGreen();
......@@ -292,16 +292,16 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
dest->setPixel(dx, dy, pxl);
}
}
irr::video::ITexture* ImageManager::GetTextureFromFile(const char* file, s32 width, s32 height) {
irr::video::ITexture* ImageManager::GetTextureFromFile(const char* file, irr::s32 width, irr::s32 height) {
if(mainGame->gameConf.use_image_scale) {
irr::video::ITexture* texture;
irr::video::IImage* srcimg = driver->createImageFromFile(file);
if(srcimg == nullptr)
return nullptr;
if(srcimg->getDimension() == irr::core::dimension2d<u32>(width, height)) {
if(srcimg->getDimension() == irr::core::dimension2d<irr::u32>(width, height)) {
texture = driver->addTexture(file, srcimg);
} else {
video::IImage *destimg = driver->createImage(srcimg->getColorFormat(), irr::core::dimension2d<u32>(width, height));
irr::video::IImage *destimg = driver->createImage(srcimg->getColorFormat(), irr::core::dimension2d<irr::u32>(width, height));
imageScaleNNAA(srcimg, destimg);
texture = driver->addTexture(file, destimg);
destimg->drop();
......@@ -383,7 +383,7 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
texture = driver->addTexture(file, srcimg);
} else {
auto origsize = srcimg->getDimension();
video::IImage* destimg = driver->createImage(srcimg->getColorFormat(), irr::core::dimension2d<u32>(origsize.Width * zoom, origsize.Height * zoom));
irr::video::IImage* destimg = driver->createImage(srcimg->getColorFormat(), irr::core::dimension2d<irr::u32>(origsize.Width * zoom, origsize.Height * zoom));
imageScaleNNAA(srcimg, destimg);
texture = driver->addTexture(file, destimg);
destimg->drop();
......@@ -448,14 +448,14 @@ int ImageManager::LoadThumbThread() {
if(img != nullptr) {
int width = CARD_THUMB_WIDTH * mainGame->xScale;
int height = CARD_THUMB_HEIGHT * mainGame->yScale;
if(img->getDimension() == irr::core::dimension2d<u32>(width, height)) {
if(img->getDimension() == irr::core::dimension2d<irr::u32>(width, height)) {
img->grab();
imageManager.tThumbLoadingMutex.lock();
if(imageManager.tThumbLoadingThreadRunning)
imageManager.tThumbLoading[code] = img;
imageManager.tThumbLoadingMutex.unlock();
} else {
irr::video::IImage *destimg = imageManager.driver->createImage(img->getColorFormat(), irr::core::dimension2d<u32>(width, height));
irr::video::IImage *destimg = imageManager.driver->createImage(img->getColorFormat(), irr::core::dimension2d<irr::u32>(width, height));
imageScaleNNAA(img, destimg);
img->drop();
destimg->grab();
......
......@@ -16,14 +16,14 @@ public:
bool Initial();
//random image
irr::video::ITexture* GetRandomImage(int image_type);
irr::video::ITexture* GetRandomImage(int image_type, s32 width, s32 height);
irr::video::ITexture* GetRandomImage(int image_type, irr::s32 width, irr::s32 height);
void RefreshRandomImageList();
void RefreshImageDir(std::wstring path, int image_type);
void SetDevice(irr::IrrlichtDevice* dev);
void ClearTexture();
void RemoveTexture(int code);
void ResizeTexture();
irr::video::ITexture* GetTextureFromFile(const char* file, s32 width, s32 height);
irr::video::ITexture* GetTextureFromFile(const char* file, irr::s32 width, irr::s32 height);
irr::video::ITexture* GetTexture(int code, bool fit = false);
irr::video::ITexture* GetBigPicture(int code, float zoom);
irr::video::ITexture* GetTextureThumb(int code);
......
project "clzma"
kind "StaticLib"
cdialect "C11"
files { "*.c", "*.h" }
......@@ -33,7 +33,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
switch(event.EventType) {
case irr::EET_GUI_EVENT: {
irr::gui::IGUIElement* caller = event.GUIEvent.Caller;
s32 id = caller->getID();
irr::s32 id = caller->getID();
if(mainGame->wQuery->isVisible() && id != BUTTON_YES && id != BUTTON_NO) {
mainGame->wQuery->getParent()->bringToFront(mainGame->wQuery);
break;
......@@ -386,7 +386,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
char arg3[8];
std::snprintf(arg3, sizeof arg3, "%d", mainGame->gameConf.serverport);
execl("./bot", "bot", arg1, arg2, arg3, nullptr);
exit(0);
std::exit(0);
} else {
if(!NetServer::StartServer(mainGame->gameConf.serverport)) {
soundManager.PlaySoundEffect(SOUND_INFO);
......
......@@ -41,7 +41,7 @@ public:
bufferevent_write(dp->bev, net_server_write, 3);
}
template<typename ST>
static void SendPacketToPlayer(DuelPlayer* dp, unsigned char proto, ST& st) {
static void SendPacketToPlayer(DuelPlayer* dp, unsigned char proto, const ST& st) {
auto p = net_server_write;
if (sizeof(ST) > MAX_DATA_SIZE)
return;
......
......@@ -6,6 +6,7 @@ end
project "YGOPro"
kind "WindowedApp"
cppdialect "C++14"
files { "*.cpp", "*.h", "CGUISkinSystem/*.cpp", "CGUISkinSystem/*.h", "CXMLRegistry/*.cpp", "CXMLRegistry/*.h" }
includedirs { "../ocgcore" }
......@@ -50,7 +51,7 @@ project "YGOPro"
libdirs { "$(DXSDK_DIR)Lib/x86" }
links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32", "Dnsapi" }
filter "not action:vs*"
buildoptions { "-std=c++14", "-fno-rtti" }
buildoptions { "-fno-rtti" }
filter "not system:windows"
links { "event_pthreads", "dl", "pthread", "resolv" }
filter "system:macosx"
......
#ifndef REPLAY_MODE_H
#define REPLAY_MODE_H
#include <stdint.h>
#include <cstdint>
#include <vector>
#include "replay.h"
......
#ifndef SINGLE_MODE_H
#define SINGLE_MODE_H
#include <stdint.h>
#include <cstdint>
#include <vector>
#include "replay.h"
......
project "cspmemvfs"
kind "StaticLib"
cdialect "C11"
files { "*.c", "*.h" }
if BUILD_SQLITE then
includedirs { "../../sqlite3" }
end
filter "not action:vs*"
defines { "_POSIX_C_SOURCE=200809L" }
project "event"
kind "StaticLib"
cdialect "C11"
includedirs { "include", "compat" }
......
project "freetype"
kind "StaticLib"
cdialect "C11"
includedirs { "include" }
defines { "FT2_BUILD_LIBRARY" }
......
project "irrlicht"
kind "StaticLib"
cdialect "C11"
includedirs { "include", "source/Irrlicht", "source/Irrlicht/jpeglib", "source/Irrlicht/libpng", "source/Irrlicht/zlib" }
......@@ -318,7 +319,7 @@ project "irrlicht"
filter { "system:windows" }
defines { "_IRR_WCHAR_FILESYSTEM" }
includedirs { "$(DXSDK_DIR)include" }
includedirs { "$(DXSDK_DIR)Include" }
libdirs { "$(DXSDK_DIR)Lib/x86" }
links { "imm32" }
......
project "sqlite3"
kind "StaticLib"
cdialect "C11"
files { "sqlite3.c", "sqlite3.h" }
......@@ -37,7 +37,7 @@ newoption { trigger = "irrlicht-include-dir", category = "YGOPro - irrlicht", de
newoption { trigger = "irrlicht-lib-dir", category = "YGOPro - irrlicht", description = "", value = "PATH" }
newoption { trigger = "winxp-support", category = "YGOPro", description = "" }
newoption { trigger = "mac-arm", category = "YGOPro", description = "M1" }
newoption { trigger = "mac-arm", category = "YGOPro", description = "Cross compile for Apple Silicon" }
-- koishipro specific
......@@ -91,9 +91,9 @@ end
if not BUILD_LUA then
-- at most times you need to change this if you change BUILD_LUA to false
-- make sure your lua lib is built with C++ and version >= 5.3
LUA_INCLUDE_DIR = GetParam("lua-include-dir") or "/usr/local/include/lua"
LUA_LIB_DIR = GetParam("lua-lib-dir") or "/usr/local/lib"
LUA_LIB_NAME = GetParam("lua-lib-name")
LUA_INCLUDE_DIR = GetParam("lua-include-dir") or os.findheader(LUA_LIB_NAME)
LUA_LIB_DIR = GetParam("lua-lib-dir") or os.findlib(LUA_LIB_NAME)
end
if GetParam("lua-deb") then
......@@ -109,8 +109,8 @@ elseif GetParam("no-build-event") then
BUILD_EVENT = false
end
if not BUILD_EVENT then
EVENT_INCLUDE_DIR = GetParam("event-include-dir") or "/usr/local/include/event2"
EVENT_LIB_DIR = GetParam("event-lib-dir") or "/usr/local/lib"
EVENT_INCLUDE_DIR = GetParam("event-include-dir") or os.findheader("event")
EVENT_LIB_DIR = GetParam("event-lib-dir") or os.findlib("event")
end
if GetParam("build-freetype") then
......@@ -119,13 +119,8 @@ elseif GetParam("no-build-freetype") then
BUILD_FREETYPE = false
end
if not BUILD_FREETYPE then
if os.istarget("linux") then
FREETYPE_INCLUDE_DIR = "/usr/include/freetype2"
elseif os.istarget("macosx") then
FREETYPE_INCLUDE_DIR = "/usr/local/include/freetype2"
end
FREETYPE_INCLUDE_DIR = GetParam("freetype-include-dir") or FREETYPE_INCLUDE_DIR
FREETYPE_LIB_DIR = GetParam("freetype-lib-dir") or "/usr/local/lib"
FREETYPE_INCLUDE_DIR = GetParam("freetype-include-dir") or os.findheader("freetype")
FREETYPE_LIB_DIR = GetParam("freetype-lib-dir") or os.findlib("freetype")
end
if GetParam("build-sqlite") then
......@@ -134,8 +129,8 @@ elseif GetParam("no-build-sqlite") then
BUILD_SQLITE = false
end
if not BUILD_SQLITE then
SQLITE_INCLUDE_DIR = GetParam("sqlite-include-dir") or "/usr/local/include"
SQLITE_LIB_DIR = GetParam("sqlite-lib-dir") or "/usr/local/lib"
SQLITE_INCLUDE_DIR = GetParam("sqlite-include-dir") or os.findheader("sqlite3")
SQLITE_LIB_DIR = GetParam("sqlite-lib-dir") or os.findlib("sqlite3")
end
if GetParam("build-irrlicht") then
......@@ -144,8 +139,8 @@ elseif GetParam("no-build-irrlicht") then
BUILD_IRRLICHT = false
end
if not BUILD_IRRLICHT then
IRRLICHT_INCLUDE_DIR = GetParam("irrlicht-include-dir") or "/usr/local/include/irrlicht"
IRRLICHT_LIB_DIR = GetParam("irrlicht-lib-dir") or "/usr/local/lib"
IRRLICHT_INCLUDE_DIR = GetParam("irrlicht-include-dir") or os.findheader("irrlicht")
IRRLICHT_LIB_DIR = GetParam("irrlicht-lib-dir") or os.findlib("irrlicht")
end
USE_AUDIO = not GetParam("no-audio")
......@@ -210,7 +205,7 @@ workspace "YGOPro"
targetdir "bin/debug"
filter { "configurations:Release", "action:vs*" }
flags { "LinkTimeOptimization" }
linktimeoptimization "On"
staticruntime "On"
disablewarnings { "4244", "4267", "4838", "4577", "4018", "4996", "4477", "4091", "4800", "6011", "6031", "6054", "6262" }
......@@ -228,7 +223,7 @@ workspace "YGOPro"
vectorextensions "SSE2"
buildoptions { "/utf-8" }
defines { "_CRT_SECURE_NO_WARNINGS" }
filter "not action:vs*"
buildoptions { "-fno-strict-aliasing", "-Wno-multichar", "-Wno-format-security" }
......
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