Perforce in the Cloud, Free!

As Dave and I begin working on Ugly Baby with Dejobaan, we had the opportunity to throw the Unity project in our version control system of choice. Coming off the heels of a couple projects versioned with Unity’s Asset Server, I was definitely looking forward to working with something slightly more robust.

Perforce, in a previous life, was very expensive to use ($700+/user). Their free licensing restrictions used to only allow a handful of users/workspaces, which wouldn’t be enough for a small team with a few dev computers. That being said, they have recently changed their terms to allow for up to 20 users/workspaces and unlimited files, or unlimited users, and a limit of 1000 files. Jumping into a game that’s closing in on it’s third or fourth year of iterative development, I decided the former would be the best option for us.

On top of that, it turns out to be very easy to get everything setup for yourself at absolutely no cost.

Setting up the Server

Normally, you’d have to worry about getting a server hosted somewhere, worry about the bandwidth, the disk space, the uptime. Turns out Amazon allows for small servers hosted on their huge EC2 backbone at absolutely no cost.

You have two options here, setup an instance on your own, or use BitNami to do the management of the Amazon EC2 server instance. I have played with both, and ended up sticking with BitNami because I had it setup a server with a base installation of some task management software I wanted to try. BitNami also sends you estimates of what your monthly payment will be with regards to your past week’s activity. It’s a good way to get a heads up if you’re pushing your instance a bit too hard.

This section of the setup will be a little bit sparse, as it’s been a few weeks since I setup my own server, and I did not take notes at the time. If I run through it with a friend, I’ll come back and update the post.

What’s important though, is you setup a server with either Debian or Ubuntu. Having the apt-get package manager makes our lives a bit easier. Realize that if you screw up along the way, and want to start over, simply terminate and delete your server instance off of Amazon’s backend, and start over.

Installing Perforce

  1. Download the `daemon` utility. This utility allows `p4d` to be run by the `perforce` user instead of `root`.
      sudo apt-get install daemon
  2. Connect to the directory where the `p4` and `p4d` files where downloaded (probably the home directory).
      cd ~
  3. Make the `p4` and `p4d` files executable.
      chmod +x p4 p4d
  4. Copy the Perforce executables to `/usr/local/bin` which is already in the system PATH environment variable.
      sudo mv p4 /usr/local/bin
      sudo mv p4d /usr/local/bin
  5. Create a group for Perforce files.
      sudo addgroup p4admin
  6. Create a user for Perforce administrative work.
      sudo adduser perforce
  7. Use `visudo` to give the perforce user account the ability to use `sudo`. Add the following line at the end of the file.
      perforce ALL = ALL
  8. Log off your default user account.
  9. Log in using the `perforce` account.
  10. Create a directory to hold the repository.
      sudo mkdir /perforce_depot
      sudo chown perforce:p4admin /perforce_depot
  11. Create a directory to hold Perforce log files.
      sudo mkdir /var/log/perforce
      sudo chown perforce:p4admin /var/log/perforce
  12. Add the following lines to the end of /etc/profile. These settings will be used by client programs run on the Linux server – not by the Perforce server.
      # Perforce Settings
      export P4JOURNAL=/var/log/perforce/journal
      export P4LOG=/var/log/perforce/p4err
      export P4PORT=localhost:1666
      export P4ROOT=/perforce_depot
      export P4USER=perforce
  13. Load the Perforce settings.
      source /etc/profile
  14. Use `visudo` to remove the perforce user the ability to use sudo. (added in by me, that’s a security risk to leave in otherwise!)

Run Perforce on Boot

  1. Connect to the initialization control directory.
      cd /etc/init.d
  2. Create the Perforce control script using `sudo vi perforce`.
      #!/bin/sh -e
    
      export P4JOURNAL=/var/log/perforce/journal
      export P4LOG=/var/log/perforce/p4err
      export P4ROOT=/perforce_depot
      export P4PORT=1666
    
      PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
      . /lib/lsb/init-functions
    
      p4start="p4d -d"
      p4stop="p4 admin stop"
      p4user=perforce
    
      case "$1" in
      start)
        log_action_begin_msg "Starting Perforce Server"
        daemon -u $p4user $p4start;
        ;;
    
      stop)
        log_action_begin_msg "Stopping Perforce Server"
        daemon -u $p4user $p4stop;
        ;;
    
      restart)
        /etc/init.d/perforce stop
        /etc/init.d/perforce start
        start
        ;;
    
      *)
        echo "Usage: /etc/init.d/perforce (start|stop|restart)"
        exit 1
        ;;
    
    esac
    
    exit 0
  3. Integrate the Perforce control script into the boot process.
      sudo update-rc.d perforce defaults
  4. Goto your home directory then use the control script to start the Perforce server.
      cd ~
      sudo /etc/init.d/perforce start
  5. Use the control script to restart the Perforce server.
      sudo /etc/init.d/perforce restart

Run Perforce for the first time

Before Perforce can be used by a team there are two housekeeping task that need to be done – creating the journal and closing a security hole.

  1. Set the Perforce environment variables.
      source /etc/profile
  2. Start the perforce server. The command line is short because all of the settings are provided by the variables exported by /etc/profile.
      sudo p4d –d
  3. Create the journal.
      sudo p4d –jc
  4. By default, all users connected to Perforce are administrators. However, that level of security is not acceptable for a normal development environment. Run the `protect` option to switch out of the default security mode. For now, accept the default protections by typing `:wq` and pressing Enter.
      sudo p4 protect
  5. Stop the Perforce server.
      sudo p4 admin stop

Enabling SSL

I would suggest that you protect your Perforce connection by logging into it over SSL, rather than the plaintext connection that acts as a default.

  1. Create the directories for Perforce’s SSL certs and whatnot.
    sudo mkdir /perforce_ssl
    sudo chown perforce:p4admin /perforce_ssl
  2. Edit /etc/profile and /etc/init.d/perforce and add or edit the following lines:
    export P4PORT=ssl:1666
    export P4SSLDIR=/perforce_ssl
  3. Create a file called “config.txt” within the perforce_ssl folder, chown it to perforce:perforce, and fill it with the following contents, changing the defaults where you see fit:
    # C: Country Name - 2 letter code (default: US)
    C =
    # ST: State or Province Name - full name (default: CA)
    ST =
    # L: Locality or City Name (default: Alameda)
    L =
    # O: Organization or Company Name (default: Perforce Autogen Cert)
    O =
    # OU = Organization Unit - division or unit
    OU =
    # CN: Common Name (usually the DNS name of the server)
    # (default: the current server's DNS name)
    CN =
    # EX: number of days from today for certificate expiration 
    # (default: 730, e.g. 2 years)
    EX =
    # UNITS: unit multiplier for expiration (defaults to "days")
    # Valid values: "secs", "mins", "hours"
    UNITS =
  4.  After you’ve saved that file, type the following:
    p4d -Gc
  5. Verify that you have both a certificate.txt and a privatekey.txt in your directory now. If you don’t, check the logs at /var/log/perforce/p4err. Installing this a second time, I discovered that I needed to:
    sudo chmod 700 /perforce_ssl/
  6. Generate a fingerprint for the key and certificate pair. Make a note of this keypair, it can be given to your users to verify the authenticity of your server for secure communications.
    p4d -Gf
  7.  Restart the p4d, and it *should* start up in SSL. Confirm this by connecting via SSL (use ssl:your_ip:your_port) in your p4 client as your host address. (I would also look into setting the security settings high enough to require a password on login.)

Setting up Perforce for Unity

It’s also important to setup the typemap for Perforce, to ensure that the files that are being checked out are properly marked as text, binary, and binary exclusive.

In order to do this, type:

p4 typemap

You’ll want to paste in the following typemap, and be sure to save.

text //....js
text //....cs
text //...shader
text //....meta
text+l //....cm
text+l //....proc
text+l //....md5mesh
text+l //....md5anim
text+l //....ma
binary //....dll
binary //....exe
binary //....response
binary //....lib
binary //....pdb
binary //....u
binary //....ini
binary //....stub
binary //....ip
binary+l //....prefab
binary+l //....mb
binary+l //....mat
binary+l //....psb
binary+l //....mp3
binary+l //....fbx
binary+l //....unity
binary+l //....asset
binary+l //....aas
binary+l //....tga
binary+l //....jpg
binary+l //....lwo
binary+l //....wav
binary+l //....ogg
binary+l //....demo
binary+l //....roq
binary+l //....doc
binary+l //....xls
binary+l //....celtx
binary+l //....pdf
binary+l //....odt
binary+l //....ods
binary+l //....ppt
binary+l //....skp
binary+lS //....dds
binary+lS //....bnk
binary+lS //....light
binary+lS //....shadow
binary+lS //....ibl
binary+lS //....bik
binary+lS //....upk

Closing Thoughts

Until I have to run through this again, this is the approximation of the work that I needed to do to get Perforce up and running on my EC2 instance. It may be missing certain important bits of information, and it may be wrong, as I do remember running into a few “gotcha!”s during installation.If you have anything specific to ask or pass along, simply reach out to me via the contact page, or try Twitter.

Troubleshooting

  1. If you have everything up and running on the server, and you cannot seem to access the server from outside the server, make sure that you did not set the P4PORT to ssl:localhost:1666. This restricts all external connections, even if your firewall has an open port to your server.
Good luck!

Credit!

The majority of the credit for this knowledge is not my own. Thanks to the following sites that contained most of this information:

Indie Game Dev: UI Study

I was talking to David Evans (of Hybrid Mind Studios) earlier today, and we were discussing how the lowest common denominator for mainstream mobile games seems to be an ever-evolving glut of functionality and features that definitely posit a challenge for a small team of developers to consider undertaking. Whether you argue if it is feature bloat or merely an evolution of the mobile space, there is no argument that gamers even in the casual space are developing a literacy for mobile games. Ignoring or poorly implementing common features that they have come to expect could translate into bad reviews or a lack of interest in your game.

On that note, I figured the best thing would be to visually compare these games, and see what I might gain from sheer observation from the developers choices of their UI and Menu design.

I took four well-known games, and one successful newcomer to the App Store: Angry Birds, Cut the Rope, Jetpack Joyride, Peggle, and Tiny Wings. It is not lost on me that I chose both level-based puzzle games, and “runners”. I’m personally interested in these titles for their ability to either have continuously iterated gameplay through level design and challenges, or to keep a basic gameplay altered by the way you guide the player to interact with his or her surrounding environment.

Screenshots are provided in sections where they are applicable.

Indie Game Dev: The Jumpoff.

I have been in the game industry for almost four years, and it has been quite the ride thus far. I graduated a Computer Scientist from Syracuse and only had decided that I would make my mark on the game industry months before I received my degree. Not phased by my lack of personal development experience, I was determined to find a way into the industry, knowing that I could find my way once I got in there. Through a ridiculous amount of networking, I started at Harmonix in their QA department as a tester in March of 2009.

Almost two years later, and four products shipped with my name on them (The Beatles: Rock Band, Rock Band Network, Rock Band 3, and Dance Central), I came up for air. I had learned a ton about game development at (relatively) larger scale for the industry — at it’s peak, Harmonix was around 350 people, and has multiple projects and teams working on new stuff all the time. With such a large company, however, it is important to have some people be dedicated and focused on a particular task. By developing and harnessing experts for very specific parts of your pipeline, you can create a really strong foundation for the rest of your development team to flourish. I found my work becoming more and more pigeonholed to a direction that I wasn’t comfortable with (it was far more directed at tools than it was at game development), and I decided a change would be appropriate for me. I wanted to have my fingers in a bunch of proverbial pies, so to speak. I am fairly certain that games are my passion, but I wanted to take some time actually trying a bunch of different facets of it before I settled down into something.

Through some networking, I managed to land one of the most rewarding three months of work I have had yet, doing some development on a demo for Moonshot Games. The game is called Fallen Frontier. I did some light work in their engine, worked with the designer, implemented auto-aim, created a crowd system, and even got to design and develop a fun cannon-fodder enemy, the drone. If that experience wasn’t mind blowing enough, I got to present the game with the team at PAX East 2011. Check out some of the gameplay footage, I think everyone who worked on that is very proud of what we managed to put together for that show.

After PAX, I went full time as the lead developer on a game I had been working on in my spare time. A company in DC who does training for the DoD wanted to add a game to their training to help instill the issues that they are trying to teach their students. The game puts a player in the role of the people that they will be working with to help the player gain a broader cultural awareness of the communities, views, and goings-on of the location they are being deployed into. At a basic level, the game is a resource management and decision making game, supported by primary source information that is showing to be very successful in generating meaningful conversations in the classroom setting during the training. Being the lead developer on the project has taught me some invaluable lessons about creating systems that can systematically grow very large over the course of the project. Forcing the team, at times against their will, to deal with these larger systems during the build out caused changes much later in the project to be much smoother and understood by everyone. I can happily say that most of the requests that we get for feature additions play into the original design of the game’s system.

After about six months of full time work on that game, my tasks are starting to wrap up, and I’ve reduced my time to a four day workweek so that I can (finally?) open up some time to do some game development on my own and discover what to focus my energies on.

I bit the bullet and purchased a Unity 3 license, and am determined to release something. I hope to share some of that experience of the games I make here, not only to review the decisions I made down the road, but to hopefully help others learn from my successes and missteps, IN REAL TIME.

Mulla Nasreddin

Found a quote today, and tried to track down it’s origins. Rather than the quote, I prefer this small anecdote I found from
The Beggar King and the Secret of Happiness by Joel Ben Izzy.

The Secret of Happiness

Nasrudin is known as much for his wisdom as his foolishness, and many are those who have sought out his teaching.

One devotee tracked him down for many years before finding him in the marketplace sitting atop a pile of banana peels–no one knows why.

“Oh great sage, Nasrudin,” said the eager student. “I must ask you a very important question, the answer to which we all seek: What is the secret to attaining happiness?”

Nasrudin thought for a time, then responded. “The secret of happiness is good judgment.”

“Ah,” said the student. “But how do we attain good judgement?”

“From experience,” answered Nasrudin.

“Yes,” said the student. “But how do we attain experience?”

“Bad judgment.”

Reading about the Mulla was quite humorous as well.

Raising dead pixels on a Canon DSLR

Learned a super awesome trick today for Canon DSLRs that get a hot/dead/stuck pixel on the sensor. It’s not foolproof and might not fix the issue, but it turns out that it has fixed the problem for many people including a friend of mine today, so that’s good enough for me!

  1. Take off your lens, putting the lens cap on to protect it.
  2. Put your body cap on to cover your camera’s sensor.
  3. Turn your camera on, and go to the second “wrench” setting page on the menu.
  4. Scroll down to “Sensor Cleaning”, Select it.
  5. Select “Clean manually”
  6. Click “OK” when it tells you the mirror will open up.
  7. Let the mirror stay open for about 30-60 seconds, and then turn off the camera.
  8. Put the lens back on the camera, turn it back on, and take a few pictures
  9. If you’re lucky, you will have risen your pixel from the dead!

Should we call it an excerpt from the NecronomiCanon? ;)

Steak and Potatoes!

I have been trying to perfect cooking steak on our iron skillet and the oven. They came out a little dry this time, but inconsistency as a part of the learning process, right?

Pan seared steak with a hollandaise sauce, mashed potatoes with goat cheese, scallions and bacon, and garlic and ginger sauteed broccoli. A side of freshly baked bread, and we washed it all down with a delicious 2008 Rook by Corvidae.

Mon bon pain

The more Megan and I cooked at home, the more I wondered to myself what was possible. At my most naive, I searched online one morning for “pancakes from scratch”, and my mind was soon blown. For years, I had been buying boxed flour and baking soda.

At first, I felt cheated, but soon thereafter, I felt empowered. Armed with the Internet and a kitchen scale, I set out to truly learn some tasty recipes that we could con cot from the bare essentials. What else do we buy packaged that we can make from scratch? Turns out, pretty much everything. I’m happy to say that for almost the past four months Megan and I haven’t purchased a basic loaf of bread from the grocery store.

I’ll admit, the basis of this recipe came from Ratio, but I’ve put some slight variations onto it, and it’s become a very flexible dough for us, one that we find ourselves using for loaves, dinner rolls, and pizza.

15g yeast
300g water

20-30g lemon juice
5g sugar
10-15g salt

450g bread flour (we use King Arthurs)

  1. Let the yeast sit in the water until it’s been activated, and you’ve got a tan-milk-ish color, then add the salt, sugar, and lemon juice.
  2. Mix in the flour thoroughly. I let my dough hook run for about 5 minutes with this, while I use a spatula to scrape the insides of the bowl, ensuring everything mixes. If things start getting a little too sticky, I’ll sprinkle some flour to dry it up a little bit.
  3. After the mixing is done, take the lump of dough out and sprinkle more flour on it, until the dough can be handled without sticking to your hands.
  4. Knead the dough for a little bit longer, and then let it rest in a bowl or on the counter for 2-4 hours, depending on the temperature of the room.
  5. When the dough has doubled in size, take it out of it’s container, and shape it into the loaf that you want, and place it on a thoroughly floured surface to rise for another hour or so.
  6. Preheat the oven to 450 degrees, preferably with a baking stone inside.
  7. Cook the bread at 450 for 15 minutes, then lower the temperature to 375 for another 15 minutes.
  8. Take the bread out, and let it coli for about 30-45 minute before you serve. The gluten needs time to rest, and the flavors are still not fully formed yet.

For the nice ridges of the dough, I stole a trick that I’ve seen sushi chefs do, and wet a bread knife thoroughly before I make the cuts, rewetting it for each cut.

A simple recipe, but it has been our go to for some time now. I intend on buying some oatmeal flour in bulk soon, and seeing what we can do with that.

Returning to the books.

Photography is one of my more serious hobbies. I benefit from the fact that my sister has been going to school for it for the greater part of three years now, and that I can sponge off of her bits of advice and techniques to improve my own.

As a present, she had given me a few books, the first of which that I’ve read so far is Beauty in Photography, by Robert Adams. One interesting tidbit (albeit discovered from Wikipedia) is that Robert Adams only began photographing after he left college.

A few choice quotes:

Why do most great pictures look uncontrived? Why do most photographers bother with the deception, especially since it so often requires the hardest work of all? The answer is, I think, that the deception is necessary if the goal of art is to be reached: only pictures that look as the had been easily made can convincingly suggest that Beauty is commonplace.

After years with a camera I had wasted still more time trying to do what it apparently was not given me to do.

The book itself is a collection of essays that he’s written, and definitely worth a read. It not only describes his views on photography, but discusses the path others have taken in discovering what photography means for them, and thoughts on art criticism as well, among a few other topics.

Redmine (with Subversion) on Dreamhost

I absolutely love Redmine. I’m not sure if it’s a textbook case of Stockholm syndrome, since it took it’s fair share of cursing and bellyaching before I got it running for a company I’m currently contracting for, but since I’ve been using it, it’s got every feature that I’ve needed in small projects to keep myself organized, and my team connected.

It’s got a Wiki, Task Management (to track both Bugs and Tasks), Time Management, Repository Integration, and strong Access Control, all of which are compartmentalized by Project (of which you can have an infinite amount). That’s just scratching the surface of the features, there’s so much more available if the team were to grow larger.

Dreamhost is a pretty good host too, for many reasons, (price, featureset. The speed hit from page loads is a bit frustrating at times, but I’ve yet to find someone on the east coast that can beat them out, feature for feature, so I continue to stay a customer of theirs. (Something like 6 years and counting…)

Now, it’s really best if you start this setup with a brand new account (with SSH enabled), or you’re prepared to move a bunch of files.