www.ClassicTW.com
http://classictw.com/

Unambiguously indicating game selection
http://classictw.com/viewtopic.php?f=58&t=33213
Page 1 of 2

Author:  Mongoose [ Sun May 13, 2012 12:45 am ]
Post subject:  Unambiguously indicating game selection

SWATH has a bug where if you manually enter the wrong game, it will start parsing data for that game and potentially corrupt the database if you save it. I'm trying to avoid that bug in my own helper, but parsing a player's game selection from the TWGS prompt is a bit problematic. I think I've figured out a way to do it, but it's rather complex because a player can do other things besides enter a game from the TWGS prompt. It would be greatly simplified if there were some unambiguous indication that a player has selected a particular game. Outputting a message like "Entering game C" would be enough.

This could also be combined with my previous suggestion about giving games a UUID when they are banged, for even greater certainty that the game being played corresponds with the database loaded in the helper. The complete message could be something like:

Quote:
Entering game C {5462dc18-4653-42d1-b4e4-22fc970a6ce5}

Author:  T0yman [ Sun May 13, 2012 7:15 am ]
Post subject:  Re: Unambiguously indicating game selection

The only way to manually enter the wrong game with SWATH is if your using it connected through TWX. So technically the bug is in TWX and not SWATH. Problem is the listening port is not tied to a game which can allow you to connect to the wrong game DB. If TWX was changed to look like the attached picture this should resolve the connecting to wrong game issues.
I have requested this twice and still not done, so until then people will just have to learn to pay attention.

Attachment:
twx.jpg
twx.jpg [ 86.3 KiB | Viewed 17714 times ]

Author:  Mongoose [ Sun May 13, 2012 10:31 am ]
Post subject:  Re: Unambiguously indicating game selection

Manually logging into the wrong game is easy using SWATH alone. The simplest way is to click "No" when it asks if you want to auto-login, then select the wrong game. You can also log out of the correct game, think "Hmm, I wonder how this other game is going", and forget to turn off parsing before you look at it. Even just viewing the scores clutters the SWATH database with the names of players from the other game.

My complicated solution is that whenever the TWGS "Selection (? for menu): " prompt appears, my lexer enters a special TWGS_PROMPT state. From there, the letters [A-PR-Z] followed by a newline trigger a "gameSelected" event. The parser compares the selected game to the database and puts the lexer into either the CORRECT_GAME or WRONG_GAME state. Any other input drops the lexer back to the TWGS state, where it watches for the prompt to appear again. A newline by itself indicates the beginning of an asynchronous message from the server, like a shutdown announcement. That gets a little more complicated because the announcement could contain a message from the sysop, and that message could contain anything, including a game letter on a line by itself. To get around this, my lexer enters yet another special state when it sees the beginning of an async message, and remains in that state until it sees one of the standard server messages beginning with the ASCII bell character. The "Selection" prompt is not redisplayed, but you are actually still at that prompt, so the lexer falls back to the TWGS_PROMPT state and starts looking for a game letter again.

I *think* I've covered all the bases... but man, this was needlessly complicated. No surprise that other helpers don't even try.

Author:  T0yman [ Sun May 13, 2012 10:47 am ]
Post subject:  Re: Unambiguously indicating game selection

I won't debate what your saying, I guess I just don't understand since the game info is tied to a database. So connecting to another game requires you to manually type in all the information instead of simply selecting a game that would take you to the right game and change all associated files unless your changing games using TWX (which is a TWX problem). By simply adding the listening port to TWX Game DB it would stop you from connecting without changing the listening port.

I can't get my mind around how Swath being ran stand alone would cause you to corrupt data since when you open a saved game to check it changes all associated files.

Swath/TWX yea it has been a problem for a long time...

So the question is ... are you talking Swath Alone or connected through TWX?

Author:  Mongoose [ Sun May 13, 2012 10:54 am ]
Post subject:  Re: Unambiguously indicating game selection

I'm not talking about different servers, just different games on the same server. If I start up SWATH and load the DB for, say, Cruncher's game C, and then connect and manually log into game A instead, the database can get corrupted. SWATH doesn't notice a problem until it sees a sector number that's too high for the DB currently loaded. I'm trying to ensure that my helper notices and shuts down parsing when it sees the "A" at the TWGS prompt. But all the other things that can happen at that prompt make it complicated, and a distinct message that you've selected a certain game would make it simple. The addition of a UUID would alert the helper even if a sysop rebanged a game or changed the game letter.

Author:  T0yman [ Sun May 13, 2012 1:18 pm ]
Post subject:  Re: Unambiguously indicating game selection

OK, I got what your saying now. I never just back out of a game so I was confused what you were trying to say. :D

I always just log out & use telnet to go on a server and snoop around.

I do know that Stein is making some other changes, you might send this suggestion directly to him since I am not sure how much he visits the forum. I have the newest beta for testing and there are some nice changes coming that I thin everyone will enjoy. Never to late to add something else. :wink:

