MCPcopy Create free account
hub / github.com/Blizzard/s2client-api / TestLayerUpdate

Class TestLayerUpdate

tests/test_feature_layer_mp.cc:16–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14//
15
16class TestLayerUpdate : public TestSequence {
17public:
18 FeatureLayer8BPP start_;
19 Point2D camera_start_;
20
21 void OnTestStart() override {
22 const char* error = GetPlayerRelativeLayer(agent_, FeatureLayerType::MINIMAP, start_);
23 if (error) {
24 ReportError(error);
25 return;
26 }
27
28 const ObservationInterface* obs = agent_->Observation();
29 camera_start_ = obs->GetCameraPos();
30
31 const GameInfo& game_info = obs->GetGameInfo();
32 Point2D center = FindCenterOfMap(game_info);
33 Point2DI center_minimap = ConvertWorldToMinimap(game_info, center);
34
35 ActionFeatureLayerInterface* action = agent_->ActionsFeatureLayer();
36 action->CameraMove(center_minimap);
37
38 DebugInterface* debug = agent_->Debug();
39 debug->DebugCreateUnit(UNIT_TYPEID::TERRAN_MARINE, center, agent_->Observation()->GetPlayerID(), 1);
40 debug->SendDebug();
41
42 wait_game_loops_ = 5;
43 }
44
45 void OnStep() override {
46
47 }
48
49 void OnTestFinish() override {
50 const ObservationInterface* obs = agent_->Observation();
51 Point2D camera_end = obs->GetCameraPos();
52 if (camera_start_ == camera_end) {
53 ReportError("Camera didn't move");
54 return;
55 }
56
57 FeatureLayer8BPP end_;
58 const char* error = GetPlayerRelativeLayer(agent_, FeatureLayerType::MINIMAP, end_);
59 if (error) {
60 ReportError(error);
61 return;
62 }
63
64 if (start_.width != end_.width || start_.height != end_.height) {
65 ReportError("Layers not the same size");
66 return;
67 }
68
69 bool changed = false;
70 for (int x = 0; x < start_.width; ++x) {
71 for (int y = 0; y < start_.height; ++y) {
72 char start_value = start_.Read(Point2DI(x, y));
73 char end_value = end_.Read(Point2DI(x, y));

Callers 1

FeatureLayerMPTestBotMethod · 0.85

Calls

no outgoing calls

Tested by 1

FeatureLayerMPTestBotMethod · 0.68