diff --git a/processor/logic/GameBoard.cpp b/processor/logic/GameBoard.cpp index 514e130..d962c6c 100644 --- a/processor/logic/GameBoard.cpp +++ b/processor/logic/GameBoard.cpp @@ -30,7 +30,7 @@ bool GameBoard::attack(const PlayerMove& o) { if (sc_tile.unit <= 1) return false; - auto moving_unit = o.half ? sc_tile.unit : sc_tile.unit / 2; + auto moving_unit = o.half ? sc_tile.unit - 1 : sc_tile.unit / 2; sc_tile.unit -= moving_unit; auto isfriend = isTeammate(o.player, tt_tile.owner); auto delta diff --git a/processor/logic/PlayerMove.cpp b/processor/logic/PlayerMove.cpp index 551de55..513cad7 100644 --- a/processor/logic/PlayerMove.cpp +++ b/processor/logic/PlayerMove.cpp @@ -3,14 +3,14 @@ #include "pc/commcode.h" bool PlayerMove::isValid(pos_t w, pos_t h) const { - if (x < 0 || x >= h || y < 0 || y >= w) + if (x >= h || y >= w) return false; if ((int)dir >= 4) return false; auto xx = tx(), yy = ty(); - if (xx < 0 || xx >= h || yy < 0 || yy >= w) + if (xx >= h || yy >= w) return false; return true; diff --git a/processor/logic/terrain.cpp b/processor/logic/terrain.cpp index deea5a2..6c3ca59 100644 --- a/processor/logic/terrain.cpp +++ b/processor/logic/terrain.cpp @@ -37,35 +37,35 @@ void upmin(T& x, const T& y) { bool findCut(pos_t w, pos_t h, vector>& vertex_type) { int idx = 0; vector> dfn(h, vector(w)), low = dfn; - function tarjan - = [&](int x, int y, int fx, int fy, bool rt) { - dfn[x][y] = low[x][y] = ++idx; - int ch = 0; - for (int i = 0; i < 4; i++) { - const int xx = x + direction_dx[i], yy = y + direction_dy[i]; - if (xx < 0 || xx >= h || yy < 0 || yy >= w) - continue; + function tarjan = + [&](pos_t x, pos_t y, pos_t fx, pos_t fy, bool rt) { + dfn[x][y] = low[x][y] = ++idx; + int ch = 0; + for (int i = 0; i < 4; i++) { + const pos_t xx = x + direction_dx[i], yy = y + direction_dy[i]; + if (xx >= h || yy >= w) + continue; - if (vertex_type[xx][yy] == VertexType::Capital) - vertex_type[x][y] = VertexType::Cut; + if (vertex_type[xx][yy] == VertexType::Capital) + vertex_type[x][y] = VertexType::Cut; - if (ban(vertex_type[xx][yy]) || (xx == fx && yy == fy)) - continue; + if (ban(vertex_type[xx][yy]) || (xx == fx && yy == fy)) + continue; - if (!dfn[xx][yy]) { - ch++; - tarjan(xx, yy, x, y, 0); - upmin(low[x][y], low[xx][yy]); - if (!rt && low[xx][yy] >= dfn[x][y]) - vertex_type[x][y] = VertexType::Cut; - } else { - upmin(low[x][y], dfn[xx][yy]); - } - } + if (!dfn[xx][yy]) { + ch++; + tarjan(xx, yy, x, y, 0); + upmin(low[x][y], low[xx][yy]); + if (!rt && low[xx][yy] >= dfn[x][y]) + vertex_type[x][y] = VertexType::Cut; + } else { + upmin(low[x][y], dfn[xx][yy]); + } + } - if (rt && ch >= 2) - vertex_type[x][y] = VertexType::Cut; - }; + if (rt && ch >= 2) + vertex_type[x][y] = VertexType::Cut; + }; bool flag = false; for (pos_t i = 0; i < h; i++) { @@ -169,9 +169,9 @@ GameBoard ImportedTerrain::makeGameBoard(const InitInfo& init_info) { for (pos_t y = 0; y < w; y++) { if (g.at(x, y).type == TileType::Capital) { for (int i = 0; i < 4; i++) { - const int xx = x + direction_dx[i], - yy = y + direction_dy[i]; - if (xx < 0 || xx >= h || yy < 0 || yy >= w) + const pos_t xx = x + direction_dx[i], + yy = y + direction_dy[i]; + if (xx >= h || yy >= w) continue; if (g.at(xx, yy).type == TileType::Capital) throw BadCapitalAssign(); diff --git a/processor/pc/pctypes.cpp b/processor/pc/pctypes.cpp index cd42537..946f484 100644 --- a/processor/pc/pctypes.cpp +++ b/processor/pc/pctypes.cpp @@ -5,3 +5,5 @@ PlayerRanking::PlayerRanking() : player(neutral_player) TeamRanking::TeamRanking() : team(neutral_team), land(0), unit(0) {} +Tile::Tile() : owner(neutral_player), unit(0) {} + diff --git a/processor/pc/pctypes.h b/processor/pc/pctypes.h index 834eeb9..a68d992 100644 --- a/processor/pc/pctypes.h +++ b/processor/pc/pctypes.h @@ -56,6 +56,8 @@ struct Tile { TileType type; std::int32_t unit; + Tile(); + OGPC_DECLARE_ASTUPLE(owner, type, unit) };