Skip to content

Commit

Permalink
fix file watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriSizuku committed Nov 30, 2024
1 parent 1971bd6 commit 84376e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
5 changes: 3 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ Usage: TileViewer [-n] [-i <str>] [-o <str>] [-p <str>]
-n, --nogui decode tiles without gui
-i, --inpath=<str> tile file inpath
-o, --outpath=<str> outpath for decoded file
-p, --plugin=<str> use lua plugin to decode
--plugincfg=<str> use plugincfg, default is xxx.json with xxx plugin
-p, --plugin=<str> plugin path to decode
--plugincfg=<str> plugin config path (default pluginpath.json)
--pluginparam=<str> set the plugincfg values, for example {'name1': value1, 'name2': value2}
--start=<num> tile start offset
--size=<num> whole tile size
--nrow=<num> how many tiles in a row
Expand Down
21 changes: 8 additions & 13 deletions src/core_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,25 +187,20 @@ TileSolver::TileSolver()
size_t TileSolver::PrepareTilebuf()
{
size_t start = m_tilecfg.start;
size_t datasize = m_tilecfg.size - start;
size_t datasize = m_tilecfg.size;
size_t nbytes = calc_tile_nbytes(&m_tilecfg.fmt);

// check datasize avilable
if(!datasize)
if(m_filebuf.GetDataLen() - start < 0)
{
if(m_filebuf.GetDataLen() - start < 0)
{
wxLogError("[TileSolver::Decode] start(%u) is bigger than file (%zu)",
start, m_filebuf.GetDataLen());
return 0;
}
datasize = m_filebuf.GetDataLen() - start;
}
else
{
datasize = wxMin<size_t, size_t>(datasize, m_filebuf.GetDataLen());
wxLogError("[TileSolver::Decode] start(%u) is bigger than file (%zu)",
start, m_filebuf.GetDataLen());
return 0;
}

if(!datasize) datasize = m_filebuf.GetDataLen() - start;
else datasize = wxMin<size_t, size_t>(datasize, m_filebuf.GetDataLen() - start);

// prepares tiles
int ntile = datasize / nbytes;
if(ntile <= 0) ntile = 1; // prevent data less than nbytes
Expand Down
2 changes: 1 addition & 1 deletion src/ui_top.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TopFrame::TopFrame() :
wxGetApp().SearchPlugins(pluginDir); // find decode plugins

// file watcher
if(wxFileExists(pluginDir))
if(wxDirExists(pluginDir))
{
auto *filewatcher = new wxFileSystemWatcher();
filewatcher->SetOwner(this);
Expand Down

0 comments on commit 84376e5

Please sign in to comment.