Running from the Source on Windows

Discussion in 'Development General' started by Fuzzysqurl, Jan 23, 2014.

Thread Status:
Not open for further replies.
  1. Fuzzysqurl

    Fuzzysqurl baa baa mareep I do what I want Server Owner Developer I do what I want Server Owner Developer

    Joined:
    Sep 12, 2012
    Messages:
    2,096
    Likes Received:
    967
    I decided to update the old "How to run from the source" guide to include more pictures and bypass complicated commands and processes where ever possible. I captured screenshots for almost the entire process to make this more of a self-serving guide. Most images will be in hide tags, but particularly important ones will not be

    ****Important Links Section****
    Git Bash: http://msysgit.github.io/
    QT Creator and SDK: http://qt-project.org/downloads
    Main PO Repo Location: https://github.com/po-devs/pokemon-online


    ****Set up Git Bash****
    1. Navigate to http://msysgit.github.io/ and select "Downloads"
      [​IMG]
    2. Click and download the most recent version
      [​IMG]
    3. Open the downloaded file and you will be prompted for installation.
      [​IMG]

    First screen is simply the splash screen for the installer, click "Next."
    [​IMG]
    Second screen is the GNU General Public License. Read if you want, otherwise click "Next."
    [​IMG]
    Third screen will ask where you want to install the files. For the purpose of this tutorial, we will be using the default location.
    [​IMG]
    Fourth screen will be installation options. Again, we are going to use the default options.
    [​IMG]
    Fifth screen will ask where you want to create shortcuts in the Start Menu. Set up how you want, default is being used again.
    [​IMG]
    Sixth screen is one of the most important ones. Select the middle option "Run Git from the Windows Command Prompt"
    [​IMG]

    Seventh screen is the next most important. Select the middle option "Checkout as-is, commit Unix-style line endings"
    [​IMG]

    After you hit next, it will start to install based on the settings we have defined.
    The final screen appears moments later, you can uncheck the box "View ReleaseNotes.rtf" and click "Finish."
    If you were to open the program "Git Bash" right now, you would see a screen like this:
    [​IMG]

    You can set Git Bash to the side, we've got more work to do before we need this again!

    ****Set up QT Creator****
    1. Navigate to http://qt-project.org/downloads
      [​IMG]
    2. As this guide is aimed at Windows users, select "QT Online Installer for Windows" and wait for the download to finish.
    3. Open the downloaded file and we will go through another installation process.

    First screen is the splash page for the installer, click "Next" and wait for it to retrieve information. This might take a couple of minutes. When it is done, the next screen will appear
    Second screen is asking where you want to install the files. This tutorial is using the default place again.
    [​IMG]
    Third screen is asking about components to install. If you don't care about hard drive space and installing a bunch of stuff you'll probably never use, then you can use the default. For the purpose of this guide, we will only install the required components to run. If you decide to install more, it will take much longer to download (Default is over 12 GB, required is only about 2 GB) and future steps might look a bit different.
    [​IMG]
    Fourth screen is the license agreements. Obviously you're going to "read these in their entirety" before continuing so just click to say you've read them and select "Next."
    [​IMG]
    Fifth screen is about start menu shortcuts. We'll just use the default path again, because its so much easier.
    [​IMG]
    Sixth screen is shows that you're ready to install, so click "Install" and let the computer do its work. If you chose to install everything, you will be waiting here for a couple of minutes, and by a couple of minutes I mean you can probably grab yourself a sandwich. Depending on your download speed, you might be able to grab a couple of sandwiches. Either way, when its done, we can move to the next step.
    Seventh screen is the final screen. You can uncheck "Open Qt ReadMe" and then click "Finish"
    [​IMG]

    ****Configuring Git Bash, part 1****
    Now let's get the source on our computer so we can access it! If you've followed the installation guide perfectly for Git Bash, this next section will be really easy.
    To make things really easy to set up, I will walk you through the "cheater" method of setting it up. You wont need to know complex commands to use in Git Bash in order to set this up, making it more user-friendly if you know how to work with a computer.

    1. Find a place on your computer you would like the files to be stored on. Please note they take up some space and moving them will end up breaking things down the line, so once you pick a spot, you better be happy with it. For this tutorial, I'm going to make a folder in "My Documents" called "POServer" and use it.
      [​IMG]
    2. Right click on the folder and select "Git Bash"
    3. Git Bash should open up and the colored text should change to point to where your server files will soon be located, followed by the current branch "(master)"
    [​IMG]

    ****Cloning and configuring the source!****
    Now that Git Bash is configured, we can clone the source. At this point, you will need to use a Git Bash command in order to set everything up quickly.
    1. Type in
      Code (text):
      1. git clone git://github.com/po-devs/pokemon-online.git
      If you choose to copy and paste, then just press the "Insert" key and it will paste your clipboard into the window. Then hit enter and wait for it to clone the repo, this will take a minute to complete, but when its done, move on to Step 2.
    2. Now that you have the source on your computer, open up QT Creator again and select "Open Project."
      [​IMG]
    3. Locate the folder we created and double click on the folder called "pokemon-online" on the inside. In that folder there should be a file called "PokemonOnline.pro," select and open that file. It might take a second to load, so be patient. [​IMG]
    4. A new screen allowing you to configure your project will appear. This screen will look slightly different if you opted for the 12 GB install earlier (who does that?). Make sure only "Desktop QT 5.2.0 MinGW 32bit" is checked and then click "Configure Project" [​IMG]
    5. A bunch of QT related processes will start to occur, parsing and evaluating the project. A huge list of messages will appear near the bottom, this is good because you can now make changes to the source, while keeping a copy of the original in case you break something.
      [​IMG]
    6. When everything calms down (only takes a couple of seconds) click on the button that says "Projects." Under the header "Build Steps" click on the 1st button for "Details." New options should appear. In the new top box type, with quotes CONFIG+="po_all" (note: the image has the wrong text)[​IMG]
    7. Now go back to the "Edit" tab, right click the bolded "PokemonOnline" and select "Run qmake"
    8. Everything should be all set for you to then right click the "Server" folder and hit "Run." There might (read: will) be minor warnings that pop up, but you can ignore them. The first run will always take the longest as it is generating new files and learning how they interact with each other, but in the future it will go much faster. Right now would be a great time to continue with the guide while your computer chugs away at setting up the server. My laptop took about 25 minutes to process all of this, thought your speeds are dependent on how fast your computer is. For the record, it took under 40 seconds to run the 2nd time, which is more of what you should expect in the future.

    ****Enabling developing with your new server!****
    Now that you've got QT Creator set up to run your server, if you want to help develop the simulator, you will need a few more things.
    1. A working knowledge in C++. If you don't have this, you either need (1) to know other programming languages, or (2) can replicate and adjust already coded blocks of code, or (3) use the Help feature in QT Creator until you get comfortable.
    2. A Github account
    3. More configuration in Git Bash to allow you to use it to pull and push changes between your computer and the main source.

    1. Since this guide isn't meant to teach you C++, we will skip to requirement 2 and set up a Github account. Navigate to https://github.com
    2. Fill out the easy to use registration and click "Sign up for Github"
      [​IMG]
      ***As I already have a github account, there might be steps skipped that I cannot access because I don't want to sign up for another account that I'll never use. Maybe in the future I'll add this in.,
    3. Navigate to https://github.com/po-devs/pokemon-online and click the button that says "Fork." It will copy the master repo into one you can freely edit, now located at "https://github.com/YOUR GITHUB ACCOUNT NAME/pokemon-online"
      [​IMG]
    4. Now we need to configure Git Bash to work with your new Github account. First off, we will configure an SSH key to allow communication between your local files and the files on github. You will need to follow the tutorial at: https://help.github.com/articles/generating-ssh-keys in order to set this up. During Step 3, part 2 of this tutorial, look for the button that says "Deploy Keys" instead of "SSH Keys." No sense in rewriting this tutorial when it is already done.
    5. Assuming Step 4 completed successfully, you can either tinker in Git Bash to set everything up, or take the easy way out and just replace a file with pre-configured data. Navigate to your server's folder and go to pokemon-online/.git and look for the file named "config". The .git folder is a hidden folder, so if you don't have hidden files shown, you will need to follow the quick instructions on http://windows.microsoft.com/en-us/windows/show-hidden-files#show-hidden-files=windows-7 The process is about the same for all Windows OS, but it might vary. You can always google it if this link doesnt help you.
      [​IMG]
    6. Open the file "config" in a text editor, such as Notepad++ (http://notepad-plus-plus.org/download/) and replace the entire file with the following data. Switch "Fuzzysqurl" for whatever your Github account name is
      Code (text):
      1.  
      2. [core]
      3.     repositoryformatversion = 0
      4.     filemode = false
      5.     bare = false
      6.     logallrefupdates = true
      7.     symlinks = false
      8.     ignorecase = true
      9.     hideDotFiles = dotGitOnly
      10. [remote "origin"]
      11.     url = git@github.com:Fuzzysqurl/pokemon-online
      12.     fetch = +refs/heads/*:refs/remotes/origin/*
      13. [remote "podevs"]
      14.     url = git://github.com/po-devs/pokemon-online
      15.     fetch = +refs/heads/*:refs/remotes/podevs/*
      16.  
    7. At this point you will need to adjust your Git Bash start in settings. We will apply a more permanent path for Git Bash now, to allow you to easily use it. Find your Git Bash shortcut in your start menu, right click, and select "Properties"
    8. Modify the start in location to match the folder your server is in. You should change this to where your server files are located, such as C:\Users\Fuzzy\Documents\POServer\pokemon-online but your location will obviously be different. If you know about folder hierarchy, then fill "Start In" with the proper folder and skip to Step 10, otherwise, continue.
    9. Open the folder containing your server files and navigate to the "pokemon-online" folder. Right click "PokemonOnline.pro" and select "Properties." Copy the location of that file and use that for the "Start in" location for Git Bash
      [​IMG]
    10. Hit apply and then you will be ready to use Git Bash as a bridge between your computer and the net

    ****Common commands used in Git Bash and submitting your fix/feature!****
    These commands are far from everything you can do in Git Bash, but they are really common ones that form almost a progression of how you should order them.
    Code (text):
    1. git pull podevs master
    Overwrites your local files with the most up to date version from the web. This only works if you copied the "config" file settings from earlier.

    Code (text):
    1. git checkout -b name
    Creates and switches you to the branch "name." You can replace "name" with anything, like "Metronome". It is HIGHLY recommended to edit files using a branch. You can have multiple "versions" of your server stored locally, allowing you to edit different parts without affecting each other. If something breaks, you can quickly revert back to the original, working source, and save yourself a headache in the future.

    AT THIS POINT YOU CAN START EDITING YOUR FILES LOCALLY. When you change something, say a bug fix or a feature, be sure to test it by building and running your server. When everything works, you can proceed into submitting the changes if that was your intention.

    Code (text):
    1. git checkout name
    Switches you to an already named branch

    Code (text):
    1. git status
    View if any of your files are changed on your system. Great for staging changes for committing. Red is unstaged, Green is staged

    Code (text):
    1. git add filepath
    Stages file changes for committing to the server. Filepath should be replaced with whatever file you are looking to add, such as src/BattleServer/moves.cpp, if you were editing a move. Files in red on "git status" are mainly what you are replacing "filepath" with

    Code (text):
    1. git commit -m "Commit message"
    Combines all your files from "git add" and wraps them in a nice box with a tag that says "Commit message." Be specific with your commit messages, it makes life easier, such as "Metronome fix"

    Code (text):
    1. git push origin name
    Where "name" is the current branch you are on, like "Metronome." This will push all your local changes onto your github's repo, leaving you steps away from officially submitting a feature or fix.

    After you finish these steps, you can now head over to http://github.com and change your visible branch to what you've just created. Then click on the Green button. It will take you to a preview of the files you have changed with a box at the top saying "Click to create a pull request for this comparison".
    [​IMG]
    [​IMG]


    Write a little description of what you changed (optional, but recommended) and click "Send Pull Request."
    [​IMG]

    More advanced Git Commands
    Code (text):
    1.  git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d
    Deletes all branches that have already been merged into the "master" branch. If you submit a fix, it gets merged, then you "git pull podevs master" on your master branch, then run this, it will delete anything that is no longer needed.

    Code (text):
    1. git branch | grep -v "master" | xargs git branch -D
    Deletes all branches except master regardless of status.

    Feel free to ask any questions. If a step is confusing or doesn't work or a step could use a picture to assist, post here with suggestions!
     
    Last edited: Dec 11, 2014
  2. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    I want to post a link to Git Extensions, which is in my experience a great graphical user interface to Git. You can setup the repository like Fuzzy did and then add it into Git Extensions user interface.

    https://code.google.com/p/gitextensions/
     
  3. Randor

    Randor New Member

    Joined:
    Dec 6, 2014
    Messages:
    2
    Likes Received:
    0
    I get this error everytime I click "run" on "server"

    :-1: error: error: server\pokemon-online\src\Shared\..\..\bin\libpo-utilities.a: No such file or directory

    [​IMG]

    [​IMG]
     
  4. Fuzzysqurl

    Fuzzysqurl baa baa mareep I do what I want Server Owner Developer I do what I want Server Owner Developer

    Joined:
    Sep 12, 2012
    Messages:
    2,096
    Likes Received:
    967
    There's a chance the issue is related to the space in your folder "PO Server"
    You can try right clicking the main project and running qmake and see if that fixes it.

    Also, change that "CONFIG+=po_all" to like CONFIG+="po_all"
    I believe Withoutatrace had a problem with it because I made a mistake in this guide.
     
    Alipio likes this.
  5. Randor

    Randor New Member

    Joined:
    Dec 6, 2014
    Messages:
    2
    Likes Received:
    0
    Removing the space and getting it through GIT again and changing the CONFIG worked. Thanks a lot.
     
Thread Status:
Not open for further replies.