Pages

Tuesday, May 21, 2013

NyanChat! Complete

This was my first attempt  at creating a fully functional chat application in Java. Sure, it has plenty of bugs, but it works. Should be great for your programming projects or just to read through.

You're probably here because you're looking for something like this anyway.
Here's the link:

Download NyanChat!

The source code and executable jar files are included. Along with an odd user manual. Don't pay much attention to it, really.

Tuesday, May 7, 2013

Great Success! Get SFML to work with Code::Blocks IDE

Hello!
I said I'd report back, and that's what I'm doing. I know I'm a couple of days late, but, better late than never right?

On to the good news. I finally managed to get SFML to work. How? Well, the boys over at SFML-dev have updated their website, source code and tutorial quite recently. With this brand spanking new update, alot of things have been fixed. That means it's much easier to set up and use. I shall guide you through the process now (which is the main reason why you're here, right?).

Note that this tutorial is intended for Code::Blocks IDE on Windows. If you're using another one, try their official documentation first.

  1. Go the the Code::Blocks download page and grab yourself a binary release WITH the MingW compiler. If you're into building from source, they have those as well.
  2. Install or unpack it.
  3. Write yourself a small C++ program in Code::Blocks to make sure that it's set up properly. If it compiles and runs fine, then you've got the easy bit done.
  4. Now scoot on over to the SFML download page and grab the GCC 4.7 TDM (SJLJ) version (either 32 or 64 bit depending on you're system). In my experience the DW2 version gave me errors. If the SJLJ version gives you errors, try DW2. 
  5. Unpack the contents of the zip on your hard drive (somewhere safe, with read and write privileges). Open up the directory and locate the include and lib folders. Remember them.
  6. Go to Code::Blocks, click on the settings menu bar, and go to compiler. In older versions of Code::Blocks, it's called compiler and debugger.
  7. Under Global Compiler Settings, search for the Search Directories tab and click on it. Now, in this tab, you have more subtabs, two of which are called compiler and linker.
  8. Under the compiler tab, add the directory to SFML's include folder from step 5. So if you unpacked the zip to the root of your C: drive, an example of the directory would be C:\SFML-2.0\include.
  9. Under the linker tab, add the directory to SFML's lib folder from step 5. If unpacked to the same place, an example would be C:\SFML-2.0\lib. Click OK to apply your settings
  10. Phew. Okay, now we need to add SFML's libraries to the linker. Next to the Search Directories tab is a Linker settings tab. Click it.
  11. Under Link Libraries, add the following libraries IN THIS ORDER. i.e click on add, navigate to the lib folder in SFML, and add libsfml-graphics.a, libsfml-audio.a, libsfml-window.a and then libsfml-system.a (libsfml-graphics.a must be at the top, libsfml-system.a must be at the bottom). If you're project is using some networking libraries as well, don't forget libsfml-network.a as well.
  12. Click OK and apply all settings. Now, navigate to the bin folder in your SFML directory and copy all the .dll files into the folder your project's executable is found, which should be the bin folder of your project.
  13. Time to test out your code. Create a main.cpp and enter this code:
Now compile, and run. Voila!

Okay, if this doesn't work for you, let me know.

Friday, May 3, 2013

A C++ Library that lives up to it's name (sort of)

Hello again. You remember me, right? Of course you do!

You wouldn't be here otherwise.

Recently, I've been tasked with developing an educational game as a 3rd Year Computer Science Project. It also happens to be a group project, which helps with the workload. However, it has to be done in C++.

<sarcasm> Great </sarcasm>

If those HTML tags don't work for you, you should try updating your browser.*

Now, for a group of students who spent a majority of their high school and university career developing in Java - being thrown into the deep end with a language that has no native libraries for simple media processing and GUI creation sounds like development hell. It is, especially when you have just over a month to complete it (don't forget other projects and tests being  thrown into the mix!).

We were cut some slack, though. We have the freedom of choosing our own IDE and libraries to use for our project, which should make our lives easier. So, after much research and debate, we narrowed the possibilities down to three options:

  1. Visual C++ 2010
  2. QtCreator
  3. SFML
The first option would have been great. Until we realised that we are developing in Linux (more specifically, Fedora 14). So we threw Visual out the window. Splat.
QtCreator was our next option. It looked promising, but at the end of it all, we learned that it's commercial software and we have to BUY it. The trial version lasts 30 days. That's less than our expected development time and we didn't want to take any risks. 

So, we were left with SFML. It looks promising, and we can use it to create a rather pleasant looking game with sprites instead of fancy coloured GUI components. The problem that arose with SFML, however, was setting it up.

No matter how closely we followed the tutorials, we always ended up with either an executable that refused to execute (in some rare cases, it would execute but crash immediately) or the IDE would not be able to find the library at all. Many people around the world (even some of my fellow classmates who wanted to use the library for their game) have a similar issue, but what boggles me is that others have managed to get it to work.  

I've used the MingW version with Code::Blocks and Eclipse, to no avail. On Windows 8 it compiles but the executable is broken. On Ubuntu 10.10 and Fedora 14, both IDE's can't find the libraries, even after we've added them to the libs and the linker. The other option was with Visual C++ 2008, so I tried the SFML version of that as well. The results were still the same.

I refuse to give up on this. I've been working with SFML 1.6, so I think I should try 2.0 next time. After I compile it from source, that is. I'm also going to try this in Windows 7, using a slightly older and less buggy version of Eclipse. 

I shall have results tomorrow, and I shall make a note of them here. If I get it to work, I will post a nice little tutorial on how I managed to get it working. If you managed to figure out the relevance of the title of this post with some of it's content, a million points to you.

*I was being sarcastic here, too.

Monday, July 16, 2012

Insane Installer of Insanity - Item Level 63

So, I managed to get Diablo III (thank you, Chris and Verushka!) as an early birthday present and I've been cleaving ass with a variety of weapons against the hellspawn for several weeks now. Despite many claiming the game to be a fail, I find it enjoyable. Maybe it's because I'm a newcomer to the series? I doubt it.

Diablo III
My copy of Diablo III
But, have you heard of my horror stories of installing the game? Blizzard decided to make the process of installing the game "A pain in the ass to many" according to myself, and as a result there are lots of people out there who couldn't install the game (there are some who probably still can't).

Gather around the fire, readers, and listen to my tale. Learn from my mistakes, and you will be rewarded - I think.

It began with me looking at the fold-out cover box thingy in awe, carefully removing the disc and putting it in my DVD drive. I was quite keen on checking out the installer, because Starcraft II had the best one I've ever seen. A box appeared on my screen, to my dismay, because this was not the awesome installer I was expecting. It said "Checking for updates" and there was a progress bar beneath it, which was taking forever to progress. I had a look at my bandwidth monitor and saw that the little program was using a lot of my bandwidth, so I thought it was downloading the game updates prior to the install. I thought this was acceptable. Seeing that the progress bar only moved a little bit in the space of an entire 15 minutes, I turned my monitor off and went to sleep believing that it would be done downloading by the time I wake up.

Forgive me, Bul-Kathos, because I was wrong.

I woke up (the next morning) and the first thing I did was turn on my monitor and move the mouse to check if it was done. To my horror, another box appeared. This is what it said:

Error code BLZPTS0000J. Failed to run a required program (Blizzard Setup). Wait one minute and try again and if that doesn't work please restart your computer and try again.

Wut. Wait one minute, you say? I waited the whole night! Why can't you run the Blizzard Setup? What is this error code BLZPTS0000J? Why am I naked? (I'm serious, I had clothes on the night before. It must be that evil faerie again). So I left my room, brushed my teeth (hygiene is important, yo), put some clothes on and returned. I fired up Firefox and googled this error code. According to the Battle.net support page it seems that I didn't have the correct privileges or administrator rights for the application. This makes no sense, because I have an administrator account. Nevertheless, I ran the executable as an administrator and tried again. The updater checked for updates, so I left to eat breakfast.

Yeah that's what I looked like
When I returned, I was greeted with the same error code and the same story about trying again in a minute. So I waited one minute and tried again.

The same thing happened.

At this point I was rather annoyed. Why? First of all, why would you lie to me by saying that waiting one minute can possibly solve a problem like this? Secondly, how hard can it be to check if an application is up to date and download the new one if its not? At that point I realised that perhaps its working fine, but my antivirus is blocking its write privileges as well as its internet connectivity. I opened up my antivirus and disabled the virus protection, as well as the firewall. With a sigh, I ran the executable with administrator settings yet again, watching the progress bar move painfully slow for roughly 15 minutes. At the back of my mind, I began to doubt that the antivirus solution I had installed was not the problem, and I was right - the updater eventually presented me with the same error code.

I was running out of options fast. I googled some more and browsed through many forums where people like me encountered the same problem and had asked the Diablo community for help, only to be inundated with replies such as "It worked for me" or "n00b". I eventually came across a few posts that suggested I delete the working folder for the updater and try again, because the updater may encounter the usual bug or a loss of internet connectivity and fail. The downloads are incremental, so if there was a problem downloading the first time, there would be more problems the second time and so on, thus making any more attempts redundant. Challenge accepted.

This fabled working folder was hidden in a place called C:\ProgramData\Battle.net on my computer, and the folder was hidden, so I had to enable hidden files and folders. I found it, and deleted it. Rinse and repeat. Waited for the updater to give me a response... and it finally happened.

Error code BLZPTS00002. Failed to run a required program (Blizzard Setup). Wait one minute and try again and if that doesn't work please restart your computer and try again.

At first, I wanted to kill myself, but then I had a closer look at the message. The error code changed! Finally, some progress! I googled this new error code, and the wise and mighty Battle.net support page told me that there was something wrong with my internet connection, or perhaps a 3rd party application may be interfering. We pay roughly R300 for our internet connection, and there's something wrong with it. Some more sleuthing hinted that I need to port forward for the updater to work. According to Blizzard, the following ports needed to be forwarded:
  • 80 for HTTP
  • 1119 for the game client, as well as patch version queries
  • 6881 - 6999 for launcher, as well as downloads
So let's see here: two ports for playing the game and more than a hundred ports for launching and downloading? <sarcasm> That makes sense. </sarcasm>

I make my way into the forbidden lands of port forwarding in my router settings, only to find out that I don't know how to enter a range of ports instead of just one. Eventually I figured out that you can just separate the upper and lower bounds of ports with a hyphen (go figure). Hopeful thoughts are racing through my mind as I attempt to run the updater again (almost forgetting to run it as administrator). Needless to say, this is what I get in the end:

Error code BLZPTS0000J. Failed to run a required program (Blizzard Setup). Wait one minute and try again and if that doesn't work please restart your computer and try again.

I'm back to square one, folks. It's been almost two days, and the game is still broken even before it's installed. Like a man wandering through the Stinging Sands for days, dying of thirst and blood loss, I am becoming more and more desperate for any signs of salvation. I eventually give up, because I'm pretty much fed up and I've only a few hundred megabytes of my ADSL cap left due to the updater continuously doing Tyrael-knows-what, even though it’s not making any progress with the installation. Defeated and dreary, I close my workspace and launch Battlefield 3 to restore some of my vigour.

Then it hit me.

Finally some results
Earlier this year I had trouble getting Origin to download updates for Battlefield 3, and I eventually figured out a way to fix it (the post on how I managed to fix it can be found here). I wondered: perhaps I could apply some of the methods I used there, here? Maybe then it would install? Like Luke Skywalker leaping like a ballerina out of the rebel base shortly after being kissed by Leia*, I reboot my PC and boot Windows 7 into safe mode with networking. I run the updater as an administrator and the usual update checking box appears. To my amazement (and sheer joy) the progress bar moves swiftly to the end, bringing the first phase of the installer to fruition. It then begins to PROPERLY DOWNLOAD the installer updates! Invisible tears of joy stream down my cheeks as I excitedly watch the progress bar move. I constantly check the working directory too, noting how the size of the folder becomes bigger with each passing second. That means its working. It's downloading the installer.

So I'm there, watching the progress bar grow, getting ready to finally install the game, when it just stops. The progress bar shortens a bit, downloads, gets bigger, then shortens again. This happens a few times and eventually the window closes, reopens, and repeats the cycle. My victory was short lived, it seems. I navigate to the working directory and checked out the log to see the issue. According to the log, the updater failed to initialise the installer because it was in safe mode! Great. Now what? Perhaps if I boot back into Windows normally, it would work? I gave it a try and voila! It worked! It checked for updates in a few seconds, it updated the installer in a few seconds, and it launched the installer!

Damn I was so close
I finally had a good look at the Diablo III installer. It worked similarly to the Starcraft II installer i.e installing the game whilst presenting the game's lore in a tasteful manner. However, there was something odd. Now matter how long I left the installer to do its job, it remained at 0%. What's worse, is that it was using my bandwidth too!

Not again.

I ultimately reached the conclusion that there was some software suite conflicting with the install process. There is no clog in safe mode, but it lacks the software environment necessary to launch the installer. Normal Windows launches the installer, but encounters the clog. What I needed was a compromise: I needed some way to boot into Windows with only the Microsoft services, and not anything else. Administrative tools, anyone? System Configuration turned out to be my saviour. With this I could disable any programs or services and prevent them from loading when I start Windows. I clicked on the Services tab and disabled all of the services that are NOT created my Microsoft (I left my graphics card drivers enabled as well, so leave anything by NVidia or ATi). I also clicked on the Startup tab and did the same thing there. I rebooted, started the installer and voila! The installer worked!  It installed the game, it downloaded updates and applied them, it did its job!

I can finally play it
Now I needed all my software back, so I just re-enabled them in the System Configuration tool and rebooted. Now, whenever there is an update, I just disable the necessary programs, reboot, update the game, re-enable the disabled programs, reboot and I'm good to go! Achievement unlocked?

That was the longest install of my life. That is also the end of my painful story. That should net me at least a 1000XP right? So for now, if you would kindly excuse me, I have a few bosses that I need to farm.

THE END

* That was meant to be a joke. I know Leia and Luke are siblings. That was the point of the joke. Oh gosh. 


This post was edited by my dear Neliel-chan. Ichigo nyu nyu!

Wednesday, April 11, 2012

Install Windows 7 from a USB drive

There comes a point in your life, where do you don't stock up on blank DVD's or CD's, and all you have are external hard disks and flash drives. Now, what happens when you need to re-install Windows and you have no proper disc to do it with? Perhaps the original disc is damaged (but can be recovered), or you only have the ISO version (which is completely legal, so long as you plan to register it with a valid key) of it?

This happened to me recently, and I managed to figure out how to do it. Its possible to install Windows 7 (or Windows 8, if you want to) from a USB drive, be it an external hard disk or a small flash disk. This post is about how its done.

You'll need:

  • Another PC with Windows on it (at least XP), or if you haven't re-installed on the current PC, don't (at least not yet). You'll need it.
  • An external hard drive, or a flash disk. They must have at least 4GB of capacity IN TOTAL.
  • Your Windows 7 (or Windows 8) disc or ISO (must be mounted).

Now on to the juicy parts:

PART 1


Fig. 1

