4018
by sirver
- moved more files into logic library. |
1 |
/*
|
11165
by The Widelands Bunnybot
Update copyright end year to 2025 |
2 |
* Copyright (C) 2002-2025 by the Widelands Development Team
|
4018
by sirver
- moved more files into logic library. |
3 |
*
|
4 |
* This program is free software; you can redistribute it and/or
|
|
5 |
* modify it under the terms of the GNU General Public License
|
|
6 |
* as published by the Free Software Foundation; either version 2
|
|
7 |
* of the License, or (at your option) any later version.
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
10152
by The Widelands Bunnybot
Add check for missing copyright headers (#5223) |
15 |
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
4018
by sirver
- moved more files into logic library. |
16 |
*
|
17 |
*/
|
|
18 |
||
7649.1.2
by fios at foramnagaidhlig
Renamed instances.h to map_object.h. |
19 |
#ifndef WL_LOGIC_MAP_OBJECTS_MAP_OBJECT_H
|
20 |
#define WL_LOGIC_MAP_OBJECTS_MAP_OBJECT_H
|
|
4018
by sirver
- moved more files into logic library. |
21 |
|
10070
by The Widelands Bunnybot
Resolve thread sanitizer issues (#5114) |
22 |
#include <atomic> |
6044
by Holger Rapp
Replaced a std::map via boost::unordered_map. This makes widelands on games without AI ~10% faster on my system |
23 |
|
7036
by Holger Rapp
Moved macros into base_macros. |
24 |
#include "base/macros.h" |
11186
by The Widelands Bunnybot
Split PlayerCommand into smaller files (CB #4786 / GH #6424) |
25 |
#include "commands/command.h" |
9204
by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044) |
26 |
#include "graphic/animation/animation.h" |
27 |
#include "graphic/animation/diranimations.h" |
|
7175.12.1
by fios at foramnagaidhlig
Added player color to MapObjects' representative_image. Visible when ordering a new building, in construction/dismantlesite windows and in the building statistics. |
28 |
#include "graphic/color.h" |
7175.7.244
by fios at foramnagaidhlig
MapObjects' Representative images are now loaded from graphics cache. |
29 |
#include "graphic/image.h" |
9204
by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044) |
30 |
#include "logic/map_objects/info_to_draw.h" |
9461
by The Widelands Bunnybot
Tribes filtering (#3693) |
31 |
#include "logic/map_objects/map_object_type.h" |
7839.9.3
by fios at foramnagaidhlig
Renamed all instances of "hp" and "hitpoints" to "health" for consistency. TrainingAttribute is now an enum class with consistent saveloading datatype. |
32 |
#include "logic/map_objects/tribes/training_attribute.h" |
6969.1.10
by Holger Rapp
A simpler approach to checking code. The success file is now codecheck_<hash of |
33 |
#include "logic/widelands.h" |
10083
by The Widelands Bunnybot
Replace `boost::signals2` (#5133) |
34 |
#include "notifications/signal.h" |
7175.7.244
by fios at foramnagaidhlig
MapObjects' Representative images are now loaded from graphics cache. |
35 |
#include "scripting/lua_table.h" |
6044
by Holger Rapp
Replaced a std::map via boost::unordered_map. This makes widelands on games without AI ~10% faster on my system |
36 |
|
6966.1.3
by Holger Rapp
Distributed the remaining functions in widelands_streamread.cc logically. |
37 |
class RenderTarget; |
4018
by sirver
- moved more files into logic library. |
38 |
|
39 |
namespace Widelands { |
|
40 |
||
8822.2.1
by Benedikt Straub
First commit for level-dependent soldier animations |
41 |
class MapObject; |
6890.1.1
by Holger Rapp
Refactored. |
42 |
class Player; |
4018
by sirver
- moved more files into logic library. |
43 |
|
7105.3.16
by fios at foramnagaidhlig
Big Map_Object type refactoring - this compiles, but segfaults every 2n-1 times that Widelands is started and a single player game created. |
44 |
/**
|
4018
by sirver
- moved more files into logic library. |
45 |
* Base class for descriptions of worker, files and so on. This must just
|
46 |
* link them together
|
|
47 |
*/
|
|
9372
by The Widelands Bunnybot
Add optional braces to logic code (#3993) |
48 |
class MapObjectDescr { |
49 |
public: |
|
9398
by The Widelands Bunnybot
Detect work area overlaps from MapObject programs (#4014) |
50 |
using AttributeIndex = uint32_t; |
51 |
using Attributes = std::vector<AttributeIndex>; |
|
52 |
||
8048
by GunChleoc
Ran clang-format. |
53 |
enum class OwnerType { kWorld, kTribe }; |
7175.7.40
by fios at foramnagaidhlig
Added code for immovables and ships. Replaced owner tribe in descriptions with an owner type (tribe or world). |
54 |
|
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
55 |
MapObjectDescr(MapObjectType init_type, |
8048
by GunChleoc
Ran clang-format. |
56 |
const std::string& init_name, |
9501
by The Widelands Bunnybot
Shift tribe helptexts (#4153) |
57 |
const std::string& init_descname); |
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
58 |
MapObjectDescr(MapObjectType init_type, |
8048
by GunChleoc
Ran clang-format. |
59 |
const std::string& init_name, |
60 |
const std::string& init_descname, |
|
61 |
const LuaTable& table); |
|
7175.7.244
by fios at foramnagaidhlig
MapObjects' Representative images are now loaded from graphics cache. |
62 |
virtual ~MapObjectDescr(); |
4018
by sirver
- moved more files into logic library. |
63 |
|
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
64 |
[[nodiscard]] const std::string& name() const { |
8048
by GunChleoc
Ran clang-format. |
65 |
return name_; |
66 |
}
|
|
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
67 |
[[nodiscard]] const std::string& descname() const { |
8048
by GunChleoc
Ran clang-format. |
68 |
return descname_; |
69 |
}
|
|
7105.3.20
by Holger Rapp
- Moves type_name() out of Map_Object_Descr into a standalone function |
70 |
|
7150.4.4
by fios at foramnagaidhlig
Picked up some stragglers |
71 |
// Type of the MapObjectDescr.
|
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
72 |
[[nodiscard]] MapObjectType type() const { |
8048
by GunChleoc
Ran clang-format. |
73 |
return type_; |
74 |
}
|
|
7105.3.16
by fios at foramnagaidhlig
Big Map_Object type refactoring - this compiles, but segfaults every 2n-1 times that Widelands is started and a single player game created. |
75 |
|
8822.2.25
by Nordfriese
Adressed code review |
76 |
virtual uint32_t get_animation(const std::string& animname, const MapObject* mo) const; |
9238
by The Widelands Bunnybot
Unify program parsers (#3805) |
77 |
|
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
78 |
[[nodiscard]] uint32_t main_animation() const; |
79 |
[[nodiscard]] std::string get_animation_name(uint32_t) const; ///< needed for save, debug |
|
4018
by sirver
- moved more files into logic library. |
80 |
|
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
81 |
[[nodiscard]] bool is_animation_known(const std::string& name) const; |
7175.7.40
by fios at foramnagaidhlig
Added code for immovables and ships. Replaced owner tribe in descriptions with an owner type (tribe or world). |
82 |
|
8646.6.25
by GunChleoc
Preload graphics for existing map objects at game start to prevent jitter. |
83 |
/// Preload animation graphics at default scale
|
84 |
void load_graphics() const; |
|
85 |
||
7175.7.244
by fios at foramnagaidhlig
MapObjects' Representative images are now loaded from graphics cache. |
86 |
/// Returns the image for the first frame of the idle animation if the MapObject has animations,
|
87 |
/// nullptr otherwise
|
|
7175.12.1
by fios at foramnagaidhlig
Added player color to MapObjects' representative_image. Visible when ordering a new building, in construction/dismantlesite windows and in the building statistics. |
88 |
const Image* representative_image(const RGBColor* player_color = nullptr) const; |
7175.7.244
by fios at foramnagaidhlig
MapObjects' Representative images are now loaded from graphics cache. |
89 |
|
7175.7.245
by fios at foramnagaidhlig
Menu icon graphics are now a property of MapObject and loaded on demand. |
90 |
/// Returns the menu image if the MapObject has one, nullptr otherwise
|
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
91 |
[[nodiscard]] const Image* icon() const; |
7175.7.245
by fios at foramnagaidhlig
Menu icon graphics are now a property of MapObject and loaded on demand. |
92 |
/// Returns the image fileneme for the menu image if the MapObject has one, is empty otherwise
|
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
93 |
[[nodiscard]] const std::string& icon_filename() const; |
7175.7.245
by fios at foramnagaidhlig
Menu icon graphics are now a property of MapObject and loaded on demand. |
94 |
|
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
95 |
[[nodiscard]] bool has_attribute(AttributeIndex) const; |
96 |
[[nodiscard]] const MapObjectDescr::Attributes& attributes() const; |
|
9398
by The Widelands Bunnybot
Detect work area overlaps from MapObject programs (#4014) |
97 |
static AttributeIndex get_attribute_id(const std::string& name, bool add_if_not_exists = false); |
8531.2.2
by GunChleoc
Removed some code duplication and programming by exception. |
98 |
|
9501
by The Widelands Bunnybot
Shift tribe helptexts (#4153) |
99 |
/// Sets a tribe-specific ware or immovable helptext for this MapObject
|
100 |
void set_helptexts(const std::string& tribename, |
|
101 |
std::map<std::string, std::string> localized_helptext); |
|
102 |
/// Gets the tribe-specific ware or immovable helptext for the given tribe. Fails if it doesn't
|
|
103 |
/// exist.
|
|
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
104 |
[[nodiscard]] const std::map<std::string, std::string>& |
105 |
get_helptexts(const std::string& tribename) const; |
|
9501
by The Widelands Bunnybot
Shift tribe helptexts (#4153) |
106 |
/// Returns whether a tribe-specific helptext exists for the given tribe
|
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
107 |
[[nodiscard]] bool has_helptext(const std::string& tribename) const; |
9501
by The Widelands Bunnybot
Shift tribe helptexts (#4153) |
108 |
|
6115
by Nicolai Hähnle
Use boost::noncopyable throughout |
109 |
protected: |
9398
by The Widelands Bunnybot
Detect work area overlaps from MapObject programs (#4014) |
110 |
// Add attributes to the attribute list
|
111 |
void add_attributes(const std::vector<std::string>& attribs); |
|
112 |
void add_attribute(AttributeIndex attr); |
|
4018
by sirver
- moved more files into logic library. |
113 |
|
8646.6.19
by GunChleoc
Shift collection of filenames for directional animations to C++. Converted carriers, flags and frontiers. |
114 |
/// Sets the directional animations in 'anims' with the animations
|
115 |
/// '<basename>_(ne|e|se|sw|w|nw)'.
|
|
10191
by The Widelands Bunnybot
Fix misc clang-tidy checks in `logic` (#5255) |
116 |
void assign_directional_animation(DirAnimations* anims, const std::string& basename) const; |
8646.6.19
by GunChleoc
Shift collection of filenames for directional animations to C++. Converted carriers, flags and frontiers. |
117 |
|
4018
by sirver
- moved more files into logic library. |
118 |
private: |
9228
by The Widelands Bunnybot
Warfare tutorial - Teach the player about scouting (#3774) |
119 |
void add_animations(const LuaTable& table, |
120 |
const std::string& animation_directory, |
|
121 |
Animation::Type anim_type); |
|
8646.6.19
by GunChleoc
Shift collection of filenames for directional animations to C++. Converted carriers, flags and frontiers. |
122 |
|
8480.3.2
by GunChleoc
Fixed a typo. |
123 |
/// Throws an exception if the MapObjectDescr has no representative image
|
10191
by The Widelands Bunnybot
Fix misc clang-tidy checks in `logic` (#5255) |
124 |
void check_representative_image() const; |
8480.3.1
by GunChleoc
All MapObjectDescr check in the constructor if they have a representative image. |
125 |
|
7175.1.13
by fios at foramnagaidhlig
Cleaned up a bunch of typedefs |
126 |
using Anims = std::map<std::string, uint32_t>; |
9398
by The Widelands Bunnybot
Detect work area overlaps from MapObject programs (#4014) |
127 |
|
128 |
static std::map<std::string, AttributeIndex> attribute_names_; |
|
129 |
Attributes attribute_ids_; |
|
4018
by sirver
- moved more files into logic library. |
130 |
|
8048
by GunChleoc
Ran clang-format. |
131 |
const MapObjectType type_; /// Subclasses pick from the enum above |
132 |
std::string const name_; /// The name for internal reference |
|
133 |
std::string const descname_; /// A localized Descriptive name |
|
9501
by The Widelands Bunnybot
Shift tribe helptexts (#4153) |
134 |
|
135 |
/// Tribe-specific helptexts. Format: <tribename, <category, localized_text>>
|
|
136 |
std::map<std::string, std::map<std::string, std::string>> helptexts_; |
|
137 |
||
8048
by GunChleoc
Ran clang-format. |
138 |
Anims anims_; |
9094
by Wideland's Bunnybot
Merged lp:~widelands-dev/widelands/representative_image_in_font_renderer: |
139 |
std::string icon_filename_; // Filename for the menu icon |
4018
by sirver
- moved more files into logic library. |
140 |
|
7150.4.2
by fios at foramnagaidhlig
Replaced Map_Object_Descr with MapObjectDescr |
141 |
DISALLOW_COPY_AND_ASSIGN(MapObjectDescr); |
4018
by sirver
- moved more files into logic library. |
142 |
};
|
143 |
||
144 |
/**
|
|
7150.4.7
by fios at foramnagaidhlig
Picked up Map_Object stragglers |
145 |
* \par Notes on MapObject
|
4018
by sirver
- moved more files into logic library. |
146 |
*
|
7150.4.7
by fios at foramnagaidhlig
Picked up Map_Object stragglers |
147 |
* MapObject is the base class for everything that can be on the map:
|
4018
by sirver
- moved more files into logic library. |
148 |
* buildings, animals, decorations, etc... most of the time, however, you'll
|
149 |
* deal with one of the derived classes, BaseImmovable or Bob.
|
|
150 |
*
|
|
7150.4.7
by fios at foramnagaidhlig
Picked up Map_Object stragglers |
151 |
* Every MapObject has a unique serial number. This serial number is used as
|
7175.1.5
by fios at foramnagaidhlig
Renamed classes in Widelands namespace + widelands.h |
152 |
* key in the ObjectManager map, and in the safe ObjectPointer.
|
4018
by sirver
- moved more files into logic library. |
153 |
*
|
154 |
* Unless you're perfectly sure about when an object can be destroyed you
|
|
7175.1.5
by fios at foramnagaidhlig
Renamed classes in Widelands namespace + widelands.h |
155 |
* should use an ObjectPointer or, better yet, the type safe OPtr template.
|
4018
by sirver
- moved more files into logic library. |
156 |
* This is not necessary when the relationship and lifetime between objects
|
157 |
* is well-defined, such as in the relationship between Building and Flag.
|
|
158 |
*
|
|
7150.4.7
by fios at foramnagaidhlig
Picked up Map_Object stragglers |
159 |
* MapObjects can also have attributes. They are mainly useful for finding
|
4018
by sirver
- moved more files into logic library. |
160 |
* objects of a given type (e.g. trees) within a certain radius.
|
161 |
*
|
|
7150.4.7
by fios at foramnagaidhlig
Picked up Map_Object stragglers |
162 |
* \warning DO NOT allocate/free MapObjects directly. Use the appropriate
|
4018
by sirver
- moved more files into logic library. |
163 |
* type-dependent create() function for creation, and call die() for removal.
|
164 |
*
|
|
6775.1.1
by Holger Rapp
Removed HTML writing as it has not been updated in a very long time. Compile fixes for clang-3.3. |
165 |
* \note Convenient creation functions are defined in class Game.
|
4018
by sirver
- moved more files into logic library. |
166 |
*
|
167 |
* When you do create a new object yourself (i.e. when you're implementing one
|
|
168 |
* of the create() functions), you need to allocate the object using new,
|
|
8589.4.2
by GunChleoc
Fixed member variable shadowing in fleet.h. Refactored owner()/get_owner() and messages()/get_messages() to clearly distinguish between const& and *. |
169 |
* potentially set it up by calling basic functions like set_position(), etc.
|
170 |
* and then call init(). After that, the object is supposed to
|
|
4018
by sirver
- moved more files into logic library. |
171 |
* be fully created.
|
8939
by Wideland's Bunnybot
Merged lp:~widelands-dev/widelands/appveyor_reenable_glbinding: |
172 |
*/
|
4018
by sirver
- moved more files into logic library. |
173 |
|
174 |
/// If you find a better way to do this that doesn't cost a virtual function
|
|
175 |
/// or additional member variable, go ahead
|
|
8048
by GunChleoc
Ran clang-format. |
176 |
#define MO_DESCR(type) \
|
177 |
public: \
|
|
178 |
const type& descr() const { \
|
|
179 |
return dynamic_cast<const type&>(*descr_); \
|
|
180 |
}
|
|
4018
by sirver
- moved more files into logic library. |
181 |
|
7150.4.3
by fios at foramnagaidhlig
Replaced Map_Object with MapObject |
182 |
class MapObject { |
7175.1.4
by fios at foramnagaidhlig
Renamed everything in editor_game_base.h and widelands_geometry.h |
183 |
friend struct ObjectManager; |
7175.1.5
by fios at foramnagaidhlig
Renamed classes in Widelands namespace + widelands.h |
184 |
friend struct ObjectPointer; |
4018
by sirver
- moved more files into logic library. |
185 |
|
7150.4.4
by fios at foramnagaidhlig
Picked up some stragglers |
186 |
MO_DESCR(MapObjectDescr) |
4018
by sirver
- moved more files into logic library. |
187 |
|
188 |
public: |
|
10465
by The Widelands Bunnybot
Create .clang-tidy config file and sanitize headers (#5681) |
189 |
virtual ~MapObject() = default; |
190 |
||
4018
by sirver
- moved more files into logic library. |
191 |
struct LogSink { |
8385.2.1
by GunChleoc
Pass function arguments per (const) reference where possible. |
192 |
virtual void log(const std::string& str) = 0; |
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
193 |
virtual ~LogSink() = default; |
4018
by sirver
- moved more files into logic library. |
194 |
};
|
195 |
||
8048
by GunChleoc
Ran clang-format. |
196 |
virtual void load_finish(EditorGameBase&) { |
197 |
}
|
|
10634
by The Widelands Bunnybot
Fix Shipyard/PortDock/FleetInterface Load Order Regression (#5928) |
198 |
virtual void postload(EditorGameBase&) { |
199 |
}
|
|
4869
by sigra
* Attemt to properly fix bug #1919495 (check that a worker in a flag's capacity wait queue has a waitforcapacity task for that flag) reported by Gamer - gamer2000. The previous fix (revision 3080) did not check that. Instead it introduced a kludge in the Write function, which was very ugly and awkward. (Of course kludges for handling old savegames should only be executed at load time.) The necessary check could not be where the flag's capacity wait queue is loaded, because then the bob, with its stack of tasks, has not been fully loaded yet. So add the function Flag::load_finish, and call it for each flag after bobs have been loaded. If a worker is found in the queue but does not have the task, handle it by logging a WARNING and removing the worker from the queue. Since the commit message of the previous fix mentions that a building's leave queue has the same issue, fix it in the same way. Also add the boolean variable Bob::Task::unique, determining whether a task type must be unique in a stack. If a savegame has a stack with more than one such task, game_data_error is thrown. Also add an assert to Bob::push_task to make sure that such a task is not duplicated in a stack at runtime. Most task types are set to be unique. |
200 |
|
7175.7.244
by fios at foramnagaidhlig
MapObjects' Representative images are now loaded from graphics cache. |
201 |
virtual const Image* representative_image() const; |
202 |
||
4018
by sirver
- moved more files into logic library. |
203 |
protected: |
8385.1.1
by GunChleoc
Made a bunch of constructors explicit. |
204 |
explicit MapObject(MapObjectDescr const* descr); |
4018
by sirver
- moved more files into logic library. |
205 |
|
206 |
public: |
|
8048
by GunChleoc
Ran clang-format. |
207 |
Serial serial() const { |
208 |
return serial_; |
|
209 |
}
|
|
4018
by sirver
- moved more files into logic library. |
210 |
|
211 |
/**
|
|
6669.2.5
by charlyghislain at gmail
Make a signal-slot connection to be notified of object removal |
212 |
* Is called right before the object will be removed from
|
8691.1.1
by Notabilis
Only store window for reopening when the construction site has been finished. |
213 |
* the game. No connection is handled in this class.
|
7697.1.1
by Tino
codechecker fix |
214 |
*
|
215 |
* param serial : the object serial (cannot use param comment as this is a callback)
|
|
6669.2.5
by charlyghislain at gmail
Make a signal-slot connection to be notified of object removal |
216 |
*/
|
10083
by The Widelands Bunnybot
Replace `boost::signals2` (#5133) |
217 |
Notifications::Signal<uint32_t /* serial */> removed; |
6669.2.5
by charlyghislain at gmail
Make a signal-slot connection to be notified of object removal |
218 |
|
219 |
/**
|
|
4018
by sirver
- moved more files into logic library. |
220 |
* Attributes are fixed boolean properties of an object.
|
221 |
* An object either has a certain attribute or it doesn't.
|
|
222 |
* See the \ref Attribute enume.
|
|
223 |
*
|
|
224 |
* \return whether this object has the given attribute
|
|
225 |
*/
|
|
4364
by sigra
Clean away some useless comments. No longer use a special whitespace rule, for function bodies that fit on a single line, that was used to save vertical screen space, but was not so popular. |
226 |
bool has_attribute(uint32_t const attr) const { |
227 |
return descr().has_attribute(attr); |
|
228 |
}
|
|
4018
by sirver
- moved more files into logic library. |
229 |
|
230 |
/**
|
|
7175.1.5
by fios at foramnagaidhlig
Renamed classes in Widelands namespace + widelands.h |
231 |
* \return the value of the given \ref TrainingAttribute. -1 if this object
|
4018
by sirver
- moved more files into logic library. |
232 |
* doesn't have this kind of attribute.
|
233 |
* The default behaviour returns \c -1 for all attributes.
|
|
234 |
*/
|
|
7839.9.3
by fios at foramnagaidhlig
Renamed all instances of "hp" and "hitpoints" to "health" for consistency. TrainingAttribute is now an enum class with consistent saveloading datatype. |
235 |
virtual int32_t get_training_attribute(TrainingAttribute attr) const; |
4018
by sirver
- moved more files into logic library. |
236 |
|
8048
by GunChleoc
Ran clang-format. |
237 |
void remove(EditorGameBase&); |
238 |
virtual void destroy(EditorGameBase&); |
|
4018
by sirver
- moved more files into logic library. |
239 |
|
240 |
// The next functions are really only needed in games, not in the editor.
|
|
8048
by GunChleoc
Ran clang-format. |
241 |
void schedule_destroy(Game&); |
9586
by The Widelands Bunnybot
Make `Time` and `Duration` typesafe (#4325) |
242 |
Time schedule_act(Game&, const Duration& tdelta, uint32_t data = 0); |
8048
by GunChleoc
Ran clang-format. |
243 |
virtual void act(Game&, uint32_t data); |
4018
by sirver
- moved more files into logic library. |
244 |
|
8048
by GunChleoc
Ran clang-format. |
245 |
LogSink* get_logsink() { |
246 |
return logsink_; |
|
247 |
}
|
|
248 |
void set_logsink(LogSink*); |
|
4018
by sirver
- moved more files into logic library. |
249 |
|
250 |
/// Called when a new logsink is set. Used to give general information.
|
|
8807.1.1
by GunChleoc
Made as many portdock functions const as possible and followed the snowball effect. |
251 |
virtual void log_general_info(const EditorGameBase&) const; |
4018
by sirver
- moved more files into logic library. |
252 |
|
8131.2.26
by Holger Rapp
Move owner_ into MapObjects and calculate which text to draw outside of the individual objects draw routines. |
253 |
Player* get_owner() const { |
254 |
return owner_; |
|
255 |
}
|
|
256 |
||
9423
by The Widelands Bunnybot
Transform and remove by percent (#4070) |
257 |
const Player& owner() const; |
8589.4.2
by GunChleoc
Fixed member variable shadowing in fleet.h. Refactored owner()/get_owner() and messages()/get_messages() to clearly distinguish between const& and *. |
258 |
|
6915
by Holger Rapp
Removed legacy.cc/legacy.h and it's uses. |
259 |
// Header bytes to distinguish between data packages for the different
|
7150.4.7
by fios at foramnagaidhlig
Picked up Map_Object stragglers |
260 |
// MapObject classes. Be careful in changing those, since they are written
|
6915
by Holger Rapp
Removed legacy.cc/legacy.h and it's uses. |
261 |
// to files.
|
4018
by sirver
- moved more files into logic library. |
262 |
enum { |
7150.4.9
by fios at foramnagaidhlig
Renamed header_Map_Object to HeaderMapObject etc. |
263 |
HeaderMapObject = 1, |
264 |
HeaderImmovable = 2, |
|
6915
by Holger Rapp
Removed legacy.cc/legacy.h and it's uses. |
265 |
// 3 was battle object.
|
266 |
// 4 was attack controller.
|
|
7150.4.9
by fios at foramnagaidhlig
Renamed header_Map_Object to HeaderMapObject etc. |
267 |
HeaderBattle = 5, |
268 |
HeaderCritter = 6, |
|
269 |
HeaderWorker = 7, |
|
270 |
HeaderWareInstance = 8, |
|
271 |
HeaderShip = 9, |
|
272 |
HeaderPortDock = 10, |
|
9204
by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044) |
273 |
HeaderShipFleet = 11, |
274 |
HeaderFerryFleet = 12, |
|
10439
by The Widelands Bunnybot
Pinned Notes (#5569) |
275 |
HeaderPinnedNote = 13, |
10631
by The Widelands Bunnybot
Link ship/ferry yards to fleets and produce ships/ferries as needed (#5912) |
276 |
HeaderShipFleetInterface = 14, |
277 |
HeaderFerryFleetInterface = 15, |
|
10885
by The Widelands Bunnybot
Correct naval warfare rebasing artifacts (closes CB#4699) |
278 |
HeaderNavalInvasionBase = 16, |
4018
by sirver
- moved more files into logic library. |
279 |
};
|
280 |
||
7421.4.5
by Alexander Kartzow\
Fixed Code-Style Problems |
281 |
/**
|
282 |
* Returns whether this immovable was reserved by a worker.
|
|
283 |
*/
|
|
284 |
bool is_reserved_by_worker() const; |
|
285 |
||
286 |
/**
|
|
287 |
* Change whether this immovable is marked as reserved by a worker.
|
|
288 |
*/
|
|
289 |
void set_reserved_by_worker(bool reserve); |
|
7421.4.1
by Alexander Kartzow\
first try to fix the two hunters hunt same animal bug |
290 |
|
4018
by sirver
- moved more files into logic library. |
291 |
/**
|
292 |
* Static load functions of derived classes will return a pointer to
|
|
293 |
* a Loader class. The caller needs to call the virtual functions
|
|
294 |
* \ref load for all instances loaded that way, after that call
|
|
295 |
* \ref load_pointers for all instances loaded that way and finally
|
|
296 |
* call \ref load_finish for all instances loaded that way.
|
|
297 |
* Those are the three phases of loading. After the last phase,
|
|
298 |
* all Loader objects should be deleted.
|
|
299 |
*/
|
|
6184
by David Allwicher
And Loader became a struct |
300 |
struct Loader { |
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
301 |
EditorGameBase* egbase_{nullptr}; |
302 |
MapObjectLoader* mol_{nullptr}; |
|
303 |
MapObject* object_{nullptr}; |
|
4018
by sirver
- moved more files into logic library. |
304 |
|
305 |
protected: |
|
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
306 |
Loader() = default; |
4018
by sirver
- moved more files into logic library. |
307 |
|
308 |
public: |
|
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
309 |
virtual ~Loader() = default; |
4018
by sirver
- moved more files into logic library. |
310 |
|
8048
by GunChleoc
Ran clang-format. |
311 |
void init(EditorGameBase& e, MapObjectLoader& m, MapObject& object) { |
7793.1.1
by fios at foramnagaidhlig
Fixed member variable names in map_objects. |
312 |
egbase_ = &e; |
8048
by GunChleoc
Ran clang-format. |
313 |
mol_ = &m; |
7793.1.1
by fios at foramnagaidhlig
Fixed member variable names in map_objects. |
314 |
object_ = &object; |
4018
by sirver
- moved more files into logic library. |
315 |
}
|
316 |
||
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
317 |
[[nodiscard]] EditorGameBase& egbase() const { |
8048
by GunChleoc
Ran clang-format. |
318 |
return *egbase_; |
319 |
}
|
|
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
320 |
[[nodiscard]] MapObjectLoader& mol() const { |
8048
by GunChleoc
Ran clang-format. |
321 |
return *mol_; |
322 |
}
|
|
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
323 |
[[nodiscard]] MapObject* get_object() const { |
8048
by GunChleoc
Ran clang-format. |
324 |
return object_; |
325 |
}
|
|
326 |
template <typename T> T& get() { |
|
7793.1.1
by fios at foramnagaidhlig
Fixed member variable names in map_objects. |
327 |
return dynamic_cast<T&>(*object_); |
4566
by sigra
* Change type of Widelands::Road::m_carrier from Object_Ptr to the typesafe OPtr<Carrier>. |
328 |
}
|
4018
by sirver
- moved more files into logic library. |
329 |
|
330 |
protected: |
|
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
331 |
void load(FileRead&) const; |
4018
by sirver
- moved more files into logic library. |
332 |
|
333 |
public: |
|
334 |
virtual void load_pointers(); |
|
335 |
virtual void load_finish(); |
|
336 |
};
|
|
337 |
||
338 |
/// This is just a fail-safe guard for the time until we fully transition
|
|
7150.4.7
by fios at foramnagaidhlig
Picked up Map_Object stragglers |
339 |
/// to the new MapObject saving system
|
8048
by GunChleoc
Ran clang-format. |
340 |
virtual bool has_new_save_support() { |
341 |
return false; |
|
342 |
}
|
|
4018
by sirver
- moved more files into logic library. |
343 |
|
8048
by GunChleoc
Ran clang-format. |
344 |
virtual void save(EditorGameBase&, MapObjectSaver&, FileWrite&); |
7150.4.7
by fios at foramnagaidhlig
Picked up Map_Object stragglers |
345 |
// Pure MapObjects cannot be loaded
|
4018
by sirver
- moved more files into logic library. |
346 |
|
347 |
protected: |
|
4887
by sigra
Change some uses of the word "field" to "node" where node is actually meant. Replace some repetitive code with macros. |
348 |
/// Called only when the oject is logically created in the simulation. If
|
349 |
/// called again, such as when the object is loaded from a savegame, it will
|
|
350 |
/// cause bugs.
|
|
8340.1.2
by GunChleoc
Only cancel expedition if there is a reachable portdock. Show a warning message to owner. |
351 |
virtual bool init(EditorGameBase&); |
4887
by sigra
Change some uses of the word "field" to "node" where node is actually meant. Replace some repetitive code with macros. |
352 |
|
8048
by GunChleoc
Ran clang-format. |
353 |
virtual void cleanup(EditorGameBase&); |
4018
by sirver
- moved more files into logic library. |
354 |
|
8906.14.1
by GunChleoc
Remove z-layering fix for building texts intoduced in r8847 because it is buggy and can make building animations disappear |
355 |
/// Draws census and statistics on screen
|
9204
by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044) |
356 |
void do_draw_info(const InfoToDraw& info_to_draw, |
8906.14.1
by GunChleoc
Remove z-layering fix for building texts intoduced in r8847 because it is buggy and can make building animations disappear |
357 |
const std::string& census, |
358 |
const std::string& statictics, |
|
359 |
const Vector2f& field_on_dst, |
|
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
360 |
float scale, |
8906.14.1
by GunChleoc
Remove z-layering fix for building texts intoduced in r8847 because it is buggy and can make building animations disappear |
361 |
RenderTarget* dst) const; |
362 |
||
9586
by The Widelands Bunnybot
Make `Time` and `Duration` typesafe (#4325) |
363 |
void molog(const Time& gametime, char const* fmt, ...) const PRINTF_FORMAT(3, 4); |
8048
by GunChleoc
Ran clang-format. |
364 |
|
365 |
const MapObjectDescr* descr_; |
|
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
366 |
Serial serial_{0U}; |
367 |
LogSink* logsink_{nullptr}; |
|
368 |
std::atomic<Player*> owner_{nullptr}; |
|
7076.2.1
by fios at foramnagaidhlig
Replaced most instances of boost::noncopyable with new macro DISALLOW_COPY_AND_ASSIGN and added codecheck rule |
369 |
|
7630.2.2
by fios at foramnagaidhlig
Fixed compiler warning in instances.h |
370 |
/**
|
371 |
* MapObjects like trees are reserved by a worker that is walking
|
|
372 |
* towards them, so that e.g. two lumberjacks don't attempt to
|
|
373 |
* work on the same tree simultaneously or two hunters try to hunt
|
|
374 |
* the same animal.
|
|
375 |
*/
|
|
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
376 |
bool reserved_by_worker_{false}; |
7630.2.2
by fios at foramnagaidhlig
Fixed compiler warning in instances.h |
377 |
|
7089
by Holger Rapp
Added a bunch of newlines here and there. |
378 |
private: |
7150.4.3
by fios at foramnagaidhlig
Replaced Map_Object with MapObject |
379 |
DISALLOW_COPY_AND_ASSIGN(MapObject); |
4018
by sirver
- moved more files into logic library. |
380 |
};
|
381 |
||
382 |
inline int32_t get_reverse_dir(int32_t const dir) { |
|
383 |
return 1 + ((dir - 1) + 3) % 6; |
|
384 |
}
|
|
385 |
||
386 |
/**
|
|
387 |
*
|
|
388 |
* Keeps the list of all objects currently in the game.
|
|
389 |
*/
|
|
8048
by GunChleoc
Ran clang-format. |
390 |
struct ObjectManager { |
9204
by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044) |
391 |
using MapObjectMap = std::unordered_map<Serial, MapObject*>; |
4018
by sirver
- moved more files into logic library. |
392 |
|
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
393 |
ObjectManager() = default; |
7175.1.4
by fios at foramnagaidhlig
Renamed everything in editor_game_base.h and widelands_geometry.h |
394 |
~ObjectManager(); |
4018
by sirver
- moved more files into logic library. |
395 |
|
8048
by GunChleoc
Ran clang-format. |
396 |
void cleanup(EditorGameBase&); |
4018
by sirver
- moved more files into logic library. |
397 |
|
8048
by GunChleoc
Ran clang-format. |
398 |
MapObject* get_object(Serial const serial) const { |
7793.1.1
by fios at foramnagaidhlig
Fixed member variable names in map_objects. |
399 |
const MapObjectMap::const_iterator it = objects_.find(serial); |
400 |
return it != objects_.end() ? it->second : nullptr; |
|
4018
by sirver
- moved more files into logic library. |
401 |
}
|
402 |
||
8048
by GunChleoc
Ran clang-format. |
403 |
void insert(MapObject*); |
404 |
void remove(MapObject&); |
|
4018
by sirver
- moved more files into logic library. |
405 |
|
406 |
/**
|
|
6169
by Holger Rapp
Reintroduce boost::unordered_map. Made sure that objects are saved in order to avoid network desyncs. Works for me but needs more testing. Related to bug 905835 |
407 |
* When saving the map object, ordere matters. Return a vector of all ids
|
408 |
* that are currently available;
|
|
4018
by sirver
- moved more files into logic library. |
409 |
*/
|
8048
by GunChleoc
Ran clang-format. |
410 |
std::vector<Serial> all_object_serials_ordered() const; |
4018
by sirver
- moved more files into logic library. |
411 |
|
9425
by The Widelands Bunnybot
Refactor playerfields visibility (#4046) |
412 |
bool is_cleaning_up() const { |
413 |
return is_cleaning_up_; |
|
414 |
}
|
|
415 |
||
4018
by sirver
- moved more files into logic library. |
416 |
private: |
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
417 |
Serial lastserial_{0U}; |
7793.1.1
by fios at foramnagaidhlig
Fixed member variable names in map_objects. |
418 |
MapObjectMap objects_; |
7076.2.3
by fios at foramnagaidhlig
Removed all uses of boost:: noncopyable except for src/wui/unique_window_handler.h |
419 |
|
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
420 |
bool is_cleaning_up_{false}; |
9425
by The Widelands Bunnybot
Refactor playerfields visibility (#4046) |
421 |
|
7175.1.4
by fios at foramnagaidhlig
Renamed everything in editor_game_base.h and widelands_geometry.h |
422 |
DISALLOW_COPY_AND_ASSIGN(ObjectManager); |
4018
by sirver
- moved more files into logic library. |
423 |
};
|
424 |
||
425 |
/**
|
|
7150.4.7
by fios at foramnagaidhlig
Picked up Map_Object stragglers |
426 |
* Provides a safe pointer to a MapObject
|
9582
by The Widelands Bunnybot
Remove ObjectManager::object_still_available (#4353) |
427 |
* Make sure the MapObject is initialized (has a serial) before using it in ObjectPointer!
|
4018
by sirver
- moved more files into logic library. |
428 |
*/
|
7175.1.5
by fios at foramnagaidhlig
Renamed classes in Widelands namespace + widelands.h |
429 |
struct ObjectPointer { |
6564
by Holger Rapp
Some hopefully harmless fixes suggested by cppcheck - applied without much concentration, so no guarantees. |
430 |
// Provide default constructor to shut up cppcheck.
|
8048
by GunChleoc
Ran clang-format. |
431 |
ObjectPointer() { |
432 |
serial_ = 0; |
|
433 |
}
|
|
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
434 |
ObjectPointer(const MapObject* const obj) { // NOLINT allow implicit conversion |
9582
by The Widelands Bunnybot
Remove ObjectManager::object_still_available (#4353) |
435 |
assert(obj == nullptr || obj->serial_ != 0); |
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
436 |
serial_ = obj != nullptr ? obj->serial_ : 0; |
8048
by GunChleoc
Ran clang-format. |
437 |
}
|
4018
by sirver
- moved more files into logic library. |
438 |
// can use standard copy constructor and assignment operator
|
439 |
||
8365.2.1
by Holger Rapp
Refactor Attackable. |
440 |
ObjectPointer& operator=(const MapObject* const obj) { |
9582
by The Widelands Bunnybot
Remove ObjectManager::object_still_available (#4353) |
441 |
assert(obj == nullptr || obj->serial_ != 0); |
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
442 |
serial_ = obj != nullptr ? obj->serial_ : 0; |
4018
by sirver
- moved more files into logic library. |
443 |
return *this; |
444 |
}
|
|
445 |
||
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
446 |
[[nodiscard]] bool is_set() const { |
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
447 |
return serial_ != 0u; |
8048
by GunChleoc
Ran clang-format. |
448 |
}
|
4018
by sirver
- moved more files into logic library. |
449 |
|
7175.1.4
by fios at foramnagaidhlig
Renamed everything in editor_game_base.h and widelands_geometry.h |
450 |
// TODO(unknown): dammit... without an EditorGameBase object, we can't implement a
|
7810.1.1
by fios at foramnagaidhlig
Removed leading underscores from variable and function names. |
451 |
// MapObject* operator (would be really nice)
|
8048
by GunChleoc
Ran clang-format. |
452 |
MapObject* get(const EditorGameBase&); |
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
453 |
[[nodiscard]] MapObject* get(const EditorGameBase& egbase) const; |
4018
by sirver
- moved more files into logic library. |
454 |
|
8048
by GunChleoc
Ran clang-format. |
455 |
bool operator<(const ObjectPointer& other) const { |
7793.1.1
by fios at foramnagaidhlig
Fixed member variable names in map_objects. |
456 |
return serial_ < other.serial_; |
4018
by sirver
- moved more files into logic library. |
457 |
}
|
8048
by GunChleoc
Ran clang-format. |
458 |
bool operator==(const ObjectPointer& other) const { |
7793.1.1
by fios at foramnagaidhlig
Fixed member variable names in map_objects. |
459 |
return serial_ == other.serial_; |
4018
by sirver
- moved more files into logic library. |
460 |
}
|
8048
by GunChleoc
Ran clang-format. |
461 |
bool operator!=(const ObjectPointer& other) const { |
7793.1.1
by fios at foramnagaidhlig
Fixed member variable names in map_objects. |
462 |
return serial_ != other.serial_; |
4485
by sigra
Attempt to fix bug #2796085 (PendingItem at flag has stale nextstep pointer) reported by Peter Schwanemann - nasenbaer_peter. Change the type of Widelands::Flag::PendingItem::nextstep from PlayerImmovable * to OPtr<PlayerImmovable>. This is necessary, because the pointer would become stale when the target was destroyed (as demonstrated with a savegame). This problem surfaced during autosave. Attempt to improve the check for unsaved objects and make sure that it is only done in debug builds. |
463 |
}
|
4018
by sirver
- moved more files into logic library. |
464 |
|
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
465 |
[[nodiscard]] uint32_t serial() const { |
8048
by GunChleoc
Ran clang-format. |
466 |
return serial_; |
467 |
}
|
|
4018
by sirver
- moved more files into logic library. |
468 |
|
469 |
private: |
|
7793.1.1
by fios at foramnagaidhlig
Fixed member variable names in map_objects. |
470 |
uint32_t serial_; |
4018
by sirver
- moved more files into logic library. |
471 |
};
|
472 |
||
8048
by GunChleoc
Ran clang-format. |
473 |
template <class T> struct OPtr { |
10462
by The Widelands Bunnybot
Clear clang-tidy in logic headers (#5691) |
474 |
OPtr(T* const obj = nullptr) : m(obj) { // NOLINT allow implicit conversion |
8048
by GunChleoc
Ran clang-format. |
475 |
}
|
4018
by sirver
- moved more files into logic library. |
476 |
|
8048
by GunChleoc
Ran clang-format. |
477 |
OPtr& operator=(T* const obj) { |
4018
by sirver
- moved more files into logic library. |
478 |
m = obj; |
479 |
return *this; |
|
480 |
}
|
|
481 |
||
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
482 |
[[nodiscard]] bool is_set() const { |
8048
by GunChleoc
Ran clang-format. |
483 |
return m.is_set(); |
484 |
}
|
|
485 |
||
486 |
T* get(const EditorGameBase& egbase) { |
|
487 |
return static_cast<T*>(m.get(egbase)); |
|
488 |
}
|
|
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
489 |
[[nodiscard]] T* get(const EditorGameBase& egbase) const { |
8048
by GunChleoc
Ran clang-format. |
490 |
return static_cast<T*>(m.get(egbase)); |
491 |
}
|
|
492 |
||
493 |
bool operator<(const OPtr<T>& other) const { |
|
494 |
return m < other.m; |
|
495 |
}
|
|
496 |
bool operator==(const OPtr<T>& other) const { |
|
497 |
return m == other.m; |
|
498 |
}
|
|
499 |
bool operator!=(const OPtr<T>& other) const { |
|
500 |
return m != other.m; |
|
501 |
}
|
|
502 |
||
10448
by The Widelands Bunnybot
Fix clang-tidy C++17 checks (#5679) |
503 |
[[nodiscard]] Serial serial() const { |
8048
by GunChleoc
Ran clang-format. |
504 |
return m.serial(); |
505 |
}
|
|
4018
by sirver
- moved more files into logic library. |
506 |
|
507 |
private: |
|
7175.1.5
by fios at foramnagaidhlig
Renamed classes in Widelands namespace + widelands.h |
508 |
ObjectPointer m; |
4018
by sirver
- moved more files into logic library. |
509 |
};
|
510 |
||
8939
by Wideland's Bunnybot
Merged lp:~widelands-dev/widelands/appveyor_reenable_glbinding: |
511 |
} // namespace Widelands |
4018
by sirver
- moved more files into logic library. |
512 |
|
7649.1.2
by fios at foramnagaidhlig
Renamed instances.h to map_object.h. |
513 |
#endif // end of include guard: WL_LOGIC_MAP_OBJECTS_MAP_OBJECT_H |