Fixed the selection bugs

This commit is contained in:
Anna Rose 2011-07-01 14:39:45 -04:00
parent 4daaced5d7
commit 7fd7f90770
2 changed files with 7 additions and 5 deletions

View File

@ -72,10 +72,11 @@ void GameData::handle_click(int x, int y)
else if (mode == MODE_BUILD)
{
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)
{
if (select_vertex(x, y, true)) return;
Vertex* v = vertex_at(x, y, 0);
if (v == NULL) return;
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);
if (v == NULL) return;
if (v == NULL) return false;
if (only_mine && v->colour == turn->get_colour())
{
current = v;
return;
return true;
}
current = v;
return true;
}

View File

@ -32,7 +32,7 @@ class GameData : public Graph
// select or add vertex, as appropriate
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);
bool add_vertex(int x, int y, int z, int r, int colour);