From 9122bac1a2525fd13fc01bad138820e6ca162dce Mon Sep 17 00:00:00 2001 From: Griatch Date: Thu, 13 Feb 2020 09:38:00 +0100 Subject: [PATCH 1/6] Update README.md --- evennia/server/game_index_client/README.md | 69 +++------------------- 1 file changed, 8 insertions(+), 61 deletions(-) diff --git a/evennia/server/game_index_client/README.md b/evennia/server/game_index_client/README.md index f5077a43e6..5733d656dc 100644 --- a/evennia/server/game_index_client/README.md +++ b/evennia/server/game_index_client/README.md @@ -1,8 +1,8 @@ # Evennia Game Index Client -Greg Taylor 2016 +Greg Taylor 2016, Griatch 2020 -This contrib features a client for the [Evennia Game Index] +This is a client for the [Evennia Game Index] (http://evennia-game-index.appspot.com/), a listing of games built on Evennia. By listing your game on the index, you make it easy for other people in the community to discover your creation. @@ -14,74 +14,21 @@ on remedying this.* ## Listing your Game -To list your game, you'll need to enable the Evennia Game Index client. -Start by `cd`'ing to your game directory. From there, open up -`server/conf/server_services_plugins.py`. It might look something like this -if you don't have any other optional add-ons enabled: +To list your game, go to your game dir and run -```python -""" -Server plugin services + evennia connections -This plugin module can define user-created services for the Server to -start. +Follow the prompts to add details to the listing. -This module must handle all imports and setups required to start a -twisted service (see examples in evennia.server.server). It must also -contain a function start_plugin_services(application). Evennia will -call this function with the main Server application (so your services -can be added to it). The function should not return anything. Plugin -services are started last in the Server startup process. -""" - - -def start_plugin_services(server): - """ - This hook is called by Evennia, last in the Server startup process. - - server - a reference to the main server application. - """ - pass -``` - -To enable the client, import `EvenniaGameIndexService` and fire it up after the -Evennia server has finished starting: - -```python -""" -Server plugin services - -This plugin module can define user-created services for the Server to -start. - -This module must handle all imports and setups required to start a -twisted service (see examples in evennia.server.server). It must also -contain a function start_plugin_services(application). Evennia will -call this function with the main Server application (so your services -can be added to it). The function should not return anything. Plugin -services are started last in the Server startup process. -""" - -from evennia.contrib.egi_client import EvenniaGameIndexService - -def start_plugin_services(server): - """ - This hook is called by Evennia, last in the Server startup process. - - server - a reference to the main server application. - """ - egi_service = EvenniaGameIndexService() - server.services.addService(egi_service) -``` - -Next, configure your game listing by opening up `server/conf/settings.py` and +If you don't want to use the wizard you can configure your game listing by opening up `server/conf/settings.py` and using the following as a starting point: ```python ###################################################################### -# Contrib config +# Game index ###################################################################### +GAME_INDEX_ENABLED = True GAME_INDEX_LISTING = { 'game_status': 'pre-alpha', # Optional, comment out or remove if N/A From 3a10f35abde6cf58adeb8d62356dd8f05bbb10fa Mon Sep 17 00:00:00 2001 From: Griatch Date: Thu, 13 Feb 2020 09:39:13 +0100 Subject: [PATCH 2/6] Update README.md --- evennia/server/game_index_client/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/evennia/server/game_index_client/README.md b/evennia/server/game_index_client/README.md index 5733d656dc..5471ba7418 100644 --- a/evennia/server/game_index_client/README.md +++ b/evennia/server/game_index_client/README.md @@ -18,7 +18,10 @@ To list your game, go to your game dir and run evennia connections -Follow the prompts to add details to the listing. +Follow the prompts to add details to the listing. Use `evennia reload`. In your log (visible with `evennia --log` +you should see a note that info has been sent to the game index. + +## Detailed settings If you don't want to use the wizard you can configure your game listing by opening up `server/conf/settings.py` and using the following as a starting point: From fb83d7f27740a31f5344dd830f2883058ca995c6 Mon Sep 17 00:00:00 2001 From: trhr Date: Fri, 14 Feb 2020 23:50:44 -0600 Subject: [PATCH 3/6] log_error is not a function in utils/logger.py; changed to log_err in utils/dbserialize.py --- evennia/utils/dbserialize.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/evennia/utils/dbserialize.py b/evennia/utils/dbserialize.py index eb728863c1..ddfdb765de 100644 --- a/evennia/utils/dbserialize.py +++ b/evennia/utils/dbserialize.py @@ -577,7 +577,7 @@ def to_pickle(data): except TypeError: return item except Exception: - logger.log_error(f"The object {item} of type {type(item)} could not be stored.") + logger.log_err(f"The object {item} of type {type(item)} could not be stored.") raise return process_item(data) @@ -716,7 +716,7 @@ def do_pickle(data): try: return dumps(data, protocol=PICKLE_PROTOCOL) except Exception: - logger.log_error(f"Could not pickle data for storage: {data}") + logger.log_err(f"Could not pickle data for storage: {data}") raise @@ -725,7 +725,7 @@ def do_unpickle(data): try: return loads(to_bytes(data)) except Exception: - logger.log_error(f"Could not unpickle data from storage: {data}") + logger.log_err(f"Could not unpickle data from storage: {data}") raise From d0035b83fb7905b357a09ef893054b87cc799a7c Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 16 Feb 2020 20:12:13 +0100 Subject: [PATCH 4/6] Typo in CmdTeleport help text --- evennia/commands/default/building.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index 47ebaa9296..77b704356c 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -2832,8 +2832,8 @@ class CmdTeleport(COMMAND_DEFAULT_CLASS): reference. A puppeted object cannot be moved to None. loc - teleport object to the target's location instead of its contents - Teleports an object somewhere. If no object is given, you yourself - is teleported to the target location. + Teleports an object somewhere. If no object is given, you yourself are + teleported to the target location. """ key = "tel" From 27babf4469ffb1927bcab4fb585933d13e1b8c48 Mon Sep 17 00:00:00 2001 From: Griatch Date: Mon, 17 Feb 2020 01:11:31 +0100 Subject: [PATCH 5/6] Add inside_rec lockfunc. Resolves #1618 --- CHANGELOG.md | 2 ++ evennia/locks/lockfuncs.py | 30 +++++++++++++++++++++++++++++- evennia/locks/tests.py | 8 ++++++++ evennia/server/portal/amp.py | 8 ++++++-- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80c011be68..6a22e04dc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,8 @@ without arguments starts a full interactive Python console. `.get_command_info()` method for easier overloading and access. (Volund) - Removed unused `CYCLE_LOGFILES` setting. Added `SERVER_LOG_DAY_ROTATION` and `SERVER_LOG_MAX_SIZE` (and equivalent for PORTAL) to control log rotation. +- Addded `inside_rec` lockfunc - if room is locked, the normal `inside()` lockfunc will + fail e.g. for your inventory objs (since their loc is you), whereas this will pass. ## Evennia 0.9 (2018-2019) diff --git a/evennia/locks/lockfuncs.py b/evennia/locks/lockfuncs.py index bd137aed8b..eda4c2d733 100644 --- a/evennia/locks/lockfuncs.py +++ b/evennia/locks/lockfuncs.py @@ -547,11 +547,39 @@ def inside(accessing_obj, accessed_obj, *args, **kwargs): Usage: inside() - Only true if accessing_obj is "inside" accessed_obj + True if accessing_obj is 'inside' accessing_obj. Note that this only checks + one level down. So if if the lock is on a room, you will pass but not your + inventory (since their location is you, not the locked object). If you + want also nested objects to pass the lock, use the `insiderecursive` + lockfunc. """ return accessing_obj.location == accessed_obj +def inside_rec(accessing_obj, accessed_obj, *args, **kwargs): + """ + Usage: + inside_rec() + + True if accessing_obj is inside the accessed obj, at up to 10 levels + of recursion (so if this lock is on a room, then an object inside a box + in your inventory will also pass the lock). + """ + + def _recursive_inside(obj, accessed_obj, lvl=1): + if obj.location: + if obj.location == accessed_obj: + return True + elif lvl >= 10: + # avoid infinite recursions + return False + else: + return _recursive_inside(obj.location, accessed_obj, lvl + 1) + return False + + return _recursive_inside(accessing_obj, accessed_obj) + + def holds(accessing_obj, accessed_obj, *args, **kwargs): """ Usage: diff --git a/evennia/locks/tests.py b/evennia/locks/tests.py index bb02877f06..dce0e28fff 100644 --- a/evennia/locks/tests.py +++ b/evennia/locks/tests.py @@ -17,6 +17,7 @@ except ImportError: from evennia import settings_default from evennia.locks import lockfuncs +from evennia.utils.create import create_object # ------------------------------------------------------------ # Lock testing @@ -179,6 +180,13 @@ class TestLockfuncs(EvenniaTest): self.assertEqual(False, lockfuncs.inside(self.char1, self.room2)) self.assertEqual(True, lockfuncs.holds(self.room1, self.char1)) self.assertEqual(False, lockfuncs.holds(self.room2, self.char1)) + # test recursively + self.assertEqual(True, lockfuncs.inside_rec(self.char1, self.room1)) + self.assertEqual(False, lockfuncs.inside_rec(self.char1, self.room2)) + inventory_item = create_object(key="InsideTester", location=self.char1) + self.assertEqual(True, lockfuncs.inside_rec(inventory_item, self.room1)) + self.assertEqual(False, lockfuncs.inside_rec(inventory_item, self.room2)) + inventory_item.delete() def test_has_account(self): self.assertEqual(True, lockfuncs.has_account(self.char1, None)) diff --git a/evennia/server/portal/amp.py b/evennia/server/portal/amp.py index 0d4924a540..505ea5e3e0 100644 --- a/evennia/server/portal/amp.py +++ b/evennia/server/portal/amp.py @@ -314,7 +314,9 @@ class AMPMultiConnectionProtocol(amp.AMP): try: super(AMPMultiConnectionProtocol, self).dataReceived(data) except KeyError: - _get_logger().log_trace("Discarded incoming partial (packed) data (len {})".format(len(data))) + _get_logger().log_trace( + "Discarded incoming partial (packed) data (len {})".format(len(data)) + ) elif self.multibatches: # invalid AMP, but we have a pending multi-batch that is not yet complete if data[-2:] == NULNUL: @@ -323,7 +325,9 @@ class AMPMultiConnectionProtocol(amp.AMP): try: super(AMPMultiConnectionProtocol, self).dataReceived(data) except KeyError: - _get_logger().log_trace("Discarded incoming multi-batch (packed) data (len {})".format(len(data))) + _get_logger().log_trace( + "Discarded incoming multi-batch (packed) data (len {})".format(len(data)) + ) else: # not an AMP communication, return warning self.transport.write(_HTTP_WARNING) From e9d14f8673c119bcffec9f869f89e32eb2b54f76 Mon Sep 17 00:00:00 2001 From: Griatch Date: Mon, 17 Feb 2020 09:03:59 +0100 Subject: [PATCH 6/6] Use only minor version for django recommended warning --- evennia/server/evennia_launcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/evennia/server/evennia_launcher.py b/evennia/server/evennia_launcher.py index ce0dfb2fa0..e4a1518a75 100644 --- a/evennia/server/evennia_launcher.py +++ b/evennia/server/evennia_launcher.py @@ -94,7 +94,7 @@ SRESET = chr(19) # shutdown server in reset mode PYTHON_MIN = "3.7" TWISTED_MIN = "18.0.0" DJANGO_MIN = "2.1" -DJANGO_REC = "2.2.9" +DJANGO_REC = "2.2" try: sys.path[1] = EVENNIA_ROOT @@ -1281,7 +1281,7 @@ def check_main_evennia_dependencies(): try: dversion = ".".join(str(num) for num in django.VERSION if isinstance(num, int)) # only the main version (1.5, not 1.5.4.0) - dversion_main = ".".join(dversion.split(".")[:3]) + dversion_main = ".".join(dversion.split(".")[:2]) if LooseVersion(dversion) < LooseVersion(DJANGO_MIN): print(ERROR_DJANGO_MIN.format(dversion=dversion_main, django_min=DJANGO_MIN)) error = True