home
·
contact
·
privacy
projects
/
plomrogue
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
a30d43c
)
Server: Make list of symbols of passable fields configurable.
author
Christian Heller
<c.heller@plomlompom.de>
Mon, 22 Feb 2016 00:54:10 +0000
(
01:54
+0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Mon, 22 Feb 2016 00:54:10 +0000
(
01:54
+0100)
libplomrogue.c
patch
|
blob
|
history
server/actions.py
patch
|
blob
|
history
server/ai.py
patch
|
blob
|
history
server/config/world_data.py
patch
|
blob
|
history
server/world.py
patch
|
blob
|
history
diff --git
a/libplomrogue.c
b/libplomrogue.c
index d0b15a10bc5d260f4fcf1fc75af6551863e01157..d0b656b657f23c225cd0fafe140dcfe92660ca6c 100644
(file)
--- a/
libplomrogue.c
+++ b/
libplomrogue.c
@@
-600,7
+600,8
@@
extern void age_some_memdepthmap_on_nonfov_cells(char * memdepthmap,
}
}
}
}
-extern uint8_t set_cells_passable_on_memmap_to_65534_on_scoremap(char * mem_map)
+extern uint8_t set_cells_passable_on_memmap_to_65534_on_scoremap(char * mem_map,
+ const char * symbols_passable)
{
if (!score_map)
{
{
if (!score_map)
{
@@
-610,7
+611,7
@@
extern uint8_t set_cells_passable_on_memmap_to_65534_on_scoremap(char * mem_map)
uint16_t pos;
for (pos = 0; pos < map_size; pos++)
{
uint16_t pos;
for (pos = 0; pos < map_size; pos++)
{
- if (
'.' == mem_map[pos]
)
+ if (
NULL != strchr(symbols_passable, mem_map[pos])
)
{
score_map[pos] = 65534;
}
{
score_map[pos] = 65534;
}
diff --git
a/server/actions.py
b/server/actions.py
index 849b02661174b41df67658fe92ffddadfd5558d6..6393a0ff249bc0c91e360252c27986688baec0c8 100644
(file)
--- a/
server/actions.py
+++ b/
server/actions.py
@@
-17,7
+17,7
@@
def actor_move(t):
"""If passable, move/collide(=attack) thing into T_ARGUMENT's direction."""
from server.world import build_fov_map, decrement_lifepoints
from server.utils import mv_yx_in_dir_legal
"""If passable, move/collide(=attack) thing into T_ARGUMENT's direction."""
from server.world import build_fov_map, decrement_lifepoints
from server.utils import mv_yx_in_dir_legal
- from server.config.world_data import directions_db
+ from server.config.world_data import directions_db
, symbols_passable
passable = False
move_result = mv_yx_in_dir_legal(chr(t["T_ARGUMENT"]),
t["T_POSY"], t["T_POSX"])
passable = False
move_result = mv_yx_in_dir_legal(chr(t["T_ARGUMENT"]),
t["T_POSY"], t["T_POSX"])
@@
-39,7
+39,7
@@
def actor_move(t):
log(hitter_name +" WOUNDS you.")
decrement_lifepoints(world_db["Things"][hit_id])
return
log(hitter_name +" WOUNDS you.")
decrement_lifepoints(world_db["Things"][hit_id])
return
- passable =
"." == chr(world_db["MAP"][pos])
+ passable =
chr(world_db["MAP"][pos]) in symbols_passable
dir = [dir for dir in directions_db
if directions_db[dir] == chr(t["T_ARGUMENT"])][0]
if passable:
dir = [dir for dir in directions_db
if directions_db[dir] == chr(t["T_ARGUMENT"])][0]
if passable:
diff --git
a/server/ai.py
b/server/ai.py
index 3212be0c09020816370aba309d1b7404b9df3c0b..88b087939f5ca2cd49c428f30fe1420b110c36c1 100644
(file)
--- a/
server/ai.py
+++ b/
server/ai.py
@@
-33,6
+33,7
@@
def get_dir_to_target(t, filter):
"s": memory map cell with greatest-reachable degree of unexploredness
"""
from server.utils import rand, libpr, c_pointer_to_bytearray
"s": memory map cell with greatest-reachable degree of unexploredness
"""
from server.utils import rand, libpr, c_pointer_to_bytearray
+ from server.config.world_data import symbols_passable
def zero_score_map_where_char_on_memdepthmap(c):
# OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
def zero_score_map_where_char_on_memdepthmap(c):
# OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
@@
-112,13
+113,13
@@
def get_dir_to_target(t, filter):
def set_cells_passable_on_memmap_to_65534_on_scoremap():
# OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
def set_cells_passable_on_memmap_to_65534_on_scoremap():
# OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
- # ord_dot = ord(".")
# memmap = t["T_MEMMAP"]
# for i in [i for i in range(world_db["MAP_LENGTH"] ** 2)
# memmap = t["T_MEMMAP"]
# for i in [i for i in range(world_db["MAP_LENGTH"] ** 2)
- # if
ord_dot == memmap[i]
]:
+ # if
memmap[i] in symbols_passable
]:
# set_map_score(i, 65534) # i.e. 65535-1
map = c_pointer_to_bytearray(t["T_MEMMAP"])
# set_map_score(i, 65534) # i.e. 65535-1
map = c_pointer_to_bytearray(t["T_MEMMAP"])
- if libpr.set_cells_passable_on_memmap_to_65534_on_scoremap(map):
+ if libpr.set_cells_passable_on_memmap_to_65534_on_scoremap(map,
+ symbols_passable):
raise RuntimeError("No score map allocated for set_cells_passable"
"_on_memmap_to_65534_on_scoremap().")
raise RuntimeError("No score map allocated for set_cells_passable"
"_on_memmap_to_65534_on_scoremap().")
diff --git
a/server/config/world_data.py
b/server/config/world_data.py
index 193da78a4367286e575b0fb4eb77010f0764b608..97725a3a1fe2f157d9543d33682b0f0cef4041b0 100644
(file)
--- a/
server/config/world_data.py
+++ b/
server/config/world_data.py
@@
-32,3
+32,5
@@
thing_defaults = {
"T_MEMDEPTHMAP": False,
"fovmap": False
}
"T_MEMDEPTHMAP": False,
"fovmap": False
}
+
+symbols_passable = "."
diff --git
a/server/world.py
b/server/world.py
index a05a010dc4636310e4c95b259862b802c07119af..480ea28f424c30335434803f97993cd8c8639602 100644
(file)
--- a/
server/world.py
+++ b/
server/world.py
@@
-8,7
+8,7
@@
def thingproliferation(t, prol_map):
"""To chance of 1/TT_PROLIFERATE, create t offspring in open neighbor cell.
Naturally only works with TT_PROLIFERATE > 0. The neighbor cell must be be
"""To chance of 1/TT_PROLIFERATE, create t offspring in open neighbor cell.
Naturally only works with TT_PROLIFERATE > 0. The neighbor cell must be be
- marked
'.'
in prol_map. If there are several map cell candidates, one is
+ marked
"."
in prol_map. If there are several map cell candidates, one is
selected randomly.
"""
from server.config.world_data import directions_db
selected randomly.
"""
from server.config.world_data import directions_db
@@
-18,7
+18,7
@@
def thingproliferation(t, prol_map):
candidates = []
for dir in [directions_db[key] for key in sorted(directions_db.keys())]:
mv_result = mv_yx_in_dir_legal(dir, t["T_POSY"], t["T_POSX"])
candidates = []
for dir in [directions_db[key] for key in sorted(directions_db.keys())]:
mv_result = mv_yx_in_dir_legal(dir, t["T_POSY"], t["T_POSX"])
- if mv_result[0] and ord(
'.'
) == prol_map[mv_result[1]
+ if mv_result[0] and ord(
"."
) == prol_map[mv_result[1]
* world_db["MAP_LENGTH"]
+ mv_result[2]]:
candidates.append((mv_result[1], mv_result[2]))
* world_db["MAP_LENGTH"]
+ mv_result[2]]:
candidates.append((mv_result[1], mv_result[2]))
@@
-235,6
+235,7
@@
def make_world(seed):
of ID = world["PLAYER_TYPE"]. Place Things randomly, and actors not on each
other. Init player's memory map. Write "NEW_WORLD" line to out file.
"""
of ID = world["PLAYER_TYPE"]. Place Things randomly, and actors not on each
other. Init player's memory map. Write "NEW_WORLD" line to out file.
"""
+ from server.config.world_data import symbols_passable
def free_pos():
i = 0
def free_pos():
i = 0
@@
-243,7
+244,8
@@
def make_world(seed):
while 1:
y = rand.next() % world_db["MAP_LENGTH"]
x = rand.next() % world_db["MAP_LENGTH"]
while 1:
y = rand.next() % world_db["MAP_LENGTH"]
x = rand.next() % world_db["MAP_LENGTH"]
- if "." == chr(world_db["MAP"][y * world_db["MAP_LENGTH"] + x]):
+ if chr(world_db["MAP"][y * world_db["MAP_LENGTH"] + x]) in \
+ symbols_passable:
break
i += 1
if i == 65535:
break
i += 1
if i == 65535: