diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-09-28 22:17:29 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-09-28 22:17:29 +0200 |
commit | 3165458c5993a447556efbbefc5aeb4352353347 (patch) | |
tree | 89195d960927cb1f43b871d367efd7f3081ace71 /AnvilStats/Utils.cpp | |
parent | AnvilStats: improved speed (~5x) by caching the entire region file in the processing thread (diff) | |
download | cuberite-3165458c5993a447556efbbefc5aeb4352353347.tar cuberite-3165458c5993a447556efbbefc5aeb4352353347.tar.gz cuberite-3165458c5993a447556efbbefc5aeb4352353347.tar.bz2 cuberite-3165458c5993a447556efbbefc5aeb4352353347.tar.lz cuberite-3165458c5993a447556efbbefc5aeb4352353347.tar.xz cuberite-3165458c5993a447556efbbefc5aeb4352353347.tar.zst cuberite-3165458c5993a447556efbbefc5aeb4352353347.zip |
Diffstat (limited to 'AnvilStats/Utils.cpp')
-rw-r--r-- | AnvilStats/Utils.cpp | 225 |
1 files changed, 225 insertions, 0 deletions
diff --git a/AnvilStats/Utils.cpp b/AnvilStats/Utils.cpp new file mode 100644 index 000000000..e6fe296e0 --- /dev/null +++ b/AnvilStats/Utils.cpp @@ -0,0 +1,225 @@ +
+// Utils.cpp
+
+// Implements utility functions
+
+#include "Globals.h"
+#include "Utils.h"
+
+
+
+
+
+const char * GetBiomeString(unsigned char a_Biome)
+{
+ static const char * BiomeNames[] = // Biome names, as equivalent to their index
+ {
+ "Ocean",
+ "Plains",
+ "Desert",
+ "Extreme Hills",
+ "Forest",
+ "Taiga",
+ "Swampland",
+ "River",
+ "Hell",
+ "Sky",
+ "Frozen Ocean",
+ "Frozen River",
+ "Ice Plains",
+ "Ice Mountains",
+ "Mushroom Island",
+ "Mushroom Island Shore",
+ "Beach",
+ "Desert Hills",
+ "Forest Hills",
+ "Taiga Hills",
+ "Extreme Hills Edge",
+ "Jungle",
+ "Jungle Hills",
+ } ;
+ return (a_Biome < ARRAYCOUNT(BiomeNames)) ? BiomeNames[a_Biome] : "";
+}
+
+
+
+
+
+const char * GetBlockTypeString(unsigned char a_BlockType)
+{
+ static const char * BlockTypeNames[] = // Block type names, as equivalent to their index
+ {
+ "air",
+ "stone",
+ "grass",
+ "dirt",
+ "cobblestone",
+ "planks",
+ "sapling",
+ "bedrock",
+ "water",
+ "stillwater",
+ "lava",
+ "stilllava",
+ "sand",
+ "gravel",
+ "goldore",
+ "ironore",
+ "coalore",
+ "log",
+ "leaves",
+ "sponge",
+ "glass",
+ "lapisore",
+ "lapisblock",
+ "dispenser",
+ "sandstone",
+ "noteblock",
+ "bedblock",
+ "poweredrail",
+ "detectorrail",
+ "stickypiston",
+ "cobweb",
+ "tallgrass",
+ "deadbush",
+ "piston",
+ "pistonhead",
+ "wool",
+ "pistonmovedblock",
+ "flower",
+ "rose",
+ "brownmushroom",
+ "redmushroom",
+ "goldblock",
+ "ironblock",
+ "doubleslab",
+ "slab",
+ "brickblock",
+ "tnt",
+ "bookcase",
+ "mossycobblestone",
+ "obsidian",
+ "torch",
+ "fire",
+ "mobspawner",
+ "woodstairs",
+ "chest",
+ "redstonedust",
+ "diamondore",
+ "diamondblock",
+ "workbench",
+ "crops",
+ "soil",
+ "furnace",
+ "litfurnace",
+ "signblock",
+ "wooddoorblock",
+ "ladder",
+ "tracks",
+ "cobblestonestairs",
+ "wallsign",
+ "lever",
+ "stoneplate",
+ "irondoorblock",
+ "woodplate",
+ "redstoneore",
+ "redstoneorealt",
+ "redstonetorchoff",
+ "redstonetorchon",
+ "button",
+ "snow",
+ "ice",
+ "snowblock",
+ "cactus",
+ "clayblock",
+ "reedblock",
+ "jukebox",
+ "fence",
+ "pumpkin",
+ "netherrack",
+ "soulsand",
+ "glowstone",
+ "portal",
+ "jack-o-lantern",
+ "cakeblock",
+ "repeateroff",
+ "repeateron",
+ "lockedchest",
+ "trapdoor",
+ "silverfishblock",
+ "stonebricks",
+ "hugebrownmushroom",
+ "hugeredmushroom",
+ "ironbars",
+ "glasspane",
+ "melon",
+ "pumpkinstem",
+ "melonstem",
+ "vines",
+ "fencegate",
+ "brickstairs",
+ "stonebrickstairs",
+ "mycelium",
+ "lilypad",
+ "netherbrick",
+ "netherbrickfence",
+ "netherbrickstairs",
+ "netherwartblock",
+ "enchantmenttable",
+ "brewingstandblock",
+ "cauldronblock",
+ "endportal",
+ "endportalframe",
+ "endstone",
+ "dragonegg",
+ "redstonelampoff",
+ "redstonelampon",
+ "woodendoubleslab",
+ "woodenslab",
+ "cocoapod",
+ "sandstonestairs", /* 128 */
+ "Emerald Ore",
+ "Ender Chest",
+ "Tripwire Hook",
+ "Tripwire",
+ "Block of Emerald",
+ "Spruce Wood Stairs",
+ "Birch Wood Stairs",
+ "Jungle Wood Stairs",
+ "Command Block",
+ "Beacon",
+ "Cobblestone Wall",
+ "Flower Pot",
+ "Carrots",
+ "Potatoes",
+ "Wooden Button",
+ "Head",
+ } ;
+
+ return (a_BlockType < ARRAYCOUNT(BlockTypeNames)) ? BlockTypeNames[a_BlockType] : "";
+}
+
+
+
+
+
+int GetNumCores(void)
+{
+ // Get number of cores by querying the system process affinity mask (Windows-specific)
+ DWORD Affinity, ProcAffinity;
+ GetProcessAffinityMask(GetCurrentProcess(), &ProcAffinity, &Affinity);
+ int NumCores = 0;
+ while (Affinity > 0)
+ {
+ if ((Affinity & 1) == 1)
+ {
+ ++NumCores;
+ }
+ Affinity >>= 1;
+ } // while (Affinity > 0)
+ return NumCores;
+}
+
+
+
+
|