| 12 |
|
#include "copyright.h" |
| 13 |
|
|
| 14 |
|
#include <time.h> |
| 15 |
< |
#ifdef _WIN32 |
| 15 |
> |
#if defined(_WIN32) || defined(_WIN64) |
| 16 |
|
#include <winsock.h> /* struct timeval. XXX find a replacement? */ |
| 17 |
|
#else |
| 18 |
|
#include <sys/time.h> |
| 20 |
|
#include <ctype.h> |
| 21 |
|
#include <string.h> |
| 22 |
|
|
| 23 |
+ |
#include "platform.h" |
| 24 |
|
#include "paths.h" |
| 25 |
|
#include "ranimove.h" |
| 26 |
|
|
| 189 |
|
} |
| 190 |
|
|
| 191 |
|
|
| 192 |
+ |
void |
| 193 |
+ |
quit(ec) /* make sure exit is called */ |
| 194 |
+ |
int ec; |
| 195 |
+ |
{ |
| 196 |
+ |
if (ray_pnprocs > 0) /* close children if any */ |
| 197 |
+ |
ray_pclose(0); |
| 198 |
+ |
exit(ec); |
| 199 |
+ |
} |
| 200 |
+ |
|
| 201 |
+ |
|
| 202 |
|
static void |
| 203 |
|
setdefaults(void) /* set default values */ |
| 204 |
|
{ |
| 350 |
|
av[ac=0] = NULL; |
| 351 |
|
/* load options from file, first */ |
| 352 |
|
if (optf != NULL && *optf) { |
| 353 |
< |
ac = wordfile(av, optf); |
| 353 |
> |
ac = wordfile(av, 1024, optf); |
| 354 |
|
if (ac < 0) { |
| 355 |
|
sprintf(errmsg, "cannot load options file \"%s\"", |
| 356 |
|
optf); |
| 359 |
|
} |
| 360 |
|
/* then from options string */ |
| 361 |
|
if (qval != NULL && qval[0] == '-') |
| 362 |
< |
ac += wordstring(av+ac, qval); |
| 362 |
> |
ac += wordstring(av+ac, 1024-ac, qval); |
| 363 |
|
|
| 364 |
|
/* restore default parameters */ |
| 365 |
|
ray_restore(NULL); |
| 615 |
|
) |
| 616 |
|
{ |
| 617 |
|
static char combuf[1024]; |
| 618 |
< |
int cfm = 0; |
| 618 |
> |
static int cfm = 0; |
| 619 |
|
int uses_inline; |
| 620 |
|
FILE *fp; |
| 621 |
|
int i; |
| 622 |
|
/* is octree static? */ |
| 623 |
|
if (!vdef(MOVE)) |
| 624 |
|
return(vval(OCTREEF)); |
| 625 |
< |
/* done already */ |
| 625 |
> |
/* done already? */ |
| 626 |
|
if (n == cfm) |
| 627 |
|
return(combuf); |
| 628 |
|
/* else create object file */ |
| 629 |
< |
strcpy(objtmpf, "movinobj.rad"); |
| 619 |
< |
fp = fopen(objtmpf, "w"); |
| 629 |
> |
fp = fopen(mktemp(strcpy(objtmpf, TEMPLATE)), "w"); |
| 630 |
|
if (fp == NULL) { |
| 631 |
|
sprintf(errmsg, "cannot write to moving objects file '%s'", |
| 632 |
|
objtmpf); |
| 657 |
|
vdef(OCONV) ? vval(OCONV) : "", |
| 658 |
|
vval(OCTREEF), objtmpf); |
| 659 |
|
else |
| 660 |
< |
sprintf(combuf, "!xform -f %s | oconv -f -i '%s' -", |
| 661 |
< |
objtmpf, vval(OCTREEF)); |
| 660 |
> |
sprintf(combuf, "!xform -f %s | oconv %s -f -i '%s' -", |
| 661 |
> |
objtmpf, vdef(OCONV) ? vval(OCONV) : "", |
| 662 |
> |
vval(OCTREEF)); |
| 663 |
|
return(combuf); |
| 664 |
|
} |
| 665 |
|
|
| 852 |
|
return(obj_move[moi].cprio); |
| 853 |
|
} |
| 854 |
|
|
| 855 |
+ |
|
| 856 |
+ |
#if defined(_WIN32) || defined(_WIN64) |
| 857 |
+ |
/* replacement function for Windoze */ |
| 858 |
+ |
static int |
| 859 |
+ |
gettimeofday(struct timeval *tp, void *dummy) |
| 860 |
+ |
{ |
| 861 |
+ |
FILETIME ft; |
| 862 |
+ |
LARGE_INTEGER li; |
| 863 |
+ |
__int64 t; |
| 864 |
+ |
|
| 865 |
+ |
SYSTEMTIME st; |
| 866 |
+ |
FILETIME ft2; |
| 867 |
+ |
LARGE_INTEGER li2; |
| 868 |
+ |
__int64 t2; |
| 869 |
+ |
|
| 870 |
+ |
st.wYear = 1970; |
| 871 |
+ |
st.wHour = 0; |
| 872 |
+ |
st.wMinute = 0; |
| 873 |
+ |
st.wSecond = 0; |
| 874 |
+ |
st.wMilliseconds = 1; |
| 875 |
+ |
|
| 876 |
+ |
SystemTimeToFileTime(&st, &ft2); |
| 877 |
+ |
li2.LowPart = ft2.dwLowDateTime; |
| 878 |
+ |
li2.HighPart = ft2.dwHighDateTime; |
| 879 |
+ |
t2 = li2.QuadPart; |
| 880 |
+ |
|
| 881 |
+ |
GetSystemTimeAsFileTime(&ft); |
| 882 |
+ |
li.LowPart = ft.dwLowDateTime; |
| 883 |
+ |
li.HighPart = ft.dwHighDateTime; |
| 884 |
+ |
t = li.QuadPart; |
| 885 |
+ |
t -= t2; // From 1970 |
| 886 |
+ |
t /= 10; // In microseconds |
| 887 |
+ |
tp->tv_sec = (long)(t / 1000000); |
| 888 |
+ |
tp->tv_usec = (long)(t % 1000000); |
| 889 |
+ |
return 0; |
| 890 |
+ |
} |
| 891 |
+ |
|
| 892 |
+ |
#endif |
| 893 |
|
|
| 894 |
|
extern double |
| 895 |
|
getTime(void) /* get current time (CPU or real) */ |