Fig. 2
  1. Plug in your flash disk or hard drive into a USB port of the computer with Windows on it, and back up all of the data into a safe place, because we need to erase and format it.
  2. Open the command prompt with administrator rights. You can do this by navigating to C:\Windows\System32, right clicking on cmd.exe, and then clicking on Run as Administrator. Note that if you don't have Windows installed to drive C:/ you will have to navigate to the drive its installed on. Alternatively, you can go to your Start Menu, click on All Programs, then Accessories, and then right click on Command Prompt and select Run as Administrator.
  3. Once the command prompt is open, type DISKPART and press enter. Refer to Fig. 1
  4. Type LIST DISK and press enter. Remember the disk number of the drive you plan to boot from. The size and free space of the disk will give you a clue as to what is what.
  5. Now you need to type the following commands IN ORDER,  like you did for the ones above. 
  • SELECT DISK ### (where ### is the disk number you noted earlier)
  • CLEAN
  • CREATE PARTITION PRIMARY
  • SELECT PARTITION 1
  • ACTIVE
  • FORMAT FS=NTFS (Note that if you are working in XP, this command won't work. You need to navigate to the drive in my computer, right click on it, and click on format. In the new window, make sure you format to NTFS and not FAT32 or exFAT)
  • ASSIGN
  • EXIT

PART 2

  1. Keep the command prompt open.
  2. Insert your Windows disc into your DVD drive or mount the image. Make a note of the drive letter of your Windows disc, as well as the drive letter of the drive you want to boot from.
  3. Go back to the command prompt and type #: CD BOOT (where # is the drive letter of your Windows disc) and press enter.
  4. Type BOOTSECT.EXE /NT60 #: (where # is the drive letter of the disk you want to boot from) and press enter. This fancy pants command makes the drive boot-able. Almost there!
  5. Copy the contents of the Windows disc onto the empty boot-able drive. Once that is done, your device is ready to be booted from, and installed.
  6. Now this step is hardware specific, and I cannot help you during this because there are literally hundreds of motherboards out there. You need to make sure that your computer can boot from a USB device, and there is usually a setting for this in your BIOS. Refer to your motherboard manual for this. If you don't want to do this, you can always risk it and hope that your computer is already configured to boot from USB.
  7. Proceed to install Windows as you normally would. \:D/
I hope this helped you in some way. Enjoy!

Fix for Origin

Several months ago, I managed to get my hands on Battlefield 3 for PC, which was awesome. Eventually I found out that it required EA's new Origin service to install and play. I don't have the best internet connection out there, so being forced to download numerous patches (over 3GB in size) through Origin and not from anywhere else, was a horrible experience for me.

What made it even more horrible was that Origin didn't function properly.

Sure, its in beta, and one can expect bugs, but its main function is to allow people to digitally download their paid for game, allowing him or her to install the game on any PC with an internet connection, without the need for a disc. However, after installing (from the disc) I was told that it needed to download a 3GB patch in order for me to play online, and Origin had issues downloading this patch (as well as a host of other games and patches). When I attempted to start the download, it was stuck in a never ending loop that went in this order:

  1. Preparing
  2. Downloading 0kb out of 0.00kb (it would stay stuck like this for a few minutes)
  3. Preparing
Throughout this time, it was using up my bandwidth, and yet again, this was not a good thing. After doing some research, I found out that others have also been experiencing this issue, and up until now, there has been no fix. Reading through forums, it would seem that there was some conflicting software involved, as well as network settings that could be interfering.

I managed to get Origin to work, using the last option. However, it is advisable to try out the first few options as well, because they have worked for some users, and it may work for you too.

OPTION 1 - Run Origin with administrator rights
For some people, Origin might be trying to write to a directory that is write protected from unauthorized users, so by running Origin as an admin, or by changing the directory's write privileges, the problem may be solved. To do this, right click on the Origin shortcut or executable, and click on Run as Administrator. If you need to enter a password, do so when it asks you. Hopefully this method fixes your problem.

OPTION 2 - Use a VPN or PROXY
Your ISP might be blocking Origin from connecting, or the network you are on might be restricting Origin as well. This is usually the case with universities or public networks. Forums have recommended Hotspot Shield. Download this and install it. Run it, and once the VPN/Proxy is activated, use Origin and try it again.

OPTION 3 - Boot Windows into Safe Mode with Networking
Windows 7 Advanced Boot Options
Windows 7 Advanced Boot Options
This is the option that worked for me, after the previous two options failed to fix the problem. When you boot Windows into safe mode, Windows only loads the core processes, drivers and services that are required for Windows to function, so the user can diagnose/fix the problem without being limited by other programs. To do this, restart your computer, and as soon as your PC finishes showing you the BIOS screen, keep tapping the F8 button on your keyboard. You will eventually be led to a black and white screen with numerous boot options for Windows. Make sure you select Safe Mode with Networking and not plain old Safe Mode, because your computer needs to be connected to the internet for Origin to work. Once that is done, login and proceed to use Origin. This HAS to work, if the previous options didn't. If not, then there is a problem with the network or your PC.

If you have any other fixes for this, please share it! And good luck!

Sunday, February 26, 2012

Welcome Back, Comrades!

Hello again, this is my blog - rebooted.

My previous one was a wreck, filled with nonsense that won't be of any assistance to anybody, so this time I aim for a small piece of the internet where I could post helpful articles, progress of any current projects of mine, source code to programs I write, and generally anything which could potentially serve some kind of purpose.

Also, I decided to go with a Fallout theme. The woman in this blog's banner is my version of the Lone Wanderer from Fallout 3. It looks better than the previous one, too.

Then there is the title. Why "Escape The Vault"? Well, these are my adventures. This is me, finding my own way out of this situation. What will I find beyond? I don't know, but I'll find out eventually.

Until next time!