Pass clang-format on various cpp/header files (#5559)

master
Loïc Blot 2017-04-23 09:52:40 +02:00 committed by GitHub
parent 0c34fe20a1
commit 91a9382c25
30 changed files with 138 additions and 183 deletions

View File

@ -41,12 +41,12 @@ public:
void add(const std::string &ip, const std::string &name); void add(const std::string &ip, const std::string &name);
void remove(const std::string &ip_or_name); void remove(const std::string &ip_or_name);
bool isModified(); bool isModified();
private: private:
Mutex m_mutex; Mutex m_mutex;
std::string m_banfilepath; std::string m_banfilepath;
StringMap m_ips; StringMap m_ips;
bool m_modified; bool m_modified;
}; };
#endif #endif

View File

@ -37,11 +37,12 @@ class GenerateNotifier;
TODO(hmmmm): Remove dependency on biomes TODO(hmmmm): Remove dependency on biomes
TODO(hmmmm): Find alternative to overgeneration as solution for sunlight issue TODO(hmmmm): Find alternative to overgeneration as solution for sunlight issue
*/ */
class CavesNoiseIntersection { class CavesNoiseIntersection
{
public: public:
CavesNoiseIntersection(INodeDefManager *nodedef, BiomeManager *biomemgr, CavesNoiseIntersection(INodeDefManager *nodedef, BiomeManager *biomemgr,
v3s16 chunksize, NoiseParams *np_cave1, NoiseParams *np_cave2, v3s16 chunksize, NoiseParams *np_cave1, NoiseParams *np_cave2,
s32 seed, float cave_width); s32 seed, float cave_width);
~CavesNoiseIntersection(); ~CavesNoiseIntersection();
void generateCaves(MMVManip *vm, v3s16 nmin, v3s16 nmax, u8 *biomemap); void generateCaves(MMVManip *vm, v3s16 nmin, v3s16 nmax, u8 *biomemap);
@ -65,10 +66,12 @@ private:
/* /*
CavernsNoise is a cave digging algorithm CavernsNoise is a cave digging algorithm
*/ */
class CavernsNoise { class CavernsNoise
{
public: public:
CavernsNoise(INodeDefManager *nodedef, v3s16 chunksize, NoiseParams *np_cavern, CavernsNoise(INodeDefManager *nodedef, v3s16 chunksize, NoiseParams *np_cavern,
s32 seed, float cavern_limit, float cavern_taper, float cavern_threshold); s32 seed, float cavern_limit, float cavern_taper,
float cavern_threshold);
~CavernsNoise(); ~CavernsNoise();
bool generateCaverns(MMVManip *vm, v3s16 nmin, v3s16 nmax); bool generateCaverns(MMVManip *vm, v3s16 nmin, v3s16 nmax);
@ -105,7 +108,8 @@ private:
This algorithm is very fast, executing in less than 1ms on average for an This algorithm is very fast, executing in less than 1ms on average for an
80x80x80 chunk of map on a modern processor. 80x80x80 chunk of map on a modern processor.
*/ */
class CavesRandomWalk { class CavesRandomWalk
{
public: public:
MMVManip *vm; MMVManip *vm;
INodeDefManager *ndef; INodeDefManager *ndef;
@ -150,18 +154,16 @@ public:
// ndef is a mandatory parameter. // ndef is a mandatory parameter.
// If gennotify is NULL, generation events are not logged. // If gennotify is NULL, generation events are not logged.
CavesRandomWalk(INodeDefManager *ndef, CavesRandomWalk(INodeDefManager *ndef, GenerateNotifier *gennotify = NULL,
GenerateNotifier *gennotify = NULL, s32 seed = 0, int water_level = 1,
s32 seed = 0, content_t water_source = CONTENT_IGNORE,
int water_level = 1, content_t lava_source = CONTENT_IGNORE);
content_t water_source = CONTENT_IGNORE,
content_t lava_source = CONTENT_IGNORE);
// vm and ps are mandatory parameters. // vm and ps are mandatory parameters.
// If heightmap is NULL, the surface level at all points is assumed to // If heightmap is NULL, the surface level at all points is assumed to
// be water_level. // be water_level.
void makeCave(MMVManip *vm, v3s16 nmin, v3s16 nmax, PseudoRandom *ps, void makeCave(MMVManip *vm, v3s16 nmin, v3s16 nmax, PseudoRandom *ps,
bool is_large_cave, int max_stone_height, s16 *heightmap); bool is_large_cave, int max_stone_height, s16 *heightmap);
private: private:
void makeTunnel(bool dirswitch); void makeTunnel(bool dirswitch);
@ -183,7 +185,8 @@ private:
tl;dr, tl;dr,
*** DO NOT TOUCH THIS CLASS UNLESS YOU KNOW WHAT YOU ARE DOING *** *** DO NOT TOUCH THIS CLASS UNLESS YOU KNOW WHAT YOU ARE DOING ***
*/ */
class CavesV6 { class CavesV6
{
public: public:
MMVManip *vm; MMVManip *vm;
INodeDefManager *ndef; INodeDefManager *ndef;
@ -222,18 +225,16 @@ public:
// ndef is a mandatory parameter. // ndef is a mandatory parameter.
// If gennotify is NULL, generation events are not logged. // If gennotify is NULL, generation events are not logged.
CavesV6(INodeDefManager *ndef, CavesV6(INodeDefManager *ndef, GenerateNotifier *gennotify = NULL,
GenerateNotifier *gennotify = NULL, int water_level = 1, content_t water_source = CONTENT_IGNORE,
int water_level = 1, content_t lava_source = CONTENT_IGNORE);
content_t water_source = CONTENT_IGNORE,
content_t lava_source = CONTENT_IGNORE);
// vm, ps, and ps2 are mandatory parameters. // vm, ps, and ps2 are mandatory parameters.
// If heightmap is NULL, the surface level at all points is assumed to // If heightmap is NULL, the surface level at all points is assumed to
// be water_level. // be water_level.
void makeCave(MMVManip *vm, v3s16 nmin, v3s16 nmax, void makeCave(MMVManip *vm, v3s16 nmin, v3s16 nmax, PseudoRandom *ps,
PseudoRandom *ps, PseudoRandom *ps2, PseudoRandom *ps2, bool is_large_cave, int max_stone_height,
bool is_large_cave, int max_stone_height, s16 *heightmap = NULL); s16 *heightmap = NULL);
private: private:
void makeTunnel(bool dirswitch); void makeTunnel(bool dirswitch);

View File

@ -85,7 +85,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
// Size of player's main inventory // Size of player's main inventory
#define PLAYER_INVENTORY_SIZE (8*4) #define PLAYER_INVENTORY_SIZE (8 * 4)
// Maximum hit points of a player // Maximum hit points of a player
#define PLAYER_MAX_HP 20 #define PLAYER_MAX_HP 20
@ -110,10 +110,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// TODO: implement dpi-based scaling for windows and remove this hack // TODO: implement dpi-based scaling for windows and remove this hack
#if defined(_WIN32) #if defined(_WIN32)
#define TTF_DEFAULT_FONT_SIZE (18) #define TTF_DEFAULT_FONT_SIZE (18)
#else #else
#define TTF_DEFAULT_FONT_SIZE (16) #define TTF_DEFAULT_FONT_SIZE (16)
#endif #endif
#define DEFAULT_FONT_SIZE (10) #define DEFAULT_FONT_SIZE (10)
#endif #endif

View File

@ -29,6 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "serverscripting.h" #include "serverscripting.h"
#include "log.h" #include "log.h"
void add_legacy_abms(ServerEnvironment *env, INodeDefManager *nodedef) { void add_legacy_abms(ServerEnvironment *env, INodeDefManager *nodedef)
{
} }

View File

@ -38,4 +38,3 @@ private:
}; };
#endif #endif

View File

@ -36,4 +36,3 @@ void set_default_settings(Settings *settings);
void override_default_settings(Settings *settings, Settings *from); void override_default_settings(Settings *settings, Settings *from);
#endif #endif

View File

@ -58,7 +58,7 @@ public:
*/ */
virtual void step(f32 dtime) = 0; virtual void step(f32 dtime) = 0;
virtual Map & getMap() = 0; virtual Map &getMap() = 0;
u32 getDayNightRatio(); u32 getDayNightRatio();
@ -78,7 +78,7 @@ public:
// counter used internally when triggering ABMs // counter used internally when triggering ABMs
u32 m_added_objects; u32 m_added_objects;
IGameDef* getGameDef() { return m_gamedef; } IGameDef *getGameDef() { return m_gamedef; }
protected: protected:
GenericAtomic<float> m_time_of_day_speed; GenericAtomic<float> m_time_of_day_speed;
@ -117,6 +117,7 @@ protected:
float m_cache_nodetimer_interval; float m_cache_nodetimer_interval;
IGameDef *m_gamedef; IGameDef *m_gamedef;
private: private:
Mutex m_time_lock; Mutex m_time_lock;
@ -124,4 +125,3 @@ private:
}; };
#endif #endif

View File

@ -30,7 +30,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
struct key_setting { struct key_setting
{
int id; int id;
const wchar_t *button_name; const wchar_t *button_name;
KeyPress key; KeyPress key;
@ -38,12 +39,11 @@ struct key_setting {
gui::IGUIButton *button; gui::IGUIButton *button;
}; };
class GUIKeyChangeMenu : public GUIModalMenu
class GUIKeyChangeMenu: public GUIModalMenu
{ {
public: public:
GUIKeyChangeMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, GUIKeyChangeMenu(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id,
s32 id, IMenuManager *menumgr); IMenuManager *menumgr);
~GUIKeyChangeMenu(); ~GUIKeyChangeMenu();
void removeChildren(); void removeChildren();
@ -56,10 +56,9 @@ public:
bool acceptInput(); bool acceptInput();
bool OnEvent(const SEvent& event); bool OnEvent(const SEvent &event);
private: private:
void init_keys(); void init_keys();
bool resetMenu(); bool resetMenu();
@ -67,13 +66,12 @@ private:
void add_key(int id, const wchar_t *button_name, const std::string &setting_name); void add_key(int id, const wchar_t *button_name, const std::string &setting_name);
bool shift_down; bool shift_down;
s32 activeKey; s32 activeKey;
std::vector<KeyPress> key_used; std::vector<KeyPress> key_used;
gui::IGUIStaticText *key_used_text; gui::IGUIStaticText *key_used_text;
std::vector<key_setting *> key_settings; std::vector<key_setting *> key_settings;
}; };
#endif #endif

View File

@ -27,12 +27,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
class GUIPasswordChange : public GUIModalMenu class GUIPasswordChange : public GUIModalMenu
{ {
public: public:
GUIPasswordChange(gui::IGUIEnvironment* env, GUIPasswordChange(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id,
gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, Client *client);
IMenuManager *menumgr,
Client* client);
~GUIPasswordChange(); ~GUIPasswordChange();
void removeChildren(); void removeChildren();
/* /*
Remove and re-add (or reposition) stuff Remove and re-add (or reposition) stuff
@ -43,12 +41,10 @@ public:
bool acceptInput(); bool acceptInput();
bool OnEvent(const SEvent& event); bool OnEvent(const SEvent &event);
private:
Client* m_client;
private:
Client *m_client;
}; };
#endif #endif

View File

@ -29,4 +29,3 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <SColor.h> #include <SColor.h>
#endif #endif

View File

@ -36,4 +36,3 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#endif #endif
#endif #endif

View File

@ -25,14 +25,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
typedef UNORDERED_MAP<std::string, int> ItemGroupList; typedef UNORDERED_MAP<std::string, int> ItemGroupList;
static inline int itemgroup_get(const ItemGroupList &groups, static inline int itemgroup_get(const ItemGroupList &groups, const std::string &name)
const std::string &name)
{ {
ItemGroupList::const_iterator i = groups.find(name); ItemGroupList::const_iterator i = groups.find(name);
if(i == groups.end()) if (i == groups.end())
return 0; return 0;
return i->second; return i->second;
} }
#endif #endif

View File

@ -34,16 +34,16 @@ public:
KeyPress(); KeyPress();
KeyPress(const char *name); KeyPress(const char *name);
KeyPress(const irr::SEvent::SKeyInput &in, bool prefer_character=false); KeyPress(const irr::SEvent::SKeyInput &in, bool prefer_character = false);
bool operator==(const KeyPress &o) const bool operator==(const KeyPress &o) const
{ {
return (Char > 0 && Char == o.Char) || return (Char > 0 && Char == o.Char) || (valid_kcode(Key) && Key == o.Key);
(valid_kcode(Key) && Key == o.Key);
} }
const char *sym() const; const char *sym() const;
const char *name() const; const char *name() const;
protected: protected:
static bool valid_kcode(irr::EKEY_CODE k) static bool valid_kcode(irr::EKEY_CODE k)
{ {
@ -68,4 +68,3 @@ void clearKeyCache();
irr::EKEY_CODE keyname_to_keycode(const char *name); irr::EKEY_CODE keyname_to_keycode(const char *name);
#endif #endif

View File

@ -38,30 +38,30 @@ with this program; if not, write to the Free Software Foundation, Inc.,
inline u8 diminish_light(u8 light) inline u8 diminish_light(u8 light)
{ {
if(light == 0) if (light == 0)
return 0; return 0;
if(light >= LIGHT_MAX) if (light >= LIGHT_MAX)
return LIGHT_MAX - 1; return LIGHT_MAX - 1;
return light - 1; return light - 1;
} }
inline u8 diminish_light(u8 light, u8 distance) inline u8 diminish_light(u8 light, u8 distance)
{ {
if(distance >= light) if (distance >= light)
return 0; return 0;
return light - distance; return light - distance;
} }
inline u8 undiminish_light(u8 light) inline u8 undiminish_light(u8 light)
{ {
// We don't know if light should undiminish from this particular 0. // We don't know if light should undiminish from this particular 0.
// Thus, keep it at 0. // Thus, keep it at 0.
if(light == 0) if (light == 0)
return 0; return 0;
if(light == LIGHT_MAX) if (light == LIGHT_MAX)
return light; return light;
return light + 1; return light + 1;
} }
@ -85,9 +85,9 @@ extern const u8 *light_decode_table;
// 0 <= return value <= 255 // 0 <= return value <= 255
inline u8 decode_light(u8 light) inline u8 decode_light(u8 light)
{ {
if(light > LIGHT_MAX) if (light > LIGHT_MAX)
light = LIGHT_MAX; light = LIGHT_MAX;
return light_decode_table[light]; return light_decode_table[light];
} }
@ -97,12 +97,12 @@ inline float decode_light_f(float light_f)
{ {
s32 i = (u32)(light_f * LIGHT_MAX + 0.5); s32 i = (u32)(light_f * LIGHT_MAX + 0.5);
if(i <= 0) if (i <= 0)
return (float)light_decode_table[0] / 255.0; return (float)light_decode_table[0] / 255.0;
if(i >= LIGHT_MAX) if (i >= LIGHT_MAX)
return (float)light_decode_table[LIGHT_MAX] / 255.0; return (float)light_decode_table[LIGHT_MAX] / 255.0;
float v1 = (float)light_decode_table[i-1] / 255.0; float v1 = (float)light_decode_table[i - 1] / 255.0;
float v2 = (float)light_decode_table[i] / 255.0; float v2 = (float)light_decode_table[i] / 255.0;
float f0 = (float)i - 0.5; float f0 = (float)i - 0.5;
float f = light_f * LIGHT_MAX - f0; float f = light_f * LIGHT_MAX - f0;
@ -119,11 +119,10 @@ void set_light_table(float gamma);
inline u8 blend_light(u32 daylight_factor, u8 lightday, u8 lightnight) inline u8 blend_light(u32 daylight_factor, u8 lightday, u8 lightnight)
{ {
u32 c = 1000; u32 c = 1000;
u32 l = ((daylight_factor * lightday + (c-daylight_factor) * lightnight))/c; u32 l = ((daylight_factor * lightday + (c - daylight_factor) * lightnight)) / c;
if(l > LIGHT_SUN) if (l > LIGHT_SUN)
l = LIGHT_SUN; l = LIGHT_SUN;
return l; return l;
} }
#endif #endif

View File

@ -30,7 +30,13 @@ class GenericCAO;
class ClientActiveObject; class ClientActiveObject;
class IGameDef; class IGameDef;
enum LocalPlayerAnimations {NO_ANIM, WALK_ANIM, DIG_ANIM, WD_ANIM}; // no local animation, walking, digging, both enum LocalPlayerAnimations
{
NO_ANIM,
WALK_ANIM,
DIG_ANIM,
WD_ANIM
}; // no local animation, walking, digging, both
class LocalPlayer : public Player class LocalPlayer : public Player
{ {
@ -97,12 +103,11 @@ public:
float hurt_tilt_timer; float hurt_tilt_timer;
float hurt_tilt_strength; float hurt_tilt_strength;
GenericCAO* getCAO() const { GenericCAO *getCAO() const { return m_cao; }
return m_cao;
}
void setCAO(GenericCAO* toset) { void setCAO(GenericCAO *toset)
assert( m_cao == NULL ); // Pre-condition {
assert(m_cao == NULL); // Pre-condition
m_cao = toset; m_cao = toset;
} }
@ -113,28 +118,20 @@ public:
v3s16 getLightPosition() const; v3s16 getLightPosition() const;
void setYaw(f32 yaw) void setYaw(f32 yaw) { m_yaw = yaw; }
{
m_yaw = yaw;
}
f32 getYaw() const { return m_yaw; } f32 getYaw() const { return m_yaw; }
void setPitch(f32 pitch) void setPitch(f32 pitch) { m_pitch = pitch; }
{
m_pitch = pitch;
}
f32 getPitch() const { return m_pitch; } f32 getPitch() const { return m_pitch; }
void setPosition(const v3f &position) void setPosition(const v3f &position) { m_position = position; }
{
m_position = position;
}
v3f getPosition() const { return m_position; } v3f getPosition() const { return m_position; }
v3f getEyePosition() const { return m_position + getEyeOffset(); } v3f getEyePosition() const { return m_position + getEyeOffset(); }
v3f getEyeOffset() const; v3f getEyeOffset() const;
private: private:
void accelerateHorizontal(const v3f &target_speed, const f32 max_increase); void accelerateHorizontal(const v3f &target_speed, const f32 max_increase);
void accelerateVertical(const v3f &target_speed, const f32 max_increase); void accelerateVertical(const v3f &target_speed, const f32 max_increase);
@ -169,9 +166,8 @@ private:
bool camera_barely_in_ceiling; bool camera_barely_in_ceiling;
aabb3f m_collisionbox; aabb3f m_collisionbox;
GenericCAO* m_cao; GenericCAO *m_cao;
Client *m_client; Client *m_client;
}; };
#endif #endif

View File

@ -31,8 +31,8 @@ class BiomeManager;
extern FlagDesc flagdesc_mapgen_flat[]; extern FlagDesc flagdesc_mapgen_flat[];
struct MapgenFlatParams : public MapgenParams
struct MapgenFlatParams : public MapgenParams { {
u32 spflags; u32 spflags;
s16 ground_level; s16 ground_level;
s16 large_cave_depth; s16 large_cave_depth;
@ -53,7 +53,8 @@ struct MapgenFlatParams : public MapgenParams {
void writeParams(Settings *settings) const; void writeParams(Settings *settings) const;
}; };
class MapgenFlat : public MapgenBasic { class MapgenFlat : public MapgenBasic
{
public: public:
MapgenFlat(int mapgenid, MapgenFlatParams *params, EmergeManager *emerge); MapgenFlat(int mapgenid, MapgenFlatParams *params, EmergeManager *emerge);
~MapgenFlat(); ~MapgenFlat();

View File

@ -32,8 +32,8 @@ class BiomeManager;
extern FlagDesc flagdesc_mapgen_fractal[]; extern FlagDesc flagdesc_mapgen_fractal[];
struct MapgenFractalParams : public MapgenParams
struct MapgenFractalParams : public MapgenParams { {
u32 spflags; u32 spflags;
float cave_width; float cave_width;
u16 fractal; u16 fractal;
@ -57,7 +57,8 @@ struct MapgenFractalParams : public MapgenParams {
void writeParams(Settings *settings) const; void writeParams(Settings *settings) const;
}; };
class MapgenFractal : public MapgenBasic { class MapgenFractal : public MapgenBasic
{
public: public:
MapgenFractal(int mapgenid, MapgenFractalParams *params, EmergeManager *emerge); MapgenFractal(int mapgenid, MapgenFractalParams *params, EmergeManager *emerge);
~MapgenFractal(); ~MapgenFractal();

View File

@ -22,7 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapgen.h" #include "mapgen.h"
struct MapgenSinglenodeParams : public MapgenParams { struct MapgenSinglenodeParams : public MapgenParams
{
MapgenSinglenodeParams() {} MapgenSinglenodeParams() {}
~MapgenSinglenodeParams() {} ~MapgenSinglenodeParams() {}
@ -30,7 +31,8 @@ struct MapgenSinglenodeParams : public MapgenParams {
void writeParams(Settings *settings) const {} void writeParams(Settings *settings) const {}
}; };
class MapgenSinglenode : public Mapgen { class MapgenSinglenode : public Mapgen
{
public: public:
u32 flags; u32 flags;
content_t c_node; content_t c_node;

View File

@ -32,8 +32,8 @@ class BiomeManager;
extern FlagDesc flagdesc_mapgen_v5[]; extern FlagDesc flagdesc_mapgen_v5[];
struct MapgenV5Params : public MapgenParams
struct MapgenV5Params : public MapgenParams { {
u32 spflags; u32 spflags;
float cave_width; float cave_width;
s16 cavern_limit; s16 cavern_limit;
@ -55,8 +55,8 @@ struct MapgenV5Params : public MapgenParams {
void writeParams(Settings *settings) const; void writeParams(Settings *settings) const;
}; };
class MapgenV5 : public MapgenBasic
class MapgenV5 : public MapgenBasic { {
public: public:
MapgenV5(int mapgenid, MapgenV5Params *params, EmergeManager *emerge); MapgenV5(int mapgenid, MapgenV5Params *params, EmergeManager *emerge);
~MapgenV5(); ~MapgenV5();

View File

@ -64,8 +64,7 @@ bool Metadata::operator==(const Metadata &other) const
return true; return true;
} }
const std::string &Metadata::getString(const std::string &name, const std::string &Metadata::getString(const std::string &name, u16 recursion) const
u16 recursion) const
{ {
StringMap::const_iterator it = m_stringvars.find(name); StringMap::const_iterator it = m_stringvars.find(name);
if (it == m_stringvars.end()) { if (it == m_stringvars.end()) {
@ -99,11 +98,9 @@ bool Metadata::setString(const std::string &name, const std::string &var)
return true; return true;
} }
const std::string &Metadata::resolveString(const std::string &str, const std::string &Metadata::resolveString(const std::string &str, u16 recursion) const
u16 recursion) const
{ {
if (recursion <= 1 && if (recursion <= 1 && str.substr(0, 2) == "${" && str[str.length() - 1] == '}') {
str.substr(0, 2) == "${" && str[str.length() - 1] == '}') {
return getString(str.substr(2, str.length() - 3), recursion + 1); return getString(str.substr(2, str.length() - 3), recursion + 1);
} else { } else {
return str; return str;

View File

@ -34,4 +34,3 @@ enum ModifiedState
}; };
#endif #endif

View File

@ -25,27 +25,25 @@ void NameIdMapping::serialize(std::ostream &os) const
{ {
writeU8(os, 0); // version writeU8(os, 0); // version
writeU16(os, m_id_to_name.size()); writeU16(os, m_id_to_name.size());
for(UNORDERED_MAP<u16, std::string>::const_iterator for (UNORDERED_MAP<u16, std::string>::const_iterator i = m_id_to_name.begin();
i = m_id_to_name.begin(); i != m_id_to_name.end(); ++i) {
i != m_id_to_name.end(); ++i){
writeU16(os, i->first); writeU16(os, i->first);
os<<serializeString(i->second); os << serializeString(i->second);
} }
} }
void NameIdMapping::deSerialize(std::istream &is) void NameIdMapping::deSerialize(std::istream &is)
{ {
int version = readU8(is); int version = readU8(is);
if(version != 0) if (version != 0)
throw SerializationError("unsupported NameIdMapping version"); throw SerializationError("unsupported NameIdMapping version");
u32 count = readU16(is); u32 count = readU16(is);
m_id_to_name.clear(); m_id_to_name.clear();
m_name_to_id.clear(); m_name_to_id.clear();
for(u32 i=0; i<count; i++){ for (u32 i = 0; i < count; i++) {
u16 id = readU16(is); u16 id = readU16(is);
std::string name = deSerializeString(is); std::string name = deSerializeString(is);
m_id_to_name[id] = name; m_id_to_name[id] = name;
m_name_to_id[name] = id; m_name_to_id[name] = id;
} }
} }

View File

@ -38,47 +38,51 @@ public:
m_name_to_id.clear(); m_name_to_id.clear();
} }
void set(u16 id, const std::string &name){ void set(u16 id, const std::string &name)
{
m_id_to_name[id] = name; m_id_to_name[id] = name;
m_name_to_id[name] = id; m_name_to_id[name] = id;
} }
void removeId(u16 id){ void removeId(u16 id)
{
std::string name; std::string name;
bool found = getName(id, name); bool found = getName(id, name);
if(!found) return; if (!found)
return;
m_id_to_name.erase(id); m_id_to_name.erase(id);
m_name_to_id.erase(name); m_name_to_id.erase(name);
} }
void eraseName(const std::string &name){ void eraseName(const std::string &name)
{
u16 id; u16 id;
bool found = getId(name, id); bool found = getId(name, id);
if(!found) return; if (!found)
return;
m_id_to_name.erase(id); m_id_to_name.erase(id);
m_name_to_id.erase(name); m_name_to_id.erase(name);
} }
bool getName(u16 id, std::string &result) const{ bool getName(u16 id, std::string &result) const
{
UNORDERED_MAP<u16, std::string>::const_iterator i; UNORDERED_MAP<u16, std::string>::const_iterator i;
i = m_id_to_name.find(id); i = m_id_to_name.find(id);
if(i == m_id_to_name.end()) if (i == m_id_to_name.end())
return false; return false;
result = i->second; result = i->second;
return true; return true;
} }
bool getId(const std::string &name, u16 &result) const{ bool getId(const std::string &name, u16 &result) const
{
UNORDERED_MAP<std::string, u16>::const_iterator i; UNORDERED_MAP<std::string, u16>::const_iterator i;
i = m_name_to_id.find(name); i = m_name_to_id.find(name);
if(i == m_name_to_id.end()) if (i == m_name_to_id.end())
return false; return false;
result = i->second; result = i->second;
return true; return true;
} }
u16 size() const{ u16 size() const { return m_id_to_name.size(); }
return m_id_to_name.size();
}
private: private:
UNORDERED_MAP<u16, std::string> m_id_to_name; UNORDERED_MAP<u16, std::string> m_id_to_name;
UNORDERED_MAP<std::string, u16> m_name_to_id; UNORDERED_MAP<std::string, u16> m_name_to_id;
}; };
#endif #endif

View File

@ -34,8 +34,7 @@ void ScriptApiMainMenu::setMainMenuData(MainMenuDataForScript *data)
lua_pushnil(L); lua_pushnil(L);
} }
lua_settable(L, gamedata_idx); lua_settable(L, gamedata_idx);
setboolfield(L, gamedata_idx, "reconnect_requested", setboolfield(L, gamedata_idx, "reconnect_requested", data->reconnect_requested);
data->reconnect_requested);
lua_pop(L, 1); lua_pop(L, 1);
} }
@ -58,7 +57,7 @@ void ScriptApiMainMenu::handleMainMenuEvent(std::string text)
// Call it // Call it
lua_pushstring(L, text.c_str()); lua_pushstring(L, text.c_str());
PCALL_RES(lua_pcall(L, 1, 0, error_handler)); PCALL_RES(lua_pcall(L, 1, 0, error_handler));
lua_pop(L, 1); // Pop error handler lua_pop(L, 1); // Pop error handler
} }
void ScriptApiMainMenu::handleMainMenuButtons(const StringMap &fields) void ScriptApiMainMenu::handleMainMenuButtons(const StringMap &fields)
@ -90,6 +89,5 @@ void ScriptApiMainMenu::handleMainMenuButtons(const StringMap &fields)
// Call it // Call it
PCALL_RES(lua_pcall(L, 1, 0, error_handler)); PCALL_RES(lua_pcall(L, 1, 0, error_handler));
lua_pop(L, 1); // Pop error handler lua_pop(L, 1); // Pop error handler
} }

View File

@ -23,7 +23,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h" #include "nodedef.h"
#include "content_mapnode.h" #include "content_mapnode.h"
class TestMapNode : public TestBase { class TestMapNode : public TestBase
{
public: public:
TestMapNode() { TestManager::registerTestModule(this); } TestMapNode() { TestManager::registerTestModule(this); }
const char *getName() { return "TestMapNode"; } const char *getName() { return "TestMapNode"; }

View File

@ -25,7 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h" #include "nodedef.h"
#include "network/networkprotocol.h" #include "network/networkprotocol.h"
class TestNodeDef : public TestBase { class TestNodeDef : public TestBase
{
public: public:
TestNodeDef() { TestManager::registerTestModule(this); } TestNodeDef() { TestManager::registerTestModule(this); }
const char *getName() { return "TestNodeDef"; } const char *getName() { return "TestNodeDef"; }
@ -55,7 +56,7 @@ void TestNodeDef::testContentFeaturesSerialization()
std::ostringstream os(std::ios::binary); std::ostringstream os(std::ios::binary);
f.serialize(os, LATEST_PROTOCOL_VERSION); f.serialize(os, LATEST_PROTOCOL_VERSION);
//verbosestream<<"Test ContentFeatures size: "<<os.str().size()<<std::endl; // verbosestream<<"Test ContentFeatures size: "<<os.str().size()<<std::endl;
std::istringstream is(os.str(), std::ios::binary); std::istringstream is(os.str(), std::ios::binary);
ContentFeatures f2; ContentFeatures f2;

View File

@ -22,7 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "exceptions.h" #include "exceptions.h"
#include "objdef.h" #include "objdef.h"
class TestObjDef : public TestBase { class TestObjDef : public TestBase
{
public: public:
TestObjDef() { TestManager::registerTestModule(this); } TestObjDef() { TestManager::registerTestModule(this); }
const char *getName() { return "TestObjDef"; } const char *getName() { return "TestObjDef"; }
@ -60,7 +61,6 @@ void TestObjDef::testHandles()
UASSERTEQ(ObjDefHandle, OBJDEF_ORE, type); UASSERTEQ(ObjDefHandle, OBJDEF_ORE, type);
} }
void TestObjDef::testAddGetSetClear() void TestObjDef::testAddGetSetClear()
{ {
ObjDefManager testmgr(NULL, OBJDEF_GENERIC); ObjDefManager testmgr(NULL, OBJDEF_GENERIC);

View File

@ -24,7 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_sao.h" #include "content_sao.h"
#include "server.h" #include "server.h"
class TestPlayer : public TestBase { class TestPlayer : public TestBase
{
public: public:
TestPlayer() { TestManager::registerTestModule(this); } TestPlayer() { TestManager::registerTestModule(this); }
const char *getName() { return "TestPlayer"; } const char *getName() { return "TestPlayer"; }

View File

@ -21,7 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "profiler.h" #include "profiler.h"
class TestProfiler : public TestBase { class TestProfiler : public TestBase
{
public: public:
TestProfiler() { TestManager::registerTestModule(this); } TestProfiler() { TestManager::registerTestModule(this); }
const char *getName() { return "TestProfiler"; } const char *getName() { return "TestProfiler"; }

View File

@ -1,10 +1,8 @@
src/activeobject.h src/activeobject.h
src/ban.cpp src/ban.cpp
src/ban.h
src/camera.cpp src/camera.cpp
src/camera.h src/camera.h
src/cavegen.cpp src/cavegen.cpp
src/cavegen.h
src/cguittfont/CGUITTFont.cpp src/cguittfont/CGUITTFont.cpp
src/cguittfont/CGUITTFont.h src/cguittfont/CGUITTFont.h
src/cguittfont/irrUString.h src/cguittfont/irrUString.h
@ -36,14 +34,11 @@ src/clouds.h
src/collision.cpp src/collision.cpp
src/collision.h src/collision.h
src/config.h src/config.h
src/constants.h
src/content_abm.cpp
src/content_cao.cpp src/content_cao.cpp
src/content_cao.h src/content_cao.h
src/content_cso.cpp src/content_cso.cpp
src/content_cso.h src/content_cso.h
src/content_mapblock.cpp src/content_mapblock.cpp
src/content_mapblock.h
src/content_mapnode.cpp src/content_mapnode.cpp
src/content_nodemeta.cpp src/content_nodemeta.cpp
src/content_nodemeta.h src/content_nodemeta.h
@ -55,7 +50,6 @@ src/craftdef.cpp
src/craftdef.h src/craftdef.h
src/database.cpp src/database.cpp
src/database-dummy.cpp src/database-dummy.cpp
src/database-dummy.h
src/database-leveldb.cpp src/database-leveldb.cpp
src/database-postgresql.cpp src/database-postgresql.cpp
src/database-postgresql.h src/database-postgresql.h
@ -65,7 +59,6 @@ src/daynightratio.h
src/debug.cpp src/debug.cpp
src/debug.h src/debug.h
src/defaultsettings.cpp src/defaultsettings.cpp
src/defaultsettings.h
src/drawscene.cpp src/drawscene.cpp
src/drawscene.h src/drawscene.h
src/dungeongen.cpp src/dungeongen.cpp
@ -73,7 +66,6 @@ src/dungeongen.h
src/emerge.cpp src/emerge.cpp
src/emerge.h src/emerge.h
src/environment.cpp src/environment.cpp
src/environment.h
src/event.h src/event.h
src/event_manager.h src/event_manager.h
src/exceptions.h src/exceptions.h
@ -97,10 +89,8 @@ src/guiFileSelectMenu.cpp
src/guiFormSpecMenu.cpp src/guiFormSpecMenu.cpp
src/guiFormSpecMenu.h src/guiFormSpecMenu.h
src/guiKeyChangeMenu.cpp src/guiKeyChangeMenu.cpp
src/guiKeyChangeMenu.h
src/guiMainMenu.h src/guiMainMenu.h
src/guiPasswordChange.cpp src/guiPasswordChange.cpp
src/guiPasswordChange.h
src/guiscalingfilter.cpp src/guiscalingfilter.cpp
src/guiscalingfilter.h src/guiscalingfilter.h
src/guiTable.cpp src/guiTable.cpp
@ -108,7 +98,6 @@ src/guiTable.h
src/guiVolumeChange.cpp src/guiVolumeChange.cpp
src/guiVolumeChange.h src/guiVolumeChange.h
src/httpfetch.cpp src/httpfetch.cpp
src/httpfetch.h
src/hud.cpp src/hud.cpp
src/hud.h src/hud.h
src/imagefilters.cpp src/imagefilters.cpp
@ -121,19 +110,13 @@ src/inventorymanager.cpp
src/inventorymanager.h src/inventorymanager.h
src/irrlicht_changes/static_text.cpp src/irrlicht_changes/static_text.cpp
src/irrlicht_changes/static_text.h src/irrlicht_changes/static_text.h
src/irrlichttypes_bloated.h
src/irrlichttypes_extrabloated.h
src/irrlichttypes.h src/irrlichttypes.h
src/itemdef.cpp src/itemdef.cpp
src/itemdef.h src/itemdef.h
src/itemgroup.h
src/itemstackmetadata.cpp src/itemstackmetadata.cpp
src/keycode.cpp src/keycode.cpp
src/keycode.h
src/light.cpp src/light.cpp
src/light.h
src/localplayer.cpp src/localplayer.cpp
src/localplayer.h
src/log.cpp src/log.cpp
src/log.h src/log.h
src/main.cpp src/main.cpp
@ -145,14 +128,10 @@ src/mapblock_mesh.h
src/map.cpp src/map.cpp
src/mapgen.cpp src/mapgen.cpp
src/mapgen_flat.cpp src/mapgen_flat.cpp
src/mapgen_flat.h
src/mapgen_fractal.cpp src/mapgen_fractal.cpp
src/mapgen_fractal.h
src/mapgen.h src/mapgen.h
src/mapgen_singlenode.cpp src/mapgen_singlenode.cpp
src/mapgen_singlenode.h
src/mapgen_v5.cpp src/mapgen_v5.cpp
src/mapgen_v5.h
src/mapgen_v6.cpp src/mapgen_v6.cpp
src/mapgen_v6.h src/mapgen_v6.h
src/mapgen_v7.cpp src/mapgen_v7.cpp
@ -168,8 +147,6 @@ src/map_settings_manager.cpp
src/map_settings_manager.h src/map_settings_manager.h
src/mesh.cpp src/mesh.cpp
src/mesh.h src/mesh.h
src/mesh_generator_thread.cpp
src/metadata.cpp
src/metadata.h src/metadata.h
src/mg_biome.cpp src/mg_biome.cpp
src/mg_biome.h src/mg_biome.h
@ -182,11 +159,8 @@ src/mg_schematic.h
src/minimap.cpp src/minimap.cpp
src/minimap.h src/minimap.h
src/modalMenu.h src/modalMenu.h
src/modifiedstate.h
src/mods.cpp src/mods.cpp
src/mods.h src/mods.h
src/nameidmapping.cpp
src/nameidmapping.h
src/network/clientopcodes.cpp src/network/clientopcodes.cpp
src/network/clientopcodes.h src/network/clientopcodes.h
src/network/clientpackethandler.cpp src/network/clientpackethandler.cpp
@ -257,7 +231,6 @@ src/script/cpp_api/s_inventory.cpp
src/script/cpp_api/s_inventory.h src/script/cpp_api/s_inventory.h
src/script/cpp_api/s_item.cpp src/script/cpp_api/s_item.cpp
src/script/cpp_api/s_item.h src/script/cpp_api/s_item.h
src/script/cpp_api/s_mainmenu.cpp
src/script/cpp_api/s_mainmenu.h src/script/cpp_api/s_mainmenu.h
src/script/cpp_api/s_node.cpp src/script/cpp_api/s_node.cpp
src/script/cpp_api/s_node.h src/script/cpp_api/s_node.h
@ -361,14 +334,9 @@ src/unittest/test_filepath.cpp
src/unittest/test.h src/unittest/test.h
src/unittest/test_inventory.cpp src/unittest/test_inventory.cpp
src/unittest/test_keycode.cpp src/unittest/test_keycode.cpp
src/unittest/test_mapnode.cpp
src/unittest/test_map_settings_manager.cpp src/unittest/test_map_settings_manager.cpp
src/unittest/test_nodedef.cpp
src/unittest/test_noderesolver.cpp src/unittest/test_noderesolver.cpp
src/unittest/test_noise.cpp src/unittest/test_noise.cpp
src/unittest/test_objdef.cpp
src/unittest/test_player.cpp
src/unittest/test_profiler.cpp
src/unittest/test_random.cpp src/unittest/test_random.cpp
src/unittest/test_schematic.cpp src/unittest/test_schematic.cpp
src/unittest/test_serialization.cpp src/unittest/test_serialization.cpp