From: Christian Heller Date: Mon, 22 Feb 2016 00:54:10 +0000 (+0100) Subject: Server: Make list of symbols of passable fields configurable. X-Git-Tag: tce~187 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/process?a=commitdiff_plain;h=2d78939fd39c64a41742a73558708628e38e282d;p=plomrogue Server: Make list of symbols of passable fields configurable. --- diff --git a/libplomrogue.c b/libplomrogue.c index d0b15a1..d0b656b 100644 --- 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) { @@ -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++) { - if ('.' == mem_map[pos]) + if (NULL != strchr(symbols_passable, mem_map[pos])) { score_map[pos] = 65534; } diff --git a/server/actions.py b/server/actions.py index 849b026..6393a0f 100644 --- 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 - 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"]) @@ -39,7 +39,7 @@ def actor_move(t): 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: diff --git a/server/ai.py b/server/ai.py index 3212be0..88b0879 100644 --- 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 + from server.config.world_data import symbols_passable 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: - # ord_dot = ord(".") # 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"]) - 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().") diff --git a/server/config/world_data.py b/server/config/world_data.py index 193da78..97725a3 100644 --- a/server/config/world_data.py +++ b/server/config/world_data.py @@ -32,3 +32,5 @@ thing_defaults = { "T_MEMDEPTHMAP": False, "fovmap": False } + +symbols_passable = "." diff --git a/server/world.py b/server/world.py index a05a010..480ea28 100644 --- 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 - 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 @@ -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"]) - 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])) @@ -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. """ + from server.config.world_data import symbols_passable 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"] - 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: