Symphony Of Empires
world.hpp File Reference
#include <cstdlib>
#include <cstdint>
#include <cstddef>
#include <cstring>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <mutex>
#include <string>
#include <memory>
#include <array>
#include <glm/vec2.hpp>
#include "eng3d/profiler.hpp"
#include "eng3d/string.hpp"
#include "eng3d/log.hpp"
#include "eng3d/luavm.hpp"
#include "nation.hpp"
#include "product.hpp"
#include "indpobj.hpp"
#include "building.hpp"
#include "server/lua_api.hpp"
#include "server/economy.hpp"
#include "province.hpp"
#include "unit.hpp"
#include "event.hpp"
#include "diplomacy.hpp"
Include dependency graph for world.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  World
 
struct  Eng3D::Deser::Serializer< World >
 

Macros

#define LIST_FOR_TYPE(type, list, list_type)
 
#define CONST_LIST_FOR_LOCAL_TYPE(type, list, list_type)
 
#define LIST_FOR_LOCAL_TYPE(type, list, list_type)
 

Variables

World g_world
 

Macro Definition Documentation

◆ CONST_LIST_FOR_LOCAL_TYPE

#define CONST_LIST_FOR_LOCAL_TYPE (   type,
  list,
  list_type 
)
Value:
inline const list_type<type>& get_list(const type* = nullptr) const {\
return list;\
};\
inline list_type<type>& get_list(const type* = nullptr) {\
return list;\
};\
inline void insert(type& ptr) {\
auto& type_list = this->get_list((type*)nullptr);\
std::scoped_lock lock(list_mutex);\
ptr.cached_id = type::Id(type_list.size());\
Eng3D::Log::debug("world_insert", "Inserting object " #type " with ID=" + std::to_string(static_cast<size_t>(ptr.cached_id)));\
type_list.push_back(ptr);\
};\
list_type<type> list;
void debug(const std::string_view category, const std::string_view msg)
Definition: log.cpp:58

Definition at line 71 of file world.hpp.

◆ LIST_FOR_LOCAL_TYPE

#define LIST_FOR_LOCAL_TYPE (   type,
  list,
  list_type 
)
Value:
inline const list_type<type>& get_list(const type* = nullptr) const {\
return list;\
};\
inline list_type<type>& get_list(const type* = nullptr) {\
return list;\
};\
inline void insert(type& ptr) {\
auto& type_list = this->get_list((type*)nullptr);\
std::scoped_lock lock(list_mutex);\
ptr.cached_id = type::Id(type_list.size());\
Eng3D::Log::debug("world_insert", "Inserting object " #type " with ID=" + std::to_string(static_cast<size_t>(ptr.cached_id)));\
type_list.push_back(ptr);\
};\
inline void remove(type& ptr) {\
size_t cached_id = static_cast<size_t>(this->get_id<type>(ptr));\
auto& type_list = this->get_list((type*)nullptr);\
std::scoped_lock lock(list_mutex);\
cached_id = type_list.size();\
Eng3D::Log::debug("world_remove", "Removing object " #type " with ID=" + std::to_string(static_cast<size_t>(cached_id)));\
for(size_t i = cached_id + 1; i < type_list.size(); i++)\
type_list[i].cached_id = type::Id(static_cast<size_t>(type_list[i].cached_id) - 1);\
type_list.erase(type_list.begin() + cached_id);\
};\
list_type<type> list;

Definition at line 87 of file world.hpp.

◆ LIST_FOR_TYPE

#define LIST_FOR_TYPE (   type,
  list,
  list_type 
)
Value:
inline const list_type<type*>& get_list(const type* = nullptr) const {\
return list;\
};\
inline list_type<type*>& get_list(const type* = nullptr) {\
return list;\
};\
list_type<type*> list;

Definition at line 62 of file world.hpp.

Variable Documentation

◆ g_world

World g_world
extern

Definition at line 59 of file world.cpp.