Fixed the selection bugs
This commit is contained in:
10
gamedata.cpp
10
gamedata.cpp
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user