Repository: evennia/evennia

Issue:
[BUG] Expanded Room time-of-day tags do not update until post-character entry
#### Describe the bug
When entering an Expanded Room, characters will see an out-of-date description if time has reached a new tag but the room hasn't updated yet.

#### To Reproduce
Steps to reproduce the behavior:
1. Use Expanded Rooms contrib
2. Create a room with time of day tags.
3. Visit room after time-of-day change.
4. See error

#### Expected behavior
Rooms should update before a character enters so that the description is not incorrect.

![image](https://github.com/evennia/evennia/assets/73198594/cd7719e8-b7c5-47c0-b9d5-81f5e42c9e39)




Discussion:
Issue resolves if `at_post_move` logic is moved instead to `at_object_receive`, but I'm not sure that's an ideal solution.
I'm not familiar with the extended room code but this definitely sounds wrong. It should check if it needs to be updated when *looked at*, not based on object entry or departure, or things like changing time of day will not update correctly when spending time in a room.

It could be that it is, but the update is occurring after the description is retrieved instead of before?
I did some initial investigation of this, but didn't immedately see the issue. Will need more research.

Resolving patch:
diff --git a/evennia/contrib/grid/extended_room/extended_room.py b/evennia/contrib/grid/extended_room/extended_room.py
--- a/evennia/contrib/grid/extended_room/extended_room.py
+++ b/evennia/contrib/grid/extended_room/extended_room.py
@@ -47,6 +47,7 @@ def at_cmdset_creation(self):
 
 from django.conf import settings
 from django.db.models import Q
+
 from evennia import (
     CmdSet,
     DefaultRoom,
@@ -432,16 +433,16 @@ def replace_legacy_time_of_day_markup(self, desc):
 
         """
         desc = desc or ""
-        time_of_day = self.get_time_of_day()
+        current_time_of_day = self.get_time_of_day()
 
         # regexes for in-desc replacements (gets cached)
         if not hasattr(self, "legacy_timeofday_regex_map"):
             timeslots = deque()
-            for time_of_day in self.times_of_day:
+            for tod in self.times_of_day:
                 timeslots.append(
                     (
-                        time_of_day,
-                        re.compile(rf"<{time_of_day}>(.*?)</{time_of_day}>", re.IGNORECASE),
+                        tod,
+                        re.compile(rf"<{tod}>(.*?)</{tod}>", re.IGNORECASE),
                     )
                 )
 
@@ -453,11 +454,10 @@ def replace_legacy_time_of_day_markup(self, desc):
                 timeslots.rotate(-1)
 
         # do the replacement
-        regextuple = self.legacy_timeofday_regex_map[time_of_day]
-        desc = regextuple[0].sub(r"\1", desc)
-        desc = regextuple[1].sub("", desc)
-        desc = regextuple[2].sub("", desc)
-        return regextuple[3].sub("", desc)
+        regextuple = self.legacy_timeofday_regex_map[current_time_of_day]
+        for regex in regextuple:
+            desc = regex.sub(r"\1" if regex == regextuple[0] else "", desc)
+        return desc
 
     def get_display_desc(self, looker, **kwargs):
         """


Test patch: