Fixed the selection bugs
This commit is contained in:
parent
4daaced5d7
commit
7fd7f90770
10
gamedata.cpp
10
gamedata.cpp
|
@ -72,10 +72,11 @@ void GameData::handle_click(int x, int y)
|
||||||
else if (mode == MODE_BUILD)
|
else if (mode == MODE_BUILD)
|
||||||
{
|
{
|
||||||
if (point_in_vertex(x, y, 0)) select_vertex(x, y, true);
|
if (point_in_vertex(x, y, 0)) select_vertex(x, y, true);
|
||||||
if (!point_in_vertex(x, y, 0)) add_vertex(x, y, 0, r, colour);
|
else add_vertex(x, y, 0, r, colour);
|
||||||
}
|
}
|
||||||
else if (mode == MODE_ATTACK)
|
else if (mode == MODE_ATTACK)
|
||||||
{
|
{
|
||||||
|
if (select_vertex(x, y, true)) return;
|
||||||
Vertex* v = vertex_at(x, y, 0);
|
Vertex* v = vertex_at(x, y, 0);
|
||||||
if (v == NULL) return;
|
if (v == NULL) return;
|
||||||
if (v->colour != colour) attack_vertex(v);
|
if (v->colour != colour) attack_vertex(v);
|
||||||
|
@ -83,18 +84,19 @@ void GameData::handle_click(int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameData::select_vertex(int x, int y, bool only_mine)
|
bool GameData::select_vertex(int x, int y, bool only_mine)
|
||||||
{
|
{
|
||||||
Vertex * v = vertex_at(x, y, 0);
|
Vertex * v = vertex_at(x, y, 0);
|
||||||
if (v == NULL) return;
|
if (v == NULL) return false;
|
||||||
|
|
||||||
if (only_mine && v->colour == turn->get_colour())
|
if (only_mine && v->colour == turn->get_colour())
|
||||||
{
|
{
|
||||||
current = v;
|
current = v;
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
current = v;
|
current = v;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class GameData : public Graph
|
||||||
|
|
||||||
// select or add vertex, as appropriate
|
// select or add vertex, as appropriate
|
||||||
void handle_click(int x, int y);
|
void handle_click(int x, int y);
|
||||||
void select_vertex(int x, int y, bool only_mine = false);
|
bool select_vertex(int x, int y, bool only_mine = false);
|
||||||
void attack_vertex(Vertex* target);
|
void attack_vertex(Vertex* target);
|
||||||
|
|
||||||
bool add_vertex(int x, int y, int z, int r, int colour);
|
bool add_vertex(int x, int y, int z, int r, int colour);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user