mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
Clang-format: fix some header files and remove them from whitelist
This commit is contained in:
parent
b751c59f43
commit
f7088f69ab
@ -68,15 +68,9 @@ public:
|
|||||||
*ratio = m_day_night_ratio;
|
*ratio = m_day_night_ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setHotbarImage(const std::string &name)
|
void setHotbarImage(const std::string &name) { hud_hotbar_image = name; }
|
||||||
{
|
|
||||||
hud_hotbar_image = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getHotbarImage() const
|
std::string getHotbarImage() const { return hud_hotbar_image; }
|
||||||
{
|
|
||||||
return hud_hotbar_image;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setHotbarSelectedImage(const std::string &name)
|
void setHotbarSelectedImage(const std::string &name)
|
||||||
{
|
{
|
||||||
@ -89,7 +83,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setSky(const video::SColor &bgcolor, const std::string &type,
|
void setSky(const video::SColor &bgcolor, const std::string &type,
|
||||||
const std::vector<std::string> ¶ms)
|
const std::vector<std::string> ¶ms)
|
||||||
{
|
{
|
||||||
m_sky_bgcolor = bgcolor;
|
m_sky_bgcolor = bgcolor;
|
||||||
m_sky_type = type;
|
m_sky_type = type;
|
||||||
@ -97,7 +91,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void getSky(video::SColor *bgcolor, std::string *type,
|
void getSky(video::SColor *bgcolor, std::string *type,
|
||||||
std::vector<std::string> *params)
|
std::vector<std::string> *params)
|
||||||
{
|
{
|
||||||
*bgcolor = m_sky_bgcolor;
|
*bgcolor = m_sky_bgcolor;
|
||||||
*type = m_sky_type;
|
*type = m_sky_type;
|
||||||
@ -130,6 +124,7 @@ public:
|
|||||||
void setDirty(bool dirty) { m_dirty = true; }
|
void setDirty(bool dirty) { m_dirty = true; }
|
||||||
|
|
||||||
u16 protocol_version;
|
u16 protocol_version;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
serialize() writes a bunch of text that can contain
|
serialize() writes a bunch of text that can contain
|
||||||
|
@ -22,7 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
#include "lua_api/l_base.h"
|
#include "lua_api/l_base.h"
|
||||||
|
|
||||||
class ModApiMapgen : public ModApiBase {
|
class ModApiMapgen : public ModApiBase
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
// get_biome_id(biomename)
|
// get_biome_id(biomename)
|
||||||
// returns the biome id used in biomemap
|
// returns the biome id used in biomemap
|
||||||
|
@ -23,12 +23,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
#include "lua_api/l_base.h"
|
#include "lua_api/l_base.h"
|
||||||
|
|
||||||
|
class ModApiSound : public ModApiBase
|
||||||
class ModApiSound: public ModApiBase
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static int l_sound_play(lua_State *L);
|
static int l_sound_play(lua_State *L);
|
||||||
static int l_sound_stop(lua_State *L);
|
static int l_sound_stop(lua_State *L);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize(lua_State *L, int top);
|
static void Initialize(lua_State *L, int top);
|
||||||
};
|
};
|
||||||
|
@ -21,21 +21,21 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#ifndef __L_STORAGE_H__
|
#ifndef __L_STORAGE_H__
|
||||||
#define __L_STORAGE_H__
|
#define __L_STORAGE_H__
|
||||||
|
|
||||||
#include "lua_api/l_base.h"
|
|
||||||
#include "l_metadata.h"
|
#include "l_metadata.h"
|
||||||
|
#include "lua_api/l_base.h"
|
||||||
|
|
||||||
class ModMetadata;
|
class ModMetadata;
|
||||||
|
|
||||||
class ModApiStorage: public ModApiBase
|
class ModApiStorage : public ModApiBase
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
static int l_get_mod_storage(lua_State *L);
|
static int l_get_mod_storage(lua_State *L);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize(lua_State *L, int top);
|
static void Initialize(lua_State *L, int top);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class StorageRef: public MetaDataRef
|
class StorageRef : public MetaDataRef
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ModMetadata *m_object;
|
ModMetadata *m_object;
|
||||||
@ -43,11 +43,12 @@ private:
|
|||||||
static const char className[];
|
static const char className[];
|
||||||
static const luaL_reg methods[];
|
static const luaL_reg methods[];
|
||||||
|
|
||||||
virtual Metadata* getmeta(bool auto_create);
|
virtual Metadata *getmeta(bool auto_create);
|
||||||
virtual void clearMeta();
|
virtual void clearMeta();
|
||||||
|
|
||||||
// garbage collector
|
// garbage collector
|
||||||
static int gc_object(lua_State *L);
|
static int gc_object(lua_State *L);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StorageRef(ModMetadata *object);
|
StorageRef(ModMetadata *object);
|
||||||
~StorageRef() {}
|
~StorageRef() {}
|
||||||
@ -56,7 +57,7 @@ public:
|
|||||||
static void create(lua_State *L, ModMetadata *object);
|
static void create(lua_State *L, ModMetadata *object);
|
||||||
|
|
||||||
static StorageRef *checkobject(lua_State *L, int narg);
|
static StorageRef *checkobject(lua_State *L, int narg);
|
||||||
static ModMetadata* getobject(StorageRef *ref);
|
static ModMetadata *getobject(StorageRef *ref);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __L_STORAGE_H__ */
|
#endif /* __L_STORAGE_H__ */
|
||||||
|
@ -24,7 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
class AsyncEngine;
|
class AsyncEngine;
|
||||||
|
|
||||||
class ModApiUtil : public ModApiBase {
|
class ModApiUtil : public ModApiBase
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
NOTE:
|
NOTE:
|
||||||
@ -112,9 +113,7 @@ public:
|
|||||||
|
|
||||||
static void InitializeClient(lua_State *L, int top);
|
static void InitializeClient(lua_State *L, int top);
|
||||||
|
|
||||||
static void InitializeAsync(AsyncEngine& engine);
|
static void InitializeAsync(AsyncEngine &engine);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* L_UTIL_H_ */
|
#endif /* L_UTIL_H_ */
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#ifndef L_VMANIP_H_
|
#ifndef L_VMANIP_H_
|
||||||
#define L_VMANIP_H_
|
#define L_VMANIP_H_
|
||||||
|
|
||||||
#include "lua_api/l_base.h"
|
|
||||||
#include "irr_v3d.h"
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include "irr_v3d.h"
|
||||||
|
#include "lua_api/l_base.h"
|
||||||
|
|
||||||
class Map;
|
class Map;
|
||||||
class MapBlock;
|
class MapBlock;
|
||||||
@ -31,7 +31,8 @@ class MMVManip;
|
|||||||
/*
|
/*
|
||||||
VoxelManip
|
VoxelManip
|
||||||
*/
|
*/
|
||||||
class LuaVoxelManip : public ModApiBase {
|
class LuaVoxelManip : public ModApiBase
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
std::map<v3s16, MapBlock *> modified_blocks;
|
std::map<v3s16, MapBlock *> modified_blocks;
|
||||||
bool is_mapgen_vm;
|
bool is_mapgen_vm;
|
||||||
|
57
src/sky.h
57
src/sky.h
@ -17,9 +17,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "irrlichttypes_extrabloated.h"
|
|
||||||
#include <ISceneNode.h>
|
#include <ISceneNode.h>
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
|
#include "irrlichttypes_extrabloated.h"
|
||||||
|
|
||||||
#ifndef SKY_HEADER
|
#ifndef SKY_HEADER
|
||||||
#define SKY_HEADER
|
#define SKY_HEADER
|
||||||
@ -34,7 +34,7 @@ class Sky : public scene::ISceneNode
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! constructor
|
//! constructor
|
||||||
Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
|
Sky(scene::ISceneNode *parent, scene::ISceneManager *mgr, s32 id,
|
||||||
ITextureSource *tsrc);
|
ITextureSource *tsrc);
|
||||||
|
|
||||||
virtual void OnRegisterSceneNode();
|
virtual void OnRegisterSceneNode();
|
||||||
@ -42,22 +42,18 @@ public:
|
|||||||
//! renders the node.
|
//! renders the node.
|
||||||
virtual void render();
|
virtual void render();
|
||||||
|
|
||||||
virtual const aabb3f &getBoundingBox() const
|
virtual const aabb3f &getBoundingBox() const { return m_box; }
|
||||||
{ return m_box; }
|
|
||||||
|
|
||||||
// Used by Irrlicht for optimizing rendering
|
// Used by Irrlicht for optimizing rendering
|
||||||
virtual video::SMaterial& getMaterial(u32 i)
|
virtual video::SMaterial &getMaterial(u32 i) { return m_materials[i]; }
|
||||||
{ return m_materials[i]; }
|
|
||||||
|
|
||||||
// Used by Irrlicht for optimizing rendering
|
// Used by Irrlicht for optimizing rendering
|
||||||
virtual u32 getMaterialCount() const
|
virtual u32 getMaterialCount() const { return SKY_MATERIAL_COUNT; }
|
||||||
{ return SKY_MATERIAL_COUNT; }
|
|
||||||
|
|
||||||
void update(float m_time_of_day, float time_brightness,
|
void update(float m_time_of_day, float time_brightness, float direct_brightness,
|
||||||
float direct_brightness, bool sunlight_seen, CameraMode cam_mode,
|
bool sunlight_seen, CameraMode cam_mode, float yaw, float pitch);
|
||||||
float yaw, float pitch);
|
|
||||||
|
|
||||||
float getBrightness(){ return m_brightness; }
|
float getBrightness() { return m_brightness; }
|
||||||
|
|
||||||
const video::SColor &getBgColor() const
|
const video::SColor &getBgColor() const
|
||||||
{
|
{
|
||||||
@ -72,8 +68,9 @@ public:
|
|||||||
bool getCloudsVisible() { return m_clouds_visible && m_visible; }
|
bool getCloudsVisible() { return m_clouds_visible && m_visible; }
|
||||||
const video::SColorf &getCloudColor() { return m_cloudcolor_f; }
|
const video::SColorf &getCloudColor() { return m_cloudcolor_f; }
|
||||||
|
|
||||||
void setVisible(bool visible){ m_visible = visible; }
|
void setVisible(bool visible) { m_visible = visible; }
|
||||||
void setFallbackBgColor(const video::SColor &fallback_bg_color){
|
void setFallbackBgColor(const video::SColor &fallback_bg_color)
|
||||||
|
{
|
||||||
m_fallback_bg_color = fallback_bg_color;
|
m_fallback_bg_color = fallback_bg_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +83,8 @@ private:
|
|||||||
{
|
{
|
||||||
if (!m_sunlight_seen)
|
if (!m_sunlight_seen)
|
||||||
return 0;
|
return 0;
|
||||||
float x = m_time_of_day >= 0.5 ? (1 - m_time_of_day) * 2 : m_time_of_day * 2;
|
float x = m_time_of_day >= 0.5 ? (1 - m_time_of_day) * 2
|
||||||
|
: m_time_of_day * 2;
|
||||||
|
|
||||||
if (x <= 0.3)
|
if (x <= 0.3)
|
||||||
return 0;
|
return 0;
|
||||||
@ -101,19 +99,19 @@ private:
|
|||||||
video::SColor m_mix_scolor(video::SColor col1, video::SColor col2, f32 factor)
|
video::SColor m_mix_scolor(video::SColor col1, video::SColor col2, f32 factor)
|
||||||
{
|
{
|
||||||
video::SColor result = video::SColor(
|
video::SColor result = video::SColor(
|
||||||
col1.getAlpha() * (1 - factor) + col2.getAlpha() * factor,
|
col1.getAlpha() * (1 - factor) + col2.getAlpha() * factor,
|
||||||
col1.getRed() * (1 - factor) + col2.getRed() * factor,
|
col1.getRed() * (1 - factor) + col2.getRed() * factor,
|
||||||
col1.getGreen() * (1 - factor) + col2.getGreen() * factor,
|
col1.getGreen() * (1 - factor) + col2.getGreen() * factor,
|
||||||
col1.getBlue() * (1 - factor) + col2.getBlue() * factor);
|
col1.getBlue() * (1 - factor) + col2.getBlue() * factor);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
video::SColorf m_mix_scolorf(video::SColorf col1, video::SColorf col2, f32 factor)
|
video::SColorf m_mix_scolorf(video::SColorf col1, video::SColorf col2, f32 factor)
|
||||||
{
|
{
|
||||||
video::SColorf result = video::SColorf(
|
video::SColorf result =
|
||||||
col1.r * (1 - factor) + col2.r * factor,
|
video::SColorf(col1.r * (1 - factor) + col2.r * factor,
|
||||||
col1.g * (1 - factor) + col2.g * factor,
|
col1.g * (1 - factor) + col2.g * factor,
|
||||||
col1.b * (1 - factor) + col2.b * factor,
|
col1.b * (1 - factor) + col2.b * factor,
|
||||||
col1.a * (1 - factor) + col2.a * factor);
|
col1.a * (1 - factor) + col2.a * factor);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,12 +132,11 @@ private:
|
|||||||
video::SColor m_skycolor;
|
video::SColor m_skycolor;
|
||||||
video::SColorf m_cloudcolor_f;
|
video::SColorf m_cloudcolor_f;
|
||||||
v3f m_stars[SKY_STAR_COUNT];
|
v3f m_stars[SKY_STAR_COUNT];
|
||||||
video::S3DVertex m_star_vertices[SKY_STAR_COUNT*4];
|
video::S3DVertex m_star_vertices[SKY_STAR_COUNT * 4];
|
||||||
video::ITexture* m_sun_texture;
|
video::ITexture *m_sun_texture;
|
||||||
video::ITexture* m_moon_texture;
|
video::ITexture *m_moon_texture;
|
||||||
video::ITexture* m_sun_tonemap;
|
video::ITexture *m_sun_tonemap;
|
||||||
video::ITexture* m_moon_tonemap;
|
video::ITexture *m_moon_tonemap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
66
src/sound.h
66
src/sound.h
@ -20,9 +20,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#ifndef SOUND_HEADER
|
#ifndef SOUND_HEADER
|
||||||
#define SOUND_HEADER
|
#define SOUND_HEADER
|
||||||
|
|
||||||
#include "irrlichttypes_bloated.h"
|
|
||||||
#include <string>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
#include "irrlichttypes_bloated.h"
|
||||||
|
|
||||||
class OnDemandSoundFetcher
|
class OnDemandSoundFetcher
|
||||||
{
|
{
|
||||||
@ -36,61 +36,68 @@ struct SimpleSoundSpec
|
|||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
float gain;
|
float gain;
|
||||||
SimpleSoundSpec(std::string name="", float gain=1.0):
|
SimpleSoundSpec(std::string name = "", float gain = 1.0) : name(name), gain(gain)
|
||||||
name(name),
|
{
|
||||||
gain(gain)
|
}
|
||||||
{}
|
bool exists() { return name != ""; }
|
||||||
bool exists() {return name != "";}
|
|
||||||
// Serialization intentionally left out
|
// Serialization intentionally left out
|
||||||
};
|
};
|
||||||
|
|
||||||
class ISoundManager
|
class ISoundManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ISoundManager(){}
|
virtual ~ISoundManager() {}
|
||||||
|
|
||||||
// Multiple sounds can be loaded per name; when played, the sound
|
// Multiple sounds can be loaded per name; when played, the sound
|
||||||
// should be chosen randomly from alternatives
|
// should be chosen randomly from alternatives
|
||||||
// Return value determines success/failure
|
// Return value determines success/failure
|
||||||
virtual bool loadSoundFile(const std::string &name,
|
virtual bool loadSoundFile(
|
||||||
const std::string &filepath) = 0;
|
const std::string &name, const std::string &filepath) = 0;
|
||||||
virtual bool loadSoundData(const std::string &name,
|
virtual bool loadSoundData(
|
||||||
const std::string &filedata) = 0;
|
const std::string &name, const std::string &filedata) = 0;
|
||||||
|
|
||||||
virtual void updateListener(v3f pos, v3f vel, v3f at, v3f up) = 0;
|
virtual void updateListener(v3f pos, v3f vel, v3f at, v3f up) = 0;
|
||||||
virtual void setListenerGain(float gain) = 0;
|
virtual void setListenerGain(float gain) = 0;
|
||||||
|
|
||||||
// playSound functions return -1 on failure, otherwise a handle to the
|
// playSound functions return -1 on failure, otherwise a handle to the
|
||||||
// sound. If name=="", call should be ignored without error.
|
// sound. If name=="", call should be ignored without error.
|
||||||
virtual int playSound(const std::string &name, bool loop,
|
virtual int playSound(const std::string &name, bool loop, float volume) = 0;
|
||||||
float volume) = 0;
|
virtual int playSoundAt(
|
||||||
virtual int playSoundAt(const std::string &name, bool loop,
|
const std::string &name, bool loop, float volume, v3f pos) = 0;
|
||||||
float volume, v3f pos) = 0;
|
|
||||||
virtual void stopSound(int sound) = 0;
|
virtual void stopSound(int sound) = 0;
|
||||||
virtual bool soundExists(int sound) = 0;
|
virtual bool soundExists(int sound) = 0;
|
||||||
virtual void updateSoundPosition(int sound, v3f pos) = 0;
|
virtual void updateSoundPosition(int sound, v3f pos) = 0;
|
||||||
|
|
||||||
int playSound(const SimpleSoundSpec &spec, bool loop)
|
int playSound(const SimpleSoundSpec &spec, bool loop)
|
||||||
{ return playSound(spec.name, loop, spec.gain); }
|
{
|
||||||
|
return playSound(spec.name, loop, spec.gain);
|
||||||
|
}
|
||||||
int playSoundAt(const SimpleSoundSpec &spec, bool loop, v3f pos)
|
int playSoundAt(const SimpleSoundSpec &spec, bool loop, v3f pos)
|
||||||
{ return playSoundAt(spec.name, loop, spec.gain, pos); }
|
{
|
||||||
|
return playSoundAt(spec.name, loop, spec.gain, pos);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DummySoundManager: public ISoundManager
|
class DummySoundManager : public ISoundManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool loadSoundFile(const std::string &name,
|
virtual bool loadSoundFile(const std::string &name, const std::string &filepath)
|
||||||
const std::string &filepath) {return true;}
|
{
|
||||||
virtual bool loadSoundData(const std::string &name,
|
return true;
|
||||||
const std::string &filedata) {return true;}
|
}
|
||||||
|
virtual bool loadSoundData(const std::string &name, const std::string &filedata)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
void updateListener(v3f pos, v3f vel, v3f at, v3f up) {}
|
void updateListener(v3f pos, v3f vel, v3f at, v3f up) {}
|
||||||
void setListenerGain(float gain) {}
|
void setListenerGain(float gain) {}
|
||||||
int playSound(const std::string &name, bool loop,
|
int playSound(const std::string &name, bool loop, float volume) { return 0; }
|
||||||
float volume) {return 0;}
|
int playSoundAt(const std::string &name, bool loop, float volume, v3f pos)
|
||||||
int playSoundAt(const std::string &name, bool loop,
|
{
|
||||||
float volume, v3f pos) {return 0;}
|
return 0;
|
||||||
|
}
|
||||||
void stopSound(int sound) {}
|
void stopSound(int sound) {}
|
||||||
bool soundExists(int sound) {return false;}
|
bool soundExists(int sound) { return false; }
|
||||||
void updateSoundPosition(int sound, v3f pos) {}
|
void updateSoundPosition(int sound, v3f pos) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -98,4 +105,3 @@ public:
|
|||||||
extern DummySoundManager dummySoundManager;
|
extern DummySoundManager dummySoundManager;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -30,9 +30,8 @@ static inline std::string hex_encode(const char *data, unsigned int data_size)
|
|||||||
char buf2[3];
|
char buf2[3];
|
||||||
buf2[2] = '\0';
|
buf2[2] = '\0';
|
||||||
|
|
||||||
for(unsigned int i = 0; i < data_size; i++)
|
for (unsigned int i = 0; i < data_size; i++) {
|
||||||
{
|
unsigned char c = (unsigned char)data[i];
|
||||||
unsigned char c = (unsigned char) data[i];
|
|
||||||
buf2[0] = hex_chars[(c & 0xf0) >> 4];
|
buf2[0] = hex_chars[(c & 0xf0) >> 4];
|
||||||
buf2[1] = hex_chars[c & 0x0f];
|
buf2[1] = hex_chars[c & 0x0f];
|
||||||
ret.append(buf2);
|
ret.append(buf2);
|
||||||
@ -43,16 +42,16 @@ static inline std::string hex_encode(const char *data, unsigned int data_size)
|
|||||||
|
|
||||||
static inline std::string hex_encode(const std::string &data)
|
static inline std::string hex_encode(const std::string &data)
|
||||||
{
|
{
|
||||||
return hex_encode(data.c_str(), data.size());
|
return hex_encode(data.c_str(), data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool hex_digit_decode(char hexdigit, unsigned char &value)
|
static inline bool hex_digit_decode(char hexdigit, unsigned char &value)
|
||||||
{
|
{
|
||||||
if(hexdigit >= '0' && hexdigit <= '9')
|
if (hexdigit >= '0' && hexdigit <= '9')
|
||||||
value = hexdigit - '0';
|
value = hexdigit - '0';
|
||||||
else if(hexdigit >= 'A' && hexdigit <= 'F')
|
else if (hexdigit >= 'A' && hexdigit <= 'F')
|
||||||
value = hexdigit - 'A' + 10;
|
value = hexdigit - 'A' + 10;
|
||||||
else if(hexdigit >= 'a' && hexdigit <= 'f')
|
else if (hexdigit >= 'a' && hexdigit <= 'f')
|
||||||
value = hexdigit - 'a' + 10;
|
value = hexdigit - 'a' + 10;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
@ -29,22 +29,23 @@ typedef unsigned int Uint32;
|
|||||||
|
|
||||||
class SHA1
|
class SHA1
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// fields
|
// fields
|
||||||
Uint32 H0, H1, H2, H3, H4;
|
Uint32 H0, H1, H2, H3, H4;
|
||||||
unsigned char bytes[64];
|
unsigned char bytes[64];
|
||||||
int unprocessedBytes;
|
int unprocessedBytes;
|
||||||
Uint32 size;
|
Uint32 size;
|
||||||
void process();
|
void process();
|
||||||
public:
|
|
||||||
SHA1();
|
public:
|
||||||
~SHA1();
|
SHA1();
|
||||||
void addBytes( const char* data, int num );
|
~SHA1();
|
||||||
unsigned char* getDigest();
|
void addBytes(const char *data, int num);
|
||||||
// utility methods
|
unsigned char *getDigest();
|
||||||
static Uint32 lrot( Uint32 x, int bits );
|
// utility methods
|
||||||
static void storeBigEndianUint32( unsigned char* byte, Uint32 num );
|
static Uint32 lrot(Uint32 x, int bits);
|
||||||
static void hexPrinter( unsigned char* c, int l );
|
static void storeBigEndianUint32(unsigned char *byte, Uint32 num);
|
||||||
|
static void hexPrinter(unsigned char *c, int l);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SHA1_HEADER
|
#define SHA1_HEADER
|
||||||
|
101
src/util/sha2.h
101
src/util/sha2.h
@ -57,21 +57,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HEADER_SHA_H
|
#ifndef HEADER_SHA_H
|
||||||
# define HEADER_SHA_H
|
#define HEADER_SHA_H
|
||||||
|
|
||||||
# include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1))
|
#if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1))
|
||||||
# error SHA is disabled.
|
#error SHA is disabled.
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
# if defined(OPENSSL_FIPS)
|
#if defined(OPENSSL_FIPS)
|
||||||
# define FIPS_SHA_SIZE_T size_t
|
#define FIPS_SHA_SIZE_T size_t
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Compat stuff from OpenSSL land
|
Compat stuff from OpenSSL land
|
||||||
@ -79,11 +79,10 @@ extern "C" {
|
|||||||
|
|
||||||
/* crypto.h */
|
/* crypto.h */
|
||||||
|
|
||||||
# define fips_md_init(alg) fips_md_init_ctx(alg, alg)
|
#define fips_md_init(alg) fips_md_init_ctx(alg, alg)
|
||||||
|
|
||||||
# define fips_md_init_ctx(alg, cx) \
|
#define fips_md_init_ctx(alg, cx) int alg##_Init(cx##_CTX *c)
|
||||||
int alg##_Init(cx##_CTX *c)
|
#define fips_cipher_abort(alg) while (0)
|
||||||
# define fips_cipher_abort(alg) while(0)
|
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
@ -92,47 +91,51 @@ extern "C" {
|
|||||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# if defined(__LP32__)
|
#if defined(__LP32__)
|
||||||
# define SHA_LONG unsigned long
|
#define SHA_LONG unsigned long
|
||||||
# elif defined(__ILP64__)
|
#elif defined(__ILP64__)
|
||||||
# define SHA_LONG unsigned long
|
#define SHA_LONG unsigned long
|
||||||
# define SHA_LONG_LOG2 3
|
#define SHA_LONG_LOG2 3
|
||||||
# else
|
#else
|
||||||
# define SHA_LONG unsigned int
|
#define SHA_LONG unsigned int
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
# define SHA_LBLOCK 16
|
#define SHA_LBLOCK 16
|
||||||
# define SHA_CBLOCK (SHA_LBLOCK*4)/* SHA treats input data as a
|
#define SHA_CBLOCK \
|
||||||
* contiguous array of 32 bit wide
|
(SHA_LBLOCK * 4) /* SHA treats input data as a \
|
||||||
* big-endian values. */
|
* contiguous array of 32 bit wide \
|
||||||
# define SHA_LAST_BLOCK (SHA_CBLOCK-8)
|
* big-endian values. */
|
||||||
# define SHA_DIGEST_LENGTH 20
|
#define SHA_LAST_BLOCK (SHA_CBLOCK - 8)
|
||||||
|
#define SHA_DIGEST_LENGTH 20
|
||||||
|
|
||||||
typedef struct SHAstate_st {
|
typedef struct SHAstate_st
|
||||||
SHA_LONG h0, h1, h2, h3, h4;
|
{
|
||||||
SHA_LONG Nl, Nh;
|
SHA_LONG h0, h1, h2, h3, h4;
|
||||||
SHA_LONG data[SHA_LBLOCK];
|
SHA_LONG Nl, Nh;
|
||||||
unsigned int num;
|
SHA_LONG data[SHA_LBLOCK];
|
||||||
|
unsigned int num;
|
||||||
} SHA_CTX;
|
} SHA_CTX;
|
||||||
|
|
||||||
# define SHA256_CBLOCK (SHA_LBLOCK*4)/* SHA-256 treats input data as a
|
#define SHA256_CBLOCK \
|
||||||
* contiguous array of 32 bit wide
|
(SHA_LBLOCK * 4) /* SHA-256 treats input data as a \
|
||||||
* big-endian values. */
|
* contiguous array of 32 bit wide \
|
||||||
# define SHA224_DIGEST_LENGTH 28
|
* big-endian values. */
|
||||||
# define SHA256_DIGEST_LENGTH 32
|
#define SHA224_DIGEST_LENGTH 28
|
||||||
|
#define SHA256_DIGEST_LENGTH 32
|
||||||
|
|
||||||
typedef struct SHA256state_st {
|
typedef struct SHA256state_st
|
||||||
SHA_LONG h[8];
|
{
|
||||||
SHA_LONG Nl, Nh;
|
SHA_LONG h[8];
|
||||||
SHA_LONG data[SHA_LBLOCK];
|
SHA_LONG Nl, Nh;
|
||||||
unsigned int num, md_len;
|
SHA_LONG data[SHA_LBLOCK];
|
||||||
|
unsigned int num, md_len;
|
||||||
} SHA256_CTX;
|
} SHA256_CTX;
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_SHA256
|
#ifndef OPENSSL_NO_SHA256
|
||||||
# ifdef OPENSSL_FIPS
|
#ifdef OPENSSL_FIPS
|
||||||
int private_SHA224_Init(SHA256_CTX *c);
|
int private_SHA224_Init(SHA256_CTX *c);
|
||||||
int private_SHA256_Init(SHA256_CTX *c);
|
int private_SHA256_Init(SHA256_CTX *c);
|
||||||
# endif
|
#endif
|
||||||
int SHA224_Init(SHA256_CTX *c);
|
int SHA224_Init(SHA256_CTX *c);
|
||||||
int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
|
int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
|
||||||
int SHA224_Final(unsigned char *md, SHA256_CTX *c);
|
int SHA224_Final(unsigned char *md, SHA256_CTX *c);
|
||||||
@ -142,12 +145,12 @@ int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
|
|||||||
int SHA256_Final(unsigned char *md, SHA256_CTX *c);
|
int SHA256_Final(unsigned char *md, SHA256_CTX *c);
|
||||||
unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);
|
unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);
|
||||||
void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
|
void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
# define SHA384_DIGEST_LENGTH 48
|
#define SHA384_DIGEST_LENGTH 48
|
||||||
# define SHA512_DIGEST_LENGTH 64
|
#define SHA512_DIGEST_LENGTH 64
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -229,7 +229,6 @@ src/raycast.h
|
|||||||
src/reflowscan.cpp
|
src/reflowscan.cpp
|
||||||
src/reflowscan.h
|
src/reflowscan.h
|
||||||
src/remoteplayer.cpp
|
src/remoteplayer.cpp
|
||||||
src/remoteplayer.h
|
|
||||||
src/rollback.cpp
|
src/rollback.cpp
|
||||||
src/rollback.h
|
src/rollback.h
|
||||||
src/rollback_interface.cpp
|
src/rollback_interface.cpp
|
||||||
@ -291,7 +290,6 @@ src/script/lua_api/l_itemstackmeta.h
|
|||||||
src/script/lua_api/l_mainmenu.cpp
|
src/script/lua_api/l_mainmenu.cpp
|
||||||
src/script/lua_api/l_mainmenu.h
|
src/script/lua_api/l_mainmenu.h
|
||||||
src/script/lua_api/l_mapgen.cpp
|
src/script/lua_api/l_mapgen.cpp
|
||||||
src/script/lua_api/l_mapgen.h
|
|
||||||
src/script/lua_api/l_metadata.cpp
|
src/script/lua_api/l_metadata.cpp
|
||||||
src/script/lua_api/l_metadata.h
|
src/script/lua_api/l_metadata.h
|
||||||
src/script/lua_api/l_minimap.cpp
|
src/script/lua_api/l_minimap.cpp
|
||||||
@ -313,13 +311,9 @@ src/script/lua_api/l_server.h
|
|||||||
src/script/lua_api/l_settings.cpp
|
src/script/lua_api/l_settings.cpp
|
||||||
src/script/lua_api/l_settings.h
|
src/script/lua_api/l_settings.h
|
||||||
src/script/lua_api/l_sound.cpp
|
src/script/lua_api/l_sound.cpp
|
||||||
src/script/lua_api/l_sound.h
|
|
||||||
src/script/lua_api/l_storage.cpp
|
src/script/lua_api/l_storage.cpp
|
||||||
src/script/lua_api/l_storage.h
|
|
||||||
src/script/lua_api/l_util.cpp
|
src/script/lua_api/l_util.cpp
|
||||||
src/script/lua_api/l_util.h
|
|
||||||
src/script/lua_api/l_vmanip.cpp
|
src/script/lua_api/l_vmanip.cpp
|
||||||
src/script/lua_api/l_vmanip.h
|
|
||||||
src/script/scripting_mainmenu.cpp
|
src/script/scripting_mainmenu.cpp
|
||||||
src/script/scripting_mainmenu.h
|
src/script/scripting_mainmenu.h
|
||||||
src/script/serverscripting.cpp
|
src/script/serverscripting.cpp
|
||||||
@ -340,11 +334,9 @@ src/settings_translation_file.cpp
|
|||||||
src/shader.cpp
|
src/shader.cpp
|
||||||
src/shader.h
|
src/shader.h
|
||||||
src/sky.cpp
|
src/sky.cpp
|
||||||
src/sky.h
|
|
||||||
src/socket.cpp
|
src/socket.cpp
|
||||||
src/socket.h
|
src/socket.h
|
||||||
src/sound.cpp
|
src/sound.cpp
|
||||||
src/sound.h
|
|
||||||
src/sound_openal.cpp
|
src/sound_openal.cpp
|
||||||
src/sound_openal.h
|
src/sound_openal.h
|
||||||
src/staticobject.cpp
|
src/staticobject.cpp
|
||||||
@ -411,7 +403,6 @@ src/util/directiontables.cpp
|
|||||||
src/util/directiontables.h
|
src/util/directiontables.h
|
||||||
src/util/enriched_string.cpp
|
src/util/enriched_string.cpp
|
||||||
src/util/enriched_string.h
|
src/util/enriched_string.h
|
||||||
src/util/hex.h
|
|
||||||
src/util/md32_common.h
|
src/util/md32_common.h
|
||||||
src/util/numeric.cpp
|
src/util/numeric.cpp
|
||||||
src/util/numeric.h
|
src/util/numeric.h
|
||||||
@ -421,8 +412,6 @@ src/util/pointer.h
|
|||||||
src/util/serialize.cpp
|
src/util/serialize.cpp
|
||||||
src/util/serialize.h
|
src/util/serialize.h
|
||||||
src/util/sha1.cpp
|
src/util/sha1.cpp
|
||||||
src/util/sha1.h
|
|
||||||
src/util/sha2.h
|
|
||||||
src/util/srp.cpp
|
src/util/srp.cpp
|
||||||
src/util/srp.h
|
src/util/srp.h
|
||||||
src/util/strfnd.h
|
src/util/strfnd.h
|
||||||
|
Loading…
Reference in New Issue
Block a user