diff --git a/code/datums/sun.dm b/code/datums/sun.dm index 3517ad6d98e..9ce8a73cb72 100644 --- a/code/datums/sun.dm +++ b/code/datums/sun.dm @@ -2,14 +2,15 @@ var/angle var/dx var/dy - var/counter = 50 // to make the vars update during 1st call +// var/counter = 50 // to make the vars update during 1st call var/rate var/list/solars // for debugging purposes, references solars_list at the constructor + var/nexttime = 3600 // Replacement for var/counter to force the sun to move every X IC minutes /datum/sun/New() solars = solars_list - rate = rand(75,125)/100 // 75% - 125% of standard rotation + rate = rand(750,1250)/1000 // 75.0% - 125.0% of standard rotation if(prob(50)) rate = -rate @@ -17,13 +18,22 @@ /datum/sun/proc/calc_position() - counter++ +/* counter++ if(counter<50) // count 50 pticks (50 seconds, roughly - about a 5deg change) return - counter = 0 + counter = 0 */ + + angle = ((rate*world.time/100)%360 + 360)%360 + /* + Yields a 45 - 75 IC minute rotational period + Rotation rate can vary from 4.8 deg/min to 8 deg/min (288 to 480 deg/hr) + */ + + // To prevent excess server load the server only updates the sun's sight lines every 6 minutes + if(nexttime < world.time) + return + nexttime = nexttime + 3600 // 600 world.time ticks = 1 minute, 3600 = 6 minutes. - angle = ((rate*world.realtime/100)%360 + 360)%360 // gives about a 60 minute rotation time - // now 45 - 75 minutes, depending on rate // now calculate and cache the (dx,dy) increments for line drawing var/s = sin(angle) diff --git a/code/modules/power/solar.dm b/code/modules/power/solar.dm index 01003ed2911..2be8b7717a6 100644 --- a/code/modules/power/solar.dm +++ b/code/modules/power/solar.dm @@ -277,10 +277,10 @@ var/list/solars_list = list() var/cdir = 0 var/gen = 0 var/lastgen = 0 - var/track = 0 // 0= off 1=timed 2=auto (tracker) - var/trackrate = 600 // 300-900 seconds - var/trackdir = 1 // 0 =CCW, 1=CW - var/nexttime = 0 + var/track = 0 // 0=off 1=manual 2=automatic + var/trackrate = 60 // Measured in tenths of degree per minute (i.e. defaults to 6.0 deg/min) + var/trackdir = 1 // -1=CCW, 1=CW + var/nexttime = 0 // Next clock time that manual tracking will move the array /obj/machinery/power/solar_control/New() @@ -371,9 +371,11 @@ var/list/solars_list = list() return use_power(250) - if(track==1 && nexttime < world.timeofday && trackrate) - nexttime = world.timeofday + 3600/abs(trackrate) - cdir = (cdir+trackrate/abs(trackrate)+360)%360 + if(track==1 && nexttime < world.time && trackdir*trackrate) + // Increments nexttime using itself and not world.time to prevent drift + nexttime = nexttime + 6000/trackrate + // Nudges array 1 degree in desired direction + cdir = (cdir+trackdir+360)%360 set_panels(cdir) update_icon() @@ -402,19 +404,28 @@ var/list/solars_list = list() user.set_machine(src) var/t = "Solar Generator Control
"
-	t += "Generated power : [round(lastgen)] W

" - t += "Orientation: [rate_control(src,"cdir","[cdir]°",1,15)] ([angle2text(cdir)])


" - t += "



" + t += "Generated power : [round(lastgen)] W
" + t += "Station Rotational Period: [60/abs(sun.rate)] minutes
" + t += "Station Rotational Direction: [sun.rate<0 ? "CCW" : "CW"]
" + t += "Star Orientation: [sun.angle]° ([angle2text(sun.angle)])
" + t += "Array Orientation: [rate_control(src,"cdir","[cdir]°",1,10,60)] ([angle2text(cdir)])
" + t += "


" t += "Tracking: " switch(track) if(0) - t += "Off Timed Auto
" + t += "Off Manual Automatic
" if(1) - t += "Off Timed Auto
" + t += "Off Manual Automatic
" if(2) - t += "Off Timed Auto
" + t += "Off Manual Automatic
" - t += "Tracking Rate: [rate_control(src,"tdir","[trackrate] deg/h ([trackrate<0 ? "CCW" : "CW"])",5,30,180)]

" + t += "Manual Tracking Rate: [rate_control(src,"tdir","[trackrate/10]°/min ([trackdir<0 ? "CCW" : "CW"])",1,10)]
" + t += "Manual Tracking Direction: " + switch(trackdir) + if(-1) + t += "CW CCW
" + if(1) + t += "CW CCW
" t += "Close
" user << browse(t, "window=solcon") onclose(user, "solcon") @@ -443,11 +454,11 @@ var/list/solars_list = list() set_panels(cdir) update_icon() if(href_list["tdir"]) - src.trackrate = dd_range(-7200,7200,src.trackrate+text2num(href_list["tdir"])) - if(src.trackrate) nexttime = world.timeofday + 3600/abs(trackrate) + src.trackrate = dd_range(0,360,src.trackrate+text2num(href_list["tdir"])) + if(src.trackrate) nexttime = world.time + 6000/trackrate if(href_list["track"]) - if(src.trackrate) nexttime = world.timeofday + 3600/abs(trackrate) + if(src.trackrate) nexttime = world.time + 6000/trackrate track = text2num(href_list["track"]) if(powernet && (track == 2)) for(var/obj/machinery/power/tracker/T in get_solars_powernet()) @@ -455,6 +466,9 @@ var/list/solars_list = list() cdir = T.sun_angle break + if(href_list["trackdir"]) + trackdir = text2num(href_list["trackdir"]) + set_panels(cdir) update_icon() src.updateUsrDialog()