X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=roguelike-server;h=187835d1ce11bc04d47071fd298d5b4256635d12;hb=701258936cd27bc93649c4074532d4b1d40542df;hp=75606ac32f53c5a995e25f0f0ad2320c242ed8d7;hpb=458d6dd3a3ccc56c04e459a6c8ca289d7bcf92b6;p=plomrogue diff --git a/roguelike-server b/roguelike-server index 75606ac..187835d 100755 --- a/roguelike-server +++ b/roguelike-server @@ -110,7 +110,8 @@ def obey(command, prefix, replay=False, do_record=False): is called (and io_db["record_chunk"] written) if 15 seconds have passed since the last time it was called. The prefix string is inserted into the server's input message between its beginning 'input ' and ':'. All activity - is preceded by a server_test() call. + is preceded by a server_test() call. Commands that start with a lowercase + letter are ignored when world_db["WORLD_ACTIVE"] is False/0. """ server_test() if io_db["verbose"]: @@ -124,6 +125,8 @@ def obey(command, prefix, replay=False, do_record=False): and len(tokens) == commands_db[tokens[0]][0] + 1: if commands_db[tokens[0]][1]: commands_db[tokens[0]][2](*tokens[1:]) + elif tokens[0][0].islower() and not world_db["WORLD_ACTIVE"]: + print("Ignoring lowercase-starting commands when world inactive.") elif replay: print("Due to replay mode, reading command as 'go on in record'.") line = io_db["file_record"].readline() @@ -140,7 +143,8 @@ def obey(command, prefix, replay=False, do_record=False): if time.time() > io_db["save_wait"] + 15: atomic_write(io_db["path_record"], io_db["record_chunk"], do_append=True) - save_world() + if world_db["WORLD_ACTIVE"]: + save_world() io_db["record_chunk"] = "" io_db["save_wait"] = time.time() io_db["worldstate_updateable"] = world_db["WORLD_ACTIVE"] @@ -1177,7 +1181,8 @@ def command_ping(): def command_quit(): """Abort server process.""" if None == opts.replay: - save_world() + if world_db["WORLD_ACTIVE"]: + save_world() atomic_write(io_db["path_record"], io_db["record_chunk"], do_append=True) raise SystemExit("received QUIT command") @@ -1344,10 +1349,9 @@ def command_worldactive(worldactive_string): """Toggle world_db["WORLD_ACTIVE"] if possible. An active world can always be set inactive. An inactive world can only be - set active with a "wait" ThingAction, and a player Thing (of ID 0). On - activation, rebuild all Things' FOVs, and the player's map memory. + set active with a "wait" ThingAction, and a player Thing (of ID 0), and a + map. On activation, rebuild all Things' FOVs, and the player's map memory. """ - # In original version, map existence was also tested (unnecessarily?). val = integer_test(worldactive_string, 0, 1) if val: if 0 != world_db["WORLD_ACTIVE"]: @@ -1366,7 +1370,7 @@ def command_worldactive(worldactive_string): if 0 == Thing: player_exists = True break - if wait_exists and player_exists: + if wait_exists and player_exists and "MAP" in world_db: for id in world_db["Things"]: if world_db["Things"][id]["T_LIFEPOINTS"]: build_fov_map(world_db["Things"][id])