Skip to content

Instantly share code, notes, and snippets.

View squiddy's full-sized avatar
🏠
Working from home

Reiner Gerecke squiddy

🏠
Working from home
View GitHub Profile
class Block(object):
"""
Block IDs this class is responsible for.
"""
slots = tuple()
def build(self, factory, player, x, y, z, face):
"""
Called when a player places a block of this type.
@squiddy
squiddy / ampoule_bug_test.py
Created March 22, 2011 22:26
Windows twisted amp bug
from ampoule import child, util
from twisted.protocols import amp
class Test(amp.Command):
response = [("blocks", amp.String())]
class MyChild(child.AMPChild):
@Test.responder
def test(self):
return {"blocks": '\x00'*4073}
@squiddy
squiddy / skylight_spreading_benchmark.py
Created March 30, 2011 13:37
Benchmark for skylight spreading for bravo
import math
import time
from bravo.chunk import Chunk
from bravo.plugins.generators import simplex, caves
def average(l):
return sum(l) / len(l)
def stddev(l):
@squiddy
squiddy / bravo_light_strength.diff
Created March 30, 2011 22:26
Bravo skylight spreading strength (MasterofJOKers)
diff --git a/bravo/chunk.py b/bravo/chunk.py
index 1b53573..6d6d519 100644
--- a/bravo/chunk.py
+++ b/bravo/chunk.py
@@ -198,7 +198,8 @@ class Chunk(object):
while glow:
for coords in spread:
- if coords[2] > max_height:
+ if lightmap[coords] <= glow:
diff --git a/bravo/packets.py b/bravo/packets.py
index 400f09b..43d04e5 100644
--- a/bravo/packets.py
+++ b/bravo/packets.py
@@ -73,6 +73,9 @@ metadata = Struct("metadata",
),
Const(UBInt8("terminator"), 0x7f),
)
+from construct import StringAdapter, RepeatUntil, Field
+metadata = StringAdapter(RepeatUntil(lambda obj, ctx: obj == "\x7f",
@squiddy
squiddy / gist:1482109
Created December 15, 2011 18:02
codespeed django 1.2
diff --git a/example/settings.py b/example/settings.py
index 5d6f346..da47af2 100644
--- a/example/settings.py
+++ b/example/settings.py
@@ -98,7 +98,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
- 'django.core.context_processors.static',
+ 'staticfiles.context_processors.static',
@squiddy
squiddy / pychan.diff
Created March 19, 2012 21:53
PyChan Tooltip patch
diff --git a/horizons/engine/pychan_util.py b/horizons/engine/pychan_util.py
index a4d869b..e1ad670 100644
--- a/horizons/engine/pychan_util.py
+++ b/horizons/engine/pychan_util.py
@@ -21,7 +21,6 @@
# ###################################################
import functools
-import new
import functools
import httplib
import json
import threading
import time
import urllib
from wsgiref.simple_server import make_server
from irc.client import SimpleIRCClient
diff --git a/content/scenarios/tutorial_en.yaml b/content/scenarios/tutorial_en.yaml
index 3845ecc..1be531d 100644
--- a/content/scenarios/tutorial_en.yaml
+++ b/content/scenarios/tutorial_en.yaml
@@ -410,8 +410,7 @@ events:
- type: set_var
arguments: ["tutorial_progress", 16]
conditions:
- - type: time_passed
- arguments: [0]
[util/log]:74 debug => Logging system initialized
[util/log]:74 debug => Logging system initialized
[gl/texture]:61 debug => Loaded image data/img/console/left.png with 40x300:4
[gl/texture]:61 debug => Loaded image data/img/console/right.png with 40x300:4
[gl/texture]:61 debug => Loaded image data/img/console/middle.png with 1x300:4
[state/console/console]:220 debug => Loading console state.
[state/console/console_renderer]:57 debug => Loading console renderer state
[obj/md5/model/model]:125 debug => Parsing model data/models/berserker/berserker.md5mesh
[obj/md5/model/model]:136 debug => Model version: 10
[obj/md5/model/model]:144 debug => Model joints: 41