add support to SDLBackend for rendering 24bit data
[openc2e.git] / caosVM_history.cpp
blob332329cd3b0770760ccc3ac3d151de127b8d4f88
1 /*
2 * caosVM_history.cpp
3 * openc2e
5 * Created by Alyssa Milburn on Mon Dec 19 2005.
6 * Copyright (c) 2005 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"
24 * TODO:
26 * monikers are auto-created when referenced by name, so the hasMoniker() asserts should be removed
29 /**
30 HIST CAGE (integer) moniker (string) event (integer)
31 %status maybe
33 void caosVM::v_HIST_CAGE() {
34 VM_PARAM_INTEGER(event)
35 VM_PARAM_STRING(moniker)
37 caos_assert(world.history.hasMoniker(moniker));
38 monikerData &m = world.history.getMoniker(moniker);
39 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
40 result.setInt(m.events[event].stage);
43 /**
44 HIST COUN (integer) moniker (string)
45 %status maybe
47 void caosVM::v_HIST_COUN() {
48 VM_PARAM_STRING(moniker)
50 if (world.history.hasMoniker(moniker)) {
51 monikerData &m = world.history.getMoniker(moniker);
52 result.setInt(m.events.size());
53 } else {
54 result.setInt(0);
58 /**
59 HIST CROS (integer) moniker (string)
60 %status maybe
62 void caosVM::v_HIST_CROS() {
63 VM_PARAM_STRING(moniker)
65 caos_assert(world.history.hasMoniker(moniker));
66 result.setInt(world.history.getMoniker(moniker).no_crossover_points);
69 /**
70 HIST EVNT (command) moniker (string) type (integer) relatedmoniker1 (string) relatedmoniker2 (string)
71 %status maybe
73 Fire a life event of the specified type with the specified moniker.
75 void caosVM::c_HIST_EVNT() {
76 VM_PARAM_STRING(relatedmoniker2)
77 VM_PARAM_STRING(relatedmoniker1)
78 VM_PARAM_INTEGER(type)
79 VM_PARAM_STRING(moniker)
81 caos_assert(world.history.hasMoniker(moniker));
82 monikerData &m = world.history.getMoniker(moniker);
83 m.addEvent(type, relatedmoniker1, relatedmoniker2);
86 /**
87 HIST FIND (integer) moniker (string) event (integer) from (integer)
88 %status maybe
90 void caosVM::v_HIST_FIND() {
91 VM_PARAM_INTEGER(from)
92 VM_PARAM_INTEGER(event)
93 VM_PARAM_STRING(moniker)
95 caos_assert(world.history.hasMoniker(moniker));
96 monikerData &m = world.history.getMoniker(moniker);
98 for (int i = from + 1; i >= 0 && (unsigned int)i < m.events.size(); i++) {
99 if (m.events[i].eventno == (unsigned int)event) {
100 result.setInt(i);
101 return;
105 result.setInt(-1);
109 HIST FINR (integer) moniker (string) event (integer) from (integer)
110 %status maybe
112 void caosVM::v_HIST_FINR() {
113 VM_PARAM_INTEGER(from)
114 VM_PARAM_INTEGER(event)
115 VM_PARAM_STRING(moniker)
117 caos_assert(world.history.hasMoniker(moniker));
118 monikerData &m = world.history.getMoniker(moniker);
120 if (from == -1) from = m.events.size();
122 for (int i = from - 1; i >= 0 && (unsigned int)i < m.events.size(); i--) {
123 if (m.events[i].eventno == (unsigned int)event) {
124 result.setInt(i);
125 return;
129 result.setInt(-1);
133 HIST FOTO (string) moniker (string) event (integer)
134 %status maybe
136 void caosVM::v_HIST_FOTO() {
137 VM_PARAM_INTEGER(event)
138 VM_PARAM_STRING(moniker)
140 caos_assert(world.history.hasMoniker(moniker));
141 monikerData &m = world.history.getMoniker(moniker);
142 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
144 result.setString(m.events[event].photo);
148 HIST FOTO (command) moniker (string) event (integer) photo (string)
149 %status maybe
151 void caosVM::c_HIST_FOTO() {
152 VM_PARAM_STRING(photo)
153 VM_PARAM_INTEGER(event)
154 VM_PARAM_STRING(moniker)
156 caos_assert(world.history.hasMoniker(moniker));
157 monikerData &m = world.history.getMoniker(moniker);
158 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
160 // TODO: handle magic (ie, atticing old photo)
161 m.events[event].photo = photo;
165 HIST GEND (integer) moniker (string)
166 %status maybe
168 void caosVM::v_HIST_GEND() {
169 VM_PARAM_STRING(moniker)
171 caos_assert(world.history.hasMoniker(moniker));
172 monikerData &m = world.history.getMoniker(moniker);
174 result.setInt(m.gender);
178 HIST GNUS (integer) moniker (string)
179 %status maybe
181 void caosVM::v_HIST_GNUS() {
182 VM_PARAM_STRING(moniker)
184 caos_assert(world.history.hasMoniker(moniker));
185 monikerData &m = world.history.getMoniker(moniker);
187 result.setInt(m.genus);
191 HIST MON1 (string) moniker (string) event (integer)
192 %status maybe
194 void caosVM::v_HIST_MON1() {
195 VM_PARAM_INTEGER(event)
196 VM_PARAM_STRING(moniker)
198 caos_assert(world.history.hasMoniker(moniker));
199 monikerData &m = world.history.getMoniker(moniker);
200 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
202 result.setString(m.events[event].monikers[0]);
206 HIST MON2 (string) moniker (string) event (integer)
207 %status maybe
209 void caosVM::v_HIST_MON2() {
210 VM_PARAM_INTEGER(event)
211 VM_PARAM_STRING(moniker)
213 caos_assert(world.history.hasMoniker(moniker));
214 monikerData &m = world.history.getMoniker(moniker);
215 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
217 result.setString(m.events[event].monikers[1]);
221 HIST MUTE (integer) moniker (string)
222 %status maybe
224 void caosVM::v_HIST_MUTE() {
225 VM_PARAM_STRING(moniker)
227 caos_assert(world.history.hasMoniker(moniker));
228 monikerData &m = world.history.getMoniker(moniker);
230 result.setInt(m.no_point_mutations);
234 HIST NAME (string) moniker (string)
235 %status maybe
237 Return the name of the creature with the given moniker.
239 void caosVM::v_HIST_NAME() {
240 VM_PARAM_STRING(moniker)
242 caos_assert(world.history.hasMoniker(moniker));
243 monikerData &m = world.history.getMoniker(moniker);
245 result.setString(m.name);
249 HIST NAME (command) moniker (string) name (string)
250 %status maybe
252 void caosVM::c_HIST_NAME() {
253 VM_PARAM_STRING(name)
254 VM_PARAM_STRING(moniker)
256 caos_assert(world.history.hasMoniker(moniker));
257 monikerData &m = world.history.getMoniker(moniker);
259 m.name = name;
263 HIST NETU (string) moniker (string) event (integer)
264 %status maybe
266 void caosVM::v_HIST_NETU() {
267 VM_PARAM_INTEGER(event)
268 VM_PARAM_STRING(moniker)
270 caos_assert(world.history.hasMoniker(moniker));
271 monikerData &m = world.history.getMoniker(moniker);
272 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
274 result.setString(m.events[event].networkid);
278 HIST NEXT (string) moniker (string)
279 %status stub
281 void caosVM::v_HIST_NEXT() {
282 VM_PARAM_STRING(moniker)
284 result.setString(""); // TODO
288 HIST PREV (string) moniker (string)
289 %status stub
291 void caosVM::v_HIST_PREV() {
292 VM_PARAM_STRING(moniker)
294 result.setString(""); // TODO
298 HIST RTIM (integer) moniker (string) event (integer)
299 %status maybe
301 void caosVM::v_HIST_RTIM() {
302 VM_PARAM_INTEGER(event)
303 VM_PARAM_STRING(moniker)
305 caos_assert(world.history.hasMoniker(moniker));
306 monikerData &m = world.history.getMoniker(moniker);
307 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
309 result.setInt(m.events[event].timestamp);
313 HIST TAGE (integer) moniker (string) event (integer)
314 %status maybe
316 void caosVM::v_HIST_TAGE() {
317 VM_PARAM_INTEGER(event)
318 VM_PARAM_STRING(moniker)
320 caos_assert(world.history.hasMoniker(moniker));
321 monikerData &m = world.history.getMoniker(moniker);
322 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
324 result.setInt(m.events[event].tage);
328 HIST TYPE (integer) moniker (string) event (integer)
329 %status maybe
331 void caosVM::v_HIST_TYPE() {
332 VM_PARAM_INTEGER(event)
333 VM_PARAM_STRING(moniker)
335 caos_assert(world.history.hasMoniker(moniker));
336 monikerData &m = world.history.getMoniker(moniker);
337 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
339 result.setInt(m.events[event].eventno);
343 HIST UTXT (command) moniker (string) event (integer) value (string)
344 %status maybe
346 void caosVM::c_HIST_UTXT() {
347 VM_PARAM_STRING(value)
348 VM_PARAM_INTEGER(event)
349 VM_PARAM_STRING(moniker)
351 caos_assert(world.history.hasMoniker(moniker));
352 monikerData &m = world.history.getMoniker(moniker);
353 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
355 m.events[event].usertext = value;
359 HIST UTXT (string) moniker (string) event (integer)
360 %status maybe
362 void caosVM::v_HIST_UTXT() {
363 VM_PARAM_INTEGER(event)
364 VM_PARAM_STRING(moniker)
366 caos_assert(world.history.hasMoniker(moniker));
367 monikerData &m = world.history.getMoniker(moniker);
368 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
370 result.setString(m.events[event].usertext);
374 HIST VARI (integer) moniker (string)
375 %status maybe
377 void caosVM::v_HIST_VARI() {
378 VM_PARAM_STRING(moniker)
380 caos_assert(world.history.hasMoniker(moniker));
381 monikerData &m = world.history.getMoniker(moniker);
383 result.setInt(m.variant);
387 HIST WIPE (command) moniker (string)
388 %status stub
390 void caosVM::c_HIST_WIPE() {
391 VM_PARAM_STRING(moniker)
393 caos_assert(world.history.hasMoniker(moniker));
394 monikerData &m = world.history.getMoniker(moniker);
396 // TODO
400 HIST WNAM (string) moniker (string) event (integer)
401 %status stub
403 void caosVM::v_HIST_WNAM() {
404 VM_PARAM_INTEGER(event)
405 VM_PARAM_STRING(moniker)
407 caos_assert(world.history.hasMoniker(moniker));
408 monikerData &m = world.history.getMoniker(moniker);
409 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
411 result.setString(m.events[event].worldname); // TODO
415 HIST WTIK (integer) moniker (string) event (integer)
416 %status maybe
418 void caosVM::v_HIST_WTIK() {
419 VM_PARAM_INTEGER(event)
420 VM_PARAM_STRING(moniker)
422 caos_assert(world.history.hasMoniker(moniker));
423 monikerData &m = world.history.getMoniker(moniker);
424 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
426 result.setInt(m.events[event].worldtick);
430 HIST WUID (string) moniker (string) event (integer)
431 %status maybe
433 void caosVM::v_HIST_WUID() {
434 VM_PARAM_INTEGER(event)
435 VM_PARAM_STRING(moniker)
437 caos_assert(world.history.hasMoniker(moniker));
438 monikerData &m = world.history.getMoniker(moniker);
439 caos_assert(event >= 0 && (unsigned int)event < m.events.size());
441 result.setString(m.events[event].worldmoniker);
445 HIST WVET (integer) moniker (string)
446 %status maybe
448 void caosVM::v_HIST_WVET() {
449 VM_PARAM_STRING(moniker)
451 caos_assert(world.history.hasMoniker(moniker));
452 monikerData &m = world.history.getMoniker(moniker);
454 if (m.warpveteran)
455 result.setInt(1);
456 else
457 result.setInt(0);
461 OOWW (integer) moniker (string)
462 %status maybe
464 Return the current status of the given moniker.
465 0 is unknown (never existed?), 1 is in slot, 2 is NEW: CREA creature, 3 is BORN creature, 4 is exported, 5 is dead, 6 is gone (no body), 7 is unreferenced.
467 void caosVM::v_OOWW() {
468 VM_PARAM_STRING(moniker)
470 result.setInt(0);
472 if (world.history.hasMoniker(moniker)) {
473 monikerData &m = world.history.getMoniker(moniker);
475 result.setInt((int)m.getStatus());
480 EVNT (command) object (agent)
481 %status stub
482 %pragma variants c1 c2
484 void caosVM::c_EVNT() {
485 VM_PARAM_VALIDAGENT(object)
487 // TODO
491 RMEV (command) object (agent)
492 %status stub
493 %pragma variants c1 c2
495 void caosVM::c_RMEV() {
496 VM_PARAM_VALIDAGENT(object)
498 // TODO
502 DDE: NEGG (command)
503 %status stub
504 %pragma variants c1 c2
506 void caosVM::c_DDE_NEGG() {
507 // TODO
511 DDE: DIED (command)
512 %status stub
513 %pragma variants c1 c2
515 void caosVM::c_DDE_DIED() {
516 // TODO
520 DDE: LIVE (command)
521 %status stub
522 %pragma variants c1 c2
524 void caosVM::c_DDE_LIVE() {
525 // TODO
529 /* vim: set noet: */