Make flag strings clear specified flag with 'no' prefix

Remove flagmask field from set_mapgen_params table
Add small bits of needed documentation
This commit is contained in:
kwolekr 2014-02-08 17:50:26 -05:00
parent f4f98c9550
commit 83bafbe08b
19 changed files with 122 additions and 78 deletions

@ -1360,11 +1360,10 @@ minetest.get_mapgen_object(objectname)
minetest.set_mapgen_params(MapgenParams) minetest.set_mapgen_params(MapgenParams)
^ Set map generation parameters ^ Set map generation parameters
^ Function cannot be called after the registration period; only initialization and on_mapgen_init ^ Function cannot be called after the registration period; only initialization and on_mapgen_init
^ Takes a table as an argument with the fields mgname, seed, water_level, flags, and flagmask. ^ Takes a table as an argument with the fields mgname, seed, water_level, and flags.
^ Leave field unset to leave that parameter unchanged ^ Leave field unset to leave that parameter unchanged
^ flagmask field must be set to all mapgen flags that are being modified ^ flags contains a comma-delimited string of flags to set, or if the prefix "no" is attached, clears instead.
^ flags contains only the flags that are being set ^ flags is in the same format and has the same options as 'mg_flags' in minetest.conf
^ flags and flagmask are in the same format and have the same options as 'mgflags' in minetest.conf
minetest.clear_objects() minetest.clear_objects()
^ clear all objects in the environments ^ clear all objects in the environments
minetest.line_of_sight(pos1, pos2, stepsize) -> true/false, pos minetest.line_of_sight(pos1, pos2, stepsize) -> true/false, pos

@ -381,10 +381,12 @@
#water_level = 1 #water_level = 1
# Size of chunks to be generated. # Size of chunks to be generated.
#chunksize = 5 #chunksize = 5
# Map generation attributes. Currently supported: trees, caves, flat, dungeons, nolight # Map generation attributes. Currently supported: trees, caves, flat, dungeons, light
# Flags that are not specified in the flag string are not modified from the default.
# To explicitly turn off a flag, prepend "no" to the beginning, e.g. nolight.
#mg_flags = trees, caves #mg_flags = trees, caves
# Map generation attributes specific to Mapgen V6. Currently supported: v6_biome_blend, v6_jungles, v6_nomudflow # Map generation attributes specific to Mapgen V6. Currently supported: biomeblend, jungles, mudflow
#mgv6_spflags = v6_biome_blend #mgv6_spflags = biomeblend
# How large deserts and beaches are # How large deserts and beaches are
#mgv6_freq_desert = 0.45 #mgv6_freq_desert = 0.45
#mgv6_freq_beach = 0.15 #mgv6_freq_beach = 0.15
@ -402,7 +404,7 @@
#mgv6_np_trees = 0, 1, (125, 125, 125), 2, 4, 0.66 #mgv6_np_trees = 0, 1, (125, 125, 125), 2, 4, 0.66
#mgv6_np_apple_trees = 0, 1, (100, 100, 100), 342902, 3, 0.45 #mgv6_np_apple_trees = 0, 1, (100, 100, 100), 342902, 3, 0.45
#mgv7_spflags = v7_mountains, v7_ridges #mgv7_spflags = mountains, ridges
#mgv7_np_terrain = 10, 12, (350, 350, 350), 82341, 5, 0.6 #mgv7_np_terrain = 10, 12, (350, 350, 350), 82341, 5, 0.6
#mgv7_np_bgroup = 0.5, 0.3125, (350, 350, 350), 5923, 2, 0.6 #mgv7_np_bgroup = 0.5, 0.3125, (350, 350, 350), 5923, 2, 0.6
#mgv7_np_heat = 25, 50, (500, 500, 500), 35293, 1, 0 #mgv7_np_heat = 25, 50, (500, 500, 500), 35293, 1, 0

@ -249,7 +249,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("mg_name", "v6"); settings->setDefault("mg_name", "v6");
settings->setDefault("water_level", "1"); settings->setDefault("water_level", "1");
settings->setDefault("chunksize", "5"); settings->setDefault("chunksize", "5");
settings->setDefault("mg_flags", "trees, caves"); settings->setDefault("mg_flags", "");
settings->setDefault("mgmath_generator", "mandelbox"); settings->setDefault("mgmath_generator", "mandelbox");

