Cleaned up the code and added comments.

This commit is contained in:
Patrick Fairbank
2014-09-06 22:25:12 -07:00
parent 247d5d1fee
commit d86a46f12e
35 changed files with 143 additions and 27 deletions

View File

@@ -14,10 +14,12 @@ const eventDbPath = "./event.db"
var db *Database
var eventSettings *EventSettings
// Main entry point for the application.
func main() {
rand.Seed(time.Now().UnixNano())
initDb()
// Run the webserver and DS packet listener in goroutines and use the main one for the arena state machine.
go ServeWebInterface()
listener, err := DsPacketListener()
checkErr(err)
@@ -26,6 +28,7 @@ func main() {
mainArena.Run()
}
// Opens the database and stores a handle to it in a global variable.
func initDb() {
var err error
db, err = OpenDatabase(eventDbPath)
@@ -34,6 +37,7 @@ func initDb() {
checkErr(err)
}
// Logs and exits the application if the given error is not nil.
func checkErr(err error) {
if err != nil {
log.Fatalln("Error: ", err)