Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Knowledge Base: Debug
#1
Well, I couldn't post in the Knowledge Base forum so...

Now. Programming an online game is by no means a small task (unless you use some shitty engine... but why are you reading this if you use an engine ^_^). It can be quite difficult keeping track of the packets being sent, buttons being pressed, subroutines being called. People who have spent the most time customizing the source will know that it gets very big. I think I have around 15-20 .bas files in Naruto Realm Beta, and I only just started programming that a month or two ago!

So we need to see what is actually going on in the program whilst it is running. Which is fine when dealing with the visual stuff. If you added in mining and you see your person mine like you programmed it, see the rock/ore/whatever enter your inventory you know it has all working out. Nice and peachy. But then whilst dealing with packet encryption, tricky combat subroutines and functions and the like, you start to need to know more than 'it worked' and you need to start seeing what the integers, bytes and strings have become whilst the program was running. You also need it written out in a way you will understand!

Now, I know Mirage comes with some sort of 'debug' form (which I couldn't get to work until writing something up in handlekeypresses...) and it might work for you. But when you close down the test run of your game, you lose that data (unless copied to a text file or something stupid like that...). Now, this function I am about to tell you will allow you to keep track of all the important variables in your server or client, and have them in a editable, deleteable and readable text file, even whilst not in 'Run' mode!

Code:
Debug.Print

=) Nice and easy.

You can use it like this, to show the 'name' of your packet

Code:
Debug.Print "Packet 'name': " & Parse(0)

You can have it to have a look at a packets encryption key, pre-compressed data and post-compressed data.

Code:
Debug.Print "Packet Key: " & UnCompress(Key, COMPRESS_KEY)
Debug.print "Pre-Compressed Data: " & TmpData
Debug.Print "Post-Compressed Data: " & Compress(TmpData, UnCompress(Key, COMPRESSION_KEY))

It can be used to print out any text you want it to, and variables which are set and changed whilst the program is running. You can use it to make warning messages if a sub error's... whatever you want.

It is a great function and should be used whilst either debugging, or just wondered what the hell you just programmed!

Oh, the 'debug' window should pop up when you run. If not, just press 'ctrl + g'.

You can access this window either whilst the program is running, or when you are programming.

The window's title will be 'Immediate'. That is what I get.

Like the properties box and the project viewer it can be aligned around the development window, or just put into it's own little box.

It's a very useful tool.

No doubt most of you will know about it, and use it, but some people might not. Now you do =)

~Kite
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#2
Actually this a really good write up, that should help nearly everyone with errors. For about the first 3 months i was programming i knew that it existed but not really how to use it... one day i ended up screwing up one of my packets and misunderstood enlightened me on th efact that you could include words in " " using debug.print. After i learned about that i was able to fix almost every error since with little to no assistance to anyone else.

Anyways, great job writting this :wink:
Reply
#3
I hardly ever use debug.print... for the most part, I just go through the code that is having the problems along with the code that calls it, and put in line breaks where needed (click the left side of the code window and place a little red high-light and circle).
Reply
#4
Break-Points?

Meh, i don't use those much, i don't care for them.
Reply
#5
Still, Debug.Print is very useful for simply finding out what is being sent in packets.

Whilst quickly programming in packets, I have found myself adding more than 1 seperator character, or one too many '&' signs... etc.

Anyway, whether you use it or not, you need to know about it.

~Kite
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)