add unfinished bmpImage implementation
[openc2e.git] / caosVM_time.cpp
blob1e90a5945dee13b7658f89e30792176a9a0c7bf6
1 /*
2 * caosVM_time.cpp
3 * openc2e
5 * Created by Alyssa Milburn on Sat Jun 05 2004.
6 * Copyright (c) 2004 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #include "caosVM.h"
21 #include "World.h"
22 #include "Engine.h"
23 #include "Backend.h"
24 #include <time.h> // gmtime and strftime
26 /**
27 PACE (float)
28 %status maybe
30 return speed factor of last ten ticks.
32 < 1.0 = engine is ticking faster than BUZZ rating. > 1.0 = engine is ticking slower.
34 You might want to use this to reduce the amount of agents created or the amount of processing done if the speed factor is above 1.0.
36 void caosVM::v_PACE() {
37 result.setFloat(world.pace);
40 /**
41 BUZZ (command) interval (integer)
42 %status maybe
44 void caosVM::c_BUZZ() {
45 VM_PARAM_INTEGER(interval)
47 world.ticktime = interval;
50 /**
51 BUZZ (integer)
52 %status maybe
54 void caosVM::v_BUZZ() {
55 result.setInt(world.ticktime);
58 /**
59 DATE (integer)
60 %status maybe
62 Returns the day in the season of the current game world, starting at 0.
64 void caosVM::v_DATE() {
65 result.setInt(world.dayofseason);
68 /**
69 HIST DATE (integer) tick (integer)
70 %status stub
72 Returns the day in the season of the current game world at the specified world tick, starting at 0. See DATE.
74 void caosVM::v_HIST_DATE() {
75 VM_PARAM_INTEGER(tick)
77 result.setInt(0); // TODO
80 /**
81 SEAN (integer)
82 %status maybe
83 %pragma variants c2 cv c3
85 Returns the current game world season. 0 is spring, 1 is summer, 2 is autumn and 3 is winter.
87 void caosVM::v_SEAN() {
88 result.setInt(world.season);
91 /**
92 HIST SEAN (integer) tick (integer)
93 %status stub
95 Returns the current game world season at the specified world tick. 0 is spring, 1 is summer, 2 is autumn and 3 is winter. See SEAN.
97 void caosVM::v_HIST_SEAN() {
98 VM_PARAM_INTEGER(tick)
100 result.setInt(0); // TODO
104 TIME (integer)
105 %status maybe
107 Returns the time of day in the current game world. 0 is dawn, 1 is morning, 2 is afternoon, 3 is evening and 4 is night.
109 void caosVM::v_TIME() {
110 result.setInt(world.timeofday);
114 HIST TIME (integer) tick (integer)
115 %status stub
117 Returns the time of day in the current game world at the specified world tick. 0 is dawn, 1 is morning, 2 is afternoon, 3 is evening and 4 is night. See TIME.
119 void caosVM::v_HIST_TIME() {
120 VM_PARAM_INTEGER(tick)
122 result.setInt(0); // TODO
126 YEAR (integer)
127 %status maybe
128 %pragma variants c2 cv c3
130 Returns the number of game years elapsed in the current world.
132 void caosVM::v_YEAR() {
133 result.setInt(world.year);
137 HIST YEAR (integer) tick (integer)
138 %status stub
140 Returns the number of game years elapsed at the specified world tick. See YEAR.
142 void caosVM::v_HIST_YEAR() {
143 VM_PARAM_INTEGER(tick)
145 result.setInt(0); // TODO
149 MSEC (integer)
150 %status maybe
152 void caosVM::v_MSEC() {
153 result.setInt(engine.backend->ticks());
157 WPAU (command) paused (integer)
158 %status stub
160 If paused is 0, enable world ticks, otherwise (1) disable them.
162 void caosVM::c_WPAU() {
163 VM_PARAM_INTEGER(paused)
165 // TODO
169 WPAU (integer)
170 %status stub
172 Returns 1 if world ticks are paused, or 0 otherwise.
174 void caosVM::v_WPAU() {
175 result.setInt(0); // TODO
179 PAUS (command) paused (integer)
180 %status maybe
182 If paused is 0, unpause target agent, otherwise (1) pause it.
184 void caosVM::c_PAUS() {
185 VM_PARAM_INTEGER(paused)
187 valid_agent(targ);
189 targ->paused = paused;
193 PAUS (integer)
194 %status maybe
196 Returns 1 if target agent is paused, or 0 otherwise.
198 void caosVM::v_PAUS() {
199 valid_agent(targ);
201 if (targ->paused)
202 result.setInt(1);
203 else
204 result.setInt(0);
208 RTIF (string) timestamp (integer) format (string)
209 %status maybe
211 Returns the result of strftime with the current timestamp and format.
213 void caosVM::v_RTIF() {
214 VM_PARAM_STRING(format)
215 VM_PARAM_INTEGER(timestamp)
217 char buffer[1000]; // no idea what maximum length should be.. we can't really do this dynamically
218 time_t tstamp = timestamp;
219 strftime(buffer, 1000, format.c_str(), gmtime(&tstamp)); // TODO: does gmtime return null?
221 result.setString(buffer);
225 RTIM (integer)
226 %status maybe
228 void caosVM::v_RTIM() {
229 result.setInt(time(0));
233 WTIK (integer)
234 %status maybe
236 void caosVM::v_WTIK() {
237 result.setInt(world.worldtickcount);
241 RACE (integer)
242 %status maybe
244 void caosVM::v_RACE() {
245 result.setInt(world.race);
249 ETIK (integer)
250 %status maybe
252 void caosVM::v_ETIK() {
253 result.setInt(world.tickcount);
257 ASEA (command)
258 %status stub
259 %pragma variants c2
261 void caosVM::c_ASEA() {
262 // TODO
266 TMOD (integer)
267 %status maybe
268 %pragma variants c2
270 void caosVM::v_TMOD() {
271 result.setInt(world.timeofday); // TODO
275 SEAV (integer)
276 %status maybe
277 %pragma variants c2
279 void caosVM::v_SEAV() {
280 // TODO: hardcoding bad?
281 result.setInt((world.dayofseason * 4) + world.timeofday);
285 DAYT (integer)
286 %status stub
288 void caosVM::v_DAYT() {
289 result.setInt(0); // TODO
293 MONT (integer)
294 %status stub
296 void caosVM::v_MONT() {
297 result.setInt(0); // TODO
300 /* vim: set noet: */