u64 is annoying, get rid of it

This commit is contained in:
darkrose 2014-09-17 19:20:03 +10:00
parent c309342a7e
commit 26267e9056
17 changed files with 79 additions and 90 deletions

View File

@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// Convert a privileges value into a human-readable string,
// with each component separated by a comma.
std::string privsToString(u64 privs)
std::string privsToString(uint64_t privs)
{
std::ostringstream os(std::ios_base::binary);
if(privs & PRIV_BUILD)
@ -55,9 +55,9 @@ std::string privsToString(u64 privs)
// Converts a comma-seperated list of privilege values into a
// privileges value. The reverse of privsToString(). Returns
// PRIV_INVALID if there is anything wrong with the input.
u64 stringToPrivs(std::string str)
uint64_t stringToPrivs(std::string str)
{
u64 privs=0;
uint64_t privs=0;
Strfnd f(str);
while(f.atend() == false)
{
@ -135,7 +135,7 @@ void AuthManager::load()
// Read privileges
std::string stringprivs;
std::getline(iss, stringprivs, ':');
u64 privs = stringToPrivs(stringprivs);
uint64_t privs = stringToPrivs(stringprivs);
// Store it
AuthData ad;
@ -231,7 +231,7 @@ void AuthManager::setPassword(const std::string &username,
m_modified = true;
}
u64 AuthManager::getPrivs(const std::string &username)
uint64_t AuthManager::getPrivs(const std::string &username)
{
JMutexAutoLock lock(m_mutex);
@ -243,7 +243,7 @@ u64 AuthManager::getPrivs(const std::string &username)
return n->getValue().privs;
}
void AuthManager::setPrivs(const std::string &username, u64 privs)
void AuthManager::setPrivs(const std::string &username, uint64_t privs)
{
JMutexAutoLock lock(m_mutex);

View File

@ -32,36 +32,36 @@ using namespace jthread;
// of the player, and define things they're allowed to do. See also
// the static methods Player::privsToString and stringToPrivs that
// convert these to human-readable form.
const u64 PRIV_BUILD = 1; // Can build - i.e. modify the world
const u64 PRIV_TELEPORT = 2; // Can teleport
const u64 PRIV_SETTIME = 4; // Can set the time
const u64 PRIV_PRIVS = 8; // Can grant and revoke privileges
const u64 PRIV_SERVER = 16; // Can manage the server (e.g. shutodwn
const uint64_t PRIV_BUILD = 1; // Can build - i.e. modify the world
const uint64_t PRIV_TELEPORT = 2; // Can teleport
const uint64_t PRIV_SETTIME = 4; // Can set the time
const uint64_t PRIV_PRIVS = 8; // Can grant and revoke privileges
const uint64_t PRIV_SERVER = 16; // Can manage the server (e.g. shutodwn
// ,settings)
const u64 PRIV_SHOUT = 32; // Can broadcast chat messages to all
const uint64_t PRIV_SHOUT = 32; // Can broadcast chat messages to all
// players
const u64 PRIV_BAN = 64; // Can ban players
const uint64_t PRIV_BAN = 64; // Can ban players
// Default privileges - these can be overriden for new players using the
// config option "default_privs" - however, this value still applies for
// players that existed before the privileges system was added.
const u64 PRIV_DEFAULT = PRIV_BUILD|PRIV_SHOUT;
const u64 PRIV_ALL = 0x7FFFFFFFFFFFFFFFULL;
const u64 PRIV_INVALID = 0x8000000000000000ULL;
const uint64_t PRIV_DEFAULT = PRIV_BUILD|PRIV_SHOUT;
const uint64_t PRIV_ALL = 0x7FFFFFFFFFFFFFFFULL;
const uint64_t PRIV_INVALID = 0x8000000000000000ULL;
// Convert a privileges value into a human-readable string,
// with each component separated by a comma.
std::string privsToString(u64 privs);
std::string privsToString(uint64_t privs);
// Converts a comma-seperated list of privilege values into a
// privileges value. The reverse of privsToString(). Returns
// PRIV_INVALID if there is anything wrong with the input.
u64 stringToPrivs(std::string str);
uint64_t stringToPrivs(std::string str);
struct AuthData
{
std::string pwd;
u64 privs;
uint64_t privs;
AuthData():
privs(PRIV_DEFAULT)
@ -90,8 +90,8 @@ public:
std::string getPassword(const std::string &username);
void setPassword(const std::string &username,
const std::string &password);
u64 getPrivs(const std::string &username);
void setPrivs(const std::string &username, u64 privs);
uint64_t getPrivs(const std::string &username);
void setPrivs(const std::string &username, uint64_t privs);
bool isModified();
private:
JMutex m_mutex;

View File

@ -297,7 +297,7 @@ public:
(std::wstring)L"<"+name+L"> "+message);
}
u64 getMapSeed(){ return m_map_seed; }
uint64_t getMapSeed(){ return m_map_seed; }
void addUpdateMeshTask(v3s16 blockpos, bool ack_to_server=false);
// Including blocks at appropriate edges
@ -381,7 +381,7 @@ private:
Queue<std::wstring> m_chat_queue;
// The seed returned by the server in TOCLIENT_INIT is stored here
u64 m_map_seed;
uint64_t m_map_seed;
std::string m_password;
bool m_access_denied;

View File

@ -44,7 +44,7 @@ enum ToClientCommand
[0] u16 TOSERVER_INIT
[2] u8 deployed version
[3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
[12] u64 map seed (new as of 2011-02-27)
[12] uint64_t map seed (new as of 2011-02-27)
NOTE: The position in here is deprecated; position is
explicitly sent afterwards

View File

@ -63,18 +63,7 @@ typedef core::vector2d<f32> v2f32;
typedef core::aabbox3d<f32> aabb3f;
// irrlicht 1.8+ has it's own irr::u64
#if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2
#else
#ifdef _MSC_VER
// Windows
typedef unsigned long long u64;
#else
// Posix
#include <stdint.h>
typedef uint64_t u64;
#endif
#endif
#endif

View File

@ -35,7 +35,7 @@ FarMesh::FarMesh(
scene::ISceneNode* parent,
scene::ISceneManager* mgr,
s32 id,
u64 seed,
uint64_t seed,
Client *client
):
scene::ISceneNode(parent, mgr, id),
@ -112,7 +112,7 @@ struct HeightPoint
};
core::map<v2s16, HeightPoint> g_heights;
HeightPoint ground_height(u64 seed, v2s16 p2d)
HeightPoint ground_height(uint64_t seed, v2s16 p2d)
{
core::map<v2s16, HeightPoint>::Node *n = g_heights.find(p2d);
if(n)

View File

@ -38,7 +38,7 @@ public:
scene::ISceneNode* parent,
scene::ISceneManager* mgr,
s32 id,
u64 seed,
uint64_t seed,
Client *client
);
@ -74,7 +74,7 @@ private:
core::aabbox3d<f32> m_box;
float m_cloud_y;
float m_brightness;
u64 m_seed;
uint64_t m_seed;
v2f m_camera_pos;
float m_time;
Client *m_client;

View File

@ -1921,10 +1921,10 @@ ServerMap::ServerMap(std::string savedir):
if (g_settings->get("fixed_map_seed").empty())
{
m_seed = (((u64)(myrand()%0xffff)<<0)
+ ((u64)(myrand()%0xffff)<<16)
+ ((u64)(myrand()%0xffff)<<32)
+ ((u64)(myrand()%0xffff)<<48));
m_seed = (((uint64_t)(myrand()%0xffff)<<0)
+ ((uint64_t)(myrand()%0xffff)<<16)
+ ((uint64_t)(myrand()%0xffff)<<32)
+ ((uint64_t)(myrand()%0xffff)<<48));
}
else
{

View File

@ -432,11 +432,11 @@ public:
bool isSavingEnabled(){ return m_map_saving_enabled; }
u64 getSeed(){ return m_seed; }
uint64_t getSeed(){ return m_seed; }
private:
// Seed used for all kinds of randomness
u64 m_seed;
uint64_t m_seed;
std::string m_savedir;
bool m_map_saving_enabled;

View File

@ -1030,37 +1030,37 @@ static void make_nc(VoxelManipulator &vmanip, PseudoRandom &random)
#define CAVE_NOISE_SCALE 12.0
#define CAVE_NOISE_THRESHOLD (1.5/CAVE_NOISE_SCALE)
NoiseParams get_cave_noise1_params(u64 seed)
NoiseParams get_cave_noise1_params(uint64_t seed)
{
return NoiseParams(NOISE_PERLIN_CONTOUR, seed+52534, 4, 0.5,
50, CAVE_NOISE_SCALE);
}
NoiseParams get_cave_noise2_params(u64 seed)
NoiseParams get_cave_noise2_params(uint64_t seed)
{
return NoiseParams(NOISE_PERLIN_CONTOUR_FLIP_YZ, seed+10325, 4, 0.5,
50, CAVE_NOISE_SCALE);
}
NoiseParams get_ground_noise1_params(u64 seed)
NoiseParams get_ground_noise1_params(uint64_t seed)
{
return NoiseParams(NOISE_PERLIN, seed+983240, 4,
0.55, 80.0, 40.0);
}
NoiseParams get_ground_crumbleness_params(u64 seed)
NoiseParams get_ground_crumbleness_params(uint64_t seed)
{
return NoiseParams(NOISE_PERLIN, seed+34413, 3,
1.3, 20.0, 1.0);
}
NoiseParams get_ground_wetness_params(u64 seed)
NoiseParams get_ground_wetness_params(uint64_t seed)
{
return NoiseParams(NOISE_PERLIN, seed+32474, 4,
1.1, 40.0, 1.0);
}
bool is_cave(u64 seed, v3s16 p)
bool is_cave(uint64_t seed, v3s16 p)
{
double d1 = noise3d_param(get_cave_noise1_params(seed), p.X,p.Y,p.Z);
double d2 = noise3d_param(get_cave_noise2_params(seed), p.X,p.Y,p.Z);
@ -1074,7 +1074,7 @@ bool is_cave(u64 seed, v3s16 p)
and buffered
NOTE: The speed of these actually isn't terrible
*/
bool val_is_ground(double ground_noise1_val, v3s16 p, u64 seed)
bool val_is_ground(double ground_noise1_val, v3s16 p, uint64_t seed)
{
double f = 0.55 + noise2d_perlin(
0.5+(float)p.X/250, 0.5+(float)p.Z/250,
@ -1092,14 +1092,14 @@ bool val_is_ground(double ground_noise1_val, v3s16 p, u64 seed)
/*
Queries whether a position is ground or not.
*/
bool is_ground(u64 seed, v3s16 p)
bool is_ground(uint64_t seed, v3s16 p)
{
double val1 = noise3d_param(get_ground_noise1_params(seed), p.X,p.Y,p.Z);
return val_is_ground(val1, p, seed);
}
// Amount of trees per area in nodes
double tree_amount_2d(u64 seed, v2s16 p)
double tree_amount_2d(uint64_t seed, v2s16 p)
{
double noise = noise2d_perlin(
0.5+(float)p.X/125, 0.5+(float)p.Y/125,
@ -1111,7 +1111,7 @@ double tree_amount_2d(u64 seed, v2s16 p)
return 0.04 * (noise-zeroval) / (1.0-zeroval);
}
double surface_humidity_2d(u64 seed, v2s16 p)
double surface_humidity_2d(uint64_t seed, v2s16 p)
{
double noise = noise2d_perlin(
0.5+(float)p.X/500, 0.5+(float)p.Y/500,
@ -1124,7 +1124,7 @@ double surface_humidity_2d(u64 seed, v2s16 p)
return noise;
}
double largestone_amount_2d(u64 seed, v2s16 p)
double largestone_amount_2d(uint64_t seed, v2s16 p)
{
double noise = noise2d_perlin(
0.5+(float)p.X/250, 0.5+(float)p.Y/250,
@ -1139,7 +1139,7 @@ double largestone_amount_2d(u64 seed, v2s16 p)
/*
Incrementally find ground level from 3d noise
*/
s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision)
s16 find_ground_level_from_noise(uint64_t seed, v2s16 p2d, s16 precision)
{
// Start a bit fuzzy to make averaging lower precision values
// more useful
@ -1187,9 +1187,9 @@ s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision)
return level;
}
double get_sector_average_ground_level(u64 seed, v2s16 sectorpos, double p=4);
double get_sector_average_ground_level(uint64_t seed, v2s16 sectorpos, double p=4);
double get_sector_average_ground_level(u64 seed, v2s16 sectorpos, double p)
double get_sector_average_ground_level(uint64_t seed, v2s16 sectorpos, double p)
{
v2s16 node_min = sectorpos*MAP_BLOCKSIZE;
v2s16 node_max = (sectorpos+v2s16(1,1))*MAP_BLOCKSIZE-v2s16(1,1);
@ -1208,9 +1208,9 @@ double get_sector_average_ground_level(u64 seed, v2s16 sectorpos, double p)
return a;
}
double get_sector_maximum_ground_level(u64 seed, v2s16 sectorpos, double p=4);
double get_sector_maximum_ground_level(uint64_t seed, v2s16 sectorpos, double p=4);
double get_sector_maximum_ground_level(u64 seed, v2s16 sectorpos, double p)
double get_sector_maximum_ground_level(uint64_t seed, v2s16 sectorpos, double p)
{
v2s16 node_min = sectorpos*MAP_BLOCKSIZE;
v2s16 node_max = (sectorpos+v2s16(1,1))*MAP_BLOCKSIZE-v2s16(1,1);
@ -1239,9 +1239,9 @@ double get_sector_maximum_ground_level(u64 seed, v2s16 sectorpos, double p)
return a;
}
double get_sector_minimum_ground_level(u64 seed, v2s16 sectorpos, double p=4);
double get_sector_minimum_ground_level(uint64_t seed, v2s16 sectorpos, double p=4);
double get_sector_minimum_ground_level(u64 seed, v2s16 sectorpos, double p)
double get_sector_minimum_ground_level(uint64_t seed, v2s16 sectorpos, double p)
{
v2s16 node_min = sectorpos*MAP_BLOCKSIZE;
v2s16 node_max = (sectorpos+v2s16(1,1))*MAP_BLOCKSIZE-v2s16(1,1);
@ -1270,7 +1270,7 @@ double get_sector_minimum_ground_level(u64 seed, v2s16 sectorpos, double p)
return a;
}
bool block_is_underground(u64 seed, v3s16 blockpos)
bool block_is_underground(uint64_t seed, v3s16 blockpos)
{
s16 minimum_groundlevel = (s16)get_sector_minimum_ground_level(
seed, v2s16(blockpos.X, blockpos.Z));
@ -1281,7 +1281,7 @@ bool block_is_underground(u64 seed, v3s16 blockpos)
return false;
}
bool get_have_sand(u64 seed, v2s16 p2d)
bool get_have_sand(uint64_t seed, v2s16 p2d)
{
// Determine whether to have sand here
double sandnoise = noise2d_perlin(

View File

@ -32,7 +32,7 @@ namespace mapgen
{
bool no_op;
ManualMapVoxelManipulator *vmanip;
u64 seed;
uint64_t seed;
v3s16 blockpos;
UniqueQueue<v3s16> transforming_liquid;
@ -41,10 +41,10 @@ namespace mapgen
};
// Finds precise ground level at any position
s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
s16 find_ground_level_from_noise(uint64_t seed, v2s16 p2d, s16 precision);
// Find out if block is completely underground
bool block_is_underground(u64 seed, v3s16 blockpos);
bool block_is_underground(uint64_t seed, v3s16 blockpos);
// Main map generation routine
void make_block(BlockMakeData *data);
@ -63,8 +63,8 @@ namespace mapgen
/*
These are used by FarMesh
*/
bool get_have_sand(u64 seed, v2s16 p2d);
double tree_amount_2d(u64 seed, v2s16 p);
bool get_have_sand(uint64_t seed, v2s16 p2d);
double tree_amount_2d(uint64_t seed, v2s16 p);
}; // namespace mapgen

View File

@ -4340,7 +4340,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
// Local player gets all privileges regardless of
// what's set on their account.
u64 privs = getPlayerPrivs(player);
uint64_t privs = getPlayerPrivs(player);
// Parse commands
if(message[0] == L'/')
@ -5716,7 +5716,7 @@ void Server::handlePeerChanges()
}
}
u64 Server::getPlayerPrivs(Player *player)
uint64_t Server::getPlayerPrivs(Player *player)
{
if(player==NULL)
return 0;

View File

@ -426,7 +426,7 @@ public:
// Envlock and conlock should be locked when calling this
void SendMovePlayer(Player *player);
u64 getPlayerAuthPrivs(const std::string &name)
uint64_t getPlayerAuthPrivs(const std::string &name)
{
try{
return m_authmanager.getPrivs(name);
@ -438,7 +438,7 @@ public:
}
}
void setPlayerAuthPrivs(const std::string &name, u64 privs)
void setPlayerAuthPrivs(const std::string &name, uint64_t privs)
{
try{
return m_authmanager.setPrivs(name, privs);
@ -590,7 +590,7 @@ private:
void handlePeerChange(PeerChange &c);
void handlePeerChanges();
u64 getPlayerPrivs(Player *player);
uint64_t getPlayerPrivs(Player *player);
/*
Variables

View File

@ -76,7 +76,7 @@ void cmd_grantrevoke(std::wostringstream &os,
return;
}
u64 newprivs = stringToPrivs(wide_to_narrow(ctx->parms[2]));
uint64_t newprivs = stringToPrivs(wide_to_narrow(ctx->parms[2]));
if(newprivs == PRIV_INVALID)
{
os<<L"-!- Invalid privileges specified";
@ -91,7 +91,7 @@ void cmd_grantrevoke(std::wostringstream &os,
}
std::string playername = wide_to_narrow(ctx->parms[1]);
u64 privs = ctx->server->getPlayerAuthPrivs(playername);
uint64_t privs = ctx->server->getPlayerAuthPrivs(playername);
if(ctx->parms[0] == L"grant"){
privs |= newprivs;
@ -350,7 +350,7 @@ void cmd_setpassword(std::wostringstream &os,
void cmd_help(std::wostringstream &os,
ServerCommandContext *ctx)
{
u64 privs = ctx->privs;
uint64_t privs = ctx->privs;
if (ctx->parms.size() > 1) {
if ((privs&PRIV_SERVER) == PRIV_SERVER) {

View File

@ -38,7 +38,7 @@ struct ServerCommandContext
Player* player;
// Effective privs for the player, which may be different to their
// stored ones - e.g. if they are named in the config as an admin.
u64 privs;
uint64_t privs;
u32 flags;
ServerCommandContext(
@ -47,7 +47,7 @@ struct ServerCommandContext
Server* server,
ServerEnvironment *env,
Player* player,
u64 privs)
uint64_t privs)
: parms(parms), paramstring(paramstring),
server(server), env(env), player(player), privs(privs)
{

View File

@ -510,9 +510,9 @@ public:
return value;
}
u64 getU64(std::string name)
uint64_t getU64(std::string name)
{
u64 value = 0;
uint64_t value = 0;
std::string s = get(name);
std::istringstream ss(s);
ss>>value;
@ -551,7 +551,7 @@ public:
set(name, os.str());
}
void setU64(std::string name, u64 value)
void setU64(std::string name, uint64_t value)
{
std::ostringstream os;
os<<value;

View File

@ -45,7 +45,7 @@ extern const v3s16 g_26dirs[26];
// 26th is (0,0,0)
extern const v3s16 g_27dirs[27];
inline void writeU64(u8 *data, u64 i)
inline void writeU64(u8 *data, uint64_t i)
{
data[0] = ((i>>56)&0xff);
data[1] = ((i>>48)&0xff);
@ -76,12 +76,12 @@ inline void writeU8(u8 *data, u8 i)
data[0] = ((i>> 0)&0xff);
}
inline u64 readU64(u8 *data)
inline uint64_t readU64(u8 *data)
{
return ((u64)data[0]<<56) | ((u64)data[1]<<48)
| ((u64)data[2]<<40) | ((u64)data[3]<<32)
| ((u64)data[4]<<24) | ((u64)data[5]<<16)
| ((u64)data[6]<<8) | ((u64)data[7]<<0);
return ((uint64_t)data[0]<<56) | ((uint64_t)data[1]<<48)
| ((uint64_t)data[2]<<40) | ((uint64_t)data[3]<<32)
| ((uint64_t)data[4]<<24) | ((uint64_t)data[5]<<16)
| ((uint64_t)data[6]<<8) | ((uint64_t)data[7]<<0);
}
inline u32 readU32(u8 *data)