Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ Dawn of Time
➜ Installing/compiling the server
➜ Using Visual Studio 2019 to debug commands
Using Visual Studio 2019 to debug commands
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| BishopOsiris
USA (55 posts) Bio
|
Date
| Mon 23 Aug 2021 10:27 PM (UTC) |
Message
| I've come here with this question because I can't seem to make "non-gamers" understand what I'm asking for. Nick, I know you have extensive knowledge of this code and no one will dispute your developer prowess so I'm hoping you'll have an answer for me.
Here is a link to the question I asked on MS Forums:
https://docs.microsoft.com/en-us/answers/questions/523213/trying-to-debug-a-mud-game.html
Here is a link to the question I asked at cplusplus.com:
http://www.cplusplus.com/forum/general/279593/
I hope you all will understand what I'm looking and have a way to address it.
Thanks | Top |
|
Posted by
| Nick Gammon
Australia (23,097 posts) Bio
Forum Administrator |
Date
| Reply #1 on Tue 24 Aug 2021 02:44 AM (UTC) |
Message
| I understand your question, but you don't have to run the .exe from a DOS prompt.
Just run in "debug" mode from inside Visual Studio. It should just then run (and you would see the output in the output window). You can then place breakpoints where required and the code would stop at that place. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,097 posts) Bio
Forum Administrator |
Date
| Reply #2 on Tue 24 Aug 2021 02:46 AM (UTC) |
Message
| The responses you got off-site appear to be saying the same thing. If that isn't clear please explain in what way it isn't. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,097 posts) Bio
Forum Administrator |
Date
| Reply #3 on Tue 24 Aug 2021 05:54 AM (UTC) Amended on Tue 24 Aug 2021 05:55 AM (UTC) by Nick Gammon
|
Message
| To put the above question into context on this forum, it was:
I’m using Visual Studio 2019 to build a MUD (a text based game popular in the early ’90’s). I’m trying to figure out a way to “play the game” and watch the code execute while I’m doing it. And by “play the game” I mean enter a command like “cast ‘acid blast’ goblin”, set a break point in the code where that command is initiated and then step through the code line-by-line and see the output as it shows in the game. Yes, I realize I might have to step through 90 lines of code before I see output but that’s the point. I want to see how a particular command is executed.
The problem I’m running into is the game as it is runs from an executable created when the code compiles. I run the .exe file from a DOS prompt and the game runs in the background. I connect to the game from a MUD client and play the game that way. I can enter “cast ‘acid blast’ goblin” in the game client but I can’t see the code at that point. I need a way to start the game from VS and be able to enter commands and watch the code while it executes in VS.
Do you guys know how to do that?
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| BishopOsiris
USA (55 posts) Bio
|
Date
| Reply #4 on Tue 24 Aug 2021 09:36 AM (UTC) |
Message
| OK that's a little clearer to me but I still don't know how to enter a command. On MUSHClient I just type "cast 'acid blast' goblin" at the input. Where do I do that in the debugger? | Top |
|
Posted by
| Nick Gammon
Australia (23,097 posts) Bio
Forum Administrator |
Date
| Reply #5 on Tue 24 Aug 2021 09:04 PM (UTC) |
Message
| You seem to be misunderstanding how MUD games work. The thing you compile in Visual Studio is the server. You still need a client (such as MUSHclient) to use it, regardless of whether you are using a debugger or not.
So, you start the server in Visual Studio (in debug mode if you want to enter breakpoints).
Then you start MUSHclient as usual, and connect to your server which you are debugging (eg. localhost port 4000). Then in MUSHclient you type "cast 'acid blast' goblin" in the usual way. If you have your breakpoint set up correctly the the server will stop at the appropriate line, and you can step through and see what is happening. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| BishopOsiris
USA (55 posts) Bio
|
Date
| Reply #6 on Tue 24 Aug 2021 10:59 PM (UTC) |
Message
| This, I think, has been the downfall of my entire line of questioning. I understand the server side/client side of the game. I know MUSHClient is the client side. However, I use the .exe file created during compile to start the server side which runs in a dos window. I don't know how to "run" the game in VS. This is what I've been trying to figure out this whole time. When I run the executable I connect to 127.0.0.1 port 4000 (as you said) with MUSHClient. But I can't see the code this way because the game is running in a dos window. How do I start the server in VS as you're suggesting? | Top |
|
Posted by
| Nick Gammon
Australia (23,097 posts) Bio
Forum Administrator |
Date
| Reply #7 on Wed 25 Aug 2021 02:58 AM (UTC) Amended on Wed 25 Aug 2021 04:25 AM (UTC) by Nick Gammon
|
Message
| One of the menu items in VS is "debug" (F5). That runs the code in its debugger. You don't run the .exe from the command line, you run it from inside VS.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| BishopOsiris
USA (55 posts) Bio
|
Date
| Reply #8 on Wed 15 Sep 2021 11:26 AM (UTC) |
Message
| I did not realize that the debugger ran the program in the background. Very helpful. Thanks Nick | Top |
|
Posted by
| BishopOsiris
USA (55 posts) Bio
|
Date
| Reply #9 on Wed 15 Sep 2021 10:00 PM (UTC) |
Message
| I've tried what you suggested but I am still having no luck. When I run the debugger it runs the entire code and then exits immediately. So there's no game running on the server side.
https://d.pr/i/yIT4qQ
What I envision needs to happen is to start the game in VS using debugger which starts the server side (but doesn't immediately close). Then opening a DOS window to "connect" to the game somehow and use that as the client to interact with the game. Am I thinking about this right?
Of course, if that is the case then I should be able to use MUSHClient to connect to the server side code running in VS, right? | Top |
|
Posted by
| Nick Gammon
Australia (23,097 posts) Bio
Forum Administrator |
Date
| Reply #10 on Wed 15 Sep 2021 10:42 PM (UTC) |
Message
| Your problem is almost certainly that you are debugging in the wrong directory. There is a configuration option for what directory to use when running/debugging. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,097 posts) Bio
Forum Administrator |
Date
| Reply #11 on Wed 15 Sep 2021 11:09 PM (UTC) Amended on Wed 15 Sep 2021 11:25 PM (UTC) by Nick Gammon
|
Message
| Here is where you change it (I think - untested):
So, you change "$(ProjectDir)" to wherever you normally launch the server from.
If there are arguments you usually put on the command line (when running from a DOS window) such as the port number, put that into "Command Arguments" section. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,097 posts) Bio
Forum Administrator |
Date
| Reply #12 on Wed 15 Sep 2021 11:15 PM (UTC) Amended on Wed 15 Sep 2021 11:16 PM (UTC) by Nick Gammon
|
Message
|
Then opening a DOS window to “connect” to the game somehow and use that as the client to interact with the game. Am I thinking about this right?
Not quite. Forget about a DOS window. You run the debugger in Visual Studio which (after you get the directory right) will sit there seemingly doing nothing. Any messages you normally see in the DOS window will appear in the message part of Visual Studio.
Then you connect to the server using MUSHclient in the usual way.
Now if you want to debug a particular part of the code find that line in Visual Studio and put a breakpoint on it. Then execute the thing in MUSHclient that would send the code through that line. You should then see the breakpoint in Visual Studio (and MUSHclient will become unresponsive because it is waiting for a response) and you can look at variables and things.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,097 posts) Bio
Forum Administrator |
Date
| Reply #13 on Wed 15 Sep 2021 11:20 PM (UTC) Amended on Wed 15 Sep 2021 11:23 PM (UTC) by Nick Gammon
|
Message
| An alternative is to run the code exactly how you used to (in a DOS window) and then use Visual Studio debug menu "Attach to Process" which you can see in reply #11.
That then finds the process (I think it gives you a list of running processes and you choose the right one). Assuming you have debug information in the .exe file (because you did a debug build) then you should be able to debug, the same as if you started the debugger inside Visual Studio in the first place.
However I think it is easier to start from inside Visual Studio, assuming you keep making changes to the code. Change the code, recompile, hit F5 to start debugging, and connect with the client. Pretty simple really.
If you've set up the client to reconnect with the right player name and password when you hit <Enter> then the whole debugging session can start up in seconds. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| BishopOsiris
USA (55 posts) Bio
|
Date
| Reply #14 on Fri 17 Sep 2021 01:46 PM (UTC) Amended on Fri 17 Sep 2021 02:11 PM (UTC) by BishopOsiris
|
Message
| I changed the path to the directory containing the .exe file that runs the mud. Still didn't work. Closes out immediately. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
39,269 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top