festivecasual / sigma-mud

Experimental MUD server in Python
0 stars 0 forks source link

Logging out during combat does bad things #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Enter combat with another player, or denizen.
2. Quit the game.
3. The combat instance will try to reference the player, and instead crap out.

What is the expected output? What do you see instead?

The combat should be ended gracefully upon logout.

Please use labels and text to provide additional information.

Original issue reported on code.google.com by meagains...@gmail.com on 19 Jul 2010 at 7:57

GoogleCodeExporter commented 9 years ago
Since Python reference-counts, it's not enough to destroy an object in one 
context; it lives on until it is destroyed in all contexts.  Right now, my 
original logic in network.py ignores an object's membership in our new 
structures:

http://code.google.com/p/sigma-mud/source/browse/trunk/network.py#37

Aside from clearing the master list, the only other delete is from the current 
room's players list.  This was great at first, but it at least needs to be 
broadened and likely belongs to the player class itself or libsigma.  The 
player object knows his memberships better than the basic program context.

Of course, the act of quitting during combat is in itself a gateway for 
misbehavior.  Circle implemented the 'link-dead' concept to allow a player to 
die honorably even when a player was disconnected.  While their implementation 
was sophisticated, my feeling is that the framework can be restricted to when a 
player is in active combat.

At this moment, I'm okay with allowing a chicken escape via automatic logout on 
link death.  Later, this can be added fairly easily with a new zombie playstate 
and the associated command and login handling.  But, we at least need to refine 
the logout mechanism to remove crashes from the equation.

One of my biggest fears from my original codebase was that too much exception 
logic would be pushed out to the game mechanisms.  I would prefer to see the 
combat be agnostic of absent players.  Otherwise, this is a severe blockage to 
designer participation in the codebase, and so is a major threat to the mission 
of the project.  The objects themselves and libsigma must be able to account 
for these things before they reach configurable code, which would include the 
combat task and player commands.

A test of reference counting is attached.

As an aside but still on this subject, Player probably needs to check the link 
before sending or receiving anything at all across the wire.  Otherwise, an 
unlinked player could crash the system with a socket failure.  Is the crash 
currently on socket transmit/receive?

Production system will also need to catch all exceptions and log them rather 
than crashing!  But this should be configurable of course.

Original comment by bmcca...@gmail.com on 20 Jul 2010 at 7:10

Attachments: