• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

traintastic / traintastic / 20799539071

07 Jan 2026 11:10PM UTC coverage: 27.22% (+0.07%) from 27.155%
20799539071

push

github

reinder
[world] added scripting feature settings: show/hid scripting related stuff, see #71

53 of 108 new or added lines in 7 files covered. (49.07%)

1 existing line in 1 file now uncovered.

7918 of 29089 relevant lines covered (27.22%)

192.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.0
/server/src/core/idobject.cpp
1
/**
2
  * This file is part of Traintastic,
3
 * see <https://github.com/traintastic/traintastic>.
4
 *
5
 * Copyright (C) 2019-2026 Reinder Feenstra
6
 *
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
 */
21

22
#include "idobject.hpp"
23
#include "../traintastic/traintastic.hpp"
24
#include "../world/getworld.hpp"
25
#include "attributes.hpp"
26
#include "isvalidobjectid.hpp"
27
#include "../utils/displayname.hpp"
28

29
IdObject::IdObject(World& world, std::string_view _id) :
505✔
30
  m_world{world},
505✔
31
  id{this, "id", std::string(_id.data(), _id.size()), PropertyFlags::ReadWrite | PropertyFlags::Store | PropertyFlags::ScriptReadOnly,
1,010✔
32
    nullptr,
33
    [this](std::string& value)
1,010✔
34
    {
35
      if(!isValidObjectId(value))
20✔
36
        throw invalid_value_error();
×
37
      auto& m = m_world.m_objects;
20✔
38
      if(m.find(value) != m.end())
20✔
39
        return false;
×
40
      auto n = m.extract(id);
20✔
41
      n.key() = value;
20✔
42
      m.insert(std::move(n));
20✔
43
      return true;
20✔
44
    }}
525✔
45
{
46
  const bool editable = contains(m_world.state.value(), WorldState::Edit);
505✔
47

48
  Attributes::addDisplayName(id, DisplayName::Object::id);
505✔
49
  Attributes::addEnabled(id, editable);
505✔
50
  Attributes::addVisible(id, m_world.feature(WorldFeature::Scripting));
505✔
51
  m_interfaceItems.add(id);
505✔
52
}
505✔
53

54
IdObject::~IdObject() = default;
505✔
55

56
void IdObject::destroying()
503✔
57
{
58
  m_world.m_objects.erase(id);
503✔
59
  Object::destroying();
503✔
60
}
503✔
61

62
void IdObject::loaded()
6✔
63
{
64
  Object::loaded();
6✔
65
  Attributes::setVisible(id, m_world.feature(WorldFeature::Scripting));
6✔
66
}
6✔
67

68
void IdObject::addToWorld()
503✔
69
{
70
  m_world.m_objects.emplace(id, weak_from_this());
503✔
71
}
503✔
72

73
void IdObject::worldEvent(WorldState state, WorldEvent event)
120✔
74
{
75
  Object::worldEvent(state, event);
120✔
76

77
  Attributes::setEnabled(id, contains(state, WorldState::Edit));
120✔
78
}
120✔
79

NEW
80
void IdObject::worldFeaturesChanged(const WorldFeatures features, WorldFeature changed)
×
81
{
NEW
82
  Object::worldFeaturesChanged(features, changed);
×
83

NEW
84
  Attributes::setVisible(id, features[WorldFeature::Scripting]);
×
NEW
85
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc