1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001-2003 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001-2003 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
… | |
… | |
29 | #include <sproto.h> |
29 | #include <sproto.h> |
30 | #include <time.h> |
30 | #include <time.h> |
31 | |
31 | |
32 | #include <glib.h> |
32 | #include <glib.h> |
33 | |
33 | |
34 | #include <../random_maps/random_map.h> |
34 | #include <rmg.h> |
35 | #include <../random_maps/rproto.h> |
35 | #include <rproto.h> |
36 | #include "path.h" |
36 | #include "path.h" |
37 | |
37 | |
38 | void |
38 | void |
39 | version (object *op) |
39 | version (object *op) |
40 | { |
40 | { |
… | |
… | |
103 | i = find_free_spot (this, newmap, x, y, 1, SIZEOFFREE); |
103 | i = find_free_spot (this, newmap, x, y, 1, SIZEOFFREE); |
104 | } |
104 | } |
105 | |
105 | |
106 | if (i >= 0) |
106 | if (i >= 0) |
107 | { |
107 | { |
|
|
108 | maptile *m = newmap; |
108 | x += freearr_x[i]; |
109 | sint16 nx = x + freearr_x[i]; |
109 | y += freearr_y[i]; |
110 | sint16 ny = y + freearr_y[i]; |
|
|
111 | |
|
|
112 | if (xy_normalise (m, nx, ny)) |
|
|
113 | { |
|
|
114 | newmap = m; |
|
|
115 | x = nx; |
|
|
116 | y = ny; |
|
|
117 | } |
110 | } |
118 | } |
111 | else |
119 | else |
112 | /* not much we can do in this case. */ |
120 | /* not much we can do in this case. */ |
113 | LOG (llevInfo, "enter_map: Could not find free spot for player - will dump on top of object (%s: %d, %d)\n", &newmap->path, x, y); |
121 | LOG (llevInfo, "enter_map: Could not find free spot for player - will dump on top of object (%s: %d, %d)\n", &newmap->path, x, y); |
114 | } |
122 | } |
… | |
… | |
236 | } |
244 | } |
237 | |
245 | |
238 | /* Now process op */ |
246 | /* Now process op */ |
239 | if (expect_false (op->flag [FLAG_FREED])) |
247 | if (expect_false (op->flag [FLAG_FREED])) |
240 | { |
248 | { |
241 | LOG (llevError, "BUG: process_events(): Free object on list\n"); |
249 | LOG (llevError, "BUG: process_events(): Free object on list (%s)\n", op->debug_desc ()); |
242 | op->set_speed (0); |
250 | op->set_speed (0); |
243 | continue; |
251 | continue; |
244 | } |
252 | } |
245 | |
253 | |
246 | if (expect_false (!op->has_active_speed ())) |
254 | if (expect_false (!op->has_active_speed ())) |
… | |
… | |
420 | int |
428 | int |
421 | main (int argc, char **argv) |
429 | main (int argc, char **argv) |
422 | { |
430 | { |
423 | settings.argc = argc; |
431 | settings.argc = argc; |
424 | settings.argv = argv; |
432 | settings.argv = argv; |
425 | |
433 | |
426 | rndm.seed (time (0)); |
434 | rndm.seed (time (0)); |
427 | g_thread_init (0); // for the slice allocator only |
435 | g_thread_init (0); // for the slice allocator only |
428 | |
436 | |
|
|
437 | // temporary(?) testing hack |
|
|
438 | if (argc >= 2 && !strcmp (argv [1], "--noise")) |
|
|
439 | { |
|
|
440 | void noise_test (); |
|
|
441 | noise_test (); |
|
|
442 | exit (0); |
|
|
443 | } |
|
|
444 | |
|
|
445 | #if 0 |
|
|
446 | // code sometiems used for timing benchmarks |
|
|
447 | random_number_generator<freeciv_random_generator> rng; |
|
|
448 | rng.seed(0); |
|
|
449 | for (int i = 0; i < 10; ++i) |
|
|
450 | printf ("%08x\n", rng.get_u32()); |
|
|
451 | for (int i = 0; i < 1000000; ++i) |
|
|
452 | volatile int r = rng.get_u32 (); |
|
|
453 | cstamp s = stamp (); |
|
|
454 | for (int i = 0; i < 1000000; ++i) |
|
|
455 | volatile int r = rng.next (); |
|
|
456 | printf ("c %d\n", (int)measure (s)); |
|
|
457 | exit (0); |
|
|
458 | #endif |
|
|
459 | |
429 | init (argc, argv); |
460 | init (argc, argv); |
430 | |
461 | |
431 | for (;;) |
462 | for (;;) |
432 | cfperl_main (); |
463 | cfperl_main (); |
433 | } |
464 | } |