Ignore:
Timestamp:
04/23/09 05:28:08 (3 years ago)
Author:
james
Message:

use wrapper function for bMotionLastEvent to try to get rid of more errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/system.tcl

    r997 r1003  
    104104} 
    105105 
     106# 
     107# get the last event for a channel, or 0 if not available 
     108proc bMotion_get_last_event { channel } { 
     109        bMotion_putloglev 4 * "bMotion_get_last_event $channel" 
     110 
     111        global bMotionLastEvent 
     112 
     113        set last_event 0 
     114        catch { 
     115                set last_event $bMotionLastEvent($channel) 
     116        } 
     117        if {$last_event == 0} { 
     118                bMotion_putloglev 1 * "last event for $channel is not available, returning 0" 
     119        } 
     120 
     121        return $last_event 
     122} 
     123 
     124# 
     125# set the last event time for a channel to now 
     126proc bMotion_set_last_event { channel } { 
     127        bMotion_putloglev 4 * "bMotion_set_last_event $channel" 
     128 
     129        global bMotionLastEvent 
     130 
     131        set bMotionLastEvent($channel) [clock seconds] 
     132} 
    106133 
    107134# 
     
    109136proc bMotion_is_active_enough { channel { limit 0 } } { 
    110137        global bMotionInfo  
    111         global bMotionLastEvent  
    112138 
    113139        bMotion_putloglev 4 * "bMotion_is_active_enough $channel" 
    114140 
    115         set last_event 0 
    116         catch { 
    117                 set last_event $bMotionLastEvent($channel) 
    118         } 
     141        set last_event [bMotion_get_last_event $channel] 
     142 
    119143        if {$last_event == 0} { 
    120144                bMotion_putloglev d * "last event info for $channel not available" 
    121145                # force it to be now 
    122                 set bMotionLastEvent($channel) [clock seconds] 
     146                bMotion_set_last_event $channel 
    123147                # assume we're ok 
    124148                return 1 
     
    140164# check if every channel we can see is idle enough for us to go away 
    141165proc bMotion_random_away {} { 
    142         global bMotionLastEvent bMotionChannels bMotionInfo 
     166        global bMotionChannels bMotionInfo 
    143167 
    144168        set timeNow [clock seconds] 
     
    160184        foreach channel $bMotionChannels { 
    161185                catch { 
    162                         append line "$channel=$bMotionLastEvent($channel) " 
    163                         if {$bMotionLastEvent($channel) > $mostRecent} { 
    164                                 set mostRecent $bMotionLastEvent($channel) 
     186                        set last_event [bMotion_get_last_event $channel] 
     187                        append line "$channel=$last_event " 
     188                        if {$last_event > $mostRecent} { 
     189                                set mostRecent $last_event 
    165190                        } 
    166191                } 
     
    192217proc doRandomStuff {} { 
    193218        global bMotionInfo mood stonedRandomStuff bMotionSettings 
    194         global bMotionLastEvent bMotionOriginalNick bMotionChannels 
     219        global bMotionOriginalNick bMotionChannels 
    195220        global BMOTION_SLEEP 
    196221 
Note: See TracChangeset for help on using the changeset viewer.