1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-07 04:45:38 +00:00

Converted all tabs to four spaces

This commit is contained in:
Pieter van der Kloet 2011-01-05 22:18:21 +01:00
parent f3ae1ea737
commit dd4d022301
51 changed files with 1802 additions and 1802 deletions

View file

@ -354,45 +354,45 @@ struct option
/* Names for the values of the `has_arg' field of `struct option'. */ /* Names for the values of the `has_arg' field of `struct option'. */
#ifndef no_argument #ifndef no_argument
#define no_argument 0 #define no_argument 0
#endif #endif
#ifndef required_argument #ifndef required_argument
#define required_argument 1 #define required_argument 1
#endif #endif
#ifndef optional_argument #ifndef optional_argument
#define optional_argument 2 #define optional_argument 2
#endif #endif
struct custom_getopt_data { struct custom_getopt_data {
/* /*
* These have exactly the same meaning as the corresponding global variables, * These have exactly the same meaning as the corresponding global variables,
* except that they are used for the reentrant versions of getopt. * except that they are used for the reentrant versions of getopt.
*/ */
int custom_optind; int custom_optind;
int custom_opterr; int custom_opterr;
int custom_optopt; int custom_optopt;
char *custom_optarg; char *custom_optarg;
/* True if the internal members have been initialized. */ /* True if the internal members have been initialized. */
int initialized; int initialized;
/* /*
* The next char to be scanned in the option-element in which the last option * The next char to be scanned in the option-element in which the last option
* character we returned was found. This allows us to pick up the scan where * character we returned was found. This allows us to pick up the scan where
* we left off. If this is zero, or a null string, it means resume the scan by * we left off. If this is zero, or a null string, it means resume the scan by
* advancing to the next ARGV-element. * advancing to the next ARGV-element.
*/ */
char *nextchar; char *nextchar;
/* /*
* Describe the part of ARGV that contains non-options that have been skipped. * Describe the part of ARGV that contains non-options that have been skipped.
* `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is
* the index after the last of them. * the index after the last of them.
*/ */
int first_nonopt; int first_nonopt;
int last_nonopt; int last_nonopt;
}; };
/* /*
@ -448,137 +448,137 @@ static int custom_optopt = '?';
*/ */
static void exchange(char **argv, struct custom_getopt_data *d) static void exchange(char **argv, struct custom_getopt_data *d)
{ {
int bottom = d->first_nonopt; int bottom = d->first_nonopt;
int middle = d->last_nonopt; int middle = d->last_nonopt;
int top = d->custom_optind; int top = d->custom_optind;
char *tem; char *tem;
/* /*
* Exchange the shorter segment with the far end of the longer segment. * Exchange the shorter segment with the far end of the longer segment.
* That puts the shorter segment into the right place. It leaves the * That puts the shorter segment into the right place. It leaves the
* longer segment in the right place overall, but it consists of two * longer segment in the right place overall, but it consists of two
* parts that need to be swapped next. * parts that need to be swapped next.
*/ */
while (top > middle && middle > bottom) { while (top > middle && middle > bottom) {
if (top - middle > middle - bottom) { if (top - middle > middle - bottom) {
/* Bottom segment is the short one. */ /* Bottom segment is the short one. */
int len = middle - bottom; int len = middle - bottom;
int i; int i;
/* Swap it with the top part of the top segment. */ /* Swap it with the top part of the top segment. */
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
tem = argv[bottom + i]; tem = argv[bottom + i];
argv[bottom + i] = argv[bottom + i] =
argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i];
argv[top - (middle - bottom) + i] = tem; argv[top - (middle - bottom) + i] = tem;
} }
/* Exclude the moved bottom segment from further swapping. */ /* Exclude the moved bottom segment from further swapping. */
top -= len; top -= len;
} else { } else {
/* Top segment is the short one. */ /* Top segment is the short one. */
int len = top - middle; int len = top - middle;
int i; int i;
/* Swap it with the bottom part of the bottom segment. */ /* Swap it with the bottom part of the bottom segment. */
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
tem = argv[bottom + i]; tem = argv[bottom + i];
argv[bottom + i] = argv[middle + i]; argv[bottom + i] = argv[middle + i];
argv[middle + i] = tem; argv[middle + i] = tem;
} }
/* Exclude the moved top segment from further swapping. */ /* Exclude the moved top segment from further swapping. */
bottom += len; bottom += len;
} }
} }
/* Update records for the slots the non-options now occupy. */ /* Update records for the slots the non-options now occupy. */
d->first_nonopt += (d->custom_optind - d->last_nonopt); d->first_nonopt += (d->custom_optind - d->last_nonopt);
d->last_nonopt = d->custom_optind; d->last_nonopt = d->custom_optind;
} }
/* Initialize the internal data when the first call is made. */ /* Initialize the internal data when the first call is made. */
static void custom_getopt_initialize(struct custom_getopt_data *d) static void custom_getopt_initialize(struct custom_getopt_data *d)
{ {
/* /*
* Start processing options with ARGV-element 1 (since ARGV-element 0 * Start processing options with ARGV-element 1 (since ARGV-element 0
* is the program name); the sequence of previously skipped non-option * is the program name); the sequence of previously skipped non-option
* ARGV-elements is empty. * ARGV-elements is empty.
*/ */
d->first_nonopt = d->last_nonopt = d->custom_optind; d->first_nonopt = d->last_nonopt = d->custom_optind;
d->nextchar = NULL; d->nextchar = NULL;
d->initialized = 1; d->initialized = 1;
} }
#define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0') #define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
/* return: zero: continue, nonzero: return given value to user */ /* return: zero: continue, nonzero: return given value to user */
static int shuffle_argv(int argc, char *const *argv,const struct option *longopts, static int shuffle_argv(int argc, char *const *argv,const struct option *longopts,
struct custom_getopt_data *d) struct custom_getopt_data *d)
{ {
/* /*
* Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been
* moved back by the user (who may also have changed the arguments). * moved back by the user (who may also have changed the arguments).
*/ */
if (d->last_nonopt > d->custom_optind) if (d->last_nonopt > d->custom_optind)
d->last_nonopt = d->custom_optind; d->last_nonopt = d->custom_optind;
if (d->first_nonopt > d->custom_optind) if (d->first_nonopt > d->custom_optind)
d->first_nonopt = d->custom_optind; d->first_nonopt = d->custom_optind;
/* /*
* If we have just processed some options following some * If we have just processed some options following some
* non-options, exchange them so that the options come first. * non-options, exchange them so that the options come first.
*/ */
if (d->first_nonopt != d->last_nonopt && if (d->first_nonopt != d->last_nonopt &&
d->last_nonopt != d->custom_optind) d->last_nonopt != d->custom_optind)
exchange((char **) argv, d); exchange((char **) argv, d);
else if (d->last_nonopt != d->custom_optind) else if (d->last_nonopt != d->custom_optind)
d->first_nonopt = d->custom_optind; d->first_nonopt = d->custom_optind;
/* /*
* Skip any additional non-options and extend the range of * Skip any additional non-options and extend the range of
* non-options previously skipped. * non-options previously skipped.
*/ */
while (d->custom_optind < argc && NONOPTION_P) while (d->custom_optind < argc && NONOPTION_P)
d->custom_optind++; d->custom_optind++;
d->last_nonopt = d->custom_optind; d->last_nonopt = d->custom_optind;
/* /*
* The special ARGV-element `--' means premature end of options. Skip * The special ARGV-element `--' means premature end of options. Skip
* it like a null option, then exchange with previous non-options as if * it like a null option, then exchange with previous non-options as if
* it were an option, then skip everything else like a non-option. * it were an option, then skip everything else like a non-option.
*/ */
if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) { if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) {
d->custom_optind++; d->custom_optind++;
if (d->first_nonopt != d->last_nonopt if (d->first_nonopt != d->last_nonopt
&& d->last_nonopt != d->custom_optind) && d->last_nonopt != d->custom_optind)
exchange((char **) argv, d); exchange((char **) argv, d);
else if (d->first_nonopt == d->last_nonopt) else if (d->first_nonopt == d->last_nonopt)
d->first_nonopt = d->custom_optind; d->first_nonopt = d->custom_optind;
d->last_nonopt = argc; d->last_nonopt = argc;
d->custom_optind = argc; d->custom_optind = argc;
} }
/* /*
* If we have done all the ARGV-elements, stop the scan and back over * If we have done all the ARGV-elements, stop the scan and back over
* any non-options that we skipped and permuted. * any non-options that we skipped and permuted.
*/ */
if (d->custom_optind == argc) { if (d->custom_optind == argc) {
/* /*
* Set the next-arg-index to point at the non-options that we * Set the next-arg-index to point at the non-options that we
* previously skipped, so the caller will digest them. * previously skipped, so the caller will digest them.
*/ */
if (d->first_nonopt != d->last_nonopt) if (d->first_nonopt != d->last_nonopt)
d->custom_optind = d->first_nonopt; d->custom_optind = d->first_nonopt;
return -1; return -1;
} }
/* /*
* If we have come to a non-option and did not permute it, either stop * If we have come to a non-option and did not permute it, either stop
* the scan or describe it to the caller and pass it by. * the scan or describe it to the caller and pass it by.
*/ */
if (NONOPTION_P) { if (NONOPTION_P) {
d->custom_optarg = argv[d->custom_optind++]; d->custom_optarg = argv[d->custom_optind++];
return 1; return 1;
} }
/* /*
* We have found another option-ARGV-element. Skip the initial * We have found another option-ARGV-element. Skip the initial
* punctuation. * punctuation.
*/ */
d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-')); d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-'));
return 0; return 0;
} }
/* /*
@ -592,180 +592,180 @@ static int shuffle_argv(int argc, char *const *argv,const struct option *longopt
* *
*/ */
static int check_long_opt(int argc, char *const *argv, const char *optstring, static int check_long_opt(int argc, char *const *argv, const char *optstring,
const struct option *longopts, int *longind, const struct option *longopts, int *longind,
int print_errors, struct custom_getopt_data *d) int print_errors, struct custom_getopt_data *d)
{ {
char *nameend; char *nameend;
const struct option *p; const struct option *p;
const struct option *pfound = NULL; const struct option *pfound = NULL;
int exact = 0; int exact = 0;
int ambig = 0; int ambig = 0;
int indfound = -1; int indfound = -1;
int option_index; int option_index;
for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++) for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++)
/* Do nothing. */ ; /* Do nothing. */ ;
/* Test all long options for either exact match or abbreviated matches */ /* Test all long options for either exact match or abbreviated matches */
for (p = longopts, option_index = 0; p->name; p++, option_index++) for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) { if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
if ((unsigned int) (nameend - d->nextchar) if ((unsigned int) (nameend - d->nextchar)
== (unsigned int) strlen(p->name)) { == (unsigned int) strlen(p->name)) {
/* Exact match found. */ /* Exact match found. */
pfound = p; pfound = p;
indfound = option_index; indfound = option_index;
exact = 1; exact = 1;
break; break;
} else if (pfound == NULL) { } else if (pfound == NULL) {
/* First nonexact match found. */ /* First nonexact match found. */
pfound = p; pfound = p;
indfound = option_index; indfound = option_index;
} else if (pfound->has_arg != p->has_arg } else if (pfound->has_arg != p->has_arg
|| pfound->flag != p->flag || pfound->flag != p->flag
|| pfound->val != p->val) || pfound->val != p->val)
/* Second or later nonexact match found. */ /* Second or later nonexact match found. */
ambig = 1; ambig = 1;
} }
if (ambig && !exact) { if (ambig && !exact) {
if (print_errors) { if (print_errors) {
fprintf(stderr, fprintf(stderr,
"%s: option `%s' is ambiguous\n", "%s: option `%s' is ambiguous\n",
argv[0], argv[d->custom_optind]); argv[0], argv[d->custom_optind]);
} }
d->nextchar += strlen(d->nextchar); d->nextchar += strlen(d->nextchar);
d->custom_optind++; d->custom_optind++;
d->custom_optopt = 0; d->custom_optopt = 0;
return '?'; return '?';
} }
if (pfound) { if (pfound) {
option_index = indfound; option_index = indfound;
d->custom_optind++; d->custom_optind++;
if (*nameend) { if (*nameend) {
if (pfound->has_arg != no_argument) if (pfound->has_arg != no_argument)
d->custom_optarg = nameend + 1; d->custom_optarg = nameend + 1;
else { else {
if (print_errors) { if (print_errors) {
if (argv[d->custom_optind - 1][1] == '-') { if (argv[d->custom_optind - 1][1] == '-') {
/* --option */ /* --option */
fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n", fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n",
argv[0], pfound->name); argv[0], pfound->name);
} else { } else {
/* +option or -option */ /* +option or -option */
fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n", fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n",
argv[0], argv[d->custom_optind - 1][0], pfound->name); argv[0], argv[d->custom_optind - 1][0], pfound->name);
} }
} }
d->nextchar += strlen(d->nextchar); d->nextchar += strlen(d->nextchar);
d->custom_optopt = pfound->val; d->custom_optopt = pfound->val;
return '?'; return '?';
} }
} else if (pfound->has_arg == required_argument) { } else if (pfound->has_arg == required_argument) {
if (d->custom_optind < argc) if (d->custom_optind < argc)
d->custom_optarg = argv[d->custom_optind++]; d->custom_optarg = argv[d->custom_optind++];
else { else {
if (print_errors) { if (print_errors) {
fprintf(stderr, fprintf(stderr,
"%s: option `%s' requires an argument\n", "%s: option `%s' requires an argument\n",
argv[0], argv[0],
argv[d->custom_optind - 1]); argv[d->custom_optind - 1]);
} }
d->nextchar += strlen(d->nextchar); d->nextchar += strlen(d->nextchar);
d->custom_optopt = pfound->val; d->custom_optopt = pfound->val;
return optstring[0] == ':' ? ':' : '?'; return optstring[0] == ':' ? ':' : '?';
} }
} }
d->nextchar += strlen(d->nextchar); d->nextchar += strlen(d->nextchar);
if (longind != NULL) if (longind != NULL)
*longind = option_index; *longind = option_index;
if (pfound->flag) { if (pfound->flag) {
*(pfound->flag) = pfound->val; *(pfound->flag) = pfound->val;
return 0; return 0;
} }
return pfound->val; return pfound->val;
} }
/* /*
* Can't find it as a long option. If this is not getopt_long_only, or * Can't find it as a long option. If this is not getopt_long_only, or
* the option starts with '--' or is not a valid short option, then * the option starts with '--' or is not a valid short option, then
* it's an error. Otherwise interpret it as a short option. * it's an error. Otherwise interpret it as a short option.
*/ */
if (print_errors) { if (print_errors) {
if (argv[d->custom_optind][1] == '-') { if (argv[d->custom_optind][1] == '-') {
/* --option */ /* --option */
fprintf(stderr, fprintf(stderr,
"%s: unrecognized option `--%s'\n", "%s: unrecognized option `--%s'\n",
argv[0], d->nextchar); argv[0], d->nextchar);
} else { } else {
/* +option or -option */ /* +option or -option */
fprintf(stderr, fprintf(stderr,
"%s: unrecognized option `%c%s'\n", "%s: unrecognized option `%c%s'\n",
argv[0], argv[d->custom_optind][0], argv[0], argv[d->custom_optind][0],
d->nextchar); d->nextchar);
} }
} }
d->nextchar = (char *) ""; d->nextchar = (char *) "";
d->custom_optind++; d->custom_optind++;
d->custom_optopt = 0; d->custom_optopt = 0;
return '?'; return '?';
} }
static int check_short_opt(int argc, char *const *argv, const char *optstring, static int check_short_opt(int argc, char *const *argv, const char *optstring,
int print_errors, struct custom_getopt_data *d) int print_errors, struct custom_getopt_data *d)
{ {
char c = *d->nextchar++; char c = *d->nextchar++;
const char *temp = strchr(optstring, c); const char *temp = strchr(optstring, c);
/* Increment `custom_optind' when we start to process its last character. */ /* Increment `custom_optind' when we start to process its last character. */
if (*d->nextchar == '\0') if (*d->nextchar == '\0')
++d->custom_optind; ++d->custom_optind;
if (!temp || c == ':') { if (!temp || c == ':') {
if (print_errors) if (print_errors)
fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c); fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
d->custom_optopt = c; d->custom_optopt = c;
return '?'; return '?';
} }
if (temp[1] == ':') { if (temp[1] == ':') {
if (temp[2] == ':') { if (temp[2] == ':') {
/* This is an option that accepts an argument optionally. */ /* This is an option that accepts an argument optionally. */
if (*d->nextchar != '\0') { if (*d->nextchar != '\0') {
d->custom_optarg = d->nextchar; d->custom_optarg = d->nextchar;
d->custom_optind++; d->custom_optind++;
} else } else
d->custom_optarg = NULL; d->custom_optarg = NULL;
d->nextchar = NULL; d->nextchar = NULL;
} else { } else {
/* This is an option that requires an argument. */ /* This is an option that requires an argument. */
if (*d->nextchar != '\0') { if (*d->nextchar != '\0') {
d->custom_optarg = d->nextchar; d->custom_optarg = d->nextchar;
/* /*
* If we end this ARGV-element by taking the * If we end this ARGV-element by taking the
* rest as an arg, we must advance to the next * rest as an arg, we must advance to the next
* element now. * element now.
*/ */
d->custom_optind++; d->custom_optind++;
} else if (d->custom_optind == argc) { } else if (d->custom_optind == argc) {
if (print_errors) { if (print_errors) {
fprintf(stderr, fprintf(stderr,
"%s: option requires an argument -- %c\n", "%s: option requires an argument -- %c\n",
argv[0], c); argv[0], c);
} }
d->custom_optopt = c; d->custom_optopt = c;
if (optstring[0] == ':') if (optstring[0] == ':')
c = ':'; c = ':';
else else
c = '?'; c = '?';
} else } else
/* /*
* We already incremented `custom_optind' once; * We already incremented `custom_optind' once;
* increment it again when taking next ARGV-elt * increment it again when taking next ARGV-elt
* as argument. * as argument.
*/ */
d->custom_optarg = argv[d->custom_optind++]; d->custom_optarg = argv[d->custom_optind++];
d->nextchar = NULL; d->nextchar = NULL;
} }
} }
return c; return c;
} }
/* /*
@ -839,59 +839,59 @@ static int check_short_opt(int argc, char *const *argv, const char *optstring,
*/ */
static int getopt_internal_r(int argc, char *const *argv, const char *optstring, static int getopt_internal_r(int argc, char *const *argv, const char *optstring,
const struct option *longopts, int *longind, const struct option *longopts, int *longind,
struct custom_getopt_data *d) struct custom_getopt_data *d)
{ {
int ret, print_errors = d->custom_opterr; int ret, print_errors = d->custom_opterr;
if (optstring[0] == ':') if (optstring[0] == ':')
print_errors = 0; print_errors = 0;
if (argc < 1) if (argc < 1)
return -1; return -1;
d->custom_optarg = NULL; d->custom_optarg = NULL;
/* /*
* This is a big difference with GNU getopt, since optind == 0 * This is a big difference with GNU getopt, since optind == 0
* means initialization while here 1 means first call. * means initialization while here 1 means first call.
*/ */
if (d->custom_optind == 0 || !d->initialized) { if (d->custom_optind == 0 || !d->initialized) {
if (d->custom_optind == 0) if (d->custom_optind == 0)
d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */ d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */
custom_getopt_initialize(d); custom_getopt_initialize(d);
} }
if (d->nextchar == NULL || *d->nextchar == '\0') { if (d->nextchar == NULL || *d->nextchar == '\0') {
ret = shuffle_argv(argc, argv, longopts, d); ret = shuffle_argv(argc, argv, longopts, d);
if (ret) if (ret)
return ret; return ret;
} }
if (longopts && (argv[d->custom_optind][1] == '-' )) if (longopts && (argv[d->custom_optind][1] == '-' ))
return check_long_opt(argc, argv, optstring, longopts, return check_long_opt(argc, argv, optstring, longopts,
longind, print_errors, d); longind, print_errors, d);
return check_short_opt(argc, argv, optstring, print_errors, d); return check_short_opt(argc, argv, optstring, print_errors, d);
} }
static int custom_getopt_internal(int argc, char *const *argv, const char *optstring, static int custom_getopt_internal(int argc, char *const *argv, const char *optstring,
const struct option *longopts, int *longind) const struct option *longopts, int *longind)
{ {
int result; int result;
/* Keep a global copy of all internal members of d */ /* Keep a global copy of all internal members of d */
static struct custom_getopt_data d; static struct custom_getopt_data d;
d.custom_optind = custom_optind; d.custom_optind = custom_optind;
d.custom_opterr = custom_opterr; d.custom_opterr = custom_opterr;
result = getopt_internal_r(argc, argv, optstring, longopts, result = getopt_internal_r(argc, argv, optstring, longopts,
longind, &d); longind, &d);
custom_optind = d.custom_optind; custom_optind = d.custom_optind;
custom_optarg = d.custom_optarg; custom_optarg = d.custom_optarg;
custom_optopt = d.custom_optopt; custom_optopt = d.custom_optopt;
return result; return result;
} }
static int custom_getopt_long (int argc, char *const *argv, const char *options, static int custom_getopt_long (int argc, char *const *argv, const char *options,
const struct option *long_options, int *opt_index) const struct option *long_options, int *opt_index)
{ {
return custom_getopt_internal(argc, argv, options, long_options, return custom_getopt_internal(argc, argv, options, long_options,
opt_index); opt_index);
} }
@ -989,7 +989,7 @@ cmdline_parser_internal (
int argc, char * const *argv, struct gengetopt_args_info *args_info, int argc, char * const *argv, struct gengetopt_args_info *args_info,
struct cmdline_parser_params *params, const char *additional_error) struct cmdline_parser_params *params, const char *additional_error)
{ {
int c; /* Character of the parsed option. */ int c; /* Character of the parsed option. */
int error = 0; int error = 0;
struct gengetopt_args_info local_args_info; struct gengetopt_args_info local_args_info;
@ -1026,11 +1026,11 @@ cmdline_parser_internal (
int option_index = 0; int option_index = 0;
static struct option long_options[] = { static struct option long_options[] = {
{ "help", 0, NULL, 'h' }, { "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'V' }, { "version", 0, NULL, 'V' },
{ "raw", 0, NULL, 'r' }, { "raw", 0, NULL, 'r' },
{ "quiet", 0, NULL, 'q' }, { "quiet", 0, NULL, 'q' },
{ "loadcells", 0, NULL, 'C' }, { "loadcells", 0, NULL, 'C' },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
@ -1046,21 +1046,21 @@ cmdline_parser_internal (
opterr = custom_opterr; opterr = custom_opterr;
optopt = custom_optopt; optopt = custom_optopt;
if (c == -1) break; /* Exit from `while (1)' loop. */ if (c == -1) break; /* Exit from `while (1)' loop. */
switch (c) switch (c)
{ {
case 'h': /* Print help and exit. */ case 'h': /* Print help and exit. */
cmdline_parser_print_help (); cmdline_parser_print_help ();
cmdline_parser_free (&local_args_info); cmdline_parser_free (&local_args_info);
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
case 'V': /* Print version and exit. */ case 'V': /* Print version and exit. */
cmdline_parser_print_version (); cmdline_parser_print_version ();
cmdline_parser_free (&local_args_info); cmdline_parser_free (&local_args_info);
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
case 'r': /* Show an unformattet list of all records and subrecords. */ case 'r': /* Show an unformattet list of all records and subrecords. */
if (update_arg( 0 , if (update_arg( 0 ,
@ -1072,7 +1072,7 @@ cmdline_parser_internal (
goto failure; goto failure;
break; break;
case 'q': /* Supress all record information. Useful for speed tests.. */ case 'q': /* Supress all record information. Useful for speed tests.. */
if (update_arg( 0 , if (update_arg( 0 ,
@ -1084,7 +1084,7 @@ cmdline_parser_internal (
goto failure; goto failure;
break; break;
case 'C': /* Browse through contents of all cells.. */ case 'C': /* Browse through contents of all cells.. */
if (update_arg( 0 , if (update_arg( 0 ,
@ -1097,12 +1097,12 @@ cmdline_parser_internal (
break; break;
case 0: /* Long option with no short option */ case 0: /* Long option with no short option */
case '?': /* Invalid option. */ case '?': /* Invalid option. */
/* `getopt_long' already printed an error message. */ /* `getopt_long' already printed an error message. */
goto failure; goto failure;
default: /* bug: option not considered. */ default: /* bug: option not considered. */
fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
abort (); abort ();
} /* switch */ } /* switch */

View file

@ -43,11 +43,11 @@ struct gengetopt_args_info
const char *quiet_help; /**< @brief Supress all record information. Useful for speed tests. help description. */ const char *quiet_help; /**< @brief Supress all record information. Useful for speed tests. help description. */
const char *loadcells_help; /**< @brief Browse through contents of all cells. help description. */ const char *loadcells_help; /**< @brief Browse through contents of all cells. help description. */
unsigned int help_given ; /**< @brief Whether help was given. */ unsigned int help_given ; /**< @brief Whether help was given. */
unsigned int version_given ; /**< @brief Whether version was given. */ unsigned int version_given ; /**< @brief Whether version was given. */
unsigned int raw_given ; /**< @brief Whether raw was given. */ unsigned int raw_given ; /**< @brief Whether raw was given. */
unsigned int quiet_given ; /**< @brief Whether quiet was given. */ unsigned int quiet_given ; /**< @brief Whether quiet was given. */
unsigned int loadcells_given ; /**< @brief Whether loadcells was given. */ unsigned int loadcells_given ; /**< @brief Whether loadcells was given. */
char **inputs ; /**< @brief unamed options (options without names) */ char **inputs ; /**< @brief unamed options (options without names) */
unsigned inputs_num ; /**< @brief unamed options number */ unsigned inputs_num ; /**< @brief unamed options number */

View file

@ -67,73 +67,73 @@ void OMW::Engine::executeLocalScripts()
bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
{ {
if(! (mEnvironment.mSoundManager->isMusicPlaying())) if(! (mEnvironment.mSoundManager->isMusicPlaying()))
{ {
// Play some good 'ol tunes // Play some good 'ol tunes
mEnvironment.mSoundManager->startRandomTitle(); mEnvironment.mSoundManager->startRandomTitle();
} }
std::string effect; std::string effect;
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell(); MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell();
//If the region has changed //If the region has changed
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){ if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){
timer.restart(); timer.restart();
if (test.name != current->cell->region) if (test.name != current->cell->region)
{ {
total = 0; total = 0;
test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region)); test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region));
} }
if(test.soundList.size() > 0) if(test.soundList.size() > 0)
{ {
std::vector<ESM::Region::SoundRef>::iterator soundIter = test.soundList.begin(); std::vector<ESM::Region::SoundRef>::iterator soundIter = test.soundList.begin();
//mEnvironment.mSoundManager //mEnvironment.mSoundManager
if(total == 0){ if(total == 0){
while (!(soundIter == test.soundList.end())) while (!(soundIter == test.soundList.end()))
{ {
ESM::NAME32 go = soundIter->sound; ESM::NAME32 go = soundIter->sound;
int chance = (int) soundIter->chance; int chance = (int) soundIter->chance;
//std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; //std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
soundIter++; soundIter++;
total += chance; total += chance;
} }
} }
srand ( time(NULL) ); srand ( time(NULL) );
int r = rand() % total; //old random code int r = rand() % total; //old random code
int pos = 0; int pos = 0;
soundIter = test.soundList.begin(); soundIter = test.soundList.begin();
while (!(soundIter == test.soundList.end())) while (!(soundIter == test.soundList.end()))
{ {
const ESM::NAME32 go = soundIter->sound; const ESM::NAME32 go = soundIter->sound;
int chance = (int) soundIter->chance; int chance = (int) soundIter->chance;
//std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; //std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
soundIter++; soundIter++;
if( r - pos < chance) if( r - pos < chance)
{ {
effect = go.name; effect = go.name;
//play sound //play sound
std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
mEnvironment.mSoundManager->playSound(effect, 20.0, 1.0); mEnvironment.mSoundManager->playSound(effect, 20.0, 1.0);
break; break;
} }
pos += chance; pos += chance;
} }
} }
//mEnvironment.mSoundManager->playSound(effect, 1.0, 1.0); //mEnvironment.mSoundManager->playSound(effect, 1.0, 1.0);
//printf("REGION: %s\n", test.name); //printf("REGION: %s\n", test.name);
} }
else if(current->cell->data.flags & current->cell->Interior) else if(current->cell->data.flags & current->cell->Interior)
{ {
test.name = ""; test.name = "";
} }
try try
{ {
@ -184,7 +184,7 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
{ {
std::cerr << "Error in framelistener: " << e.what() << std::endl; std::cerr << "Error in framelistener: " << e.what() << std::endl;
} }
//std::cout << "TESTING2"; //std::cout << "TESTING2";
return true; return true;
} }
@ -294,8 +294,8 @@ void OMW::Engine::go()
assert (!mCellName.empty()); assert (!mCellName.empty());
assert (!mMaster.empty()); assert (!mMaster.empty());
test.name = ""; test.name = "";
total = 0; total = 0;

View file

@ -55,7 +55,7 @@ namespace OMW
class Engine : private Ogre::FrameListener class Engine : private Ogre::FrameListener
{ {
//int nFiles; //int nFiles;
boost::filesystem::path mDataDir; boost::filesystem::path mDataDir;
OEngine::Render::OgreRenderer mOgre; OEngine::Render::OgreRenderer mOgre;
std::string mCellName; std::string mCellName;
@ -72,8 +72,8 @@ namespace OMW
Compiler::Extensions mExtensions; Compiler::Extensions mExtensions;
Compiler::Context *mScriptContext; Compiler::Context *mScriptContext;
OEngine::GUI::MyGUIManager *mGuiManager; OEngine::GUI::MyGUIManager *mGuiManager;
ESM::Region test; ESM::Region test;
boost::timer timer; boost::timer timer;
int focusFrameCounter; int focusFrameCounter;
static const int focusUpdateFrame = 10; static const int focusUpdateFrame = 10;

View file

@ -56,10 +56,10 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
bpo::variables_map variables; bpo::variables_map variables;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
std::string configFilePath(macBundlePath() + "/Contents/MacOS/openmw.cfg"); std::string configFilePath(macBundlePath() + "/Contents/MacOS/openmw.cfg");
std::ifstream configFile (configFilePath.c_str()); std::ifstream configFile (configFilePath.c_str());
#else #else
std::ifstream configFile ("openmw.cfg"); std::ifstream configFile ("openmw.cfg");
#endif #endif
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run();

View file

@ -90,7 +90,7 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr)); return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr));
} }
MWWorld::ContainerStore<MWWorld::RefData>& Creature::getContainerStore (const MWWorld::Ptr& ptr) MWWorld::ContainerStore<MWWorld::RefData>& Creature::getContainerStore (const MWWorld::Ptr& ptr)
const const
@ -106,7 +106,7 @@ namespace MWClass
} }
return *ptr.getRefData().getContainerStore(); return *ptr.getRefData().getContainerStore();
} }
std::string Creature::getScript (const MWWorld::Ptr& ptr) const std::string Creature::getScript (const MWWorld::Ptr& ptr) const
{ {

View file

@ -29,26 +29,26 @@ namespace MWClass
void Npc::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, void Npc::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
MWWorld::Environment& environment) const MWWorld::Environment& environment) const
{ {
//Ogre::SceneNode *chest; //Ogre::SceneNode *chest;
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref = ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
ptr.get<ESM::NPC>(); ptr.get<ESM::NPC>();
//Store scenenodes by npc's name + bodypart [0] , npc's name + bodypart [1] //Store scenenodes by npc's name + bodypart [0] , npc's name + bodypart [1]
//Ex. Fargothchest , Fargothneck //Ex. Fargothchest , Fargothneck
assert (ref->base != NULL); assert (ref->base != NULL);
std::string hairID = ref->base->hair; std::string hairID = ref->base->hair;
std::string headID = ref->base->head; std::string headID = ref->base->head;
std::string npcName = ref->base->name; std::string npcName = ref->base->name;
//std::cout << "NPC: " << npcName << "\n"; //std::cout << "NPC: " << npcName << "\n";
//get the part of the bodypart id which describes the race and the gender //get the part of the bodypart id which describes the race and the gender
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
std::string headModel = "meshes\\" + std::string headModel = "meshes\\" +
environment.mWorld->getStore().bodyParts.find(headID)->model; environment.mWorld->getStore().bodyParts.find(headID)->model;
std::string hairModel = "meshes\\" + std::string hairModel = "meshes\\" +
environment.mWorld->getStore().bodyParts.find(hairID)->model; environment.mWorld->getStore().bodyParts.find(hairID)->model;
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref);
@ -59,200 +59,200 @@ namespace MWClass
const ESM::BodyPart *bodyPart = const ESM::BodyPart *bodyPart =
environment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); environment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest");
//bodyPart->model-> //bodyPart->model->
Ogre::Vector3 pos = Ogre::Vector3( 20, 20, 20); Ogre::Vector3 pos = Ogre::Vector3( 20, 20, 20);
Ogre::Vector3 axis = Ogre::Vector3( 0, 0, 1); Ogre::Vector3 axis = Ogre::Vector3( 0, 0, 1);
Ogre::Radian angle = Ogre::Radian(0); Ogre::Radian angle = Ogre::Radian(0);
std::string addresses[6] = {"", "", "", "","", ""}; std::string addresses[6] = {"", "", "", "","", ""};
std::string addresses2[6] = {"", "", "", "", "", ""}; std::string addresses2[6] = {"", "", "", "", "", ""};
std::string upperleft[5] = {"", "", "", "", ""}; std::string upperleft[5] = {"", "", "", "", ""};
std::string upperright[5] = {"", "", "", "", ""}; std::string upperright[5] = {"", "", "", "", ""};
std::string neckandup[5] = {"", "", "","",""}; std::string neckandup[5] = {"", "", "","",""};
std::string empty[6] = {"", "", "", "","", ""}; std::string empty[6] = {"", "", "", "","", ""};
int numbers = 0; int numbers = 0;
int uppernumbers = 0; int uppernumbers = 0;
int neckNumbers = 0; int neckNumbers = 0;
if (bodyPart){ if (bodyPart){
cellRender.insertMesh("meshes\\" + bodyPart->model, pos, axis, angle, npcName + "chest", addresses, numbers, true); //2 0 cellRender.insertMesh("meshes\\" + bodyPart->model, pos, axis, angle, npcName + "chest", addresses, numbers, true); //2 0
addresses2[numbers] = npcName + "chest"; addresses2[numbers] = npcName + "chest";
addresses[numbers++] = npcName + "chest"; addresses[numbers++] = npcName + "chest";
upperleft[uppernumbers] = npcName + "chest"; upperleft[uppernumbers] = npcName + "chest";
upperright[uppernumbers++] = npcName + "chest"; upperright[uppernumbers++] = npcName + "chest";
neckandup[neckNumbers++] = npcName + "chest"; neckandup[neckNumbers++] = npcName + "chest";
} }
//std::cout << "GETTING NPC PART"; //std::cout << "GETTING NPC PART";
//Orgre::SceneNode test = cellRender.getNpcPart(); //Orgre::SceneNode test = cellRender.getNpcPart();
const ESM::BodyPart *upperleg = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); const ESM::BodyPart *upperleg = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg");
const ESM::BodyPart *groin = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); const ESM::BodyPart *groin = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin");
const ESM::BodyPart *arm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); const ESM::BodyPart *arm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm");
const ESM::BodyPart *neck = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck"); const ESM::BodyPart *neck = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck");
const ESM::BodyPart *knee = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee"); const ESM::BodyPart *knee = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee");
const ESM::BodyPart *ankle = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); const ESM::BodyPart *ankle = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle");
const ESM::BodyPart *foot = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); const ESM::BodyPart *foot = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot");
const ESM::BodyPart *feet = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); const ESM::BodyPart *feet = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet");
const ESM::BodyPart *tail = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail"); const ESM::BodyPart *tail = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail");
const ESM::BodyPart *wrist = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); const ESM::BodyPart *wrist = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist");
const ESM::BodyPart *forearm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); const ESM::BodyPart *forearm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm");
const ESM::BodyPart *hand = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand.1st"); const ESM::BodyPart *hand = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand.1st");
const ESM::BodyPart *hands = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands.1st"); const ESM::BodyPart *hands = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands.1st");
//std::cout << "RACE" << bodyRaceID << "\n"; //std::cout << "RACE" << bodyRaceID << "\n";
Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75);
std::string upperarmpath[2] = {npcName + "chest", npcName + "upper arm"}; std::string upperarmpath[2] = {npcName + "chest", npcName + "upper arm"};
if (groin){ if (groin){
cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, Ogre::Radian(3.14), npcName + "groin", addresses, numbers); cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, Ogre::Radian(3.14), npcName + "groin", addresses, numbers);
addresses2[numbers] = npcName + "groin"; addresses2[numbers] = npcName + "groin";
addresses[numbers++] = npcName + "groin"; addresses[numbers++] = npcName + "groin";
} }
if (tail) { if (tail) {
cellRender.insertMesh("tail\\" + tail->model, Ogre::Vector3(0 , 0, -76), axis, Ogre::Radian(3.14), npcName + "tail", addresses, numbers, "tail"); cellRender.insertMesh("tail\\" + tail->model, Ogre::Vector3(0 , 0, -76), axis, Ogre::Radian(3.14), npcName + "tail", addresses, numbers, "tail");
//std::cout << "TAIL\n"; //std::cout << "TAIL\n";
} }
//addresses[1] = npcName + "groin"; //addresses[1] = npcName + "groin";
if(upperleg){ if(upperleg){
cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -16), axis, Ogre::Radian(3.14), npcName + "upper leg", addresses, numbers); //-18 cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -16), axis, Ogre::Radian(3.14), npcName + "upper leg", addresses, numbers); //-18
cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( -6, 0, -16), axis, Ogre::Radian(0), npcName + "upper leg2", addresses2, numbers); cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( -6, 0, -16), axis, Ogre::Radian(0), npcName + "upper leg2", addresses2, numbers);
addresses2[numbers] = npcName + "upper leg2"; addresses2[numbers] = npcName + "upper leg2";
addresses[numbers++] = npcName + "upper leg"; addresses[numbers++] = npcName + "upper leg";
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers);
} }
if(knee) if(knee)
{ {
cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee", addresses, numbers); cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee", addresses, numbers);
//cellRender.rotateMesh(Ogre::Vector3(0, 1, 0), Ogre::Radian (1), npcName + "upper arm"); //cellRender.rotateMesh(Ogre::Vector3(0, 1, 0), Ogre::Radian (1), npcName + "upper arm");
cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee2", addresses2, numbers); cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee2", addresses2, numbers);
addresses2[numbers] = npcName + "knee2"; addresses2[numbers] = npcName + "knee2";
addresses[numbers++] = npcName + "knee"; addresses[numbers++] = npcName + "knee";
} }
if(ankle){ if(ankle){
cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0, 0, -20), axis, Ogre::Radian(0), npcName + "ankle", addresses, numbers); //-1 cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0, 0, -20), axis, Ogre::Radian(0), npcName + "ankle", addresses, numbers); //-1
cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0,0, -20), axis, Ogre::Radian(0), npcName + "ankle2", addresses2, numbers); //-1 cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0,0, -20), axis, Ogre::Radian(0), npcName + "ankle2", addresses2, numbers); //-1
addresses2[numbers] = npcName + "ankle2"; addresses2[numbers] = npcName + "ankle2";
addresses[numbers++] = npcName + "ankle"; addresses[numbers++] = npcName + "ankle";
} }
if(foot){ if(foot){
if(bodyRaceID.compare("b_n_khajiit_m_") == 0) if(bodyRaceID.compare("b_n_khajiit_m_") == 0)
{ {
feet = foot; feet = foot;
} }
else else
{ {
cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -4, -15), axis, Ogre::Radian(0), npcName + "foot", addresses, numbers); cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -4, -15), axis, Ogre::Radian(0), npcName + "foot", addresses, numbers);
cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -4, -15), axis, Ogre::Radian(0), npcName + "foot2", addresses2, numbers); cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -4, -15), axis, Ogre::Radian(0), npcName + "foot2", addresses2, numbers);
addresses2[numbers] = npcName + "foot2"; addresses2[numbers] = npcName + "foot2";
addresses[numbers++] = npcName + "foot"; addresses[numbers++] = npcName + "foot";
} }
//cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); //cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers);
} }
if(feet){ if(feet){
cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, Ogre::Radian(3.14), npcName + "foot", addresses, numbers); //9, 0, -14 cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, Ogre::Radian(3.14), npcName + "foot", addresses, numbers); //9, 0, -14
cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, Ogre::Radian(3.14), npcName + "foot2", addresses2, numbers); cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, Ogre::Radian(3.14), npcName + "foot2", addresses2, numbers);
addresses2[numbers] = npcName + "foot2"; addresses2[numbers] = npcName + "foot2";
addresses[numbers++] = npcName + "foot"; addresses[numbers++] = npcName + "foot";
//cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); //cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers);
} }
if (arm){ if (arm){
//010 //010
cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(-12.5, 0, 104), Ogre::Vector3(0, 1, 0), Ogre::Radian(-3.14 / 2), npcName + "upper arm", upperleft, uppernumbers); //1, 0,.75 cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(-12.5, 0, 104), Ogre::Vector3(0, 1, 0), Ogre::Radian(-3.14 / 2), npcName + "upper arm", upperleft, uppernumbers); //1, 0,.75
//cellRender.rotateMesh(Ogre::Vector3(1, 0, 0), Ogre::Radian (.45), upperarmpath, 2); //-.5, 0, -.75 //cellRender.rotateMesh(Ogre::Vector3(1, 0, 0), Ogre::Radian (.45), upperarmpath, 2); //-.5, 0, -.75
cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(12.5, 0, 105), Ogre::Vector3(-.5, 0, -.75), Ogre::Radian(3.14), npcName + "upper arm2", upperright, uppernumbers); cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(12.5, 0, 105), Ogre::Vector3(-.5, 0, -.75), Ogre::Radian(3.14), npcName + "upper arm2", upperright, uppernumbers);
upperleft[uppernumbers] = npcName + "upper arm"; upperleft[uppernumbers] = npcName + "upper arm";
upperright[uppernumbers++] = npcName + "upper arm2"; upperright[uppernumbers++] = npcName + "upper arm2";
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); //1 -1 1 cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); //1 -1 1
cellRender.rotateMesh(Ogre::Vector3(0, .1, 0), Ogre::Radian(3.14/2), upperleft, uppernumbers); cellRender.rotateMesh(Ogre::Vector3(0, .1, 0), Ogre::Radian(3.14/2), upperleft, uppernumbers);
} }
if (forearm) if (forearm)
{ {
//addresses[1] = npcName + "upper arm"; //addresses[1] = npcName + "upper arm";
cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm", upperleft, uppernumbers); cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm", upperleft, uppernumbers);
cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm2", upperright, uppernumbers); cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm2", upperright, uppernumbers);
upperleft[uppernumbers] = npcName + "forearm"; upperleft[uppernumbers] = npcName + "forearm";
upperright[uppernumbers++] = npcName + "forearm2"; upperright[uppernumbers++] = npcName + "forearm2";
} }
//else //else
// std::cout << npcName << "has no forearm"; // std::cout << npcName << "has no forearm";
if (wrist) if (wrist)
{ {
if(upperleft[uppernumbers - 1].compare(npcName + "upper arm") == 0) if(upperleft[uppernumbers - 1].compare(npcName + "upper arm") == 0)
{ {
cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm", upperleft, uppernumbers); cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm", upperleft, uppernumbers);
cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm2", upperright, uppernumbers); cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm2", upperright, uppernumbers);
upperleft[uppernumbers] = npcName + "forearm"; upperleft[uppernumbers] = npcName + "forearm";
upperright[uppernumbers++] = npcName + "forearm2"; upperright[uppernumbers++] = npcName + "forearm2";
} }
cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "wrist", upperleft, uppernumbers); cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "wrist", upperleft, uppernumbers);
cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "wrist2", upperright, uppernumbers); cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "wrist2", upperright, uppernumbers);
upperleft[uppernumbers] = npcName + "wrist"; upperleft[uppernumbers] = npcName + "wrist";
upperright[uppernumbers++] = npcName + "wrist2"; upperright[uppernumbers++] = npcName + "wrist2";
} }
if(hand) if(hand)
{ {
//std::cout << "WE FOUND A HAND\n"; //std::cout << "WE FOUND A HAND\n";
//-50, 0, -120 //-50, 0, -120
//std::cout << "WE FOUND HANDS\n"; //std::cout << "WE FOUND HANDS\n";
std::string pass; std::string pass;
if(hand->model.compare("b\\B_N_Dark Elf_F_Hands.1st.NIF")==0 && bodyRaceID.compare("b_n_dark elf_m_") == 0) if(hand->model.compare("b\\B_N_Dark Elf_F_Hands.1st.NIF")==0 && bodyRaceID.compare("b_n_dark elf_m_") == 0)
pass = "b\\B_N_Dark Elf_M_Hands.1st.NIF"; pass = "b\\B_N_Dark Elf_M_Hands.1st.NIF";
else else
pass = hand->model; pass = hand->model;
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers,false); //0, 100, -100 0,0,120 cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers,false); //0, 100, -100 0,0,120
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120 cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120
upperleft[uppernumbers] = npcName + "hand"; upperleft[uppernumbers] = npcName + "hand";
upperright[uppernumbers++] = npcName + "hand2"; upperright[uppernumbers++] = npcName + "hand2";
//cellRender.rotateMesh(Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), upperleft, uppernumbers); //cellRender.rotateMesh(Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), upperleft, uppernumbers);
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers);
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers); cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers);
} }
if(hands) if(hands)
{ {
std::string pass; std::string pass;
if(hands->model.compare("b\\B_N_Redguard_F_Hands.1st.nif")==0 && bodyRaceID.compare("b_n_redguard_m_") == 0) if(hands->model.compare("b\\B_N_Redguard_F_Hands.1st.nif")==0 && bodyRaceID.compare("b_n_redguard_m_") == 0)
pass = "b\\B_N_Redguard_M_Hands.1st.nif"; pass = "b\\B_N_Redguard_M_Hands.1st.nif";
else if(hands->model.compare("b\\B_N_Imperial_M_Hands.1st.nif") == 0 && bodyRaceID.compare("b_n_nord_m_") == 0) else if(hands->model.compare("b\\B_N_Imperial_M_Hands.1st.nif") == 0 && bodyRaceID.compare("b_n_nord_m_") == 0)
pass = "b\\B_N_Nord_M_Hands.1st.nif"; pass = "b\\B_N_Nord_M_Hands.1st.nif";
else else
pass =hands->model; //-50, 0, -120 pass =hands->model; //-50, 0, -120
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1,-110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110 cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1,-110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110
//cellRender.insertMesh("meshes\\" + hands->model, Ogre::Vector3(42, 0,110), Ogre::Vector3(1, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110 //cellRender.insertMesh("meshes\\" + hands->model, Ogre::Vector3(42, 0,110), Ogre::Vector3(1, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120 cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120
upperleft[uppernumbers] = npcName + "hand"; upperleft[uppernumbers] = npcName + "hand";
upperright[uppernumbers++] = npcName + "hand2"; upperright[uppernumbers++] = npcName + "hand2";
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers);
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers); cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers);
} }
//neck will reset chest counter //neck will reset chest counter
if(neck) if(neck)
{ {
cellRender.insertMesh ("meshes\\" + neck->model, Ogre::Vector3( 0, 0, 120), axis, Ogre::Radian(3.14), npcName + "neck", neckandup, neckNumbers); cellRender.insertMesh ("meshes\\" + neck->model, Ogre::Vector3( 0, 0, 120), axis, Ogre::Radian(3.14), npcName + "neck", neckandup, neckNumbers);
neckandup[neckNumbers++] = npcName + "neck"; neckandup[neckNumbers++] = npcName + "neck";
} }
cellRender.insertMesh (headModel, Ogre::Vector3( 0, 0, 5), axis, Ogre::Radian(0), npcName + "head", neckandup, neckNumbers); cellRender.insertMesh (headModel, Ogre::Vector3( 0, 0, 5), axis, Ogre::Radian(0), npcName + "head", neckandup, neckNumbers);
neckandup[neckNumbers++] = npcName + "head"; neckandup[neckNumbers++] = npcName + "head";
cellRender.insertMesh (hairModel, Ogre::Vector3( 0, -1, 0), axis, Ogre::Radian(0), npcName + "hair", neckandup, neckNumbers); cellRender.insertMesh (hairModel, Ogre::Vector3( 0, -1, 0), axis, Ogre::Radian(0), npcName + "hair", neckandup, neckNumbers);
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
} }
void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{ {

View file

@ -89,53 +89,53 @@ void MWSkill::onClicked(MyGUI::Widget* _sender)
void MWSkill::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name) void MWSkill::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name)
{ {
Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name); Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
initialiseWidgetSkin(_info); initialiseWidgetSkin(_info);
} }
MWSkill::~MWSkill() MWSkill::~MWSkill()
{ {
shutdownWidgetSkin(); shutdownWidgetSkin();
} }
void MWSkill::baseChangeWidgetSkin(ResourceSkin* _info) void MWSkill::baseChangeWidgetSkin(ResourceSkin* _info)
{ {
shutdownWidgetSkin(); shutdownWidgetSkin();
Base::baseChangeWidgetSkin(_info); Base::baseChangeWidgetSkin(_info);
initialiseWidgetSkin(_info); initialiseWidgetSkin(_info);
} }
void MWSkill::initialiseWidgetSkin(ResourceSkin* _info) void MWSkill::initialiseWidgetSkin(ResourceSkin* _info)
{ {
for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter)
{ {
const std::string &name = *(*iter)->_getInternalData<std::string>(); const std::string &name = *(*iter)->_getInternalData<std::string>();
if (name == "StatName") if (name == "StatName")
{ {
MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned"); MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned");
skillNameWidget = (*iter)->castType<StaticText>(); skillNameWidget = (*iter)->castType<StaticText>();
} }
else if (name == "StatValue") else if (name == "StatValue")
{ {
MYGUI_DEBUG_ASSERT( ! skillValueWidget, "widget already assigned"); MYGUI_DEBUG_ASSERT( ! skillValueWidget, "widget already assigned");
skillValueWidget = (*iter)->castType<StaticText>(); skillValueWidget = (*iter)->castType<StaticText>();
} }
else if (name == "StatNameButton") else if (name == "StatNameButton")
{ {
MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned"); MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned");
MyGUI::ButtonPtr button = (*iter)->castType<Button>(); MyGUI::ButtonPtr button = (*iter)->castType<Button>();
skillNameWidget = button; skillNameWidget = button;
button->eventMouseButtonClick = MyGUI::newDelegate(this, &MWSkill::onClicked); button->eventMouseButtonClick = MyGUI::newDelegate(this, &MWSkill::onClicked);
} }
else if (name == "StatValueButton") else if (name == "StatValueButton")
{ {
MYGUI_DEBUG_ASSERT( ! skillValueWidget, "widget already assigned"); MYGUI_DEBUG_ASSERT( ! skillValueWidget, "widget already assigned");
MyGUI::ButtonPtr button = (*iter)->castType<Button>(); MyGUI::ButtonPtr button = (*iter)->castType<Button>();
skillNameWidget = button; skillNameWidget = button;
button->eventMouseButtonClick = MyGUI::newDelegate(this, &MWSkill::onClicked); button->eventMouseButtonClick = MyGUI::newDelegate(this, &MWSkill::onClicked);
} }
} }
} }
void MWSkill::shutdownWidgetSkin() void MWSkill::shutdownWidgetSkin()
@ -208,53 +208,53 @@ void MWAttribute::updateWidgets()
void MWAttribute::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name) void MWAttribute::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name)
{ {
Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name); Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
initialiseWidgetSkin(_info); initialiseWidgetSkin(_info);
} }
MWAttribute::~MWAttribute() MWAttribute::~MWAttribute()
{ {
shutdownWidgetSkin(); shutdownWidgetSkin();
} }
void MWAttribute::baseChangeWidgetSkin(ResourceSkin* _info) void MWAttribute::baseChangeWidgetSkin(ResourceSkin* _info)
{ {
shutdownWidgetSkin(); shutdownWidgetSkin();
Base::baseChangeWidgetSkin(_info); Base::baseChangeWidgetSkin(_info);
initialiseWidgetSkin(_info); initialiseWidgetSkin(_info);
} }
void MWAttribute::initialiseWidgetSkin(ResourceSkin* _info) void MWAttribute::initialiseWidgetSkin(ResourceSkin* _info)
{ {
for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter)
{ {
const std::string &name = *(*iter)->_getInternalData<std::string>(); const std::string &name = *(*iter)->_getInternalData<std::string>();
if (name == "StatName") if (name == "StatName")
{ {
MYGUI_DEBUG_ASSERT( ! attributeNameWidget, "widget already assigned"); MYGUI_DEBUG_ASSERT( ! attributeNameWidget, "widget already assigned");
attributeNameWidget = (*iter)->castType<StaticText>(); attributeNameWidget = (*iter)->castType<StaticText>();
} }
else if (name == "StatValue") else if (name == "StatValue")
{ {
MYGUI_DEBUG_ASSERT( ! attributeValueWidget, "widget already assigned"); MYGUI_DEBUG_ASSERT( ! attributeValueWidget, "widget already assigned");
attributeValueWidget = (*iter)->castType<StaticText>(); attributeValueWidget = (*iter)->castType<StaticText>();
} }
else if (name == "StatNameButton") else if (name == "StatNameButton")
{ {
MYGUI_DEBUG_ASSERT( ! attributeNameWidget, "widget already assigned"); MYGUI_DEBUG_ASSERT( ! attributeNameWidget, "widget already assigned");
MyGUI::ButtonPtr button = (*iter)->castType<Button>(); MyGUI::ButtonPtr button = (*iter)->castType<Button>();
attributeNameWidget = button; attributeNameWidget = button;
button->eventMouseButtonClick = MyGUI::newDelegate(this, &MWAttribute::onClicked); button->eventMouseButtonClick = MyGUI::newDelegate(this, &MWAttribute::onClicked);
} }
else if (name == "StatValue") else if (name == "StatValue")
{ {
MYGUI_DEBUG_ASSERT( ! attributeValueWidget, "widget already assigned"); MYGUI_DEBUG_ASSERT( ! attributeValueWidget, "widget already assigned");
MyGUI::ButtonPtr button = (*iter)->castType<Button>(); MyGUI::ButtonPtr button = (*iter)->castType<Button>();
attributeNameWidget = button; attributeNameWidget = button;
button->eventMouseButtonClick = MyGUI::newDelegate(this, &MWAttribute::onClicked); button->eventMouseButtonClick = MyGUI::newDelegate(this, &MWAttribute::onClicked);
} }
} }
} }
void MWAttribute::shutdownWidgetSkin() void MWAttribute::shutdownWidgetSkin()
@ -308,34 +308,34 @@ void MWSpell::updateWidgets()
void MWSpell::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name) void MWSpell::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name)
{ {
Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name); Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
initialiseWidgetSkin(_info); initialiseWidgetSkin(_info);
} }
MWSpell::~MWSpell() MWSpell::~MWSpell()
{ {
shutdownWidgetSkin(); shutdownWidgetSkin();
} }
void MWSpell::baseChangeWidgetSkin(ResourceSkin* _info) void MWSpell::baseChangeWidgetSkin(ResourceSkin* _info)
{ {
shutdownWidgetSkin(); shutdownWidgetSkin();
Base::baseChangeWidgetSkin(_info); Base::baseChangeWidgetSkin(_info);
initialiseWidgetSkin(_info); initialiseWidgetSkin(_info);
} }
void MWSpell::initialiseWidgetSkin(ResourceSkin* _info) void MWSpell::initialiseWidgetSkin(ResourceSkin* _info)
{ {
for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter)
{ {
const std::string &name = *(*iter)->_getInternalData<std::string>(); const std::string &name = *(*iter)->_getInternalData<std::string>();
if (name == "StatName") if (name == "StatName")
{ {
MYGUI_DEBUG_ASSERT( ! spellNameWidget, "widget already assigned"); MYGUI_DEBUG_ASSERT( ! spellNameWidget, "widget already assigned");
spellNameWidget = (*iter)->castType<StaticText>(); spellNameWidget = (*iter)->castType<StaticText>();
} }
} }
} }
void MWSpell::shutdownWidgetSkin() void MWSpell::shutdownWidgetSkin()
@ -423,39 +423,39 @@ void MWSpellEffect::updateWidgets()
void MWSpellEffect::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name) void MWSpellEffect::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name)
{ {
Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name); Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
initialiseWidgetSkin(_info); initialiseWidgetSkin(_info);
} }
MWSpellEffect::~MWSpellEffect() MWSpellEffect::~MWSpellEffect()
{ {
shutdownWidgetSkin(); shutdownWidgetSkin();
} }
void MWSpellEffect::baseChangeWidgetSkin(ResourceSkin* _info) void MWSpellEffect::baseChangeWidgetSkin(ResourceSkin* _info)
{ {
shutdownWidgetSkin(); shutdownWidgetSkin();
Base::baseChangeWidgetSkin(_info); Base::baseChangeWidgetSkin(_info);
initialiseWidgetSkin(_info); initialiseWidgetSkin(_info);
} }
void MWSpellEffect::initialiseWidgetSkin(ResourceSkin* _info) void MWSpellEffect::initialiseWidgetSkin(ResourceSkin* _info)
{ {
for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter)
{ {
const std::string &name = *(*iter)->_getInternalData<std::string>(); const std::string &name = *(*iter)->_getInternalData<std::string>();
if (name == "Text") if (name == "Text")
{ {
MYGUI_DEBUG_ASSERT( ! textWidget, "widget already assigned"); MYGUI_DEBUG_ASSERT( ! textWidget, "widget already assigned");
textWidget = (*iter)->castType<StaticText>(); textWidget = (*iter)->castType<StaticText>();
} }
else if (name == "Image") else if (name == "Image")
{ {
MYGUI_DEBUG_ASSERT( ! imageWidget, "widget already assigned"); MYGUI_DEBUG_ASSERT( ! imageWidget, "widget already assigned");
imageWidget = (*iter)->castType<StaticImage>(); imageWidget = (*iter)->castType<StaticImage>();
} }
} }
} }
void MWSpellEffect::shutdownWidgetSkin() void MWSpellEffect::shutdownWidgetSkin()

