diff --git a/apps/esmtool/esmtool_cmd.c b/apps/esmtool/esmtool_cmd.c index f7e4d2d32..d6556d9e7 100644 --- a/apps/esmtool/esmtool_cmd.c +++ b/apps/esmtool/esmtool_cmd.c @@ -354,45 +354,45 @@ struct option /* Names for the values of the `has_arg' field of `struct option'. */ #ifndef no_argument -#define no_argument 0 +#define no_argument 0 #endif #ifndef required_argument -#define required_argument 1 +#define required_argument 1 #endif #ifndef optional_argument -#define optional_argument 2 +#define optional_argument 2 #endif struct custom_getopt_data { - /* - * These have exactly the same meaning as the corresponding global variables, - * except that they are used for the reentrant versions of getopt. - */ - int custom_optind; - int custom_opterr; - int custom_optopt; - char *custom_optarg; - - /* True if the internal members have been initialized. */ - int initialized; - - /* - * 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 - * we left off. If this is zero, or a null string, it means resume the scan by - * advancing to the next ARGV-element. - */ - char *nextchar; - - /* - * 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 - * the index after the last of them. - */ - int first_nonopt; - int last_nonopt; + /* + * These have exactly the same meaning as the corresponding global variables, + * except that they are used for the reentrant versions of getopt. + */ + int custom_optind; + int custom_opterr; + int custom_optopt; + char *custom_optarg; + + /* True if the internal members have been initialized. */ + int initialized; + + /* + * 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 + * we left off. If this is zero, or a null string, it means resume the scan by + * advancing to the next ARGV-element. + */ + char *nextchar; + + /* + * 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 + * the index after the last of them. + */ + int first_nonopt; + int last_nonopt; }; /* @@ -448,137 +448,137 @@ static int custom_optopt = '?'; */ static void exchange(char **argv, struct custom_getopt_data *d) { - int bottom = d->first_nonopt; - int middle = d->last_nonopt; - int top = d->custom_optind; - char *tem; - - /* - * Exchange the shorter segment with the far end of the longer segment. - * That puts the shorter segment into the right place. It leaves the - * longer segment in the right place overall, but it consists of two - * parts that need to be swapped next. - */ - while (top > middle && middle > bottom) { - if (top - middle > middle - bottom) { - /* Bottom segment is the short one. */ - int len = middle - bottom; - int i; - - /* Swap it with the top part of the top segment. */ - for (i = 0; i < len; i++) { - tem = argv[bottom + i]; - argv[bottom + i] = - argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - } - /* Exclude the moved bottom segment from further swapping. */ - top -= len; - } else { - /* Top segment is the short one. */ - int len = top - middle; - int i; - - /* Swap it with the bottom part of the bottom segment. */ - for (i = 0; i < len; i++) { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - } - /* Exclude the moved top segment from further swapping. */ - bottom += len; - } - } - /* Update records for the slots the non-options now occupy. */ - d->first_nonopt += (d->custom_optind - d->last_nonopt); - d->last_nonopt = d->custom_optind; + int bottom = d->first_nonopt; + int middle = d->last_nonopt; + int top = d->custom_optind; + char *tem; + + /* + * Exchange the shorter segment with the far end of the longer segment. + * That puts the shorter segment into the right place. It leaves the + * longer segment in the right place overall, but it consists of two + * parts that need to be swapped next. + */ + while (top > middle && middle > bottom) { + if (top - middle > middle - bottom) { + /* Bottom segment is the short one. */ + int len = middle - bottom; + int i; + + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) { + tem = argv[bottom + i]; + argv[bottom + i] = + argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } else { + /* Top segment is the short one. */ + int len = top - middle; + int i; + + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } + /* Update records for the slots the non-options now occupy. */ + d->first_nonopt += (d->custom_optind - d->last_nonopt); + d->last_nonopt = d->custom_optind; } /* Initialize the internal data when the first call is made. */ static void custom_getopt_initialize(struct custom_getopt_data *d) { - /* - * Start processing options with ARGV-element 1 (since ARGV-element 0 - * is the program name); the sequence of previously skipped non-option - * ARGV-elements is empty. - */ - d->first_nonopt = d->last_nonopt = d->custom_optind; - d->nextchar = NULL; - d->initialized = 1; + /* + * Start processing options with ARGV-element 1 (since ARGV-element 0 + * is the program name); the sequence of previously skipped non-option + * ARGV-elements is empty. + */ + d->first_nonopt = d->last_nonopt = d->custom_optind; + d->nextchar = NULL; + d->initialized = 1; } #define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0') /* return: zero: continue, nonzero: return given value to user */ 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 - * moved back by the user (who may also have changed the arguments). - */ - if (d->last_nonopt > d->custom_optind) - d->last_nonopt = d->custom_optind; - if (d->first_nonopt > d->custom_optind) - d->first_nonopt = d->custom_optind; - /* - * If we have just processed some options following some - * non-options, exchange them so that the options come first. - */ - if (d->first_nonopt != d->last_nonopt && - d->last_nonopt != d->custom_optind) - exchange((char **) argv, d); - else if (d->last_nonopt != d->custom_optind) - d->first_nonopt = d->custom_optind; - /* - * Skip any additional non-options and extend the range of - * non-options previously skipped. - */ - while (d->custom_optind < argc && NONOPTION_P) - d->custom_optind++; - d->last_nonopt = d->custom_optind; - /* - * The special ARGV-element `--' means premature end of options. Skip - * 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. - */ - if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) { - d->custom_optind++; - if (d->first_nonopt != d->last_nonopt - && d->last_nonopt != d->custom_optind) - exchange((char **) argv, d); - else if (d->first_nonopt == d->last_nonopt) - d->first_nonopt = d->custom_optind; - d->last_nonopt = argc; - d->custom_optind = argc; - } - /* - * If we have done all the ARGV-elements, stop the scan and back over - * any non-options that we skipped and permuted. - */ - if (d->custom_optind == argc) { - /* - * Set the next-arg-index to point at the non-options that we - * previously skipped, so the caller will digest them. - */ - if (d->first_nonopt != d->last_nonopt) - d->custom_optind = d->first_nonopt; - return -1; - } - /* - * 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. - */ - if (NONOPTION_P) { - d->custom_optarg = argv[d->custom_optind++]; - return 1; - } - /* - * We have found another option-ARGV-element. Skip the initial - * punctuation. - */ - d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-')); - return 0; + /* + * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been + * moved back by the user (who may also have changed the arguments). + */ + if (d->last_nonopt > d->custom_optind) + d->last_nonopt = d->custom_optind; + if (d->first_nonopt > d->custom_optind) + d->first_nonopt = d->custom_optind; + /* + * If we have just processed some options following some + * non-options, exchange them so that the options come first. + */ + if (d->first_nonopt != d->last_nonopt && + d->last_nonopt != d->custom_optind) + exchange((char **) argv, d); + else if (d->last_nonopt != d->custom_optind) + d->first_nonopt = d->custom_optind; + /* + * Skip any additional non-options and extend the range of + * non-options previously skipped. + */ + while (d->custom_optind < argc && NONOPTION_P) + d->custom_optind++; + d->last_nonopt = d->custom_optind; + /* + * The special ARGV-element `--' means premature end of options. Skip + * 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. + */ + if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) { + d->custom_optind++; + if (d->first_nonopt != d->last_nonopt + && d->last_nonopt != d->custom_optind) + exchange((char **) argv, d); + else if (d->first_nonopt == d->last_nonopt) + d->first_nonopt = d->custom_optind; + d->last_nonopt = argc; + d->custom_optind = argc; + } + /* + * If we have done all the ARGV-elements, stop the scan and back over + * any non-options that we skipped and permuted. + */ + if (d->custom_optind == argc) { + /* + * Set the next-arg-index to point at the non-options that we + * previously skipped, so the caller will digest them. + */ + if (d->first_nonopt != d->last_nonopt) + d->custom_optind = d->first_nonopt; + return -1; + } + /* + * 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. + */ + if (NONOPTION_P) { + d->custom_optarg = argv[d->custom_optind++]; + return 1; + } + /* + * We have found another option-ARGV-element. Skip the initial + * punctuation. + */ + d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-')); + 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, - const struct option *longopts, int *longind, - int print_errors, struct custom_getopt_data *d) + const struct option *longopts, int *longind, + int print_errors, struct custom_getopt_data *d) { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = -1; - int option_index; - - for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match or abbreviated matches */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) { - if ((unsigned int) (nameend - d->nextchar) - == (unsigned int) strlen(p->name)) { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } else if (pfound == NULL) { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } else if (pfound->has_arg != p->has_arg - || pfound->flag != p->flag - || pfound->val != p->val) - /* Second or later nonexact match found. */ - ambig = 1; - } - if (ambig && !exact) { - if (print_errors) { - fprintf(stderr, - "%s: option `%s' is ambiguous\n", - argv[0], argv[d->custom_optind]); - } - d->nextchar += strlen(d->nextchar); - d->custom_optind++; - d->custom_optopt = 0; - return '?'; - } - if (pfound) { - option_index = indfound; - d->custom_optind++; - if (*nameend) { - if (pfound->has_arg != no_argument) - d->custom_optarg = nameend + 1; - else { - if (print_errors) { - if (argv[d->custom_optind - 1][1] == '-') { - /* --option */ - fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - } else { - /* +option or -option */ - fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n", - argv[0], argv[d->custom_optind - 1][0], pfound->name); - } - - } - d->nextchar += strlen(d->nextchar); - d->custom_optopt = pfound->val; - return '?'; - } - } else if (pfound->has_arg == required_argument) { - if (d->custom_optind < argc) - d->custom_optarg = argv[d->custom_optind++]; - else { - if (print_errors) { - fprintf(stderr, - "%s: option `%s' requires an argument\n", - argv[0], - argv[d->custom_optind - 1]); - } - d->nextchar += strlen(d->nextchar); - d->custom_optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - d->nextchar += strlen(d->nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - /* - * 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 - * it's an error. Otherwise interpret it as a short option. - */ - if (print_errors) { - if (argv[d->custom_optind][1] == '-') { - /* --option */ - fprintf(stderr, - "%s: unrecognized option `--%s'\n", - argv[0], d->nextchar); - } else { - /* +option or -option */ - fprintf(stderr, - "%s: unrecognized option `%c%s'\n", - argv[0], argv[d->custom_optind][0], - d->nextchar); - } - } - d->nextchar = (char *) ""; - d->custom_optind++; - d->custom_optopt = 0; - return '?'; + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = -1; + int option_index; + + for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match or abbreviated matches */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) { + if ((unsigned int) (nameend - d->nextchar) + == (unsigned int) strlen(p->name)) { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } else if (pfound == NULL) { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } else if (pfound->has_arg != p->has_arg + || pfound->flag != p->flag + || pfound->val != p->val) + /* Second or later nonexact match found. */ + ambig = 1; + } + if (ambig && !exact) { + if (print_errors) { + fprintf(stderr, + "%s: option `%s' is ambiguous\n", + argv[0], argv[d->custom_optind]); + } + d->nextchar += strlen(d->nextchar); + d->custom_optind++; + d->custom_optopt = 0; + return '?'; + } + if (pfound) { + option_index = indfound; + d->custom_optind++; + if (*nameend) { + if (pfound->has_arg != no_argument) + d->custom_optarg = nameend + 1; + else { + if (print_errors) { + if (argv[d->custom_optind - 1][1] == '-') { + /* --option */ + fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n", + argv[0], pfound->name); + } else { + /* +option or -option */ + fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n", + argv[0], argv[d->custom_optind - 1][0], pfound->name); + } + + } + d->nextchar += strlen(d->nextchar); + d->custom_optopt = pfound->val; + return '?'; + } + } else if (pfound->has_arg == required_argument) { + if (d->custom_optind < argc) + d->custom_optarg = argv[d->custom_optind++]; + else { + if (print_errors) { + fprintf(stderr, + "%s: option `%s' requires an argument\n", + argv[0], + argv[d->custom_optind - 1]); + } + d->nextchar += strlen(d->nextchar); + d->custom_optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + d->nextchar += strlen(d->nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + /* + * 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 + * it's an error. Otherwise interpret it as a short option. + */ + if (print_errors) { + if (argv[d->custom_optind][1] == '-') { + /* --option */ + fprintf(stderr, + "%s: unrecognized option `--%s'\n", + argv[0], d->nextchar); + } else { + /* +option or -option */ + fprintf(stderr, + "%s: unrecognized option `%c%s'\n", + argv[0], argv[d->custom_optind][0], + d->nextchar); + } + } + d->nextchar = (char *) ""; + d->custom_optind++; + d->custom_optopt = 0; + return '?'; } 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++; - const char *temp = strchr(optstring, c); - - /* Increment `custom_optind' when we start to process its last character. */ - if (*d->nextchar == '\0') - ++d->custom_optind; - if (!temp || c == ':') { - if (print_errors) - fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c); - - d->custom_optopt = c; - return '?'; - } - if (temp[1] == ':') { - if (temp[2] == ':') { - /* This is an option that accepts an argument optionally. */ - if (*d->nextchar != '\0') { - d->custom_optarg = d->nextchar; - d->custom_optind++; - } else - d->custom_optarg = NULL; - d->nextchar = NULL; - } else { - /* This is an option that requires an argument. */ - if (*d->nextchar != '\0') { - d->custom_optarg = d->nextchar; - /* - * If we end this ARGV-element by taking the - * rest as an arg, we must advance to the next - * element now. - */ - d->custom_optind++; - } else if (d->custom_optind == argc) { - if (print_errors) { - fprintf(stderr, - "%s: option requires an argument -- %c\n", - argv[0], c); - } - d->custom_optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } else - /* - * We already incremented `custom_optind' once; - * increment it again when taking next ARGV-elt - * as argument. - */ - d->custom_optarg = argv[d->custom_optind++]; - d->nextchar = NULL; - } - } - return c; + char c = *d->nextchar++; + const char *temp = strchr(optstring, c); + + /* Increment `custom_optind' when we start to process its last character. */ + if (*d->nextchar == '\0') + ++d->custom_optind; + if (!temp || c == ':') { + if (print_errors) + fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c); + + d->custom_optopt = c; + return '?'; + } + if (temp[1] == ':') { + if (temp[2] == ':') { + /* This is an option that accepts an argument optionally. */ + if (*d->nextchar != '\0') { + d->custom_optarg = d->nextchar; + d->custom_optind++; + } else + d->custom_optarg = NULL; + d->nextchar = NULL; + } else { + /* This is an option that requires an argument. */ + if (*d->nextchar != '\0') { + d->custom_optarg = d->nextchar; + /* + * If we end this ARGV-element by taking the + * rest as an arg, we must advance to the next + * element now. + */ + d->custom_optind++; + } else if (d->custom_optind == argc) { + if (print_errors) { + fprintf(stderr, + "%s: option requires an argument -- %c\n", + argv[0], c); + } + d->custom_optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } else + /* + * We already incremented `custom_optind' once; + * increment it again when taking next ARGV-elt + * as argument. + */ + d->custom_optarg = argv[d->custom_optind++]; + d->nextchar = NULL; + } + } + 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, - const struct option *longopts, int *longind, - struct custom_getopt_data *d) + const struct option *longopts, int *longind, + struct custom_getopt_data *d) { - int ret, print_errors = d->custom_opterr; - - if (optstring[0] == ':') - print_errors = 0; - if (argc < 1) - return -1; - d->custom_optarg = NULL; - - /* - * This is a big difference with GNU getopt, since optind == 0 - * means initialization while here 1 means first call. - */ - if (d->custom_optind == 0 || !d->initialized) { - if (d->custom_optind == 0) - d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */ - custom_getopt_initialize(d); - } - if (d->nextchar == NULL || *d->nextchar == '\0') { - ret = shuffle_argv(argc, argv, longopts, d); - if (ret) - return ret; - } - if (longopts && (argv[d->custom_optind][1] == '-' )) - return check_long_opt(argc, argv, optstring, longopts, - longind, print_errors, d); - return check_short_opt(argc, argv, optstring, print_errors, d); + int ret, print_errors = d->custom_opterr; + + if (optstring[0] == ':') + print_errors = 0; + if (argc < 1) + return -1; + d->custom_optarg = NULL; + + /* + * This is a big difference with GNU getopt, since optind == 0 + * means initialization while here 1 means first call. + */ + if (d->custom_optind == 0 || !d->initialized) { + if (d->custom_optind == 0) + d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */ + custom_getopt_initialize(d); + } + if (d->nextchar == NULL || *d->nextchar == '\0') { + ret = shuffle_argv(argc, argv, longopts, d); + if (ret) + return ret; + } + if (longopts && (argv[d->custom_optind][1] == '-' )) + return check_long_opt(argc, argv, optstring, longopts, + longind, 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, - const struct option *longopts, int *longind) + const struct option *longopts, int *longind) { - int result; - /* Keep a global copy of all internal members of d */ - static struct custom_getopt_data d; - - d.custom_optind = custom_optind; - d.custom_opterr = custom_opterr; - result = getopt_internal_r(argc, argv, optstring, longopts, - longind, &d); - custom_optind = d.custom_optind; - custom_optarg = d.custom_optarg; - custom_optopt = d.custom_optopt; - return result; + int result; + /* Keep a global copy of all internal members of d */ + static struct custom_getopt_data d; + + d.custom_optind = custom_optind; + d.custom_opterr = custom_opterr; + result = getopt_internal_r(argc, argv, optstring, longopts, + longind, &d); + custom_optind = d.custom_optind; + custom_optarg = d.custom_optarg; + custom_optopt = d.custom_optopt; + return result; } 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, - opt_index); + return custom_getopt_internal(argc, argv, options, long_options, + opt_index); } @@ -989,7 +989,7 @@ cmdline_parser_internal ( int argc, char * const *argv, struct gengetopt_args_info *args_info, 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; struct gengetopt_args_info local_args_info; @@ -1026,11 +1026,11 @@ cmdline_parser_internal ( int option_index = 0; static struct option long_options[] = { - { "help", 0, NULL, 'h' }, - { "version", 0, NULL, 'V' }, - { "raw", 0, NULL, 'r' }, - { "quiet", 0, NULL, 'q' }, - { "loadcells", 0, NULL, 'C' }, + { "help", 0, NULL, 'h' }, + { "version", 0, NULL, 'V' }, + { "raw", 0, NULL, 'r' }, + { "quiet", 0, NULL, 'q' }, + { "loadcells", 0, NULL, 'C' }, { 0, 0, 0, 0 } }; @@ -1046,21 +1046,21 @@ cmdline_parser_internal ( opterr = custom_opterr; optopt = custom_optopt; - if (c == -1) break; /* Exit from `while (1)' loop. */ + if (c == -1) break; /* Exit from `while (1)' loop. */ switch (c) { - case 'h': /* Print help and exit. */ + case 'h': /* Print help and exit. */ cmdline_parser_print_help (); cmdline_parser_free (&local_args_info); exit (EXIT_SUCCESS); - case 'V': /* Print version and exit. */ + case 'V': /* Print version and exit. */ cmdline_parser_print_version (); cmdline_parser_free (&local_args_info); 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 , @@ -1072,7 +1072,7 @@ cmdline_parser_internal ( goto failure; 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 , @@ -1084,7 +1084,7 @@ cmdline_parser_internal ( goto failure; break; - case 'C': /* Browse through contents of all cells.. */ + case 'C': /* Browse through contents of all cells.. */ if (update_arg( 0 , @@ -1097,12 +1097,12 @@ cmdline_parser_internal ( break; - case 0: /* Long option with no short option */ - case '?': /* Invalid option. */ + case 0: /* Long option with no short option */ + case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ 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 : "")); abort (); } /* switch */ diff --git a/apps/esmtool/esmtool_cmd.h b/apps/esmtool/esmtool_cmd.h index c2561c00a..8c420c189 100644 --- a/apps/esmtool/esmtool_cmd.h +++ b/apps/esmtool/esmtool_cmd.h @@ -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 *loadcells_help; /**< @brief Browse through contents of all cells. help description. */ - unsigned int help_given ; /**< @brief Whether help was given. */ - unsigned int version_given ; /**< @brief Whether version was given. */ - unsigned int raw_given ; /**< @brief Whether raw was given. */ - unsigned int quiet_given ; /**< @brief Whether quiet was given. */ - unsigned int loadcells_given ; /**< @brief Whether loadcells was given. */ + unsigned int help_given ; /**< @brief Whether help was given. */ + unsigned int version_given ; /**< @brief Whether version was given. */ + unsigned int raw_given ; /**< @brief Whether raw was given. */ + unsigned int quiet_given ; /**< @brief Whether quiet was given. */ + unsigned int loadcells_given ; /**< @brief Whether loadcells was given. */ char **inputs ; /**< @brief unamed options (options without names) */ unsigned inputs_num ; /**< @brief unamed options number */ diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 9e14c119b..61482279e 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -67,73 +67,73 @@ void OMW::Engine::executeLocalScripts() bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) { - if(! (mEnvironment.mSoundManager->isMusicPlaying())) - { - // Play some good 'ol tunes - mEnvironment.mSoundManager->startRandomTitle(); - } - - std::string effect; - - - - MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell(); - //If the region has changed - if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){ - timer.restart(); - if (test.name != current->cell->region) - { - total = 0; - test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region)); - } - - if(test.soundList.size() > 0) - { - std::vector::iterator soundIter = test.soundList.begin(); - //mEnvironment.mSoundManager - if(total == 0){ - while (!(soundIter == test.soundList.end())) - { - ESM::NAME32 go = soundIter->sound; - int chance = (int) soundIter->chance; - //std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; - soundIter++; - total += chance; - } - } - - srand ( time(NULL) ); - int r = rand() % total; //old random code - int pos = 0; - soundIter = test.soundList.begin(); - while (!(soundIter == test.soundList.end())) - { - const ESM::NAME32 go = soundIter->sound; - int chance = (int) soundIter->chance; - //std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; - soundIter++; - if( r - pos < chance) - { - effect = go.name; - //play sound - std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; - mEnvironment.mSoundManager->playSound(effect, 20.0, 1.0); - - break; - - } - pos += chance; - } - } - - //mEnvironment.mSoundManager->playSound(effect, 1.0, 1.0); - //printf("REGION: %s\n", test.name); - - } - else if(current->cell->data.flags & current->cell->Interior) - { - test.name = ""; - } + if(! (mEnvironment.mSoundManager->isMusicPlaying())) + { + // Play some good 'ol tunes + mEnvironment.mSoundManager->startRandomTitle(); + } + + std::string effect; + + + + MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell(); + //If the region has changed + if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){ + timer.restart(); + if (test.name != current->cell->region) + { + total = 0; + test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region)); + } + + if(test.soundList.size() > 0) + { + std::vector::iterator soundIter = test.soundList.begin(); + //mEnvironment.mSoundManager + if(total == 0){ + while (!(soundIter == test.soundList.end())) + { + ESM::NAME32 go = soundIter->sound; + int chance = (int) soundIter->chance; + //std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; + soundIter++; + total += chance; + } + } + + srand ( time(NULL) ); + int r = rand() % total; //old random code + int pos = 0; + soundIter = test.soundList.begin(); + while (!(soundIter == test.soundList.end())) + { + const ESM::NAME32 go = soundIter->sound; + int chance = (int) soundIter->chance; + //std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; + soundIter++; + if( r - pos < chance) + { + effect = go.name; + //play sound + std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; + mEnvironment.mSoundManager->playSound(effect, 20.0, 1.0); + + break; + + } + pos += chance; + } + } + + //mEnvironment.mSoundManager->playSound(effect, 1.0, 1.0); + //printf("REGION: %s\n", test.name); + + } + else if(current->cell->data.flags & current->cell->Interior) + { + test.name = ""; + } try { @@ -184,7 +184,7 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) { std::cerr << "Error in framelistener: " << e.what() << std::endl; } - //std::cout << "TESTING2"; + //std::cout << "TESTING2"; return true; } @@ -294,8 +294,8 @@ void OMW::Engine::go() assert (!mCellName.empty()); assert (!mMaster.empty()); - test.name = ""; - total = 0; + test.name = ""; + total = 0; diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 4f8f5af9c..eeefbc65d 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -55,7 +55,7 @@ namespace OMW class Engine : private Ogre::FrameListener { - //int nFiles; + //int nFiles; boost::filesystem::path mDataDir; OEngine::Render::OgreRenderer mOgre; std::string mCellName; @@ -72,8 +72,8 @@ namespace OMW Compiler::Extensions mExtensions; Compiler::Context *mScriptContext; OEngine::GUI::MyGUIManager *mGuiManager; - ESM::Region test; - boost::timer timer; + ESM::Region test; + boost::timer timer; int focusFrameCounter; static const int focusUpdateFrame = 10; diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 74508d77f..393228777 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -56,10 +56,10 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) bpo::variables_map variables; #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE - std::string configFilePath(macBundlePath() + "/Contents/MacOS/openmw.cfg"); - std::ifstream configFile (configFilePath.c_str()); + std::string configFilePath(macBundlePath() + "/Contents/MacOS/openmw.cfg"); + std::ifstream configFile (configFilePath.c_str()); #else - std::ifstream configFile ("openmw.cfg"); + std::ifstream configFile ("openmw.cfg"); #endif bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 7a50fcb2a..0d358441a 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -90,7 +90,7 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const { return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); - } + } MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) const @@ -106,7 +106,7 @@ namespace MWClass } return *ptr.getRefData().getContainerStore(); - } + } std::string Creature::getScript (const MWWorld::Ptr& ptr) const { diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index c277832ab..680265932 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -29,26 +29,26 @@ namespace MWClass void Npc::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, MWWorld::Environment& environment) const { - //Ogre::SceneNode *chest; + //Ogre::SceneNode *chest; ESMS::LiveCellRef *ref = ptr.get(); - - //Store scenenodes by npc's name + bodypart [0] , npc's name + bodypart [1] - //Ex. Fargothchest , Fargothneck + + //Store scenenodes by npc's name + bodypart [0] , npc's name + bodypart [1] + //Ex. Fargothchest , Fargothneck assert (ref->base != NULL); - std::string hairID = ref->base->hair; + std::string hairID = ref->base->hair; std::string headID = ref->base->head; - std::string npcName = ref->base->name; - //std::cout << "NPC: " << npcName << "\n"; + std::string npcName = ref->base->name; + //std::cout << "NPC: " << npcName << "\n"; //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 headModel = "meshes\\" + environment.mWorld->getStore().bodyParts.find(headID)->model; - std::string hairModel = "meshes\\" + + std::string hairModel = "meshes\\" + environment.mWorld->getStore().bodyParts.find(hairID)->model; MWRender::Rendering rendering (cellRender, ref->ref); @@ -59,200 +59,200 @@ namespace MWClass const ESM::BodyPart *bodyPart = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); - //bodyPart->model-> - Ogre::Vector3 pos = Ogre::Vector3( 20, 20, 20); - Ogre::Vector3 axis = Ogre::Vector3( 0, 0, 1); - Ogre::Radian angle = Ogre::Radian(0); - - std::string addresses[6] = {"", "", "", "","", ""}; - std::string addresses2[6] = {"", "", "", "", "", ""}; - std::string upperleft[5] = {"", "", "", "", ""}; - std::string upperright[5] = {"", "", "", "", ""}; - std::string neckandup[5] = {"", "", "","",""}; - std::string empty[6] = {"", "", "", "","", ""}; - int numbers = 0; - int uppernumbers = 0; - int neckNumbers = 0; - + //bodyPart->model-> + Ogre::Vector3 pos = Ogre::Vector3( 20, 20, 20); + Ogre::Vector3 axis = Ogre::Vector3( 0, 0, 1); + Ogre::Radian angle = Ogre::Radian(0); + + std::string addresses[6] = {"", "", "", "","", ""}; + std::string addresses2[6] = {"", "", "", "", "", ""}; + std::string upperleft[5] = {"", "", "", "", ""}; + std::string upperright[5] = {"", "", "", "", ""}; + std::string neckandup[5] = {"", "", "","",""}; + std::string empty[6] = {"", "", "", "","", ""}; + int numbers = 0; + int uppernumbers = 0; + int neckNumbers = 0; + if (bodyPart){ - + cellRender.insertMesh("meshes\\" + bodyPart->model, pos, axis, angle, npcName + "chest", addresses, numbers, true); //2 0 - addresses2[numbers] = npcName + "chest"; - addresses[numbers++] = npcName + "chest"; - upperleft[uppernumbers] = npcName + "chest"; - upperright[uppernumbers++] = npcName + "chest"; - neckandup[neckNumbers++] = npcName + "chest"; - } - //std::cout << "GETTING NPC PART"; - //Orgre::SceneNode test = cellRender.getNpcPart(); - - 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 *arm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); - 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 *ankle = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); - 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 *tail = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail"); - 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 *hand = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand.1st"); - const ESM::BodyPart *hands = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands.1st"); - - - //std::cout << "RACE" << bodyRaceID << "\n"; - - Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); - std::string upperarmpath[2] = {npcName + "chest", npcName + "upper arm"}; - + addresses2[numbers] = npcName + "chest"; + addresses[numbers++] = npcName + "chest"; + upperleft[uppernumbers] = npcName + "chest"; + upperright[uppernumbers++] = npcName + "chest"; + neckandup[neckNumbers++] = npcName + "chest"; + } + //std::cout << "GETTING NPC PART"; + //Orgre::SceneNode test = cellRender.getNpcPart(); + + 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 *arm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); + 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 *ankle = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); + 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 *tail = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail"); + 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 *hand = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand.1st"); + const ESM::BodyPart *hands = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands.1st"); + + + //std::cout << "RACE" << bodyRaceID << "\n"; + + Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); + std::string upperarmpath[2] = {npcName + "chest", npcName + "upper arm"}; + if (groin){ cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, Ogre::Radian(3.14), npcName + "groin", addresses, numbers); - addresses2[numbers] = npcName + "groin"; - addresses[numbers++] = npcName + "groin"; - } - if (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"; - } - - //addresses[1] = npcName + "groin"; - 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(0), npcName + "upper leg2", addresses2, numbers); - addresses2[numbers] = npcName + "upper leg2"; - addresses[numbers++] = npcName + "upper leg"; - cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); - } - if(knee) - { - 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.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee2", addresses2, numbers); - - addresses2[numbers] = npcName + "knee2"; - addresses[numbers++] = npcName + "knee"; - } - 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 + "ankle2", addresses2, numbers); //-1 - - addresses2[numbers] = npcName + "ankle2"; - addresses[numbers++] = npcName + "ankle"; - } - if(foot){ - if(bodyRaceID.compare("b_n_khajiit_m_") == 0) - { - feet = foot; - } - 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 + "foot2", addresses2, numbers); - addresses2[numbers] = npcName + "foot2"; - addresses[numbers++] = npcName + "foot"; - } - //cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); - } - 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 + "foot2", addresses2, numbers); - addresses2[numbers] = npcName + "foot2"; - addresses[numbers++] = npcName + "foot"; - //cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); - } - - - if (arm){ - //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.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); - upperleft[uppernumbers] = npcName + "upper arm"; - upperright[uppernumbers++] = npcName + "upper arm2"; - 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); - } - - if (forearm) - { - //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 + "forearm2", upperright, uppernumbers); - upperleft[uppernumbers] = npcName + "forearm"; - upperright[uppernumbers++] = npcName + "forearm2"; - } - //else - // std::cout << npcName << "has no forearm"; - if (wrist) - { - 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 + "forearm2", upperright, uppernumbers); - upperleft[uppernumbers] = npcName + "forearm"; - 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 + "wrist2", upperright, uppernumbers); - upperleft[uppernumbers] = npcName + "wrist"; - upperright[uppernumbers++] = npcName + "wrist2"; - } - - - if(hand) - { - //std::cout << "WE FOUND A HAND\n"; - //-50, 0, -120 - //std::cout << "WE FOUND HANDS\n"; - 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) - pass = "b\\B_N_Dark Elf_M_Hands.1st.NIF"; - else - 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 + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120 - upperleft[uppernumbers] = npcName + "hand"; - upperright[uppernumbers++] = npcName + "hand2"; - //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), upperright, uppernumbers); - } - if(hands) - { - std::string pass; - 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"; - 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"; - else - 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\\" + 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 - upperleft[uppernumbers] = npcName + "hand"; - upperright[uppernumbers++] = npcName + "hand2"; - cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); - cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers); - } - - //neck will reset chest counter - if(neck) - { - cellRender.insertMesh ("meshes\\" + neck->model, Ogre::Vector3( 0, 0, 120), axis, Ogre::Radian(3.14), npcName + "neck", neckandup, neckNumbers); - neckandup[neckNumbers++] = npcName + "neck"; - } - cellRender.insertMesh (headModel, Ogre::Vector3( 0, 0, 5), axis, Ogre::Radian(0), npcName + "head", neckandup, neckNumbers); - neckandup[neckNumbers++] = npcName + "head"; - cellRender.insertMesh (hairModel, Ogre::Vector3( 0, -1, 0), axis, Ogre::Radian(0), npcName + "hair", neckandup, neckNumbers); - ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); - - } + addresses2[numbers] = npcName + "groin"; + addresses[numbers++] = npcName + "groin"; + } + if (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"; + } + + //addresses[1] = npcName + "groin"; + 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(0), npcName + "upper leg2", addresses2, numbers); + addresses2[numbers] = npcName + "upper leg2"; + addresses[numbers++] = npcName + "upper leg"; + cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); + } + if(knee) + { + 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.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee2", addresses2, numbers); + + addresses2[numbers] = npcName + "knee2"; + addresses[numbers++] = npcName + "knee"; + } + 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 + "ankle2", addresses2, numbers); //-1 + + addresses2[numbers] = npcName + "ankle2"; + addresses[numbers++] = npcName + "ankle"; + } + if(foot){ + if(bodyRaceID.compare("b_n_khajiit_m_") == 0) + { + feet = foot; + } + 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 + "foot2", addresses2, numbers); + addresses2[numbers] = npcName + "foot2"; + addresses[numbers++] = npcName + "foot"; + } + //cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); + } + 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 + "foot2", addresses2, numbers); + addresses2[numbers] = npcName + "foot2"; + addresses[numbers++] = npcName + "foot"; + //cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); + } + + + if (arm){ + //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.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); + upperleft[uppernumbers] = npcName + "upper arm"; + upperright[uppernumbers++] = npcName + "upper arm2"; + 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); + } + + if (forearm) + { + //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 + "forearm2", upperright, uppernumbers); + upperleft[uppernumbers] = npcName + "forearm"; + upperright[uppernumbers++] = npcName + "forearm2"; + } + //else + // std::cout << npcName << "has no forearm"; + if (wrist) + { + 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 + "forearm2", upperright, uppernumbers); + upperleft[uppernumbers] = npcName + "forearm"; + 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 + "wrist2", upperright, uppernumbers); + upperleft[uppernumbers] = npcName + "wrist"; + upperright[uppernumbers++] = npcName + "wrist2"; + } + + + if(hand) + { + //std::cout << "WE FOUND A HAND\n"; + //-50, 0, -120 + //std::cout << "WE FOUND HANDS\n"; + 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) + pass = "b\\B_N_Dark Elf_M_Hands.1st.NIF"; + else + 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 + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120 + upperleft[uppernumbers] = npcName + "hand"; + upperright[uppernumbers++] = npcName + "hand2"; + //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), upperright, uppernumbers); + } + if(hands) + { + std::string pass; + 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"; + 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"; + else + 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\\" + 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 + upperleft[uppernumbers] = npcName + "hand"; + upperright[uppernumbers++] = npcName + "hand2"; + cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); + cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers); + } + + //neck will reset chest counter + if(neck) + { + cellRender.insertMesh ("meshes\\" + neck->model, Ogre::Vector3( 0, 0, 120), axis, Ogre::Radian(3.14), npcName + "neck", neckandup, neckNumbers); + neckandup[neckNumbers++] = npcName + "neck"; + } + cellRender.insertMesh (headModel, Ogre::Vector3( 0, 0, 5), axis, Ogre::Radian(0), npcName + "head", neckandup, neckNumbers); + neckandup[neckNumbers++] = npcName + "head"; + cellRender.insertMesh (hairModel, Ogre::Vector3( 0, -1, 0), axis, Ogre::Radian(0), npcName + "hair", neckandup, neckNumbers); + ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); + + } void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const { diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 946c30733..e54c35ad8 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -8,7 +8,7 @@ namespace MWClass class Npc : public MWWorld::Class { public: - + virtual std::string getId (const MWWorld::Ptr& ptr) const; ///< Return ID of \a ptr diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index e4819c80c..7f23ff34e 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -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) { - 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() { - shutdownWidgetSkin(); + shutdownWidgetSkin(); } void MWSkill::baseChangeWidgetSkin(ResourceSkin* _info) { - shutdownWidgetSkin(); - Base::baseChangeWidgetSkin(_info); - initialiseWidgetSkin(_info); + shutdownWidgetSkin(); + Base::baseChangeWidgetSkin(_info); + initialiseWidgetSkin(_info); } void MWSkill::initialiseWidgetSkin(ResourceSkin* _info) { for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) - { + { const std::string &name = *(*iter)->_getInternalData(); - if (name == "StatName") - { - MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned"); - skillNameWidget = (*iter)->castType(); - } - else if (name == "StatValue") - { - MYGUI_DEBUG_ASSERT( ! skillValueWidget, "widget already assigned"); - skillValueWidget = (*iter)->castType(); - } - else if (name == "StatNameButton") - { - MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned"); + if (name == "StatName") + { + MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned"); + skillNameWidget = (*iter)->castType(); + } + else if (name == "StatValue") + { + MYGUI_DEBUG_ASSERT( ! skillValueWidget, "widget already assigned"); + skillValueWidget = (*iter)->castType(); + } + else if (name == "StatNameButton") + { + MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned"); MyGUI::ButtonPtr button = (*iter)->castType