| 362 | inline T const& GetDataRef() const { return m_Data; } |
| 363 | |
| 364 | inline bool SetData(T const& value, SetBy setby) |
| 365 | { |
| 366 | VariableState flags = this->GetState(); |
| 367 | if (flags.CanSetValue(setby)) |
| 368 | { |
| 369 | m_Data = value; |
| 370 | this->m_State.setby = setby; |
| 371 | |
| 372 | if (m_OnChange) |
| 373 | m_OnChange(*this); |
| 374 | return true; |
| 375 | } |
| 376 | else |
| 377 | { |
| 378 | VariableState state = this->GetState(); |
| 379 | if (state.read_only) |
| 380 | donut::log::error("cvar '%s' is read-only - value not set", this->GetName().c_str()); |
| 381 | else |
| 382 | donut::log::error("cvar '%s' not enough privilege with '%s' to override '%s' - value not set", |
| 383 | this->GetName().c_str(), AsString(setby), AsString((SetBy)state.setby)); |
| 384 | } |
| 385 | return false; |
| 386 | } |
| 387 | |
| 388 | virtual bool SetValueFromString(std::string_view s, SetBy setby) override |
| 389 | { |
no test coverage detected