Skip to content

Commit

Permalink
Rename WorldTime.TICK_RATE to TICK_EVENT_RATE
Browse files Browse the repository at this point in the history
  • Loading branch information
msteiger committed Oct 31, 2014
1 parent 7ce1381 commit f641460
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public void testEventMatchesDaily() {

long days = 3;

for (int tick = 0; tick < WorldTime.TICKS_PER_DAY * days; tick++) {
WorldTimeEvent event = new WorldTimeEvent(tick * WorldTime.TICK_RATE);
for (int tick = 0; tick < WorldTime.TICK_EVENTS_PER_DAY * days; tick++) {
WorldTimeEvent event = new WorldTimeEvent(tick * WorldTime.TICK_EVENT_RATE);

for (int i = 0; i < fracs.length; i++) {
if (event.matchesDaily(fracs[i])) {
Expand Down
4 changes: 2 additions & 2 deletions engine/src/main/java/org/terasology/world/time/WorldTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public interface WorldTime extends ComponentSystem {
* The number of timer tick events per day.
* This must be a divisor of {@link #DAY_LENGTH} to avoid rounding issues.
*/
long TICKS_PER_DAY = 100;
long TICK_EVENTS_PER_DAY = 100;

long TICK_RATE = DAY_LENGTH / TICKS_PER_DAY;
long TICK_EVENT_RATE = DAY_LENGTH / TICK_EVENTS_PER_DAY;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public boolean matchesDaily(float fraction) {
long fracInMs = DoubleMath.roundToLong(fraction * WorldTime.DAY_LENGTH, RoundingMode.HALF_UP);
long diff = getDayTimeInMs() - fracInMs;

return 2 * diff < WorldTime.TICK_RATE && 2 * diff >= -WorldTime.TICK_RATE;
return 2 * diff < WorldTime.TICK_EVENT_RATE && 2 * diff >= -WorldTime.TICK_EVENT_RATE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ public void update(float delta) {
long timeInDay = LongMath.mod(startTime, DAY_LENGTH);
long day = LongMath.divide(startTime, DAY_LENGTH, RoundingMode.FLOOR);

long startTick = startTime / TICK_RATE;
long endTick = (endTime) / TICK_RATE;
long startTick = startTime / TICK_EVENT_RATE;
long endTick = (endTime) / TICK_EVENT_RATE;

if (startTick != endTick) {
long tick = endTime - endTime % TICK_RATE;
long tick = endTime - endTime % TICK_EVENT_RATE;
getWorldEntity().send(new WorldTimeEvent(tick));
}

Expand Down

0 comments on commit f641460

Please sign in to comment.