mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
Merge remote branch 'zinnschlag/master'
This commit is contained in:
commit
43c33ee85f
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -1,6 +1,6 @@
|
|||||||
[submodule "libs/mangle"]
|
[submodule "libs/mangle"]
|
||||||
path = libs/mangle
|
path = libs/mangle
|
||||||
url = git://github.com/korslund/mangle.git
|
url = git://github.com/zinnschlag/mangle.git
|
||||||
[submodule "libs/openengine"]
|
[submodule "libs/openengine"]
|
||||||
path = libs/openengine
|
path = libs/openengine
|
||||||
url = git://github.com/korslund/OpenEngine
|
url = git://github.com/zinnschlag/OpenEngine
|
||||||
|
@ -205,6 +205,8 @@ if (WIN32)
|
|||||||
add_definitions(-DBOOST_ALL_NO_LIB)
|
add_definitions(-DBOOST_ALL_NO_LIB)
|
||||||
else (WIN32)
|
else (WIN32)
|
||||||
set(PLATFORM_INCLUDE_DIR "")
|
set(PLATFORM_INCLUDE_DIR "")
|
||||||
|
find_path (UUID_INCLUDE_DIR uuid/uuid.h)
|
||||||
|
include_directories(${UUID_INCLUDE_DIR})
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
if (MSVC10)
|
if (MSVC10)
|
||||||
set(PLATFORM_INCLUDE_DIR "")
|
set(PLATFORM_INCLUDE_DIR "")
|
||||||
@ -217,13 +219,14 @@ find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread)
|
|||||||
find_package(OIS REQUIRED)
|
find_package(OIS REQUIRED)
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
include_directories("."
|
include_directories("."
|
||||||
${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre
|
${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE
|
||||||
${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
|
${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
|
||||||
${PLATFORM_INCLUDE_DIR}
|
${PLATFORM_INCLUDE_DIR}
|
||||||
${CMAKE_HOME_DIRECTORY}/extern/caelum/include
|
${CMAKE_HOME_DIRECTORY}/extern/caelum/include
|
||||||
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/MyGUIEngine/include
|
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/MyGUIEngine/include
|
||||||
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/OgrePlatform/include
|
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/OgrePlatform/include
|
||||||
${OPENAL_INCLUDE_DIR}
|
${OPENAL_INCLUDE_DIR}
|
||||||
|
${UUID_INCLUDE_DIR}
|
||||||
${LIBDIR}
|
${LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -308,22 +311,40 @@ if (BUILD_ESMTOOL)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
if (MSVC)
|
||||||
if (USE_DEBUG_CONSOLE)
|
if (USE_DEBUG_CONSOLE)
|
||||||
set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
|
||||||
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
|
||||||
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
|
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
|
||||||
else()
|
else()
|
||||||
# Turn off debug console, debug output will be written to visual studio output instead
|
# Turn off debug console, debug output will be written to visual studio output instead
|
||||||
set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
|
||||||
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS")
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Release builds use the debug console
|
# Release builds use the debug console
|
||||||
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
|
||||||
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_RELEASE "_CONSOLE")
|
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_RELEASE "_CONSOLE")
|
||||||
set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
|
||||||
|
endif(MSVC)
|
||||||
|
|
||||||
# TODO: At some point release builds should not use the console but rather write to a log file
|
# Same for MinGW
|
||||||
#set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
|
if (MINGW)
|
||||||
#set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
|
if (USE_DEBUG_CONSOLE)
|
||||||
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "-Wl,-subsystem,console")
|
||||||
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "-Wl,-subsystem,console")
|
||||||
|
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
|
||||||
|
else(USE_DEBUG_CONSOLE)
|
||||||
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "-Wl,-subsystem,windows")
|
||||||
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "-Wl,-subsystem,windows")
|
||||||
|
endif(USE_DEBUG_CONSOLE)
|
||||||
|
|
||||||
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "-Wl,-subsystem,console")
|
||||||
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "-Wl,-subsystem,console")
|
||||||
|
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_RELEASE "_CONSOLE")
|
||||||
|
endif(MINGW)
|
||||||
|
|
||||||
|
# TODO: At some point release builds should not use the console but rather write to a log file
|
||||||
|
#set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
|
||||||
|
#set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
|
||||||
endif()
|
endif()
|
||||||
|
@ -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 */
|
||||||
|
@ -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 */
|
||||||
|
@ -14,16 +14,18 @@ set(GAMEREND
|
|||||||
mwrender/cellimp.cpp
|
mwrender/cellimp.cpp
|
||||||
mwrender/interior.cpp
|
mwrender/interior.cpp
|
||||||
mwrender/exterior.cpp
|
mwrender/exterior.cpp
|
||||||
mwrender/playerpos.cpp
|
mwrender/sky.cpp
|
||||||
mwrender/sky.cpp)
|
mwrender/player.cpp
|
||||||
|
)
|
||||||
set(GAMEREND_HEADER
|
set(GAMEREND_HEADER
|
||||||
mwrender/cell.hpp
|
mwrender/cell.hpp
|
||||||
mwrender/cellimp.hpp
|
mwrender/cellimp.hpp
|
||||||
mwrender/mwscene.hpp
|
mwrender/mwscene.hpp
|
||||||
mwrender/interior.hpp
|
mwrender/interior.hpp
|
||||||
mwrender/exterior.hpp
|
mwrender/exterior.hpp
|
||||||
mwrender/playerpos.hpp
|
mwrender/sky.hpp
|
||||||
mwrender/sky.hpp)
|
mwrender/player.hpp
|
||||||
|
)
|
||||||
source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER})
|
source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER})
|
||||||
|
|
||||||
set(GAMEINPUT
|
set(GAMEINPUT
|
||||||
@ -103,6 +105,7 @@ set(GAMESCRIPT_HEADER
|
|||||||
mwscript/controlextensions.hpp
|
mwscript/controlextensions.hpp
|
||||||
mwscript/extensions.hpp
|
mwscript/extensions.hpp
|
||||||
mwscript/globalscripts.hpp
|
mwscript/globalscripts.hpp
|
||||||
|
mwscript/ref.hpp
|
||||||
)
|
)
|
||||||
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})
|
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})
|
||||||
|
|
||||||
@ -120,6 +123,7 @@ set(GAMEWORLD
|
|||||||
mwworld/actiontalk.cpp
|
mwworld/actiontalk.cpp
|
||||||
mwworld/actiontake.cpp
|
mwworld/actiontake.cpp
|
||||||
mwworld/containerutil.cpp
|
mwworld/containerutil.cpp
|
||||||
|
mwworld/player.cpp
|
||||||
)
|
)
|
||||||
set(GAMEWORLD_HEADER
|
set(GAMEWORLD_HEADER
|
||||||
mwworld/refdata.hpp
|
mwworld/refdata.hpp
|
||||||
@ -137,6 +141,7 @@ set(GAMEWORLD_HEADER
|
|||||||
mwworld/containerstore.hpp
|
mwworld/containerstore.hpp
|
||||||
mwworld/manualref.hpp
|
mwworld/manualref.hpp
|
||||||
mwworld/containerutil.hpp
|
mwworld/containerutil.hpp
|
||||||
|
mwworld/player.hpp
|
||||||
)
|
)
|
||||||
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})
|
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "mwworld/ptr.hpp"
|
#include "mwworld/ptr.hpp"
|
||||||
#include "mwworld/environment.hpp"
|
#include "mwworld/environment.hpp"
|
||||||
#include "mwworld/class.hpp"
|
#include "mwworld/class.hpp"
|
||||||
|
#include "mwworld/player.hpp"
|
||||||
|
|
||||||
#include "mwclass/classes.hpp"
|
#include "mwclass/classes.hpp"
|
||||||
|
|
||||||
@ -67,73 +68,71 @@ 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(mUseSound && !(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->getPlayer().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<ESM::Region::SoundRef>::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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell();
|
srand ( time(NULL) );
|
||||||
//If the region has changed
|
int r = rand() % total; //old random code
|
||||||
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){
|
int pos = 0;
|
||||||
timer.restart();
|
soundIter = test.soundList.begin();
|
||||||
if (test.name != current->cell->region)
|
while (!(soundIter == test.soundList.end()))
|
||||||
{
|
{
|
||||||
total = 0;
|
const ESM::NAME32 go = soundIter->sound;
|
||||||
test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region));
|
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);
|
||||||
|
|
||||||
if(test.soundList.size() > 0)
|
break;
|
||||||
{
|
|
||||||
std::vector<ESM::Region::SoundRef>::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
|
pos += chance;
|
||||||
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;
|
//mEnvironment.mSoundManager->playSound(effect, 1.0, 1.0);
|
||||||
|
//printf("REGION: %s\n", test.name);
|
||||||
|
|
||||||
}
|
}
|
||||||
pos += chance;
|
else if(current->cell->data.flags & current->cell->Interior)
|
||||||
}
|
{
|
||||||
}
|
test.name = "";
|
||||||
|
}
|
||||||
//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
|
try
|
||||||
{
|
{
|
||||||
@ -184,7 +183,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 +293,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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -377,7 +376,7 @@ void OMW::Engine::go()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sets up the input system
|
// Sets up the input system
|
||||||
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(),
|
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayer(),
|
||||||
*mEnvironment.mWindowManager, mDebug, *this);
|
*mEnvironment.mWindowManager, mDebug, *this);
|
||||||
mEnvironment.mInputManager = &input;
|
mEnvironment.mInputManager = &input;
|
||||||
|
|
||||||
@ -439,7 +438,7 @@ void OMW::Engine::activate()
|
|||||||
&ptr.getRefData().getLocals(), ptr);
|
&ptr.getRefData().getLocals(), ptr);
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> action =
|
boost::shared_ptr<MWWorld::Action> action =
|
||||||
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayerPos().getPlayer(),
|
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(),
|
||||||
mEnvironment);
|
mEnvironment);
|
||||||
|
|
||||||
interpreterContext.activate (ptr, action);
|
interpreterContext.activate (ptr, action);
|
||||||
|
@ -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;
|
||||||
|
@ -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();
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
#include <components/esm_store/cell_store.hpp>
|
||||||
|
|
||||||
#include "../mwrender/playerpos.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/nullaction.hpp"
|
#include "../mwworld/nullaction.hpp"
|
||||||
#include "../mwworld/actionteleport.hpp"
|
#include "../mwworld/actionteleport.hpp"
|
||||||
@ -65,7 +64,7 @@ namespace MWClass
|
|||||||
if (ref->ref.teleport)
|
if (ref->ref.teleport)
|
||||||
{
|
{
|
||||||
// teleport door
|
// teleport door
|
||||||
if (environment.mWorld->getPlayerPos().getPlayer()==actor)
|
if (environment.mWorld->getPlayer().getPlayer()==actor)
|
||||||
{
|
{
|
||||||
// the player is using the door
|
// the player is using the door
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
return boost::shared_ptr<MWWorld::Action> (
|
||||||
|
@ -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, -14), 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, -14), 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, -2, -18), 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, -2, -18), 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, -1, -18), 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, -1, -18), 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
|
||||||
{
|
{
|
||||||
|
@ -5,12 +5,10 @@
|
|||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
static bool isChest;
|
|
||||||
//static ;bool isChest = false;
|
|
||||||
class Npc : public MWWorld::Class
|
class Npc : public MWWorld::Class
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
||||||
///< Return ID of \a ptr
|
///< Return ID of \a ptr
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "../mwworld/environment.hpp"
|
#include "../mwworld/environment.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
#include "../mwworld/refdata.hpp"
|
#include "../mwworld/refdata.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
#include "../mwinput/inputmanager.hpp"
|
#include "../mwinput/inputmanager.hpp"
|
||||||
|
|
||||||
@ -225,7 +226,7 @@ namespace MWDialogue
|
|||||||
|
|
||||||
// check cell
|
// check cell
|
||||||
if (!info.cell.empty())
|
if (!info.cell.empty())
|
||||||
if (mEnvironment.mWorld->getPlayerPos().getPlayer().getCell()->cell->name != info.cell)
|
if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// TODO check DATAstruct
|
// TODO check DATAstruct
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "../mwgui/window_manager.hpp"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
using namespace Widgets;
|
using namespace Widgets;
|
||||||
|
|
||||||
|
@ -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()
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -15,10 +15,13 @@
|
|||||||
#include <mangle/input/filters/eventlist.hpp>
|
#include <mangle/input/filters/eventlist.hpp>
|
||||||
|
|
||||||
#include <libs/platform/strings.h>
|
#include <libs/platform/strings.h>
|
||||||
#include "../mwrender/playerpos.hpp"
|
|
||||||
|
|
||||||
#include "../engine.hpp"
|
#include "../engine.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
|
#include "../mwrender/player.hpp"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
@ -76,7 +79,7 @@ namespace MWInput
|
|||||||
OEngine::Input::Poller poller;
|
OEngine::Input::Poller poller;
|
||||||
OEngine::Render::MouseLookEventPtr mouse;
|
OEngine::Render::MouseLookEventPtr mouse;
|
||||||
OEngine::GUI::EventInjectorPtr guiEvents;
|
OEngine::GUI::EventInjectorPtr guiEvents;
|
||||||
MWRender::PlayerPos &player;
|
MWWorld::Player &player;
|
||||||
MWGui::WindowManager &windows;
|
MWGui::WindowManager &windows;
|
||||||
OMW::Engine& mEngine;
|
OMW::Engine& mEngine;
|
||||||
|
|
||||||
@ -142,7 +145,7 @@ namespace MWInput
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
InputImpl(OEngine::Render::OgreRenderer &_ogre,
|
InputImpl(OEngine::Render::OgreRenderer &_ogre,
|
||||||
MWRender::PlayerPos &_player,
|
MWWorld::Player &_player,
|
||||||
MWGui::WindowManager &_windows,
|
MWGui::WindowManager &_windows,
|
||||||
bool debug,
|
bool debug,
|
||||||
OMW::Engine& engine)
|
OMW::Engine& engine)
|
||||||
@ -182,7 +185,7 @@ namespace MWInput
|
|||||||
ogre.getRoot()->addFrameListener(this);
|
ogre.getRoot()->addFrameListener(this);
|
||||||
|
|
||||||
// Set up the mouse handler and tell it about the player camera
|
// Set up the mouse handler and tell it about the player camera
|
||||||
mouse = MouseLookEventPtr(new MouseLookEvent(player.getCamera()));
|
mouse = MouseLookEventPtr(new MouseLookEvent(player.getRenderer()->getCamera()));
|
||||||
|
|
||||||
// This event handler pumps events into MyGUI
|
// This event handler pumps events into MyGUI
|
||||||
guiEvents = EventInjectorPtr(new EventInjector(windows.getGui()));
|
guiEvents = EventInjectorPtr(new EventInjector(windows.getGui()));
|
||||||
@ -295,7 +298,7 @@ namespace MWInput
|
|||||||
{
|
{
|
||||||
// Start mouse-looking again. TODO: This should also allow
|
// Start mouse-looking again. TODO: This should also allow
|
||||||
// for other ways to disable mouselook, like paralyzation.
|
// for other ways to disable mouselook, like paralyzation.
|
||||||
mouse->setCamera(player.getCamera());
|
mouse->setCamera(player.getRenderer()->getCamera());
|
||||||
|
|
||||||
// Disable GUI events
|
// Disable GUI events
|
||||||
guiEvents->enabled = false;
|
guiEvents->enabled = false;
|
||||||
@ -304,7 +307,7 @@ namespace MWInput
|
|||||||
};
|
};
|
||||||
|
|
||||||
MWInputManager::MWInputManager(OEngine::Render::OgreRenderer &ogre,
|
MWInputManager::MWInputManager(OEngine::Render::OgreRenderer &ogre,
|
||||||
MWRender::PlayerPos &player,
|
MWWorld::Player &player,
|
||||||
MWGui::WindowManager &windows,
|
MWGui::WindowManager &windows,
|
||||||
bool debug,
|
bool debug,
|
||||||
OMW::Engine& engine)
|
OMW::Engine& engine)
|
||||||
@ -318,7 +321,7 @@ namespace MWInput
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MWInputManager::setGuiMode(MWGui::GuiMode mode)
|
void MWInputManager::setGuiMode(MWGui::GuiMode mode)
|
||||||
{
|
{
|
||||||
impl->setGuiMode(mode);
|
impl->setGuiMode(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ namespace OEngine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class PlayerPos;
|
class Player;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
@ -42,7 +42,7 @@ namespace MWInput
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MWInputManager(OEngine::Render::OgreRenderer &_ogre,
|
MWInputManager(OEngine::Render::OgreRenderer &_ogre,
|
||||||
MWRender::PlayerPos &_player,
|
MWWorld::Player&_player,
|
||||||
MWGui::WindowManager &_windows,
|
MWGui::WindowManager &_windows,
|
||||||
bool debug,
|
bool debug,
|
||||||
OMW::Engine& engine);
|
OMW::Engine& engine);
|
||||||
|
@ -8,12 +8,13 @@
|
|||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
#include "../mwworld/environment.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
void MechanicsManager::buildPlayer()
|
void MechanicsManager::buildPlayer()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = mEnvironment.mWorld->getPlayerPos().getPlayer();
|
MWWorld::Ptr ptr = mEnvironment.mWorld->getPlayer().getPlayer();
|
||||||
|
|
||||||
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr);
|
MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr);
|
||||||
@ -33,9 +34,9 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
const ESM::Race *race =
|
const ESM::Race *race =
|
||||||
mEnvironment.mWorld->getStore().races.find (
|
mEnvironment.mWorld->getStore().races.find (
|
||||||
mEnvironment.mWorld->getPlayerPos().getRace());
|
mEnvironment.mWorld->getPlayer().getRace());
|
||||||
|
|
||||||
bool male = mEnvironment.mWorld->getPlayerPos().isMale();
|
bool male = mEnvironment.mWorld->getPlayer().isMale();
|
||||||
|
|
||||||
for (int i=0; i<8; ++i)
|
for (int i=0; i<8; ++i)
|
||||||
{
|
{
|
||||||
@ -75,11 +76,11 @@ namespace MWMechanics
|
|||||||
}
|
}
|
||||||
|
|
||||||
// birthsign
|
// birthsign
|
||||||
if (!mEnvironment.mWorld->getPlayerPos().getBirthsign().empty())
|
if (!mEnvironment.mWorld->getPlayer().getBirthsign().empty())
|
||||||
{
|
{
|
||||||
const ESM::BirthSign *sign =
|
const ESM::BirthSign *sign =
|
||||||
mEnvironment.mWorld->getStore().birthSigns.find (
|
mEnvironment.mWorld->getStore().birthSigns.find (
|
||||||
mEnvironment.mWorld->getPlayerPos().getBirthsign());
|
mEnvironment.mWorld->getPlayer().getBirthsign());
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator iter (sign->powers.list.begin());
|
for (std::vector<std::string>::const_iterator iter (sign->powers.list.begin());
|
||||||
iter!=sign->powers.list.end(); ++iter)
|
iter!=sign->powers.list.end(); ++iter)
|
||||||
@ -91,7 +92,7 @@ namespace MWMechanics
|
|||||||
// class
|
// class
|
||||||
if (mClassSelected)
|
if (mClassSelected)
|
||||||
{
|
{
|
||||||
const ESM::Class& class_ = mEnvironment.mWorld->getPlayerPos().getClass();
|
const ESM::Class& class_ = mEnvironment.mWorld->getPlayer().getClass();
|
||||||
|
|
||||||
for (int i=0; i<2; ++i)
|
for (int i=0; i<2; ++i)
|
||||||
{
|
{
|
||||||
@ -330,12 +331,12 @@ namespace MWMechanics
|
|||||||
if (mUpdatePlayer)
|
if (mUpdatePlayer)
|
||||||
{
|
{
|
||||||
// basic player profile; should not change anymore after the creation phase is finished.
|
// basic player profile; should not change anymore after the creation phase is finished.
|
||||||
mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayerPos().getName());
|
mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayer().getName());
|
||||||
mEnvironment.mWindowManager->setValue ("race",
|
mEnvironment.mWindowManager->setValue ("race",
|
||||||
mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayerPos().
|
mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayer().
|
||||||
getRace())->name);
|
getRace())->name);
|
||||||
mEnvironment.mWindowManager->setValue ("class",
|
mEnvironment.mWindowManager->setValue ("class",
|
||||||
mEnvironment.mWorld->getPlayerPos().getClass().name);
|
mEnvironment.mWorld->getPlayer().getClass().name);
|
||||||
mUpdatePlayer = false;
|
mUpdatePlayer = false;
|
||||||
|
|
||||||
MWGui::WindowManager::SkillList majorSkills (5);
|
MWGui::WindowManager::SkillList majorSkills (5);
|
||||||
@ -343,8 +344,8 @@ namespace MWMechanics
|
|||||||
|
|
||||||
for (int i=0; i<5; ++i)
|
for (int i=0; i<5; ++i)
|
||||||
{
|
{
|
||||||
minorSkills[i] = mEnvironment.mWorld->getPlayerPos().getClass().data.skills[i][0];
|
minorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][0];
|
||||||
majorSkills[i] = mEnvironment.mWorld->getPlayerPos().getClass().data.skills[i][1];
|
majorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
mEnvironment.mWindowManager->configureSkills (majorSkills, minorSkills);
|
mEnvironment.mWindowManager->configureSkills (majorSkills, minorSkills);
|
||||||
@ -353,14 +354,14 @@ namespace MWMechanics
|
|||||||
|
|
||||||
void MechanicsManager::setPlayerName (const std::string& name)
|
void MechanicsManager::setPlayerName (const std::string& name)
|
||||||
{
|
{
|
||||||
mEnvironment.mWorld->getPlayerPos().setName (name);
|
mEnvironment.mWorld->getPlayer().setName (name);
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::setPlayerRace (const std::string& race, bool male)
|
void MechanicsManager::setPlayerRace (const std::string& race, bool male)
|
||||||
{
|
{
|
||||||
mEnvironment.mWorld->getPlayerPos().setGender (male);
|
mEnvironment.mWorld->getPlayer().setGender (male);
|
||||||
mEnvironment.mWorld->getPlayerPos().setRace (race);
|
mEnvironment.mWorld->getPlayer().setRace (race);
|
||||||
mRaceSelected = true;
|
mRaceSelected = true;
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
@ -368,14 +369,14 @@ namespace MWMechanics
|
|||||||
|
|
||||||
void MechanicsManager::setPlayerBirthsign (const std::string& id)
|
void MechanicsManager::setPlayerBirthsign (const std::string& id)
|
||||||
{
|
{
|
||||||
mEnvironment.mWorld->getPlayerPos().setBirthsign (id);
|
mEnvironment.mWorld->getPlayer().setBirthsign (id);
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::setPlayerClass (const std::string& id)
|
void MechanicsManager::setPlayerClass (const std::string& id)
|
||||||
{
|
{
|
||||||
mEnvironment.mWorld->getPlayerPos().setClass (*mEnvironment.mWorld->getStore().classes.find (id));
|
mEnvironment.mWorld->getPlayer().setClass (*mEnvironment.mWorld->getStore().classes.find (id));
|
||||||
mClassSelected = true;
|
mClassSelected = true;
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
@ -383,7 +384,7 @@ namespace MWMechanics
|
|||||||
|
|
||||||
void MechanicsManager::setPlayerClass (const ESM::Class& class_)
|
void MechanicsManager::setPlayerClass (const ESM::Class& class_)
|
||||||
{
|
{
|
||||||
mEnvironment.mWorld->getPlayerPos().setClass (class_);
|
mEnvironment.mWorld->getPlayer().setClass (class_);
|
||||||
mClassSelected = true;
|
mClassSelected = true;
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
|
@ -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.
|
||||||
|
@ -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,92 +97,99 @@ 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);
|
||||||
|
|
||||||
|
|
||||||
|
if(translateFirst){
|
||||||
npcPart->translate(vec);
|
npcPart->translate(vec);
|
||||||
npcPart->rotate(axis, angle);
|
npcPart->rotate(axis, angle);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
npcPart->rotate(axis, angle);
|
||||||
|
npcPart->translate(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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 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.
|
||||||
|
@ -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);
|
||||||
@ -85,7 +85,7 @@ namespace MWRender
|
|||||||
void configureFog();
|
void configureFog();
|
||||||
|
|
||||||
void setAmbientMode();
|
void setAmbientMode();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -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";
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
|
|||||||
npcPart->rotate(axis, angle);
|
npcPart->rotate(axis, angle);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
||||||
npcPart->rotate(axis, angle);
|
npcPart->rotate(axis, angle);
|
||||||
npcPart->translate(vec);
|
npcPart->translate(vec);
|
||||||
}
|
}
|
||||||
@ -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)
|
||||||
|
@ -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
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include <components/esm/loadstat.hpp>
|
#include <components/esm/loadstat.hpp>
|
||||||
|
|
||||||
|
#include "player.hpp"
|
||||||
|
|
||||||
using namespace MWRender;
|
using namespace MWRender;
|
||||||
using namespace Ogre;
|
using namespace Ogre;
|
||||||
|
|
||||||
@ -38,6 +40,13 @@ MWScene::MWScene(OEngine::Render::OgreRenderer &_rend)
|
|||||||
|
|
||||||
//used to obtain ingame information of ogre objects (which are faced or selected)
|
//used to obtain ingame information of ogre objects (which are faced or selected)
|
||||||
mRaySceneQuery = rend.getScene()->createRayQuery(Ray());
|
mRaySceneQuery = rend.getScene()->createRayQuery(Ray());
|
||||||
|
|
||||||
|
mPlayer = new MWRender::Player (getCamera());
|
||||||
|
}
|
||||||
|
|
||||||
|
MWScene::~MWScene()
|
||||||
|
{
|
||||||
|
delete mPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::string, float> MWScene::getFacedHandle (MWWorld::World& world)
|
std::pair<std::string, float> MWScene::getFacedHandle (MWWorld::World& world)
|
||||||
|
@ -20,36 +20,41 @@ namespace MWWorld
|
|||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
/** Class responsible for Morrowind-specific interfaces to OGRE.
|
class Player;
|
||||||
|
|
||||||
This might be refactored partially into a non-mw specific
|
/// \brief 3D-scene (rendering and physics)
|
||||||
counterpart in ogre/ at some point.
|
|
||||||
*/
|
|
||||||
class MWScene
|
|
||||||
{
|
|
||||||
OEngine::Render::OgreRenderer &rend;
|
|
||||||
|
|
||||||
// Root node for all objects added to the scene. This is rotated so
|
class MWScene
|
||||||
// that the OGRE coordinate system matches that used internally in
|
{
|
||||||
// Morrowind.
|
OEngine::Render::OgreRenderer &rend;
|
||||||
Ogre::SceneNode *mwRoot;
|
|
||||||
Ogre::RaySceneQuery *mRaySceneQuery;
|
|
||||||
|
|
||||||
public:
|
/// Root node for all objects added to the scene. This is rotated so
|
||||||
MWScene(OEngine::Render::OgreRenderer &_rend);
|
/// that the OGRE coordinate system matches that used internally in
|
||||||
|
/// Morrowind.
|
||||||
|
Ogre::SceneNode *mwRoot;
|
||||||
|
Ogre::RaySceneQuery *mRaySceneQuery;
|
||||||
|
|
||||||
Ogre::Camera *getCamera() { return rend.getCamera(); }
|
MWRender::Player *mPlayer;
|
||||||
Ogre::SceneNode *getRoot() { return mwRoot; }
|
|
||||||
Ogre::SceneManager *getMgr() { return rend.getScene(); }
|
|
||||||
Ogre::Viewport *getViewport() { return rend.getViewport(); }
|
|
||||||
Ogre::RaySceneQuery *getRaySceneQuery() { return mRaySceneQuery; }
|
|
||||||
|
|
||||||
//gets the handle of the object the player is looking at
|
public:
|
||||||
//pair<name, distance>
|
|
||||||
//name is empty and distance = -1 if there is no object which
|
MWScene (OEngine::Render::OgreRenderer &_rend);
|
||||||
//can be faced
|
|
||||||
std::pair<std::string, float> getFacedHandle (MWWorld::World& world);
|
~MWScene();
|
||||||
};
|
|
||||||
|
Ogre::Camera *getCamera() { return rend.getCamera(); }
|
||||||
|
Ogre::SceneNode *getRoot() { return mwRoot; }
|
||||||
|
Ogre::SceneManager *getMgr() { return rend.getScene(); }
|
||||||
|
Ogre::Viewport *getViewport() { return rend.getViewport(); }
|
||||||
|
Ogre::RaySceneQuery *getRaySceneQuery() { return mRaySceneQuery; }
|
||||||
|
MWRender::Player *getPlayer() { return mPlayer; }
|
||||||
|
|
||||||
|
/// Gets the handle of the object the player is looking at
|
||||||
|
/// pair<name, distance>
|
||||||
|
/// name is empty and distance = -1 if there is no object which
|
||||||
|
/// can be faced
|
||||||
|
std::pair<std::string, float> getFacedHandle (MWWorld::World& world);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
8
apps/openmw/mwrender/player.cpp
Normal file
8
apps/openmw/mwrender/player.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
#include "player.hpp"
|
||||||
|
|
||||||
|
namespace MWRender
|
||||||
|
{
|
||||||
|
Player::Player (Ogre::Camera *camera) : mCamera (camera)
|
||||||
|
{}
|
||||||
|
}
|
24
apps/openmw/mwrender/player.hpp
Normal file
24
apps/openmw/mwrender/player.hpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef GAME_MWRENDER_PLAYER_H
|
||||||
|
#define GAME_MWRENDER_PLAYER_H
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class Camera;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWRender
|
||||||
|
{
|
||||||
|
/// \brief Player character rendering and camera control
|
||||||
|
class Player
|
||||||
|
{
|
||||||
|
Ogre::Camera *mCamera;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Player (Ogre::Camera *camera);
|
||||||
|
|
||||||
|
Ogre::Camera *getCamera() { return mCamera; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -1,41 +0,0 @@
|
|||||||
|
|
||||||
#include "playerpos.hpp"
|
|
||||||
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
|
|
||||||
namespace MWRender
|
|
||||||
{
|
|
||||||
PlayerPos::PlayerPos (Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world) :
|
|
||||||
mCellStore (0), camera(cam), mWorld (world), mClass (0)
|
|
||||||
{
|
|
||||||
mPlayer.base = player;
|
|
||||||
mName = player->name;
|
|
||||||
mMale = !(player->flags & ESM::NPC::Female);
|
|
||||||
mRace = player->race;
|
|
||||||
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
|
|
||||||
mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerPos::~PlayerPos()
|
|
||||||
{
|
|
||||||
delete mClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerPos::setPos(float x, float y, float z, bool updateCamera)
|
|
||||||
{
|
|
||||||
mWorld.moveObject (getPlayer(), x, y, z);
|
|
||||||
|
|
||||||
if (updateCamera)
|
|
||||||
camera->setPosition (Ogre::Vector3 (
|
|
||||||
mPlayer.ref.pos.pos[0],
|
|
||||||
mPlayer.ref.pos.pos[2],
|
|
||||||
-mPlayer.ref.pos.pos[1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerPos::setClass (const ESM::Class& class_)
|
|
||||||
{
|
|
||||||
ESM::Class *new_class = new ESM::Class (class_);
|
|
||||||
delete mClass;
|
|
||||||
mClass = new_class;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,128 +0,0 @@
|
|||||||
#ifndef _MWRENDER_PLAYERPOS_H
|
|
||||||
#define _MWRENDER_PLAYERPOS_H
|
|
||||||
|
|
||||||
#include "OgreCamera.h"
|
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwworld/refdata.hpp"
|
|
||||||
#include "../mwworld/ptr.hpp"
|
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class World;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWRender
|
|
||||||
{
|
|
||||||
// This class keeps track of the player position. It takes care of
|
|
||||||
// camera movement, sound listener updates, and collision handling
|
|
||||||
// (to be done).
|
|
||||||
class PlayerPos
|
|
||||||
{
|
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> mPlayer;
|
|
||||||
MWWorld::Ptr::CellStore *mCellStore;
|
|
||||||
Ogre::Camera *camera;
|
|
||||||
MWWorld::World& mWorld;
|
|
||||||
std::string mName;
|
|
||||||
bool mMale;
|
|
||||||
std::string mRace;
|
|
||||||
std::string mBirthsign;
|
|
||||||
ESM::Class *mClass;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
PlayerPos(Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world);
|
|
||||||
|
|
||||||
~PlayerPos();
|
|
||||||
|
|
||||||
// Set the player position. Uses Morrowind coordinates.
|
|
||||||
void setPos(float _x, float _y, float _z, bool updateCamera = false);
|
|
||||||
|
|
||||||
void setCell (MWWorld::Ptr::CellStore *cellStore)
|
|
||||||
{
|
|
||||||
mCellStore = cellStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ogre::Camera *getCamera() { return camera; }
|
|
||||||
|
|
||||||
// Move the player relative to her own position and
|
|
||||||
// orientation. After the call, the new position is returned.
|
|
||||||
void moveRel(float &relX, float &relY, float &relZ)
|
|
||||||
{
|
|
||||||
using namespace Ogre;
|
|
||||||
|
|
||||||
// Move camera relative to its own direction
|
|
||||||
camera->moveRelative(Vector3(relX,0,relZ));
|
|
||||||
|
|
||||||
// Up/down movement is always done relative the world axis.
|
|
||||||
camera->move(Vector3(0,relY,0));
|
|
||||||
|
|
||||||
// Get new camera position, converting back to MW coords.
|
|
||||||
Vector3 pos = camera->getPosition();
|
|
||||||
relX = pos[0];
|
|
||||||
relY = -pos[2];
|
|
||||||
relZ = pos[1];
|
|
||||||
|
|
||||||
// TODO: Collision detection must be used to find the REAL new
|
|
||||||
// position.
|
|
||||||
|
|
||||||
// Set the position
|
|
||||||
setPos(relX, relY, relZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
MWWorld::Ptr getPlayer()
|
|
||||||
{
|
|
||||||
MWWorld::Ptr ptr (&mPlayer, mCellStore);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setName (const std::string& name)
|
|
||||||
{
|
|
||||||
mName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setGender (bool male)
|
|
||||||
{
|
|
||||||
mMale = male;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setRace (const std::string& race)
|
|
||||||
{
|
|
||||||
mRace = race;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBirthsign (const std::string& birthsign)
|
|
||||||
{
|
|
||||||
mBirthsign = birthsign;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setClass (const ESM::Class& class_);
|
|
||||||
|
|
||||||
std::string getName() const
|
|
||||||
{
|
|
||||||
return mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isMale() const
|
|
||||||
{
|
|
||||||
return mMale;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getRace() const
|
|
||||||
{
|
|
||||||
return mRace;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getBirthsign() const
|
|
||||||
{
|
|
||||||
return mBirthsign;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ESM::Class& getClass() const
|
|
||||||
{
|
|
||||||
return *mClass;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -8,6 +8,7 @@
|
|||||||
#include <components/interpreter/opcodes.hpp>
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
|
#include "ref.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -15,46 +16,14 @@ namespace MWScript
|
|||||||
{
|
{
|
||||||
namespace Ai
|
namespace Ai
|
||||||
{
|
{
|
||||||
|
template<class R>
|
||||||
class OpAiTravel : public Interpreter::Opcode1
|
class OpAiTravel : public Interpreter::Opcode1
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
Interpreter::Type_Float x = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float y = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float z = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
// discard additional arguments (reset), because we have no idea what they mean.
|
|
||||||
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
|
||||||
|
|
||||||
std::cout << "AiTravel: " << x << ", " << y << ", " << z << std::endl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpAiTravelExplicit : public Interpreter::Opcode1
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
Interpreter::Type_Float x = runtime[0].mInteger;
|
Interpreter::Type_Float x = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
@ -72,56 +41,14 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpAiEscort : public Interpreter::Opcode1
|
class OpAiEscort : public Interpreter::Opcode1
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
std::string actor = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float duration = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float x = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float y = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float z = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
// discard additional arguments (reset), because we have no idea what they mean.
|
|
||||||
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
|
||||||
|
|
||||||
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpAiEscortExplicit : public Interpreter::Opcode1
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
std::string actor = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string actor = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
@ -146,16 +73,14 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpGetAiPackageDone : public Interpreter::Opcode0
|
class OpGetAiPackageDone : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = 0;
|
Interpreter::Type_Integer value = 0;
|
||||||
|
|
||||||
@ -163,25 +88,6 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpGetAiPackageDoneExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = 0;
|
|
||||||
|
|
||||||
runtime.push (value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const int opcodeAiTravel = 0x20000;
|
const int opcodeAiTravel = 0x20000;
|
||||||
@ -204,12 +110,13 @@ namespace MWScript
|
|||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
{
|
{
|
||||||
interpreter.installSegment3 (opcodeAiTravel, new OpAiTravel);
|
interpreter.installSegment3 (opcodeAiTravel, new OpAiTravel<ImplicitRef>);
|
||||||
interpreter.installSegment3 (opcodeAiTravelExplicit, new OpAiTravelExplicit);
|
interpreter.installSegment3 (opcodeAiTravelExplicit, new OpAiTravel<ExplicitRef>);
|
||||||
interpreter.installSegment3 (opcodeAiEscort, new OpAiEscort);
|
interpreter.installSegment3 (opcodeAiEscort, new OpAiEscort<ImplicitRef>);
|
||||||
interpreter.installSegment3 (opcodeAiEscortExplicit, new OpAiEscortExplicit);
|
interpreter.installSegment3 (opcodeAiEscortExplicit, new OpAiEscort<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone);
|
interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit, new OpGetAiPackageDoneExplicit);
|
interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit,
|
||||||
|
new OpGetAiPackageDone<ExplicitRef>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,17 +14,21 @@
|
|||||||
#include "../mwworld/containerutil.hpp"
|
#include "../mwworld/containerutil.hpp"
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
|
#include "ref.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
namespace Container
|
namespace Container
|
||||||
{
|
{
|
||||||
|
template<class R>
|
||||||
class OpAddItem : public Interpreter::Opcode0
|
class OpAddItem : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
@ -37,40 +41,6 @@ namespace MWScript
|
|||||||
if (count<0)
|
if (count<0)
|
||||||
throw std::runtime_error ("second argument for AddItem must be non-negative");
|
throw std::runtime_error ("second argument for AddItem must be non-negative");
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWWorld::ManualRef ref (context.getWorld().getStore(), item);
|
|
||||||
|
|
||||||
ref.getPtr().getRefData().setCount (count);
|
|
||||||
|
|
||||||
MWWorld::Class::get (ref.getPtr()).insertIntoContainer (ref.getPtr(),
|
|
||||||
MWWorld::Class::get (ptr).getContainerStore (ptr));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpAddItemExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer count = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
if (count<0)
|
|
||||||
throw std::runtime_error ("second argument for AddItem must be non-negative");
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWWorld::ManualRef ref (context.getWorld().getStore(), item);
|
MWWorld::ManualRef ref (context.getWorld().getStore(), item);
|
||||||
|
|
||||||
ref.getPtr().getRefData().setCount (count);
|
ref.getPtr().getRefData().setCount (count);
|
||||||
@ -80,55 +50,21 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpGetItemCount : public Interpreter::Opcode0
|
class OpGetItemCount : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
std::vector<MWWorld::Ptr> list;
|
|
||||||
|
|
||||||
MWWorld::listItemsInContainer (item,
|
|
||||||
MWWorld::Class::get (ptr).getContainerStore (ptr),
|
|
||||||
context.getWorld().getStore(), list);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer sum = 0;
|
|
||||||
|
|
||||||
for (std::vector<MWWorld::Ptr>::iterator iter (list.begin()); iter!=list.end();
|
|
||||||
++iter)
|
|
||||||
{
|
|
||||||
sum += iter->getRefData().getCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.push (sum);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetItemCountExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
std::vector<MWWorld::Ptr> list;
|
std::vector<MWWorld::Ptr> list;
|
||||||
|
|
||||||
MWWorld::listItemsInContainer (item,
|
MWWorld::listItemsInContainer (item,
|
||||||
@ -147,12 +83,15 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpRemoveItem : public Interpreter::Opcode0
|
class OpRemoveItem : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
@ -165,58 +104,6 @@ namespace MWScript
|
|||||||
if (count<0)
|
if (count<0)
|
||||||
throw std::runtime_error ("second argument for RemoveItem must be non-negative");
|
throw std::runtime_error ("second argument for RemoveItem must be non-negative");
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
std::vector<MWWorld::Ptr> list;
|
|
||||||
|
|
||||||
MWWorld::listItemsInContainer (item,
|
|
||||||
MWWorld::Class::get (ptr).getContainerStore (ptr),
|
|
||||||
context.getWorld().getStore(), list);
|
|
||||||
|
|
||||||
for (std::vector<MWWorld::Ptr>::iterator iter (list.begin());
|
|
||||||
iter!=list.end() && count;
|
|
||||||
++iter)
|
|
||||||
{
|
|
||||||
if (iter->getRefData().getCount()<=count)
|
|
||||||
{
|
|
||||||
count -= iter->getRefData().getCount();
|
|
||||||
iter->getRefData().setCount (0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iter->getRefData().setCount (iter->getRefData().getCount()-count);
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// To be fully compatible with original Morrowind, we would need to check if
|
|
||||||
// count is >= 0 here and throw an exception. But let's be tollerant instead.
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpRemoveItemExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer count = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
if (count<0)
|
|
||||||
throw std::runtime_error ("second argument for RemoveItem must be non-negative");
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
std::vector<MWWorld::Ptr> list;
|
std::vector<MWWorld::Ptr> list;
|
||||||
|
|
||||||
MWWorld::listItemsInContainer (item,
|
MWWorld::listItemsInContainer (item,
|
||||||
@ -262,12 +149,12 @@ namespace MWScript
|
|||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
{
|
{
|
||||||
interpreter.installSegment5 (opcodeAddItem, new OpAddItem);
|
interpreter.installSegment5 (opcodeAddItem, new OpAddItem<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeAddItemExplicit, new OpAddItemExplicit);
|
interpreter.installSegment5 (opcodeAddItemExplicit, new OpAddItem<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetItemCount, new OpGetItemCount);
|
interpreter.installSegment5 (opcodeGetItemCount, new OpGetItemCount<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetItemCountExplicit, new OpGetItemCountExplicit);
|
interpreter.installSegment5 (opcodeGetItemCountExplicit, new OpGetItemCount<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeRemoveItem, new OpRemoveItem);
|
interpreter.installSegment5 (opcodeRemoveItem, new OpRemoveItem<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItemExplicit);
|
interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItem<ExplicitRef>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <components/interpreter/runtime.hpp>
|
#include <components/interpreter/runtime.hpp>
|
||||||
#include <components/interpreter/opcodes.hpp>
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -35,10 +37,24 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OpToggleCollision : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
InterpreterContext& context
|
||||||
|
= static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
context.getWorld().getPlayer().toggleCollisionMode();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const int numberOfControls = 7;
|
const int numberOfControls = 7;
|
||||||
|
|
||||||
const int opcodeEnable = 0x200007e;
|
const int opcodeEnable = 0x200007e;
|
||||||
const int opcodeDisable = 0x2000085;
|
const int opcodeDisable = 0x2000085;
|
||||||
|
const int opcodeToggleCollision = 0x2000130;
|
||||||
|
|
||||||
const char *controls[numberOfControls] =
|
const char *controls[numberOfControls] =
|
||||||
{
|
{
|
||||||
@ -56,6 +72,8 @@ namespace MWScript
|
|||||||
extensions.registerInstruction (enable + controls[i], "", opcodeEnable+i);
|
extensions.registerInstruction (enable + controls[i], "", opcodeEnable+i);
|
||||||
extensions.registerInstruction (disable + controls[i], "", opcodeDisable+i);
|
extensions.registerInstruction (disable + controls[i], "", opcodeDisable+i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extensions.registerInstruction ("togglecollision", "", opcodeToggleCollision);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
@ -65,6 +83,8 @@ namespace MWScript
|
|||||||
interpreter.installSegment5 (opcodeEnable+i, new OpSetControl (controls[i], true));
|
interpreter.installSegment5 (opcodeEnable+i, new OpSetControl (controls[i], true));
|
||||||
interpreter.installSegment5 (opcodeDisable+i, new OpSetControl (controls[i], false));
|
interpreter.installSegment5 (opcodeDisable+i, new OpSetControl (controls[i], false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interpreter.installSegment5 (opcodeToggleCollision, new OpToggleCollision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,4 +101,5 @@ op 0x20000c4-0x20000de: SetSkill
|
|||||||
op 0x20000df-0x20000f9: SetSkill, explicit reference
|
op 0x20000df-0x20000f9: SetSkill, explicit reference
|
||||||
op 0x20000fa-0x2000114: ModSkill
|
op 0x20000fa-0x2000114: ModSkill
|
||||||
op 0x2000115-0x200012f: ModSKill, explicit reference
|
op 0x2000115-0x200012f: ModSKill, explicit reference
|
||||||
opcodes 0x2000130-0x3ffffff unused
|
op 0x2000130: ToggleCollision
|
||||||
|
opcodes 0x2000131-0x3ffffff unused
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
#include <components/interpreter/runtime.hpp>
|
#include <components/interpreter/runtime.hpp>
|
||||||
#include <components/interpreter/opcodes.hpp>
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
|
||||||
|
#include "interpretercontext.hpp"
|
||||||
|
#include "ref.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
namespace Misc
|
namespace Misc
|
||||||
@ -55,42 +56,14 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpLock : public Interpreter::Opcode1
|
class OpLock : public Interpreter::Opcode1
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||||
{
|
{
|
||||||
InterpreterContext& context =
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer lockLevel = 100;
|
|
||||||
|
|
||||||
if (arg0==1)
|
|
||||||
{
|
|
||||||
lockLevel = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).lock (ptr, lockLevel);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpLockExplicit : public Interpreter::Opcode1
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
|
||||||
{
|
|
||||||
InterpreterContext& context =
|
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer lockLevel = 100;
|
Interpreter::Type_Integer lockLevel = 100;
|
||||||
|
|
||||||
@ -104,34 +77,14 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpUnlock : public Interpreter::Opcode0
|
class OpUnlock : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
InterpreterContext& context =
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).unlock (ptr);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpUnlockExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
InterpreterContext& context =
|
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).unlock (ptr);
|
MWWorld::Class::get (ptr).unlock (ptr);
|
||||||
}
|
}
|
||||||
@ -160,10 +113,10 @@ namespace MWScript
|
|||||||
interpreter.installSegment5 (opcodeXBox, new OpXBox);
|
interpreter.installSegment5 (opcodeXBox, new OpXBox);
|
||||||
interpreter.installSegment5 (opcodeOnActivate, new OpOnActivate);
|
interpreter.installSegment5 (opcodeOnActivate, new OpOnActivate);
|
||||||
interpreter.installSegment5 (opcodeActivate, new OpActivate);
|
interpreter.installSegment5 (opcodeActivate, new OpActivate);
|
||||||
interpreter.installSegment3 (opcodeLock, new OpLock);
|
interpreter.installSegment3 (opcodeLock, new OpLock<ImplicitRef>);
|
||||||
interpreter.installSegment3 (opcodeLockExplicit, new OpLockExplicit);
|
interpreter.installSegment3 (opcodeLockExplicit, new OpLock<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeUnlock, new OpUnlock);
|
interpreter.installSegment5 (opcodeUnlock, new OpUnlock<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlockExplicit);
|
interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlock<ExplicitRef>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
41
apps/openmw/mwscript/ref.hpp
Normal file
41
apps/openmw/mwscript/ref.hpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#ifndef GAME_MWSCRIPT_REF_H
|
||||||
|
#define GAME_MWSCRIPT_REF_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <components/interpreter/runtime.hpp>
|
||||||
|
|
||||||
|
#include "../mwworld/ptr.hpp"
|
||||||
|
#include "../mwworld/world.hpp"
|
||||||
|
|
||||||
|
#include "interpretercontext.hpp"
|
||||||
|
|
||||||
|
namespace MWScript
|
||||||
|
{
|
||||||
|
struct ExplicitRef
|
||||||
|
{
|
||||||
|
MWWorld::Ptr operator() (Interpreter::Runtime& runtime) const
|
||||||
|
{
|
||||||
|
MWScript::InterpreterContext& context
|
||||||
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
|
||||||
|
return context.getWorld().getPtr (id, false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ImplicitRef
|
||||||
|
{
|
||||||
|
MWWorld::Ptr operator() (Interpreter::Runtime& runtime) const
|
||||||
|
{
|
||||||
|
MWScript::InterpreterContext& context
|
||||||
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
return context.getReference();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -7,22 +7,26 @@
|
|||||||
#include <components/interpreter/runtime.hpp>
|
#include <components/interpreter/runtime.hpp>
|
||||||
#include <components/interpreter/opcodes.hpp>
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
|
||||||
|
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
|
|
||||||
#include "../mwsound/soundmanager.hpp"
|
#include "../mwsound/soundmanager.hpp"
|
||||||
|
|
||||||
|
#include "interpretercontext.hpp"
|
||||||
|
#include "ref.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
namespace Sound
|
namespace Sound
|
||||||
{
|
{
|
||||||
|
template<class R>
|
||||||
class OpSay : public Interpreter::Opcode0
|
class OpSay : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
@ -32,296 +36,173 @@ namespace MWScript
|
|||||||
std::string text = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string text = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().say (context.getReference(), file);
|
context.getSoundManager().say (ptr, file);
|
||||||
context.messageBox (text);
|
context.messageBox (text);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpSayDone : public Interpreter::Opcode0
|
class OpSayDone : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
runtime.push (context.getSoundManager().sayDone (context.getReference()));
|
runtime.push (context.getSoundManager().sayDone (ptr));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpStreamMusic : public Interpreter::Opcode0
|
class OpStreamMusic : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().streamMusic (sound);
|
context.getSoundManager().streamMusic (sound);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpPlaySound : public Interpreter::Opcode0
|
class OpPlaySound : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().playSound (sound, 1.0, 1.0);
|
context.getSoundManager().playSound (sound, 1.0, 1.0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpPlaySoundVP : public Interpreter::Opcode0
|
class OpPlaySoundVP : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
Interpreter::Type_Float volume = runtime[0].mFloat;
|
Interpreter::Type_Float volume = runtime[0].mFloat;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().playSound (sound, volume, pitch);
|
context.getSoundManager().playSound (sound, volume, pitch);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpPlaySound3D : public Interpreter::Opcode0
|
class OpPlaySound3D : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
bool mLoop;
|
bool mLoop;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OpPlaySound3D (bool loop) : mLoop (loop) {}
|
OpPlaySound3D (bool loop) : mLoop (loop) {}
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().playSound3D (context.getReference(), sound,
|
context.getSoundManager().playSound3D (ptr, sound, 1.0, 1.0, mLoop);
|
||||||
1.0, 1.0, mLoop);
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
template<class R>
|
||||||
class OpPlaySoundVP3D : public Interpreter::Opcode0
|
class OpPlaySoundVP3D : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
bool mLoop;
|
bool mLoop;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OpPlaySoundVP3D (bool loop) : mLoop (loop) {}
|
OpPlaySoundVP3D (bool loop) : mLoop (loop) {}
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
Interpreter::Type_Float volume = runtime[0].mFloat;
|
Interpreter::Type_Float volume = runtime[0].mFloat;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().playSound3D (context.getReference(), sound, volume,
|
|
||||||
pitch, mLoop);
|
|
||||||
|
|
||||||
}
|
context.getSoundManager().playSound3D (ptr, sound, volume, pitch, mLoop);
|
||||||
};
|
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpStopSound : public Interpreter::Opcode0
|
class OpStopSound : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().stopSound3D (context.getReference(), sound);
|
context.getSoundManager().stopSound3D (ptr, sound);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpGetSoundPlaying : public Interpreter::Opcode0
|
class OpGetSoundPlaying : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
int index = runtime[0].mInteger;
|
int index = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
runtime.push (context.getSoundManager().getSoundPlaying (
|
runtime.push (context.getSoundManager().getSoundPlaying (
|
||||||
context.getReference(), runtime.getStringLiteral (index)));
|
ptr, runtime.getStringLiteral (index)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpSayExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string file = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string text = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
context.getSoundManager().say (context.getWorld().getPtr (id, true),
|
|
||||||
file);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpSayDoneExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
runtime.push (context.getSoundManager().sayDone (
|
|
||||||
context.getWorld().getPtr (id, true)));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpPlaySound3DExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
bool mLoop;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpPlaySound3DExplicit (bool loop) : mLoop (loop) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
context.getSoundManager().playSound3D (
|
|
||||||
context.getWorld().getPtr (id, true), sound, 1.0, 1.0, mLoop);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpPlaySoundVP3DExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
bool mLoop;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpPlaySoundVP3DExplicit (bool loop) : mLoop (loop) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float volume = runtime[0].mFloat;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
context.getSoundManager().playSound3D (
|
|
||||||
context.getWorld().getPtr (id, true), sound, volume, pitch, mLoop);
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpStopSoundExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
context.getSoundManager().stopSound3D (
|
|
||||||
context.getWorld().getPtr (id, true), sound);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetSoundPlayingExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
int index = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
runtime.push (context.getSoundManager().getSoundPlaying (
|
|
||||||
context.getWorld().getPtr (id, true),
|
|
||||||
runtime.getStringLiteral (index)));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const int opcodeSay = 0x2000001;
|
const int opcodeSay = 0x2000001;
|
||||||
const int opcodeSayDone = 0x2000002;
|
const int opcodeSayDone = 0x2000002;
|
||||||
const int opcodeStreamMusic = 0x2000003;
|
const int opcodeStreamMusic = 0x2000003;
|
||||||
@ -342,7 +223,7 @@ namespace MWScript
|
|||||||
const int opcodePlayLoopSound3DVPExplicit = 0x200001e;
|
const int opcodePlayLoopSound3DVPExplicit = 0x200001e;
|
||||||
const int opcodeStopSoundExplicit = 0x200001f;
|
const int opcodeStopSoundExplicit = 0x200001f;
|
||||||
const int opcodeGetSoundPlayingExplicit = 0x2000020;
|
const int opcodeGetSoundPlayingExplicit = 0x2000020;
|
||||||
|
|
||||||
void registerExtensions (Compiler::Extensions& extensions)
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
{
|
{
|
||||||
extensions.registerInstruction ("say", "SS", opcodeSay, opcodeSayExplicit);
|
extensions.registerInstruction ("say", "SS", opcodeSay, opcodeSayExplicit);
|
||||||
@ -361,37 +242,37 @@ namespace MWScript
|
|||||||
extensions.registerInstruction ("stopsound", "c", opcodeStopSound,
|
extensions.registerInstruction ("stopsound", "c", opcodeStopSound,
|
||||||
opcodeStopSoundExplicit);
|
opcodeStopSoundExplicit);
|
||||||
extensions.registerFunction ("getsoundplaying", 'l', "c", opcodeGetSoundPlaying,
|
extensions.registerFunction ("getsoundplaying", 'l', "c", opcodeGetSoundPlaying,
|
||||||
opcodeGetSoundPlayingExplicit);
|
opcodeGetSoundPlayingExplicit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
{
|
{
|
||||||
interpreter.installSegment5 (opcodeSay, new OpSay);
|
interpreter.installSegment5 (opcodeSay, new OpSay<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeSayDone, new OpSayDone);
|
interpreter.installSegment5 (opcodeSayDone, new OpSayDone<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeStreamMusic, new OpStreamMusic);
|
interpreter.installSegment5 (opcodeStreamMusic, new OpStreamMusic);
|
||||||
interpreter.installSegment5 (opcodePlaySound, new OpPlaySound);
|
interpreter.installSegment5 (opcodePlaySound, new OpPlaySound);
|
||||||
interpreter.installSegment5 (opcodePlaySoundVP, new OpPlaySoundVP);
|
interpreter.installSegment5 (opcodePlaySoundVP, new OpPlaySoundVP);
|
||||||
interpreter.installSegment5 (opcodePlaySound3D, new OpPlaySound3D (false));
|
interpreter.installSegment5 (opcodePlaySound3D, new OpPlaySound3D<ImplicitRef> (false));
|
||||||
interpreter.installSegment5 (opcodePlaySound3DVP, new OpPlaySoundVP3D (false));
|
interpreter.installSegment5 (opcodePlaySound3DVP, new OpPlaySoundVP3D<ImplicitRef> (false));
|
||||||
interpreter.installSegment5 (opcodePlayLoopSound3D, new OpPlaySound3D (true));
|
interpreter.installSegment5 (opcodePlayLoopSound3D, new OpPlaySound3D<ImplicitRef> (true));
|
||||||
interpreter.installSegment5 (opcodePlayLoopSound3DVP, new OpPlaySoundVP3D (true));
|
interpreter.installSegment5 (opcodePlayLoopSound3DVP,
|
||||||
interpreter.installSegment5 (opcodeStopSound, new OpStopSound);
|
new OpPlaySoundVP3D<ImplicitRef> (true));
|
||||||
interpreter.installSegment5 (opcodeGetSoundPlaying, new OpGetSoundPlaying);
|
interpreter.installSegment5 (opcodeStopSound, new OpStopSound<ImplicitRef>);
|
||||||
|
interpreter.installSegment5 (opcodeGetSoundPlaying, new OpGetSoundPlaying<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeSayExplicit, new OpSayExplicit);
|
|
||||||
interpreter.installSegment5 (opcodeSayDoneExplicit, new OpSayDoneExplicit);
|
|
||||||
interpreter.installSegment5 (opcodePlaySound3DExplicit,
|
|
||||||
new OpPlaySound3DExplicit (false));
|
|
||||||
interpreter.installSegment5 (opcodePlaySound3DVPExplicit,
|
|
||||||
new OpPlaySoundVP3DExplicit (false));
|
|
||||||
interpreter.installSegment5 (opcodePlayLoopSound3DExplicit,
|
|
||||||
new OpPlaySound3DExplicit (true));
|
|
||||||
interpreter.installSegment5 (opcodePlayLoopSound3DVPExplicit,
|
|
||||||
new OpPlaySoundVP3DExplicit (true));
|
|
||||||
interpreter.installSegment5 (opcodeStopSoundExplicit, new OpStopSoundExplicit);
|
|
||||||
interpreter.installSegment5 (opcodeGetSoundPlayingExplicit,
|
|
||||||
new OpGetSoundPlayingExplicit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
interpreter.installSegment5 (opcodeSayExplicit, new OpSay<ExplicitRef>);
|
||||||
|
interpreter.installSegment5 (opcodeSayDoneExplicit, new OpSayDone<ExplicitRef>);
|
||||||
|
interpreter.installSegment5 (opcodePlaySound3DExplicit,
|
||||||
|
new OpPlaySound3D<ExplicitRef> (false));
|
||||||
|
interpreter.installSegment5 (opcodePlaySound3DVPExplicit,
|
||||||
|
new OpPlaySoundVP3D<ExplicitRef> (false));
|
||||||
|
interpreter.installSegment5 (opcodePlayLoopSound3DExplicit,
|
||||||
|
new OpPlaySound3D<ExplicitRef> (true));
|
||||||
|
interpreter.installSegment5 (opcodePlayLoopSound3DVPExplicit,
|
||||||
|
new OpPlaySoundVP3D<ExplicitRef> (true));
|
||||||
|
interpreter.installSegment5 (opcodeStopSoundExplicit, new OpStopSound<ExplicitRef>);
|
||||||
|
interpreter.installSegment5 (opcodeGetSoundPlayingExplicit,
|
||||||
|
new OpGetSoundPlaying<ExplicitRef>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -12,11 +12,13 @@
|
|||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
|
#include "ref.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
namespace Stats
|
namespace Stats
|
||||||
{
|
{
|
||||||
|
template<class R>
|
||||||
class OpGetAttribute : public Interpreter::Opcode0
|
class OpGetAttribute : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
@ -27,36 +29,7 @@ namespace MWScript
|
|||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value =
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
|
||||||
getModified();
|
|
||||||
|
|
||||||
runtime.push (value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetAttributeExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpGetAttributeExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value =
|
Interpreter::Type_Integer value =
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||||
@ -66,6 +39,7 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpSetAttribute : public Interpreter::Opcode0
|
class OpSetAttribute : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
@ -76,45 +50,17 @@ namespace MWScript
|
|||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
|
||||||
setModified (value, 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpSetAttributeExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpSetAttributeExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||||
setModified (value, 0);
|
setModified (value, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpModAttribute : public Interpreter::Opcode0
|
class OpModAttribute : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
@ -125,14 +71,11 @@ namespace MWScript
|
|||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
value += MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
value += MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||||
getModified();
|
getModified();
|
||||||
|
|
||||||
@ -141,36 +84,7 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpModAttributeExplicit : public Interpreter::Opcode0
|
template<class R>
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpModAttributeExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
value +=
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
|
||||||
getModified();
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
|
||||||
setModified (value, 0, 100);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetDynamic : public Interpreter::Opcode0
|
class OpGetDynamic : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
@ -181,46 +95,7 @@ namespace MWScript
|
|||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr))
|
|
||||||
{
|
|
||||||
// health is a special case
|
|
||||||
Interpreter::Type_Integer value =
|
|
||||||
MWWorld::Class::get (ptr).getItemMaxHealth (ptr);
|
|
||||||
runtime.push (value);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value =
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
|
||||||
getCurrent();
|
|
||||||
|
|
||||||
runtime.push (value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetDynamicExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpGetDynamicExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr))
|
if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr))
|
||||||
{
|
{
|
||||||
@ -240,6 +115,7 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpSetDynamic : public Interpreter::Opcode0
|
class OpSetDynamic : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
@ -250,45 +126,17 @@ namespace MWScript
|
|||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
|
||||||
setModified (value, 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpSetDynamicExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpSetDynamicExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
||||||
setModified (value, 0);
|
setModified (value, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpModDynamic : public Interpreter::Opcode0
|
class OpModDynamic : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
@ -299,14 +147,11 @@ namespace MWScript
|
|||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
|
|
||||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
||||||
@ -318,40 +163,7 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpModDynamicExplicit : public Interpreter::Opcode0
|
template<class R>
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpModDynamicExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats =
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
|
||||||
|
|
||||||
stats.mDynamic[mIndex].setModified (
|
|
||||||
diff + stats.mDynamic[mIndex].getModified(), 0);
|
|
||||||
|
|
||||||
stats.mDynamic[mIndex].setCurrent (diff + current);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class OpModCurrentDynamic : public Interpreter::Opcode0
|
class OpModCurrentDynamic : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
@ -362,14 +174,11 @@ namespace MWScript
|
|||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
|
|
||||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
||||||
@ -378,36 +187,7 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpModCurrentDynamicExplicit : public Interpreter::Opcode0
|
template<class R>
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpModCurrentDynamicExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats =
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
|
||||||
|
|
||||||
stats.mDynamic[mIndex].setCurrent (diff + current);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetDynamicGetRatio : public Interpreter::Opcode0
|
class OpGetDynamicGetRatio : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
@ -418,10 +198,7 @@ namespace MWScript
|
|||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
|
|
||||||
@ -436,38 +213,7 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpGetDynamicGetRatioExplicit : public Interpreter::Opcode0
|
template<class R>
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpGetDynamicGetRatioExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats =
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
|
||||||
|
|
||||||
Interpreter::Type_Float value = 0;
|
|
||||||
|
|
||||||
Interpreter::Type_Float max = stats.mDynamic[mIndex].getModified();
|
|
||||||
|
|
||||||
if (max>0)
|
|
||||||
value = stats.mDynamic[mIndex].getCurrent() / max;
|
|
||||||
|
|
||||||
runtime.push (value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetSkill : public Interpreter::Opcode0
|
class OpGetSkill : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
@ -478,36 +224,7 @@ namespace MWScript
|
|||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value =
|
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
|
||||||
getModified();
|
|
||||||
|
|
||||||
runtime.push (value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetSkillExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpGetSkillExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value =
|
Interpreter::Type_Integer value =
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||||
@ -517,6 +234,7 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpSetSkill : public Interpreter::Opcode0
|
class OpSetSkill : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
@ -527,45 +245,17 @@ namespace MWScript
|
|||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
|
||||||
setModified (value, 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpSetSkillExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpSetSkillExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||||
setModified (value, 0);
|
setModified (value, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpModSkill : public Interpreter::Opcode0
|
class OpModSkill : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
@ -576,14 +266,11 @@ namespace MWScript
|
|||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
value += MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
value += MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||||
getModified();
|
getModified();
|
||||||
|
|
||||||
@ -592,36 +279,6 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpModSkillExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpModSkillExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
value +=
|
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
|
||||||
getModified();
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
|
||||||
setModified (value, 0, 100);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const int numberOfAttributes = 8;
|
const int numberOfAttributes = 8;
|
||||||
|
|
||||||
const int opcodeGetAttribute = 0x2000027;
|
const int opcodeGetAttribute = 0x2000027;
|
||||||
@ -729,53 +386,54 @@ namespace MWScript
|
|||||||
{
|
{
|
||||||
for (int i=0; i<numberOfAttributes; ++i)
|
for (int i=0; i<numberOfAttributes; ++i)
|
||||||
{
|
{
|
||||||
interpreter.installSegment5 (opcodeGetAttribute+i, new OpGetAttribute (i));
|
interpreter.installSegment5 (opcodeGetAttribute+i, new OpGetAttribute<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeGetAttributeExplicit+i,
|
interpreter.installSegment5 (opcodeGetAttributeExplicit+i,
|
||||||
new OpGetAttributeExplicit (i));
|
new OpGetAttribute<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeSetAttribute+i, new OpSetAttribute (i));
|
interpreter.installSegment5 (opcodeSetAttribute+i, new OpSetAttribute<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeSetAttributeExplicit+i,
|
interpreter.installSegment5 (opcodeSetAttributeExplicit+i,
|
||||||
new OpSetAttributeExplicit (i));
|
new OpSetAttribute<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeModAttribute+i, new OpModAttribute (i));
|
interpreter.installSegment5 (opcodeModAttribute+i, new OpModAttribute<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeModAttributeExplicit+i,
|
interpreter.installSegment5 (opcodeModAttributeExplicit+i,
|
||||||
new OpModAttributeExplicit (i));
|
new OpModAttribute<ExplicitRef> (i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<numberOfDynamics; ++i)
|
for (int i=0; i<numberOfDynamics; ++i)
|
||||||
{
|
{
|
||||||
interpreter.installSegment5 (opcodeGetDynamic+i, new OpGetDynamic (i));
|
interpreter.installSegment5 (opcodeGetDynamic+i, new OpGetDynamic<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeGetDynamicExplicit+i,
|
interpreter.installSegment5 (opcodeGetDynamicExplicit+i,
|
||||||
new OpGetDynamicExplicit (i));
|
new OpGetDynamic<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeSetDynamic+i, new OpSetDynamic (i));
|
interpreter.installSegment5 (opcodeSetDynamic+i, new OpSetDynamic<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeSetDynamicExplicit+i,
|
interpreter.installSegment5 (opcodeSetDynamicExplicit+i,
|
||||||
new OpSetDynamicExplicit (i));
|
new OpSetDynamic<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeModDynamic+i, new OpModDynamic (i));
|
interpreter.installSegment5 (opcodeModDynamic+i, new OpModDynamic<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeModDynamicExplicit+i,
|
interpreter.installSegment5 (opcodeModDynamicExplicit+i,
|
||||||
new OpModDynamicExplicit (i));
|
new OpModDynamic<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeModCurrentDynamic+i, new OpModCurrentDynamic (i));
|
interpreter.installSegment5 (opcodeModCurrentDynamic+i,
|
||||||
|
new OpModCurrentDynamic<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeModCurrentDynamicExplicit+i,
|
interpreter.installSegment5 (opcodeModCurrentDynamicExplicit+i,
|
||||||
new OpModCurrentDynamicExplicit (i));
|
new OpModCurrentDynamic<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeGetDynamicGetRatio+i,
|
interpreter.installSegment5 (opcodeGetDynamicGetRatio+i,
|
||||||
new OpGetDynamicGetRatio (i));
|
new OpGetDynamicGetRatio<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeGetDynamicGetRatioExplicit+i,
|
interpreter.installSegment5 (opcodeGetDynamicGetRatioExplicit+i,
|
||||||
new OpGetDynamicGetRatioExplicit (i));
|
new OpGetDynamicGetRatio<ExplicitRef> (i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<numberOfSkills; ++i)
|
for (int i=0; i<numberOfSkills; ++i)
|
||||||
{
|
{
|
||||||
interpreter.installSegment5 (opcodeGetSkill+i, new OpGetSkill (i));
|
interpreter.installSegment5 (opcodeGetSkill+i, new OpGetSkill<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeGetSkillExplicit+i, new OpGetSkillExplicit (i));
|
interpreter.installSegment5 (opcodeGetSkillExplicit+i, new OpGetSkill<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeSetSkill+i, new OpSetSkill (i));
|
interpreter.installSegment5 (opcodeSetSkill+i, new OpSetSkill<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeSetSkillExplicit+i, new OpSetSkillExplicit (i));
|
interpreter.installSegment5 (opcodeSetSkillExplicit+i, new OpSetSkill<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeModSkill+i, new OpModSkill (i));
|
interpreter.installSegment5 (opcodeModSkill+i, new OpModSkill<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkillExplicit (i));
|
interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkill<ExplicitRef> (i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,60 +323,64 @@ 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 = false;
|
||||||
return test;
|
if(mData && mData->music)
|
||||||
}
|
{
|
||||||
|
test = mData->music->isPlaying();
|
||||||
|
}
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
|
||||||
SoundManager::SoundImpl SoundManager::getMData()
|
SoundManager::SoundImpl SoundManager::getMData()
|
||||||
{
|
{
|
||||||
// bool test = mData->music->isPlaying();
|
// bool test = mData->music->isPlaying();
|
||||||
return *mData;
|
return *mData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename)
|
void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename)
|
||||||
{
|
{
|
||||||
// The range values are not tested
|
// The range values are not tested
|
||||||
@ -400,8 +404,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);
|
||||||
|
@ -21,28 +21,28 @@ 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
|
||||||
// enough as it is.
|
// enough as it is.
|
||||||
struct SoundImpl;
|
struct SoundImpl;
|
||||||
|
|
||||||
SoundImpl *mData;
|
SoundImpl *mData;
|
||||||
std::vector<boost::filesystem::path> files;
|
std::vector<boost::filesystem::path> files;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SoundManager(Ogre::Root*, Ogre::Camera*, const ESMS::ESMStore &store,
|
SoundManager(Ogre::Root*, Ogre::Camera*, const ESMS::ESMStore &store,
|
||||||
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.
|
||||||
|
64
apps/openmw/mwworld/player.cpp
Normal file
64
apps/openmw/mwworld/player.cpp
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
|
||||||
|
#include "player.hpp"
|
||||||
|
|
||||||
|
#include "../mwrender/player.hpp"
|
||||||
|
|
||||||
|
#include "world.hpp"
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
Player::Player (MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world) :
|
||||||
|
mCellStore (0), mRenderer (renderer), mWorld (world), mClass (0), mCollisionMode (true)
|
||||||
|
{
|
||||||
|
mPlayer.base = player;
|
||||||
|
mName = player->name;
|
||||||
|
mMale = !(player->flags & ESM::NPC::Female);
|
||||||
|
mRace = player->race;
|
||||||
|
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
|
||||||
|
mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
|
||||||
|
}
|
||||||
|
|
||||||
|
Player::~Player()
|
||||||
|
{
|
||||||
|
delete mClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::setPos(float x, float y, float z, bool updateCamera)
|
||||||
|
{
|
||||||
|
mWorld.moveObject (getPlayer(), x, y, z);
|
||||||
|
|
||||||
|
if (updateCamera)
|
||||||
|
mRenderer->getCamera()->setPosition (Ogre::Vector3 (
|
||||||
|
mPlayer.ref.pos.pos[0],
|
||||||
|
mPlayer.ref.pos.pos[2],
|
||||||
|
-mPlayer.ref.pos.pos[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::moveRel (float &relX, float &relY, float &relZ)
|
||||||
|
{
|
||||||
|
// Move camera relative to its own direction
|
||||||
|
mRenderer->getCamera()->moveRelative (Ogre::Vector3(relX,0,relZ));
|
||||||
|
|
||||||
|
// Up/down movement is always done relative the world axis.
|
||||||
|
mRenderer->getCamera()->move (Ogre::Vector3(0,relY,0));
|
||||||
|
|
||||||
|
// Get new camera position, converting back to MW coords.
|
||||||
|
Ogre::Vector3 pos = mRenderer->getCamera()->getPosition();
|
||||||
|
relX = pos[0];
|
||||||
|
relY = -pos[2];
|
||||||
|
relZ = pos[1];
|
||||||
|
|
||||||
|
// TODO: Collision detection must be used to find the REAL new
|
||||||
|
// position, if mCollisionMode==true
|
||||||
|
|
||||||
|
// Set the position
|
||||||
|
setPos(relX, relY, relZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::setClass (const ESM::Class& class_)
|
||||||
|
{
|
||||||
|
ESM::Class *new_class = new ESM::Class (class_);
|
||||||
|
delete mClass;
|
||||||
|
mClass = new_class;
|
||||||
|
}
|
||||||
|
}
|
113
apps/openmw/mwworld/player.hpp
Normal file
113
apps/openmw/mwworld/player.hpp
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
#ifndef GAME_MWWORLD_PLAYER_H
|
||||||
|
#define GAME_MWWORLD_PLAYER_H
|
||||||
|
|
||||||
|
#include "OgreCamera.h"
|
||||||
|
|
||||||
|
#include <components/esm_store/cell_store.hpp>
|
||||||
|
|
||||||
|
#include "../mwworld/refdata.hpp"
|
||||||
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
|
namespace MWRender
|
||||||
|
{
|
||||||
|
class Player;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class World;
|
||||||
|
|
||||||
|
/// \brief NPC object representing the player and additional player data
|
||||||
|
class Player
|
||||||
|
{
|
||||||
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> mPlayer;
|
||||||
|
MWWorld::Ptr::CellStore *mCellStore;
|
||||||
|
MWRender::Player *mRenderer;
|
||||||
|
MWWorld::World& mWorld;
|
||||||
|
std::string mName;
|
||||||
|
bool mMale;
|
||||||
|
std::string mRace;
|
||||||
|
std::string mBirthsign;
|
||||||
|
ESM::Class *mClass;
|
||||||
|
bool mCollisionMode;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Player(MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world);
|
||||||
|
|
||||||
|
~Player();
|
||||||
|
|
||||||
|
/// Set the player position. Uses Morrowind coordinates.
|
||||||
|
void setPos(float _x, float _y, float _z, bool updateCamera = false);
|
||||||
|
|
||||||
|
void setCell (MWWorld::Ptr::CellStore *cellStore)
|
||||||
|
{
|
||||||
|
mCellStore = cellStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Move the player relative to her own position and
|
||||||
|
/// orientation. After the call, the new position is returned.
|
||||||
|
void moveRel (float &relX, float &relY, float &relZ);
|
||||||
|
|
||||||
|
MWWorld::Ptr getPlayer()
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr (&mPlayer, mCellStore);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWRender::Player *getRenderer() { return mRenderer; }
|
||||||
|
|
||||||
|
void setName (const std::string& name)
|
||||||
|
{
|
||||||
|
mName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setGender (bool male)
|
||||||
|
{
|
||||||
|
mMale = male;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setRace (const std::string& race)
|
||||||
|
{
|
||||||
|
mRace = race;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBirthsign (const std::string& birthsign)
|
||||||
|
{
|
||||||
|
mBirthsign = birthsign;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setClass (const ESM::Class& class_);
|
||||||
|
|
||||||
|
std::string getName() const
|
||||||
|
{
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isMale() const
|
||||||
|
{
|
||||||
|
return mMale;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getRace() const
|
||||||
|
{
|
||||||
|
return mRace;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getBirthsign() const
|
||||||
|
{
|
||||||
|
return mBirthsign;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ESM::Class& getClass() const
|
||||||
|
{
|
||||||
|
return *mClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleCollisionMode()
|
||||||
|
{
|
||||||
|
mCollisionMode = !mCollisionMode;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
@ -17,7 +17,7 @@
|
|||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
#include "environment.hpp"
|
#include "environment.hpp"
|
||||||
#include "class.hpp"
|
#include "class.hpp"
|
||||||
|
#include "player.hpp"
|
||||||
|
|
||||||
#include "refdata.hpp"
|
#include "refdata.hpp"
|
||||||
#include "globals.hpp"
|
#include "globals.hpp"
|
||||||
@ -296,12 +296,12 @@ namespace MWWorld
|
|||||||
|
|
||||||
void World::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position)
|
void World::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position)
|
||||||
{
|
{
|
||||||
mPlayerPos->setPos (position.pos[0], position.pos[1], position.pos[2], true);
|
mPlayer->setPos (position.pos[0], position.pos[1], position.pos[2], true);
|
||||||
mPlayerPos->setCell (cell);
|
mPlayer->setCell (cell);
|
||||||
// TODO orientation
|
// TODO orientation
|
||||||
|
|
||||||
mEnvironment.mMechanicsManager->addActor (mPlayerPos->getPlayer());
|
mEnvironment.mMechanicsManager->addActor (mPlayer->getPlayer());
|
||||||
mEnvironment.mMechanicsManager->watchActor (mPlayerPos->getPlayer());
|
mEnvironment.mMechanicsManager->watchActor (mPlayer->getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ namespace MWWorld
|
|||||||
|
|
||||||
World::World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir,
|
World::World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir,
|
||||||
const std::string& master, bool newGame, Environment& environment)
|
const std::string& master, bool newGame, Environment& environment)
|
||||||
: mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0), mGlobalVariables (0),
|
: mSkyManager (0), mScene (renderer), mPlayer (0), mCurrentCell (0), mGlobalVariables (0),
|
||||||
mSky (false), mCellChanged (false), mEnvironment (environment)
|
mSky (false), mCellChanged (false), mEnvironment (environment)
|
||||||
{
|
{
|
||||||
boost::filesystem::path masterPath (dataDir);
|
boost::filesystem::path masterPath (dataDir);
|
||||||
@ -329,7 +329,7 @@ namespace MWWorld
|
|||||||
mEsm.open (masterPath.file_string());
|
mEsm.open (masterPath.file_string());
|
||||||
mStore.load (mEsm);
|
mStore.load (mEsm);
|
||||||
|
|
||||||
mPlayerPos = new MWRender::PlayerPos (mScene.getCamera(), mStore.npcs.find ("player"), *this);
|
mPlayer = new MWWorld::Player (mScene.getPlayer(), mStore.npcs.find ("player"), *this);
|
||||||
|
|
||||||
// global variables
|
// global variables
|
||||||
mGlobalVariables = new Globals (mStore);
|
mGlobalVariables = new Globals (mStore);
|
||||||
@ -354,14 +354,14 @@ namespace MWWorld
|
|||||||
iter!=mBufferedCells.end(); ++iter)
|
iter!=mBufferedCells.end(); ++iter)
|
||||||
delete iter->second;
|
delete iter->second;
|
||||||
|
|
||||||
delete mPlayerPos;
|
delete mPlayer;
|
||||||
delete mSkyManager;
|
delete mSkyManager;
|
||||||
delete mGlobalVariables;
|
delete mGlobalVariables;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWRender::PlayerPos& World::getPlayerPos()
|
MWWorld::Player& World::getPlayer()
|
||||||
{
|
{
|
||||||
return *mPlayerPos;
|
return *mPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESMS::ESMStore& World::getStore()
|
ESMS::ESMStore& World::getStore()
|
||||||
@ -394,7 +394,7 @@ namespace MWWorld
|
|||||||
// the player is always in an active cell.
|
// the player is always in an active cell.
|
||||||
if (name=="player")
|
if (name=="player")
|
||||||
{
|
{
|
||||||
return mPlayerPos->getPlayer();
|
return mPlayer->getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// active cells
|
// active cells
|
||||||
@ -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)
|
||||||
@ -763,7 +763,7 @@ namespace MWWorld
|
|||||||
ptr.getCellRef().pos.pos[1] = y;
|
ptr.getCellRef().pos.pos[1] = y;
|
||||||
ptr.getCellRef().pos.pos[2] = z;
|
ptr.getCellRef().pos.pos[2] = z;
|
||||||
|
|
||||||
if (ptr==mPlayerPos->getPlayer())
|
if (ptr==mPlayer->getPlayer())
|
||||||
{
|
{
|
||||||
if (mCurrentCell)
|
if (mCurrentCell)
|
||||||
{
|
{
|
||||||
@ -777,7 +777,7 @@ namespace MWWorld
|
|||||||
|
|
||||||
if (mCurrentCell->cell->data.gridX!=cellX || mCurrentCell->cell->data.gridY!=cellY)
|
if (mCurrentCell->cell->data.gridX!=cellX || mCurrentCell->cell->data.gridY!=cellY)
|
||||||
{
|
{
|
||||||
changeCell (cellX, cellY, mPlayerPos->getPlayer().getCellRef().pos);
|
changeCell (cellX, cellY, mPlayer->getPlayer().getCellRef().pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -800,8 +800,6 @@ namespace MWWorld
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void World::positionToIndex (float x, float y, int &cellX, int &cellY) const
|
void World::positionToIndex (float x, float y, int &cellX, int &cellY) const
|
||||||
{
|
{
|
||||||
const int cellSize = 8192;
|
const int cellSize = 8192;
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
#include <components/esm_store/cell_store.hpp>
|
||||||
|
|
||||||
#include "../mwrender/playerpos.hpp"
|
|
||||||
#include "../mwrender/mwscene.hpp"
|
#include "../mwrender/mwscene.hpp"
|
||||||
|
|
||||||
#include "refdata.hpp"
|
#include "refdata.hpp"
|
||||||
@ -34,12 +33,13 @@ namespace MWRender
|
|||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class Environment;
|
class Environment;
|
||||||
|
class Player;
|
||||||
|
|
||||||
/// \brief The game world and its visual representation
|
/// \brief The game world and its visual representation
|
||||||
|
|
||||||
class World
|
class World
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef std::list<std::pair<std::string, Ptr> > ScriptList;
|
typedef std::list<std::pair<std::string, Ptr> > ScriptList;
|
||||||
|
|
||||||
@ -49,8 +49,8 @@ namespace MWWorld
|
|||||||
|
|
||||||
MWRender::SkyManager* mSkyManager;
|
MWRender::SkyManager* mSkyManager;
|
||||||
MWRender::MWScene mScene;
|
MWRender::MWScene mScene;
|
||||||
MWRender::PlayerPos *mPlayerPos;
|
MWWorld::Player *mPlayer;
|
||||||
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;
|
||||||
@ -94,9 +94,9 @@ namespace MWWorld
|
|||||||
|
|
||||||
~World();
|
~World();
|
||||||
|
|
||||||
MWRender::PlayerPos& getPlayerPos();
|
MWWorld::Player& getPlayer();
|
||||||
|
|
||||||
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.
|
||||||
|
@ -38,10 +38,13 @@ ENDIF (WIN32)
|
|||||||
IF (UNIX AND NOT APPLE)
|
IF (UNIX AND NOT APPLE)
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR)
|
||||||
FIND_PACKAGE(PkgConfig REQUIRED)
|
FIND_PACKAGE(PkgConfig REQUIRED)
|
||||||
PKG_SEARCH_MODULE(OGRE REQUIRED OGRE)
|
# Don't mark REQUIRED, but use PKG_CHECK_MODULES below (otherwise PkgConfig
|
||||||
|
# complains even if OGRE_* are set by hand).
|
||||||
|
PKG_SEARCH_MODULE(OGRE OGRE)
|
||||||
SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIRS})
|
SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIRS})
|
||||||
SET(OGRE_LIB_DIR ${OGRE_LIBDIR})
|
SET(OGRE_LIB_DIR ${OGRE_LIBDIR})
|
||||||
SET(OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "")
|
SET(OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "")
|
||||||
|
PKG_CHECK_MODULES(OGRE OGRE)
|
||||||
ENDIF (UNIX AND NOT APPLE)
|
ENDIF (UNIX AND NOT APPLE)
|
||||||
|
|
||||||
IF (APPLE)
|
IF (APPLE)
|
||||||
|
@ -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 */
|
||||||
|
@ -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 */
|
||||||
|
@ -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?
|
||||||
|
@ -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.
|
||||||
|
@ -30,7 +30,7 @@ namespace Compiler
|
|||||||
// constructors
|
// constructors
|
||||||
|
|
||||||
StreamErrorHandler (std::ostream& ErrorStream);
|
StreamErrorHandler (std::ostream& ErrorStream);
|
||||||
///< constructor
|
///< constructor
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef _ESM_READER_H
|
#ifndef _ESM_READER_H
|
||||||
#define _ESM_READER_H
|
#define _ESM_READER_H
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <libs/platform/stdint.h>
|
#include <libs/platform/stdint.h>
|
||||||
#include <libs/platform/string.h>
|
#include <libs/platform/string.h>
|
||||||
@ -451,11 +453,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 +474,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 +483,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 +493,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 +552,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 +563,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;
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
|
@ -33,7 +33,7 @@ enum PartReferenceType
|
|||||||
PRT_RPauldron = 23,
|
PRT_RPauldron = 23,
|
||||||
PRT_LPauldron = 24,
|
PRT_LPauldron = 24,
|
||||||
PRT_Weapon = 25,
|
PRT_Weapon = 25,
|
||||||
PRT_Tail = 26
|
PRT_Tail = 26
|
||||||
};
|
};
|
||||||
|
|
||||||
// Reference to body parts
|
// Reference to body parts
|
||||||
@ -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
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -27,16 +27,16 @@ struct InventoryList
|
|||||||
esm.getHT(ci, 36);
|
esm.getHT(ci, 36);
|
||||||
list.push_back(ci);
|
list.push_back(ci);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Container
|
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;
|
||||||
|
@ -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
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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];
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -29,8 +29,8 @@ struct Race
|
|||||||
|
|
||||||
enum Flags
|
enum Flags
|
||||||
{
|
{
|
||||||
Playable = 0x01,
|
Playable = 0x01,
|
||||||
Beast = 0x02
|
Beast = 0x02
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RADTstruct
|
struct RADTstruct
|
||||||
|
@ -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",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
};
|
};
|
||||||
|
@ -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)
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
|
|
||||||
using namespace boost::algorithm;
|
using namespace boost::algorithm;
|
||||||
|
|
||||||
namespace ESMS
|
namespace ESMS
|
||||||
{
|
{
|
||||||
using namespace ESM;
|
using namespace ESM;
|
||||||
@ -241,12 +241,12 @@ 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());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Cells aren't simply indexed by name. Exterior cells are treated
|
// Cells aren't simply indexed by name. Exterior cells are treated
|
||||||
// separately.
|
// separately.
|
||||||
// TODO: case handling (cell names are case-insensitive, but they are also showen to the
|
// TODO: case handling (cell names are case-insensitive, but they are also showen to the
|
||||||
|
@ -16,7 +16,7 @@ std::string macBundlePath()
|
|||||||
char path[1024];
|
char path[1024];
|
||||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||||
assert(mainBundle);
|
assert(mainBundle);
|
||||||
|
|
||||||
CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
|
CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
|
||||||
assert(mainBundleURL);
|
assert(mainBundleURL);
|
||||||
|
|
||||||
|
@ -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,199 +823,199 @@ 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++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (list.has(i))
|
if (list.has(i))
|
||||||
handleNode(&list[i], flags, node->trafo, bounds, bone);
|
handleNode(&list[i], flags, node->trafo, bounds, bone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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,52 +1086,52 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* More code currently not in use, from the old D source. This was
|
/* More code currently not in use, from the old D source. This was
|
||||||
used in the first attempt at loading NIF meshes, where each submesh
|
used in the first attempt at loading NIF meshes, where each submesh
|
||||||
@ -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
|
||||||
|
@ -67,17 +67,17 @@ 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");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ogre::Vector3 convertVector3(const Nif::Vector& vec);
|
Ogre::Vector3 convertVector3(const Nif::Vector& vec);
|
||||||
Ogre::Quaternion convertRotation(const Nif::Matrix& rot);
|
Ogre::Quaternion convertRotation(const Nif::Matrix& rot);
|
||||||
|
|
||||||
@ -123,15 +123,15 @@ 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
|
||||||
Ogre::Mesh *mesh;
|
Ogre::Mesh *mesh;
|
||||||
|
@ -1,256 +0,0 @@
|
|||||||
/* //This is old
|
|
||||||
if (pieces > 1){ //pieces > 1
|
|
||||||
MeshPtr justChest = MeshManager::getSingleton().createManual("justchest", group, NIFLoader::getSingletonPtr());
|
|
||||||
Ogre::AxisAlignedBox bounds = resize->getBounds();
|
|
||||||
Ogre::Vector3 width2 = bounds.getCorner(bounds.NEAR_RIGHT_BOTTOM) - bounds.getCorner(bounds.NEAR_LEFT_BOTTOM);
|
|
||||||
Ogre::Vector3 depth2 = (bounds.getCorner(bounds.FAR_LEFT_BOTTOM) - bounds.getCorner(bounds.NEAR_LEFT_BOTTOM));
|
|
||||||
Ogre::Vector3 height2 = bounds.getCorner(bounds.NEAR_LEFT_TOP) - bounds.getCorner(bounds.NEAR_LEFT_BOTTOM);
|
|
||||||
cout << "Width:" << width2; cout << "Height:" << height2; cout << "Depth:" << depth2;
|
|
||||||
/*int width = bounds.getMaximum().x - bounds.getMinimum().x;
|
|
||||||
int height = bounds.getMaximum().y - bounds.getMinimum().y;
|
|
||||||
int depth = bounds.getMaximum().z - bounds.getMinimum().z;
|
|
||||||
int xinc = width / pieces;
|
|
||||||
int yinc = height / pieces;
|
|
||||||
int zinc = depth / pieces;
|
|
||||||
int xmincorner = bounds.getMinimum().x + xinc*pieceIndex;
|
|
||||||
int ymincorner = bounds.getMinimum().y + yinc*pieceIndex;
|
|
||||||
int zmincorner = bounds.getMinimum().z + xinc*pieceIndex;*/
|
|
||||||
//Ogre::Vector3 bottom_left = bounds.getCorner(bounds.NEAR_LEFT_BOTTOM) + (width2 / pieces) * pieceIndex; //width2
|
|
||||||
//Ogre::Vector3 top_right = bottom_left + (width2 / pieces) + height2 + depth2;
|
|
||||||
//Ogre::AxisAlignedBox set = AxisAlignedBox ( Ogre::Vector3(xmincorner, bounds.getMinimum().y, bounds.getMinimum().z), Ogre::Vector3(xmincorner + xinc, bounds.getMaximum().y, bounds.getMaximum().z));
|
|
||||||
//Ogre::AxisAlignedBox set = bounds;//AxisAlignedBox(bottom_left, top_right);
|
|
||||||
//bounds.setMinimumX(xmincorner);
|
|
||||||
//bounds.setMaximumX(xmincorner + xinc);
|
|
||||||
//bounds.setMinimumY(ymincorner);
|
|
||||||
//bounds.setMaximumY(ymincorner + yinc);
|
|
||||||
//bounds.setMinimumZ(zmincorner);
|
|
||||||
//bounds.setMaximumZ(zmincorner + zinc);
|
|
||||||
//bounds.setMinimumY(bounds.getMinimum().y);
|
|
||||||
//bounds.setMaximumY( bounds.getMaximum().y;
|
|
||||||
//resize->_setBounds(set, true);
|
|
||||||
//resize->reload();
|
|
||||||
|
|
||||||
//Ogre::Mesh::SubMeshIterator subMeshIterator = resize->getSubMeshIterator();
|
|
||||||
/*Ogre::Vector3* point;
|
|
||||||
Ogre::SubMesh* subMesh;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
size_t vertex_count = 0;
|
|
||||||
Vector3* vertices;
|
|
||||||
size_t index_count = 0;
|
|
||||||
unsigned* indices;
|
|
||||||
Vector3 position = Vector3::ZERO;
|
|
||||||
Quaternion orient = Quaternion::IDENTITY;
|
|
||||||
Vector3 scale = Vector3::UNIT_SCALE;
|
|
||||||
|
|
||||||
|
|
||||||
// int vertex_count = 0;
|
|
||||||
//int index_count = 0;
|
|
||||||
|
|
||||||
bool added_shared = false;
|
|
||||||
size_t current_offset = vertex_count;
|
|
||||||
size_t shared_offset = vertex_count;
|
|
||||||
size_t next_offset = vertex_count;
|
|
||||||
size_t index_offset = index_count;
|
|
||||||
size_t prev_vert = vertex_count;
|
|
||||||
size_t prev_ind = index_count;
|
|
||||||
// Calculate how many vertices and indices we're going to need
|
|
||||||
/*
|
|
||||||
std::cout <<"FIRST CYCLE\n";
|
|
||||||
for(int i = 0;i < resize->getNumSubMeshes();i++)
|
|
||||||
{
|
|
||||||
std::cout<< "WEHAVEMESHES\n";
|
|
||||||
SubMesh* submesh = resize->getSubMesh(i);
|
|
||||||
|
|
||||||
// We only need to add the shared vertices once
|
|
||||||
if(submesh->useSharedVertices)
|
|
||||||
{
|
|
||||||
if(!added_shared)
|
|
||||||
{
|
|
||||||
VertexData* vertex_data = resize->sharedVertexData;
|
|
||||||
vertex_count += vertex_data->vertexCount;
|
|
||||||
added_shared = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
VertexData* vertex_data = submesh->vertexData;
|
|
||||||
vertex_count += vertex_data->vertexCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the indices
|
|
||||||
Ogre::IndexData* index_data = submesh->indexData;
|
|
||||||
index_count += index_data->indexCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
// Vector3* vertices;
|
|
||||||
// Allocate space for the vertices and indices
|
|
||||||
/*vertices = new Vector3[vertex_count];
|
|
||||||
indices = new unsigned[index_count];
|
|
||||||
|
|
||||||
int meshcounter = 0;
|
|
||||||
added_shared = false;
|
|
||||||
std::cout <<"SECOND CYCLE: " << resize->getNumSubMeshes() << "\n";
|
|
||||||
// Run through the submeshes again, adding the data into the arrays
|
|
||||||
int i;
|
|
||||||
for(i = 0;i < resize->getNumSubMeshes();i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
SubMesh* submesh = resize->getSubMesh(i);
|
|
||||||
|
|
||||||
Ogre::VertexData* vertex_data = submesh->useSharedVertices ? resize->sharedVertexData : submesh->vertexData;
|
|
||||||
/*
|
|
||||||
if((!submesh->useSharedVertices)||(submesh->useSharedVertices && !added_shared))
|
|
||||||
{
|
|
||||||
if(submesh->useSharedVertices)
|
|
||||||
{
|
|
||||||
added_shared = true;
|
|
||||||
shared_offset = current_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Ogre::VertexElement* posElem = vertex_data->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
|
|
||||||
Ogre::HardwareVertexBufferSharedPtr vbuf = vertex_data->vertexBufferBinding->getBuffer(posElem->getSource());
|
|
||||||
unsigned char* vertex = static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
|
|
||||||
Ogre::Real* pReal;
|
|
||||||
|
|
||||||
bool onepointexists = true;
|
|
||||||
Vector3 lastpoint;
|
|
||||||
for(size_t j = 0; j < vertex_data->vertexCount; ++j, vertex += vbuf->getVertexSize())
|
|
||||||
{
|
|
||||||
posElem->baseVertexPointerToElement(vertex, &pReal);
|
|
||||||
|
|
||||||
Vector3 pt;
|
|
||||||
pt.x = (*(pReal++));
|
|
||||||
pt.y = (*(pReal++));
|
|
||||||
pt.z = (*(pReal++));
|
|
||||||
//cout << "X:" << pt.x << "Y:" <<pt.y << "Z:" <<pt.z << "\n";
|
|
||||||
//cout << "Boxmin:" << set.getMinimum() <<" Boxmax:" <<set.getMaximum() <<"\n";
|
|
||||||
//if(set.intersects(pt))
|
|
||||||
//onepointexists = true;
|
|
||||||
if(!set.intersects(pt))
|
|
||||||
{
|
|
||||||
pt = lastpoint;
|
|
||||||
//*pReal = pt.x;
|
|
||||||
//*(pReal+1) = pt.y;
|
|
||||||
//*(pReal+2) = pt.z;
|
|
||||||
//vertex
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
lastpoint = pt;
|
|
||||||
|
|
||||||
|
|
||||||
pt = (orient * (pt * scale)) + position;
|
|
||||||
if(!set.intersects(pt))
|
|
||||||
onepointexists = false;
|
|
||||||
|
|
||||||
vertices[current_offset + j].x = pt.x;
|
|
||||||
vertices[current_offset + j].y = pt.y;
|
|
||||||
vertices[current_offset + j].z = pt.z;
|
|
||||||
|
|
||||||
}
|
|
||||||
/*if(true)
|
|
||||||
{
|
|
||||||
std::cout<< "Wearegoingtodelete"<< submesh->getMaterialName() << "\n";
|
|
||||||
|
|
||||||
if(meshcounter <= 2)
|
|
||||||
resize->destroySubMesh(i);
|
|
||||||
else if(meshcounter > 3 && meshcounter < 7)
|
|
||||||
resize->destroySubMesh(i);
|
|
||||||
//submesh->setMaterialName("BaseWhiteNoLighting"); //red
|
|
||||||
//submesh->updateMaterialUsingTextureAliases();
|
|
||||||
//resize->
|
|
||||||
meshcounter++;
|
|
||||||
//delete submesh;
|
|
||||||
//reakb;
|
|
||||||
}*/
|
|
||||||
/*
|
|
||||||
vbuf->unlock();
|
|
||||||
next_offset += vertex_data->vertexCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ogre::IndexData* index_data = submesh->indexData;
|
|
||||||
|
|
||||||
size_t numTris = index_data->indexCount / 3;
|
|
||||||
unsigned short* pShort;
|
|
||||||
unsigned int* pInt;
|
|
||||||
Ogre::HardwareIndexBufferSharedPtr ibuf = index_data->indexBuffer;
|
|
||||||
bool use32bitindexes = (ibuf->getType() == Ogre::HardwareIndexBuffer::IT_32BIT);
|
|
||||||
if (use32bitindexes) pInt = static_cast<unsigned int*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
|
|
||||||
else pShort = static_cast<unsigned short*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
|
|
||||||
|
|
||||||
for(size_t k = 0; k < numTris; ++k)
|
|
||||||
{
|
|
||||||
size_t offset = (submesh->useSharedVertices)?shared_offset:current_offset;
|
|
||||||
|
|
||||||
unsigned int vindex = use32bitindexes? *pInt++ : *pShort++;
|
|
||||||
indices[index_offset + 0] = vindex + offset;
|
|
||||||
vindex = use32bitindexes? *pInt++ : *pShort++;
|
|
||||||
indices[index_offset + 1] = vindex + offset;
|
|
||||||
vindex = use32bitindexes? *pInt++ : *pShort++;
|
|
||||||
indices[index_offset + 2] = vindex + offset;
|
|
||||||
|
|
||||||
index_offset += 3;
|
|
||||||
}
|
|
||||||
ibuf->unlock();
|
|
||||||
current_offset = next_offset;*/
|
|
||||||
//if (i == 3) //i!=3 i!=5
|
|
||||||
//{
|
|
||||||
//cout << "RETURNINGJUST\n";
|
|
||||||
//SubMesh* test =
|
|
||||||
//test = resize->getSubMesh(i);
|
|
||||||
// cout << "s:" << shape << "\n";
|
|
||||||
//NiTriShapeData *data = shape->data.getPtr();
|
|
||||||
// SubMesh *sub = justChest->createSubMesh(name + "2");
|
|
||||||
//sub = resize->getSubMesh(i);
|
|
||||||
|
|
||||||
// int nextBuf = 0;
|
|
||||||
|
|
||||||
// This function is just one long stream of Ogre-barf, but it works
|
|
||||||
// great.
|
|
||||||
|
|
||||||
// Add vertices
|
|
||||||
//int numVerts = data->vertices.length / 3;
|
|
||||||
//sub->vertexData = new VertexData();
|
|
||||||
//sub->vertexData->vertexCount = numVerts;
|
|
||||||
|
|
||||||
//justChest->load();
|
|
||||||
//return resize;
|
|
||||||
//}
|
|
||||||
// 0 hand thumb
|
|
||||||
// 1 hand thumb no chest on dunmer
|
|
||||||
//}
|
|
||||||
//resize->destroySubMesh(1);
|
|
||||||
/* while (subMeshIterator.hasMoreElements())
|
|
||||||
{
|
|
||||||
resize->getNum
|
|
||||||
//resize->d
|
|
||||||
std::cout << "CHEST";
|
|
||||||
subMesh = subMeshIterator.getNext();*/
|
|
||||||
//std::vector<Vector3>::type test =
|
|
||||||
//std::vector<Ogre::Vector3>::iterator fileIter = subMesh->extremityPoints.begin();
|
|
||||||
|
|
||||||
//std::vector<Ogre::Vector3>::type test = subMesh->extremityPoints;
|
|
||||||
//void* pData = subMesh->vertexData->vertexBufferBinding->getBuffer(1)->lock(0, 1000, HardwareBuffer::HBL_DISCARD);
|
|
||||||
|
|
||||||
|
|
||||||
// if(set.contains( subMesh->vertexData->vertexStart))
|
|
||||||
//delete subMesh;
|
|
||||||
//subMeshIterator.getNext();
|
|
||||||
//delete[] subMesh;
|
|
||||||
//subMesh->extremityPoints.clear();
|
|
||||||
//subMesh->mLodFaceList.clear();
|
|
||||||
//resize->destroySubMesh(subMesh->indexData->indexStart);
|
|
||||||
//resize->destroySubMesh(subMesh->indexData->);
|
|
||||||
//subMesh->
|
|
||||||
//std::cout << "THIS" << subMesh;
|
|
||||||
///}
|
|
||||||
//subMesh->vertexData->vertexBufferBinding->getBuffer(0)->readData(subMesh->vertexData->vertexStart, sizeof Ogre::Vector3, point);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//boost::filesystem::directory_iterator dir_iter(dir), dir_end;
|
|
||||||
|
|
||||||
//return resize;
|
|
@ -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
|
||||||
|
@ -26,3 +26,7 @@ if (MYGUI_USE_FREETYPE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS} uuid)
|
target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS} uuid)
|
||||||
|
|
||||||
|
if (MINGW)
|
||||||
|
target_link_libraries(${PROJECT_NAME} libwinmm.a)
|
||||||
|
endif (MINGW)
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 7345f2307f3ce6682a4044b98a811fac2cb7c4f0
|
Subproject commit 12e5c8d704b959c78a62931b2360d18092b82c3d
|
@ -1,9 +1,9 @@
|
|||||||
// Wrapper for string.h on Mac
|
// Wrapper for string.h on Mac and MinGW
|
||||||
#ifndef _STRING_WRAPPER_H
|
#ifndef _STRING_WRAPPER_H
|
||||||
#define _STRING_WRAPPER_H
|
#define _STRING_WRAPPER_H
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) || defined(__MINGW32__)
|
||||||
// need our own implementation of strnlen
|
// need our own implementation of strnlen
|
||||||
static size_t strnlen(const char *s, size_t n)
|
static size_t strnlen(const char *s, size_t n)
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
// Wrapper for MSVC
|
// Wrapper for MSVC/GCC
|
||||||
#ifndef _STRINGS_WRAPPER_H
|
#ifndef _STRINGS_WRAPPER_H
|
||||||
#define _STRINGS_WRAPPER_H
|
#define _STRINGS_WRAPPER_H
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#pragma warning(disable: 4996)
|
|
||||||
#define strcasecmp stricmp
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#else
|
|
||||||
#include <strings.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
// For GCC, just use strings.h (this applies to mingw too)
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
# include <strings.h>
|
||||||
|
#elif defined(MSVC)
|
||||||
|
# pragma warning(disable: 4996)
|
||||||
|
# define strcasecmp stricmp
|
||||||
|
# define snprintf _snprintf
|
||||||
|
#else
|
||||||
|
# warning "Unable to determine your compiler, you should probably take a look here."
|
||||||
|
# include <strings.h> // Just take a guess
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _STRINGS_WRAPPER_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user