ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/time.C
(Generate patch)

Comparing deliantra/server/common/time.C (file contents):
Revision 1.10 by root, Sat Mar 17 22:11:22 2007 UTC vs.
Revision 1.14 by root, Thu May 17 21:32:08 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 * 7 *
32#include <sys/time.h> 32#include <sys/time.h>
33 33
34/* 34/*
35 * Gloabal variables: 35 * Gloabal variables:
36 */ 36 */
37long pticks; 37tick_t pticks;
38 38
39static const char *season_name[5] = { 39static const char *season_name[5] = {
40 "New Year", 40 "New Year",
41 "Growth", 41 "Growth",
42 "Harvest", 42 "Harvest",
75}; 75};
76 76
77void 77void
78get_tod (timeofday_t * tod) 78get_tod (timeofday_t * tod)
79{ 79{
80 unsigned int todtick = runtime * (1. / RUNTIME_PER_HOUR); 80 unsigned int todtick = (unsigned int)(runtime * (1. / RUNTIME_PER_HOUR));
81 81
82 tod->year = todtick / HOURS_PER_YEAR; 82 tod->year = todtick / HOURS_PER_YEAR;
83 tod->month = todtick / HOURS_PER_MONTH % MONTHS_PER_YEAR; 83 tod->month = todtick / HOURS_PER_MONTH % MONTHS_PER_YEAR;
84 tod->day = todtick % HOURS_PER_MONTH / DAYS_PER_MONTH; 84 tod->day = todtick % HOURS_PER_MONTH / DAYS_PER_MONTH;
85 tod->hour = todtick % HOURS_PER_DAY; 85 tod->hour = todtick % HOURS_PER_DAY;
86 tod->minute = (runtime - todtick * RUNTIME_PER_HOUR) * (60. / RUNTIME_PER_HOUR); 86 tod->minute = (int)((runtime - todtick * RUNTIME_PER_HOUR) * (60. / RUNTIME_PER_HOUR));
87 87
88 tod->dayofweek = tod->day % DAYS_PER_WEEK; 88 tod->dayofweek = tod->day % DAYS_PER_WEEK;
89 tod->weekofmonth = tod->day / WEEKS_PER_MONTH; 89 tod->weekofmonth = tod->day / WEEKS_PER_MONTH;
90 tod->season = min (4, tod->month / 3); 90 tod->season = min (4, tod->month / 3);
91} 91}
92 92
93void 93void
94print_tod (object *op) 94print_tod (object *op)
95{ 95{
96 timeofday_t tod; 96 timeofday_t tod;
97
98 get_tod (&tod); 97 get_tod (&tod);
99 98
100 char todmsg [1024]; 99 char todmsg [1024];
101 100
102 int day = tod.day + 1; 101 int day = tod.day + 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines