Skip to content

Commit

Permalink
Fixed map appearing scroll blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
cvet committed Dec 27, 2024
1 parent e0e9b39 commit b30ac99
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
4 changes: 3 additions & 1 deletion BuildTools/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2088,8 +2088,10 @@ def ctxSetArgs(args, setIndex=0):
globalLines.append(' ctx->SetArgObject(' + str(setIndex) + ', PASS_AS_PVOID(as_' + p[1] + '));')
elif p[0] in ['string', 'any']:
globalLines.append(' ctx->SetArgObject(' + str(setIndex) + ', &as_' + p[1] + ');')
elif p[0] in ['int8', 'uint8', 'bool']:
elif p[0] in ['int8', 'uint8']:
globalLines.append(' ctx->SetArgByte(' + str(setIndex) + ', as_' + p[1] + ');')
elif p[0] in ['bool']:
globalLines.append(' ctx->SetArgByte(' + str(setIndex) + ', as_' + p[1] + ' ? 1 : 0);')
elif p[0] in ['int16', 'uint16']:
globalLines.append(' ctx->SetArgWord(' + str(setIndex) + ', as_' + p[1] + ');')
elif p[0] in ['int', 'uint'] or p[0] in engineEnums or p[0] in scriptEnums:
Expand Down
36 changes: 14 additions & 22 deletions Source/Client/MapView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ void MapView::RebuildMapOffset(ipos hex_offset)
}

// Track
if (_isShowTrack && (GetHexTrack(hex) != 0)) {
if (_isShowTrack && GetHexTrack(hex) != 0) {
auto&& spr = GetHexTrack(hex) == 1 ? _picTrack1 : _picTrack2;
auto& mspr = _mapSprites.InsertSprite(DrawOrderType::Track, hex, //
{_engine->Settings.MapHexWidth / 2, (_engine->Settings.MapHexHeight / 2) + (spr ? spr->Size.height / 2 : 0)}, &field.Offset, //
Expand Down Expand Up @@ -4382,40 +4382,32 @@ void MapView::FindSetCenter(mpos hex)
return;
}

const auto view_size = GetViewSize();
const auto iw = view_size.width / 2 + 2;
const auto ih = view_size.height / 2 + 2;
auto hex2 = hex;
mpos corrected_hex = hex;

auto find_set_center_dir = [this, &hex2](const array<int, 2>& dirs, int steps) {
auto hex3 = hex2;
const auto dirs_index = (dirs[1] == -1 ? 1 : 2);
const auto find_set_center_dir = [this, &corrected_hex](const array<int, 2>& dirs, size_t steps) {
auto moved_hex = corrected_hex;
const auto dirs_index = dirs[1] == -1 ? 1 : 2;

auto i = 0;
size_t i = 0;

for (; i < steps; i++) {
if (!GeometryHelper::MoveHexByDir(hex3, static_cast<uint8>(dirs[i % dirs_index]), _mapSize)) {
if (!GeometryHelper::MoveHexByDir(moved_hex, static_cast<uint8>(dirs[i % dirs_index]), _mapSize)) {
break;
}

if (_isShowTrack) {
GetHexTrack(hex3) = 1;
}

if (_hexField->GetCellForReading(hex3).Flags.ScrollBlock) {
if (_hexField->GetCellForReading(moved_hex).Flags.ScrollBlock) {
break;
}

if (_isShowTrack) {
GetHexTrack(hex3) = 2;
}
}

for (; i < steps; i++) {
GeometryHelper::MoveHexByDir(hex2, GeometryHelper::ReverseDir(static_cast<uint8>(dirs[i % dirs_index])), _mapSize);
GeometryHelper::MoveHexByDir(corrected_hex, GeometryHelper::ReverseDir(static_cast<uint8>(dirs[i % dirs_index])), _mapSize);
}
};

const auto view_size = GetViewSize();
const auto iw = view_size.width / 2 + 2;
const auto ih = view_size.height / 2 + 2;

if constexpr (GameSettings::HEXAGONAL_GEOMETRY) {
find_set_center_dir({0, 5}, ih); // Up
find_set_center_dir({3, 2}, ih); // Down
Expand All @@ -4437,7 +4429,7 @@ void MapView::FindSetCenter(mpos hex)
find_set_center_dir({2, 1}, ih); // Down-Right
}

RebuildMap(ipos {hex.x, hex.y});
RebuildMap(ipos {corrected_hex.x, corrected_hex.y});
}

void MapView::SetShootBorders(bool enabled, uint dist)
Expand Down

0 comments on commit b30ac99

Please sign in to comment.