Skip to content

Commit

Permalink
Small bugfixes (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgosar authored Dec 27, 2022
1 parent 1f9b93b commit a143efe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion MineCity2000-GUI/MineCity2000.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ private void bw_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;

mapper.Worker = worker;
mapper = new SCMapper(buildingsDir);
mapper.Worker = worker;
mapper.makeMap(inputFile, outputDir);
}
private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
button3.Enabled = true;
if ((e.Cancelled == true))
{
statusLabel.Text = "Canceled!";
Expand Down
10 changes: 8 additions & 2 deletions MineCity2000/SCMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,15 @@ private static int[][] interpolateTriangles(int p1, int p2, int p3, int p4)
result[i][j] = p4 * SECTION_HEIGHT + (j - i) * diffLowerLeft;
}
}
else//wtf
else //Irregular terrain shapes, usually at the start of bridges
{
result[i][j] = (((SQUARE_SIZE - j) * (i * p2 + (SQUARE_SIZE - i) * p1) + j * (i * p4 + (SQUARE_SIZE - i) * p3)) * SECTION_HEIGHT) / SQUARE_SIZE * SQUARE_SIZE;
int remainderI = SQUARE_SIZE - 1 - i;
int remainderJ = SQUARE_SIZE - 1 - j;
int weightP1 = remainderI* remainderJ;
int weightP2 = i* remainderJ;
int weightP3 = remainderI * j;
int weightP4 = i * j;
result[i][j] = SECTION_HEIGHT*(p1 * weightP1 + p2 * weightP2 + p3 * weightP3 + p4 * weightP4) / ((SQUARE_SIZE-1) * (SQUARE_SIZE - 1));
}
}
}
Expand Down

0 comments on commit a143efe

Please sign in to comment.