Skip to content

Commit eaccbd4

Browse files
committed
removed more refereces to __tcod.py, currently working in pypy
1 parent 49b71b3 commit eaccbd4

File tree

12 files changed

+20
-18
lines changed

12 files changed

+20
-18
lines changed

dev/benchmark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def print_result(string):
1919
print(string, file=log)
2020

2121
class Benchmark:
22-
default_frames = 50
22+
default_frames = 100
2323

24-
def run(self, console, frames=None, times=3):
24+
def run(self, console, frames=None, times=4):
2525
if times > 1:
2626
print_result('Running %s' % self.__class__.__name__)
2727
while times > 0:

tdl/Release/_libtcod.obj

-66.5 KB
Binary file not shown.

tdl/Release/_libtcod.pypy-26.exp

800 Bytes
Binary file not shown.

tdl/Release/_libtcod.pypy-26.lib

2.12 KB
Binary file not shown.

tdl/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
from . import event, map, noise
7373
from .libtcod import _unpackfile
7474
from .libtcod import _ffi, _lib
75-
from . import __style as _style
75+
from . import style as _style
7676

7777

7878
_IS_PYTHON3 = (_sys.version_info[0] == 3)
@@ -110,7 +110,10 @@ def _formatChar(char):
110110
def _format_str(string):
111111
if isinstance(string, str):
112112
array = _array.array('I')
113-
array.frombytes(string.encode(_utf32_codec))
113+
if _IS_PYTHON3:
114+
array.frombytes(string.encode(_utf32_codec))
115+
else:
116+
array.fromstring(string.encode(_utf32_codec))
114117
return array
115118
return string
116119

tdl/_libtcod.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static PyObject **_cffi_unpack_args(PyObject *args_tuple, Py_ssize_t expected,
390390

391391
#include <libtcod.h>
392392

393-
static void set_char(TCOD_console_t console, int x, int y,
393+
void set_char(TCOD_console_t console, int x, int y,
394394
int ch, int fg, int bg){
395395
// normalize x, y
396396
int width=TCOD_console_get_width(console);
@@ -402,7 +402,6 @@ static void set_char(TCOD_console_t console, int x, int y,
402402
y = y % height;
403403
if(y<0){y += height;};
404404

405-
406405
if(ch != -1){
407406
TCOD_console_set_char(console, x, y, ch);
408407
}

tdl/build_libtcod.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,8 @@
506506
}
507507
508508
""",
509-
include_dirs=['include/'],
510-
library_dirs=['lib/win32/'],
509+
include_dirs=['include/', 'tdl/include/'],
510+
library_dirs=['lib/win32/', 'tdl/lib/win32/'],
511511
libraries=['libtcod-VS'])
512512

513513

tdl/event.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from .libtcod import _ffi, _lib
3737

3838
#from . import __tcod as _tcod
39-
from . import __style as _style
39+
from . import style as _style
4040
import tdl as _tdl
4141

4242
_eventQueue = []
@@ -323,12 +323,12 @@ def _processEvents():
323323
mouse = _ffi.new('TCOD_mouse_t *')
324324
libkey = _ffi.new('TCOD_key_t *')
325325
while 1:
326-
libevent = _lib.TCOD_sys_check_for_event(_tcod.TCOD_EVENT_ANY, libkey, mouse)
326+
libevent = _lib.TCOD_sys_check_for_event(_lib.TCOD_EVENT_ANY, libkey, mouse)
327327
if not libevent: # no more events from libtcod
328328
break
329329

330330
#if mouse.dx or mouse.dy:
331-
if libevent & _tcod.TCOD_EVENT_MOUSE_MOVE:
331+
if libevent & _lib.TCOD_EVENT_MOUSE_MOVE:
332332
events.append(MouseMotion((mouse.x, mouse.y),
333333
(mouse.cx, mouse.cy),
334334
(mouse.dx, mouse.dy),
@@ -360,7 +360,7 @@ def _processEvents():
360360
_mousem = mouse.mbutton
361361
_mouser = mouse.rbutton
362362

363-
if libkey.vk == _tcod.K_NONE:
363+
if libkey.vk == _lib.TCODK_NONE:
364364
break
365365
if libkey.pressed:
366366
keyevent = KeyDown

tdl/libtcod.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def _unpackfile(filename):
1414
except ImportError:
1515
#from tdl import __path__
1616
def _unpackfile(filename):
17-
return os.path.abspath(os.path.join(__path__[0], filename))
17+
return _os.path.abspath(_os.path.join(__path__[0], filename))
1818

1919
def _unpackFramework(framework, path):
2020
"""get framework.tar file, remove ".tar" and add path"""
21-
return os.path.abspath(os.path.join(_unpackfile(framework)[:-4], path))
21+
return _os.path.abspath(_os.path.join(_unpackfile(framework)[:-4], path))
2222

2323
def _loadDLL(dll):
2424
"""shorter version of file unpacking and linking"""

tdl/map.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import tdl as _tdl
1010
#from .__tcod import _lib, _PATHCALL
1111
from .libtcod import _ffi, _lib
12-
from . import __style as _style
12+
from . import style as _style
1313

1414
_FOVTYPES = {'BASIC' : 0, 'DIAMOND': 1, 'SHADOW': 2, 'RESTRICTIVE': 12, 'PERMISSIVE': 11}
1515

@@ -182,7 +182,7 @@ def quick_fov(x, y, callback, fov='PERMISSIVE', radius=7.5, lightWalls=True, sph
182182
# pass one, write callback data to the tcodMap
183183
#for (x_, cX), (y_, cY) in _itertools.product(((i, _ctypes.c_int(i)) for i in range(mapSize)),
184184
# ((i, _ctypes.c_int(i)) for i in range(mapSize))):
185-
for x_, y_ in _itertools.product(range(mapSize), range(mapSize))
185+
for x_, y_ in _itertools.product(range(mapSize), range(mapSize)):
186186
pos = (x_ + x - radius,
187187
y_ + y - radius)
188188
transparent = bool(callback(*pos))
@@ -193,7 +193,7 @@ def quick_fov(x, y, callback, fov='PERMISSIVE', radius=7.5, lightWalls=True, sph
193193
touched = set() # points touched by field of view
194194
#for (x_, cX),(y_, cY) in _itertools.product(((i, _ctypes.c_int(i)) for i in range(mapSize)),
195195
# ((i, _ctypes.c_int(i)) for i in range(mapSize))):
196-
for x_, y_ in _itertools.product(range(mapSize), range(mapSize))
196+
for x_, y_ in _itertools.product(range(mapSize), range(mapSize)):
197197
if sphere and _math.hypot(x_ - radius, y_ - radius) > trueRadius:
198198
continue
199199
if inFOV(tcodMap, x_, y_):

0 commit comments

Comments
 (0)