Permalink
Browse files

Fixed: Statement seems to have no effect

Change several strings-in-void-context into comments like they ought to be.
Change member accesses in void context into assertions or prints.
  • Loading branch information...
1 parent b7ce019 commit f4b40912a35b9101957bb17bc8eac8832ac96e45 @codewarrior0 codewarrior0 committed Oct 27, 2012
Showing with 59 additions and 61 deletions.
  1. +19 −19 blockrotation.py
  2. +14 −14 infiniteworld.py
  3. +3 −3 mce.py
  4. +1 −1 nbt.py
  5. +2 −2 test/anvil_test.py
  6. +20 −22 test/nbt_test.py
View
@@ -7,7 +7,7 @@ def genericVerticalFlip(cls):
if hasattr(cls, "Up") and hasattr(cls, "Down"):
rotation[cls.Up] = cls.Down
rotation[cls.Down] = cls.Up
-
+
if hasattr(cls, "TopNorth") and hasattr(cls, "TopWest") and hasattr(cls, "TopSouth") and hasattr(cls, "TopEast"):
rotation[cls.North] = cls.TopNorth
rotation[cls.West] = cls.TopWest
@@ -32,7 +32,7 @@ def genericRotation(cls):
rotation[cls.TopWest] = cls.TopSouth
rotation[cls.TopSouth] = cls.TopEast
rotation[cls.TopEast] = cls.TopNorth
-
+
return rotation
@@ -43,7 +43,7 @@ def genericEastWestFlip(cls):
if hasattr(cls, "TopWest") and hasattr(cls, "TopEast"):
rotation[cls.TopWest] = cls.TopEast
rotation[cls.TopEast] = cls.TopWest
-
+
return rotation
@@ -54,7 +54,7 @@ def genericNorthSouthFlip(cls):
if hasattr(cls, "TopNorth") and hasattr(cls, "TopSouth"):
rotation[cls.TopSouth] = cls.TopNorth
rotation[cls.TopNorth] = cls.TopSouth
-
+
return rotation
rotationClasses = []
@@ -123,7 +123,7 @@ class HalfSlab:
TopCobblestoneSlab = 11
TopBrickSlab = 12
TopStoneBrickSlab = 13
-
+
HalfSlab.flipVertical = arange(16, dtype='uint8')
HalfSlab.flipVertical[HalfSlab.StoneSlab] = HalfSlab.TopStoneSlab
HalfSlab.flipVertical[HalfSlab.SandstoneSlab] = HalfSlab.TopSandstoneSlab
@@ -432,20 +432,20 @@ class Vines:
flipEastWest = arange(16, dtype='uint8')
flipNorthSouth = arange(16, dtype='uint8')
-"""
-Value Description Textures
-0 Fleshy piece Pores on all sides
-1 Corner piece Cap texture on top, directions 1 (cloud direction) and 2 (sunrise)
-2 Side piece Cap texture on top and direction 2 (sunrise)
-3 Corner piece Cap texture on top, directions 2 (sunrise) and 3 (cloud origin)
-4 Side piece Cap texture on top and direction 1 (cloud direction)
-5 Top piece Cap texture on top
-6 Side piece Cap texture on top and direction 3 (cloud origin)
-7 Corner piece Cap texture on top, directions 0 (sunset) and 1 (cloud direction)
-8 Side piece Cap texture on top and direction 0 (sunset)
-9 Corner piece Cap texture on top, directions 3 (cloud origin) and 0 (sunset)
-10 Stem piece Stem texture on all four sides, pores on top and bottom
-"""
+
+#Mushroom types:
+#Value Description Textures
+#0 Fleshy piece Pores on all sides
+#1 Corner piece Cap texture on top, directions 1 (cloud direction) and 2 (sunrise)
+#2 Side piece Cap texture on top and direction 2 (sunrise)
+#3 Corner piece Cap texture on top, directions 2 (sunrise) and 3 (cloud origin)
+#4 Side piece Cap texture on top and direction 1 (cloud direction)
+#5 Top piece Cap texture on top
+#6 Side piece Cap texture on top and direction 3 (cloud origin)
+#7 Corner piece Cap texture on top, directions 0 (sunset) and 1 (cloud direction)
+#8 Side piece Cap texture on top and direction 0 (sunset)
+#9 Corner piece Cap texture on top, directions 3 (cloud origin) and 0 (sunset)
+#10 Stem piece Stem texture on all four sides, pores on top and bottom
class HugeMushroom:
View
@@ -846,20 +846,20 @@ def clipLight(light):
progressInfo = u"{0} Pass {1}: {2} chunks".format(light, i, len(newDirtyChunks))
info(progressInfo)
- """
- propagate light!
- for each of the six cardinal directions, figure a new light value for
- adjoining blocks by reducing this chunk's light by light absorption and fall off.
- compare this new light value against the old light value and update with the maximum.
-
- we calculate all chunks one step before moving to the next step, to ensure all gaps at chunk edges are filled.
- we do an extra cycle because lights sent across edges may lag by one cycle.
-
- xxx this can be optimized by finding the highest and lowest blocks
- that changed after one pass, and only calculating changes for that
- vertical slice on the next pass. newDirtyChunks would have to be a
- list of (cPos, miny, maxy) tuples or a cPos : (miny, maxy) dict
- """
+
+# propagate light!
+# for each of the six cardinal directions, figure a new light value for
+# adjoining blocks by reducing this chunk's light by light absorption and fall off.
+# compare this new light value against the old light value and update with the maximum.
+#
+# we calculate all chunks one step before moving to the next step, to ensure all gaps at chunk edges are filled.
+# we do an extra cycle because lights sent across edges may lag by one cycle.
+#
+# xxx this can be optimized by finding the highest and lowest blocks
+# that changed after one pass, and only calculating changes for that
+# vertical slice on the next pass. newDirtyChunks would have to be a
+# list of (cPos, miny, maxy) tuples or a cPos : (miny, maxy) dict
+
newDirtyChunks = set(newDirtyChunks)
newDirtyChunks.discard(zeroChunk)
View
6 mce.py
@@ -678,7 +678,7 @@ def printFreeSectors(runs):
if len(command):
if len(command) > 1:
rx, rz = map(int, command[:2])
- level.allChunks
+ print "Calling allChunks to preload region files: %d chunks" % len(level.allChunks)
rf = level.regionFiles.get((rx, rz))
if rf is None:
print "Region {rx},{rz} not found.".format(**locals())
@@ -704,7 +704,7 @@ def printFreeSectors(runs):
else:
if command[0] == "free":
- level.allChunks
+ print "Calling allChunks to preload region files: %d chunks" % len(level.allChunks)
for (rx, rz), rf in level.regionFiles.iteritems():
runs = getFreeSectors(rf)
@@ -713,7 +713,7 @@ def printFreeSectors(runs):
printFreeSectors(runs)
else:
- level.allChunks
+ print "Calling allChunks to preload region files: %d chunks" % len(level.allChunks)
coords = (r for r in level.regionFiles)
for i, (rx, rz) in enumerate(coords):
print "({rx:6}, {rz:6}): {count}, ".format(count=level.regionFiles[rx, rz].chunkCount),
View
2 nbt.py
@@ -341,7 +341,7 @@ def write_value(self, buf):
buf.write("\x00")
- "collection functions"
+ # --- collection functions ---
def __getitem__(self, key):
# hits=filter(lambda x: x.name==key, self.value)
View
@@ -28,7 +28,7 @@ def testUnsetProperties(self):
level = self.anvilLevel.level
del level.root_tag['Data']['LastPlayed']
import time
- level.LastPlayed
+ assert 0 != level.LastPlayed
level.LastPlayed = time.time() * 1000 - 1000000
def testGetEntities(self):
@@ -125,4 +125,4 @@ def testPlayerSpawn(self):
level.setPlayerSpawnPosition((0, 64, 0), "Player")
level.getPlayerPosition()
- level.players
+ assert len(level.players) != 0
View
@@ -15,24 +15,24 @@ def testLoad(self):
"Load an indev level."
level = nbt.load("testfiles/hell.mclevel")
- """The root tag must have a name, and so must any tag within a TAG_Compound"""
+ # The root tag must have a name, and so must any tag within a TAG_Compound
print level.name
- """Use the [] operator to look up subtags of a TAG_Compound."""
+ # Use the [] operator to look up subtags of a TAG_Compound.
print level["Environment"]["SurroundingGroundHeight"].value
- """Numeric, string, and bytearray types have a value that can be accessed and changed. """
+ # Numeric, string, and bytearray types have a value that can be accessed and changed.
print level["Map"]["Blocks"].value
return level
def testCreate(self):
"Create an indev level."
- "The root of an NBT file is always a TAG_Compound."
+ # The root of an NBT file is always a TAG_Compound.
level = nbt.TAG_Compound(name="MinecraftLevel")
- "Subtags of a TAG_Compound are automatically named when you use the [] operator."
+ # Subtags of a TAG_Compound are automatically named when you use the [] operator.
level["About"] = nbt.TAG_Compound()
level["About"]["Author"] = nbt.TAG_String("codewarrior")
level["About"]["CreatedOn"] = nbt.TAG_Long(time.time())
@@ -48,7 +48,7 @@ def testCreate(self):
level["Entities"] = nbt.TAG_List([entity])
- "You can also create and name a tag before adding it to the compound."
+ # You can also create and name a tag before adding it to the compound.
spawn = nbt.TAG_List((nbt.TAG_Short(100), nbt.TAG_Short(45), nbt.TAG_Short(55)))
spawn.name = "Spawn"
@@ -60,30 +60,30 @@ def testCreate(self):
mapTag2 = nbt.TAG_Compound([spawn])
mapTag2.name = "Map"
- "I think it looks more familiar with [] syntax."
+ # I think it looks more familiar with [] syntax.
l, w, h = 128, 128, 128
mapTag["Height"] = nbt.TAG_Short(h) # y dimension
mapTag["Length"] = nbt.TAG_Short(l) # z dimension
mapTag["Width"] = nbt.TAG_Short(w) # x dimension
- "Byte arrays are stored as numpy.uint8 arrays. "
+ # Byte arrays are stored as numpy.uint8 arrays.
mapTag["Blocks"] = nbt.TAG_Byte_Array()
mapTag["Blocks"].value = numpy.zeros(l * w * h, dtype=numpy.uint8) # create lots of air!
- "The blocks array is indexed (y,z,x) for indev levels, so reshape the blocks"
+ # The blocks array is indexed (y,z,x) for indev levels, so reshape the blocks
mapTag["Blocks"].value.shape = (h, l, w)
- "Replace the bottom layer of the indev level with wood"
+ # Replace the bottom layer of the indev level with wood
mapTag["Blocks"].value[0, :, :] = 5
- "This is a great way to learn the power of numpy array slicing and indexing."
+ # This is a great way to learn the power of numpy array slicing and indexing.
mapTag["Data"] = nbt.TAG_Byte_Array()
mapTag["Data"].value = numpy.zeros(l * w * h, dtype=numpy.uint8)
- "Save a few more tag types for completeness"
+ # Save a few more tag types for completeness
level["ShortArray"] = nbt.TAG_Short_Array(numpy.zeros((16, 16), dtype='uint16'))
level["IntArray"] = nbt.TAG_Int_Array(numpy.zeros((16, 16), dtype='uint32'))
@@ -102,17 +102,17 @@ def testToStrings(self):
def testModify(self):
level = self.testCreate()
- "Most of the value types work as expected. Here, we replace the entire tag with a TAG_String"
+ # Most of the value types work as expected. Here, we replace the entire tag with a TAG_String
level["About"]["Author"] = nbt.TAG_String("YARRR~!")
- "Because the tag type usually doesn't change, "
- "we can replace the string tag's value instead of replacing the entire tag."
+ # Because the tag type usually doesn't change,
+ # we can replace the string tag's value instead of replacing the entire tag.
level["About"]["Author"].value = "Stew Pickles"
- "Remove members of a TAG_Compound using del, similar to a python dict."
+ # Remove members of a TAG_Compound using del, similar to a python dict.
del(level["About"])
- "Replace all of the wood blocks with gold using a boolean index array"
+ # Replace all of the wood blocks with gold using a boolean index array
blocks = level["Map"]["Blocks"].value
blocks[blocks == 5] = 41
@@ -130,7 +130,7 @@ def testSave(self):
level = self.testCreate()
level["Environment"]["SurroundingWaterHeight"].value += 6
- "Save the entire TAG structure to a different file."
+ # Save the entire TAG structure to a different file.
TempLevel("atlantis.mclevel", createFunc=level.save) #xxx don't use templevel here
@@ -155,10 +155,8 @@ def testErrors(self):
if n:
print "Named list element failed: %s" % n
- """
- attempt to delete non-existent TAG_Compound elements
- this generates a KeyError like a python dict does.
- """
+ # attempt to delete non-existent TAG_Compound elements
+ # this generates a KeyError like a python dict does.
level = self.testCreate()
try:
del level["DEADBEEF"]

0 comments on commit f4b4091

Please sign in to comment.