Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Sep 4, 2016
1 parent 3e6fcc4 commit c29ea4e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
6 changes: 1 addition & 5 deletions src/editor/map/context_manager.cpp
Expand Up @@ -214,11 +214,7 @@ void context_manager::edit_side_dialog(int side)
//TODO
//t.support()

// TODO: @celticminstrel: the side parameter passed here is then used to access
// the team by index in set_side_setup. In teditor_edit_side, it's displayed as
// a side number, as as such is shown +1. Just a note for the team index refactor
// branch.
editor_team_info team_info(t, side);
editor_team_info team_info(t);

if(gui2::teditor_edit_side::execute(team_info, gui_.video())) {
get_map_context().set_side_setup(team_info);
Expand Down
8 changes: 4 additions & 4 deletions src/editor/map/map_context.cpp
Expand Up @@ -40,8 +40,8 @@

namespace editor {

editor_team_info::editor_team_info(const team& t, const int side)
: side(side)
editor_team_info::editor_team_info(const team& t)
: side(t.side())
, id(t.team_name())
, name(t.user_team_name())
, gold(t.gold())
Expand Down Expand Up @@ -219,8 +219,8 @@ map_context::map_context(const config& game_config, const std::string& filename,

void map_context::set_side_setup(editor_team_info& info)
{
assert(teams_.size() > static_cast<unsigned int>(info.side));
team& t = teams_[info.side];
assert(teams_.size() >= static_cast<unsigned int>(info.side));
team& t = teams_[info.side - 1];

This comment has been minimized.

Copy link
@Wedge009

Wedge009 Sep 23, 2016

Member

Just wondering how this fixes a test. Because this seems to break the Editor - see https://gna.org/bugs/?25093.

This comment has been minimized.

Copy link
@CelticMinstrel

CelticMinstrel Sep 23, 2016

Author Member

info.side is supposed to be the side number (from 1 to n). If this is crashing, that would seem to indicate that it's instead the side index (from 0 to n-1), somehow. team::side() returns the side number, not the index, but maybe it's being changed to the index elsewhere...?

This comment has been minimized.

Copy link
@Wedge009

Wedge009 Sep 24, 2016

Member

I had a bit of dig into team.hpp/cpp and ran it through both a normal game and the editor. It does indeed look like side is supposed to be 1-based, but I think the editor is initialising all side numbers to 0 and instead of correctly assigning the side number. So it looks like running into an error here is a symptom rather than a cause.

// t.set_save_id(id);
// t.set_name(name);
t.change_team(info.id, info.name);
Expand Down
2 changes: 1 addition & 1 deletion src/editor/map/map_context.hpp
Expand Up @@ -31,7 +31,7 @@
namespace editor {

struct editor_team_info {
editor_team_info(const team& t, const int side);
editor_team_info(const team& t);

int side;
std::string id;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/editor/edit_side.cpp
Expand Up @@ -54,7 +54,7 @@ teditor_edit_side::teditor_edit_side(editor::editor_team_info& info)
: controller_(info.controller)
, share_vision_(info.share_vision)
{
register_label("side_number", true, std::to_string(info.side + 1), true);
register_label("side_number", true, std::to_string(info.side), true);

register_text("team_name", true, info.id, true);
register_text("user_team_name", true, info.name, true);
Expand Down
11 changes: 4 additions & 7 deletions src/tests/gui/test_gui2.cpp
Expand Up @@ -675,15 +675,12 @@ struct twrapper<gui2::teditor_edit_scenario>
template<>
struct twrapper<gui2::teditor_edit_side>
{
std::string name, user_name;
int gold, income, village, support;
bool no_leader, hidden, fog, shroud;
team::CONTROLLER controller;
team::SHARE_VISION share_vision;
team t;
editor::editor_team_info info;
twrapper() : info(t) {}
gui2::teditor_edit_side* create()
{
return new gui2::
teditor_edit_side(1, name, user_name, gold, income, village, support, fog, shroud, share_vision, controller, no_leader, hidden);
return new gui2::teditor_edit_side(info);
}
};

Expand Down

0 comments on commit c29ea4e

Please sign in to comment.