Skip to content
Permalink
Browse files

added time recording for total game length and amount of time slept to

the game log
  • Loading branch information...
Jake Fonseca
Jake Fonseca committed Oct 19, 2014
1 parent cb44144 commit 2e479182ca70e4fb3076ab2ce432b9134322d764
Showing with 17 additions and 3 deletions.
  1. +2 −0 instance_file.xml
  2. +7 −2 lib/OCCPGameServer.rb
  3. +8 −1 lib/OCCPGameServer/main.rb
@@ -17,6 +17,7 @@

<!-- Users for the web services console -->
<users>
<user name="brandon" pass="workhere"/>
<user name="moderator" pass="token"/>
<user name="blueplayer" pass="token"/>
<user name="spectator" pass="token"/>
@@ -41,6 +42,7 @@
<scoreboard name="moderator-board" />
<permitted-users>
<user name="moderator" />
<user name="brandon" />
</permitted-users>
</user-interface>
</user-interfaces>
@@ -188,7 +188,7 @@ def self.instance_file_parser(instancefile)
new_team = Team.new

#TODO Decide if this needs fixing
new_team.teamid = i #SecureRandom.uuid
new_team.teamid = SecureRandom.uuid
i += 1
new_team.teamname = teamxmlnode.attributes["name"]
new_team.teamhost = teamxmlnode.find('team-host').first.attributes["hostname"]
@@ -492,7 +492,12 @@ def self.instance_file_parser(instancefile)
# Wait for Children to exit
userInterface.join
main.join


#Log final times
totalgametime = $appCore.endtime - $appCore.begintime
$log.info "Total game length: #{'%.2f' % totalgametime} sec"
$log.info "Total time paused: #{'%.2f' % (totalgametime - $appCore.gameclock.gametime)} sec"

#Cleanup and Close Files
$db.close

@@ -5,7 +5,7 @@ class Main
attr_accessor :gameclock, :networkid, :scenarioname, :INBOX, :eventRunQueue
attr_accessor :STATE, :db, :scoreKeeper, :interfaces, :ipPools
attr_accessor :gameid, :type, :description
attr_reader :teams
attr_reader :teams, :begintime, :endtime

def initialize
@events = {}
@@ -28,6 +28,9 @@ def initialize
@ipPools = {}
@nsPool = Array.new
@nsRegistry = IPTools::NetNSRegistry.new

@begintime = nil
@endtime = nil
end

def add_event()
@@ -108,6 +111,9 @@ def set_state(state)
@gameclock.pause
end
when RUN
if @begintime == nil
@begintime = Time.now
end
@gameclock.resume
@teams.each { |team|
team.INBOX << GMessage.new({:fromid=>'Main Thread',:signal=>'COMMAND', :msg=>{:command => 'STATE', :state=> RUN}})
@@ -120,6 +126,7 @@ def set_state(state)
team.INBOX << GMessage.new({:fromid=>'Main Thread',:signal=>'COMMAND', :msg=>{:command => 'STATE', :state=> STOP}})
}
@gameclock.pause
@endtime = Time.now
when QUIT
@teams.each { |team|
team.INBOX << GMessage.new({:fromid=>'Main Thread',:signal=>'COMMAND', :msg=>{:command => 'STATE', :state=> STOP}})

0 comments on commit 2e47918

Please sign in to comment.
You can’t perform that action at this time.