Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Seran
Newbie


Joined: 21 Apr 2017
Posts: 8

PostPosted: Fri Apr 21, 2017 8:12 pm   

GMCP bug for Room.Players
 
When I get Room.Players from GMCP, the list seems to show every player I have encountered from every room I have been to, not just the ones in the current room. Is there a way to only see the players in the current room I'm in (after I've been to several other rooms)?
Room.AddPlayer and Room.RemovePlayer seem to have the same problem.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sat Apr 22, 2017 1:17 am   
 
Sounds like it might be something gameside with the variables not being cleared properly, before they send you updated information.
I hate to push it off, but this may be an issue for the admin on your game.
_________________
Discord: Shalimarwildcat
Reply with quote
Seran
Newbie


Joined: 21 Apr 2017
Posts: 8

PostPosted: Sat Apr 22, 2017 10:16 pm   
 
shalimar wrote:
Sounds like it might be something gameside with the variables not being cleared properly, before they send you updated information.
I hate to push it off, but this may be an issue for the admin on your game.


I checked with another player of the same game who uses a different client, they said they don't have this problem.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Apr 23, 2017 2:14 am   
 
Sounds similar to this issue: http://forums.zuggsoft.com/forums/viewtopic.php?t=38639
I'm not sure that it's really an issue on either end, moreso a misunderstanding of how GMCP data is cached.
Reply with quote
Seran
Newbie


Joined: 21 Apr 2017
Posts: 8

PostPosted: Sun Apr 23, 2017 1:40 pm   
 
Daern wrote:
Sounds similar to this issue: http://forums.zuggsoft.com/forums/viewtopic.php?t=38639
I'm not sure that it's really an issue on either end, moreso a misunderstanding of how GMCP data is cached.


It looks like the Room exits issue was fixed by Zugg 7 years ago. Although CMud caches GMCP data until something changes, however despite the caching, the non-Room.Player related data are always current and accurate. Room.Players, Room.AddPlayer and Room.RemovePlayer are no longer accurate once the player has been to more than one room, I would call that a bug.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Mon Apr 24, 2017 2:39 am   
 
The problem is that the GMCP spec doesn't have any way to tell the client which data should and shouldn't be cached, and so CMUD caches everything. If there's anything that you don't want to be cached, you need to handle those cases manually. Something like this should do the trick (might not work exactly as written, I haven't written code for CMUD in a few years, but gives you a general idea anyway):

Code:
#var PlayersInRoom {}
#trigger {Room.Players} {PlayersInRoom = %gmcp.Room.Players;%gmcp.Room.Players = {}} "gmcp"
#trigger {Room.AddPlayer} {#additem PlayersInRoom %gmcp.Room.AddPlayer;%gmcp.Room.AddPlayer = {}} "gmcp"
#trigger {Room.RemovePlayer} {#loop %numitems(@PlayersInRoom) {#if (%db(%item(@PlayersInRoom, %i), "name") == %gmcp.Room.RemovePlayer) {#delnitem PlayersInRoom %i;#break}};%gmcp.Room.RemovePlayer = ""} "gmcp"
Reply with quote
Seran
Newbie


Joined: 21 Apr 2017
Posts: 8

PostPosted: Sat Apr 29, 2017 11:01 pm   
 
Daern wrote:
The problem is that the GMCP spec doesn't have any way to tell the client which data should and shouldn't be cached, and so CMUD caches everything. If there's anything that you don't want to be cached, you need to handle those cases manually. Something like this should do the trick (might not work exactly as written, I haven't written code for CMUD in a few years, but gives you a general idea anyway):

Code:
#var PlayersInRoom {}
#trigger {Room.Players} {PlayersInRoom = %gmcp.Room.Players;%gmcp.Room.Players = {}} "gmcp"
#trigger {Room.AddPlayer} {#additem PlayersInRoom %gmcp.Room.AddPlayer;%gmcp.Room.AddPlayer = {}} "gmcp"
#trigger {Room.RemovePlayer} {#loop %numitems(@PlayersInRoom) {#if (%db(%item(@PlayersInRoom, %i), "name") == %gmcp.Room.RemovePlayer) {#delnitem PlayersInRoom %i;#break}};%gmcp.Room.RemovePlayer = ""} "gmcp"



Thanks, that worked. Correct syntax for the triggers:
Code:
#TRIGGER {Room.Players} {PlayersInRoom = %gmcp.Room.Players; #loopdb %gmcp.Room.Players {#delkey %gmcp.Room.Players %key}} "gmcp"
#TRIGGER {Room.AddPlayer} {#loopdb %gmcp.Room.AddPlayer { #addkey PlayersInRoom %key %val;   #delkey %gmcp.Room.AddPlayer %key}} "gmcp"
#TRIGGER {Room.RemovePlayer} {#delkey PlayersInRoom %gmcp.Room.RemovePlayer} "gmcp"


Note:
1. The script does not work in Lua since zs.sys.gmcp is readonly and cannot be overwritten
2. In zscript, setting %gmcp.Room.Players = {} screws up the variable as CMUD must retain a reference to the original table elsewhere and will not update the new {}.
3. I have not bothered to reset Room.RemovePlayer for my game since it only shows the last player who left the room, not a list of players like Room.Players or Room.AddPlayer.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Apr 30, 2017 5:34 am   
 
Awesome, thanks for fixing it up :) I'll keep this post for future reference.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net