ofs | hex dump | ascii |
---|
0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 01 00 00 00 01 00 08 06 00 00 00 5c 72 a8 | .PNG........IHDR.............\r. |
0020 | 66 00 00 00 06 62 4b 47 44 00 ff 00 ff 00 ff a0 bd a7 93 00 00 00 09 70 48 59 73 00 00 0e c3 00 | f....bKGD..............pHYs..... |
0040 | 00 0e c3 01 c7 6f a8 64 00 00 00 07 74 49 4d 45 07 e0 06 09 13 13 0d 29 e6 2b 0e 00 00 20 00 49 | .....o.d....tIME.......).+.....I |
0060 | 44 41 54 78 da ec bd 69 90 64 d7 75 1e f8 9d bb bd 25 b3 b6 ac a5 57 74 a3 bb 81 c6 d2 00 1a 00 | DATx...i.d.u.....%....Wt........ |
0080 | 41 09 82 08 50 84 28 53 a3 5d e2 26 41 b2 2d 8d 16 92 96 ac 99 b1 1c 31 e1 08 7b c2 e1 f0 fc 98 | A...P.(S.].&A.-........1..{..... |
00a0 | 3f 76 88 d2 58 33 f6 58 63 71 3c a6 68 4a 63 7b c6 16 69 ca a2 24 6b 17 40 82 20 08 80 c4 d2 0b | ?v..X3.Xcq<.hJc{..i..$k.@....... |
00c0 | d0 04 ba 51 7b e5 f2 b6 7b ef 99 1f f7 bd 57 d9 c5 06 40 88 24 d0 00 df e9 c8 a8 ae aa 97 59 55 | ...Q{...{.....W...@.$.........YU |
00e0 | 99 79 be 7b 96 ef 7c 07 e8 ac b3 ce 3a eb ac b3 ce 3a eb ac b3 ce 3a eb ac b3 ce 3a eb ac b3 ce | .y.{..|.....:....:....:....:.... |
0100 | 3a eb ac b3 ce 3a eb ac b3 ce 3a eb ac b3 ce 3a eb ac b3 ce 3a eb ac b3 ce 3a eb ac b3 ce 3a eb | :....:....:....:....:....:....:. |
0120 | ac b3 ce 3a eb ec cd 6e d4 3d 05 dd 0b d9 d9 37 e1 fb e5 b6 db 6e 8b 7a bd de 5c 96 65 d5 e7 3e | ...:...n.=.....7.....n.z..\.e..> |
0140 | f7 b9 4d 00 dc 3d 2d 6f 5c 93 dd 53 d0 d9 57 6b b7 de 7a ab 9e 9d 9d ed 13 d1 ac b5 b6 17 c7 31 | ..M..=-o\..S..Wk..z............1 |
0160 | 6d 6d 6d e5 1d 08 bc 71 4d 74 4f 41 67 5f ad 2d 2e ce db 9d 9d ed 9d f1 78 b4 51 55 c5 9a 94 52 | mmm....qMtOAg_.-........x.QU...R |
0180 | dd 74 d3 4d f3 dd fb a8 8b 00 3a fb 26 b0 73 e7 9e a5 7d fb f6 cd cd cc cc dc 1b 45 f1 dd cc fc | .t.M......:.&.s...}........E.... |
01a0 | a8 d6 5a 1f 38 70 20 be 78 f1 62 17 09 74 00 d0 d9 9b 39 ff 3f 7d fa f4 dc 60 30 f7 2e 80 ff 7a | ..Z.8p..x.b..t....9.?}...`0....z |
01c0 | 51 14 df 91 e7 93 13 4a e9 3f 5b 5c 5c 1c dc 71 c7 1d fa 89 27 9e 18 77 20 d0 01 40 67 6f 52 e7 | Q......J.?[\\..q....'..w...@goR. |
01e0 | 9f 9b 9b bb df 39 7e a0 28 8a b7 8d 46 e3 43 d6 ba fd 00 0e 1c 3e 7c f8 cc f2 f2 f2 35 a7 4f 9f | .....9~.(...F.C......>|.....5.O. |
0200 | 2e 1e 7e f8 e1 61 07 02 1d 00 74 f6 e6 3b f9 ef 77 ce 3f 90 e7 f9 db c6 e3 f1 8a b5 56 1a 63 92 | ..~..a....t..;..w.?.........V.c. |
0220 | 34 4d f7 1b 63 8e 2e 2f 2f 27 71 1c f7 4e 9d 3a b5 dd 81 40 07 00 9d bd a9 9c 7f 50 9f fc f9 bd | 4M..c..//'q..N.:...@.......P.... |
0240 | e3 f1 64 a5 aa 2a 44 51 44 49 92 c8 24 49 92 a5 a5 a5 7d fd 7e ff 14 80 44 29 65 6f b9 e5 96 cd | ..d..*DQDI..$I....}.~...D)eo.... |
0260 | 0e 04 3a 00 e8 ec 2a b0 c3 87 0f 8b 9d 9d 9d af cd f9 bd 7b 20 2f f2 7b c7 93 c9 8a ad 2c e2 38 | ..:...*............{./.{.....,.8 |
0280 | 46 1c c7 48 92 84 66 67 67 e5 f2 f2 72 6c 8c 99 05 70 94 99 a5 10 a2 3c 79 f2 e4 e6 a3 8f 3e da | F..H..fgg...rl...p.....<y.....>. |
02a0 | 81 40 07 00 9d bd 9e 76 f3 89 65 79 f8 da 9e b8 70 61 c7 ff 55 72 7e 66 0e ce 3f 1e af d8 ca 22 | .@.....v..ey....pa..Ur~f..?...." |
02c0 | 49 12 24 49 82 38 8e d1 ef f7 b1 6f df 3e 9a 99 99 91 f5 7b 29 f2 de 5f e3 9c 13 4a a9 f2 c6 1b | I.$I.8.....o.>.....{).._...J.... |
02e0 | 6f ec 40 a0 03 80 ce 5e 4f bb ed c6 c3 e8 a7 33 78 f2 99 8b fc ea 9c bf 7f bf f7 78 a0 28 f2 7b | o.@....^O......3x..........x.(.{ |
0300 | 27 93 6c c5 3b df 3a 7f 92 24 e8 f7 fb 58 5a 5a c2 fc fc 3c 84 08 34 00 66 26 e7 5c e4 bd bf 86 | '.l.;.:..$...XZZ...<..4.f&.\.... |
0320 | 99 a5 d6 ba bc fd f6 db bb 74 a0 03 80 ce 5e 2f 7b ea dc 8b fc 6a 9c ff e8 d1 a3 73 33 33 e9 fd | .........t....^/{....j.....s33.. |
0340 | cc 78 a0 2c ab 7b f3 3c 5f f1 3e 38 7f 9a a6 ad f3 2f 2e 2e 62 61 61 01 42 08 30 33 98 19 de 7b | .x.,.{.<_.>8...../..baa.B.03...{ |
0360 | 38 e7 08 40 24 84 38 1c 45 91 9c 99 99 29 6f bf fd f6 cd 07 1f 7c b0 03 81 0e 00 3a bb 8a 8d 8e | 8..@$.8.E....)o......|.....:.... |
0380 | 1e 3d 3a 37 37 d7 bf 9f 88 1e b0 d6 dd 5b 96 e5 8a f7 8c 28 8a 90 a6 29 e2 38 c6 cc cc 0c 16 16 | .=:77........[.....(...).8...... |
03a0 | 16 da 93 bf 71 fc da f9 01 00 42 08 32 c6 44 c6 98 c3 52 4a c9 cc e5 89 13 27 ba 74 a0 03 80 ce | ....q.....B.2.D...RJ.....'.t.... |
03c0 | ae 66 e7 4f 12 73 3f 11 3d e0 9c bf d7 5a b7 c2 0c 18 63 da 9c 7f 66 66 06 83 c1 00 f3 f3 f3 50 | .f.O.s?.=....Z....c...ff.......P |
03e0 | 4a c1 39 07 ef 7d 0b 02 b5 f3 c3 18 03 63 0c 49 29 8d b5 f6 e0 f6 f6 b6 dd d8 d8 18 2e 2d 2d 6d | J.9..}.......c.I)............--m |
0400 | 5e b8 70 61 dc 3d dd 57 8f 75 1c ee ce d0 38 bf 10 f2 01 eb fc bd 55 65 5b e7 8f a2 08 51 14 a1 | ^.pa.=.W.u....8.......Ue[....Q.. |
0420 | d7 eb 61 61 61 01 b3 b3 b3 90 52 be a4 f3 2b a5 a0 94 02 00 54 55 85 e1 70 18 67 59 76 c7 64 32 | ..aaa.....R...+.....TU..p.gYv.d2 |
0440 | 49 ca b2 4c af bd f6 da 04 dd 14 6a 17 01 74 76 75 d8 75 d7 5d 97 cc f6 7a ef 24 41 3f ee 3d df | I..L.......j..tvu.u.]...z.$A?.=. |
0460 | eb 9d 5f 11 42 b6 8e df 54 fb 07 83 01 e6 e6 e6 60 8c 81 73 ee 32 00 00 00 22 82 94 12 52 ca e9 | .._.B...T.......`..s.2..."...R.. |
0480 | 7a 00 88 88 8d 31 2e 8a 22 3b 1e 8f 3f b1 b5 b5 35 4e d3 14 a3 d1 a8 4b 05 3a 00 e8 ec f5 b4 b7 | z....1..";..?...5N.....K.:...... |
04a0 | be f5 46 25 44 7c 0f 08 3f e5 9c bb cf 39 bf 6f da f9 a3 28 6a c3 fe 69 e7 b7 d6 02 40 eb fc 00 | ..F%D|..?....9.o...(j..i....@... |
04c0 | 20 a5 bc ac 20 28 a5 84 52 8a 88 48 8c c7 63 b3 b9 b9 b9 58 14 c5 41 ad f5 1f 79 ef 8b 85 85 05 | .....(..R..H..c....X..A...y..... |
04e0 | da dc dc ec 5e 84 0e 00 3a 7b 3d ec 3d df 75 ab 9e e4 f2 16 c7 f4 77 bc f3 f7 55 95 dd 4f 24 5a | ....^...:{=.=.u.......w...U..O$Z |
0500 | 92 cf f4 c9 3f 3f 3f 8f 28 8a 2e 2b f4 ed 3d f9 85 10 6d 2a a0 b5 86 94 12 d6 5a 8c 46 23 5a 5f | ....???.(..+..=...m*......Z.F#Z_ |
0520 | 5f 97 3b 3b 3b 49 96 65 fb b3 2c 3b 92 e7 f9 1f 9f 3f 7f be e8 5e 85 0e 00 3a 7b 1d ec fd 7f ed | _.;;;I.e..,;.....?...^...:{..... |
0540 | 94 d8 9a f0 f5 e3 02 7f af b2 fe 9d 65 65 57 88 a8 61 f7 7d 45 d8 3f ed fc 44 04 22 ba cc f9 89 | ............eeW..a.}E.?..D.".... |
0560 | 08 de 7b 10 11 94 52 10 42 a0 aa 2a ec ec ec 60 6d 6d 0d 3b 3b 3b 34 c9 32 39 99 4c 92 2c cb f6 | ..{...R.B..*...`mm.;;;4.29.L.,.. |
0580 | 03 7c 74 71 71 e9 8f 36 37 37 cb ee d5 e8 00 a0 b3 d7 d0 de fb 9d 37 ca 9d 9c 4f 6d 8d dc 2f 4d | .|tqq..677............7...Om../M |
05a0 | 0a ff ee d2 ba f9 2b 39 ff c2 c2 42 1b f6 ef 75 fe 06 00 a6 db 80 42 08 68 ad 21 84 40 59 96 d8 | ......+9...B...u......B.h.!.@Y.. |
05c0 | d9 d9 c1 c6 c6 06 76 76 76 30 99 4c 90 65 19 65 93 89 64 e6 c4 18 dd d7 5a d1 fc fc c2 67 37 36 | ......vvv0.L.e.e..d.....Z....g76 |
05e0 | 36 7c f7 aa bc 7e a6 ba a7 e0 9b cb 76 26 36 d9 18 fb ff 61 94 f3 4f 54 5e 28 29 d5 65 ce df eb | 6|...~......v&6....a..OT^().e... |
0600 | f5 30 3f 3f ff 15 39 7f c3 f6 23 22 30 73 fb 71 2a df 07 11 5d e6 fc c3 e1 10 59 96 21 cb 32 4c | .0??..9...#"0s.q*...].....Y.!.2L |
0620 | 26 13 30 b3 30 5a 97 4a ab 75 80 2e 6e 6e ae 47 00 aa ee 55 e9 00 a0 b3 af c2 6e 3f 7d ea dd 69 | &.0.0Z.J.u..nn.G...U......n?}..i |
0640 | d2 fb a7 20 da 2e f2 c9 af 15 f9 f6 6f 17 66 f2 e2 53 8f ac bd 62 45 fd e8 91 a3 ea e0 a1 83 27 | ............o.f..S...bE........' |
0660 | 33 ad 3e c4 66 fc 23 e5 68 13 52 c9 b6 d2 bf b7 d5 67 8c 81 b5 16 d6 da f6 c4 6f 1c 7e 3a 05 68 | 3.>.f.#.h.R......g........o.~:.h |
0680 | 5a 7f 00 5e d2 f9 b3 2c 03 7b 07 ad f4 86 d2 ea 73 92 c4 bf 2e 37 37 7f 6f 7d 7d 7d d2 bd aa 5d | Z..^...,.{......s....77.o}}}...] |
06a0 | 0a d0 d9 2b d8 cf 03 64 ee 3e f5 93 b6 aa 7e 75 6b 6b 6b ff 64 3c 5a 8a 35 4e ec 9b 4f 8a 83 49 | ...+...d.>....~ukkk.d<Z.5N..O..I |
bool getGameMinetestConfig(const std::string &game_path, Settings &conf)
{
std::string conf_path .h.......9(.6..........O.^xa.@.. |
0720 | 77 00 d0 d9 2b d9 c2 bd a7 7f 82 88 7f 39 cf c6 0b db 9b eb f0 d5 84 16 fa 66 71 b6 1f 1f 93 46 | w...+........9...........fq....F |
0740 | e5 76 ff e2 99 9b d3 d5 c9 e3 6b 57 70 fe 23 47 f4 e1 43 87 6f 30 ca fc 62 55 55 ef 1e 0e 87 83 | .v........kWp.#G..C.o0..bUU..... |
0760 | 3c cf 61 8c 41 1c c7 32 49 12 3b 37 37 27 16 17 17 db 6a 7f 13 f6 4f 57 fa 85 10 6d ce df 7c 2e | <.a.A..2I.;77'....j...OW...m..|. |
0780 | a5 7c 59 e7 1f 8f 27 f0 de 41 29 b9 29 a5 7c 88 04 3e b2 bd 3d fc c4 f3 cf 3f bf 05 c0 75 af 6c | .|Y...'..A).).|..>..=....?...u.l |
07a0 | 07 00 9d bd 82 7d df 3b ee fa 31 cf fe c3 d9 64 3c 28 b3 1d f4 8c c7 42 2a a1 c9 93 10 62 a0 94 | .....}.;..1....d<(.....B*....b.. |
07c0 | 39 c6 da 14 22 1e 9c 3b 25 87 e3 c7 37 77 43 81 43 87 96 d5 d2 d2 ca 8d 46 eb 9f b7 95 7d cf 78 | 9..."..;%.
std::string getGameName(const std::string &game_path)
{
Settings conf;
if(!getGameConfig(game_path, conf))
return "";
if(!conf.exists("name"))
return "";
return conf.get("name");
}
struct GameFindPath
{
std::string path;
bool user_specific;
GameFindPath(const std::string &path, bool user_specific):
path(path),
user_specific(user_specific)
{}
};
Strfnd getSubgamePathEnv() {
std::string sp;
char *subgame_path = getenv("MINETEST_SUBGAME_PATH");
if(subgame_path) {
sp = std::string(subgame_path);
}
return Strfnd(sp);
}
SubgameSpec findSubgame(const std::string &id)
{
if(id == "")
return SubgameSpec();
std::string share = porting::path_share;
std::string user = porting::path_user;
std::vector<GameFindPath> find_paths;
Strfnd search_paths = getSubgamePathEnv();
while(!search_paths.atend()) {
std::string path = search_paths.next(":");
find_paths.push_back(GameFindPath(
path + DIR_DELIM + id, false));
find_paths.push_back(GameFindPath(
path + DIR_DELIM + id + "_game", false));
}
find_paths.push_back(GameFindPath(
user + DIR_DELIM + "games" + DIR_DELIM + id + "_game", true));
find_paths.push_back(GameFindPath(
user + DIR_DELIM + "games" + DIR_DELIM + id, true));
find_paths.push_back(GameFindPath(
share + DIR_DELIM + "games" + DIR_DELIM + id + "_game", false));
find_paths.push_back(GameFindPath(
share + DIR_DELIM + "games" + DIR_DELIM + id, false));
// Find game directory
std::string game_path;
bool user_game = true; // Game is in user's directory
for(u32 i=0; i<find_paths.size(); i++){
const std::string &try_path = find_paths[i].path;
if(fs::PathExists(try_path)){
game_path = try_path;
user_game = find_paths[i].user_specific;
break;
}
}
if(game_path == "")
return SubgameSpec();
std::string gamemod_path = game_path + DIR_DELIM + "mods";
// Find mod directories
std::set<std::string> mods_paths;
if(!user_game)
mods_paths.insert(share + DIR_DELIM + "mods");
if(user != share || user_game)
mods_paths.insert(user + DIR_DELIM + "mods");
std::string game_name = getGameName(game_path);
if(game_name == "")
game_name = id;
std::string menuicon_path;
#ifndef SERVER
menuicon_path = getImagePath(game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
#endif
return SubgameSpec(id, game_path, gamemod_path, mods_paths, game_name,
menuicon_path);
}
SubgameSpec findWorldSubgame(const std::string &world_path)
{
std::string world_gameid = getWorldGameId(world_path, true);
// See if world contains an embedded game; if so, use it.
std::string world_gamepath = world_path + DIR_DELIM + "game";
if(fs::PathExists(world_gamepath)){
SubgameSpec gamespec;
gamespec.id = world_gameid;
gamespec.path = world_gamepath;
gamespec.gamemods_path= world_gamepath + DIR_DELIM + "mods";
gamespec.name = getGameName(world_gamepath);
if(gamespec.name == "")
gamespec.name = "unknown";
return gamespec;
}
return findSubgame(world_gameid);
}
std::set<std::string> getAvailableGameIds()
{
std::set<std::string> gameids;
std::set<std::string> gamespaths;
gamespaths.insert(porting::path_share + DIR_DELIM + "games");
gamespaths.insert(porting::path_user + DIR_DELIM + "games");
Strfnd search_paths = getSubgamePathEnv();
while(!search_paths.atend()) {
gamespaths.insert(search_paths.next(":"));
}
for(std::set<std::string>::const_iterator i = gamespaths.begin();
i != gamespaths.end(); i++){
std::vector<fs::DirListNode> dirlist = fs::GetDirListing(*i);
for(u32 j=0; j<dirlist.size(); j++){
if(!dirlist[j].dir)
continue;
// If configuration file is not found or broken, ignore game
Settings conf;
if(!getGameConfig(*i + DIR_DELIM + dirlist[j].name, conf))
continue;
// Add it to result
const char *ends[] = {"_game", NULL};
std::string shorter = removeStringEnd(dirlist[j].name, ends);
if(shorter != "")
gameids.insert(shorter);
else
gameids.insert(dirlist[j].name);
}
}
return gameids;
}
std::vector<SubgameSpec> getAvailableGames()
{
std::vector<SubgameSpec> specs;
std::set<std::string> gameids = getAvailableGameIds();
for(std::set<std::string>::const_iterator i = gameids.begin();
i != gameids.end(); i++)
specs.push_back(findSubgame(*i));
return specs;
}
#define LEGACY_GAMEID "minetest"
bool getWorldExists(const std::string &world_path)
{
return (fs::PathExists(world_path + DIR_DELIM + "map_meta.txt") ||
fs::PathExists(world_path + DIR_DELIM + "world.mt"));
}
std::string getWorldGameId(const std::string &world_path, bool can_be_legacy)
{
std::string conf_path = world_path + DIR_DELIM + "world.mt";
Settings conf;
bool succeeded = conf.readConfigFile(conf_path.c_str());
if(!succeeded){
if(can_be_legacy){
// If map_meta.txt exists, it is probably an old minetest world
if(fs::PathExists(world_path + DIR_DELIM + "map_meta.txt"))
return LEGACY_GAMEID;
}
return "";
}
if(!conf.exists("gameid"))
return "";
// The "mesetint" gameid has been discarded
if(conf.get("gameid") == "mesetint")
return "minetest";
return conf.get("gameid");
}
std::vector<WorldSpec> getAvailableWorlds()
{
std::vector<WorldSpec> worlds;
std::set<std::string> worldspaths;
worldspaths.insert(porting::path_user + DIR_DELIM + "worlds");
infostream<<"Searching worlds..."<<std::endl;
for(std::set<std::string>::const_iterator i = worldspaths.begin();
i != worldspaths.end(); i++){
infostream<<" In "<<(*i)<<": "<<std::endl;
std::vector<fs::DirListNode> dirvector = fs::GetDirListing(*i);
for(u32 j=0; j<dirvector.size(); j++){
if(!dirvector[j].dir)
continue;
std::string fullpath = *i + DIR_DELIM + dirvector[j].name;
std::string name = dirvector[j].name;
// Just allow filling in the gameid always for now
bool can_be_legacy = true;
std::string gameid = getWorldGameId(fullpath, can_be_legacy);
WorldSpec spec(fullpath, name, gameid);
if(!spec.isValid()){
infostream<<"(invalid: "<<name<<") ";
} else {
infostream<<name<<" ";
worlds.push_back(spec);
}
}
infostream<<std::endl;
}
// Check old world location
do{
std::string fullpath = porting::path_user + DIR_DELIM + "world";
if(!fs::PathExists(fullpath))
break;
std::string name = "Old World";
std::string gameid = getWorldGameId(fullpath, true);
WorldSpec spec(fullpath, name, gameid);
infostream<<"Old world found."<<std::endl;
worlds.push_back(spec);
}while(0);
infostream<<worlds.size()<<" found."<<std::endl;
return worlds;
}
bool initializeWorld(const std::string &path, const std::string &gameid)
{
infostream << "Initializing world at " << path << std::endl;
fs::CreateAllDirs(path);
// Create world.mt if does not already exist
std::string worldmt_path = path + DIR_DELIM "world.mt";
if (!fs::PathExists(worldmt_path)) {
std::ostringstream ss(std::ios_base::binary);
ss << "gameid = " << gameid << "\nbackend = sqlite3\n";
if (!fs::safeWriteToFile(worldmt_path, ss.str()))
return false;
infostream << "Wrote world.mt (" << worldmt_path << ")" << std::endl;
}
// Create map_meta.txt if does not already exist
std::string mapmeta_path = path + DIR_DELIM "map_meta.txt";
if (!fs::PathExists(mapmeta_path)) {
std::ostringstream ss(std::ios_base::binary);
ss
<< "mg_name = " << g_settings->get("mg_name")
<< "\nseed = " << g_settings->get("fixed_map_seed")
<< "\nchunksize = " << g_settings->get("chunksize")
<< "\nwater_level = " << g_settings->get("water_level")
<< "\nmg_flags = " << g_settings->get("mg_flags")
<< "\n[end_of_params]\n";
if (!fs::safeWriteToFile(mapmeta_path, ss.str()))
return false;
infostream << "Wrote map_meta.txt (" << mapmeta_path << ")" << std::endl;
}
return true;
}
|