@ -372,7 +372,6 @@ void EmergeManager::loadParamsFromSettings(Settings *settings) {
params.sparams = createMapgenParams(params.mg_name); params.sparams = createMapgenParams(params.mg_name);
if (params.sparams) if (params.sparams)
params.sparams->readParams(settings); params.sparams->readParams(settings);
} }
@ -381,7 +380,7 @@ void EmergeManager::saveParamsToSettings(Settings *settings) {
settings->setU64("seed", params.seed); settings->setU64("seed", params.seed);
settings->setS16("water_level", params.water_level); settings->setS16("water_level", params.water_level);
settings->setS16("chunksize", params.chunksize); settings->setS16("chunksize", params.chunksize);
settings->setFlagStr("mg_flags", params.flags, flagdesc_mapgen); settings->setFlagStr("mg_flags", params.flags, flagdesc_mapgen, (u32)-1);
if (params.sparams) if (params.sparams)
params.sparams->writeParams(settings); params.sparams->writeParams(settings);

@ -45,7 +45,7 @@ FlagDesc flagdesc_mapgen[] = {
{"caves", MG_CAVES}, {"caves", MG_CAVES},
{"dungeons", MG_DUNGEONS}, {"dungeons", MG_DUNGEONS},
{"flat", MG_FLAT}, {"flat", MG_FLAT},
{"nolight", MG_NOLIGHT}, {"light", MG_LIGHT},
{NULL, 0} {NULL, 0}
}; };

@ -35,7 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define MG_CAVES 0x02 #define MG_CAVES 0x02
#define MG_DUNGEONS 0x04 #define MG_DUNGEONS 0x04
#define MG_FLAT 0x08 #define MG_FLAT 0x08
#define MG_NOLIGHT 0x10 #define MG_LIGHT 0x10
/////////////////// Ore generation flags /////////////////// Ore generation flags
// Use absolute value of height to determine ore placement // Use absolute value of height to determine ore placement
@ -114,11 +114,11 @@ struct MapgenParams {
MapgenSpecificParams *sparams; MapgenSpecificParams *sparams;
MapgenParams() { MapgenParams() {
mg_name = "v6"; mg_name = DEFAULT_MAPGEN;
seed = 0; seed = 0;
water_level = 1; water_level = 1;
chunksize = 5; chunksize = 5;
flags = MG_TREES | MG_CAVES; flags = MG_TREES | MG_CAVES | MG_LIGHT;
sparams = NULL; sparams = NULL;
} }
}; };

@ -169,7 +169,7 @@ void MapgenMathParams::writeParams(Settings *settings) {
MapgenMath::MapgenMath(int mapgenid, MapgenParams *params_, EmergeManager *emerge) : MapgenV7(mapgenid, params_, emerge) { MapgenMath::MapgenMath(int mapgenid, MapgenParams *params_, EmergeManager *emerge) : MapgenV7(mapgenid, params_, emerge) {
mg_params = (MapgenMathParams *)params_; mg_params = (MapgenMathParams *)params_;
this->flags |= MG_NOLIGHT; this->flags &= ~MG_LIGHT;
Json::Value & params = mg_params->params; Json::Value & params = mg_params->params;
invert = params["invert"].empty() ? 1 : params["invert"].asBool(); //params["invert"].empty()?1:params["invert"].asBool(); invert = params["invert"].empty() ? 1 : params["invert"].asBool(); //params["invert"].empty()?1:params["invert"].asBool();

@ -89,7 +89,7 @@ void MapgenSinglenode::makeChunk(BlockMakeData *data) {
updateLiquid(&data->transforming_liquid, node_min, node_max); updateLiquid(&data->transforming_liquid, node_min, node_max);
// Calculate lighting // Calculate lighting
if (!(flags & MG_NOLIGHT)) if (flags & MG_LIGHT)
calcLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE, calcLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE); node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE);

@ -38,9 +38,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapgen_v6.h" #include "mapgen_v6.h"
FlagDesc flagdesc_mapgen_v6[] = { FlagDesc flagdesc_mapgen_v6[] = {
{"v6_jungles", MGV6_JUNGLES}, {"jungles", MGV6_JUNGLES},
{"v6_biome_blend", MGV6_BIOME_BLEND}, {"biomeblend", MGV6_BIOMEBLEND},
{"v6_nomudflow", MGV6_NOMUDFLOW}, {"mudflow", MGV6_MUDFLOW},
{NULL, 0} {NULL, 0}
}; };
@ -93,7 +93,7 @@ MapgenV6::~MapgenV6() {
MapgenV6Params::MapgenV6Params() { MapgenV6Params::MapgenV6Params() {
spflags = MGV6_BIOME_BLEND; spflags = MGV6_BIOMEBLEND | MGV6_MUDFLOW;
freq_desert = 0.45; freq_desert = 0.45;
freq_beach = 0.15; freq_beach = 0.15;
@ -131,7 +131,7 @@ void MapgenV6Params::readParams(Settings *settings) {
void MapgenV6Params::writeParams(Settings *settings) { void MapgenV6Params::writeParams(Settings *settings) {
settings->setFlagStr("mgv6_spflags", spflags, flagdesc_mapgen_v6); settings->setFlagStr("mgv6_spflags", spflags, flagdesc_mapgen_v6, (u32)-1);
settings->setFloat("mgv6_freq_desert", freq_desert); settings->setFloat("mgv6_freq_desert", freq_desert);
settings->setFloat("mgv6_freq_beach", freq_beach); settings->setFloat("mgv6_freq_beach", freq_beach);
@ -365,7 +365,7 @@ BiomeType MapgenV6::getBiome(int index, v2s16 p)
if (d > freq_desert) if (d > freq_desert)
return BT_DESERT; return BT_DESERT;
if ((spflags & MGV6_BIOME_BLEND) && if ((spflags & MGV6_BIOMEBLEND) &&
(d > freq_desert - 0.10) && (d > freq_desert - 0.10) &&
((noise2d(p.X, p.Y, seed) + 1.0) > (freq_desert - d) * 20.0)) ((noise2d(p.X, p.Y, seed) + 1.0) > (freq_desert - d) * 20.0))
return BT_DESERT; return BT_DESERT;
@ -481,7 +481,7 @@ void MapgenV6::makeChunk(BlockMakeData *data) {
addDirtGravelBlobs(); addDirtGravelBlobs();
// Flow mud away from steep edges // Flow mud away from steep edges
if (!(spflags & MGV6_NOMUDFLOW)) if (spflags & MGV6_MUDFLOW)
flowMud(mudflow_minpos, mudflow_maxpos); flowMud(mudflow_minpos, mudflow_maxpos);
} }
@ -543,7 +543,7 @@ void MapgenV6::makeChunk(BlockMakeData *data) {
} }
// Calculate lighting // Calculate lighting
if (!(flags & MG_NOLIGHT)) if (flags & MG_LIGHT)
calcLighting(node_min - v3s16(1, 1, 1) * MAP_BLOCKSIZE, calcLighting(node_min - v3s16(1, 1, 1) * MAP_BLOCKSIZE,
node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE); node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE);

@ -26,8 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/////////////////// Mapgen V6 flags /////////////////// Mapgen V6 flags
#define MGV6_JUNGLES 0x01 #define MGV6_JUNGLES 0x01
#define MGV6_BIOME_BLEND 0x02 #define MGV6_BIOMEBLEND 0x02
#define MGV6_NOMUDFLOW 0x04 #define MGV6_MUDFLOW 0x04
extern FlagDesc flagdesc_mapgen_v6[]; extern FlagDesc flagdesc_mapgen_v6[];

@ -39,8 +39,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
FlagDesc flagdesc_mapgen_v7[] = { FlagDesc flagdesc_mapgen_v7[] = {
{"v7_mountains", MGV7_MOUNTAINS}, {"mountains", MGV7_MOUNTAINS},
{"v7_ridges", MGV7_RIDGES}, {"ridges", MGV7_RIDGES},
{NULL, 0} {NULL, 0}
}; };
@ -55,7 +55,7 @@ MapgenV7::MapgenV7(int mapgenid, MapgenParams *params, EmergeManager *emerge) {
this->seed = (int)params->seed; this->seed = (int)params->seed;
this->water_level = params->water_level; this->water_level = params->water_level;
this->flags = params->flags | MGV7_MOUNTAINS | MGV7_RIDGES; this->flags = params->flags;
this->gennotify = emerge->gennotify; this->gennotify = emerge->gennotify;
this->csize = v3s16(1, 1, 1) * params->chunksize * MAP_BLOCKSIZE; this->csize = v3s16(1, 1, 1) * params->chunksize * MAP_BLOCKSIZE;
@ -141,7 +141,7 @@ void MapgenV7Params::readParams(Settings *settings) {
void MapgenV7Params::writeParams(Settings *settings) { void MapgenV7Params::writeParams(Settings *settings) {
settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7); settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7, (u32)-1);
settings->setNoiseParams("mgv7_np_terrain_base", np_terrain_base); settings->setNoiseParams("mgv7_np_terrain_base", np_terrain_base);
settings->setNoiseParams("mgv7_np_terrain_alt", np_terrain_alt); settings->setNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
@ -262,7 +262,7 @@ void MapgenV7::makeChunk(BlockMakeData *data) {
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max); updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
if (!(flags & MG_NOLIGHT)) if (flags & MG_LIGHT)
calcLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE, calcLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE); node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE);
//setLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE, //setLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,

@ -87,6 +87,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define strtoll(x, y, z) _strtoi64(x, y, z) #define strtoll(x, y, z) _strtoi64(x, y, z)
#define strtoull(x, y, z) _strtoui64(x, y, z) #define strtoull(x, y, z) _strtoui64(x, y, z)
#define strcasecmp(x, y) stricmp(x, y) #define strcasecmp(x, y) stricmp(x, y)
#define strncasecmp(x, y, n) strnicmp(x, y, n)
#else #else
#define ALIGNOF(x) __alignof__(x) #define ALIGNOF(x) __alignof__(x)
#endif #endif

@ -839,12 +839,11 @@ void push_hit_params(lua_State *L,const HitParams &params)
} }
/******************************************************************************/ /******************************************************************************/
u32 getflagsfield(lua_State *L, int table, u32 getflagsfield(lua_State *L, int table, const char *fieldname,
const char *fieldname, FlagDesc *flagdesc) { FlagDesc *flagdesc, u32 *flagmask)
std::string flagstring; {
std::string flagstring = getstringfield_default(L, table, fieldname, "");
flagstring = getstringfield_default(L, table, fieldname, ""); return readFlagString(flagstring, flagdesc, flagmask);
return readFlagString(flagstring, flagdesc);
} }
/******************************************************************************/ /******************************************************************************/

@ -121,7 +121,7 @@ int getenumfield (lua_State *L,
u32 getflagsfield (lua_State *L, int table, u32 getflagsfield (lua_State *L, int table,
const char *fieldname, const char *fieldname,
FlagDesc *flagdesc); FlagDesc *flagdesc, u32 *flagmask);
void push_items (lua_State *L, void push_items (lua_State *L,
const std::vector<ItemStack> &items); const std::vector<ItemStack> &items);

@ -78,7 +78,8 @@ void ScriptApiEnv::environment_OnMapgenInit(MapgenParams *mgparams)
lua_pushinteger(L, mgparams->water_level); lua_pushinteger(L, mgparams->water_level);
lua_setfield(L, -2, "water_level"); lua_setfield(L, -2, "water_level");
std::string flagstr = writeFlagString(mgparams->flags, flagdesc_mapgen); std::string flagstr = writeFlagString(mgparams->flags,
flagdesc_mapgen, (u32)-1);
lua_pushstring(L, flagstr.c_str()); lua_pushstring(L, flagstr.c_str());
lua_setfield(L, -2, "flags"); lua_setfield(L, -2, "flags");

@ -210,13 +210,20 @@ int ModApiMapgen::l_set_mapgen_params(lua_State *L)
lua_getfield(L, 1, "flagmask"); lua_getfield(L, 1, "flagmask");
if (lua_isstring(L, -1)) { if (lua_isstring(L, -1)) {
flagstr = lua_tostring(L, -1); flagstr = lua_tostring(L, -1);
emerge->params.flags &= ~readFlagString(flagstr, flagdesc_mapgen); emerge->params.flags &= ~readFlagString(flagstr, flagdesc_mapgen, NULL);
errorstream << "set_mapgen_params(): flagmask field is deprecated, "
"see lua_api.txt" << std::endl;
} }
lua_getfield(L, 1, "flags"); lua_getfield(L, 1, "flags");
if (lua_isstring(L, -1)) { if (lua_isstring(L, -1)) {
u32 flags, flagmask;
flagstr = lua_tostring(L, -1); flagstr = lua_tostring(L, -1);
emerge->params.flags |= readFlagString(flagstr, flagdesc_mapgen); flags = readFlagString(flagstr, flagdesc_mapgen, &flagmask);
emerge->params.flags &= ~flagmask;
emerge->params.flags |= flags;
} }
return 0; return 0;
@ -227,7 +234,8 @@ int ModApiMapgen::l_set_gen_notify(lua_State *L)
{ {
if (lua_isstring(L, 1)) { if (lua_isstring(L, 1)) {
EmergeManager *emerge = getServer(L)->getEmergeManager(); EmergeManager *emerge = getServer(L)->getEmergeManager();
emerge->gennotify = readFlagString(lua_tostring(L, 1), flagdesc_gennotify); emerge->gennotify = readFlagString(lua_tostring(L, 1),
flagdesc_gennotify, NULL);
} }
return 0; return 0;
} }
@ -371,7 +379,8 @@ int ModApiMapgen::l_register_decoration(lua_State *L)
break; } break; }
case DECO_SCHEMATIC: { case DECO_SCHEMATIC: {
DecoSchematic *dschem = (DecoSchematic *)deco; DecoSchematic *dschem = (DecoSchematic *)deco;
dschem->flags = getflagsfield(L, index, "flags", flagdesc_deco_schematic); dschem->flags = getflagsfield(L, index, "flags",
flagdesc_deco_schematic, NULL);
dschem->rotation = (Rotation)getenumfield(L, index, dschem->rotation = (Rotation)getenumfield(L, index,
"rotation", es_Rotation, ROTATE_0); "rotation", es_Rotation, ROTATE_0);
@ -445,7 +454,7 @@ int ModApiMapgen::l_register_ore(lua_State *L)
ore->clust_size = getintfield_default(L, index, "clust_size", 0); ore->clust_size = getintfield_default(L, index, "clust_size", 0);
ore->height_min = getintfield_default(L, index, "height_min", 0); ore->height_min = getintfield_default(L, index, "height_min", 0);
ore->height_max = getintfield_default(L, index, "height_max", 0); ore->height_max = getintfield_default(L, index, "height_max", 0);
ore->flags = getflagsfield(L, index, "flags", flagdesc_ore); ore->flags = getflagsfield(L, index, "flags", flagdesc_ore, NULL);
ore->nthresh = getfloatfield_default(L, index, "noise_threshhold", 0.); ore->nthresh = getfloatfield_default(L, index, "noise_threshhold", 0.);
lua_getfield(L, index, "wherein"); lua_getfield(L, index, "wherein");

@ -572,12 +572,15 @@ public:
return value; return value;
} }
u32 getFlagStr(std::string name, FlagDesc *flagdesc) u32 getFlagStr(std::string name, FlagDesc *flagdesc, u32 *flagmask)
{ {
std::string val = get(name); std::string val = get(name);
return (isdigit(val[0])) ? stoi(val) : readFlagString(val, flagdesc); return (isdigit(val[0])) ? stoi(val) :
readFlagString(val, flagdesc, flagmask);
} }
// N.B. if getStruct() is used to read a non-POD aggregate type,
// the behavior is undefined.
bool getStruct(std::string name, std::string format, void *out, size_t olen) bool getStruct(std::string name, std::string format, void *out, size_t olen)
{ {
size_t len = olen; size_t len = olen;
@ -755,10 +758,19 @@ fail:
} }
} }
// N.B. getFlagStrNoEx() does not set val, but merely modifies it. Thus,
// val must be initialized before using getFlagStrNoEx(). The intention of
// this is to simplify modifying a flags field from a default value.
bool getFlagStrNoEx(std::string name, u32 &val, FlagDesc *flagdesc) bool getFlagStrNoEx(std::string name, u32 &val, FlagDesc *flagdesc)
{ {
try { try {
val = getFlagStr(name, flagdesc); u32 flags, flagmask;
flags = getFlagStr(name, flagdesc, &flagmask);
val &= ~flagmask;
val |= flags;
return true; return true;
} catch (SettingNotFoundException &e) { } catch (SettingNotFoundException &e) {
return false; return false;
@ -856,6 +868,9 @@ fail:
} }
//////////// Set setting //////////// Set setting
// N.B. if setStruct() is used to write a non-POD aggregate type,
// the behavior is undefined.
bool setStruct(std::string name, std::string format, void *value) bool setStruct(std::string name, std::string format, void *value)
{ {
char sbuf[2048]; char sbuf[2048];
@ -960,9 +975,10 @@ fail:
return true; return true;
} }
void setFlagStr(std::string name, u32 flags, FlagDesc *flagdesc) void setFlagStr(std::string name, u32 flags,
FlagDesc *flagdesc, u32 flagmask)
{ {
set(name, writeFlagString(flags, flagdesc)); set(name, writeFlagString(flags, flagdesc, flagmask));
} }
void setBool(std::string name, bool value) void setBool(std::string name, bool value)

@ -108,8 +108,9 @@ std::string urldecode(std::string str)
return oss.str(); return oss.str();
} }
u32 readFlagString(std::string str, FlagDesc *flagdesc) { u32 readFlagString(std::string str, FlagDesc *flagdesc, u32 *flagmask)
u32 result = 0; {
u32 result = 0, mask = 0;
char *s = &str[0]; char *s = &str[0];
char *flagstr, *strpos = NULL; char *flagstr, *strpos = NULL;
@ -119,22 +120,37 @@ u32 readFlagString(std::string str, FlagDesc *flagdesc) {
while (*flagstr == ' ' || *flagstr == '\t') while (*flagstr == ' ' || *flagstr == '\t')
flagstr++; flagstr++;
bool flagset = true;
if (!strncasecmp(flagstr, "no", 2)) {
flagset = false;
flagstr += 2;
}
for (int i = 0; flagdesc[i].name; i++) { for (int i = 0; flagdesc[i].name; i++) {
if (!strcasecmp(flagstr, flagdesc[i].name)) { if (!strcasecmp(flagstr, flagdesc[i].name)) {
mask |= flagdesc[i].flag;
if (flagset)
result |= flagdesc[i].flag; result |= flagdesc[i].flag;
break; break;
} }
} }
} }
if (flagmask)
*flagmask = mask;
return result; return result;
} }
std::string writeFlagString(u32 flags, FlagDesc *flagdesc) { std::string writeFlagString(u32 flags, FlagDesc *flagdesc, u32 flagmask)
{
std::string result; std::string result;
for (int i = 0; flagdesc[i].name; i++) { for (int i = 0; flagdesc[i].name; i++) {
if (flags & flagdesc[i].flag) { if (flagmask & flagdesc[i].flag) {
if (!(flags & flagdesc[i].flag))
result += "no";
result += flagdesc[i].name; result += flagdesc[i].name;
result += ", "; result += ", ";
} }
@ -147,7 +163,8 @@ std::string writeFlagString(u32 flags, FlagDesc *flagdesc) {
return result; return result;
} }
char *mystrtok_r(char *s, const char *sep, char **lasts) { char *mystrtok_r(char *s, const char *sep, char **lasts)
{
char *t; char *t;
if (!s) if (!s)
@ -172,7 +189,8 @@ char *mystrtok_r(char *s, const char *sep, char **lasts) {
return s; return s;
} }
u64 read_seed(const char *str) { u64 read_seed(const char *str)
{
char *endptr; char *endptr;
u64 num; u64 num;

@ -319,8 +319,8 @@ inline std::string unescape_string(std::string &s)
std::string translatePassword(std::string playername, std::wstring password); std::string translatePassword(std::string playername, std::wstring password);
std::string urlencode(std::string str); std::string urlencode(std::string str);
std::string urldecode(std::string str); std::string urldecode(std::string str);
u32 readFlagString(std::string str, FlagDesc *flagdesc); u32 readFlagString(std::string str, FlagDesc *flagdesc, u32 *flagmask);
std::string writeFlagString(u32 flags, FlagDesc *flagdesc); std::string writeFlagString(u32 flags, FlagDesc *flagdesc, u32 flagmask);
char *mystrtok_r(char *s, const char *sep, char **lasts); char *mystrtok_r(char *s, const char *sep, char **lasts);
u64 read_seed(const char *str); u64 read_seed(const char *str);