The Battle for Wesnoth  1.19.5+dev
id.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #include "log.hpp"
17 #include "units/id.hpp"
18 
19 #include <cassert>
20 
21 static lg::log_domain log_unit("unit");
22 #define DBG_UT LOG_STREAM(debug, log_unit)
23 
24 namespace n_unit
25 {
27 
29  {
31  DBG_UT << "id: " << next_id_;
33  }
34 
36  {
38  DBG_UT << "fake id: " << fake_id_;
40  }
41 
42  std::size_t id_manager::get_save_id() const
43  {
44  return next_id_;
45  }
46 
47  void id_manager::set_save_id(std::size_t id)
48  {
49  clear();
50  DBG_UT << "set save id: " << id;
51  next_id_ = id;
52  }
53 
55  {
56  fake_id_ = 0;
57  }
58 
60  {
61  next_id_ = 0;
62  reset_fake();
63  }
64 }
void reset_fake()
Definition: id.cpp:54
std::size_t get_save_id() const
Used for saving id to savegame.
Definition: id.cpp:42
void clear()
Clears id counter after game.
Definition: id.cpp:59
static id_manager manager_
Definition: id.hpp:47
std::size_t next_id_
Definition: id.hpp:45
void set_save_id(std::size_t)
Definition: id.cpp:47
unit_id next_fake_id()
Definition: id.cpp:35
std::size_t fake_id_
Definition: id.hpp:46
unit_id next_id()
returns id for unit that is created
Definition: id.cpp:28
std::string id
Text to match against addon_info.tags()
Definition: manager.cpp:198
static lg::log_domain log_unit("unit")
#define DBG_UT
Definition: id.cpp:22
Standard logging facilities (interface).
Definition: id.cpp:25
static unit_id create_fake(std::size_t val)
Definition: id.hpp:33
static unit_id create_real(std::size_t val)
Definition: id.hpp:32
static const std::size_t highest_bit
Definition: id.hpp:26