View file

@ -43,7 +43,7 @@ namespace MWGui
const SkillValue& getSkillValue() const { return value; } const SkillValue& getSkillValue() const { return value; }
// Events // Events
typedef delegates::CDelegate1<MWSkill*> EventHandle_SkillVoid; typedef delegates::CDelegate1<MWSkill*> EventHandle_SkillVoid;
/** Event : Skill clicked.\n /** Event : Skill clicked.\n
signature : void method(MWSkill* _sender)\n signature : void method(MWSkill* _sender)\n
@ -51,18 +51,18 @@ namespace MWGui
EventHandle_SkillVoid eventClicked; EventHandle_SkillVoid eventClicked;
/*internal:*/ /*internal:*/
virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name); virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
protected: protected:
virtual ~MWSkill(); virtual ~MWSkill();
void baseChangeWidgetSkin(ResourceSkin* _info); void baseChangeWidgetSkin(ResourceSkin* _info);
void onClicked(MyGUI::Widget* _sender); void onClicked(MyGUI::Widget* _sender);
private: private:
void initialiseWidgetSkin(ResourceSkin* _info); void initialiseWidgetSkin(ResourceSkin* _info);
void shutdownWidgetSkin(); void shutdownWidgetSkin();
void updateWidgets(); void updateWidgets();
@ -90,7 +90,7 @@ namespace MWGui
const AttributeValue& getAttributeValue() const { return value; } const AttributeValue& getAttributeValue() const { return value; }
// Events // Events
typedef delegates::CDelegate1<MWAttribute*> EventHandle_AttributeVoid; typedef delegates::CDelegate1<MWAttribute*> EventHandle_AttributeVoid;
/** Event : Attribute clicked.\n /** Event : Attribute clicked.\n
signature : void method(MWAttribute* _sender)\n signature : void method(MWAttribute* _sender)\n
@ -98,18 +98,18 @@ namespace MWGui
EventHandle_AttributeVoid eventClicked; EventHandle_AttributeVoid eventClicked;
/*internal:*/ /*internal:*/
virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name); virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
protected: protected:
virtual ~MWAttribute(); virtual ~MWAttribute();
void baseChangeWidgetSkin(ResourceSkin* _info); void baseChangeWidgetSkin(ResourceSkin* _info);
void onClicked(MyGUI::Widget* _sender); void onClicked(MyGUI::Widget* _sender);
private: private:
void initialiseWidgetSkin(ResourceSkin* _info); void initialiseWidgetSkin(ResourceSkin* _info);
void shutdownWidgetSkin(); void shutdownWidgetSkin();
void updateWidgets(); void updateWidgets();
@ -137,16 +137,16 @@ namespace MWGui
const std::string &getSpellId() const { return id; } const std::string &getSpellId() const { return id; }
/*internal:*/ /*internal:*/
virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name); virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
protected: protected:
virtual ~MWSpell(); virtual ~MWSpell();
void baseChangeWidgetSkin(ResourceSkin* _info); void baseChangeWidgetSkin(ResourceSkin* _info);
private: private:
void initialiseWidgetSkin(ResourceSkin* _info); void initialiseWidgetSkin(ResourceSkin* _info);
void shutdownWidgetSkin(); void shutdownWidgetSkin();
void updateWidgets(); void updateWidgets();
@ -171,16 +171,16 @@ namespace MWGui
const SpellEffectValue &getSpellEffect() const { return effect; } const SpellEffectValue &getSpellEffect() const { return effect; }
/*internal:*/ /*internal:*/
virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name); virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
protected: protected:
virtual ~MWSpellEffect(); virtual ~MWSpellEffect();
void baseChangeWidgetSkin(ResourceSkin* _info); void baseChangeWidgetSkin(ResourceSkin* _info);
private: private:
void initialiseWidgetSkin(ResourceSkin* _info); void initialiseWidgetSkin(ResourceSkin* _info);
void shutdownWidgetSkin(); void shutdownWidgetSkin();
void updateWidgets(); void updateWidgets();

