Skip to content

Commit 4081457

Browse files
committed
committing changes while things are still stable
1 parent 1ef58f1 commit 4081457

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+19530
-79
lines changed

dev/stressTest.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,22 @@ def updateTest(self, deltaTime):
156156
HEIGHT = 20
157157
def main():
158158
console = tdl.init(46, 20, renderer='OPENGL')
159-
for Test in [FullDrawCharTest, PreCompiledColorTest, CharOnlyTest, TypewriterCharOnlyTest, ColorOnlyTest, GetCharTest,
159+
for Test in [FullDrawCharTest, CharOnlyTest, TypewriterCharOnlyTest, ColorOnlyTest, GetCharTest,
160160
SingleRectTest, DrawStrTest, BlitScrollTest]:
161161
Test(console).run()
162162
console.clear()
163163

164164
if __name__ == '__main__':
165-
pr = profile.Profile()
166-
try:
167-
pr.runcall(main)
168-
finally:
169-
pr.dump_stats('profile.prof')
170-
stats = pstats.Stats('profile.prof')
171-
stats.strip_dirs()
172-
stats.sort_stats('time')
173-
stats.reverse_order()
174-
stats.print_stats()
175-
os.remove('profile.prof')
165+
main()
166+
#pr = profile.Profile()
167+
#try:
168+
# pr.runcall(main)
169+
#finally:
170+
# pr.dump_stats('profile.prof')
171+
# stats = pstats.Stats('profile.prof')
172+
# stats.strip_dirs()
173+
# stats.sort_stats('time')
174+
# stats.reverse_order()
175+
# stats.print_stats()
176+
# os.remove('profile.prof')
176177

include/bresenham.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* libtcod 1.5.1
3+
* Copyright (c) 2008,2009,2010,2012 Jice & Mingos
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
* * The name of Jice or Mingos may not be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY JICE AND MINGOS ``AS IS'' AND ANY
17+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL JICE OR MINGOS BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
#ifndef _TCOD_BRESENHAM_H
29+
#define _TCOD_BRESENHAM_H
30+
31+
typedef bool (*TCOD_line_listener_t) (int x, int y);
32+
33+
TCODLIB_API void TCOD_line_init(int xFrom, int yFrom, int xTo, int yTo);
34+
TCODLIB_API bool TCOD_line_step(int *xCur, int *yCur); /* advance one step. returns true if we reach destination */
35+
/* atomic callback function. Stops when the callback returns false */
36+
TCODLIB_API bool TCOD_line(int xFrom, int yFrom, int xTo, int yTo, TCOD_line_listener_t listener);
37+
38+
/* thread-safe versions */
39+
typedef struct {
40+
int stepx;
41+
int stepy;
42+
int e;
43+
int deltax;
44+
int deltay;
45+
int origx;
46+
int origy;
47+
int destx;
48+
int desty;
49+
} TCOD_bresenham_data_t;
50+
51+
TCODLIB_API void TCOD_line_init_mt(int xFrom, int yFrom, int xTo, int yTo, TCOD_bresenham_data_t *data);
52+
TCODLIB_API bool TCOD_line_step_mt(int *xCur, int *yCur, TCOD_bresenham_data_t *data);
53+
TCODLIB_API bool TCOD_line_mt(int xFrom, int yFrom, int xTo, int yTo, TCOD_line_listener_t listener, TCOD_bresenham_data_t *data);
54+
55+
#endif

include/bresenham.hpp

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/*
2+
* libtcod 1.5.1
3+
* Copyright (c) 2008,2009,2010,2012 Jice & Mingos
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
* * The name of Jice or Mingos may not be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY JICE AND MINGOS ``AS IS'' AND ANY
17+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL JICE OR MINGOS BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
#ifndef _TCOD_BRESENHAM_HPP
29+
#define _TCOD_BRESENHAM_HPP
30+
class TCODLIB_API TCODLineListener {
31+
public :
32+
virtual bool putPoint(int x,int y) = 0;
33+
virtual ~TCODLineListener() {}
34+
};
35+
36+
class TCODLIB_API TCODLine {
37+
public :
38+
/**
39+
@PageName line
40+
@PageCategory Base toolkits
41+
@PageTitle Line drawing toolkit
42+
@PageDesc This toolkit is a very simple and lightweight implementation of the bresenham line drawing algorithm. It allows you to follow straight paths on your map very easily.
43+
@FuncTitle Initializing the line
44+
@FuncDesc First, you have to initialize the toolkit with your starting and ending coordinates.
45+
@Cpp static void TCODLine::init (int xFrom, int yFrom, int xTo, int yTo)
46+
@C void TCOD_line_init (int xFrom, int yFrom, int xTo, int yTo)
47+
@Py line_init (xFrom, yFrom, xTo, yTo)
48+
@C# static void TCODLine::init(int xFrom, int yFrom, int xTo, int yTo)
49+
@Lua tcod.line.init(xFrom,yFrom, xTo,yTo)
50+
@Param xFrom,yFrom Coordinates of the line's starting point.
51+
@Param xTo,yTo Coordinates of the line's ending point.
52+
*/
53+
static void init(int xFrom, int yFrom, int xTo, int yTo);
54+
55+
/**
56+
@PageName line
57+
@FuncTitle Walking the line
58+
@FuncDesc You can then step through each cell with this function. It returns true when you reach the line's ending point.
59+
@Cpp static bool TCODLine::step (int * xCur, int * yCur)
60+
@C bool TCOD_line_step (int * xCur, int * yCur)
61+
@Py line_step () # returns x,y or None,None if finished
62+
@C# static bool TCODLine::step(ref int xCur, ref int yCur)
63+
@Lua tcod.line.step(x,y) -- returns lineEnd,x,y
64+
@Param xCur,yCur the coordinates of the next cell on the line are stored here when the function returns
65+
@CppEx
66+
// Going from point 5,8 to point 13,4
67+
int x = 5, y = 8;
68+
TCODLine::init(x,y,13,4);
69+
do {
70+
// update cell x,y
71+
} while (!TCODLine::step(&x,&y));
72+
@CEx
73+
int x = 5, y = 8;
74+
TCOD_line_init(x,y,13,4);
75+
do {
76+
// update cell x,y
77+
} while (!TCOD_line_step(&x,&y));
78+
@PyEx
79+
libtcod.line_init(5,8,13,4)
80+
# update cell 5,8
81+
x,y=libtcod.line_step()
82+
while (not x is None) :
83+
# update cell x,y
84+
x,y=libtcod.line_step()
85+
@LuaEx
86+
x=5
87+
y=8
88+
tcod.line.init(x,y,13,4)
89+
repeat
90+
-- update cell x,y
91+
lineEnd,x,y = tcod.line.step(x,y)
92+
until lineEnd
93+
*/
94+
static bool step(int *xCur, int *yCur);
95+
96+
/**
97+
@PageName line
98+
@FuncTitle Callback-based function
99+
@FuncDesc The function returns false if the line has been interrupted by the callback (it returned false before the last point).
100+
@Cpp
101+
class TCODLIB_API TCODLineListener {
102+
virtual bool putPoint (int x, int y) = 0;
103+
};
104+
static bool TCODLine::line (int xFrom, int yFrom, int xTo, int yTo, TCODLineListener * listener)
105+
@C
106+
typedef bool (*TCOD_line_listener_t) (int x, int y);
107+
bool TCOD_line(int xFrom, int yFrom, int xTo, int yTo, TCOD_line_listener_t listener)
108+
@Py
109+
def line_listener(x,y) : # ...
110+
line(xFrom, yFrom, xTo, yTo, listener)
111+
@C# static bool line(int xFrom, int yFrom, int xTo, int yTo, TCODLineListener listener)
112+
@Param xFrom,yFrom Coordinates of the line's starting point.
113+
@Param xTo,yTo Coordinates of the line's ending point.
114+
@Param listener Callback called for each line's point. The function stops if the callback returns false.
115+
@CppEx // Going from point 5,8 to point 13,4
116+
class MyLineListener : public TCODLineListener {
117+
public:
118+
bool putPoint (int x,int y) {
119+
printf ("%d %d\n",x,y);
120+
return true;
121+
}
122+
};
123+
MyLineListener myListener;
124+
TCODLine::line(5,8,13,4,&myListener);
125+
@CEx bool my_listener(int x,int y) {
126+
printf ("%d %d\n",x,y);
127+
return true;
128+
}
129+
TCOD_line_line(5,8,13,4,my_listener);
130+
@PyEx def my_listener(x,y):
131+
print x,y
132+
return True
133+
libtcod.line_line(5,8,13,4,my_listener)
134+
*/
135+
static bool line(int xFrom, int yFrom, int xTo, int yTo, TCODLineListener *listener);
136+
};
137+
138+
#endif

include/bsp.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* libtcod 1.5.1
3+
* Copyright (c) 2008,2009,2010,2012 Jice & Mingos
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
* * The name of Jice or Mingos may not be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY JICE AND MINGOS ``AS IS'' AND ANY
17+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL JICE OR MINGOS BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
#ifndef _TCOD_BSP_H
29+
#define _TCOD_BSP_H
30+
31+
typedef struct {
32+
TCOD_tree_t tree; /* pseudo oop : bsp inherit tree */
33+
int x,y,w,h; /* node position & size */
34+
int position; /* position of splitting */
35+
uint8 level; /* level in the tree */
36+
bool horizontal; /* horizontal splitting ? */
37+
} TCOD_bsp_t;
38+
39+
typedef bool (*TCOD_bsp_callback_t)(TCOD_bsp_t *node, void *userData);
40+
41+
TCODLIB_API TCOD_bsp_t *TCOD_bsp_new();
42+
TCODLIB_API TCOD_bsp_t *TCOD_bsp_new_with_size(int x,int y,int w, int h);
43+
TCODLIB_API void TCOD_bsp_delete(TCOD_bsp_t *node);
44+
45+
TCODLIB_API TCOD_bsp_t * TCOD_bsp_left(TCOD_bsp_t *node);
46+
TCODLIB_API TCOD_bsp_t * TCOD_bsp_right(TCOD_bsp_t *node);
47+
TCODLIB_API TCOD_bsp_t * TCOD_bsp_father(TCOD_bsp_t *node);
48+
49+
TCODLIB_API bool TCOD_bsp_is_leaf(TCOD_bsp_t *node);
50+
TCODLIB_API bool TCOD_bsp_traverse_pre_order(TCOD_bsp_t *node, TCOD_bsp_callback_t listener, void *userData);
51+
TCODLIB_API bool TCOD_bsp_traverse_in_order(TCOD_bsp_t *node, TCOD_bsp_callback_t listener, void *userData);
52+
TCODLIB_API bool TCOD_bsp_traverse_post_order(TCOD_bsp_t *node, TCOD_bsp_callback_t listener, void *userData);
53+
TCODLIB_API bool TCOD_bsp_traverse_level_order(TCOD_bsp_t *node, TCOD_bsp_callback_t listener, void *userData);
54+
TCODLIB_API bool TCOD_bsp_traverse_inverted_level_order(TCOD_bsp_t *node, TCOD_bsp_callback_t listener, void *userData);
55+
TCODLIB_API bool TCOD_bsp_contains(TCOD_bsp_t *node, int x, int y);
56+
TCODLIB_API TCOD_bsp_t * TCOD_bsp_find_node(TCOD_bsp_t *node, int x, int y);
57+
TCODLIB_API void TCOD_bsp_resize(TCOD_bsp_t *node, int x,int y, int w, int h);
58+
TCODLIB_API void TCOD_bsp_split_once(TCOD_bsp_t *node, bool horizontal, int position);
59+
TCODLIB_API void TCOD_bsp_split_recursive(TCOD_bsp_t *node, TCOD_random_t randomizer, int nb,
60+
int minHSize, int minVSize, float maxHRatio, float maxVRatio);
61+
TCODLIB_API void TCOD_bsp_remove_sons(TCOD_bsp_t *node);
62+
63+
#endif

0 commit comments

Comments
 (0)