Author:  Vid Kid [ Sun May 13, 2012 6:45 pm ]
Post subject:  Re: Unambiguously indicating game selection

Ok , I have been following this thread for awhile.
Toyman brings up an idea where he wants to assosiate the listening port to the twx database (on the setup screen)
But since my login script already prevents you from entering a game that you have not already made an account in .. the safty is in place.

I did a little code check and have written a test to check what listening port
is being used for twx proxy.
So the only thing left is to work it into twx login and store it into the .cfg file to compair with.

I'm not sure how I will be able to use this to prevent a twx from using the same listening port on 2 games yet.
But I will keep working (thinking of a solution)

Code below :

Code:
GetMenuValue TWX_RECONNECT $val
Echo ANSI_10 "*TWX_LISTENPORT is : "& ANSI_14 $val "*"

Author:  Mongoose [ Wed May 16, 2012 4:37 pm ]
Post subject:  Re: Unambiguously indicating game selection

I've got it recognizing the game letter at the TWGS prompt. This method should prevent most accidents... but again, it'll fail if the sysop ever changes the game letter. I'd still really love to see a game UUID.

Author:  Vid Kid [ Wed May 16, 2012 8:33 pm ]
Post subject:  Re: Unambiguously indicating game selection

Here is a piece of code that will tie twx listening port to a game.
It is used when you have multiple twx's open and want to insure
not to mix them by accident.

Based on a conversation I had with Toyman and listening ports.
Add this to your login script and all is well.

Code:
LoadVar $LISTENPORT
GetMenuValue TWX_LISTENPORT $val
IF ($LISTENPORT < "1")
GetMenuValue TWX_LISTENPORT $val
SetVar $LISTENPORT $val
SaveVar $LISTENPORT
Goto :LPort
End
IF ($LISTENPORT = $val)
Else
Sound failed
Disconnect
Echo ANSI_10 "*TWX_LISTENPORT Should be : "& ANSI_14 $LISTENPORT "*"
Halt
End
:LPort
# Echo ANSI_10 "*TWX_LISTENPORT is : "& ANSI_14 $val "*"

Author:  Vid Kid [ Wed May 16, 2012 8:38 pm ]
Post subject:  Re: Unambiguously indicating game selection

I could not find the original thread about the twx and UUID things about keeping from getting corrupt data.
I also could not find the post where I put up a 2 line code to show how to locate the twx listening port.

So I continued the thread here where it was talking about corrupt data in hopes to further helping others in the prevention of such things.

But if all we were to answer was for Auto Save feature ..
Swath & twx (which are the most used current helper programs)
Swath asks for user intervention and twx does auto save.
So having a new helper software auto save , once it can detect and prevent data corruption , would be nice ..

For now though , having the user decide if they want to save date (once they KNOW they did not pick up false data) though say the Swath Sync
or TWX Sync or KNOW for sure they have NEVER been in another game , has been our best option. Swath 1.9.8 maybe even one before that
will put up a banner when it does detect corrupt data.

Vid

Author:  Mongoose [ Sun May 20, 2012 2:42 am ]
Post subject:  Re: Unambiguously indicating game selection

Turns out that if a sysop has customized their TWGS menu, the game selection prompt can be completely different, making it impossible to detect game selection.

So... still dreaming of that unambiguous "game selected" message.

Author:  Mongoose [ Sun May 20, 2012 2:53 am ]
Post subject:  Re: Unambiguously indicating game selection

Oooh... I just thought of something. I could create a rule that matches [A-PR-Z] followed by the stuff that leads up to that "Trade Wars 2002 Win32 module now loading" message. I feel so frickin' clever right now. I'll see if it works tomorrow.

Author:  Mongoose [ Sun May 20, 2012 11:26 am ]
Post subject:  Re: Unambiguously indicating game selection

Code:
[A-PR-Z]&#27;\[2J&#27;\[H&#27;\[0m&#27;\[2J&#27;\[H&#27;\[2J&#27;\[H&#27;\[0m&#27;\[2J&#27;\[H&#27;\[2J&#27;\[H&#27;\[1;36mTrade Wars &#27;\[33m2002 &#27;\[30mWin32 module now loading.


Oh yes... this rule seems to work perfectly. Weird how it clears the screen, like, four times.

Author:  Vid Kid [ Sun May 20, 2012 11:59 am ]
Post subject:  Re: Unambiguously indicating game selection

the
Code:
[2J

will home your curser , looks like 5 times in what you wrote , if I'm not mistaken.

Author:  Mongoose [ Sun May 20, 2012 12:34 pm ]
Post subject:  Re: Unambiguously indicating game selection

Yeah. All those redundant ANSI codes are what TWGS spews immediately after you select a game letter. At least on 2.xx... I haven't looked at what it sends on 1.xx or HVS yet. I seem to remember that back in the day, it just said "Trade Wars 2002 module now loading", not "Win32". But if it's slightly different on different versions, I can just change the regex to match them all.

Page 1 of 2 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/