View file

@ -11,7 +11,7 @@
namespace Ogre namespace Ogre
{ {
class SceneNode; class SceneNode;
class Vector3; class Vector3;
} }
namespace ESM namespace ESM
@ -37,13 +37,13 @@ namespace MWRender
/// start inserting a new reference. /// start inserting a new reference.
virtual void insertBegin (ESM::CellRef &ref) = 0; virtual void insertBegin (ESM::CellRef &ref) = 0;
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements) = 0; virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements) = 0;
/// insert a mesh related to the most recent insertBegin call. /// insert a mesh related to the most recent insertBegin call.
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst) = 0; virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst) = 0;
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements) = 0; virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements) = 0;
virtual void insertMesh(const std::string &mesh) = 0; virtual void insertMesh(const std::string &mesh) = 0;
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements) = 0; virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements) = 0;
/// insert a light related to the most recent insertBegin call. /// insert a light related to the most recent insertBegin call.

View file

@ -63,26 +63,26 @@ void ExteriorCellRender::insertBegin (ESM::CellRef &ref)
void ExteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements) void ExteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements)
{ {
assert(insert); assert(insert);
Ogre::SceneNode *parent = insert; Ogre::SceneNode *parent = insert;
//std::cout << "ELEMENTS:" << elements; //std::cout << "ELEMENTS:" << elements;
for (int i = 0; i < elements; i++){ for (int i = 0; i < elements; i++){
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i])) if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i])); parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i]));
} }
parent->rotate(axis, angle); parent->rotate(axis, angle);
} }
/* /*
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements){ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements){
assert (insert); assert (insert);
//insert-> //insert->
Ogre::SceneNode *parent = insert; Ogre::SceneNode *parent = insert;
for (int i = 0; i < elements; i++){ for (int i = 0; i < elements; i++){
if(sceneParent[i] != "" && parent->getChild(sceneParent[i])) if(sceneParent[i] != "" && parent->getChild(sceneParent[i]))
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i])); parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i]));
} }
npcPart = parent->createChildSceneNode(sceneNodeName); npcPart = parent->createChildSceneNode(sceneNodeName);
NIFLoader::load(mesh); NIFLoader::load(mesh);
MovableObject *ent = scene.getMgr()->createEntity(mesh); MovableObject *ent = scene.getMgr()->createEntity(mesh);
@ -97,19 +97,19 @@ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
*/ */
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements) void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements)
{ {
insertMesh(mesh, vec, axis, angle, sceneNodeName, sceneParent, elements, true); insertMesh(mesh, vec, axis, angle, sceneNodeName, sceneParent, elements, true);
} }
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst){ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst){
assert (insert); assert (insert);
//insert-> //insert->
Ogre::SceneNode *parent = insert; Ogre::SceneNode *parent = insert;
for (int i = 0; i < elements; i++){ for (int i = 0; i < elements; i++){
if(sceneParent[i] != "" && parent->getChild(sceneParent[i])) if(sceneParent[i] != "" && parent->getChild(sceneParent[i]))
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i])); parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i]));
} }
npcPart = parent->createChildSceneNode(sceneNodeName); npcPart = parent->createChildSceneNode(sceneNodeName);
MeshPtr good2 = NIFLoader::load(mesh); MeshPtr good2 = NIFLoader::load(mesh);
MovableObject *ent = scene.getMgr()->createEntity(mesh); MovableObject *ent = scene.getMgr()->createEntity(mesh);
@ -128,68 +128,68 @@ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
Ogre::MeshManager *m = MeshManager::getSingletonPtr(); Ogre::MeshManager *m = MeshManager::getSingletonPtr();
const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif"; const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif";
const std::string beast2 ="meshes\\b\\B_N_Khajiit_M_Skins.nif"; const std::string beast2 ="meshes\\b\\B_N_Khajiit_M_Skins.nif";
const std::string beast3 ="meshes\\b\\B_N_Argonian_F_Skins.nif"; const std::string beast3 ="meshes\\b\\B_N_Argonian_F_Skins.nif";
const std::string beast4 ="meshes\\b\\B_N_Argonian_M_Skins.nif"; const std::string beast4 ="meshes\\b\\B_N_Argonian_M_Skins.nif";
const std::string beasttail1 ="tail\\b\\B_N_Khajiit_F_Skins.nif"; const std::string beasttail1 ="tail\\b\\B_N_Khajiit_F_Skins.nif";
const std::string beasttail2 ="tail\\b\\B_N_Khajiit_M_Skins.nif"; const std::string beasttail2 ="tail\\b\\B_N_Khajiit_M_Skins.nif";
const std::string beasttail3 ="tail\\b\\B_N_Argonian_F_Skins.nif"; const std::string beasttail3 ="tail\\b\\B_N_Argonian_F_Skins.nif";
const std::string beasttail4 ="tail\\b\\B_N_Argonian_M_Skins.nif"; const std::string beasttail4 ="tail\\b\\B_N_Argonian_M_Skins.nif";
const std::string beastfoot1 ="foot\\b\\B_N_Khajiit_F_Skins.nif"; const std::string beastfoot1 ="foot\\b\\B_N_Khajiit_F_Skins.nif";
const std::string beastfoot2 ="foot\\b\\B_N_Khajiit_M_Skins.nif"; const std::string beastfoot2 ="foot\\b\\B_N_Khajiit_M_Skins.nif";
const std::string beastfoot3 ="foot\\b\\B_N_Argonian_F_Skins.nif"; const std::string beastfoot3 ="foot\\b\\B_N_Argonian_F_Skins.nif";
const std::string beastfoot4 ="foot\\b\\B_N_Argonian_M_Skins.nif"; const std::string beastfoot4 ="foot\\b\\B_N_Argonian_M_Skins.nif";
if(mesh.compare(beast1) == 0 && m->getByName(beasttail1).isNull()) if(mesh.compare(beast1) == 0 && m->getByName(beasttail1).isNull())
{ {
//std::cout << "CLONINGKHAJIITF\n"; //std::cout << "CLONINGKHAJIITF\n";
good2->reload(); good2->reload();
MeshPtr tail = good2->clone(beasttail1); MeshPtr tail = good2->clone(beasttail1);
good2->reload(); good2->reload();
MeshPtr foot = good2->clone(beastfoot1); MeshPtr foot = good2->clone(beastfoot1);
good2->reload(); good2->reload();
} }
else if(mesh.compare(beast2) == 0 && m->getByName(beasttail2).isNull()) else if(mesh.compare(beast2) == 0 && m->getByName(beasttail2).isNull())
{ {
//std::cout << "CLONINGKHAJIITM\n"; //std::cout << "CLONINGKHAJIITM\n";
good2->reload(); good2->reload();
MeshPtr tail = good2->clone(beasttail2); MeshPtr tail = good2->clone(beasttail2);
good2->reload(); good2->reload();
MeshPtr foot = good2->clone(beastfoot2); MeshPtr foot = good2->clone(beastfoot2);
good2->reload(); good2->reload();
} }
else if(mesh.compare(beast3) == 0 && m->getByName(beasttail3).isNull()) else if(mesh.compare(beast3) == 0 && m->getByName(beasttail3).isNull())
{ {
//std::cout << "CLONINGARGONIANF\n"; //std::cout << "CLONINGARGONIANF\n";
good2->reload(); good2->reload();
MeshPtr tail = good2->clone(beasttail3); MeshPtr tail = good2->clone(beasttail3);
good2->reload(); good2->reload();
MeshPtr foot = good2->clone(beastfoot3); MeshPtr foot = good2->clone(beastfoot3);
good2->reload(); good2->reload();
} }
else if(mesh.compare(beast4) == 0 && m->getByName(beasttail4).isNull()) else if(mesh.compare(beast4) == 0 && m->getByName(beasttail4).isNull())
{ {
//std::cout << "CLONINGARGONIANM\n"; //std::cout << "CLONINGARGONIANM\n";
good2->reload(); good2->reload();
MeshPtr tail = good2->clone(beasttail4); MeshPtr tail = good2->clone(beasttail4);
good2->reload(); good2->reload();
MeshPtr foot = good2->clone(beastfoot4); MeshPtr foot = good2->clone(beastfoot4);
good2->reload(); good2->reload();
} }
} }
// insert a mesh related to the most recent insertBegin call. // insert a mesh related to the most recent insertBegin call.
void ExteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements) void ExteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements)
{ {
assert(insert); assert(insert);
Ogre::SceneNode *parent = insert; Ogre::SceneNode *parent = insert;
//std::cout << "ELEMENTS:" << elements; //std::cout << "ELEMENTS:" << elements;
for (int i = 0; i < elements; i++){ for (int i = 0; i < elements; i++){
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i])) if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i])); parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i]));
} }
parent->scale(axis); parent->scale(axis);
} }
// insert a mesh related to the most recent insertBegin call. // insert a mesh related to the most recent insertBegin call.

View file

@ -54,7 +54,7 @@ namespace MWRender
Ogre::SceneNode *base; Ogre::SceneNode *base;
Ogre::SceneNode *insert; Ogre::SceneNode *insert;
Ogre::SceneNode *npcPart; Ogre::SceneNode *npcPart;
// 0 normal, 1 more bright, 2 max // 0 normal, 1 more bright, 2 max
int ambientMode; int ambientMode;
@ -65,12 +65,12 @@ namespace MWRender
virtual void insertBegin (ESM::CellRef &ref); virtual void insertBegin (ESM::CellRef &ref);
/// insert a mesh related to the most recent insertBegin call. /// insert a mesh related to the most recent insertBegin call.
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements); virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements);
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst); virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst);
virtual void insertMesh(const std::string &mesh); virtual void insertMesh(const std::string &mesh);
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements); virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements);
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements); virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
/// insert a light related to the most recent insertBegin call. /// insert a light related to the most recent insertBegin call.
virtual void insertLight(float r, float g, float b, float radius); virtual void insertLight(float r, float g, float b, float radius);

View file

@ -65,52 +65,52 @@ void InteriorCellRender::insertBegin (ESM::CellRef &ref)
// insert a mesh related to the most recent insertBegin call. // insert a mesh related to the most recent insertBegin call.
void InteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements) void InteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements)
{ {
assert(insert); assert(insert);
Ogre::SceneNode *parent = insert; Ogre::SceneNode *parent = insert;
//std::cout << "ELEMENTS:" << elements; //std::cout << "ELEMENTS:" << elements;
for (int i = 0; i < elements; i++){ for (int i = 0; i < elements; i++){
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i])) if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i])); parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i]));
} }
parent->rotate(axis, angle); parent->rotate(axis, angle);
} }
// insert a mesh related to the most recent insertBegin call. // insert a mesh related to the most recent insertBegin call.
void InteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements) void InteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements)
{ {
assert(insert); assert(insert);
Ogre::SceneNode *parent = insert; Ogre::SceneNode *parent = insert;
//std::cout << "ELEMENTS:" << elements; //std::cout << "ELEMENTS:" << elements;
for (int i = 0; i < elements; i++){ for (int i = 0; i < elements; i++){
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i])) if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i])); parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i]));
} }
parent->scale(axis); parent->scale(axis);
} }
void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements) void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements)
{ {
insertMesh(mesh, vec, axis, angle, sceneNodeName, sceneParent, elements, true); insertMesh(mesh, vec, axis, angle, sceneNodeName, sceneParent, elements, true);
} }
void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst){ void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst){
assert (insert); assert (insert);
//insert-> //insert->
Ogre::SceneNode *parent = insert; Ogre::SceneNode *parent = insert;
for (int i = 0; i < elements; i++){ for (int i = 0; i < elements; i++){
if(sceneParent[i] != "" && parent->getChild(sceneParent[i])) if(sceneParent[i] != "" && parent->getChild(sceneParent[i]))
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i])); parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i]));
} }
npcPart = parent->createChildSceneNode(sceneNodeName); npcPart = parent->createChildSceneNode(sceneNodeName);
//npcPart->showBoundingBox(true); //npcPart->showBoundingBox(true);
MeshPtr good2 = NIFLoader::load(mesh); MeshPtr good2 = NIFLoader::load(mesh);
MovableObject *ent = scene.getMgr()->createEntity(mesh); MovableObject *ent = scene.getMgr()->createEntity(mesh);
//ent->extr //ent->extr
// MovableObject *ent2 = scene.getMgr()->createEntity(bounds // MovableObject *ent2 = scene.getMgr()->createEntity(bounds
// ); // );
//ent-> //ent->
//std::cout << mesh << bounds << "\n"; //std::cout << mesh << bounds << "\n";
@ -127,55 +127,55 @@ void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
npcPart->attachObject(ent); npcPart->attachObject(ent);
Ogre::MeshManager *m = MeshManager::getSingletonPtr(); Ogre::MeshManager *m = MeshManager::getSingletonPtr();
const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif"; const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif";
const std::string beast2 ="meshes\\b\\B_N_Khajiit_M_Skins.nif"; const std::string beast2 ="meshes\\b\\B_N_Khajiit_M_Skins.nif";
const std::string beast3 ="meshes\\b\\B_N_Argonian_F_Skins.nif"; const std::string beast3 ="meshes\\b\\B_N_Argonian_F_Skins.nif";
const std::string beast4 ="meshes\\b\\B_N_Argonian_M_Skins.nif"; const std::string beast4 ="meshes\\b\\B_N_Argonian_M_Skins.nif";
const std::string beasttail1 ="tail\\b\\B_N_Khajiit_F_Skins.nif"; const std::string beasttail1 ="tail\\b\\B_N_Khajiit_F_Skins.nif";
const std::string beasttail2 ="tail\\b\\B_N_Khajiit_M_Skins.nif"; const std::string beasttail2 ="tail\\b\\B_N_Khajiit_M_Skins.nif";
const std::string beasttail3 ="tail\\b\\B_N_Argonian_F_Skins.nif"; const std::string beasttail3 ="tail\\b\\B_N_Argonian_F_Skins.nif";
const std::string beasttail4 ="tail\\b\\B_N_Argonian_M_Skins.nif"; const std::string beasttail4 ="tail\\b\\B_N_Argonian_M_Skins.nif";
const std::string beastfoot1 ="foot\\b\\B_N_Khajiit_F_Skins.nif"; const std::string beastfoot1 ="foot\\b\\B_N_Khajiit_F_Skins.nif";
const std::string beastfoot2 ="foot\\b\\B_N_Khajiit_M_Skins.nif"; const std::string beastfoot2 ="foot\\b\\B_N_Khajiit_M_Skins.nif";
const std::string beastfoot3 ="foot\\b\\B_N_Argonian_F_Skins.nif"; const std::string beastfoot3 ="foot\\b\\B_N_Argonian_F_Skins.nif";
const std::string beastfoot4 ="foot\\b\\B_N_Argonian_M_Skins.nif"; const std::string beastfoot4 ="foot\\b\\B_N_Argonian_M_Skins.nif";
if(mesh.compare(beast1) == 0 && m->getByName(beasttail1).isNull()) if(mesh.compare(beast1) == 0 && m->getByName(beasttail1).isNull())
{ {
//std::cout << "CLONINGKHAJIITF\n"; //std::cout << "CLONINGKHAJIITF\n";
good2->reload(); good2->reload();
MeshPtr tail = good2->clone(beasttail1); MeshPtr tail = good2->clone(beasttail1);
good2->reload(); good2->reload();
MeshPtr foot = good2->clone(beastfoot1); MeshPtr foot = good2->clone(beastfoot1);
good2->reload(); good2->reload();
} }
else if(mesh.compare(beast2) == 0 && m->getByName(beasttail2).isNull()) else if(mesh.compare(beast2) == 0 && m->getByName(beasttail2).isNull())
{ {
//std::cout << "CLONINGKHAJIITM\n"; //std::cout << "CLONINGKHAJIITM\n";
good2->reload(); good2->reload();
MeshPtr tail = good2->clone(beasttail2); MeshPtr tail = good2->clone(beasttail2);
good2->reload(); good2->reload();
MeshPtr foot = good2->clone(beastfoot2); MeshPtr foot = good2->clone(beastfoot2);
good2->reload(); good2->reload();
} }
else if(mesh.compare(beast3) == 0 && m->getByName(beasttail3).isNull()) else if(mesh.compare(beast3) == 0 && m->getByName(beasttail3).isNull())
{ {
//std::cout << "CLONINGARGONIANF\n"; //std::cout << "CLONINGARGONIANF\n";
good2->reload(); good2->reload();
MeshPtr tail = good2->clone(beasttail3); MeshPtr tail = good2->clone(beasttail3);
good2->reload(); good2->reload();
MeshPtr foot = good2->clone(beastfoot3); MeshPtr foot = good2->clone(beastfoot3);
good2->reload(); good2->reload();
} }
else if(mesh.compare(beast4) == 0 && m->getByName(beasttail4).isNull()) else if(mesh.compare(beast4) == 0 && m->getByName(beasttail4).isNull())
{ {
//std::cout << "CLONINGARGONIANM\n"; //std::cout << "CLONINGARGONIANM\n";
good2->reload(); good2->reload();
MeshPtr tail = good2->clone(beasttail4); MeshPtr tail = good2->clone(beasttail4);
good2->reload(); good2->reload();
MeshPtr foot = good2->clone(beastfoot4); MeshPtr foot = good2->clone(beastfoot4);
good2->reload(); good2->reload();
} }
} }
void InteriorCellRender::insertMesh(const std::string &mesh) void InteriorCellRender::insertMesh(const std::string &mesh)

View file

@ -29,7 +29,7 @@ namespace MWRender
class InteriorCellRender : public CellRender, private CellRenderImp class InteriorCellRender : public CellRender, private CellRenderImp
{ {
//static bool isChest; //static bool isChest;
static bool lightConst; static bool lightConst;
static float lightConstValue; static float lightConstValue;
@ -54,7 +54,7 @@ namespace MWRender
Ogre::SceneNode *base; Ogre::SceneNode *base;
Ogre::SceneNode *insert; Ogre::SceneNode *insert;
Ogre::SceneNode *npcPart; Ogre::SceneNode *npcPart;
// 0 normal, 1 more bright, 2 max // 0 normal, 1 more bright, 2 max
int ambientMode; int ambientMode;
@ -63,12 +63,12 @@ namespace MWRender
/// start inserting a new reference. /// start inserting a new reference.
virtual void insertBegin (ESM::CellRef &ref); virtual void insertBegin (ESM::CellRef &ref);
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements); virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements);
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements); virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
/// insert a mesh related to the most recent insertBegin call. /// insert a mesh related to the most recent insertBegin call.
virtual void insertMesh(const std::string &mesh); virtual void insertMesh(const std::string &mesh);
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements); virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements);
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst); virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst);
/// insert a light related to the most recent insertBegin call. /// insert a light related to the most recent insertBegin call.
virtual void insertLight(float r, float g, float b, float radius); virtual void insertLight(float r, float g, float b, float radius);
@ -93,7 +93,7 @@ namespace MWRender
virtual ~InteriorCellRender() { destroy(); } virtual ~InteriorCellRender() { destroy(); }
/// Make the cell visible. Load the cell if necessary. /// Make the cell visible. Load the cell if necessary.
//virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements); //virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
virtual void show(); virtual void show();
/// Remove the cell from rendering, but don't remove it from /// Remove the cell from rendering, but don't remove it from

View file

@ -62,7 +62,7 @@ namespace MWSound
sounds based on the sound factory it is given. sounds based on the sound factory it is given.
*/ */
OEManagerPtr mgr; OEManagerPtr mgr;
SoundPtr music; SoundPtr music;
/* This class calls update() on the sound manager each frame /* This class calls update() on the sound manager each frame
using and Ogre::FrameListener using and Ogre::FrameListener
@ -310,7 +310,7 @@ namespace MWSound
bool useSound) bool useSound)
: mData(NULL) : mData(NULL)
{ {
MP3Lookup(dataDir / "Music/Explore/"); MP3Lookup(dataDir / "Music/Explore/");
if(useSound) if(useSound)
mData = new SoundImpl(root, camera, store, (dataDir / "Sound").file_string()); mData = new SoundImpl(root, camera, store, (dataDir / "Sound").file_string());
} }
@ -323,56 +323,56 @@ namespace MWSound
void SoundManager::MP3Lookup(boost::filesystem::path dir) void SoundManager::MP3Lookup(boost::filesystem::path dir)
{ {
boost::filesystem::directory_iterator dir_iter(dir), dir_end; boost::filesystem::directory_iterator dir_iter(dir), dir_end;
std::string mp3extension = ".mp3"; std::string mp3extension = ".mp3";
for(;dir_iter != dir_end; dir_iter++) for(;dir_iter != dir_end; dir_iter++)
{ {
if(boost::filesystem::extension(*dir_iter) == mp3extension) if(boost::filesystem::extension(*dir_iter) == mp3extension)
{ {
files.push_back(*dir_iter); files.push_back(*dir_iter);
} }
} }
} }
void SoundManager::startRandomTitle() void SoundManager::startRandomTitle()
{ {
std::vector<boost::filesystem::path>::iterator fileIter; std::vector<boost::filesystem::path>::iterator fileIter;
if(files.size() > 0) if(files.size() > 0)
{ {
fileIter = files.begin(); fileIter = files.begin();
srand ( time(NULL) ); srand ( time(NULL) );
int r = rand() % files.size() + 1; //old random code int r = rand() % files.size() + 1; //old random code
for(int i = 1; i < r; i++) for(int i = 1; i < r; i++)
{ {
fileIter++; fileIter++;
} }
std::string music = fileIter->file_string(); std::string music = fileIter->file_string();
try try
{ {
std::cout << "Playing " << music << "\n"; std::cout << "Playing " << music << "\n";
streamMusic(music); streamMusic(music);
} }
catch(std::exception &e) catch(std::exception &e)
{ {
std::cout << " Music Error: " << e.what() << "\n"; std::cout << " Music Error: " << e.what() << "\n";
} }
} }
} }
bool SoundManager::isMusicPlaying() bool SoundManager::isMusicPlaying()
{ {
bool test = mData->music->isPlaying(); bool test = mData->music->isPlaying();
return test; return test;
} }
SoundManager::SoundImpl SoundManager::getMData() SoundManager::SoundImpl SoundManager::getMData()
{ {
// bool test = mData->music->isPlaying(); // bool test = mData->music->isPlaying();
return *mData; return *mData;
} }
@ -400,8 +400,8 @@ namespace MWSound
// Play the sound and tell it to stream, if possible. TODO: // Play the sound and tell it to stream, if possible. TODO:
// Store the reference, the jukebox will need to check status, // Store the reference, the jukebox will need to check status,
// control volume etc. // control volume etc.
if (mData->music) if (mData->music)
mData->music->stop(); mData->music->stop();
mData->music = mData->mgr->load(filename); mData->music = mData->mgr->load(filename);
mData->music->setStreaming(true); mData->music->setStreaming(true);
mData->music->setVolume(0.4); mData->music->setVolume(0.4);

View file

@ -21,7 +21,7 @@ namespace ESMS
namespace MWSound namespace MWSound
{ {
//SoundPtr *music; //SoundPtr *music;
class SoundManager class SoundManager
{ {
// Hide implementation details - engine.cpp is compiling // Hide implementation details - engine.cpp is compiling
@ -29,7 +29,7 @@ namespace MWSound
struct SoundImpl; struct SoundImpl;
SoundImpl *mData; SoundImpl *mData;
std::vector<boost::filesystem::path> files; std::vector<boost::filesystem::path> files;
public: public:
@ -37,12 +37,12 @@ namespace MWSound
boost::filesystem::path dataDir, bool useSound); boost::filesystem::path dataDir, bool useSound);
~SoundManager(); ~SoundManager();
void startRandomTitle(); void startRandomTitle();
void MP3Lookup(boost::filesystem::path dir); void MP3Lookup(boost::filesystem::path dir);
//struct SoundImpl; //struct SoundImpl;
bool isMusicPlaying(); bool isMusicPlaying();
SoundImpl getMData(); SoundImpl getMData();
void say (MWWorld::Ptr reference, const std::string& filename); void say (MWWorld::Ptr reference, const std::string& filename);
///< Make an actor say some text. ///< Make an actor say some text.

View file

@ -610,7 +610,7 @@ namespace MWWorld
adjustSky(); adjustSky();
mCellChanged = true; mCellChanged = true;
//currentRegion->name = ""; //currentRegion->name = "";
} }
void World::changeCell (int X, int Y, const ESM::Position& position) void World::changeCell (int X, int Y, const ESM::Position& position)

View file

@ -50,7 +50,7 @@ namespace MWWorld
MWRender::SkyManager* mSkyManager; MWRender::SkyManager* mSkyManager;
MWRender::MWScene mScene; MWRender::MWScene mScene;
MWRender::PlayerPos *mPlayerPos; MWRender::PlayerPos *mPlayerPos;
Ptr::CellStore *mCurrentCell; // the cell, the player is in Ptr::CellStore *mCurrentCell; // the cell, the player is in
CellRenderCollection mActiveCells; CellRenderCollection mActiveCells;
CellRenderCollection mBufferedCells; // loaded, but not active (buffering not implementd yet) CellRenderCollection mBufferedCells; // loaded, but not active (buffering not implementd yet)
ESM::ESMReader mEsm; ESM::ESMReader mEsm;
@ -96,7 +96,7 @@ namespace MWWorld
MWRender::PlayerPos& getPlayerPos(); MWRender::PlayerPos& getPlayerPos();
ESMS::ESMStore& getStore(); ESMS::ESMStore& getStore();
const ScriptList& getLocalScripts() const; const ScriptList& getLocalScripts() const;
///< Names and local variable state of all local scripts in active cells. ///< Names and local variable state of all local scripts in active cells.

View file

@ -363,45 +363,45 @@ struct option
/* Names for the values of the `has_arg' field of `struct option'. */ /* Names for the values of the `has_arg' field of `struct option'. */
#ifndef no_argument #ifndef no_argument
#define no_argument 0 #define no_argument 0
#endif #endif
#ifndef required_argument #ifndef required_argument
#define required_argument 1 #define required_argument 1
#endif #endif
#ifndef optional_argument #ifndef optional_argument
#define optional_argument 2 #define optional_argument 2
#endif #endif
struct custom_getopt_data { struct custom_getopt_data {
/* /*
* These have exactly the same meaning as the corresponding global variables, * These have exactly the same meaning as the corresponding global variables,
* except that they are used for the reentrant versions of getopt. * except that they are used for the reentrant versions of getopt.
*/ */
int custom_optind; int custom_optind;
int custom_opterr; int custom_opterr;
int custom_optopt; int custom_optopt;
char *custom_optarg; char *custom_optarg;
/* True if the internal members have been initialized. */ /* True if the internal members have been initialized. */
int initialized; int initialized;
/* /*
* The next char to be scanned in the option-element in which the last option * The next char to be scanned in the option-element in which the last option
* character we returned was found. This allows us to pick up the scan where * character we returned was found. This allows us to pick up the scan where
* we left off. If this is zero, or a null string, it means resume the scan by * we left off. If this is zero, or a null string, it means resume the scan by
* advancing to the next ARGV-element. * advancing to the next ARGV-element.
*/ */
char *nextchar; char *nextchar;
/* /*
* Describe the part of ARGV that contains non-options that have been skipped. * Describe the part of ARGV that contains non-options that have been skipped.
* `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is
* the index after the last of them. * the index after the last of them.
*/ */
int first_nonopt; int first_nonopt;
int last_nonopt; int last_nonopt;
}; };
/* /*
@ -457,137 +457,137 @@ static int custom_optopt = '?';
*/ */
static void exchange(char **argv, struct custom_getopt_data *d) static void exchange(char **argv, struct custom_getopt_data *d)
{ {
int bottom = d->first_nonopt; int bottom = d->first_nonopt;
int middle = d->last_nonopt; int middle = d->last_nonopt;
int top = d->custom_optind; int top = d->custom_optind;
char *tem; char *tem;
/* /*
* Exchange the shorter segment with the far end of the longer segment. * Exchange the shorter segment with the far end of the longer segment.
* That puts the shorter segment into the right place. It leaves the * That puts the shorter segment into the right place. It leaves the
* longer segment in the right place overall, but it consists of two * longer segment in the right place overall, but it consists of two
* parts that need to be swapped next. * parts that need to be swapped next.
*/ */
while (top > middle && middle > bottom) { while (top > middle && middle > bottom) {
if (top - middle > middle - bottom) { if (top - middle > middle - bottom) {
/* Bottom segment is the short one. */ /* Bottom segment is the short one. */
int len = middle - bottom; int len = middle - bottom;
int i; int i;
/* Swap it with the top part of the top segment. */ /* Swap it with the top part of the top segment. */
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
tem = argv[bottom + i]; tem = argv[bottom + i];
argv[bottom + i] = argv[bottom + i] =
argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i];
argv[top - (middle - bottom) + i] = tem; argv[top - (middle - bottom) + i] = tem;
} }
/* Exclude the moved bottom segment from further swapping. */ /* Exclude the moved bottom segment from further swapping. */
top -= len; top -= len;
} else { } else {
/* Top segment is the short one. */ /* Top segment is the short one. */
int len = top - middle; int len = top - middle;
int i; int i;
/* Swap it with the bottom part of the bottom segment. */ /* Swap it with the bottom part of the bottom segment. */
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
tem = argv[bottom + i]; tem = argv[bottom + i];
argv[bottom + i] = argv[middle + i]; argv[bottom + i] = argv[middle + i];
argv[middle + i] = tem; argv[middle + i] = tem;
} }
/* Exclude the moved top segment from further swapping. */ /* Exclude the moved top segment from further swapping. */
bottom += len; bottom += len;
} }
} }
/* Update records for the slots the non-options now occupy. */ /* Update records for the slots the non-options now occupy. */
d->first_nonopt += (d->custom_optind - d->last_nonopt); d->first_nonopt += (d->custom_optind - d->last_nonopt);
d->last_nonopt = d->custom_optind; d->last_nonopt = d->custom_optind;
} }
/* Initialize the internal data when the first call is made. */ /* Initialize the internal data when the first call is made. */
static void custom_getopt_initialize(struct custom_getopt_data *d) static void custom_getopt_initialize(struct custom_getopt_data *d)
{ {
/* /*
* Start processing options with ARGV-element 1 (since ARGV-element 0 * Start processing options with ARGV-element 1 (since ARGV-element 0
* is the program name); the sequence of previously skipped non-option * is the program name); the sequence of previously skipped non-option
* ARGV-elements is empty. * ARGV-elements is empty.
*/ */
d->first_nonopt = d->last_nonopt = d->custom_optind; d->first_nonopt = d->last_nonopt = d->custom_optind;
d->nextchar = NULL; d->nextchar = NULL;
d->initialized = 1; d->initialized = 1;
} }
#define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0') #define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
/* return: zero: continue, nonzero: return given value to user */ /* return: zero: continue, nonzero: return given value to user */
static int shuffle_argv(int argc, char *const *argv,const struct option *longopts, static int shuffle_argv(int argc, char *const *argv,const struct option *longopts,
struct custom_getopt_data *d) struct custom_getopt_data *d)
{ {
/* /*
* Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been
* moved back by the user (who may also have changed the arguments). * moved back by the user (who may also have changed the arguments).
*/ */
if (d->last_nonopt > d->custom_optind) if (d->last_nonopt > d->custom_optind)
d->last_nonopt = d->custom_optind; d->last_nonopt = d->custom_optind;
if (d->first_nonopt > d->custom_optind) if (d->first_nonopt > d->custom_optind)
d->first_nonopt = d->custom_optind; d->first_nonopt = d->custom_optind;
/* /*
* If we have just processed some options following some * If we have just processed some options following some
* non-options, exchange them so that the options come first. * non-options, exchange them so that the options come first.
*/ */
if (d->first_nonopt != d->last_nonopt && if (d->first_nonopt != d->last_nonopt &&
d->last_nonopt != d->custom_optind) d->last_nonopt != d->custom_optind)
exchange((char **) argv, d); exchange((char **) argv, d);
else if (d->last_nonopt != d->custom_optind) else if (d->last_nonopt != d->custom_optind)
d->first_nonopt = d->custom_optind; d->first_nonopt = d->custom_optind;
/* /*
* Skip any additional non-options and extend the range of * Skip any additional non-options and extend the range of
* non-options previously skipped. * non-options previously skipped.
*/ */
while (d->custom_optind < argc && NONOPTION_P) while (d->custom_optind < argc && NONOPTION_P)
d->custom_optind++; d->custom_optind++;
d->last_nonopt = d->custom_optind; d->last_nonopt = d->custom_optind;
/* /*
* The special ARGV-element `--' means premature end of options. Skip * The special ARGV-element `--' means premature end of options. Skip
* it like a null option, then exchange with previous non-options as if * it like a null option, then exchange with previous non-options as if
* it were an option, then skip everything else like a non-option. * it were an option, then skip everything else like a non-option.
*/ */
if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) { if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) {
d->custom_optind++; d->custom_optind++;
if (d->first_nonopt != d->last_nonopt if (d->first_nonopt != d->last_nonopt
&& d->last_nonopt != d->custom_optind) && d->last_nonopt != d->custom_optind)
exchange((char **) argv, d); exchange((char **) argv, d);
else if (d->first_nonopt == d->last_nonopt) else if (d->first_nonopt == d->last_nonopt)
d->first_nonopt = d->custom_optind; d->first_nonopt = d->custom_optind;
d->last_nonopt = argc; d->last_nonopt = argc;
d->custom_optind = argc; d->custom_optind = argc;
} }
/* /*
* If we have done all the ARGV-elements, stop the scan and back over * If we have done all the ARGV-elements, stop the scan and back over
* any non-options that we skipped and permuted. * any non-options that we skipped and permuted.
*/ */
if (d->custom_optind == argc) { if (d->custom_optind == argc) {
/* /*
* Set the next-arg-index to point at the non-options that we * Set the next-arg-index to point at the non-options that we
* previously skipped, so the caller will digest them. * previously skipped, so the caller will digest them.
*/ */
if (d->first_nonopt != d->last_nonopt) if (d->first_nonopt != d->last_nonopt)
d->custom_optind = d->first_nonopt; d->custom_optind = d->first_nonopt;
return -1; return -1;
} }
/* /*
* If we have come to a non-option and did not permute it, either stop * If we have come to a non-option and did not permute it, either stop
* the scan or describe it to the caller and pass it by. * the scan or describe it to the caller and pass it by.
*/ */
if (NONOPTION_P) { if (NONOPTION_P) {
d->custom_optarg = argv[d->custom_optind++]; d->custom_optarg = argv[d->custom_optind++];
return 1; return 1;
} }
/* /*
* We have found another option-ARGV-element. Skip the initial * We have found another option-ARGV-element. Skip the initial
* punctuation. * punctuation.
*/ */
d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-')); d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-'));
return 0; return 0;
} }
/* /*
@ -601,180 +601,180 @@ static int shuffle_argv(int argc, char *const *argv,const struct option *longopt
* *
*/ */
static int check_long_opt(int argc, char *const *argv, const char *optstring, static int check_long_opt(int argc, char *const *argv, const char *optstring,
const struct option *longopts, int *longind, const struct option *longopts, int *longind,
int print_errors, struct custom_getopt_data *d) int print_errors, struct custom_getopt_data *d)
{ {
char *nameend; char *nameend;
const struct option *p; const struct option *p;
const struct option *pfound = NULL; const struct option *pfound = NULL;
int exact = 0; int exact = 0;
int ambig = 0; int ambig = 0;
int indfound = -1; int indfound = -1;
int option_index; int option_index;
for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++) for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++)
/* Do nothing. */ ; /* Do nothing. */ ;
/* Test all long options for either exact match or abbreviated matches */ /* Test all long options for either exact match or abbreviated matches */
for (p = longopts, option_index = 0; p->name; p++, option_index++) for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) { if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
if ((unsigned int) (nameend - d->nextchar) if ((unsigned int) (nameend - d->nextchar)
== (unsigned int) strlen(p->name)) { == (unsigned int) strlen(p->name)) {
/* Exact match found. */ /* Exact match found. */
pfound = p; pfound = p;
indfound = option_index; indfound = option_index;
exact = 1; exact = 1;
break; break;
} else if (pfound == NULL) { } else if (pfound == NULL) {
/* First nonexact match found. */ /* First nonexact match found. */
pfound = p; pfound = p;
indfound = option_index; indfound = option_index;
} else if (pfound->has_arg != p->has_arg } else if (pfound->has_arg != p->has_arg
|| pfound->flag != p->flag || pfound->flag != p->flag
|| pfound->val != p->val) || pfound->val != p->val)
/* Second or later nonexact match found. */ /* Second or later nonexact match found. */
ambig = 1; ambig = 1;
} }
if (ambig && !exact) { if (ambig && !exact) {
if (print_errors) { if (print_errors) {
fprintf(stderr, fprintf(stderr,
"%s: option `%s' is ambiguous\n", "%s: option `%s' is ambiguous\n",
argv[0], argv[d->custom_optind]); argv[0], argv[d->custom_optind]);
} }
d->nextchar += strlen(d->nextchar); d->nextchar += strlen(d->nextchar);
d->custom_optind++; d->custom_optind++;
d->custom_optopt = 0; d->custom_optopt = 0;
return '?'; return '?';
} }
if (pfound) { if (pfound) {
option_index = indfound; option_index = indfound;
d->custom_optind++; d->custom_optind++;
if (*nameend) { if (*nameend) {
if (pfound->has_arg != no_argument) if (pfound->has_arg != no_argument)
d->custom_optarg = nameend + 1; d->custom_optarg = nameend + 1;
else { else {
if (print_errors) { if (print_errors) {
if (argv[d->custom_optind - 1][1] == '-') { if (argv[d->custom_optind - 1][1] == '-') {
/* --option */ /* --option */
fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n", fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n",
argv[0], pfound->name); argv[0], pfound->name);
} else { } else {
/* +option or -option */ /* +option or -option */
fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n", fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n",
argv[0], argv[d->custom_optind - 1][0], pfound->name); argv[0], argv[d->custom_optind - 1][0], pfound->name);
} }
} }
d->nextchar += strlen(d->nextchar); d->nextchar += strlen(d->nextchar);
d->custom_optopt = pfound->val; d->custom_optopt = pfound->val;
return '?'; return '?';
} }
} else if (pfound->has_arg == required_argument) { } else if (pfound->has_arg == required_argument) {
if (d->custom_optind < argc) if (d->custom_optind < argc)
d->custom_optarg = argv[d->custom_optind++]; d->custom_optarg = argv[d->custom_optind++];
else { else {
if (print_errors) { if (print_errors) {
fprintf(stderr, fprintf(stderr,
"%s: option `%s' requires an argument\n", "%s: option `%s' requires an argument\n",
argv[0], argv[0],
argv[d->custom_optind - 1]); argv[d->custom_optind - 1]);
} }
d->nextchar += strlen(d->nextchar); d->nextchar += strlen(d->nextchar);
d->custom_optopt = pfound->val; d->custom_optopt = pfound->val;
return optstring[0] == ':' ? ':' : '?'; return optstring[0] == ':' ? ':' : '?';
} }
} }
d->nextchar += strlen(d->nextchar); d->nextchar += strlen(d->nextchar);
if (longind != NULL) if (longind != NULL)
*longind = option_index; *longind = option_index;
if (pfound->flag) { if (pfound->flag) {
*(pfound->flag) = pfound->val; *(pfound->flag) = pfound->val;
return 0; return 0;
} }
return pfound->val; return pfound->val;
} }
/* /*
* Can't find it as a long option. If this is not getopt_long_only, or * Can't find it as a long option. If this is not getopt_long_only, or
* the option starts with '--' or is not a valid short option, then * the option starts with '--' or is not a valid short option, then
* it's an error. Otherwise interpret it as a short option. * it's an error. Otherwise interpret it as a short option.
*/ */
if (print_errors) { if (print_errors) {
if (argv[d->custom_optind][1] == '-') { if (argv[d->custom_optind][1] == '-') {
/* --option */ /* --option */
fprintf(stderr, fprintf(stderr,
"%s: unrecognized option `--%s'\n", "%s: unrecognized option `--%s'\n",
argv[0], d->nextchar); argv[0], d->nextchar);
} else { } else {
/* +option or -option */ /* +option or -option */
fprintf(stderr, fprintf(stderr,
"%s: unrecognized option `%c%s'\n", "%s: unrecognized option `%c%s'\n",
argv[0], argv[d->custom_optind][0], argv[0], argv[d->custom_optind][0],
d->nextchar); d->nextchar);
} }
} }
d->nextchar = (char *) ""; d->nextchar = (char *) "";
d->custom_optind++; d->custom_optind++;
d->custom_optopt = 0; d->custom_optopt = 0;
return '?'; return '?';
} }
static int check_short_opt(int argc, char *const *argv, const char *optstring, static int check_short_opt(int argc, char *const *argv, const char *optstring,
int print_errors, struct custom_getopt_data *d) int print_errors, struct custom_getopt_data *d)
{ {
char c = *d->nextchar++; char c = *d->nextchar++;
const char *temp = strchr(optstring, c); const char *temp = strchr(optstring, c);
/* Increment `custom_optind' when we start to process its last character. */ /* Increment `custom_optind' when we start to process its last character. */
if (*d->nextchar == '\0') if (*d->nextchar == '\0')
++d->custom_optind; ++d->custom_optind;
if (!temp || c == ':') { if (!temp || c == ':') {
if (print_errors) if (print_errors)
fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c); fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
d->custom_optopt = c; d->custom_optopt = c;
return '?'; return '?';
} }
if (temp[1] == ':') { if (temp[1] == ':') {
if (temp[2] == ':') { if (temp[2] == ':') {
/* This is an option that accepts an argument optionally. */ /* This is an option that accepts an argument optionally. */
if (*d->nextchar != '\0') { if (*d->nextchar != '\0') {
d->custom_optarg = d->nextchar; d->custom_optarg = d->nextchar;
d->custom_optind++; d->custom_optind++;
} else } else
d->custom_optarg = NULL; d->custom_optarg = NULL;
d->nextchar = NULL; d->nextchar = NULL;
} else { } else {
/* This is an option that requires an argument. */ /* This is an option that requires an argument. */
if (*d->nextchar != '\0') { if (*d->nextchar != '\0') {
d->custom_optarg = d->nextchar; d->custom_optarg = d->nextchar;
/* /*
* If we end this ARGV-element by taking the * If we end this ARGV-element by taking the
* rest as an arg, we must advance to the next * rest as an arg, we must advance to the next
* element now. * element now.
*/ */
d->custom_optind++; d->custom_optind++;
} else if (d->custom_optind == argc) { } else if (d->custom_optind == argc) {
if (print_errors) { if (print_errors) {
fprintf(stderr, fprintf(stderr,
"%s: option requires an argument -- %c\n", "%s: option requires an argument -- %c\n",
argv[0], c); argv[0], c);
} }
d->custom_optopt = c; d->custom_optopt = c;
if (optstring[0] == ':') if (optstring[0] == ':')
c = ':'; c = ':';
else else
c = '?'; c = '?';
} else } else
/* /*
* We already incremented `custom_optind' once; * We already incremented `custom_optind' once;
* increment it again when taking next ARGV-elt * increment it again when taking next ARGV-elt
* as argument. * as argument.
*/ */
d->custom_optarg = argv[d->custom_optind++]; d->custom_optarg = argv[d->custom_optind++];
d->nextchar = NULL; d->nextchar = NULL;
} }
} }
return c; return c;
} }
/* /*
@ -848,59 +848,59 @@ static int check_short_opt(int argc, char *const *argv, const char *optstring,
*/ */
static int getopt_internal_r(int argc, char *const *argv, const char *optstring, static int getopt_internal_r(int argc, char *const *argv, const char *optstring,
const struct option *longopts, int *longind, const struct option *longopts, int *longind,
struct custom_getopt_data *d) struct custom_getopt_data *d)
{ {
int ret, print_errors = d->custom_opterr; int ret, print_errors = d->custom_opterr;
if (optstring[0] == ':') if (optstring[0] == ':')
print_errors = 0; print_errors = 0;
if (argc < 1) if (argc < 1)
return -1; return -1;
d->custom_optarg = NULL; d->custom_optarg = NULL;
/* /*
* This is a big difference with GNU getopt, since optind == 0 * This is a big difference with GNU getopt, since optind == 0
* means initialization while here 1 means first call. * means initialization while here 1 means first call.
*/ */
if (d->custom_optind == 0 || !d->initialized) { if (d->custom_optind == 0 || !d->initialized) {
if (d->custom_optind == 0) if (d->custom_optind == 0)
d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */ d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */
custom_getopt_initialize(d); custom_getopt_initialize(d);
} }
if (d->nextchar == NULL || *d->nextchar == '\0') { if (d->nextchar == NULL || *d->nextchar == '\0') {
ret = shuffle_argv(argc, argv, longopts, d); ret = shuffle_argv(argc, argv, longopts, d);
if (ret) if (ret)
return ret; return ret;
} }
if (longopts && (argv[d->custom_optind][1] == '-' )) if (longopts && (argv[d->custom_optind][1] == '-' ))
return check_long_opt(argc, argv, optstring, longopts, return check_long_opt(argc, argv, optstring, longopts,
longind, print_errors, d); longind, print_errors, d);
return check_short_opt(argc, argv, optstring, print_errors, d); return check_short_opt(argc, argv, optstring, print_errors, d);
} }
static int custom_getopt_internal(int argc, char *const *argv, const char *optstring, static int custom_getopt_internal(int argc, char *const *argv, const char *optstring,
const struct option *longopts, int *longind) const struct option *longopts, int *longind)
{ {
int result; int result;
/* Keep a global copy of all internal members of d */ /* Keep a global copy of all internal members of d */
static struct custom_getopt_data d; static struct custom_getopt_data d;
d.custom_optind = custom_optind; d.custom_optind = custom_optind;
d.custom_opterr = custom_opterr; d.custom_opterr = custom_opterr;
result = getopt_internal_r(argc, argv, optstring, longopts, result = getopt_internal_r(argc, argv, optstring, longopts,
longind, &d); longind, &d);
custom_optind = d.custom_optind; custom_optind = d.custom_optind;
custom_optarg = d.custom_optarg; custom_optarg = d.custom_optarg;
custom_optopt = d.custom_optopt; custom_optopt = d.custom_optopt;
return result; return result;
} }
static int custom_getopt_long (int argc, char *const *argv, const char *options, static int custom_getopt_long (int argc, char *const *argv, const char *options,
const struct option *long_options, int *opt_index) const struct option *long_options, int *opt_index)
{ {
return custom_getopt_internal(argc, argv, options, long_options, return custom_getopt_internal(argc, argv, options, long_options,
opt_index); opt_index);
} }
@ -1007,7 +1007,7 @@ cmdline_parser_internal (
int argc, char * const *argv, struct gengetopt_args_info *args_info, int argc, char * const *argv, struct gengetopt_args_info *args_info,
struct cmdline_parser_params *params, const char *additional_error) struct cmdline_parser_params *params, const char *additional_error)
{ {
int c; /* Character of the parsed option. */ int c; /* Character of the parsed option. */
int error = 0; int error = 0;
struct gengetopt_args_info local_args_info; struct gengetopt_args_info local_args_info;
@ -1044,10 +1044,10 @@ cmdline_parser_internal (
int option_index = 0; int option_index = 0;
static struct option long_options[] = { static struct option long_options[] = {
{ "help", 0, NULL, 'h' }, { "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'V' }, { "version", 0, NULL, 'V' },
{ "extract", 1, NULL, 'x' }, { "extract", 1, NULL, 'x' },
{ "long", 0, NULL, 'l' }, { "long", 0, NULL, 'l' },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
@ -1063,21 +1063,21 @@ cmdline_parser_internal (
opterr = custom_opterr; opterr = custom_opterr;
optopt = custom_optopt; optopt = custom_optopt;
if (c == -1) break; /* Exit from `while (1)' loop. */ if (c == -1) break; /* Exit from `while (1)' loop. */
switch (c) switch (c)
{ {
case 'h': /* Print help and exit. */ case 'h': /* Print help and exit. */
cmdline_parser_print_help (); cmdline_parser_print_help ();
cmdline_parser_free (&local_args_info); cmdline_parser_free (&local_args_info);
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
case 'V': /* Print version and exit. */ case 'V': /* Print version and exit. */
cmdline_parser_print_version (); cmdline_parser_print_version ();
cmdline_parser_free (&local_args_info); cmdline_parser_free (&local_args_info);
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
case 'x': /* Extract file from archive. */ case 'x': /* Extract file from archive. */
if (update_arg( (void *)&(args_info->extract_arg), if (update_arg( (void *)&(args_info->extract_arg),
@ -1089,7 +1089,7 @@ cmdline_parser_internal (
goto failure; goto failure;
break; break;
case 'l': /* Include extra information in archive listing. */ case 'l': /* Include extra information in archive listing. */
if (update_arg( 0 , if (update_arg( 0 ,
@ -1102,12 +1102,12 @@ cmdline_parser_internal (
break; break;
case 0: /* Long option with no short option */ case 0: /* Long option with no short option */
case '?': /* Invalid option. */ case '?': /* Invalid option. */
/* `getopt_long' already printed an error message. */ /* `getopt_long' already printed an error message. */
goto failure; goto failure;
default: /* bug: option not considered. */ default: /* bug: option not considered. */
fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
abort (); abort ();
} /* switch */ } /* switch */

View file

@ -39,15 +39,15 @@ struct gengetopt_args_info
{ {
const char *help_help; /**< @brief Print help and exit help description. */ const char *help_help; /**< @brief Print help and exit help description. */
const char *version_help; /**< @brief Print version and exit help description. */ const char *version_help; /**< @brief Print version and exit help description. */
char * extract_arg; /**< @brief Extract file from archive. */ char * extract_arg; /**< @brief Extract file from archive. */
char * extract_orig; /**< @brief Extract file from archive original value given at command line. */ char * extract_orig; /**< @brief Extract file from archive original value given at command line. */
const char *extract_help; /**< @brief Extract file from archive help description. */ const char *extract_help; /**< @brief Extract file from archive help description. */
const char *long_help; /**< @brief Include extra information in archive listing help description. */ const char *long_help; /**< @brief Include extra information in archive listing help description. */
unsigned int help_given ; /**< @brief Whether help was given. */ unsigned int help_given ; /**< @brief Whether help was given. */
unsigned int version_given ; /**< @brief Whether version was given. */ unsigned int version_given ; /**< @brief Whether version was given. */
unsigned int extract_given ; /**< @brief Whether extract was given. */ unsigned int extract_given ; /**< @brief Whether extract was given. */
unsigned int long_given ; /**< @brief Whether long was given. */ unsigned int long_given ; /**< @brief Whether long was given. */
char **inputs ; /**< @brief unamed options (options without names) */ char **inputs ; /**< @brief unamed options (options without names) */
unsigned inputs_num ; /**< @brief unamed options number */ unsigned inputs_num ; /**< @brief unamed options number */

View file

@ -37,10 +37,10 @@ namespace Compiler
public: public:
ErrorHandler(); ErrorHandler();
///< constructor ///< constructor
virtual ~ErrorHandler(); virtual ~ErrorHandler();
///< destructor ///< destructor
bool isGood() const; bool isGood() const;
///< Was compiling successful? ///< Was compiling successful?

View file

@ -96,7 +96,7 @@ namespace Compiler
Scanner (ErrorHandler& errorHandler, std::istream& inputStream, Scanner (ErrorHandler& errorHandler, std::istream& inputStream,
const Extensions *extensions = 0); const Extensions *extensions = 0);
///< constructor ///< constructor
void scan (Parser& parser); void scan (Parser& parser);
///< Scan a token and deliver it to the parser. ///< Scan a token and deliver it to the parser.

View file

@ -30,7 +30,7 @@ namespace Compiler
// constructors // constructors
StreamErrorHandler (std::ostream& ErrorStream); StreamErrorHandler (std::ostream& ErrorStream);
///< constructor ///< constructor
}; };
} }

View file

@ -451,11 +451,11 @@ public:
bool isEmptyOrGetName() bool isEmptyOrGetName()
{ {
if(c.leftRec) if(c.leftRec)
{ {
esm->read(c.subName.name, 4); esm->read(c.subName.name, 4);
c.leftRec -= 4; c.leftRec -= 4;
return false; return false;
} }
return true; return true;
} }
@ -472,7 +472,7 @@ public:
{ {
skipHSub(); skipHSub();
if(static_cast<int> (c.leftSub) != size) if(static_cast<int> (c.leftSub) != size)
fail("skipHSubSize() mismatch"); fail("skipHSubSize() mismatch");
} }
/* Sub-record header. This updates leftRec beyond the current /* Sub-record header. This updates leftRec beyond the current
@ -481,7 +481,7 @@ public:
void getSubHeader() void getSubHeader()
{ {
if(c.leftRec < 4) if(c.leftRec < 4)
fail("End of record while reading sub-record header"); fail("End of record while reading sub-record header");
// Get subrecord size // Get subrecord size
getT(c.leftSub); getT(c.leftSub);
@ -491,7 +491,7 @@ public:
// Check that sizes added up // Check that sizes added up
if(c.leftRec < 0) if(c.leftRec < 0)
fail("Not enough bytes left in record for this subrecord."); fail("Not enough bytes left in record for this subrecord.");
} }
/** Get sub header and check the size /** Get sub header and check the size
@ -550,9 +550,9 @@ public:
{ {
// General error checking // General error checking
if(c.leftFile < 12) if(c.leftFile < 12)
fail("End of file while reading record header"); fail("End of file while reading record header");
if(c.leftRec) if(c.leftRec)
fail("Previous record contains unread bytes"); fail("Previous record contains unread bytes");
getUint(c.leftRec); getUint(c.leftRec);
getUint(flags);// This header entry is always zero getUint(flags);// This header entry is always zero
@ -561,7 +561,7 @@ public:
// Check that sizes add up // Check that sizes add up
if(c.leftFile < c.leftRec) if(c.leftFile < c.leftRec)
fail("Record size is larger than rest of file"); fail("Record size is larger than rest of file");
// Adjust number of bytes c.left in file // Adjust number of bytes c.left in file
c.leftFile -= c.leftRec; c.leftFile -= c.leftRec;

View file

@ -43,8 +43,8 @@ namespace ESM
if(esm.isNextSub("AIDT")) if(esm.isNextSub("AIDT"))
{ {
esm.getHExact(&AI, sizeof(AI)); esm.getHExact(&AI, sizeof(AI));
hasAI = true; hasAI = true;
} }
else hasAI = false; else hasAI = false;
@ -73,45 +73,45 @@ namespace ESM
if(subName.val == REC_ONAM) if(subName.val == REC_ONAM)
{ {
actor = esm.getHString(); actor = esm.getHString();
if(esm.isEmptyOrGetName()) return; if(esm.isEmptyOrGetName()) return;
} }
if(subName.val == REC_RNAM) if(subName.val == REC_RNAM)
{ {
race = esm.getHString(); race = esm.getHString();
if(esm.isEmptyOrGetName()) return; if(esm.isEmptyOrGetName()) return;
} }
if(subName.val == REC_CNAM) if(subName.val == REC_CNAM)
{ {
clas = esm.getHString(); clas = esm.getHString();
if(esm.isEmptyOrGetName()) return; if(esm.isEmptyOrGetName()) return;
} }
factionLess = false; factionLess = false;
if(subName.val == REC_FNAM) if(subName.val == REC_FNAM)
{ {
npcFaction = esm.getHString(); npcFaction = esm.getHString();
if(npcFaction == "FFFF") factionLess = true; if(npcFaction == "FFFF") factionLess = true;
if(esm.isEmptyOrGetName()) return; if(esm.isEmptyOrGetName()) return;
} }
if(subName.val == REC_ANAM) if(subName.val == REC_ANAM)
{ {
cell = esm.getHString(); cell = esm.getHString();
if(esm.isEmptyOrGetName()) return; if(esm.isEmptyOrGetName()) return;
} }
if(subName.val == REC_DNAM) if(subName.val == REC_DNAM)
{ {
pcFaction = esm.getHString(); pcFaction = esm.getHString();
if(esm.isEmptyOrGetName()) return; if(esm.isEmptyOrGetName()) return;
} }
if(subName.val == REC_SNAM) if(subName.val == REC_SNAM)
{ {
sound = esm.getHString(); sound = esm.getHString();
if(esm.isEmptyOrGetName()) return; if(esm.isEmptyOrGetName()) return;
} }
if(subName.val == REC_NAME) if(subName.val == REC_NAME)
{ {
response = esm.getHString(); response = esm.getHString();
if(esm.isEmptyOrGetName()) return; if(esm.isEmptyOrGetName()) return;
} }
while(subName.val == REC_SCVR) while(subName.val == REC_SCVR)
@ -133,17 +133,17 @@ namespace ESM
} }
else else
esm.fail("INFO.SCVR must precede INTV or FLTV, not " esm.fail("INFO.SCVR must precede INTV or FLTV, not "
+ subName.toString()); + subName.toString());
selects.push_back(ss); selects.push_back(ss);
if(esm.isEmptyOrGetName()) return; if(esm.isEmptyOrGetName()) return;
} }
if(subName.val == REC_BNAM) if(subName.val == REC_BNAM)
{ {
resultScript = esm.getHString(); resultScript = esm.getHString();
if(esm.isEmptyOrGetName()) return; if(esm.isEmptyOrGetName()) return;
} }
questStatus = QS_None; questStatus = QS_None;

View file

@ -13,10 +13,10 @@ struct Apparatus
{ {
enum AppaType enum AppaType
{ {
MortarPestle = 0, MortarPestle = 0,
Albemic = 1, Albemic = 1,
Calcinator = 2, Calcinator = 2,
Retort = 3 Retort = 3
}; };
struct AADTstruct struct AADTstruct

View file

@ -64,17 +64,17 @@ struct Armor
{ {
enum Type enum Type
{ {
Helmet = 0, Helmet = 0,
Cuirass = 1, Cuirass = 1,
LPauldron = 2, LPauldron = 2,
RPauldron = 3, RPauldron = 3,
Greaves = 4, Greaves = 4,
Boots = 5, Boots = 5,
LGauntlet = 6, LGauntlet = 6,
RGauntlet = 7, RGauntlet = 7,
Shield = 8, Shield = 8,
LBracer = 9, LBracer = 9,
RBracer = 10 RBracer = 10
}; };
struct AODTstruct struct AODTstruct

View file

@ -15,24 +15,24 @@ struct Class
{ {
enum AutoCalc enum AutoCalc
{ {
Weapon = 0x00001, Weapon = 0x00001,
Armor = 0x00002, Armor = 0x00002,
Clothing = 0x00004, Clothing = 0x00004,
Books = 0x00008, Books = 0x00008,
Ingredient = 0x00010, Ingredient = 0x00010,
Lockpick = 0x00020, Lockpick = 0x00020,
Probe = 0x00040, Probe = 0x00040,
Lights = 0x00080, Lights = 0x00080,
Apparatus = 0x00100, Apparatus = 0x00100,
Repair = 0x00200, Repair = 0x00200,
Misc = 0x00400, Misc = 0x00400,
Spells = 0x00800, Spells = 0x00800,
MagicItems = 0x01000, MagicItems = 0x01000,
Potions = 0x02000, Potions = 0x02000,
Training = 0x04000, Training = 0x04000,
Spellmaking = 0x08000, Spellmaking = 0x08000,
Enchanting = 0x10000, Enchanting = 0x10000,
RepairItem = 0x20000 RepairItem = 0x20000
}; };
enum Specialization enum Specialization
@ -65,7 +65,7 @@ struct Class
esm.getHNT(data, "CLDT", 60); esm.getHNT(data, "CLDT", 60);
if(data.isPlayable > 1) if(data.isPlayable > 1)
esm.fail("Unknown bool value"); esm.fail("Unknown bool value");
description = esm.getHNOString("DESC"); description = esm.getHNOString("DESC");
} }

View file

@ -14,16 +14,16 @@ struct Clothing
{ {
enum Type enum Type
{ {
Pants = 0, Pants = 0,
Shoes = 1, Shoes = 1,
Shirt = 2, Shirt = 2,
Belt = 3, Belt = 3,
Robe = 4, Robe = 4,
RGlove = 5, RGlove = 5,
LGlove = 6, LGlove = 6,
Skirt = 7, Skirt = 7,
Ring = 8, Ring = 8,
Amulet = 9 Amulet = 9
}; };
struct CTDTstruct struct CTDTstruct

View file

@ -34,9 +34,9 @@ struct Container
{ {
enum Flags enum Flags
{ {
Organic = 1, // Objects cannot be placed in this container Organic = 1, // Objects cannot be placed in this container
Respawn = 2, // Respawns after 4 months Respawn = 2, // Respawns after 4 months
Unknown = 8 Unknown = 8
}; };
std::string name, model, script; std::string name, model, script;

View file

@ -16,24 +16,24 @@ struct Creature
// Default is 0x48? // Default is 0x48?
enum Flags enum Flags
{ {
Biped = 0x001, Biped = 0x001,
Respawn = 0x002, Respawn = 0x002,
Weapon = 0x004, // Has weapon and shield Weapon = 0x004, // Has weapon and shield
None = 0x008, // ?? None = 0x008, // ??
Swims = 0x010, Swims = 0x010,
Flies = 0x020, // Don't know what happens if several Flies = 0x020, // Don't know what happens if several
Walks = 0x040, // of these are set Walks = 0x040, // of these are set
Essential = 0x080, Essential = 0x080,
Skeleton = 0x400, // Does not have normal blood Skeleton = 0x400, // Does not have normal blood
Metal = 0x800 // Has 'golden' blood Metal = 0x800 // Has 'golden' blood
}; };
enum Type enum Type
{ {
Creatures = 0, Creatures = 0,
Deadra = 1, Deadra = 1,
Undead = 2, Undead = 2,
Humanoid = 3 Humanoid = 3
}; };
struct NPDTstruct struct NPDTstruct

View file

@ -17,12 +17,12 @@ struct Dialogue
{ {
enum Type enum Type
{ {
Topic = 0, Topic = 0,
Voice = 1, Voice = 1,
Greeting = 2, Greeting = 2,
Persuasion = 3, Persuasion = 3,
Journal = 4, Journal = 4,
Deleted = -1 Deleted = -1
}; };
char type; char type;
@ -37,11 +37,11 @@ struct Dialogue
esm.getT(type); esm.getT(type);
else if(si == 4) else if(si == 4)
{ {
// These are just markers, their values are not used. // These are just markers, their values are not used.
int i; int i;
esm.getT(i); esm.getT(i);
esm.getHNT(i,"DELE"); esm.getHNT(i,"DELE");
type = Deleted; type = Deleted;
} }
else esm.fail("Unknown sub record size"); else esm.fail("Unknown sub record size");
} }

View file

@ -13,10 +13,10 @@ struct Enchantment
{ {
enum Type enum Type
{ {
CastOnce = 0, CastOnce = 0,
WhenStrikes = 1, WhenStrikes = 1,
WhenUsed = 2, WhenUsed = 2,
ConstantEffect = 3 ConstantEffect = 3
}; };
struct ENDTstruct struct ENDTstruct
@ -25,7 +25,7 @@ struct Enchantment
int cost; int cost;
int charge; int charge;
int autocalc; // Guessing this is 1 if we are supposed to auto int autocalc; // Guessing this is 1 if we are supposed to auto
// calculate // calculate
}; };
ENDTstruct data; ENDTstruct data;

View file

@ -14,12 +14,12 @@ struct RankData
{ {
int attribute1, attribute2; // Attribute level int attribute1, attribute2; // Attribute level
int skill1, skill2; // Skill level (faction skills given in int skill1, skill2; // Skill level (faction skills given in
// skillID below.) You need one skill at // skillID below.) You need one skill at
// level 'skill1' and two skills at level // level 'skill1' and two skills at level
// 'skill2' to advance to this rank. // 'skill2' to advance to this rank.
int factReaction; // Reaction from faction members int factReaction; // Reaction from faction members
}; };
struct Faction struct Faction
@ -29,7 +29,7 @@ struct Faction
struct FADTstruct struct FADTstruct
{ {
// Which attributes we like // Which attributes we like
int attribute1, attribute2; int attribute1, attribute2;
RankData rankData[10]; RankData rankData[10];

View file

@ -110,12 +110,12 @@ struct GameSetting
"Return to Companion Share display."); // same "Return to Companion Share display."); // same
cS("sCompanionWarningMessage", cS("sCompanionWarningMessage",
"Your mercenary is poorer now than when he contracted with you. Your mercenary will quit if you do not give him gold or goods to bring his Profit Value to a positive value."); "Your mercenary is poorer now than when he contracted with you. Your mercenary will quit if you do not give him gold or goods to bring his Profit Value to a positive value.");
// 'Your mercenary is poorer now than when he contracted with // 'Your mercenary is poorer now than when he contracted with
// you. Your mercenary will quit if you do not give him gold // you. Your mercenary will quit if you do not give him gold
// or goods to bring his Profit to a positive value.' // or goods to bring his Profit to a positive value.'
// [The difference here is "Profit Value" -> "Profit"] // [The difference here is "Profit Value" -> "Profit"]
// Strings that matches the id // Strings that matches the id
cS("sEffectSummonFabricant", id);// 'Summon Fabricant' cS("sEffectSummonFabricant", id);// 'Summon Fabricant'
return false; return false;
} }
@ -145,13 +145,13 @@ struct GameSetting
cS("sEffectSummonCreature04", id); // same cS("sEffectSummonCreature04", id); // same
cS("sEffectSummonCreature05", id); // same cS("sEffectSummonCreature05", id); // same
// Integers // Integers
cI("iWereWolfBounty", 10000); // 1000 cI("iWereWolfBounty", 10000); // 1000
cI("iWereWolfFightMod", 100); // same cI("iWereWolfFightMod", 100); // same
cI("iWereWolfFleeMod", 100); // same cI("iWereWolfFleeMod", 100); // same
cI("iWereWolfLevelToAttack", 20); // same cI("iWereWolfLevelToAttack", 20); // same
// Floats // Floats
cF("fFleeDistance", 3000); // same cF("fFleeDistance", 3000); // same
cF("fCombatDistanceWerewolfMod", 0.3); // same cF("fCombatDistanceWerewolfMod", 0.3); // same
cF("fWereWolfFatigue", 400); // same cF("fWereWolfFatigue", 400); // same
@ -210,8 +210,8 @@ struct GameSetting
// We are apparently allowed to be empty // We are apparently allowed to be empty
if(!esm.hasMoreSubs()) if(!esm.hasMoreSubs())
{ {
type = VT_None; type = VT_None;
return; return;
} }
// Load some data // Load some data
@ -219,18 +219,18 @@ struct GameSetting
NAME n = esm.retSubName(); NAME n = esm.retSubName();
if(n == "STRV") if(n == "STRV")
{ {
str = esm.getHString(); str = esm.getHString();
type = VT_String; type = VT_String;
} }
else if(n == "INTV") else if(n == "INTV")
{ {
esm.getHT(i); esm.getHT(i);
type = VT_Int; type = VT_Int;
} }
else if(n == "FLTV") else if(n == "FLTV")
{ {
esm.getHT(f); esm.getHT(f);
type = VT_Float; type = VT_Float;
} }
else else
esm.fail("Unwanted subrecord type"); esm.fail("Unwanted subrecord type");
@ -242,7 +242,7 @@ struct GameSetting
// the 'id' string correctly before calling load(). // the 'id' string correctly before calling load().
if( ( spf != SF_Tribunal && isDirtyTribunal() ) || if( ( spf != SF_Tribunal && isDirtyTribunal() ) ||
( spf != SF_Bloodmoon && isDirtyBloodmoon() ) ) ( spf != SF_Bloodmoon && isDirtyBloodmoon() ) )
dirty = true; dirty = true;
} }
}; };

View file

@ -14,15 +14,15 @@ struct Light
{ {
enum Flags enum Flags
{ {
Dynamic = 0x001, Dynamic = 0x001,
Carry = 0x002, // Can be carried Carry = 0x002, // Can be carried
Negative = 0x004, // Negative light? Negative = 0x004, // Negative light?
Flicker = 0x008, Flicker = 0x008,
Fire = 0x010, Fire = 0x010,
OffDefault = 0x020, // Off by default OffDefault = 0x020, // Off by default
FlickerSlow = 0x040, FlickerSlow = 0x040,
Pulse = 0x080, Pulse = 0x080,
PulseSlow = 0x100 PulseSlow = 0x100
}; };
struct LHDTstruct struct LHDTstruct

View file

@ -17,8 +17,8 @@ struct Misc
float weight; float weight;
int value; int value;
int isKey; // There are many keys in Morrowind.esm that has this int isKey; // There are many keys in Morrowind.esm that has this
// set to 0. TODO: Check what this field corresponds to // set to 0. TODO: Check what this field corresponds to
// in the editor. // in the editor.
}; };
MCDTstruct data; MCDTstruct data;

View file

@ -17,36 +17,36 @@ struct NPC
enum Services enum Services
{ {
// This merchant buys: // This merchant buys:
Weapon = 0x00001, Weapon = 0x00001,
Armor = 0x00002, Armor = 0x00002,
Clothing = 0x00004, Clothing = 0x00004,
Books = 0x00008, Books = 0x00008,
Ingredients = 0x00010, Ingredients = 0x00010,
Picks = 0x00020, Picks = 0x00020,
Probes = 0x00040, Probes = 0x00040,
Lights = 0x00080, Lights = 0x00080,
Apparatus = 0x00100, Apparatus = 0x00100,
RepairItem = 0x00200, RepairItem = 0x00200,
Misc = 0x00400, Misc = 0x00400,
// Other services // Other services
Spells = 0x00800, Spells = 0x00800,
MagicItems = 0x01000, MagicItems = 0x01000,
Potions = 0x02000, Potions = 0x02000,
Training = 0x04000, // What skills? Training = 0x04000, // What skills?
Spellmaking = 0x08000, Spellmaking = 0x08000,
Enchanting = 0x10000, Enchanting = 0x10000,
Repair = 0x20000 Repair = 0x20000
}; };
enum Flags enum Flags
{ {
Female = 0x0001, Female = 0x0001,
Essential = 0x0002, Essential = 0x0002,
Respawn = 0x0004, Respawn = 0x0004,
Autocalc = 0x0008, Autocalc = 0x0008,
Skeleton = 0x0400, // Skeleton blood effect (white) Skeleton = 0x0400, // Skeleton blood effect (white)
Metal = 0x0800 // Metal blood effect (golden?) Metal = 0x0800 // Metal blood effect (golden?)
}; };
#pragma pack(push) #pragma pack(push)

View file

@ -14,7 +14,7 @@ struct PathGrid
{ {
int x, y; // Grid location, matches cell for exterior cells int x, y; // Grid location, matches cell for exterior cells
short s1; // ?? Usually but not always a power of 2. Doesn't seem short s1; // ?? Usually but not always a power of 2. Doesn't seem
// to have any relation to the size of PGRC. // to have any relation to the size of PGRC.
short s2; // Number of path points? Size of PGRP block is always 16 * s2; short s2; // Number of path points? Size of PGRP block is always 16 * s2;
}; // 12 bytes }; // 12 bytes
@ -35,9 +35,9 @@ struct PathGrid
if(esm.isNextSub("PGRP")) if(esm.isNextSub("PGRP"))
{ {
esm.skipHSub(); esm.skipHSub();
int size = esm.getSubSize(); int size = esm.getSubSize();
if(size != 16*data.s2) if(size != 16*data.s2)
esm.fail("Path grid table size mismatch"); esm.fail("Path grid table size mismatch");
} }
// Size varies. Path grid chances? Connections? Multiples of 4 // Size varies. Path grid chances? Connections? Multiples of 4
@ -45,10 +45,10 @@ struct PathGrid
// it later. // it later.
if(esm.isNextSub("PGRC")) if(esm.isNextSub("PGRC"))
{ {
esm.skipHSub(); esm.skipHSub();
int size = esm.getSubSize(); int size = esm.getSubSize();
if(size % 4 != 0) if(size % 4 != 0)
esm.fail("PGRC size not a multiple of 4"); esm.fail("PGRC size not a multiple of 4");
} }
} }
}; };

View file

@ -29,8 +29,8 @@ struct Race
enum Flags enum Flags
{ {
Playable = 0x01, Playable = 0x01,
Beast = 0x02 Beast = 0x02
}; };
struct RADTstruct struct RADTstruct

View file

@ -3,31 +3,31 @@
namespace ESMS namespace ESMS
{ {
const std::string Skill::sSkillNames[Length] = { const std::string Skill::sSkillNames[Length] = {
"Block", "Block",
"Armorer", "Armorer",
"Medium Armor", "Medium Armor",
"Heavy Armor", "Heavy Armor",
"Blunt Weapon", "Blunt Weapon",
"Long Blade", "Long Blade",
"Axe", "Axe",
"Spear", "Spear",
"Athletics", "Athletics",
"Enchant", "Enchant",
"Destruction", "Destruction",
"Alteration", "Alteration",
"Illusion", "Illusion",
"Conjuration", "Conjuration",
"Mysticism", "Mysticism",
"Restoration", "Restoration",
"Alchemy", "Alchemy",
"Unarmored", "Unarmored",
"Security", "Security",
"Sneak", "Sneak",
"Acrobatics", "Acrobatics",
"Light Armor", "Light Armor",
"Short Blade", "Short Blade",
"Marksman", "Marksman",
"Speechcraft", "Speechcraft",
"Hand To Hand", "Hand To Hand",
}; };
} }

View file

@ -20,8 +20,8 @@ struct Skill
int attribute; // see defs.hpp int attribute; // see defs.hpp
int specialization;// 0 - Combat, 1 - Magic, 2 - Stealth int specialization;// 0 - Combat, 1 - Magic, 2 - Stealth
float useValue[4]; // How much skill improves through use. Meaning float useValue[4]; // How much skill improves through use. Meaning
// of each field depends on what skill this // of each field depends on what skill this
// is. We should document this better later. // is. We should document this better later.
}; // Total size: 24 bytes }; // Total size: 24 bytes
SKDTstruct data; SKDTstruct data;

View file

@ -13,14 +13,14 @@ struct SoundGenerator
{ {
enum Type enum Type
{ {
LeftFoot = 0, LeftFoot = 0,
RightFoot = 1, RightFoot = 1,
SwimLeft = 2, SwimLeft = 2,
SwimRight = 3, SwimRight = 3,
Moan = 4, Moan = 4,
Roar = 5, Roar = 5,
Scream = 6, Scream = 6,
Land = 7 Land = 7
}; };
// Type // Type

View file

@ -12,7 +12,7 @@ struct Spell
ST_Spell = 0, // Normal spell, must be cast and costs mana ST_Spell = 0, // Normal spell, must be cast and costs mana
ST_Ability = 1, // Inert ability, always in effect ST_Ability = 1, // Inert ability, always in effect
ST_Blight = 2, // Blight disease ST_Blight = 2, // Blight disease
ST_Disease = 3, // Common disease ST_Disease = 3, // Common disease
ST_Curse = 4, // Curse (?) ST_Curse = 4, // Curse (?)
ST_Power = 5 // Power, can use once a day ST_Power = 5 // Power, can use once a day
}; };

View file

@ -13,26 +13,26 @@ struct Weapon
{ {
enum Type enum Type
{ {
ShortBladeOneHand = 0, ShortBladeOneHand = 0,
LongBladeOneHand = 1, LongBladeOneHand = 1,
LongBladeTwoHand = 2, LongBladeTwoHand = 2,
BluntOneHand = 3, BluntOneHand = 3,
BluntTwoClose = 4, BluntTwoClose = 4,
BluntTwoWide = 5, BluntTwoWide = 5,
SpearTwoWide = 6, SpearTwoWide = 6,
AxeOneHand = 7, AxeOneHand = 7,
AxeTwoHand = 8, AxeTwoHand = 8,
MarksmanBow = 9, MarksmanBow = 9,
MarksmanCrossbow = 10, MarksmanCrossbow = 10,
MarksmanThrown = 11, MarksmanThrown = 11,
Arrow = 12, Arrow = 12,
Bolt = 13 Bolt = 13
}; };
enum Flags enum Flags
{ {
Magical = 0x01, Magical = 0x01,
Silver = 0x02 Silver = 0x02
}; };
#pragma pack(push) #pragma pack(push)

View file

@ -241,7 +241,7 @@ namespace ESMS
struct ciLessBoost : std::binary_function<std::string, std::string, bool> struct ciLessBoost : std::binary_function<std::string, std::string, bool>
{ {
bool operator() (const std::string & s1, const std::string & s2) const { bool operator() (const std::string & s1, const std::string & s2) const {
//case insensitive version of is_less //case insensitive version of is_less
return lexicographical_compare(s1, s2, is_iless()); return lexicographical_compare(s1, s2, is_iless());
} }
}; };

View file

@ -333,7 +333,7 @@ void NIFLoader::findRealTexture(String &texName)
// mesh. // mesh.
void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std::list<VertexBoneAssignment> &vertexBoneAssignments) void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std::list<VertexBoneAssignment> &vertexBoneAssignments)
{ {
// cout << "s:" << shape << "\n"; // cout << "s:" << shape << "\n";
NiTriShapeData *data = shape->data.getPtr(); NiTriShapeData *data = shape->data.getPtr();
SubMesh *sub = mesh->createSubMesh(shape->name.toString()); SubMesh *sub = mesh->createSubMesh(shape->name.toString());
@ -426,7 +426,7 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
for (std::list<VertexBoneAssignment>::iterator it = vertexBoneAssignments.begin(); for (std::list<VertexBoneAssignment>::iterator it = vertexBoneAssignments.begin();
it != vertexBoneAssignments.end(); it++) it != vertexBoneAssignments.end(); it++)
{ {
sub->addBoneAssignment(*it); sub->addBoneAssignment(*it);
} }
} }
@ -476,8 +476,8 @@ static void vectorMul(const Matrix &A, float *C)
void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bounds) void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bounds)
{ {
//if( MWClass::Npc.isChest) //if( MWClass::Npc.isChest)
//cout << "t:" << shape << "\n"; //cout << "t:" << shape << "\n";
assert(shape != NULL); assert(shape != NULL);
// Interpret flags // Interpret flags
@ -727,9 +727,9 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
void NIFLoader::handleNode(Nif::Node *node, int flags, void NIFLoader::handleNode(Nif::Node *node, int flags,
const Transformation *trafo, BoundsFinder &bounds, Bone *parentBone) const Transformation *trafo, BoundsFinder &bounds, Bone *parentBone)
{ {
stack++; stack++;
//if( MWClass::isChest) //if( MWClass::isChest)
// cout << "u:" << node << "\n"; // cout << "u:" << node << "\n";
// Accumulate the flags from all the child nodes. This works for all // Accumulate the flags from all the child nodes. This works for all
// the flags we currently use, at least. // the flags we currently use, at least.
flags |= node->flags; flags |= node->flags;
@ -779,8 +779,8 @@ void NIFLoader::handleNode(Nif::Node *node, int flags,
if (!skel.isNull()) //if there is a skeleton if (!skel.isNull()) //if there is a skeleton
{ {
std::string name = node->name.toString(); std::string name = node->name.toString();
//if (isBeast && isChest) //if (isBeast && isChest)
// std::cout << "NAME: " << name << "\n"; // std::cout << "NAME: " << name << "\n";
// Quick-n-dirty workaround for the fact that several // Quick-n-dirty workaround for the fact that several
// bones may have the same name. // bones may have the same name.
if(!skel->hasBone(name)) if(!skel->hasBone(name))
@ -823,12 +823,12 @@ void NIFLoader::handleNode(Nif::Node *node, int flags,
{ {
NodeList &list = ((NiNode*)node)->children; NodeList &list = ((NiNode*)node)->children;
int n = list.length(); int n = list.length();
int i = 0; int i = 0;
if(isHands){ if(isHands){
//cout << "NumberOfNs: " << n << "Stack:" << stack << "\n"; //cout << "NumberOfNs: " << n << "Stack:" << stack << "\n";
//if(stack == 3) //if(stack == 3)
//n=0; //n=0;
} }
for (; i<n; i++) for (; i<n; i++)
{ {
@ -837,185 +837,185 @@ void NIFLoader::handleNode(Nif::Node *node, int flags,
} }
} }
else if (node->recType == RC_NiTriShape) else if (node->recType == RC_NiTriShape)
{ {
// For shapes // For shapes
/*For Beast Skins, Shape Bone Names /*For Beast Skins, Shape Bone Names
Tri Left Foot Tri Left Foot
Tri Right Foot Tri Right Foot
Tri Tail Tri Tail
Tri Chest Tri Chest
*/ */
if((isChest && stack < 10 ) || (isHands && counter < 3) || !(isChest || isHands)){ //(isBeast && isChest && stack < 10 && counter == skincounter ) if((isChest && stack < 10 ) || (isHands && counter < 3) || !(isChest || isHands)){ //(isBeast && isChest && stack < 10 && counter == skincounter )
std::string name = node->name.toString(); std::string name = node->name.toString();
//if (isChest) //if (isChest)
//std::cout << "NAME: " << name << "\n"; //std::cout << "NAME: " << name << "\n";
if(isChest && isBeast && skincounter == 0 && name.compare("Tri Chest") == 0){ if(isChest && isBeast && skincounter == 0 && name.compare("Tri Chest") == 0){
//std::cout <<"BEASTCHEST1\n"; //std::cout <<"BEASTCHEST1\n";
handleNiTriShape(dynamic_cast<NiTriShape*>(node), flags, bounds); handleNiTriShape(dynamic_cast<NiTriShape*>(node), flags, bounds);
skincounter++; skincounter++;
} }
else if(isChest && isBeast && skincounter == 1 && name.compare("Tri Tail") == 0){ else if(isChest && isBeast && skincounter == 1 && name.compare("Tri Tail") == 0){
//std::cout <<"BEASTCHEST2\n"; //std::cout <<"BEASTCHEST2\n";
handleNiTriShape(dynamic_cast<NiTriShape*>(node), flags, bounds); handleNiTriShape(dynamic_cast<NiTriShape*>(node), flags, bounds);
skincounter++; skincounter++;
} }
else if(isChest && isBeast && skincounter == 2 && name.compare("Tri Left Foot") == 0){ else if(isChest && isBeast && skincounter == 2 && name.compare("Tri Left Foot") == 0){
//std::cout <<"BEASTCHEST3\n"; //std::cout <<"BEASTCHEST3\n";
handleNiTriShape(dynamic_cast<NiTriShape*>(node), flags, bounds); handleNiTriShape(dynamic_cast<NiTriShape*>(node), flags, bounds);
skincounter=1000; skincounter=1000;
} }
else if (!isChest || !isBeast) else if (!isChest || !isBeast)
{ {
handleNiTriShape(dynamic_cast<NiTriShape*>(node), flags, bounds); handleNiTriShape(dynamic_cast<NiTriShape*>(node), flags, bounds);
} }
//if(isBeast && isChest) //if(isBeast && isChest)
//cout << "Handling Shape, Stack " << stack <<"\n"; //cout << "Handling Shape, Stack " << stack <<"\n";
counter++; counter++;
} }
/*if(isHands){ /*if(isHands){
//cout << "Handling Shape, Stack " << stack <<"\n"; //cout << "Handling Shape, Stack " << stack <<"\n";
counter++; counter++;
}*/ }*/
} }
stack--; stack--;
} }
void NIFLoader::loadResource(Resource *resource) void NIFLoader::loadResource(Resource *resource)
{ {
if(skincounter == 1000) if(skincounter == 1000)
skincounter = 0; skincounter = 0;
stack = 0; stack = 0;
counter = 0; counter = 0;
std::string name = resource->getName(); std::string name = resource->getName();
if(resourceName.compare(name) != 0) if(resourceName.compare(name) != 0)
{ {
skincounter = 0; skincounter = 0;
resourceName = name; resourceName = name;
} }
//std::cout <<"NAME:" << name; //std::cout <<"NAME:" << name;
//if(name.length() >= 20) //if(name.length() >= 20)
// {std::string split = name.substr(name.length() - 20, 20); // {std::string split = name.substr(name.length() - 20, 20);
//if(name == //if(name ==
//std::cout <<"NAME:" << name << "LEN: " << name.length() << "\n"; //std::cout <<"NAME:" << name << "LEN: " << name.length() << "\n";
const std::string test ="meshes\\b\\B_N_Dark Elf_M_Skins.NIF"; const std::string test ="meshes\\b\\B_N_Dark Elf_M_Skins.NIF";
const std::string test2 ="meshes\\b\\B_N_Dark Elf_M_Skins.nif"; const std::string test2 ="meshes\\b\\B_N_Dark Elf_M_Skins.nif";
const std::string test3 ="meshes\\b\\B_N_Redguard_F_Skins.NIF"; const std::string test3 ="meshes\\b\\B_N_Redguard_F_Skins.NIF";
const std::string test4 ="meshes\\b\\B_N_Redguard_F_Skins.nif"; const std::string test4 ="meshes\\b\\B_N_Redguard_F_Skins.nif";
const std::string test5 ="meshes\\b\\B_N_Dark Elf_F_Skins.nif"; const std::string test5 ="meshes\\b\\B_N_Dark Elf_F_Skins.nif";
const std::string test6 ="meshes\\b\\B_N_Redguard_M_Skins.nif"; const std::string test6 ="meshes\\b\\B_N_Redguard_M_Skins.nif";
const std::string test7 ="meshes\\b\\B_N_Wood Elf_F_Skins.nif"; const std::string test7 ="meshes\\b\\B_N_Wood Elf_F_Skins.nif";
const std::string test8 ="meshes\\b\\B_N_Wood Elf_M_Skins.nif"; const std::string test8 ="meshes\\b\\B_N_Wood Elf_M_Skins.nif";
const std::string test9 ="meshes\\b\\B_N_Imperial_F_Skins.nif"; const std::string test9 ="meshes\\b\\B_N_Imperial_F_Skins.nif";
const std::string test10 ="meshes\\b\\B_N_Imperial_M_Skins.nif"; const std::string test10 ="meshes\\b\\B_N_Imperial_M_Skins.nif";
const std::string test11 ="meshes\\b\\B_N_Khajiit_F_Skins.nif"; const std::string test11 ="meshes\\b\\B_N_Khajiit_F_Skins.nif";
const std::string test12 ="meshes\\b\\B_N_Khajiit_M_Skins.nif"; const std::string test12 ="meshes\\b\\B_N_Khajiit_M_Skins.nif";
const std::string test13 ="meshes\\b\\B_N_Argonian_F_Skins.nif"; const std::string test13 ="meshes\\b\\B_N_Argonian_F_Skins.nif";
const std::string test14 ="meshes\\b\\B_N_Argonian_M_Skins.nif"; const std::string test14 ="meshes\\b\\B_N_Argonian_M_Skins.nif";
const std::string test15 ="meshes\\b\\B_N_Nord_F_Skins.nif"; const std::string test15 ="meshes\\b\\B_N_Nord_F_Skins.nif";
const std::string test16 ="meshes\\b\\B_N_Nord_M_Skins.nif"; const std::string test16 ="meshes\\b\\B_N_Nord_M_Skins.nif";
const std::string test17 ="meshes\\b\\B_N_Imperial_F_Skins.nif"; const std::string test17 ="meshes\\b\\B_N_Imperial_F_Skins.nif";
const std::string test18 ="meshes\\b\\B_N_Imperial_M_Skins.nif"; const std::string test18 ="meshes\\b\\B_N_Imperial_M_Skins.nif";
const std::string test19 ="meshes\\b\\B_N_Orc_F_Skins.nif"; const std::string test19 ="meshes\\b\\B_N_Orc_F_Skins.nif";
const std::string test20 ="meshes\\b\\B_N_Orc_M_Skins.nif"; const std::string test20 ="meshes\\b\\B_N_Orc_M_Skins.nif";
const std::string test21 ="meshes\\b\\B_N_Breton_F_Skins.nif"; const std::string test21 ="meshes\\b\\B_N_Breton_F_Skins.nif";
const std::string test22 ="meshes\\b\\B_N_Breton_M_Skins.nif"; const std::string test22 ="meshes\\b\\B_N_Breton_M_Skins.nif";
const std::string test23 ="meshes\\b\\B_N_High Elf_F_Skins.nif"; const std::string test23 ="meshes\\b\\B_N_High Elf_F_Skins.nif";
const std::string test24 ="meshes\\b\\B_N_High Elf_M_Skins.nif"; const std::string test24 ="meshes\\b\\B_N_High Elf_M_Skins.nif";
//std::cout <<"LEN1:" << test.length() << "TEST: " << test << "\n"; //std::cout <<"LEN1:" << test.length() << "TEST: " << test << "\n";
if(name.compare(test) == 0 || name.compare(test2) == 0 || name.compare(test3) == 0 || name.compare(test4) == 0 || if(name.compare(test) == 0 || name.compare(test2) == 0 || name.compare(test3) == 0 || name.compare(test4) == 0 ||
name.compare(test5) == 0 || name.compare(test6) == 0 || name.compare(test7) == 0 || name.compare(test8) == 0 || name.compare(test9) == 0 || name.compare(test5) == 0 || name.compare(test6) == 0 || name.compare(test7) == 0 || name.compare(test8) == 0 || name.compare(test9) == 0 ||
name.compare(test10) == 0 || name.compare(test11) == 0 || name.compare(test12) == 0 || name.compare(test13) == 0 || name.compare(test10) == 0 || name.compare(test11) == 0 || name.compare(test12) == 0 || name.compare(test13) == 0 ||
name.compare(test14) == 0 || name.compare(test15) == 0 || name.compare(test16) == 0 || name.compare(test17) == 0 || name.compare(test14) == 0 || name.compare(test15) == 0 || name.compare(test16) == 0 || name.compare(test17) == 0 ||
name.compare(test18) == 0 || name.compare(test19) == 0 || name.compare(test20) == 0 || name.compare(test21) == 0 || name.compare(test18) == 0 || name.compare(test19) == 0 || name.compare(test20) == 0 || name.compare(test21) == 0 ||
name.compare(test22) == 0 || name.compare(test23) == 0 || name.compare(test24) == 0 name.compare(test22) == 0 || name.compare(test23) == 0 || name.compare(test24) == 0
){ ){
//std::cout << "Welcome Chest\n"; //std::cout << "Welcome Chest\n";
isChest = true; isChest = true;
if(name.compare(test11) == 0 || name.compare(test12) == 0 || name.compare(test13) == 0 || name.compare(test14) == 0) if(name.compare(test11) == 0 || name.compare(test12) == 0 || name.compare(test13) == 0 || name.compare(test14) == 0)
{ {
isBeast = true; isBeast = true;
//std::cout << "Welcome Beast\n"; //std::cout << "Welcome Beast\n";
} }
else else
isBeast = false; isBeast = false;
} }
else else
isChest = false; isChest = false;
const std::string hands ="meshes\\b\\B_N_Dark Elf_M_Hands.1st.NIF"; const std::string hands ="meshes\\b\\B_N_Dark Elf_M_Hands.1st.NIF";
const std::string hands2 ="meshes\\b\\B_N_Dark Elf_F_Hands.1st.NIF"; const std::string hands2 ="meshes\\b\\B_N_Dark Elf_F_Hands.1st.NIF";
const std::string hands3 ="meshes\\b\\B_N_Redguard_M_Hands.1st.nif"; const std::string hands3 ="meshes\\b\\B_N_Redguard_M_Hands.1st.nif";
const std::string hands4 ="meshes\\b\\B_N_Redguard_F_Hands.1st.nif"; const std::string hands4 ="meshes\\b\\B_N_Redguard_F_Hands.1st.nif";
const std::string hands5 ="meshes\\b\\b_n_argonian_m_hands.1st.nif"; const std::string hands5 ="meshes\\b\\b_n_argonian_m_hands.1st.nif";
const std::string hands6 ="meshes\\b\\b_n_argonian_f_hands.1st.nif"; const std::string hands6 ="meshes\\b\\b_n_argonian_f_hands.1st.nif";
const std::string hands7 ="meshes\\b\\B_N_Breton_M_Hand.1st.NIF"; const std::string hands7 ="meshes\\b\\B_N_Breton_M_Hand.1st.NIF";
const std::string hands8 ="meshes\\b\\B_N_Breton_F_Hands.1st.nif"; const std::string hands8 ="meshes\\b\\B_N_Breton_F_Hands.1st.nif";
const std::string hands9 ="meshes\\b\\B_N_High Elf_M_Hands.1st.nif"; const std::string hands9 ="meshes\\b\\B_N_High Elf_M_Hands.1st.nif";
const std::string hands10 ="meshes\\b\\B_N_High Elf_F_Hands.1st.nif"; const std::string hands10 ="meshes\\b\\B_N_High Elf_F_Hands.1st.nif";
const std::string hands11 ="meshes\\b\\B_N_Nord_M_Hands.1st.nif"; const std::string hands11 ="meshes\\b\\B_N_Nord_M_Hands.1st.nif";
const std::string hands12 ="meshes\\b\\B_N_Nord_F_Hands.1st.nif"; const std::string hands12 ="meshes\\b\\B_N_Nord_F_Hands.1st.nif";
const std::string hands13 ="meshes\\b\\b_n_khajiit_m_hands.1st.nif"; const std::string hands13 ="meshes\\b\\b_n_khajiit_m_hands.1st.nif";
const std::string hands14 ="meshes\\b\\b_n_khajiit_f_hands.1st.nif"; const std::string hands14 ="meshes\\b\\b_n_khajiit_f_hands.1st.nif";
const std::string hands15 ="meshes\\b\\B_N_Orc_M_Hands.1st.nif"; const std::string hands15 ="meshes\\b\\B_N_Orc_M_Hands.1st.nif";
const std::string hands16 ="meshes\\b\\B_N_Orc_F_Hands.1st.nif"; const std::string hands16 ="meshes\\b\\B_N_Orc_F_Hands.1st.nif";
const std::string hands17 ="meshes\\b\\B_N_Wood Elf_M_Hands.1st.nif"; const std::string hands17 ="meshes\\b\\B_N_Wood Elf_M_Hands.1st.nif";
const std::string hands18 ="meshes\\b\\B_N_Wood Elf_F_Hands.1st.nif"; const std::string hands18 ="meshes\\b\\B_N_Wood Elf_F_Hands.1st.nif";
const std::string hands19 ="meshes\\b\\B_N_Imperial_M_Hands.1st.nif"; const std::string hands19 ="meshes\\b\\B_N_Imperial_M_Hands.1st.nif";
const std::string hands20 ="meshes\\b\\B_N_Imperial_F_Hands.1st.nif"; const std::string hands20 ="meshes\\b\\B_N_Imperial_F_Hands.1st.nif";
if(name.compare(hands) == 0 || name.compare(hands2) == 0 || name.compare(hands3) == 0 || name.compare(hands4) == 0 || if(name.compare(hands) == 0 || name.compare(hands2) == 0 || name.compare(hands3) == 0 || name.compare(hands4) == 0 ||
name.compare(hands5) == 0 || name.compare(hands6) == 0 || name.compare(hands7) == 0 || name.compare(hands8) == 0 || name.compare(hands5) == 0 || name.compare(hands6) == 0 || name.compare(hands7) == 0 || name.compare(hands8) == 0 ||
name.compare(hands9) == 0 || name.compare(hands10) == 0 || name.compare(hands11) == 0 || name.compare(hands12) == 0 || name.compare(hands9) == 0 || name.compare(hands10) == 0 || name.compare(hands11) == 0 || name.compare(hands12) == 0 ||
name.compare(hands13) == 0 || name.compare(hands14) == 0 || name.compare(hands15) == 0 || name.compare(hands16) == 0 || name.compare(hands13) == 0 || name.compare(hands14) == 0 || name.compare(hands15) == 0 || name.compare(hands16) == 0 ||
name.compare(hands17) == 0 || name.compare(hands18) == 0 || name.compare(hands19) == 0 || name.compare(hands20) == 0) name.compare(hands17) == 0 || name.compare(hands18) == 0 || name.compare(hands19) == 0 || name.compare(hands20) == 0)
{ {
//std::cout << "Welcome Hands1st\n"; //std::cout << "Welcome Hands1st\n";
isHands = true; isHands = true;
isChest = false; isChest = false;
} }
else else
isHands = false; isHands = false;
/* /*
else if(name.compare(test3) == 0 || name.compare(test4) == 0) else if(name.compare(test3) == 0 || name.compare(test4) == 0)
{ {
std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n"; std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n";
isChest = true; isChest = true;
} }
else if(name.compare(test5) == 0 || name.compare(test6) == 0) else if(name.compare(test5) == 0 || name.compare(test6) == 0)
{ {
std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n"; std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n";
isChest = true; isChest = true;
} }
else if(name.compare(test7) == 0 || name.compare(test8) == 0) else if(name.compare(test7) == 0 || name.compare(test8) == 0)
{ {
std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n"; std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n";
isChest = true; isChest = true;
} }
else if(name.compare(test9) == 0 || name.compare(test10) == 0) else if(name.compare(test9) == 0 || name.compare(test10) == 0)
{ {
std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n"; std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n";
isChest = true; isChest = true;
}*/ }*/
//if(split== "Skins.NIF") //if(split== "Skins.NIF")
// std::cout << "\nSPECIAL PROPS\n"; // std::cout << "\nSPECIAL PROPS\n";
resourceName = ""; resourceName = "";
MeshManager *m = MeshManager::getSingletonPtr(); MeshManager *m = MeshManager::getSingletonPtr();
// Check if the resource already exists // Check if the resource already exists
//MeshPtr ptr = m->load(name, "custom"); //MeshPtr ptr = m->load(name, "custom");
//cout << "THISNAME: " << ptr->getName() << "\n"; //cout << "THISNAME: " << ptr->getName() << "\n";
//cout << "RESOURCE:"<< resource->getName(); //cout << "RESOURCE:"<< resource->getName();
mesh = 0; mesh = 0;
skel.setNull(); skel.setNull();
@ -1028,7 +1028,7 @@ void NIFLoader::loadResource(Resource *resource)
// Look it up // Look it up
resourceName = mesh->getName(); resourceName = mesh->getName();
//std::cout << resourceName << "\n"; //std::cout << resourceName << "\n";
if (!vfs->isFile(resourceName)) if (!vfs->isFile(resourceName))
{ {
@ -1086,50 +1086,50 @@ MeshPtr NIFLoader::load(const std::string &name,
MeshManager *m = MeshManager::getSingletonPtr(); MeshManager *m = MeshManager::getSingletonPtr();
// Check if the resource already exists // Check if the resource already exists
ResourcePtr ptr = m->getByName(name, group); ResourcePtr ptr = m->getByName(name, group);
MeshPtr resize; MeshPtr resize;
const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif"; const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif";
const std::string beast2 ="meshes\\b\\B_N_Khajiit_M_Skins.nif"; const std::string beast2 ="meshes\\b\\B_N_Khajiit_M_Skins.nif";
const std::string beast3 ="meshes\\b\\B_N_Argonian_F_Skins.nif"; const std::string beast3 ="meshes\\b\\B_N_Argonian_F_Skins.nif";
const std::string beast4 ="meshes\\b\\B_N_Argonian_M_Skins.nif"; const std::string beast4 ="meshes\\b\\B_N_Argonian_M_Skins.nif";
const std::string beasttail1 ="tail\\b\\B_N_Khajiit_F_Skins.nif"; const std::string beasttail1 ="tail\\b\\B_N_Khajiit_F_Skins.nif";
const std::string beasttail2 ="tail\\b\\B_N_Khajiit_M_Skins.nif"; const std::string beasttail2 ="tail\\b\\B_N_Khajiit_M_Skins.nif";
const std::string beasttail3 ="tail\\b\\B_N_Argonian_F_Skins.nif"; const std::string beasttail3 ="tail\\b\\B_N_Argonian_F_Skins.nif";
const std::string beasttail4 ="tail\\b\\B_N_Argonian_M_Skins.nif"; const std::string beasttail4 ="tail\\b\\B_N_Argonian_M_Skins.nif";
if (!ptr.isNull()){ if (!ptr.isNull()){
//if(pieces > 1) //if(pieces > 1)
//cout << "It exists\n"; //cout << "It exists\n";
resize = MeshPtr(ptr); resize = MeshPtr(ptr);
//resize->load(); //resize->load();
//resize->reload(); //resize->reload();
} }
else // Nope, create a new one. else // Nope, create a new one.
{ {
resize = MeshManager::getSingleton().createManual(name, group, NIFLoader::getSingletonPtr()); resize = MeshManager::getSingleton().createManual(name, group, NIFLoader::getSingletonPtr());
//cout <<"EXISTING" << name << "\n"; //cout <<"EXISTING" << name << "\n";
//if(pieces > 1) //if(pieces > 1)
//cout << "Creating it\n"; //cout << "Creating it\n";
//resize->load(); //resize->load();
//resize->reload(); //resize->reload();
//return 0; //return 0;
ResourcePtr ptr = m->getByName(name, group); ResourcePtr ptr = m->getByName(name, group);
resize = MeshPtr(ptr); resize = MeshPtr(ptr);
//NIFLoader::getSingletonPtr()-> //NIFLoader::getSingletonPtr()->
/*ResourcePtr ptr = m->getByName(name, group); /*ResourcePtr ptr = m->getByName(name, group);
if (!ptr.isNull()){ if (!ptr.isNull()){
if(pieces > 1) if(pieces > 1)
cout << "It exists\n"; cout << "It exists\n";
resize = MeshPtr(ptr);*/ resize = MeshPtr(ptr);*/
//return resize; //return resize;
} }
return resize; return resize;
} }
@ -1146,9 +1146,9 @@ MeshPtr NIFLoader::load(const std::string &name,
extern "C" void ogre_insertTexture(char* name, uint32_t width, uint32_t height, void *data) extern "C" void ogre_insertTexture(char* name, uint32_t width, uint32_t height, void *data)
{ {
TexturePtr texture = TextureManager::getSingleton().createManual( TexturePtr texture = TextureManager::getSingleton().createManual(
name, // name name, // name
"General", // group "General", // group
TEX_TYPE_2D, // type TEX_TYPE_2D, // type
width, height, // width & height width, height, // width & height
0, // number of mipmaps 0, // number of mipmaps
PF_BYTE_RGBA, // pixel format PF_BYTE_RGBA, // pixel format

View file

@ -67,13 +67,13 @@ namespace Mangle
class NIFLoader : Ogre::ManualResourceLoader class NIFLoader : Ogre::ManualResourceLoader
{ {
public: public:
static int numberOfMeshes; static int numberOfMeshes;
static NIFLoader& getSingleton(); static NIFLoader& getSingleton();
static NIFLoader* getSingletonPtr(); static NIFLoader* getSingletonPtr();
virtual void loadResource(Ogre::Resource *resource); virtual void loadResource(Ogre::Resource *resource);
static Ogre::MeshPtr load(const std::string &name, static Ogre::MeshPtr load(const std::string &name,
const std::string &group="General"); const std::string &group="General");
@ -123,14 +123,14 @@ class NIFLoader : Ogre::ManualResourceLoader
std::string resourceName; std::string resourceName;
std::string resourceGroup; std::string resourceGroup;
int skincounter; int skincounter;
bool isChest; bool isChest;
bool isBeast; bool isBeast;
bool isHands; bool isHands;
bool isFeet; bool isFeet;
int counter; int counter;
int numbers; int numbers;
int stack; int stack;
// pointer to the ogre mesh which is currently build // pointer to the ogre mesh which is currently build

View file

@ -29,7 +29,7 @@ struct MyMeshLoader : ManualResourceLoader
HardwareVertexBufferSharedPtr vbuf = HardwareVertexBufferSharedPtr vbuf =
HardwareBufferManager::getSingleton().createVertexBuffer( HardwareBufferManager::getSingleton().createVertexBuffer(
VertexElement::getTypeSize(VET_FLOAT3), VertexElement::getTypeSize(VET_FLOAT3),
numVerts, HardwareBuffer::HBU_STATIC_WRITE_ONLY); numVerts, HardwareBuffer::HBU_STATIC_WRITE_ONLY);
// Upload the vertex data to the card // Upload the vertex data to the card