Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from xxzl0130/static
Browse files Browse the repository at this point in the history
merge Static
  • Loading branch information
xxzl0130 authored Oct 16, 2021
2 parents e1b97ac + 8f5d97d commit d5a9a1f
Show file tree
Hide file tree
Showing 18 changed files with 353 additions and 220 deletions.
8 changes: 4 additions & 4 deletions Chip/Chip.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@
<Import Project="$(QtMsBuild)\qt_defaults.props" />
</ImportGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core</QtModules>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core</QtModules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'" Label="QtSettings">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core</QtModules>
</PropertyGroup>
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.props')">
Expand All @@ -85,7 +85,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat />
<DebugInformationFormat>None</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<PreprocessorDefinitions>CHIP_LIB;BUILD_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down
8 changes: 4 additions & 4 deletions ChipDataWindow/ChipDataWindow.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@
<Import Project="$(QtMsBuild)\qt_defaults.props" />
</ImportGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core;network;sql;widgets</QtModules>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core;network;sql;widgets</QtModules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'" Label="QtSettings">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core;network;sql;widgets</QtModules>
</PropertyGroup>
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.props')">
Expand Down Expand Up @@ -106,7 +106,7 @@
</QtMoc>
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat />
<DebugInformationFormat>None</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<PrecompiledHeader>Use</PrecompiledHeader>
Expand Down
23 changes: 11 additions & 12 deletions ChipSolver/ChipSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ void ChipSolver::setUseAlt(bool b)
void ChipSolver::stop()
{
running_ = false;
solveRunning_ = false;
}

ChipViewInfo ChipSolver::solution2ChipView(const Solution& solution, const QString& squad)
Expand Down Expand Up @@ -193,7 +192,7 @@ void ChipSolver::run()
configIndex_ = 0;
solutions.clear();
tmpChips_.resize(8, 0);
thSolutionQueue_.clear();
thSolutionQueue_ = std::queue<std::shared_ptr<std::priority_queue<Solution>>>();
emit solvePercentChanged(0);

// 对153特殊处理
Expand Down Expand Up @@ -379,11 +378,11 @@ void ChipSolver::startSolve()
param.chips = CodeX::instance()->chips;
param.gridChips = CodeX::instance()->gridChips;

while (true)
while (running_)
{
int index = 0;
{
QMutexLocker locker(&configIndexLock_);
std::unique_lock<std::mutex> locker(configIndexLock_);
index = configIndex_;
// 取出本线程轮到的配置序号
if (index < tmpSquadConfig_.configs.size())
Expand All @@ -409,7 +408,7 @@ void ChipSolver::startSolve()
// 放到队列里交给合并线程处理
{
std::unique_lock<std::mutex> locker(queueMutex_);
thSolutionQueue_.enqueue(param.queue);
thSolutionQueue_.push(param.queue);
}
queueCV_.notify_all();

Expand All @@ -430,16 +429,18 @@ void ChipSolver::startSolve()

void ChipSolver::merge()
{
while(running_)
do
{
{
std::unique_lock<std::mutex> locker(queueMutex_);
queueCV_.wait_for(locker, std::chrono::milliseconds(10), [&]() {return !thSolutionQueue_.empty(); });
queueCV_.wait_for(locker, std::chrono::milliseconds(10)/*, [&]() {return !thSolutionQueue_.empty() || !solveRunning_; }*/);
}

std::unique_lock<std::mutex> locker(queueMutex_);
while (!thSolutionQueue_.empty())
{
auto it = thSolutionQueue_.head();
thSolutionQueue_.dequeue();
auto it = thSolutionQueue_.front();
thSolutionQueue_.pop();

while(!it->empty())
{
Expand All @@ -450,7 +451,5 @@ void ChipSolver::merge()
if (solutions.size() > targetBlock_.showNumber)
solutions.resize(targetBlock_.showNumber);
}
if(!solveRunning_)
return;
}
} while (solveRunning_);
}
4 changes: 2 additions & 2 deletions ChipSolver/ChipSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public slots:
// 当前配置序号
int configIndex_;
//
QMutex configIndexLock_;
std::mutex configIndexLock_;
// 使用已装备
bool useEquipped_;
// 使用已锁定
Expand Down Expand Up @@ -168,7 +168,7 @@ public slots:
void findSolution(SolverParam& param);
void startSolve();
// 各个线程给出的结果的队列
QQueue<std::shared_ptr<std::priority_queue<Solution>>> thSolutionQueue_;
std::queue<std::shared_ptr<std::priority_queue<Solution>>> thSolutionQueue_;
//
std::mutex queueMutex_;
std::condition_variable queueCV_;
Expand Down
4 changes: 4 additions & 0 deletions ChipSolver/ChipSolver.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@
<file>Resources/Mk-153.json</file>
<file>Resources/Mk-153-52-result.json</file>
<file>Resources/Mk-153-result.json</file>
<file>Resources/PP-93.json</file>
<file>Resources/PP-93-2-result.json</file>
<file>Resources/PP-93-4-result.json</file>
<file>Resources/PP-93-result.json</file>
</qresource>
</RCC>
8 changes: 4 additions & 4 deletions ChipSolver/ChipSolver.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@
<Import Project="$(QtMsBuild)\qt_defaults.props" />
</ImportGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core;gui</QtModules>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core;gui</QtModules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'" Label="QtSettings">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core;gui</QtModules>
</PropertyGroup>
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.props')">
Expand All @@ -94,7 +94,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat />
<DebugInformationFormat>None</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<PreprocessorDefinitions>CHIPSOLVER_LIB;BUILD_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down
1 change: 1 addition & 0 deletions ChipSolver/Resources/PP-93-2-result.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ChipSolver/Resources/PP-93-4-result.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ChipSolver/Resources/PP-93-result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[{"ID":17,"rotate":1,"x":2,"y":0},{"ID":28,"rotate":3,"x":3,"y":1},{"ID":30,"rotate":1,"x":0,"y":3},{"ID":30,"rotate":1,"x":5,"y":3},{"ID":17,"rotate":1,"x":3,"y":5},{"ID":28,"rotate":1,"x":2,"y":4}],[{"ID":17,"rotate":1,"x":2,"y":0},{"ID":28,"rotate":3,"x":3,"y":1},{"ID":30,"rotate":1,"x":0,"y":3},{"ID":30,"rotate":1,"x":5,"y":3},{"ID":16,"rotate":1,"x":2,"y":5},{"ID":29,"rotate":3,"x":3,"y":4}],[{"ID":17,"rotate":1,"x":2,"y":0},{"ID":28,"rotate":3,"x":3,"y":1},{"ID":30,"rotate":1,"x":0,"y":3},{"ID":30,"rotate":1,"x":5,"y":3},{"ID":24,"rotate":0,"x":4,"y":4},{"ID":25,"rotate":0,"x":2,"y":4}],[{"ID":16,"rotate":1,"x":3,"y":0},{"ID":29,"rotate":1,"x":2,"y":1},{"ID":30,"rotate":1,"x":0,"y":3},{"ID":30,"rotate":1,"x":5,"y":3},{"ID":16,"rotate":1,"x":2,"y":5},{"ID":29,"rotate":3,"x":3,"y":4}],[{"ID":16,"rotate":1,"x":3,"y":0},{"ID":29,"rotate":1,"x":2,"y":1},{"ID":30,"rotate":1,"x":0,"y":3},{"ID":30,"rotate":1,"x":5,"y":3},{"ID":24,"rotate":0,"x":4,"y":4},{"ID":25,"rotate":0,"x":2,"y":4}],[{"ID":25,"rotate":2,"x":4,"y":0},{"ID":24,"rotate":2,"x":2,"y":0},{"ID":30,"rotate":1,"x":0,"y":3},{"ID":30,"rotate":1,"x":5,"y":3},{"ID":24,"rotate":0,"x":4,"y":4},{"ID":25,"rotate":0,"x":2,"y":4}],[{"ID":17,"rotate":1,"x":2,"y":0},{"ID":24,"rotate":0,"x":4,"y":1},{"ID":30,"rotate":1,"x":5,"y":3},{"ID":17,"rotate":1,"x":3,"y":5},{"ID":24,"rotate":2,"x":2,"y":3},{"ID":30,"rotate":1,"x":0,"y":3}],[{"ID":16,"rotate":1,"x":3,"y":0},{"ID":25,"rotate":0,"x":2,"y":1},{"ID":30,"rotate":1,"x":0,"y":3},{"ID":16,"rotate":1,"x":2,"y":5},{"ID":25,"rotate":2,"x":4,"y":3},{"ID":30,"rotate":1,"x":5,"y":3}],[{"ID":17,"rotate":1,"x":2,"y":0},{"ID":24,"rotate":0,"x":4,"y":1},{"ID":30,"rotate":1,"x":5,"y":3},{"ID":17,"rotate":1,"x":3,"y":5},{"ID":21,"rotate":1,"x":1,"y":4},{"ID":38,"rotate":2,"x":0,"y":3}],[{"ID":16,"rotate":1,"x":3,"y":0},{"ID":25,"rotate":0,"x":2,"y":1},{"ID":30,"rotate":1,"x":0,"y":3},{"ID":16,"rotate":1,"x":2,"y":5},{"ID":21,"rotate":0,"x":4,"y":4},{"ID":38,"rotate":2,"x":4,"y":3}],[{"ID":13,"rotate":2,"x":3,"y":0},{"ID":25,"rotate":1,"x":0,"y":2},{"ID":24,"rotate":1,"x":0,"y":4},{"ID":12,"rotate":0,"x":3,"y":5},{"ID":30,"rotate":1,"x":5,"y":3},{"ID":38,"rotate":1,"x":4,"y":2}],[{"ID":16,"rotate":1,"x":3,"y":0},{"ID":21,"rotate":2,"x":1,"y":1},{"ID":38,"rotate":0,"x":0,"y":3},{"ID":16,"rotate":1,"x":2,"y":5},{"ID":21,"rotate":0,"x":4,"y":4},{"ID":38,"rotate":2,"x":4,"y":3}],[{"ID":17,"rotate":1,"x":2,"y":0},{"ID":21,"rotate":3,"x":4,"y":1},{"ID":38,"rotate":0,"x":4,"y":3},{"ID":17,"rotate":1,"x":3,"y":5},{"ID":21,"rotate":1,"x":1,"y":4},{"ID":38,"rotate":2,"x":0,"y":3}]]
35 changes: 35 additions & 0 deletions ChipSolver/Resources/PP-93.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "PP-93",
"optional": {
"PP-93":0,
"PP-93-2":2,
"PP-93-4":4
},
"width": 8,
"height": 8,
"blocks": 32,
"color": 1,
"palindrome": 1,
"map": [
"11100111",
"11100111",
"11000011",
"00000000",
"00000000",
"11000011",
"11100111",
"11100111"
],
"MaxBlocks": {
"damage": 16,
"def_break": 2,
"hit": 6,
"reload": 7
},
"MaxValues": {
"damage": 169,
"def_break": 55,
"hit": 100,
"reload": 91
}
}
5 changes: 5 additions & 0 deletions ChipSolver/Resources/squads.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@
"Mk-153": {
"6格+5格1类": "Mk-153-result.json",
"带5格2类": "Mk-153-52-result.json"
},
"PP-93":{
"填满": "PP-93-result.json",
"最多空2格": "PP-93-2-result.json",
"最多空4格": "PP-93-4-result.json"
}
}
8 changes: 4 additions & 4 deletions ChipTableView/ChipTableView.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@
<Import Project="$(QtMsBuild)\qt_defaults.props" />
</ImportGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core;gui;widgets</QtModules>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core;gui;widgets</QtModules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'" Label="QtSettings">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core;gui;widgets</QtModules>
</PropertyGroup>
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.props')">
Expand All @@ -94,7 +94,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat />
<DebugInformationFormat>None</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<PreprocessorDefinitions>CHIPTABLEVIEW_LIB;BUILD_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down
8 changes: 7 additions & 1 deletion ChipTableView/SolutionTableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,13 @@ void SolutionTableModel::sort(int column, Qt::SortOrder order)
case 5:
std::sort(solution_->begin(), solution_->end(),
[&](const Solution& a, const Solution& b)
{return cmp(a.totalValue.id, b.totalValue.id); });
{
if(a.totalValue.id != b.totalValue.id)
return !cmp(a.totalValue.id, b.totalValue.id);
if(a.totalValue.no != b.totalValue.no)
return !cmp(a.totalValue.no, b.totalValue.no);
return cmp(a.totalValue.exp, b.totalValue.exp);
});
break;
case 6:
std::sort(solution_->begin(), solution_->end(),
Expand Down
8 changes: 4 additions & 4 deletions ChipView/ChipView.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@
<Import Project="$(QtMsBuild)\qt_defaults.props" />
</ImportGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core</QtModules>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core</QtModules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'" Label="QtSettings">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core</QtModules>
</PropertyGroup>
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.props')">
Expand All @@ -94,7 +94,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat />
<DebugInformationFormat>None</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<PreprocessorDefinitions>CHIPVIEW_LIB;BUILD_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down
2 changes: 1 addition & 1 deletion CodeX.sln
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Global
{C5E57C1B-2CA2-3C74-ACE0-17423754CB69} = {E39C117F-8162-470F-8423-70F8562A03A1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Qt5Version = Qt 5.12.11 x64
SolutionGuid = {C3A7A5BC-ECAE-4D3A-891B-42496C40D214}
Qt5Version = Qt 5.12.9 x64
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion CodeX/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

AboutDialog::AboutDialog(QWidget *parent)
: QDialog(parent),
version(2,2,4),
version(2,3,0),
ui(new Ui::AboutDialog()),
accessManager_(new QNetworkAccessManager(this))
{
Expand Down
8 changes: 4 additions & 4 deletions CodeX/CodeX.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@
<Import Project="$(QtMsBuild)\qt_defaults.props" />
</ImportGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core;gui;network;sql;widgets</QtModules>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core;gui;network;sql;widgets</QtModules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'" Label="QtSettings">
<QtInstall>Qt 5.12.9 x64</QtInstall>
<QtInstall>Qt 5.12.11 x64</QtInstall>
<QtModules>core;gui;network;sql;widgets</QtModules>
</PropertyGroup>
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.props')">
Expand Down Expand Up @@ -107,7 +107,7 @@
</QtMoc>
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat />
<DebugInformationFormat>None</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<PrecompiledHeader>Use</PrecompiledHeader>
Expand Down
Loading

0 comments on commit d5a9a1f

Please sign in to comment.